Skip to content

Instantly share code, notes, and snippets.

View pedrolopez's full-sized avatar

Pedro López pedrolopez

View GitHub Profile
task :deploy do
puts 'Deploying site to Heroku ...'
puts `git push heroku`
puts 'Running database migrations ...'
puts `heroku rake db:migrate`
release_name = "release-#{Time.now.utc.strftime("%Y%m%d%H%M%S")}"
puts "Tagging release as '#{release_name}'"
puts `git tag -a #{release_name} -m 'Tagged release'`
# Usage: rake name:task app_name
task PROD = "appname" # "task" here stubs to prevent rake errors with commandline
task STAGING = "appname-staging"
APP = ARGV[1] || PROD # default app
puts "=== APP #{APP} ==="
namespace :deploy do
#Deploy and rollback on Heroku in staging and production
task :deploy_staging => ['deploy:set_staging_app', 'deploy:push', 'deploy:restart', 'deploy:tag']
task :deploy_production => ['deploy:set_production_app', 'deploy:push', 'deploy:restart', 'deploy:tag']
namespace :deploy do
PRODUCTION_APP = 'YOUR_PRODUCTION_APP_NAME_ON_HEROKU'
STAGING_APP = 'YOUR_STAGING_APP_NAME_ON_HEROKU'
task :staging_migrations => [:set_staging_app, :push, :off, :migrate, :restart, :on, :tag]
task :staging_rollback => [:set_staging_app, :off, :push_previous, :restart, :on]
#!/usr/bin/env ruby
# This is a basic deploy script for Heroku apps.
# It provides a structure you can use to expand on
# and add your own prereqs and deploy tasks.
#
# It basically ensures that:
# 1. There are no uncommited files
# 2. You can ssh to github
# 3. You can connect to heroku

Installation

In order to get support for the clipboard and necessary interpreters, we need to compile and install from source.

# install build dependencies for vim:
sudo apt-get -y build-dep vim

# install some additional, necessary tools:
sudo apt-get -y install checkinstall mercurial python-dev python3.3-dev

clone the latest version of vim source:

Ruby, RVM and Mountain Lion

Key problems

Mountain Lion (10.8) has three main difference compared to Lion (10.7):

  • XCode 4.4 does not install Command Line Tools by default
  • X11 isn't available anymore
  • The installed version of OpenSSL has some bugs

How to work around

Implement simple rails store app with abilities to track user's activities
Features:
- product has title, description, price, tags
- pages: list of products, product's detail page
- search by products(use mysql)
- track user's clicks by the product in the search results
- every user should have unique tracking code. Use cookies to set it.
- save product id, user's ip, search keywords, user-agent, user's geo location, user's tracking code
- page: the list of tracking clicks
#!/usr/bin/env ruby
# vim: set syntax=ruby
# Ensures that changes to the Rails schema.rb file may only be committed if a
# migration file is also committed at the same time.
def schema_modified?
%x[ git diff --cached |grep schema.rb ] == ''
end
Gemfile.lock merge=bundlelock
db/schema.rb merge=railsschema
# Within Mac VM
sudo -s
# Create user with id 1000 and group with id 1000
dscl . -create /Groups/mygroup
dscl . -create /Groups/mygroup name mygroup
dscl . -create /Groups/mygroup passwd "clave"
dscl . -create /Groups/mygroup gid 1000
dscl . -create /Users/myuser
dscl . -create /Users/myuser UserShell /bin/bash
dscl . -create /Users/myuser RealName "myuser"