Skip to content

Instantly share code, notes, and snippets.

<?php
# 安全なウェブアプリケーションの作り方 P156のリファラチェックには若干の脆弱性あり
$http_referer ='http://example.jp/45/45-002ch.php';
# もちろんこれはOK
if ( preg_match('#\Ahttp://example.jp/45/45-002ch.php#', $http_referer) ) {
@nihen
nihen / gist:1148366
Created August 16, 2011 03:07
perl string
use 5.12.0;
use Benchmark qw/cmpthese/;
say alloc_once_lval() eq alloc_each() ? 'ok' : 'ng';
say alloc_once_replace() eq alloc_each() ? 'ok' : 'ng';
sub alloc_once_lval {
my $str = ' ' x 50000;
my $pos = 0;
for ( 0..9999 ) {
@nihen
nihen / Hoge::Model::MyModel.pm
Created May 10, 2011 13:28
PerRequest model instance
package Hoge::Model::MyModel;
use base 'Catalyst::Model::Factory';
#use base 'Catalyst::Model::Factory::PerRequest';
#use base 'Catalyst::Model::Adaptor';
__PACKAGE__->config( class => 'Hoge::MyModel' );
1;
use DBI;
use Data::Dumper;
my $dbh = DBI->connect(
"dbi:mysql:database=sandbox",
'',
'',
{AutoInactiveDestroy => 1, RaiseError => 1}
);
diff --git a/lib/DBIx/Skinny.pm b/lib/DBIx/Skinny.pm
index c974aea..954050b 100644
--- a/lib/DBIx/Skinny.pm
+++ b/lib/DBIx/Skinny.pm
@@ -805,6 +805,12 @@ sub _close_sth {
undef $sth;
}
+sub DESTROY {
+ my $class = shift;
use t::Utils;
use Mock::Basic;
use Test::More;
my $dbh = t::Utils->setup_dbh;
Mock::Basic->set_dbh($dbh);
Mock::Basic->setup_test_db;
Mock::Basic->do(q{
create view mock_basic_view as select * from mock_basic
use utf8;
use Test::More;
use Encode;
use Crypt::TripleDES;
my $plaintext = 'ぴーえすぴー2';
my $passphrase = 'Next Generation Portable';
my $des = new Crypt::TripleDES;
my $cyphertext = $des->encrypt3( Encode::encode('utf-8', $plaintext), $passphrase );
sub add_where_simple {
my $self = shift;
my($term, @bind) = @_;
push @{ $self->{where} }, "($term)";
push @{ $self->{bind} }, @bind;
}
Template----
1-122
2-
3-123
Xslate/TTerse----
Text::Xslate: Can't locate object method "moge" via package "Hash::MultiValue" at test.pl line 25.
(/home/chiba/tmp/tmpl/test.tt:1:&main[3]) at test.pl line 25
eval {...} called at test.pl line 25
----------------------------------------------------------------------------
1-[% req.moge %]
% perl benchmark/x-poor-env.pl
Perl/5.12.1 i686-linux
Text::Xslate/0.1056
Template/2.22
HTML::Template/2.9
Text::MicroTemplate/0.15
Text::MicroTemplate::Extended/0.11
1..4
ok 1 - TTerse: Text::Xslate::Syntax::TTerse
ok 2 - TT: Template-Toolkit