In Elixir, the equals sign =
is not an assignment, instead i's like an assertion. It succeeds if Elixir can find a way of making the left-hand side equal the right-hand side. Elixir calls =
a match operator.
a = 1
=> 1
FROM centos:7 | |
RUN yum -y update && yum -y install java-1.8.0-openjdk java-1.8.0-openjdk-devel epel-release libffi-devel gcc-c++ make openssl-devel git sudo | |
ENV JAVA_HOME /etc/alternatives/jre | |
# Add entrypoint script | |
ADD scripts/entrypoint.sh /usr/local/bin/entrypoint.sh | |
RUN chmod +x /usr/local/bin/entrypoint.sh | |
ENTRYPOINT ["entrypoint.sh"] |
# URL with http:// or https:// | |
%r{\A(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?\z}ix | |
/\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i |
# app/models/user.rb | |
class User < ActiveRecord::Base | |
has_secure_password | |
validates :firstname, presence: true, length: 4..20 | |
validates :middlename, length: 4..20, allow_blank: true | |
validates :lastname, presence: true, length: 4..20 | |
validates :email, format: { with: /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z\d\-]+)*\.[a-z]+\z/i } | |
validates :password, presence: true, confirmation: true, length: { minimum: 8 } | |
Page 47
This kind of mindset is crucial to managing your career, because when you start to think of yourself as a business, you start to make good business decisions.
Page 52
Every step you take without a clear direction is a wasted step. Don’t randomly walk through life without a purpose for your career.
Your big goal should be something not too specific, but clear enough that you can know if you’re steering toward it or not. Think about what you want to ultimately do with your career.
# Gemfile | |
gem 'google-api-client' | |
gem 'googleauth' |
# 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]] |
# 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 |
# 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 |
# 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 |