Skip to content

Instantly share code, notes, and snippets.

View eiriklv's full-sized avatar

Eirik L. Vullum eiriklv

View GitHub Profile
@DarcInc
DarcInc / gist:9641557
Created March 19, 2014 13:25
Node AMQ Message Producer
var queueName = 'tasks';
var exchangeName = 'taskExchange';
var key = 'all';
var amq = require('amq');
var readline = require('readline');
var connection = amq.createConnection(
{ host: 'localhost', debug: true },
{ reconnect: { strategy: 'constant', initial: 1000 } }
@DarcInc
DarcInc / gist:9641582
Last active August 29, 2015 13:57
Node AMQ Message Consumer
var queueName = 'tasks';
var amq = require('amq');
var connection = amq.createConnection(
{ host: 'localhost', debug: true },
{ reconnect: { strategy: 'constant', initial: 1000 } }
);
var queue = connection.queue(queueName, { durable: true });
// browserify
var browserify = require('browserify');
var es6ify = require('es6ify');
// gulp stuff
var gulp = require('gulp');
var livereload = require('gulp-livereload');
var source = require('vinyl-source-stream');
var jshint = require('gulp-jshint');
var livereload = require('gulp-livereload');
var watch = require('gulp-watch');
require 'rubygems'
require 'openssl'
require 'digest/md5'
key = OpenSSL::PKey::RSA.new(2048)
cipher = OpenSSL::Cipher::AES.new(256, :CBC)
ctx = OpenSSL::SSL::SSLContext.new
puts "Spoof must be in DER format and saved as root.cer"
raw = File.read "root.cer"
cert = OpenSSL::X509::Certificate.new raw
cert.version = 2
@brigand
brigand / index.html
Created May 1, 2014 23:16
React Drag and Drop
<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>);
}
@soyuka
soyuka / global.js
Last active August 29, 2015 14:07
Opinion about global wrappers in nodejs
//global variable
test = 'hello';
//is exactly the same as
global.test = 'hello';
//local variable - this will definitly override your global variable
var test = 'hello';
//using the process scope, if, and really if, you can't do without a global variable
var StoreListenerMixin = function(...stores) {
var StoreMixin = {
getInitialState() {
return this.getStateFromStores(this.props);
},
componentDidMount() {
stores.forEach(store => store.addChangeListener(this.handleStoresChanged));
this.setState(this.getStateFromStores(this.props));
@simenbrekken
simenbrekken / README.md
Last active August 29, 2015 14:10
React in the Real World
var React = require('react');
var Ridiculous = React.createClass({
getInitialState () {
console.log(this.props.name, 'getInitialState');
return { foo: true };
},
render () {
console.log(this.props.name, 'render');
@aulizko
aulizko / server.es6.js
Last active September 8, 2015 08:21
SSR with react-router@1.0.0-beta4
// That variant actually works with 1.0.0-beta4
// Link to the previous (1.0.0-beta3) version:
// https://github.com/cdebotton/react-universal/blob/master/src/server.js#L49
import createLocation from 'history/lib/createLocation';
import createHistory from 'history/lib/createMemoryHistory';
import ReactDOM from 'react-dom/server';
import {Router} from 'react-router';
import Layout from './views/Layout';
import Application from './containers/Application';