Skip to content

Instantly share code, notes, and snippets.

@lamberta
lamberta / camshifting.c
Created November 11, 2009 05:18
OpenCV example for face detection with Haar and tracking with CamShift.
#include "camshifting.h"
/* Create a camshift tracked object from a region in image. */
TrackedObj* create_tracked_object (IplImage* image, CvRect* region) {
TrackedObj* obj;
//allocate memory for tracked object struct
if((obj = malloc(sizeof *obj)) != NULL) {
//create-image: size(w,h), bit depth, channels
obj->hsv = cvCreateImage(cvGetSize(image), 8, 3);
#!/bin/bash
# Create Git Repository
# created by Jim Kubicek, 2009
# jimkubicek@gmail.com
# http://jimkubicek.com
# DESCRIPTION
# Create remote git repository from existing project
# this script needs to be run from within the project directory
@subtleGradient
subtleGradient / safari-get-html.js
Created June 16, 2010 18:51
Node.js JavaScript for Mac OS X. Uses osascript AppleScript to control Safari. Remote control Safari from the terminal!
#!/usr/bin/env node #// -*- Mode: Node.js JavaScript; tab-width: 4; -*-
/*
---
url: http://gist.github.com/441101
name : safari-get-html
description : safari-get-html will rock your socks!
authors : Thomas Aylott
copyright : © 2010 Thomas Aylott
license : MIT
@timcharper
timcharper / ido-other-window.el
Created July 28, 2010 03:17
Invoke any command using ido in other window / split window, deciding after the fact instead of before
;; This makes ido-find-file-other-window,
;; ido-switch-buffer-other-window, et. al obsolete. It’s a much better
;; abstraction, and I believe it should become apart of ido mode,
;; because any command that uses ido-completing-read can benefit from
;; it without any additional effort, including textmate.el’s
;; textmate-goto-symbol.
(require 'ido)
(defun ido-completing-read-multiple (prompt choices &optional predicate require-match initial-input hist def sentinel)
"Read multiple items with ido-completing-read. Reading stops
when the user enters SENTINEL. By default, SENTINEL is
\"*done*\". SENTINEL is disambiguated with clashing completions
by appending _ to SENTINEL until it becomes unique. So if there
are multiple values that look like SENTINEL, the one with the
most _ at the end is the actual sentinel value. See
documentation for `ido-completing-read' for details on the
other parameters."
(let
@blambeau
blambeau / destr.rb
Created November 22, 2011 09:00
Fun destructuring in Ruby 1.9
class Hash
def with(&block)
block.call *block.parameters.map{|x| self[x.last]}
end
end
# Example
h = {:name => "blambeau", :hobby => "ruby"}
#!/usr/bin/env ruby-local-exec
require 'rubygems'
require 'active_support'
require 'active_support/core_ext'
class Foo
def self.bar
'bar'
@pvinis
pvinis / face_detector.rb
Created December 7, 2011 12:06
run with "macruby face_detector.rb" or "macruby face_detector.rb https://fbcdn-sphotos-a.akamaihd.net/hphotos-ak-snc7/304055_10150415385415891_522505890_10347873_1682210515_n.jpg?dl=1" for a photo of me with woody and buzz lightyear :p
framework 'Cocoa'
class NSColor
def toCGColor
color_RGB = colorUsingColorSpaceName(NSCalibratedRGBColorSpace)
## approach #1
# components = Array.new(4){Pointer.new(:double)}
# color_RGB.getRed(components[0],
# green: components[1],
# blue: components[2],
module Compass::SassExtensions::Functions::GradientSupport
module Functions
def linear_gradient_hm_header(color)
stop1 = Sass::Script::Number.new(45, ["%"])
stop2 = Sass::Script::Number.new(50, ["%"])
cstops = color_stops(
hmBoxHdrGrad1(color),
ColorStop.new(hmBoxHdrGrad2(color), stop1),
ColorStop.new(color, stop2),
@wtaysom
wtaysom / methodfinder_what.rb
Created December 19, 2011 10:48
_why's Ruby MethodFinder addition tweaked and revised.
require 'methodfinder'
# _why's MethodFinder addition tweaked and revised.
# <http://redhanded.hobix.com/inspect/stickItInYourIrbrcMethodfinder.html>
class MethodFinder
def self.with_redirected_streams
redirect_streams
yield
ensure