Skip to content

Instantly share code, notes, and snippets.

View hhamilto's full-sized avatar
🎯
Focusing

Hurricane Hamilton hhamilto

🎯
Focusing
View GitHub Profile
@hhamilto
hhamilto / top_movies.sql
Last active September 28, 2017 11:58 — forked from pamelafox/top_movies.sql
Top 100 Movies
/* Source: http://www.boxofficemojo.com/alltime/world/ */
CREATE TABLE top_movies(
rank TEXT NOT NULL PRIMARY KEY
, title TEXT
, studio TEXT
, worldwide TEXT
, domestic_money TEXT
, domestic_percent TEXT
, overseas_money TEXT
// I kept my implementation's external dependencies to only the
// core express module and standard node modules
express = require('express')
crypto = require('crypto')
http = require('http')
assert = require('assert')
app = express()
//parse form values
app.use(function(req,res,next){
@hhamilto
hhamilto / parseTimeAmount.js
Created March 24, 2013 16:04
This javascript function takes a human typed amount of time (like "1 hour 30 mins", or "1.25 hours and 3 seconds") and converts it into a number of seconds for easy programmatic manipulation. Couldn't find it anywhere, so I made it.
function parseTimeAmount(stime){
var tokens = stime.split(/\s/);
var seconds = 0;
for(var i = 0; i < tokens.length; i++){
var quantity = parseFloat(tokens[i]);
if(!isNaN(quantity)){
i++;
if(/sec/.test(tokens[i])){
seconds+=quantity;
}else if(/min/.test(tokens[i])){
@hhamilto
hhamilto / human_number_parser
Last active December 15, 2015 08:39
This is a JavaScript function that will parse a human typed number into an integer up to a quintillion, which is over the max size for a js int.
function mparseInt(snum){
console.log(1);
snum = $.trim(snum);
var tokens = snum.split(/[\s-]+/);
// with a 'z' because we are so very street, yo.
var holdz = [];
for(var i = 0; i < tokens.length; i++){
var token = tokens[i].replace(/-/,'').toLowerCase();
var hold = null;
if(token == 'zero' || token == ''){
@hhamilto
hhamilto / Violent Method names found in the wild
Created March 21, 2013 22:26
This is a list of violent methods/pieces of code that people have found in the wild.
super.invokeExplosively(target, input);