Donnerstag, 31. Mai 2007

Is extreme-programming extreme?

Here is a nice song from the extreme programming japan user group(xpjug) which answeres the question:

Labels: , , , ,

Samstag, 26. Mai 2007

Aha nice - Firebug Console API

The nice Firebug-Console-API api allows us to control the firebug output console and more direct from scripts.

Read more:
Debugging with Firebug an article by Andrew Dupont.

Firebug - Web Development Evolved

Labels: , ,

Donnerstag, 24. Mai 2007

Deploying with capistrano - The copy method

Capistrano is a great tool for automating tasks on remote machines. In this article i will show you howto update a static webpage where the server has no svn installed. The only things you need are: a local ruby, rubygems and capistrano installation and ssh access to the remote webserver where the files should deployed to.
You need capistrano 2.0 or 2.0 preview, install the preview with:
gem install net-ssh
gem install net-sftp
gem install highline
gem install -s http://gems.rubyonrails.com capistrano
Similar to make's Makefile's capistrano uses Capfile's. To create a Capfile in the current directory execute:
capify .
Now you can edit the Capfile to fit your deployment needs:
require 'capistrano/version'
# Load the deployment recipe
load 'deploy'
# Give a name for your application
set :application, :website
# Define a server role
role :server, 'yourhomepage.com'
# Define where to store the deployed files
set :deploy_to, '/hp/aa/ab/ne'
# Define where to create the symlink to the current release, normally
# this would be your htdocs or www directory
set :current_path, '/hp/aa/ab/ne/www'
# Define that we want to deploy via copy, this is usefull if your server
# has no subversion client installed
set :deploy_via, 'copy'
# Set the deploy strategy to export, otherwise the files are checked out
# from your repository
set :copy_strategy, :export
# Set your ssh user name and password
# (If you omit the password and did not have setup public key authentication,
# capistrano will prompt you for the password)
set :user, 'your-ssh-username'
set :password, your-ssh-password'
# Set the project repository. All files inside the specified directory
# will deployed.
set :repository, 'file:///repositories/website/public'

# Override tasks not needed for deployment of static files
namespace :deploy do
task :finalize_update do
logger.info 'do nothing - overridden finalize_update'
end
task :restart do
logger.info 'do nothing - overridden finalize_update'
end
end
Thats it, now you can setup your host for deployment with(First you need to go into the directory where your Capfile is stored):
cap deploy:setup
And deploy with:
cap deploy
You will find many default setting in: lib/capistrano/recipes/deploy.rb.

Labels: , ,

Montag, 21. Mai 2007

Ressourcen schonende Backuplösung

Die "Heinlein - Professional Linux Support GmbH" stellt eine Backuplösung vor, welche die Möglichkeiten von rsync, hardlinks und ssh voll ausschöpft. Ich verwende diese Lösung nun seit einigen Wochen und bin sehr zufrieden damit. Die Backups laufen schnell und belasten nicht das Netzwerk.
Hier ein Auszug aus dem Artikel:
  • Stabiler täglicher Betrieb ohne Wartungsarbeiten
  • Komprimierter Transfer der Daten im Netzwerk
  • Bandbreitenlimitierung des Backup-Prozesses
  • Sicherer Transfer der Daten – ssh-verschlüsselt
  • Snapshot des gebackupten Systems, Rekonstruktion eines bestimmten Zustandes vor n-Tagen möglich
  • Bequemes Backup auf einfachen Festplatten, ohne teuren Tape-Roboter oder teure Bandlaufwerke. Große Datenmengen möglich.
  • Schnelles Zurückspielen der Daten in Festplattengeschwindigkeit möglich (schneller als Bandlaufwerke)

Labels: , ,

Samstag, 19. Mai 2007

Testing with Rails

Jay Fields has labeled all his great posts about rails testing with: "RailsConf2007". Now we can find all relevant posts more easily. Thanks.
Source: http://blog.jayfields.com/2007/05/railsconf07-testing-presentation.html

Labels: , , ,

Mittwoch, 16. Mai 2007

The new Art of Flamewar

Please take the following not to serious. Flamewar can pull your energy off. I think the best thing we can do is respect other people independent from the technologies they are using. Sometimes it is hard to talk to people when they want to argue you into something. Encounter them with acceptance for there opinion. Do not try argue them into something. Instead explain your opinion only if they really want to know your opinion. Just my two cent.
Rails vs. Java


Rails vs. PHP



Source: http://www.railsenvy.com/

Labels: , ,

Samstag, 12. Mai 2007

Backup one file

I found my self often doing something like that:
sudo cp /boot/grub/menu.lst /boot/grub/menu.lst_bu_2007-05-12_13-20
With the following script all we need to do is:
sudo backup-one-file /boot/grub/menu.lst
And the result is a backup created in /boot/grub/menu.lst_bu_2007-05-12_13-21-30
#!/usr/bin/env ruby

require 'fileutils'

if ARGV.empty?
puts "Usage: backup-one-file <file-name>"
exit
end

source = ARGV[0]

unless File.exist?(source)
puts "Error: File #{source} does not exist!"
exit
end

target = source + "_bu_" + Time.now.strftime("%Y-%m-%d_%H-%M-%S")

begin
FileUtils.cp(source, target)
rescue Exception => e
puts "Could not copy to #{target}"
puts e.message
puts "Maybe you need to run as root!"
else
puts "Backup created in: #{target}"
end

Labels: , ,

Mittwoch, 9. Mai 2007

ri and ri_proxy

Yesterday i have written a little caching proxy script for ri. The script forwards any invocation to ri. The results are cached in a sqlite3 database. So that any subsequent calls are much faster, not fast as i wished but definitely faster.
#!/usr/bin/env ruby

require 'rubygems'

ROOT = File.dirname(__FILE__)
BASE_NAME = File.basename(__FILE__)

DB_FILE = File.join(ROOT, BASE_NAME + '.sqlite3')
DB_CONFIG = {:adapter => 'sqlite3', :timeout => 5000, :database => DB_FILE}

LOG_FILE = File.join(ROOT, BASE_NAME + '.log')

# speed up active record loading a bit
require 'active_support'
RAILS_CONNECTION_ADAPTERS = ['sqlite']

require 'active_record'
ActiveRecord::Base.logger = nil # Logger.new(LOG_FILE)
ActiveRecord::Base.establish_connection(DB_CONFIG)

class RiMethodEntry < ActiveRecord::Base
end

force = false
if !RiMethodEntry.table_exists? or force
ActiveRecord::Schema.define(:version => 1) do
create_table :ri_method_entries, :force => true do |t|
t.column :name, :string, :null => false
t.column :text, :text, :null => false
end
add_index :ri_method_entries, :name
end
end

ARGV.length > 0 or raise Exception.new("No arguments found!")
name = ARGV[0]
entry = RiMethodEntry.find_by_name(name)
if entry
puts entry.text
exit
end

args = ARGV.collect { |a| %{"#{a}"} }
text = `ri #{args.join(" ")}`
found = text.starts_with?('-')

puts text
exit unless found

RiMethodEntry.create(:name => name, :text => text)

Labels: , , ,

Donnerstag, 3. Mai 2007

Install ruby on debian sytems the apt way

If you want to install ruby through apt you normally get only the interpreter. If you want to install ruby with all it's tools, you need to take a look into the package description to find out what is missing.
apt-cache show ruby1.8
The output should be similar to the following:
Package: ruby1.8
Priority: optional
Section: interpreters
Installed-Size: 296
Maintainer: Ubuntu Core Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: akira yamada <akira@debian.org>
Architecture: i386
Version: 1.8.5-4ubuntu2
Depends: libc6 (>= 2.5-0ubuntu1), libruby1.8 (>= 1.8.5)
Suggests: ruby1.8-examples, rdoc1.8, ri1.8
Filename: pool/main/r/ruby1.8/ruby1.8_1.8.5-4ubuntu2_i386.deb
Size: 217212
MD5sum: d2cedcce835b84af193332a413344b89
SHA1: 40c93e9a5df7ea9ed2567f6c8d843282c69a800a
SHA256: 7e756450dbdc504f94f67d936594c28d48923557fb7d4c32d6e9bfe147123729
Description: Interpreter of object-oriented scripting language Ruby 1.8
Ruby is the interpreted scripting language for quick and easy
object-oriented programming. It has many features to process text
files and to do system management tasks (as in perl). It is simple,
straight-forward, and extensible.
.
This package provides version 1.8 series of Ruby.
.
On Debian, Ruby 1.8 is provided as separate packages. You can get
full Ruby 1.8 distribution by installing following packages.
.
ruby1.8 ruby1.8-dev ri1.8 rdoc1.8 irb1.8 ruby1.8-elisp
ruby1.8-examples libdbm-ruby1.8 libgdbm-ruby1.8 libtcltk-ruby1.8
libopenssl-ruby1.8 libreadline-ruby1.8
Bugs: mailto:ubuntu-users@lists.ubuntu.com
Origin: Ubuntu
Task: kubuntu-desktop
As you can see the full install of ruby and it's tools would be:
sudo apt-get install ruby1.8 ruby1.8-dev ri1.8 rdoc1.8 irb1.8 \
ruby1.8-elisp ruby1.8-examples libdbm-ruby1.8 libgdbm-ruby1.8 \
libtcltk-ruby1.8 libopenssl-ruby1.8 libreadline-ruby1.8
So far so good. Maybe you need to add the the universe repositories to your /etc/apt/sources.list to install all the packages.
It would be nice if debian could provide a meta-package for those people who want all the ruby tools anyway.

Labels: ,

Mittwoch, 2. Mai 2007

Installing ruby on rails on ubuntu 6.06 LTS by compiling nearly anything

#!/bin/sh

sudo apt-get install build-essential

cd /tmp

# download
wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6.tar.bz2
wget http://rubyforge.org/frs/download.php/17190/rubygems-0.9.2.tgz
wget http://www.zlib.net/zlib-1.2.3.tar.gz
wget http://www.sqlite.org/sqlite-3.3.17.tar.gz

# unpack
tar xf ruby-1.8.6.tar.bz2
tar xf rubygems-0.9.2.tgz
tar xf zlib-1.2.3.tar.gz
tar xf sqlite-3.3.17.tar.gz

# install
sudo apt-get install libreadline5 libreadline5-dev

cd /tmp/sqlite-3.3.17 &&amp; ./configure && make && sudo make install
cd /tmp/zlib-1.2.3 &&amp; ./configure && make && sudo make install
cd /tmp/ruby-1.8.6 &&amp; ./configure && make && sudo make install

cd /tmp/rubygems-0.9.2 && sudo ruby setup.rb
sudo gem install sqlite3-ruby -y
sudo gem install rails -y
sudo gem install mongrel -y

# create a rails test application
cd /tmp
rails rails_test --database=sqlite3
cd rails_test/
./script/generate model user name:string
rake db:migrate
./script/generate scaffold user
./script/server
If you need more you can look at the great deprec tools.
Update: A colleague told me to use "checkinstall". So we will not bypass the package management. Good point.

Labels: , ,