Skip to content

Instantly share code, notes, and snippets.

Simon Stender Boisen ssboisen

  • Humio
  • Aarhus, Denmark
Block or report user

Report or block ssboisen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View ConsoleApplication.cpp
#include "stdafx.h"
#include <iostream>
#include <functional>
class FunctionTester
{
public:
FunctionTester();
std::function<int(bool)> DoStuff();
};
View project_euler_p1.fsx
{1..999} |> Seq.sumBy (fun n -> if n % 3 = 0 || n % 5 = 0 then n else 0)
View problem_2.fsx
let fibs = Seq.unfold( fun (a,b) -> Some( a + b, (b, a + b) ) ) (1,1)
let result = fibs |> Seq.takeWhile ( fun x -> x <= 4000000)
|> Seq.sumBy ( fun x -> if x % 2 = 0 then x else 0)
View gist:1877672
public static void ShouldBeStructurallyEqualTo<T, U>(this IEnumerable<T> actual, IEnumerable<U> expected)
{
var actualList = actual.ToList();
var expectedList = expected.ToList();
actualList.Should().HaveCount(expectedList.Count());
bool isArrayOfValueType = typeof (T).IsArray && typeof (T).GetElementType().IsValueType;
foreach (var pair in actualList.Zip(expectedList, Tuple.Create))
{
if (isArrayOfValueType)
View gist:3002299
public sealed class Option<T> : IEquatable<Option<T>>
{
private readonly T m_Value;
private static readonly Option<T> g_None = new Option<T>();
private Option() { }
private Option(T value)
{
m_Value = value;
}
View wrapgist.ps1
$psgit = @{
'tb' = "git branch -r --no-color |
where { `$_ -match ' (?<fb>origin/(?<b>#1.+))' } |
% { git branch --set-upstream `$matches['b'] `$matches['fb'] }";
}
Set-Alias git Wrap-Git
function Wrap-Git {
if (-not $psgit.ContainsKey($args[0])) {
@ssboisen
ssboisen / gist:3049158
Created Jul 4, 2012
ReplaceElementAt alternatives
View gist:3049158
let ReplaceElementAt index element sequence =
let beforeIndex = sequence |> Seq.take index
let atIndex = element |> Seq.singleton
let afterIndex = sequence |> Seq.skip (index + 1)
Seq.append beforeIndex <| Seq.append atIndex afterIndex
let ReplaceElementAt index element sequence =
let beforeIndex = sequence |> Seq.take index
let afterIndex = sequence |> Seq.skip (index + 1)
seq { yield! beforeIndex; yield element; yield! afterIndex }
View gist:3780381
ssh -L 12345:internal-remote-server:8081 -N username@publicfacing-remote-server
View gist:3780423
#!/bin/sh
changedPackageFiles=$(git diff --cached --name-only | grep -i packages.config)
grepedCommitMessage=$(grep -i 'Update Packages' $1)
if [ -n "$changedPackageFiles" -a -z "$grepedCommitMessage" ]
then
echo "Aborting commit."
echo "Your changing the following packages.config files but you did not confirm this action:"
echo "$changedPackageFiles"
View gist:3877706
git branch -r --merged | where { $_ -match ' origin/(?<branch>ssb.+)' } | % { git push origin {:}$matches['branch'] }
You can’t perform that action at this time.