This file contains 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 HasStates | |
def state_field(column, state_names) | |
state_names.each do |name| | |
define_method("#{name}?") do | |
self.send(column) == name | |
end | |
end | |
end | |
end |
This file contains 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
dog(rover). | |
dog(felix). | |
dog(benny). | |
has_owner(rover). | |
has_owner(benny). | |
is_happy(Dog) :- has_owner(Dog). | |
is_happy(Dog) :- breed(Dog, poodle). |
This file contains 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 QueueItem = { | |
filename: string | |
resolve: () => void | |
originalValue: any | |
stubValue: any | |
} | |
type Stub = { | |
queue: QueueItem[] | |
filename: string | |
originalValue: any |
This file contains 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 Showcase extends React.Component { | |
constructor(props) { | |
super(props) | |
this.state = { ... } | |
} | |
toggle() { | |
this.setState({ open: ! this.state.open }) | |
} | |
render() { | |
var {open, loading} = this.state |
This file contains 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
/* | |
Create this as a file ~/Library/KeyBindings/DefaultKeyBinding.dict | |
Then restart your computer. | |
NOTE: ~ means alt/option | |
^ means ctrl | |
*/ | |
{ | |
"~f"="moveWordForward:"; | |
"~b"="moveWordBackward:"; | |
"~<"="moveToBeginningOfDocument:"; |
This file contains 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
// | |
// Our main data fetching tool. | |
// This fetches an object of promise makers ONLY ON THE CLIENT SIDE, | |
// and manages loading and data states for each key. | |
// | |
import React from 'react' | |
import http from './http' | |
export default (promisesMakers, options={}) => Component => | |
class FetchHOC extends React.Component { |
This file contains 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 inc = (x) => x + 1; | |
var double = (x) => x * 2; | |
var x = 10 |> inc |> double; | |
var y = 10 |> inc; |
This file contains 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
Configuring for host x86_64-apple-darwin16.6.0 ... | |
Configuring for target x86_64-apple-darwin16.6.0 ... | |
Using compiler gcc. | |
The C compiler is ANSI-compliant. | |
Checking the sizes of integers and pointers... | |
Wow! A 64 bit architecture! | |
This is a little-endian architecture. | |
Doubles can be word-aligned. | |
64-bit integers can be word-aligned. | |
Native division and modulus have round-towards-zero semantics, will use them. |
This file contains 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
<!doctype html><title>Minimal Mithril</title> | |
<div id="app"></div> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/mithril/1.0.1/mithril.min.js"></script> | |
<script> | |
var AppComponent = { | |
view: function (vnode) { | |
return m('h1', "Hello World!") |
NewerOlder