Skip to content

Instantly share code, notes, and snippets.

Avatar
🦕
QUIC & HTTP3 @ JAVA

Oleksii Kachaiev kachayev

🦕
QUIC & HTTP3 @ JAVA
View GitHub Profile
View kleene.clj
(ns kleene)
;;
;; Inspired by "Regexes, Kleene Algebras and Real Ultimate Power"
;; http://plastic-idolatry.com/erik/oslo2014.pdf
;;
;; What do we want to do?...
;;
;; (def p1 (times (Var. "w") (Var. "o") (Var. "w"))
;; (matches? p1 "wow") ;; true
@kachayev
kachayev / gearman-install.sh
Created Jun 13, 2011
Shell/bash script for installing gearman server on debian-like linux
View gearman-install.sh
sudo bash
cd /usr/local/lib
wget http://launchpad.net/gearmand/trunk/0.18/+download/gearmand-0.18.tar.gz
tar -xvzf gearmand-0.18.tar.gz
cd gearmand-0.18/
apt-get install libboost-program-options-dev uuid-dev libevent-dev build-essential g++
./configure && sudo make && sudo make install
ldconfig
@kachayev
kachayev / clojure-channels-1-generator.clj
Last active Oct 7, 2015
Channels-driven concurrency with Clojure
View clojure-channels-1-generator.clj
;; Channels-driven concurrency with Clojure
;; Clojure variant for code examples from this gist:
;; https://gist.github.com/3124594
;; Primarily taken from Rob Pike's talk on Google I/O 2012:
;; http://www.youtube.com/watch?v=f6kdp27TYZs&feature=youtu.be
;;
;; Concurrency is the key to designing high performance network services.
;; Clojure provides several concurrency primitives, like futures/promises, atom, agent etc.
;; There is no implementation for "Go channels" in core, but we can use
;; 3rd-party library Lamina to do the same things.
@kachayev
kachayev / fp.py
Created Oct 30, 2012
Implement mapping data structure and "classes" using functions and lists
View fp.py
## Author: Alexey Kachayev
## Email: kachayev@gmail.com
## Talk: "Functional programming with Python", UA PyCon 2012
## URL: http://ua.pycon.org/static/talks/kachayev/index.html#/
###############################################
## Imitate dictionary functionality
###############################################
def dict_pair((key, value)):
@kachayev
kachayev / barber.go
Last active Dec 11, 2015
Solve "Sleeping Barber Problem" with Golang (more about problem - http://en.wikipedia.org/wiki/Sleeping_barber_problem)
View barber.go
package main
import (
"fmt"
"time"
"math/rand"
)
const (
CUTTING_TIME = 20
@kachayev
kachayev / pingpong.scala
Created Feb 6, 2013
Simplest ping-pong example of Scala Actors
View pingpong.scala
import scala.actors.Actor
import scala.actors.Actor._
case object Ping
case object Pong
case object Stop
class Ping(count: Int, pong: Actor) extends Actor {
def act() {
var pingsLeft = count - 1
@kachayev
kachayev / sleep_barber.erl
Last active Dec 12, 2015
Solve sleeping barber problem with many barbers and many client generators
View sleep_barber.erl
%%
%% Solve sleeping barber problem in most general case
%% Task description on Wikipedia:
%% http://en.wikipedia.org/wiki/Sleeping_barber_problem
%%
%% Additions to classic variant:
%% * many barbers
%% * many clients generators with random timeouts between clients
%% * calculation for total served clients
%% * random time for each client to make barber's job
@kachayev
kachayev / sleep_barber_monitor.erl
Created Feb 11, 2013
Solve sleeping barber problem with many barbers and many client generators and barber failures (monitor)
View sleep_barber_monitor.erl
%%
%% Solve sleeping barber problem in most general case
%% Task description on Wikipedia:
%% http://en.wikipedia.org/wiki/Sleeping_barber_problem
%%
%% Additions to classic variant:
%% * many barbers
%% * many clients generators with random timeouts between clients
%% * calculation for total served clients
%% * random time for each client to make barber's job
@kachayev
kachayev / sleep_barber_exit.erl
Created Feb 11, 2013
Solve sleeping barber problem with many barbers and many client generators and barber failures (exit)
View sleep_barber_exit.erl
%%
%% Solve sleeping barber problem in most general case
%% Task description on Wikipedia:
%% http://en.wikipedia.org/wiki/Sleeping_barber_problem
%%
%% Additions to classic variant:
%% * many barbers
%% * many clients generators with random timeouts between clients
%% * calculation for total served clients
%% * random time for each client to make barber's job
@kachayev
kachayev / uniq_substr.hs
Last active Dec 13, 2015
Define function that returns count of unique substrings consuming O(1) memory
View uniq_substr.hs
import Data.List
uniqSubstr :: String -> Int
uniqSubstr = sum . (map pair) . pairwise . sort . tails
where
pairwise l@(_:ht) = zip l ht
prefix pre post = length $ takeWhile (uncurry (==)) $ zip pre post
pair (pre, post) = length $ drop (prefix pre post) post
You can’t perform that action at this time.