Skip to content

Instantly share code, notes, and snippets.

View memememomo's full-sized avatar
🏠
Working from home

Uchiko memememomo

🏠
Working from home
  • Aichi, Japan
View GitHub Profile
@memememomo
memememomo / Util.pm
Created May 27, 2014 13:00
Test::Mojoでビルドされたアプリにブラウザでアクセスする ref: http://qiita.com/uchiko/items/8bef175a43889b29b7da
package t::Util;
use strict;
use warnings;
use utf8;
use Net::EmptyPort qw(empty_port);
use Mojo::Server::Daemon;
sub run_server {
my ($app) = @_;
my $port = empty_port();
package MyApp::DB;
use parent 'Teng';
use DateTime;
# プラグイン有効
__PACKAGE__->load_plugin('Pager');
__PACKAGE__->load_plugin('Count');
# hookの設定
use Class::Method::Modifiers;
<html>
<head><title>テスト</title></head>
<body>
<div>
[% content.raw %]
</div>
</body>
</html>
@memememomo
memememomo / Example.pm
Created May 20, 2014 23:40
Mojoliciousのプラグインを作る ref: http://qiita.com/uchiko/items/58f33ae7724b7fd720fb
package Mojolicious::Plugin::Example;
use Mojo::Base 'Mojolicious::Plugin';
sub register {
my ($self, $app, $conf) = @_;
}
1;
@memememomo
memememomo / basic.t
Created May 20, 2014 11:45
Test::TCP + Net::Server::Mail::SMTPで、一時的に受信メールサーバを立ててテストする ref: http://qiita.com/uchiko/items/79718bcf192a043f7b35
use strict;
use warnings;
use Test::More;
use Test::TCP;
use Net::Server::Mail::SMTP;
use Net::SMTP;
use Email::MIME;
use Email::MIME::MobileJP::Parser;
@memememomo
memememomo / file0.txt
Created May 19, 2014 13:51
Jenkins + plenv で、ブランチ毎のテスト実行環境を構築する ref: http://qiita.com/uchiko/items/88d6c54d5ad4ca1318a6
$ sudo yum install java-1.6.0-openjdk
$ sudo yum install java-1.6.0-openjdk-devel
$ cpanm Mojolicious::Plugin::FillInFormLite
@memememomo
memememomo / app.psgi
Created May 18, 2014 06:11
開発時にplackupで起動した時に出力されるログを制御する ref: http://qiita.com/uchiko/items/a72eb946705187c46f98
use Plack::Builder;
builder {
enable 'LogFilter', filter => sub {
my ($env, $output) = @_;
# ignore static file log
if ($output =~ /\/static\/(js|css|images)/) {
return 0;
}
@memememomo
memememomo / echo_client.php
Created May 17, 2014 09:33
テスト用にPHPで簡単なTCPサーバを書いた ref: http://qiita.com/uchiko/items/14b42621034ae63a69c0
<?php
if (($sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) === false) {
die("socket_create() failed: ".socket_strerror(socket_last_error()));
}
if (socket_connect($sock, '127.0.0.1', 5000) === false) {
die("socket_connect() failed: ".socket_strerror(socket_last_error()));
}
@memememomo
memememomo / test1.php
Created May 17, 2014 04:02
PHPで動的にメソッドを追加する方法 ref: http://qiita.com/uchiko/items/1c97a1ae0cd98b1b229d
class Object
{
static private $_methods = array();
static public function addMethod($name, Closure $cb)
{
self::$_methods[$name] = $cb;
}
public function __call($name, array $args)