Skip to content

Instantly share code, notes, and snippets.

View zeeshanlakhani's full-sized avatar

Zeeshan Lakhani zeeshanlakhani

View GitHub Profile
@jeremyheiler
jeremyheiler / WaitNotify1.java
Last active August 29, 2015 14:04
Basic example of using wait() and notify().
public class Main {
public static final Object LOCK = new Object();
public static void main(String[] args) throws InterruptedException {
new Thread(new A()).start();
new Thread(new B()).start();
}
}
@ctford
ctford / lenses.clj
Created July 12, 2014 20:40
A Clojure lens implementation based on focus and fmap.
(ns shades.lenses)
; We only need three fns that know the structure of a lens.
(defn lens [focus fmap] {:focus focus :fmap fmap})
(defn view [x {:keys [focus]}] (focus x))
(defn update [x {:keys [fmap]} f] (fmap f x))
; The identity lens.
(defn fapply [f x] (f x))
(def id (lens identity fapply))
@philandstuff
philandstuff / euroclojure2014.org
Last active February 19, 2024 05:12
Euroclojure 2014

EuroClojure 2014, Krakow

Fergal Byrne, Clortex: Machine Intelligence based on Jeff Hawkins’ HTM Theory

  • @fergbyrne
  • HTM = Hierarchical Temporal Memory
  • Slides

big data

  • big data is like teenage sex
    • noone knows how to do it
    • everyone thinks everyone else is doing it
module Main
import Effect.State
data BTree a = Leaf
| Node (BTree a) a (BTree a)
instance Show a => Show (BTree a) where
show Leaf = "[]"
show (Node l x r) = "[" ++ show l ++ " "
: fib ( a b -- x y ) [ + ] keep swap ;
! My goal was to implement this with produce.
1 1
[ dup 4000000 < ] [ fib dup ] produce
2nip ! Remove the workspace
dup length 1 - swap remove-nth ! Remove the extra value
[ dup odd? [ drop 0 ] when ]
map-sum
USING: kernel math math.functions sequences ;
IN: euler1
: euler1 ( x -- y )
iota [ dup [ 3 divisor? ] [ 5 divisor? ] bi or [ drop 0 ] unless ] map-sum ;
@gfredericks
gfredericks / schema->gen.clj
Created March 26, 2014 16:49
Trying to generate test.check generators from prismatic schemas.
(ns schema->gen
"Functions for generating test data from schemas."
(:require [four.stateful :as four]
[re-rand :refer [re-rand]]
[schema.core :as sch]
[simple-check.generators :as gen]))
(defn ^:private re-randify-regex
"schema requires ^$ while re-rand forbids them"
[re]
@slfritchie
slfritchie / presentation.md
Created March 18, 2014 09:22
Erlang tracing, for the Riak source code reading series, 2014-03-18, Tokyo, Japan

Erlang Tracing: more than you wanted to know

Rough Outline

  • What can be traced?
  • How can trace events be specified?
  • "match specifications": twisty passages, all alike
  • WTF, can I just use DTrace and drink my coffee/beer/whisky in peace?
  • Trace delivery mechanisms: pick one of two
@elasticdog
elasticdog / gist:8806073
Last active May 9, 2019 18:19
Working with Git Submodules

Add New Submodule

$ cd ~/.dotfiles/
$ git submodule add http://github.com/scrooloose/nerdtree.git vim/bundle/nerdtree
$ git submodule init
$ git commit -m 'Add nerd tree plugin as submodule'

Updating

@DarrenN
DarrenN / buffer.cljs
Last active December 31, 2015 08:49
Buffered vector as a value - not stored in an atom
(ns DarrenN.stateless.buffer)
;; create-buffer returns a vector scoped to size. When new items are added
;; they are passed to functions in add-listeners. If the vector is at its
;; size limit then items are shifted off the front of the vector and
;; passed to the functions in destroy-listeners
;; Callbacks for adding/removing item from vector
(def destroy-listeners [(fn [i] (print (str i " removed")))])
(def add-listeners [(fn [i] (print (str i " added")))])