Skip to content

Instantly share code, notes, and snippets.

(use-package gist
:ensure
:bind (("C-c a g l" . gist-list)
("C-c a g b" . gist-buffer)
("C-c a g B" . gist-buffer-private)
("C-c a g r" . gist-region)
("C-c a g R" . gist-region-private)))
@slackorama
slackorama / fun-with-jq.sh
Created May 11, 2016 01:11
Get the master that each node is using
for h in $list_of_es_hosts; do
echo -n "$h ";
curl -s http://$h:9200/_cluster/state/master_node,nodes | \
jq '.master_node as $master | .nodes[$master].name';
done
@slackorama
slackorama / *snippet*.sh
Last active March 18, 2016 02:35
Convert elasticsearch _search results to a table using csvtoolkit.
curl ... | \
jq '[.hits.hits[]._source | {"bucket": .bucketStart,
"rate": .totalBitRate, "cnt": .bitRateCnt}]' | \
in2csv --format=json | \
csvlook
#!/usr/bin/env python
"""es-index-differ.py
Usage:
es-index-differ.py [options] <host>
Options:
-h --help show this
-v --version show version info
import re
board = [[0 for x in xrange(1000)] for x in xrange(1000)]
on_off = re.compile(r'(toggle|turn on|turn off) ([0-9]+),([0-9]+) through ([0-9]+),([0-9]+)')
def count_on(board):
return sum([sum(row) for row in board])
def toggle(v):
#!/usr/bin/env python
"""Grab the books from the current year from goodreads and emit some HTML.
"""
import requests
from xml.dom import minidom
import datetime, time
from email.utils import parsedate
import sys
@slackorama
slackorama / es-fielddata.py
Last active December 23, 2015 17:36
Output top consumers of Elasticsearch fielddata by each node in a CSV format.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""es-fielddata
Usage:
es-fielddata [options]
Options:
-h --help show this
-v --version show version info
export GIT_RADAR_FORMAT="%{$reset_color%} %{$fg[grey]%}git:(%{$reset_color%}%{remote: }%{branch}%{ :local}%{$fg[grey]%})%{$reset_color%}%{ :changes}"
@slackorama
slackorama / gh-starred-pinboard.py
Last active January 8, 2019 19:00
Make Github starred repos bookmarks in pinboard. I wish IFTTT did this.
#!/usr/bin/env python
# send github starred repos to pinboard
# Get the token here:
# https://api.pinboard.in/v1/user/api_token/info
from __future__ import print_function
import sys
// ==UserScript==
// @name TidyBZ2
// @namespace http://www.sethmason.com/userscripts
// @description Provide some keyboard shortcuts and clean up the interface for
// bugzilla2 version of bugzilla.
// @include https://*/show_bug.cgi?id=*
// @include https://*process_bug.cgi*
// @author Seth Mason
// @version 0.1
// @license Creative Commons public domain (http://creativecommons.org/licenses/publicdomain/)