Skip to content

Instantly share code, notes, and snippets.

@drakeguan
drakeguan / m2s.cpp
Created April 10, 2014 08:10
mpo2stereo, convert .mpo image into two separated stereo images.
// MPO2Stereo:
// Converts Fujifilm MPO format 3D
// images into JPEG stereo pairs
//
// code by:
// Andres Hernandez [cybereality]
#include <iostream>
#include <fstream>
@drakeguan
drakeguan / bmpReader.cpp
Created April 10, 2014 03:29
bmpReader, to make Nuke (The Foundry) handle .bmp reading through freeimage
// vim: set hls is si et sw=4 sts=4 nu:
#include <stdio.h>
#include <string.h>
#include <FreeImage.h>
#include "DDImage/DDWindows.h"
#include "DDImage/Reader.h"
#include "DDImage/Row.h"
#include "DDImage/Knob.h"
@drakeguan
drakeguan / flask_file_upload
Created October 9, 2013 08:46
Hello world in Flask
#!/usr/bin/env python
from flask import Flask
from flask import request
from flask import render_template
app = Flask(__name__)
@app.route('/hello')
def hello_world():
@drakeguan
drakeguan / ConvertEXRToJPG.py
Created August 22, 2013 03:55
Convert OpenEXR to JPEG with gamma encoding (2.4) efficiently through OpenEXR and numpy.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import numpy
import OpenEXR
import Imath
import Image
@drakeguan
drakeguan / manpy
Created June 11, 2012 11:05
man for python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pydoc
import sys
def usage():
print 'man for python.'
print 'Usage: manpy OBJECT'
print 'Ex: manpy os.walk'
@drakeguan
drakeguan / concurrent_map.py
Created July 1, 2011 18:07
concurrent map
## {{{ http://code.activestate.com/recipes/577360/ (r1)
import threading
def concurrent_map(func, data):
"""
Similar to the bultin function map(). But spawn a thread for each argument
and apply `func` concurrently.
Note: unlike map(), we cannot take an iterable argument. `data` should be an
indexable sequence.
@drakeguan
drakeguan / gist:965888
Created May 11, 2011 03:47
bmpReader for Nuke
#include <stdio.h>
#include <string.h>
#include <freeimage.h>
#include "DDImage/DDWindows.h"
#include "DDImage/Reader.h"
#include "DDImage/Row.h"
#include "DDImage/Knob.h"
#include "DDImage/Knobs.h"
@drakeguan
drakeguan / gist:947661
Created April 29, 2011 01:01
eval() of lis.py, a tiny lisp simulator in python by Peter Norvig
def eval(x, env=global_env):
"Evaluate an expression in an environment."
if isa(x, Symbol): # variable reference
return env.find(x)[x]
elif not isa(x, list): # constant literal
return x
elif x[0] == 'quote': # (quote exp)
(_, exp) = x
return exp
elif x[0] == 'if': # (if test conseq alt)