Skip to content

Instantly share code, notes, and snippets.

View ajfarkas's full-sized avatar

AJ Farkas ajfarkas

View GitHub Profile
@ajfarkas
ajfarkas / README.md
Last active August 29, 2015 14:19
Luminance Histograms for Red, Green, and Blue Hues

Histograms of the range of luminance values for all unmixed hues of red, green, and blue.

Middle gray for our eyes is 18% gray for computer monitors (rgb(47,47,47) is L*a*b*(50.015), where L*.domain([0, 100])). The background color is the RGB value closest to L* == 50.

@ajfarkas
ajfarkas / hexToRGBa.js
Last active August 29, 2015 14:13
hex to RGBa conversion
function hexToRGBa(hex, alpha){
var r = parseInt( hex.slice(1,3), 16 ),
g = parseInt( hex.slice(3,5), 16 ),
b = parseInt( hex.slice(5,7), 16 ),
a = alpha || 1;
return "rgba(" + r + ", " + g + ", " + b + ", " + a + ")";
}
@ajfarkas
ajfarkas / defineVar.js
Created January 6, 2015 05:44
Generate variables from strings using object notation
var array = ["One", "Two", "Three"], local = {};
//for local scope
array.forEach( function(value, index){
local["number" + value] = index + 1;
});
console.log(local.numberOne) //1
console.log(local.numberTwo) //2
console.log(local.numberThree) //3
@ajfarkas
ajfarkas / smoothScroll.js
Created January 4, 2015 00:21
Smooth Scroll for web in Vanilla JS
function scrollSmooth(node, time){
var distance = node.getBoundingClientRect().top,
step = 10 * distance / time,
frames = distance / step,
i = 0,
run;
function goTo(){
window.scrollBy(0, step);
i++;
@ajfarkas
ajfarkas / keybase.md
Created December 5, 2014 19:22
Identity Verification

Keybase proof

I hereby claim:

  • I am ajfarkas on github.
  • I am ajfarkas (https://keybase.io/ajfarkas) on keybase.
  • I have a public key whose fingerprint is 64F2 8417 973A F3FB B17A E94E 3826 66A0 FAA3 8A08

To claim this, I am signing this object: