Roll your own iPython Notebook server with Amazon Web Services (EC2) using their Free Tier.
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
list nodes_to_visit = {root}; | |
while( nodes_to_visit isn't empty ) { | |
currentnode = nodes_to_visit.first(); | |
nodes_to_visit.prepend( currentnode.children ); | |
//do something | |
} | |
BFS: | |
list nodes_to_visit = {root}; |
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
function arr2csv(arr) { | |
var cols = []; | |
/* get a list of unique columns */ | |
_.each(arr, function(item) { | |
cols = _.union(_.keys(item), cols); | |
}); | |
var csvRows = [cols.join("\t")]; | |
for ( var i = 0; i < arr.length; i++ ) { | |
var row = arr[i]; |
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
Good basic intro on types | |
https://docs.python.org/2/tutorial/introduction.html | |
https://docs.python.org/2/tutorial/controlflow.html | |
blocks use : and indent | |
while a < b: | |
print a | |
if x < 0: |
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 request = require('request'); | |
var async = require('async'); | |
var url = "..."; | |
var payload = "..."; | |
var calls = []; | |
var clients = 100; | |
var callsPerClient = 20; | |
var thinkTime = 0; |
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
// | |
// Regular Expression for URL validation | |
// | |
// Author: Diego Perini | |
// Updated: 2010/12/05 | |
// License: MIT | |
// | |
// Copyright (c) 2010-2013 Diego Perini (http://www.iport.it) | |
// | |
// Permission is hereby granted, free of charge, to any person |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
function smoosher(object) { | |
var nodesToVisit = [ { path:[], d: object }]; | |
var result = []; | |
var visitedObjects = []; | |
while ( nodesToVisit.length > 0 ) { | |
var currentNode = nodesToVisit.shift(); | |
var nodeType = typeof currentNode.d === 'undefined' ? 'undefined' : | |
(typeof currentNode.d === 'object' && ! currentNode.d) ? 'null' : | |
({}).toString.call(currentNode.d).match(/\s([a-zA-Z]+)/)[1].toLowerCase(); |
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
### | |
this is a function that makes it easy to map one object to another | |
using underscore/lodash. | |
### | |
_ = require('lodash') #3.10.1 | |
mapper = (obj,mapping,initial)-> | |
newObj = if initial then initial else {} | |
_.each(mapping, (from, to)-> |