Skip to content

Instantly share code, notes, and snippets.

View zmughal's full-sized avatar
🌿
fiddling with attribute grammars.

Zaki Mughal [sivoais] zmughal

🌿
fiddling with attribute grammars.
View GitHub Profile
@zmughal
zmughal / gist:770604
Created January 8, 2011 06:14
Shell stocks plot
#!/bin/sh
YEAR0="2008"; YEAR1="2010"; STOCK="IBM"; wget -qO- "http://ichart.finance.yahoo.com/table.csv?s=$STOCK&a=00&b=1&c=$YEAR0&d=11&e=31&f=$YEAR1&g=d" \
| cut -d, -f1,7 \
| sort -n \
| grep -v Date \
| gnuplot -p -e \
"set datafile separator ',';
set xdata time; set timefmt '%Y-%m-%d';
set format x \"%b %d\\n%Y\";
plot '-' using 1:2 with lines title '$STOCK'"
#!/bin/sh
mkdir ~/build
cd ~/build
wget "http://prdownloads.sourceforge.net/wine/wine-1.3.9.tar.bz2"
tar -xvf "wine-1.3.9.tar.bz2"
cd wine-1.3.9
# http://bugs.winehq.org/show_bug.cgi?id=16822#attach_32614
wget -O ME_mouse_id_32614.patch http://bugs2.winehq.org/attachment.cgi?id=32614
@zmughal
zmughal / wchoose.sh
Created February 18, 2011 05:09
Window chooser
#!/bin/sh
# reqs: wmctrl, zenity
wmctrl -l \
| sed 's/\([^ ]\+\) \+\([^ ]\+\) \+\([^ ]\+\) \+\(.*\)$/\1:\4/' \
| grep -v "^0x[0-9a-f]\+:$" \
| sed 's/\(0x[0-9a-f]\+\):\(.\+\)/\1\n\2/' \
| zenity --list --title "Windows" --text "Window list" --column="ID" \
--column "Window" --hide-column=1 \
| xargs wmctrl -i -a
@zmughal
zmughal / ncurses_window_update.pl
Created May 8, 2011 04:01
Note to self: more syntax can make things clean
# this
if($data_pos < @data) {
# data on line
$self->window()->addstr($data[$data_pos]);
} else {
# tilde on line
$self->window()->addstr("~");
}
# or this
@zmughal
zmughal / unicode_underline.sh
Created July 16, 2011 23:16
Unicode underline
# Use diacritic for underlining
perl -CS -ple 's/./$&\x{332}/g'
@zmughal
zmughal / conky_todo.sh
Created September 10, 2011 03:01
conky + todo.pl
#!/bin/sh
BOLD_FONT="Lucida Sans:size=6:bold"
NORM_FONT="Lucida Sans:size=6:normal"
if [ "$1" = "format-color" ]; then
sed 's,\[3\([0-9]\)\(;1\)\?m,${color\1},g' \
| sed 's,\[2m,${font '"$BOLD_FONT"'},g' \
| sed 's,\[0m,${color}${font '"$NORM_FONT"'},g' \
| sed 's/^\(\*\) \([A-Z0-9]\+\)/${color8}\1${color} ${font '"$BOLD_FONT"'}${color4}\2${color}${font '"$NORM_FONT"'}/g'
exit
elif [ "$1" = "format" ]; then
@zmughal
zmughal / rsvp_term
Created October 14, 2011 09:57
Rapid Serial Visual Presentation in the terminal
#!/usr/bin/perl
# Requires: figlet
use Time::HiRes qw/sleep/;
while(<>) {
@F = split;
for my $word (@F) {
print "\n" x 5;
system "figlet", "-tcWf", "big", "$word";
sleep(0.1 + 0.2*(length $word)/3);
@zmughal
zmughal / unicode_smallcaps.pl
Created January 25, 2012 05:20
Unicode fun
#!/usr/bin/perl -CS
%lookup = ( a => "\x{1d00}", b => "\x{299}", c => "\x{1d04}", d => "\x{1d05}",
e => "\x{1d07}", f => "\x{493}", g => "\x{262}", h => "\x{29c}",
i => "\x{26a}", j => "\x{1d0a}", k => "\x{1d0b}", l => "\x{29f}",
m => "\x{1d0d}", n => "\x{274}", o => "\x{1d0f}", p => "\x{1d18}",
q => "\x{1eb}", r => "\x{280}", s => "s", t => "\x{1d1b}",
u => "\x{1d1c}", v => "\x{1d20}", w => "\x{1d21}", x => "x",
y => "\x{28f}", z => "\x{1d22}",);
while(<>) { s,[a-z],$lookup{$&} // $&,ge; print; }
@zmughal
zmughal / fb-ticker-dump-test.pl
Created February 16, 2012 13:46
Use WWW::Scripter to print Facebook ticker to STDOUT.
#!/usr/bin/perl
use strict;
no warnings;# "recursion";
use WWW::Scripter;
use YAML qw/LoadFile/;
use File::HomeDir;
use File::Spec;
use HTML::TreeBuilder::XPath;
@zmughal
zmughal / rsvp_term_tts.pl
Created March 9, 2012 05:27
Rapid Serial Visual Presentation + Festival
#!/usr/bin/perl
# Requires: figlet
use Time::HiRes qw/sleep/;
use IO::File;
use Lingua::Sentence;
my $opt_s = 0;
my $opt_w = 1;
my $opt_q = 0;
while(@ARGV && $ARGV[0] =~ /^-[wsq]$/) {