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 / 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 / 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;
}
// 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 / 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
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 / 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) {
@asvny
asvny / components.delete-blog.js
Created August 31, 2017 01:36 — forked from jamesarosen/components.delete-blog.js
passing-deferreds-down
import Ember from 'ember';
export default Ember.Component.extend({
classNames: [ 'delete-blog' ],
sudoDeferred: null,
isDone: false,
isWorking: false,
message: null,
@asvny
asvny / components.ui-btn.js
Created August 31, 2017 02:43
New Twiddle
import Ember from 'ember';
const { Logger: { assert } , tryInvoke } = Ember;
const PromiseProxy = Ember.Object.extend(Ember.PromiseProxyMixin);
const isPromise = (p) => typeof p === 'object' && p !== null && typeof p.then === 'function';
export default Ember.Component.extend({
tagName: 'button',
@asvny
asvny / semver-check.re
Last active April 8, 2018 10:17
Semver check
module Semver = {
let checkVersion = (a, b) => {
let x = String.index(a, '.');
let y = String.index(b, '.');
let _b = x > y ? String.concat(String.make(x - y, '0'), [b]) : b;
let _a = y > x ? String.concat(String.make(y - x, '0'), [a]) : a;
let cmp = String.compare(_a, _b);
if (cmp == 0) {
0;
} else if (cmp > 0) {
@asvny
asvny / animate.js
Created June 12, 2018 12:47
Animate
const rafPromise = _ => new Promise(r => requestAnimationFrame(r));
const transEndPromise = ele => new Promise(r => {
ele.addEventListener('transitionend', function f() {
ele.removeEventListener('transitionend', f);
r();
});
});
const animate = (ele, styles) => {