Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
⭐️ 🚀 🍻 🍶

kazu69 kazu69

:octocat:
⭐️ 🚀 🍻 🍶
View GitHub Profile
@kazu69
kazu69 / labelclick.js
Created February 5, 2012 09:06
checked true for iphone, ipad etc
View labelclick.js
var labelClick = function() {
var labels = document.getElementsByTagName('label');
console.log(labels);
for(var i=0,len=labels.length; i<len; i++){
if(labels[i].getAttribute('for')) {
labels[i].addEventListener('click',function(){
var id = this.getAttribute('for'),
target = document.getElementById(id);
if(['radio','checkbox'].indexOf(target.getAttribute('type')) !== -1){
@kazu69
kazu69 / sinatra_oauth.rb
Created March 13, 2012 04:48
sinatra oauth(authenticate) sample
View sinatra_oauth.rb
#encoding: UTF-8
require 'rubygems'
require 'sinatra'
require 'erb'
require 'pp'
require 'twitter_oauth'
set :sessions, true
@kazu69
kazu69 / pjax.rb
Created March 13, 2012 16:34
Pjax(pushState + Ajax) with Sinatra and BackboneJs
View pjax.rb
#encoding: UTF-8
require 'rubygems'
require 'sinatra'
require 'erb'
require 'pp'
class Sinatra::Request
def pjax?
env['HTTP_X_PJAX'] || self['_pjax']
@kazu69
kazu69 / check_device.js
Created April 3, 2012 00:56
device check
View check_device.js
function iOS_hasRetinaDisplay()
{
return window.devicePixelRatio > 1;
}
//UAでデバイスのチェック
function iOS_initPage()
{
if(navigator.standalone) iOS_createWebappLinks();
// iOS class
@kazu69
kazu69 / ga_shorten.js
Created April 10, 2012 09:11
google analytics async tag sorten
View ga_shorten.js
(function(d, t ,s) {
var js,ga = d.createElement(t);
ga.type = 'text/javascript'; ga.async = true; ga.src = '//' + s;
js = d.getElementsByTagName(t)[0]; js.parentNode.insertBefore(ga, js);
})(document, 'script', 'google-analytics.com/ga.js');
View photoshop-grid-script.js
// check for document
if(app.documents.length > 0){
// get active document
var psDoc = app.activeDocument;
// get user input on column count
var colWidth = parseInt( prompt("Column size?", 5) );
var docWidth = psDoc.width;
@kazu69
kazu69 / Router_spec.js
Created May 22, 2012 10:49
Backbone + sinonjsでのbackbone Routerのテスト例
View Router_spec.js
describe("Routerは", function() {
beforeEach(function() {
this.router = App.Router();
// routes {
// '' : 'index',
// 'login' : 'login'
// }
@kazu69
kazu69 / gist:2769620
Created May 22, 2012 15:01
sinon.jsとbackbonejsのsimpleなSpyTest
View gist:2769620
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Backbone + sinon simple tests</title>
<script src="http://code.jquery.com/jquery-1.7.2.min.js" type="text/javascript"></script>
<script type="text/javascript" src='http://documentcloud.github.com/underscore/underscore-min.js'></script>
<script type="text/javascript" src='http://documentcloud.github.com/backbone/backbone.js'></script>
<script type="text/javascript" src='http://sinonjs.org/releases/sinon-1.3.4.js'></script>
<script src="https://raw.github.com/douglascrockford/JSON-js/master/json2.js" type="text/javascript"></script>
@kazu69
kazu69 / gist:2770136
Created May 22, 2012 16:38
Sinon.js stabのsimple test
View gist:2770136
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Backbone + sinon simple tests</title>
<script type="text/javascript" src='http://documentcloud.github.com/underscore/underscore-min.js'></script>
<script type="text/javascript" src='http://documentcloud.github.com/backbone/backbone.js'></script>
<script type="text/javascript" src='http://sinonjs.org/releases/sinon-1.3.4.js'></script>
<script type="text/javascript">
@kazu69
kazu69 / data-bind.html
Created May 26, 2012 02:59
data binding attributes
View data-bind.html
<!--
http://ericbidelman.tumblr.com/post/23615290220/data-binding-using-data-attributes
-->
<style>
input[type="range"] {
vertical-align: middle;
margin: 2em;
font-size: 14px;
height: 20px;
}