Skip to content

Instantly share code, notes, and snippets.

View churib's full-sized avatar

Timo Grodzinski churib

View GitHub Profile
@churib
churib / gist:1984690
Created March 6, 2012 07:34
race condittion fnDeleteRow
$(document).ready( function () {
var table;
table = $('#urls_table').dataTable( {
"bProcessing": true,
"sAjaxSource": "/test.pl/url/all/",
"sDom": 'T<"clear">lfrtip',
"sPaginationType": "full_numbers",
"oTableTools": {
"sRowSelect": "multi",
"aButtons": [
AnyEvent
App::Cache
Captcha::reCAPTCHA
Capture::Tiny
Carp::Always
CGI::Upload
Class::Accessor
Clone
CPAN::HTTP::Client
CPAN::HTTP::Credentials
@churib
churib / gist:3278264
Created August 6, 2012 20:45
rename dirs
#!/usr/bin/env perl
use warnings;
use strict;
run() if !caller;
sub run {
chdir '/home/timo/Pictures/Fiene/';
my @files = <*>;
@churib
churib / gist:4080838
Created November 15, 2012 19:56
recursive lambda
(defmacro lambda* (fname args &rest body)
`(lambda ,args
(labels ((,fname ,args ,@body))
(fname ,@args))))
(defmacro alambda (args &body body)
`(labels ((self ,args ,@body))
#'self))
my $s = "lorem ipsum...";
my @a = (0,3);
print( substr( $s, @a ) ); # --> rem ipsum... --> scalar @a :(
{1 => undef}; # works, but
sub foo { return };
{1 => foo() } # Odd number of elements in anonymous hash
sub bar { return undef }
{1 => bar() } # works!
use strict;
use warnings;
package Minimum;
use Validation::Class;
directive 'my_directive' => sub { die };
mixin 'my_mixin' => {
(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))))))
@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';
@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