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 / gist:317994b4b9190287c3c6beff1ecb2ff4
Last active Jul 27, 2019
example of language with self-contained functions
View gist:317994b4b9190287c3c6beff1ecb2ff4

Xah Lee said:

i really want a language where you can copy paste any function definition in any project and use in another project. doesn't seem to exist. For this to work, the function param must encode any dependency, of global var and libs.

It took me a while to get my head around this idea, but here's some thoughts so far.

(I'll use C# as my example syntax here)

Imagine a function that is already self-contained....

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 Aug 16, 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
You can’t perform that action at this time.