Skip to content

Instantly share code, notes, and snippets.

@nishinoshake
nishinoshake / output_sass.sh
Last active May 29, 2016 04:18
SASSでファイル変更を監視してコンパイル
sass --style expanded --watch hoge.scss:hoge.css
@nishinoshake
nishinoshake / mixin.scss
Last active May 29, 2016 04:17
mixinまとめ
@mixin min($width: 960px) {
@media only screen and (min-width: $width) {
@content;
}
}
@mixin max($width: 959px) {
@media only screen and (max-width: $width) {
@content;
}
@nishinoshake
nishinoshake / custom.txt
Created March 3, 2016 08:08
カスタムフィールドテンプレート
ACFよりも自由度が高い
グループ化とグループ追加ができる。
↓ここが詳しい
http://kotori-blog.com/wordpress/customfieldtemplate_add/
@nishinoshake
nishinoshake / oops.md
Last active May 29, 2016 04:16
switch_to_blogしてもカスタム投稿タイプは切り替わらない
@nishinoshake
nishinoshake / get_median.js
Last active December 1, 2016 11:11
JSで中央値を計算する
var getMedian = function(arr) {
var half = Math.floor(arr.length / 2);
var temp = arr.sort(function(a, b) { return a - b; });
console.log(temp);
if ( temp.length % 2 ) {
return temp[half];
} else {
return ( temp[half - 1] + temp[half] ) / 2;
}
@nishinoshake
nishinoshake / update.sql
Last active May 29, 2016 04:13
MySQLで置換UPDATE
UPDATE wp_posts SET post_content=REPLACE (post_content,'href="/','href="/hoge/');
@nishinoshake
nishinoshake / countdown.js
Last active May 29, 2016 04:12
カウントダウンをクラスの切り替えで
$(function() {
var limit = new Date("Feb 1,2016 00:00:00"),
$times = [
$('#date10'), $('#date01'),
$('#hour10'), $('#hour01'),
$('#minute10'), $('#minute01'),
$('#second10'), $('#second01')
];
var updateTime = function(timeArray) {
@nishinoshake
nishinoshake / validation.php
Created March 22, 2016 09:54
入力チェック
// 文字列を強制する
$name = isset($_POST['name']) && is_string($_POST['name']) ? $_POST['name'] : '';
@nishinoshake
nishinoshake / guideline.js
Last active May 29, 2016 04:10
とりあえずJSはこんな風に書くことにする
;(function () {
// 変数は一番上ででまとめて宣言
var i,
j,
k;
// functionの()はくっつける
// ,のあとはスペース
// ()の内側はすべてくっつける
function hoge(value1, value2) {
@nishinoshake
nishinoshake / sample.js
Last active May 29, 2016 04:53
Node.jsでPOSTデータを使う
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.post('/send/', function(req, res){
var s1 = req.body.s1 ? req.body.s1: 0,
s2 = req.body.s2 ? req.body.s2: 0,
s3 = req.body.s3 ? req.body.s3: 0;
io.sockets.emit('socket_sensor', [s1, s2, s3]);
res.send('OK');