Skip to content

Instantly share code, notes, and snippets.

View bigpresh's full-sized avatar

David Precious bigpresh

View GitHub Profile
315 # And a route to list records already in the table:
316 get "$args{prefix}" => sub {
317 # TODO: handle pagination
318 my $sth = $dbh->prepare("select * from $table_name");
319 $sth->execute;
320 my $table = HTML::Table::FromDatabase->new(
321 -sth => $sth,
322 -border => 1,
323 );
324 return $table->getTable;
my $matches;
while ($html =~ m{
<optgroup \s+ label="
(?<label> .+?)
">
(?<options_html> .+?)
</optgroup>
}gxsi)
{
say "Group: [$+{label}]";
@bigpresh
bigpresh / gist:644719
Created October 25, 2010 10:11
Simple CRUD!
simple_crud(
prefix => 'test',
db_table => 'test',
record_title => 'Test Thing',
);
@bigpresh
bigpresh / beforefiltertest.pl
Created October 27, 2010 10:12
Quick test case for before filters
#!/usr/bin/perl
use strict;
use Dancer;
set logger => 'console';
set log => 'debug';
before sub {
debug("In before filter");
#!/usr/bin/perl
use Dancer;
get '/' => sub {
set_cookie TestCookie => 'Testing';
"Some content.";
};
dance;
DB<1> $foo = 'Foo';
DB<2> x ref $foo;
0 ''
DB<3> $foo->{bar} = 'Bar';
DB<4> x ref $foo;
0 ''
DB<5> x $foo;
0 'Foo'
@bigpresh
bigpresh / gist:786080
Created January 19, 2011 12:09
example init.d script for starting Dancer apps
[davidp@shakermaker:~]$ cat /etc/init.d/site-ijedomestics
#! /bin/sh
# Simple script for starting Dancer applications.
SITENAME=ijedomestics
PORT=5000
DIR=/websites/ijedomestics
SCRIPT=ijedomestics.pl
USER=davidp
#!/usr/bin/perl
use Dancer;
set template => 'template_toolkit';
get '/' => sub {
return template 'index', { foo => [ qw(one two three four) ] };
};
dance;
@bigpresh
bigpresh / output
Created January 31, 2011 22:23
PHP CSV parsing example for Jim
[davidp@supernova:~/tmp/php-csv-test]$ php php-csv-test.php
array (
0 =>
array (
'name' => 'David Precious',
'age' => '29',
'comment' => 'rocks',
),
)
@bigpresh
bigpresh / gist:820759
Created February 10, 2011 15:59
enabling pg_enable_utf8 in Dancer config.yml
plugins:
Database:
driver: pg
...
dbi_params:
pg_enable_utf8: 1