Skip to content

Instantly share code, notes, and snippets.

View hagbarddenstore's full-sized avatar

Kim Johansson hagbarddenstore

View GitHub Profile
@hagbarddenstore
hagbarddenstore / idg-ad.txt
Created October 16, 2015 09:51
A fun rant in Swedish regarding the "Top developers in Sweden"-list.
Kim Johansson, mjukvaruingenjör, Detectify
Antal år i yrket: 6 år.
Kompetens: Agila systemutvecklingsmetoder, arkitetur, devops, molnplattformer,
distribuerade system, skalbarhet, prestanda, databaser.
Många språk, främst C#, Go och PHP.
Verksamhetsområde: Generalist, verksam inom försvarsindustrin, telekombranschen
it-säkerhetsindustrin och webbbyråer.
var allies = m.SubMenu("Muted").SubMenu("Allies").Items;
var enemies = m.SubMenu("Muted").SubMenu("Allies").Items;
foreach (var item in allies.Concat(enemies))
{
Log(item.Name);
}
@hagbarddenstore
hagbarddenstore / s3-get.sh
Created July 14, 2015 20:38
A Bash script to retrieve a file stored on S3 via temporary IAM role credentials.
#!/bin/bash
if [ $# -ne 3 ]
then
echo "Usage: s3-get iam-role-name s3-resource output-file"
exit 1
fi
Role=$1
Resource=$2
@hagbarddenstore
hagbarddenstore / Makefile
Created May 19, 2015 12:50
A Makefile for Go projects
PREFIX?=$(shell pwd)
VERSION=$(shell git describe --match 'v[0-9]*' --dirty='.m' --always)
GO_LDFLAGS=-ldflags "-X `go list ./version`.Version $(VERSION)"
.PHONY: clean all fmt vet lint build test binaries
.DEFAULT: default
all: AUTHORS clean fmt vet fmt lint build test binaries
AUTHORS: .mailmap .git/HEAD
@hagbarddenstore
hagbarddenstore / Classes.cs
Last active August 29, 2015 14:21
The question is, how to parse JSON which contains a defined set of types, but allowing multiple types in an array.
class Animal {
protected Animal(string type)
{
Type = type;
}
public string Type { get; private set; }
}
class Dog : Animal
This file has been truncated, but you can view the full file.
using System;
public static class Program
{
public static void Main()
{
var items = new string[50000];
items[0] = "0";
items[1] = "1";
@hagbarddenstore
hagbarddenstore / example.go
Last active August 29, 2015 14:20
Question: How to determine if a value is a valid nil/empty string or is absent in the input JSON. If the value is absent, it shouldn't be changed, but if it's present and is nil/empty string it should be removed.
package example
const (
updateJson1 = `
{
"firstname": "Peter",
"lastname": "Griffin"
}
`
- name: download teamcity
get_url:
url=https://download.jetbrains.com/teamcity/TeamCity-9.0.3.tar.gz
dest=/tmp/teamcity.tar.gz
sha256sum=cacef22cf53506346078c05ff9c12dd5bd773c90596cf72fbf4ff49ff8493d1a
- name: unpack teamcity
unarchive:
src=/tmp/teamcity.tar.gz
dest=/opt/teamcity
@hagbarddenstore
hagbarddenstore / StructureMap.cs
Created March 26, 2015 13:17
StructureMap example...
var container = new Container();
container.Configure(configurer =>
{
configurer.For<IUsersRepository>().Use<SqlServerUsersRepository>();
configurer.For<IPostsRepository>().Use<SqlServerPostsRepository>();
});
var usersRepository = container.GetInstance<IUsersRepository>();
List<Customer> _customers = new List<Customer>
{
new Customer { Id = 1, Name = "Customer1" },
new Customer { Id = 2, Name = "Customer2" },
new Customer { Id = 3, Name = "Customer3" },
new Customer { Id = 4, Name = "Customer4" },
new Customer { Id = 5, Name = "Customer5" },
new Customer { Id = 6, Name = "Customer6" },
};