Skip to content

Instantly share code, notes, and snippets.

View leaysgur's full-sized avatar
🫖

Yuji Sugiura leaysgur

🫖
View GitHub Profile
@leaysgur
leaysgur / adjustDisplaySize.js
Created February 19, 2014 15:31
Adjust display size by style zoom to html elm.
;(function(global) {
var doc = global.document;
var deviceRatio = global.innerWidth / 320;
doc.documentElement.style.zoom = deviceRatio;
}(this.self || global));
@leaysgur
leaysgur / v-repeat-in-v-repeat.html
Last active August 29, 2015 13:57
How to v-repeat in v-repeat at Vue.js
<script src="http://cdnjs.cloudflare.com/ajax/libs/vue/0.8.8/vue.min.js"></script>
<ul id="list">
<li v-repeat="monsters">
{{name}}
<div v-repeat="types">タイプ{{$index + 1}}: {{$value}}</div>
<ul>
<li v-repeat="baseStats">{{$root.lang[$key]}}: {{$value}}</li>
</ul>
</li>
</ul>
@leaysgur
leaysgur / Vue.tap.js
Created March 16, 2014 11:26
Use Vue.js and v-tap directicve with jQuery.tap.js
Vue.directive('tap', {
isFn: true,
bind: function () {
this.el = $(this.el);
},
update: function (fn) {
var vm = this.vm;
this.handler = function (e) {
e.targetVM = vm;
@leaysgur
leaysgur / layout_smart_with_spacing_v0.13.rb
Created April 9, 2014 12:25
Use layout smart with spacing at compass sprite-map
# For Compass v0.13
# See also http://stackoverflow.com/questions/16793278/generate-sprites-with-compass-with-smart-layout-and-spacing
module Compass
module SassExtensions
module Sprites
module Layout
class Smart < SpriteLayout
def layout!
calculate_positions!
@leaysgur
leaysgur / prepare-commit-msg
Last active August 29, 2015 14:01
Add branch name to top of commit msg
#!/bin/sh
# Add branch name to top of commit msg.
# Save this as: .git/hooks/prepare-commit-msg
# And then: chmod +x .git/hooks/prepare-commit-msg
######################################################
BRANCH=$(git branch | grep '*' | sed 's/* //')
(
mv $1 $1.BAK;
/bin/echo -n "#[${BRANCH}] " >$1;
@leaysgur
leaysgur / jquery.classes-transition.js
Created July 9, 2014 13:06
jQuery add/removeClass with transition and callback.
(function(global, $, undefined) {
'use strict';
var doc = global.document;
// まずイベント名を確定させる
var TRANSITION_END = (function() {
var events = {
'transition': 'transitionend',
'WebkitTransition': 'webkitTransitionEnd'
@leaysgur
leaysgur / easy-typewrite.js
Created July 11, 2014 17:10
The Easiest way to typewrite text.
/**
* TypeWriter的な動きを実装するスニペット
* 気になる点としては、不完全な文字(<s とかタグの途中とか)をそのままHTMLとしてDOMに突っ込むので、
* うまく解釈してくれないやつがいたらバグりそう
*/
var str = "<p>This is my <span style='color:red;'>special string</span> with <br><br>an <img src='http://placehold.it/150x150'> image !</p>",
i = 0,
isTag,
dest = document.getElementById('hoge'),
@leaysgur
leaysgur / .csslintrc
Created October 1, 2014 06:01
.csslintrc
{
"adjoining-classes": false,
"box-model": false,
"box-sizing": false,
"compatible-vendor-prefixes": false,
"empty-rules": false,
"fallback-colors": false,
"font-sizes": false,
"gradients": false,
"important": false,
@leaysgur
leaysgur / pre-commit
Last active August 29, 2015 14:07
奇数サイズの画像があればコミットできないようにするフック
# ---------------------------------------------------------------------
# 奇数サイズの画像があればコミットできないようにするフック
#
# git_hooks pre-commmitとして設定
# ---------------------------------------------------------------------
#!/bin/sh
cmd=`find /path/to/img/dir -name '*.png' | xargs file | awk '{ if ($5%2 || $7%2) print $1 }'`
if [[ -n $cmd ]]; then
echo '以下の画像のサイズが奇数になってるのでコミットできません'
@leaysgur
leaysgur / eve.js
Last active August 29, 2015 14:10
SimpleEventInterface
var Eve = function() {
this._events = {};
};
Eve.prototype = {
constructor: Eve,
on: function(evName, handler) {
var events = this._events;
if (!(evName in events)) {
events[evName] = [];