it sucks or not?

You can find many post outside the web disguising on how much and why a programming language sucks. In particular, I’ve found a lot with this argument about PHP.

Personally, I don’t understand why programmers waste their time on writing this useless things. The more, I don’t understand is why they attack PHP the most of the time… or maybe I know … it’s because it’s the most used in the web, isn’t it?

If it sucks, why the hell people and big enterprises persist in using it? Why the bloody hell BBC is going to migrate his websites on PHP platform? Why Facebook use PHP? Why Yahoo?

I’d like to link an article because it reflects my thoughts No, PHP does not suck; YOU suck

Cheers.

Perl reference

Study it! if you are beginning with perl, that chapter is the one you will never jump over!
http://perldoc.perl.org/perlreftut.html

Extract portions from long log files

Do you have a really long log file and you need to extract a portion from it?
Well, there are different approaches to this and it depends from what you really need from that file.
I’ll show you the case where I need to extract a portion of y lines from an x line number :

  1. get the line number
    to get the line number, if you don’t know it already, use grep and a pattern
    grep -n pattern /var/log/examplelogfile
  2. extract the portion
    use head to output the first 200 lines and use tail to take 100 lines starting from the bottom
    head -n 200 /var/log/examplelogfile | tail -n 100

In this case, I extracted the portion from line 100 to line 200. In other words, I’ve taken 100 lines starting from line 100.
I hope I’ve been clear enough!

ps. thanks to my colleague Mauro for the second part of this trick.

grep excluding .svn dirs

Grep is a fantastic search command that let you filter results and give you what you need. It is used to search in the content of files and is very useful for programmers like us :)

Typically, when you search in a directory recursively and you whant to exclude hidden directory such as the .svn, you so this:
grep -ri "your password is" * | grep -v .
this waste time cause search in all directories including the ones you want to exclude and then remove the unwanted results.
This other method, is the correct and quickest one:
grep -r 'content_graphic' assets/js --exclude-dir=\*.svn\*
COOOL!

If you want to make this permanent when you use grep, just put it in your profile file: on a Mac open ~/.profile with a text editor. If you’re using Linux, edit ~/.bashrc or ~/.bash_profile or ~/.profile.

Add the following line to the top of the file:
GREP_OPTIONS="--exclude-dir=\*.svn\*"
export GREP_OPTIONS

save and close!

Happy grepping to everybody ;)

svn log: filter by username

I’ve found this command useful to filter the svn log by username:
svn log | sed -n '/username/,/-----$/ p'
I hope is useful to anyone like it was for me ;)

ps. It’s really useful to read the sed manual as well!

Ubuntu, Firefox, ATI and xorg overload

I was stuck with firefox and xorg on my Ubuntu machine: it was so slooooow. Today, finally, I’ve found a solution: just add the following option to your xorg.conf file under the device section:

Option "XAANoOffscreenPixmaps" "true"

then reboot your machine or your xorg server only (ctrl-alt-backspace) and …

breath deeply :O

from gedit to TextMate …

As I told in one of my previous post, I switched to an Apple Macbook thanks to a great offer I found on eBay but, I continue to use linux at work and in a virtual machine on the macbook too. One thing I really miss when I’m on linux is definitively TextMate! Thanks to this blogger I’ve found a great compromise with gedit that I want to share: thanks GRIGIO!!!

Opera font rendering and Ubuntu (maybe any Linux distro)

I just found this silly problem here: http://ubuntuforums.org/showthread.php?t=474960

Basically, just disable X font rendering here opera:config#UserPrefs|EnableCoreXFonts, save and restart Opera.
That’s it!

Radeon 9200 PRO (rv280) and Gutsy

I’ve just solved a problem with dual head at work and I want to share this.
The “man” that gave me a hand was here and thaks to him, this is my working xorg.conf configuration:
Section "Device"
Identifier "ATI Technologies Inc RV280 [Radeon 9200 PRO]”
Driver “ati”
BusID “PCI:3:2:0″
Option “monitor-DVI-0″ “Dell E176FP”
Option “monitor-VGA-0″ “Dell E196FP”
EndSection
Section “Monitor”
Identifier “Dell E196FP”
Option “DPMS”
HorizSync 31-83
VertRefresh 56-76
EndSection
Section “Monitor”
Identifier “Dell E176FP”
Option “DPMS”
HorizSync 31-80
VertRefresh 56-75
Option “RightOf” “Dell E196FP”
EndSection
Section “Screen”
Identifier “Default Screen”
Device “ATI Technologies Inc RV280 [Radeon 9200 PRO]”
Monitor “Dell E196FP”
DefaultDepth 16
SubSection “Display”
Modes “1280×1024″ “1024×768″ “800×600″ “640×480″
Virtual 2560 1024
EndSubSection
EndSection

Modify it to fits your needs. Cheers to my collegues that tried to help me too ;)

Update on my Life

Hi guys, It’s been a while from my last post: sorry but I’ve been busy.
I recently moved to London tryin to save myself from Italian way of underpay and understimate other’s jobs. Here it seems that all goes as it should!
I’m working at www.photobox.co.uk and soon I’ll write more about Perl and Javascript without forgetting PHP and Linux stuff.

Stay Tuned