Skip to content

Instantly share code, notes, and snippets.

View kulte's full-sized avatar

Zachary Friedman kulte

View GitHub Profile
// Examples of pure functions. No side effects. No mutations.
function square(x) {
return x * x;
}
function squareAll(items) {
return items.map(square);
}
// Examples of impure functions.
@kulte
kulte / promise.js
Created December 13, 2013 21:46 — forked from wavded/promise.js
"use strict"
var Promise = function () {
this.state = 'pending'
this.thenables = []
}
Promise.prototype.resolve = function (value) {
if (this.state != 'pending') return
this.state = 'fulfilled'
@kulte
kulte / git-1.sh
Created September 18, 2013 23:22
git checkout bcee89a90aad3877da531d6cb10ca91c6155d577 -- app/assets/images/sales
factory :user do
email "bob.bobsen@gmail.com"
password "secret"
trait :with_comments do
after(:create) do |user, evaluator|
# FactoryGirl.create_list(factory, number_of_items, factory_attrs)
FactoryGirl.create_list(:comment, 1, user: user)
end
end
@kulte
kulte / indexOf-2.js
Last active December 22, 2015 18:19
var powerRankings = [
"49ers",
"Seahawks",
"Broncos"
];
var index = powerRankings.indexOf("Seahawks", 1);
var rank = index + 1;
var powerRankings = [
"49ers",
"Seahawks",
"Broncos"
];
var index = powerRankings.indexOf("Seahawks");
var rank = index + 1;
class MyApp::Interface::NavigationBar
include ActionView::Helpers::UrlHelper
delegate :url_helpers, to: 'Rails.application.routes'
def initialize(template, current_user)
@template = template
@current_user = current_user
end
class MyApp::Interface::NavigationBar
include ActionView::Helpers::UrlHelper
delegate :url_helpers, to: 'Rails.application.routes'
def initialize(template, current_user)
@template = template
@current_user = current_user
end
##
# Runs a single test with setup/teardown hooks.
def run
with_info_handler do
time_it do
capture_exceptions do
before_setup; setup; after_setup
self.send self.name
module ActionView
module Helpers
module FormHelper
def encrypted_text_field(object_name, method, options = {})
InstanceTag.new(object_name, method, self, options.delete(:object)).to_encrypted_input_field_tag("text", options)
end
class InstanceTag
def to_encrypted_input_field_tag(field_type, options = {})