This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Given a logfile with pairwise loglines when an event starts, and when it finishes, | |
# this script plots the duration for the events. | |
# Feed me a log file with rows like these: | |
# 2014-07-21 07:50:03,440 INFO Begin job | |
# 2014-07-21 07:52:50,530 INFO End job | |
# 2014-07-21 08:00:03,044 INFO Begin job | |
# 2014-07-21 08:02:02,548 INFO End job |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Build shell command completions | |
# | |
function _build_completions { | |
local current_word | |
COMPREPLY=() | |
current_word=${COMP_WORDS[COMP_CWORD]} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gdb -batch -ex 'call close(3)' -p <PID> # closes file descriptor 3 for process with <PID> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val primes: Stream[Int] = 2 #:: Stream.from(3).filter { n => !primes.takeWhile(_ <= math.sqrt(n)).exists(n % _ == 0) } | |
def isPrime(n: Int) = primes.dropWhile(_ < n).head == n |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* <b>Fixed Point Combinator is:</b> | |
* Y = λf.(λx.f (x x)) (λx.f (x x)) | |
* | |
* <b>Proof of correctness:</b> | |
* Y g = (λf . (λx . f (x x)) (λx . f (x x))) g (by definition of Y) | |
* = (λx . g (x x)) (λx . g (x x)) (β-reduction of λf: applied main function to g) | |
* = (λy . g (y y)) (λx . g (x x)) (α-conversion: renamed bound variable) | |
* = g ((λx . g (x x)) (λx . g (x x))) (β-reduction of λy: applied left function to right function) | |
* = g (Y g) (by second equality) [1] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ######################################################################### | |
# This bash script adds tab-completion feature to django-admin.py and | |
# manage.py. | |
# | |
# Testing it out without installing | |
# ================================= | |
# | |
# To test out the completion without "installing" this, just run this file | |
# directly, like so: | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class selfdestructing_tempdir(object): | |
def __enter__(self): | |
import tempfile | |
self._tempdir = tempfile.mkdtemp() | |
return self._tempdir | |
def __exit__(self, type, value, traceback): | |
import shutil | |
shutil.rmtree(self._tempdir) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exec 4<>/dev/tcp/gopher.meulie.net/70 | |
echo "" >&4 | |
cat <&4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time.sleep | |
import zmq | |
context = zmq.Context() | |
socket = context.socket(zmq.PUB) | |
socket.bind('tcp://127.0.0.1:2000') | |
# Allow clients to connect before sending data | |
sleep(10) | |
socket.send_pyobj({1:[1,2,3]}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SECRET_BREAKOUT_RETURN_CODE=119 | |
while scala; [ $? != $SECRET_BREAKOUT_RETURN_CODE ] ; do continue; done |