Skip to content

Instantly share code, notes, and snippets.

@rupa
rupa / hack.sh
Created April 7, 2012 01:46 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
function! SuperTab()
if (strpart(getline('.'),col('.')-2,1)=~'^\W\?$')
return "\<Tab>"
else
return "\<C-n>"
endif
endfunction
function! SuperShiftTab()
if (strpart(getline('.'),col('.')-2,1)=~'^\W\?$')
return "\<S-Tab>"
#!/bin/bash
# rly dum markov
# db file
db=~/.smirnoff.db
# min length of chain to learn
min=3
function help {
echo "$(basename $0) [ -init | -cram | -help ]"
@rupa
rupa / capslockenforcementbot
Created October 22, 2010 21:27
capslock enforcement bot
#!/usr/bin/perl
use POSIX;
use IO::Socket;
use utf8;
use Encode;
#fork && exit;
setsid;
@rupa
rupa / sshh_functions.sh
Created October 12, 2010 05:57
ssh/scp through NAT
# ssh/scp through NAT, as long as $outer has nc
# ssh v5.4+ should allow ssh -oProxyCommand="ssh -W $inner:%p" $outer $*
# hosts could also be defined in .ssh/config:
# Host foo
# hostname inner
# ProxyCommand ssh outer nc -w 1 %h %p
sshh() {
[ "$1" = "-h" ] && {
echo "sshh [opts] outer inner [cmd]"
return
@rupa
rupa / hhgttg.summarized.txt
Created June 16, 2010 23:02
Douglas Adams v. Open Text Summarizer
Hitchhiker's Guide To The Galaxy 1-5
summarized with Open Text Summarizer at ratio of 1%
http://libots.sourceforge.net/
-------------------------------------------------------------------------------
I
Mr Prosser's mouth opened and closed a couple of times while his mind was for a
@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 ) {