Skip to content

Instantly share code, notes, and snippets.


Leon Bambrick secretGeek

Block or report user

Report or block secretGeek

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
secretGeek / WindowsIsUsingDarkTheme.cs
Created Jun 16, 2019
Test if Windows is using a dark theme (from a Windows forms app, for example) (This is not battle-tested in the wild)
View WindowsIsUsingDarkTheme.cs
//using Microsoft.Win32
public bool WindowsIsUsingDarkTheme()
var keyName = @"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize";
var valueName = "AppsUseLightTheme";
var value = Registry.GetValue(keyName, valueName, null);
if (value == null)
return false;
View gist:5ecad391916efa4a3acaa94685d4e41b

(my possibly incorrect line of thinking in relation to this tweet... )

First thing I think is:

we're not trying to work out the probability of being caught exactly once, or exactly twice etc. So we use an old statistics trick and turn it around, asking:

What is one minus the probability that he will be caught exactly 0 times?

To set about answering this, we start by saying, how often does he drink?

secretGeek / fforr.cs
Last active May 15, 2019
A new and better* way to write for loops in C#. (* .... it's not better)
View fforr.cs
// In this week's episode of "YOUR DOING IT WRONG"
void Main()
// The ** OLD ** keyword-heavy way to write a for loop.... nobody does this any more...
for (int i = 0; i < 12; i++)
secretGeek / Program.cs
Created Aug 30, 2017
simulate Alt-Enter in parent console from windows app
View Program.cs
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
namespace PaulBettsWIN32
static class Program
static void Main(string[] args)
View sudoku (linqpad)
void Main()
var grid = goodGrid();
var foundOne = false;
var game = grid.Write();
secretGeek / golfquine.cs
Created Feb 11, 2016
golf quine in c# (157 bytes)
View golfquine.cs
class c{static void Main(){var s="class c{{static void Main(){{var s={0}{1}{0};System.Console.Write(s,(char)34,s);}}}}";System.Console.Write(s,(char)34,s);}}
secretGeek / Download_Worry_Dream_References.linq
Created Feb 11, 2016
LinqPad script that downloads all PDFs/etc from Bret Victors worry dream refs page.
View Download_Worry_Dream_References.linq
void Main()
// LinqPad script that downloads all PDFs/etc from Bret Victors worry dream refs page.
var targetPath = @"PATH_TO_WHERE_YOU_KEEP_YOUR_EBOOK\eBooks";
//These filenames were extracted from -- using NimbleText.
//(TODO: Use regex or html agility pack to find them programmatically)
var refs = new string[] {
View quine.cs
using System;
namespace Quine
class Program
static string[] program = new string[] {
"using System;",
"namespace Quine",
" class Program",
View todo.ps1
dir *.md | % { $file = $_.Name; get-content $_ | select-string -pattern "//TODO:" | % { $file.substring(0,10) + ":" + $_.ToString().replace("//TODO:","").trim() }} | more
secretGeek / bake.ps1
Created Oct 1, 2014
bake.ps1 -- generates an epub for me, using pandoc, with my chosen cover image, stylesheet, yaml metadata and my chapters.
View bake.ps1
pandoc -f markdown -t epub --epub-cover-image=cover.jpg -o yfp.epub --smart --toc --epub-stylesheet=epub.css title.txt .\ .\ .\ .\ .\ .\ .\ .\ .\ .\ .\ .\ .\ .\ --epub-chapter-level=3
You can’t perform that action at this time.