Instantly share code, notes, and snippets.

View mission.py
# 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",
View gist:e6ed1fd3d8c42edcc082
$ node
> a = []
[]
> b = []
[]
> a == b
false
> a === b
false
> a == a
View gist:9322235
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))]
View gist:7580693
postCtx :: Context String
postCtx =
dateFieldWith esArLocale "date" "%x" `mappend`
dateField "isoPublishDate" "%FT%TZ" `mappend`
defaultContext
authors :: [Person]
authors = [ Person
{ personName = "Tordek"
, personURI = Just absoluteRoot
View gist:3549370

wNetStrings

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?

View gist:3509609
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
View about.md
View import.pl
#!/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 = <>;
View tinyfw.php
<?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