Skip to content

Instantly share code, notes, and snippets.

View phloe's full-sized avatar

Rasmus Fløe phloe

View GitHub Profile
@phloe
phloe / Bake Cookies
Last active December 10, 2015 18:49
var bake_cookie = (function () {
function decode (string) {
return decodeURIComponent(
string.replace(/%2[1789A]/gi, function(d){
return String.fromCharCode(parseInt(d.slice(1), 16));
})
);
}
_amoeba(function ($, $$, _) {
var link = $("link[href$='base-static.css']");
if (link) {
link.el.href = link.el.href.replace("-static.css", ".css");
var viewport = $("meta[name='viewport']");
if (!viewport) {
viewport = _.create("meta", {name: "viewport"}, document.head, "top");
}
@phloe
phloe / combine-layout.md
Last active July 27, 2020 07:23
combine-layout - float/inline-block layout technique

combine-layout

The following outlines a technique combining floating blocks and inline-blocks allowing for fairly interesting layouts without the need to use nested rows and avoids some problems when using pure floats.

The technique itself only uses three classnames:

  • combine-layout - defines the containing element.
  • break - starts a new row when in floating block context.
  • divide - starts off the inline-block context.
@phloe
phloe / css
Created October 9, 2012 13:15
for placeholder-less lazyloading
.figure {
width: 25%;
float: left;
position: relative;
background-color: red;
margin: 0;
overflow: hidden;
}
.figure:before {
content: "";
@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 = [];
}, {
@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 / 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 / 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 / bookmarklet.js
Created April 17, 2012 02:53
Gist bookmarklet test
alert("hello world");
@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