This note will walk you though setting up and securing a Ubuntu 10.04 LTS then deploying a Rails application with mulit-stage deployment.
TODO:
- Add section for NGINX setup
| task :reminder_mail => [:environment] do | |
| @users = User.active | |
| @holidays = Holiday.all | |
| @holiday_dates = [] | |
| @dates_to_check = [] | |
| @holidays.each {|h| @holiday_dates << h.holiday.to_s} | |
| (Date.new(Time.now.year, Time.now.month, 1)..Date.yesterday).each { |date| @dates_to_check << date.to_s} | |
| @users.each do |user| |
| task :weekly_report => [:environment] do | |
| @start_date=Date.today.beginning_of_week | |
| start_date=@start_date.to_date | |
| @end_date=6.days.since(@start_date) | |
| end_date=@end_date.to_date | |
| @project=Project.find_all_by_isactive(true) | |
| @proj=[] | |
| @project.each do |project| | |
| @proj << {:name => project.projectname,:billable => project.timeentries.sum(:hours_taken, :conditions=>['DATE(task_date)>=? and DATE(task_date)<=? and status=?',start_date,end_date, "Billable"]),:nonbillable => project.timeentries.sum(:hours_taken, :conditions=>['DATE(task_date)>=? and DATE(task_date)<=? and status=?',start_date,end_date, "NonBillable"]) ,:hours =>project.timeentries.sum(:hours_taken, :conditions=>['DATE(task_date)>=? and DATE(task_date)<=?',start_date,end_date])} | |
| end |
| #!/bin/sh | |
| # | |
| # Removes trailing whitespace from all source files in the current directory and its children. | |
| # Note the `-i .bak` switch to sed. This will create a backup copy alongside any modified files | |
| # like `Somefile.cpp.bak` Simply remove the `.bak` argument to `-i` to prevent the backup | |
| # files from being generated | |
| # | |
| /usr/bin/find . -type f -and \( -name '*.m' -or -name '*.h' -or -name '*.mm' -or -name '*.cpp' -or -name '*.c' \) -and -print0 | xargs -0 sed -i .bak -E "s/[[:space:]]+$//" |
| desc "Remove trailing whitespace for source files" | |
| task :strip_whitespace do | |
| files = %w[ .autotest .rspec .rvmrc Gemfile ] | |
| globs = %w[ lib/**/*.rb spec/**/*.rb ] | |
| files_from_globs = globs.map { |glob| Dir[glob] } | |
| files_to_strip = (files + files_from_globs).flatten | |
| system "sed -e 's/[ \t]*$//' -i '' #{files_to_strip.join(" ")}" | |
| end |
| def who_to_connect | |
| @sent_invitations = current_user.sent_inv.where(:is_pending => 1).collect(&:friend_id) | |
| @friends = friends_list | |
| @friends = @friends + @sent_invitations | |
| options = %w(majors careers) | |
| @sug_list = [] | |
| options.each do |option| | |
| @my_majors = eval("current_user.#{option}") |
| class ImportedContactsController << ApplicationController | |
| require 'net/http' | |
| require 'net/https' | |
| require 'uri' | |
| #THIS METHOD TO SEND USER TO THE GOOGLE AUTHENTICATION PAGE. | |
| def authenticate | |
| # initiate authentication w/ gmail | |
| # create url with url-encoded params to initiate connection with contacts api | |
| # next - The URL of the page that Google should redirect the user to after authentication. | |
| # scope - Indicates that the application is requesting a token to access contacts feeds. |
| (setq inhibit-startup-message t) ;; Removes startup message | |
| (setq-default indent-tabs-mode nil) | |
| (custom-set-variables | |
| ;; custom-set-variables was added by Custom. | |
| ;; If you edit it by hand, you could mess it up, so be careful. | |
| ;; Your init file should contain only one such instance. | |
| ;; If there is more than one, they won't work right. | |
| '(auto-save-default t) |
| task :migrate_wp => :environment do | |
| wp = Mysql2::Client.new(:host => "localhost", :username => "root", :password => "root", :database => "mageshblog") | |
| results = wp.query("select * from wp_zxdasg_posts;") | |
| results.each do |r| | |
| Post.create( | |
| :user_id => r["author"], | |
| :date => r["post_date"], | |
| :content => r["post_content"], | |
| :title => r["post_title"], |