emmanuel.vaisse.log

To content | To menu | To search

Wednesday 30 April 2008

Startup GNU screen Bash/shell config

first, edit .bash_profile in your home.

#!/bin/bash
export PS1="$PS2\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ "

Second, make a symbolic link to .bashrc

ln -s ~/.bash_profile ~/.bashrc

Last, the .screenrc file :

# Bottom line status 
hardstatus alwayslastline "%{=}%{wk} %Y/%m/%d -%C%A  %=%{kG} %{w}%w"
# Turn off start message:
startup_message off
# Set messages timeout to one second:
msgwait 1
# first window
screen -t default 0
# default windows title with the auto-title
# needs to add the title-escape-sequence in ~/.bashrc
shelltitle '$ |:' 

Finaly, you can start your terminal with the screen recall command, re-attach all screens or create a new one.

screen -RR

Sunday 27 April 2008

Using Parrot Boombox bluetooth speaker on Ubuntu 8 Hardy

I've just found how to use my bluetooth speaker on Ubuntu 8 (macbook pro santa rosa). My laptop bluetooth is fully fonctionnal on ubuntu out of the box. It's very easy to connect speaker with the bluetooth panel in gnome, so I'll just explain how to put sound on these speaker after installation. No specific package are required. The command use gstreamer as AD2P channel (bluetooth audio hifi protocol). Open a terminal and type :

 gconftool -t string -s /system/gstreamer/0.10/default/musicaudiosink \ 
            "sbcenc ! a2dpsink device=XX:XX:XX:XX:XX:XX"

Where xx:xx:xx:xx:xx:xx is the adresse of your bluetooth speaker.

To come back to default configuration :

 gconftool -t string -s /system/gstreamer/0.10/default/musicaudiosink "autoaudiosink"

More info here : http://wiki.bluez.org/wiki/HOWTO/Au...

Sunday 20 April 2008

SVN auto add/move/del

On small projects, I use this script for simply update all changes (including add and remove actions) on the svn repo. name the command ( here svnscan ) :

$ sudo nano /usr/local/bin/svnscan

Type in the file

#!/bin/bash
svn status
svn status | egrep "^\?" | sed -e 's/? *//' | xargs svn add
svn status | egrep "^\!" | sed -e 's/! *//' | xargs svn rm

Don't forget to make the command executable :

$ sudo chmod +x /usr/local/bin/svnscan

Monday 31 March 2008

Rails2 scaffolding

There is a new scaffold generator syntax in Rails2. The new method is more straightforward, you define controllers, view AND models in one command.

$ ./script/generate scaffold Computer hostname:string fqdn:string \ 
                                      mac:string ip:string \
                                      description:text 

Here your models, controllers and views are generated. Now sync your database.

$ rake db:migrate

Your tests are now finished, you can delete every change

$ ./script/destroy scaffold Computer

Thursday 27 March 2008

2D Game Physics with Ruby

Chipmunk, a 2D physics library under MIT licence, provide a Ruby scripting extension. The sketches video will tell you how chipmunk look great (other examples on Chipmunk wiki). To complete your Ruby gamedev toolbox, take a look at Aerosol (actually bundled with Chipmunk) or Gosu, the high-level game development library. Andrea O. K. Wright has posted two articles about ruby game development.

HotRuby, the Ruby/Javascript virtual machine

HotRuby run ruby in javascript block, in your browser or even in Flash. HotRuby runs opcode, compiled by YARV (Yet Another Ruby VM).

Monday 24 March 2008

Rails 2 — validates_format_of

To validate a CNAME or nil field in a Ruby on Rails model, you can use validates_format_of method this way :

validates_format_of :cname,
  :with => /^[a-z][a-z0-9\-]*$/i,
  :if => Proc.new {|model| model.cname.to_s != ""}

In Rails 2.0 version, you can use now :

validates_format_of :cname,
  :with => /^[a-z][a-z0-9\-]*$/i,
  :allow_blank => true

Wednesday 05 March 2008

AppJet : Hosted Javascript application

AppJet, a new hosted web framework solution, is impressive and innovative. Using javascript as server-side application, it’s fast and free, with a quick very "getting started".
This will comptete against the actual boss, Heroku, the hosted ruby on rails IDE.

Rack : the Ruby framework/server interface

As a new line in the ruby history book, Rack interface servers with ruby web frameworks. Sounds like the new ruby WSGI no ? Just take a look.