Skip to content

Instantly share code, notes, and snippets.

View tbl3rd's full-sized avatar
👣
Scalawag

Tom Lyons tbl3rd

👣
Scalawag
View GitHub Profile
# ~/Src/Perl/scrabble.pl
Usage: scrabble.pl <words-file> <letter> [<letter> ...]
Where: <words-file> is a file of words to search.
<letter> is a letter [a-z].
Print to STDOUT a list of words from <words-file>
composed of only the <letter>s specified.
1# ~/Src/Perl/scrabble.pl words-file a b c
Error: Cannot open 'words-file'
Usage: scrabble.pl <words-file> <letter> [<letter> ...]
Where: <words-file> is a file of words to search.
tbl.local # ls
stl.cc
tbl.local # cat stl.cc
// C++ has strong support for internationalization and localization, and
// it is better developed than the C equivalents. Here's a small sample
// program illustrating some techniques. This program is pure ANSI/ISO
// standard C++. It should compile and run on any conforming hosted C++
// implementation on any OS. If you want it to run on a platform that
// uses wide characters for its native data representation, just change
// 'std::string' to 'std::wstring' in main(). It parses words and frobs
@tbl3rd
tbl3rd / icon.curl
Created March 20, 2013 01:37
Bit-frobbing in Curl, a programming language: http://www.curl.com/
|| See http://msdn2.microsoft.com/en-us/library/ms997538.aspx
|| A .ico file is an IconDir followed by 0 or more IconDirEntry
|| objects, one for each icon pixmap in the file. Each IconDirEntry
|| describes an IconImage object. All the IconImage objects are in a
|| last section following all the IconDirEntry objects.
|| Note: Encode every icon with 32-bit pixels because that's where the
|| world is headed anyway, and it is much simpler.
@tbl3rd
tbl3rd / meta.pl
Created March 20, 2013 01:54
Perl meta-programming in anger.
#!/usr/bin/perl -w
use strict;
use sigtrap qw(die normal-signals error-signals);
use Carp;
use Config;
use Fcntl qw(:flock);
use File::Basename;
use File::Copy;
use File::Path;
@tbl3rd
tbl3rd / Get out of Python free!
Last active December 18, 2015 08:29
Sugar a dict with object syntax.
# Work around the usual object orientation problem with the
# "Get out of Python free!" card.
#
class Oops:
def __init__(self, **stuff):
self.__dict__.update(stuff)
def start_capture_subprocesses(logdir):
"""
Start a console capture subprocess for each node in configstore,
~/C # cat reverse.c
// make CFLAGS+=-std=c99 reverse
// ./reverse a b c d e f g h i j k l
#include <stdio.h>
#include <stdlib.h>
// A linked list of strings.
// .next is the next Item.
// .s is the payload string.
@tbl3rd
tbl3rd / sshs
Created August 6, 2013 02:02
When you can't get there from here ...
#! /opt/local/bin/perl -w
use strict;
use File::Basename;
# Return ssh with the standard command line options.
#
sub ssh {
my @result = qw(ssh -A -t);
push @result, qw(-o UserKnownHostsFile=/dev/null);
@tbl3rd
tbl3rd / PanPalPitchDrop.clj
Created December 11, 2013 17:20
Palindromic Pangram: pitch drop solution
(ns panpal.core
(:require [clojure.java.io :as io]
[clojure.math.combinatorics :as comb]
[clojure.pprint :as pp]
[clojure.string :as str])
(:gen-class))
(def ^{:private true :doc "The default word list file."}
words
"http://www.itasoftware.com/careers/work-at-ita/PuzzleFiles/WORD.LST")
@tbl3rd
tbl3rd / PanPalPitchDropDance.clj
Created December 11, 2013 17:24
Palindromic Pangram: pitch drop solution (ELI5 extended dance mix)
;; Everything from ';' to the end of a line is a Clojure comment.
;; A letter is one of "abcdefghijklmnopqrstuvwxyz". Examples: \q \j \z
;; A word is a Clojure (Java) string of letters. Example: "word"
;; A sentence is a sequence of words. Example: ["sequence" "of" "words"]
;; [...] denotes a Clojure vector, #{...} a set, {...} a map.
;; In Java you call a method like this: object.method(arg1, arg2, arg3);
@tbl3rd
tbl3rd / PanPalMortal.clj
Last active December 31, 2015 01:29
Palindromic Pangram: mortal solution
(ns panpal.core
(:import [java.io BufferedReader FileReader])
(:require [clojure.pprint :as p]
[clojure.string :as s]))
;; A 'word' is a string of lower-case letters: "word"
;; A 'sentence' is a vector of words: ["a" "vector" "of" "words"]
;; A 'palindrome' is a 'sentence' whose letters are the same read
;; forward and backward. (def ted ...) defines 'ted' to be '...'.