Skip to content

Instantly share code, notes, and snippets.

View sowenjub's full-sized avatar
🏝️
Living in Paraside

Arnaud Joubay sowenjub

🏝️
Living in Paraside
View GitHub Profile
@sowenjub
sowenjub / ScrollViewThatFits.swift
Created February 28, 2024 08:34
ScrollViewThatFits
import SwiftUI
struct ScrollViewThatFits<Content: View>: View {
var showsIndicators: Bool
@ViewBuilder
var content: Content
init(showsIndicators: Bool = false, @ViewBuilder content: () -> Content) {
self.showsIndicators = showsIndicators
@sowenjub
sowenjub / ci_post_xcodebuild.sh
Created January 25, 2024 17:25
Uploading dSYMs files to Sentry with Xcode Cloud
#!/bin/sh
# Don't forget to run 'chmod +x ci_post_xcodebuild.sh' from the terminal after adding this file to your project
set -e
if [[ -n $CI_ARCHIVE_PATH ]];
then
# Install Sentry CLI into the current directory ($CI_PRIMARY_REPOSITORY_PATH/ci_scripts)
export INSTALL_DIR=$PWD
@sowenjub
sowenjub / Font+Fraction.swift
Created January 24, 2023 09:33
An extension to display fractions in SwiftUI. This is the answer I posted on https://stackoverflow.com/questions/71359423/how-can-i-show-a-fraction-with-swiftui/75219519#75219519
import SwiftUI
extension UIFont {
static func fractionFont(ofSize pointSize: CGFloat) -> UIFont {
let systemFontDesc = UIFont.systemFont(ofSize: pointSize).fontDescriptor
let featureSettings: [UIFontDescriptor.FeatureKey: Int] = [
.type: kFractionsType,
.selector: kDiagonalFractionsSelector,
]
let attributes = [
# mailboxes/concerns/mail_params.rb
module MailParams
extend ActiveSupport::Concern
def mail_params
attachments = build_attachments
body = build_rich_body(attachments)
{ subject: mail.subject, body: body, attachments: attachments.map { |a| a[:blob] } }
end
@sowenjub
sowenjub / SettingsSection
Created April 27, 2022 11:06
Toggling a Diagnostic Mode button in SwiftUI using Settings.bundle
struct SettingsSection: View {
@State var isShowingCloudLink = false
var body: some View {
Section {
if isShowingCloudLink {
NavigationLink(destination: CloudSettingsView()) {
Label(…)
}
}
@sowenjub
sowenjub / import_notes_app_to_evernote.applescript
Last active August 26, 2021 03:39 — forked from pdxmph/import_notes_app_to_evernote.applescript
Updated to import the modification date as well since that's how notes are sorted in Note.app
tell application "Notes"
set theNotes to every note of the folder "Notes"
repeat with thisNote in theNotes
set myTitle to the name of thisNote
set myText to the body of thisNote
set myCreateDate to the creation date of thisNote
set myUpdateDate to the modification date of thisNote
tell application "Evernote"
set theTransferredNote to create note with html myText ¬
title myTitle ¬
struct UIElementPreview<Value: View>: View {
enum Format {
case device, sizeThatFits, darkMode, rightToLeft, localizations, contentSizes, contentSizesMinMax
}
var formats: [Format]
/// Filter out "base" to prevent a duplicate preview.
private let localizations = Bundle.main.localizations.map(Locale.init).filter { $0.identifier != "base" }
@sowenjub
sowenjub / fun_with_splats.rb
Last active February 24, 2021 19:12
Some notes about the splat operator
def args_to_array(*args)
p args
end
args_to_array("hello", "world")
# ["hello", "world"]
def args_to_array(foo, *args) # Works, order matters
p "foo: #{foo}", args
end
args_to_array("hello", "world")
= f.label :email, required: true, class: "block text-xxs uppercase text-gray-500" do |label_builder|
= label_builder.translation
span.ml-2.normal-case.text-orange-400.text-xxs.font-semibold= t("required")
= f.email_field :email, autocomplete: false, required: true, class: "form-input mt-1 block w-full text-field focus:shadow-outline focus:border-green-300", placeholder: "richard@piedpiper.com"
# Or with the form builder
= f.label :email, required: true, class: "block text-xxs uppercase text-gray-500", required_class: "ml-2 normal-case text-orange-400 text-xxs font-semibold"
= f.email_field :email, autocomplete: false, required: true, class: "form-input mt-1 block w-full text-field focus:shadow-outline focus:border-green-300", placeholder: "richard@piedpiper.com"
@sowenjub
sowenjub / gist:1663423
Created January 23, 2012 14:35
Place a new marker and update fields in a form with gmaps4rails
<%= gmaps4rails(@json) %>
<% content_for :scripts do %>
<script type="text/javascript" charset="utf-8">
var markersArray = [];
// On click, clear markers, place a new one, update coordinates in the form
Gmaps.map.callback = function() {
google.maps.event.addListener(Gmaps.map.map, 'click', function(event) {
clearOverlays();
placeMarker(event.latLng);
updateFormLocation(event.latLng);