Skip to content

Instantly share code, notes, and snippets.

View T1T4N's full-sized avatar
👽

Robert Armenski T1T4N

👽
View GitHub Profile
# Cloning a treeless repo from a reference on disk
git clone --reference "$HOME/Developer/repo-ref" --filter=tree:0 ssh://git@bitbucket/repo.git repo
@T1T4N
T1T4N / run_whisper.sh
Created October 10, 2022 14:47
Run OpenAI Whisper on M1 MacBook Pro
# Original author: https://twitter.com/esizkur/status/1579207536812904448
git clone https://github.com/ggerganov/whisper.cpp
cd whisper.cpp
make
./download-ggml-model.sh large
ffmpeg -i recording.m4a -acodec pcm_s16le -ar 16000 recording.wav
./main -m models/ggml-large.bin -l de -f recording.wav | tee transcript.log
# borrowed from https://github.com/ytdl-org/youtube-dl/blob/master/youtube_dl/jsinterp.py
pairs = dict(zip(*zip('()', '{}', '[]')))
#{
# '(': ')',
# '{': '}',
# '[': ']'
#}
@T1T4N
T1T4N / generate-xcode-compilation-database.md
Last active June 20, 2024 13:53
Generate a JSON Compilation Database from an Xcode project

Introduction

A JSON compilation database is a very handy output format which is parsed and used by many development tools. Unfortunately for us Apple Developers, it is not straightforward to generate one from within Xcode, as it is (probably) not Apple's priority and therefore there is no toggle/switch/setting that can be easily enabled to get this information.

There is however a solution, thanks to Apple using Clang/LLVM as their main toolchain.

Implementation

The standard way to generate this with clang would be to use the -MJ flag and give it a file name that typically corresponds to the input file. Using this flag indirectly through Xcode is hard, given that we're not aware of all the other arguments when a compiler call is executed.

However, there is a second hidden/badly documented LLVM flag: -gen-cdb-fragment-path - it is implemented in terms of -MJ and has the same functionality, but it's argument in contrast is an output directory.

@T1T4N
T1T4N / infer-macos.rb
Created July 25, 2022 12:24
Build Infer on macOS 12 Monterey using Xcode 13.4.1 on Apple Silicon M1 (Pro)
class InferCustom < Formula
desc "Static analyzer for Java, C, C++, and Objective-C"
homepage "https://fbinfer.com/"
license "MIT"
revision 1
version "532dd663d"
head "https://github.com/facebook/infer.git", branch: "main"
stable do
url "https://github.com/facebook/infer/archive/532dd663d.tar.gz"
@T1T4N
T1T4N / clang-format-for-xcode-12.md
Created July 12, 2022 14:43
Getting clang-format to work in Xcode 12+

Version info

The original repository can be found on GitHub: XcodeClangFormat

Tested with version 1.2.1 (commit 240bba0)

Setup

  1. Clone the original repository from GitHub (XcodeClangFormat)
  2. Navigate into the directory (cd XcodeClangFormat)
  3. Make sure to read the README.md file
  4. Execute ./configure in the repository directory, which will generate an xcconfig file
@T1T4N
T1T4N / build-an-xcode-source-extension.md
Created July 12, 2022 14:38
Creating an Xcode Source Extension

Build Settings

Depending on the project requirements, these are the necessary changes it running:

  • Set the correct ARCHS (standard or only x86_64)
  • Add XcodeKit.framework dependency (Embed and Sign) to the extension target
  • If Swift code needs to be parsed, Embed and Sign the following library:
    • $(DEVELOPER_DIR)/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/lib_InternalSwiftSyntaxParser.dylib

Troubleshooting

Menu item is there but disabled

@T1T4N
T1T4N / stress-ng-test.sh
Created July 5, 2022 19:22
Linus Tech Tips (LTT) M1 Ultra Review
# M1 Ultra
stress-ng --cpu 20 --cpu-method idct --matrix 20 --matrix-method mean --maximize
# M1 Max
stress-ng --cpu 10 --cpu-method idct --matrix 10 --matrix-method mean --maximize
# Intel PC
stress-ng --cpu 24 --cpu-method fft --matrix 24 --matrix-method mean --maximize
@T1T4N
T1T4N / git-sparse-checkout.md
Last active July 11, 2022 10:06
Git sparse checkout

Introduction

Starting with Git 2.37.0 there are a lot of improvements, particularly the full integration and rollout of sparse index. Using partial checkouts can really help the speed of git commands, among others committing, amending, stashing and querying status. This guide is to be considered experimental, so please don't modify/destroy your main repo checkout. A personal recommendation: use a sparse worktree

Usage

Note: the sparse-checkout.txt file mentioned below is a simple newline separated list of relative directories within the repository.

@T1T4N
T1T4N / QueryIPAddresses.swift
Created June 21, 2022 09:31
Query internal iOS IP addresses from all interfaces and return them in a Swift-friendly structure
struct IPData {
var address: String
var family: UInt8
var interface: String
}
func getIpAddresses() -> [IPData] {
var addresses: [IPData] = []
// Get list of all interfaces on the local machine: