Skip to content

Instantly share code, notes, and snippets.

Avatar
🛠️
Building stuff

Gio Lodi mokagio

🛠️
Building stuff
View GitHub Profile
@mokagio
mokagio / Date+SyntaxSugar.swift
Created Jun 2, 2021
Swift Date with year, month, and day
View Date+SyntaxSugar.swift
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 Mar 5, 2021
Fastlane, Ruby, constants, and functions
View Fastfile
#
# Proper version
#
WRAP_EMOJI = "🌯"
lane :test do |options|
UI.message wrap_in_emoji("Hello, World!")
end
def wrap_in_emoji(string)
@mokagio
mokagio / repro-3708.sh
Last active Jun 11, 2020
Script to reproduce the behavior described in https://github.com/rubygems/rubygems/issues/3708
View repro-3708.sh
#!/bin/bash
# I run this only on macOS
set -ex
ISSUE=3708
ROOT_DIR=/tmp/repro-$ISSUE
rm -rf $ROOT_DIR
@mokagio
mokagio / md_footnotes.md
Last active Aug 4, 2020
Markdown Footnote
View md_footnotes.md
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

@mokagio
mokagio / tables.md
Last active Feb 14, 2019
How to do tables in GitHub flavoured Markdown
View tables.md

This:

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

becomes this:

@mokagio
mokagio / Good.md
Created Jan 16, 2019
Companies doing Good Stuff
View Good.md
  • Neybox health tracking apps
  • Stile give teachers tools to teach better STEMs
  • Chargefox help locate charge stations for electric cars
View Gmail_Web_Keyboard_Shortcuts.md
Action Shortcut
Add a Cc ⇧⌘c
Mark as unread ⇧u
Undo z
@mokagio
mokagio / SimpleDataSource.swift
Created May 18, 2018
Ready made `UITableViewDataSource` for those simple scenarios in which you want to display homogeneous data, of type `T`, in a single section, on a standard `UITableViewCell`
View SimpleDataSource.swift
// swift version 4.1
import UIKit
/// Ready made `UITableViewDataSource` for those simple scenarios in which you want to display
/// homogeneous data, of type `T`, in a single section, on a standard `UITableViewCell`.
class SimpleDataSource<T>: NSObject, UITableViewDataSource {
typealias Item = T
let data: [T]
@mokagio
mokagio / sort-tests.rb
Created Nov 28, 2017
Script used to get the slowest tests from Xcode as part of the Code Quality Challenge
View sort-tests.rb
# Run your tests in Xcode, copy the result in the console in a file, the run
#
# cat your_file | ruby sort-tests.rb
report = ARGF.read
times = report.lines
.select { |l| l.match(/Test Case .* \((\d*\.\d*) seconds\)/).nil? == false }
.map do |m|
{
@mokagio
mokagio / bootstrap
Created Nov 22, 2017
CQC day 8 bootstrap script
View bootstrap
#!/bin/bash
#
# Setup your local copy of the app. Run this script immediately after cloning
# the codebase.
#
set -eo pipefail
# First ensure all the required tools are available