Skip to content

Instantly share code, notes, and snippets.

require 'find'
require 'fileutils'
dir = '/your_directory'
Find.find(dir) do |path|
if FileTest.directory?(path) && File.basename(path) == '.svn'
p 'rm directory:' + path
FileUtils.remove_dir(path)
else
def custom_link_to(post)
"<a href='/blog/#{post.datetime.year}/#{post.datetime.month}/#{post.datetime.day}/#{post.slug}'>post.title</a>"
end
#routes
"/blog/:year", :controller => 'posts', :action => 'posts_for_year'
#controller actions
# Critical default settings:
disable_system_gems
disable_rubygems
bundle_path ".gems/bundler_gems"
# List gems to bundle here:
gem "rails", "3.0.pre", :git => "git://github.com/rails/rails.git"
gem "arel", :git => "git://github.com/rails/arel.git"
gem "i18n"
gem "dm-appengine"
# Critical default settings:
disable_system_gems
disable_rubygems
bundle_path ".gems/bundler_gems"
# List gems to bundle here:
gem "rails", "3.0.pre", :git => "git://github.com/rails/rails.git"
gem "arel", :git => "git://github.com/rails/arel.git"
gem "i18n"
gem "dm-appengine"
# Critical default settings:
disable_system_gems
disable_rubygems
bundle_path ".gems/bundler_gems"
# List gems to bundle here:
gem "rails", "3.0.pre", :git => "git://github.com/rails/rails.git"
gem "arel", :git => "git://github.com/rails/arel.git"
gem "i18n"
gem "dm-appengine"
#!/usr/bin/env ruby
# -*- ruby -*-
require 'rubygems'
require 'daemon-spawn'
RAILS_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
class DelayedJobWorker < DaemonSpawn::Base
def start(args)
ENV['RAILS_ENV'] ||= args.first || 'development'
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
@rociiu
rociiu / dramerr.c
Created February 6, 2010 01:21 — forked from antirez/dramerr.c
/* The following is a simple program to check for memory corrections in
* DRAM with ECC switched off. Accordingly to recend large scale studies
* such as http://www.cs.toronto.edu/~bianca/papers/sigmetrics09.pdf
* the error rate is of 25,000-75,000 errors per billion hours per Mbit.
*
* If this is true you should see at least one error after a few days
* running this program at max in a computer without ECC.
*
* Compile with: gcc -O2 -Wall -W -o dramerr dramerr.c
*
# Run rake db:size to get a print of your database size in bytes.
# Run rake db:tables:size to get the sizes for individual tables
# Works for MySQL and PostgreSQL. Not tested elsewhere.
namespace :db do
desc 'Print data size for entire database'
task :size => :environment do
database_name = ActiveRecord::Base.connection.instance_variable_get("@config")[:database]
adapter = ActiveRecord::Base.connection.adapter_name.downcase
# Newbie Programmer
def factorial(x)
if x == 0
return 1
else
return x * factorial(x - 1)
end
end
puts factorial(6)
puts factorial(0)