Skip to content

Instantly share code, notes, and snippets.

@wx13
wx13 / wman.sh
Created July 7, 2010 18:36
script to find man pages on the web
#!/bin/bash
tmpfile=/tmp/wman.$RANDOM
cmd=$1
for n in $(seq 1 8)
do
w3m -dump http://linux.die.net/man/${n}/${cmd} > $tmpfile
answ=$(head -n1 $tmpfile)
if [ "${answ}" != "Not Found" ]
then
@wx13
wx13 / latex2png.sh
Created July 19, 2010 21:53
bash script to convert a latex equation into a png image
#!/bin/bash
alias latex='/usr/bin/latex'
alias dvipng='/usr/bin/dvipng'
alias convert='/usr/bin/convert'
#choose a number from 75-300
density=300
if [ $# != 2 ]
then
echo "Usage: $0 output_file latex_code"
@wx13
wx13 / days.rb
Created July 19, 2010 22:07
ruby script to generate list of days in a year
#!/usr/bin/ruby
require 'date'
weekday = ["Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"]
month = ["", "January", "February", "March", "April", "May",
"June", "July", "August", "September", "October",
"November", "December"]
@wx13
wx13 / days.rb
Created July 19, 2010 22:14
stuff for creating homework sheets
#!/usr/bin/ruby
require 'date'
weekday = ["Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"]
month = ["", "January", "February", "March", "April", "May",
"June", "July", "August", "September", "October",
"November", "December"]
@wx13
wx13 / killer.sh
Created July 19, 2010 22:18
kill jobs easily
#!/bin/bash
str=$1
list=$(ps -asW | grep ${str})
#list=$(ps -asW | grep ${str} | awk '{print "[" NR "]", $0}')
OLDIFS=${IFS}
IFS=`echo -en "\n\b"`
i=0
for line in ${list}
do
i=$((i+1))
@wx13
wx13 / clac.sh
Created July 19, 2010 22:22
simple way to use awk as a calculator
#!/bin/bash
calc_str=$1
echo Example: clac \'5*3\' | \
awk "
BEGIN{
pi = 3.14159265359;
}
{print ${calc_str}}"
@wx13
wx13 / gist:959395
Created May 6, 2011 17:35
set terminal window title
function chtt {
echo -en "\033]2;$@\007"
}
@wx13
wx13 / gist:959399
Created May 6, 2011 17:36
expand paths in history when using cd
function cd_save_hist() {
if [ -z "$1" ]
then
d="$HOME"
else
d="$1"
fi
builtin cd "$d"
dp=$(pwd)
history -s cd ${dp}
@wx13
wx13 / gdiff.sh
Created June 3, 2011 19:59
bash script to colorize diff output, kind of like git does
#!/bin/bash
RED=`echo -e '\033[31m'`
GREEN=`echo -e '\033[32m'`
BLUE=`echo -e '\033[36m'`
YELLOW=`echo -e '\033[33m'`
NORMAL=`echo -e '\033[0m'`
diff -uN $@ \
| sed "s/^@@.*@@/$BLUE&$NORMAL/g" \
@wx13
wx13 / jedi.bat
Created March 9, 2012 23:23
windows batch script to open a file in a cygwin editor (replace "jedi" with editor of your choice)
@echo off
C:
chdir C:/Users/jdevita/cygwin/bin
set HOME=\Users\jdevita\cygwin\home\jdevita
echo %1 > C:/Users/jdevita/cygwin/tmp/temp.txt
bash --login -i -c "jedi \"$(sed -e 's/\"//g' -e 's/\([A-Z]\):/\/cygdrive\/\1/' -e 's/\\\/\//g' -e 's/ *$//' /tmp/temp.txt)\""