Skip to content

Instantly share code, notes, and snippets.

View DominicFinn's full-sized avatar

Dominic Finn DominicFinn

View GitHub Profile
@DominicFinn
DominicFinn / CheckBoxManager.js
Created January 30, 2013 17:01
A basic check box manager that lets you switch all the checkboxes with a class of 'checkboxElementsClass' on or off.
var checkBoxManager = {
allSelected: false,
checkBoxes: null,
init: function ($checkBoxes) {
var that = this;
that.checkBoxes = $checkBoxes;
},
@DominicFinn
DominicFinn / SmsForm.html
Created February 5, 2013 09:32
An example form for sending SMS using a form on the web for Leanne
<!--https://www.esendex.com/secure/messenger/formpost/SendSMS.aspx?
username=xxx@xxx.com&
account=ex000xxxx&
password=xxx&
recipient=xxx&
body=xxx&
plaintext=1-->
<form method="post" action="https://www.esendex.com/secure/messenger/formpost/SendSMS.aspx?">
<label for="username">Enter your username:</label>
@DominicFinn
DominicFinn / MultipleAssertions.cs
Created April 23, 2013 08:33
A way to test multiple assertions in the same method but not fail on the first assertion so you have an overview of what failed. Note, this is not my ideal situation, just a proof of concept.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;
namespace TestWithExceptions
{
/// <summary>
@DominicFinn
DominicFinn / EsendexSoapQuestion.vb
Created May 7, 2013 15:54
Helping Lea with an Esendex Soap question... Below requires a service reference to be created with the URL https://www.esendex.com/secure/messenger/soap/InboxService.asmx?op=GetMessagesForDay
Imports System.ServiceModel
Module Module1
Sub Main()
Dim service = New ServiceReference1.InboxServiceSoapClient()
Dim messageHeader = New EsendexSoap.ServiceReference1.MessengerHeader
messageHeader.Account = ""
@DominicFinn
DominicFinn / BaseActivity.java
Created May 17, 2013 11:29
Just a little example of extracting some of the ghoulishness of doing find view by ID and then casting to a specific type. I prefer this because then the type is already cast and you don't have to provide the generic type in the argument like GetViewById<T> because it's inferred.
package com.example.test1;
import android.app.Activity;
public class BaseActivity extends Activity {
protected <T> T GetViewById(int id) {
return (T)findViewById(id);
}
@DominicFinn
DominicFinn / LambdasAndAnonymousFunctions.vb
Created May 18, 2013 14:13
A basic example of an array of anonymous types and then using anonymous functions to filter that array.
Module LambdasAndAnonymousFunctions
Sub Main()
Dim people = {
New With {.Name = "Mick", .Age = 12},
New With {.Name = "Michelle", .Age = 24}
}
Dim nameBeginsWithM = Function(name) name.ToUpper.StartsWith("M")
Dim ageIsEven = Function(age) age Mod 2 = 0
@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)
@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 / 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 / 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"]);