Skip to content

Instantly share code, notes, and snippets.

View tremby's full-sized avatar

Bart Nagel tremby

View GitHub Profile
@tremby
tremby / gist:1571669
Created January 6, 2012 18:01
sprunge -- simple sprunge script
#!/bin/bash
url=$(curl -F 'sprunge=<-' -H "Expect: " http://sprunge.us 2>/dev/null)
if [ $? -ne 0 ]; then
echo "request failed" >&2
exit 1
fi
if [ $# -gt 0 ]; then
url="$url?$1"
fi
echo $url
@tremby
tremby / gist:1571672
Created January 6, 2012 18:01
8ball -- simple magic 8-ball script with original answers
#!/usr/bin/env ruby
def usage(stdout = false)
stream = stdout ? $stdout : $stderr
bin = File.basename($0)
indent = " " * (bin.length() + "Usage: ".length())
stream.puts("Usage: #{bin} [--help|-h]")
stream.puts(indent + " [--yes|--no|--maybe]")
@tremby
tremby / gist:1571674
Created January 6, 2012 18:02
albumsbylength -- print out all albums in MPD library prefixed with their total length
#!/usr/bin/env python
import mpd
HOST = "localhost"
PORT = 6600
PASS = None
client = mpd.MPDClient()
client.connect(HOST, PORT)
@tremby
tremby / gist:1571676
Created January 6, 2012 18:02
bell -- emit bell
#!/bin/sh
echo -n 
@tremby
tremby / gist:1571679
Created January 6, 2012 18:03
im -- change Pidgin status
#!/bin/bash
purple-remote getstatus &>/dev/null
if [ $? -ne 0 ]; then
exit 1
fi
# get old status and message
if [ -f $HOME/.imstatus ]; then
previousstatus=$(head -n 1 $HOME/.imstatus)
@tremby
tremby / imgur.sh
Last active March 4, 2016 09:16
imgur -- upload an image to Imgur
# This has moved to https://github.com/tremby/imgur.sh
@tremby
tremby / gist:1571684
Created January 6, 2012 18:05
lock -- update status and lock screen
#!/bin/bash
if [ "$(purple-remote getstatus)" = "available" ]; then
setstatus=true
else
setstatus=false
fi
if $setstatus; then
echo "setting away"
im away
@tremby
tremby / gist:1571689
Created January 6, 2012 18:06
np -- print MPD now playing string
#!/bin/bash
np=$(mpc --format "%artist% -- \"%title%\" (##%track% on %album%)" | head -1)
if [[ $np == "volume:"* ]]; then
exit 1
fi
echo "np: $np"
@tremby
tremby / gist:1571691
Created January 6, 2012 18:07
phpman-text -- plain text doc and comments from php.net for a PHP command
#!/usr/bin/env php
<?php
if (!isset($_SERVER["argv"][1])) {
fwrite(STDERR, "No keyword given\n");
exit(1);
}
$xmlstring = @file_get_contents("http://php.net/" . urlencode($_SERVER["argv"][1]));
if ($xmlstring === false) {
@tremby
tremby / gist:1571696
Created January 6, 2012 18:07
plot -- ascii plot of numerical input data
#!/usr/bin/env ruby
def usage(stdout = false)
stream = stdout ? $stdout : $stderr
bin = File.basename($0)
indent = " " * (bin.length() + "Usage: ".length())
stream.puts("Usage: #{bin} [--help|-h]")
stream.puts(indent + " [--vertical]")