Skip to content

Instantly share code, notes, and snippets.

View alecthegeek's full-sized avatar
🤖
Dem keyboards don't go click click on their own you know

Alec Clews alecthegeek

🤖
Dem keyboards don't go click click on their own you know
View GitHub Profile
@alecthegeek
alecthegeek / server-command
Created June 28, 2013 22:26
Start and Stop commands for PaperCut
#! /usr/bin/env bash
if [[ -x /Applications/PaperCut\ MF/server/bin/mac/server-command &&
-x /Applications/PaperCut\ NG/server/bin/mac/server-command ]] ; then
echo copies of both NG and MF installed!
exit 1
elif [[ -x /Applications/PaperCut\ MF/server/bin/mac/server-command ]]; then
app_root='/Applications/PaperCut MF'
elif [[ -x /Applications/PaperCut\ NG/server/bin/mac/server-command ]]; then
app_root='/Applications/PaperCut NG'
@alecthegeek
alecthegeek / gist:7595870
Last active December 29, 2015 01:49 — forked from anonymous/gist:7595857
Running HomeBrew Rhino debugger on OS X
#!/bin/sh
# https://developer.mozilla.org/en/docs/Rhino/Debugger
java -cp $(brew --prefix)/Cellar/rhino/1.7R4/libexec/js.jar org.mozilla.javascript.tools.debugger.Main "$@"
@alecthegeek
alecthegeek / keybase.md
Created March 24, 2014 03:20
My Keybase Proof

Keybase proof

I hereby claim:

  • I am alecthegeek on github.
  • I am alecthegeek (https://keybase.io/alecthegeek) on keybase.
  • I have a public key whose fingerprint is BF8A E8CC 9DA3 C1E3 C5BD 0CDD 3FE7 B98F 9BBB FC7C

To claim this, I am signing this object:

@alecthegeek
alecthegeek / dbshare.sh
Last active August 29, 2015 14:04
CLI script to copy a file to the user's public DropBox folder and put a shortened public link in the clipboard. Inspired by @matthewmccullough and @tlberglund
#! /usr/bin/env bash
# $1 file to share
db_home=$HOME/DropBox # You need to run the DropBox client on your workstation
db_id=<999999> #Put your Dropbox ID here
if [[ -f "$1" ]] ; then
cp "$1" $db_home/Public #Only works if you have an Old Style account with magic Public directory
@alecthegeek
alecthegeek / go-install-tools
Last active September 3, 2015 18:18
Set up a "standard" go project workspace with support for 3rdparty modules, version control repo and a template main package
# Install all the Go tools and godep tool
# Location of gobin is based on installation by OS X Homebrew
sudo -u admin GOPATH=/tmp GOBIN=/usr/local/opt/go/bin go get -u golang.org/x/tools/cmd/...
sudo -u admin GOPATH=/tmp GOBIN=/usr/local/opt/go/bin go get -u github.com/tools/godep
#!/bin/bash
# manage Tmux
if [ -n "$TMUX" ]; then # in tmux
if [ -n "$COLORTERM" ]; then # in rich VT
export TERM=xterm-256color-italic
fi
elif tmux list-sessions > /dev/null 2>&1 ; then
tmux attach # try to attach
#! /usr/bin/env sh
# Set up some shit dependeing on primary mac address
if=en0 # Change this is you don't want to use primary
updateHost() {
# $1 = ip address
# $2 = hostname
# $3 = interface name
@alecthegeek
alecthegeek / setup_wifi.sh
Last active August 29, 2015 14:13
Setup up a wifi interface
#!/bin/sh
ssid=$1; shift
psk=$1; shift
network_id=$(wpa_cli list_networks | tail -n +3 | grep $ssid |cut -f 1)
if [ -z $network_id ] ; then
maxNetworkId=$(wpa_cli list_networks | tail -n +3 | tail -n 1| cut -f 1)]
if [ -z $maxNetworkId ] ; then
@alecthegeek
alecthegeek / wpa_supplicant.sh
Created January 13, 2015 06:54
Add a network to the wpa_supplicant.conf
#!/bin/dash
ssid=$1 ;shift
psk=$1; shift
# Is this network already defined?
network_id=$(wpa_cli list_networks | tail -n +3 | grep $ssid |cut -f 1)
if [ -z $network_id ] ; then
maxNetworkId=$(wpa_cli list_networks | tail -n +3 | tail -n 1 | cut -f 1)]
@alecthegeek
alecthegeek / ackermann.go
Last active August 29, 2015 14:17
Simple Ackermann function
// Niave implementation of the Ackermann function
// https://en.wikipedia.org/wiki/Ackermann_function
package main
import "fmt"
func Ackermann(m, n uint) uint {
//fmt.Printf("Called Ackermann(%d,%d) ", m, n)
if m == 0 {
return n + 1