Skip to content

Instantly share code, notes, and snippets.

@tomyhero
tomyhero / fbbot.go
Created April 14, 2016 09:25
facebook messenger platform sample
package main
import (
"bytes"
"encoding/json"
"fmt"
log "github.com/Sirupsen/logrus"
"io/ioutil"
"net/http"
)
@tomyhero
tomyhero / test.html
Created February 29, 2016 02:56
check image load timing
<html>
<head>
<title>test</title>
</head>
<body>
<img src="http://blog-imgs-19.fc2.com/r/i/s/risuco/20090509_003.jpg" onload="console.log('loaded 1')">
<img src="https://upload.wikimedia.org/wikipedia/ja/archive/4/4b/20100914121956!Wiki-ezorisu3.jpg" onload="console.log('loaded 2')">
<img src="http://inuneko-sp.gsj.bz/images/special/risubon/02_004_MG_3434.jpg" onload="console.log('loaded 3')">
<img src="http://www.pref-nagano-hosp.jp/kiso/wp-content/uploads/d7d3388f23579594a4d7ef7aaf0a69e8.jpg" onload="console.log('loaded 4')">
@tomyhero
tomyhero / gist:7cd7e2f1885fac993942
Last active August 29, 2015 14:23
goji db middleware
package middleware
import (
"database/sql"
"fmt"
_ "github.com/go-sql-driver/mysql"
"github.com/zenazn/goji/web"
"net/http"
)
@tomyhero
tomyhero / gist:ebbdeea14046905e729c
Created June 23, 2015 05:55
how to check 404 before execute ServeHTTP with goji
package main
import (
"fmt"
"github.com/zenazn/goji"
"github.com/zenazn/goji/web"
"net/http"
)
func main() {
@tomyhero
tomyhero / gist:850298
Created March 2, 2011 01:36
addding elsif
sub _decode_args {
my($h, $ie) = @_;
for my $key( keys %{$h} ) {
if ( ref $h->{$key} eq 'ARRAY' ) {
my @values = map { Encode::decode($ie, $_) } @{$h->{$key}};
$h->{$key} = \@values;
}
elsif(ref $h->{$key} ){
# do nithing;
}
@tomyhero
tomyhero / gist:833544
Created February 18, 2011 11:03
args encode patch
diff -x .git -urN Pickles-origin/lib/Pickles/Plugin/Encode.pm Pickles/lib/Pickles/Plugin/Encode.pm
--- Pickles-origin/lib/Pickles/Plugin/Encode.pm 2011-02-18 18:52:18.000000000 +0900
+++ Pickles/lib/Pickles/Plugin/Encode.pm 2011-02-18 19:58:34.000000000 +0900
@@ -19,6 +19,17 @@
my $ie = $config->{input_encoding} || 'utf-8';
_decode( $c->req->query_parameters, $ie );
_decode( $c->req->body_parameters, $ie );
+ for my $key (keys %{$c->args}){
+ if( ref $c->args->{$key} eq 'ARRAY'){
+ my $array = $c->args->{$key};
use warnings;
use strict;
use Test::More;
use Data::Section::Simple;
use Text::Xslate;
my $reader = Data::Section::Simple->new(__PACKAGE__);
my $templates = $reader->get_data_section;
my $tx = Text::Xslate->new(
</div><!-- /mainContent -->
[% WRAPPER 'footer.inc' INTO footer_content %]
<script>
function myJsRun(){}
myJsRun();
</script>
[% END %]
#macro.inc
[%- MACRO hoge() BLOCK %]
hoge
[% END %]
#index.tx
Hello Macro [% hoge() %]
#
my $xslate = Text::Xslate->new(