This file contains 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
#!/usr/bin/env python3 | |
from collections import defaultdict | |
import os | |
import sys | |
def read_cmdline(file): | |
try: | |
with open(file, "rb") as f: | |
cmd = str(f.read(), encoding="utf-8") |
This file contains 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 | |
if [ $# -eq 0 ]; then | |
echo "Usage: pwait <PID>" | |
echo "Waits until PID has terminated, then continues." | |
echo "Example: pwait 123 && echo DONE" | |
exit 1 | |
fi | |
for pid in "$@"; do |
This file contains 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
# Fast way to compute the Stirling numbers of the second kind. | |
# https://en.wikipedia.org/wiki/Stirling_numbers_of_the_second_kind | |
from math import factorial | |
def binom(a,b): | |
return factorial(a) / (factorial(b)*factorial(a-b)) | |
def stirling_fast(n,k): | |
"Returns the Stirling number of the second kind." |
This file contains 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
#!/usr/bin/env python | |
""" | |
Starts vim with several possible input formats. | |
Examples: | |
v foo/bar/baz.c # full correct path | |
v baz.c # finds baz.c and edits the first | |
v baz.c:123 # same but start at line 123 | |
v baz.c +123 # same as above |
This file contains 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 | |
# Show all TODO and FIXME from current directory along with who's | |
# responsible. | |
# | |
# Requires parallel to work (unless you want to make everything slow) | |
( find . \( -name '*.cpp' -o \ | |
-name '*.py' -o \ | |
-name '*.h' -o \ |
This file contains 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
#!/usr/bin/env python | |
""" | |
Starts vim with several possible input formats. | |
Examples: | |
v foo/bar/baz.c # full correct path | |
v baz.c # finds baz.c and edits the first | |
v baz.c:123 # same but start at line 123 | |
v baz.c +123 # same as above |
This file contains 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
"""Demonstrates how to construct and send raw Ethernet packets on the | |
network. | |
You probably need root privs to be able to bind to the network interface, | |
e.g.: | |
$ sudo python sendeth.py | |
""" | |
from socket import * |
This file contains 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
TARGETS = a.o foo.o a | |
run: a | |
./a | |
all: $(TARGETS) | |
foo.o: foo.txt | |
ld -r -b binary -o $@ $< |
This file contains 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
/* | |
* Example of heterogeneous arrayo in golang. | |
* | |
* The trick is simply to create an array that accepts elements that conform | |
* to the naked interface (an interface with no requirements). | |
* | |
* Expected output: | |
* | |
* $ go run array.go | |
* [1 2 3.14 hey {10 20}] |
This file contains 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
/* | |
* ================================================= | |
* DAT320 Operating Systems, University of Stavanger | |
* | |
* LAB 0: PROTECTION AND THREADS | |
* Written by Christian Stigen Larsen, 2012-08-24 | |
* ================================================= | |
* | |
* ABOUT | |
* ----- |
NewerOlder