Skip to content

Instantly share code, notes, and snippets.

View sevvie's full-sized avatar

sevvie Rose sevvie

View GitHub Profile
@sevvie
sevvie / testml_bridge.ls
Last active December 17, 2015 02:29
Converting TestML-rb's
testml = require("../lib/testml")
class TestMLBridge
uppercase: (s) ->
s.to-upper-case!
lowercase: (s) ->
s.to-lower-case!
combine: (...args) ->
@sevvie
sevvie / gol.clj
Created May 27, 2013 03:18
Continuing my explorations into Conway's Game of Life.
; An exploration into Conway's Game of Life, in Clojure.
; Based on the work of Chas Emerick, Brian Carper and Christophe Grand, in the book
; _Clojure Programming_.
;
; There are three implementations of the stepping function here:
; - indexed-step, which handles the algorithm much like I have in other languages.
; - indexed-functional-step, which removes the loops and instead operates with reduces
; - functional-step, a method that removes the need for indexes by using the properties of sequences
; - pure-step, an elegant and tiny redesign of the idea.
(defn empty-board
@sevvie
sevvie / wilsons-maze.clj
Last active December 17, 2015 19:59
I've fallen head-over-heels for Clojure. x.x Working through _Clojure Programming_, though, I've run into a problem I just can't seem to figure out; it behaves as if it's working, except it doesn't actually draw the maze. Forgive my spacious manner of writing Lisps. It just makes it easier to visualize everything for me.
(defn wilson-maze
"Returns a random maze carved out of walls; walls is a set of
two-item sets, #{a b}, where a and b are locations. The returned
maze is a set of the remaining walls."
[walls]
(let [paths (reduce
(fn [index [a b]] (merge-with into index {a [b] b [a]}))
{} (map seq walls))
start-loc (rand-nth (keys paths))]
(loop [walls walls
@sevvie
sevvie / target-web.js
Last active December 18, 2015 09:39
An exploration of languages that compile to JavaScript.
var express = require('express')
var port = process.env.PORT || 5000;
var app = express();
app.use(express.logger());
app.get('/', function (req, res) {
res.send("Hello world, from Java`Script.");
});
@sevvie
sevvie / second-song.clj
Created July 14, 2013 08:03
I haven't had this much fun programming in a long time. Live-coding example, with Clojure, Overtone & SuperCollider. I don't know if it's actually music, though.
(ns overtone-tutorial.second-song
(:use overtone.live
overtone.inst.drum))
(def metro (metronome 120))
(definst saw-wave [freq 440 attack 0.01 sustain 0.4 release 0.1 vol 0.4]
(* (env-gen (lin-env attack sustain release) 1 1 0 1 FREE)
(saw freq)
vol))
@sevvie
sevvie / dlog.ls
Last active December 20, 2015 08:49
global <<< require \prelude-ls
fs = require \fs
yaml = require \js-yaml
marked = require \marked
hljs = require \highlight.js
jade = require \jade
marked.setOptions {highlight: (lang, code) ->
hljs.highlightAuto(lang, code).value
}
use v6;
use lib 'lib';
use Test;
subtest {
ok 1 + 1 eq 2, "Reality sinks in; this isn't a dream.";
is 123.WHAT.gist, "(Int)", "Integers are treated as _scalar Int objects_";
is 1.23.WHAT.gist, "(Rat)" "Rationals are treated as _scalar Rat objects_";
is "moo".WHAT.gist, "(Str)", "Strings are treated as _scalar Str objects_";
is [1, 2, 3].WHAT.gist, "(Array)", "Arrays, or Lists, are treated as _Array objects_";
is {'name' => 'Camelia'}.WHAT.gist, "(Hash)", "Hashes, or hash-maps, are treated as _Hash objects_";
}, "Yeah... I've suspended disbelief for the narrative; I'm stranded.";
@sevvie
sevvie / gist:f76fc310473dd64d2e7d
Created February 14, 2016 08:06
Happy Valentine's Day, love.
The game is on; your first clue has two parts:
the monitor you gave
https://goo.gl/3NCcdL
@sevvie
sevvie / Model.jsx
Created May 22, 2016 20:32
the most beautiful react code I have seen, thanks to mobx.
class AppState {
@observable raw_ticket_data;
@observable sort_by = 'Owner';
@observable group_by = 'Queue';
constructor(raw_ticket_data) {
this.raw_ticket_data = raw_ticket_data;