Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
# Aside from removing Ruby on Rails specific code this is taken verbatim from
# mislav's git-deploy (http://github.com/mislav/git-deploy) and it's awesome
# - Ryan Florence (http://ryanflorence.com)
#
# Install this hook to a remote repository with a working tree, when you push
# to it, this hook will reset the head so the files are updated
if ENV['GIT_DIR'] == '.'
@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;
@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
@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
@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": "..."
@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
@hofmannsven
hofmannsven / README.md
Last active November 10, 2024 13:48
Git CLI Cheatsheet
@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);
@branneman
branneman / better-nodejs-require-paths.md
Last active October 18, 2024 20:29
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

@niksumeiko
niksumeiko / git.migrate
Last active November 10, 2024 18:26
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.