Goals of this tutorial:
- deploy a new Rails app with capistrano
- make it fast (total process takes less than 5 minutes)
- make it simple (no unecessary config)
- manual ssh to the server not required
Rails application stack:
- nginx
- unicorn
- postgresql
| require 'net/http' | |
| page_id = "your page id" | |
| access_token = "your access token" | |
| html_source = "your html content" | |
| uri = URI.parse("https://graph.facebook.com/v2.6/#{page_id}/instant_articles") | |
| request = Net::HTTP::Post.new(uri.path) | |
| request.set_form_data({ | |
| access_token: access_token, |
| monitor: bundle exec ruby monitor.rb |
| console.log(`%c :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | |
| :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | |
| :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | |
| :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | |
| :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | |
| ::: |
Goals of this tutorial:
Rails application stack:
| # spec/rails_helper.rb | |
| require_relative 'support/webpack_test_helper.rb' | |
| # ... | |
| config.before(:suite) do | |
| # Compile webpack if necessary. | |
| # Only runs if checksum of JS files has changed | |
| WebpackTestHelper.compile_webpack_assets | |
| end |
| 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") |
| -- @desc: The fastest, type-agnostic way to copy a Redis key | |
| -- @usage: redis-cli --eval copy_key.lua <source> <dest> , [NX] | |
| local s = KEYS[1] | |
| local d = KEYS[2] | |
| if redis.call("EXISTS", d) == 1 then | |
| if type(ARGV[1]) == "string" and ARGV[1]:upper() == "NX" then | |
| return nil | |
| else |
| # [SUBJECT] - If applied, this commit will... | |
| # ******** Above this line ******** # | |
| # 1. Separate subject from body with a blank line | |
| # 2. Limit the subject line to 50 characters | |
| # 3. Capitalize the first letter subject line | |
| # 4. Do not end the subject line with a period | |
| # 5. Use the imperative mood in the subject line | |
| # 6. Wrap the body at 72 characters |
| $camphor300:'d09GMgABAAAAAQ5UABIAAAAEn0QAAQ3tAAEZmQAAAAAAAAAAAAAAAAAAAAAAAAAAG4SkahzOKgZgFotgAIosCCIJgnMRCAqLlgCKvTwBNgIkA5lwE4GnDguZdAAEIAW7bwcgDHJb0WS0WUXZkokWaBHx4wKbY7TigANIU/t980QCGzI/IkCsdbqJZwY1ZOgWDngIamw3I43435Dd+zJ1kNmKVp/DvXNAwaNm//////////////////+/NZkMZ5cAl0CpbZ3oiwloFA5GyIWNzOYVLt1bpXPX+pABI2fo5rMZpgVYIzYqgxt92ajECqUKh2G9gaOCVRC23VSRVypHfbvb7wYcwEM25WArF0esm1yKzDixrJRdcBGtcpBZTFbFbIl8LIU4gWOnEdSITqkoGrHWJ8ywn9eVFWWk3lC6m07qp1TXntHaWp6ekYHLrFoyzOXYiQnn2kWX2zqMaFBTca25vHKndPhJV66HRhQzL9lB3OT20KGTXuFHu62wm1qzoV/iTnaiLdc8o/D7B+1O94BrjSE3cia6U1A5XNp0kHmUj8IMBaeiGaiNJV7b1csb0bq8EWYo2h1TuipR+7hmYjxeZsonGLNcmgsKp5EUDCEj9SvRyxX2uMUNfINmfNqglBYNNtjtNmdwWV2ly4uQKheyDyka2RTRoQ3IEfs+0BNcGJ4Z5AnmHNpFbCKW5PsXkAzJ6VVzzVMo0fwIUpQQT67itTNRE946/NxDashl9KuAFUbZ6yW91vObh+WAMZ1mQ1J4wotF6KXHuo65X6wSz406hW/T6XZMf/6W+HGYUxCDfhyjPaoMGcWccmbYM/H35NdHTOd79Jg0ho/BDBvRy2vcg8pHsv07UYiKrDFeqzL0Qk7qCkXLuukl2EKuR3xS6VtsLEaT0BfWoDYoQ1YvEjjT729XNMYoCX3j+2ApedBG/UHLOJ7AAnfPSqdmmePsY+522MpfPaf7kf6fIJMn0/4SE6PmuI3yjyeGjWn+1qj/ukf09DE |
| { | |
| "captchaResult": "CAPTCHA_NOT_NEEDED", | |
| "kind": "pagespeedonline#result", | |
| "id": "https://www.powr.io/", | |
| "loadingExperience": { | |
| "id": "https://www.powr.io/", | |
| "metrics": { | |
| "CUMULATIVE_LAYOUT_SHIFT_SCORE": { | |
| "percentile": 2, | |
| "distributions": [ |