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, 1 June 2009
Sunday, 14 December 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, 1 February 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";
}
Thursday, 31 January 2008
Reasons to switch from CVS to SVN
Plenty of reasons to switch to SVN/subversion as soon as possible.
SVN is better - easier to usage, no hacks for typical development tasks like
changing file names, directory structure etc.
What developer can do in SVN compared to CVS:
- can change file names and their place in project directory structure preserving
history. ### It is very important if you can make lib named "foo", code it and
week later rename to more apropiate name. This is more agile.
- can store more than plain files: symlinks, file rights. ### There are
still some problems if you would like to store your server files with
exactly the same permissions, but it is much more better than in CVS.
- handling with tags and branches is more intuitive. SVN shows them as
separated directories. ### SVN propose structure for your project where
the default (HEAD) branch for development is named "trunk". Other branches
you have in subdirectory "branches" and tagged versions are under "tags".
- commits in SVN goes together as a "transaction". All files in commit must
pass to be added to SVN repository. ### This is more safer approach than
"every file goes own way" like we have in CVS.
- commits in SVN get unique revision numbers. Single commited files belongs to
such revision number. Single files don't have own version numbers. ###
This is just different than in CVS. It has one advantage: revision number
in SVN means "this exact snapshot of code", the same like tag in CVS.
Compared to CVS, you can obtain snapshot by date (same in CVS - but you
know, this is UTC or localtime, and which timezone, huh?) and also by revision
number, without tagging code.
- mayby this is admin problem but it is simpler to make SVN working through SSL
without unix accounts on remote server (SVN repo). Do you know how to do
it in CVS?
SVN is better - easier to usage, no hacks for typical development tasks like
changing file names, directory structure etc.
What developer can do in SVN compared to CVS:
- can change file names and their place in project directory structure preserving
history. ### It is very important if you can make lib named "foo", code it and
week later rename to more apropiate name. This is more agile.
- can store more than plain files: symlinks, file rights. ### There are
still some problems if you would like to store your server files with
exactly the same permissions, but it is much more better than in CVS.
- handling with tags and branches is more intuitive. SVN shows them as
separated directories. ### SVN propose structure for your project where
the default (HEAD) branch for development is named "trunk". Other branches
you have in subdirectory "branches" and tagged versions are under "tags".
- commits in SVN goes together as a "transaction". All files in commit must
pass to be added to SVN repository. ### This is more safer approach than
"every file goes own way" like we have in CVS.
- commits in SVN get unique revision numbers. Single commited files belongs to
such revision number. Single files don't have own version numbers. ###
This is just different than in CVS. It has one advantage: revision number
in SVN means "this exact snapshot of code", the same like tag in CVS.
Compared to CVS, you can obtain snapshot by date (same in CVS - but you
know, this is UTC or localtime, and which timezone, huh?) and also by revision
number, without tagging code.
- mayby this is admin problem but it is simpler to make SVN working through SSL
without unix accounts on remote server (SVN repo). Do you know how to do
it in CVS?
Thursday, 17 January 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/
Thursday, 13 December 2007
No idea for new project?
Friday, 21 September 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, 4 September 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, 16 August 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, 8 August 2007
Mysql, convert from latin1-unicode to unicode-unicode
If you have your unicode data stored in a default latin1 mysql data fields, there is a simple way to migrate it to a proper unicode/utf8 coding:
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 you have 2/3-bytes sequences as a one non-ascii character in latin1 field, it means you have unicode (eg. utf8) text there - but for mysql it is still a latin1 string. It can work for some time if you do all your data operations outside database in a programming language and connect to MySQL as a latin1 client. But probably this is not what you would like to have as a long-term solution, e.g. you would like to use SQL for sort/comparisons, any reporting tools so you need to have data properly encoded.
If you do convert directly unicode-in-latin1 to unicode (by single alter table) it would become a 4-byte-mess, as MySQL will take existing utf8 multi-byte sequences as proper latin1 characters. The workaround is to hide coding info for MySQL by going through temporary BLOB step to keep all data untouched.
Be aware: After few several latin1-unicode conversions, I would check in the first step if you do not have a mix of latin1/utf8 coding and perhaps deal with it by conversion in external scripts.
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 you have 2/3-bytes sequences as a one non-ascii character in latin1 field, it means you have unicode (eg. utf8) text there - but for mysql it is still a latin1 string. It can work for some time if you do all your data operations outside database in a programming language and connect to MySQL as a latin1 client. But probably this is not what you would like to have as a long-term solution, e.g. you would like to use SQL for sort/comparisons, any reporting tools so you need to have data properly encoded.
If you do convert directly unicode-in-latin1 to unicode (by single alter table) it would become a 4-byte-mess, as MySQL will take existing utf8 multi-byte sequences as proper latin1 characters. The workaround is to hide coding info for MySQL by going through temporary BLOB step to keep all data untouched.
Be aware: After few several latin1-unicode conversions, I would check in the first step if you do not have a mix of latin1/utf8 coding and perhaps deal with it by conversion in external scripts.
Friday, 20 July 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 - Mac OsX - Redhat - Centos - Ubuntu - FreeBSD - Solaris - Windows commands equivalents
Updated [2016-02]: OsX/Mac/Darwin/Yosemite/El Capitan
Update: Added Solaris (both OpenSolaris and SunOS) and Windows (where applicable) coverage for this set of commands.
Update: Coverage for redhat-fedora-centos Linux line / yum package manager.
Systems covered:
Linux groups:
* Redhat based: Redhat, Fedora, Centos (yum/rpm packages)
* Debian based: Debian, Ubuntu, Kubuntu (dpkg/.deb packages)
Mac OsX: Darwin/Yosemite/El Capitan
OsX is usually very close to BSD systems, but sometimes suprisingly has Linux-style commands/tools.
Windows: around XP/2007 and newer
Check what groups do I belong to?
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, kPackageKit)
Install a binary package
Update binary packages
Install a package from sources
...The more I see the less I know...
Update: Added Solaris (both OpenSolaris and SunOS) and Windows (where applicable) coverage for this set of commands.
Update: Coverage for redhat-fedora-centos Linux line / yum package manager.
Systems covered:
Linux groups:
* Redhat based: Redhat, Fedora, Centos (yum/rpm packages)
* Debian based: Debian, Ubuntu, Kubuntu (dpkg/.deb packages)
Mac OsX: Darwin/Yosemite/El Capitan
OsX is usually very close to BSD systems, but sometimes suprisingly has Linux-style commands/tools.
Windows: around XP/2007 and newer
Accounts
Check what groups do I belong to?
{linux, osx, freebsd, solaris}$ groups
{windows - active directory}> dsquery user -samid %USERNAME%|dsget user -memberof
Disk, filesystem
Disk usage
{linux, osx, bsd}$ du -sh
Count subdirectories in current directory:
{linux}$ du --max-depth=1
{osx, bsd}$ du -d1
{SunOS}$ du
Typical approach to find biggest directories/files on disk:
{linux}$ du --max-depth=1 -kx|sort -n
{osx, bsd}$ 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)"
{osx, bsd}$ find -E . -type f -regex ".*\.(java|class)"
Show open files and programs:
{linux, osx}$ lsof
{freebsd}$ fstat
Real time disk usage (is there something which shows results for every disk in linux?):
{linux}$ vmstat 3
{osx, bsd}$ iostat 3
Swap info:
{linux}$ free
{freebsd}$ swapinfo
{osx}$ vm_stat
{osx}$ top -l 1 -s 0 -n 0
Networking
Show open ports and apps connected to them:
{linux}$ netstat -apne --inet
{osx}$ lsof -i
{freebsd}$ sockstat
{SunOS}$ netstat
{windows}$ netstat -b
netstat -b -v # slower but with tree of dependencies
Kernel issues
Show loaded modules:
{linux}$ lsmod
{osx}$ kextstat
{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
{osx}$ dtrace
{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
{debian ubuntu}$ dpkg -S /path/to/checked_file
{redhat centos}$ rpm -qf /path/to/file
{osx, for brew}$ ls -l `which node`|perl -lane '{print $F[-1]}'
OsX - it shows the original brew package/file this command is linked to
Have we got a package like... (in (k)ubuntu you can use more friendly tools like synaptic, apt-get, kPackageKit)
{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/"
{redhat centos}$ yum search name
yum provides name
Install a binary package
{debian ubuntu}$ apt-get install package_name
{redhat centos}$ yum install name
{freebsd}$ pkg_add -r package_name
{windows}$ msiexec /i package.msi
{osx}$ ???
In FreeBSD you have packages made in distribution release time - unfortunately there are no binary upgrades for released version)Update binary packages
{debian ubuntu}$ apt-get update; apt-get upgrade
{redhat centos}$ yum update
Install a package from sources
{debian ubuntu}$ apt-src
{freebsd}$ cd /usr/ports/path/package; make install clean
{osx}$ use brew or macports
...The more I see the less I know...
Subscribe to:
Posts (Atom)
