Skip to content

Instantly share code, notes, and snippets.

View Tordek's full-sized avatar
🤔
Thinking of code

Guillermo O. Freschi Tordek

🤔
Thinking of code
View GitHub Profile
# 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",
$ node
> a = []
[]
> b = []
[]
> a == b
false
> a === b
false
> a == a
@Tordek
Tordek / gist:9322235
Last active August 29, 2015 13:56
Trie-based random word implementation
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))]
@Tordek
Tordek / gist:7580693
Last active December 28, 2015 23:39
Playing around with Hakyll and Atom
postCtx :: Context String
postCtx =
dateFieldWith esArLocale "date" "%x" `mappend`
dateField "isoPublishDate" "%FT%TZ" `mappend`
defaultContext
authors :: [Person]
authors = [ Person
{ personName = "Tordek"
, personURI = Just absoluteRoot
@Tordek
Tordek / gist:3549370
Created August 31, 2012 05:34
wNetstrings

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?

@Tordek
Tordek / gist:3509609
Created August 29, 2012 10:03
TNetstring parser
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
@Tordek
Tordek / about.md
Created August 10, 2011 23:05 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
@Tordek
Tordek / import.pl
Created November 22, 2010 19:04
CSV to SQL
#!/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 = <>;
<?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