Skip to content

Instantly share code, notes, and snippets.

View phloe's full-sized avatar

Rasmus Fløe phloe

View GitHub Profile
alert('hello, world');
@phloe
phloe / centered_triangle.html
Created May 3, 2011 10:43 — forked from romannurik/centered_triangle.html
A simple CSS trick to create a horizontally- or vertically-centered 'selected' callout triangle using zero images.
<!DOCTYPE html>
<html>
<head>
<style>
body {
margin: 40px;
}
a {
display: inline-block;
@phloe
phloe / mustachsucks.html
Created May 18, 2011 17:35 — forked from ryanflorence/mustachsucks.html
Mustache sucks
<h2>{{name}}</h2>
<ul>
{{#subItems}}
<li>
Sub Item name: {{name}}
Parent Item name: {{?!}}
parent name is inaccessible since the subItem has a name property :(
how is this not a common use case?
</li>
{{/subItems}}
(function (doc) {
var parent = doc.documentElement,
rect = parent.getBoundingClientRect(),
canvas = doc.createElement("canvas"),
context = canvas.getContext("2d"),
max = 0, rects = [];
canvas.width = rect.width;
canvas.height = rect.height;
@phloe
phloe / isXDomain.js
Created January 9, 2012 14:17
Crossdomain url test
/*
document.location of the current page tested against a url (string) like:
"pages/page.html" // false
"../pages/page.html" // false
"/pages/page.html" // false
"//foo.bar.com/pages/page.html" // false
"http://foo.bar.com/pages/page.html" // false
"//bar.com/pages/page.html" // true
@phloe
phloe / bookmarklet.js
Created April 17, 2012 02:53
Gist bookmarklet test
alert("hello world");
@phloe
phloe / dom.js
Last active October 3, 2015 18:07
Create elements from selectors
var dom = function (selector) {
var element, props, el,
id, className, attributes,
attribute, name, value, i;
while (selector.length > 1) {
props = selector.match(/(?:\s|^)([^.#\[\s]+|)(#[^.\[\s]+|)((?:\.[^.\[\s]+)+|)((?:\[[^\]]+\])+|)$/);
el = document.createElement(props && props[1] || "div");
if (element) {
@phloe
phloe / test.css
Created April 27, 2012 13:49
escaping selector fun
div {
margin: 10px;
min-height: 20px;
padding: 2px;
}
span {
margin: 2px;
}
div {
@phloe
phloe / gist:3159850
Created July 22, 2012 14:24
Blur document
document.body.appendChild(document.createElement("div")).innerHTML = "<svg><filter id='#'><feGaussianBlur stdDeviation='3'/></filter></svg>";
document.body.style.filter = "url(#\#)";
@phloe
phloe / uMVC.js
Last active October 10, 2015 22:48
peter michaux's uMVC in an IIFE for readability ;D
var uMVC = (function () {
function create (constructor, prototype) {
for (var name in prototype) constructor.prototype[name] = prototype[name];
return constructor;
}
return {
Model: create(
function() {
this._observers = [];
}, {