Skip to content

Instantly share code, notes, and snippets.

@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 / README.md
Last active February 2, 2016 04:47
Clifford Attractors
@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');
}
}
});
// 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() {
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"
@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
@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 / 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 / colour.as
Created February 10, 2012 12:08
Custom colour library for actionscript, used in gunnmap and astrotour amongst other projects
//Arthur Gunn 2007, [email protected]
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 / _form_carrier_wave_file.html.haml
Created March 24, 2011 10:14
Carrierwave support for rails_admin
= label_tag "#{field.abstract_model.to_param}_#{field.name}", field.label
.input
- if field.bindings[:object].send("#{field.name}_url")
.row
= link_to field.bindings[:object].send("#{field.name}_url")
%br
= form.check_box "remove_#{field.name}"
= form.label "remove_#{field.name}", "Remove existing #{field.label.downcase}", class: "inline"
.row
= form.file_field field.name, class: "fileUploadField #{field.has_errors? ? "errorField" : nil}"