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 / mongoNonUnique.js
Created November 13, 2017 16:02
MongoDB count non-unique
db.cases.aggregate([{"$group":{"_id":"$guid", "count": {"$sum":1}}}, {"$match": {"count":{"$gt":1}}}])
@codyhanson
codyhanson / gist:d52069cf04054705dac2175b46ec0e4e
Last active February 12, 2017 21:18
NETCDL Certifier Implementation Standards
NETCDL Certifier Implementation Standards
This document, while not a formal RFC, should serve as a guide for implemen-
tors of future NETCDL Certifier Software. The key words ”MUST”, ”MUST NOT”,
”REQUIRED”, ”SHALL”, ”SHALL NOT”, ”SHOULD”, ”SHOULD NOT”, ”REC-
OMMENDED”, ”MAY”, and ”OPTIONAL” in this document are to be interpreted
as described in RFC2119[7].
A NETCDL certifier MUST recognize and parse a body of text that conforms to the official NETCDL grammar specification.
If a parse error occurs, the certifier SHOULD inform the user the cause of the error, so that they may fix it.
During certification the certifier SHALL evaluate every assertion in the input document.
@codyhanson
codyhanson / gist:63ebfef0f8c2dbb36189f30bc94bd552
Created February 12, 2017 21:12
NETCDL Example Document
# Certification Subject: Home Network
# Author: Cody Hanson <chanson@uwalumni.com>
# Date: 10/1/2016
# Version: 1.0
define host myRouter as 192.168.1.1
define network myNetwork as 192.168.1.0/24
define network DMZ as 10.0.0.0/24
define host ftpSite as speedtest.tele2.net
@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
@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 / 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 / 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 / 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 / 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 / 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;