(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| $: (Dollar Colon) is basically a shorthand version of $LOAD_PATH. $: contains an array of paths that your script will search through when using require. | |
| $0 (Dollar Zero) contains the name of the ruby program being run. This is typically the script name. | |
| $* (Dollar Splat) is basically shorthand for ARGV. $* contains the command line arguments that were passed to the script. | |
| $? (Dollar Question Mark) returns the exit status of the last child process to finish. | |
| $$ (Dollar Dollar) returns the process number of the program currently being ran. | |
| $~ (Dollar Tilde) contains the MatchData from the previous successful pattern match. | |
| $1, $2, $3, $4 etc represent the content of the previous successful pattern match. | |
| $& (Dollar Ampersand) contains the matched string from the previous successful pattern match. | |
| $+ (Dollar Plus) contains the last match from the previous successful pattern match. | |
| $` (Dollar Backtick) contains the string before the actual matched string of the previous successful pattern match. |
| require 'sidekiq/api' | |
| # 1. Clear retry set | |
| Sidekiq::RetrySet.new.clear | |
| # 2. Clear scheduled jobs | |
| Sidekiq::ScheduledSet.new.clear |
This is just some code I recently used in my development application in order to add token-based authentication for my api-only rails app. The api-client was to be consumed by a mobile application, so I needed an authentication solution that would keep the user logged in indefinetly and the only way to do this was either using refresh tokens or sliding sessions.
I also needed a way to both blacklist and whitelist tokens based on a unique identifier (jti)
Before trying it out DIY, I considered using:
The following outlines how to setup Heroku + Cloudflare with a full SSL certificate. What this means is that communication between the browser and the Cloudflare CDN is encrypted as well as communication between Cloudflare and Heroku’s origin server. Follow these steps exactly and the setup is a breeze.
First you want to add the root domain and the www domain to heroku. You do this by clicking into your production application, then going to settings and then scrolling down to Domains and certificates.
Here you will add <your_domain>.com and www.<your_domain>.com. This will give you two CNAME records. They will look something like <your_domain>.com.herokudns.com and www.<your_domain>.com.herokudns.com.
In programming languages, literals are textual representations of values in the source code. This is a syntactical concept.
Some examples:
7 # integer literal| ruby '2.7.1' | |
| gem 'rails', github: 'rails/rails' | |
| gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data | |
| # Action Text | |
| gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra' | |
| gem 'okra', github: 'basecamp/okra' | |
| # Drivers |
Developing an app to accompany our website, worried that we would lose people in the transition if they couldn't remember their password, we were looking to make our app do Password AutoFill, a feature in iOS.
A talk from WWDC introducing the feature: https://developer.apple.com/videos/play/wwdc2017/206/
It works well, but there were a few bumps in the road making it work for React Native on Expo, so here are some notes to help out.
Apple's docs are here: https://developer.apple.com/documentation/security/password_autofill and they say something like this:
| require 'rails_helper' | |
| RSpec.describe TodosController, :type => :controller do | |
| describe "GET #index" do | |
| #describe "POST #create" do | |
| #describe "GET #show" do | |
| #describe "PATCH #update" do (or PUT #update) | |
| #describe "DELETE #destroy" do | |
| #describe "GET #new" do |
| # spec/system/support/login_helpers.rb | |
| # See this blog post for setup guide: https://evilmartians.com/chronicles/system-of-a-test-setting-up-end-to-end-rails-testing | |
| module LoginHelpers | |
| def login_as(user) | |
| # Craft session cookie to make request authenticated (to pass even routing constraints) | |
| # Compilation of these: | |
| # - https://dev.to/nejremeslnici/migrating-selenium-system-tests-to-cuprite-42ah#faster-signin-in-tests | |
| # - https://turriate.com/articles/2011/feb/how-to-generate-signed-rails-session-cookie | |
| # - https://github.com/rails/rails/blob/43e29f0f5d54294ed61c31ddecdf76c2e1a474f7/actionpack/test/dispatch/cookies_test.rb#L350 |