Skip to content

Instantly share code, notes, and snippets.

View bigpresh's full-sized avatar

David Precious bigpresh

View GitHub Profile
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
@bigpresh
bigpresh / app output
Created February 15, 2011 22:48
Dancer cookies test case
[davidp@supernova:~/tmp/dancer-multicookies]$ perl app.pl
>> Dancer 1.3010 server 25291 listening on http://0.0.0.0:4002
== Entering the development dance floor ...
[25291] debug @0.003111> [hit #1]Cookies: {
"dancer.session" => bless({ name => "dancer.session", path => "/", value => ["123, wtf"] }, "Dancer::Cookie"),
} in /usr/local/share/perl/5.10.0/Dancer/Plugin/DebugDump.pm l. 19
@bigpresh
bigpresh / gist:828519
Created February 15, 2011 23:31
Supporting comma-separated cookies...
diff --git a/lib/Dancer/Cookies.pm b/lib/Dancer/Cookies.pm
index 15735fe..dd4992d 100644
--- a/lib/Dancer/Cookies.pm
+++ b/lib/Dancer/Cookies.pm
@@ -23,7 +23,7 @@ sub parse_cookie_from_env {
return {} unless defined $env_str;
my $cookies = {};
- foreach my $cookie ( split( '; ', $env_str ) ) {
+ foreach my $cookie ( split( /[,;]\s/, $env_str ) ) {
@bigpresh
bigpresh / i18ntest.pm
Created February 18, 2011 22:36
D::P::I18n test case
package i18ntest::I18N::en;
use base 'i18ntest::I18N';
our %Lexicon = ( hello => 'Hello' );
package i18ntest::I18N::fr;
use base 'i18ntest::I18N';
our %Lexicon = ( hello => 'Bonjour' );
package i18ntest;
@bigpresh
bigpresh / GitHubPullRequests.pm
Created April 26, 2011 11:59
GitHubPullRequests - not fetching default project from bot store
# A quick Bot::BasicBot::Pluggable module to fetch a count of open pull requests
# for a GitHub project.
#
# David Precious <davidp@preshweb.co.uk>
package Bot::BasicBot::Pluggable::Module::GitHubPullRequests;
use strict;
use base 'Bot::BasicBot::Pluggable::Module';
use LWP::Simple;
use JSON;
@bigpresh
bigpresh / runtimeloggerconfig.pl
Created May 3, 2011 21:33
Dead simple test case for logging configured at runtime
[davidp@supernova:~/tmp/runtimeloggerconfig]$ perl runtimeloggerconfig.pl
>> Dancer 1.3030 server 19286 listening on http://0.0.0.0:3000
== Entering the development dance floor ...
^C
# a request was made, answered with the default error 500 page
[davidp@supernova:~/tmp/runtimeloggerconfig]$ cat logs/development.log
[davidp@supernova:~/tmp/runtimeloggerconfig]$
# Nothing logged.