Fork me on GitHub

Rails … the beginning

Finally I started a little RoR project with my friend Antonello but we did it in the wrong way :D

We started from the database design (not exactly the rails way) and we are trying to solve problems that a Rails developer usually doesn’t have like create the scaffold without migration scripts!

Here are 3 simple steps to do it:

  • rake db:schema:dump (create the schema dump from the existing database)
  • mv db/schema.rb db/migrate/001_initial.rb (create the initial migration script manually)
  • script/generate scaffold firstmodule field1:text field2:varchar field3:date –skip-migration

The most important thing you should never forget is that your tables on the database must have a PLURAL name but use the SINGULAR name when you create the scaffold for that table.
 ( ex: the table name is “tools” but the command to create the scaffold is script/generate scaffold tool )

Happy RoRing !!!

ignore .DS_Store forever in GIT

With a couple of little commands, you’ll be able to ignore the .DS_Store files forever from your git repositories on mac!

The following command will add the .gitignore file to the git configuration

git config --global core.excludesfile ~/.gitignore

then, the following, will add the .DS_Store to the list


echo .DS_Store >> ~/.gitignore

and voilà!

LightTPD nightmare

if are trying to use mod_evhost in lighttpd in a more advanced way like using deep subdomains or with particulars tld like “co.uk” aka 2tls, you should know that

$HTTP["host"] =~ "^([^.]+)\.([^.]+)\.babelclient\.photobox\.([^.]+)\.([^.]+)$"{
evhost.path-pattern = "/web/%5/%6/assets"
}

will NEVER WORK but

$HTTP["host"] =~ "^([^.]+)\.([^.]+)\.babelclient\.photobox\.([^.]+)\.([^.]+)"{
evhost.path-pattern = "/web/%5/%6/assets/"
}

WILL WORK.

compare the two pieces of code and start screaming like a mad!

.bashrc not executed

Me and my friend Antonello, are going to start an experimental testing server to improve our skills in Ruby, PHP and start with Python as well.
After the installation, Antonello provided me an access created with webmin but, after the login I noticed that bashrc, actually bash, was not executed!
Editing /etc/passwd file, I was able to re-enable bash at login instead of sh:
your user line should look like
loginname:x:1001:1001::/home/antonio:/bin/bash
and not
loginname:x:1001:1001::/home/antonio:/bin/sh

;)

F*#king Eclipse (Parental Advisory : Explicit Content)

This morning I had a lot of problems with my Eclipse Ganymede installation: svn plugin (subversive) refused to work properly… well, actually, it didn’t worked at all!!

After some time trying to understand the source of the problem, I came out with a GREAT IDEA : “I can remove some file from my workspace folder!!!” So I went there, I displayed the hidden folders, I entered in the .metadata folder and deleted all folders related to svn and team plugins and … you know what?? It f#*king worked…

I love how Eclipse doesn’t help in solving this… F%£k IT!

But, at the end, is a good IDE…

bye

Cleanup the system memory cache on linux

what is that? you have done digited free in you linux shell and you see that all the memory is fulfilled by the cache?

sudo -s
sync; echo 3 > /proc/sys/vm/drop_caches

svn: Entry has unexpectedly changed special status

If you have this error after tryin a commit, for sure you have replaced a standard file with a symlink or viceversa, haven’t you?

In that case, what you have to do is just svn add <the resource changed> and svn will replace the file with the new one!

Were you already scared :D ?

Anyway, the correct procedure to replace a real file with a symlink in svn is the following:

  1. svn remove of the file you want to link
  2. ln -s <link>
  3. svn add of the new link

;)

proper nfs umount

Hi

if you try to umount an NFS mountpoint this way
root:~> umount /mountpoint
and your shell answer this way
umount: /mountpoint: device is busy
umount: /mountpoint: device is busy

then try killing all processes using the mountpoint and update the nfs export fs
root:~> fuser -k -m /mountpoint
root:~> exportfs -au

at this point, you can safely umount
root:~> umount /mountpoint

peace!

in_array() in Perl?

I was looking for this useful function I always use in php and found this simple article.
Basically, the function that permit you to do that is grep used in this way:
my $string = ‘fin_helm’;
my @array = qw/full_plate manteau boots two_handed_sword fin_helm/;
if(grep $_ eq $string, @array)
{
print “$string is in the array”;
}

easy?

just a note for me: Perl references

I said not to jump the chapter 4 of the Camel book (the Dromedary one) otherwise you’ll not know what @{…} (literally: at plus curly brackets) do!!
As explained in page 252, that expression, dereferenciate an array reference returning the array itself.
Remember that arghh..

ps. why Perl should be so complicated?