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 / 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 / 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 / .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 / 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 / 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 / whitespace-remove.sh
Last active January 14, 2020 05:44
Find Swift files with whitespace-only lines and replace them with empty lines
while read -r line ; do echo "$line"; sed -i '' 's/^ *$//g' "$line"; done < <(grep -rl --exclude-dir Pods --include "*.swift" "^ *$" .)
@maxchuquimia
maxchuquimia / print_args.swift
Last active October 15, 2019 23:37
Log a function call with it's arguments
func print_args(function: String = #function, prefix: String = "", _ args: Any...) {
let log = function
.components(separatedBy: ":")
.enumerated()
.reduce(prefix.isEmpty ? "" : prefix + " ") { (log, arg1) -> String in
let (idx, chunk) = arg1
if idx == args.count - 1 {
return log + "\(chunk): \(args[idx])"
} else if idx < args.count {
@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
@maxchuquimia
maxchuquimia / OSThirteenDynamicFixes.h
Created September 12, 2019 05:23
Fixes large titles in iOS13 when you still need to compile with Xcode 10 and Swift.
#import <Foundation/Foundation.h>
@class UINavigationBar;
NS_ASSUME_NONNULL_BEGIN
@interface OSThirteenDynamicFixes: NSObject
/**
On iOS 13.0+, ensure the background color and title properties are set properly (they are not available in Xcode 10, these are from a future SDK)
@maxchuquimia
maxchuquimia / text-to-flags.swift
Created August 30, 2019 05:59
An old script of mine that tries to convert a string into Slack flag codes
// DEVELOPER_DIR=/Applications/Xcode9-beta.app/Contents/Developer/ swift text-to-flags.swift
import Foundation
let input = CommandLine.arguments[1].uppercased()
if input.rangeOfCharacter(from: CharacterSet(charactersIn: "ABCDEFGHIJKLMNOPQRSTUVWXYZ").inverted) != nil {
fatalError("unsupported character found")
}
func request(_ r: URLRequest) -> [String] {