Skip to content

Instantly share code, notes, and snippets.

View mjdominus's full-sized avatar

Mark Jason Dominus (陶敏修) mjdominus

View GitHub Profile
@mjdominus
mjdominus / gist:1486532
Created December 16, 2011 15:44
is the working tree dirty?
# This is the function that git-rebase--interactive uses to determine if the
# working tree is clean, and to bail out if not
require_clean_work_tree () {
# test if working tree is dirty
git rev-parse --verify HEAD > /dev/null &&
git update-index --ignore-submodules --refresh &&
git diff-files --quiet --ignore-submodules &&
git diff-index --cached --quiet HEAD --ignore-submodules -- ||
die "Working tree is dirty"
}
@mjdominus
mjdominus / gist:1477812
Created December 14, 2011 18:22
Victor Dubourg
1679 A news writer in Holland who had presumed to print some very
severe and sarcastic reflections on Madame Maintenon and Louis XIV
suffered the following severe punishment. Some months after this
offence he was induced by a person sent expressly for the purpose to
make a tour into French Flanders. The instant he had quitted the Dutch
territories, he was put under arrest and immediately, by his majesty's
express command, conducted to Mount St Michael, then one of the state
prisons of France. He was shut up in a wooden cage comprising about
twelve feet square and twenty feet in height. Here he lived upwards of
three and twenty years; and here he at length expired. During the long
@mjdominus
mjdominus / gist:1473879
Created December 13, 2011 21:04
%^&!@^%&!@
@@ -127,19 +127,19 @@ test "without_successor" => sub {
[ 'missed', [ 29, 30, 31 ], "2000-01-29" ], # successor delayed until 29th
) {
my ($name, $schedule, $succ_creation_date) = @$test;
- $succ_creation_date ||= "2000-01-12"; # Should be created on Jan 12
+ $succ_creation_date ||= "2000-01-11"; # Should be created on Jan 11
@mjdominus
mjdominus / gist:1418671
Created December 1, 2011 18:11
__git_ps1
__git_ps1 ()
{
local g="$(__gitdir)"
if [ -n "$g" ]; then
local r
local b
if [ -f "$g/rebase-merge/interactive" ]; then
r="|REBASE-i"
b="$(cat "$g/rebase-merge/head-name")"
elif [ -d "$g/rebase-merge" ]; then
@mjdominus
mjdominus / gist:1418341
Created December 1, 2011 17:20
git describe fail
[mjd@orca]:[~/src/moonpig]:[master]$ git branch
active-charge
active-charge-old
c-account
do-with-ledger
findby
install
* master
ob-devel
old-master
@mjdominus
mjdominus / greektime.pl
Created November 23, 2011 23:38
Greek clock program
#!/usr/bin/perl
my $A = 1.5 * 3600; # Latitude adjustment in seconds
my $time = time;
my $days_since_equinox = ($time - 1047950185)/86400;
my $dst = (localtime($time))[9];
my $PI = atan2(0, -1);
my $days_per_year = 365.2422;
@mjdominus
mjdominus / timer.pl
Created November 22, 2011 20:11
Timed alert program
#!/icg/bin/perl
use Getopt::Std;
my %opt;
getopts('t:', \%opt);
my $z = shift or die;
if ($z =~ s/m$//) { $z *= 60 }
elsif ($z =~ s/h$//) { $z *= 3600 }
elsif ($z =~ s/s$//) { $z *= 1 }
elsif ($z =~ /\D/) { die "Usage: timer [ 30[s] | 5m | 1h ] message...\n" }
@mjdominus
mjdominus / gist:1377427
Created November 18, 2011 19:05
StandardPhobiaList.java
package com.plover.Necronomicon;
import java.util.LinkedList;
import com.plover.Necronomicon.Effects.AgoraphobiaEndEffect;
import com.plover.Necronomicon.Effects.AgoraphobiaStartEffect;
import com.plover.Necronomicon.Effects.CompoundEffect;
import com.plover.Necronomicon.Effects.DepowerEffect;
import com.plover.Necronomicon.Effects.MegalomaniaEffect;
import com.plover.Necronomicon.Effects.SchizophreniaEffect;
@mjdominus
mjdominus / gist:1370709
Created November 16, 2011 17:17
Can't eliminate remote branch
$ git push origin :active-charge-rebuild-work
error: unable to push to unqualified destination: active-charge-rebuild-work
The destination refspec neither matches an existing ref on the remote nor
begins with refs/, and we are unable to guess a prefix based on the source ref.
error: failed to push some refs to '[email protected]:git/moonpig.git'
@mjdominus
mjdominus / patch
Created November 13, 2011 20:05
Bug fix
diff --git a/lib/Moonpig/Role/Storage.pm b/lib/Moonpig/Role/Storage.pm
index dd86f9c..4ecfca9 100644
--- a/lib/Moonpig/Role/Storage.pm
+++ b/lib/Moonpig/Role/Storage.pm
@@ -26,7 +26,7 @@ sub do_with_ledger_array {
my ($self, $guids, $code, $opts) = @_;
$Carp::Internal{ (__PACKAGE__) }++;
my %guids = map { $_ => $_ } @$guids;
- $self->do_with_ledgers(\%guids, sub { $code->(values %{$_[0]}) }, $opts);
+ $self->do_with_ledgers(\%guids, sub { $code->(@{$_[0]}{@$guids}) }, $opts);