Skip to content

Instantly share code, notes, and snippets.

@rm-hull
rm-hull / unknown-pleasures.cljs
Last active October 10, 2017 06:27
PSR B1919+21 is a pulsar with a period of 1.3373 seconds, and a pulse width of 0.04 second. It was the first radio pulsar discovered (on November 28, 1967 by Jocelyn Bell Burnell and Antony Hewish). The power and regularity of the signals was thought to resemble a beacon, so for a time the source was nicknamed "LGM-1" (for "Little Green Men"). A…
(ns big-bang.examples.unknown-pleasures
(:require
[jayq.core :refer [show]]
[enchilada :refer [ctx canvas canvas-size value-of]]
[big-bang.examples.unknown-pleasures.data :refer [data-points]]
[monet.canvas :refer [begin-path move-to line-to close-path
fill fill-rect fill-style
stroke-join stroke-cap stroke-width stroke-style stroke
translate scale save restore]]))
@rm-hull
rm-hull / content.md
Created January 4, 2017 19:16 — forked from ayosec/content.md
Why Lisp macros are cool, a Perl perspective
@rm-hull
rm-hull / SSD1331.py
Created November 27, 2016 11:56 — forked from TheRayTracer/SSD1331.py
The below Python source files control an OLED display (size 96 x 64, 65K colours) using a SSD1331 chipset and the SPI interface. The source code initialises the chipset and includes hardware accelerated functions for drawing primitive shapes and a non-hardware accelerated full ASCII set. Examples include a basic Space Invaders game, and a clock.
import struct
import spidev
import sys
import time
import random
import RPi.GPIO as gpio
ascii = [
[ 0x55, 0x00, 0x55, 0x00, 0x55 ],
[ 0x55, 0x00, 0x55, 0x00, 0x55 ],
@rm-hull
rm-hull / penrose-tiling.cljs
Last active July 5, 2016 19:48
A Penrose tiling is a non-periodic tiling generated by an aperiodic set of prototiles. Penrose tilings are named after mathematician and physicist Roger Penrose who investigated these sets in the 1970s. This gist describes the tiling in terms of a rewriting grammar (an 'L-system') and renders using a turtle (https://github.com/rm-hull/turtle) on…
(ns lindenmayer-systems.demo
(:use [turtle.core :only [draw!]]
[turtle.renderer.vector :only [->svg]]
[turtle.renderer.canvas :only [->canvas]]
[enchilada :only [ctx canvas svg]]
[dommy.core :only [set-html! insert-after! replace! hide! show!]]
[jayq.core :only [show]])
(:use-macros [dommy.macros :only [sel1]]))
(def L '(:left 36))
@rm-hull
rm-hull / quadratic-residues.cljs
Last active June 30, 2016 22:24
Exploring quadratic residues and fixed points with clock arithmetic and digraphs, in Clojurescript with force-directed graph layout provided by _arbor.js_. Inspired, in part, by http://pi3.sites.sheffield.ac.uk/tutorials/week-8. Defaults to 51 data points, which produces a pleasing digraph, but add a _num=X_ param to the URL to show different ri…
(ns quadratic-residue.demo.core)
(defn follow [lookup-table]
(fn [n]
(loop [k n
edges {}]
(let [next-k (lookup-table k)]
(if (edges next-k)
edges
(recur next-k (assoc edges k next-k)))))))
@rm-hull
rm-hull / EARTH.md
Last active March 11, 2016 02:22
ClojureScript & WebGL integration by way of PhiloGL.js - an interactive spheroid. Modified from https://github.com/tsaastam/cljs-webgl-example
@rm-hull
rm-hull / big-bang-simple-animation.cljs
Last active January 4, 2016 12:49
Simple animation demo for big-bang
(ns big-bang.example.cat-animation
(:require-macros [cljs.core.async.macros :refer [go]])
(:require [enchilada :refer [canvas ctx canvas-size proxy-request]]
[cljs.core.async :as async :refer [<!]]
[dataview.loader :refer [fetch-image]]
[big-bang.core :refer [big-bang!]]
[jayq.core :refer [show attr]]))
(defn increment-and-wrap [x]
(if (< x 800)
@rm-hull
rm-hull / BIGBANG_MOUSE_DEMO.md
Last active January 4, 2016 11:49
Demonstration of using Big-Bang: reactively capturing a stream of mouse move events

Move the mouse around to see a demonstration of Big-Bang mouse-move event handling. Big-bang uses core.async to handle events in a reactive manner, dispatching to relevant state-handlers so that manipulating state occurs in a purely functional manner.

In the code below, the update function is only fired when a new mouse-move event is delivered to big-bang's event loop. It is passed the event and the current 'world-state', of which it returns a modified version. The render function is invoked on a javascript requestAnimationFrame() callback only if the world state has been changed.

Big-bang is a new library, and is subject to ongoing change, but supports a flexible architecture which allows:

  • Reactive handling of browser events
  • Interval timer for periodic firings
  • Interaction with any DOM elements (originally targetted against <canvas>, but as demonstrated below there is no restriction)
  • Interaction with the outs
@rm-hull
rm-hull / OM_MOUSE_DEMO.md
Last active January 4, 2016 11:49
Demonstration of using Swannodette's OM: reactively capturing a stream of mouse move events.
#include <nall/platform.hpp>
#include <nall/stdint.hpp>
using namespace nall;
extern "C" {
void filter_size(unsigned&, unsigned&);
void filter_render(uint32_t*, uint32_t*, unsigned, const uint16_t*, unsigned, unsigned, unsigned);
};
enum {