This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
import datrie | |
import random | |
import string | |
import sys | |
suffix_trie = datrie.Trie(string.ascii_lowercase + u"_") | |
def suffixes(s): | |
return [s[i:] for i in range(len(s))] |
$ node | |
> a = [] | |
[] | |
> b = [] | |
[] | |
> a == b | |
false | |
> a === b | |
false | |
> a == a |
<?php | |
/* | |
* Copyright (c) 2009, Guillermo O. <Tordek> Freschi | |
* All rights reserved. | |
* | |
* Redistribution and use in source and binary forms, with or without | |
* modification, are permitted provided that the following conditions are met: | |
* * Redistributions of source code must retain the above copyright | |
* notice, this list of conditions and the following disclaimer. | |
* * Redistributions in binary form must reproduce the above copyright |
#!/usr/bin/env perl | |
use warnings; | |
use strict; | |
# Read the first parameter: tablename. | |
my $tablename = shift; | |
# The first line holds the names of the fields. | |
my $fields = <>; |
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
module TParser where | |
import Text.ParserCombinators.Parsec | |
import qualified Data.Map as Map | |
import Control.Applicative hiding (many) | |
data TNetString = N | |
| B Bool | |
| S String | |
| I Integer |
A retake on netstrings.
wNetstrings are a silly format I thought of while writing a tnetstrings parser with Parsec in Haskell.
An arguable weakness of tnetstrings is that you need to hold the string up to the type mark in memory in order to start parsing them. This is arguably minimal, since you still need to have everything in memory in order to parse it properly (into a number or whatever). A slightly bigger issue I ran into while writing the parser is that it was hard to write the parser without backtracking, making it slower than it could be (mainly because of Lists and Dicts). Now, arguably, that's just because I know shit about Haskell.
Another format?
postCtx :: Context String | |
postCtx = | |
dateFieldWith esArLocale "date" "%x" `mappend` | |
dateField "isoPublishDate" "%FT%TZ" `mappend` | |
defaultContext | |
authors :: [Person] | |
authors = [ Person | |
{ personName = "Tordek" | |
, personURI = Just absoluteRoot |
# Original Idea by Never Engine | |
# https://neverengine.wordpress.com/2016/08/17/espionage-mission-generator/ | |
import random | |
TEMPLATE = """The mission is to {mission} via {method} in {locale}. Resistance will come from {enemy}, but an ally can be found in {ally}. Potential Intelligence can be uncovered via {intelligence_source}, revealing {intelligence}. Completion of this mission will result in the gain of {reward}. Possible Twists and Turns include: {twists_and_turns}.""" | |
MISSION = [ | |
"Turn Enemies", "Prevent Allies from Turning", | |
"Implicate Enemies", "Prevent Allies from being Implicated", |