Skip to content

Instantly share code, notes, and snippets.

@nishinoshake
nishinoshake / canvas.js
Created February 2, 2016 15:37
canvasで画像を使う
var canvas = document.getElementById('canvas'),
ctx = canvas.getContext('2d'),
image = new Image();
canvas.setAttribute('width', window.innerWidth);
canvas.setAttribute('height', window.innerHeight);
image.src = 'sample.jpg';
image.addEventListener('load', function() {
@nishinoshake
nishinoshake / canvasRotate.js
Last active May 29, 2016 04:24
Canvasを回転させる
var offsetX = item.x + item.width / 2,
offsetY = item.y + item.height / 2;
ctx.save();
ctx.translate(offsetX, offsetY);
ctx.rotate(deg * 180/PI);
ctx.translate(-offsetX, -offsetY);
ctx.restore();
@nishinoshake
nishinoshake / rename.sh
Last active May 29, 2016 04:23
awkで一括リネーム
ls | awk '{printf "mv %s test%d.png\n", $0, NR-1}' | sh
@nishinoshake
nishinoshake / reboundBall.js
Last active May 29, 2016 04:23
Canvasで跳ね返るボール
$(function(){
$('<canvas id="yes"></canvas>').appendTo('body');
var canvas = document.getElementById('yes'),
ctx = canvas.getContext('2d'),
ww = $(window).width(),
wh = $(window).height(),
circle = [],
color = [
'#303F9F',
'#3F51B5',
@nishinoshake
nishinoshake / judgeNew.php
Last active May 29, 2016 04:22
PHPで新しいかの判定
function judgeNew($postedDate) {
$past = 7; // 1 week
if ( strtotime($postedDate) >= strtotime('-' . $past . ' day') ) {
return true;
} else {
return false;
}
}
@nishinoshake
nishinoshake / readme.md
Last active May 29, 2016 04:21
WordPressテンプレート作成

##WordPressテンプレート作成

###各ファイルの特徴 style.css
ここにテーマの情報も書く。メインのスタイル。

index.php
いろんなファイルがなかったら最後に参照されるファイル。

header.php

@nishinoshake
nishinoshake / removeClassRegExp.js
Last active May 29, 2016 04:21
jQueryのremoveClassを正規表現で
$about.removeClass(function(index, className) {
return (className.match(/\bbg\d+/g) || []).join(' ');
});
@nishinoshake
nishinoshake / readme.md
Last active May 29, 2016 04:20
WP_Queryの引数まとめ
@nishinoshake
nishinoshake / for.scss
Last active May 29, 2016 04:20
SASSのforでdelayずらし
@for $i from 0 through 11 {
ul li:nth-of-type(#{$i + 1}) { transition-delay: #{$i * 80ms};}
}
@nishinoshake
nishinoshake / getThumbnail.php
Last active May 29, 2016 04:19
Wordpressでサムネイルがない場合はnoimage
function getThumbnailUrl() {
if ( get_post_thumbnail_id() ) {
$thumbnailUrl = wp_get_attachment_image_src(get_post_thumbnail_id(), true)[0];
} else {
$thumbnailUrl = get_template_directory_uri() . '/images/noimage.jpg';
}
return $thumbnailUrl;
}