Skip to content

Instantly share code, notes, and snippets.

View DominicFinn's full-sized avatar
💭
Whirring away

Dominic Finn DominicFinn

💭
Whirring away
View GitHub Profile
@DominicFinn
DominicFinn / server.js
Created July 28, 2013 12:50
Anonymous functions vs Named Functions for Node.js
var start = function(route) {
// sets up the server
http.createServer(function(request, response) {
var pathName = url.parse(request.url).pathname;
console.log("Request for " + pathName + " Recieved");
route(pathName);
@DominicFinn
DominicFinn / forant.vb
Created July 25, 2013 11:36
little swap out thing for Ant
dim nextLesson = (From l In lessons
Where l.Order = currentLesson.Order + 1
Select l).FirstOrDefault()
if not nextLesson is nothing then
Me.NextSong = nextLesson.Id
end if
If (currentLesson.Order > 1) Then
dim previousLesson = (From l In lessons
@DominicFinn
DominicFinn / ErrorController.cs
Created July 19, 2013 13:18
Error Controller for Pete
public sealed class ErrorController : Controller
{
readonly IResponse response;
public ErrorController(IResponse response)
{
this.response = response;
}
public ActionResult Error(HttpStatusCode statusCode, Exception exception)
@DominicFinn
DominicFinn / selenium.php
Last active December 19, 2015 02:39
Basic Selenium Automation with PHP and PHPUnit for Jons perusal.
<?php
class WebTest extends PHPUnit_Extensions_Selenium2TestCase
{
protected function setUp()
{
$this->setBrowser('firefox');
$this->setBrowserUrl('http://www.example.com/');
}
public function testTitle()
@DominicFinn
DominicFinn / timepickerexample.html
Last active December 19, 2015 02:09
DateTime picker example for Ant
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Example</title>
<link href="CSS/smoothness/jquery-ui-1.10.3.custom.css" rel="stylesheet" type="text/css" />
<style>
/* css for timepicker */
@DominicFinn
DominicFinn / AttackTheServer.cs
Created June 20, 2013 11:50
Example of sending lots of requests to the server.
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace WebRequest
{
[TestClass]
public class AttackTheServer
{
@DominicFinn
DominicFinn / namedFunctions.js
Created May 29, 2013 13:44
An interesting benefit of naming your function
var greeter = function greet(people) {
if (people.length > 0) {
console.log("hola " + people.pop());
greet(people);
}
}
greeter(["Hotrod", "Cup", "Grimlock", "Blaster"]);
@DominicFinn
DominicFinn / check.js
Created May 24, 2013 14:19
little things
//some sort of request
{
consoleId: '0c84f45c-b7e4-4d88-9efd-2a3e62acda55'
userId: 'affc5de4-cc3f-4e3f-9dec-0b4af26cc2cd'
gameId: 'dbb4c1dd-3f29-4f5f-b993-5f09d36659db'
}
//some sort of response
@DominicFinn
DominicFinn / Currying.js
Created May 19, 2013 20:10
The specs below rely on Jasmine (http://pivotal.github.io/jasmine/). Just a little test with the Jasmine framework as I haven't really looked at it for more than a year now.
function addTwoNumbers(x, y) {
var oldX = x, oldY = y;
if (typeof oldY === "undefined") {
return function(newY) {
return oldX + newY;
};
}
return x + y;
@DominicFinn
DominicFinn / Recursion.cs
Created May 18, 2013 20:58
Testing performance of different ways to recursively calculate the Fibonacci sequence. Not a great test because a) it doesn't calculate high numbers in the sequence and it doesn't bench mark against iterative ways. Interesting nevertheless.
namespace CSharpEquiv
{
public static class Recursion
{
public static int Fib1(int x)
{
return (x == 1 || x == 2) ? 1 : Fib1(x - 1) + Fib1(x - 2);
}
public static int Fib2(int x)