Skip to content

Instantly share code, notes, and snippets.


Jake Marsh jakemmarsh

View GitHub Profile
jakemmarsh / check_deps.js
Created Feb 21, 2018
Node script to find any JS files that are not imported anywhere else.
View check_deps.js
const fs = require('fs');
const path = require('path');
const childProcess = require('child_process');
const directoryToSearch = process.argv[2];
function getAllFilesInDirectory(dirOrFile) {
if (fs.statSync(dirOrFile).isDirectory()) {
return Array.prototype.concat(...fs.readdirSync(dirOrFile).map((f) => getAllFilesInDirectory(path.join(dirOrFile, f))));
} else if (dirOrFile.indexOf('.js') !== -1) {
jakemmarsh / nginx.config
Last active Sep 13, 2021
Modify nginx proxy settings in Elastic Beanstalk options
View nginx.config
mode: "000644"
owner: root
group: root
content: |
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;
jakemmarsh / TagInput.js
Created Feb 19, 2015
View TagInput.js
* @jsx React.DOM
'use strict';
var React = require('react/addons');
var _ = require('lodash');
var $ = require('jquery');
var tokenfield = require('bootstrap-tokenfield')($);
jakemmarsh / header-switcher.js
Created Feb 12, 2014
AngularJS Directive for looping through and displaying multiple headers
View header-switcher.js
directives.directive('headerSwitcher', function() {
return {
restrict: 'A',
scope: {
elementType: '='
link: function(scope, element, attrs) {
var headers = $(element).children(scope.elementType),
headerIndex = -1;
jakemmarsh /
Last active Aug 29, 2015
a simple keystore system in Python. Multiple values can be stored in a single key, and are retrieved based on time of creation.
import time
class keyStore:
def __init__(self): = {}
def put(self, key, value):
# create array if it doesn't exist
if key not in[key] = []
jakemmarsh /
Created Jan 9, 2014
Interview coding exercise to parse and build strings based on the number of occurrences of characters.
# Take a string as input, such as "a3c4b2", and output a new string of the letters
# repeated the specified number of times i.e. "aaabbcccc"
def parse(string):
newString = ""
for i in range(0, len(string)):
currentChar = string[i]
for j in range(0, int(string[i])):
newString += currentChar
jakemmarsh /
Last active Jan 2, 2016
a basic implementation of the common "elevator" interview question.
import time
class Elevator:
def __init__(self):
self.state = "stand"
self.doors = "open"
self.currentFloor = 1
self.requests = []
def requestFloor(self, floorNum):
jakemmarsh /
Last active Oct 3, 2021
a simple implementation of a Binary Search Tree in Python
class Node:
def __init__(self, val):
self.val = val
self.leftChild = None
self.rightChild = None
def get(self):
return self.val
def set(self, val):
jakemmarsh / file.js
Created Sep 8, 2013
Express endpoint to retrieve file from MongoDB GridFS
View file.js
exports.get = function(req, res) {
var db = new mongo.Db('downloadr', new mongo.Server("", 27017, {}), {safe: false, strict: false}); (err) {
if (err) return handleError(err);
var gfs = Grid(db, mongo);
// create a read stream from gfs...
.createReadStream({ _id: req.param('fileId') })
jakemmarsh / filters.js
Created Jul 16, 2013
AngularJS filter to create links out of URLs
View filters.js
app.filter('parseUrl', function() {
var //URLs starting with http://, https://, or ftp://
replacePattern1 = /(\b(https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim,
//URLs starting with "www." (without // before it, or it'd re-link the ones done above).
replacePattern2 = /(^|[^\/])(www\.[\S]+(\b|$))/gim,
//Change email addresses to mailto:: links.
replacePattern3 = /(\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,6})/gim;
return function(text, target, otherProp) {
angular.forEach(text.match(replacePattern1), function(url) {