Skip to content

Instantly share code, notes, and snippets.

test
> git
git, the filemanager with GNU Interactive Tools, is now called gitfm.
If you are looking for git, Linus Torvald's content tracker, install
the cogito and git-core packages and see README.Debian and git(7).
This transition script will be removed in the debian stable
release after etch.
#!/bin/env ruby
require 'rubygems'
require 'activerecord'
# require 'activesupport'
require 'pp'
require 'logger'
ActiveRecord::Base.establish_connection(
:adapter => "mysql",
def name_to_path
polish = Hash.new
polish["ą"] = "a"
polish["ć"] = "c"
polish["ę"] = "e"
polish["ł"] = "l"
polish["ń"] = "n"
polish["ó"] = "o"
polish["ś"] = "s"
polish["ż"] = "z"
class AddImgToPortfolios < ActiveRecord::Migration
def self.up
add_column :portfolios, :img_file_name, :string
add_column :portfolios, :img_content_type, :string
add_column :portfolios, :img_file_size, :integer
add_column :portfolios, :img_updated_at, :datetime
end
def self.down
remove_column :portfolios, :img_file_name
$single_types_available = { 1 => "2", "oki" => 'dupa'};
my ($x,undef) = keys %{$single_types_available};
print "X: $x\n"
oki@nil ~/ruby/ruby_1_9 (svn::trunk/) $ svn info
Path: .
URL: http://svn.ruby-lang.org/repos/ruby/trunk
Repository Root: http://svn.ruby-lang.org/repos/ruby
Repository UUID: b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Revision: 20387
Node Kind: directory
Schedule: normal
Last Changed Author: matz
Last Changed Rev: 20387
#!/usr/bin/env ruby
# sir, avi
ARGV[0] || (puts "Use ./#{$0} dir"; exit 0)
n = 0
Dir[ARGV[0]+'/*'].sort_by { |f|
File.stat(f).mtime
}.each { |f| `mv #{f} #{f.gsub(/([^\/])+$/, ('%03d.avi' % n=n+1))}` }
require 'rexml/document'
xml = REXML::Document.new(File.open("list.xml"))
puts xml.elements.to_a("//entry").size
>> a = [1,2,3]
=> [1, 2, 3]
>> b = %w(a b c)
=> ["a", "b", "c"]
>> x = [a,b]
=> [[1, 2, 3], ["a", "b", "c"]]
>> x.transpose
=> [[1, "a"], [2, "b"], [3, "c"]]
>>