Monday, December 13, 2010

Google translate from shell...

Follows this

#!/usr/bin/env python
from urllib2 import urlopen
from urllib import urlencode
import sys

# The google translate API can be found here:
# http://code.google.com/apis/ajaxlanguage/documentation/#Examples

lang1=sys.argv[1]
lang2=sys.argv[2]
langpair='%s|%s'%(lang1,lang2)
text=' '.join(sys.argv[3:])
base_url='http://ajax.googleapis.com/ajax/services/language/translate?'
params=urlencode( (('v',1.0),
('q',text),
('langpair',langpair),) )
url=base_url+params
content=urlopen(url).read()
start_idx=content.find('"translatedText":"')+18
translation=content[start_idx:]
end_idx=translation.find('"}, "')
translation=translation[:end_idx]
print translation


Usage: filename lang1 lang2 word_or_sentence_to_translate

:)

Sunday, December 12, 2010

Making screenshots under Ubuntu....

1. Install scrot
sudo aptitude install scrot
2. Open configuration editor
gconf-editor
3. Go to apps/metacity/keybinding_commands and change the existing command_scteenshot from gnome-screen shot to scrot '%H-%M-%S_%Y-%m-%d_ccnas.png' -e 'mv $f ~/Pictures/'

Then after Print Screen key is pressed, the screen shot will be created and located in your Pictures folder in your home directory..

:)

Sunday, November 28, 2010

Archaic English....

These forms are commonly used by the Behemoth band so it's valuable to be familiar with them :)

'Thou' corresponds to 'I/you/he/she'. (Nominative)
'Thee' corresponds to 'me/you/him/her'. (Accusative)
'Thy' corresponds to 'my/your/his/her'. (Possessive)
'Thine' -- 'mine/yours/his/hers'.

Beautiful, doesn't it? :)

Saturday, November 27, 2010

How to configure fonts in Packet Tracer under Ubuntu 10.10

Followed by the instruction.

1. Install appreciate components:

sudo apt-get install libqtwebkit2.2-cil libqt4-script libqt4-qt3support libqt4-sql

2. Make packettracer (sudo gedit /usr/local/PacketTracer5/packettracerfile) look like the following one:

#!/bin/bash

echo Starting Packet Tracer 5.3

PTDIR=/usr/local/PacketTracer5
#export LD_LIBRARY_PATH=$PTDIR/lib
pushd $PTDIR/bin > /dev/null
./PacketTracer5 $@ > /dev/null 2>&1
popd > /dev/null

3. Make fun :)

Monday, November 8, 2010

How to install Ubuntu by using WUBI?

I used to have a problem: I needed Windows XP for my educational issues and I needed Ubuntu for some personal purposes. I thought about some kind of virtual machines like VirtualBox or Virtual PC, but each of them makes my laptop work slower. And I found WUBI....
WUBI is some kind of *buntu installer which makes the installation process very easy. You can use it when you want to install and manage the *buntu from your Windows. So how to do it? It's really simple. I did it in this way:
1) I had created an ISO file of my *buntu and I mounted it as a drive in Windows
2) I created a new directory (lets say d:\Linux) where I placed iso of my system and corresponding wubi.exe file (taken from this CD)
3) I ran the wubi.exe and choose parameters for my Linux installation
4) In case of any error I chose "Continue"
5) I restarted my laptop at the end of installation
6) From boot menu I chose Ubuntu and I followed by its messages

That's all :)
For me it's really helpful tool which prevents you from partitioning and resizing of your disk.
There is a few cons of the wubi installer and linux installation done in this way:
- some time wubi wants to download a new iso file from the net despite the fact that (according to the wubiguide) there is an ISO file insode of directory contains wubi.exe
- access to hard disk is a little bit slower because there is no native linux file system but file system created by Windows.

Using wubi is up to you but in my opinion it's very great tool and it makes that number of people using this great operation system will be bigger and bigger...

And last but not least.... you can remove the linux installed by using wubi from the Control Panel of your Windows....Great, doesn't it? :)

Sunday, October 31, 2010

How to add a timestamp to photo?

This way: :)

convert dom23.jpg -fill white -undercolor '#00000010' -gravity SouthEast -annotate +0+5 " $(date)" dom23_b.jpg

Saturday, September 25, 2010

Saturday, August 28, 2010

Give somebody a chance for life....

BEHEMOTH leader Nergal has just found out he needs a marrow transplant
to fight the sickness he has recently been diagnosed with, leukaemia. In
light of this he wants to remind everyone about the need to be on the
marrow registry. The more people get tested and donate, the more of a
chance for life there is for him and people in the same situation.

For more information visit Behemoth.p

Saturday, August 7, 2010

Thursday, July 22, 2010

Find a string inside of file in subdirectories

find ./ -type f | xargs grep -i 'eth11' :)

Enable bool log in Debian

Set flag to Yes in /etc/default/bootlogd :)

Wednesday, July 21, 2010

Friday, June 4, 2010

How to convert jpg files to one PDF?

1. Install imagemagick
sudo aptitude install imagemagick
2. Go to directory contains your jpegs and type the following command:
convert *.jpg foo.pdf
3. Make fun :)

Routine check of disks

Nearly all Ubuntu users know, that every 30 boots their system performs what is know as an "fsck" to make sure your hard drive has no errors. If you go through periods of frequent rebooting, these checks can become annoying.

To change how often these boot up checks occur, run this command in a terminal:
sudo tune2fs -c 50 /dev/hda1
where 50 is max number of mounting patrition without error checking and /dev/hda1 is checking partition.

Make fun :)

Saturday, April 17, 2010

GG inside of Empathy.... :)

Everything if here: http://www.ubucentrum.net/2010/01/gadu-gadu-i-import-kontaktow-w-empathy.html

Make fun :)

Monday, April 12, 2010

Układ równań w OpenOffice

left lbrace alignl stack{ # # } right none :)

Sunday, April 11, 2010

Black Saturday :/

No comments needed... only silence and silent prayers and hope that everything will be OK...
link

Sunday, March 21, 2010

Some strange optimization of the C# :D

Sometimes optimization mechanism build in the compilator is able to do some strange things. For example when the following code is concerned we think than reference var1 is not equal the var2 reference.

string var1 = "text";
string var2 = "text";

bool condition = object.ReferenceEquals(var1, var2);


But the optimizer of the C# "thought" that it is not needed to create some new reference on the management heap and it uses the local one.
When we make a little change in the previous code, for example modify the second string by adding the "t" letter at the end of it after its initialization

string var1 = "text";
string var2 = "tex";
var2 += "t";

bool condition = object.ReferenceEquals(var1, var2);

then the references will not be eqal.

This could be a cause of a huge set of problems in the real programming world, so take care about it :)

Nullable values in the C# language

Nullable value = 5;
value = null;
System.Diagnostics.Debug.Assert(value == null);


or

int? value = 5;
value = null;
System.Diagnostics.Debug.Assert(value == null);


Clear and easy, doesn't it? :)

What's new in C# 4.0

Spending time on doing nothing I have found a really god article about some news in the 4-th version of C# which I would like to present in this post. Especially I have ben interested in one construction in particular which allows the programmer invoking some method for the all elements of a collection in the pararell way. It looks like the following one:

string []tab=new string[]{"a","b","c","d","e"};
System.Threading.Tasks.Parallel.ForEach(tab, Method);

where

private static void Method(string val)
{
}

Programmers' everydays life :)

Test Driven Development

Sunday, March 14, 2010

Sunday, March 7, 2010

Disk docking damages your HD!!!

99_chron_dysk.sh

#!/bin/sh
hdparm -B 255 /dev/sda

Saturday, March 6, 2010

How to split a large mp3 file into some smaller?

Sometimes I come across the issue that I want to listen to some mp3s on my mobile phone but the file is larger than the storage size on my cell. I 'googled' and I found mp3splt application. It's really easy in use and makes your like much better than it used to be:)

For example if you want to split some file into 10 others you should simply type the following code in your shell window and voila

mp3splt -t 10.00 zaga.mp3

Search This Blog