Skip to content

Instantly share code, notes, and snippets.

View ryonsherman's full-sized avatar

Ryon Sherman ryonsherman

View GitHub Profile
@ryonsherman
ryonsherman / usenetpatch.py
Last active August 29, 2015 14:22
Binary diff + yEnc encoding
% ./usenetpatch.py --help
usage: usenetpatch.py [-h] {diff,patch} ...
positional arguments:
{diff,patch} mode
diff diff mode
patch patch mode
optional arguments:
-h, --help show this help message and exit
@ryonsherman
ryonsherman / fileIsBinary.py
Last active August 29, 2015 14:21
Determine whether a file is binary or text
#!/usr/bin/env python2
def fileIsBinary(path):
text = bytearray([7, 8, 9, 10, 12, 13, 27]) + bytearray(range(0x20, 0x100))
return bool(open(path, 'rb').read(1024).translate(None, text))
@ryonsherman
ryonsherman / log.py
Last active August 29, 2015 14:18
Overridden Python logging methods to return passed message
#!/usr/bin/env python2
import logging
# get root logger
log = logging.getLogger()
# wrapper to return message after logging
def log_return(fn):
def wrapper(msg, *args, **kwargs):
fn(msg, *args, **kwargs)
@ryonsherman
ryonsherman / unicombine.py
Last active August 29, 2015 14:16
Output text containing random Combining Diacritical Marks
#!/usr/bin/env python2
import sys
import random
text = ' '.join(sys.argv[1:])
if not text:
sys.exit("usage: %s <text>" % sys.argv[0])
output = []
for char in text:
@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
@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 / 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 / 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 / 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 / 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')