Skip to content

Instantly share code, notes, and snippets.

@rurabe
rurabe / no_in_words.rb
Created June 13, 2012 07:37
This module adds the method 'in_words' which describes an integer in english.
module InWords
def in_words
numerals = ["","one","two","three","four","five","six","seven","eight","nine"]
tens = ["","ten","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"]
teens = %w(ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen)
powers = [""," thousand"," million"," billion"," trillion"," quadrillion"," quintillion"," sextillion"," septillion"," octillion"," nonillion"," decillion"," undecillion"," duodecillion"," tredecillion"," quattuordecillion"," quindecillion"," sexdecillion"," septendecillion"," octodecillian"," novemdecillion"," vigintillion"]
result = []
counter = 0
negative = false
@rurabe
rurabe / rack_city.rb
Created June 13, 2012 08:17
Rack City
when 1010102050
"Rack City bitch, Rack Rack City bitch."
@rurabe
rurabe / event_manager.rb
Created June 19, 2012 07:00
Event Manager
# Dependencies
require "csv"
require 'sunlight'
# Class Definition
class EventManager
INVALID_ZIPCODE = "00000"
INVALID_PHONE_NUMBER = "0000000000"
@rurabe
rurabe / todo.rb
Created June 21, 2012 22:39
To Do
class Task
attr_accessor :unique_id, :description, :creation_time, :completion_time
def initialize(description,task_list)
@description = description
@unique_id = task_list.task_counter
@creation_time = Time.now
@completion_time = nil
task_list.add(self)
@rurabe
rurabe / sql_students.xml
Created July 3, 2012 18:10
SQL Exercises - Students
<?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=""/>
@rurabe
rurabe / baseline_survey.json
Created July 16, 2012 02:13 — forked from gchow/baseline_survey.json
Goldie's Pile of Fun
{
"survey_id": 1,
"title": "Baseline Survey (Draft)",
"introduction": "Thank you for taking the time to participate in this survey of SamaHub workers. The purpose of this survey is to better understand the background and demographics of our workers in order to continue to deliver the best work opportunities through the SamaHub. \n\nThere are no ‘wrong’ answers and all information collected will be strictly private and anonymous at the individual level. The survey is comprised of a total of 55 short questions and will take approximately 25 minutes to complete. \n\nSamaHub workers will be surveyed regularly (1-2 times a year) through the SamaHub; additionally, with the permission of the respondent, a selection of SamaHub workers may also be contacted in-person or via telephone for questions.",
"sections": [
{
"section_id": "A",
"title": "Part A: Basic Information",
"questions": [
{
@rurabe
rurabe / ar-tutor.html
Created July 19, 2012 01:31
ActiveRecord Tutor Partial Template
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>AR Tutor Example</title>
<meta name="description" content="Example tabable nav with Twitter Bootstrap">
<link href="./bootstrap.css" rel="stylesheet">
<style type="text/css">
textarea {
font-family: "Monaco",monospace
<!DOCTYPE html>
<html lang='en'>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<meta charset="UTF-8">
<style>
.cell{
width:50px ;
height:50px;
padding: 0px;
@rurabe
rurabe / product.rb
Created July 25, 2012 18:57
#DBC AcitveRecord Validation Practice
class Product < ActiveRecord::Base
attr_accessible :description, :imageurl, :price, :size, :title
validates_presence_of :title, :price, :description, :imageurl, :size
validates :title, :length => { :maximum => 50 }, :uniqueness => { :case_sensitive => false }
validates :description, :length => { :maximum => 250 }
validates :price, :format => { :with => /[\d\,]*\.\d{2}$/ }
validates :imageurl, :format => { :with => /#{URI::regexp}\.(jpg|png|gif)$/i }
validates :size, :inclusion => { :in => %w(small medium large) }
end
@rurabe
rurabe / report_locations.js
Last active August 29, 2015 14:10
A jQuery extension that reports the locations of clicks in the SVG coordinate system
(function(){
var transform = function(el,pt){
return pt.matrixTransform( el.getScreenCTM().inverse() );
};
$.fn.extend({
reportLocations : function(callback){
var $this = this;
var svg = $this.closest('svg')[0];
var pt = svg.createSVGPoint();