Skip to content

Instantly share code, notes, and snippets.

@darraghjones
darraghjones / Program.cs
Created March 25, 2022 14:25
How do I schedule work on the ThreadPool without causing thread starvation
using System.Diagnostics;
const bool async = true;
const bool sync = true;
int concurrency = 0, total = 0, dequeued = 0;
var s = Stopwatch.StartNew();
var cts = new CancellationTokenSource();
cts.CancelAfter(TimeSpan.FromSeconds(30));
Disable-UAC
#--- Configuring Windows properties ---
#--- Windows Features ---
# Show hidden files, Show protected OS files, Show file extensions
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowFullPathInTitleBar -EnableShowFileExtensions
#--- File Explorer Settings ---
# will expand explorer to the actual folder you're in
@darraghjones
darraghjones / MemBroker.cs
Created May 3, 2017 22:27
Subject backed in-memory message broker
class MemBroker : IDisposable
{
private readonly Subject<object> s = new Subject<object>();
public IDisposable Register<T>(Action<T> handler)
{
return s.Subscribe(o =>
{
if (o is T) handler((T)o);
});
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowProtectedOSFiles -EnableShowFileExtensions -EnableShowFullPathInTitleBar
Enable-RemoteDesktop
cinstm fiddler4
cinst git.install
cinstm console-devel
cinstm poshgit
cinstm dotpeek
@darraghjones
darraghjones / billboards.rb
Created January 24, 2012 21:43
Facebook Hacker Cup 2012
def calculate_font_size(width, height, words)
font_size = 0
while true do
return font_size if !will_text_fit(width, height, words, font_size + 1)
font_size += 1
end
end
def will_text_fit(width, height, words, font_size)
rows = 1