Skip to content

Instantly share code, notes, and snippets.

View Munter's full-sized avatar

Peter Müller Munter

View GitHub Profile
@Munter
Munter / inline.js
Last active December 19, 2016 08:54
var Assetgraph = require('assetgraph');
new Assetgraph({
root: 'myProject'
})
.logEvents()
.lodAssets('index.html')
.populate({
followRelations: { crossorigin: false }
})
/*
* This transform works on an assumption about browser loading and rendering behavior of CSS:
* When a browser loads CSS in <head> it render blocks untill all CSS in <head> has loaded.
*
* That might be slow.
*
* To appear faster, browsers will render what they have in buffer already if they meet a style <link> in <body>
* before they dive into the render blocking load.
* This lets you potentially inline critical css in <head> and put the bulk of your CSS "below the fold".
* The effect will be a quick render with critical styles applied, just before the render blockign starts.
@Munter
Munter / check-jspm-config.js
Created July 7, 2015 12:34
Small script to automatically verify that a jspm package has been correctly installed and configured
var jspm = require('../package.json').jspm;
var jsdom = require('jsdom');
var async = require('async');
var chalk = require('chalk');
var express = require('express');
var app = express();
app
.get('*.html', function (req, res) {
@Munter
Munter / northernlights.js
Created August 26, 2016 13:34
Lighting control program for JSConf Iceland northern lights
const { totalCols } = config
function crazyCaterpillar(time) {
const newLights = new Lights()
let dead = [];
for (let i = 0; i < 3; i++) {
dead.push(Math.round(Math.random() * totalCols));
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
h1 { padding: 50px 200px; border: 3px dotted gray; }
h1.drag { background: #123456; cursor: grabbing;}
</style>
@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;
@Munter
Munter / fs.write.js
Created July 23, 2016 19:42
What is the expected console output of the following?
var fs = require('fs');
fs.open('hello-world.txt', 'ax', function (err, fd) {
if (err) {
console.error(err);
}
fs.write(fd, new Buffer('hello world'), function (err) {
if (err) {
console.log('manual', 'noooo');
 ⚠ file:///home/munter/git/epik/dist/lib/components/requirejs/require.js: ENOENT, open '/home/munter/git/epik/dist/lib/components/requirejs/require.js'
Including assets:
file:///home/munter/git/epik/dist/example/index.html
file:///home/munter/git/epik/dist/example/router.html

 ⚠ file:///home/munter/git/epik/dist/lib/components/requirejs/require.js: ENOENT, open '/home/munter/git/epik/dist/lib/components/requirejs/require.js'
Including assets:
file:///home/munter/git/epik/dist/example/index.html
file:///home/munter/git/epik/dist/example/router.html

@Munter
Munter / falconeers.less
Created July 19, 2013 08:45
This gist shows the development less file of Falcon Social. Profile images are individual images, which are anotated to be sprited in the production build post process. [See the resulting image here](http://global.falconsocial.com/static/69ab1fb324.png). This gives you the power to use images in different modules across the application without h…
.falconeer-profile {
.profile {
margin-top: 8px;
width: 92px;
height: 92px;
background-repeat: none;
}
&#ulrik {
.profile { background-image: url(/images/falconeers/Ulrik-side.png?sprite=falconeers); }
@Munter
Munter / .jshintrc
Created June 4, 2013 10:31
jshint configuration
{
// JSHint Default Configuration File (as on JSHint website)
// See http://jshint.com/docs/ for more details
"maxerr" : 50, // {int} Maximum error before stopping
// Enforcing
"bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.)
"camelcase" : false, // true: Identifiers must be in camelCase
"curly" : true, // true: Require {} for every new block or scope