Skip to content

Instantly share code, notes, and snippets.

@ml242
ml242 / calculator.rb
Created September 25, 2013 14:41
Calculator Stuff
if num1 == "q"
puts "Thanks, bye!"
elsif
@ml242
ml242 / sinatra_helper_db_do.rb
Created October 9, 2013 20:45
Sinatra DB helper DO
helpers do
def db_exec(sql)
conn = PG.connect(:dbname =>'DB_NAME', :host => 'localhost')
result = conn.exec(sql)
conn.close
result
end
end
require 'active_record'
ActiveRecord::Base.logger = Logger.new( STDOUT )
ActiveRecord::Base.establish_connection(
:adapter => "postgresql",
:host => "localhost",
:username => "philco",
:password => "",
:database => "amazon_db"
@ml242
ml242 / gist:7025473
Last active December 25, 2015 19:09
Gemfile for Development
group :development do
gem 'better_errors' # Replaces the standard Rails error page with a much better and more useful error page
# https://github.com/charliesome/better_errors
end
group :development, :test do
gem 'capybara'
gem "rspec-rails"
@ml242
ml242 / gist:7025499
Last active December 25, 2015 19:09
Updating the Database.yml
development:
adapter: postgresql
encoding: unicode
database: <%= File.basename(Rails.root) %>_development
pool: 5
host: localhost
username: <%= ENV['PG_USERNAME'] %>
password:
test:
@ml242
ml242 / gist:7026209
Created October 17, 2013 14:44
Restful Routing Paths in Rails 3.2
get '/countries' => 'countries#index' #
get '/countries/new' => 'countries#new' #
post '/countries' => 'countries#create' #
get '/countries/:id' => 'countries#show' #
get '/countries/:id/edit' => 'countries#edit' #
post '/countries/:id' => 'countries#update' #
post '/countries/:id/delete' => 'countries#destroy' #
@ml242
ml242 / Git basics
Created November 8, 2013 23:08
Basic Git commands for groups from Jonathan's quick lecture
Git checkout -b "twilio_integration" (or feature in quotes that you're working on)
git checkout branch master (obviously moves back to master)
git push origin "twilio_integration" (or feature in quotes - just pushes the branch your working on)
when you're finished
git merge "twilio_integration" <- moves the twilio integration branch into the master branch
@ml242
ml242 / Amazon AWS demo from pbear
Last active December 28, 2015 05:39
Amazon AWS install
brew install imagemagick
gem install paperclip
-> add paperclip to gem file
gem install aws-sdk
gem 'paperclip'
gem 'aws-sdk'
rails new project
@ml242
ml242 / Add Guard to a Ruby workflow
Last active December 28, 2015 17:38
Adding Rspec and Guard to a ruby project that isn't backed by Rails
go to your directory
run --> rspec --init
cd into rspec (this is where you create your helper, i.e. bus_spec.rb), or just use touch to place them
cd ..
run --> rspec spec/
run --> bundle init
add gem 'rspec'
add gem 'guard-rspec'
run --> bundle install
@ml242
ml242 / Rspec within Rails
Last active December 28, 2015 19:29
Rspec for Rails
i.e. RAILS_ENV = (development, test, production)
Gemfile:
gem "rspec-rails", :group => [:test, :development]
gem 'jquery-rails'
development:
adapter: postgresql