Skip to content

Instantly share code, notes, and snippets.

@flakyfilibuster
flakyfilibuster / Coup d'etat
Created November 5, 2012 00:49
Congress Database 1: From CSV to SQLite with Ruby
update politicians set name='Sen. Shereef Bishay' where id=422;
@flakyfilibuster
flakyfilibuster / one_to_one_schema_design.xml
Created November 1, 2012 03:56
Solution for One to One Schema Design
<?xml version="1.0" encoding="utf-8" ?>
<!-- SQL XML created by WWW SQL Designer, http://code.google.com/p/wwwsqldesigner/ -->
<!-- Active URL: http://socrates.devbootcamp.com/sql.html -->
<sql>
<datatypes db="mysql">
<group label="Numeric" color="rgb(238,238,170)">
<type label="Integer" length="0" sql="INTEGER" re="INT" quote=""/>
<type label="Decimal" length="1" sql="DECIMAL" re="DEC" quote=""/>
<type label="Single precision" length="0" sql="FLOAT" quote=""/>
<type label="Double precision" length="0" sql="DOUBLE" re="DOUBLE" quote=""/>
@flakyfilibuster
flakyfilibuster / todos.xml
Created October 29, 2012 06:47
Solution for Todo Schema Design
<?xml version="1.0" encoding="utf-8" ?>
<!-- SQL XML created by WWW SQL Designer, http://code.google.com/p/wwwsqldesigner/ -->
<!-- Active URL: http://socrates.devbootcamp.com/sql.html -->
<sql>
<datatypes db="mysql">
<group label="Numeric" color="rgb(238,238,170)">
<type label="Integer" length="0" sql="INTEGER" re="INT" quote=""/>
<type label="Decimal" length="1" sql="DECIMAL" re="DEC" quote=""/>
<type label="Single precision" length="0" sql="FLOAT" quote=""/>
<type label="Double precision" length="0" sql="DOUBLE" re="DOUBLE" quote=""/>
@flakyfilibuster
flakyfilibuster / Add_support_for_multiple_users.xml
Created October 29, 2012 06:41
Solution for One To Many Schema Design
<?xml version="1.0" encoding="utf-8" ?>
<!-- SQL XML created by WWW SQL Designer, http://code.google.com/p/wwwsqldesigner/ -->
<!-- Active URL: http://socrates.devbootcamp.com/sql.html -->
<sql>
<datatypes db="mysql">
<group label="Numeric" color="rgb(238,238,170)">
<type label="Integer" length="0" sql="INTEGER" re="INT" quote=""/>
<type label="Decimal" length="1" sql="DECIMAL" re="DEC" quote=""/>
<type label="Single precision" length="0" sql="FLOAT" quote=""/>
<type label="Double precision" length="0" sql="DOUBLE" re="DOUBLE" quote=""/>
@flakyfilibuster
flakyfilibuster / image_converter.rb
Created October 26, 2012 07:05
image_converter & caption!
require 'RMagick'
include Magick
def image_reformatting(input_image)
img = Magick::Image.read(input_image)[0]
img.format = "png"
img.write("format.png")
text = Draw.new
class Hospital
attr_reader :name, :location, :employees, :patients, :admins
def initialize(name, location)
@name, @location, @employees, @patients, @admins = name, location, [], [], []
end
end
@flakyfilibuster
flakyfilibuster / switcharoo_test.rb
Created October 25, 2012 03:12
switcharoo_test
# run with: ruby switcharoo_test.rb
require 'minitest/autorun'
def switcharoo(string, switch_point, delimiter=false)
if switch_point < 0
raise "switch_point too small"
elsif switch_point > string.size
raise "switch_point too big"
end
@flakyfilibuster
flakyfilibuster / option_parser.rb
Created October 22, 2012 18:55
OptionParser Example
require 'optparse'
options = {date: false, sort: false, ddate: false, tag: false, prio: false}
optparse = OptionParser.new do|opts|
opts.on("--date") do
options[:date] = true
end
opts.on('--sort') do
@flakyfilibuster
flakyfilibuster / todo.rb
Created October 21, 2012 22:17
Todo app
require 'yaml'
class TodoList < Hash
def initialize(file_name)
@file_name = file_name
File.open( @file_name, 'w' ) { |file| YAML.dump( self, file )}
end
@flakyfilibuster
flakyfilibuster / hospital.rb
Created October 19, 2012 02:58
hospital app
class Hospital
attr_accessor :name, :employees, :patients
def initialize(name, location)
@name, @location, @employees, @patients = name, location, [], []
end
end