Monthly Archives: April 2010

Starvation vs. Synchronize vs. Deadlock

Starvation In computer science, starvation is a multitasking-related problem, where a process is perpetually denied necessary resources. Without those resources, the program can never finish its task. Starvation is similar in effect to deadlock. Two or more programs become deadlocked … Continue reading

Leave a comment

Threads vs. Processes

Threads vs. Processes Processes Both threads and processes are methods of parallelizing an application. However, processes are independent execution units that contain their own state information, use their own address spaces, and only interact with each other via interprocess communication … Continue reading

Leave a comment

Mutex vs. Semaphore, what is the difference?

Mutex vs. Semaphore, what is the difference? The Toilet Example Mutex Is a key to a toilet. One person can have the key – occupy the toilet – at the time. When finished, the person gives (frees) the key to … Continue reading

Leave a comment

Linux Screen Basics

$ screen : start a screen session $ screen -ls : list screen sessions (useful if more than one session) $ screen -x : connect to already attached screen session (subsequent windows) $ screen -r : reattach to a detached … Continue reading

Posted in Linux | Leave a comment

How To Show Different Colors Per Level Using Log4perl

Use the following appender to show different colors. You can also customize the color per level. log4perl.appender.SCREEN = Log::Log4perl::Appender::ScreenColoredLevels log4perl.appender.SCREEN.color.INFO = white log4perl.appender.SCREEN.color.FATAL= bold underline blink red on_white attributes BOLD, DARK, UNDERLINE, UNDERSCORE, BLINK colors BLACK, RED, GREEN, YELLOW, BLUE, … Continue reading

Leave a comment

How To Print in Color Using Perl

http://perldoc.perl.org/Term/ANSIColor.html use Term::ANSIColor; print color ‘bold blue’; print “This text is bold blue.\n”; print color ‘reset’; print “This text is normal.\n”; print colored (“Yellow on magenta.”, ‘yellow on_magenta’), “\n”; print “This text is normal.\n”; print colored ['yellow on_magenta'], ‘Yellow on … Continue reading

Leave a comment

How To Log to Multiple Files Using Log4perl

How to log to multiple files using a single Log4perl logger. Example: you have an INFO level logger, but you want to log warnings and errors to separate files. You also want to log to the screen. ### Throw everything … Continue reading

Posted in Languages | Tagged | 1 Comment

How To Quickly Go Split Screen in VIM

Horizontal split :split Vertical split :vsplit Switching screens CTRL-w, directional key (in the direction you want to move to)

Posted in Everything Else | Leave a comment

How To Determine a Good Unique Key

Make the unique key long enough to allow for reasonable duplication of names in the real world For example, for a table of people, a unique key of country/state/city/address might be a good choice.  This allows for two people in … Continue reading

Leave a comment

How To Access Values in Perl Hash as an Array, Given a List of Keys

my @fields = ( “country_name”, “region_name”, “city_name”, ); while (my $row = $sth->fetchrow_hashref) { my %row = %$row; printf $format, @row{ @fields }; }

Leave a comment

Center a Table Using CSS

How to center a table (and similar block items like div): table { margin-left: auto; margin-right: auto; } Centering text: span { text-align: center; }

Posted in Languages | Tagged | Leave a comment

How To Store Phone Numbers in MySQL

Store phone numbers as strings, not numbers. Phone numbers are identifiers that happen to use digits. Phone numbers starting with zero are valid, but may be interpreted as octal by a programming language. Strip the phone number to only digits … Continue reading

1 Comment