Skip to content

Instantly share code, notes, and snippets.

View alexandrutasica's full-sized avatar

Alexandru Tasica alexandrutasica

View GitHub Profile
@alexandrutasica
alexandrutasica / color-conversion-algorithms.js
Created March 22, 2019 13:14 — forked from mjackson/color-conversion-algorithms.js
RGB, HSV, and HSL color conversion algorithms in JavaScript
/**
* Converts an RGB color value to HSL. Conversion formula
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
* Assumes r, g, and b are contained in the set [0, 255] and
* returns h, s, and l in the set [0, 1].
*
* @param Number r The red color value
* @param Number g The green color value
* @param Number b The blue color value
* @return Array The HSL representation
@alexandrutasica
alexandrutasica / .htaccess
Created February 18, 2019 14:41 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@alexandrutasica
alexandrutasica / [JS] rgba to byte number.js
Created January 28, 2019 08:24
[Javascript] Convert RGBA object to byte number and vice-versa.
/*
rgbaToInt({r: 0, g: 0, b: 0, a: 1}) => 4278190080
intToRgba(4278190080) => { r: 0, g: 0, b: 0, a: 1 }
The value 4278190080 is the representation of the black color with 100% opacity. The value is in base 10, translated to base 2 will result (ABGA): 11111111 00000000 00000000 00000000.
The result can be easily used with byte-shifting in C.
*/
function pad(n, width, z) {
z = z || '0';