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 | |
# | |
# markov.py | |
# | |
# Reads in a text file and produces a list of random | |
# words with similar 3-grams to those found in the input file. | |
# | |
# Usage: ./markov.py <text_filename> | |
# |
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 | |
import datetime | |
import json | |
import os | |
import random | |
import time | |
num_words = 10 |
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
// glhelp.c | |
// | |
#include "glhelp.h" | |
// The following files are available from: | |
// https://github.com/tylerneylon/oswrap | |
// Please add the appropriate (win or mac) oswrap directory to your project. | |
#include "cbit.h" | |
#include "oswrap/oswrap.h" |
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
<!DOCTYPE html> | |
<!-- | |
# matrix.html | |
*An interactive tool to perform elementary row operations on a matrix.* | |
I built this tool so I could speed up some hand calculations I was performing | |
while learning linear programming algorithms. | |
I thought it might be helpful for others learning or working with linear |
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
-- all_top_sorts.lua | |
-- | |
-- Generate all permutations - aka topological sorts - of | |
-- the set [1, 2, ..., n] such that the permutation has | |
-- certain pairs in a given order. This can also be thought | |
-- of as listing all linear orders consistent with a given | |
-- partial order. | |
-- | |
-- This code is based on chapter 3 of | |
-- Donald Knuth's book Literate Programming. |
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
-- time_lock_inj.lua | |
-- | |
local usage_str = [[ | |
Usage: | |
lua time_lock_inj.lua <list_of_input_source_files> | |
Injects lock timing code for all the given files. | |
This assumes you're locking things with calls to |
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
--[[ Summary: Below, "entity" and "item" may be different types. | |
They simply implement same-name methods. | |
--]] | |
-- A bit from entities.lua: | |
function entities.runloop(dt) | |
for _, entity in pairs(all_entities) do | |
entity:update_and_draw(dt) | |
end |
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
-- Call this function as `grid = can_find_solution(N)`. | |
function can_find_solution(N, x0, y0, grid) | |
x0, y0 = x0 or 0, y0 or 1 -- Set default vals (0, 1). | |
if grid == nil then | |
grid = {} | |
for i = 0, N do grid[i] = {} end | |
end | |
for x = 1, x0 - 1 do | |
if grid[x][y0] or grid[x][y0 - x0 + x] or grid[x][y0 + x0 - x] then | |
return false |
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 is similar to love.graphics.rectangle, except that the rectangle has | |
-- rounded corners. r = radius of the corners, n ~ #points used in the polygon. | |
function rounded_rectangle(mode, x, y, w, h, r, n) | |
n = n or 20 -- Number of points in the polygon. | |
if n % 4 > 0 then n = n + 4 - (n % 4) end -- Include multiples of 90 degrees. | |
local pts, c, d, i = {}, {x + w / 2, y + h / 2}, {w / 2 - r, r - h / 2}, 0 | |
while i < n do | |
local a = i * 2 * math.pi / n | |
local p = {r * math.cos(a), r * math.sin(a)} | |
for j = 1, 2 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
-- This is meant to be used in a for loop, as in: | |
-- for perm in perms(n) do <stuff> end | |
function perms(n) | |
local function iter(state, val) | |
if not val then | |
val = {} | |
for i = 1, n do | |
val[i] = i | |
end | |
return val |
OlderNewer