Skip to content

Instantly share code, notes, and snippets.

use strict;
use warnings;
use Benchmark qw/ cmpthese timethese /;
use Math::BigInt;
my $bigint = Math::BigInt->from_hex('0x0123456789ABCDEF');
my $modulus = Math::BigInt->bone << 32;
cmpthese timethese 100000, +{
'Bit operation' => sub {
@hatyuki
hatyuki / Makefile
Last active December 31, 2015 14:49
CC := gcc
google-2fa: google-2fa.o base32.o hmac.o sha1.o
$(CC) -g -o $@ $+
clean:
$(RM) *.o google-2fa
google-2fa.o: google-2fa.c base32.h hmac.h sha1.h
demo.o: demo.c base32.h hmac.h sha1.h
#!perl
use 5.010000;
use strict;
use warnings;
use feature qw/ say /;
use Config::Pit qw/ pit_get /;
use Term::ANSIColor qw/ colored /;
use Text::Markdown::GFM::Lite;
sub process
.clickable {
cursor: pointer;
}
@hatyuki
hatyuki / MyApp.php
Last active December 17, 2015 11:09
<?php
require_once 'MyConfig.php';
$_SERVER['APP_ENV'] = 'development';
MyConfig::param('dsn'); # => 'sqlite:/tmp/development.db'
$_SERVER['APP_ENV'] = 'production';
MyConfig::param('dsn'); # => 'sqlite:/tmp/production.db'
package My::Cabinet;
use strict;
use warnings;
use Plack::Util ( );
use Scope::Container::Cabinet -base;
register 'Furl' => sub {
Plack::Util::load_class('Furl');
return Furl->new(agent => 'Furl');
};
#!/usr/bin/env perl
use strict;
use warnings;
use Getopt::Long ( );
our $VERSION = '1.3';
main : {
my $opt = parse_options( );
$opt->{header} = build_range(delete $opt->{range}, delete $opt->{bias});
$opt->{agent} = build_user_agent($opt->{agent});
package Method::Delegation;
use strict;
use warnings;
use Exporter 'import';
our @EXPORT = qw/ delegate /;
sub delegate ($%)
{
my ($key, %args) = @_;
my $pkg = caller(0);
diff --git a/lib/Teng.pm b/lib/Teng.pm
index 8a38ee0..30a3756 100644
--- a/lib/Teng.pm
+++ b/lib/Teng.pm
@@ -368,7 +368,7 @@ sub search_by_sql {
sub _guess_table_name {
my ($class, $sql) = @_;
- if ($sql =~ /\sfrom\s+([\w]+)\s*/si) {
+ if ($sql =~ /\sfrom\s+"?([\w]+)"?\s*/si) {
@hatyuki
hatyuki / gist:817956
Created February 9, 2011 05:41
escape_query.t
use t::Utils;
use Mock::Basic;
use Test::More;
my $dbh = t::Utils->setup_dbh;
my $db = Mock::Basic->new({ dbh => $dbh });
$db->setup_test_db;
$db->insert('mock_basic',{
id => 1,