Skip to content

Instantly share code, notes, and snippets.

View jmpinit's full-sized avatar

Owen Trueblood jmpinit

View GitHub Profile
@jmpinit
jmpinit / Screen.java
Created March 30, 2014 19:47
Hacky program to take screenshots of webpages at URLs from a file (one URL per line). Uses [Selenium](http://docs.seleniumhq.org/).
import java.util.*;
import java.io.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.*;
import org.openqa.selenium.htmlunit.*;
import org.apache.commons.io.*;
public class Screeny {
@jmpinit
jmpinit / build.gradle
Last active August 29, 2015 13:57
Helps set up an OpenCV project in Android Studio.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android-library'
@jmpinit
jmpinit / imdur.py
Last active August 29, 2015 14:00
Downloads images from imgur corresponding to all possible capitalizations of the given word. Only words of length 5 or 7 will work because of imgur's hash design.
#!/usr/bin/env python
import urllib, hashlib
import sys, os, os.path
if not len(sys.argv) == 2:
print "usage: imdur.py <a word>"
sys.exit(1)
if not (len(sys.argv[1]) == 5 or len(sys.argv[1]) > 7):
@jmpinit
jmpinit / map.py
Created April 21, 2014 18:19
Generate a Java array representing the rough voxel geometry of a model from 2 images of it taken orthogonal to each other.
import sys
import numpy as np
from PIL import Image
filenames = ["panda1.png", "panda2.png", "panda3.png", "panda4.png"]
images = [Image.open(fn) for fn in filenames]
images = [im.convert('RGB') for im in images]
levels = np.zeros((16, 16, 9), np.int16)
@jmpinit
jmpinit / panda.pde
Created April 21, 2014 18:27
Processing sketch showing a simple 3D raycasting effect based on the disk change effect in https://www.youtube.com/watch?v=L8onlB0F1_A .
import java.awt.geom.*;
final int WIDTH = 60;
final int HEIGHT = 32;
final int ZOOM = 4;
final int STEPS = 64;
int[][][] screen;
Slice[] slices;
@jmpinit
jmpinit / bookmarklet.js
Created June 25, 2014 15:18
Bookmarklet that adds configurable event filter to hackaday.io/myfeed.
var filter = document.createElement('style');
filter.innerHTML = ".section-feed-filters { display: block; }";
function hider(target) {
if($(this).prop('checked')) {
$(target).css({
"visibility":"visible",
"height":"auto",
"margin":"2em",
"border-collapse":"initial"
@jmpinit
jmpinit / fft.py
Created September 20, 2014 02:21
# from http://www.swharden.com/blog/2010-03-05-realtime-fft-graph-of-audio-wav-file-or-microphone-input-with-python-scipy-and-wckgraph/
import pyaudio
import scipy
import struct
import scipy.fftpack
from Tkinter import *
import threading
import time, datetime
import wckgraph
#!/bin/sh
# DESCRIPTION: compiles c++ project for Spark Core and flashes it to core connected in DFU mode
# USAGE: sparkflash <main app sourcefile> <source files...>
# EXAMPLE: sparkflash snowglobe.ino *.cpp *.h
# NOTE: assumes the following directory structure:
# $HOME/bin/
import numpy as np
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt
R = [15620.0, 31000.0, 62000.0, 124000.0, 250000.0, 500000.0, 1000000.0, 2000000.0]
R8 = 3922
VCC = 5
def int_to_bit_array(i, length):
@jmpinit
jmpinit / Paper.java
Created November 1, 2014 18:36
Minimal SurfaceView example.
public class Paper extends SurfaceView implements SurfaceHolder.Callback {
private PaperThread paperThread = null;
public Paper(Context context) {
super(context);
getHolder().addCallback(this);
paperThread = new PaperThread(getHolder(), this);
}