View rwlock.py
# -*- coding: utf-8 -*-
""" rwlock.py
A class to implement read-write locks on top of the standard threading
library.
This is implemented with two mutexes (threading.Lock instances) as per this
wikipedia pseudocode:
https://en.wikipedia.org/wiki/Readers%E2%80%93writer_lock#Using_two_mutexes
View wordvec_example.py
# wordvec_example.py
#
# This file shows one way to work with word2vec data in Python.
#
# Setup:
#
# 1. Install gensim:
#
# pip install gensim
#
View cow.c
// 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"
View lua_interp.c
// A bare-bones Lua interpreter, in C.
#include <stdio.h>
#include <string.h>
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
int main() {
View whatisit.py
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')
View mnist.py
""" A function that can read MNIST's idx file format into numpy arrays.
The MNIST data files can be downloaded from here:
http://yann.lecun.com/exdb/mnist/
This relies on the fact that the MNIST dataset consistently uses
unsigned char types with their data segments.
"""
View colortable.sh
# A bash function to print out a table of
# colors supported by your terminal.
colortable() {
tput setaf 0
for i in $(seq 0 $(tput colors)); do
tput setab $i
printf %4d $i
done
echo
View in_yo_.profile
ssfile ()
{
f="$(ls -1tr $HOME/Desktop/Screen*.png | tail -1)";
g=$(echo $f | tr ' ' _);
mv "$f" "$g";
echo $g
}
View [goes in your .profile]
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) &)
View .block
license: mit