Skip to content

Instantly share code, notes, and snippets.

View jeffrydegrande's full-sized avatar

Jeffry Degrande jeffrydegrande

View GitHub Profile
require 'nokogiri'
module Wordpress
class Post
attr_reader :title, :post_date, :body, :description, :tags, :author
WP_NS = {
'wp' => 'http://wordpress.org/export/1.0/',
'content' => 'http://purl.org/rss/1.0/modules/content/',
'dc' => 'http://purl.org/dc/elements/1.1/'
}
$ whois basecamphq.com.br
% Copyright (c) Nic.br
% The use of the data below is only permitted as described in
% full by the terms of use (http://registro.br/termo/en.html),
% being prohibited its distribution, comercialization or
% reproduction, in particular, to use it for advertising or
% any similar purpose.
% 2010-04-14 16:29:26 (BRT -03:00)
class Thing < ActiveRecord::Base
def to_json
old_value = ActiveRecord::Base.include_root_in_json
ActiveRecord::Base.include_root_in_json = false
json = super
ActiveRecord::Base.include_root_in_json = old_value
json
end
end
# heroku: multiple accounts/multiple environments
check ~/.heroku => credentials
heroku config:add RACK_ENV=staging --app foo-staging
heroku config:add RACK_ENV=production --app foo-production
## Deploy and migrate
You'll be doing this next command pretty often. We push the current branch to the staging server's master branch. Since this is the first deploy we'll need to do the same thing for production and run all the migrations.
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe 'Machinist' do
models = Dir[File.expand_path(File.dirname(__FILE__) + '/../app/models/*.rb')].
map{|file| File.basename(file, '.rb') } - %w{mailer}
models.map{ |model| model.classify.constantize }.each do |model|
it "should have a blueprint for the #{model} model" do
model.make.should be_instance_of(model)
end

GitHub Javascript Strategy

Unless otherwise necessary (such as mobile development), the GitHub javascript codebase is based off jQuery. You can safely assume it will be included on every page.

File naming

  • All jquery plugins should be prefixed with jquery, such as jquery.facebox
  • All github-specific jquery plugins should be prefixed with jquery.github. Like jquery.github.repo_list.js
  • All page-specific files (that only run on ONE page) should be prefixed with page. page.billing.js
$ git diff
diff --git a/lib/sprockets_on_heroku.rb b/lib/sprockets_on_heroku.rb
index 781b9cf..77b3153 100644
--- a/lib/sprockets_on_heroku.rb
+++ b/lib/sprockets_on_heroku.rb
@@ -44,7 +44,9 @@ class SprocketsOnHeroku
def initialize_sprockets
secretary.concatenation.save_to(javascript_location_on_heroku)
minify
- self.class.original_sprockets_location = '/sprockets.js'
style.css: *.sass sass/*.sass
sass -t expanded style.sass > style.css
mockup.html: mockup.haml
haml mockup.haml mockup.html
clean:
rm -fr *.html
rm -fr *.css
source 'http://rubygems.org'
gem 'rails', '3.0.0.rc'
gem "rails3-generators"
gem "mongoid", ">= 2.0.0.beta.14"
gem "bson_ext", "1.0.4"
gem "haml"
gem "devise", ">= 1.1.1"
gem "devise_invitable", :path => File.join(File.dirname(__FILE__), '/vendor/gems/devise_invitable')
gem 'responders'
args = Rails.application.routes.routes.first.defaults.dup.merge({:host => 'localhost'})
Rails.application.routes.url_for(args)
=> "http://localhost/users/sign_in"