Skip to content

Instantly share code, notes, and snippets.

View eiriklv's full-sized avatar
🤒
Out sick - I may be slow to respond.

Eirik L. Vullum eiriklv

🤒
Out sick - I may be slow to respond.
View GitHub Profile
<html>
<head>
<title>Test</title>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://fb.me/react-0.5.1.js"></script>
<script src="http://fb.me/JSXTransformer-0.5.1.js"></script>
</head>
<div id="main"/>
<script type="text/jsx">
/** @jsx React.DOM */
var DragItem = React.createClass({
drag: function(ev) {
ev.dataTransfer.setData("draggedItem", JSON.stringify(this.props.item));
},
render: function () {
return (<div draggable="true" onDragStart={this.drag} className="item">{this.props.item.text}</div>);
}
@eiriklv
eiriklv / cors.js
Created September 9, 2014 11:17
Express allow CORS
module.exports.allowCORS = function(app) {
var allowCrossDomain = function(req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization');
if ('OPTIONS' == req.method) {
res.send(200);
} else {
next();
@eiriklv
eiriklv / combinator.js
Created September 9, 2014 22:35
Create all possible combinations from a dictionary
// create combination from a dictionary
function combination(dictionary, length, depth, input, output) {
// check if this is the original call and instantiate the helpers
if (!depth) {
output = [];
input = '';
depth = 0;
}
// loop through the dictionary to create combinations
@eiriklv
eiriklv / rAF.js
Last active August 29, 2015 14:06 — forked from paulirish/rAF.js
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
@eiriklv
eiriklv / emitter.js
Last active August 29, 2015 14:06 — forked from brentertz/emitter.js
var util = require('util'),
EventEmitter = require('events').EventEmitter;
var Server = function() {
var self = this;
this.on('custom_event', function() {
self.logSomething('custom_event');
});
@eiriklv
eiriklv / emitter.js
Last active August 29, 2015 14:06 — forked from brentertz/emitter.js
var util = require('util'),
EventEmitter = require('events').EventEmitter;
var Server = function() {
var self = this;
this.on('custom_event', function() {
self.logSomething('custom_event');
});

How to set up Gulp with an ExpressionEngine project

I freaking love working with technologies like Grunt and Gulp, and wanted to share how to get my current EE front-end workflow set up. With a few tweaks, this can also be used with virtually any other sites (I've used it with Laravel, static sites, Craft, etc).

Install Node.js

  • If Node is not yet installed on the machine, it will need to be installed

Install Gulp (if needed)

@eiriklv
eiriklv / gist:7d913c6dc6022c0533e0
Last active August 29, 2015 14:06
Conditional sourcemaps for browserify
var browserify = require('browserify');
var gulp = require('gulp');
var handleErrors = require('../util/handle-errors');
var source = require('vinyl-source-stream');
function createSingleBundle(options) {
browserify({
entries: options.input,
extensions: options.extensions
})