Skip to content

Instantly share code, notes, and snippets.

View brock's full-sized avatar
😎

Brock Angelo brock

😎
View GitHub Profile
@brock
brock / backup_all_dbs.sh
Created September 20, 2012 01:03
Backup All DB's and transfer to S3 with s3cmd
#!/bin/bash
BACKUP_DIR="~/db_backups"
DBUSER=""
DBPASSWORD=""
BUCKET=""
FROM='"Backups" <backups@localhost>'
TO='"Admin" <admin@localhost>'
SUBJECT='Backup Log'
@brock
brock / export_db.sh
Created September 20, 2012 01:03
Export DB, gzip and domain replacement.
#!/bin/bash
USER=""
PASSWORD=""
if [ -z $1 ]; then
echo -e "ERROR: No database name. Usage: export_db DATABASE_NAME"
exit;
fi
DB=$1
@brock
brock / upload.rb
Created November 7, 2012 19:48 — forked from thechrisoshow/upload.rb
This script uploads files to a S3 bucket
require 'rubygems'
require 'aws/s3'
# Change the access key and secret to your amazon credentials
AWS::S3::Base.establish_connection!(
:access_key_id => 'ACCESS_KEY_ID',
:secret_access_key => 'SECRET'
)
# Change this to your S3 bucket name
WEBSITE_BUCKET_NAME = "YOUR_BUCKET_NAME"
@brock
brock / clearS3Bucket.rb
Created November 8, 2012 02:23
Delete all files in s3 bucket
# Credit to MattLor
# http://stackoverflow.com/questions/27267/delete-amazon-s3-buckets
require 'aws/s3'
AWS::S3::Base.establish_connection!(
:access_key_id => 'your access key',
:secret_access_key => 'your secret key'
)
@brock
brock / gist:4036187
Created November 8, 2012 02:28
htaccess redirect www to non-www
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
@brock
brock / ruby_challenge_11_7_12.rb
Created November 8, 2012 02:32
Ruby Challenge 2
digits = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
# Challenge 1: use the <digits> array to display the
# numbers 1 - 100 in a 10x10 block. Try to use only
# one *puts* statement
# terminal output:
#
# 1 2 3 4 5 6 7 8 9 10
# 11 12 13 14 15 16 17 18 19 20
# 21 22 23 24 25 26 27 28 29 30
@brock
brock / git_cal.rb
Created November 14, 2012 05:35
Git Commit Calendar
require 'date'
require 'colored'
require 'time'
date = Date.today
puts date.strftime("%B %Y").center(20)
puts "Su Mo Tu We Th Fr Sa"
days_in_month = (Date.new(date.year, 12, 31) << (12 - date.month)).day
@brock
brock / hack.sh
Created November 14, 2012 05:36 — forked from neil477/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@brock
brock / vimblog.vim
Created November 21, 2012 04:55 — forked from gavinzhou/vimblog.vim
vimblog
" Requirements:
" - you'll need VIM compiled with Ruby scripting support
" - example: for Debian/Ubuntu: sudo apt-get install vim-ruby
" - please, copy this file to one of your VIM dir
" - example: to your .vim home folder: $HOME/.vim/vimlog.vim
" - please, add this code to your .vimrc file:
"
" if !exists('*Wordpress_vim')
" runtime vimlog.vim
" endif
@brock
brock / gist:4123148
Created November 21, 2012 05:11 — forked from yuhonas/gist:4122118
iTerm / Sublime AppleScript
tell application "System Events"
# create an iTerm session if we dont have one
if not (exists (processes where name is "iTerm")) then
tell application "iTerm" to (make new terminal)
end if
tell application "iTerm"
activate
tell the current terminal
set SublimeSessionName to "sublime"