Skip to content

Instantly share code, notes, and snippets.

View jnareb's full-sized avatar

Jakub Narębski jnareb

View GitHub Profile
@jnareb
jnareb / gist:772631
Created January 10, 2011 10:46
proposed t/flush.t for HTML::Zoom
use strict;
use warnings FATAL => 'all';
use HTML::Zoom;
use HTML::Zoom::CodeStream;
use Test::More;
# turns iterator into stream
@jnareb
jnareb / gist:772641
Created January 10, 2011 11:02
fixed snippet from HTML::Zoom manpage (proposal)
sub code_stream (&) {
my $code = shift;
return sub {
HTML::Zoom::CodeStream->new({
code => $code,
});
}
}
$zoom->select('.item')->repeat(code_stream {
@jnareb
jnareb / HTML::Zoom::FilterBuilder.pm.patch
Created January 11, 2011 12:33
documenting ->collect in HTML::Zoom::FilterBuilder
diff --git a/lib/HTML/Zoom/FilterBuilder.pm b/lib/HTML/Zoom/FilterBuilder.pm
index 50398b3..809e267 100644
--- a/lib/HTML/Zoom/FilterBuilder.pm
+++ b/lib/HTML/Zoom/FilterBuilder.pm
@@ -381,7 +381,7 @@ alter the content of that stream.
This class defines the following public API
-=head2 set_attribute ( $attr=>value | {name=>$attr,value=>$value} )
+=head2 set_attribute ( $attr=>$value | {name=>$attr,value=>$value} )
@jnareb
jnareb / gist:912389
Created April 10, 2011 14:37
Absolutely positioned block element inside relatively positioned inline (or inline-block) element
<html>
<head>
<title>
Absolutely positioned block element
inside relatively positioned inline (or inline-block) element
</title>
<style>
div {
border: 1px dotted #a0a0a0;
}
@jnareb
jnareb / gist:1994187
Created March 7, 2012 16:26
running CGI app run_request with PSGI interface
sub to_psgi_app {
require CGI::Emulate::PSGI;
our $CGI = 'CGI';
our $first_request = 1;
my $app = CGI::Emulate::PSGI->handler(sub {
CGI::initialize_globals();
our $cgi = CGI->new();
@jnareb
jnareb / fragment 1.perl
Created March 31, 2012 12:19
fragment of gitweb code responsible for static assets in PSGI
if (-d "++GITWEBSTATICDIR++") {
require Plack::App::URLMap;
require Plack::App::File;
my $urlmap = Plack::App::URLMap->new();
$urlmap->map("/" => $app);
foreach my $static_url (@stylesheets, $stylesheet, $logo, $favicon, $javascript) {
next if (!defined $static_url || $static_url eq "");
(my $static_file = $static_url) =~ s!^.*/!!; # basename
@jnareb
jnareb / gist:2953631
Created June 19, 2012 11:29
libmodbus - reading from many slave_ids via RTU
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <modbus.h>
#define SM4_ID 3
#define P120_ID 2
@jnareb
jnareb / modbus-test-multi.c
Created June 19, 2012 12:11
libmodbus - reading from many slave_ids via RTU (expanded)
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <modbus.h>
#include "timing.h"
#define SM4_ID 3
body {
background: lightblue;
}
canvas {
background: white;
margin: 10px;
padding: 10px;
}
body {
background: lightblue;
}
canvas {
background: white;
margin: 10px;
padding: 10px;
}