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
#!/bin/bash | |
set -o errexit -o nounset -o pipefail | |
function -h { | |
cat <<USAGE | |
USAGE: deploy.bash | |
This will bootstrap a git checkout of the repo and then try to deploy it. | |
USAGE | |
}; function --help { -h ;} # A nice way to handle -h and --help |
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
def getAverageSentiment(responses: Seq[Response], label: String): Double = responses.map { response => | |
(response.json \\ label).head.as[Double] | |
}.sum / responses.length.max(1) // avoid division by zero |
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
<script src="/src/hospitality.js"></script> | |
<script> | |
hospitality.init({ | |
visit: { | |
new: function() { alert('new-user'); }, | |
return: function() { alert('return-user'); } | |
} | |
}); | |
</script> |
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 tester = mocha.run(); | |
tester.on("fail", function(test, err) { | |
setTimeout(function() { throw err}, 1); | |
}); |
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
import urllib | |
import urllib2 | |
print urllib2.urlopen("http://localhost:8080/login", | |
urllib.urlencode({ "username": "foo", "password": "bar" }).read() |
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 | |
# Take all the positional parameters ($*) and normalize them | |
# -ab1 becomes -a -b 1 or -b1 -a becomes -b 1 -a | |
# Note that the : after b means that it should have a value instead of | |
# just being the boolean flag that a is. | |
args=`getopt ab: $*` | |
# Rewrite ARGV with the output of getopt | |
set -- $args |
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 | |
usage() { | |
cat << EOF | |
usage: $0 [options] <argv>... | |
Options: | |
-h Show help options. | |
-v Print version info. | |
EOF |
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
/*global module:false*/ | |
"use strict"; | |
var _ = require('underscore'); | |
module.exports = function(grunt) { | |
_.each([ | |
'grunt-contrib-watch', |
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
location / { | |
# For CORS | |
if ($request_method = OPTIONS ) { | |
add_header Access-Control-Allow-Origin $http_origin; | |
add_header Access-Control-Allow-Methods "GET, OPTIONS"; | |
add_header Access-Control-Allow-Headers 'Authorization,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,X-CSRF-Token,X-Zendesk-Lotus-Version'; | |
add_header Access-Control-Allow-Credentials "true"; | |
add_header Content-Length 0; | |
add_header Content-Type "text/plain charset=UTF-8"; | |
return 204; |
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() { | |
var scope = {}; | |
with(scope) { | |
return { | |
events: { | |
'app.activated':'doSomething', | |
'click header': 'check' |