Skip to content

Instantly share code, notes, and snippets.

View bigpresh's full-sized avatar

David Precious bigpresh

View GitHub Profile
[davidp@supernova:~/dev/<projectdir>]$ git-push
Pushing to <repo-url-snipped>
To <repo-url-snipped>
! [rejected] master -> master (non-fast forward)
error: failed to push some refs to '<repo-url-snipped>'
Dancer is a Perl framework for building web applications with minimal effort. It
started as a port of Ruby's Sinatra project, but has grown on its own path. A
Dancer app can run as a standalone Web server or from any webserver using PSGI,
and lets the user write an application with very few lines of code. It's
powerful and flexible enough to knock up a simple website or web service very
quickly, and can scale to much larger projects.
Building a Web application with Dancer is as easy as loading the library and
defining route handlers. Dancer provides an elegant syntax for defining route
handlers, can render views with a variety of template engines, supports static
port: 4002
dsn: "dbi:SQLite:dbname=test.db"
#!/usr/bin/perl
use Dancer;
get '/' => sub {
"query string: " . request->env->{QUERY_STRING};
};
dance;
my @matches;
my @filenames = (...);
for my $filename (@filenames) {
open(my $fh, '<', $filename) or die "Failed to open $filename - $!";
while (my $line = <$fh>) {
if ($line =~ /foo/) {
push @matches, $line;
}
}
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...