Skip to content

Instantly share code, notes, and snippets.

View jamband's full-sized avatar
👀
web browser

Tomoki Morita jamband

👀
web browser
View GitHub Profile
@jamband
jamband / PostController.php
Created May 26, 2015 11:02
Yii 2: Ajax + Delete
<?php
class PostController extends Controller
{
// ...
public function actionDelete($id)
{
$this->findModel($id)->delete();
if (!Yii::$app->request->isAjax) {
return $this->redirect(['index']);
@jamband
jamband / a_test.go
Last active October 14, 2015 07:02
Go: Benchmark of repeat and concatenation of characters
package s
import (
"bytes"
"testing"
)
func A1() (s string) {
for i := 0; i < 1000; i++ {
s += "a"
@jamband
jamband / hoge.sh
Last active December 23, 2015 14:19
bash スクリプトの配列操作
#!/bin/bash
declare -a a=(a1 a2 a3)
# 配列をすべて表示
echo "${a[@]}"
# a1 a2 a3
# 配列の先頭に要素を追加
a=(a0 ${a[@]})
@jamband
jamband / iStreamInfoClipper.applescript
Last active December 23, 2015 10:49
iTunes のラジオで現在流れている曲の情報をワンクリックでテキストファイルに保存する AppleScript
if application "iTunes" is running then
tell application "iTunes"
set songInfo to current stream title
-- 保存場所は任意
set savePath to "/Users/jamband/Dropbox/document/etc/music.txt"
do shell script "echo \"" & songInfo & "\" >>" & savePath
end tell
end if
@jamband
jamband / main.php
Last active December 21, 2015 17:19
<?php
return array(
...
'aliases' => array(
'actions' => 'application.components.actions',
),
'import' => array(
'application.models.*',
'application.components.*',
//'application.components.actions.*',
@jamband
jamband / DeleteCept.php
Created August 1, 2013 09:17
Codeception::PageObject acceptance sample
<?php
$scenario->group('containJs');
$I = new WebGuy($scenario);
$I->amOnPage(WordPage::URL_EDIT);
SitePage::of($I)->login();
$I->amGoingTo('400エラーの確認');
$I->amOnPage(WordPage::URL_DELETE.'/5');
$I->see($error400);
@jamband
jamband / autounit.rb
Last active April 6, 2019 08:50
Yii + PHPUnit + watchr + terminal-notifier
watch('./(.*).php') { |m| changed(m[0]) }
def changed(file)
run "clear && cd tests && phpunit unit"
end
def run(cmd)
result = `#{cmd}`
puts result
notify result
@jamband
jamband / autounit.rb
Created January 15, 2013 11:21
Yii + PHPUnit + watchr (growlなし)
$exec = "phpunit"
watch('models/(.*).php') { |m| changed(m[0]) }
watch('tests/unit/(.*)Test.php') { |m| changed(m[0]) }
def changed(file)
# pathは人それぞれ
path = "/Users/xxx/Dropbox/htdocs/hoge/protected/tests/"
run "cd #{path} && #{$exec} unit/"
end
@jamband
jamband / index.php
Created January 12, 2013 14:51
PHP: trait example
<?php
trait Trait1
{
public function a()
{
echo 'a1';
}
}
trait Trait2
@jamband
jamband / console.php
Last active December 10, 2015 22:08
Yii Framework: Creating Migrations
<?php
return array(
...
'commandMap' => array(
'migrate' => array(
'class' => 'system.cli.commands.MigrateCommand',
'migrationTable' => 'migration',
'templateFile' => 'application.migrations.template',
),
),