Skip to content

Instantly share code, notes, and snippets.

View asvny's full-sized avatar
🎯
Focusing

Annamalai Saravanan asvny

🎯
Focusing
View GitHub Profile
@asvny
asvny / raf.js
Created July 21, 2017 11:23
raf scheduler
const rafScheduler = (fn) => {
let lastArgs = [];
let frameId = null;
return (...args) => {
// Always capture the latest value
lastArgs = args;
// There is already a frame queued
if (frameId) {
import Ember from 'ember';
const REGEX_GET_DEPS = /[^[\]]+(?=])/g;
const REGEX_REPLACE = /\[(\w+)\]/g;
const DELETE_SYMBOL = '$$DELETE$$';
const interpolate = (text) => {
const deps = text.match(REGEX_GET_DEPS);
return Ember.computed(...deps, function(){
@asvny
asvny / post-receive
Created June 9, 2017 06:43 — forked from lemiorhan/post-receive
Post-receive hook to deploy the code being pushed to production branch to a specific folder
#!/bin/bash
target_branch="production"
working_tree="PATH_TO_DEPLOY"
while read oldrev newrev refname
do
branch=$(git rev-parse --symbolic --abbrev-ref $refname)
if [ -n "$branch" ] && [ "$target_branch" == "$branch" ]; then
// Place your settings in this file to overwrite the default settings
{
"editor.fontFamily": "Operator Mono",
"editor.fontLigatures": true,
"editor.fontSize": 14,
"editor.tabSize": 2,
"editor.lineHeight": 22,
"editor.formatOnType": true,
"editor.tabCompletion": true,
"editor.fontLigatures": true,
@asvny
asvny / importScript.js
Created May 29, 2017 04:22 — forked from tbranyen/importScript.js
Native `import()` polyfill (Note: can't name it `import` due to reserved word limitations)
Object.defineProperty(window, Symbol.for('registry'), {
value: new Map(),
});
window.importScript = src => {
const registry = window[Symbol.for('registry')];
if (registry.has(src)) {
return registry.get(src).promise;
}
@asvny
asvny / color.js
Last active May 18, 2017 07:14
Random color
// http://martin.ankerl.com/2009/12/09/how-to-create-random-colors-programmatically/
function hsv_to_rgb(h, s = 0.5, v = 0.95) {
let _h = ( Math.random() + 0.618033988749895 ) % 1;
h = h || _h;
let h_i = Number((h*6).toFixed(0));
@asvny
asvny / custom-fonts.js
Created March 20, 2017 11:26
fetch custom fonts from page
[...document.styleSheets[0].rules].filter(sel => sel.cssText.startsWith('@font-face') ).map(sel =>sel.style.fontFamily)
@asvny
asvny / sw-multiplex.js
Created March 4, 2017 09:36 — forked from ghaiklor/sw-multiplex.js
Multiplexing downloads via Service Workers
/**
* Size of one chunk when requesting with Range
* @type {Number}
* @private
*/
const CHUNK_SIZE = 204800;
/**
* Concat two ArrayBuffers
* @param {ArrayBuffer} ab1
@asvny
asvny / controllers.application.js
Last active October 3, 2016 12:06
multiple checkbox
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
checked:[],
grp: [
{ d: 'a' , v: false },
{ d: 'b' , v: false },
{ d: 'c' , v: false },
{ d: 'd' , v: false }
@asvny
asvny / components.ui-input.js
Last active June 10, 2017 03:59
New Twiddle
import Ember from 'ember';
export default Ember.Component.extend({
classNames:['ui-input'],
classNameBindings:[
'isFilled:has-value'
],
currentValue: '',
isFilled: Ember.computed.notEmpty('currentValue'),
});