- command + T to open new tab
- shift + command + [ / ] to switch between tabs
- command + W to close the tab
- command + D to have vertical divided windows
- command + [ / ] to switch between windows
man command
checks out the manual for the command
, for instance use man echo
to see the description of the echo
command.
Use q
to quit the manual mode, normally q
works for the similar mode entered by other command like ri Array
.
git init
git add .
add current directory to stage
git add -A
add all untrack directories and files to stage
git commit
commit staged files
git checkout -b new-branch-name
create new branch and checkout to new branch
This file contains hidden or 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
# Prepare the schema for the additional session records. | |
# XXXXXXXXXXXXXXXX_create_user_session.rb | |
class CreateUserSessions < ActiveRecord::Migration | |
def change | |
create_table :user_sessions do |t| | |
t.references :user, :foreign_key => true, :index => true, :null => false | |
t.text :user_agent | |
t.datetime :expire_at # use expire_at to control the expiration after issuing JWT | |
t.timestamps null: false |
This file contains hidden or 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
# In Gemfile | |
# Include AWS SDK V1 for paperclip if your paperclip version is less than 5.0 | |
gem 'aws-sdk-v1' | |
# Need to AWS V2 SDK for SNS methods, gem 'aws-sdk', '~>1.6' doesn't have Aws::SNS methods | |
gem 'aws-sdk', '~> 2.0' | |
###################################################### |
This file contains hidden or 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
# In db/migrate/XXXXXXX_create_amazon_sns_infos.rb | |
class CreateAmazonSnsInfos < ActiveRecord::Migration | |
def change | |
create_table :amazon_sns_infos do |t| | |
t.references :user, :foreign_key => true, :index => true, :null => false | |
t.string :platform | |
t.string :device_token | |
t.string :endpoint_arn | |
t.string :platform_application_arn |
This file contains hidden or 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
# In app/services/parse_installation_wrapper.rb | |
class ParseInstallationWrapper | |
def self.check_and_unregister(options = {}) | |
# provide no params will clear out the Parse installation with no device_token | |
object_ids = get_push_registered_installation_object_ids(options) | |
delete_push_installations(object_ids) | |
end | |
private |
This file contains hidden or 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
# In your api call endpoint for update_push_subscription | |
# I use Grape, but the logic is similar in RailsAPI | |
resource :update_push_subscription do | |
desc "Update the user mobil push notification registration on Amazon SNS" | |
params do | |
requires :push_platform, type: String, desc: "Push Service Platform", values: %w(apns gcm) | |
requires :device_token, type: String, desc: "Device Token for Mobile Push Notification" | |
end | |
post do |
This file contains hidden or 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
# In app/services/push_services_wrapper.rb | |
require 'json/ext' | |
class PushServicesWrapper | |
attr_reader :message, :to_email, :channels, :badge, :from_id, :push_time, :addition, :push_uri, :to_id | |
def initialize(options = {}) | |
@message = options[:message] | |
@to_email = options[:to_email].kind_of?(Array) ? options[:to_email] : [options[:to_email]] |
This file contains hidden or 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
# Gemfile | |
gem 'google-api-client' | |
gem 'googleauth' |
OlderNewer