Skip to content

Instantly share code, notes, and snippets.

View rtraschke's full-sized avatar

Robby Raschke rtraschke

View GitHub Profile
@rtraschke
rtraschke / magic.erl
Last active August 29, 2015 14:25
Encouraged by a tweet by Alice Maz (https://twitter.com/alicemazzy/status/623774654772170752), here's my Erlang version of "how to crack a simple crypt" exercise.
-module(magic).
-export([crack/1]).
crack(BaseH) ->
Base = hex_string_to_bytes(BaseH),
Scores = lists:sort([ {score(Base, I), I} || I <- lists:seq(0, 255) ]),
{_, Best_Key} = lists:last(Scores),
<< <<(C bxor Best_Key)>> || C <- Base >>.
@rtraschke
rtraschke / Readme.md
Last active August 29, 2015 14:15
CSV parser in Lua

The make_csv_parser{ separator="char", delimiter="char", escape=true or "char", trim=true } function builds a CSV line parser. The make_csv_parser() function returns a new function that takes a string (e.g. one line from a CSV file) as an argument and returns an array of field values. The returned function splits the string into components according to the provided special CSV charaters. By default, the setting separator is a comma, the string delimiter is a double-quote, no escape character is used (i.e., string delimiters must be stuttered within a string) and extra spaces around the separators are not trimmed. Setting escape to true uses the backslash character as the escape. Setting trim to true enables the trimming of whitespace around the separator characters.

For example:

> parse = make_csv_parser()
> T = parse [[a b,"a,b"," a,""b""c", hello "world"!,]]
> for i, v in ipairs(T) do print(i, v) end
1	a b
2	a,b

3 a,"b"c

@rtraschke
rtraschke / Trello_Burndown.html
Last active July 28, 2018 21:25
Quick and dirty-ish page and script to pull annotated cards from Trello lists for creating basic burndown charts. Uses the Trello client.js and Google JSAPI APIs. General idea is that you mark lists in your board with a trailing asterisk, and annotate your cards with actions "estimate 1.5 days" or "estimate 5 hours", and then as you work, add ac…
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Trello Estimation Timelines</title>
<style type="text/css">
body {
font-family: arial;
@rtraschke
rtraschke / gitcolorage.lua
Last active December 27, 2015 04:29
Make a color bar showing the age of lines in a file from git blame output.
--[[
Little script that expects to be fed the output of "git blame -t -p"
and will generate SVG image 50 px high with horizontal lines coloured
by the age of a line of code. See the accompanying shells script for
an example invocation.
The SVG will be the number of code lines wide (plus a border).
The brightness of a vertical line shows the age, white being just now,
black, the time the file was first created.