Skip to content

Instantly share code, notes, and snippets.

View bigpresh's full-sized avatar

David Precious bigpresh

View GitHub Profile
my @sources;
my $in_section;
while (my $line = <$fh>) {
$in_section++ if $line =~ /^# You can add/;
next unless $in_section;
$line =~ /^source (.+)/ and push @sources, $1;
}
23:16 < merlyn> ugh - body must be bytes and should not contain wide characters (UTF-8
strings). at
/usr/local/lib/perl5/site_perl/5.10.1/Plack/Middleware/StackTrace.pm
line 27
23:16 < merlyn> why does plack care if I'm sending utf8?
23:17 < merlyn> looks related to this issue -
http://github.com/miyagawa/Plack/issues/issue/115
23:20 < merlyn> might be a bug in Dancer then
23:20 < merlyn> it's passing the utf8 string to plack, instead of byte-ing it
23:21 < merlyn> this statement is triggering - if (ref $res->[2] eq 'ARRAY' && grep
[davidp@supernova:~]$ cat test.yml
plack_middlewares:
Static:
- path
- qr{^/(images|js|css)/}
- root
- './public/'
#!/usr/bin/perl
use common::sense;
use Data::Dump;
use CGI;
my $cgi = CGI->new;
print $cgi->header;
my @selected = $cgi->param('myfield');
my $form = HTML::Form->parse($mech->response);
my $dropdown = $form->find_input('DropdownName');
my @labels = $dropdown->value_names;
my @values = $dropdown->possible_values;
# The above works perfectly for fetching a list of values and labels,
# but for each entry in the drop-down, I need to know which <optgroup>
# it's in. HTML::Form doesn't appear to provide that info...
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;