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 / 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 / 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 / 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 / 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 / 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?
[email protected]&
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 / 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 / gist:4482623
Created January 8, 2013 10:05
Future Pay Setup
<form action="https://secure-test.worldpay.com/wcc/purchase" method="post" class="buyForm">
<input type="hidden" name="amount" ID="amount" value="" runat="server"/><!-- amount due NOW-->
<input type="hidden" name="testMode" id="testMode" value="100" runat="server"/>
<input type="hidden" name="desc" id="desc" value="removed!" runat="server"/>
<input type="hidden" name="cartId" id="cartId" value="Monthly Membership" runat="server"/>
<input type="hidden" name="instId" id="instId" value="removed!" runat="server"/>
<input type="hidden" name="currency" id="currency" value="GBP" runat="server"/>
<input type="hidden" name="futurePayType" id="futurePayType" value="regular" runat="server"/>
<input type="hidden" name="option" id="option" value="0" runat="server"/>
<input type="hidden" name="startDelayMult" value="4" runat="server" id="startDelayMult"/>
@DominicFinn
DominicFinn / IRepository.cs
Created November 22, 2012 11:11
Generic Interface Problem
using System;
using System.Collections.Generic;
using TeaLeague.Core.Domain;
namespace TeaLeague.Core.Repository
{
//What's the best way to approach this, seen as StructureMap seems to have problems with open generics....
@DominicFinn
DominicFinn / LotteryNumbers.java
Created November 19, 2012 21:06
Lottery numbers
package lotterynumbergenerator;
import java.util.Arrays;
import java.util.Random;
public class LotteryNumberGenerator {
public static void main(String[] args) {
//an array to keep track of the numbers that have been created
@DominicFinn
DominicFinn / SessionBuilder.cs
Created November 15, 2012 09:58
SessionBuilder
using FluentNHibernate.Cfg;
using FluentNHibernate.Cfg.Db;
using NHibernate;
using NHibernate.Tool.hbm2ddl;
using TeaLeague.Core.Domain;
namespace TeaLeague.Core.Database
{
public interface INHibernateHelper
{