Skip to content

Instantly share code, notes, and snippets.

@trevnorris
trevnorris / perf-flame-graph-notes.md
Last active December 24, 2023 05:25
Quick steps of how to create a flame graph using perf

The prep-script.sh will setup the latest Node and install the latest perf version on your Linux box.

When you want to generate the flame graph, run the following (folder locations taken from install script):

sudo sysctl kernel.kptr_restrict=0
# May also have to do the following:
# (additional reading http://unix.stackexchange.com/questions/14227/do-i-need-root-admin-permissions-to-run-userspace-perf-tool-perf-events-ar )
sudo sysctl kernel.perf_event_paranoid=0
@niksumeiko
niksumeiko / git.migrate
Last active May 31, 2024 21:18
Moving git repository and all its branches, tags to a new remote repository keeping commits history
#!/bin/bash
# Sometimes you need to move your existing git repository
# to a new remote repository (/new remote origin).
# Here are a simple and quick steps that does exactly this.
#
# Let's assume we call "old repo" the repository you wish
# to move, and "new repo" the one you wish to move to.
#
### Step 1. Make sure you have a local copy of all "old repo"
### branches and tags.
@branneman
branneman / better-nodejs-require-paths.md
Last active April 27, 2024 04:16
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@bryanmacfarlane
bryanmacfarlane / messagequeue.js
Last active July 28, 2019 23:23
node.js http long polling server. using a messaging as an example of longpoll usage.
//
// Crude node.js longpoll example via a simple message queue
//
//--------------------
// app.js
//--------------------
var queue = require('./queue/messagequeue');
app.get('/messages/:queueName/:lastMsgId', queue.getMessages);
app.post('/messages/:queueName', queue.postMessages);
@hofmannsven
hofmannsven / README.md
Last active June 4, 2024 04:25
Git CLI Cheatsheet
@mathieue
mathieue / do-it.sh
Last active December 22, 2015 02:59
graphite + statsd install with chef-solo
# install chef-solo one line !
curl -L https://www.opscode.com/chef/install.sh | bash
# cookbooks have their rep: check the dir name == cookbook name
mkdir -p /opt/cookbooks
git clone https://github.com/hw-cookbooks/graphite
git clone https://github.com/opscode-cookbooks/apache2.git
git clone https://github.com/opscode-cookbooks/python.git
git clone https://github.com/opscode-cookbooks/runit.git
git clone https://github.com/opscode-cookbooks/memcached.git
@honza
honza / gist.md
Created June 30, 2013 23:03
Clojure vs Haskell

Haskell vs Clojure

The JSON data is in the following format

{
    "Genesis": {
        "1": {
            "1": "In the beginning..." ,
            "2": "..."
@domenic
domenic / promise-retryer.js
Last active September 16, 2023 02:43
Generalized promise retryer
"use strict";
// `f` is assumed to sporadically fail with `TemporaryNetworkError` instances.
// If one of those happens, we want to retry until it doesn't.
// If `f` fails with something else, then we should re-throw: we don't know how to handle that, and it's a
// sign something went wrong. Since `f` is a good promise-returning function, it only ever fulfills or rejects;
// it has no synchronous behavior (e.g. throwing).
function dontGiveUp(f) {
return f().then(
undefined, // pass through success
@DoubleBrotherProgrammer
DoubleBrotherProgrammer / FindColumnInDatabase.sql
Created August 8, 2011 18:15
Find column across all SQL Server databases
/* Find column in all databases */
DECLARE @db_name varchar(100),
@col_name varchar(100),
@sql_statement nvarchar(MAX)
-- column you are looking for
SET @col_name = 'PLANNED_SAMPLE_ID'
-- fill cursor with database names
@magiconair
magiconair / node-long-poll-1.js
Created February 1, 2011 15:27
Long polling server skeleton
/**
* Module import
*/
var express = require('express');
/**
* Port the server listens on
*/
var port = 3000;