This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# This script is an adaptation from http://www.sqlite.org/cvstrac/wiki?p=ConverterTools | |
# It expects stdin input from mysqldump with the following params: | |
# mysqldump --skip-extended-insert --add-drop-table --compatible=ansi --skip-add-locks --skip-comments --skip-disable-keys --skip-set-charset | |
# Note: Don't use --skip-quote-names as this script expects quoted names | |
# | |
# Note: This script imports boolean values as they are stored in Mysql, e.g., as the integers 0 and 1. | |
# As a result, boolean fields need to be further normalized after this transform step | |
# such that false field values are 'f' and true field values are 't', which is |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rubygems" | |
require "rbench" | |
def noop | |
end | |
RBench.run(100_000) do | |
column :one, :title => "Unthreaded" | |
column :two, :title => "Threaded" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def valid?(card_number) | |
digits = card_number | |
.split("") | |
.map { |number| number.to_i } | |
numbers = [] | |
digits.each_with_index do |digit, index| | |
if index.even? | |
numbers << digit * 2 | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ rake test_mysql | |
(in /Users/erik/projects/rails/activerecord) | |
/opt/local/bin/ruby -I"lib:test:test/connections/native_mysql" "/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "test/cases/aaa_create_tables_test.rb" "test/cases/active_schema_test_mysql.rb" "test/cases/adapter_test.rb" "test/cases/aggregations_test.rb" "test/cases/ar_schema_test.rb" "test/cases/associations/belongs_to_associations_test.rb" "test/cases/associations/callbacks_test.rb" "test/cases/associations/cascaded_eager_loading_test.rb" "test/cases/associations/eager_load_includes_full_sti_class_test.rb" "test/cases/associations/eager_load_nested_include_test.rb" "test/cases/associations/eager_singularization_test.rb" "test/cases/associations/eager_test.rb" "test/cases/associations/extension_test.rb" "test/cases/associations/habtm_join_table_test.rb" "test/cases/associations/has_and_belongs_to_many_associations_test.rb" "test/cases/associations/has_many_associations_test.rb" "test/cases/associations/has_many_through_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'rbench' | |
require 'twitter' | |
class Bench | |
def self.setup | |
Twitter.configure do |config| | |
config.consumer_key = CONSUMER_KEY | |
config.consumer_secret = CONSUMER_SECRET | |
config.oauth_token = OAUTH_TOKEN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'fileutils' | |
require 'find' | |
usage_args = ['--usage', '--help', '-u', '-h'] | |
if ARGV.length.eql? 0 or ARGV.length.eql? 1 and usage_args.include? ARGV[0] | |
puts "Usage: #{__FILE__} string_to_strip [directory]" | |
exit 0 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rubygems" | |
require "rbench" | |
def single_quoted_string | |
'aaa' + 'bbb' | |
end | |
def double_quoted_string | |
"aaa" + "bbb" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'twitter' | |
user = "sferik" | |
query = /rimm/i | |
(1..16).each do |page| | |
Twitter.user_timeline(user, :page => page, :count => 200).each do |tweet| | |
puts tweet.id.to_s + ": " + tweet.text if query.match(tweet.text) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function for_each_ruby { | |
for ruby in `rvm list strings` | |
do | |
echo "rvm use $ruby; $1;" | |
done | |
} | |
default_gems=`cat ~/.rvm/gemsets/default.gems | tr '\n' ' '` | |
alias install_default_gems=`for_each_ruby "yes | gem install $default_gems"` | |
alias update_all_gems=`for_each_ruby "yes | gem update; yes | gem cleanup"` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class StatusesController < ApplicationController | |
before_filter :authenticate | |
def create | |
@tweet = Twitter.update(params[:text]) | |
end | |
private | |
def authenticate |