Skip to content

Instantly share code, notes, and snippets.

View mastoj's full-sized avatar

Tomas Jansson mastoj

View GitHub Profile
@mastoj
mastoj / extreme_startup.js
Created February 28, 2013 21:15
Coding dojo. The most interesting parts are from row 123 to 149.
var express = require("express");
/* Reimplement this function to answer questions. */
var myName = function(matches) {
return "Tomas";
};
var yourName = function(matches) {
return matches[1];
private string _connectionStringKey = "MyCloudStorage";
private string _containerName = "mycontainer"; // important with lower case letters
public ActionResult Index()
{
ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";
var files = GetFiles();
return View(model: files);
}
@mastoj
mastoj / sample_tests.sml
Created January 28, 2013 09:13
sml test setup
val remove_card_tests = start_string
val should_thrown_exception_if_not_in_list =
assert_raise ((fn y => remove_card ([(Spades, Jack), (Hearts, Num 5)], (Diamonds, Num 4), CardNotFound)), CardNotFound)
val removes_first_entry_if_in_list =
assert_equal([(Diamonds, Num 8), (Spades, Jack), (Hearts, Ace)],
remove_card ([(Hearts, Ace), (Diamonds, Num 8), (Spades, Jack), (Hearts, Ace)], (Hearts, Ace), CardNotFound),
card_list_formatter)
@mastoj
mastoj / gist:2954528
Created June 19, 2012 14:32
Simple generic output formatter
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
namespace FileGenerator
{
class Program
{
@mastoj
mastoj / Program.cs
Created May 30, 2012 08:51
Eksempel på Parallel
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace ParallellDemo
{
public class Worker
@mastoj
mastoj / RavenDBError
Created May 29, 2012 19:11
Trying to reproduce a raven db error
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;
using Raven.Abstractions.Data;
using Raven.Client.Document;
using Raven.Client.Indexes;
@mastoj
mastoj / ImplicitDemo
Created May 4, 2012 07:47
Implicit operator demo
class Program
{
static void Main(string[] args)
{
var helloB = new HelloB() {PropB = "PropB"};
Console.WriteLine("HelloB.PropB: " + helloB.PropB);
HelloA helloA = helloB;
Console.WriteLine("HelloA.PropA: " + helloA.PropA);
helloA.PropA = "PropA";
Console.WriteLine("HelloA.PropA: " + helloA.PropA);
@mastoj
mastoj / JpgProcessor.cs
Created October 11, 2011 07:53
WcfWebApi Content-Disposition
public class JpgProcessor : MediaTypeFormatter
{
public JpgProcessor()
{
SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/jpg"));
}
protected override object OnReadFromStream(Type type, Stream stream, HttpContentHeaders contentHeaders)
{
throw new NotImplementedException();
}
@mastoj
mastoj / NavigationObserver.cs
Created September 9, 2011 22:28
WatiN observable browser
public class NavigationObserver
{
private HttpStatusCode _statusCode;
private bool _errorOccured;
public NavigationObserver(IE ie)
{
InternetExplorer internetExplorer = (InternetExplorer)ie.InternetExplorer;
internetExplorer.NavigateError += IeNavigateError;
internetExplorer.NavigateComplete2 += internetExplorer_NavigateComplete2;
using System;
using System.Collections.Generic;
using System.Linq;
namespace DynamicTest
{
class Program
{
static void Main(string[] args)
{