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
// 7date.c | |
// | |
// Print out today's date in the form | |
// <day-of-year base 7 (0-indexed)>.<year> | |
// | |
// Examples: | |
// | |
// Jan 1, 1925 == 0.1925 | |
// | |
// Feb 1, 2025 == 43.2025 |
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/python | |
# | |
# queue_math.py | |
# | |
# Checking some calculations on the memory efficiency of a | |
# hypothetical queue data structure. | |
# | |
import random | |
import sys |
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
-- This returns a sequence of k distinct indexes in the range [1, n] chosen so | |
-- that, within the context of the pseudorandom generator, each k-subset has an | |
-- equal probability of being returned. | |
function random_indexes(k, n) | |
-- This is a partial Fisher-Yates shuffle, as suggested by this answer: | |
-- http://stackoverflow.com/a/29868630/3561 | |
local shuf = {} | |
local indexes = {} | |
for i = 1, k do | |
local j = math.random(i, n) |
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
timey() { | |
# Inspired by | |
# https://gist.github.com/commanda/775ebcbe630919b554128b31c3dfb9dd | |
if [ "$#" -ne 1 ]; then | |
echo "usage: timey <number of minutes>" | |
return | |
fi | |
url=https://media.giphy.com/media/yWh7b6fWA5rJm/giphy.gif | |
seconds=$(( $1 * 60 )) | |
((sleep $seconds; open -a "Google Chrome.app" $url) &) |
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
ssfile () | |
{ | |
f="$(ls -1tr $HOME/Desktop/Screen*.png | tail -1)"; | |
g=$(echo $f | tr ' ' _); | |
mv "$f" "$g"; | |
echo $g | |
} |
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
import itertools, os, sys | |
it, chars = 20, '.-=*x#X' | |
sys.stdout.write('\x1b[?25l') | |
w = int(os.popen('tput cols').read()) | |
h = int(os.popen('tput lines').read()) - 1 | |
x_max, y_max = float(w) / (2.0 * h) * 1.2, 1.2 | |
for j in itertools.count(1): | |
sys.stdout.write('\x1b[1;1H') |
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/local/bin/python3 | |
# | |
# bye_camels.py from https://github.com/tylerneylon/cstructs | |
# | |
""" | |
Usage: | |
bye_camels.py <input_file> [<output_file>] | |
bye_camels.py -i <input_file> <output_file> | |
Replaces all camel-case identifiers in the input with |
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 bare-bones Lua interpreter, in C. | |
#include <stdio.h> | |
#include <string.h> | |
#include "lua.h" | |
#include "lauxlib.h" | |
#include "lualib.h" | |
int main() { |
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
// keylog.c | |
// | |
// Usage: | |
// ./keylog [command ...] | |
// | |
// This runs the given command, capturing all keyboard input in the file | |
// "outfile." This is currently written for mac os x. I'm guessing slight edits | |
// would allow it to work on other *nix systems as well. | |
// | |
// I learned how to do this by looking at the source of the "script" binary, |
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 Lua module written in C. | |
// | |
// This module enables terminal-based ASCII art | |
// of a loquacious bovine nature. | |
// | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include "lua.h" |