Skip to content

Instantly share code, notes, and snippets.

@ktuite
ktuite / imageServer.py
Created July 3, 2014 00:20
Twisted server that serves up images in a directory
from twisted.web.resource import Resource
from twisted.web import server
from twisted.python import log
from twisted.internet import defer
import os
from datetime import datetime
from twisted.protocols.basic import FileSender
##########################
#### Global Variables ####
@ktuite
ktuite / slit-scan.pde
Created June 18, 2014 03:19
slit-scan video code from http://www.flong.com/texts/lists/slit_scan/ updated to work with processing 2.2.1
import processing.video.*;
Capture C;
int X=0;
void setup() {
size(640, 480);
String[] cameras = Capture.list();
if (cameras.length == 0) {
@ktuite
ktuite / mturk_boto_intro.py
Last active August 19, 2020 07:06
Super simple python script that uses boto to connect to amazon mturk. If you use the sandbox, you'll see a balance of $10,000! Otherwise, you'll see your normal balance.
import boto.mturk.connection
sandbox_host = 'mechanicalturk.sandbox.amazonaws.com'
real_host = 'mechanicalturk.amazonaws.com'
mturk = boto.mturk.connection.MTurkConnection(
aws_access_key_id = 'XXX',
aws_secret_access_key = 'XXX',
host = sandbox_host,
debug = 1 # debug = 2 prints out all requests. but we'll just keep it at 1
#import <UIKit/UIKit.h>
@interface TestTwoController : UIViewController <UITextFieldDelegate,UIPickerViewDataSource,UIPickerViewDelegate>
@end
@ktuite
ktuite / getTransform.cpp
Created October 30, 2013 01:18
Replacement for estimateRigidTransform using GSL instead of OpenCV
// call in place of something like: Mat warp_mat = estimateRigidTransform( f, c, false);
// like this: Mat warp_mat = getSimilarityTransform(f,c);
// then you can use it with warpAffine
// needs GSL http://www.gnu.org/software/gsl/
// #include <gsl/gsl_linalg.h>
// #include <gsl/gsl_blas.h>
Mat getTransform(vector<Point2f> src, vector<Point2f> dst){
// use GSL to do the actual transformations.... but put it back into opencv-happy format
@ktuite
ktuite / poisson.cpp
Last active December 19, 2015 22:09 — forked from thorikawa/poisson.cpp
#include <opencv2/opencv.hpp>
#include <iostream>
#include <vector>
#include <cmath>
#include <assert.h>
using namespace std;
using namespace cv;
@ktuite
ktuite / gist:4220561
Created December 5, 2012 23:42
A snippet of a twisted server (python) that returns a crossdomain xml file
class RootResource(Resource):
def __init__(self):
Resource.__init__(self)
self.putChild('heartbeat', HeartbeatResource())
self.putChild('launch', LaunchResource())
self.putChild('get_port', GetPortResource())
self.putChild('crossdomain.xml', Grahh())
self.putChild('style.css', static.File("style.css"))
self.putChild('jquery.min.js', static.File("jquery.min.js"))
self.putChild('sketchup.js', static.File("sketchup.js"))
@ktuite
ktuite / UniqueId.java
Created December 3, 2012 03:08
Generating and storing a random, unique user id to track unique installations of an android app.
// adaptation of: http://android-developers.blogspot.com/2011/03/identifying-app-installations.html
// but using shared preferences instead of a file: http://developer.android.com/reference/android/content/SharedPreferences.html
// here's a better look at using shared preferences: http://developer.android.com/guide/topics/data/data-storage.html#pref
public class UniqueId {
private static String sID = null;
private static final String SHARED_PREF_KEY = "SKETCHABIT2";
private static final String ID_KEY = "id";