Skip to content

Instantly share code, notes, and snippets.

View jdoig's full-sized avatar

James Doig jdoig

  • Addepar
  • Edinburgh
View GitHub Profile
@jdoig
jdoig / 1-each.rb
Created October 29, 2011 12:24
7 Languages in 7 Weeks: Day 2
(1..16).to_a.each {|i| i % 4==0 ? puts(i) : print(i) }
@jdoig
jdoig / oops.rb
Created November 9, 2011 19:02
Total bastardization of day 3
def get_filename(obj)
filename = obj.to_s.downcase + '.txt'
end
def read_line(line)
line.chomp.split(', ')
end
module ActsAsCsv
def self.included(base)
@jdoig
jdoig / nicerImmutable.cs
Created February 21, 2012 21:54
some .NET 4.0 syntax sugar for immuable state
class Program
{
static void Main(string[] args)
{
var james = new Person(
name: "James",
age: 31,
deceased: false);
}
}
@jdoig
jdoig / profiles.clj
Created August 12, 2012 09:31
example of a profile using github repro plugin
{:user {:plugins [[lein-difftest "1.3.7"]
[lein-marginalia "0.7.1"]
[lein-pprint "1.1.1"]
[lein-swank "1.4.3"]
[lein-git-deps "0.0.1-SNAPSHOT"]]}}
@jdoig
jdoig / project.clj
Created August 12, 2012 09:32
adding git dependancies to a project
:git-dependencies [["git://github.com/tnm/murmurhash-java.git"]]
:java-source-paths [".lein-git-deps/murmurhash-java/src/main/java/ie/ucd/murmur/"]
@jdoig
jdoig / github_java_import_demo.clj
Created August 12, 2012 09:39
importing java example
(ns github-java-import-demo.core
(:import (ie.ucd.murmur MurmurHash))
(:gen-class))
(defn -main
"I don't do a whole lot."
[& args]
(println (str "Hello " (MurmurHash/hash32 "World"))))
@jdoig
jdoig / Application.coffee
Last active December 13, 2015 19:58
hello-world for game{closure} in coffeescript
`import ui.TextView as TextView`
class helloWorld extends GC.Application
initUI:->
textView = new TextView({
superview: @view
layout: "box"
text: "Hello, Coffee!"
color: "white"})
@jdoig
jdoig / Application.coffee
Last active December 13, 2015 20:38
Coffeescript game{closure} trail animation example
`import ui.View as View`
`import animate`
toColor = (x) -> (x % 255).toString(16)
class Trail extends GC.Application
createTrail: (pt) ->
opts = merge(pt, {superview: GC.app.view})
new TrailBox(pt, opts)
@jdoig
jdoig / Application.coffee
Created February 25, 2013 23:03
A Mario sprite animated using game{closure} and coffeescript
`import ui.SpriteView as SpriteView;`
class Mario extends GC.Application
initUI: ->
sprite = new SpriteView({
superview: @.view
x: 100
y: 100
width: 23
height: 29
ig.module
'game.entities.Player'
.requires
'impact.entity'
.defines =>
class @.EntityPlayer extends ig.Entity
animSheet: new ig.AnimationSheet 'media/player.png', 16, 16
size: