Skip to content

Instantly share code, notes, and snippets.

View chales's full-sized avatar

Chris Hales chales

View GitHub Profile
# Install AWS CLI tools, https://github.com/aws/aws-cli/
# Add these functions to ~/.bash_profile or ~/.profile
# Modify to fit specific needs such as adding a bastion proxy option.
#
# Usage examples:
# $ hostname_from_instance <instance-name>
# $ ip_from_instance <instance-name>
# $ ssh-aws <instance-name>
#
# ssh-instance - function to let you SSH to an EC2 instance ID
# Written by Mike Babineau <[email protected]>. Original here: https://gist.github.com/mbabineau/319882/
# Put this in ~/.profile and reload your terminal
function ssh-instance() {
if [ $# -lt 1 ] || [ $# -gt 3 ]; then
echo "Usage: ssh-instance [-r region] <instance id>"
else
case "$1" in
"-r")
@chales
chales / sethostname.sh
Created June 24, 2014 15:54
Set ubuntu hostname via script using sed
#!/bin/bash
# Set $chostname to current hostname
chostname=$(cat /etc/hostname)
# Display current hostname
echo "Current hostname is '$chostname'"
# Set $newhostname as new hostname
echo "Enter new hostname: "
@chales
chales / aws_iam_policy.json
Created June 24, 2014 21:56 — forked from kixorz/aws_iam_policy.json
Review original: Update Route53 DNS records from your EC2 instance using this simple Ruby script. You can call it from rc.local after setting your hostname locally. First parameter is the desired <hostname>.<domain> Domain and other parameters are hardcoded. This script is useful for handling internal DNS changes in your systems after instance c…
{
"Statement": [
{
"Action": [
"route53:ChangeResourceRecordSets",
"route53:GetHostedZone",
"route53:ListResourceRecordSets"
],
"Effect": "Allow",
"Resource": [
<?php
/**
* @file
* Amazon Elastic Load Balancer Settings.
*
* Force server to use https:// path if SSL is handled at load balancer.
*
* @see http://drupal.org/node/185161#comment-5452038
*/
"""
Queries the slowlog database table maintained by Amazon RDS and outputs it in
the normal MySQL slow log text format. Modified version of the script by
memonic (Thanks!) at https://gist.github.com/1481025
Things to change in this script for your own setup:
<root_user> to your mysql root user (e.g. "root")
<root_pass> to your mysql root password (e.g. "hunter2")
<host_domain> to your mysql root password (e.g. "prod-01.w3rfs2.us-east-1.rds.amazonaws.com")
drush php-eval 'node_access_rebuild();'
@chales
chales / pre-commit
Created January 15, 2015 15:40
Git pre-commit hook to run PHP Lint and PHP_CodeSniffer against Drupal project commits.
#!/usr/bin/php
<?php
/**
* @file
* Git pre-commit hook that runs PHP lint and PHPCS against commits.
* DrupalCS requires PHPCS 1.x
*
* Install:
* 1. Copy this file to /<my/git/project>/.git/hooks/pre-commit
#!/usr/bin/env sed -f
# whitespace at end of lines
s/\s\+$//
# fix comma followed by non-space character
# don't be picky, this is correct even for text!
/function/!s/\(,\)\(\S\)/\1 \2/g
# fix comments may not appear after statements
@chales
chales / vsh.sh
Last active May 8, 2016 17:27 — forked from ernix/vsh.sh
Terminal color switcher.
#!/bin/sh
#--------------------------------------------------------------------#
# Set OSX terminal window background color per SSH hosts.
#--------------------------------------------------------------------#
change_bgcolor () {
case $1 in
red)
osascript -e 'tell app "Terminal" to set background color of first window to {17655, 0, 0, -16373}';;