Skip to content

Instantly share code, notes, and snippets.

@spalger
spalger / git-restage
Last active August 29, 2015 13:56
Re-stages a staged file (courtesy of @esvinson)
gitFiles=$(git status --porcelain | grep "^[ADM\?][AMD] " | sed -e "s|^[ADM\?][AMD] ||")
if [[ -n "${gitFiles}" ]] ; then
for fname in $gitFiles ; do
git add --all -- "${fname}"
echo "Restaging ${fname}"
done
else
echo "No files changed"
fi
@spalger
spalger / scratch.js
Created March 14, 2014 15:33
Modified reproduction for elastic/elasticsearch-js#54, modified to comply with jshint and reports progress and success.
var elasticsearch = require('./src/elasticsearch');
var async = require('async');
var _ = require('lodash-node');
var client = new elasticsearch.Client({
host: 'localhost:9200'
});
async.eachSeries(_.range(100), function (value, done) {
async.eachSeries(_.range(500), function (value, done) {
client.create({ index: 'tests', type: 'test', body: {something: true, value: value} }, done);
@spalger
spalger / only_client_nodes.js
Last active August 29, 2015 13:58
nodesToHostCallback for the elasticsearch.js client that filters out nodes which are not in "client" mode.
var elasticsearch = require('elasticsearch');
var baseNodesToHostCallback = require('elasticsearch/src/lib/nodes_to_host');
var client = new elasticsearch.Client({
/* host seed list */
hosts: [ ... ],
// sniff every 5 minutes
sniffInterval: 1000 * 60 * 5,
{
"aggConfig": {
"type": "terms",
"schema": "split",
"params": {
"field": "agent.raw",
"size": 2,
"order": "desc",
"row": true
}
{ "key": "value" }
@spalger
spalger / index.js
Last active October 29, 2015 21:03
requirebin sketch
const url = require('url');
const rison = require('rison');
window.parseRison = function () {
var output = document.getElementById('risonOutput');
var input = document.getElementById('risonInput').value;
var j = function (v) {
return JSON.stringify(v, null, ' ');
};
@spalger
spalger / patch_sonarr.sh
Last active November 14, 2015 21:54
Patch Sonarr static files so that they load properly on iOS, which interestingly loads the templates file for both the runtime and the templates...
#!/usr/bin/env bash
set -e
cd ~/apps/NzbDrone/UI;
all="handlebars.combined.js"
runtime="handlebars.runtime.js"
tmpl="templates.js"
#####
@spalger
spalger / gist:6322190
Created August 23, 2013 18:00
get the branch name in the PS1
parse_git_branch ()
{
if git rev-parse --git-dir >/dev/null 2>&1
then
gitver=$(git branch 2>/dev/null| sed -n '/^\*/s/^\* //p')
else
return 0
fi
echo -e ":$(branch_color)$gitver${c_plain}"
}