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 / 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
egonSchiele / diners.hs
Last active Oct 16, 2019
Dining philosophers solution in Haskell using STM. Taken from with some minor modifications.
View diners.hs
import Control.Monad
import Control.Concurrent
import Control.Concurrent.STM
import System.Random
import Text.Printf
-- Forks
type Fork = TMVar Int
newFork :: Int -> IO Fork
egonSchiele / dining.rb
Last active Sep 22, 2018
Dining philosophers in Ruby with Celluloid. Modified from
View dining.rb
require 'rubygems'
require 'celluloid'
class Waiter
include Celluloid
attr_reader :philosophers
attr_reader :forks
attr_reader :eating
egonSchiele / dining_with_waiter.rb
Created May 16, 2013
Dining philosophers using locks in Ruby. This implements a Waiter who is in charge of forks.
View dining_with_waiter.rb
require 'thread'
class Waiter
def initialize
@mutex =
def can_eat? philosopher
left = philosopher.left_fork
right = philosopher.right_fork
egonSchiele / reader.hs
Created Jun 10, 2013
Reader monad example
View reader.hs
import Control.Monad.Reader
hello :: Reader String String
hello = do
name <- ask
return ("hello, " ++ name ++ "!")
bye :: Reader String String
bye = do
name <- ask
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|
egonSchiele / Mario.hs
Created Jul 15, 2013
Lens example using Mario
View Mario.hs
{-# LANGUAGE TemplateHaskell #-}
import Control.Lens
data Point = Point {
_x :: Double,
_y :: Double
} deriving (Show)
data Mario = Mario { _location :: Point } deriving (Show)
egonSchiele / Timer.hs
Created Jul 16, 2013
Drawing timer in Haskell
View Timer.hs
import Control.Concurrent
import System.Process
import System.Environment
say str = system $ "say '" ++ str ++ "'"
timer :: Int -> IO ()
timer 1 = do
say "one minute left! oh crap!"
threadDelay $ 30 * 1000 * 1000
View githubNotifications.hs
import Control.Applicative
import Github.Gists
import Github.Users.Followers
import System.Directory
import Control.Monad
import qualified Data.Set as S
import Text.Printf
import System.Process
import System.IO.Unsafe
egonSchiele / crazy.rb
Created Jul 29, 2013
can't kill this
View crazy.rb
trap("SIGINT") do
puts "goodbye!"
# exit
while true
You can’t perform that action at this time.