Skip to content

Instantly share code, notes, and snippets.

@gelosi
Created November 10, 2025 08:28
Show Gist options
  • Select an option

  • Save gelosi/cda634b36d474fc2e8b6b99802ed3920 to your computer and use it in GitHub Desktop.

Select an option

Save gelosi/cda634b36d474fc2e8b6b99802ed3920 to your computer and use it in GitHub Desktop.
useful cmd commands for copypasta activities (i think, this will be moved to the repo)
#shabash
print "danger: this script meant to be copypasta archive, not to run."
exit 1
find . -type f -name "*\.json" | grep ".imageset" | xargs grep -C 2 "\"idiom\"\ \:\ \"universal\""
sed -i '' 's/"idiom" : "universal"/"idiom" : "iphone"/g' file.txt
# non-destructive
find . -type f -name "*\.json" | grep ".imageset" | xargs sed 's/"idiom" : "universal"/"idiom" : "iphone"/g' %
#carthage
carthage update --platform ios --cache-builds --no-use-binaries --use-ssh
rm -rf ${TMPDIR}TemporaryItems/*carthage*
ls ~/Library/Caches/org.carthage.CarthageKit
# parsing Cartfiles and finding things / dependencies in iOS projects
~/Library/Caches/org.carthage.CarthageKit/
## where name pattern filter using regEx replace \n pass list to the next grep filter ...
find Carthage -name "Cartfile" | grep -E "some\-|other\-" | tr '\n' '\0' | xargs -n 1 -0 grep -H "line-to-find" | sort
find Carthage -name "Cartfile" | tr '\n' '\0' | xargs -n 1 -0 grep -H "line-of-interest" | sort
## size of binaries
find . -type f -perm +0111 | grep -v '.dylib' | grep -v '.png' | grep -v '.bundle' | xargs du -csh | sort -h
find . -type f -perm +0111 | grep -vE '\.dylib|\.png|\.bundle|\.h' | xargs du -csh | sort -h
## maybe cooler version – instead of filtering out, include only "kinda binary name without extension"
find . -type f -perm +0111 | grep -E '\/\w+$' | xargs du -csh | sort -h
## find files grep them and be cool
find . -type f | grep -E '\.m+$|\.swift$' | grep -v 'Test?|Mock\|Example' | tr '\n' '\0' | xargs -n 1 -0 grep -m1 -H -- "trackingAuthorizationStatus"
# the translations
## regex to find stings not containing string
^((?!badword).)*$
## validation
find . -name "*.strings" | tr '\n' '\0' | xargs -n 1 -0 plutil -lint -s
## convertions
plutil -convert binary1 -o res.strings Localisable.strings
## jq simple query into json
| jq '.rootarrayname[].struct.field'
# diffing
diff -y --suppress-common-lines file1 file2 | wc -l
## renaming branches
git branch -m release/v21.11.1 hotfix/v21.11.1
git fetch origin
git branch -u origin/hotfix/v21.11.1 hotfix/v21.11.1
# searching things inside sub-projects which are using carthage and copying resources
find Carthage -name "Cartfile.resolved" | grep -E "some\-|other" | sed 's/\/Cartfile.resolved//' | tr '\n' '\0' | xargs -n 1 -0 grep -lr "carthage copy-frameworks"
# fun
say -v Fred --rate 1 "You have 5 minutes to the next meeting. Djude."
# versioning from PLIST
/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" ./Path/App-Info.plist
## itunes request ShotName (uses application specific password)
xcrun altool --list-providers -u "[email protected]" -p "password"
#resign git commits
git rebase --exec 'git commit --amend --no-edit -n -S' -i branchName
# xcodebuild tests
# -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.1'
set -o pipefail && env NSUnbufferedIO=YES \
xcodebuild \
-workspace ./Volo.xcworkspace \
-scheme AppBuildScheme \
-destination 'platform=iOS Simulator,name=iPhone 11,OS=13.6' \
-resultBundlePath './output/AppBuildScheme.xcresult' \
-parallel-testing-enabled YES \
-parallel-testing-worker-count 2 \
-maximum-concurrent-test-simulator-destinations 2 \
-testPlan 'SomeUITests' UITEST_VAR=value \
-retry-tests-on-failure \
-test-iterations 3 test-without-building
| tee '/path/to/the.log'
| xcbeautify
## swiftformat with the problem on the spaces in file names?
gst -s | cut -c 4- | grep ".swift" | xargs swiftformat --verbose --dryrun
### open ios sumulator with deeplink
xcrun simctl openurl booted https://....
xcrun simctl shutdown all
### xcode ####
xcrun xcresulttool get --path pathToThe.xcresult --format json > tests.json
### git ####
# show the changes after rebase/merge
git status --porcelain | grep '^??' | cut -c4-
# ,..and clean them
git status --porcelain | grep '^??' | cut -c4- | xargs rm
### git hooks prototype ###
git --no-pager diff --cached --name-only --diff-filter=d "*.swift" | swiftformat \
&& git --no-pager diff --name-only --diff-filter=d "*.swift" | swiftformat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment