Skip to content

Instantly share code, notes, and snippets.

View jmpinit's full-sized avatar

Owen Trueblood jmpinit

View GitHub Profile
@jmpinit
jmpinit / libload.sh
Last active June 6, 2020 15:28
How to use a shared library written in C from a program written in Rust. ( rust version 0.7. \ host: i686-unknown-linux-gnu ).
# so the lib can be found when the test is run
export LD_LIBRARY_PATH=./:$LD_LIBRARY_PATH
# alternatively put the .so generated after running make someplace where the system will find it
# download & build Julia
cd /path/to/where/you/want/julia/to/be
git clone git://github.com/JuliaLang/julia.git
cd julia
make # ...wait 20 hours (or have a faster computer than I)
# install prerequisites for IJulia
sudo apt-get install pip
sudo pip install ipython
sudo pip install jinja2 tornado pyzmq
@jmpinit
jmpinit / bhack.js
Last active December 26, 2015 09:39
Modify bsim 2.0.0 from MIT's Computation Structures (6.004) class to add video out.
$(".tty").prepend( '<div style="float: right;"><canvas id="television" width="192" height="128" style="background-color: lightblue;">xbetahack ERROR: html5 canvas is missing.</canvas></div>');
bhack = {
tv: {
canvas: null,
width: 96,
height: 64,
pos: 0,
fill: function(col) {
import java.awt.*;
import java.awt.image.*;
import java.awt.event.KeyEvent;
Robot player;
BufferedImage capture = null;
PImage converted = null;
void setup() {
@jmpinit
jmpinit / makefile
Created December 7, 2013 01:16
Example makefile for making use of command line hack of JSim.
all: beta_test.jsim
java -jar ~/bin/jsim/clisim.jar -g $<
benmark: beta_test.jsim
@java -jar ~/bin/jsim/clisim.jar -g $< | json benmark
.PHONY: all
@jmpinit
jmpinit / gist:8190649
Created December 31, 2013 00:46
MSR900 MagStripe reader/writer.
import sys, serial
from operator import eq
ser = serial.Serial('/dev/ttyUSB0', 9600)
init = [0x61, 0x65, 0x61]
delimiter = [0x3F, 0x1C, 0x1B]
ok = [0x30]
errors = [0x31, 0x32, 0x34, 0x39]
(function() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.fillRect(100, 100, 100, 100);
for(var i = 0; i < sound.length; i++) {
sound[i] = Math.random() * 2 - 1;
}
})
(function() {
if(!document.time) document.time = 0;
document.time++;
var t = document.time;
for(var i = 0; i < sound.length; i++) {
sound[i] = (t*(((t>>12)|(t>>8))&(63&(t>>4))))/0xff % 1;
t++;
}
/**
* Written by jmptable for 6.005 problem set 0 artwork problem
* run in [processing](http://processing.org/)
*/
import java.awt.Color;
import java.util.*;
import javax.swing.*;
import java.io.File;
@jmpinit
jmpinit / ipynbtopdf
Created February 15, 2014 20:02
Simple zsh script to convert IPython Notebook files to PDFs. Requires IPython version >1 and wkhtmltopdf utility.
#!/usr/bin/zsh
ipython nbconvert "$1"
NAME=$(basename "$1" .ipynb)
wkhtmltopdf "$NAME.html" "$NAME.pdf"
rm "$NAME.html"