Skip to content

Instantly share code, notes, and snippets.

Avatar

Róbert Oroszi oroce

  • vernsurance
  • Budapest, Hungary
View GitHub Profile
@oroce
oroce / client-production.js
Created Jan 29, 2014
just a dummy browserify transform to clean up configuration
View client-production.js
module.exports = {
"foo": process.env.FOO ? process.env.FOO : "bar"
};
View statsd-forwarder.js
// default behaviour is statsdClient.set
godot.reactor()
.statsd()
// this will emit statsdClient.timer
godot.reactor()
.tagged( 'timer' )
.statsd({ type: 'timer' })
// this will emit statsdClient.inc or stasdClient.decr
@oroce
oroce / atob(base64).json
Created Feb 11, 2014
mixpanel.people.set list bug
View atob(base64).json
{
"$set": {
"$os": "Mac OS X",
"$browser": "Chrome",
"$initial_referrer": "$direct",
"$initial_referring_domain": "$direct",
"Test Values": [
"foo",
"bar",
"foobar"
@oroce
oroce / npm install
Created Feb 15, 2014
using riak backed npm
View npm install
npm --registry http://registry.oroszi.net:8008/riak/docs install debug
@oroce
oroce / test.js
Created Feb 19, 2014
dummy example of mocking
View test.js
describe(function(){
afterEach(function(){
removeMock( mysqlConnection, "query" );
});
it( "should return error because user doesnt exist", function(){
mock( mysqlConnection, "query", function( sql, params, cb ){
( cb||params )( null, [] );
});
@oroce
oroce / express.js
Created Feb 21, 2014
singleton-storage sync version
View express.js
var storage = require("./singleton-storage");
app.get("/data", function( req, res ){
var key = "key1";
var data = storage.get(key);
res.json(data); // data is {"foo":"bar"}
});
View load-async.js
var http = require("http");
var express = require("express");
var app = express();
var server = http.createServer(app);
var startServer = function(err){
if( err ){
console.log("wont start server due error", err );
throw err;
}
server.listen(3000,function( err ){
View transform-with-pause.js
var util = require('util');
var Transform = require('stream').Transform;
var MyTransformKlass = function(){
Transform.apply(this,arguments);
this.pause();
setTimeout(function imAsync(){
this.resume();
}.bind(this), 30000);
};
@oroce
oroce / grunt-task.js
Created Mar 7, 2014
upload files from your grunt to nginx without backend or upstream
View grunt-task.js
grunt.registerMultiTask("upload", function(){
var async = require("async");
var request = require("request");
var path = require("path");
var fs = require("fs");
var done = this.async();
var files = [];
var url = this.data.url;
var fns = [];
@oroce
oroce / baseview.js
Last active Aug 29, 2015
event delegation in backbone
View baseview.js
var Backbone = require('backbone');
var _ = require('underscore');
// original: https://github.com/jashkenas/backbone/blob/master/backbone.js#L1037
var delegateEventSplitter = /^(\S+)\s*(.*)$/;
var BaseView = Backbone.View.extend({
// original: https://github.com/jashkenas/backbone/blob/master/backbone.js#L1112
delegateEvents: function(events){
if (!(events || (events = _.result(this, 'events')))) return this;