Skip to content

Instantly share code, notes, and snippets.

View dive's full-sized avatar
👹

Artem Loenko dive

👹
View GitHub Profile
@dive
dive / fix_ios_15_simulator_spotlight_cpu.sh
Created December 16, 2021 10:35
Fix the iOS 15 Simulator high CPU usage due to the Spotlight/Suggestions Engine
#!/bin/env sh
disable_suggestions() {
if [ -d "$1" ]; then
pushd "$1" || return
find . -name com.apple.suggestions.plist \
-exec echo {} \; \
-exec plutil -replace SuggestionsAppLibraryEnabled -bool NO {} \;
popd || return
fi
@dive
dive / fix-emacs-permissions-catalina.el
Created September 29, 2019 09:55
Fix Emacs permissions on macOS Catalina
;;; package --- Fix permissions for Emacs.app on macOS Catalina
;;; Author: Artem Loenko
;;; Mail-To: <artyom.loenko@mac.com>
;;; Commentary:
;;; Code:
(defconst _default-emacs-app-plist-path "/Applications/Emacs.app/Contents/Info.plist")
(defconst _temp-buffer-name "*fixing Emacs permissions*")
(defconst _temp-buffer (get-buffer-create _temp-buffer-name))
(with-current-buffer _temp-buffer (erase-buffer))
@dive
dive / xed_xcode_invocation_tool.md
Last active July 27, 2023 15:23
Xcode invocation tool - xed

Xcode invocation tool - xed

xed is a command-line tool that launches the Xcode application and opens the given documents (xcodeproj, xcworkspace, etc.), or opens a new document, optionally with the contents of standard input.

If you work from the command line, this tool is a better option than open (which can open Xcode projects as well). Why?

  • xed knows about the current selected Xcode version (open behaves unpredictably if you have multiple Xcode installed)
  • You can use it open all files from a specific commit (with a little help explained below). It is useful on code-reviews or when you want to explore significant changes in the repository
  • You can use it as a "quick open" helper. Helps with monorepo phenomena, when you have hundreds of projects in the repository (I will show you an example below)
@dive
dive / grammarly_ios_keyboard_unboxing.md
Last active April 9, 2023 11:17
Grammarly iOS Keyboard — Unboxing

Grammarly iOS Keyboard – Unboxing

Grammarly is a lovely writing assistant. Twenty million people use the tool across the globe according to the statistics available on the site. I use it too. No complaints, it does its job quite well, and I am a happy user. The only thing that always worried me is the Grammarly iOS Keyboard. As an iOS engineer, I know how easily you can collect different data, sensitive information, and even do not ask users about the consent. So, let's check what is inside the Grammarly iOS application.

TL;DR

  • Grammarly iOS uses at least three trackers (Adjust, AppsFlyer, Internal analytics)
  • Grammarly Keyboard has access to keystrokes, sensitive data, and able to send them over the network

Frameworks

@dive
dive / xcrun_xcode_development_tools.md
Last active December 16, 2022 01:48
Multiple Xcode versions or Why `xcrun` is your friend

Multiple Xcode versions or Why xcrun is your friend

The story

I recently spent a few hours helping a friend of mine investigate a weird issue in their Continuous Development infrastructure. Builds were failing with different fatal errors mostly related to SDK paths and .platform directory locations. At first sight, it was clear that something is wrong with the current selected Xcode, but all our initial attempts to catch the problem failed.

In the end, we isolated the problem; one of the tools they use changes PATH silently for the environment to simplify access to Xcode tools. Due to their internal logic, the CD pipeline changes a current selected Xcode a few times on the way within the same script. In some cases, the pipeline ended with xcodebuild in the environment's PATH that does not reflect the expected version after the xcode-select --switch command.

How? Pretty easy, actually. A simplified sequence looked like this:

@dive
dive / org-agenda-bulk-custom-functions.el
Created September 29, 2019 20:08
org-mode: org-agenda-bulk-custom-functions
(defun dive/org-mark-as-reviewed ()
"Mark current selected items as REVIEWED."
(org-set-property "REVIEWED" (org-time-stamp '(16) nil)))
(add-to-list 'org-agenda-bulk-custom-functions
'(?R dive/org-mark-as-reviewed))

Script

#!/bin/env sh

# http://haxx.se 
# http://daniel.haxx.se

sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder
@dive
dive / current_selected_installed_xcode.md
Last active April 16, 2022 23:29
How to get the current selected Xcode and list installed

How to get the current selected Xcode and list installed

Current Selected Xcode

xcode-select

This is the most common way to get the path to the selected instance:

xcrun xcode-select --print-path
@dive
dive / pxed.sh
Created July 19, 2020 15:39
Shell script to scan and open Xcode projects in the current directory
#!/usr/bin/env bash
set -euo pipefail
declare -a PROJECTS=()
function XcodeProjectsInCurrentDirectory() {
TEMP_FILE=$(mktemp)
SEARCH_PATTERN="*${1}*.xcodeproj"
find . -iname "$SEARCH_PATTERN" -type d -print0 | sort -z > "$TEMP_FILE"
while IFS= read -r -d $'\0'; do
@dive
dive / generate_xcworkspace.sh
Created November 8, 2020 21:30
Shell script to generate .xcworkspace with all .xcodeproj in the current directory
#!/usr/bin/env bash
set -eo pipefail
# Prepare the workspace in the TEMP directory
NAME="Temp.xcworkspace"
DATA_FILE="contents.xcworkspacedata"
TEMP_DIR=$(mktemp -d)
mkdir "${TEMP_DIR}/${NAME}"
touch "${TEMP_DIR}/${NAME}/${DATA_FILE}"