Skip to content

Instantly share code, notes, and snippets.

View nukemberg's full-sized avatar

Avishai Ish-Shalom nukemberg

View GitHub Profile
@nukemberg
nukemberg / dyanmodb_reservation_calc.py
Created June 22, 2021 16:24
DynamoDB table WCU/RCU reservation calculator
import boto3
from datetime import datetime
from dateutil.relativedelta import relativedelta
import numpy as np
def get_table_metrics(cloudwatch_client, table_name, start_time, end_time):
response = cloudwatch_client.get_metric_data(
MetricDataQueries=[
{
'Id': 'dynamoDBWCU',
@nukemberg
nukemberg / keybase.md
Last active May 11, 2020 09:00
keybase.md

Keybase proof

I hereby claim:

  • I am nukemberg on github.
  • I am nukemberg (https://keybase.io/nukemberg) on keybase.
  • I have a public key ASBTwRI1eKp5afEkzz0_rQCxL_D53ItY-6hBNKNDRExF9go

To claim this, I am signing this object:

@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.

@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 / 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 / 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 / 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 / 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 / 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 / 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)