Strainu onLine
Blogul unui automatist
23rd
FEB
Network Programming Homeworks
Posted by Strainu | Filed under C, Java, Software
Network Programming Homeworks from the Automatics and Computer Science Faculty, UPB, 5th year, prof. Valentin Cristea. The archive contains a homework made in Java. Themes: RPC (Remote Procedure Call), Sorting trees using MPI, Secure chat server in JAVA, Bidding system using CORBA.
(more…)
23rd
Parallel Algorithms Homeworks
Posted by Strainu | Filed under C, Java, Software
Parallel Algorithms Homeworks from the Automatics and Computer Science Faculty, UPB, 5th year, prof. Valentin Cristea. The archive contains a homework made in Java. Themes: Parallel Game of Life with OpenMP, Sudoku with Replicated Workers, image manipulation (filters, Huffman coding), routing tables.
(more…)
22nd
DEC
QuickTemplate
Posted by Strainu | Filed under JavaScript, Software, Wikipedia

QuickTemplate is a JavaScript script that can be used by Wikipedia users to add several new links under the edit window, so you can quickly add useful templates. The script allows the user to configure different parameters. You can show the following templates:
- image copyrights;
- maintenance templates;
- delete templates;
- disputes;
- messages.
Tags: JavaScript, Software, Wikipedia
16th
NOV
Pagerename
Posted by Strainu | Filed under My Projects, Python
Pagerename.py is a small Python script that integrates in the pywikipedia framework. For those of you who don’t know, it’s the main tool used by robots on Wikipedia. I wrote the script a good while ago, when I needed to quickly rename several hundred pages on the Romanian Wikipedia. The script was designed to make the same modification on all the titles from a series of pages. You can remove parts of the title or add a new text at the beginning and/or and of the title.
In the mean time the guys at pywikipedia wrote movepages.py, a somewhat similar script. Nevertheless, in September I decided to propose my script for inclusion in pywikipedia. Unfortunately, it didn’t make it, however it was included in the project’s encyclopedia, at http://botwiki.sno.cc/wiki/Python:Pagerename.py. I’d love to hear your opinion about the script. Please leave any comments you might have below.
11th
NOV
Using Serialization with non-blocking sockets
Posted by Strainu | Filed under Java
The most common way to make a server in Java is to create a thread pool and associate each request with a thread. Java5 offers a special class called Executor that can help you with the task. However, if you ever needed to make a server which can handle thousands of connections, you know this solution doesn’t scale very well. Most processors can’t handle more than a few hundreds of threads.
The solution is to use non-blocking sockets, a feature introduced in java 1.4 (the java.nio package). However, this has an important drawback: you can’t use the getInputStream(), getOutputStream() functions from the Socket class to serialize objects. The reason is simple: with non-blocking sockets, there is no way the system can guarantee that the whole object has been sent/received.
You can however “trick” the virtual machine by using explicit Streams. You have a simple example below. We try to send an object with the Message type.
- The sending end
Message outgoingMessage;
SocketChannel socketChannel;
//we open the channel and connect
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
objectOutputStream.writeObject(outgoingMessage);
objectOutputStream.flush();
socketChannel.write(ByteBuffer.wrap(byteArrayOutputStream.toByteArray())); - The receiving end
SocketChannel socketChannel;
ByteBuffer data;
//we open the channel and connect
socketChannel.read(data);
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(data.array());
ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream);
Message message = (Message)objectInputStream.readObject();
The code works if you receive the whole object or more than one object (the readObject() function reads exactly one object). However, I had some issues with reconstructing the object if it arrived in multiple pieces. Any suggestions on that part would be useful.
Here are some resources that I found useful: a discussion at forum.java.sun.com and another discution about the subject.
6th
NOV
Automatic MySQL Backups
Posted by Strainu | Filed under SQL
Ever had a database crush before you made any backups? Then you now how important it is to have regular backups. But why bother doing them yourself, when you can have a script to do it for you?
automysqlbackup.sh is a simple script that automates your backups. It keeps daily backups for the last week, weekly backups for the last month and monthly backups for older versions of the database. The files are gzipped text files, so you can easily check them manually.
The script has many options, including the possibility to send emails with the new backup files and to use a single file for multiple databases.
24th
AUG
Operating Systems design homeworks
Posted by Strainu | Filed under C, Software
Operating Systems design homeworks from the Automatics and Computer Science Faculty, UPB, 4th year, prof. Octavian Purdilă. Themes: system calls, UART driver, file system driver, firewall, RAID software.
(more…)
Tags: C/C++, kernel, Operating Systems, Software
31st
JUL
css float formating with javascript versus IE
Posted by dragos | Filed under HTML
If you ever, by any chance try to format some HTML elements with javascript, and that formating would refer to float propertries, please be aware. Let me give you the most simple example I’ve met:
document.getElementById('a2').style.width='100px';
document.getElementById('a3').style.width='100px';
document.getElementById('a1').style.backgroundColor = '#FF0000';
document.getElementById('a2').style.backgroundColor = '#FF0000';
document.getElementById('a3').style.backgroundColor = '#FF0000';
document.getElementById('a1').style.cssFloat= 'left';
document.getElementById('a2').style.cssFloat= 'left';
document.getElementById('a3').style.cssFloat= 'left';
All the browsers will interpret it well, EXCEPT IE. On IE, the previous formating of the divs remains. The solution took me about 2 hours, and it looks like this. Do not ask me if changing the floating now would work, ’cause I don’t know. I’m just to afraid even to think at such thing.
document.getElementById('a2').style.width='100px';
document.getElementById('a3').style.width='100px';
document.getElementById('a1').style.backgroundColor = '#FF0000';
document.getElementById('a2').style.backgroundColor = '#FF0000';
document.getElementById('a3').style.backgroundColor = '#FF0000';
30th
JUN
Parallel Computing homeworks
Posted by Strainu | Filed under C, Software
Parallel Computing homeworks from the Automatics and Computer Science Faculty, 4th year, prof. Nicolae TapuÅŸ. Subjects:
- MPI,
- OpenMPI,
- pthreads,
- parallel Sudoku solver and generator.
29th
JUN
Database design project
Posted by Strainu | Filed under SQL, Software
Database design project 4th year, Computer Science Faculty, Bucharest, prof. Mircea Petrescu. (more…)
Recent Posts:
- 28 Oct Some people just won̵...
- 18 Aug Wiki Loves Monuments RomÃ...
- 15 May Want to work on Pidgin or...
- 14 Apr Free WiFi in the metro!
- 04 Apr Libertatea dincolo de sof...
- 11 Feb Electrocasnice online: Do...
- 15 Oct Wikipedia română –...
- 14 Oct Veliko Tarnovo Sound ...
- 11 Oct Romanian Postal Codes in ...
- 11 Jul Wikimania 2010 – zi...






