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
""" | |
Implementation of memoization decorator in Python. | |
Written by Christian Stigen Larsen | |
http://csl.sublevel3.org | |
Put in the public domain by the author, 2012 | |
This is an example of how to use decorators to implement different kind of | |
behaviour in Python. |
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
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
/* | |
* ================================================= | |
* DAT320 Operating Systems, University of Stavanger | |
* | |
* LAB 0: PROTECTION AND THREADS | |
* Written by Christian Stigen Larsen, 2012-08-24 | |
* ================================================= | |
* | |
* ABOUT | |
* ----- |
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
#| | |
| Celsius-Fahrenheit temperature table | |
| | |
| Taken from | |
| http://programmingpraxis.com/2012/09/07/the-first-two-programs/2/ | |
| | |
| Ported to current R7RS scheme by Christian Stigen Larsen | |
| Public Domain, 2012 | |
| | |
| Works in Mickey Scheme |
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
/* | |
* Simple program I wrote after reading Felix Von Leitner's notes | |
* on optimization at http://www.fefe.de/source-code-optimization.pdf | |
* | |
* In the 90s, it used to be faster to do (x<<8)+(x<<6) than x*320, | |
* but today with the Intel Core i7, it's actually faster to do | |
* x*320. | |
* | |
* And the compiler knows it! | |
* |
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
/* | |
* Reverse string in "canonical" C++ | |
* | |
* Why did I make this a gist? Because I've seen so | |
* many cumbersome ways of doing this in C++, including | |
* using <algorithm> and std::reverse, using loops and | |
* so on. Yeah, those work too, and loops are fine for | |
* C, but in C++, you should simply just use the iterators | |
* and standard constructors that std::string gives you. | |
* |
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
/* | |
* A simple sieve of Eratosthenes using bitsets, written by Christian Stigen Larsen | |
* You are free to use this code for anything (i.e., public domain). | |
* | |
* This sieve allocates the bitset on the heap, so you can calculate a lot | |
* of prime numbers. | |
*/ | |
#ifndef INC_PRIMES_H | |
#define INC_PRIMES_H |