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
| [{"id":43,"latitude":56.4340324,"longitude":12.7268848,"name":"Båstad v","slug":"bastad-v","path":"/stations/bastad-v","status":"unresponsive","observations":[]},{"id":1,"latitude":55.37704,"longitude":14.15016,"name":"Dennis station","slug":"station-1","path":"/stations/station-1","status":"unresponsive","observations":[]},{"id":16,"latitude":63.397091,"longitude":13.075093,"name":"New Camp Åre","slug":"camp","path":"/stations/camp","status":"unresponsive","observations":[]},{"id":99,"latitude":60.5262,"longitude":18.3766,"name":"Örskär","slug":"orskar","path":"/stations/orskar","status":"active","observations":[{"id":2426287,"station_id":99,"speed":11.9,"direction":null,"max_wind_speed":13.8,"min_wind_speed":0.0,"temperature":null,"created_at":"2017-01-17T17:10:44.180Z","updated_at":"2017-01-17T17:10:44.180Z","speed_calibration":1.0}]},{"id":97,"latitude":57.3672,"longitude":17.0986,"name":"Ölands Norra Udde","slug":"olands-norra-udde","path":"/stations/olands-norra-udde","status":"active","observations":[{ |
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
| $spacers: '0', '4px', '8px', '16px', '24px', '32px', '40px'; | |
| // Aliases for easy use | |
| $spacer-0: nth($spacers, 1) !default; // 0 | |
| $spacer-1: nth($spacers, 2) !default; // 4px | |
| $spacer-2: nth($spacers, 3) !default; // 8px | |
| $spacer-3: nth($spacers, 4) !default; // 16px | |
| $spacer-4: nth($spacers, 5) !default; // 24px | |
| $spacer-5: nth($spacers, 6) !default; // 32px | |
| $spacer-6: nth($spacers, 7) !default; // 40px |
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
| module Reviews | |
| module PathHelpers | |
| def self.included(base) | |
| base.module_eval do | |
| alias_method :old_book_reviews_path, :book_reviews_path | |
| [Film, Book].each do |model| | |
| singular, plural = model.model_name.singular, model.model_name.plural | |
| alias_method "old_#{singular}_reviews_path".to_sym, | |
| "#{singular}_reviews_path" | |
| define_method "#{singular}_reviews_path" do |reviewable = nil| |
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
| # spec/support/shared_contexts/policy.rb | |
| # require this file from rails_helper.rb | |
| require 'pundit/rspec' | |
| RSpec.shared_context "Policy" do | |
| let(:user) { build_stubbed(:user) } | |
| subject { described_class } | |
| let(:model_class) { described_class.to_s.chomp('Policy').constantize } | |
| let(:permitted_attributes) do | |
| described_class.new(User.new, model_class).permitted_attributes |
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
| require 'benchmark' | |
| require 'active_support/all' | |
| arr = Array.new(1000_0000) { rand(1...20) } | |
| Benchmark.bm do |benchmark| | |
| benchmark.report "arr.sum { |n| n.odd? ? n : 0 }" do | |
| arr.sum { |n| n.odd? ? n : 0 } | |
| end | |
| benchmark.report "arr.select(&:odd?).sum" 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
| require 'rails_helper' | |
| RSpec.describe Post, type: :model do | |
| let(:blog) { FactoryBot.create(:blog) } | |
| it "can be created from an assocation" do | |
| post = blog.posts.create | |
| expect(post.persisted?).to be_truthy | |
| end | |
| end |
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
| <h1 id="title">Hello-World</h1> | |
| <p>Just your average Rails app. But with no features.</p> |
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
| module MyApp | |
| module Assocations | |
| def self.included(base) | |
| base.extend ClassMethods | |
| end | |
| module ClassMethods | |
| def decorate_association(**options, &block) | |
| yield AssocationDecorator.new(self, options) |
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
| Running via Spring preloader in process 13691 | |
| Loading development environment (Rails 6.0.2.1) | |
| irb(main):001:0> CountryImporterJob.perform_now('africa') | |
| Performing CountryImporterJob (Job ID: 10d7fa89-fb75-4e98-b007-78e3544af766) from Async(default) enqueued at with arguments: "africa" | |
| (0.2ms) BEGIN | |
| Country Create (0.9ms) INSERT INTO "countries" ("name", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["name", "Algeria"], ["created_at", "2020-04-22 10:13:32.879869"], ["updated_at", "2020-04-22 10:13:32.879869"]] | |
| (1.7ms) COMMIT | |
| (0.2ms) BEGIN | |
| Country Create (0.5ms) INSERT INTO "countries" ("name", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["name", "Angola"], ["created_at", "2020-04-22 10:13:32.897737"], ["updated_at", "2020-04-22 10:13:32.897737"]] | |
| (1.1ms) COMMIT |
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
| require 'benchmark' | |
| def vowel_cipher(string) | |
| string.tr "aAeEiIoOuU", "eEiIoOuUaA" | |
| end | |
| NEXT_VOWEL = {"a"=>"e", "A"=>"E", "e"=>"i", "E"=>"I", "i"=>"o", | |
| "I"=>"O", "o"=>"u", "O"=>"U", "u"=>"a", "U"=>"A"} | |
| def vowel_cipher_gsub(str) |