Skip to content

Instantly share code, notes, and snippets.

View strootman's full-sized avatar
🤘

Jonathan D Strootman strootman

🤘
View GitHub Profile
@strootman
strootman / git-log2json.sh
Created October 12, 2017 22:11 — forked from textarcana/git-log2json.sh
Convert Git logs to JSON. The first script (git-log2json.sh) is all you need, the other two files contain only optional bonus features :) UPDATED 2017: Today I would just use https://github.com/tarmstrong/git2json
#!/usr/bin/env bash
# Use this one-liner to produce a JSON literal from the Git log:
git log \
--pretty=format:'{%n "commit": "%H",%n "author": "%aN <%aE>",%n "date": "%ad",%n "message": "%f"%n},' \
$@ | \
perl -pe 'BEGIN{print "["}; END{print "]\n"}' | \
perl -pe 's/},]/}]/'
@strootman
strootman / etc-nginx-nginx.conf
Created April 18, 2017 22:40 — forked from aaronfeng/etc-nginx-nginx.conf
nginx json log format
# /etc/nginx/nginx.conf
log_format main '{'
'"remote_addr": "$remote_addr",'
'"remote_user": "$remote_user",'
'"time_local": "$time_local",'
'"request": "$request",'
'"status": "$status",'
'"body_bytes_sent": "$body_bytes_sent",'
'"http_referer": "$http_referer",'
@strootman
strootman / gist:90ee221198c71dfad34f6abb15ed837a
Created April 10, 2017 20:46 — forked from lukas-vlcek/gist:5143799
Adding a new analyzer into existing index in Elasticsearch (requires close/open the index). Tested with Elasticsearch 0.19.12.
// create an index with an analyzer "myindex"
curl -X PUT localhost:9200/myindex -d '
{
"settings" : {`
"index":{
"number_of_replicas":0,
"number_of_shards":1,
"analysis":{
"analyzer":{
"first":{
@strootman
strootman / elasticsearch.md
Created April 10, 2017 20:44 — forked from nicolashery/elasticsearch.md
Elasticsearch: updating the mappings and settings of an existing index

Elasticsearch: updating the mappings and settings of an existing index

Note: This was written using elasticsearch 0.9.

Elasticsearch will automatically create an index (with basic settings and mappings) for you if you post a first document:

$ curl -X POST 'http://localhost:9200/thegame/weapons/1' -d \
'{
  "_id": 1,
@strootman
strootman / default-w-var-sub.yml
Created July 22, 2016 21:37
Example of using the `default()` jinja filter with a variable
# 1.
# $ ansible-playbook default-w-var-sub.yml
#
# PLAY [Test default variable using substitution] ********************************
#
@strootman
strootman / pr.md
Created March 30, 2016 17:19 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@strootman
strootman / journal.go
Created March 3, 2016 02:11 — forked from stuart-warren/journal.go
Golang read from systemd journal
package journal
// #cgo pkg-config: --cflags --libs libsystemd-journal
// #include <systemd/sd-journal.h>
import (
"C"
)
func New() (j *C.struct_sd_journal) {
j = new(C.struct_sd_journal)
@strootman
strootman / groups_for_hosts.txt.j2
Created November 24, 2015 19:31
A means of determining which inventory groups are associated with a given host
{{inventory_hostname}}
========================
{% for group in group_names %}
{{ group }}
{% endfor %}
---
@strootman
strootman / dump_all_vars.yaml
Created November 24, 2015 19:27
A way to dump all the vars for a host. Must be used with `--limit`, otherwise, last host wins.
---
- name: Dump all vars
hosts: all
tasks:
- name: Dump all vars
template: src=scripts/dump_vars.j2 dest=/tmp/ansible.all
@strootman
strootman / pre-push
Last active May 20, 2019 03:41 — forked from chadmaughan/pre-commit.sh
A pre-push git hook which runs a gradle test task
#!/bin/sh
# this hook is in SCM so that it can be shared
# to install it, create a symbolic link in the projects .git/hooks folder
#
# i.e. - from the .git/hooks directory, run
# $ ln -s ../../git-hooks/pre-commit.sh pre-commit
#
# to skip the tests, run with the --no-verify argument
# i.e. - $ 'git commit --no-verify'