Skip to content

Instantly share code, notes, and snippets.

Aditya Bhargava egonSchiele

Block or report user

Report or block egonSchiele

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
@egonSchiele
egonSchiele / canny.cpp
Created Dec 28, 2010
Adding automatic thresholding to cvCanny in OpenCV
View canny.cpp
// new
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// 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
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 http://dtrace.org/blogs/brendan/2011/10/10/top-10-dtrace-scripts-for-mac-os-x/ */
dtrace:::BEGIN
{
@egonSchiele
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 http://dtracebook.com/index.php/Network_Lower_Level_Protocols:soconnect.d#Mac_OS_X */
@egonSchiele
egonSchiele / install_homebrew.rb
Created Jul 2, 2012
less annoying install_homebrew.rb
View install_homebrew.rb
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
# This script installs to /usr/local only. To install elsewhere you can just
# untar https://github.com/egonSchiele/homebrew/tarball/master 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
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
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
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
@@methods
end
def self.set_method k, v
@egonSchiele
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 GADTs #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@egonSchiele
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
think
dine
@egonSchiele
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
self.think
You can’t perform that action at this time.