Skip to content

Instantly share code, notes, and snippets.

@OrinZ
OrinZ / rgbToHSL.php
Last active June 12, 2021 16:42 — forked from brandonheyer/rgbToHSL.php
PHP snippet to convert RGB hex to HSL array, and HSL array to RGB hex
<?
function rgb2hsl( $rgb ) {
$rgb = trim($rgb, '#');
if( strlen($rgb) == 6)
$rgb = str_split($rgb, 2);
elseif( strlen($rgb) == 3)
$rgb = array($rgb[0] . $rgb[0], $rgb[1] . $rgb[1], $rgb[2] . $rgb[2]);
foreach($rgb as &$value)
$value = hexdec($value) / 255;
@OrinZ
OrinZ / shorten-bookmarklet.js
Created June 23, 2009 02:55 — forked from simonw/shorten-bookmarklet.js
A bookmarklet to report the rev=canonical attribute if one exists, or alert if one does not.
/* bookmarklet for extracting rev=canonical if it exists, or simply notifying if one does not */
(function(){
var url=document.location;
var links=document.getElementsByTagName('link');
var found=0;
for(var i = 0, l; l = links[i]; i++) {
if (l.getAttribute('rev') == 'canonical' || (/alternate short/).exec(l.getAttribute('rel'))) {
found=l.getAttribute('href');
break;
}