Skip to content

Instantly share code, notes, and snippets.

View Farzy's full-sized avatar

Farzad FARID Farzy

View GitHub Profile
0:14 [farzy:pts/0] karma% time ruby fib.rb
ruby fib.rb 2,42s user 0,30s system 98% cpu 2,757 total
[/tmp]
0:14 [farzy:pts/0] karma% time ruby1.9 fib.rb
ruby1.9: unknown encoding name: None (ArgumentError)
ruby1.9 fib.rb 0,02s user 0,01s system 5% cpu 0,509 total
#!/usr/bin/env ruby
#
# Author: Vitalie Lazu <[email protected]>
# Date: Sat, 10 Jan 2009 19:12:43 +0200
#
# CLI ruby client for Tracks: rails application for GTD methodology
# http://www.getontracks.org/development/
# You need to set ENV['GTD_LOGIN'], ENV['GTD_PASSWORD']
@Farzy
Farzy / gist:46399
Created January 13, 2009 10:47
Postfix catchall domain
We couldn’t find that file to show.
@Farzy
Farzy / sort-noaccent.rb
Created January 22, 2009 20:16
Sort strings while handling accentuated characters correctly
#!/usr/bin/ruby -w
# -*- coding: None -*-
# vim: sw=2 sts=2:
# Tri sans accents
$KCODE = 'u'
class String
def no_accent
@Farzy
Farzy / clean-data.rb
Created January 23, 2009 10:27
Ruby for system administration
# Small example of the use of Ruby for system administration
# This sample script does the following:
# - Read a text file, "data.in". This is our main data
# - Read a list of data patterns, one per line. Each line is just a word or a sentence.
# - Suppress each line of the input file that contains one of the patterns
# - Output to "data.out"
# Version 1: simple syntax without blocks. But the opened files have to be
# closed manually if necessary.
# Read file as an array of lines
@Farzy
Farzy / ruby1.8-hash.rb
Created February 5, 2009 23:03
Comparing Ruby 1.8 and Ruby 1.9's hash ordering
% irb1.8
>> h = Hash.new
=> {}
>> 10.times { |i| h[i] = i*10 }
=> 10
>> h
=> {5=>50, 0=>0, 6=>60, 1=>10, 7=>70, 2=>20, 8=>80, 3=>30, 9=>90, 4=>40}
We couldn’t find that file to show.
@Farzy
Farzy / gist:76392
Created March 9, 2009 17:44
rsyslog: Give Cyrus Imap its own logfile
We couldn’t find that file to show.
@Farzy
Farzy / Rakefile
Created March 10, 2009 09:00
Example of YAML config file in a Ruby admin script
#
# Rakefile de contrôle de la migration LDAP / IMAP
#
# Date : 2009-01-13
#
# Copyright (C) 2009 Farzad FARID <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
@Farzy
Farzy / gist:79035
Created March 14, 2009 10:17
Configuration 3G+ Bouygues Telecom
We couldn’t find that file to show.