Skip to content

Instantly share code, notes, and snippets.

View pqnelson's full-sized avatar

Alex pqnelson

  • Unfold, Inc.
  • Los Angeles, CA
View GitHub Profile
@pqnelson
pqnelson / c-unit-test.md
Last active January 29, 2019 16:22
Unit Tests in ANSI C

Basic Structure

Since C does not provide a "canonical" unit testing framework, we have to implement our own. The basic template for testing frameworks is called xUnit, which we'll follow.

For C, I guess the analogous xUnit patterns would be:

  • Test runner: the .c file with the main() function running all (or some specified subset of) the test suites
  • Test suite: a collection of test cases
  • Test case: the function which is a single unit test, i.e., has a single assert
@pqnelson
pqnelson / 0.aut
Created November 3, 2017 18:16
Landau in Automath
+l
@[a:'prop'][b:'prop']
imp:=[x:a]b:'prop'
[a1:a][i:imp(a,b)]
mp:=<a1>i:b
a@refimp:=[x:a]x:imp(a,a)
b@[c:'prop'][i:imp(a,b)][j:imp(b,c)]
trimp:=[x:a]<<x>i>j:imp(a,c)
@con:='prim':'prop'
a@not:=imp(con):'prop'

1. What is rhetoric?

It comes from the Greek word Rhetorica meaning "Public speaking". It first and foremost means public speaking, but it typically is focused on persuasion.

It could be considered the art of persuasion. This includes written expression.

Until the renaissance, it was focused more on "oral

@pqnelson
pqnelson / stats.md
Created August 2, 2016 14:27
Collection of links, papers, etc. on Statistics, Machine Learning, etc.

Notes

  • Konstantin Zuev, "Statistical Inference" arXiv:1603.04929, 145 pages
    • If you are going to start anywhere, here's a good place to start.
  • Ryan Martin, "A statistical inference course based on p-values" arXiv:1606.02352, 16 pages
  • Ryan Martin, Chuanhai Liu, "Validity and the foundations of statistical inference" arXiv:1607.05051, 29 pages.
    • This answers a number of "foundational" concerns I have, like "What is a statistical inference, really?"
@pqnelson
pqnelson / contracts.bib
Created February 19, 2016 17:28
Contracts Reading List
@string{icse = "International Conference on Software Engineering"}
@string{cacm = "Communications of the {ACM}"}
@string{ieee-software = "{IEEE Software}"}
@string{tools = "Technology of Object-Oriented Languages and Systems"}
@string{lncs = "Lecture Notes in Computer Science" }
@string{jacm = "Journal of the {ACM}"}
@string{ecoop = "European Conference on Object-Oriented Programming"}
@string{toplas = "{ACM} Transactions on Programming Languages and Systems"}
@string{oopsla = "{Object-Oriented Programming, Systems, Languages, and Applications}"}
@string{oopsla-companion = "{Object-Oriented Programming, Systems, Languages, and Applications Companion}"}
@pqnelson
pqnelson / automath.py
Created January 2, 2016 18:45
Automath Pygments Highlighter
from pygments import highlight
from pygments.lexer import RegexLexer, bygroups
from pygments.token import *
from pygments.formatters import HtmlFormatter
# A quick and dirty syntax highlighter for Automath code
# Admittedly, this should be cleaned up some, but it's just a proof of concept.
class AutomathLexer(RegexLexer):
name = 'Automath'
@pqnelson
pqnelson / minimal_we.c
Created January 1, 2016 19:20
Terrible C hack for Linked Lists
// a doubly linked list of "stuff"
struct item {
int kind;
struct item *next, *prev;
};
// an item can be a man eating bear
#define MAN_EATING_BEAR_KIND 1
struct manEatingBear {
int kind;
@pqnelson
pqnelson / ZFC.aut
Created December 22, 2015 04:57
Automath examples
#!/usr/local/bin/aut -Q
{
This is ZFC in AUT-QE, as opposed to AUT-68 which Wiedijk provides. The difference
is fewer primitive notions: we have 1+3+2+6+8+1=21 primitive notions,
Wiedijk's AUT-68 version has 31 primitive notions.
To see Wiedijk's version, see https://www.cs.ru.nl/~freek/zfc-etc/
}
'
' #DEBUG ERROR ON
' (If you "uncomment" the statement above, don't forget to un-comment the "ON ERROR GOTO...")
'
' Changed RotRec to 1000 - May 28, 2011 (Teams to keep track of for Pitching Rotations)
' Changed RotRec to 1500 - June 4, 2011
' Changed WLRec to 1500 - June 4, 2011 (Teams to keep track of in Standings)
' If more than 300 teams involved, user needs to use STAT-TEAM-LIMIT= in .CMD
'
'
@pqnelson
pqnelson / neural-network.clj
Created July 27, 2015 00:02
A simple linear-threshold neural network, with an XOR neural net factory.
(ns user.neural-network
(:import [java.lang.reflect Array]))
;; So far, this handles linear threshold nodes, specifically examining
;; Minsky and Papert's XOR dilemma. The make-xor-network is a factory function
;; which produces such a network.
;;
;; It's fairly optimized, using deftypes and whatnot. One could add an
;; activation function for further generality, or add a logistic function
;; and add some training routines to further improve things.