Skip to content

Instantly share code, notes, and snippets.

@hoehrmann
hoehrmann / google-phonetic.pl
Created Feb 14, 2014
Google Translate phonetic (english-only?) transliterations
View google-phonetic.pl
#!perl -w
use strict;
use warnings;
use LWP::UserAgent;
use URI;
use JSON;
use YAML::XS;
my $uri = URI->new('http://translate.google.com/translate_a/t');
View google-geocode-easteregg.json
{
"results" : [
{
"address_components" : [
{
"long_name" : "\u003ca href=http://localhost:20000/form/DataTool.view_region?submit=Send+to+RPC&3=t&3.1=-22.467512&3.1.=y&3.2=-42.655755&3.2.=y&3.3=2.500000&3.3.=y&3.4=0.000000&3.4.=y&3.5=0.071465&3.5.=y&3.6=-1.143429&3.6.=y&database=mapmaker_prod\u003eSV pose\u003c/a\u003e",
"short_name" : "\u003ca href=http://localhost:20000/form/DataTool.view_region?submit=Send+to+RPC&3=t&3.1=-22.467512&3.1.=y&3.2=-42.655755&3.2.=y&3.3=2.500000&3.3.=y&3.4=0.000000&3.4.=y&3.5=0.071465&3.5.=y&3.6=-1.143429&3.6.=y&database=mapmaker_prod\u003eSV pose\u003c/a\u003e",
"types" : [ "route" ]
},
{
View CopyConsoleScreen.c
#include <stdio.h>
#include <stdlib.h>
#include <Windows.h>
int
main(int argc, char *argv[]) {
char* buffer;
BOOL bStatus;
COORD coords;
HANDLE hConsole;
@hoehrmann
hoehrmann / Automaton JSON
Created Nov 10, 2013
Rough sketch for a flexible JSON format to store and exchange state automata.
View Automaton JSON
{
"start": "State0",
"alphabet": {
...
},
"symbols": {
"aA": {
View NNTP over HTTP gateway.txt
Request for status information
* ?action=about&...
* CAPABILITIES
* DATE
* ...
Retrieve some basic information about the service. For instance,
which authentication method the service would like to use, or if
some optional protocol features are implemented. Can also be used
to support the DATE command by looking at the Date header. If
@hoehrmann
hoehrmann / abnf2greibach.pl
Last active Dec 27, 2015
Turns ABNF grammar into a "simpler" ABNF grammar that is essentially in Greibach Normal Form plus epsilon rules so information on which non-terminals match the empty string is not lost; furthermore it only generates terminals for the form %x0000-10FFFF. Specifically, this means that the grammar contains no left recursion.
View abnf2greibach.pl
#!perl -w
use Modern::Perl;
use Parse::ABNF;
use Data::Dumper;
use YAML::XS;
use Graph::Directed;
use List::OrderBy;
#####################################################################
#
@hoehrmann
hoehrmann / compact_diff_to_sdiff.pl
Created Oct 25, 2013
Takes the output of Algorithm::Diff::compact_diff and turns it into what Algorithm::Diff::sdiff would have returned. This may be useful in conjunction with Algorithm::Diff::XS which speeds up compact_diff considerably but not sdiff.
View compact_diff_to_sdiff.pl
#!perl -w
use Modern::Perl;
use Algorithm::Diff::XS;
use Test::More;
use Data::Random qw/rand_chars/;
sub compact_diff_to_sdiff {
my ($a, $b, @cdiff) = @_;
my @temp;
View merge-plain-text-with-html-dom.pl
#!perl -w
use Modern::Perl;
use XML::LibXML;
use Algorithm::Diff::XS;
#####################################################################
# Merges the Lynx rendering of a HTML document with libxml2-parsed
# DOM representation of the same document to figure out which parts
# of the text are in a blockquote element. This is useful when using
# a html2text program while wanting to format parts differently when
@hoehrmann
hoehrmann / truecrypt-apply-keyfiles-to-password.pl
Created Oct 9, 2013
Compute a TrueCrypt password from a TrueCrypt password and associated keyfiles.
View truecrypt-apply-keyfiles-to-password.pl
#!perl -w
use Modern::Perl;
use String::CRC32;
use MIME::Base64;
use autodie;
#####################################################################
# Apply keyfiles to TrueCrypt passwords -- TrueCrypt allows users to
# specify one or more keyfiles that are applied to user passwords to
# make password recovery more difficult. Oddly, many of the popular
View SVG Tidy snippet.js
var properties = {
"alignment-baseline" : {
"ani" : true,
"app" : [
"altGlyph",
"textPath",
"tref",
"tspan"
],
"inh" : false,
You can’t perform that action at this time.