Skip to content

Instantly share code, notes, and snippets.

View ytkhs's full-sized avatar
On vacation

ytkhs ytkhs

On vacation
View GitHub Profile
@ytkhs
ytkhs / backbone.sample.js
Last active December 18, 2015 03:29
backbone.js sample
var SampleModel = Backbone.Model.extend({
});
var SampleCollection = Backbone.Collection.extend({
model : SampleModel,
url : '/test/api',
parse : function(response) {
return response.samples;
}
@ytkhs
ytkhs / table.md
Created June 6, 2013 03:41
table for markdown
Left align Right align Center align
This This This
column column column
will will will
be be be
left right center
aligned aligned aligned
@ytkhs
ytkhs / h.php
Last active December 18, 2015 03:39
htmlspecialchars は第三引数まで必ず指定する
<?php
if (!function_exists('h')) {
function h($string) {
/*
出力までやってしまう.
@see http://koseki.hatenablog.com/entry/20120216/htmlspecialhonyarara
*/
echo htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
}
<?php
// delete APC Cache.
// apache graceful とかでも消える。
if(function_exists('apc_clear_cache')) {
if(apc_clear_cache()) {
echo 'システムキャッシュをクリアしました</br>';
}
@ytkhs
ytkhs / git_archive
Created June 24, 2013 06:43
gitで差分だけをzipにする
$ git archive --format=zip --prefix=dir/ HEAD `git diff <commit> --name-only` -o ~/output.zip
@ytkhs
ytkhs / 301_redirect.php
Created June 24, 2013 08:02
UserAgentを見てスマートフォン版⇔PC版をリダイレクトする場合とか
<?php
header('HTTP/1.1 301 Moved Permanently');
header('Vary: User-Agent');
header(sprintf('Location: %s', $url));
@ytkhs
ytkhs / flush_cache.sh
Created June 28, 2013 08:32
Mac で DNSキャッシュを消す
$ sudo dscacheutil -flushcache
@ytkhs
ytkhs / clean_svn.sh
Created July 4, 2013 03:05
.svn ディレクトリを再帰的に削除する
find . -name .svn -type d | xargs rm -fr
@ytkhs
ytkhs / mac_mail.php
Created July 5, 2013 02:58
mac で phpの mail() を使うとき
/*
% sudo postfix start
% tail -f /var/log/mail.log
*/
<?php
mail(
'[email protected]', // your email address
'Test', // email subject
'This is an email', // email body
@ytkhs
ytkhs / mysql_upgrade
Created July 8, 2013 06:24
mysql でユーザが作れないエラーが出た時の対処
$ mysql_upgrade -u root -p