Skip to content

Instantly share code, notes, and snippets.

View gbishop's full-sized avatar

Gary Bishop gbishop

View GitHub Profile
@gbishop
gbishop / xorg.conf
Created November 16, 2012 00:04
nVidia X11 configuration for dual portrait mode monitors
Section "Monitor"
Identifier "Monitor0"
VendorName "Unknown"
ModelName "SHARP HDMI"
HorizSync 15.0 - 75.0
VertRefresh 23.0 - 76.0
Option "DPMS"
EndSection
Section "Screen"
@gbishop
gbishop / xorg.conf
Created August 26, 2012 21:16
Drive two HD displays in portrait mode using nVida graphics on Ubuntu Precise
# I couldn't get the GUI tools to do the right thing so I edited the generated file by hand.
# the key magic is the Option Rotate right along with the placement
# nvidia-xconfig: X configuration file generated by nvidia-xconfig
# nvidia-xconfig: version 295.40 (buildmeister@swio-display-x86-rhel47-04.nvidia.com) Thu Apr 5 22:33:07 PDT 2012
Section "ServerLayout"
Identifier "Layout0"
Screen 0 "Screen0" 0 0
InputDevice "Keyboard0" "CoreKeyboard"
@gbishop
gbishop / remoteCommand.js
Created February 9, 2012 00:31
A web-testing hack to allow me to force refresh in several browsers simultaneously.
$(function(){
/* poll for commands to run. I mostly use it with window.location.reload(true); */
function remoteCommand() {
$.ajax({
url: "/wp-content/themes/thr3/remoteCommand.php",
cache: false,
timeout: 100000,
success: function(data) {
if (data != 'no') {
@gbishop
gbishop / iPadAudio
Created December 21, 2011 20:04
Play sound on the iPad from Javascript using jquery mobile
I keep forgetting how to do this...
To play audio in Safari on the iPad using javascript you have to create the audio node in response to a user event. You have to give the audio node a legal url and call load. Then reuse that same node to play sounds in the future.
In jquery mobile I bound to the 'tap' event on body. If I haven't already created the audio object I create it there. Then I can use it later.
@gbishop
gbishop / Run.js
Created January 9, 2011 02:20
Komodo Edit macro to Save and Run a Python program, killing the previous instance if necessary
if (komodo.view) { komodo.view.setFocus() };
komodo.doCommand('cmd_save')
ko.run.output.kill(-1);
setTimeout(function(){
ko.run.runEncodedCommand(window, '%(python) -i \"%F\" {\'cwd\': u\'%D\'}');
}, 100);
@gbishop
gbishop / muteRadio
Created January 6, 2011 19:17
Mute Rhythmbox at the top of the hour so I don't hear the news break
#!/usr/bin/python
'''I run this with crontab using the line:
1 8-17 * * 1-5 /home/gb/bin/muteRadio
'''
import sys
import os
import time
import dbus
@gbishop
gbishop / diffObjects.py
Created December 26, 2010 13:22
Visually compare python objects with diff
from difflib import Differ
from pprint import pformat
def diff(o1, o2):
po1 = pformat(o1).splitlines()
po2 = pformat(o2).splitlines()
d = Differ()
r = [ line for line in d.compare(po1, po2) if line[0] in '+-' ]
return '\n'.join(r)
@gbishop
gbishop / hitcher.js
Created November 2, 2010 14:37
A hack at customized callback behavior in dojo
dojo.provide('uow.hitcher');
/*
uow.hitcher: provide additional control over callbacks
usage:
my = uow.hitcher({ callPeriod: 500 }); // note this didn't hitch, it created a hitcher named my.
your = uow.hitcher(); // this one is independent of the first
# monkey patch the python json module to handle undefined
import json
json.decoder._CONSTANTS['undefined'] = None
json.scanner.pattern('(-?Infinity|NaN|true|false|null|undefined)')(json.decoder.JSONConstant)
json.decoder.JSONScanner = json.decoder.Scanner(json.decoder.ANYTHING)
if __name__ == '__main__':
print json.loads('{ "foo": 1, "bar": undefined }')
#!/usr/bin/python
'''Yet another Montage experiment for desktop wallpaper
This version works with a variant on the "Pseudo-Poisson" dart throwing algorithms
that were popular in stochastic ray-tracing years ago. It throws darts at a rectangular
region ensuring that no darts are closer together than a minimum distance. It allows the
minimum distance to scale down so you can have some big pictues and some smaller pictures.
The help text was intended to be self explanatory...