- Change your database RDS instance security group to allow your machine to access it.
- Add your ip to the security group to acces the instance via Postgres.
- Make a copy of the database using pg_dump
$ pg_dump -h <public dns> -U <my username> -f <name of dump file .sql> <name of my database>
- you will be asked for postgressql password.
- a dump file(.sql) will be created
- Restore that dump file to your local database.
- but you might need to drop the database and create it first
$ psql -U <postgresql username> -d <database name> -f <dump file that you want to restore>
- the database is restored
View how-to-copy-aws-rds-to-local.md
View rails http status codes
HTTP status code symbols for Rails | |
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings. | |
Status Code Symbol | |
1xx Informational | |
100 :continue | |
101 :switching_protocols | |
102 :processing |
View pg-downgrade-semaphore.sh
#!/usr/bin/env bash -l | |
set -e | |
### | |
# Add the line below to your setup command in Project Settings | |
# | |
# wget https://gist.githubusercontent.com/mimimalizam/27959bbc653de3965bb40955f4bc43df/raw/pg-downgrade-semaphore.sh && bash pg-downgrade-semaphore.sh | |
# | |
# Note: reset your dependency cache in Project Settings > Admin, before running this script |
View video-example.rb
#!/usr/bin/env ruby | |
# this is a test of ruby-processing (https://github.com/jashkenas/ruby-processing) with the video library | |
# use "rp5 unpack library" at a command line to install the video library, among others | |
# tested with Ruby 1.9.2 | |
# video file: http://bit.ly/H5yBjK | |
class VideoTest < Processing::App |
View rspec_model_testing_template.rb
# This is a skeleton for testing models including examples of validations, callbacks, | |
# scopes, instance & class methods, associations, and more. | |
# Pick and choose what you want, as all models don't NEED to be tested at this depth. | |
# | |
# I'm always eager to hear new tips & suggestions as I'm still new to testing, | |
# so if you have any, please share! | |
# | |
# @kyletcarlson | |
# | |
# This skeleton also assumes you're using the following gems: |
View gist:cc0bd1e616a7cdf9e7aa8194fc87b18a
People
![]() :bowtie: |
:smile: |
:laughing: |
---|---|---|
:blush: |
:smiley: |
:relaxed: |
:smirk: |
:heart_eyes: |
:kissing_heart: |
:kissing_closed_eyes: |
:flushed: |
:relieved: |
:satisfied: |
:grin: |
:wink: |
:stuck_out_tongue_winking_eye: |
:stuck_out_tongue_closed_eyes: |
:grinning: |
:kissing: |
:kissing_smiling_eyes: |
:stuck_out_tongue: |
View capybara cheat sheet
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |
View db.rake
# Put this in your Rails app's lib/tasks directory | |
namespace :db do | |
desc "Fix 'ERROR: must be owner of extension plpgsql' complaints from Postgresql" | |
task :fix_psql_dump do |task| | |
filename = ENV['DB_STRUCTURE'] || File.join(ActiveRecord::Tasks::DatabaseTasks.db_dir, "structure.sql") | |
sql = File.read(filename) | |
sql.sub!(/(CREATE EXTENSION IF NOT EXISTS plpgsql)/, '-- \1') | |
sql.sub!(/(COMMENT ON EXTENSION plpgsql)/, '-- \1') | |
File.open(filename, 'w') do |f| | |
f.write(sql) |
View bash.sh
$ RAILS_ENV=test rails c | |
[1] pry(main)> FactoryGirl.find_definitions | |
# then we can use each test row code in rails console |
View your_model.rb
# heading jsonb cloumn, and title a field inside jsonb search in jsonb | |
# heading: { title: "ABC" } | |
# For detail look at http://edgeguides.rubyonrails.org/active_record_postgresql.html#json-and-jsonb | |
def self.search(search) | |
q = "%#{search.downcase}%" | |
where("lower(heading ->> 'title') LIKE ?", q) | |
end |
NewerOlder