Skip to content

Instantly share code, notes, and snippets.

View davidchua's full-sized avatar

David davidchua

View GitHub Profile
@davidchua
davidchua / deploy.rb
Last active December 11, 2015 07:29
Default Capistrano Script to get Started - Git - RVM System
load 'deploy/assets'
require "bundler/capistrano"
set :application, "some_web"
set :repository, "[email protected]:whatever.git"
set :deploy_to, "/home/ubuntu/some_web"
set :user, 'ubuntu'
set :use_sudo, false
@davidchua
davidchua / zerigo_to_aws_route53.rb
Last active February 22, 2017 20:19
quick and dirty ruby script to copy dns from zerigo to amazon aws route 53 (route53). allows users to migrate ALL zones from zerigo over to Route53
#!/usr/local/rvm/rubies/ruby-1.9.2-p180/bin/ruby
require 'rubygems'
require 'zerigo_dns'
require 'route53'
Zerigo::DNS::Base.user = '[email protected]'
Zerigo::DNS::Base.api_key = 'yourkeyhere'
# iterate through all domain names
#!/bin/bash
#
# Homepage: http://www.debian-tutorials.com
# Email: [email protected]
# Bash script to download and install or upgrade wordpress to specified directory.
install_wp ()
{
cd ~</pre>
<!--more-->
<pre>
namespace :db do
desc "Backup database to #{RAILS_ROOT}/db/backup"
task :backup => :environment do
max_backups = (ENV["MAX"] || 14).to_i
timestamp = Time.now.strftime("%Y%m%d_%H%M%S")
backup_folder = File.join("db", "backup")
backup_file = File.join(backup_folder, "#{RAILS_ENV}_dump_#{timestamp}.sql.gz")
FileUtils.makedirs(backup_folder)
db_config = ActiveRecord::Base.configurations[RAILS_ENV]
command = "mysqldump -u #{db_config['username']} -p#{db_config['password']} --default-character-set=utf8 --single-transaction --quick #{db_config['database']} | gzip -c > #{backup_file}"
Workflow:
1) Do a git pull to ensure your master is having the latest copy
2) Create a new branch with the command
git checkout -b <branchname>
"I'd normally name the branchname something in relation to the task at hand, this is supposed to make your life easier."
# ~/.bashrc
# for git branch display on bash
# -- START ---
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
function proml {
PS1="\u@\h:\w\[\033[0;32m\]$(parse_git_branch)\[\033[0;0m\]> "