Skip to content

Instantly share code, notes, and snippets.

View mnem's full-sized avatar

Dave Clayton-Wagner mnem

View GitHub Profile
@mnem
mnem / pester.sh
Created January 7, 2012 18:22
Spammer takes over friends account, utilise scripting for minor lulz
# One `brew install watch` later...
watch -n 5 ./pester.sh
@mnem
mnem / pwgen_a.sh
Created January 5, 2012 20:07
Quick 'n' dirty password generation commands for *nix/mac
# Will generate passwords up to 76 characters long.
#
# Change the 20 at the end to change the length.
dd if=/dev/urandom count=1 2> /dev/null | base64 | sed -ne 2p | cut -c-20
@mnem
mnem / ebook_select_ipad_versions.rb
Created December 26, 2011 15:43
Script to look in each subfolder containing ebook files and select the 'best' candidates for chucking on an iPad
#!/usr/bin/env ruby
require "fileutils"
output_folder_name = "_ipad_selection"
output = File.expand_path File.join(Dir.pwd, output_folder_name)
selected = []
# Gather folders to look at
folders = Dir.glob(%w{*/*.epub */*.pdf}).map {|file| File.dirname file}
folders.delete_if { | item | item.match(/^#{output_folder_name}/)}
@mnem
mnem / ebook_tidy_to_subfolders.rb
Created December 26, 2011 15:41
Script to move and group all ebook files in the current folder into a pretty named subfolder.
#!/usr/bin/env ruby
require "fileutils"
folder_map = {}
def make_folder_name name
return name.gsub /_/, " "
end
# Gather all the files in this directory
@mnem
mnem / test.sh
Created December 14, 2011 18:06
#!/bin/sh
echo Tilde:~
echo HOME:$HOME
if [ `whoami` != 'root' ]; then
sudo $0 $* || exit 1
fi
@mnem
mnem / alias_pbcopy_pbpaste.sh
Created December 7, 2011 16:35
pbcopy and pbpaste for linux
# Emulate pbcopy and pbpaste for copying to and from the pasteboard/clipboard
#
# via: http://whereswalden.com/2009/10/23/pbcopy-and-pbpaste-for-linux/
alias pbcopy='xsel --clipboard --input'
alias pbpaste='xsel --clipboard --output'
@mnem
mnem / git_fetch_pull_all_subfolders.sh
Created December 6, 2011 14:35
Simple bash script for fetching and pulling all repos in the executed folder to the latest of the branch they are on
#!/bin/bash
################
# Uncomment if you want the script to always use the scripts
# directory as the folder to look through
#REPOSITORIES="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
REPOSITORIES=`pwd`
IFS=$'\n'
@mnem
mnem / Recipe - Scottish Tablet.md
Created November 4, 2011 17:44
My Mum's family recipe for tablet. It's awesome. Imagine a neutron star made from sugar. It'd be a bit like this.

Scottish Tablet

  • 397g tin of sweetened condensed milk. Don't confuse this with evaporated milk.
  • 200ml milk
  • 1kg sugar
  • A piece of butter around the size of a walnut

Method

@mnem
mnem / gist:1285665
Created October 13, 2011 22:00
Python: Hacking in a new builtin
def mnemlog(message):
import datetime
mnemlog = open("/Users/mnem/mnemlog","a+",0)
mnemlog.write(str(datetime.datetime.now()) + " " + message + "\n")
mnemlog.close()
mod = __import__("__builtin__");
mod.mnemlog = mnemlog
mnemlog("It has been done")
getSize(a):4
getSize(b):4
getSize(TestClass):880
getSize(this):428
getSize(a):4
getSize(aa):4
getSize(b):4
getSize(TestClass):884
getSize(this):428