Skip to content

Instantly share code, notes, and snippets.

View dansteingart's full-sized avatar

Dan Steingart dansteingart

View GitHub Profile
@dansteingart
dansteingart / gist:1095920
Created July 20, 2011 20:58
SIPS batch convert
sips -s format jpeg path_in --out path_out
@dansteingart
dansteingart / gist:1115829
Created July 30, 2011 18:28
Speeding up the ADC's on an arduino
#define FASTADC 1
// defines for setting and clearing register bits
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif
@dansteingart
dansteingart / bytelogger.js
Created January 18, 2012 22:10
Simple Data Logger in Node.Js
var http = require("http"); //HTTP Server
var url = require("url"); // URL Handling
var fs = require('fs'); // Filesystem Access (writing files)
var express = require('express'), //App Framework (similar to web.py abstraction)
app = express.createServer();
app.use(express.bodyParser());
app.use(app.router);
io = require('socket.io').listen(app); //Socket Creations
io.set('log level', 1)
@dansteingart
dansteingart / index.html
Created January 19, 2012 02:29
client side logger thing
<html>
<head>
<LINK REL=StyleSheet HREF="/flot/style.css" TYPE="text/css" MEDIA=screen>
<style>
</style>
</head>
<body>
<script src="/socket.io/socket.io.js"></script>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Circular Progressbar</title>
<script type="text/javascript" src="http://paperjs.org/static/js/paper.js"></script>
<script type="text/paperscript" canvas="canvas">
project.currentStyle = {
strokeColor: 'red',
strokeWidth: 60,
@dansteingart
dansteingart / outout.js
Created March 9, 2012 03:00
Node Script for MongoExport
var exec = require('child_process').exec;
var child;
//Put path to mongoexport here
mel = "/Users/ardustat/Downloads/mongodb-osx-x86_64-2.0.2/bin/mongoexport"
function mongoexport(collection)
{
out_string = mel + " -csv -o "+collection+".csv -d ardustat -c "+collection+" -f time,cell_potential,working_potential,current"
child = exec(out_string, function (error, stdout, stderr)
@dansteingart
dansteingart / Spawner.js
Created November 1, 2012 01:09
Keeping Tabs On Multiple Spawned Processes in NodeJS
//First make placeholders for results as globals
results = {}
processes = {}
//Now Spawn Processes within code you need, where index is an identifier
spawn_list[index] = spawn(/*file here*/)
processes[index] = spawn_list[index].pid
results[processes[index]] = {}
results[processes[index]]['index'] = index //funny looking but important
results[processes[index]]['stdout'] = ""
# code to set set current here
for i in range(120):
#code to get data here
time.sleep(.5)
import serial
from glob import glob
from time import sleep
port = glob("/dev/tty.usb*")[0]
ard = serial.Serial(port,57600)
print "waiting to start"
for i in range(3,0,-1):
print i,
sleep(1)
@dansteingart
dansteingart / keithleytest.py
Created September 12, 2013 20:52
Keithley and Python
import serial
from glob import glob
port = glob("/dev/tty.u*")[0]
ser = serial.Serial(port,57600)
ser.open()
ser.timeout = .5
def write(string):