Skip to content

Instantly share code, notes, and snippets.

View horitaku1124's full-sized avatar

Horimatsu Takuya horitaku1124

  • Tokyo
View GitHub Profile
@horitaku1124
horitaku1124 / 1.httaccess
Created November 25, 2013 11:12
特定のURIのみIP制限したい
RewriteEngine on
RewriteCond %{REMOTE_ADDR} !^1\.2\.3\.4$
RewriteCond %{REMOTE_ADDR} !^5\.6\.7\.8$
RewriteCond %{REQUEST_URI} ^/something.html$ [NC]
RewriteRule ^(.*)$ - [F]
@horitaku1124
horitaku1124 / forwarding.sh
Last active December 21, 2015 00:38
SSHポートフォワーディング
#!/bin/bash
#ローカルの8080番ポートにアクセスするとリモートの80番に転送される
#http://localhost:8080/ にアクセスすると http://1.2.3.4:80/ の内容が表示される。
ssh -L 8080:localhost:80 [email protected] -p 22 -i /path/to/id_rsa
@horitaku1124
horitaku1124 / StatementIterator.php
Created August 7, 2013 13:19
PDOのセレクト結果をForeachで回すためのイテレータ
<?php
/**
* PDOのセレクト結果をForeachで回すためのイテレータ
*
* Class StatementIterator
* @package LIBRARY
*/
class StatementIterator implements \Iterator {
/**
@horitaku1124
horitaku1124 / git_note.md
Last active December 20, 2015 16:29
git自分まとめ

登録系

コミットした後に小さなミスを修正したい場合に、直前のコミットを取り消す。
$ git reset --soft HEAD^
コミット取り消し
$ git reset HEAD^
@horitaku1124
horitaku1124 / dynamic_call.js
Last active December 19, 2015 21:19
文字から宣言された関数を呼び出す
var Funs = {fun1: function(n){return n + 100;}};
Funs["fun1"](1); // => 101
({fun1: function(n){return n + 100;}})["fun1"](2); // => 102
@horitaku1124
horitaku1124 / date_format.js
Created July 8, 2013 01:56
JavaScriptで日付フォーマット
Date.prototype.format = function(str) {
var y = this.getFullYear();
var m = this.getMonth() + 1;
var d = this.getDate();
m = (m < 10 ? "0" : "") + m;
d = (d < 10 ? "0" : "") + d;
return str.replace(/Y/g, y).replace(/m/g, m).replace(/d/g, d);
};
console.log(new Date().format("Y-m-d"));
@horitaku1124
horitaku1124 / setting_idea.md
Last active December 19, 2015 06:59
IntelliJ IDEAの初期設定

行以降にカーソルが移動しないように

Settings -> Editor -> Allow placement of caret after end of line

改行コード

File -> Settings -> Code Style -> General Line separator

行番号

Editor -> Appearance -> Show line numbers

@horitaku1124
horitaku1124 / js-dom.md
Last active December 18, 2015 02:39
DOMを操作するときのjQueryとかのやりかた

チェックボックスがチェックされているか。

DOM
document.getElementById('id').checked
jQuery
$('#id').is(":checked");
@horitaku1124
horitaku1124 / wp_setup.sh
Created May 10, 2013 16:09
Wordpressの自動設定(失敗版)
#!/bin/bash
WP_ROOT=/var/www
WP_SITE=http://wp-local/
MYSQL_LOGIN='-u root -ptest '
MYSQL='mysql '$MYSQL_LOGIN
MYSQLDUMP='mysqldump '$MYSQL_LOGIN
WP_DB=wp_db
MYSQL_WP_USER=wp_user
@horitaku1124
horitaku1124 / chpasswd.sh
Last active December 16, 2015 16:59
$ ./chpasswd user newpassword でuserのパスワードを変更
#!/bin/bash
expect -c "
set timeout 10
spawn passwd $1
expect \"新しいパスワード:\" {
send \"$2\n\"
expect \"新しいパスワードを再入力してください:\"
send \"$2\n\"
} \"New password:\" {