Skip to content

Instantly share code, notes, and snippets.

View chribben's full-sized avatar

Christian Jacobsen chribben

View GitHub Profile
import Mouse
import Window
-- Mouse.isDown is true whenever the left mouse button
-- is pressed down and false otherwise.
--MODEL
type Points = [(Int,Int)]
--UPDATE
import List
import Mouse
import Window
--MODEL
defaultBall = {x = 0, y = 0, v = toFloat 0, angle = toFloat 0}
--UPDATE
location t b = { b | x <- b.x - t * b.v * cos b.angle,
y <- b.y - t * b.v * sin b.angle }
import String
import Graphics.Input (Input, input)
import Graphics.Input.Field as Field
xaxis = segment (-150,-100) (150,-100)
yaxis = segment (-150,-100) (-150,100)
content : Input Field.Content
content = input Field.noContent
field = Field.field Field.defaultStyle content.handle id "Type here!" <~ content.signal
import Keyboard
import Window
import Graphics.Input (Input, input, button, dropDown)
import Graphics.Input.Field (Content, noContent, field, defaultStyle, Forward, Backward)
-- MODEL
data Direction = North | East | South | West
type Robot = {x:Int, y:Int, dir:Direction}
type Board = [(Int,Int)]
type Game = {robot:Robot, board:Board}
@chribben
chribben / pong.elm
Last active August 29, 2015 14:03
Pong
import Basics
import Keyboard
import Random
--MODEL
background = {width = 500.0, height = 500.0, color = black}
paddle1 = {width = background.height/30, height = background.height/7, x = 20-background.width/2, y = 0.0}
paddle2 = {paddle1 | x <- background.width/2 - 20}
ball = {side = paddle1.height/5, x = 0, y = 0, vx = 1, vy = 0.3}
--UPDATE
open System
open System.Windows.Forms
open System.Drawing
//************Number of cells and dimensions************
let cellSide = 10
let noOfCellsInOneDir = 16
let side = cellSide * noOfCellsInOneDir
let totNoOfCells = pown noOfCellsInOneDir 2
//***********Helper functions********************
let mapMatrix matrix = (List.map >> List.map) matrix
@chribben
chribben / QuickSort.fsx
Created September 17, 2014 21:12
Using the function pattern matching construct to bind the tuple from List.partion to ltx and gtx in a forward pipe
let rec quickSort l =
match l with
| [] -> []
| x::xs -> xs |> List.partition (fun y -> y < x) |> function (ltx,gtx) -> (quickSort ltx)@x::quickSort gtx
[STAThread]
static void Main()
{
_nui = new Runtime();
var app = new Application();
var window = new Window();
InitializeNui(); //Initializing the Runtime object and opening video streams
CreateGUI(window); //Setting up a canvas to hold the RGB video and the image attached to the hand of captured person
var skeletonFrameReadyObservable = Observable.FromEventPattern(_nui, "SkeletonFrameReady");
var trackedSkeletons = from ev in skeletonFrameReadyObservable
@chribben
chribben / FailingMTUnitTest.cs
Created January 14, 2012 20:55
Failing MT unit test
[Scenario]
public class Test_Bus_Subscriptions_For_Consumers_In_Dummy_Saga_Using_Castle_As_IoC :
Given_a_service_bus_instance
{
readonly IWindsorContainer _container;
public Test_Bus_Subscriptions_For_Consumers_In_Dummy_Saga_Using_Castle_As_IoC()
{
_container = new WindsorContainer();
_container.Register(
@chribben
chribben / EventsNotPublishedUsingMT.cs
Created February 1, 2012 21:19
Events that aren't published
//Test
[TestFixture]
public class TestSendMessageReceiveEvent
{
private IWindsorContainer _container;
private readonly Guid _aggregateId = Guid.NewGuid();
private static readonly ILog _Logger = LogManager.GetLogger(typeof (TestSendMessageReceiveEvent));
private readonly ManualResetEvent _received = new ManualResetEvent(false);
public TestSendMessageReceiveEvent()