Skip to content

Instantly share code, notes, and snippets.

@toreholmberg
toreholmberg / gulpfile.babel.js
Last active May 25, 2016 16:24
Gulp 4 + ES2015
import gulp, { src, dest, parallel, series } from 'gulp';
import del from 'del';
import sourcemaps from 'gulp-sourcemaps';
import postcss from 'gulp-postcss';
import cssnext from 'cssnext';
import atImport from 'postcss-import';
import precss from 'precss';
import watchify from 'watchify';
import browserify from 'browserify';
import source from 'vinyl-source-stream';
var gulp = require('gulp'),
changed = require('gulp-changed'),
plumber = require('gulp-plumber'),
postcss = require('gulp-postcss'),
cssnext = require('cssnext'),
precss = require('precss'),
template = require('gulp-template'),
babel = require('gulp-babel'),
del = require('del'),
runSequence = require('run-sequence'),
@toreholmberg
toreholmberg / gist:824e446cc29646c8dcdf
Created February 20, 2015 21:54
Deferred image load
(function(window, document) {
'use strict';
function process() {
var els = document.querySelectorAll('[data-def-src], [data-def-bg], [data-def-srcset]'),
len = els.length;
for (var i = 0; i < len; i++) {
@toreholmberg
toreholmberg / gist:5398bcd6a33b97e8bd1d
Last active August 29, 2015 14:07
clockwork start
RAILS_ENV=production /usr/local/rvm/bin/app_clockwork /srv/www/SITE/current/clock.rb -e production >> /srv/www/SITE/shared/log/clockwork.log 2>&1 &
@toreholmberg
toreholmberg / gist:e18eac943a0c81f4e9d9
Created September 4, 2014 18:00
unicorn rvm upstart
description "Unicorn app"
author "Tore Holmberg <[email protected]>"
start on virtual-filesystems
stop on runlevel [06]
pre-start script
export HOME="/srv/www/nginx/app/current"
cd $HOME
exec sudo -u deploy /usr/local/rvm/bin/app_unicorn_rails -c /srv/www/nginx/app/current/config/unicorn_production.rb -E production -D
@toreholmberg
toreholmberg / gist:9514721
Created March 12, 2014 19:42
OS X gem install libv8
gem install libv8 -v 3.11.8.13 -- --with-system-v8
@toreholmberg
toreholmberg / gist:9243025
Created February 27, 2014 02:18
git checkout all branches
for remote in `git branch -r | grep -v master `; do git checkout --track $remote ; done
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
// usage
$('selector').click(__bind(this.handler, this));
// or
this.handler = __bind(this.handler, this);
$('selector').click(this.handler, this);
<script type='text/javascript'>
//<![CDATA[
var d = ['wii', '3ds', 'dsi'];
var l = d.length;
for(var i = 0; i < l; i++) {
if (navigator.userAgent.toLowerCase().indexOf(d[i]) > -1)
location.href = 'wii'; // url
}
//]]>
</script>