Skip to content

Instantly share code, notes, and snippets.

@tarnacious
tarnacious / app.coffee
Created June 13, 2011 09:50
Asteroids
HEIGHT = 600
WIDTH = 900
class Vector
constructor:(@x,@y) ->
add: (other) ->
new Vector @x + other.x, @y + other.y
class KeyboardInput
constructor: ->
@keys = {}
document.onkeyup = (e) =>
@keys[@charCode e] = false
true
document.onkeydown = (e) =>
@keys[@charCode e] = true
@tarnacious
tarnacious / diagrams.coffee
Created June 18, 2011 02:56
Tile Land - Diagrams
class ScaleDiagram
constructor: ->
@context
@height = 40
@width = 40
@camera_x = 200
@camera_y = 120
@camera_height = 80
@camera_width = 80
# Playing around with the examples in Getting Started with WebGL.
#
# https://developer.mozilla.org/en/WebGL/Getting_started_with_WebGL
#
vertices = [ -1.0, -1.0, 1.0, # Font Face
1.0, -1.0, 1.0,
1.0, 1.0, 1.0,
-1.0, 1.0, 1.0,
@tarnacious
tarnacious / _ManosChat.cs
Created July 20, 2011 13:18
Very basic long polling "chat" application using Manos de mono
/*
A very basic long polling "chat" application using Manos de Mono (https://github.com/jacksonh/manos)
The entire project is just this server code, index.html and app.js.
With manos installed it can be built:
$ manos --build
Which produces and single assembly which can be run:
@tarnacious
tarnacious / gist:1109394
Created July 27, 2011 13:50
Wow. Amazingly easy to get working in a shell.
$ make console
(cd bin/ManosYakRiak; csharp)
Mono C# Shell, type "help;" for help
Enter statements below.
csharp> LoadAssembly("ManosYakRiak.dll");
csharp> var client = new RiakClient();
csharp> var message = client.GetLastMessageFromRiak();
csharp> Console.WriteLine("{0}: {1}",message.name,message.message);
345: afasdf<br />asdf<br />asd<br />
@tarnacious
tarnacious / riak.config
Created July 27, 2011 14:29
Connecting to Riak with Corrugated Iron
$ csharp
Mono C# Shell, type "help;" for help
Enter statements below.
csharp> LoadAssembly("CorrugatedIron.dll");
csharp> var config = CorrugatedIron.Config.RiakClusterConfiguration.LoadFromConfig("riakConfig","riak.config");
csharp> var cluster = new CorrugatedIron.Comms.RiakCluster(config, new CorrugatedIron.Comms.RiakConnectionFactory());
csharp> var client = cluster.CreateClient();
csharp> var buckets = client.ListBuckets();
csharp> foreach(var bucket in buckets.Value) { Console.WriteLine(bucket); };
@tarnacious
tarnacious / mailredirect.py
Created November 3, 2011 07:00
MailRedirectServer
import smtpd
import asyncore
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.parser import Parser
import quopri
class MailRedirectServer(smtpd.SMTPServer):
@tarnacious
tarnacious / 4.hs
Created November 4, 2011 10:21
Programming in Haskell excercises
-- 4.8.1
halve :: [a] -> ([a],[a])
halve xs = (take (length xs `div` 2) xs, drop (length xs `div` 2) xs)
-- Eek, I'm sure that's not ideal!
-- 4.8.2
-- a) Conditional
@tarnacious
tarnacious / tdb.hs
Created November 24, 2011 22:50
tdb
$ ghci
GHCi, version 6.12.1: http://www.haskell.org/ghc/ :? for help
Prelude> let make = (\a b -> take b (repeat a))
Prelude> ("abc",123) `make` 3
[("abc",123),("abc",123),("abc",123)]