Skip to content

Instantly share code, notes, and snippets.

In order to keep this easy to navigate, it is asked that you squash your commits down to a few, or one, discreet changesets before submitting a pull request. Fixing a bug will usually only need one commit, while a larger feature might contain a couple of separate improvements that is easier to track through different commits.

Once you have rebased your work on top of the latest state of the upstream master, you may have several commits related to the issue you were working on. Once everything is done, squash them into a single commit with a descriptive message, like "Issue #100: Retweet bugfix."

To squash four commits into one, do the following:

$ git rebase -i HEAD~4

In the text editor that comes up, replace the words "pick" with "squash" next to the commits you want to squash into the commit before it. Save and close the editor, and git will combine the "squash"'ed commits with the one before it. Git will then give you the opportunity to change your commit message to something like, "Issue #100: Fixed r

@davidrapin
davidrapin / neo4js.js
Created November 26, 2015 16:25
Start/stop/status on multiple Neo4j instances
/**
* Start, stop or get the status of all Neo4j installations in current folder.
*
* Usage:
* >node neo4js status
* >node neo4js start
* >node neo4js stop
* Author: David Rapin
* Date: 2015-11-26.
* licence: MIT
@davidrapin
davidrapin / test.js
Created July 21, 2015 23:10
check rawmode switch
'use strict';
var state = false;
function readbin(_state) {
if (_state === state) {
console.log('not changing state (' + state + ')');
return;
}
console.log('changing state (' + _state + ')');
@davidrapin
davidrapin / spawn-enoent.js
Created July 7, 2015 13:35
Diagnose "node spawn ENOENT"
(function() {
var childProcess = require("child_process");
var oldSpawn = childProcess.spawn;
function mySpawn() {
console.log('spawn called');
console.log(arguments);
return oldSpawn.apply(this, arguments);
}
childProcess.spawn = mySpawn;
})();
@davidrapin
davidrapin / jsonError.js
Last active April 18, 2024 19:16
Extract a detailed JSON parse error (with line and column) in nodejs
'use strict';
var clarinet = require('clarinet');
/**
* Extract a detailed JSON parse error
* using https://github.com/dscape/clarinet
*
* @param {string} json
* @returns {{snippet:string, message:string, line:number, column:number, position:number}} or undefined if no error
*/
@davidrapin
davidrapin / call-info.js
Last active January 20, 2025 09:09
Wrap all functions of an Object for call info statistic (number of calls, sync time, promises time)
/**
* Usage:
* var dataServiceInfo = wrapForCallInfo(require('../services/data').prototype);
* process.on('exit', function() {
* dataServiceInfo.print('DataService');
* });
*
* @param {Object} toWrap an object (or its prototype) to wrap for call statistics gathering.
* @returns {{print:function, data:Object}}
*/
@davidrapin
davidrapin / .profile
Last active August 29, 2015 14:14
iptables cheat sheet
# show routing (with rule numbers per Chain fortable:"nat")
alias routing='sudo iptables -t nat -L -n -v --line-number'
# open 80 explicitly
# sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
# redirect 80 to 8080
# iptables -t nat -A OUTPUT -o lo -p tcp --dport 80 -j REDIRECT --to-port 8080
# delete a rule (table:"nat", Chain:"OUTPUT" rule:1)
@davidrapin
davidrapin / gist:3073da076e304bfbc357
Created January 23, 2015 19:12
Cypher query: source and target Labels for relationships.
MATCH (a)-[r]->(b)
WHERE type(r) = 'ACTED_IN'
RETURN type(r), labels(a), labels(b)
LIMIT 100
@davidrapin
davidrapin / gist:5b054bc14691c79636e7
Created January 23, 2015 18:35
Install Marvel-Sense for ElasticSearch
bin/plugin -i elasticsearch/marvel/latest
@davidrapin
davidrapin / gist:ff452f05c4e8b5434aa4
Created January 19, 2015 16:16
use installed Git without installing XCode (OSX)
# git is installed under /usr/local/git/bin/
ls -1 /usr/local/git/bin/ |xargs -INAME sudo rm -f /usr/bin/NAME
ls -1 /usr/local/git/bin/ |xargs -INAME sudo ln -s /usr/local/git/bin/NAME /usr/bin/NAME