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
-- Two dashes start a one-line comment. | |
--[[ | |
Adding two ['s and ]'s makes it a | |
multi-line comment. | |
--]] | |
---------------------------------------------------- | |
-- 1. Variables and flow control. | |
---------------------------------------------------- |
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
--[[ json.lua | |
A compact pure-Lua JSON library. | |
The main functions are: json.stringify, json.parse. | |
## json.stringify: | |
This expects the following to be true of any tables being encoded: | |
* They only have string or number keys. Number keys must be represented as | |
strings in json; this is part of the json spec. |
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
-- copy.lua | |
-- | |
-- Lua functions of varying complexity to deep copy tables. | |
-- | |
-- 1. The Problem. | |
-- | |
-- Here's an example to see why deep copies are useful. Let's | |
-- say function f receives a table parameter t, and it wants to |
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
# -*- 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 |
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
""" 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. | |
""" |
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
{"th": 0.03309640905197913, "he": 0.03289597993942979, "pr": 0.002746850084321499, "ro": 0.005424830253317676, "oj": 8.741181560521646e-05, "je": 0.0003752527437597676, "ec": 0.00287222864811888, "ct": 0.002534942652551277, "gu": 0.0005968725994861245, "ut": 0.005476041215995479, "te": 0.009365425536611424, "en": 0.012622619352446206, "nb": 0.00012891035432688487, "be": 0.007778768641231889, "er": 0.023745110677485717, "rg": 0.0005032801504542766, "eb": 0.00018630195043131993, "bo": 0.0023371623828990704, "oo": 0.004796171539066018, "ok": 0.002003408177860971, "of": 0.008637876687533663, "da": 0.0015663490998348887, "av": 0.003626265926167919, "vi": 0.001449800012361267, "id": 0.005190849130738056, "co": 0.006384594329710305, "op": 0.0019883980681105803, "pp": 0.0020528532452740228, "pe": 0.004910071783642512, "rf": 0.0011416512886620695, "fi": 0.0026135249918327343, "ie": 0.003583884439813875, "el": 0.006230961441676894, "ld": 0.005101671419868088, "hi": 0.010678368665954422, "is": 0.009714189851399914, "fo" |
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
<!DOCTYPE HTML> | |
<html> | |
<body> | |
<svg width="600" height="600" vertion="1.1" | |
id="svg" xmlns="http://www.w3.org/2000/svg"> | |
<defs> | |
<clipPath id="angleClip"> | |
<polygon id="atriangle" /> | |
</clipPath> |
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 macro tests if a char is a continuation byte in utf8. | |
#define IS_CONT(x) (((x) & 0xc0) == 0x80) | |
// This returns the code point encoded at **s and advances *s to point to the | |
// next character. Thus it can easily be used in a loop. | |
int decode_code_point(char **s) { | |
int k = **s ? __builtin_clz(~(**s << 24)) : 0; // Count # of leading 1 bits. | |
int mask = (1 << (8 - k)) - 1; // All 1s with k leading 0s. | |
int value = **s & mask; | |
// k = 0 for one-byte code points; otherwise, k = #total bytes. |
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
license: mit |
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
#!/usr/bin/awk -f | |
# | |
# call_graph.awk | |
# | |
# Usage: | |
# ./call_graph.awk my_program.lua | dot -Tpng > call_graph.png | |
# | |
# This is a script that generates a visual call graph | |
# for a Lua file. This script only shows calls made | |
# to functions defined within the input Lua file; that is, |
NewerOlder