Skip to content

Instantly share code, notes, and snippets.

// Preferences.sublime-settings
// Settings in here override those in "Default/Preferences.sublime-settings", and
// are overridden in turn by file type specific settings.
    "draw_white_space": "all",
    "translate_tabs_to_spaces": true,
    "trim_trailing_white_space_on_save": true
View SemanticModel.cs
namespace SemanticModelTest
public class ModelTest
public void RaisesEvents()
// Act
var user = new User();
dlidstrom /
Last active Sep 29, 2015
Intended to be an entry in pcmcontest.
import random
moves = ['R', 'P', 'S']
dna_encode = {
'PP': '1', 'PR': '2', 'PS': '3',
'RP': '4', 'RS': '5', 'RR': '6',
'SS': '7', 'SP': '8', 'SR': '9' }
beat_move = {'R': 'P', 'P': 'S', 'S': 'R'}
output = ''

“Straighter is greater” — Walter Ray Williams, legendar

“Älska att vinna; få aldrig nog av att göra strike. Alla kan göra strike men vinnaren gör även spärr. Spärra så får du chansen att vinna.” > — Lidas, Fredrikshof IF

dlidstrom / isPrime.js
Created Sep 16, 2015
Primality checking using regular expression.
View isPrime.js
function isPrime(n) {
var e = /^1?$|^(11+?)\1+$/;
return !e.exec('1'.repeat(n));
View MiniProfiler.Console.cs
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;
using System.Linq;
using StackExchange.Profiling;
using StackExchange.Profiling.EntityFramework6;
namespace EffortTest
dlidstrom / Program.cs
Created Jun 8, 2015
Complete example on how to retrieve search highlightings using RavenDB
View Program.cs
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using Raven.Abstractions.Data;
using Raven.Abstractions.Indexing;
using Raven.Client;
using Raven.Client.Embedded;
using Raven.Client.Indexes;
dlidstrom / watch.ps1
Last active Oct 14, 2015
Runs a batch file continuously whenever another file is changed.
View watch.ps1
# watch a file changes in the current directory,
# execute all tests when a file is changed or renamed
if (($BatFile -eq $null) -or (-not (Test-Path -Path $Batfile)))
"Specify bat file to run continuously."
dlidstrom / NTimes.cs
Created Apr 1, 2015
Output number of words occurring exactly n times
View NTimes.cs
public class Program
static void Main()
var words = File.ReadAllText(@"C:\Programming\words.txt")
.Split(' ', '\r', '\n')
.Select(x => x.Trim())
.Where(x => !string.IsNullOrEmpty(x))
var candidates = new Dictionary<string, int>();