Skip to content

Instantly share code, notes, and snippets.

View codyhanson's full-sized avatar
🍻
Cheers

Cody Hanson codyhanson

🍻
Cheers
View GitHub Profile
@codyhanson
codyhanson / gitFetchAll.py
Created June 19, 2013 15:18
Use the littleworkers library to fetch many gitrepos at once.
#! /usr/bin/env python
from littleworkers import Pool
# Define your commands.
commands = [
"cd repo1; git fetch",
"cd repo2; git fetch",
"cd repo3; git fetch",
"cd repo4; git fetch",
@codyhanson
codyhanson / prime.py
Created June 20, 2013 21:42
A really inefficient way to compute prime numbers.
#! /usr/bin/env python
curnum = 2
nums = []
while True:
prime = True
for num in nums:
if curnum % num == 0:
prime = False
@codyhanson
codyhanson / imac_volume.pl
Created January 3, 2014 14:52
Controls the volume on my old iMac
#! /usr/bin/perl
die "usage volume.pl NUMBER" if @ARGV == 0;
$vol = $ARGV[0];
$command = 'sudo osascript -e "set Volume ' . $vol .'"';
system($command);
@codyhanson
codyhanson / jarvis.pl
Created January 3, 2014 14:54
old script I made to have an IronMan style Jarvis alarm clock with the old iMac. uses the OSX talk say command.
#! /usr/bin/perl
#Turn your mac into your (not) so humble servant, Jarvis!
#Version 1.0 5/12/2010 Cody Hanson
#Macintosh only, sorry!
#Dedicated to Mr Tony Stark, who is a badass.
use strict;
use warnings;
@codyhanson
codyhanson / scope-fixed.js
Last active August 29, 2015 14:03
Javascript Scoping
#! /usr/bin/env node
function gen(val){
return function(){
console.log('My value is:' + val);
}
}
var a = [1, 2, 3, 4, 5];
var fps = [];
@codyhanson
codyhanson / simpleTryCatch.js
Created June 30, 2014 15:01
Javascript Exception Handling
#!/usr/bin/env node
function asyncCall(callback){
console.log('Starting Async Function');
setTimeout(callback,1000);
}
try {
asyncCall(function (){
var err = new Error('MyError');
@codyhanson
codyhanson / pg_restore.md
Last active August 29, 2015 14:06
Restore heroku pgdump to local database, and work with copies.

Download the Heroku backup that you want

Get list of backups

heroku pgbackups --app $APP

Get url for backup, and download

heroku pgbackups:url $backupId --app $APP
@codyhanson
codyhanson / longestChain.js
Created November 6, 2015 19:20
longest chain
var _ = require('underscore');
var sprintf = require('sprintf-js').sprintf;
var words = _.chain(require('fs').readFileSync('wordsEn.txt').toString().split("\r\n")).compact().sortBy('length').value();
var chains = [];
function contains(smaller, bigger) {
if (smaller.length >= bigger.length) return false;
for (var i = 0; i < smaller.length; i++) if (_.indexOf(bigger, smaller[i]) == -1) return false;
return true;
}
for (var i = 0; i < words.length; i++) {
@codyhanson
codyhanson / FIN_scan.py
Created August 16, 2016 04:13 — forked from zypeh/FIN_scan.py
A simple snippets from [Infosec Institute]("http://resources.infosecinstitute.com/port-scanning-using-scapy/")
# !/usr/python
# The FIN scan utilizes the FIN flag inside the TCP packet,
# along with the port number to connect to on the server.
# If there is no response from the server, then the port is open.
import logging
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
from scapy.all import *
@codyhanson
codyhanson / curlloop.sh
Created September 14, 2016 15:23
Handy script to repeatedly hit a webserver and print the response code.
#!/bin/bash
# Example Output and Usage
# clh@mint ~ $ ./curlloop.sh google.com
# 0: http://www.google.com/ - 200
# 1: http://www.google.com/ - 200
# 2: http://www.google.com/ - 200
# 3: http://www.google.com/ - 200
COUNT=0