Hacker GitHub

← All repos

darius/sketchbook

View on GitHub ↗ ★ 50 Python

Smallish programs written to learn something.

22 mentions on Hacker News by 1 person: 0 stories, 22 comments · first 2011-11-06 · latest 2019-12-14

Mentions per year 22 mentions · busiest year 2013 (5)
20082026
  1. …admitted to some confusion about the "Play on Regular Expressions" paper (which I haven't read): https://github.com/darius/sketchbook/blob/master/regex/nfa_p... Sorry it's not pedagogically great either; I was rederiving the method for…
  2. …but it's very close. You're welcome. FWIW I drafted a lot of variations while messing with this: https://github.com/darius/sketchbook/tree/master/regex (some of this code is incorrect) and https://github.com/darius/sketchbook/tree/master/le…
    comment by abecedarius · 2018-11-12 · in Derivatives of Regular Expressions (2007)
  3. Reminds me of this Python line: decorator = decorator(decorator)(decorator) https://github.com/darius/sketchbook/blob/master/misc/decora... There was a subtle bug when leaving out the last (decorator). I know, it's very silly.
    comment by abecedarius · 2017-09-27 · in Git git git git git
  4. I had some fun Haskelling Thompson's algorithm too: https://github.com/darius/sketchbook/blob/master/regex/nfave... -- though I think Haskell's at a disadvantage for this one.
    comment by abecedarius · 2017-08-21 · in McCLIM: A GUI Toolkit for Common Lisp
  5. Similar: https://github.com/darius/sketchbook/blob/master/misc/autodi...
  6. Since those all have a lot more code than is needed to show the basic idea of an NFA-based matcher: https://github.com/darius/sketchbook/blob/master/regex/nfa_s...
    comment by abecedarius · 2016-07-20 · in Stack Overflow Outage Postmortem
  7. …different styles: structured for precedence climbing, and as you say OO or 'data driven' for Pratt. https://github.com/darius/sketchbook/blob/master/parsing/pre... https://github.com/darius/sketchbook/blob/master/parsing/pra...
    comment by abecedarius · 2016-03-31 · in Super Tiny Compiler
  8. …comparison, since Norvig's Lisp is very different from my Python in lots of distracting ways: https://github.com/darius/sketchbook/blob/master/misc/symbdi... This symbolic differentiator could be made to not blow up, by memoizing, i.e.…
    comment by abecedarius · 2016-01-02 · in Automatic Differentiation (2009)
  9. Here's some code I just hacked up to show the idea: https://github.com/darius/sketchbook/blob/master/misc/autodi... At the bottom it computes both the value and the derivative of x^3 at x=2. x^3 is 8 and 3x^2 is 12. For comparison,…
    comment by abecedarius · 2016-01-02 · in Automatic Differentiation (2009)
  10. The Pratt/TDOP scheme is a decentralized or OO way to organize the same idea. I coded them both, at https://github.com/darius/sketchbook/blob/master/parsing/pre... and https://github.com/darius/sketchbook/blob/master/parsing/pra... (My…
    comment by abecedarius · 2015-05-25 · in Top Down Operator Precedence (1973)
  11. …since it's so often recommended I seem to've missed something. P.S. precedence climbing in Python: https://github.com/darius/sketchbook/blob/master/parsing/pre... . Pratt's top-down operator precedence parsing is essentially an…
    comment by abecedarius · 2014-12-14 · in c4x86 - JIT compiler for x86 in 86 lines
  12. …well-designed. (I haven't tried it yet. What I do is code to ANSI terminal codes directly: e.g. https://github.com/darius/sketchbook/blob/master/misc/sokoba... )
  13. …I had it break these ties by picking the minimum label in each set, so earlier alternatives win: https://github.com/darius/sketchbook/blob/master/lex/dfa_nfa...
    comment by abecedarius · 2014-02-20 · in Fast request routing using regular expressions
  14. I coded a brute-force one before: https://github.com/darius/sketchbook/blob/master/regex/find_... Though it cares about the size of the AST rather than the concrete syntax. I can't try running it now, I'm on an iPad.
    comment by abecedarius · 2014-01-07 · in Python code to solve xkcd 1313 by Peter Norvig
  15. …Does this introspect on the parameters of some_decorator? FWIW I'm happy enough with https://github.com/darius/sketchbook/blob/master/misc/decora...
    comment by abecedarius · 2013-11-03 · in Painless Decorators in Python
  16. …general (decide whether to keep trying some other way, or sleep a bit before the next try, etc.): https://github.com/darius/sketchbook/blob/master/misc/retryi... A couple things look wrong in the OP's last snippet: shouldn't ignore_small =…
    comment by abecedarius · 2013-10-10 · in Abstracting Control Flow
  17. …exactly it (it just enumerated all regexes in order of size), but here's a crude solution now: https://github.com/darius/sketchbook/blob/master/regex/find_... (In defense of my memory, I had written superoptimizers for other things.)
  18. …be even shorter, though I don't seem to have one handy in Python. Pratt parsing is similar, though: https://github.com/darius/sketchbook/blob/master/parsing/pra... And here's precedence parsing in C: http://wry.me/~darius/hacks/dcalc.c (I…
    comment by abecedarius · 2013-02-24 · in How To Write A Calculator in 70 Python Lines
  19. Worth mentioning that the Thompson algorithm can be coded more concisely: https://github.com/darius/sketchbook/blob/master/regex/nfa_s...
    comment by abecedarius · 2013-02-23 · in Debuggex: A visual regex debugger
  20. …can be fun if you try to put your own spin on things, though with diminishing returns. Edit: also https://github.com/darius/sketchbook/blob/master/regex/grep....
  21. …(208341, 66317), (312689, 99532), # (833719, 265381), (1146408, 364913), (4272943, 1360120)] From https://github.com/darius/sketchbook/blob/master/misc/ration...
    comment by abecedarius · 2012-07-25 · in The Mystery of 355/113
  22. …k: loop_node(k, re) def empty(k): return k def seq(re1, re2): return lambda k: re1(re2(k)) From https://github.com/darius/sketchbook I'm not sure how the original comes to 14 lines. btw.
    comment by abecedarius · 2011-11-06 · in Regular Expression Engine in 14 lines of Python