Skip to content

Instantly share code, notes, and snippets.

View T1T4N's full-sized avatar
👽

Robert Armenski T1T4N

👽
View GitHub Profile
@T1T4N
T1T4N / primes.py
Created December 14, 2022 12:26
Python one liner - first 10 primes
print(list(filter(lambda x: all(x%d for d in range (2,x)), range(2, 3**10)))[:10])
@T1T4N
T1T4N / update-a-git-mirror.sh
Last active February 8, 2024 09:37
Mirroring a git repo
git clone --bare https://github.com/project/repo.git
cd repo
git push --mirror ssh://git@bitbucket/lib/new-repo.git
#f this results in the following error, go to step 4: 
#You are attempting to update refs that are reserved for Bitbucket's pull request functionality. Bitbucket manages these refs automatically, and they may not be updated by users.
#remote: Rejected refs:
#remote:     refs/pull-requests/1/from
git push ssh://git@bitbucket/lib/new-repo.git
@T1T4N
T1T4N / mirror-git-repo.sh
Last active February 7, 2024 10:37
Mirroring a git repository to Bitbucket
git clone --bare https://github.com/project/repo.git
cd repo
git push --mirror ssh://git@bitbucket/lib/new-repo.git
# if this results in the following error:
# You are attempting to update refs that are reserved for Bitbucket's pull request functionality. Bitbucket manages these refs automatically, and they may not be updated by users.
# remote: Rejected refs:
# remote: refs/pull-requests/1/from
#
# then use the following commands
Never set WKWebView as the top view in a XIB, otherwise:
WKWebView: configuration cannot be nil
Correct approach: Add it as a subview with correct constraints
@T1T4N
T1T4N / gist:a77ddb077469e3a05a29241db6dbe73d
Created October 24, 2022 12:19
Xcode 12+ - Sane navigation flow for editor tabs
⌘ + ⇧ + O - Open in temporary Tab
⌘ + ⌥ + O - Make tab permanent
# 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 April 2, 2024 07:29
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"