Skip to content

Instantly share code, notes, and snippets.

View ghosthamlet's full-sized avatar

hamlet ghosthamlet

  • The Rest Is Silence of Code
View GitHub Profile
@egonSchiele
egonSchiele / Mario.hs
Created July 15, 2013 01:41
Lens example using Mario
{-# LANGUAGE TemplateHaskell #-}
import Control.Lens
data Point = Point {
_x :: Double,
_y :: Double
} deriving (Show)
data Mario = Mario { _location :: Point } deriving (Show)
@stuartsierra
stuartsierra / spellcheck.clj
Created July 9, 2013 01:47
Example implementation of Norvig's Spellchecker in Clojure, using core.async
;; Example implementation of Norvig's Spellchecker in Clojure,
;; using core.async
;;
;; There are probably some bugs in this.
;;
;; Original problem: https://github.com/ericnormand/spelling-jam
;; from Lambda Jam, Chicago, 2013: http://lambdajam.com/
;;
;; Clojure core.async introduction:
;; http://clojure.com/blog/2013/06/28/clojure-core-async-channels.html
(ns enliven.lenses
(:refer-clojure :exclude [get put update]))
(defprotocol Lens
(-get [lens data])
(-put [lens data v]))
(defprotocol Updatable
(-update [lens data f]))
(ns enliven.lenses
(:refer-clojure :exclude [get put update]))
(defprotocol Lens
(-get [lens data])
(-put [lens data v]))
(defprotocol Updatable
(-update [lens data f]))
@rm-hull
rm-hull / psychedelic-animation.cljs
Last active May 14, 2019 06:23
ClojureScript re-implementation of a js1k.com runner up, originally by Piotr Stosur: "Animated fractal shapes (mainly rotating spirals) similar to CEVs after taking psychedelic/dissociative drugs. :P Based on copying previous frame into 4 smaller fragments (once per frame, no other kind of iterations) so it's much faster than per-pixel fractal g…
; rewritten in Clojurescript from javascript (originally by Piotr Stosur: http://js1k.com/2013-spring/demo/1431)
(ns psychedelic-animation.demo
(:use [enchilada :only [canvas svg ctx]]
[jayq.core :only [show hide]]
[monet.core :only [animation-frame]]
[monet.canvas :only [fill-style fill-rect draw-image rotate translate]]))
(show canvas)
(hide svg)
@hiredman
hiredman / boot.cljs
Created March 15, 2013 04:43
clojurescript drag and drop
(defn handle-file-select [evt]
(.stopPropagation evt)
(.preventDefault evt)
(let [files (.-files (.-dataTransfer evt))]
(dotimes [i (.-length files)]
(let [rdr (js/FileReader.)
the-file (aget files i)]
(set! (.-onload rdr)
(fn [e]
(let [file-content (.-result (.-target e))
(ns puzzle
(:refer-clojure :exclude [==])
(:use [clojure.core.logic])
(:require [clojure.core.logic.set :as set]))
(defn existso [q ps] (fresh [x] (featurec x ps) (membero x q)))
(defn ruleo [q p v tp tv] (existso q {p v tp tv}))
(defn neg-ruleo [q p v tp tv] (fresh [x] (!= x tv)) (existso q {p v tp x}))
(defn earliero [q p v op ov]
(ns logic-play.puzzle
(:refer-clojure :exclude [==])
(:use [clojure.core.logic])
(:require [clojure.tools.macro :as mu]
[clojure.set :as set]
[clojure.core.logic.fd :as fd]))
;; -----
;; CLP(Set) Boilerplate
(defn index [xs] (->> xs (map-indexed (fn [i x] [x (inc i)])) (into {})))
@arvearve
arvearve / gist:4158578
Created November 28, 2012 02:01
Mathematics: What do grad students in math do all day?

Mathematics: What do grad students in math do all day?

by Yasha Berchenko-Kogan

A lot of math grad school is reading books and papers and trying to understand what's going on. The difficulty is that reading math is not like reading a mystery thriller, and it's not even like reading a history book or a New York Times article.

The main issue is that, by the time you get to the frontiers of math, the words to describe the concepts don't really exist yet. Communicating these ideas is a bit like trying to explain a vacuum cleaner to someone who has never seen one, except you're only allowed to use words that are four letters long or shorter.

What can you say?