- Add
lint.ymlunder.github/workflows/ - Add the
swiftlintstub underbin/ - Don't forget to
chmod +x bin/swiftlint
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
| # … | |
| Dotenv::Rails.files.unshift(".env.stripe-webhooks.local") if Rails.env.development? # Dotenv technically optional… You'd just need to parse this yourself without it. | |
| # … |
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
| @propertyWrapper | |
| struct LocalizedString { | |
| let localizedKeyValue: LocalizedStringKey | |
| let stringValue: String | |
| // This initializer handles string literals | |
| init(wrappedValue: LocalizedStringKey) { | |
| self.localizedKeyValue = wrappedValue | |
| let mirror = Mirror(reflecting: wrappedValue) |
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
| FROM registry:2 |
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
| # neat one-liner to stick invalid records on top for instance if you're using fields_for to edit a nested collection of records | |
| some_query.partition(&:invalid?).flatten |
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
| thing.audio.open do |file| | |
| input = file.path | |
| output = "#{file.path}.mp3" | |
| filename = "#{thing.audio.filename}.mp3" | |
| system("ffmpeg", "-i", input, output, exception: true) | |
| thing.audio_mp3.attach(io: File.open(output), filename:, content_type: "audio/mpeg") | |
| ensure | |
| File.delete(output) if File.exist?(output) | |
| 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
| name: lint | |
| on: | |
| pull_request: | |
| push: | |
| branches: [ master ] | |
| jobs: | |
| lint-js: | |
| if: ${{ !startsWith(github.head_ref, 'dependabot/') }} |
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
| max_redirects = 3 | |
| # Follow redirects | |
| response = max_redirects.times.lazy.filter_map { | |
| puts "Requesting #{url}…" | |
| response = Net::HTTP.get_response(URI(url)) | |
| case response | |
| when Net::HTTPRedirection | |
| url = response["location"] | |
| 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
| github_keys = accounts.map { |account| | |
| Net::HTTP.get(URI("https://github.com/#{account}.keys")) | |
| .lines(chomp: true) | |
| .map { |line| "#{line} @#{account}" } | |
| }.flatten |
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
| class RawQueryParam < SimpleDelegator | |
| def to_query(key) | |
| "#{key}=#{value}" | |
| end | |
| end | |
| # … | |
| whatever_url(@whatever, host: "bogus.dev", blah: RawQueryParam.new("{test}")) | |
| # => "http://bogus.dev/whatever?blah={test}" |
NewerOlder