Skip to content

Instantly share code, notes, and snippets.

@pete
pete / 0README
Created March 11, 2013 21:34
See 0README. Power management.
These change the background color in X (and I think they don't work if you are
using a desktop system, so the `xset` command ought to be changed for whatever
Gnome/KDE/LXDE/XFCE/ASDFJKLSEMICOLON thing you are using if you are using such a
thing) based on battery power remaining. The Lua one requires luaposix to be
installed.
The reason there are two versions is that Ruby was, when it ought to have been
sleeping, doing some select() loop. I figured Lua would not do that to me, and
it does not. (Porting is usually more fun than fighting the language.)
@pete
pete / gist:4694295
Created February 1, 2013 21:31
Ridiculous nonsense.
#!/usr/bin/env ruby
# Hey, wanna see something fun?
#
# My disk broke. Thinking quickly, I decided to harness the unlimited power of
# User Error, and partially wreck my backup.
#
# Don't ask.
#
# md0 had most of the data. But the filesystem and partition table were
# wrecked, and some unknown amount of data had been exchanged between it and
@pete
pete / tac.b
Created October 8, 2012 20:38
"tac", ported to Limbo as an example.
implement Tac;
include "sys.m"; sys: Sys;
include "bufio.m"; bufio: Bufio; Iobuf: import bufio;
include "draw.m";
Tac: module {
init: fn(nil: ref Draw->Context, args: list of string);
};
#!/bin/sh
dropdb thedb
createdb thedb
ssh root@host5 /usr/local/pgsql/bin/pg_dump \
gzip -c \| \
tee prod.db.gz | \
gunzip | \
tee prod-without-audits.sql | \
psql thedb
@pete
pete / jsonpp
Created January 24, 2012 23:10
JSON pretty-printer. Not sophisticated.
#! /usr/bin/env ruby
require 'json'
require 'pp'
mode = :ruby
ARGV.each_with_index { |arg, i|
next unless arg.start_with? ?-
The "/" has to be there before rack even gets to it; you cant do a GET without a path of some sort.
@pete
pete / gist:1152433
Last active September 26, 2015 20:07
Metabolic Fascism!
From Olin Shivers's "opinion file", a collection of posts from the "Opinion
Bboard" at CMU ( http://www.ccs.neu.edu/home/shivers/opinion.html ):
17-May-89 12:18 Hans.Tallis@ML metabolic fascism
Article 106 of ics.whimsey:
>From: David A Honig <[email protected]>
Subject: Metabolic Fascism
Lines: 144
------------------------------------------------------------------------
@pete
pete / 0README
Created August 7, 2011 00:15
Twitter 1x1 tracking gif URLs
I was looking at the traffic New Twitter was sending across, having
opened Firebug to see just how wide the content was (too wide for my
848px-wide phone at 920px). I kept seeing 1x1 transparent .gifs, which
all True Patriots have been at war with since the 90s, so I was curious
as to what they were doing in there. There was nothing interesting in
the headers (except the expected six or so different ways to instruct
all browsers everywhere to not cache the content), but the URLs are
huge.
As far as I can tell from the five or six URLs I looked at, it's just
@pete
pete / gist:1096147
Created July 20, 2011 23:06
Awk script to install Ruby.
#!/usr/bin/awk -f
# Assuming no Ruby installation, gets and installs Ruby, Rubygems (if 1.8), and
# bundler and isolate (latest versions). If your OS is detected as Debian (or
# Ubuntu), the prerequisites for compiling Ruby will be installed. Other OS's
# either aren't supported, don't need this script, or perhaps I didn't consider
# them.
# If you pass -h, help, -help, or --help, you'll get some helpful info about how
# to control the script.
Here I have started sqlite3 and pointed it at the xmms2 database.
Note the columns "id", "key", and "value": it is a bad, one-level
key/value store done in sqlite3. The sound file used as an example
is apparently shipped with xmms2.
sqlite> select * from Media where id = 1;
id,key,value,source,intval
1,added,1301974718,1,1301974718
1,album,Dreamweb,4,
1,artist,mind.in.a.box,4,