Skip to content

Instantly share code, notes, and snippets.

View whostolebenfrog's full-sized avatar

Ben Griffiths whostolebenfrog

View GitHub Profile
module Parser where
data Token = Open_object | Close_object | Open_array | Close_array | List_delim |
Assign_delim | Quote | String_literal String deriving (Show, Eq, Read)
data JsonElement = FullJsonArray [JsonElement] | StringValue String deriving (Show, Eq, Read)
tokens :: [(Char, Token)]
tokens = [
('{', Open_object),
@whostolebenfrog
whostolebenfrog / quicksort.clj
Created June 13, 2012 15:15
Quicksort in clojure
;; Idea based on concatenating those values before the pivot with the pivot and those that come after the pivot.
;;
;; Call recursively until the length of the collection is 1 (then return just that item in the collection).
;;
;; Getting the items before and after the pivot is done by filtering the collection with an anonymous function
;; that takes a single argument and compares that to the pivot.
(defn quicksort
"Recursive quick sort implementation"
[items]
@whostolebenfrog
whostolebenfrog / quicksort2.clj
Created June 13, 2012 21:44
More clojure quicksort
;; improved version of my first solution, cut out the let by
;; using destructuring.
(defn quicksort [[pivot & others]]
(when pivot
(concat
(quicksort (filter #(>= pivot %) others))
[pivot]
(quicksort (filter #(< pivot %) others)))))
;; code golf style (shortest solution) - based on Tom C's solution
(ns secret-santa.core
(require [clojure.set :refer [difference]]))
;; note: only works if each person is in a single constraint
(def people #{:carole :ben :andrew :hillary :tom :dick :harry :barry})
(def constraints '([:carole :ben] [:andrew :hillary]))
(defn split
(defroutes context-routes
(context "/1.x/users/:userid" req
(GET "/info" {params :params} (get-user-info params))
(POST "/info" [] (update-user-info! req))))
(defroutes clean-routes
(GET "/1.x/status" [] (status-method-elsewhere))
(GET "/1.x/users/:userid/foo" [] (no-foo-here))
(GET "/1.x/users/:userid/bar" [] (keeps-routes-clean)))
@whostolebenfrog
whostolebenfrog / gcnotes
Created March 6, 2013 13:27
Notes from - Martjin Verburg - Garbage collection, the useful parts
Know more - Gil Tene
GC is about tracking live objects, not dead objects.
Poor GC -> OOM, high pauses, long pause times
Hotspot -> C/C++/Assembly
Heap is broken into several generations pools. [all this is tuneable]
-- Eden
@whostolebenfrog
whostolebenfrog / neo_notes.md
Last active December 14, 2015 14:18
Notes on Becoming polyglot - putting neo4j into production. Toby O'Rourke

Neo4j - Becoming polyglot, Putting neo4j into production and what happened next

Bite the bullet - try something novel, they found that getting the tech in allows you to find new usecases and understand what and where it can be used.

Neo technology were the big player, OrientDB and Dex are new players with seemingly successful use. Graph space is becoming bigger. www.orientdb.org sparsity-technologies.com/dex

tinkerpop, Blueprints -> like jdbc for graphs? You don't have to program to the vendors APIs. This means you can compare between the various vendors without having to reimplement for each one. www.tinkerpop.com

@whostolebenfrog
whostolebenfrog / performance_java.md
Created March 6, 2013 17:22
Notes on: Performance testing Java applications - Martin Thompson

Performance testing java applications - Martin Thompson

What is testing

Fast is generic, breaks down to: -- throughput -- bandwidth

-- latency -- response time

@whostolebenfrog
whostolebenfrog / pres.md
Created March 7, 2013 10:20
Notes on: Instantly better presentations - Damian Conway

Instantly better presentations - Damian Conway

It probably just makes more sense to just view his version online at:

http://damian.conway.org/IBP.pdf

But making notes is useful anyway.

7 tips are