Skip to content

Instantly share code, notes, and snippets.

View joemasilotti's full-sized avatar
📱
Helping Rails developers build iOS and Android apps with Turbo Native.

Joe Masilotti joemasilotti

📱
Helping Rails developers build iOS and Android apps with Turbo Native.
View GitHub Profile
@joemasilotti
joemasilotti / UI Testing - Mocking Network Data
Last active January 18, 2024 03:35
Xcode UI Testing - How to mock network data
.
@joemasilotti
joemasilotti / .rouge-line-focusing.md
Last active November 6, 2023 07:03
Rouge syntax highlighting with line focusing

This gist shows how I'm using Rouge to highlight individual lines of code. On top of the existing syntax highlighting.

I'm using Sitepress which uses markdown-rails under the hood. But this should be applicable to any application rendering markdown with Redcarpet - sub out ApplicationMarkdown as your renderer.

Append @[] when setting the language in a fenced code block to highlight lines of code. Dashes will cover the range, inclusive. Commas will highlight each line.

Examples:

```swift@[4-6]
@joemasilotti
joemasilotti / Endpoint.swift
Last active May 28, 2023 16:54
A Rails-like environment helper for iOS apps, from https://masilotti.com/rails-like-endpoint-switcher-for-ios-apps/
import Foundation
enum Environment: String {
case development, staging, production
}
extension Environment {
static var current: Environment {
if isAppStore {
return .production
@joemasilotti
joemasilotti / ExampleView.swift
Created March 1, 2023 01:15
An idea to make interaction with design constants more natural
struct ExampleView: View {
var body: some View {
VStack(spacing: .default) {
HStack(spacing: .xl) {
Text("Is this crazy?")
.font(.system(size: .lg, weight: .semibold))
}
}
}
}
@joemasilotti
joemasilotti / Gemfile
Last active October 25, 2022 08:40
How To Test PDFs with Capybara Blog post with details: http://pivotallabs.com/test-pdfs-with-capybara/
group :test do
gem 'rspec-rails'
gem 'capybara'
gem 'pdf-reader'
end
@joemasilotti
joemasilotti / show.html.erb
Created October 19, 2022 20:51
Tailwind CSS v3.2 data attribute variants + Stimulus
<div data-controller="toggle">
<button type="button" data-action="toggle#toggle">Toggle</button>
<div data-toggle-target="element" data-expanded="false" class="data-[expanded=false]:hidden">
Here is some toggle-able content!
</div>
</div>
@joemasilotti
joemasilotti / ..md
Last active September 13, 2022 14:20
Resetting NSUserDefaults in UI Testing

Resetting NSUserDefaults in UI Testing

  1. Add "UI-Testing" to launchArguments before launching the app under test
  2. On launch, check for the argument in AppDelegate.swift
  3. If it exists remove everything for the app's domain from NSUserDefaults
@joemasilotti
joemasilotti / .Pay subscription notifications.md
Last active August 16, 2022 13:40
Pay subscription changes

Goal: send a notification when a customer subscribes, churns, pauses, etc.

This is the barebones working version. Is there something I'm missing in Pay that could help with this?

If not, happy to clean it up and submit a PR if it will be valuable for others.

Note: This first-pass implementation is ugly, but the tests pass. There is obviously a lot to improve in terms of code quality, but my bigger focus is on the direction and idea.

@joemasilotti
joemasilotti / result_type.rb
Last active May 25, 2022 02:50
ResultType
module ResultType
extend ActiveSupport::Concern
module ClassMethods
def define_type(type)
define_method "#{type}?" do
true
end
end
end
@joemasilotti
joemasilotti / cold_message.rb
Created April 27, 2022 03:08
Service layer extraction
# AFTER the refactor
class ColdMessage
class BusinessBlank < StandardError; end
class MissingSubscription < StandardError; end
class ExistingConversation < StandardError
attr_reader :conversation