Skip to content

Instantly share code, notes, and snippets.

View aholmes's full-sized avatar

Aaron Holmes aholmes

View GitHub Profile
var container = $('.markdown-body'),
classes = {};
container.find('h2').each(function(i)
{
var className = $(this).text().replace(/[^-a-zA-Z0-9_ ]+/g, '').trim(),
currentClass, next;
classes[className] = {};
@aholmes
aholmes / size.py
Created August 4, 2014 22:17
Get the height and width of an uncompressed SWF.
#!/usr/bin/python
import array
f = open('uncompressed_test_adx30.swf', 'r')
input = f.read(8)
chars = [ord(ch) for ch in input]
nbits = chars[0] >> 3
var myDirective = function()
{
return {
template: '<div data-ng-include="template.url"></div>',
link: function(scope)
{
scope.template = { url: '' };
}
};
}
@aholmes
aholmes / random-number-minmax-bash.sh
Created January 10, 2015 20:35
Random number with MIN and MAX in Bash
#!/bin/bash
MIN=$1
MAX=$2
NUM=$(( ( RANDOM % ( MAX - MIN + 1 ) + MIN ) ))
@aholmes
aholmes / delete_posts.js
Created February 1, 2015 22:46
Delete old reddit posts
// Change this to the URL of your profile where you'd like to start deleting posts.
var startUrl = 'http://www.reddit.com/user/YOUR_USER_NAME/?count=100&after=WHATEVER_THE_TAG_IS';
function reload(cb)
{
var newdoc=undefined;
$.ajax(startUrl).success(function(data)
{
newdoc=$(data);
@aholmes
aholmes / load_stylesheets.js
Created February 6, 2015 18:18
Load stylesheets after DOM render
var cb = function ()
{
var s = document.querySelector('head style:last-of-type');
['/path/to/stylesheet/one.css','/path/to/stylesheet/two.css']
.forEach(function (v)
{
var l = document.createElement('link'); l.rel = 'stylesheet'; l.href = v;
s.parentNode.appendChild(l, s);
});
@aholmes
aholmes / T-Mobile-925.xml
Created February 14, 2015 04:46
Phone registry information for the Nokia 925 on T-Mobile.
<RegistryInformation
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<DeviceUpdateKey>
<KeyName>Software\Microsoft\Windows\CurrentVersion\DeviceUpdate</KeyName>
<Subkeys>
<RegistryKey>
<KeyName>Software\Microsoft\Windows\CurrentVersion\DeviceUpdate\Agent</KeyName>
<Subkeys>
<RegistryKey>
<KeyName>Software\Microsoft\Windows\CurrentVersion\DeviceUpdate\Agent\Engine</KeyName>
@aholmes
aholmes / while_loop_comparisons.c
Created February 17, 2015 01:28
Benchmarks of different ways to calculate the end parameters of a while loop.
#include <stdio.h>
#include <conio.h>
#ifdef WIN32
#include <windows.h>
double get_time()
{
LARGE_INTEGER t, f;
QueryPerformanceCounter(&t);
@aholmes
aholmes / print_ascii_art.js
Last active January 17, 2022 13:44
Prints ASCII art in your console.
var art=' :.+8.\n\
I=.$= O\n\
7O?7D?O~I$\n\
,+Z?+OI+:77\n\
~Z+?OO$OO7I\n\
.IOD?=$ZZO,\n\
OI~IZ+~8=,\n\
DDDDDDDDDDDDDDDDDDDD DDDD8 8DDDDDDDDDDDDDDDDDDDDD 7Z~+Z+$7D+?\n\
DDDDDDDDDDDDDDDDDDDD8 DDDD8 8DDDDDDDDDDDDDDDDDDDDD =$II$Z~IZ+\n\
DDDD8 DDDDD DDDD8 DDDDD ?$:==:~$O\n\
@aholmes
aholmes / trampoline.js
Created May 9, 2015 06:20
Trampoline (indirect jump) implementation in TypeScript
var Trampoline = (function ()
{
function Trampoline(func, baseConditionReachedFunc)
{
var _this = this;
this.func = func;
this.baseConditionReachedFunc = baseConditionReachedFunc;
if (typeof func !== 'function') throw new Error('Wrong type');