Skip to content

Instantly share code, notes, and snippets.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace EulerPalindrome {
class Program {
static void Main(string[] args) {
string test2 = "Anna";
@henrik-ch
henrik-ch / workingNow.cs
Created February 26, 2011 08:41
web access to test at work
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
namespace RestTestApp
{
internal class Program
[Test]
public void StringFormat6() {
string x = "hello";
string y = "jello".Replace("j", "h");
Assert.AreNotSame(x, y);
string z = string.Intern(y);
Assert.AreSame(x, z);
}
@henrik-ch
henrik-ch / SeqRandom.fs
Created June 22, 2011 15:43
start to generate series of random numbers (tuples of double and millisecond delay)
let random = new System.Random()
Seq.initInfinite (fun _ -> (random.NextDouble(), random.Next(500, 10000)))
|> Seq.filter (fun (x,y) -> x < 0.5)
|> Seq.take 5
|> Seq.iter (fun elem -> printfn "%A" elem)
printfn ""
@henrik-ch
henrik-ch / findFromRight.js
Created February 26, 2012 13:32
find right for google app script
// inspired by Chris Rae's VBA site: http://chrisrae.com/vba/
function findRight(findIn, findWhat) {
var findLoc=0;
for(findLoc=(findIn.length - findWhat.length + 1);findLoc>=1;findLoc--)
{
if (findIn.substring(findLoc,(findLoc + findWhat.length)) === findWhat) {return findLoc;}
}
return -1;
}
@henrik-ch
henrik-ch / FindRightTests.js
Created February 29, 2012 06:33
find right test assertions
var q = 'http://gas-unit.googlecode.com/svn/trunk/gas-unit/gasUnit.js';
var s = UrlFetchApp.fetch(q).getContentText();
eval(s);
function runFindRightAssertions() {
var testFixture = new TestFixture('Tests on findRight function');
testFixture.addTest(
@henrik-ch
henrik-ch / gist:2428996
Created April 20, 2012 14:14
haskell show types
:set +t
:unset +
@henrik-ch
henrik-ch / gist:2429013
Created April 20, 2012 14:17
haskell load
:load
--used like
:load myFirstProgram.hs
-- Good one to note, including packages is different and done with<br />
:import
-- used like
:import Data.List
@henrik-ch
henrik-ch / gist:2429157
Created April 20, 2012 14:40
Haskell list comprehensions
-- [output function | generators/predicates]
-- like this
[ x * 2| x <- [1..4]]
-- can be read as take x and multiply it with two, and get x from the list consisting of 1 to 4.
-- [2,4,6,8]
-- or like this
[ (x * 2, y - 3)| x <- [1..3], y <- [2..4]]
--[(2,-1),(2,0),(2,1),(4,-1),(4,0),(4,1),(6,-1),(6,0),(6,1)]
@henrik-ch
henrik-ch / heathrow.erl
Created May 29, 2012 11:17
solution to the heathrow route planning problem from learnyousomeerlang.com
-module(heathrow).
-compile([debug_info, export_all]).
mainFunc() ->
BottomGraphVal = {{0,[]},{0,[]}},
MoveCosts = [{50, 10, 30}, {5, 90, 20}, {40, 2, 25}, {10, 8,0}],
AccIn = {BottomGraphVal, [], []},