Skip to content

Instantly share code, notes, and snippets.

@zhiyao
zhiyao / <!doctype html>.html
Created September 26, 2012 14:50
HTML: Starting Template
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<title></title>
</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
</body>
@zhiyao
zhiyao / Heroku db task
Created October 30, 2012 16:10
Heroku database backup, transfer between production and staging server, alot faster that the heroku db:pull and db:push. This will only work if your local app is setup with postgres database
#!/usr/bin/env ruby
#Place this in your root directory of your rails app
#Ensure that you have install thor gem
#To list the command, type 'thor -T'
module Heroku
class Db < Thor
desc "production_to_local", "clone a remote heroku database to the local environment"
method_option :remote_production, :type => :string, :default => 'production'
@zhiyao
zhiyao / Capistrano Postgresql
Created October 30, 2012 17:36
capistrano postgresql backup, import and export to production server, reference mledom.blogspot.com/2009/11/capistrano-sync-production-to.html
require "bundler/capistrano"
namespace :db do
require 'yaml'
desc "Copy the remote production database to the local development database NOTE: postgreSQL specific"
task :pg_backup_production, :roles => :db, :only => { :primary => true } do
# First lets get the remote database config file so that we can read in the database settings
tmp_db_yml = "tmp/database.yml"
get("#{shared_path}/config/database.yml", tmp_db_yml)
@zhiyao
zhiyao / gist:4175056
Created November 30, 2012 10:39
issue-bundle-output
Using rake (10.0.2)
Using i18n (0.6.1)
Using multi_json (1.3.7)
Using activesupport (3.2.9)
Using builder (3.0.4)
Using activemodel (3.2.9)
Using erubis (2.7.0)
Using journey (1.0.4)
Using rack (1.4.1)
Using rack-cache (1.2)
@zhiyao
zhiyao / gist:4175061
Created November 30, 2012 10:40
issues-gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.9'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
@zhiyao
zhiyao / gist:4175067
Created November 30, 2012 10:42
issues-development-log
Completed 500 Internal Server Error in 64ms
NoMethodError (undefined method `products' for #<Spree::Promotion::Rules::FirstOrder:0x007fc21936ff78>):
activemodel (3.2.9) lib/active_model/attribute_methods.rb:407:in `method_missing'
activerecord (3.2.9) lib/active_record/attribute_methods.rb:149:in `method_missing'
activerecord (3.2.9) lib/active_record/associations/collection_proxy.rb:89:in `map'
activerecord (3.2.9) lib/active_record/associations/collection_proxy.rb:89:in `method_missing'
/Users/kennychan/.bundler/ruby/1.9.1/spree-df8470bcc693/core/app/models/spree/calculator/per_item.rb:36:in `matching_products'
/Users/kennychan/.bundler/ruby/1.9.1/spree-df8470bcc693/core/app/models/spree/calculator/per_item.rb:16:in `block in compute'
activerecord (3.2.9) lib/active_record/associations/collection_proxy.rb:89:in `each'
# config/environment.rb
config.gem "bitfluent-activemerchant", :lib => "activemerchant"
#!/usr/bin/env bash
apt-get -y update
apt-get -y install build-essential zlib1g-dev libssl-dev lib64readline-gplv2-dev libyaml-dev
cd /tmp
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz
tar -xvzf ruby-1.9.3-p194.tar.gz
cd ruby-1.9.3-p194/
./configure --prefix=/usr/local
make
make install
@zhiyao
zhiyao / gist:7244804
Created October 31, 2013 05:44
installing ruby
fancy_echo "Installing Postgres, a good open source relational database ..."
brew install postgres --no-python
initdb /usr/local/var/postgres -E utf8
fancy_echo "Installing Redis, a good key-value database ..."
brew install redis
fancy_echo "Installing The Silver Searcher (better than ack or grep) to search the contents of files ..."
brew install the_silver_searcher
@zhiyao
zhiyao / rename_jade_to_pug.rb
Created October 3, 2016 08:15
Rename jade extension to pug extension
jade_files = Dir.glob("../**/*.jade")
jade_files.each do |jade_file|
puts "Renaming #{jade_file}"
pug_file = jade_file.gsub(/.jade$/, '.pug')
puts "> #{pug_file}"
File.rename(jade_file, pug_file)
end