Skip to content

Instantly share code, notes, and snippets.

@kentaromiura
kentaromiura / index.js
Created May 31, 2014 23:01
requirebin sketch
var global = window,
div = document.createElement('div');
div.innerHTML = atob('CjxzY3JpcHQgaWQ9InNoYWRlci1mcyIgdHlwZT0ieC1zaGFkZXIveC1mcmFnbWVudCI+CnByZWNpc2lvbiBtZWRpdW1wIGZsb2F0OwoKICB2YXJ5aW5nIHZlYzQgdkNvbG9yOwoKICB2b2lkIG1haW4odm9pZCkgewogICAgZ2xfRnJhZ0NvbG9yID0gdkNvbG9yOwogIH0KPC9zY3JpcHQ+Cgo8c2NyaXB0IGlkPSJzaGFkZXItdnMiIHR5cGU9Ingtc2hhZGVyL3gtdmVydGV4Ij4KICAgICAgYXR0cmlidXRlIHZlYzMgYVZlcnRleFBvc2l0aW9uOwogIGF0dHJpYnV0ZSB2ZWM0IGFWZXJ0ZXhDb2xvcjsKCiAgdW5pZm9ybSBtYXQ0IHVNVk1hdHJpeDsKICB1bmlmb3JtIG1hdDQgdVBNYXRyaXg7CgogIHZhcnlpbmcgdmVjNCB2Q29sb3I7CgogIHZvaWQgbWFpbih2b2lkKSB7CiAgICBnbF9Qb3NpdGlvbiA9IHVQTWF0cml4ICogdU1WTWF0cml4ICogdmVjNChhVmVydGV4UG9zaXRpb24sIDEuMCk7CiAgICB2Q29sb3IgPSBhVmVydGV4Q29sb3I7CiAgfQo8L3NjcmlwdD4KICAgIAo=');
document.body.appendChild(div)
var mat4 = require('gl-matrix').mat4;
@kentaromiura
kentaromiura / index.js
Created May 30, 2014 18:56
requirebin sketch
var prime = require("prime"),
defer = require("prime/defer");
var Transition = require('transition')
var forIn = require('mout/object/forIn');
var slice_ = Array.prototype.slice;
@kentaromiura
kentaromiura / index.js
Created May 30, 2014 18:47
requirebin sketch
// example using the raf module from npm. try changing some values!
var requestAnimationFrame = require("raf")
var canvas = document.createElement("canvas")
canvas.width = 500
canvas.height = 500
document.body.appendChild(canvas)
var context = canvas.getContext("2d")
@kentaromiura
kentaromiura / index.js
Created May 30, 2014 13:41
requirebin sketch
var prime = require("prime"),
defer = require("prime/defer");
var Transition = require('transition')
var forIn = require('mout/object/forIn');
var slice_ = Array.prototype.slice;
@kentaromiura
kentaromiura / index.js
Created May 30, 2014 11:01
requirebin sketch
var prime = require("prime"),
defer = require("prime/defer");
var Transition = prime({
constructor: function Transition(duration, equation, callback) {
if (!duration) throw new Error('no duration given');
if (!equation) throw new Error('no equation given');
if (!callback) throw new Error('no callback given');
@kentaromiura
kentaromiura / Object.get.js
Created February 25, 2014 21:45
Object.get implementation
module.exports = function(object, path, defaultValue){
/*
if(arguments.length == 2){ // generic pattern
defaultValue = path;
path = object;
object = this;
}
*/
var result = defaultValue,
paths = path.split('.'),
/*jslint browser: true, indent: 2 */
var Delayed = (function (delay) {
/*! Andrea Giammarchi - Mit Style License */
// https://gist.github.com/WebReflection/7286687
'use strict';
// method shared across all delayed wrappers
function clear() {
@kentaromiura
kentaromiura / Gruntfile.js
Last active December 19, 2015 07:19
Grunt rule to compile any html inside javascript it matches any files that ends in .element.html, so if you have for example x-foo.element.html it generates x-foo.js Really useful for using the declarative element syntax, eg: http://jsfiddle.net/kentaromiura/uJqy9/ instead of the register api. Requires: grunt, btoa.
module.exports = function(grunt) {
var log = function(){
grunt.log.write(Array.prototype.slice.apply(arguments).join('') + '\n')
},
btoa = require('btoa')
// Project configuration.
grunt.initConfig({
(function(){var s = document.createElement('style'); s.innerText = ".quick-chat-history-message-alias-container{border-top:1px solid silver;}\n.quick-chat-history-header{background-color:whitesmoke;padding-top:0.2em;}"; document.documentElement.appendChild(s)})()
@kentaromiura
kentaromiura / Monad.js
Last active December 11, 2015 02:38
Monad.js
(function(a){var b={},c=function(d){var e=b[d];if(!e){e=b[d]={};var f=e.exports={};a[d].call(f,c,e,f,window)}return e.exports};window.Monad=c("0")})({0:function(a,b,c,d){function e(a){if(a instanceof e)return a;this.value=function(){return a}}e.prototype.bind=function(a){var b=this.value();return a===e||b===null||b===undefined?this:typeof a=="function"?new e(a(b)):this},b.exports=e}})