Skip to content

Instantly share code, notes, and snippets.

View pefoley2's full-sized avatar

Peter Foley pefoley2

View GitHub Profile
@pefoley2
pefoley2 / migrate.sh
Last active August 29, 2015 13:55
ircbot sqlite->postgres
#!/bin/bash
set -e
dbname="msbob"
sqlite3 db.sqlite .dump >dump
sed -i -e "/PRAGMA/d" -e "/sqlite_sequence/d" -e "s/INTEGER PRIMARY KEY AUTOINCREMENT/SERIAL PRIMARY KEY/g" dump
dropdb --if-exists $dbname
createdb -O ircbot $dbname
cat dump | psql -U ircbot -q $dbname
rm dump
@pefoley2
pefoley2 / gist:8022705
Created December 18, 2013 13:52
usb bootable script
MIRROR="distfiles.gentoo.org"
ISO=`wget -q -O - http://$MIRROR/releases/amd64/autobuilds/latest-iso.txt | grep -v \# | sed "s#/.*##"`
wget -N http://$MIRROR/releases/amd64/autobuilds/$ISO/install-amd64-minimal-$ISO.iso
7z e -y install-amd64-minimal-$ISO.iso image.squashfs isolinux/gentoo isolinux/gentoo.igz
read -p "Enter block device to format (blank to skip): " DEV
if ! test -z $DEV; then
[ `id -u` != 0 ] && echo "must be root" && exit
dd if=/dev/zero of=/dev/$DEV bs=512 count=1
parted /dev/$DEV mklabel msdos
parted /dev/$DEV mkpart primary 0% 100%
@pefoley2
pefoley2 / gist:7781810
Created December 4, 2013 03:18
cross!
set -e
set -o pipefail
TOPDIR=`pwd`
BUILD=`/usr/share/gnuconfig/config.guess`
TARGET=$1
DIR=$TOPDIR/$TARGET
export ARCH=`echo $TARGET | sed 's/-.*//'`
if test -z $TARGET; then
echo "Error: must specify target"
echo "Usage: ./cross.sh alpha-linux"
@pefoley2
pefoley2 / gist:7781803
Created December 4, 2013 03:18
canada!
set -e
set -o pipefail
TOPDIR=`pwd`
BUILD=`/usr/share/gnuconfig/config.guess`
HOST=$1
TARGET=$2
HOST_DIR=$TOPDIR/$HOST
TARGET_DIR=$TOPDIR/$TARGET
CROSS_DIR=$TOPDIR/cross-$HOST-$TARGET
export HOSTARCH=`echo $HOST | sed 's/-.*//'`
@pefoley2
pefoley2 / gist:6756788
Created September 29, 2013 21:36
largest files in cslbot
100 ./commands/microwave.py
108 ./helpers/command.py
115 ./commands/weather.py
117 ./commands/quote.py
139 ./helpers/server.py
221 ./bot.py
222 ./commands/vote.py
235 ./helpers/control.py
459 ./handler.py
@pefoley2
pefoley2 / Fun.java
Last active December 24, 2015 02:38
horrible things with java.
import jnr.posix.*;
import jnr.constants.platform.*;
import java.io.*;
public class Fun {
public static void main(String[] args) throws Segfault {
throw new Segfault();
}
}