RSS | Archive | Random | E-mail

About

Hi, I'm Christian Castelli, a 28 years old italian programmer located in Pisa (Italy). Here I post small snippets of code which can be useful in my work.

Links

Codepuzzling main site
Development site
ByteStrike italian blog
Follow me on Twitter

My Life Style

while(passion) {
  try {
    myLife.run();
  }catch(LifeExceptions) {  
    stronger++;
    continue;
   }
}

Following

17 September 09

[Bash] How much memory consume a process

ps -aylC geany |grep "geany" |awk '{print $8'} |sort -n |tail -n 1

Tags: bash memory awk
Comments (View)
8 June 09

[SQL] How to compare two SQL schema with sqlfairy

First of all, install sqlfairy on your machine if you haven’t done yet, then simply give in input to the program the path to the SQL schemas:

sqlt-diff -d -c schema_to_update.sql=MySQL updated_schema.sql=MySQL 2>/dev/null|grep -v "DROP TABLE"

Notes on this command:
  • -d: prints debug info;
  • -c: case insensitive;
  • 2>/dev/null: don’t print warning and error messages so you can grep results data;
  • grep -v “word”: don’t print lines that match the pattern specified between quotes
Tags: sql bash
Comments (View)
3 June 09

[Shell] How to modify bash shell prompt

The UNIX shell displays a command prompt when the system is ready to accept commands on the command line. To customize your prompt you will need to modify the PS1 (“prompt string 1”) shell variable. For example if you want to show “user@host:working_path”, you have to set PS1 variable in this way in your .bash_profile:

# ~/.bash_profile: executed by bash(1) for login shells.

PS1='[\u@\h:\w]$ '
Next digit source ~/.bash_profile and you’re ready.

Tags: bash shell
Comments (View)
Themed by Hunson. Originally by Josh