I hereby claim:
- I am mthomas on github.
- I am mbthomas (https://keybase.io/mbthomas) on keybase.
- I have a public key whose fingerprint is E4C0 9C84 99DC 5074 BF1D 4DC9 9626 DBC2 6248 BC3B
To claim this, I am signing this object:
#!/bin/bash | |
set -o errexit | |
set -o pipefail | |
pids="" | |
RESULT=0 | |
(sleep 1; echo 'a'; exit 1) & | |
pids="$pids $!" |
I hereby claim:
To claim this, I am signing this object:
#csharp | |
(new[]{1,2,3,4}).Where( i => i % 2 == 0 ); | |
#ruby | |
[1,2,3,4].select{ |x| x.even? } | |
#python | |
[x for x in [1,2,3,4] if not x%2] | |
#or, more norvingly | |
filter(lambda x: not x%2, [1,2,3,4]) |
<h1>Sign In</h1> | |
<%= form_for(:session, :url => sessions_path) do |f| %> | |
<div class="field"> | |
<%= f.label :email %> | |
<%= f.text_field :email %> | |
</div> | |
<div class="field"> | |
<%= f.label :password %> | |
<%= f.password_field :password %> |
resources :sessions | |
match '/sigin', :to => 'sessions#new' | |
match '/signout', :to => 'sessions#destroy' |
class SessionsController < ApplicationController | |
before_filter :require_no_user, :only => [:new, :create] | |
before_filter :require_user, :only => :destroy | |
def new | |
end | |
def create | |
authenticate! | |
class ApplicationController < ActionController::Base | |
helper :all # include all helpers, all the time | |
protect_from_forgery # See ActionController::RequestForgeryProtection for details | |
private | |
def require_user | |
unless current_user | |
flash[:notice] = "You must be logged in to access that page" | |
redirect_to new_session_url | |
return false |
Rails.configuration.middleware.use RailsWarden::Manager do |manager| | |
manager.default_strategies :password | |
manager.failure_app = SessionsController | |
end | |
# Setup Session Serialization | |
class Warden::SessionSerializer | |
def serialize(user) | |
user.id | |
end |
var names = Array("Mike, Bob, John"); | |
var itemNames = Array(...); | |
var itemSuffixes = Array(...); | |
var users = names.Each(name => CreateUser(name + "@demo.company.com", "password")); | |
var items = 100.Times(i => CreateItem(Pick(itemNames), Pick(itemSuffixes), RandomPrice())); | |
var transactions = 50.Times(i => PurchaseItem(Pick(users), Pick(items))); |
public static class DemoExtensions{ | |
public static T Pick<T>(this IEnumerable<T> items){ | |
/*return random element out of items*/ | |
} | |
public static T Take<T>(this IList<T> items){ | |
/*thread safe: return random element out of items and remove it*/ | |
} | |
public static IList<T> Times<T>(this int x, Func<int, T> action){ |