Skip to content

Instantly share code, notes, and snippets.

@webgyo
webgyo / emailreg.js
Created June 10, 2016 07:13 — forked from tsmd/emailreg.js
RFC 5322 準拠の、メールアドレス判別のための正規表現。
// comment 、 IP アドレス表記には未対応。
var emailReg = /^([-!#-'*+/-9=?A-Z^-~]+(\.([-!#-'*+/-9=?A-Z^-~]+|"([!#-\[\]-~]|\\[\x00-~])+"))*|"([!#-\[\]-~]|\\[\x00-~])+")@([-!#-'*+/-9=?A-Z^-~]+(\.[-!#-'*+/-9=?A-Z^-~]+)*)$/;
// RFC 822 との互換性を考慮しない
var emailReg = /^([-!#-'*+/-9=?A-Z^-~]+(\.[-!#-'*+/-9=?A-Z^-~]+)*|"([!#-\[\]-~]|\\[\x00-~])+")@([-!#-'*+/-9=?A-Z^-~]+(\.[-!#-'*+/-9=?A-Z^-~]+)*)$/;
// ダブルクオート内であっても制御文字を許可しない
var emailReg = /^([-!#-'*+/-9=?A-Z^-~]+(\.[-!#-'*+/-9=?A-Z^-~]+)*|"([!#-\[\]-~]|\\[\x09 -~])+")@([-!#-'*+/-9=?A-Z^-~]+(\.[-!#-'*+/-9=?A-Z^-~]+)*)$/;
// ローカルパートにおけるピリオドの連続を許可する(ただし先頭のピリオドは許可しない)
@webgyo
webgyo / gist:e8958efffa4453948f8c
Last active August 29, 2015 14:27 — forked from syuichi-tsuji/gist:ea387588c834bcc23c96
スクロールイベント 上下方向の判定
var start_pos = 0;
$(window).scroll(function(e){
var current_pos = $(this).scrollTop();
if (current_pos > start_pos) {
console.log('down');
} else {
console.log('up');
}
start_pos = current_pos;
});
@webgyo
webgyo / oop.md
Last active August 29, 2015 14:23 — forked from sunaot/oop.md

OOP とトップダウンの構造化プログラミングの設計上の違いとしてわかりやすいのは、 フローごとの動作の差異をどこが担保するかだと思います。

決済で、キャリア決済とクレジットカードによる決済を実装しようとしたとき、 トップダウンの場合、

case payment_method
when :carrier
  do_carrier_payment
<?php
// {app}/config/database.php
class DATABASE_CONFIG
{
var $default = array(
// デフォルトのDB設定...
);
// https://github.com/cakephp/datasources を導入してArraySource用のDB設定を追加します。
@webgyo
webgyo / main.js
Last active August 29, 2015 14:13 — forked from yat1ma30/main.js
var SCREEN_SIZE = 500; // キャンバスのサイズ
var SIDE_CELLS = 200; // 一辺のセルの数
var CELL_SIZE = SCREEN_SIZE / SIDE_CELLS; // 1マスの幅
var FPS = 200; // フレームレート
var canvas; // キャンバス
var context; // コンテキスト
var dirs = [ // アリの方向用配列
{'row': -1, 'col': 0},
{'row': 0, 'col': 1},
{'row': 1, 'col': 0},
@webgyo
webgyo / gulpfile.js
Last active August 29, 2015 14:11 — forked from gaspanik/gulpfile.js
// Original: https://github.com/gaspanik/gulpbase/
var gulp = require('gulp'),
// 列挙するのが面倒なので、load-pluginsでプラグインをロード。何使ってるかは「package.json」で
$ = require('gulp-load-plugins')({
pattern: ['gulp-*', 'gulp.*'],
replaceString: /\bgulp[\-.]/
}),
@webgyo
webgyo / 0_reuse_code.js
Last active August 29, 2015 14:11
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
CREATE TABLE test (
day1 DATETIME,
day2 TIMESTAMP
);
SET SESSION time_zone = 'UTC';
INSERT INTO test VALUES ('2014-12-25 00:00:00', '2014-12-25 00:00:00');
SET SESSION time_zone = 'Asia/Tokyo';
INSERT INTO test VALUES ('2014-12-25 00:00:00', '2014-12-25 00:00:00');
SET SESSION time_zone = 'UTC';
SELECT * FROM test;
{
/*
* UI関係
*/
// カラー&スキーマ
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme", // カラー
"theme": "Soda Dark.sublime-theme", // スキーマ
// カーソルのスタイル ("smooth", "phase", "blink", "wide", "solid")
"caret_style": "smooth",