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 / spring-collection
Last active September 10, 2015 08:04 — forked from nicebarbarian/spring-collection
framer.js: spring collection
exessiveSpring = "spring(200, 15, -3)"
gentleSpring = "spring(40, 5, 0)"
swingSpring = "spring(120, 15, 0)"
smoothSpring = "spring(100, 20, 0)"
superSlowSpring = "spring(30, 20, 0)"
slowSpring = "spring(100, 15, -3)"
snapSpring = "spring(200, 20, 0)"
tightSpring = "spring(300, 25, 0)"
straightSpring = "spring(500, 40, 0)"
@asvny
asvny / what-forces-layout.md
Last active September 22, 2015 06:19 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@asvny
asvny / auto_curry.js
Created October 6, 2015 12:03 — forked from cem2ran/auto_curry.js
Auto-currying for the masses
Function.prototype._curry = function (f=this) {
return (...args) => args.length < f.length
? f._curry(args.reduce((g, arg) => g.bind(null, arg), f))
: f.apply(null, args);
};
@asvny
asvny / bind.js
Created November 24, 2015 16:30 — forked from WickyNilliams/bind.js
Super simple one-way data-binding
/**
* follows a path on the given data to retrieve a value
*
* @example
* var data = { foo : { bar : "abc" } };
* followPath(data, "foo.bar"); // "abc"
*
* @param {Object} data the object to get a value from
* @param {String} path a path to a value on the data object
* @return the value of following the path on the data object
@asvny
asvny / basicServiceWorker.js
Created December 21, 2015 08:32 — forked from adactio/basicServiceWorker.js
A basic Service Worker, for use on, say, a blog.
'use strict';
// Licensed under a CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
// http://creativecommons.org/publicdomain/zero/1.0/
(function() {
// Update 'version' if you need to refresh the cache
var staticCacheName = 'static';
var version = 'v1::';
@asvny
asvny / blogServiceWorker.js
Created December 21, 2015 08:33 — forked from adactio/blogServiceWorker.js
A Service Worker to progressively enhance a blog by storing assets in a cache, and keeping limited caches of pages and images for offline browsing.
'use strict';
// Licensed under a CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
// http://creativecommons.org/publicdomain/zero/1.0/
(function() {
// A cache for core files like CSS and JavaScript
var staticCacheName = 'static';
// A cache for pages to store for offline
var t = 'The quick brown fox jumped over the lazy dog' ;
const longestWord = (input) => {
let arr = input.split(' ');
let arrL = arr.map((word)=>word.length);
let max=arrL.reduce((prev,curr,i)=> curr > prev ? i : prev,0);
return arr[max];
}
const code = `clicking on ".container" add class "active" on it`;
//
const compose = (...funcs) => value => funcs.reduceRight((a, b) => b(a), value);
const flatten = (arr) => { return Array.isArray(arr) ? [].concat.apply([], arr) : [arr] };
const findBlocks = () => {
let codeBlocks = [...document.querySelectorAll('code')];
// return codeBlocks.map(codeBlock => codeBlock.textContent.trim())
@asvny
asvny / async.js
Created April 1, 2016 09:59
async in js
function async(genFunc) {
var gen = genFunc();
function step(value) {
var next = gen.next(value);
var promise = next.value;
return promise
.then((v) => {
if (!next.done) {
step(v);
}
@asvny
asvny / app.js
Created May 10, 2016 11:46 — forked from arvis/app.js
Basic express and mongoose CRUD application
/**
* Module dependencies.
*/
var express = require('express')
, routes = require('./routes')
, http = require('http')
, mongoose = require('mongoose')
, path = require('path');