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
type State = { ms: number, lightOn: boolean }; | |
const initialState = {ms: 0, lightOn: false}; | |
type Event = { type: 'TIME_PASSED'; ms: number }; | |
const reduce = (event: Event) => (state: State): State => ((newMs) => ((toggle) => toggle ? { | |
// ignore remaining time for simplicity | |
ms: 0, | |
lightOn: !state.lightOn | |
} : { | |
...state, |
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
``` | |
directive @cacheControl( | |
maxAge: Int | |
scope: CacheControlScope | |
) on FIELD_DEFINITION | OBJECT | INTERFACE | |
# A keystone list | |
type User { | |
# This virtual field will be resolved in one of the following ways (in this order): | |
# 1. Execution of 'labelResolver' set on the User List config, or | |
# 2. As an alias to the field set on 'labelField' in the User List config, or |
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 A = RouteController.extend({ | |
onBeforeAction: function() { | |
console.warn('A'); | |
this.next(); | |
} | |
}); | |
var B = A.extend({ | |
onBeforeAction: function() { | |
console.warn('B'); | |
this.next(); |
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
#!/usr/bin/env bash | |
apt-get -y update | |
apt-get -y install make build-essential zlib1g-dev libssl-dev libreadline5-dev libyaml-dev | |
cd /tmp | |
wget --no-clobber ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz | |
tar -xvzf ruby-1.9.3-p125.tar.gz | |
cd ruby-1.9.3-p125/ | |
./configure --prefix=/usr/local | |
make | |
make install |
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 ApplicationController < ActionController::Base | |
protect_from_forgery | |
def current_ability | |
@current_ability ||= Ability.new(current_member) | |
end | |
rescue_from CanCan::AccessDenied do |exception| | |
flash[:alert] = "Access Denied." | |
redirect_to root_url |
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 SessionsController < ApplicationController | |
def new | |
if member = Member.find_by_password_digest(cookies[:digest]) | |
session[:member_id] = member.id | |
redirect_to (session[:ref] || root_path), :notice => "Welcome back #{member.first_name}" | |
end | |
end | |
def create |
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>Log In</h2> | |
<%= form_tag sessions_path do %> | |
<div class="field"> | |
<%= label_tag :user_name %><br> | |
<%= text_field_tag :user_name, params['user_name'] %> | |
</div> | |
<p></p> | |
<div class="field"> | |
<%= label_tag :password %><br/> |