Skip to content

Instantly share code, notes, and snippets.

View tokuhirom's full-sized avatar
💖
Focusing

Tokuhiro Matsuno tokuhirom

💖
Focusing
View GitHub Profile
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use 5.010000;
use autodie;
package URI::Lite {
use Class::Accessor::Lite 0.05 (
rw => [qw(scheme user password host port path query)],
@tokuhirom
tokuhirom / gist:9928481
Created April 2, 2014 05:34
MemProfile.pm
package Devel::MemProfile;
use strict;
use warnings;
use utf8;
use 5.010_001;
use Devel::Symdump;
use B::Size2::Terse;
sub new {
my $class = shift;
sub Member::get_ad($self, $id) {
my $ad = $self->db->find->ad($id) or throw NotFoundException->throw;
if ($ad->member_id eq $self->id) {
return $ad;
} else {
return SecurityException->throw(); # ここはもう
}
}
sub Controller::dispatch_update_ad($c) {
@tokuhirom
tokuhirom / epoch
Created May 16, 2014 09:52
The epoch command
#!/usr/bin/env perl
use strict;
use warnings;
use Time::Piece;
use Pod::Usage;
&main; exit;
sub show($) {
my $time = shift;
@tokuhirom
tokuhirom / .zshrc
Last active August 29, 2015 14:03
repos
e() { cd $(repos-list --null | peco --null) }
@tokuhirom
tokuhirom / moose.t
Created July 3, 2014 09:47
no Moose
use strict;
use warnings;
use Test::More;
ok(!eval { require Moose; 1; }, 'no Moose');
ok(!eval { require DateTime; 1; }, 'no DateTime');
ok(!eval { require Devel::StackTrace::WithLexicals; 1; }, 'no Devel::StackTrace::WithLexicals');
done_testing;
@tokuhirom
tokuhirom / fillinform.js
Created January 27, 2015 13:38
fillinform.js
(function () {
// public domain. buggy.
"use strict"
var elems = document.getElementsByClassName("fillinform");
var query = parseQuery();
for (var i = 0, l = elems.length; i < l; i++) {
var it = elems[i];
Object.keys(query).forEach(function (key) {
var input = it.querySelector("input[name=" + key + "]");
if (input.type == "checkbox") {
@tokuhirom
tokuhirom / rakudo-build
Created February 2, 2015 07:47
rakudo-build
#!/bin/sh
set -x
set -e
WORK=$HOME/.rakudo-build/
PREFIX=$HOME/perl6
mkdir -p $PREFIX
mkdir -p $WORK
rm -rf $WORK/rakudo
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.stream.Collectors;
public class Hoge {
public static void main(String[] args) throws IOException {
Files.readAllLines(Paths.get(args[0])).stream()
.flatMap(line -> Arrays.stream(line.split("\\W+")))
@tokuhirom
tokuhirom / avans2.md
Last active August 29, 2015 14:27
avans2 の新設計

Controller

コントローラクラスは、得になにも継承する必要はない。が、各プロジェクトで親になるクラスを作っておいたほうが便利。

基本的な見た目は 1 と変わらない。

public class EntryController {
  @GET("/entry/detail")
  public WebResponse index(@Param("id") long id) {