Skip to content

Instantly share code, notes, and snippets.

@badsyntax
badsyntax / terst.js
Created December 19, 2014 10:39
Modernizr test for IE11 min-height flex-grow bug
// Test whether flex-grow will work on elements whose parents
// have min-height set. IE11 does not pass this test.
(function testMinheightflexgrow(Modernizr) {
Modernizr.testStyles([
'#modernizr{display:flex;min-height:10px;}',
'#modernizr :first-child{flex-grow:1;}'
].join(''), function(elem, rule) {
Modernizr.addTest('minheightflexgrow', elem.firstElementChild.offsetHeight === 10);
}, 2);
}(window.Modernizr));
.fix {
padding: rem(10px) $gutterMargin;
// We revert to using content-box and calc() as IE11 will ignore the border-box
// box model when calculating the flex-basis width.
box-sizing: content-box;
@include flex-basis(calc(33.3333% - (#{$gutterMargin} * 2)));
}
padding: rem(10px) $gutterMargin;
// We revert to using content-box and calc() as IE11 will ignore border-box when
// calculating the flex-basis width.
box-sizing: content-box;
@include flex-basis(calc(33.3333% - (#{$gutterMargin} * 2)));
@badsyntax
badsyntax / haproxy.1.cfg
Last active September 19, 2022 09:38
Some example haproxy configs
# SSL termination at proxy
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
@badsyntax
badsyntax / supervisord.conf
Created October 27, 2014 09:56
Set stopasgroup to true to tell supervisor to send the stop signal to the whole process group to prevent orphaned processes when starting/stopping supervisord. This is required when running npm scripts from supervisor.
[program:node-server]
directory=/var/www
command=/usr/bin/npm start
stopasgroup=true
autostart=true
autorestart=true
[program:node-watch]
directory=/var/www
command=/usr/bin/npm run watch
#!/usr/bin/env bash
i=0;
for file in *.jpg
do
((i++))
# Resize
convert $file -resize 588x452\! resized/`basename $file`
# Overlay an index number
convert resized/`basename $file` -pointsize 50 -fill white -undercolor '#00000080' -gravity North -annotate +0+10 $i resized/`basename $file`
@badsyntax
badsyntax / index.md
Created September 1, 2014 08:38 — forked from mathisonian/index.md

demo gif

The final result: require() any module on npm in your browser console with browserify

This article is written to explain how the above gif works in the chrome (and other) browser consoles. A quick disclaimer: this whole thing is a huge hack, it shouldn't be used for anything seriously, and there are probably much better ways of accomplishing the same.

inspiration

My inspiration for building this was Max Ogden's Requirebin, which allows users to use a browser based editor to run custom javascript in the browser (including javascript that had require() statements that would normally need to be pre-processed using browserify).

{
"directory": "assets/components"
}
@badsyntax
badsyntax / install.js
Created May 15, 2014 08:37
Bower install does not use .bowerrc in cwd.
var bower = require('bower');
var path = require('path');
var cwd = path.resolve(__dirname, 'project');
bower.commands.install([], {}, {
cwd: cwd
})
.on('log', function(result) {
console.log(result.id, result.message);