Skip to content

Instantly share code, notes, and snippets.

Avatar

AJ Farkas ajfarkas

View GitHub Profile
@ajfarkas
ajfarkas / hexToRGBa.js
Last active Aug 29, 2015
hex to RGBa conversion
View hexToRGBa.js
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 Jan 6, 2015
Generate variables from strings using object notation
View defineVar.js
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 Jan 4, 2015
Smooth Scroll for web in Vanilla JS
View smoothScroll.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 Dec 5, 2014
Identity Verification
View keybase.md

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: