Skip to content

Instantly share code, notes, and snippets.

@itayw
itayw / authors.js
Created October 31, 2013 15:15
nodejs script to create AUTHORS.md
var
fs = require('fs'),
spawn = require('child_process').spawn,
git = spawn('git', ["log", "--format='%aN##<%aE>'"]);
var exclusions = ['<chef@bitdeli.com>'];
var buffer = '';
git.stdout.on('data', function (data) {
buffer += data;
@itayw
itayw / out.js
Created October 31, 2013 17:20
nodejs - simple write to file
var fs = require('fs');
fs.writeFile("/tmp/test", "Hey there!", function(err) {
if(err) {
console.log(err);
} else {
console.log("The file was saved!");
}
});
@itayw
itayw / bitdeli.md
Created October 31, 2013 17:34
A sample bitdeli tag syntax

Bitdeli Badge

@itayw
itayw / hook.js
Last active December 27, 2015 09:19
hook object functions and measure times
//Simple prototype modifier to add console.time measure
// whenever a function is called.
//The hook will ignore any function starting with _ as treat
// as private.
Object.prototype.hookEvents = function (modifier) {
var obj = this;
var name, fn;
for (name in obj) {
@itayw
itayw / test.js
Created November 13, 2013 10:22
Check relative paths
var path = require('path');
var x = 'c:\\';
var y = 'C:\\joola.io\\joola.io.config\\config'
console.log(x, y);
console.log(path.resolve(x));
if (path.resolve(x) == path.join(__dirname, x))
@itayw
itayw / license
Created November 19, 2013 12:01
Default licensing on new JS files
/**
* joola.io
*
* Copyright Joola Smart Solutions, Ltd. <info@joo.la>
*
* Licensed under GNU General Public License 3.0 or later.
* Some rights reserved. See LICENSE, AUTHORS.
*
* @license GPL-3.0+ <http://spdx.org/licenses/GPL-3.0+>
*/
@itayw
itayw / head.html
Created November 20, 2013 13:35 — forked from juliangruber/head.html
requirebin sketch
<style type='text/css'> html, body { margin: 0; padding: 0; border: 0; } </style>
@itayw
itayw / gist:7566317
Created November 20, 2013 16:35
nconf-redis issue with null JSON values
var
nconf = require('nconf');
require('nconf-redis');
var options = {
host:'localhost',
port:80,
method:'GET'
}
var net = require('net')
var sock = net.connect(1337)
process.stdin.pipe(sock)
sock.pipe(process.stdout)
sock.on('connect', function () {
process.stdin.resume();
process.stdin.setRawMode(true)
@itayw
itayw / gist:7657175
Created November 26, 2013 11:53
increase fs watcher limit for webstorm
For an intelligent IDE it is essential to be in the know about any external changes in files it working with - e.g. changes made by VCS, or build tools, or code generators etc. For that reason, IntelliJ platform spins background process to monitor such changes. The method it uses is platform-specific; and on Linux it is Inotify facility.
Inotify requires a "watch handle" to be set for each directory in the project. Unfortunately, the default limit of watch handles may not be enough for reasonably sized projects, and reaching the limit will force IntelliJ platform to fall back to recursive scans of directory trees.
To prevent this situation it is recommended to increase the watches limit (to, say, 512K). You can do it by adding following line to the /etc/sysctl.conf file:
fs.inotify.max_user_watches = 524288
Then run this command to apply the change:
sudo sysctl -p