- What is a class?
- What is an object?
- What is a module? Can you tell me the difference between classes and modules?
- Can you tell me the three levels of method access control for classes and modules? What do they imply about the method?
- There are three ways to invoke a method in ruby. Can you give me at least two?
- Explain this ruby idiom: a ||= b
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###################################### UBUNTU ############################################### | |
==== to search by port ====== | |
lsof -wni tcp:3000 | |
==== to kill by port ======== | |
sudo kill -9 `sudo lsof -t -i:3000` | |
==== another way to search and kill a process using port === | |
sudo lsof -i -P -n | grep 6379 | |
sudo kill -9 <process_id> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query | |
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails | |
#payload: [{"kind"=>"person"}] | |
Segment.where("payload @> ?", [{kind: "person"}].to_json) | |
#data: {"interest"=>["music", "movies", "programming"]} | |
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json) | |
Segment.where("data #>> '{interest, 1}' = 'movies' ") | |
Segment.where("jsonb_array_length(data->'interest') > 1") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Use Case - Use Devise Confirmable module to confirm newly added organization(org) using email(association) | |
We want Three things to work - | |
Use confirmable - send_confirmation_instructions to send email when new org is added | |
Define Routes - organization_confirmation_url, so that user can use this route to confirm the org | |
Add confirmable columns inside existing organizations table, update token,timestamps on db | |
====== HERE WE START ========= | |
- `organization.rb` | |
has_one :contact_detail ##contains email |
Do you have spaces in your Windows username?
- Create a new account on Windows without a space.
#Installation
- Download cygwin from http://cygwin.com
- Run setup-(x86|x86_64).exe
- Click next until selecting repo to download packages
- Choose http://cs.vt.edu (gotta go fast), click next
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
First, setup and install monit on Ubuntu server | |
###get the latest | |
sudo apt-get update | |
##install monit | |
sudo apt-get install monit | |
##edit monit and add the below custom scripts | |
sudo vim /etc/monit/monitrc | |
##reload and verify | |
sudo monit reload | |
sudo monit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this monit config goes in /etc/monit/conf.d | |
check process puma_master | |
with pidfile /data/myapp/current/tmp/puma.pid | |
start program = "/etc/monit/scripts/puma start" | |
stop program = "/etc/monit/scripts/puma stop" | |
group myapp | |
check process puma_worker_0 | |
with pidfile /data/myapp/current/tmp/puma_worker_0.pid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stats = Sidekiq::Stats.new | |
stats.queues | |
stats.enqueued | |
stats.processed | |
stats.failed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Make sure heroku toolbelt and rvm are installed | |
#heroku toolbelt available to download on their site, rvm available via curl | |
\curl -sSL https://get.rvm.io | bash -s stable --ruby | |
rvm use "2.1.1" | |
rvm use --create 2.1.1@project | |
gem install rails | |
#if using postgres (good for heroku) pass argument to 'rails new' | |
rails new project --database=postgresql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'aws-sdk' | |
s3 = Aws::S3::Resource.new( | |
region: 'us-east-1', | |
credentials: Aws::InstanceProfileCredentials.new() | |
) | |
bucket = s3.bucket('my-daily-backups') | |
file = (DateTime.now).strftime("%Y.%m.%d-backup") | |
if bucket.object(file).exists? |