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 / 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 / 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 / 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 / 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 / logistic_regression_grapefruit.m
Created Mar 10, 2016
Logistic regression for orange vs grapefruit
View logistic_regression_grapefruit.m
% data
x = [1, 2, 3, 4, 5, 6];
y = [0, 0, 0, 1, 1, 1];
% function to calculate the predicted value
function result = h(x, t0, t1)
result = sigmoid(t0 + t1 * x);
% sigmoid function
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 / regression.m
Last active Aug 31, 2018
Linear regression in Octave
View regression.m
% scaled features.
% x = square feet
% y = sale price
x = [1, 2, 4];
y = [2, 2.5, 3];
% function to calculate the predicted value
function result = h(x, t0, t1)
result = t0 + t1 * x;
egonSchiele / why.markdown
Last active Jul 20, 2018
Why read Grokking Algorithms?
View why.markdown

If you have already taken a course in algorithms, why read Grokking Algorithms (

If you were learning graph algorithms, which approach would you prefer:

  1. Imagine you have to take public transit from your home to your office. How do you figure out the fastest route? Use graph algorithms! OR

  2. We can choose between two standard ways to represent a graph G = (V, E): as a collection of adjacency lists or as an adjacency matrix. Either way applies to both directed and undirected graphs.

I prefer the first way: lead with lots of examples, and clear writing. The second way is an excerpt from "Introduction to Algorithms"...that's how they start their section on graph algorithms.

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)
You can’t perform that action at this time.