Tbpgr Blog

Employee Experience Engineer tbpgr(てぃーびー) のブログ

2014-04-03から1日間の記事一覧

PHP | preg_replace

PHP

概要 preg_replace 詳細 正規表現を利用した文字列置換 サンプル #!/usr/bin/env php

PHP | strcmp

PHP

概要 strcmp 詳細 strcmp関数で文字列を比較し、結果を数値で返却する 同じなら0 大きいなら正の数値 大きいなら負の数値 を返却します。 サンプル 'b' puts 'a' …

PHP | uasort

PHP

概要 uasort 詳細 uasortでユーザー定義のソートを適用する サンプル id = $id; } function getId() { return $this->id; } } function idComparator($a, $b) { if ($a->getId() == $b->getId()) { return 0; } return ($a->getId() < $b->getId()) ? -1 : 1…

PHP | asort,arsort

PHP

概要 asort,arsort 詳細 asort,arsort関数で配列をソートする サンプル 2 [1] => 3 [2] => 1 ) Array ( [2] => 1 [0] => 2 [1] => 3 ) Array ( [1] =…

Ruby | gnuplot + gnuplot gem でグラフを操作

概要 gnuplot + gnuplot gem でグラフを操作 詳細 gnuplot + gnuplot gem でグラフを操作します。 設定 ※Windows + Cygwin環境・Cygwinのsetup.exeでgnuplotをインストール・gnuplot gemをインストール $ gem install gnuplot サンプルコード y=x*2 のグラフ…

Ruby | Hash | reject

概要 Hash#reject 詳細 Hashから条件に一致しない要素を抽出する サンプルコード # encoding: utf-8 require 'tbpgr_utils' h = { hoge_key1: :hoge_value, hoge_key2: :hoge_value, hige_key: :hige_value, hage_key: :hage_value, } bulk_puts_eval bindin…

TbpgrUtils | 追加要件 Familyable 追加

概要 追加要件 Familyable 追加 詳細 追加要件 Familyableを追加する 仕様 ・親子モデルと親、子、兄弟へのアクセスを提供 ・全体のモデルとしてFamilyクラスを提供 ・FamilyクラスのmixinとしてFamilyableクラスを提供 ・Familyクラスには任意のクラスの配…