Skip to content

Instantly share code, notes, and snippets.

View davidjb's full-sized avatar

David Beitey davidjb

View GitHub Profile
@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
@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 / webhook.py
Created February 3, 2016 23:42
Simple webhook endpoint for accepting requests to trigger a git update
from bottle import route, run, response, request, redirect
import os
import subprocess
@route('/', method="POST")
@route('/')
def main():
os.chdir('/opt/example-org-pages')
return_code = subprocess.check_call('git pull', shell=True)
if return_code == 0:
@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 / education-ict-promotion.rst
Last active August 29, 2015 14:26
Pycon AU 2015 Notes
@davidjb
davidjb / acceleration-demo.html
Last active June 7, 2019 22:16
Web API demos for acceleration, compass (non-standard), directions, geolocation and more.
<!DOCTYPE html>
<html>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<body>
<script type="text/javascript" charset="utf-8">
var counter = 0;
var timeout;
window.addEventListener('devicemotion', function(event) {
var accel = event.acceleration;
ldap_server ldap_users {
url 'ldaps://ldap.example.org:636/dc=org?uid?sub?...';
require valid_user;
}
ldap_server ldap_groups {
url 'ldaps://ldap.example.org:636/dc=org?uid?sub?(objectClass=person)';
group_attribute "uniqueMember";
group_attribute_is_dn on;
require group 'cn=staff,ou=groups,dc=org';
@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;

Keybase proof

I hereby claim:

  • I am davidjb on github.
  • I am davidjb (https://keybase.io/davidjb) on keybase.
  • I have a public key ASAZEqpWhpC67z2LE3_yK1mVIwTsB2AZXX22I_r7STi1rAo

To claim this, I am signing this object: