Skip to content

Instantly share code, notes, and snippets.

View ryonsherman's full-sized avatar

Ryon Sherman ryonsherman

View GitHub Profile
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 / 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
@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 / 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 / fortune.py
Last active January 4, 2016 04:29
Console `fortune` command output
#!/usr/bin/env python2
from subprocess import Popen, PIPE
def fortune(db=''):
f = Popen(['fortune', db], stdout=PIPE).communicate()[0]
return unicode(f).strip().encode('ascii', 'xmlcharrefreplace')
@ryonsherman
ryonsherman / bing_wallpaper.sh
Last active August 29, 2015 13:57
Bing wallpaper downloader
#!/usr/bin/env sh
LOC="en-US"
for RES in _1920x1200 _1366x768 _1280x720 _1024x768; do
XML="http://www.bing.com/HPImageArchive.aspx?format=xml&idx=0&n=1&mkt=${LOC}"
URL="http://www.bing.com$(echo $(curl -s ${XML}) | grep -oP "<urlBase>(.*)</urlBase>" | cut -d ">" -f 2 | cut -d "<" -f 1)${RES}.jpg"
IMG=${URL##*/}
curl -s -o /tmp/$IMG $URL
file /tmp/$IMG | grep -i HTML && rm -rf /tmp/$IMG && continue
@ryonsherman
ryonsherman / tomorrow.php
Last active August 29, 2015 13:58
Tomorrow at a glance
#!/usr/bin/env php
<?php
if (!count(debug_backtrace())) {
$script = new Script();
print date('l', $script->date).": ".
html_entity_decode("[temp 0&deg;:0&deg;:%] ").
"[sun {$script->sun->rise}-{$script->sun->set}]".
"\n";
}
@ryonsherman
ryonsherman / gist:60cd1afa24879184ac9e
Last active August 29, 2015 14:03
Managed to get LibreSSL packaged... and break everything.
ryon.sherman@ryon-laptop /tmp % pacman -U libressl-2.0.0-2-x86_64.pkg.tar.xz
loading packages...
resolving dependencies...
looking for inter-conflicts...
:: libressl and openssl are in conflict. Remove openssl? [y/N] y
Packages (2): openssl-1.0.1.h-1 [removal] libressl-2.0.0-2
Total Installed Size: 4.93 MiB
Net Upgrade Size: -1.23 MiB
@ryonsherman
ryonsherman / extended_property.php
Last active August 29, 2015 14:05
CodeIgniter Library for Accessing MSSQL Extended Property
<?php
class Extended_property {
var $CI;
function Extended_property()
{
this->CI =& get_instance();
}
@ryonsherman
ryonsherman / mkinitcpio-uboot.sh
Last active August 29, 2015 14:12
Shell script to create and install uboot initcpio image
#!/bin/sh
mkinitcpio -g /boot/uImage.new
mkimage -n initramfs \
-A arm -O linux -T ramdisk -C gzip \
-d /boot/uImage.new /boot/uInitrd \
-a 0x00000000 -e 0x00000000