Skip to content

Instantly share code, notes, and snippets.

@Khanashima
Khanashima / ac_token.php
Created April 19, 2014 11:45
【facebook php sdk】アクセストークンを2ヶ月にする ref: http://qiita.com/kiimiiis/items/543ee5861563b77f9bfb
$config = array(
'appId' => APPID,
'secret' => SECRET
);
$facebook = new Facebook($config);
$facebook->setExtendedAccessToken();
$longToken = $facebook->getAccessToken();
class Controller_Base extends Controller_Template
{
public function before()
{
parent::before();
//header.phpをテンプレートの$headerとbindさせる。
$this->template->header = View::forge('parts/header');
//footer.phpをテンプレートの$footerとbindさせる。
$this->template->footer = View::forge('parts/footer');
}
@Khanashima
Khanashima / file2.html
Created April 22, 2014 12:07
共通のテンプレートにアクション毎に設定できる追加ファイルを読み込ませる ref: http://qiita.com/kiimiiis/items/c48cb7136ac88c70b724
<script type="text/javascript" src="http://localhost/fuelphp/assets/js/test.js?1398130262"></script>
<script type="text/javascript" src="http://localhost/fuelphp/assets/js/hello.js?1398130262"></script>
@Khanashima
Khanashima / file0.txt
Created May 2, 2014 12:35
【FuelPHP ver1.7.1】URLのindex.phpを取る ref: http://qiita.com/kiimiiis/items/507d293976fe87e7f0b9
* Set this to 'index.php if you don't use URL rewriting
*/
- //'index_file' => false,
+ 'index_file' => false,
@Khanashima
Khanashima / file0.java
Created May 3, 2014 13:06
オブジェクト指向に近づく9つのルール (ThoughtWorks アンソロジーより) ref: http://qiita.com/kiimiiis/items/dab7ebbcab640b4f2aa0
class Board {
String board() {
StringBuffer buf = new StringBuffer();
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) {
buf.append(data[i][j]);
}
buf.append("\n");
}
return buf.toString();
C:\xampp\htdocs\PhpProject1>php ./single.php
1
string(1) "1"
@Khanashima
Khanashima / file0.php
Created July 12, 2014 09:43
array_unique()で値の重複は削除できるけど、キーが飛び飛びになる。array_values()で解決 ref: http://qiita.com/kiimiiis/items/c39aea90b653f8b5f5cf
<?php
//テスト配列
$array = array('test1', 'test2', 'test1', 'test3', 'test2', 'test');
//配列で重複している物を削除する
$unique = array_unique($array);
//キーが飛び飛びになっているので、キーを振り直す
@Khanashima
Khanashima / file0.txt
Last active August 29, 2015 14:06
【logrotateの実行タイミング】/etc/crontabに無い時の確認方法 ref: http://qiita.com/kiimiiis/items/b9bc67922fb0baf37a1e
# /etc/anacrontab: configuration file for anacron
# See anacron(8) and anacrontab(5) for details.
SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# the maximal random delay added to the base delay of the jobs
RANDOM_DELAY=45
# the jobs will be started during the following hours only
@Khanashima
Khanashima / file0.php
Created December 28, 2014 22:42
【FuelPHP】確認用の値と同じかどうかのValiadaiton ref: http://qiita.com/kiimiiis/items/6211765f8492eb3cd381
//emailの入力の検証
$val->add('email', 'email')
->add_rule('required')
->add_rule('match_field','email_re');
//emailの確認用の入力の検証
$val->add('email_re', '確認用')
->add_rule('required');
//バリデーションメッセージは下記で設定。param:1は確認用のラベルが表示される。
@Khanashima
Khanashima / file0.php
Created May 27, 2015 04:03
1時間以内に解けなければプログラマ失格となってしまう5つの問題の問題4 ref: http://qiita.com/kiimiiis/items/269e88f30ac21a21f763
//$list = array(5, 50, 56);
$list = array(50, 2, 1, 9);
usort($list, 'comp');
echo '<pre>';
print_r(implode('', $list));
echo '</pre>';
function comp($int1, $int2) {
$str1 = (string)$int1;