Linux : ethernet interface supported media

Posted by Antonin AMAND Sat, 30 Sep 2006 20:54:00 GMT

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 eth0

FLV encoding with ffmpeg 7

Posted by Antonin AMAND Mon, 25 Sep 2006 17:22:00 GMT

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 install

second step : Installing ffmpeg

Getting sources from svn :

 $ svn export svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg

Change dir to ffmpeg and compile with liblame

$ ./configure --enable-mp3lame && make && sudo make install

Your 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.flv

to 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&amp;autoStart=false">
<param name="movie" value="flvplayer.swf?file=output.flv&amp;autoStart=false" />
<param name="wmode" value="transparent" />
</object>

</body>
</html>

Enjoy !

Creating favicon.ico on Unix machines

Posted by Antonin AMAND Sat, 23 Sep 2006 14:27:00 GMT

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 png2ico

and create your favicon file :

$ png2ico favicon.ico favicon16.png favicon32.png

Now 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

Posted by Antonin AMAND Sat, 23 Sep 2006 13:57:00 GMT

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 -configuration

All right, you’re now setup the old fashion way.

Mac OS X : Restart ARDAgent from ssh

Posted by Antonin AMAND Sat, 23 Sep 2006 13:47:00 GMT

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

Posted by Antonin AMAND Fri, 22 Sep 2006 12:05:00 GMT

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 ;) ).

Here is the list of shorcuts from Johnathan Tron’s blog

Buying a mac, being lucky...

Posted by Antonin AMAND Thu, 07 Sep 2006 16:05:00 GMT

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

Posted by Antonin AMAND Wed, 06 Sep 2006 20:01:00 GMT

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/zsh

Ruby on Rails : Find with default order

Posted by Antonin AMAND Tue, 05 Sep 2006 12:56:00 GMT

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.