Skip to content

Instantly share code, notes, and snippets.

View mjdominus's full-sized avatar

Mark Jason Dominus (陶敏修) mjdominus

View GitHub Profile
#!/bin/bash
set -e
# Send a private message to someone on slack
# from the command line.
# Print a usage message and exit.
usage(){
local name=$(basename "$0")
@mjdominus
mjdominus / gist:8699632
Last active August 29, 2015 13:55
Paragraph 56
56. Ford and Aboodowieh arrange for persons employed by MWDC, whose identity is known to Ford and Aboodowieh but not known to the
plaintiff, to facilitate the exposure of the plaintiff to Petros, and to facilitate the attack on the plaintiff on March 23, 2012,
and more particularly, to arrange for the plaintiff's detention in range 1B, and to ensure that there was no supervision or
surveillance of the area where the plaintiff was assaulted.
(A followup tweet adds “MWDC is Metro West Detention Centre”.)
[ 0.000000] Initializing cgroup subsys cpuset
[ 0.000000] Initializing cgroup subsys cpu
[ 0.000000] Initializing cgroup subsys cpuacct
[ 0.000000] Linux version 3.13.0-32-generic (buildd@kissel) (gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1) ) #57-Ubuntu SMP Tue Jul 15 03:51:08 UTC 2014 (Ubuntu 3.13.0-32.57-generic 3.13.11.4)
[ 0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-3.13.0-32-generic.efi.signed root=UUID=955da1a0-707a-4705-be99-02b2551d91c8 ro quiet splash vt.handoff=7
[ 0.000000] KERNEL supported cpus:
[ 0.000000] Intel GenuineIntel
[ 0.000000] AMD AuthenticAMD
[ 0.000000] Centaur CentaurHauls
[ 0.000000] e820: BIOS-provided physical RAM map:
@mjdominus
mjdominus / 1729.txt
Created May 9, 2015 23:47
Sum of cubes in exactly two ways
1729: 1 12; 9 10
4104: 2 16; 9 15
13832: 2 24; 18 20
20683: 10 27; 19 24
32832: 4 32; 18 30
39312: 2 34; 15 33
40033: 9 34; 16 33
46683: 3 36; 27 30
64232: 17 39; 26 36
65728: 12 40; 31 33
import qualified Data.Map as Map
newtype NestedMap k = NestedMap (Map.Map k (NestedMap k))
instance (Show k) => Show (NestedMap k)
where
show (NestedMap m) =
if (Map.null m)
then "{}"
else listToString
(\e -> "{ " ++ e ++ ", ")
Mar 15 12:23:13 <\yrlnry> schacon: My coworker and I were talking about ticgit today. I was (mistakenly) looking at your github version and I was pleased at how small it was. Then he said he thought it was dead, and then we discovered that other people have continued to develop it.
Mar 15 12:23:32 <\yrlnry> schacon: How would you characterize the current status of ticgit? Do you still like it?
Mar 15 12:25:08 <schacon> i started pulling in some of the newer branches, but the tests they include are somewhat brittle
Mar 15 12:25:14 <schacon> i've been working on fixing them up
Mar 15 12:26:07 <\yrlnry> Do you consider it alive? Are you still using it yourself?
Mar 15 12:26:15 <schacon> jeffWelling fork is probably the best
Mar 15 12:26:45 <schacon> i don't currently use it much, but a lot of people do and i've been starting to work on it again
Mar 15 12:27:06 <\yrlnry> If you were starting today, would you prefer the jeffWelling fork of ticgit, or would y
  • Overview

I have a bunch of classes that represent email filters, and are backed by a legacy database. The interface to the legacy database is through DBIx::Class. A filter is essentially two things: a condition and an action. An email message is passed to the condition object, which reports whether the condition is satisfied; if so, the message is passed to the action object, which performs some action, possibly modifying the message. The legacy database principally involves two tables: mh_conds, representing conditions, and mh_actions, representing actions.

I have code that examines the tables using DBIx::Class and constructs Filter objects, and also code for the reverse direction: you can manufacture a Filter object, including its subsidiary Condition and Action objects, and then store it into the database.

The storage code is peculiar. The way it works is that Condition and Action objects each have an as_rows method, which returns a list of DBIx::Class::Row objects. To i

Little-used features list:
-P option
-u option
dump
...
.. in scalar context
formats:
in general
$: to control line breaking in a ^.... field
@mjdominus
mjdominus / gist:659737
Created November 2, 2010 15:02
Big tree query that the RDB handled just fine
String query = "select distinct a.tree.rootNode "
+
// Find the trees with three nodes a, b, and c, such that...
"from PhyloTreeNode as a, PhyloTreeNode as b, PhyloTreeNode as c, "
+
// There's a node "ab" (which will be an ancestor of both a and b)
"PhyloTreeNode as ab "
+
// All four nodes are in the same tree
"where a.tree = b.tree " + "and a.tree = c.tree " + "and a.tree = ab.tree "
@mjdominus
mjdominus / fib5.pl
Created March 28, 2011 17:42
fibonacci identity
sub choose {
my ($n, $k) = @_;
return 1 if $k == 0;
return 0 if $n == 0;
return choose($n-1, $k-1) * $n / $k;
}
sub pow5 {
my ($k) = @_;
my $p = 1;