This file contains hidden or 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
Step 1: Create the cheatsheet. |
This file contains hidden or 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
var itemTemplateSource = $('#templates .item').html() | |
var itemTemplate = _.template(itemTemplateSource); | |
var AddItemView = Backbone.View.extend({ | |
events: { | |
'submit': 'createItem' | |
}, | |
createItem: function (e) { | |
e.preventDefault(); | |
var itemName = this.$('.name').val(); |
This file contains hidden or 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 'deterministic' | |
class X | |
include Deterministic | |
def go | |
# The `>>` is from Deterministic. It feeds the result | |
# of the left side into the right side. | |
# get_num >> mcurry(:add, 1) >> mcurry(:double) |
This file contains hidden or 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 Book < ActiveRecord::Base | |
validates :name, :presence => true | |
validates :published_at, :presence => true | |
end |
This file contains hidden or 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
<h2>Create New Order</h2> | |
<% if @error %> | |
<p>Error: <%= @error %> </p> | |
<% end %> | |
<%= form_tag orders_path, :method => :post do %> | |
<!-- Our goal is to an array of item ids --> | |
<select class="item-select" name="order[item_ids][]"> |
This file contains hidden or 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
module Library do | |
record Author do | |
fields do | |
name :: String | |
end | |
name :: Book -> String | |
name { author: authorName } = authorName | |
end |
This file contains hidden or 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
var myData = [ | |
{ | |
week: 1, | |
count: 5 | |
}, | |
{ | |
week: 2, | |
count: 1 | |
}, | |
{ |
This file contains hidden or 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
// | |
// A model representing an Entry | |
// | |
window.Entry = {} | |
var store = [] | |
var idCounter = 1 | |
Entry.all = function () { | |
return store |
This file contains hidden or 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
// Partially apply arguments to a function. Useful for binding | |
// specific data to an event handler. | |
// Example: | |
// | |
// var add = function (x,y) { return x + y } | |
// var add5 = add.papp(5) | |
// add5(7) //=> 12 | |
// | |
Function.prototype.papp = function () { | |
var slice = Array.prototype.slice |
This file contains hidden or 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
# Hamming | |
Write a program that can calculate the Hamming difference between two DNA strands. | |
A mutation is simply a mistake that occurs during the creation or | |
copying of a nucleic acid, in particular DNA. Because nucleic acids are | |
vital to cellular functions, mutations tend to cause a ripple effect | |
throughout the cell. Although mutations are technically mistakes, a very | |
rare mutation may equip the cell with a beneficial attribute. In fact, | |
the macro effects of evolution are attributable by the accumulated |
OlderNewer