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
| # frozen_string_literal: true | |
| require "bundler/inline" | |
| gemfile(true) do | |
| source "https://rubygems.org" | |
| # Use Rails directly from GitHub (main branch - nightly/edge) | |
| gem "rails", github: "rails/rails", branch: "main" |
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
| #!/usr/bin/env ruby | |
| # frozen_string_literal: true | |
| # Reproduces a database deadlock in Rails with PostgreSQL/MySQL | |
| # | |
| # This script creates two threads that update records in opposite order, | |
| # reliably causing a database deadlock. | |
| # | |
| # Usage: | |
| # ruby deadlock_bug_report.rb |
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
| # Small simplification on the CSV part II blog post - https://www.sitepoint.com/guide-ruby-csv-library-part-2/ | |
| # Original code in the blog post | |
| def load_guests | |
| CSV.open('guests.csv', headers:true) do |guest| | |
| guests = guest.each | |
| guests.select do |row| | |
| row['Times arrived'].to_i > 10 | |
| 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
| int[] ar = Console.ReadLine() | |
| .Split(' ') | |
| .Where(token => !string.IsNullOrWhiteSpace(token)) | |
| .Select(token => Convert.ToInt32(token)) | |
| .ToArray(); |