Skip to content

Instantly share code, notes, and snippets.

View nukemberg's full-sized avatar

Avishai Ish-Shalom nukemberg

View GitHub Profile
@nukemberg
nukemberg / knife.sh
Created June 28, 2011 07:51 — forked from ches/knife
bash completion for Chef's knife command (updated for 0.10)
# vim: ft=sh:ts=4:sw=4:autoindent:expandtab:
# Author: Avishai Ish-Shalom <avishai@fewbytes.com>
# We need to specify GNU sed for OS X, BSDs, etc.
if [[ "$(uname -s)" == "Darwin" ]]; then
SED=gsed
else
SED=sed
fi
@nukemberg
nukemberg / s3_multicopy.py
Created February 1, 2012 11:44
s3 multithreaded bucket copy
#! /usr/bin/python
import threading, Queue
import boto, sys, time
import argparse
import logging
parser = argparse.ArgumentParser(description="Multithreaded mass copier for Amazon S3")
parser.add_argument("-s", help="Source bucket", dest="src_bucket", type=str, required=True)
parser.add_argument("-d", help="Destination bucket", dest="dst_bucket", type=str, required=True)
@nukemberg
nukemberg / lsb.rb
Last active December 27, 2015 00:09
install lsb-release on debian and reload ohai
unless node["lsb"]["codename"]
execute "apt-get-update-lsb" do
command "apt-get update"
action :nothing
# tip: to suppress this running every time, just use the apt cookbook
not_if do
::File.exists?('/var/lib/apt/periodic/update-success-stamp') &&
::File.mtime('/var/lib/apt/periodic/update-success-stamp') > Time.now - 86400*2
end
end.run_action(:run)
@nukemberg
nukemberg / gist:02c289fb689eb1c58690
Last active August 29, 2015 14:20
workspace prompt for bash
BLUE="34;1m"
ORANGE="33m"
GREEN="32m"
RED="31m"
ROOT_COLOR="31;4m"
ENV_COLOR="$GREEN" # set from puppet or chef, should be RED for prod
function _colorify() {
echo -en "\[\e[$1\]$2\[\e[0m\]"
}
@nukemberg
nukemberg / puppet-template.json
Last active August 29, 2015 14:23
Puppet HTTP report elasticsearch template
{
"template" : "puppet-*",
"mappings" : {
"puppet_report" : {
"_source": {"enabled": true},
"dynamic_date_formats": ["yyyy-MM-dd HH:mm:ss.SSSSSS ZZ"],
"properties" : {
"configuration_version" : {
"type" : "string",
"index": "not_analyzed"
@nukemberg
nukemberg / facter-inventory.json
Created April 7, 2016 23:52
Elasticsearch index template for ELK based facter/puppet inventory
{
"template": "inventory",
"mappings": {
"host": {
"_source": {
"enabled": true,
"excludes" : ["network.interfaces.*.arp", "kernel.pnp_drivers", "kernel.modules"]
},
"dynamic_templates": [
{
@nukemberg
nukemberg / motd-template.erb
Created April 12, 2016 12:47
motd puppet template
<% if @ec2_instance_id -%>
🍻 This is a <%= scope.lookupvar("ec2_instance_type") %>, an EC2 <%= scope.lookupvar("virtual") %> server managed by Puppet.
<% else -%>
🍻 This is a  <%= scope.lookupvar("manufacturer") %> <%= scope.lookupvar("productname") %> server, a  <%= scope.lookupvar("virtual") %> server managed by Puppet.
<% end -%>
Hostname...: <%= scope.lookupvar("fqdn") %>
Environment: <%= scope.lookupvar("environment") %>
Role.......: <%= scope.lookupvar("role") %>
<% if @ec2_security_groups -%>SecurityGrp: <%= scope.lookupvar("ec2_security_groups") %><% end %>
@nukemberg
nukemberg / conway.clj
Last active December 29, 2016 22:27
Conway's Game of Life in Clojure
(ns conway.core
(:require [clojure.set :refer [intersection]]))
(defn neighbours [[x y]]
(for [i [-1 0 1] j [-1 0 1] :when (not= i j 0)]
[(x + i) (y + j)]))
(defn alive-next-gen [board cell]
(let [alive-neighbours (intersection board (neighbours cell))
@nukemberg
nukemberg / deezer2gmusic.py
Created January 20, 2017 00:03
Deezer playlist export -> Google Music import
#!/usr/bin/env python3
from gmusicapi.clients import Mobileclient
import click
import requests
import re
from itertools import tee, filterfalse
from pprint import pprint
from concurrent.futures import ThreadPoolExecutor
@nukemberg
nukemberg / README.md
Last active August 28, 2019 08:02
elasticsearch index template for logs

Logs index template for Elasticsearch

Mapping templates

Dynamic mapping templates have been defined for various field usage. Select the correct mapping for your field by prepending the specified prefix.

Example: a field named text_message will by mapped as an analyzed string field, a field named ni_request_tag will not be indexed.

The default mapping template for string fields is keyword.

In many cases you might want to modify the prefixes to match the current naming scheme in your code. e.g. I frequently change ID_* to *Id to accomodate field names like requestId. In typed languages like Java/Scala you could have the serializer emit fields with appropriate prefixes for you.