Skip to content

Instantly share code, notes, and snippets.

@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',
<!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}
<!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">
<head>
<title>Template Example</title>
<meta charset="utf-8">
</head>
<body>
<section id="placeholder0"></section>
<section id="placeholder1"></section>
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;
@nblenke
nblenke / Google Image Resize Proxy
Created January 28, 2014 14:30
Use Google's Image caching/optimization proxy to resize an image
(function () {
var img = document.createElement('img');
path = encodeURIComponent('https://s3.amazonaws.com/llama0/burningfiremonkey.gif'),
width = 600,
refresh = 2592000;
img.src = 'https://images1-focus-opensocial.googleusercontent.com/gadgets/proxy?url=' + path + '&resize_w=' + width + '&container=focus&refresh=' + refresh;
document.body.appendChild(img);
}());
<!DOCTYPE html>
<html>
<head>
<title>Calendar Puzzle</title>
<style>
.mark {border-top:1px solid red;width:400px;height:30px;}
.time {float:left}
.event {left:100px;position:absolute;opacity:.4;color:#fff}
.event {background:red;width:302px;}
/*.event + .event {background:green;width:150px;left:252px;}*/
@nblenke
nblenke / Angular Single Page
Created November 15, 2013 15:00
A one page Angular starter application template
<!DOCTYPE html>
<html lang="en" ng-app="app">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<head>
<title>Angular</title>
</head>
<body>
<a href="#!/">Home</a> | <a href="#!/test">Test</a>
<div ng-view></div>
@nblenke
nblenke / Backbone Single Page
Last active December 24, 2015 12:29
A one page Backbone starter application template
<!DOCTYPE html>
<html lang="en">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<head>
<title>Backbone</title>
</head>
<body>
<header></header>
@nblenke
nblenke / Stagify
Last active December 24, 2015 12:29
Create a staging environment
var stagify = function () {
if (window.location.search.search('staging=true') !== -1) {
$('html')
.addClass('staging')
.find('a').each(function () {
var h = $(this).attr('href'),
q = !!h && h.search(/\?/) !== -1 ? '&': '?';
if (!!h && h.search('#') === -1) {
$(this).attr('href', h + q + 'staging=true');
}