Skip to content

Instantly share code, notes, and snippets.

View sevvie's full-sized avatar

sevvie Rose sevvie

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / cmd-line.ls
Last active December 17, 2015 00:29
These five lines of code make me way too happy.
#!env lsc
global <<< require \prelude-ls
cmd-line-args = drop 2, process.argv
console.log cmd-line-args
@sevvie
sevvie / gol-ls.ls
Last active December 16, 2015 19:29
The Game of Life, in LiveScript, by sevvie. See also: https://gist.github.com/sevvie/5431662. Thanks to @Nami-Doc, @gkz, and @audreyt for the pointers!
# Conway's Game of Life, in LiveScript
# ====================================
#
# Conway's Game of Life is a cellular automaton, published by John H Conway
# in 1970, fulfilling the design principles but greatly simplifying the
# research of von Neumann, into a hypothetical machine that could build
# copies of itself. It is a zero-player game, meaning there is no input, and
# the game will progress on its own with a 'seed', or configuration, to
# begin with.
#
sevvie@Prudence - ~/Downloads % ping guildwars2.com [0]
PING guildwars2.com (64.25.40.16): 56 data bytes
64 bytes from 64.25.40.16: icmp_seq=0 ttl=112 time=136.137 ms
64 bytes from 64.25.40.16: icmp_seq=0 ttl=112 time=136.543 ms (DUP!)
64 bytes from 64.25.40.16: icmp_seq=0 ttl=112 time=136.551 ms (DUP!)
64 bytes from 64.25.40.16: icmp_seq=0 ttl=112 time=136.575 ms (DUP!)
64 bytes from 64.25.40.16: icmp_seq=1 ttl=112 time=95.445 ms
64 bytes from 64.25.40.16: icmp_seq=1 ttl=112 time=95.829 ms (DUP!)
64 bytes from 64.25.40.16: icmp_seq=1 ttl=112 time=95.849 ms (DUP!)
64 bytes from 64.25.40.16: icmp_seq=1 ttl=112 time=96.232 ms (DUP!)
{
package Card;
sub new {
my $type = shift;
my $obj = [];
my $args = [@_];
if( ref(\$args->[0]) eq 'SCALAR' ) {
if( $args->[0] eq 'key' ) {
$obj = [$args->[1], $args->[3]];
package mapgen
import "testing"
func TestNoiseGenerator(t *testing.T) {
prng := new(PerlinNoisePRNG)
prng.seed = 1
var e float64
for i := 0.0; i < 64; i++ {
for j := 0.0; j < 64; j++ {