Skip to content

Instantly share code, notes, and snippets.

View ryonsherman's full-sized avatar

Ryon Sherman ryonsherman

View GitHub Profile
@ryonsherman
ryonsherman / genhash.php
Last active January 3, 2016 19:49
Generates a hashtable containing the sha256 hash of a 10 character string containing every permutation of a combintaion of two letters, one upper-case and one lower-case.
#/usr/bin/env php
<?php
/*
Generates a hashtable containing the sha256 hash of
a 10 character string containing every permutation of
a combintaion of two letters, one upper-case and
one lower-case.
Example:
...
@ryonsherman
ryonsherman / cryptsetup_1.6.3+nuke_keys.diff
Created January 6, 2014 18:40
offensive-security cryptsetup-nuke-keys patch ported to 1.6.3
diff -rupN cryptsetup-1.6.3/lib/libcryptsetup.h cryptsetup-1.6.3.new/lib/libcryptsetup.h
--- cryptsetup-1.6.3/lib/libcryptsetup.h 2013-12-01 03:20:33.000000000 -0600
+++ cryptsetup-1.6.3.new/lib/libcryptsetup.h 2014-01-06 12:08:01.210167782 -0600
@@ -725,6 +725,8 @@ int crypt_keyslot_destroy(struct crypt_d
#define CRYPT_ACTIVATE_PRIVATE (1 << 4)
/** corruption detected (verity), output only */
#define CRYPT_ACTIVATE_CORRUPTED (1 << 5)
+/** key slot is a nuke, will wipe all keyslots */
+#define CRYPT_ACTIVATE_NUKE (1 << 30)
@ryonsherman
ryonsherman / app.py
Last active December 30, 2015 01:08
Example Flask implementation of Redis, MongoDB, Jinja, uWSGI, and Web Sockets.
#!/usr/bin/env python2
import os
import glob
import flask
import logging
import humongolus
from flask import Flask
from redis import StrictRedis
def ordinal(n):
return str(n) + ('th' if 10 <= n % 100 < 20 else {1:'st', 2:'nd', 3:'rd'}.get(n % 10, 'th'))
@ryonsherman
ryonsherman / numsort.py
Last active December 20, 2015 19:49
Sort numerical values regardless of format
#!/usr/bin/env python2
numsort = lambda l: sorted(l, key=lambda x: int(str(x).split('-')[0].split('.')[0].replace('$', '')))
@ryonsherman
ryonsherman / lotto_nums.py
Created May 10, 2013 17:17
One-liner to scrape winning lotto numbers and display most common selection at each position.
import urllib, csv, collections; print ', '.join([collections.Counter(values).most_common(1)[0][0] for values in map(lambda i: [value[0] for value in map(lambda values: [value for index, value in enumerate(values) if index is i], map(lambda row: row[4:10], csv.reader(urllib.urlopen("http://txlottery.org/export/sites/lottery/Games/Lotto_Texas/Winning_Numbers/lottotexas.csv"))))], range(6))])
@ryonsherman
ryonsherman / irc_bot.py
Created May 10, 2013 17:12
Basic IRC bot boilerplate.
import time
from twisted.words.protocols import irc
from twisted.internet import reactor, protocol, ssl
NETWORK = 'irc.network.com'
PORT = 6697
CHANNEL = 'channel'
NICKNAME = 'bot'
@ryonsherman
ryonsherman / rgb_to_hex.js
Created February 13, 2013 19:31
Convert RGB values to hex.
var hex = (r | (g << 8) | (b << 16)).toString(16).toUpperCase();
@ryonsherman
ryonsherman / app.yaml
Created February 12, 2013 18:39
Simple MVC/Template implementation of the GAE Framework using webapp2/jinja2.
application: webapp2_framework
version: 1
runtime: python27
api_version: 1
threadsafe: true
libraries:
- name: jinja2
version: latest
@ryonsherman
ryonsherman / youtube_iframe.py
Last active May 19, 2016 17:59
Parse Youtube URL, extract video ID, and provide embed iframe.
from urlparse import urlparse, parse_qs
url = urlparse('https://www.youtube.com/watch?v=XXXXXXXXXXX')
if 'youtube' in url.netloc.lower():
video_id = parse_qs(url.query).get('v', [False])[0]
if video_id:
print '<iframe width="560" height="315" src="http://www.youtube.com/embed/{0}" frameborder="0" allowfullscreen></iframe>'.format(video_id)