Skip to content

Instantly share code, notes, and snippets.

View churib's full-sized avatar

Timo Grodzinski churib

View GitHub Profile
#/usr/bin/env perl
use warnings;
use strict;
use List::Util 'all';
sub foo {
print "before: @_\n";
all { print "in all block: @_\n" } qw( bar );
print "after: @_\n";
#!/usr/bin/perl
# Author: Todd Larason <[email protected]>
# $XFree86: xc/programs/xterm/vttests/256colors2.pl,v 1.2 2002/03/26 01:46:43 dickey Exp $
# use the resources for colors 0-15 - usually more-or-less a
# reproduction of the standard ANSI colors, but possibly more
# pleasing shades
# should look like https://forums.freebsd.org/threads/urxvt-tmux-256-colors.38399/
#!/usr/bin/env perl
use strict;
use warnings;
package Foo;
sub new {
my( $class, $hash ) = @_;
return bless $hash, $class;
#!/bin/sh
perl -pe 's/(\[.*?\] ){3}(.*?), referer.*/$2/'
#!/usr/bin/env perl
use strict;
use warnings;
for ( 1 .. 2 ) {
my $var = 0 if 0;
$var++; # no warning/error?
print "$var\n";
}
@churib
churib / gist:7655616
Last active December 29, 2015 10:18
inverleaved joins
SELECT A.*, B.*, C.*
FROM A
LEFT JOIN B
ON B.aid = A.id
LEFT JOIN C
ON C.bid = B.id
LEFT JOIN D
ON D.cid = C.id AND D.aid = A.id
@churib
churib / gist:6728594
Created September 27, 2013 13:29
dbi profiling
$dbh = DBI->connect( $DSN, $DB_USER, $DB_PASS ) || die "cannot connect to database";
$dbh->{HandleError} = sub { confess( shift ) };
$dbh->{Profile} = 31;
$DBI::Profile::ON_DESTROY_DUMP = $DBI::Profile::ON_DESTROY_DUMP = sub {
my ( $result ) = @_;
my $time = $1 if ( $result =~ m/DBI::Profile: ([\d\.]+?)s/ );
return if $time and $time < 0.3;
open my $fh, '>>', '/home/writers/sitedata/logs/db_profile.log';
(defun remove* (symbol tree)
"Removes SYMB0L from TREE."
(cond ((null tree) tree)
((atom (car tree))
(if (equalp symbol (car tree))
(remove* symbol (cdr tree))
(cons (car tree) (remove* symbol (cdr tree)))))
(t (cons (remove* symbol (car tree))
(remove* symbol (cdr tree))))))
use strict;
use warnings;
package Minimum;
use Validation::Class;
directive 'my_directive' => sub { die };
mixin 'my_mixin' => {
{1 => undef}; # works, but
sub foo { return };
{1 => foo() } # Odd number of elements in anonymous hash
sub bar { return undef }
{1 => bar() } # works!