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
// mostly stolen from http://phrogz.net/JS/classes/OOPinJS2.html | |
// first we define a mammal... | |
function Mammal(name) { | |
this.name = name; | |
this.offspring = []; | |
} | |
Mammal.prototype.haveABaby = function() { | |
var newBaby = new Mammal("Baby " + this.name); | |
this.offspring.push(newBaby); |
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
// say you have the following object: | |
var friends = { | |
bob: {name: "Bob Robertson", nickname: "Bob the Terrible"}, | |
jim: {name: "Jim Jameson", nickname: "Jim the Magnificent"}, | |
bill: {name: "Bill Williamson", nickname: "Doodles"}, | |
} | |
// So if you want to get Bob's nickname, you could access it like so: | |
console.log(friends.bob.nickname); // prints "Bob the Terrible" | |
// but say you just have Bill's name in a variable, and you need to look it up. |
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
function compare(choice1, choice2) { | |
if (choice1 == choice2) return "The result is a tie!"; | |
if (choice1 == "rock") { | |
if (choice2 == "paper") { | |
return "paper wins"; | |
} else { // scissors | |
return "rock wins"; | |
} | |
// or with a ternary statement... | |
//return (choice2 == "paper" ? "paper" : "rock") + " wins" |
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
sets! | |
one(1): True | |
two(2): True | |
Join/Or! | |
one_or_two(1): True | |
one_or_two(2): True | |
Intersect/And! | |
one_but_not_two(1): True |
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
manage-staging: | |
provider: aws | |
image: ami-43e2772a | |
size: m1.small | |
script: bootstrap-salt-minion | |
minion: | |
grains: | |
staging: True | |
database: True | |
media: True |
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
State: - pkg [425/1906] | |
Name: python-dev | |
Function: installed | |
Result: False Comment: The following package(s) failed to install/update: python-dev. | |
Changes: libgomp1: {'new': '4.6.3-1ubuntu5', 'old': ''} libmpfr4: {'new': '3.1.0-3ubuntu2', 'old': ''} libz-dev: {'new': '1', 'old': ''} | |
gcc-4.6: {'new': '4.6.3-1ubuntu5', 'old': ''} python2.7-dev: {'new': '2.7.3-0ubuntu3.1', 'old': ''} linux-libc-dev: {'new': '3.2.0-37.58', 'old': ''} | |
cpp-4.6: {'new': '4.6.3-1ubuntu5', 'old': ''} python-dev: {'new': '2.7.3-0ubuntu2', 'old': ''} | |
gcc: {'new': '4:4.6.3-1ubuntu5', 'old': ''} | |
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
@router.node(('bigram',)) | |
def bigrams(msg): | |
'get bigrams from a document' | |
prev = None | |
for word in msg.document.strip().split(' '): | |
yield (prev, word) | |
prev = word | |
@router.node(('bigram', 'frequency'), 'bigrams') | |
def count_bigrams(msg): |
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
style: swiss.css |
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
require 'zurb-foundation' | |
# Require any additional compass plugins here. | |
# Set this to the root of your project when deployed: | |
http_path = "/" | |
css_dir = "_site/static/css" | |
sass_dir = "_sass" | |
images_dir = "static/images" | |
javascripts_dir = "static/js" |
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
''' | |
Usage: | |
class MyResource(CustomURIResource): | |
class Meta: | |
queryset = User.objects.all() | |
resource_name = 'user' | |
url_field = 'username' | |
Will make accessible URIs like so: |