Skip to content

Instantly share code, notes, and snippets.

@cdaven
cdaven / DeadlockController.cs
Created Feb 9, 2022
ASP.NET async Deadlock Example
View DeadlockController.cs
using System.Threading.Tasks;
using System.Web.Mvc;
namespace DeadlockExperiment.Controllers
{
public class DeadlockController : Controller
{
public ActionResult Index()
{
AsyncMethod().Wait(); // Deadlock!
@cdaven
cdaven / AsyncDeadlock.cs
Last active Feb 9, 2022
Example of synchronous blocking causing deadlock
View AsyncDeadlock.cs
async Task PauseAsync()
{
// Normal asynchronous method call
await Task.Delay(1000);
}
void Pause()
{
// Synchronous method blocking on asynchronous method
PauseAsync().Wait();
@cdaven
cdaven / AdventOfCode2020_Day1.fs
Last active Dec 2, 2020
Advent of Code 2020, Day1 (F#)
View AdventOfCode2020_Day1.fs
open System
let readLines filePath = System.IO.File.ReadAllLines(filePath)
let day1 =
printfn "** Day 1 **"
// Läs in alla rader till ett set av heltal
let entries = readLines "data/1.txt" |> Set.ofArray |> Set.map Int32.Parse
// Ta fram alla "2020-kompis-par" för varje tal
@cdaven
cdaven / MicroBreak.ahk
Last active Aug 13, 2020
Micro Break Reminder for Windows using AutoHotkey
View MicroBreak.ahk
#Persistent
; Run ShowBreakMessage every 30 minutes
SetTimer, ShowBreakMessage, 1800000
Return
ShowBreakMessage:
if (A_TimeIdlePhysical > 900000)
{
; Idle more than 15 minutes - no reminder
@cdaven
cdaven / Spacemacs on Windows 10.md
Last active Apr 9, 2022
Setting up Spacemacs on Windows 10
View Spacemacs on Windows 10.md

Install Emacs First

Download emacs-w64 and extract somewhere, e.g. a tools or apps folder like C:\Users\<user>\tools\emacs.

Select Emacs' Home

Emacs and many other applications store its configuration in the user's "home" folder. Translated directly from the Unix world, that is %UserProfile% (C:\Users\<user>), but Windows prefers %AppData% instead (C:\Users\<user>\AppData\Roaming).

For simplicity's sake, override this by specifying the HOME environment variable explicitly. Emacs and some other applications (e.g. MinGW) lets this override the default.

@cdaven
cdaven / SetupUbuntuDevelopment.sh
Last active Dec 26, 2019
Setup Ubuntu Development Machine on Windows
View SetupUbuntuDevelopment.sh
#!/bin/bash
# Instructions for setting up a custom development machine
# on Ubuntu 18.04, distributed via Microsoft Store.
# Step 1: Install the Windows Subsystem for Linux:
# https://docs.microsoft.com/en-us/windows/wsl/install-win10
# Step 2: Install Ubuntu via Windows Store:
# https://www.microsoft.com/store/apps/9N9TNGVNDL3Q
View TypeScriptChanges.md
View keybase.md

Keybase proof

I hereby claim:

  • I am cdaven on github.
  • I am cdaven (https://keybase.io/cdaven) on keybase.
  • I have a public key whose fingerprint is 9B13 97E4 CED0 D7E1 F3DA 40F1 3CB0 EC77 AA22 DB8C

To claim this, I am signing this object:

View git-flow.md

git-flow cheat sheet

TL;DR from A successful Git branching model by Vincent Driessen.

Creating a feature branch

When starting work on a new feature, branch off from the develop branch.

$ git checkout -b myfeature develop
@cdaven
cdaven / 0_reuse_code.js
Created Jul 4, 2014
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console