Skip to content

Instantly share code, notes, and snippets.

Avatar

Aditya Bhargava egonSchiele

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.
//
//
View Letter to Mayor Carter
Hi Mayor Carter,
Like many citizens of Saint Paul, I've been glued to the news this week. As protests spread from Minneapolis to Saint Paul, I've been shocked at how cops are ESCALATING this situation instead of DE-ESCALATING it.
We need police reform, and training is not enough.
I want to show you what a cop told me.
"The training involved lecture, personal testimony from people who have had crisis interactions with police, and role-playing scenarios, in which the cops are tested. They generally did not do well. Many didn’t take the training seriously. Most don’t respond well to being challenged. They want to be obeyed. They want total control. People in crisis rarely give them that, and things tend to escalate. The cops are taught how to deescalate situations, using techniques such as mirroring, silence, and modulating the tempo. But, as I said, many of them consider this stuff bullshit. A culture change is necessary, from the top down and from the ground up. A big help would be if cops were legally held
View Letter to Governor Walz
Hi Governor Walz and Lt Governor Flanagan,
Like many citizens of the Twin Cities, I've been glued to the news this week. I want to let you know I'm so thankful that Chauvin got arrested.
Now he needs to be convicted and go to jail.
I've seen again and again that the police get let off with a slap on the wrist. This does not work.
I want to show you what a cop told me.
"The training involved lecture, personal testimony from people who have had crisis interactions with police, and role-playing scenarios, in which the cops are tested. They generally did not do well. Many didn’t take the training seriously. Most don’t respond well to being challenged. They want to be obeyed. They want total control. People in crisis rarely give them that, and things tend to escalate. The cops are taught how to deescalate situations, using techniques such as mirroring, silence, and modulating the tempo. But, as I said, many of them consider this stuff bullshit. A culture change is necessary, from the top down and from the grou
@egonSchiele
egonSchiele / diners.hs
Last active May 25, 2020
Dining philosophers solution in Haskell using STM. Taken from http://rosettacode.org/wiki/Dining_philosophers#Haskell 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
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
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 = Mutex.new
end
def can_eat? philosopher
left = philosopher.left_fork
right = philosopher.right_fork
@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 / 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);
end
% sigmoid function
@egonSchiele
egonSchiele / dining.rb
Last active Sep 22, 2018
Dining philosophers in Ruby with Celluloid. Modified from https://gist.github.com/bugant/4984042
View dining.rb
require 'rubygems'
require 'celluloid'
class Waiter
include Celluloid
FORK_FREE = 0
FORK_USED = 1
attr_reader :philosophers
attr_reader :forks
attr_reader :eating
@egonSchiele
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;
end
You can’t perform that action at this time.