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:
using System; | |
using System.Linq; | |
using System.Runtime.CompilerServices; | |
namespace Scratch | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ |
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()); |
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 |
{ | |
"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": { |
-- 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 = |
# 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. |
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) | |
} |
I hereby claim:
To claim this, I am signing this object:
public static int AddFive(int a) | |
{ | |
// object of a compiler-generated type is created | |
Program.<>c__DisplayClass1_0 cDisplayClass10 = new Program.<>c__DisplayClass1_0(); | |
// reference to a compiler-generated field | |
cDisplayClass10.a = a; | |
// reference to a compiler-generated method | |
Program.<AddFive>g__InnerAdd1_0(5, ref cDisplayClass10); | |
// reference to a compiler-generated field | |
return cDisplayClass10.a; |
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import sys | |
import os | |
sys.path.append('/Applications/Anki.app/Contents/Resources/lib/python2.7/site-packages.zip') | |
import anki | |
from anki.exporting import AnkiPackageExporter | |
TMPDIR="/tmp" | |
FBASENAME="thai" |