Skip to content

Instantly share code, notes, and snippets.

View sairion's full-sized avatar
⚛️

Jaeho Lee (Jay) sairion

⚛️
View GitHub Profile
// This function can be impure in JS context...
function sum(arr) {
var z = 0;
for (var i=0;i<arr.length;i++) {
z += arr[i];
}
return z;
}
// sec 1: valueOf() impureness
import ReactDOM from 'react';
// render without using JSX
export function jsRender(Component, data={}, targetElement, callback=null) {
ReactDOM.render(<Component {...data} />, targetElement, callback)
}
// Render after specific element.
export function wrappedRenderCreator(
function pp(givenNth/*: int*/, curNth = 0/*: int*/, dir = 1 /* { 1 | -1 } */, result = 0/*: int*/) {
// console.log(arguments[1], arguments[2], arguments[3]);
'use strict';
if (givenNth === curNth) {
return result;
} else {
return pp(givenNth, curNth + 1, isTurnAround(curNth + 1) * dir, result + dir);
}
}
// %
function mod(num, by) {
var tmp_num = num;
while (tmp_num - by >= 0) {
tmp_num -= by
}
return tmp_num;
}
function fizzbuzzMod (limit) {
@sairion
sairion / DebounceUntilTimeout.js
Last active April 22, 2016 15:43
keyboard event type (i.e. keyword-based recommendation)
export function debounceUntilTimeout(fun, delay, context = null) {
var timer;
return function delayedFunctionWrapper(...args) {
clearTimeout(timer);
args.unshift(context);
timer = setTimeout(fun.bind.apply(fun, args), delay);
};
}
@sairion
sairion / style-mixin.js
Last active April 9, 2016 17:47
style-mixin.js
export const Display = {
None: { display: 'none' },
Block: { display: 'block' },
Inline: { display: 'inline' },
InlineBlock: { display: 'inline-block' },
NoneIf(cond) {
return cond ? Display.None : null;
},
BlockIf(cond) {
return cond ? Display.Block : null;
@sairion
sairion / native-mixed-click.js
Last active April 6, 2016 09:06
native-mixed-click.js
// To make the most of native browser click event
// Util.js
export function isPlainLeftClick(event) {
return !(event.button !== 0 || event.altKey || event.metaKey || event.ctrlKey || event.shiftKey);
}
// index.js
import { isPlainLeftClick } from 'Util';
el.on('click', event => {
@sairion
sairion / main.js
Created January 25, 2014 04:44
Kill Mobile Safari or Mobile Chrome browser window's default rubber band effect being triggered when using drag/swipe event on child element.
document.addEventListener('touchmove', function(e){e.preventDefault();}, false);
@sairion
sairion / easing.js
Created January 22, 2014 08:18 — forked from gre/easing.js
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {
// no easing, no acceleration
linear: function (t) { return t },
// accelerating from zero velocity
easeInQuad: function (t) { return t*t },
// decelerating to zero velocity

#Techniques for Anti-Aliasing @font-face on Windows

It all started with an email from a client: Do these fonts look funky to you? The title is prickly.

The font in question was Port Lligat Sans from Google Web Fonts.

The "prickly" is aliasing caused by lack of hinting