Linux : ethernet interface supported media
I was just checking on my machines if all my ethernet cards supports 1Gb ethernet. On OS X ifconfig will give you what you want under the section supported media, but on Linux Debian it doesn’t. For this you have to use ethtool :
sudo ethtool eth0FLV encoding with ffmpeg 15
ffmeg is a command-line tool for video encoding which has the ability to encode videos in FLV format (Macromedia plugin for direct-streaming).
First, you need to install ffmpeg with liblame support.
You may grab it as package or compile from sources.
We will compile from sources in this article for more compatibility.
first step : Installing lame get sources at http://lame.sourceforge.net, untar the archive and chdir to unpacked sources directory.
$ ./configure && make && sudo make installsecond step : Installing ffmpeg
Getting sources from svn :
$ svn export svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpegChange dir to ffmpeg and compile with liblame
$ ./configure --enable-mp3lame && make && sudo make installYour now setup. You can continue with encoding your first video
$ /usr/local/bin/ffmpeg -i input.mov -ar 22050 -ab 56 -aspect 4:3 \
-b 200 -r 12 -f flv -s 320x240 -acodec mp3 -ac 1 output.flvto view the result download a swf FLV player and create a html file :
<html>
<head>
<title>Flash FLV Player</title>
</head>
<body>
<h3>My First FLV video</h3>
<object type="application/x-shockwave-flash" width="320" height="260" wmode="transparent" data="flvplayer.swf?file=output.flv&autoStart=false">
<param name="movie" value="flvplayer.swf?file=output.flv&autoStart=false" />
<param name="wmode" value="transparent" />
</object>
</body>
</html>Enjoy !
Creating favicon.ico on Unix machines
Favicon are little icons that you can see in your browser before URL address.
To create this icons on unix-likes proceed as follow.
Open your favourite Image manipulator program, for me It will be The GIMP.
Create a 16×16 px PNG, and optionally a 32×32 px PNG.
Install png2ico from sources, package or compile it via darwinports.
For OS X with darwinports :
$ sudo port install png2icoand create your favicon file :
$ png2ico favicon.ico favicon16.png favicon32.pngNow that you have your favicon file, just put it in your web server root directory.
You can had the following for IE compatibily in your web pages :
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
Mac OS X : change lookup order, files comes first
I’m originally a Linux user. Then, in Linux lookup default order is to look first in /etc/hosts file and then to launch the dns query.
But In OS X default is to search to into NetInfo DB first.
To change this behaviour you have to change the configuration of the lookup daemon.
$ cd /etc
#if lookupd directory doesn't exists create it
$ sudo mkdir lookupd
$ cd lookupd
$ sudo echo LookupOrder Cache FF NI DNS DS > /tmp/hosts
$ sudo mv /tmp/hosts .
# reload configuration of lookupd
$ sudo lookupd -configurationAll right, you’re now setup the old fashion way.
Mac OS X : Restart ARDAgent from ssh
ARDAgent (Apple Remote Desktop Agent) sometimes freeze and then it may be impossible to control your remote server.
Here is the command line to restart it.
# ssh into you machine
$ ssh user@host
# locate the restart script
$ locate kickstart
/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart
# restart the agent
$ cd /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources
$ sudo ./kickstart -restart -agent
Ruby on Rails / Prototype : Shortcuts for javascript
If, as me, you use the prototype javascript library on top of all your scripts, you might want to use this shortcuts to save some time and increase readability of your code (But only if you know them ;) ).
Buying a mac, being lucky...
The point of this blog is not to talk about my life but for this time I’ll make an exception.
Luck comes when you doesn’t expect it.
After six month of great frustration with my iBook cause it doesn’t stop to crash, I decide to buy the new Macbook.
So, I go to my favorite store with the intention to buy the cheapest macbook. But when i arrive to the shelf, I discover that the 1GBram – DVDWriter – 2Ghz intel is sold at a reduced price (about less $150). It’s still more expensive but I decide to buy it. Unfortunatly, they doesn’t have it anymore, I have to go an other store (30 miles further) which is supposed to have it at the same price.
But when i arrive, they don’t have anymore. Sadly, I decide to take the one i came for at the first time, the cheapest. I’m not so sad, I have my new Macbook anyway, and I spent less money.
I come back home, unpack, plug, configure, and start to look at the system info tool. This is a this moment that I figure out there where a mistake in the labelling and that I have bought the more expensive one at the price of the cheapest.

Yes, this happens only to others, except for me ;)
Mac OS X : properly change shell when using zsh from darwinports/macports
If like me you use a up to date zsh shell under Mac OS X installed via DarwinPorts (which change name to MacPorts) you may want to set it as your default shell.
To do this in a proper way (not by changing it in Terminal.app Preferences) you should proceed as following.
$ sudo vi /etc/shells
# add the following line :
/opt/local/bin/zsh
$chsh
# and change /bin/bash to /opt/local/bin/zshRuby on Rails : Find with default order 1
I’ve found a solution (I am propably not the first ;-) ) for default ordering on ActiveRecord:Base children. The tip is to override the find method :
class Contact < ActiveRecord:Base
def Contact.find(*args)
if args[1]
args[1][:order] = "last_name, first_name" if args[1].is_a?(Hash) && !args[1][:order]
else
args[1] = {:order => "last_name, first_name"}
end
super(*args)
end
end
If you have something cleaner please comment this post.
Ruby
Just a little post to say why ruby is for me the best language that i ever played with.
- Ruby is beautiful
- Ruby is easy
- Ruby is fast
- Ruby is fun
- Ruby is red

