Skip to content

Instantly share code, notes, and snippets.

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
View keybase.md

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 Aug 29, 2015
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
View dbshare.sh
#! /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
View tmux_manager.sh
#!/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
View hackip.sh
#! /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 Aug 29, 2015
Setup up a wifi interface
View setup_wifi.sh
#!/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 Jan 13, 2015
Add a network to the wpa_supplicant.conf
View wpa_supplicant.sh
#!/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 Aug 29, 2015
Simple Ackermann function
View ackermann.go
// 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 Jun 13, 2015
Using Vim and Vundle when developing Go code?
View goinstallbinaries.sh
GOPATH=/tmp/$$.installgobin GOBIN=$(go env GOROOT)/bin vim -u ~/.vimrc -c ":GoInstallBinaries" -c ":q" /tmp/src/$$.go
@alecthegeek
alecthegeek / deletesillycupsfiles
Created Jul 4, 2015
Remove spurious CUPS files created in /tmp
View deletesillycupsfiles
#!/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 Jul 27, 2015
Pauses and Resumes data sync with cloud storage services
View manageCloudStorageSync.sh
#!/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