Skip to content

Instantly share code, notes, and snippets.

View aaroncaito's full-sized avatar

Aaron Caito aaroncaito

View GitHub Profile
@aaroncaito
aaroncaito / sanitize-phone-number.py
Last active December 19, 2015 22:39
Tel:// compat phonenum formatting
phone = phone.replace(/[- ()]/g, "")
return "1"+phone
@aaroncaito
aaroncaito / 0_reuse_code.js
Last active August 29, 2015 14:21
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console

Keybase proof

I hereby claim:

  • I am aaroncaito on github.
  • I am aaroncaito (https://keybase.io/aaroncaito) on keybase.
  • I have a public key ASA7rblCYllGjbN6ONoEd9ZPH2Dk0vdbaqZnKdzNvy7QMgo

To claim this, I am signing this object:

@aaroncaito
aaroncaito / terraform.tf
Last active December 14, 2016 06:38
snippet for app stack for 1 environment for nayrb1523@reddit
```
# DEMO TO SHOW RESOURCE RELATIONSHIPS
## NOT TO BE USED WITHOUT SIGNIFICANT CHANGES
- Complete resource requirements
- Don't use inline rules for security groups as you'll have circular dependencies
- Probably use a lot more variables with settings files per environment
- Make pod blocks and turn them into re-usable module
- Make vpc&zone as module as well
- Newer terraform handles lists better, better ways to do stuff
cidrs=(1.18.12.0/24
1.15.46.253/24
1.65.231.0/24)
for cidr in ${cidrs[@]};do aws ec2 authorize-security-group-ingress --profile <some-profile> --group-id <some-sec-group> --protocol tcp --port 22 --cidr $cidr --dry-run; done
servers=$(aws ec2 describe-instances --filters "Name=tag:opsworks:stack,Values=$$<TAG>" --profile AIM --query "Reservations[*].Instances[*].PublicIpAddress")
for server in ${servers[@]}
do
echo "-=# $server #=-"
test=`ssh -t -i .ssh/$$<KEY> ubuntu@$server 'if tail /var/log/apache2/error.log | grep Segmentation > /dev/null; then echo -n "1"; else echo -n "0"; fi'`
echo $test
if [ $test == 1 ]
then
echo "Segmentation fault found, restarting apache2 on $server"
ssh -t -i .ssh/$$<KEY> ubuntu@$server 'sudo service apache2 restart'
servers=( $$host1 $$host2 $$host3 )
for server in ${servers[@]}; do ip=`dig +short $server`; echo "-=# $server #=- -=@ $ip @=-"; done
pbpaste > ~/var/servers
cat ~/var/servers | grep $$public_ip
#!/usr/bin/env python3
'''
Sample script creates some ec2 instances, applies security rules, and
configures salt reporting to master.
'''
import boto.ec2, time, os