Skip to content

Instantly share code, notes, and snippets.

View loufranco's full-sized avatar

Lou Franco loufranco

View GitHub Profile
@loufranco
loufranco / make3d.py
Created July 17, 2017 12:41
A Python script to make red/cyan 3D photos
from PIL import Image
import sys
# Check arguments
if len(sys.argv) < 3:
print "Usage: python make3d.py <leftimage> <rightimage> <3doutputname>"
quit()
# Open the left and right images
imLeft = Image.open(sys.argv[1])
#include <iostream>
using namespace std;
struct Const {
Const(int c) : c(c) {}
int c;
};
struct One : Const {
One() : Const(1) {}
@loufranco
loufranco / WrapPatternMatching.swift
Last active August 29, 2015 14:13
Wrapping Swift Pattern Matching in a Closure
import Foundation
import Darwin
// Given Box and Result definitions from "Functional Programming in Swift"
// Buy it here: http://objc.io/books
// You need Box because Swift can't handle generics in Enums directly
public class Box<T> {
let unbox:T
init(_ value:T) { self.unbox = value }
@loufranco
loufranco / capper.c
Created April 4, 2014 00:49
Capitalize the first uncapped word
char* capper(char* s, char* outs) {
strcpy(outs, s);
for (char* s2=outs; *s2; ++s2) {
if (islower(*s2) && (s2==outs || isspace(*(s2-1)))) {
*s2=toupper(*s2);
break;
}
}
return outs;
}