Skip to content

Instantly share code, notes, and snippets.

@rupa
rupa / capslockenforcementbot
Created October 21, 2009 01:03
ENFORCEMENT BOT FOR CAPSLOCKDAY 10/22
#!/usr/bin/perl
use POSIX;
use IO::Socket;
#fork && exit;
setsid;
$nick = "CAPSLOCKENFORCEMENTBOT";
@rupa
rupa / README
Created June 19, 2009 05:15
pure shell version of http://github.com/rupa/j2
z is the new j
First, there was [j](http://github.com/rupa/j/).
Then, there was [j2](http://github.com/rupa/j2/), with some python added. Made
it easier to experiment with some stuff I'd been thinking about.
Now there's this, where I rewrote j2 back in bash. I like it. Sorry about all
the repos , but it kind of grew this way.
# change part of pwd path, and cd to it
# example:
# /usr/lib/foo$ cx lib src
# /usr/src/foo$
# slashes need double escaping: \\/
# surprisingly, most everything else doesn't
cx() {
local cd="$PWD"
while [ $1 ]; do
cd="$(echo $cd | sed "s/$1/$2/")"
function rat {
# change part of pwd path, and cd to it
# example:
# /usr/lib/foo$ rat li src
# /usr/src/foo$
local cd=$(echo $PWD | awk -v q="$*" -F\/ '
BEGIN { l = split(q,a," ") }
{
for( i=1;i<=NF;i++ ) {
for( j=1;j<=l;j=j+2 ) {
function rat {
# change part of pwd path, and cd to it
# example:
# /usr/lib/foo$ rat li src
# /usr/src/foo$
local cd=$(echo $PWD | awk -v q="$*" -F\/ '
BEGIN { l = split(q,a," ") }
{
for( i=1;i<=NF;i++ ) {
for( j=1;j<=l;j=j+2 ) {
@rupa
rupa / screc.sh
Created June 1, 2009 23:02
screencaps to video
#!/bin/bash
# OSX requires Quicktime Pro, linux requires scrot and mencoder
# jpg faster/png higher quality
FORMAT=jpg
usage() {
cat <<!
use: $(basename $0) -c <path/to/empty/folder> [seconds]
$(basename $0) -o <path/to/empty/folder>
@rupa
rupa / README
Created February 23, 2009 07:08
experimental directory navigation
# cd to the shortest, first, non-hidden dir under $root matching all args
#
# USE:
# alias alias=root=root __h [--]
#
# DESCRIPTION
#
# This provides a helper function (__h) meant to be used with aliases to do
# smart directory navigation
#
@rupa
rupa / j.sh
Created February 16, 2009 17:28
# maintains a jump-list of directories you actually use
# old directories eventually fall off the list
# inspired by http://wiki.github.com/joelthelion/autojump
# and something similar i had - but i could never get the dir list right.
#
# INSTALL:
# source into .bashrc under your '[-z "$PS1" ] || return' line
# cd around for a while
#
# USE:
@rupa
rupa / ewmh
Created January 29, 2009 16:48
EWMH
this module is mostly for making your workspace switcher function properly in GNOMe, KDE, or any other EWMH desktop.
import XMonad.Hooks.EwmhDesktops
This module only has three user facing functions.
There is a function for your layout hook that tells xmonad what EWMH is doing. It lets you click/drag windows in the workspace switcher:
myLayout = ewmhDesktopsLayout
@rupa
rupa / gist:47475
Created January 15, 2009 16:41
lan detection
#!/bin/bash
function wireless {
case "$(uname)" in
Linux)/sbin/iwconfig 2>/dev/null | awk -F\" '/ESSID/&&!/NOT READY/{print $2}';;
Darwin)/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I | awk '/ SSID/{print $2}';;
esac
}
function int_ip {