Skip to content

Instantly share code, notes, and snippets.

View yuka2py's full-sized avatar

yuka2py yuka2py

View GitHub Profile
@yuka2py
yuka2py / react-ripple.jsx
Created December 17, 2015 02:29
Rippleエフェクトだけを実現する React コンポーネント。
import React from 'react';
import assign from 'object-assign';
export default class Ripple extends React.Component
{
constructor(props) {
super(props);
this.canvas = null;
@yuka2py
yuka2py / gist:0108694eb877ca633c5a
Created March 26, 2015 06:19
gulpfile for browserify + TypeScript + React.js with JSX
var gulp = require('gulp');
var plumber = require('gulp-plumber');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var tsify = require('tsify');
var reactify = require('reactify');
gulp.task('browserify', function () {
return browserify({
entries: [App.Src + 'scripts/app.ts'],
@yuka2py
yuka2py / date.js
Created February 13, 2016 06:06
日付をなんかうまいことパースしてくれるやつ。
let mapZenHan = () => {
let zen = ' 0123456789.,abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXZY!?.,’”!#$%&’()=|‘@{}[]-*+:;¥_/?.,><'.split('');
let han = ' 0123456789.,abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXZY!?.,\'"!#$%&\'()=|`@{}[]-*+:;\\_/?.,><'.split('');
let map = [];
for (let i = 0, len = src.length; i < len; i++) {
map.push([new RegExp(zen[i], 'g')], han[i])
}
return map;
@yuka2py
yuka2py / flash.php
Created December 21, 2013 08:32
PHPでフラッシュを実現する簡単なユーティリティ
<?php
/**
* This is alias of the flash::next() for conbinience.
* @param $class
* @param $content
*/
function flash($class, $content) {
flash::next($class, $content);
}
@yuka2py
yuka2py / modernizer.environ.js
Last active December 29, 2015 18:59
デバイスやブラウザを判定する Modernizr 用の追加テストです。 えっと…。いや、実務では要りますよ。やっぱり。今回まとめました。
(function() {
if (!window.Modernizr) {
return;
}
var ua = new String(window.navigator.userAgent.toLowerCase());
ua.has = function (cond) {
return this.indexOf(cond) != -1;
};
@yuka2py
yuka2py / render.php
Last active December 29, 2015 16:49
PHP 自体をテンプレートエンジンとして利用するための簡単なユーティリティ。Django 風の extend、block、capture、strip などを備えている。
<?php
/**
* echo のエイリアス
* @return void
*/
function e($text) {
echo $text;
}
@yuka2py
yuka2py / gist:6148288
Last active December 20, 2015 14:39 — forked from miya0001/gist:6145701
ページ内のjQueryの有無に関わらず、別のjQueryをロードしてスクリプトで利用する。既存のjQueryがあれば、それを変更しない。 ブックマークレットなどでの利用を想定。
(function(func){
var jq = document.createElement('script');
jq.src = '//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js';
jq.async = 1;
jq.onload = function() {
document.body.removeChild(jq);
func(jQuery.noConflict(true));
};
document.body.appendChild(jq);
})(function($){
@yuka2py
yuka2py / gist:5996538
Created July 14, 2013 23:25
メモ。svn の trunk を git で管理。
1. svn の trunk の中で git init
2. ~/.subversion/config に以下を記述して git リソースなどを svn 管理下から除外する
global-ignores = .DS_Store Thumbs.db .git .gitignore
@yuka2py
yuka2py / debug.php
Last active December 17, 2015 16:39
CakePHP の debug 関数が心地よかったので、簡易版を書いたので貼っておきます。 あくまで簡易版 (*'-'*)。ちなみに WordPress 案件中に作ったので、WordPress 記法になっているのがミソですw $var は、出力したい変数。 $label は、ついでに出力したい文字列。 $echo は、true の場合のみ出力する。条件付きで出力したいとき、if 書く手間をほんの少し減らすことができます。
<?php
/**
* Output the contents of the variable along with the file and line number.
* @param mixed $var output variable of any types.
* @param string $label optional. default is null.
* @param boolean $echo optional. default is true.
* @return void
*/
function debug( $var, $label=null, $echo=true ) {
@yuka2py
yuka2py / cconsole.php
Last active December 17, 2015 04:49
This is small utility to log output to the console of the browser from the PHP.
<?php
register_shutdown_function('cconsole::flush');
class cconsole
{
private static $logs = array();
private static $prefix = '[php] ';
private static $timers = array();