Skip to content

Instantly share code, notes, and snippets.

View theavish's full-sized avatar

Avi Samloff theavish

View GitHub Profile
@theavish
theavish / colormeter.js
Created May 1, 2019 15:26 — forked from krypton/colormeter.js
Calculate difference in percentage between 2 hex colors
function color_meter(cwith, ccolor) {
if (!cwith && !ccolor) return;
var _cwith = (cwith.charAt(0)=="#") ? cwith.substring(1,7) : cwith;
var _ccolor = (ccolor.charAt(0)=="#") ? ccolor.substring(1,7) : ccolor;
var _r = parseInt(_cwith.substring(0,2), 16);
var _g = parseInt(_cwith.substring(2,4), 16);
var _b = parseInt(_cwith.substring(4,6), 16);
@theavish
theavish / slugify.js
Created March 11, 2019 15:52 — forked from mathewbyrne/slugify.js
Javascript Slugify
function slugify(text)
{
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}
@theavish
theavish / slugify.js
Created March 11, 2019 15:52 — forked from mathewbyrne/slugify.js
Javascript Slugify
function slugify(text)
{
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}
{
"always_prompt_for_file_reload": false,
"always_show_minimap_viewport": true,
"animation_enabled": true,
"atomic_save": false,
"auto_close_tags": true,
"auto_complete": true,
"auto_complete_commit_on_tab": false,
"auto_complete_cycle": false,
"auto_complete_delay": 50,
@theavish
theavish / timeSince.js
Created April 14, 2016 15:45
time since ____
function timeSince(date) {
var seconds = Math.floor(((new Date().getTime()/1000) - date))
var interval = Math.floor(seconds / 31536000);
if (interval >= 1) {
if(interval == 1) return interval + " year ago";
else
return interval + " years ago";
}