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
-- 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 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
#!/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
// 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 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
#!/usr/local/bin/python3 | |
# | |
# Usage: | |
# md_to_tex.py <md_filename> > myfile.tex | |
# | |
# Converts simple markdown to a LaTeX file. | |
# Use, for example, "pdflatex myfile.tex" to | |
# generate a pdf file using your output file. | |
# | |
# The current script does *not* parse all |
OlderNewer