Mostly for Win-XP: It is really handy to have an auto-complete with standard windows shell, cmd. Surprise: it works! The default expand sequence is Ctrl-F.
To change it to more popular tab, open (win-R) regedit and go to HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor, change CompletionChar and PathCompletionChar to 9.
That's it.
Open your cmd window again and enjoy.
The more detailed description you cand find at http://support.microsoft.com/kb/310530
Monday, June 1, 2009
Sunday, December 14, 2008
Matrix, Paweł Hajdan, Chromium and Chrome
I just heard this news yesterday being in Warsaw for a couple of hours: Paweł Hajdan Jr, the member of "Matrix", became a first external commiter to Chromium Code.
See Chromium Blog
Congratulations!!!
"Matrix" is a name of the group that I started 5 years ago to improve the software development and internet services delivery for Polish Scouting Association, ZHR.pl. Paweł was the youngest guy at the first Matrix meeting 5 years ago. It was really nice to see him again with his talk about security in web applications given to the members of Matrix group.
See Chromium Blog
Congratulations!!!
"Matrix" is a name of the group that I started 5 years ago to improve the software development and internet services delivery for Polish Scouting Association, ZHR.pl. Paweł was the youngest guy at the first Matrix meeting 5 years ago. It was really nice to see him again with his talk about security in web applications given to the members of Matrix group.
Friday, February 1, 2008
Exif auto-rotate & scale your photos
Typically after a journey to new place I finish with hundreds of photos from my camera. When I am browsing it on linux (or mac osx) everything is ok - gwenview can read EXIF rotation data and show them in proper direction (rotate on the fly). The problem begin when you upload such "good" portrait image or send it by email - it will be 90deg rotated. Ooops!
A small script can fix it and create subdirectories with 1280x1024 and 800x600 scaled images. It also rotates original images lossless preserving original EXIF data - don't be afraid about the quality!
To use this, simply add packages: imagemagick, exiftran & perl bindings Image::Magick.
A small script can fix it and create subdirectories with 1280x1024 and 800x600 scaled images. It also rotates original images lossless preserving original EXIF data - don't be afraid about the quality!
To use this, simply add packages: imagemagick, exiftran & perl bindings Image::Magick.
#!/usr/bin/perl -w
`exiftran -aip *.JPG`;
`exiftran -aip *.jpg`;
use strict;
use Image::Magick;
use Cwd;
my $currdir = ( getcwd =~ m{([^/]+)$} )[0];
my $webdir = $currdir . '_to1280';
my $web800 = $currdir . '_to800';
print "Creating dirs: $webdir, $web800\n";
mkdir $webdir;
mkdir $web800;
print $| = 1;
foreach my $filename (<*.jpg>, <*.JPG>) {
# read this
my $image = Image::Magick->new();
$image->read($filename);
# scale it
print "$filename ";
$image->Thumbnail(geometry => '1280x1024>');
$image->write($webdir . '/' . lc($filename));
$image->Thumbnail(geometry => '800x600>');
$image->write($web800 . '/' . lc($filename));
print ".\n";
}
Labels:
exif,
imagemagick,
perl,
photos
Thursday, January 17, 2008
My photo-CV /yeap, I am looking for a new job/

I used to work hard, in a stress and time-critical environment - it is always a challenge for me.

I like to work with others - to cooperate to solve complex problems! IT world is too complicated to go thorough really alone. RTFMs, lists, IRC, friends...

It is very practical to document my work...

... but it is even better to share my knowledge with other people! /last yapc::eu 2007, vienna/

It is not so easy to optimize code and databases, to make it better, faster, more efficient and reliable - better for users... but it just need to be done

having my workplace and codebase really nice is also a pleasure to dig more /cvs, subversion, good directory layout, getting best of all /etc/*, .ssh/.rc files/

simplicity of architecture & design, good ERM models and libraries can give project a real power! /from 2NF, 3NF to fast ETL tools and database tuning/

As a good developer, I always try to learn something new and get more from my work /enjoy safaribooksonline, free sources, books to do what need to be done the best way/
Labels:
curriculum vitae,
cv,
job,
photo
Thursday, December 13, 2007
No idea for new project?
Friday, September 21, 2007
What I hate in perl5 and Catalyst
Perl - references
Let's remove all simple data-structures like @lists and %hashes. When we think "list" let use list-refs, ref-hashes instead of hashes. Let's keep only scalars and references with implicit dereferencing, like in Python or Ruby. No wantarray context-dependent behaviour! No @{$foo} and \@foo and other nasty code! Perl will be clear and more funny!
current perl:
$foo = [ map { ... } @$bar ]
better perl:
$foo = map { } $bar
As I see folks have problems why we write:
%hash = (foo => 42);
$hash{foo} # where is hash sign, % ?
@list = qw/foo bar baz/;
$list[1] # where is list sign, @ ?
and there is no much difference between lists and refs, but differences between various forms of using refs are probably bigger than list<->ref:
$list[1][2] # wolf
$$list[1][2] # dog1
$list->[1][2] # dog2
$list->[1]->[2] # dog3
Sure, there is only one dog, welcome to TIMTOWDI world!
There are also some troubles with
$ref = \@list;
$ref = [@ref]
# maybe it is @list?
$ref = [ $some->method ]
# or maybe it is %hash?
$ref = { $some->method }
# could be better to make something like
$ref = $some->method->return_as_hashref
$ref = $some->method->return_as_arrayref
Maybe I should stop writing perl code because I think too much about all those things? ;)
Catalyst - index is different than other actions
What is a difference between:
Controller app::foo;
sub index : Private {
my ($self, $c, $param1) = @_;
}
sub show : Local {
my ($self, $c, $param1) = @_;
}
?
Index will not catch arguments, will not work with /foo/123, although /foo/show/123 will work that way. To fix index, we need to use LocalRegex
sub index : LocalRegex('^(.*)$') {
my ( $self, $c ) = @_;
my ($param1) = @{ $c->req->captures };
}
Tuesday, September 4, 2007
YAPC::Europe 2007 in Vienna
Larry Wall, Damian Conway, many great perl hackers, interesting events, all in one place in one time.
It was my first YAPC and also first YAPC talk (slides from Catalyst refactoring are with others from this yapc on slideshare - also check perlbuzz.com) and Bartosz Jakubski's YAPC::EU 2007 photos.
However more interesting was to see in real life how this OS world works, met many interesting people from the perl community. There is probably nothing more interesting than long talks about POE, Catalyst and other kinda-like-app-servers or any other stuff during evenings near the Dunau Kanal and in other nice places in Vienna.
Huh, many words to say how great and cool was this YAPC!!!
PS: I will try to remember difference between Dbix and (Dbic or Dbix::Class) at least to avoid bot activation on #catalyst /and mst should also be happy ;)
It was my first YAPC and also first YAPC talk (slides from Catalyst refactoring are with others from this yapc on slideshare - also check perlbuzz.com) and Bartosz Jakubski's YAPC::EU 2007 photos.
However more interesting was to see in real life how this OS world works, met many interesting people from the perl community. There is probably nothing more interesting than long talks about POE, Catalyst and other kinda-like-app-servers or any other stuff during evenings near the Dunau Kanal and in other nice places in Vienna.
Huh, many words to say how great and cool was this YAPC!!!
PS: I will try to remember difference between Dbix and (Dbic or Dbix::Class) at least to avoid bot activation on #catalyst /and mst should also be happy ;)
Thursday, August 16, 2007
Ruby, Rails and Netbeans (compared to Catalyst)
In current time I am working on my bike-"startup" site, rowerem.org (in Polish: by-bike org) which promotes using bicycles in Krakow and cities at all. This is a free project, no money just fun and opportunity to learn something new.
For long time I was not sure I should do it in perl/Catalyst, some kind of python framework or Ruby/Rails. From the hosting point of view it should be php but... never mind ;) Because I like python, this simplicity, explicit constructions I was checking python frameworks. Unfortunately Django goes own way of MTV, Turbogears is not so well designed (opinions), Pylons - not so popular to have mature quality of all web-related libs. Inspired by latest billboards ads in the city I chose Rails ;)
What is good about Rails?
- Good documentation. You have few good, printed books: Rails Recipes, Rails Cookbook and of course Agile Web Development with Rails. If you have a problem with something, just google for it or check in book. Howtos on rails/doc are also helpful. The step-in cost is very small compared to eg. Perl/Catalyst even when I code in Perl for 10 years when Ruby is still fresh for me.
- not too deep directory structure. It is simpler compared to Catalyst.
- model (ActiveRecord) is really simple to use. Maybe DBIx::Class is powerful but hard to use for night development (after typical day in work). Or I am just too lazy ;)
- good IDE. Have you ever tried Netbeans 6? There are some issues like hard-to-work-without-mouse, hard to (re)define shortcuts / compared to Kdevelop / but... you have good, free IDE for Ruby and Rails projects!
Now it is very funny to extend Catalyst knowledge based on Rails usage - "there should be something like this in Catalyst", this works also in the opposite direction, because both frameworks are quite similar.
Do you use Catalayst? Or maybe you use Rails? What do you think about them?
For long time I was not sure I should do it in perl/Catalyst, some kind of python framework or Ruby/Rails. From the hosting point of view it should be php but... never mind ;) Because I like python, this simplicity, explicit constructions I was checking python frameworks. Unfortunately Django goes own way of MTV, Turbogears is not so well designed (opinions), Pylons - not so popular to have mature quality of all web-related libs. Inspired by latest billboards ads in the city I chose Rails ;)
What is good about Rails?
- Good documentation. You have few good, printed books: Rails Recipes, Rails Cookbook and of course Agile Web Development with Rails. If you have a problem with something, just google for it or check in book. Howtos on rails/doc are also helpful. The step-in cost is very small compared to eg. Perl/Catalyst even when I code in Perl for 10 years when Ruby is still fresh for me.
- not too deep directory structure. It is simpler compared to Catalyst.
- model (ActiveRecord) is really simple to use. Maybe DBIx::Class is powerful but hard to use for night development (after typical day in work). Or I am just too lazy ;)
- good IDE. Have you ever tried Netbeans 6? There are some issues like hard-to-work-without-mouse, hard to (re)define shortcuts / compared to Kdevelop / but... you have good, free IDE for Ruby and Rails projects!
Now it is very funny to extend Catalyst knowledge based on Rails usage - "there should be something like this in Catalyst", this works also in the opposite direction, because both frameworks are quite similar.
Do you use Catalayst? Or maybe you use Rails? What do you think about them?
Wednesday, August 8, 2007
Mysql, unicode in latin1, bad but not lost!
If you just created project, have some unicode data but have just found it is a unicode in latin1 fields - simple repair it in 2 steps:
1) change text fields (char/varchar/text) format to BLOB to loose coding info
2) change BLOB to varchar/text setting proper coding.
Description: if we have 2/3-bytes sequences as a one non-ascii character in latin1 field, it means we have unicode (eg. utf8) text but for mysql it is a latin1 string. It can work for some time if you do all operations outside database in programming language. But typically you would like to use SQL for sort/comparisons and have data properly coded.
If you did convert directly unicode-in-latin1 to unicode it would be 4-byte-noise. So we loose coding info by BLOB step to leave data untouched.
1) change text fields (char/varchar/text) format to BLOB to loose coding info
2) change BLOB to varchar/text setting proper coding.
ALTER TABLE `news` CHANGE `body` `body` BLOB NULL DEFAULT NULL;
ALTER TABLE `news` CHANGE `body` `body` TEXT CHARACTER SET utf8 NULL DEFAULT NULL;
Description: if we have 2/3-bytes sequences as a one non-ascii character in latin1 field, it means we have unicode (eg. utf8) text but for mysql it is a latin1 string. It can work for some time if you do all operations outside database in programming language. But typically you would like to use SQL for sort/comparisons and have data properly coded.
If you did convert directly unicode-in-latin1 to unicode it would be 4-byte-noise. So we loose coding info by BLOB step to leave data untouched.
Friday, July 20, 2007
Perl, unicode, utf-8, mysql
Handling unicode/utf8 in Perl is quite trivial when you understand "two string approaches".
Perl 5.8 by default can handle UTF-8 strings like a sequence of bytes (1-4 bytes per one char). You can "compress" them to unicode strings with
Such encoded string has unicode flag, you can check it with:
If they have latin1/2/russian/etc. chars after unicode packing:
Remember: unicode flag does not mean you MUST have wide characters in string.
Wide characters (ord > 255) can be in such unicode string, but it can also has a set of unicode-octets, "unpacked" in unicode string.
Use Test::utf8 to check you have wide chars or not.
- check all sources in your program are the same, coded as unicode (wide) or unicode-string. Typically wide-char-strings is a better approach then byte-string (see perldoc Encode). All inputs/outputs like files, DBI, network need to be converted to your choosen internal format.
- do not use use utf8 pragma unless you really need it. In this case all strings have unicode flag, but it does not mean they have wide chars!
Two approaches to get unicode working with MySQL:
1) after connecting to database, do("SET NAMES 'utf8');
All unicode strings will be octets, without unicode flag.
2) use DBI connection with flag: mysql_enable_utf8 (since DBD::mysql >= 4)
All unicode strings will have wide chars and unicode flag.
Only the second approach works correctly with AutoReconnect flag.
Good news: there is no difference for inserts/updates you use octets or wide_char_strings.
Check also this Martin Fowler - utf8 in perl
Perl 5.8 by default can handle UTF-8 strings like a sequence of bytes (1-4 bytes per one char). You can "compress" them to unicode strings with
$wide_char_string = Encode::decode_utf8($octets)
Such encoded string has unicode flag, you can check it with:
Encode::is_utf8($checked_string)
If they have latin1/2/russian/etc. chars after unicode packing:
length($octets) > length($wide_char_string)
Remember: unicode flag does not mean you MUST have wide characters in string.
Wide characters (ord > 255) can be in such unicode string, but it can also has a set of unicode-octets, "unpacked" in unicode string.
Use Test::utf8 to check you have wide chars or not.
FAQ / typical problems:
- check all sources in your program are the same, coded as unicode (wide) or unicode-string. Typically wide-char-strings is a better approach then byte-string (see perldoc Encode). All inputs/outputs like files, DBI, network need to be converted to your choosen internal format.
- do not use use utf8 pragma unless you really need it. In this case all strings have unicode flag, but it does not mean they have wide chars!
(octet_string eq unicode_string) == falseYou cannot compare such strings without decode/encode, they are natively different!
Perl, utf8, MySQL
Two approaches to get unicode working with MySQL:
1) after connecting to database, do("SET NAMES 'utf8');
All unicode strings will be octets, without unicode flag.
2) use DBI connection with flag: mysql_enable_utf8 (since DBD::mysql >= 4)
All unicode strings will have wide chars and unicode flag.
Only the second approach works correctly with AutoReconnect flag.
Good news: there is no difference for inserts/updates you use octets or wide_char_strings.
More to read
Check also this Martin Fowler - utf8 in perl
Linux - FreeBSD - commands
These systems are really close each other. FreeBSD comes from Berkeley and Linux comes from Finland so it's pretty sure some differences need to be - and here they are :)
Disk usage
Count subdirectories in current directory:
Typical approach to find biggest directories/files on disk:
Find some kinds of files (regex is a mask for full path, no need for begin/end marks)
Show open files and programs:
Real time disk usage (is there something which shows results for every disk in linux?):
Swap info:
Show open ports and apps connected to them:
Show loaded modules:
Load kernel module:
Remove loaded module:
Trace the system calls of a program:
libraries - show all paths + libs:
Different linux distros make it own way. I'll focus on debian-based distributions like Debian, Ubuntu, Kubuntu etc.
Find which package this file belongs to?
Have we got a package like... (in (k)ubuntu you can use more friendly tools like synaptic, apt-get)
Install a binary package
Install a package from sources
...The more I see the less I know...
Disk, filesystem
Disk usage
{linux}$ du -sh
{freebsd}$ du -sh
Count subdirectories in current directory:
{linux}$ du --max-depth=1
{freebsd}$ du -d1
Typical approach to find biggest directories/files on disk:
{linux}$ du --max-depth=1 -kx|sort -n
{freebsd}$ du -d1 -kx|sort -n
Find some kinds of files (regex is a mask for full path, no need for begin/end marks)
{linux}$ find . -regextype posix-extended -type f -regex ".*\.(java|class)"
{freebsd}$ find -E . -type f -regex ".*\.(java|class)"
Show open files and programs:
{linux}$ lsof
{freebsd}$ fstat
Real time disk usage (is there something which shows results for every disk in linux?):
{linux}$ vmstat 3
{freebsd}$ iostat 3
Swap info:
{linux}$ free
{freebsd}$ swapinfo
Networking
Show open ports and apps connected to them:
{linux}$ netstat -apne --inet
{freebsd}$ sockstat
Kernel issues
Show loaded modules:
{linux}$ lsmod
{freebsd}$ kldstat
Load kernel module:
{linux}$ modprobe SomeModule
{freebsd}$ kldload SomeModule
Remove loaded module:
{linux}$ rmmod SomeModule
{freebsd}$ kldunload SomeModule
Program development
Trace the system calls of a program:
{linux}$ strace
{freebsd}$ truss
(strace is also available in /usr/ports/devel/strace)
libraries - show all paths + libs:
{linux}$ ldconfig -p
{freebsd}$ ldconfig -r
Packages management
Different linux distros make it own way. I'll focus on debian-based distributions like Debian, Ubuntu, Kubuntu etc.
Find which package this file belongs to?
{freebsd}$ pkg_info -W /path/to/checked_file
{linux}$ dpkg -S /path/to/checked_file
Have we got a package like... (in (k)ubuntu you can use more friendly tools like synaptic, apt-get)
{linux}$ apt-cache search your_name
{freebsd}$ cd /usr/ports; make search key=your_name
make search name=pear display=name,path
you can also try simple locate (only in package names):
{freebsd}$ locate -i your_name | grep "/usr/ports/"
Install a binary package
{linux}$ apt-get install package_name
{freebsd}$ pkg_add -r package_name
In FreeBSD you have packages made in distribution release time - unfortunately there are no binary upgrades for released version)Install a package from sources
{linux}$ apt-src
{freebsd}$ cd /usr/ports/path/package; make install clean
...The more I see the less I know...
Friday, July 13, 2007
YAPC Vienna 2007 - my talk
I will have a Catalyst talk at Yet Another Perl Conference in Vienna, 28th to 30th August 2007 in Web track.
More on conference site,
http://vienna.yapceurope.org/ye2007/talks#18
More on conference site,
http://vienna.yapceurope.org/ye2007/talks#18
Subscribe to:
Posts (Atom)
