Skip to content

Instantly share code, notes, and snippets.

Cristian Carlesso kentaromiura

Block or report user

Report or block kentaromiura

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View maps.onRemove.patch.js
// The following code patches google.maps API since in `onRemove` they don't check for null
// sometimes this conflicts with the way React handle DOM.
const PATCH_ONREMOVE = Symbol.for('Patch onRemove');
function waitForGoogleThenPatch() {
/* global google */
if (typeof google === 'undefined') {
window.requestAnimationFrame(waitForGoogleThenPatch);
} else {
const Marker = google.maps.Marker;
View globalpretty.js
(function (modules, global) {
var cache = {}, require = function (id) {
var module = cache[id];
if (!module) {
module = cache[id] = {};
var exports = module.exports = {};
modules[id].call(exports, require, module, exports, global);
}
return module.exports;
};
@kentaromiura
kentaromiura / Foo-test.js
Created Oct 26, 2016
Testing Foo interaction using jest + enzyme + enzyme-to-json
View Foo-test.js
'use strict';
const Foo = require('../Foo');
const React = require('react');
import { mount } from 'enzyme';
import { mountToJson } from 'enzyme-to-json';
describe('Foo', () => {
it('simulate a change event using enzyme', () => {
@kentaromiura
kentaromiura / index.js
Created May 28, 2016
requirebin sketch
View index.js
var big = require('decimal.js');
var denominator = new big(2);
var num = new big(1);
document.body.innerHTML = (num.dividedBy(denominator.toPower(2048)).toString());
@kentaromiura
kentaromiura / index.js
Created Mar 15, 2016
requirebin sketch
View index.js
// require() some stuff from npm (like you were using browserify)
// and then hit Run Code to run it on the right
var twister = require('mersenne-twister')
var generator = new twister();
function rand(max, modifier) {
modifier = modifier || 0;
var rnd = generator.random_incl();
return modifier + 1 + Math.round(rnd * max);
@kentaromiura
kentaromiura / index.js
Created Jan 26, 2016
requirebin sketch
View index.js
// require() some stuff from npm (like you were using browserify)
// and then hit Run Code to run it on the right
var immutable = require('immutable')
var set = immutable.Set.of('a','b','c')
console.log(
set.reduce(function(result, prop){
result['property' + this.index++] = prop
@kentaromiura
kentaromiura / EnemyStats.js
Created Nov 1, 2015
EnemyStats plugin for RPGMaker MV
View EnemyStats.js
/* Version 0.1.0 @kentaromiura
TODO: remove access to 'private' properties
TODO: find out if there's already an emitter
TODO: text now overlaps, check how to get the Sprite height/width properties
for the enemy to move the text in another position
TODO: make the text floating up and down (optional)
TODO: add a % bar below the text (optional)
*/
/*:
@kentaromiura
kentaromiura / transform.js
Created Jul 26, 2015
MooTools Class to ES 2015
View transform.js
module.exports = function(file, api) {
var j = api.jscodeshift;
var root = j(file.source);
root.find(j.Identifier).forEach(function(p) {
if(p.value.name === 'Class') {
if(p.parentPath.name === 'init'){
var classDefinition = p.parentPath.value.arguments[0];
var varname = p.parentPath.parentPath;
var name = varname.value.id;
var target = varname.parentPath.parentPath
You can’t perform that action at this time.