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> | |
<head> | |
<link rel="stylesheet" type="text/css" href="line-numbers.css"> | |
</head> | |
<body> | |
<pre><code>function add (a, b) { | |
return a + b; | |
}</code></pre> |
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
var Comment = {] | |
Comment.create = function (attrs) { | |
return m.request({ method: 'POST', url: '/comments', data: attrs }) | |
} | |
// A view-model is basically a temporary, disposable copy of a model. | |
// It allows the user can either commit or cancel the changes they make. | |
Comment.vm = function (attrs) { | |
attrs = attrs || {} |
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
// | |
// A model representing an Entry | |
// | |
window.Entry = {} | |
var store = [] | |
var idCounter = 1 | |
Entry.all = function () { | |
return store |
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 Comment = {} | |
Comment.store = Store('Comment') | |
Comment.fetchForPost = function (postId) { | |
return m.request({ method: 'GET', url: '/api/post/' + postId + '/comments' }) | |
.then(Comment.store.syncAll) | |
} |
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
class Showcase extends React.Component { | |
constructor(props) { | |
super(props) | |
this.state = { ... } | |
} | |
toggle() { | |
this.setState({ open: ! this.state.open }) | |
} | |
render() { | |
var {open, loading} = this.state |
NewerOlder