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
View keybase.md

Keybase proof

I hereby claim:

  • I am egonschiele on github.
  • I am adit (https://keybase.io/adit) on keybase.
  • I have a public key whose fingerprint is 31AE C08A 8B28 F75B 596D 8146 0264 FC99 3D75 484F

To claim this, I am signing this object:

@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
View notes_on_cameras.markdown

Notes on cameras

Lenses

Focal length

Prime (fixed) lens

If it says 17mm, it's fixed at that...you can't zoom in or out. Advantages: cheaper.

@egonSchiele
egonSchiele / Main.hs
Last active Nov 12, 2015
kcombinations
View Main.hs
{-# LANGUAGE MultiWayIf #-}
import Data.List
import Control.Monad
import Control.Monad.Trans.Writer
kcombinations n arr = snd . runWriter $ combos [] 1 n arr
combos :: (Eq a) => [a] -> Int -> Int -> [a] -> Writer [[a]] ()
combos acc step n array = forM_ (zip array [1..]) $ \(val, i) -> if
| val `elem` acc -> return ()
@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 / 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
@egonSchiele
egonSchiele / dining02.rb
Created May 13, 2013
Another implementation of the dining philosophers in Ruby using Celluloid. This time the forks are mutexes and we don't block to acquire them.
View dining02.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
@egonSchiele
egonSchiele / searchHackage.rb
Created Jun 19, 2013
Search hackage from vim
View searchHackage.rb
#!/usr/bin/env ruby
_import = $stdin.gets
import = _import.chomp.gsub("import", "").gsub("qualified", "").gsub(/as .*/, "")
cmd = "hoogle -i '#{import}'"
puts cmd
packages = `#{cmd}`
lines = packages.split("\n")
package = lines.find do |line|
You can’t perform that action at this time.