Skip to content

Instantly share code, notes, and snippets.

@banksean
banksean / perlin-noise-classical.js
Created February 15, 2010 10:00
two Perlin noise generators in javascript. The simplex version is about 10% faster (in Chrome at least, haven't tried other browsers)
// Ported from Stefan Gustavson's java implementation
// http://staffwww.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf
// Read Stefan's excellent paper for details on how this code works.
//
// Sean McCullough banksean@gmail.com
/**
* You can pass in a random number generator object if you like.
* It is assumed to have a random() method.
*/
@remy
remy / gist:350433
Created March 31, 2010 14:58
Storage polyfill
if (typeof window.localStorage == 'undefined' || typeof window.sessionStorage == 'undefined') (function () {
var Storage = function (type) {
function createCookie(name, value, days) {
var date, expires;
if (days) {
date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
expires = "; expires="+date.toGMTString();
@natw
natw / fizzbuzz.py
Created November 15, 2012 16:22
best fizzbuzz
import random
for i in range(0, 100):
if not i % 15:
random.seed(1178741599)
print [i+1, "Fizz", "Buzz", "FizzBuzz"][random.randint(0,3)]
@nsmaciej
nsmaciej / sweet.js
Created February 27, 2014 23:53
Messing around with sweet.js (sweetjs.org)
macro $ttos {
case {_ $x} => {
var pattern = #{$x};
var tokenString = pattern[0].token.value.toString();
var stringValue = makeValue(tokenString, #{$here});
return withSyntax($val = [stringValue]) {
return #{$val};
}
}
}

Emacs for Clojure

Some emacs-related links I pointed people at earlier, dropped here for posterity, with commentary.

Emacs distributions

Ubuntu

12.04+ seems to have Emacs 24.3 in its default repos. Just in case, here is a decent PPA with good instructions:

(require '[clojure.walk :refer [macroexpand-all postwalk]]
'[clojure.pprint :refer [pprint]])
(def ^:dynamic *platform* :clj)
(defmacro +clj [form]
(if (= :clj *platform*)
form
::elide))
@pandeiro
pandeiro / README.md
Last active June 2, 2020 08:02
Example of a simple webapp written as a single file

Instructions

  1. Get Boot
  2. Copy the above file to $HOME/app.boot
  3. $ chmod a+x $HOME/app.boot
  4. $ cd && ./app.boot
@sebmarkbage
sebmarkbage / Enhance.js
Last active January 31, 2024 18:33
Higher-order Components
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {
@mrb
mrb / abstint.md
Last active October 4, 2020 18:45
"Programs that eat programs" Works cited/bibliography
@csaunders
csaunders / repl.rkt
Created March 19, 2015 23:26
WOO REPLZ!
Welcome to DrRacket, version 6.0.1 [3m].
Language: racket; memory limit: 128 MB.
exercise 2.1
1/2
-1/2
-1/5
-3/1
exercise 2.2
(0,2.5)
(1.0,3.5)