Skip to content

Instantly share code, notes, and snippets.

View levibostian's full-sized avatar

Levi Bostian levibostian

View GitHub Profile
@levibostian
levibostian / README.md
Last active July 29, 2025 23:52
Beginner guide to conventional commits.

You know that when you are writing code and you make a git commit to your code? You know that when you make a commit, you are asked to type a message for that commit, right?

Conventional commits are a set of rules to follow for what to type for your commit messages. For example, let's say that you add a new feature to your latest app where users can upload a photo for their profile. Instead of writing a commit message like this: Add feature so users can upload profile picture for profile, you would write a commit message like this: feat(profile): user can upload profile picture. Notice that when you read both messages, they both mean the same thing. However, they are written in 2 different formats. When you write your commit message in the later format, we call that a Conventional commit.

Why?

Conventional commits are becoming more popular today and for good reason. Conventional commits are not only more descriptive to read, but they are written in a format that a computer can understand better

@levibostian
levibostian / TableViewExtensions.swift
Created June 22, 2020 18:56
Swift show/hide loading indicator at the bottom of the list. Great for paging.
import UIKit
extension UITableView {
func showLoadingFooter() {
let spinner = UIActivityIndicatorView(style: .gray)
spinner.startAnimating()
spinner.frame = CGRect(x: CGFloat(0), y: CGFloat(0), width: self.bounds.width, height: CGFloat(44))
self.tableFooterView = spinner
self.tableFooterView?.isHidden = false
@levibostian
levibostian / loop.sh
Last active April 20, 2020 16:28
CLI to run command until success, or timeout.
#!/bin/bash
# Script that executes a command until it succeeds or timesout.
# Usage: `./bin/loop.sh command-here`
# You can override the default parts of the script by:
# `SLEEP_TIME=1 MAX_TRIES=2 ./bin/loop.sh command-here`
#
# The script will send STDOUT message giving you an update on how things are going. The exit code of the command will be successful or failed depending on if the command succeeded before the timeout.
# Thanks, https://stackoverflow.com/a/12321815/1486374
@levibostian
levibostian / README.md
Last active July 31, 2020 20:45
Coordinator pattern scenarios. For project: https://github.com/daveneff/Coordinator

Scenarios

This document gives you suggestions on how to handle different scenarios in your project and how can you use Coordinator in each scenario.

This document is meant to give you ideas. Remember, however, Coordinator is flexible. Solve each problem in a way that fits your app best.

Swap UIViewControllers

Let's say that you have a scenario where you are displaying a screen and after you are complete with that screen, you need to swap to another screen.

@levibostian
levibostian / AutoMockable.stencil
Created March 15, 2020 18:42
Sourcery advanced templates
// swiftlint:disable line_length
// swiftlint:disable variable_name
import RxSwift
import Foundation
#if os(iOS) || os(tvOS) || os(watchOS)
import UIKit
#elseif os(OSX)
import AppKit
#endif
@levibostian
levibostian / README.md
Last active February 19, 2021 22:56
Installing and managing Java on macOS. Handy for Android dev.

Android Studio comes with a SDK for java built in. You can use that as it defaults pretty easily. However, you may need more.

Installing java

We love homebrew. That is our preferred way of installing everything, including java. The instructions below are up to date as of the time of writing, but it may not work anymore. Check out this answer to get the latest tips on how to install java.

brew tap AdoptOpenJDK/openjdk
@levibostian
levibostian / howto.md
Last active April 18, 2023 10:30
How to run Ruby scripts from within XCode build phase script

It is assumed that you know what a XCode build phase is and how to create them. Create one, then follow the directions below to get it all working.

  • You may find more success from creating a bash script that executes ruby code then to copy/paste the ruby code directly into XCode's script box. This way you can use XCode as the place to setup your environment and then run the code in the ruby script you want to have executed.

To do this, it's quite simple. Create a new file in the root directory of your project. script.rb, for example.

Then, in your XCode build phase, keep the shell at it's default of /bin/sh and have the script run the ruby script:

./script.rb
@levibostian
levibostian / Foundation.swift
Created November 24, 2019 19:53
XCTest extensions
import Foundation
import XCTest
extension XCTest {
func XCTAssertNewer(_ newer: Date, _ older: Date, file: StaticString = #file, line: UInt = #line) {
XCTAssertGreaterThan(newer.timeIntervalSince1970, older.timeIntervalSince1970, "\(newer) is *not* newer then \(older)", file: file, line: line)
}
func XCTAssertOlder(_ older: Date, _ newer: Date, file: StaticString = #file, line: UInt = #line) {
XCTAssertGreaterThan(older.timeIntervalSince1970, newer.timeIntervalSince1970, "\(older) is *not* older then \(newer)", file: file, line: line)
@levibostian
levibostian / Contact.kt
Created June 20, 2019 14:13
Read contacts in Android
import android.os.Parcelable
import kotlinx.android.parcel.Parcelize
@Parcelize
data class Contact(val contact_name: String,
val emails: List<String>?,
val phone_numbers: List<String>?): Parcelable
@levibostian
levibostian / log.txt
Last active March 4, 2019 19:30
kotlin crash - Cause: Back-end (JVM) Internal error: wrong code generated - Teller
Executing tasks: [:teller-android:generateDebugSources, :teller-android:compileDebugSources, :teller-android:createMockableJar, :teller-android:compileDebugUnitTestSources]
> Transform rxandroid.aar (io.reactivex.rxjava2:rxandroid:2.1.0) with JetifyTransform
> Transform multidex.aar (androidx.multidex:multidex:2.0.1) with JetifyTransform
> Task :teller-android:preBuild UP-TO-DATE
> Transform rxandroid.aar (io.reactivex.rxjava2:rxandroid:2.1.0) with ExtractAarTransform
> Task :teller-android:preDebugBuild UP-TO-DATE
> Transform multidex.aar (androidx.multidex:multidex:2.0.1) with ExtractAarTransform
> Transform rxandroid.aar (io.reactivex.rxjava2:rxandroid:2.1.0) with AarTransform
> Transform rxandroid.aar (io.reactivex.rxjava2:rxandroid:2.1.0) with AarTransform