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
String.prototype.hashCode = function(){ | |
var hash = 0; | |
if (this.length == 0) return hash; | |
for (i = 0; i < this.length; i++) { | |
char = this.charCodeAt(i); | |
hash = ((hash<<5)-hash)+char; | |
hash = hash & hash; // Convert to 32bit integer | |
} | |
return hash; | |
} |
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
// Implements fig syntax. | |
package main | |
import ( | |
"gopkg.in/yaml.v1" | |
"io/ioutil" | |
"log" | |
) | |
var metaConfig MetaConfig |
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
module.exports = Runner; | |
function Runner() { | |
this.stack = []; | |
this.passed = 0; | |
this.failed = 0; | |
} | |
Runner.prototype.it = function (msg, test) { | |
this.stack.push(new Test(msg, test)); |
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 | |
# Run in mock production mode with docker | |
dockerEnv() { | |
mkdir -p images; | |
printf "Starting the mongodb container...\n"; | |
docker run -d --name="spacedb" beshippable/dbbase; | |
printf "Starting the application container...\n"; | |
docker run -v $(pwd):/app -p 8080:8080 -v $(pwd)/images:/img \ | |
--name="spacecam" -e NODE_ENV=prod --link spacedb:db \ |
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
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
func main() { | |
now := time.Now() | |
oneMonthAgo := time.Unix(now.Unix() - (60 * 60 * 24 * 30), 0) |
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
[ { title: 'Makin\' It Singles', | |
name: 'Upper-scale urban singles.', | |
description: 'Pre-middle-age to middle-age singles with upper-scale incomes. May or may not own their own home. Most have college educations and are employed in mid-management professions.' }, | |
{ title: 'Aspiring Urbanites', | |
name: 'Urban singles with moderate income.', | |
description: 'Low- to middle-income singles over a wide age range. Some have a college education. They work in a variety of occupations, including some management-level positions.' }, | |
{ title: 'Bright Lights, Big City', | |
name: 'Very mobile singles living in the city.', | |
description: 'Singles ranging in age from early 20s to mid-40s who have moved to an urban setting. Most rent their apartment or condo. Some have a college education and work in services and the professional sector.' } ] |
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
// My attempt to make David Walsh's xmlToJson function work | |
// with libxmltojs. This reproduces the document tree but not | |
// the text inside in each node. There is a lot of data in these | |
// documents we are not using... I think we should stick to the | |
// xpath queries. | |
// Changes XML to JSON | |
function xmlToJson (xml) { | |
// Create the return object | |
var obj = {}; |
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
using HttpCommon | |
using Dates | |
# Creating a query string that will encode unix datetimes | |
# given Julia DateTimes. Methods to handle more types could | |
# easily be added. | |
function qstring(kv::Tuple...) | |
encodeval(v::String) = encodeURI(v) | |
encodeval(dt::DateTime) = string(int64(datetime2unix(dt))) | |
encodepair(p::Tuple) = string(encodeval(p[1]), "=", encodeval(p[2]), "&") |
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 | |
test_exec() { | |
echo -e "Checking for command: \e[34m$1\e[0m" | |
EX=$(which $1) | |
if [[ ! "$EX" ]]; then | |
echo -e "\e[31mUh oh! It looks like you need to install $1:" | |
echo -e "$2\e[0m" | |
exit 1 | |
else |
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 | |
# Asks the user a yes or no question, returning the boolean result | |
# $1: Message message to print | |
# $2: Default answer (defaults to "no" (1)) | |
std_askyesno() { | |
local CONF="y/N" | |
if [[ $2 == 0 ]]; then local CONF="Y/n"; fi | |
local reply="n" | |
read -p "$1 $CONF " -n 1 -r reply |