Skip to content

Instantly share code, notes, and snippets.

View shoenig's full-sized avatar
🪁
lets Go

Seth Hoenig shoenig

🪁
lets Go
View GitHub Profile
@shoenig
shoenig / KMP.java
Created December 4, 2011 17:19
Knuth-Morris-Pratt String Searching in Java
public class KMP {
public static void main(String abc[]) {
System.out.println("Testing KMP");
test("abc", "a", 0);
test("abc", "b", 1);
test("abc", "c", 2);
test("abc", "d", -1);
test("catdog", "tdo", 2);
test("ratatat", "at", 1);
test("foo", "", 0);
@shoenig
shoenig / BM.java
Created December 4, 2011 17:21
Boyer-Moore String Searching in Java
public class BM {
public static void main(String[] abc) {
System.out.println("Testing BM");
test("abc", "a", 0);
test("abc", "b", 1);
test("abc", "c", 2);
test("abc", "d", -1);
test("catdog", "tdo", 2);
test("ratatat", "at", 1);
test("foo", "", 0);
@shoenig
shoenig / RK.java
Created December 5, 2011 15:54
Rabin-Karp String Searching in Java
public class RK {
public static void main(String[] abc) {
testHash("abc", 0, 3, 294, 0); // abc
testHash("abc", 0, 2, 195, 0); // ab
testHash("abc", 1, 2, 197, 195); // bc
testHash("rompy", 1, 3, 332, 334); // omp
System.out.println("Testing RK");
test("abc", "a", 0);
@shoenig
shoenig / tp.py
Created January 20, 2012 04:54
turn touchpad on/off
#!/usr/bin/env python
# this is embarrassingly written in python
import sys
import os
if (len(sys.argv) != 2) or (sys.argv[1] not in ('on', 'off')):
print 'Usage: tp [on/off]'
else:
if sys.argv[1] in ('on',):
@shoenig
shoenig / quotes.txt
Last active October 6, 2015 19:37
quotes
Ryan: I hope some day in the near future linus torvalds is on film taking a shit in front of the door to a canonical office pointing to it and saying "THIS IS WHAT YOU DID TO MY BABY!"
<eck> QOTW, "Rob, I'm sure you're focused on recovering things at the comment. When the dust settles, you might want to ask your team how "PHP", "personal www dir" and "business critical app" were ever grouped together."
<eck> this is on a ticket i'm handling
<thoughtpolice> FML
<thoughtpolice> i'm totally getting bitten by this linux leapsecond futex bug
<x[LGWs4x4i]uG2N0> ha ha
<x[LGWs4x4i]uG2N0> he uses linux
<x[LGWs4x4i]uG2N0> laughinggirls.jpg
<mserrano> int mean(int x, int y) { return (x & y) + ((x ^ y) >> 1); }
@shoenig
shoenig / ws
Created January 15, 2013 23:34
script for removing trailing whitespace from files
#!/usr/bin/awk -f
# accumulate a run of white-space-only lines so they can be printed or discarded
/^[[:space:]]*$/ {
accumlines = accumlines nl $0
nl = "\n"
accum = 1
next
}
@shoenig
shoenig / gist:8467283
Created January 17, 2014 02:05
Worthwhile GNOME Shell extensions
https://extensions.gnome.org/extension/584/taskbar/
@shoenig
shoenig / mqtt-sequential.go
Created January 30, 2014 01:06
MQTT sequential publisher or subscriber
/*
* Copyright (c) 2013 IBM Corp.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Seth Hoenig
junit.framework.AssertionFailedError:
Expected :1399352399000
Actual :1399352399000
<Click to see difference>