Skip to content

Instantly share code, notes, and snippets.

View otto-schnurr's full-sized avatar

Otto Schnurr otto-schnurr

View GitHub Profile

git commands to update local copy when default branch name has been changed from master to main:

git branch -m master main
git fetch origin

git branch -u origin/main main

# source: @_sa_s
# Quick Xcode tip: if you want to launch a project with a particular Xcode version without running xcode-select, run
env DEVELOPER_DIR=/Applications/Xcode_11.3.app xed .
@otto-schnurr
otto-schnurr / ViewController+Extension.swift
Last active February 29, 2020 15:28
Simplest way to add a child view controller.
// A re-usable alternative.
// reference: https://rambo.codes/posts/2020-02-20-mvc-with-sugar
public extension UIViewController {
func install(_ child: UIViewController) {
addChild(child)
child.view.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(child.view)

Retrieving Logs from Device

Based on Stack Overflow answer here.

  • Do the things that make your app generate os_log messages.
  • Trigger a [sysdiagnose][].
    • Hold down volume up, volumn down, sleep button.
    • Wait for 1.5 seconds until the device to vibrates.
  • If that doesn't work, then press all three buttons briefly and then release.
@otto-schnurr
otto-schnurr / GitHub-Pages-Notes.md
Last active May 24, 2018 13:46
Notes: GitHub Pages

GitHub Pages

Compiled by Otto Schnurr from here in March 2017.

Basics

GitHub Pages is a static site hosting service.

@otto-schnurr
otto-schnurr / ios-logging.md
Last active March 27, 2021 07:47
Notes: iOS Unified Logging

From WWDC 2016: Unified Logging and Activity Tracing.

Apple Recommendations

  • os_log: Critical details for debugging issues.
  • os_log_info: Additional information to embed in error or fault reports.
  • os_log_debug: Optional, high-volume information that can be explicitly turned on during development.
  • os_log_error: Additional app information is bundled into the log message.
  • os_log_fault: Additional system information is bundled into the log message.
#!/usr/bin/env python
from fileinput import input as data
from itertools import imap
def ifasta(lines):
name, dna = None, ''
for line in imap(str.rstrip, lines):
if line.startswith('>'):
if name:
#!/usr/bin/env swift
import Foundation.NSString
private extension String {
var fastaID: String? {
guard hasPrefix(">") else { return nil }
return String(characters.dropFirst())
}
#!/usr/bin/xcrun swift -F .
// FileInput module from https://github.com/otto-schnurr/FileInput-swift
import FileInput
func complement(base: Character) -> Character {
switch base {
case "A": return "T"
case "T": return "A"
case "C": return "G"
case "G": return "C"
#!/usr/bin/xcrun swift -F .
// FileInput module from https://github.com/otto-schnurr/FileInput-swift
import FileInput
func complement(base: Character) -> Character {
switch base {
case "T": return "U"
default: return base
}
}