Skip to content

Instantly share code, notes, and snippets.

View Munter's full-sized avatar

Peter Müller Munter

View GitHub Profile
@Munter
Munter / .pushmap.json
Created February 19, 2014 18:32
Example configuration for telling a web server what web assets should be pushed using SPDY/HTTP2 push before the corresponding .html-file is served.
{
"index.html": [
{
"path": "js/jquery.js",
"etag": "123456" // MD5-sum of file or similar hash. Maybe the erver can make this up
},
{
"path": "js/underscore.js",
"etag": "123456"
}
PATH:=./node_modules/.bin/:${PATH}
PHONY: clean build
build: app/index.html
buildProduction \
--root app \
--outroot build \
$<
#dave .hide {
transition: all 0.2s;
-webkit-transform: translate(12px, 86px) scale(0.933, 1);
}
#dave:hover .hide {
-webkit-transform: none;
}
@Munter
Munter / inlineCss.js
Created June 19, 2014 08:55
Inline your CSS into your HTML-pages
new AssetGraph({ root: 'path/to/website' })
.loadAssets('index.html')
.populate({
followRelations: Assetgraph.query.or({
type: 'HtmlStyle'
},
{
type: 'HtmlAnchor',
hrefType: ['relative', 'rootRelative']
}
munter at Peters-MacBook-Air in ~/git/cardio on master
$ cardio http://www.lonelyplanet.com/ > report.json
✔ http://www.lonelyplanet.com/
✔ https://www.lonelyplanet.com/favicon.ico
✔ http://assets.staticlp.com/assets/icons/critical-601e7308f8b9de6ff4e5959ddc66cf40.css
✔ http://assets.staticlp.com/assets/common_core_no_font-928186620565d22d6ead4a614e110d0a.css
✔ http://assets.staticlp.com/assets/common_core_no_font_ie-08e8af4b81dd4d19840ba438c16cf48b.css
✔ http://assets.staticlp.com/assets/application-efb1d5aff5fcab6c6eb3d5c9b713cca6.css
✔ http://assets.staticlp.com/assets/application_ie-e96cb99e9b418b52e1c70786b86a7d84.css
✔ http://media.lonelyplanet.com/a/g/hi/t/f1df0ac7e602b5111d3aaefa29949491-store.jpg
@Munter
Munter / MyClass.js
Created July 17, 2014 08:55
An example of using self and bind()
function MyClass(otherInstance) {
var self = this;
self.options = {
loaded: false
};
setTimeout(function () {
self.options.loaded = true;
@Munter
Munter / jsx.js
Created August 3, 2014 19:52
Requirejs JSX transformer plugin. Works runtime and in r.js and lets you run without a file extension or with a custom one
define(function () {
'use strict';
var buildMap = {};
var transform = {
/**
* Reads the .jsx file synchronously and requires react-tools
* to perform the transform when compiling using r.js
Chromecast is connecting
Connected to 0/0 peers
Downloaded 0 Bytes (0 b/s) with 0 hotswaps
Uploaded 0 Bytes (0 b/s)
Potentially unhandled rejection [1] TypeError: Object [object Object] has no method 'start'
at /home/munter/git/peercast/node_modules/chromecast-player/chromecast-player.js:30:13
at init (/home/munter/git/peercast/node_modules/chromecast-player/node_modules/when/lib/makePromise.js:38:5)
at new Promise (/home/munter/git/peercast/node_modules/chromecast-player/node_modules/when/lib/makePromise.js:26:53)
at promise (/home/munter/git/peercast/node_modules/chromecast-player/node_modules/when/when.js:100:10)
at findDevice (/home/munter/git/peercast/node_modules/chromecast-player/chromecast-player.js:17:10)
@Munter
Munter / scrollToMin.js
Created November 7, 2014 17:41
A function to find the minimum scrollTop offset to scroll the given element into view of its scrolling ancestor.
define(function (require) {
function findScrollParent(el) {
return $(el).scrollParent()[0]; // FIXME: scrollParent adds a jquery UI dependency
}
return function (element, margin) {
if (!element instanceof HTMLElement) {
throw new Error('scrollToMin: First argument must be a DOM node');
}
@Munter
Munter / buildFromWeb.js
Created November 25, 2014 23:40
Example script of how to do a production build of a website with external assets directly to disc
var AssetGraph = require('assetgraph-builder');
var graph = new AssetGraph({ root: 'https://raw.githubusercontent.com/saulshanabrook/hamilton-energy/gh-pages/'});
graph
.logEvents()
.loadAssets([
'index.html',
'README.md'
])