Skip to content

Instantly share code, notes, and snippets.

View Dalstroem's full-sized avatar

Dennis Dalstrøm Dalstroem

View GitHub Profile
$ mkdir -p ~/.config/xmobar && cd ~/.config/xmobar
git clone https://github.com/jaor/xmobar
cd xmobar
-------------------------------------------------------------
$ sudo apt install libghc-aeson-dev libghc-async-dev libghc-extensible-exceptions-dev libghc-parsec-numbers-dev libghc-regex-compat-dev
@Dalstroem
Dalstroem / keybase.md
Created November 9, 2020 12:20
Keybase proof.

Keybase proof

I hereby claim:

  • I am Dalstroem on github.
  • I am dalstroem (https://keybase.io/dalstroem) on keybase.
  • I have a public key whose fingerprint is DA04 A0B0 2F23 3FDC E5BF 1B05 5A49 1D19 E681 12D4

To claim this, I am signing this object:

@Dalstroem
Dalstroem / New-Password.ps1
Last active June 12, 2019 19:30
PowerShell scripts and functions
function New-Password ($Length=60) {
$characters = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
$random = 1..$Length | ForEach-Object { Get-Random -Maximum $characters.Length }
$characters[$random] -join ''
}
@Dalstroem
Dalstroem / Encrypter.cs
Last active April 19, 2018 07:49
File encryption and decryption with random salt.
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Text;
namespace Dalstroem
{
public class Encrypter
{
@Dalstroem
Dalstroem / calculate-age.md
Created May 29, 2017 06:50
Calculate age
var today = DateTime.Now; // 2017-05-29
var birthday = new DateTime(1988, 2, 26);
var age = (int)(today - birthday / 10000); // 29
@Dalstroem
Dalstroem / Container.cs
Last active November 16, 2016 11:34
Simple IoC container with dependency injection feature.
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
namespace Dalstroem
{
public class Container
{
private readonly ConcurrentDictionary<Type, ContainerEntry> _entries = new ConcurrentDictionary<Type, ContainerEntry>();
@Dalstroem
Dalstroem / TaskWithRetry.cs
Last active June 6, 2016 06:36
C# 6 feature for retrying a task nth times.
public static async Task WithRetry(Func<Task> action, int retryCount = 3)
{
var retries = 0;
while(true)
{
try
{
await action().ConfigureAwait(false);
return;