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 / 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
#!/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
@alecthegeek
alecthegeek / goinstallbinaries.sh
Created June 13, 2015 06:02
Using Vim and Vundle when developing Go code?
GOPATH=/tmp/$$.installgobin GOBIN=$(go env GOROOT)/bin vim -u ~/.vimrc -c ":GoInstallBinaries" -c ":q" /tmp/src/$$.go
@alecthegeek
alecthegeek / deletesillycupsfiles
Created July 4, 2015 05:19
Remove spurious CUPS files created in /tmp
#!/usr/bin/env sh
# Remove spurious CUPS files created in /tmp
find /private/tmp -maxdepth 1 -type l -name 55\*|sudo xargs rm
@alecthegeek
alecthegeek / manageCloudStorageSync.sh
Created July 27, 2015 13:07
Pauses and Resumes data sync with cloud storage services
#!/usr/bin/env bash
# Pause the following Cloud Storage Services
services=('Google Drive' Copy Dropbox)
# Based on ideas and code on https://github.com/tjluoma/dropbox-pause-unpause
if [[ $0 =~ pause || $1 =~ pause ]] ; then
command=STOP