Skip to content

Instantly share code, notes, and snippets.

@mtcomb
mtcomb / ActionListTest.clj
Created April 12, 2014 01:39
Using lanterna (https://code.google.com/p/lanterna/) from clojure directly
(ns lant.ActionListTest)
; lanterna/src/test/java/com/googlecode/lanterna/test/gui/ActionListTest.java
(import 'com.googlecode.lanterna.gui.Action)
(import 'com.googlecode.lanterna.gui.Border)
(import 'com.googlecode.lanterna.gui.Border$Invisible)
(import 'com.googlecode.lanterna.gui.GUIScreen)
(import 'com.googlecode.lanterna.gui.GUIScreen$Position)
(import 'com.googlecode.lanterna.gui.Window)
(import 'com.googlecode.lanterna.gui.component.ActionListBox)
@mtcomb
mtcomb / meas.py
Last active August 29, 2015 14:01
measuring temperature with the TEMPer USB Thermometer in every 60 seconds
#!/usr/bin/python
from temperusb import TemperHandler
import threading, time
import logging
# logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
fh = logging.FileHandler('temp.log')
@mtcomb
mtcomb / vox.m
Created May 22, 2014 02:43
loading a raw binary file generated by binvox
% binvox -t raw Laurana50k.dxf
% http://www.cadkit.net/2012/01/sample-dxf-files.html
fp=fopen('Laurana50k.raw');
a=fread(fp);
a=reshape(a,[256,256,256]);
imagesc(squeeze(a(:,:,128)));
axis xy;
axis square;
pause;
@mtcomb
mtcomb / poly.py
Created June 13, 2014 16:34
extract polygons from an svg file
from xml.dom import minidom
xmldoc = minidom.parse('XML_example_polygon.svg')
itemlist = xmldoc.getElementsByTagName('polygon')
for s in itemlist :
for p in s.attributes['points'].value.split():
print p
import numpy as np
import pylab
; http://stackoverflow.com/questions/3651494/jfilechooser-with-confirmation-dialog
; in Clojure
(defn chooser []
(proxy [javax.swing.JFileChooser] []
(approveSelection []
(let [f (proxy-super getSelectedFile)]
(if (and (.exists f)
(= (.getDialogType this)
javax.swing.JFileChooser/SAVE_DIALOG))
@mtcomb
mtcomb / juno.py
Created October 25, 2014 16:00
convert MIDI CC to SysEx
from mididings import *
from mididings import event
config(
out_ports=['juno106','alphajuno']
)
def Juno106(ev):
# print ev.port,ev.channel,ev.ctrl,ev.value
return event.SysExEvent(ev.port,[0xF0,0x41,0x32,0x00,ev.ctrl,ev.value,0xF7])
@mtcomb
mtcomb / jomox_airbase99.lua
Created October 25, 2014 16:42
Guru synth definition for Jomox AirBase 99
return SynthDefinition{
content_height = 450,
id = "jomox_airbase99";
name = "Jomox AirBase 99",
author = "mtcomb [ymtcomb@gmail.com]",
beta = true,
Section {
name = "Analog",
Group {
layout = "horizontal",
@mtcomb
mtcomb / extract.py
Last active October 11, 2015 06:26
extract gzipped json data from packets with tshark
#!/usr/bin/env python
# extract gzipped json data from packets with tshark
#
# e.g.: capture flight data from www.flightradar24.com
# open www.flightradar24.com in a web browser
# $ tshark -f "net 83.140.21.0/24" -i eth2 -w capture.cap
# leave tshark running
# $ ./extract.py
@mtcomb
mtcomb / coupler.m
Created May 19, 2015 15:50
polygon models
% C. Microstrip Branch Line Coupler
% from http://dx.doi.org/10.1109/22.55775
_=[nan,nan];
ix=@(x) size(x,1)+1;
W1=2.413;
W2=3.96;
% The distance from the source plane to the edge of the coupler is 50*dy
L=50*0.406;