Skip to content

Instantly share code, notes, and snippets.

get '/cats' do
@cats = Cat.all
erb :index
end
get '/cats/:id' do
@cat = Cat.find(params[:id])
erb :show
end
<h1>Items Page</h1>
<% if @errors %>
<p><%= @errors %></p>
<% end %>
<form id='new-item-form' method='post' action='/items'>
<input type='text' name='name' placeholder='name'/>
<input type='text' name='price' placeholder='price'/>
<input type='text' name='description' placeholder='description'/>
@data-doge
data-doge / controller_snippet.rb
Created May 7, 2015 07:50
filtered_query_params
def index
query_params = Rack::Utils.parse_nested_query request.env["QUERY_STRING"]
@filtered_cats = Cat.where(query_params)
end
function Cell () {
this.alive = Math.random() > 0.8;
this.neighbors = 0;
}
function Conway (size) {
this.size = size;
this.grid = this.generateGrid();
this.directions = [ [-1,-1], [-1, 0], [-1, 1], [ 0,-1], [ 0, 1], [ 1,-1], [ 1, 0], [ 1, 1] ];
}
@data-doge
data-doge / gist:20245adab81ef612691a
Created May 12, 2015 03:34
ways to create objects in js
// object literal notation
var eugene = {
name : 'eugene',
age : 22,
meow: function () {
console.log("meow");
}
};
console.log(eugene);
@data-doge
data-doge / application.js
Last active August 29, 2015 14:21
jon - refactor example
function CustomerView (search_customers_container, show_customers_container, new_customer_container) {
this.search_customers_container = search_customers_container;
this.show_customers_container = show_customers_container;
this.new_customer_container = new_customer_container;
}
CustomerView.prototype.showCustomers = function(customers) {
this.show_customers_container.html("<h3>Customer List: </h3>");
customers.forEach(this.showCustomer.bind(this));
};
FactoryGirl.define do
factory :cat do
name Faker::Name.name
life_story Faker::Lorem.paragraph
image_url Faker::Avatar.image
factory :cat_with_1_life do
lives 1
@data-doge
data-doge / cat.rb
Last active August 29, 2015 14:21
meowtown skeleton
class Cat < ActiveRecord::Base
validates :name, presence: true
validates :life_story, presence: true
validates :image_url, presence: true
def lose_a_life!
if self.lives > 1
self.lives -= 1
self.save

welcome to cobudget page

- your email address and name, 
	- create token, set user to admin

creating a cobudget flow

cobudget:

- explanation of a cobudget -- it is a budgetting process involving multiple people
- do you want to give this round an easy to remember title? 
- Who is involved in this round? What are their names and email addresses? How much money do they each have to contribute?
$cipher = {1000 => "M", 900 => "CM", 500 => "D", 400 => "CD", 100 => "C", 90 => "XC", 50 => "L", 40 => "XL", 10 => "X", 9 => "IX", 5 => "V", 4 => "IV", 1 => "I"}
def to_roman(number)
roman_numeral = ""
$cipher.each do |arabic, roman|
count = number / arabic
roman_numeral += roman * count
number -= arabic * count
end
roman_numeral