Showing posts with label clojurescript. Show all posts
Showing posts with label clojurescript. Show all posts

Friday, January 16, 2015

cljx-sampling: A Clojure(script) library for sampling and random numbers

For a current hobby project I need the ability to generate seeded random numbers and/or sample items from collections in either the JVM or the browser. The PPRNG lib offers seedable random numbers, but it uses different generators depending on the environment. Given a seed I want to generate the same sequence of numbers regardless where the code is running.

So I've open-sourced a little library, cljx-sampling, that uses a seedable 32-bit Xorshift random number generator for consistent results in both Clojure and Clojurescript. I also reused some of my code from bigml/sampling and combined it with the Xorshift RNG to allow for convenient (and still consistent) in-memory samples over collections. Maybe you'll find it useful?

https://github.com/ashenfad/cljx-sampling

Saturday, January 26, 2013

My God, it's full of stars... and ClojureScript



I just open sourced a portion of a perpetually half-finished ClojureScript game.  The project uses ClojureScript, canvas, and affine transforms to build an interactive star map. The star map supports panning and zooming (click and drag to pan, scroll in or out to zoom).
The notable bits of the codebase are the canvas namespace and the affine transform namespace. My implementation of the star map was borrowed from an earlier incarnation I once did in Java 2D. I think there's an opportunity for a nice ClojureScript/Clojure library that would accept the same 2D drawing and transform operations for either a browser canvas element or a Java Graphics object.
Anyway...
To see the map in action: http://ashenfad.github.com/stars/
To see the project page: https://github.com/ashenfad/stars