Skip to content

Instantly share code, notes, and snippets.

View burdandrei's full-sized avatar
👻

Andrei Burd burdandrei

👻
View GitHub Profile
@burdandrei
burdandrei / bitnami_backup
Created March 10, 2015 14:49
Simple script to back up your bitnami app to s3
#!/bin/bash
#
# Script for backing up bitnami app and upload tarballs to S3
set -e
usage(){
echo "Usage: BITNAMI_APP=<> BITNAMI_DB_PASSWORD=<> S3_BUCKET=<> $0"
exit 1
}
@burdandrei
burdandrei / gemcheck.sh
Created April 15, 2015 11:46
Check that you got all the gems needed to trigger the ruby script
#!/bin/bash -e
#
# Wrapper to check all the needed gems are installed
GL=$(gem list)
for gem in $(cat Gemfile | grep -w gem | cut -f2 -d ' '| tr -d "'"); do
if ! $(echo $GL | grep -wq $gem); then
gem install bundler
bundle install
break
@burdandrei
burdandrei / starprint.sh
Last active August 29, 2015 14:22
Do you love to to read scripts outputs as I do? Print these messages with stars around!
#!/usr/bin/env bash
#
# Just echo everything with Stars Around
starprint(){
local INPUT=$*
local LENGTH=$(echo "$INPUT" | awk '{print length+4}')
line() { for i in $(eval echo "{1..$LENGTH}"); do echo -n '*'; done; echo; }
line
echo -n "* "; echo -n $INPUT;echo -n " *";echo
@burdandrei
burdandrei / random_cowsay.sh
Last active August 29, 2015 14:22
Finish your scripts with Fun success output
#!/usr/bin/env bash
random_cowsay() {
local INPUT=$*
echo $INPUT | cowsay -f $(ls /usr/share/cowsay/cows/ | shuf -n1)
}
@burdandrei
burdandrei / ssh_tunnel.sh
Created June 24, 2015 08:21
Example of forwarding remote port to localhost (Connecting to DB behind the firewall through the SSH Tunnel)
#!/usr/bin/env bash
REMOTE_HOST=ip-10-2-10-197.ec2.internal # Related to PROXY_HOST
REMOTE_PORT=27017
LOCAL_PORT=27017
PROXY_HOST=ec2-55-210-99-165.compute-1.amazonaws.com
ssh -f -L ${LOCAL_PORT}:${REMOTE_HOST}:${REMOTE_PORT} $PROXY_HOST -N
@burdandrei
burdandrei / ec2ssh.sh
Last active August 10, 2016 06:52
Connect to aws instances in cluster/single mode with filters from command line
#!/usr/bin/env bash
#
# Wrapper for CSSH running instances by tag
usage(){
cat << EOF >&2
usage: $0 options
This script Gathers instances from AWS and runs ClusterSSH to them
@burdandrei
burdandrei / CloudSearchExport.rb
Created November 17, 2015 15:02
Export all your data from CloudSearch and be free!
#!/usr/bin/env ruby
#
# Cloudsearch export script
#
# Required ENV Variables
# * AWS_ACCESS_KEY_ID
# * AWS_SECRET_ACCESS_KEY
# * CS_SEARCH_ENDPOINT
# * OUT_FILENAME
#
@burdandrei
burdandrei / UnregisterResqueWorkersByHostname.rb
Created November 25, 2015 11:06
Clear stuck/stale Resque workers?
hostname = ''
Resque.workers.each { |w| w.unregister_worker if w.id.start_with?(hostname) }
@burdandrei
burdandrei / Predeploy_Instance_Count_Adjust.sh
Created November 27, 2015 18:31
Sometimes you want to double the number of instances they to receive the new version, and then Autoscaling to hande the magic
#!/usr/bin/env bash
#
# Double the instance count for widget ASG
# Required ENV Variables
# * ELB_NAME
# * ASG_NAME
#
asg_check() {
local pending_instance_count=$(aws autoscaling describe-auto-scaling-groups \
@burdandrei
burdandrei / travis-cache-docker.yml
Last active December 21, 2015 15:01
Template for travis.yml with docker cache between the builds
sudo: required
dist: trusty
services:
- docker
cache:
- directories:
- /var/tmp/docker