Skip to content

Instantly share code, notes, and snippets.

function RgbToHsv(r, g, b) {
var min = Math.min(r, g, b),
max = Math.max(r, g, b),
delta = max - min,
h, s, v = max;
v = Math.floor(max / 255 * 100);
if (max == 0) return {h: 0, s: 0, v: 0};
s = Math.floor(delta / max * 100);
var deltadiv = delta == 0 ? 1 : delta;
<!DOCTYPE html>
<html lang="en">
<head>
<title>Template Example</title>
<meta charset="utf-8">
</head>
<body>
<section id="placeholder0"></section>
<section id="placeholder1"></section>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Underscore Template Example</title>
<meta charset="utf-8">
<style>
.viewer {width:240px;height:280px;margin:10px;float:left;border:1px solid red}
.viewer nav {width:100%;height:50px;border:1px solid green}
.viewer nav a {width:30px;height:30px;float:left;margin:5px;border:1px solid orange}
.viewer aside {width:106px;height:210px;margin:5px 0 0;border:1px solid purple}
<!DOCTYPE html>
<html lang="en" ng-app="app">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<head>
<title>Angular Template Example</title>
<style>
.viewer {width:240px;height:280px;margin:10px;float:left;border:1px solid red}
.viewer nav {width:100%;height:50px;border:1px solid green}
.viewer nav a {width:30px;height:30px;float:left;margin:5px;border:1px solid orange}
@nblenke
nblenke / IE11 IE8 Document Mode Conditional Comment Workaround
Last active August 29, 2015 13:57
IE8 Conditional Comments don't apply to IE8 Document Mode in IE11, this is a workaround to load legacy css/shivs
(function () {
'use strict';
var str = window.navigator.userAgent,
ie11 = /Trident\/7\.0/,
docMode8 = /MSIE 8\.0/;
if (ie11.test(str) && docMode8.test(str)) {
$('<link/>', {
rel: 'stylesheet',
type: 'text/css',
@nblenke
nblenke / example
Created October 1, 2014 14:39
domModified
/*
domModified
Add mutation listener to DOM element and trigger callback once it has completed
https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
Usage:
domModified({
selector: '#selector',
@nblenke
nblenke / gist:ca88e47a4861b6bb6e07
Created October 1, 2014 19:32
Fixed header on scroll
(function () {
var el = document.querySelector('#header'),
className = 'fixed',
offset = (el.offsetTop + el.offsetHeight),
scrollTop = function () {
return document.body.scrollTop || document.documentElement.scrollTop;
};
if (scrollTop() > offset) {
el.className = className;
var tapFlag = 0,
tapping = function (ev) {
var bool = false;
if (ev.type === 'touchstart') {
tapFlag = 1;
}
if (ev.type === 'touchmove') {
tapFlag = 0;
}
if (ev.type === 'touchend') {
@nblenke
nblenke / gist:33871970008561ec8049
Last active August 29, 2015 14:19
Android/iTunes App Download Notification
/* jshint strict: true */
/* globals $ */
/*
* Show a "Download App" notification on Android and iPhone.
* Notification will appear once per page every 30 days unless dismissed,
* once dismissed, it won't show again for 30 days
*/
(function () {
@nblenke
nblenke / index.html
Last active September 22, 2015 20:58
carousel blur on slide change
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Swiper/3.0.8/css/swiper.min.css">
<style>
.swiper-container img {
max-width:100%;
}
.swiper-slide {