Search This Blog

Thursday, February 24, 2011

Deploying web page in python using PYLONS.

This approach is simple and painless. (It differs from the one on pylonsbooks much)  It doesn’t use python environment (pyt-env) embedded in userspace etc. ROOT access is required to install pylons in this manner.
Ubuntu version: 10.10 Server
  1. Install apache server

    aptitude install apache2

  2. Check if it works:  should give you: “It works!”
  3. Install  Python WSGI adapter module for Apache

    aptitude install libapache2-mod-wsgi

  4. Disable the default apache site:

    a2dissite 000-default

    (or any other site in: /etc/apache2/sites-enabled)
  5. Install easy_install for python
    apt-get install python-setuptools python-dev build-essential

  6. Set the proxy if necessary:

    export HTTP_PROXY=http://user:pass@

  7. easy_install paste
  8. aptitude install python-pastedeploy
  9. easy_install SQLAlchemy
  10. easy_install Pylons
  11. add www-data user to your user group

    usermod -a -G simplesite www-data

  12. set debug = false in your development.ini

    debug = false

  13. move you application to: /usr/lib/pymodules/python2.6

<VirtualHost *>
    ServerName etiopia
    ServerAlias etiopia

    # Logfiles
    ErrorLog  /var/log/apache2/error.log
    CustomLog /var/log/apache2/access.log combined

    # Setup mod_wsgi
    WSGIScriptAlias / /home/ubuntu/OBIAD/dispatch.wsgi

    <Directory /home/ubuntu/OBIAD>
    Order deny,allow
    Allow from all


  • a2ensite OBIAD

OBIAD is the site name. It can be any name instead of OBIAD.

#Load the Pylons application
from paste.deploy import loadapp
application = loadapp('config:/home/ubuntu/OBIAD/development.ini')

Place your application in the following directory, so that python can find it: /usr/lib/pymodules/python2.6
Restart apache with:

/etc/init.d/apache2 restart

Look for any errors in: /var/log/apache2/error.log
While starting apache I had the following error. Despite this everything worked fine (There was a bug and we can ignore this error):

[error] Exception KeyError: KeyError(140024401471296,) in <module 'threading' from '/usr/lib/python2.6/threading.pyc'> ignored
[error] Exception KeyError: KeyError(140024401471296,) in <module 'threading' from '/usr/lib/python2.6/threading.pyc'> ignored
[notice] caught SIGTERM, shutting down
[warn] mod_wsgi: Compiled for Python/2.6.5.
[warn] mod_wsgi: Runtime using Python/2.6.6.
[notice] Apache/2.2.16 (Ubuntu) mod_wsgi/3.2 Python/2.6.6 configured -- resuming normal operations

Errors you may encounter:
ImportError: No module named paste.deploy –> install paste with “easy_install paste”
ImportError: No module named deploy –> aptitude install python-pastedeploy
OSError: File '/home/ubuntu/OBIAD/development.ini' not found –> copy your *.ini from you application to the destination directory
DistributionNotFound: dinner –> you haven’t copied your application to destination directory (/usr/lib/pymodules/python2.6/)
DistributionNotFound: SQLAlchemy>=0.5 –>  easy_install SQLAlchemy

Proxy causing errors. If you see any of the messages:

[error] [client] IOError: failed to write data
[error] [client] mod_wsgi (pid=7892): Exception occurred processing WSGI script '/home/ubuntu/OBIAD/dispatch.wsgi'.

it’s probably your proxy causing problems. Mod_wsgi does not do well with proxies unfortunately.

Wednesday, February 23, 2011

Keep track of failed ssh login attempts

Your sshd configuration is probably kept in:

change the line with LogLevel to:
LogLevel DEBUG

You can track login attempts in:

Simple Webpages in Python. Using mod_python with Apache


Writing web pages in python without any environment isn’t painless. Despite inconveniences you have access to Session, Cookies  and Transactions fields.

You can distinguish between incoming addresses thanks to:
request.uri   field.

Simple page using just one function:

from mod_python import apache

def handler ( request ):
    request.content_type = 'text/html'
    request.write ( "<html>" )
    request.write ( "<head>" )
    request.write ( "<title>Text Document</title>" )
    request.write ( "</head>" )
    request.write ( "<body bgcolor='#D2D2D2'>" )
    request.write ( "<table align='center' bgcolor='#000000' cellspacing='1px' cellpadding='5px' width='60%'>" )
    request.write ( "<tr><td bgcolor='#FFFFFF' align='center'>" )
    request.write ( "SIMPLE WEB PAGE IN MOD_PYTHON" )
    request.write ( "Res: " + str(increment(1)))
    request.write ( "</td></tr>" )
    request.write ( "</table>" )
    request.write ( "</body>" )
    request.write ( "</html>" )
    return apache.OK
def increment(x):
    return x+1


There’s a good manual concerning mod_python here:

Monday, February 21, 2011

Virtual Box – auto screen resize isn’t working

After installing VBox Tools your Ubuntu screen should be resizing automatically as you resize window size. Unfortunately despite enabling option: Machine->Auto resize guest display, the display stays as it is.

bug work-around:
- resize the window size as you wish, then go to guest system and try: System->Preferences->Monitors (under gnome). There should be a resolution that fits your CURRENT window size (the biggest one)

The size is also set correctly after system restart.

There is no patch for this bug yet (VBox: 4.0.4, Ubuntu: 10.10 Server)

Linux – beginner’s guide

This is basic linux command line reference guide. I collected these when I was learning linux long time ago.

configure network:
file: /etc/network/interfaces

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static

configure DNS entries:

restart telnet service:
/etc/init.d/inetd restart

restart networking:
/etc/init.d/networking restart

configure proxy:
Acquire::http::Proxy "http://user_name:password@";

add default gateway:
route add default gw

configure samba:

restart samba service:
service smbd restart

restart xen deamon:
/etc/init.d/xend restart

xen config:

add users to sudoers:
www-data ALL=(ALL) ALL

default www directory

configure wget to use proxy:
#use_proxy = on

Configure apt-get sources:

to use samba you need to install:
aptitude install samba smbfs smbclient
mount -o username=backup,password=backup // /mnt/BACKUP/
tar cvzf alldoc.tar.gz *.doc
tar cvzf alldoc.tar.gz ./docs/
tar xzvf foo.tar

what should mount at boot:
// /mnt/mechlak cifs username=backup,password=backup
/etc/init.d/inetd restart

setting samba users:
smbpasswd -a root
   new passwd: xxxxxx

run-time variable data:

file: /etc/sudoers
root ALL=(ALL) ALL
list devices (PCI):

configure grub:
nano /boot/grub/menu.lst
update grub from menu.lst (grub 1 style)
grub-install /dev/sda
update-grub <- grub 2 style

prevent X11 from starting at boot:
update-rc.d -f gdm remove

mount NTFS share on samba:
smbmount // /mnt/point
smbmount // -o username=xxxx,password=xxxx /mnt/point
mount -t smbfs –o username=xxxx,password=xxxx // /mnt/point

Remove kernel module on Linux – failed

When I was reinstalling Virtual Box I stumbled on an error with unloading module vboxnetflt.

I tried several methods to remove that module manually:

root@server:~# /etc/init.d/vboxdrv setup
* Stopping VirtualBox kernel modules
* Cannot unload module vboxnetflt
root@server:~# modprobe -r vboxnetflt
FATAL: Module vboxnetflt not found.
root@server:~# rmmod vboxnetflt
ERROR: Module vboxnetflt is in use

I had no success even with force:
root@server:~# rmmod --force vboxnetflt
ERROR: Removing 'vboxnetflt': Resource temporarily unavailable

I turned out we had a lost vbox process VBoxHeadless hanging. After killing it everything went fine. So if rmmod --force did not work for you – look for potential processes keeping handles to the module.

Friday, February 18, 2011

Apache – enable python script support/python module. mod_python


The installation procedure on Windows is like this:

  1. Install Apache server from httpd-2.2.17-win32-x86-openssl-0.9.8o.msi
  2. Install python 2.5 from python-2.5.2.msi
  3. Install mod_python-3.3.1.win32-py2.5-Apache2.2.exe showing it apache main directory (in my case it was: c:\Program Files\Apache Software Foundation\Apache2.2\modules\)
  4. If step 3 won’t work for you, do this step as well. Copy mod_python.dll and to: $apache$/modules/
    (in my case it was: c:\Program Files\Apache Software Foundation\Apache2.2\modules\)
  5. Copy all the files from mod_python-3.3.1.tar\mod_python-3.3.1\lib\python\mod_python\*.* to c:\Python25\Lib\mod_python\
    (there are 12 *.py files in there)
  6. Change httpd.conf

add this line in # Dynamic Shared Object (DSO) Support section:
LoadModule python_module modules/

add this piece of code in two sections (#ScriptAlias: and in IfModule cgid_module section:

    <Directory "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/python">
       AddHandler mod_python .py
       PythonHandler test
       PythonDebug on

example httpd.conf can be found in my package.

   7.  Create a file for testing: C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/python/

test name is important as we defined the name earlier in “PythonHandler” section!!!!

package with all the files needed:

Flash Builder, Flex, PHP + MySQL login/authentication page

This example is based on corlan’s post. I simplified it and added connection to MySQL and password encryption in MD5.

Basically this examples shows how easily we can implement logging in Flash Builder / flex. GUI is displayed in flash and it connects to PHP server that stores passwords in MySQL database. Passwords are encrypted using MD5.




Below you can find Flash Builder project, scripts in PHP to put in your Apache WWW directory in location: localhost/user_auth. The third file is MySQL database export.

You can easily encrypt your passwords in MD5 thanks to this site:

More info on Flex HttpService can be found here:

Thursday, February 17, 2011

Determine Windows ComputerName only by IP address

To determine Windows ComputerName (DomainName) on linux when you only have IP address
you can call:
smbclient -L  ip_address
nmblookup ip_address

To get MAC address of the client's network card:
Linux (you need root privileges for that):
ping ip_address
arp | grep ip_address

ping ip_address
arp -a

To determine you own IP address on Windows:
(it's a new command introduced in Vista)

Wednesday, February 16, 2011

Nokia & Windows Phone 7–Really?!

The news of Nokia adapting WP7 was here and there for quite a long time. But still – it’s a shock they really did it. They could’ve chosen Android and boost their sales. What kind of a manager does such a mistake??!!

WP7 is in BETA phase in my view:

  • No threading for apps
  • No copy&pase?!
  • No handy apps like Winamp, Skype etc (because of no threading support)
  • hardly any functions – no WiFi/Bluetooth Internet tethering !!!

Well – MAYBE they’ll write something useful soon in 1-2 years… but Android has it all like yesterday…

And these huuuge blocks in the main menu. REALLY?!

Sales speak for themselves …


Tuesday, February 15, 2011

Memory – simple game in C#

Simple C#/WPF memory game with numbers instead of pictures.





Source code:

Executable only (win32):

Delete all ".svn" folders from a directory

If you're working with SVN repositories and you suddenly want to send a project to a friend from "the outside of SVN" by email you don't want to share all your ".svn" data. Normally you'd struggle with deleting every ".svn" directory in all subdirectories - this can be really frustrating. 

There's however a neat solution to the problem:


You can "upgrade" your windows with "delete all '.svn'" with a single click by importing this reg file.


I don't like reg files too - you don't know what they do. But don't worry. All there's inside is this:

Windows Registry Editor Version 5.00[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN]
@="Delete SVN Folders"
@="cmd.exe /c \"TITLE Removing SVN Folders in %1 && COLOR 9A && FOR /r \"%1\" %%f IN (.svn) DO RD /s /q \"%%f\" \""

Which basically means:
- create "Delete SVN Folders" position in the right-click menu
- delete ".svn" files in the directory you right-clicked

Monday, February 14, 2011

RUU for google Android phones

If you have a rooted google Android phone you can download original Froyo images from here:

- Blade
- Desire
- DesireHD
- Hero
- Tatoo
- Wildfire

For Wildfire the newest Froyo RUU is from 09 Jan 2011:

There's a large repository of Shipped (RUU) roms at:

VirtualBox 4.0 invalid command 'registerimage'

When moving from VirtualBox 3.x to VirtualBox 4.0 you might experience the following error:

VirtualBox 4.0 invalid command 'registerimage'

It's due to the change of some of the VBoxManage commands.
The old way to register hdd image was:

VBoxManage registerimage disk C:\FORCOMVM\FORCOMVM.vdi

You can do this in the following way now:
VBoxManage storageattach FORCOMVM --storagectl "SATA Controller" --device 0 --port 0 --type hdd --medium C:\FORCOMVM\FORCOMVM.vdi

You need to have a VM called FORCOMVM and an EMPTY controller "SATA Controller".
If you have controller  IDE type: "IDE Controller". If you want to attach a drive to a non-empty controller use a different port number.

Working with DataGrid in Flex (Flash Builder) Updating Data from DataGrid to database

We want to create a simple DataGrid that reads and writes back data
to MySQL table. The update process can be done ad-hoc (as soon as the user finishes updating cell)
or by clicking a button after editing all values.

DataGrid and button definishions in MXML:

<mx:DataGrid x="534" y="35" id="dataGrid" creationComplete="dataGrid_creationCompleteHandler(event)" dataProvider="{getAllItemsResult.lastResult}" editable="true" enabled="true" dataChange="dataGrid_dataChangeHandler(event)" itemEditEnd="dataGrid_itemEditEndHandler(event)" click="dataGrid_clickHandler(event)">
<mx:DataGridColumn headerText="CONT" dataField="CONT"/>
<mx:DataGridColumn headerText="ID" dataField="ID"/>
<s:Button x="744" y="35" label="Save" click="button2_clickHandler(event)"/>

Events are fired as follows:

dataGrid_itemEditEndHandler - for every row in dataGrid! when we "edit" dataGrid on a web page
dataGrid_dataChangeHandler(event) - fires up when "source" data changes
   (IT WILL NOT fire when you finish "editing" dataGrid and want to upload data do database server)

You can find cell editing help here:

Event methods:

protected function button2_clickHandler(event:MouseEvent):void
//dataGrid is the id (name) of our dataGrid table
var dataProvider = dataGrid.dataProvider;
var item = null;
for (var i:int = 0; i < dataProvider.length; i++)
item = dataProvider.getItemAt(i);
//updateItem is the method of SamplePHP in our services connecting to MySQL database


protected function dataGrid_itemEditEndHandler(event:DataGridEvent):void
// Get the cell editor and cast it to TextInput.
var myEditor:TextInput = TextInput(event.currentTarget.itemEditorInstance);
// Get the new value from the editor.
var newVal:String = myEditor.text;
// Get the old value.
var oldVal:String =[event.dataField]; 

//dataGrid is the id (name) of our dataGrid table
var dataProvider = dataGrid.dataProvider;
var item = null;
//this allows us to fire the update only once. dataGrid_itemEditEndHandler is fired for EVERY row :)
if (oldVal !== newVal)
var item = dataProvider.getItemAt(event.rowIndex);
//CONT is the name of the row's column we want to update
dataGrid.selectedItem.CONT = newVal;
//updateItem is the method of SamplePHP in our services connecting to MySQL database
//"Item Edited");

Source files:

To generate  a sample PHP connecting class go to Data/Services tab (on the bottom) and click "add new service".

You need Zend Framework to connect to PHP. FlashBuilder will install it for you in $WEB_ROOT$/ZendFramework.

database user: root; pass: sys;

Flash Builder DataGrid events are not working on google chrome

As for now (Feb 2011) DataGrid events from Flash aren't working as you'd expect on
Google chrome. If you're experiencing problems with FB debug under Firefox :/
I haven't been able to enable debugging at all under chrome with their standard
Flash plugin. If you still want to use Chrome follow these steps:

Google & Adobe are working together on prividing better flash support:

Friday, February 11, 2011

Wirtualne Laboratorium / Virtual Laboratory - test engineer portal

Some time ago I've written a portal in pure PHP for controlling test laboratory of C# applications. The whole testing process is based on a framework of our own production. TestSuites are run from Windows Scheduler that fires up AutoIt processes. AutoIt scripts clone a Virtual Machine. Later TestComplete 8.1 scripts are run on this VM. All actions are stored in Firebird Database engine.

The environment maintains a couple of Semaphores that are used for starting Virtual Machines. Clones are set up to start with a specific IP address that is later changed according to a dynamic list. Remote commands are sent to Windows guests via STAF (Software Testing Automation Framework). Semaphores prevent Virtual Machine clones to start at once and mix up their IP addresses and Host names.

The Virtual Laboratory portal includes:

- viewing running tests

- viewing today's tests

- viewing current week's tests

- viewing tests that ended with an error

- viewing tests from a specific time period

- viewing global testing log from today

- viewing global testing log from this week

- viewing the list of semaphores and their status

- viewing Virtual Laboratory statistics (run tests and their results, percantage of success etc)

  (all tests are divided into Test Suites that are divided into TestCases)

- viewing TestCase's/TestSuite's notes

- "count statistics" - fires up firebird's recalculation of indexes on "statistic's tables"

- help








Configure Flash Builder 4 to work with WAMP / PHP configuration

Quick start on Flex and Adobe Flash Builder technologies.

1.Download and install WAMP server:

or from:

After installing WAMP install XDebug for PHP. In order to do this download the XDebug DLL file and place it in a location accessible by the PHP installation. A good location is usually the ext directory of the PHP setup; for example: C:/wamp/bin/php/php5.2.8/ext.

Next, locate the php.ini file being used by your PHP installation. In WAMP, the php.ini configured for use with the server is located in the bin folder of the installed apache folder, for example:

Add the following part at the end of php.ini:

You can check wheter everything XDebug was correctly installed goin to the address:


There should be a section concerning XDebug.

2. Start Flash builder now. Create a new project. Select this project and clik Properties. Navigate to Flex Server section and select PHP Application server type. Sample configuration below:



Android vs. iPhone vs. Blackberry

Really funny :)


Thursday, February 10, 2011

Synergy+ - version compatible with Windows 7

I was trying to install the new synergy but it's not compatible with the newest version of Windows. You can also try "InputDirector" if you'd like to take the alternative.

There's also a version with a slightly different GUI that work on Win7 - Synergy+ (not developed any more).
Working version can be download here:

Synergy is a simple program allowing you to share one mouse/keyboard on many computers
(one mouse/keyboard for many computers with separate screens)

Note: there's a problem with mouse scroll (wheel) on some hardware. Nothing can be done with it - in case of InputDirector & Synergy+. Try attaching a different mouse if you experience such a bug.

Force Ubuntu not to use swap

My server had 24GB of RAM and only 20GB were used. Despite this Ubuntu was using 1GB of swap. 
You can force Linux not use swap by setting a parameter called swappiness.
Set swappiness by adding "vm.swappiness=x" (between 0 and 100) to /etc/sysctl.conf. If set to 0, swap is turned off.

More info:

Wednesday, February 9, 2011

List all files used by a process

To list files used by a process simply type:
ls -l /proc/3456/fd
where 3456 is PID of a process.

To get the PID you can use:
ps -C VBoxHeadless -o pid= 
where VBoxHeadless is you process name.

A script listing processes' opened files. Pass a list of processes in the form of a list to it:

  line="$@" # get all args
  #  just echo them, but you may need to customize it according to your need
  # for example, F1 will store first field of $line, see readline2 script
  # for more examples
  # F1=$(echo $line | awk '{ print $1 }')
  ls -l /proc/$line/fd
  echo $line

### Main script stars here ###
# Store file name

# Make sure we get file name as command line argument
# Else read it from standard input device
if [ "$1" == "" ]; then
   # make sure file exist and readable
   if [ ! -f $FILE ]; then
   echo "$FILE : does not exists"
   exit 1
   elif [ ! -r $FILE ]; then
   echo "$FILE: can not read"
   exit 2
# read $FILE using the file descriptors

# Set loop separator to end of line
IFS=$(echo -en "\n\b")
exec 3<&0
exec 0<"$FILE"
while read -r line
# use $line variable to process line in processLine() function
processLine $line
exec 0<&3

# restore $IFS which was used to determine what the field separators are
exit 0 

Browsing the web securely&privately

Some time ago I’ve learned that there exist pretty good google alternatives who take their responses and enable you to query the web without tracing all the moves you make. The widely defined “internet privacy” as irrelevant as it may sound is really important. And google’s attempts to record almost everything you do might become irritating at some point. If feel so, try:


LightCatcher–Framstick creatures example

LightCatcher - Framstick genotype + neuron

author: Bartosz Kosarzycki


The main idea behind this project was to create a framstick that could follow a flying torch in a 3-d area. The example creature however isn't able to discern three dimensions as it is limited to 2-d.
The implementation was divided into two steps:
  • designing the body structure
  • implementing neuron "brain"

Designing the body structure

The simplest body structure allowing us to follow a light in (x,y) is a simple cross with Catchlight neuron in the middle. There has to be a SeeLight neuron on each end of the four sides.
Such a genotype is presented below:
There are neural connections from SeeLights to Catchlight neuron which acts as a command center. Every SeeLight neuron is placed exactly 2 measument units from the center. LightCatcher body was written in //f0 language of framsticks.
Body structure on 2-d plane is presented below:
This architecture has a serious flaw: when we want to move the creature across (e.g. up & left) we cannot do this as the framstick's function applyForce() applied two times in one go() function does not work as we would expect. The effect is that when we chase a light that moves in a straight line and it suddenly turns to a side we need some time to adjust our path (we will start turning left when the value from left neuron is greater than the value of top neuron.)

The Catchlight neuron

Catchlight neuron is the command center of the whole creature. This type of neuron has to be connected to 4 other Seelight neurons. If that's not the case the command center will cease to work and print an exception: "Wrong number of inputs in 'CatchLight' neuron.".
The Catchlight neuron code can be downloaded in the download section below.
We get values of all four SeeLight neurons like this:
var leftVal = Neuro.getInputState(0);
Then we get maximum values from horizontal and vertical neurons:
var halfMaxVert = Math.max(topVal, bottomVal);
var halfMaxHor = Math.max(leftVal, rightVal);
Later we decide whether to go in vertical or horizontal direction. We cannot move in both as the limitation of applyForce() forbids us that. In the end we calculate Force values to apply (in x and y axis) with the use of calcDirections() function. ThedecideToPush() decides whether to push the creature. If the function weren't there we would push the creature indifinately towards the light even if it was going in the right direction. This would cause it to gain more and more speed. Every creature in Framsticks has mass so it would be hard to change the creature's direction with that much speed gained.
If we have calculated force x,y value and decided whether to push the creature or not we can apply the force at last. This can be done like this:
middlePart.applyForce(dir[0]*vbv[0], dir[1]*vbv[1], 0);
The force is applied to the middlePart (that is where the Catchlight neuron is placed). We would expect the creature to bend and leave its SeeLight neurons behind. Fortunately there is a mode we can set in Framsticks called "ODE" which makes creatures stiff and enables the whole structure to work as we need it to.

The Flashlight neuron

The Flashlight neuron is used to create 'a moving torch'. It's a very simple creature that moves randomly in 2-d. It should 'run away' and be hard to catch but cannot move too fast as the LightCatcher wouldn't be able to catch up. The body is nothing more than: X[LightStill].


The creature has extensive debugging built in. During runtime press ctrl+m in Framsticks to see the debugging messages. Example messages.out can be gotten from downloads section.



All the above files: here

Instructions on Framsticks environment usage

To use this creature in Framsticks do the following:
  • copy Catchlight.neuro and Flashlight.neuro to: $FramsticksMainDirectory$/scripts
  • copy LightCatcher.expt to the main Framsticks directory
  • disable gravity in Framsticks
  • change initial elevation of framsticks to 0 (Experiment - Parameters)
  • change the world simulation engine to "ODE" (it's set to "MechaStick" at default)
  • it's not neccessary but it's better to set Experiment - Parameters - Initial placement to "Central" and initial orientation to "Always 0 degrees"
You can open the experiment by pressing ctrl+O and selecting LightCatcher.expt file. It has preset "world parameters" so the experiment works out-of-the-box and there is no need to set anything. Now place a creature called 'Light catcher' on the plane by selecting it in gene pool and pressing ctrl+alt+s. Place 'moving still-emiting flashlight' in the same manner and start the simulation.


Link to Framstick Environment:

Tuesday, February 8, 2011

VirtualBox Cloner has become OPEN SOURCE

I'm proud to announce that VirtualBox 4.0 Cloner is now open source :)!!!

project home page is located at:

Project thread:

Happy cloning :)

Monday, February 7, 2011

Broken hard drive sound

Do you want to be an expert on drive failure in just 10 seconds?Smile
Here’re some drive failure noises you can here in Data Recovery lab. Various producers like: Western Digital, Seagate and Samsung are attached.

Sunday, February 6, 2011

CUPS – installing HP LaserJet 1100 on Windows 7 x64

There are two problems to begin with:
a) Microsoft has deleted old drivers from Windows 7 at default
b) CUPS is not recognized by automatic Windows 7 network printer search

When I tried to install the HP LaserJet 1100 the normal way Windows 7 didn’t want to install drivers for x86 (the only one I had). I didn’t have “Windows Update” option/button HP suggested me to use.

Then I learned about “Print Management” which resolved the issue.

CUPS is “Common Unix Printing System”


The procedure is:

  • Open “Print Management” (start->type: “Print Management”)
  • Navigate to Print Servers->your_print_server->Drivers
  • right-click in the open tab and choose “add driver”


  • Click next
  • Select ONLY x64 architecture (if you select both you won’t have Windows Update button!)
  • Click Windows Update Button
  • WAIT – about 3 minutes (yeaahhh!) Smile
  • This process takes a lot of CPU time


  • Select HP –> HP Laser Jet 1100


  • You have a 64bit printer driver!


Now install printer from CUPS:

  • Open printers (search->type “printers”)
  • right-click –> add printer
  • choose a “network printer”
  • and then “select a printer by name”

    This address contains CUPS port (631) and printer name (HP_LasertJet_1100) – your address might be (and probably will) be different.
  • Wait for a connection
  • Select newly installed x64 driver Smile

Tuesday, February 1, 2011

Virtual Gallery - Gesture Recognition Gallery

The idea behind this project was to create a gallery that could be controlled without mouse/keyboard. The operator can define markers and then use them to control the whole gallery. There are gestures for zooming, moving to next image etc.

The main library used in this project is called touchless and was created by Microsoft. A brief description can be found here:

We used C#, .NET and new WPF GUI to make it shiny ;) The application consists of two main parts. The first part is executed at launch. One can define markers and check camera image at this point. We can check marker acquisition quality and other properties. The second part launches after pressing "launch gallery" button. This part is written in WPF. One can navigate using keyboard/mouse or GESTURES :).

Notes on markers:
Best markers are of bright/lurid color. There is no golden rule but a marker has to be easily distinguished from the environment. REMEMBER: you need two markers - the application has to distinguish between them as well. You can use red LEGO block and a blue LEGO block. Try wearing black shirt while experimenting - it can help.

- Launch the application
- Press "add a marker" - the image freezes - you can select marker now
- Press a LMB on the center of the marker and drag to the outer end of the marker (the application draws an invisible circle around the marker)
- Add a second marker
- Press "launch gallery" (you can launch the gallery without adding markers or having camera image)
- Press "launch gallery" in WPF - it loads images in $APP_EXEC_PATH$/images
- Navigate with mouse/keyboard or gestures

Keyboard shortcuts:
Esc - back/exit
left/right arrow - rotate
up/down arrow - zoom in/zoom out
page up/down while in single image - previous/next image
page up/down while in gallery - previous/next page of images

Gestures dictionary:
COMING SOON :)  - see video sample for now.

Video on youtube demonstrating the project:

Gallery of images:

Executable version 32-bit Windows:

authors: Bartosz Kosarzycki, Łukasz Rek

Semantic Data Acquisition from Wikipedia

We've created a group of three developers: Anna Cudzich, me (Bartosz Kosarzycki), Sławomir Wałkowski and started working on Semantic Data Acquisition project at PUT. The idea was simple - get data from Wikipedia and convert it to an ontology (RDF file). We wanted to benefit from the structure of Wikipedia - like tables with preformatted data. We focused on just a few basic fact on American Inventors:
- name
- date of birth/death
- place of birth/death
- native american or immigrant
- inventions

The first step was to download wiki page content as described here:

Then we:
- parsed HTML files to get: *.out (with text info on inventors) and *.table (with structured HTML table data)
- got rid of all trash along the way (empty spaces, white characters etc)
- written a parser to get desired info from strings of text (*.out) and *.table and merge it together. We differentiated word types - nouns, verbs, pronouns etc to get better quality of information.
- created an ontology (written an XML file in RDF with appropriate info)

The file can be loaded with TWINKLE tool:

We used SPARQL to retrieve information from RDF. SPARQL is a query language defined by w3c for RDF files. more info here:

Sample queries in SPARQL:

just get the surnames of inventors:
prefix inv: <>
SELECT ?surname
{ ?x inv:surname ?surname }

Get some more info:
prefix inv: <>
SELECT ?place ?firstname1 ?surname1 ?firstname2 ?surname2
?x inv:firstname ?firstname1 .
?x inv:surname ?surname1 .
?x inv:wasbornin ?place .
?y inv:surname ?surname2 .
?y inv:firstname ?firstname2 .
?y inv:wasbornin ?place
ORDER BY ASC (?surname1)

To Count professions:
prefix sparql: <>
prefix inv: <>
SELECT (COUNT(sparql:lower-case(?profession )) AS ?total)  ?profession
?x inv:profession ?profession
GROUP BY (?profession)
ORDER BY ASC (?total)

The project site at PUT can be found here:

technologies, IDEs and programs used: