Tuesday, 8 November 2011

Grub, no count down after failed run, how to fix it

This default grub behavior could be very annoying especially with virtual machines running headless or whatever should stand up after failure. It could be fixed by modifying make_timeout () in /etc/grub.d/00_header: Original code: ****
make_timeout ()
{
    cat << EOF
if [ "\${recordfail}" = 1 ]; then
  set timeout=-1
else
  set timeout=${2}
fi
EOF
}
**** here is how to fix it: ****
make_timeout ()
{
    cat << EOF
if [ "\${recordfail}" = 1 ]; then
  set timeout=${2}
else
  set timeout=${2}
fi
EOF
}
**** /I know it is a "secure programming" approach in terms of how this code looks like now... and yes, it is/ The original hint is taken from here: http://forum.xbmc.org/showthread.php?t=64857

Tuesday, 11 October 2011

cssh - cluster ssh - do your cluster work easier

This is a very simple but powerful tool for interactive work with many machines at once
Just log in to them
cssh node1 node2 node3
and do the same operations on all of them.

It needs x-window (mmm, just wonder if there is a pure-text replacement?) and it is worth to configure ssh keys and perhaps ssh-agent to make your logins easier but still safe.
cssh comes with packages for ubuntu/debian, not sure if redhat/centos rpms catch up here. This project page is http://sourceforge.net/projects/clusterssh/
Many thanks for this tool!

Tuesday, 27 September 2011

CPAN of the week

Carp::Always - this is what you need when perl -MCarp=verbose doesn't work the way you expect it. Spotted in some post by JRockway.

Mock::Quick - mock whatever you want, but also takeover/partially override existing modules and classes. The beauty of certainty for TDD or just when escaping from too many dependencies.

Sunday, 5 June 2011

Git ignore file

I just find myself like searching for this again and again as I am not a very heavy git user now, but setting global core.excludesfile seems to be very similar to svn/cvs approach.

How to ignore certain types of files in git?

1) Put the excludes in your $GIT_DIR/info/exclude file (.git/info/exclude), if this is specific to one tree.

2) Run git config --global core.excludesfile ~/.gitignore and add patterns to your ~/.gitignore. This option applies if you want to ignore certain patterns across all trees.

/taken from StackOverflow by Emil

Wednesday, 16 March 2011

Back ticks equivalent in cmd / windows

How to get a result of one command and use it in another command in Windows shell, like with backticks in Unix/Linux shell?

Here is a working example:
for /f "tokens=1* delims=" %%s in ('gnuwin32\date +"%%Y%%m%%d_%%H%%M"') do echo output_%%s.log

> output_20110215_1057.log


Works in Windows XP, Vista, Windows 7.

Remember:
1) The variable used in a for loop must be a one letter (at least in XP, Vista)
2) gnuwin32 is a set of GNU tools like grep/sed/awk/date which can be run natively in Windows without cost of additonal Cygwin-like layers

Thursday, 10 February 2011

Mr Openoffice is happy with default A4 page

This is that kind of thing that you know you want to change, but there is always no time to do it. But it is just a minute, really!

http://selinap.com/2008/12/how-to-set-openoffice-default-page-format-to-a4/

Simply:
1) change page format
2) save it as a template (File -> template)
3) set this template as a default (File -> template -> organize -> commands -> set as a default tpl)

Do it, do it!

Monday, 5 April 2010

Rails, flushing buffer log - what a waste of time to fix it

It was so stupid...

There was a ruby on rails application. There were some changes in a production server. Some missing libraries needed to be added. You are fixing one thing then another, try and fix, try and fix and so on. That is fine as long as we know what needs to be done.

Finally this application was ready to work in development but not in production mode. There was nothing on screen nor in log/development.log even with enabled -u (debug) flag for script/server (you should have ruby-debug gem and ruby-dev package also as a dependency).

What is wrong as I am still getting "Application error
There is an error in this application. Please let us apologize for this inconvenience and help to fix it by reporting this problem to site-master", why there is NOTHING in the log or maybe - where is this f..$%&* log at all? log/production.log is untouched even after shutting down the server.

Ok, probably the error is somewhere in differences between environments so maybe this could be a database.yml, different place of connection socket but why I can not see even a simple error message about this?

After some time for browsing forums, groups and so on the proper solution was to add
Rails.logger.auto_flushing = 1
at the end of my config/environment.rb

My question is - even if this large buffer is understandable solution for heavy production environments why I cannot see anything after closing down my server? Should not this log be flushed then?

If you want to check your logger settings...



Run your rails console:

script/console

and then type:
RAILS_DEFAULT_LOGGER.inspect

so it looks like:
script/console production
Loading production environment (Rails 2.3.5)
>> RAILS_DEFAULT_LOGGER.inspect


and check @auto_flushing= value.

If you have @auto_flushing=1 then you are at home.

Monday, 1 June 2009

Auto-complete cmd in Windows (like in bash)

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

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.

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.


#!/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?

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 /all those apache/mod_rewrite/squid/non-forking-light-servers approaches.../






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/