Skip to content

Instantly share code, notes, and snippets.

View kszarek's full-sized avatar

Krzysztof Szarek kszarek

View GitHub Profile
@kszarek
kszarek / allocate-shard.sh
Last active January 5, 2017 08:45
Allocate unassiged shard in ES
#!/bin/bash
if [[ $# -ne 1 ]]
then
echo "Allocate an unassigned shard to a node."
echo
echo "$0 destination_node_name"
exit 1
fi
# The allow_primary parameter will force a new empty primary shard to be allocated without any data.
@kszarek
kszarek / es-rolling-restart.sh
Last active October 22, 2015 10:30
ES Rolling restart
curl -XPUT localhost:9200/_cluster/settings -d '{"transient":{"cluster.routing.allocation.enable": "none"}}'
/etc/init.d/elasticsearch restart
sleep 15
curl -XPUT localhost:9200/_cluster/settings -d '{"transient":{"cluster.routing.allocation.enable": "all"}}'
@kszarek
kszarek / ec2-snapshot-copy.go
Created October 17, 2015 17:37
ec2-snapshot-copy.go
package main
import (
"flag"
"fmt"
"os"
"regexp"
"time"
"github.com/aws/aws-sdk-go/aws"
@kszarek
kszarek / java.sh
Created August 20, 2015 20:26
Install Java on Ubuntu
#!/bin/bash
set -xe
echo "Add repository and install java"
apt-get -y install python-software-properties
add-apt-repository -y ppa:webupd8team/java
apt-get -q -y update
apt-get -y upgrade
echo "Accept license"

Keybase proof

I hereby claim:

  • I am krzysztofszarek on github.
  • I am kszarek (https://keybase.io/kszarek) on keybase.
  • I have a public key whose fingerprint is 3830 FF0B C48D 86FF C8BF 0D40 AACD 88D7 CAD4 A964

To claim this, I am signing this object:

@kszarek
kszarek / fabfile.py
Created October 22, 2014 09:26
Custom task for fabric
class CustomTask(Task):
def __init__(self, func, myarg, *args, **kwargs):
super(CustomTask, self).__init__(*args, **kwargs)
self.func = func
self.myarg = myarg
if env.hosts == []:
logger.debug("env.hosts is empty")
# if hasattr(env, 'env_name'):
logger.debug("Found env_name in env")
@kszarek
kszarek / decorators.py
Created October 22, 2014 09:16
fabric decorator
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'Krzysztof Szarek'
from functools import wraps
from fabric.decorators import _wrap_as_new
from darwin.ec2 import _cloud_hosts
@kszarek
kszarek / upstreams.conf.erb
Created August 12, 2014 18:58
only one can rule the world
#cartmans
upstream wo {
<%- @wo.each do |host| %>
server <%= host %>:80<%- if @wo.length > 1 and @wo.index(host) != 0 %> backup<%- end %>;
<%- end %>
}
#cartmans2
upstream wo2 {
<%- @wo.each do |host| %>
server <%= host %>:80<%- if @wo.length > 1 and @wo.index(host).modulo(2) != 1 %> backup<%- end %>;
@kszarek
kszarek / default.rb
Created August 4, 2014 06:12
chef cron @reboot
cron "chef-client-autostart" do
time :reboot
command "/opt/chef/embedded/bin/ruby /usr/bin/chef-client -c /etc/chef/client.rb -L /var/log/chef.log -P /var/run/chef/client.pid"
end
@kszarek
kszarek / ec2_functions.py
Created June 23, 2014 12:06
Create ec2 instance with new ssd backed ebs
dev_sda1 = boto.ec2.blockdevicemapping.BlockDeviceType(
delete_on_termination=True, volume_type='gp2')
dev_sda1.size = env.ebs_size # size in Gigabytes
bdm = boto.ec2.blockdevicemapping.BlockDeviceMapping()
bdm['/dev/sda'] = dev_sda1