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 / sample.php
Created June 11, 2014 10:38
同じバリデーションルールでも、フィールドごとにエラーメッセージを変更する方法 ref: http://qiita.com/uchiko/items/6782b93d620636a806f4
$val = Validation::forge();
// クロージャを設定
// Validation の _validation_required メソッドを利用する
$required_rule = function ($v) use ($val) { return $val->_validation_required($v); };
// テキストフォーム
$val->add('name', 'お名前')
->add_rule(['required_name' => $required_rule]);
$val->set_message('required_name', 'お名前を入力してください。');
@memememomo
memememomo / user.php
Created June 10, 2014 05:29
ORM + Pagination で、ページネーションする ref: http://qiita.com/uchiko/items/b6a8a2f1ce8d3fe3cbf6
public function action_index()
{
// カテゴリ1の総数を取得する。
$query =
Model_User::query()->where('category_id', 1);
$total_items = $query->count();
// Paginationインスタンスを生成
$pagination = Pagination::forge('users', [
'total_items' => $total_items,
@memememomo
memememomo / file0.txt
Created June 9, 2014 11:38
Porboという開発用PSGIサーバを作った ref: http://qiita.com/uchiko/items/a1d66f12a1442a26118c
$ [email protected]:memememomo/Porbo.git
$ cd Porbo
$ cpanm .
@memememomo
memememomo / .vimrc
Created June 7, 2014 11:20
Goをインストールし、Vimで書く環境を整えるまでの手順 ref: http://qiita.com/uchiko/items/4c186292f007535116cc
filetype off
filetype plugin indent off
set runtimepath+=$GOROOT/misc/vim
filetype plugin indent on
syntax on
autocmd FileType go autocmd BufWritePre <buffer> Fmt
exe "set rtp+=".globpath($GOPATH, "src/github.com/nsf/gocode/vim")
set completeopt=menu,preview
@memememomo
memememomo / file1.txt
Created June 6, 2014 03:44
FuelPHPで他のサービスのWebAPIを利用する ref: http://qiita.com/uchiko/items/3cec115db0b99a25d089
$ php oil refine test
@memememomo
memememomo / composer.json
Created June 3, 2014 07:28
ComposerでPHPUnitをインストールし、FuelPHPでユニットテストを行う ref: http://qiita.com/uchiko/items/b62eafc18519a5970046
...
"require": {
...
"phpunit/phpunit": "4.1.*",
"piece/stagehand-testrunner": ">=3.5.0"
},
...
@memememomo
memememomo / public.php
Created June 3, 2014 07:21
Controller間共通でHTTPヘッダを追加する方法 ref: http://qiita.com/uchiko/items/e61d11ddff71e5330194
class Controller_Public extends Controller_Template
{
pubulic function after($response)
{
$response = parent::after($response);
$response->set_header('X-FRAME-OPTIONS', 'SAMEORIGIN');
return $response;
}
}
@memememomo
memememomo / config.php
Created June 3, 2014 03:30
FuelPHPをインストールし、ビルトインサーバで動作させる ref: http://qiita.com/uchiko/items/a5c2e45264963acc0e4a
// set default charset
ini_set('default_charset', 'UTF-8');
@memememomo
memememomo / .zshrc
Created June 1, 2014 01:43
zsh と oh-my-zsh を入れて、zshに再入門した ref: http://qiita.com/uchiko/items/253088bb0d7bbf574bff
export LANG=ja_JP.UTF-8
alias vi="vim -u NONE --noplugin"
alias v=vim
alias g=git
alias pl=perl
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
などなど...
@memememomo
memememomo / file0.txt
Created May 31, 2014 00:52
Mojo::UserAgentがスクレイピングツールとして便利 ref: http://qiita.com/uchiko/items/2d925c23fa04b696fc7a
$ cpanm Mojolicious IO::Socket::SSL