Skip to content

Instantly share code, notes, and snippets.

View asbjornenge's full-sized avatar
Swinging madly across the sun.

Asbjorn Enge asbjornenge

Swinging madly across the sun.
View GitHub Profile
@aslansky
aslansky / gist:8741515
Created January 31, 2014 19:44
gulp livereload (gulp 3.5.0)
var gulp = require('gulp');
var gutil = require('gulp-util');
var sass = require('gulp-sass');
var lr = require('tiny-lr');
var http = require('http');
var path = require('path');
var ecstatic = require('ecstatic');
var tlr = lr();
var livereload = function (evt, filepath) {
tlr.changed({
@asbjornenge
asbjornenge / reactTestQueryUtil.js
Last active August 29, 2015 14:05
React test utils wrapper
var React = require('react')
var ReactAddons = require('react/addons')
var ReactTestUtils = React.addons.TestUtils
var reactTestQueryUtil = function (tree) {
this.tree = tree
}
reactTestQueryUtil.prototype.class = function (cls) {
this.class = cls
return this
@asbjornenge
asbjornenge / Router.js
Created February 20, 2015 22:44
Tiny React Router
import React from 'react'
import assign from 'react/lib/Object.assign'
import Route from 'route-parser'
export default class Router extends React.Component {
constructor(props) {
super(props)
let routes = Object.keys(this.props.routes).map((route) => {
return { route : new Route(route), handler : this.props.routes[route] }
})
@asbjornenge
asbjornenge / nanodom.js
Last active December 31, 2015 22:29
Nanodom.js - a very small dom manipulation library.
define([], function() {
function dom() {}
dom.prototype = new Array;
dom.prototype.append = function(element) { element.map(function(e) { this[0].appendChild(e) }.bind(this)); return this}
dom.prototype.remove = function() { this.map(function(e) {e.parentNode.removeChild(e)}); return this}
dom.prototype.prepend = function(element) { element.map(function(e) { this[0].insertBefore(e, this[0].childNodes[0]) }.bind(this)); return this}
dom.prototype.empty = function(elements) { this.map(function(e) { e.innerHTML = ""}); return this}
dom.prototype.addClass = function(classes) { this.map(function(e) { e.className += ' '+classes}); return this}
dom.prototype.removeClass = function(classes) {
@juliangruber
juliangruber / extend.plist
Created May 30, 2016 20:30
Here is how to accept custom protocol links like dat://LINK in an @electronjs app, in osx. For this to work you need to properly package the app into a `.app`, and place the CFBundleURLTypes spec into it's Info.plist. Then, move the app into another directory using Finder (!). Here we're using electron-packager.
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>Dat Link</string>
<key>CFBundleURLSchemes</key>
<array>
<string>dat</string>
</array>
</dict>
@theanalyst
theanalyst / fibs.c
Last active November 23, 2018 14:02
Hy, Python & C play nicely with each other
#include "fibs.h"
long fib(int n)
{
if (n == 0)
return 1;
else if (n == 1)
return 1;
else
return fib(n-1) + fib(n-2);
@jpetazzo
jpetazzo / README.md
Last active August 21, 2019 17:55
Give network superpowers to docker

Unionize: network superpowers for your docker containers

Unionize lets you connect together docker containers in arbitrarily complex scenarios.

Note: I recommend to use https://github.com/jpetazzo/pipework instead.

  • pipework is a better name than unionize
  • it's hosted on a "real" github repo instead of a small gist :-)

Now if you want Unionize, it's still here. Just check those examples.

@dakk
dakk / tezos-baking-howto.md
Last active March 6, 2022 21:22
tezos-baking-howto.md

Tezos baking howto

This howto is valid for Betanet on Ubuntu or Debian

Setup

Prereq

You have to install some dependencies. In debian / ubuntu run:

@bradwright
bradwright / websockets-server.js
Created June 11, 2011 23:29
Pure Node.js WebSockets server
/*
* node-ws - pure Javascript WebSockets server
* Copyright Bradley Wright <brad@intranation.com>
*/
// Use strict compilation rules - we're not animals
'use strict';
var net = require('net'),
crypto = require('crypto');
@nrabinowitz
nrabinowitz / quantize.js
Created July 25, 2011 17:19
Javascript module for color quantization, based on Leptonica
/*!
* quantize.js Copyright 2008 Nick Rabinowitz.
* Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
*/
// fill out a couple protovis dependencies
/*!
* Block below copied from Protovis: http://mbostock.github.com/protovis/
* Copyright 2010 Stanford Visualization Group
* Licensed under the BSD License: http://www.opensource.org/licenses/bsd-license.php