Skip to content

Instantly share code, notes, and snippets.

@Takazudo
Takazudo / dateconvert.js
Created March 9, 2012 16:03
Backbone.js date convert
var MyModel = Backbone.Model.extend({
initialize: (attrs){
var self = this;
self.updateDate();
self.bind('change:date', function(){
self.updateDate();
});
},
updateDate: function(){
var date = this.get('date');
@Takazudo
Takazudo / github.css
Created June 16, 2016 02:10
Marked github.css
html,
body {
color: black
}
#wrapper {
font: 16px helvetica, arial, freesans, clean, sans-serif;
-webkit-font-smoothing: antialiased;
line-height: 1.6;
padding: 3px;
background: #fff;
@Takazudo
Takazudo / Cakefile
Created February 17, 2012 18:14
Cakefile to concatenate, minify coffee
# ==================================================================
# Cakefile - compile, concatenate, minify coffee
# ==================================================================
# ├─ Cakefile
# ├─ lib
# │   ├─ all.js
# │   └─ all.min.js
# └─ src
# ├─ fuga.coffee
# └─ hoge.coffee
var win8orhigher = (function() {
// windows browsers has str like "Windows NT 6.2" in its UA
// Win8 UAs' version is "6.2"
// browsers above this version may has touch events.
var ua = navigator.userAgent;
var matched = ua.match(/Windows NT ([\d\.]+)/);
if(!matched) { return false; }
var version = matched[1] * 1;
if(version < 6.2) { return false; }
return true;
# transitionEnd event name detection from Modernizr
# http://modernizr.com/docs/
transEndEventName = do ->
names =
WebkitTransition: "webkitTransitionEnd"
MozTransition: "transitionend"
OTransition: "oTransitionEnd"
msTransition: "MSTransitionEnd"
transition: "transitionend"
@Takazudo
Takazudo / eventmodule.coffee
Created December 10, 2012 10:42
lazy event implementation with jQuery
/* lazy eventy implementation with jQuery */
class Module
on: (evName, callback) ->
@_observer = $({}) unless @_observer?
@_observer.on evName, (args...) =>
args.shift() # we don't want event object
callback.apply @_observer, args
@
one: (evName, callback) ->
@Takazudo
Takazudo / audiopreloader.coffee
Created December 5, 2012 07:44
audio on the fly doesn't fire events correctly
class Module
_.extend Module::, Backbone.Events
class AudioPreloader extends Module
constructor: (options) ->
@options = options
@playableSrc = @_detectPlayableSrc()
@Takazudo
Takazudo / lazyEventModuleWithBackbone.coffee
Created November 27, 2012 09:44
lazyEventModuleWithBackbone
class Module
_.extend Module::, Backbone.Events
class App extends Module
app = new App
app.on 'hoge', ->
console.log 'hoge done!'
@Takazudo
Takazudo / requestAnimationFramePolyfill.coffee
Created November 27, 2012 10:09
requestAnimationFrame polyfill
window.requestAnimFrame = do ->
window.requestAnimationFrame or
window.webkitRequestAnimationFrame or
window.mozRequestAnimationFrame or
window.oRequestAnimationFrame or
window.msRequestAnimationFrame or
(callback, element) ->
window.setTimeout callback, 1000 / 60