Skip to content

Instantly share code, notes, and snippets.

View waf's full-sized avatar

Will Fuqua waf

View GitHub Profile
@waf
waf / keybase.md
Created September 14, 2017 06:58

Keybase proof

I hereby claim:

  • I am waf on github.
  • I am wafuqua (https://keybase.io/wafuqua) on keybase.
  • I have a public key whose fingerprint is CB5A FF04 64BE 97B8 9FD3 190D 67B6 F489 167C 16A3

To claim this, I am signing this object:

Add-Type -AssemblyName System.Speech;
$synth = (New-Object System.Speech.Synthesis.SpeechSynthesizer)
$synth.SelectVoice("Microsoft Zira Desktop")
# speak the text, blocking the current thread
function Speak($text)
{
$synth.Speak($text)
}
@waf
waf / plank-countdown-functional.ps1
Last active October 18, 2017 14:55
plank countdown script in more of a functional style
# main entry point
function Main
{
$total = 60 * 2 + 58
$timings = Generate-Timings -Total $total
Speak-Timings $timings
}
# int -> string[]
# generates an array of strings representing what should be said at each second.
@waf
waf / plank.idr
Created October 19, 2017 16:02
Plank script in idris
-- Counter app, count up in 30 seconds increments, and
-- then count down the last 10 seconds
module Main
import System
-- given a second, what should we say at that second?
sayWhatAt : Int -> String
sayWhatAt 30 = "30 seconds passed"
sayWhatAt 60 = "1 minute passed"
sayWhatAt seconds =
@waf
waf / mobile_device_list.json
Created October 20, 2017 08:15
json from chromedriver's mobile_device_list.cc as of 2017-10-06
{
"iPad": {
"deviceScaleFactor": 2,
"mobile": true,
"height": 1024,
"width": 768,
"touch": true,
"userAgent": "Mozilla/5.0 (iPad; CPU OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1"
},
"Laptop with touch": {
What is parsing?
Turning text (or some other stream of bytes) into a more useful format
- Turning strings into JSON objects
- Turning bytes into TCP packet structs
- Turning strings into some C# object hierarchy
Levels of parsing:
0 - avoid it -- use some standard format and library (json, xml, etc)
1 - string indexOf / split
2 - regex
@waf
waf / Program.cs
Created April 17, 2018 02:22
Testing memory usage when iterating IDictionary vs Dictionary
class Program
{
const int trials = 1_000_000;
static void Main(string[] args)
{
Dictionary<int, string> dict = Enumerable
.Range(1, 10)
.ToDictionary(number => number, number => number.ToString());
@waf
waf / Program.cs
Last active May 3, 2018 10:50
Fun with string interpolation
using System;
using System.Linq;
using System.Runtime.CompilerServices;
namespace Scratch
{
class Program
{
static void Main(string[] args)
{
@waf
waf / DisableAutoInstallApps.reg
Created May 16, 2018 06:26
disable windows 10 auto-installed apps
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager]
"SilentInstalledAppsEnabled"=dword:00000000
@waf
waf / ConEmu-Theme.xml
Last active October 8, 2018 16:07
Dracula ConEmu Theme - matches the colors of http://github.com/waf/dracula-cmd/
<!--
Quick instructions below, see full, detailed instructions here:
https://github.com/joonro/ConEmu-Color-Themes/blob/master/README.org#how-to-install
To install this ConEmu theme, add it to C:\Users\USER\AppData\Roaming\ConEmu.xml:
...
<key name="Colors" modified="2018-10-08 22:42:53" build="180503">
<value name="Count" type="long" data="1"/>
... paste the xml tag here and increment the above count...