Skip to content

Instantly share code, notes, and snippets.

@sirhc
sirhc / tweet.sh
Last active August 29, 2015 14:03
Screen scrape a tweet
#!/bin/bash -eu
curl -sL "$1" \
| perl -l -ne 'm{"text/xml\+oembed"} && m{title=".*? on Twitter: "([^"]*)""} && print $1' \
| perl -pe 's{&#(\d+);}{chr($1)}ge; s{"}{"}g;' \
| perl -pe 's{(https?://t.co/\w+)}{ `curl -s -D- $1 | awk '\''/^location:/{print \$2}'\'' | tr -d "\r\n"` }ge' \
| sed -e :a -e '/^\n*$/{$d;N;};/\n$/ba'
@sirhc
sirhc / gist:11351815
Created April 27, 2014 18:09
GNOME Hacks
gsettings set org.gnome.shell.overrides focus-change-on-pointer-rest false
@sirhc
sirhc / gist:11351036
Created April 27, 2014 17:29
Solarized Links
http://ethanschoonover.com/solarized
https://github.com/altercation/vim-colors-solarized
https://github.com/altercation/mutt-colors-solarized
https://github.com/sigurdga/gnome-terminal-colors-solarized
https://github.com/seebi/dircolors-solarized
https://github.com/huyz/irssi-colors-solarized
@sirhc
sirhc / pony.pl
Created January 13, 2014 22:16
Acme::Pony
use Acme::Pony;
bUf
Fybuff
ybuFFYbuF
fyBUFfYbuFf
YBufFYBuFFyb
uFfYBUffybufF
ybuFfybUff
yBuFfYBuFfy buF
FyBuffYBUfFybuFFY bUfFyB

No web proxy:

$ openssl s_client -showcerts -connect pypi.python.org:443 </dev/null >/dev/null
depth=2 C = US, O = DigiCert Inc, OU = www.digicert.com, CN = DigiCert High Assurance EV Root CA
verify return:1
depth=1 C = US, O = DigiCert Inc, OU = www.digicert.com, CN = DigiCert High Assurance CA-3
verify return:1
depth=0 C = US, ST = California, L = San Francisco, O = "Fastly, Inc.", CN = *.a.ssl.fastly.net
verify return:1

DONE

@sirhc
sirhc / gist:6734348
Created September 27, 2013 19:59
Perl build instructions
cd /tmp
# download perl-5.16.2 from https://metacpan.org/module/perl
gzip -cd perl-5.16.2.tar.gz | tar xf -
cd perl-5.16.2
sh Configure -des \
-Dcf_by=`whoami` \
@sirhc
sirhc / pd.bash
Created June 21, 2013 17:35
Try a bunch of perldoc commands to find documentation, finally failing over to man.
#!/bin/bash
#
# Vim configuration for pd (~/.vim/after/ftplugin/perl.vim):
# :setlocal keywordprg=pd
# :setlocal iskeyword+=:,$,@,%
pd=$(type -P cpandoc)
pd=${pd:-"$(type -P perldoc)"}
$pd -f "$@" 2>/dev/null && exit
@sirhc
sirhc / pd.sh
Created April 5, 2013 16:36
Perldoc/cpandoc wrapper
#!/bin/bash
pd=$(type -P cpandoc)
pd=${pd:-"$(type -P perldoc)"}
$pd -f "$@" 2>/dev/null && exit
$pd "$@" 2>/dev/null && exit
$pd -q "$@" 2>/dev/null && exit
man "$@" 2>/dev/null && exit
@sirhc
sirhc / constitution.pod
Created February 28, 2013 17:56
U.S. Constitution in POD format

NAME

The Constitution of the United States of America

PREAMBLE

We the people of the United States, in order to form a more perfect union, establish justice, insure domestic tranquility, provide for the common defense, promote the general welfare, and secure the blessings of liberty to ourselves and our posterity, do ordain and establish this Constitution for the

@sirhc
sirhc / bogosort.pl
Created September 26, 2012 19:15
Bogosorts in Perl
#!/usr/bin/env perl
use strict;
use List::Util qw( shuffle );
print "Unsorted list: @ARGV\n";
@ARGV = shuffle @ARGV while !is_sorted(@ARGV);
print "Sorted list: @ARGV\n";
sub is_sorted {