Skip to content

Instantly share code, notes, and snippets.

@samrat
samrat / running_pd.org
Created March 22, 2016 08:23
Running a local copy of Velleman's ProofDesigner

Running a local copy of ProofDesigner

  1. Download the jar wget http://www.cs.amherst.edu/~djv/pd/ProofDesigner.jar
  2. Create html file with contents:
<HTML>
<HEAD>
<TITLE>Proof Designer</TITLE>
<SCRIPT language="JavaScript">
function showHTML() {
from bs4 import BeautifulSoup
from urllib.request import urlopen
import subprocess
import re
import os
import sys
import pickle
import shutil
"""
@samrat
samrat / euler_method.org
Created February 19, 2016 05:37
Solving differential equations using Euler's method in Org tables

$$w’ = (3-w)(w+1)$$

twm1
04-5
1-10
2-10
3-10

$$y’ = e2/y$$

import feedparser
import subprocess
import os
import sys
def download_entry(entry):
ext = os.path.splitext(entry.link)[1]
subprocess.call(["wget", entry.link, "-O", entry.title + ext, "-c"])
point points[] = {{163,216},
{173,271},
{195,291},
{192,307},
{173,290},
{173,327},
{166,328},
{153,281},
{142,336},
{133,351},
open Core.Std
type point = {x : float;
y : float}
let avg_two a b =
0.75 *. a +. 0.25 *. b
let avg_two_points a b =
{x= (avg_two a.x b.x);
@samrat
samrat / run_bench.ml
Created July 22, 2015 07:40
run_bench.ml
> #require "core_bench"
> open Core.Std;;
> open Core_bench.Std;;
let run_bench tests =
Command.run (Bench.make_command tests);;
@samrat
samrat / sdl2_stbtt.c
Last active September 4, 2023 12:30
Drawing text into a bitmap w/ stb_truetype
#include "SDL.h"
/*
Compilation:
============
gcc -g --std=c99 -o sdl2_stbtt sdl2_stbtt.c `sdl2-config --cflags --libs` -lm
Usage:
======
./sdl2_stbtt /usr/share/fonts/TTF/LiberationMono-Regular.ttf
@samrat
samrat / hashtable.rkt
Created March 6, 2015 09:45
Quick n' dirty hashtable implementation in Racket
#lang racket
;; USAGE:
;; =====
;; (init-hashtable 100)
;; (insert ht 13 3)
;; (lookup ht 13)
;; (delete ht 13)
;; list of random integers in [0, num-buckets); used for hashing
@samrat
samrat / tridiag.jl
Created February 4, 2015 14:43
Tridiagonal matrix
function tridiag_elem(i,j)
if abs(j-i) > 1; return(0); end
return(1);
end
function tridiag_mat(n)
[tridiag_elem(i,j) for i in [0:n-1], j in [0:n-1]]
end