Skip to content

Instantly share code, notes, and snippets.

@mdekstrand
mdekstrand / gist:811901
Created February 4, 2011 22:28
Ubuntu LablGTK META file (should be like Debian)
version="2.14.0"
requires(mt) = "threads"
requires(mt,mt_vm) = "threads.vm"
requires(mt,mt_posix) = "threads.posix"
directory="+lablgtk2"
archive(byte) = "lablgtk.cma"
archive(native) = "lablgtk.cmxa"
archive(byte,mt) += "gtkThread.cmo"
archive(native,mt) += "gtkThread.cmx"
@mdekstrand
mdekstrand / nextrip.pl
Created February 9, 2011 19:23
Query tool for Metro Transit NexTrip
#!/usr/bin/env perl
=head1 NAME
nextrip.pl - NexTrip query tool
=head1 SYNOPSIS
B<nextrip.pl> [I<OPTIONS>]
@mdekstrand
mdekstrand / rpm-sizes.pl
Created June 22, 2011 17:53
Perl script to print RPM packages by size
#!/usr/bin/env perl
use warnings;
use strict;
# get these with `yum install perl-RPM2 perl-Number-Bytes-Human'
use RPM2;
use Number::Bytes::Human qw{format_bytes};
my $db = RPM2->open_rpm_db();
@mdekstrand
mdekstrand / gist:1448381
Created December 8, 2011 20:21
Code that fails to match
def needState(need: InfoNeed) = {
object needs extends Obj('needs) {
object thisNeed extends Obj(Symbol(need.name)) {
val state = Child[String, Property[String]](Some(this), UserProps.Need.state)
}
}
js match {
case needs.thisNeed.state(st) => Some(st)
case _ => None
}
@mdekstrand
mdekstrand / Launch_Terminal.bsh
Created January 23, 2012 22:29
Launch Terminal JEdit macro
// Launch a terminal in the buffer's current directory.
terminalCommand = "gnome-terminal";
dir = buffer.getDirectory();
cmd = new String[]{terminalCommand, "--working-directory=" + dir};
Runtime.getRuntime().exec(cmd);
@mdekstrand
mdekstrand / pdf-thumbnail.sh
Created February 1, 2012 17:56
Generate thumbnails of PDF files
#!/bin/sh
for file in "$@"; do
outfile="${file%%.pdf}.jpg"
echo "Thumbnailing $file to $outfile"
convert -resize 300 "$file[0]" "$outfile"
done
@mdekstrand
mdekstrand / texlive-missing-docs.pl
Created November 19, 2012 17:48
Script to scan for uninstalled docs
#!/usr/bin/env perl
use warnings;
use strict;
use RPM2;
use Getopt::Std;
my %opts;
getopts("c", \%opts) or exit 1;
@mdekstrand
mdekstrand / gist:4519727
Created January 12, 2013 18:19
Code for path-dependent type post.
trait InfoNeed {
type DataType
/** Get the web request to fetch data */
def request: WebRequest[DataType]
/** Get the neighbors from some fetched data (to determine new nodes to visit) */
def neighbors(data: DataType): Traversable[Node]
/** Save the data to the data store. */
def save(store: DataStore, data: DataType)
}
@mdekstrand
mdekstrand / path-types-infoneed.scala
Last active December 11, 2015 00:58
Info Need for path-dependent types blog post.
trait InfoNeed {
type DataType
/** Get the web request to fetch data */
def request: WebRequest[DataType]
/** Get the neighbors from some fetched data */
def neighbors(data: DataType): Traversable[Node]
/** Save the data to the data store. */
def save(store: DataStore, data: DataType)
}
@mdekstrand
mdekstrand / path-types-process.scala
Created January 12, 2013 18:23
Processing code for path-dependent types post.
def fetch[T](req: WebRequest[T]): Result[T]
def process(need: Need) {
val req = need.request
val res = fetch(req)
// now we save the data
res match {
case Good(data) => need.save(store, data)
/* error cases */
}