Skip to content

Instantly share code, notes, and snippets.

View jesboat's full-sized avatar

Jade Sailor jesboat

  • Boston, MA
View GitHub Profile
@jesboat
jesboat / gist:2728469
Created May 19, 2012 01:17
Packet trace for ServerFault question http://serverfault.com/questions/390558
No. Time Source Destination Protocol Length Info
1 0.000000 10.116.254.17 10.116.254.1 NFS 172 V3 GETATTR Call (Reply In 2), FH:0xbec98b1c
Frame 1: 172 bytes on wire (1376 bits), 172 bytes captured (1376 bits)
Internet Protocol Version 4, Src: 10.116.254.17 (10.116.254.17), Dst: 10.116.254.1 (10.116.254.1)
Transmission Control Protocol, Src Port: 798 (798), Dst Port: nfs (2049), Seq: 1, Ack: 1, Len: 120
Remote Procedure Call, Type:Call XID:0x2f8a18a9
Fragment header: Last fragment, 116 bytes
1... .... .... .... .... .... .... .... = Last Fragment: Yes
.000 0000 0000 0000 0000 0000 0111 0100 = Fragment Length: 116
@jesboat
jesboat / chrome-bug.html
Created August 19, 2012 03:22
This exhibits a bug in Chrome's JS engine
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<title>Rawr</title>
<p>JS follows
<pre>
<script type="text/javascript">
function wr(str) {
document.write(str + "<br>");
}
var a = {valueOf: function(x) { wr("a"); return 1; }};
var b = {valueOf: function(x) { wr("b"); return 2; }};
#!/usr/bin/perl
use strict;
use warnings;
{
package Base;
sub scan_stash {
my ($for, $stash, $seen) = @_;
if (my $glob = $stash->{$for}) {
@jesboat
jesboat / rev.cpp
Created February 3, 2013 18:22
Reversing a singly linked list in O(n) time with a single extra node reference.
#include <vector>
#include <ostream>
#include <iostream>
#include <string>
#include <cstdlib>
struct Node {
Node *next;
int val;
Node(Node *n, int v) : next(n), val(v) { }
@jesboat
jesboat / friends.pl
Created February 19, 2013 07:29
A quick hack to Graphviz-ify your Facebook friends.
#!/usr/bin/perl
use strict;
use warnings;
use WWW::Mechanize;
use JSON::Syck qw(Load Dump);
use DB_File;
my $URL = 'https://graph.facebook.com/%s?method=GET&format=json&access_token=XYZ';
@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;
@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 / 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');
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 / 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