Skip to content

Instantly share code, notes, and snippets.

View alessioalex's full-sized avatar

Alexandru Vlăduţu alessioalex

View GitHub Profile
@rf
rf / convert.js
Last active May 20, 2016 18:15
Symbolicate linux perf output of a node program using the v8 log
var fs = require('fs');
var infile = process.argv[2];
if (!infile) return console.log("need infile");
var data = fs.readFileSync(infile, 'utf8').split('\n');
var outlines = [];
data.forEach(function(item) {
@bcks
bcks / brookyln_museum.js
Last active August 29, 2015 14:05
Brooklyn Museum Bot
// runs under Node.js
var fs = require('fs'),
request = require('request'),
Twitter = require('node-twitter');
var twitterRestClient = new Twitter.RestClient(
'CONSUMER_KEY',
'CONSUMER_SECRET',
'TOKEN',
@addyosmani
addyosmani / appcache-tooling.md
Last active August 29, 2015 14:05
AppCache manifest generation tooling

Tools that read through a directory, stream or tree and create an Application Cache manifest for you.

AppCache is still a douche but luckily there are tools available to take the pain out of generating your initial manifest files:

  • Grunt: grunt-manifest is currently the de facto option, but the project lead is looking for a new maintainer. In light of that grunt-appcache is an alternative in case you're looking for more active support.
  • Gulp: gulp-manifest is inspired by grunt-manifest and has a similar set of options.
  • Broccoli: broccoli-manifest brings manifest file compilation based on trees.

Do review what is generated. As with any automation tooling, be careful that what is being generated is what you actually intend on being cached. I generally rel

@Raynos
Raynos / open-handles.js
Last active August 29, 2015 14:02
What keeps my process open?
var setInterval = require('timers').setInterval;
setInterval(function () {
var handles = process._getActiveHandles();
console.log('no of handles', handles.length);
handles.forEach(function (obj) {
if ('ontimeout' in obj) {
console.log('timer handle', obj);
} else if ('readable' in obj && 'writable' in obj) {
@remy
remy / vat.md
Last active September 14, 2015 14:15
Testing logic for when VAT is applied

VAT Rules

Capture:

  • COUNTRY
  • VAT (optional and validated)
IF country IS "GB"
  ADD_VAT
IF country IS IN (eu) AND vat IS EMPTY
var $ = require('NodObjC');
$.import('Cocoa');
var installNSBundleHook = function() {
var cls = $.NSBundle;
if (cls) {
var bundleIdentifier = cls.getInstanceMethod('bundleIdentifier');
bundleIdentifier.setImplementation(function(val) {
var levelup = require('levelup');
var db = levelup('riak://localhost:8087/somebucket', { db: require('riakdown'), valueEncoding: 'json'});
var multilevel = require('multilevel');
var net = require('net');
net.createServer(function (con) {
con.pipe(multilevel.server(db)).pipe(con);
}).listen(3000);
@pgte
pgte / personalized_sync_arch.md
Last active August 29, 2015 14:00
personalized sync

Personalized Sync

The goal is for each client to have a local personalized copy of the database. This personal local database is a subset of all the existing documents. Clients can share documents or not.

Authenticated session and filters

Each client intiates an authenticated session with the server. On each session, server sets up personalized read and write filters. These filters only propagate changes that the user is allowed / interested in.

@anasnakawa
anasnakawa / constant.js
Last active August 29, 2015 14:00
mocking constant behaviour using `Object.defineProperty`, works on real browsers & IE9+
/**
* simulating constant behaviour where
* given value cannot be changed
*
* @param {object} target object where the constant will be defined
* @param {string} key
* @param {object} value
* @return {object} constant
*
* example