Skip to content

Instantly share code, notes, and snippets.

View dingram's full-sized avatar

Dave Ingram dingram

View GitHub Profile
#!/usr/bin/env zsh
# ------------------------------------------------------------------------------
# Fish style live command coloring.
# ------------------------------------------------------------------------------
# Token types styles.
# See http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#SEC135
ZLE_RESERVED_WORD_STYLE='bold'
ZLE_ALIAS_STYLE='bold'
ZLE_BUILTIN_STYLE='bold'
@dingram
dingram / message.lua
Last active November 13, 2020 09:56
"message" effect for keyleds
-- Message effect for keyleds: lights up keys in order
--
-- Config:
--
-- color: the color that each key will use
-- group: the group of keys to light up, in order. Either this or "message"
-- must be set.
-- message: a string of space-separated key names to light up, in order. Each
-- key name may be followed by a colon and a number in ms to override the
-- time to light that key. For example, "t e s t:1000 i n g space t h i s"
#!/bin/bash
#
# git-svn-rebase-all
# by Dave Ingram <http://github.com/dingram/>
#
SHELL=${SHELL:-/bin/bash}
curbranch=$(git symbolic-ref HEAD 2>/dev/null)
if [ $? -eq 0 ]; then
curbranch=${curbranch##*/}
else
#!/bin/zsh
SCREEN_SERIAL="1WSZMS2"
INPUT_DP1="0f"
INPUT_HDMI1="11"
if [[ ! -e "/dev/i2c-1" ]]; then
echo "Module i2c-dev is not loaded; loading..."
sudo modprobe i2c-dev
if [[ ! -e "/dev/i2c-1" ]]; then
@dingram
dingram / whotime
Last active December 20, 2015 15:38
#!/bin/bash
#
# By Dave Ingram
export TZ="Europe/London"
case $( date +%I ) in
01) DOCTOR='William Hartnell' ;;
02) DOCTOR='Patrick Troughton' ;;
03) DOCTOR='Jon Pertwee' ;;
04) DOCTOR='Tom Baker' ;;
@dingram
dingram / js-sdk.min.js
Created September 10, 2012 14:34
A minimalist way of including social JavaScript SDKs into a page. Includes Google Analytics, Twitter widgets, Facebook, and Google +1
window.___gcfg={lang:'en-GB'};var _gaq=_gaq||[];_gaq.push(['_setAccount','UA-123456-9']);_gaq.push(['_trackPageview']);!function(d,s){var st=d.getElementsByTagName(s)[0],j=function(i,u){if(d.getElementById(i))return;var js=d.createElement(s);js.id=i;js.async=true;js.src=u;st.parentNode.insertBefore(js,st)};setTimeout(function(){j("twitter-wjs","//platform.twitter.com/widgets.js");j("facebook-jssdk","//connect.facebook.net/en_GB/all.js#xfbml=1");j("gplusone-sdk","https://apis.google.com/js/plusone.js")}, 0);j("ga-sdk",('https:'==d.location.protocol?'https://ssl':'http://www')+'.google-analytics.com/ga.js')}(document,'script');
@dingram
dingram / gist:2171573
Created March 23, 2012 15:10
vimrc sessions
"*****************************************************************************
" Vim Sessions
"*****************************************************************************
" ignore 'options' because of latex-suite (would be pointless to save that!)
set sessionoptions=blank,curdir,folds,help,resize,tabpages,winsize
if has('win32') || has('win64')
set sessionoptions+=slash,unix
map <leader>ss :mksession! ~/_vimsession<cr>
map <leader>sr :source ~/_vimsession<cr>
else
@dingram
dingram / gist:1405675
Created November 29, 2011 17:43
Date highlight script for Google Docs
function numToCol(c) {
var r = '';
if (c > 25) {
r = String.fromCharCode('A'.charCodeAt(0) + parseInt(c / 26, 10) - 1);
}
r = r + String.fromCharCode('A'.charCodeAt(0) + parseInt(c % 26, 10));
return r;
}
function getCellForDate_(d) {
@dingram
dingram / lipsum.pl
Created October 19, 2010 14:41
Lorem Ipsum (lipsum) generator, in Perl, using lipsum.com
#!/usr/bin/perl -w
use LWP::UserAgent;
use HTTP::Request::Common;
use HTML::Entities;
use Getopt::Long;
# Generate lipsum (courtesy of lipsum.com)
# probably needs neatening up here and there
# comments? who needs comments? perl is easy to understand...
RewriteEngine On
RewriteRule ^index.php$ - [L]
RewriteRule .* index.php [L,QSA]