Skip to content

Instantly share code, notes, and snippets.

View tsabat's full-sized avatar

Tim Sabat tsabat

View GitHub Profile
#!/bin/bash
set -x verbose
########################
# Create scaling policy
########################
AUTOSCALING_GROUP="app-autoscaling-group"
TYPE="ChangeInCapacity"
COOLDOWN=300
#!/bin/bash
AUTOSCALING_GROUP_NAME="app-autoscaling-group"
AVAILABILITY_ZONES="us-west-2c"
LAUNCH_CONFIG_NAME="app-launch-config"
MAX_SIZE=10
MIN_SIZE=2
DESIRED_CAPACITY=2
GRACE_PERIOD="300"
HEALTH_CHECK_TYPE="ELB"
#!/bin/bash
LB_NAME="app-lb-west"
LISTNER_HTTP="lb-port=80,instance-port=80,protocol=http"
CERT_ID="cert-id=arn:aws:iam::555555555555:server-certificate/production/myCert"
LISTENER_HTTPS="lb-port=443,instance-port=80,protocol=https,$CERT_ID"
ZONES="us-west-2c"
elb-create-lb $LB_NAME \
--listener $LISTENER_HTTP \

We use solr running on tomcat6 as the search server, resque to queue them up, and standard http requests to query the docs.

We can index about 15 documents per second.

@tsabat
tsabat / huge_file.md
Last active December 20, 2015 12:49
Find huge files in git repo

All the credit for this goes to this so solution

#!/usr/bin/env ruby -w
head, treshold = ARGV
head ||= 'HEAD'
Megabyte = 1000 ** 2
treshold = (treshold || 0.1).to_f * Megabyte

big_files = {}
@tsabat
tsabat / remove.md
Last active December 20, 2015 17:18

remove all but last 5. Run this from the releases directory.

sudo rm -rf `ls -t | awk 'NR>5'`
@tsabat
tsabat / headers.md
Created August 28, 2013 20:19
For Fabrice, the headers he wants

#Call to i.cdpn.io

This is what we have now:

curl -i -D- -o/dev/null -H "Origin: http://codepen.io" http://i.cdpn.io.s3.amazonaws.com/5.ucBde.4d9702ae-058b-4249-b03a-76319088194a.png

Notice the response does not include Access-Control-Expose-Headers

select
beginsd now, qRuns, qTime, tName, trxStarted, trxTime, rows, modified, locked, hoursLeftL, estimatedEndL, modifiedPerSecL, avgRows, estimatedEndG, modifiedPerSecG, hoursLeftG
from (
select
(@tname:='pens') tName,
@beginsd:=sysdate() beginsd,
@trxStarted:=(select trx_started from information_schema.innodb_trx where trx_query like concat('alter table %', @tname, '%')) trxStarted,
@trxTime:=timediff(@beginsd, @trxStarted) trxTime,
@rows:=(select table_rows from information_schema.tables where table_name like @tname) rows,
@runs:=(ifnull(@runs, 0)+1) qRuns,
@tsabat
tsabat / ruby.md
Last active December 22, 2015 07:49
ruby on 13.4

for capistrano demo, the following will install a modern ruby env. I just had to do this for the new db server we set up. rbenv is preferable because ruby gets patched a lot for vulnerabilities, but this will work.

sudo apt-get install build-essential -y
sudo apt-get install libxslt-dev libxml2-dev
sudo apt-get install ruby1.9.1-full -y
sudo update-alternatives --config ruby
gem install nokogiri --pre
@tsabat
tsabat / redis_clients.sh
Created September 7, 2013 19:41
a unique list of all connected redis clients
redis-cli client list | awk '{print $1}' | sed s/addr=//g | sed s/:.*//g | uniq