Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/perl -w
use strict;
use Getopt::Long;
# PUT YOUR MOUNTPOINTS HERE
# No trailing slashes
use constant MOUNT_POINTS => qw(
/mnt
);
@sortega
sortega / .promptrc
Created May 21, 2010 14:27
Usage: add . ~/.promptrc to your .bashrc
function git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function git_prompt {
__git_ps1 '%s' | sed -e "s/\(.*\)/\1$(git_dirty):/"
}
function proml {
#!/usr/bin/perl -w
use Getopt::Long;
use strict;
sub usage {
print <<EOB ;
usage: $0 --tabwidth 2 <files>
Compacts the indentation to the desired fixed step.
@sortega
sortega / fix_encoding.pl
Created January 12, 2011 11:14
Fix garbled encoding (latin1 reencoded as utf8)
#!/usr/bin/perl
use strict;
use Encode;
binmode( STDIN, ':utf8' );
binmode( STDOUT, ':latin1' );
while (<>) {
print Encode::decode('utf8', $_);
}
@sortega
sortega / slidenup.sh
Created February 8, 2011 13:30
Prepare slide pdfs to print 6 slides per page (2x3)
alias slidenup='pdfnup --nup "2x3" --no-landscape --frame true --delta ".25cm .5cm" --offset ".25cm .25cm" --scale 0.9'
@sortega
sortega / form.php
Created March 9, 2011 18:39
Para depurar formularios web
<?php echo("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es" lang="es-ES">
<head>
<title>Depurador de formularios</title>
</head>
<body>
<h1>Depurador de formularios</h1>
(use 'clojure.test)
(defn transpose [m]
(apply map vector m))
(defn window1d
"Computes all triples of consecutives elements"
[padding acoll]
(partition 3 1 [padding] (cons padding acoll)))
@sortega
sortega / epochfilter.pl
Created February 24, 2012 07:50
Annotate text input to expand epoch timestamps to normal time.
#!/usr/bin/env perl
use strict;
sub tag {
my $epoch = shift;
return "$epoch=<".(scalar (localtime $epoch)).">";
}
sub tag_line {
my $line = shift;
@sortega
sortega / force_feed_macports
Created April 3, 2012 12:29
Force feed macports
Just copy the archive to /opt/local/var/macports/distfiles/{port_name}/
@sortega
sortega / trenes.clj
Created May 9, 2012 18:19
Some cache simulation code to play around
(ns trenes
(:require [clojure.string :as str]))
(defn empty-cache [c]
{:capacity c
:values {}
:time 0
:misses 0
})