Skip to content

Instantly share code, notes, and snippets.

@gunn
gunn / colour.as
Created February 10, 2012 12:08
Custom colour library for actionscript, used in gunnmap and astrotour amongst other projects
//Arthur Gunn 2007, arthur@gunn.co.nz
package nz.co.gunn.colour {
public class Colour {
public function Colour () {};
public static function getColourString (colour:uint):String {
var string:String = colour.toString(16);
while (string.length < 6) string = 0+string;
return string;
};
public static function colourFromRGB (rgb:RGB):uint {
@gunn
gunn / index.html
Last active December 14, 2015 22:39
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>OMG Circles!</title>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?1.25.0"></script>
<style type="text/css">
body {
background: #222;
@gunn
gunn / index.html
Last active February 17, 2016 07:53
<!doctype html>
<html>
<head>
<title>JS1k</title>
<meta charset="utf-8" />
</head>
<body>
<canvas id="c"></canvas>
<script>
var b = document.body;
@gunn
gunn / bf.rb
Last active December 17, 2015 22:29
Just a tiny brainfuck implemetation in ruby
class BrainFuck
def initialize code
@code = code.gsub(/[^<>\[\]\+\-\.,]+/, "")
end
def run code
code = @code.split ""
tape = []
c = t = 0
rails new assets_test -O -T --skip-keeps
cd assets_test
echo "\ngem 'ember-rails'" >> Gemfile
echo "\nAssetsTest::Application.config.ember.variant = :development" >> config/application.rb
bundle
rails r "puts Rails.application.config.assets.paths"
// Load the light version of all subjects on page load
App.ApplicationController = Em.Controller.extend({
init: function() {
return App.Subject.find();
}
});
// Fetch all our previously loaded subjects
App.SubjectsRoute = Ember.Route.extend({
model: function() {
@gunn
gunn / application.js
Created August 22, 2014 11:06
Component action forwarding
App.ApplicationRoute = Em.Route.extend({
actions: {
open: function(tweet) {
var handle, url;
handle = tweet.account.screen_name;
url = "https://twitter.com/" + handle + "/status/" + tweet.tweet_id;
return window.open(url, '_blank');
}
}
});
@gunn
gunn / README.md
Last active February 2, 2016 04:47
Clifford Attractors
@gunn
gunn / index.html
Created February 17, 2016 08:08
Slightly de-minified from my js1k entry.
<!doctype html>
<html>
<head>
<title>JS1k</title>
<meta charset="utf-8" />
</head>
<body>
<canvas id="c"></canvas>
<script>
var b = document.body;
@gunn
gunn / index.html
Created January 17, 2017 00:32
D3 nest.sortKeys example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Nest Test</title>
</head>
<body>
<h3>Sorted?</h3>
<script src="https://d3js.org/d3.v4.min.js"></script>