Skip to content

Instantly share code, notes, and snippets.

View Munter's full-sized avatar

Peter Müller Munter

View GitHub Profile
@Munter
Munter / defer.js
Created November 14, 2011 15:08
Javascript delayed loading function
var defer = function (config) {
var inc;
if (config.id && !document.getElementById(config.id)) {
inc = document.createElement('script');
if (config.id) {
inc.id = config.id;
}
inc.async = true;
inc.src = config.url;
inc.onload = config.callback || function () {};
@Munter
Munter / external.js
Created March 19, 2012 14:41 — forked from anonymous/VxS6ZWqg
a guest on Mar 19th, 2012 - pastebin.com/VxS6ZWqg
function set_new_material(materialObj) {
alert(document.getElementById('paper_finish').value);
document.getElementById('paper_finish').value = materialObj.finish;
}
@Munter
Munter / .htaccess
Created April 18, 2012 11:43
Apache .htaccess file to make all files in a directory be served with a far future expires header
ExpiresActive On\n
ExpiresDefault "access plus 1 year"
FileETag none
Header append Cache-Control "public"
@Munter
Munter / optimizeimages.sh
Created May 2, 2012 12:44
Shell script to recursively optimize all image in the current directory. WARNING: THIS OVERWRITES YOUR ORIGINALS AND REMOVES METADATA!
#!/bin/sh
set -o errexit
PNGS=`find . -iname "*.png"`
JPGS=`find . -iname "*.jpg"`
TMP1="_TMP1.PNG"
TMP2="_TMP2.PNG"
echo "Optimizing PNG"
for PNG in ${PNGS}
iVBORw0KGgoAAAANSUhEUgAAARwAAATgBAMAAADXsuAWAAAAGFBMVEUAAAAA/wAA////AP///wD/AAAAAAD////fPtU8AAAAAXRSTlMAQObYZgAAP/JJREFUeNrtnU2S5MqNrWvUPX6T93bQvYJr2gACWoACzmm3GfxgKjOJwPbfwEkG6fSgM7OiIrPuZUl9WyVloT6CTv8BcBw/fqD3639+/Ef3Z368ysx/RO+X/7Duz/zPi8yc+JlA/0f8RWa+I87Qt+N9nPEEjv1+OKP07cC6ONJ/KsfvhyPj0LVj6OGMQ/+p0Bny3xBnHEK6djqfsltIdJ/KrfO1+w+LUaSPA3RxRLo4QB9HeoaKHRzjjNJ/KnSf6oeFRMfN5U31cIbovnP0pm//YaMMcfxcCCD88LncRGLsONlh0XHyt8O5VvSfxzmxSIyvwZGhO2GEozsrn1mzTqzoowz9afAEzij9ReLEEnpm/jqDc2JWDsBegeMGw3sWibOze2feOYNzbpE4Z6eHc2LsnMI5aaeHc+LLqq14e/vVteNwx8/PO27bEbh7wrJXfs00eGI23T7T/nN95az8YZz9APjKNcthtXu+EgfwetfyhTgO27nnC3EAByr3fB2Ow4DaPV+HAzisds+X4RSW+uP6MpzinNo9X4VTnGOo3PNVOMU57pV7vghndk7tnl+IMxyYmUdOPXp2OK0z6R5nvzPY4exDaqicA7hj654djoiM9e5wh9PYGexw9ltMbCdkm/+9ck+NMxYcOcZp7Axs55zdHnOFYwDgcIcDsEMceQVOI2iEavE0gxk2C+kX4XiZdMq/Af85nP7YGfdWapzZOz+NU77QQ5xi5ckXAQNiGTvmD2utL0s6X5aX3NPnvTMNnce/fwpnSoXZp8fOPPuhfF9HOIeP9Uqc+ZuyQ5xDOx/AOZp3YEA44O5eoo7PcQ7nr3nsuHfGzuGsXGbB2UfrebCxhB7N7rM5j86XdbhmTRC+/OMI52jt+8ASerCiY1oaMP/TD3AOdwbnl9CD
@Munter
Munter / dabblet.css
Created August 3, 2012 07:31
Untitled
body {
background: black;
color: white;
}
p {
width: 300px;
}
p:first-letter {
@Munter
Munter / data-uri.html.md
Last active December 14, 2015 19:39
Suggestion for new section on browserdiet.com on data-URI background images
Error in user YAML: (<unknown>): mapping keys are not allowed in this context at line 1 column 8
---
order: ?
title: Inline CSS backgrounds
---

This technique is an alternative to using CSS sprites.

A Data-URI is a way to inline the content of the URI you would normally point to. In this example we are using it to inline the content of the CSS background images in order to reduce the number of HTTP requests required to load a page.

Before:

@Munter
Munter / Makefile
Last active December 14, 2015 20:59
all: 2011.pdf 2012.pdf
%.pdf:
node report.js $* > $*.tex
pdflatex -interaction=nonstopmode -halt-on-error $*.tex
@Munter
Munter / Makefile
Created April 2, 2013 12:54
Makefile targets to quickly switch development server to a different backend
livelocal:
-screen -S live -X quit
screen -S live -d -m livestyle --compiless -r http-pub --proxy http://127.0.0.1/
livetest:
-screen -S live -X quit
screen -S live -d -m livestyle --compiless -r http-pub --proxy http://$(TESTING)/
livepublishing:
-screen -S live -X quit
@Munter
Munter / example.server.config
Created May 16, 2013 08:42
Nginx example setup for a single page web application with far future expires static content in /static/ and proxying to several backends on any other request that /static or /.
upstream backends {
ip_hash;
server 0.0.0.0:80;
server 0.0.0.0:80;
}
server {
server_name app.falconsocial.com;