Skip to content

Instantly share code, notes, and snippets.

@nishinoshake
nishinoshake / tag.md
Last active May 29, 2016 04:07
タグの命名

####全体的なやつ wrap, wrapper, layout, outline

####サイト上部 head, header, headline

####ナビゲーション nav, navi, gnav, header_nav, category_nav, globalnavi, menu, content_nav

####メインビジュアル

@nishinoshake
nishinoshake / readme.md
Last active May 29, 2016 04:07
Jadeのルール

Jadeのルール

要点

  • nodeベースのHTMLテンプレートエンジン
  • 閉じタグがなくてインデントで階層を表現
  • セレクタはCSSセレクタの記法
  • 属性は()で,で区切る

文法の概要

CSSセレクタがそのままつかえる

p#ID名.クラス名 ここに文章がはいる

@nishinoshake
nishinoshake / readme.md
Last active May 29, 2016 04:07
Markdown記法

Markdown記法について

セクション見出し

細かい見出し

h4

h5
h6

強調

  • リスト1
@nishinoshake
nishinoshake / sample.sh
Last active May 29, 2016 05:12
シェルスクリプトの書き方
#!/bin/sh
# 1行目は実行するシェルを指定する。シバン、シェバン行という。
# 変数の代入はそのまま
string="Hello"
# 変数の表示は$をつけて
echo $string
@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');
@nishinoshake
nishinoshake / guideline.js
Last active May 29, 2016 04:10
とりあえずJSはこんな風に書くことにする
;(function () {
// 変数は一番上ででまとめて宣言
var i,
j,
k;
// functionの()はくっつける
// ,のあとはスペース
// ()の内側はすべてくっつける
function hoge(value1, value2) {
@nishinoshake
nishinoshake / validation.php
Created March 22, 2016 09:54
入力チェック
// 文字列を強制する
$name = isset($_POST['name']) && is_string($_POST['name']) ? $_POST['name'] : '';
@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 / 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 / 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;
}