Skip to content

Instantly share code, notes, and snippets.

View secretGeek's full-sized avatar
😮‍💨
just-so-tired

Leon Bambrick secretGeek

😮‍💨
just-so-tired
View GitHub Profile
@secretGeek
secretGeek / count.ps1
Last active October 11, 2020 11:42
count.ps1 -- determine number of words added to .md files, and number of tasks done in todo.txt; craft a commit message with this data, and commit all work.
Get-Content *.md | Measure-Object –Word | % { $count = $_.Words }
hg add
$message = "words: " + $count
$todo = (get-content .\todo.txt | select-string -pattern "[_]").length
$done = (get-content .\todo.txt | select-string -pattern "[x]").length
$message = $message + ", tasks: " + $done + "/" + ($todo + $done) + ""
hg commit -m $message
& .\progress.ps1
@secretGeek
secretGeek / progress.ps1
Last active August 29, 2015 14:07
progress.ps1 (assumes commits are handled by count.ps1) give details about daily word and task counts, and show today's progress as a percent of goal.
# draw a bar (in the console) of a given size, n
function bar($n) {
$co = "green";
if ($n -lt 100) {
$co = "red"; #less than 100%: is RED
} elseif ($n -ge 500) {
$co = "blue"; #greater than 500% is Blue
}
1..([system.math]::min(50,$n/10)) | % { barbit($co);}
@secretGeek
secretGeek / stats.ps1
Last active August 29, 2015 14:07
stats.ps1, summarize the numbers of words in each markdown file, and display them by size descending.
$x = "";
dir *.md | % { $x = $_.Name; type $_.Name | Measure-Object –Word | % { ("{0,5}" -f $_.Words) + " " + $x } } | sort -desc
@secretGeek
secretGeek / chapters.ps1
Last active August 29, 2015 14:07
chapters.ps1 -- gives me a basic table of contents for the book I'm working on, include count of words and remaining todo's in each chapter.
$totalWords = 0
$totalTodo = 0;
dir *.md | % {
$name = $_.Name;
$len = $_.length;
$todos = (get-content $_ | select-string -pattern "//TODO:").length
$subChapters = (get-content $_ | select-string -pattern "^### ").length
$words = (get-content $_ | measure-object -word).Words;
$totalWords = $totalWords + $words;
@secretGeek
secretGeek / bake.ps1
Created October 1, 2014 02:50
bake.ps1 -- generates an epub for me, using pandoc, with my chosen cover image, stylesheet, yaml metadata and my chapters.
pandoc -f markdown -t epub --epub-cover-image=cover.jpg -o yfp.epub --smart --toc --epub-stylesheet=epub.css title.txt .\00_Title.md .\01_Before_we_begin.md .\02_ideas.md .\03_Choose_your_concept.md .\04_Landing_page.md .\05_Pricing.md .\06_Build_your_product.md .\07_Launch_time.md .\08_Optimize.md .\09_Support.md .\10_Refresh.md .\11_tools.md .\12_Glossary.md .\13_reading_list.md --epub-chapter-level=3
dir *.md | % { $file = $_.Name; get-content $_ | select-string -pattern "//TODO:" | % { $file.substring(0,10) + ":" + $_.ToString().replace("//TODO:","").trim() }} | more
using System;
namespace Quine
{
class Program
{
static string[] program = new string[] {
"using System;",
"namespace Quine",
"{",
" class Program",
@secretGeek
secretGeek / Download_Worry_Dream_References.linq
Created February 11, 2016 00:59
LinqPad script that downloads all PDFs/etc from Bret Victors worry dream refs page.
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 http://worrydream.com/refs/ -- using NimbleText.
//(TODO: Use regex or html agility pack to find them programmatically)
var refs = new string[] {
"Hamming-TheArtOfDoingScienceAndEngineering.pdf",
"Licklider-IntergalacticNetwork.pdf",
@secretGeek
secretGeek / golfquine.cs
Created February 11, 2016 13:02
golf quine in c# (157 bytes)
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);}}
void Main()
{
//testGenerating();
var grid = goodGrid();
//grid.Write().Dump();
grid.MakeGame();
//grid.Write().Dump();
var foundOne = false;
var game = grid.Write();
while(!foundOne)