Skip to content

Instantly share code, notes, and snippets.

Nicolas Pinto npinto

  • MIT
  • Boston, MA
Block or report user

Report or block npinto

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View mtgox-btcusd-watch.sh
#!/bin/bash
watch -n 10 'curl https://data.mtgox.com/api/2/BTCUSD/money/ticker | tee data/ticker.$(date +"%Y-%m-%d_%R:%S.%N").json | python -mjson.tool; for f in data/*.json; do gzip $f; done;'
@npinto
npinto / imageOrientation.mm
Created Jan 31, 2013
imageOrientation.mm
View imageOrientation.mm
UIImageOrientation imageOrientation;
if (UserDefaults.usingFrontCamera) {
switch (curDeviceOrientation) {
case UIDeviceOrientationLandscapeLeft:
imageOrientation = UIImageOrientationDown;
break;
case UIDeviceOrientationLandscapeRight:
imageOrientation = UIImageOrientationUp;
break;
case UIDeviceOrientationPortraitUpsideDown:
View exifOrientation.mm
UIDeviceOrientation curDeviceOrientation = [[UIDevice currentDevice] orientation];
enum {
PHOTOS_EXIF_0ROW_TOP_0COL_LEFT = 1, // 1 = 0th row is at the top, and 0th column is on the left (THE DEFAULT).
PHOTOS_EXIF_0ROW_TOP_0COL_RIGHT = 2, // 2 = 0th row is at the top, and 0th column is on the right.
PHOTOS_EXIF_0ROW_BOTTOM_0COL_RIGHT = 3, // 3 = 0th row is at the bottom, and 0th column is on the right.
PHOTOS_EXIF_0ROW_BOTTOM_0COL_LEFT = 4, // 4 = 0th row is at the bottom, and 0th column is on the left.
PHOTOS_EXIF_0ROW_LEFT_0COL_TOP = 5, // 5 = 0th row is on the left, and 0th column is the top.
PHOTOS_EXIF_0ROW_RIGHT_0COL_TOP = 6, // 6 = 0th row is on the right, and 0th column is the top.
PHOTOS_EXIF_0ROW_RIGHT_0COL_BOTTOM = 7, // 7 = 0th row is on the right, and 0th column is the bottom.
@npinto
npinto / json_bundle.m
Created Jan 22, 2013
JSONKit w/ NSBundle file
View json_bundle.m
NSString* jsonPath = [[NSBundle mainBundle] pathForResource:@"arr_fb" ofType:@"json"];
NSData* jsonData = [NSData dataWithContentsOfFile:jsonPath];
JSONDecoder* decoder = [[JSONDecoder alloc] initWithParseOptions:JKParseOptionNone];
NSDictionary* json = [decoder objectWithData:jsonData];
NSArray* shape = [json objectForKey:@"shape"];
NSUInteger fbn_ = [[shape objectAtIndex:0] intValue];
@npinto
npinto / __location__.py
Created Oct 17, 2012
How to reliably open a file in the same directory as a Python script
View __location__.py
import os
from os import path
__location__ = path.realpath(path.join(os.getcwd(), path.dirname(__file__)))
@npinto
npinto / theano_hacks.py
Created Oct 3, 2012
Theano Memory Hacks
View theano_hacks.py
import time
import gc
import numpy as np
def theano_memory_hack(func_exp, local_vars,
input_exps=('input',),
msize_best=None,
msize_start=1024, msize_factor=2,
verbose=False):
@npinto
npinto / subprocess_is_painful.py
Created Sep 12, 2012
Python shell interface is painful (subprocess, commands, etc.)
View subprocess_is_painful.py
url = "http://www.youtube.com/watch?v=pkCTAeLsX7E"
import os
import sysfrom sys import stderr
import tempfile
import commandsfrom os import path
from sys import stdout
from subprocess import Popen, PIPE, STDOUT
@npinto
npinto / cv2_detect.py
Created Sep 5, 2012
Simple face detection with OpenCV 'cv2' python bindings from 2.4.x
View cv2_detect.py
import cv2
import cv2.cv as cv
def detect(img, cascade_fn='haarcascades/haarcascade_frontalface_alt.xml',
scaleFactor=1.3, minNeighbors=4, minSize=(20, 20),
flags=cv.CV_HAAR_SCALE_IMAGE):
cascade = cv2.CascadeClassifier(cascade_fn)
rects = cascade.detectMultiScale(img, scaleFactor=scaleFactor,
@npinto
npinto / labels_to_integers.py
Created Sep 4, 2012
String labels to sorted 0-based integers.
View labels_to_integers.py
In [12]: l = ['a', 'a', 'c', 'c', 'c', 'b']
In [13]: u = np.unique(l)
In [14]: u
Out[14]:
array(['a', 'b', 'c'],
dtype='|S1')
In [15]: np.searchsorted(u, l)
@npinto
npinto / .gitignore
Created Aug 1, 2012
Cython 0.16 C++ Demo
View .gitignore
*.so
_demo.cpp
build
You can’t perform that action at this time.