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 / 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 / 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 {
#!/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 / enhanced-cd.sh
Created August 14, 2014 20:09
Better version of the enhanced `cd` described in the `iselect(1)` man page
#!bash
# database scan for enhanced cd command
cds() {
(
set -o pipefail
# XXX: handle directories with newlines in their names?
find "$HOME" -type d -print \
| sort -u > "$HOME/.cdpaths"
exit $?
@jesboat
jesboat / big.html
Created August 18, 2014 19:12
You probably don't want to open this
<!DOCTYPE html
PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<title>Blah</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<body>
<script type="text/javascript">
x = "blah";
for (i=0; i<28; i++) {
@jesboat
jesboat / parse-mr-counters.pl
Created August 19, 2014 03:01
Quick script to scrape the counters from a Hadoop jobdetails.jsp page
#!/usr/bin/env perl
use strict;
use warnings;
use XML::XPath;
@ARGV == 1 or die "Usage: $0 infile.xml\n";
my ($infile) = @ARGV;
my $xp;
@jesboat
jesboat / gist:4e628ed93537b9e9ab72
Created August 30, 2014 10:40
Fix a spurious ssh error/warning message
diff -ru OpenSSH-186 2/openssh/ssh.c OpenSSH-186/openssh/ssh.c
--- OpenSSH-186 2/openssh/ssh.c 2013-07-02 16:09:16.000000000 -0700
+++ OpenSSH-186/openssh/ssh.c 2014-08-30 03:32:29.000000000 -0700
@@ -1505,6 +1505,7 @@
u_int n_ids;
char *identity_files[SSH_MAX_IDENTITY_FILES];
Key *identity_keys[SSH_MAX_IDENTITY_FILES];
+ int identity_file_userprovided[SSH_MAX_IDENTITY_FILES];
#ifdef ENABLE_PKCS11
Key **keys;
#!/usr/bin/perl
use strict;
use warnings;
use 5.010;
use autodie;
use File::Temp qw(tempdir);
use File::Spec;
use File::Slurp qw(read_dir);
@jesboat
jesboat / delete-old-branches
Created January 16, 2015 03:09
deletes branches in a git repo not accessed in the last month
#!/usr/bin/perl
use strict;
use warnings;
use autodie;
use Time::Piece;
use Time::Seconds;
use Getopt::Long;
@jesboat
jesboat / pass-by-ref.cpp
Created April 7, 2015 04:20
demo of pass-by-value vs pass-by-reference in C++
#include <iostream>
#include <string>
using std::string;
void passByVal(string passBy) {
passBy = "reference";
}
void passByRef(string &passBy) {