Skip to content

Instantly share code, notes, and snippets.

@nishinoshake
nishinoshake / getRandomFloat
Last active September 23, 2016 08:41
JSで乱数を取得する
function getRandomFloat(min, max) {
return Math.random() * (max - min) + min;
}
@nishinoshake
nishinoshake / awesome.css
Last active May 29, 2016 04:48
CSSでfontawesom
sample:before {
content: "\f14a";
font-family: FontAwesome;
}
@nishinoshake
nishinoshake / deferred.js
Last active May 29, 2016 04:37
Deferredによる非同期処理
function sample() {
df().then(function() {
});
}
function df() {
var d = new $.Deferred;
$("sample").fadeIn(200, function() {
d.resolve(); //d.reject('Error!!');
@nishinoshake
nishinoshake / skipWorktree.sh
Last active May 29, 2016 04:37
gitでインデックスされているファイルをあえて無視する
#skip file
git update-index --skip-worktree file
#no-skip file
git update-index --no-skip-worktree file
#display all skip files
#"S" means skip
git ls-files -v | grep ^S
@nishinoshake
nishinoshake / chcheDom.js
Last active May 29, 2016 04:36
javascriptの時間測定
//DOM生成を単純に繰り返すと3000ms
console.time('createNode');
for (var i = 0; i < 100000; i++) {
$('#Main').append('<div>' + i + '</div>');
}
console.timeEnd('createNode');
//キャッシュすると300ms
var dom = '';
for (var i = 0; i < 100000; i++) {
@nishinoshake
nishinoshake / .htaccess
Last active May 29, 2016 04:33
Basic認証
AuthUserFile /home/hoge/.htpasswd
AuthGroupFile /dev/null
AuthName "enter password"
AuthType Basic
require valid-user
@nishinoshake
nishinoshake / .htaccess
Created January 8, 2016 03:05
Basic認証外し
Satisfy any
order allow,deny
allow from all
@nishinoshake
nishinoshake / .htaccess
Last active May 29, 2016 04:32
PC/SPの振り分け
RewriteEngine on
RewriteBase /sample/html/
RewriteCond %{REQUEST_URI} !/sp/
RewriteCond %{HTTP_USER_AGENT} (iPod|iPhone|iPad|Android|Windows\ Phone)
RewriteRule ^(.*)$ sp/$1 [R]
RewriteBase /sample/html/
RewriteCond %{REQUEST_URI} /sp/
RewriteCond %{HTTP_USER_AGENT} !(iPod|iPhone|iPad|Android|Windows\ Phone)
@nishinoshake
nishinoshake / .htaccess
Created January 8, 2016 03:07
Facebookのクローラーを許可
AuthUserFile absolute_path
AuthGroupFile /dev/null
AuthName "Please enter your ID and password"
AuthType Basic
require valid-user
<Files ~ "^\.(htaccess|htpasswd)$">
deny from all
</Files>
@nishinoshake
nishinoshake / directory.md
Last active May 29, 2016 04:47
WordPressのテンプレートファイル構成

header.php ヘッダー部分
index.php メイン部分
sidebar.php サイドバー部分
footer.php フッター部分
single.php 投稿記事のテンプレート
page.php ページのテンプレート
comments.php コメントのテンプレート
search.php 検索結果のテンプレート
searchform.php 検索フォームのテンプレート
archive.php アーカイブのテンプレート