Skip to content

Instantly share code, notes, and snippets.

View maxchuquimia's full-sized avatar

Max Chuquimia maxchuquimia

  • Sydney, Australia
View GitHub Profile
@maxchuquimia
maxchuquimia / .lldbinit
Created April 8, 2020 09:37
My .lldbinit
command alias objc expression -l objc -O --
command regex swift 's#(.+)#expression -l Swift -O -- defer { CATransaction.flush() }; %1#'
breakpoint set -n AppDelegate.application --one-shot true --auto-continue true
breakpoint command add
swift import Foundation
swift import UIKit
swift import MyApp_tvOS
swift import MyApp_iOS
swift func $printSubviews(of view: UIView) { print(view.perform("recursiveDescription")!) }
@maxchuquimia
maxchuquimia / kill_sim_clones.sh
Last active January 27, 2024 23:17
Shutdown all Simulator clones created by Xcode when running tests
xcrun simctl --set testing list | grep Booted | grep Clone | sed 's/^.*(\([A-Z0-9\-]*\)).*$/\1/g' | xargs -I {} xcrun simctl --set testing shutdown "{}"
@maxchuquimia
maxchuquimia / price-list.txt
Created July 19, 2023 23:03
Apple App Store price tiers (scraped from HTML of USD subscription price picker)
$0.29
$0.39
$0.49
$0.59
$0.69
$0.79
$0.89
$0.90
$0.95
$0.99
@maxchuquimia
maxchuquimia / SoundPlayer.swift
Created June 16, 2016 03:43
Super simple SoundFont (.sf2 or .dls) player example in Swift
//
// SoundPlayer.swift
// SoundPlayer
//
// Created by Max Chuquimia on 16/06/2016.
//
import Foundation
import AVFoundation
@maxchuquimia
maxchuquimia / asn1-der-decode.swift
Last active March 19, 2021 09:38
Decoding an ASN.1 DER Sequence in Swift
//
// Final implementation, as described in
// http://nspasteboard.com/2016/10/23/decoding-asn1-der-sequences-in-swift/
//
import Foundation
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Implementation (required)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@maxchuquimia
maxchuquimia / VIM.xccolortheme
Last active September 28, 2020 07:17
A handcrafted Xcode theme inspired by VIM
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DVTConsoleDebuggerInputTextColor</key>
<string>0.794852 1 0.923414 1</string>
<key>DVTConsoleDebuggerInputTextFont</key>
<string>Courier - 13.0</string>
<key>DVTConsoleDebuggerOutputTextColor</key>
<string>1 0.93397 0.612968 1</string>
@maxchuquimia
maxchuquimia / skype_time.sh
Created July 1, 2020 12:30
Calculate total time in Skype calls with a person (parsing Skype export)
cat skype_export.json | jq -r '.conversations[] | select(.displayName != null) | select(.displayName | contains("PEER NAME HERE")) | .MessageList[] | select(.messagetype == "Event/Call") | .content' | grep 'ended' | sed -e 's/^.*callId="\([^"]*\)".*<duration>\(.*\)<\/d.*$/\1 \2/g' | uniq | sed 's/^.* \(.*\)$/\1/g' | awk '{ SUM += $1} END { printf "%.2f", SUM }'
@maxchuquimia
maxchuquimia / URLRequest+Curl.swift
Created January 21, 2020 23:03
Represent URLRequest as a CURL string for easy debugging
extension URLRequest {
func curlString() -> String {
var curl = "curl --insecure"
// Method
if let method = httpMethod {
curl += " -X \(method)"
}
@maxchuquimia
maxchuquimia / import-uikit.sh
Last active January 14, 2020 05:45
Find all Swift files where you (probably) forgot to `import UIKit`. Useful for when you remove something that imports UIkit.h from your bridging header
grep -rlZE "(UI[a-zA-Z]*View|CG[A-Za-z]*)" --include "*.swift" --exclude-dir Pods . | tr '\n' '\0' | xargs -0 grep -LZ "^import UIKit"
@maxchuquimia
maxchuquimia / segment-download.sh
Last active January 14, 2020 05:44
A one-liner to download a segmented stream from the internet. Adjust the prefix zeros as needed in the printf.
for i in {0..999}; do i=$(printf "%03d" $i); echo -en " Downloading $i\r"; curl -s --fail "<url>/segment_$i.ts" >> /tmp/test.ts || break; done