Skip to content

Instantly share code, notes, and snippets.

View davidjb's full-sized avatar

David Beitey davidjb

View GitHub Profile
@davidjb
davidjb / mysql.cfg
Last active August 13, 2017 09:23
Buildout for Python database connectors (cx_Oracle, MySQL-python) and dependencies
[extra-parts]
parts +=
python-mysql
[python-mysql]
recipe = zc.recipe.egg
egg = MySQL-python
[instance1]
eggs +=
@davidjb
davidjb / jpype.cfg
Created July 5, 2012 23:44
Buildout for JPype (for Plone)
#Notes about JPype
#------------------------------------
#You need to install default-jre / openjdk-6-jre (Debian/Ubuntu), or
#java-1.6.0-openjdk (RHEL/CentOS) *and* associated development packages.
#The JAVA_HOME variable should be
#set as an environmental variable prior to using the following.
#You might want to use the following to set this:
#Ubuntu: export JAVA_HOME="/usr/lib/jvm/java-6-openjdk"
#RHEL: export JAVA_HOME="/etc/alternatives/java_sdk"
#and include these in your profile (eg ~/.bash_profile) to load them on
@davidjb
davidjb / ago2.py
Created January 9, 2013 01:59
Improved humanisation for Ago
from datetime import datetime, timedelta
import ago
def human(date,
precision=2,
past_fmt="{} ago",
present_fmt="right now",
future_fmt="in {}",
present_tolerance=timedelta(0)):
@davidjb
davidjb / reference-tooltips.js
Last active August 13, 2017 08:32
Replace HTML paragraphs with incremental identifiers, and create custom tooltips via JavaScript with jQuery Tools.
jQuery(function($) {
$(window).ready(function() {
var reference_url = '//terrestrialclimatechange.org.au/references';
var storage_key = 'references.data';
var ref_link_structure = function(reference) {
return '<a href="' + reference_url + '#ref-' + reference + '">' + reference + '</a>';
};
var tooltip_structure = function(content) {
return $('<div class="tooltip" />').append(content);
@davidjb
davidjb / test-io.sh
Last active November 8, 2017 00:08
I/O Performance tests with fio
#!/bin/sh
#Run like this:
# wget -O - https://gist.githubusercontent.com/davidjb/8777451/raw/test-io.sh | sudo sh
# or
# curl https://gist.githubusercontent.com/davidjb/8777451/raw/test-io.sh | sudo sh
if command -v yum > /dev/null 2>&1; then
sudo rpm -ihv http://mirrors.kernel.org/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm
sudo yum install -y fio git
elif command -v apt-get > /dev/null 2>&1; then
sudo apt-get install -y fio git
@davidjb
davidjb / buildout.cfg
Last active July 13, 2021 10:18
Example SQLAlchemy integration with Plone
[buildout]
...
[instance]
...
eggs=
...
z3c.saconfig
zcml-additional =
@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'])

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:

@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;