Skip to content

Instantly share code, notes, and snippets.

View paulbdavis's full-sized avatar

Paul Davis paulbdavis

View GitHub Profile
package auth
type tokenRefresher struct {
oauth *oauth2.Config
tokens map[string]*oauth2.Token
locks map[string]*sync.Mutex
accessed map[string]time.Time
}
func newRefresher(oauthConfig *oauth2.Config) *tokenRefresher {
(defun ds/handle-new-window (window)
(let ((new-class (window-class window))
(current-class (window-class (current-window))))
(let* ((frames (group-frames (current-group)))
(isempty (= 1 (length (group-windows (current-group)))))
(fx (- (screen-width (current-screen)) 5))
(fy (- (screen-height (current-screen)) 30))
(dir (if (= (mod (length frames) 2) 0) :row :column)))
(focus-frame (current-group) (find-frame (current-group) fx fy))
;; (ds/split-frame-to-empty (current-group) dir 0.61803)))
#!/usr/bin/env bash
export script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
conf_dir="${XDG_CONFIG_HOME:-$HOME/.config}"
cache_dir="${XDG_CACHE_HOME:-$HOME/.cache}"
data_dir="${XDG_DATA_HOME:-$HOME/.local/share}"
# set failure stuff
trap_msg='s=$?; if [ $s -ne 42 ]; then echo "$0: Error on line "$LINENO": $BASH_COMMAND"; fi; exit $s'

Keybase proof

I hereby claim:

  • I am paulbdavis on github.
  • I am dangersalad (https://keybase.io/dangersalad) on keybase.
  • I have a public key ASBsiEsnfEEFp8x_rGAr73gGGMZBMpKYf_KDfOjOq1yhuQo

To claim this, I am signing this object:

On 1.4.1

% time go build -v
github.com/paulbdavis/httperror
github.com/paulbdavis/evil-lair
go build -v  1.08s user 0.19s system 91% cpu 1.390 total

on 1.4.2

@paulbdavis
paulbdavis / server-setup.sh
Created January 13, 2014 20:17
Ubuntu server setup (docker, node, mongo, bitcoind)
#!/usr/bin/env bash
# add ppas
add-apt-repository -y ppa:chris-lea/node.js
add-apt-repository -y ppa:bitcoin/bitcoin
#mongo
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' > /etc/apt/sources.list.d/mongodb.list
#docker
wget -qO- https://get.docker.io/gpg | apt-key add -
@paulbdavis
paulbdavis / eventcmd
Last active January 2, 2016 20:29
mcabber eventcmd script
#!/usr/bin/env bash
EVENT_TYPE="$1"
EVENT_SUBTYPE="$2"
JID="$3"
FILE="$4"
TITLE="XMPP"
SOUND_DIR="$HOME/.mcabber/sounds"
SOUND_DEVICE="alsa_output.usb-Burr-Brown_from_TI_USB_Audio_CODEC-00-CODEC.analog-stereo"
TIMEOUT=10000
FROM myrepo/base
MAINTAINER me
RUN mkdir /app
RUN apt-get update && apt-get -y install packages i need;
ENV HOME /root
RUN echo 'ssh host info for git repo server' > /root/.ssh/known_hosts
@paulbdavis
paulbdavis / external-ip
Last active December 14, 2015 22:09
Script to get your external ip, with caching (use a cron job to remove the file periodically, or whatever)
#!/usr/bin/env bash
if [ "$1" = "-r" ]
then
rm $HOME/.externalip
exit 0;
fi
cacheFile="$HOME/.externalip"
if [ ! -f "$cacheFile" ] || [ ! "$(cat $cacheFile)" ]
then
@paulbdavis
paulbdavis / Xresources
Created February 24, 2013 23:04
My Xresources file for Zenburn colors with XTerm
#define FONT -xos4-terminus-medium-r-normal--16-160-72-72-c-80-iso10646-1
#define WIDEFONT -misc-fixed-medium-r-normal-ja-13-120-100-100-c-180-iso10646-1
XTerm*faceName: DejaVu Sans Mono
XTerm*faceSize: 10
*customization: -color
XTerm*termName: xterm-256color
XTerm*font: FONT
XTerm*wideFont: WIDEFONT
XTerm*boldFont: FONT
XTerm*reverseWrap: true