Skip to content

Instantly share code, notes, and snippets.

"emeraldwalk.runonsave": {
"commands": [
{
"match": "\\.go$",
"cmd": "go test > ~/tcrfeedback 2>&1 && git commit -am wip || git reset --hard"
}
]
}
#!/usr/bin/env bash
if [ "$1" = "" ]; then echo "Usage: gobootstrap.sh kata_name" && exit 1; fi
touch $1.go $1_test.go
go mod init $1/1
go mod tidy
set tabstop=4
set shiftwidth=4
set expandtab
set smarttab
set number
set ai "auto indent
set si "smart indent
set wrap "wrap lines
@alexwirz
alexwirz / TestCombinations.cs
Created August 2, 2015 14:29
Create test combinations for legacy code.
[UseReporter(typeof(DiffReporter))]
[TestClass]
public class TestCombinations
{
public string RunLegacyManagerProcessor(string a, int b, bool c)
{
if (c) return "42";
if (b > 12) return a.Length.ToString();
return b.ToString();
}
@alexwirz
alexwirz / process_stdin_input
Last active August 29, 2015 14:21
read a list of integers from STDIN (hackerrank)
let list =
stdin.ReadToEnd().Split '\n'
|> Array.map(fun x -> int(x))
|> Array.toList
let has number list = List.exists (fun elem -> elem = number) list
let rec distinct list =
match list with
[] -> []
| x :: xs when has x xs -> distinct xs
| x :: xs -> x :: distinct xs
let l = [ 1; 2; 3; 1; 2; 1 ]
distinct l
#/usr/bin/python
import fdb
import time
fdb.api_version(21)
db = fdb.open ()
writesCount = 10000
started = time.time()
@alexwirz
alexwirz / FizzBuzz.swift
Created June 16, 2014 17:31
Fizz Buzz in Swift
import Cocoa
func fizzBuzz (number : Int) -> String {
let (n,m) = (number % 3, number % 5)
switch (n,m) {
case (n,m) where n == 0 && m == 0:
return "FizzBuzz"
case (n,m) where n == 0:
return "Fizz"
case (n,m) where m == 0:
@alexwirz
alexwirz / FoundationDbDemo1.cs
Created June 10, 2014 17:37
Stupid composite key implementation.
private static async Task Demo()
{
var cancellationTokenSource = new CancellationTokenSource();
using (var db = await Fdb.OpenAsync())
{
var partition = db.Partition("my_data");
var firstId = Guid.NewGuid();
var firstSequence = new[] { "foo", "bar", "baz" };
// writing the data:
module FizzBuzz
let fizzbuzzNumberProc x =
if x % 15 = 0 then "FizzBuzz"
elif x % 3 = 0 then "Fizz"
elif x % 5 = 0 then "Buzz"
else x.ToString ()
let fizzbuzzNumber x =
match x with