Skip to content

Instantly share code, notes, and snippets.

Laxman Singh Laxman-SM

  • intertrust technologies india
  • US, Hyderabad (india)
Block or report user

Report or block Laxman-SM

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:7624a5793a874f1751ddad3c3dfede7f
#!/bin/bash -xe
# Parse server.properties to get Zookeeper hosts
ZK_HOST=$(grep 'zookeeper.connect=' /etc/kafka/server.properties | cut -d'=' -f 2)
# Find the newest version of Kafka in the /opt directory
KAFKA_PATH=$(find /opt/ -maxdepth 1 -name kafka-2* | sort | tail -n1)
# Manually configured list of brokers to rebalance across (zero-indexed)
BROKER_LIST="0,1,2"
@Laxman-SM
Laxman-SM / recover_source_code.md
Created Jan 23, 2018 — forked from jay-johnson/recover_source_code.md
How to recover lost Python source code if it's still resident in-memory
View recover_source_code.md

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb
@Laxman-SM
Laxman-SM / deploy.sh
Created Dec 19, 2017 — forked from bvis/deploy.sh
Autoregister your swarm nodes in Portainer
View deploy.sh
# Create the password needed to login to portainer and reuse it for the portainer endpoints.
export VOLUME_DRIVER=local
export PORTAINER_PASS=mySuperSECRETPass
export PORTAINER_ENC_PASS=$(docker run --rm httpd:2.4-alpine htpasswd -nbB admin ${PORTAINER_PASS} | cut -d ":" -f 2)
echo $PORTAINER_PASS | docker secret create portainer_password.v1 --label portainer -
# Deploy the stack!
docker stack deploy --compose-file docker-compose.yml portainer
@Laxman-SM
Laxman-SM / README.md
Created Dec 19, 2017 — forked from bvis/README.md
Docker Env Vars expanded with secrets content
View README.md

Variables by Secrets

Sample script that allows you to define as environment variables the name of the docker secret that contains the secret value. It will be in charge of analyze all the environment variables searching for the placeholder to substitute the variable value by the secret.

Usage

You can define the next environment variables:

View README.md

CloudFormation -> Terraform Import Helpers

I wrote these scripts to help faciliate batch import of our CloudFormation templates into Terraform Configuration.

region-batch.sh

This script is a light wrapper around batch.sh. It simply iterates over the list of regions provided, exports expected variables, creates required directories, and calls batch.sh.

BASE_DIR=/path/to/dir EXCLUDE_REGEX="(some-stack-production|some-stack-staging)" ./region-batch.sh us-east-1 us-west-1
@Laxman-SM
Laxman-SM / kube-rotate.sh
Created Nov 11, 2017 — forked from mgoodness/kube-rotate.sh
Bash script for draining & terminating EC2 Kubernetes nodes
View kube-rotate.sh
#!/usr/bin/env bash
k8s_node=$(echo $1 | cut -f2 -d '/')
kubectl drain --force --ignore-daemonsets --delete-local-data ${k8s_node}
if [[ $? -eq 0 ]]; then
kubectl delete node ${k8s_node}
fi
@Laxman-SM
Laxman-SM / env2secret.py
Created Oct 30, 2017 — forked from lwolf/env2secret.py
Script to convert docker-compose compatible environment files into kubernetes secrets
View env2secret.py
"""
requires click package:
- pip install click
Example usage:
- python env2secret.py --src=production-ru.env --dst=production-ru-secret.yaml --fmt=yaml --name=my-app-secret
"""
import base64
import click
View Cloudformation.json
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Cloud Formation Template for S3 based static site",
"Mappings": {
"RegionMap": {
"us-east-1": {
"S3hostedzoneID": "Z3AQBSTGFYJSTF",
"websiteendpoint": "s3-website-us-east-1.amazonaws.com"
},
"us-west-1": {
@Laxman-SM
Laxman-SM / docker-compose-coreos.sh
Created Sep 18, 2017 — forked from sourcec0de/docker-compose-coreos.sh
Install docker compose on coreos
View docker-compose-coreos.sh
sudo su -
mkdir -p /opt/bin
curl -L https://github.com/docker/compose/releases/download/1.5.1/docker-compose-`uname -s`-`uname -m` > /opt/bin/docker-compose
chmod +x /opt/bin/docker-compose
You can’t perform that action at this time.