Skip to content

Instantly share code, notes, and snippets.

View mokagio's full-sized avatar
🛠️
Building stuff

Gio Lodi mokagio

🛠️
Building stuff
View GitHub Profile
@mokagio
mokagio / .editorconfig
Last active October 1, 2024 10:48
.editorconfig for Xcode 16
[*]
insert_final_newline = true
trim_trailing_whitespace = true
[*.{swift,h,m}]
indent_style = space
indent_size = 4
# Other properties Xcode 16 supports, as per https://developer.apple.com/documentation/xcode-release-notes/xcode-16-release-notes
#
@mokagio
mokagio / install-xcode-cli-tools.sh
Created September 9, 2015 09:28
Install Xcode CLI Tools without GUI
#!/bin/bash
# See http://apple.stackexchange.com/questions/107307/how-can-i-install-the-command-line-tools-completely-from-the-command-line
echo "Checking Xcode CLI tools"
# Only run if the tools are not installed yet
# To check that try to print the SDK path
xcode-select -p &> /dev/null
if [ $? -ne 0 ]; then
echo "Xcode CLI tools not found. Installing them..."
@mokagio
mokagio / tables.md
Last active August 31, 2023 00:14
How to do tables in GitHub flavoured Markdown

This:

heading 1 | heading 2 | heading 3
--- | --- | ---
abc | bcd | cde
def | efg | fgh

becomes this:

@mokagio
mokagio / String+Random.swift
Created February 27, 2023 01:55
Two methods to create random strings in Swift
extension String {
enum RandomStringGenerationError: Error {
case secRandomCopyBytesFailed(status: Int32)
}
/// Returns a cryptographically secure string generated with characters from the given `Set<Character>` and with length
/// `length`.
///
/// - Complexity: O(n) where n is the given `length`.
// I find hard-wrapping better because it makes it easier to diff changes over
// long line **without** relying on the tool of choice supporting
// soft-wrapping. Change at the end of a "long" line
// Change at the end of a "long" line
-Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequatypo.
+Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
// Change with 80 characters hard-wrap
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
@mokagio
mokagio / pre-commit
Created July 15, 2014 23:49
A git pre-commit hook to remove trailing whitespaces
# #!/bin/bash
#
# git hook script to find and fix trailing whitespace
# in your commits. Bypass it with the --no-verify option
# to git-commit
#
# usage: make a soft link to this file, e.g., ln -s ~/config/pre-commit.git.sh ~/some_project/.git/hooks/pre-commit
#
# credits: https://github.com/imoldman/config/blob/master/pre-commit.git.sh
@mokagio
mokagio / ExampleView.swift
Last active July 20, 2021 05:51
SwiftUI simple view body printout – Xcode 13 beta 2
import SwiftUI
struct ExampleView: View {
var body: some View {
VStack {
Text("Title").bold()
Text("Subtitle")
}
}
}
@mokagio
mokagio / Date+SyntaxSugar.swift
Created June 2, 2021 20:48
Swift Date with year, month, and day
extension Date {
static func with(calendar: Calendar = .current, year: Int, month: Int, day: Int) -> Date {
// Because the `calendar` value is non-nil, it's safe to force unwrap the `date` value
DateComponents(calendar: calendar, year: year, month: month, day: day).date!
}
}
@mokagio
mokagio / Fastfile
Created March 5, 2021 04:03
Fastlane, Ruby, constants, and functions
#
# Proper version
#
WRAP_EMOJI = "🌯"
lane :test do |options|
UI.message wrap_in_emoji("Hello, World!")
end
def wrap_in_emoji(string)
@mokagio
mokagio / md_footnotes.md
Last active August 4, 2020 21:00
Markdown Footnote
Lorem ipsum dolor sit amet, consectetur adipiscing elit[<sup id="footnote-id">1</sup>](#fn1).

### Footnotes
1. <span id="fn1"></span> [_consectetur adipiscing elit_](#footnote-id). Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Example