Skip to content

Instantly share code, notes, and snippets.

View jesboat's full-sized avatar

Jade Sailor jesboat

  • Boston, MA
View GitHub Profile
#!/usr/bin/perl
use strict;
use warnings;
use Errno;
use IO::Socket::INET;
my $sock = IO::Socket::INET->new(
LocalPort => 6666,
ReuseAddr => 1,
@jesboat
jesboat / ProxySample.java
Created April 3, 2014 02:13
Sample of using `java.lang.reflect.Proxy`
package scratch;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Arrays;
public class ProxySample {
@jesboat
jesboat / hist.sh
Last active August 29, 2015 13:57
Simple histogram
hist() {
local sortopts1= sortopts2=
while [[ $# != 0 && "$1" == -* ]]; do
if [ "$1" = -r ]; then
sortopts2=-r
elif [ "$1" = -n ]; then
sortopts1=-n
elif [[ "$1" = -rn || "$1" = -nr ]]; then
sortopts1=-n sortopts2=-r
else
@jesboat
jesboat / Eep.java
Created September 13, 2013 20:55
Don't try this at home.
public class Eep {
class Foo {
final int bar;
Foo() {
Eep.this.foo = this;
if (true) {
throw new RuntimeException("lolol");
}
bar = 42;
@jesboat
jesboat / youtube-account.pl
Created July 10, 2013 17:31
Script to upload cs173 lecture videos (as seen on http://cs.brown.edu/courses/cs173/2012/Videos/) to YouTube.
$USER = 'foo@gmail.com';
$PASS = 'abc123';
@jesboat
jesboat / fgrep.sh
Created July 6, 2013 03:19
fgrep in sh (maybe bashisms)
fgrep() {
# Parse options
local dashv=0 dashq=0 dashx=0 opt= OPTIND=1
local usage='
echo "Usage: fgrep [-vqx] string" >&2;
return 1;
'
while getopts "vqx" opt; do
case "$opt" in
quicksort lst = case lst of
pivot:rest -> (quicksort less) ++ [pivot] ++ (quicksort grtr) where
less = filter (<= pivot) rest
grtr = filter (> pivot) rest
empty -> empty
@jesboat
jesboat / xml2text.pl
Created March 28, 2013 22:25
Parse a libpurple buddy list XML file, and print in a simple one-per-line text format. Include whether the buddy lives on the same server as your account. (Assumes all buddies/accounts have user@domain style IDs, for example, XMPP.)
#!/usr/bin/perl
use strict;
use warnings;
use 5.012;
use XML::XPath;
my $xp = XML::XPath->new(filename => 'blist.xml');
@jesboat
jesboat / oops.php
Last active December 15, 2015 03:59
<?php
$a = "blah blah blah --";
$b = "img src=http://jesnetplus.com/evil.js width=400 height=400 alt=hi";
?>
<!DOCTYPE html>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Broken</title>
@jesboat
jesboat / amazon-wishlist-to-csv.pl
Created March 1, 2013 20:43
Convert a HTML dump of an amazon.com wishlist to a CSV.
#!/usr/bin/perl
use strict;
use warnings;
use open qw(:utf8 :std);
use HTML::TreeBuilder;
use XML::XPath;
use HTML::Entities;
use Text::CSV;