Skip to content

Instantly share code, notes, and snippets.

Avatar

Dennis Dalstrøm Dalstroem

View GitHub Profile
View xmobar.txt
$ 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
View keybase.md

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 Jun 12, 2019
PowerShell scripts and functions
View New-Password.ps1
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 Apr 19, 2018
File encryption and decryption with random salt.
View Encrypter.cs
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Text;
namespace Dalstroem
{
public class Encrypter
{
View calculate-age.md
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 Nov 16, 2016
Simple IoC container with dependency injection feature.
View Container.cs
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 Jun 6, 2016
C# 6 feature for retrying a task nth times.
View TaskWithRetry.cs
public static async Task WithRetry(Func<Task> action, int retryCount = 3)
{
var retries = 0;
while(true)
{
try
{
await action().ConfigureAwait(false);
return;