Skip to content

Instantly share code, notes, and snippets.


Aditya Bhargava egonSchiele

View GitHub Profile
egonSchiele / canny.cpp
Created Dec 28, 2010
Adding automatic thresholding to cvCanny in OpenCV
View canny.cpp
// new
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
egonSchiele / hfsslower.d
Created Mar 10, 2012
copy of Brenden Gregg's hfsslower.d
View hfsslower.d
#!/usr/sbin/dtrace -s
#pragma D option quiet
#pragma D option defaultargs
#pragma D option switchrate=10hz
/* from */
egonSchiele / soconnect.d
Created Mar 10, 2012
Brendan Gregg's soconnect.d script
View soconnect.d
#!/usr/sbin/dtrace -s
#pragma D option quiet
#pragma D option switchrate=10hz
inline int af_inet = 2; /* AF_INET defined in bsd/sys/socket.h */
inline int af_inet6 = 30; /* AF_INET6 defined in bsd/sys/socket.h */
/* from */
egonSchiele / install_homebrew.rb
Created Jul 2, 2012
less annoying install_homebrew.rb
View install_homebrew.rb
# This script installs to /usr/local only. To install elsewhere you can just
# untar anywhere you like.
module Tty extend self
def blue; bold 34; end
def white; bold 39; end
def red; underline 31; end
def reset; escape 0; end
def bold n; escape "1;#{n}" end
egonSchiele / chk.rb
Created Jul 7, 2012
Find undefined symbols in a ruby script
View chk.rb
require 'rubygems'
require 'ruby2ruby'
require 'ruby_parser'
require 'set'
require 'trollop'
require 'contracts'
include Contracts
class Foo < SexpProcessor
egonSchiele / bench.rb
Last active Nov 11, 2017
Benchmarking OpenStruct alternatives
View bench.rb
require 'benchmark'
require 'ostruct'
require 'rubygems'
require 'deep_struct'
require 'classy_struct'
require 'structure'
require 'deepopenstruct'
require 'recursive-open-struct'
require './fast_struct/lib/fast_struct'
egonSchiele / wrap_bench.rb
Created Mar 4, 2013
Time difference between wrapped methods and regular methods
View wrap_bench.rb
require 'benchmark'
module Wrapper
def self.extended(klass)
klass.class_eval do
@@methods = {}
def self.methods
def self.set_method k, v
egonSchiele / Main.hs
Created Apr 17, 2013
Read and write from a database using persistent and Scotty
View Main.hs
{-# LANGUAGE EmptyDataDecls #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
egonSchiele / rons.rb
Last active Mar 9, 2019
The dining philosophers problem in Ruby, solved using the resource hierarchy solution
View rons.rb
require 'thread'
class Ron
def initialize(name, left_fork, right_fork)
@name = name
@left_fork = left_fork
@right_fork = right_fork
while true
egonSchiele / dining01.rb
Created May 13, 2013
A celluloid implementation of dining philosophers where the forks are actors too. Could cause deadlock since we wait on forks.
View dining01.rb
require 'rubygems'
require 'celluloid'
class Philosopher
include Celluloid
def initialize(name, left_fork, right_fork)
@name = name
@left_fork = left_fork
@right_fork = right_fork
You can’t perform that action at this time.