Skip to content

Instantly share code, notes, and snippets.

View timvw's full-sized avatar

Tim Van Wassenhove timvw

View GitHub Profile
@timvw
timvw / emptyspark.sh
Last active August 29, 2015 14:23
Create an sbt project for scala and spark
#!/bin/bash
# usage: emptyspark.sh blah
# Result: project is created at /Users/timvw/src/blah
# Inspired by: https://gist.github.com/alvinj/3194379
project=$1
basedir="/Users/timvw/src"
targetdir="$basedir/$1"
scalaversion="2.11.6"
sparkversion="1.4.0"
@timvw
timvw / UpdateVersions.fsx
Last active August 29, 2015 14:23
Update AssemblyVersion and AssemblyFileVersions (in fsharp and scala)
open System
open System.IO
open System.Text.RegularExpressions
let getAssemblyVersionFiles path =
Directory.GetFiles(path, "AssemblyVersions.cs", SearchOption.AllDirectories)
let assemblyVersionPattern = "AssemblyVersion\(\"(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+).(?<build>\d+)\"\)"
let assemblyFileVersionPattern = "AssemblyFileVersion\(\"(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+).(?<build>\d+)\"\)"
@timvw
timvw / getlatest.sh
Created July 7, 2015 08:59
Git fetch on windows
#!/bin/bash
function gitfetch {
cd $1
git fetch
}
for repo in $(find /c/src -type d -maxdepth 1 -name icteam-\*); do gitfetch $repo; done
@timvw
timvw / classify.m
Last active August 29, 2015 14:26
function [accuracy, precision, recall, f1] = classify(X)
% X is a matrix with the following data:
% X(1,1) we predict that it is true, it is true - true positive
% X(1,2) we predict that it is true, it is false - false positive
% X(2,1) we predict that it is false, it is true - false negative
% X(2,2) we predict that it is false, it is false - true negative
accuracy = ( X(1,1) + X(2,2) ) / sum(sum(X))
precision = X(1,1) / ( X(1,1) + X(1,2) )
@timvw
timvw / GetArtifacts.ps1
Created September 25, 2015 09:50
Download all the latest buildartifacts from a set of builds from teamcity
# define parameters
$baseDir = "c:\temp" #"%system.agent.work.dir%"
$username = "ICTEAM\TIMVW"
$password = "Password"
$teamcityUrl = "http://teamcity.icteam.be"
$branchName = "feature/MS-001" #$branchName = "<default>"
$buildTypeIds = @(
"MS_Nightly_Module1",
"MS_Nightly_Module2",
@timvw
timvw / installall.ps1
Created September 29, 2015 09:02
use nuget package manager console in visual studio to install all packages from packages.config
([xml](Get-Content 'packages.config')).packages.package |% { install-package $_.id -version $_.version }
@timvw
timvw / session.sh
Created October 6, 2015 08:40
(imho) inconsistent behaviour
mbpro:~ timvw$ which keepass
mbpro:~ timvw$ keepass
[1] 12681
mbpro:~ timvw$ which keepass
[1]+ Exit 1 mono ~/src/keepass/Build/KeePass/Debug/KeePass.exe > /dev/null 2>&1
@timvw
timvw / Dockerfile
Last active April 7, 2020 19:58
windowsservercore + chocolatey
FROM windowsservercore
LABEL Description="chocolatey on windows" Vendor="icteam" Version="0.1.0"
RUN @powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://ch
ocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
@timvw
timvw / using.sc
Created January 9, 2016 19:38
Scala type refinement
def using[T <: { def close(): Unit }, S](obj: T)
(operation: T => S) = {
val result = operation(obj)
obj.close()
result
}
@timvw
timvw / Demo.sc
Created January 10, 2016 21:11
map/flatmap/filter implemented as for-expression
object Demo {
def map[A, B](xs: List[A], f: A => B): List[B] =
for (x <- xs) yield f(x)
def flatMap[A, B](xs: List[A], f: A => List[B]): List[B] =
for (x <- xs; y <- f(x)) yield y
def filter[A](xs: List[A], p: A => Boolean): List[A] =
for (x <- xs if p(x)) yield x
}