Skip to content

Instantly share code, notes, and snippets.

View tsucchi's full-sized avatar

Takuya Tsuchida tsucchi

View GitHub Profile
@tsucchi
tsucchi / test.pl
Created February 13, 2014 01:32
scalar contextだと思ってた...
#!/usr/bin/env perl
use strict;
use warnings;
my $aa = {
aa => hoge(),
bb => 'xxx',
};
sub hoge {
@tsucchi
tsucchi / .replyrc
Created March 14, 2014 03:36
replyでOtogiri使う
script_line1 = use strict
script_line2 = use warnings
script_line3 = use 5.018002
script_line4 = use Otogiri;
script_line5 = use Otogiri::Plugin;
script_line6 = my $connect_info = ["dbi:...",'username','password', { AutoCommit => 1, RaiseError => 1,PrintError => 0, pg_enable_utf8 => 1,}];
script_line7 = Otogiri->load_plugin('DeleteCascade');
script_line8 = my $db = Otogiri->new( connect_info => $connect_info );
[Interrupt]
@tsucchi
tsucchi / test.pl
Created May 15, 2014 05:35
なんでや
#!/usr/bin/perl
use strict;
use warnings;
sub hoge {
die "hoge";
}
eval {
hoge({ return'hogehoge' });
#!/usr/bin/perl
use strict;
use warnings;
sub hoge {
die "hoge";
}
hoge({ return'hogehoge' });
# tsucchi@dev[1017]$ perl test.pl
@tsucchi
tsucchi / otogiri.pl
Last active August 29, 2015 14:01
Reply-Otogiri の環境で require してるやつ。カラム名とかで grep して CREATE TABLE文 or テーブル名を返す物体
uuse strict;
use warnings;
my @table_ddls;
my %table_ddl_exists;
sub sql {
my ($sql) = @_;
return Search_by_sql($sql);
}
#!/bin/bash
# plenvを自動的に入れてくれるやつです
set -e
if [[ $(which plenv 2> /dev/null) ]]; then
echo 'plenv already installed.'
elif [[ ! $(which git) ]]; then
echo 'git is not installed!!!!!!!'
exit 1;
@tsucchi
tsucchi / .bashrc
Last active August 29, 2015 14:02
Reply-Otogiri 環境で、こんな感じのaliasにしたら、最高っぽい仕上がりになった。(僕はperlbrew 環境と system perl を併用してて、system perl 側はいじれないため)
MY_PERLBREW_PERL="perl-5.20@default"
alias reply-service1="perlbrew exec -q --with $MY_PERLBREW_PERL env PERL_REPLY_PLUGIN_ORM=service1 reply --cfg $HOME/etc/.replyrc_otogiri"
alias reply-service2="perlbrew exec -q --with $MY_PERLBREW_PERL env PERL_REPLY_PLUGIN_ORM=service2 reply --cfg $HOME/etc/.replyrc_otogiri"
@tsucchi
tsucchi / test.pl
Last active August 29, 2015 14:04
use constant でうっかりミス
#!/usr/bin/env perl
use strict;
use warnings;
use Data::Dumper;
use constant hoge => 123;
my $fuga = {
hoge => 456,
};
@tsucchi
tsucchi / score.pl
Created September 23, 2014 14:54
ラストの演習問題の回答例
use strict;
use warnings;
use Data::Dumper;
# https://github.com/perl-entrance-org/workshop-2014-03/blob/master/slide.md
# ラストの練習問題の回答例
my $papix = {
name => 'papix',
affiliation => 'namba.pm',
@tsucchi
tsucchi / table_dumper.pl
Created November 17, 2014 04:23
テーブルの中身を dump する君1号
#!perl
use strict;
use warnings;
use Otogiri;
use Otogiri::Plugin;
use File::Path qw(remove_tree make_path);
use File::Spec;
use File::Slurp qw(write_file);
my $config = do "/home/tsucchi/.otogiri_connect_info.pl";