Skip to content

Instantly share code, notes, and snippets.

View davidjb's full-sized avatar

David Beitey davidjb

View GitHub Profile
@davidjb
davidjb / nginx.debug.log
Created May 20, 2014 06:01
nginx-ajp-dump
2014/05/19 22:26:57 [debug] 17235#0: bind() 0.0.0.0:80 #6
2014/05/19 22:26:57 [notice] 17235#0: using the "epoll" event method
2014/05/19 22:26:57 [debug] 17235#0: counter: 00007FAA59195080, 1
2014/05/19 22:26:57 [notice] 17235#0: nginx/1.6.0
2014/05/19 22:26:57 [notice] 17235#0: built by gcc 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC)
2014/05/19 22:26:57 [notice] 17235#0: OS: Linux 2.6.32-431.el6.x86_64
2014/05/19 22:26:57 [notice] 17235#0: getrlimit(RLIMIT_NOFILE): 1024:4096
2014/05/19 22:26:57 [debug] 17235#0: write: 7, 00007FFFD4159CB0, 6, 0
2014/05/19 22:26:57 [debug] 17235#0: setproctitle: "nginx: master process nginx.debug"
2014/05/19 22:26:57 [notice] 17235#0: start worker processes
@davidjb
davidjb / latestbrowsers.py
Last active August 29, 2015 14:08
This obtains and processes all latest browser versions from CanIUse JSON raw data
import requests
caniuse = requests.get('https://github.com/Fyrd/caniuse/raw/master/fulldata-json/data-2.0.json')
data = caniuse.json()
# We could do a lot more than print here, but this is just an uber quick demo
for agent in data['agents']:
print(data['agents'][agent]['browser'] + ': ' + data['agents'][agent]['current_version'])
@davidjb
davidjb / gnome_mediakeys.c
Last active August 29, 2015 14:22
Example code for listening to multimedia key presses in GNOME
#include <gio/gio.h>
static void
on_signal (GDBusProxy *proxy,
gchar *sender_name,
gchar *signal_name,
GVariant *parameters,
gpointer user_data)
{
gchar *parameters_str;
@davidjb
davidjb / education-ict-promotion.rst
Last active August 29, 2015 14:26
Pycon AU 2015 Notes
@davidjb
davidjb / links.rst
Last active October 14, 2015 00:40
Random hacky snippets for use within Nginx, mostly for debugging purposes.
@davidjb
davidjb / flickr-mass-description.js
Last active November 25, 2015 07:46
Short JS snippet for changing all descriptions on a Flickr mass edit page.
function changeDescriptions(text) {
var elements = document.getElementsByClassName('together_description');
for (var j = 0; j < 2; j++) {
// Do this twice because Flickr needs it (probably 2 x keyup events)
for (var i = 0; i < elements.length; i++) {
var event = new Event('keyup');
elements[i].dispatchEvent(event);
elements[i].value = text;
}
}
@davidjb
davidjb / readynas-fsck.rst
Last active February 8, 2016 21:48
Details on how to recover if an FSCK fails on a ReadyNAS system. Originally from the ReadyNAS forums, since removed.

Rather than RAM (default) or the root partition (/var/ -- far too small!), I used a high-capacity USB drive. Make sure this USB drive has enough free space before starting. You need at least X GB of space if your volume is 8TB like mine was. So, I'm guessing that this is why the fsck fails in the first place - at least, this is what my logs indicated when it said "Error storing directory block information (inode=90885846, block=0, num=6983948): Memory allocation failed"

  1. Get root access to your NAS. I had already enabled root ssh before things went haywire because after the volume failed, FrontView would not load.
  2. Attach a high-capacity storage device to the NAS via USB. Wait while the ReadyNAS loads the drive.
  3. Download and compile the latest e2fsckprogs from the internet:

    wget
    cd
    ./configure
    make
@davidjb
davidjb / configure
Created February 9, 2016 21:57
nghttpd configure steps (h2load)
$ ./configure
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
$(document).ready(function() {
$(".globalheader a").click(function() {
if($(this).attr('href').toLowerCase() != "javascript:;" && $(this).attr('href') != "#") {
ga('send', 'event', {
eventCategory: 'Global Header',
eventAction: 'open',
eventLabel: $(this).attr('href'),
transport: 'beacon'
});
}
@davidjb
davidjb / sec.py
Created April 22, 2016 13:42
Security Engineering Python Code (COMP3/9441)
# Warmup
ciphertext = "TGPRGWTADEKI HI3OYNODONAT ES4LOCIINTB} FC4LURSDTHO_ LO1IRYAEEIU_ AM{NOPBAVNT_"
letter_sets = [[l for l in w] for w in ciphertext.split()]
print(''.join(''.join(w) for w in zip(*x)))