Skip to content

Instantly share code, notes, and snippets.

View thoolihan's full-sized avatar

Tim Hoolihan thoolihan

View GitHub Profile
@thoolihan
thoolihan / Rakefile
Created January 20, 2012 14:47
Sample Rakefile for .Net build
namespace :build do
build_configs = ["Debug", "Release"]
desc "build debug"
task "debug" do
sh build_cmd()
end
desc "build release"
task "release" do
@thoolihan
thoolihan / shut-up.el
Created March 14, 2012 21:12
Perhaps my Greatest Emacs Lisp Creation...
(defun shut-up ()
(interactive)
(setq warning-minimum-level :error))
@thoolihan
thoolihan / PasswordTest.cs
Created March 23, 2012 17:24
Example of NUnit TestCase Syntax
[TestCase("abcdefgH", Result = false)]
[TestCase("@Bcdefgh", Result = true)]
[TestCase("#Bcdefgh", Result = true)]
[TestCase("$Bcdefgh", Result = true)]
[TestCase("%Bcdefgh", Result = true)]
[TestCase("^Bcdefgh", Result = true)]
[TestCase("&Bcdefgh", Result = true)]
[TestCase("+Bcdefgh", Result = true)]
[TestCase("=Bcdefgh", Result = true)]
[TestCase("!Bcdefgh", Result = true)]
@thoolihan
thoolihan / Cakefile
Created July 30, 2012 20:17
Basic Cakefile for building all coffeescript files
{exec} = require 'child_process'
task "default", "build the files", (options) ->
exec "coffee --compile --output app/ src/"
exec "coffee --compile --output spec/ spec/"
@thoolihan
thoolihan / jquery-jasmine.js
Last active December 12, 2015 08:19
Using base jQuery functionality to demonstrate jasmine
describe("jQuery", function() {
it("should return correct type for null", function(){
expect($.type(null)).toBe("null");
});
it("should see an empty string as an empty object", function(){
expect($.isEmptyObject("")).toBeTruthy();
});
describe("affirmation create view", function(){
var a_view, values, div, affs;
beforeEach(function(){
div = $('<div class="_surface"></div>');
$('body').append(div);
affs = new App.Collections.Affirmations();
values = new App.Collections.Values([new App.Models.Value({description: 'x'})]);
a_view = new App.Views.NewAffirmation({
el: '._surface',
@thoolihan
thoolihan / gist:5209879
Created March 21, 2013 00:55
TDD Example of Jasmine testing a backbone view
describe("affirmation create view", function(){
var a_view, values, div, affs;
beforeEach(function(){
div = $('<div class="_surface"></div>');
$('body').append(div);
affs = new App.Collections.Affirmations();
values = new App.Collections.Values([new App.Models.Value({description: 'x'})]);
a_view = new App.Views.NewAffirmation({
el: '._surface',
@thoolihan
thoolihan / gist:5209939
Created March 21, 2013 01:12
Example C# Unit Test
using System.Linq;
using Kryptos.Model;
using Kryptos.Model.Tests;
using Kryptos.Presentation.Property;
using NUnit.Framework;
using Rhino.Mocks;
using Should.Fluent;
namespace Kryptos.Presentation.Test.Property
{
@thoolihan
thoolihan / MapReduce.scala
Created April 13, 2013 14:04
currying mapreduce example from Martin Odersky's scala course on Coursera https://class.coursera.org/progfun-002/lecture/37
package week2
object product {
def mapReduce(map:Int=>Int, reduce:(Int,Int)=>Int, init:Int)(a:Int, b:Int): Int = {
if(a>b) init
else reduce(map(a), mapReduce(map,reduce,init)(a+1,b))
} //> mapReduce: (map: Int => Int, reduce: (Int, Int) => Int, init: Int)(a: Int, b
//| : Int)Int
def product(f: Int => Int)(a: Int, b: Int): Int = mapReduce(f,(x,y) => x*y,1)(a,b)
@thoolihan
thoolihan / gist:8675592
Last active January 4, 2016 20:39
#ASPNET Fix
public partial class AdminHomePage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack) //note removal of !
{
try
{
Login sourcePage = Context.PreviousHandler as Login;
Label1.Text = sourcePage.Property1;