Skip to content

Instantly share code, notes, and snippets.

View jerrymarino's full-sized avatar

Jerry Marino jerrymarino

View GitHub Profile
T0.x1
@jerrymarino
jerrymarino / .md
Created September 21, 2021 22:46
Updating swift checkouts latest

Updating all swift checkouts to a tag

cd ~/swift-projects
find . -name \*.git  -exec /bin/bash -c 'cd $(dirname {}) && pwd && git fetch' \;
cd swift
./utils/update-checkout   --tag swift-5.4.2-RELEASE
@jerrymarino
jerrymarino / nix-tips.md
Created June 3, 2019 18:20
Tips for using the nix package manager on macOS
@jerrymarino
jerrymarino / SwiftBinaryDemangler.sh
Created January 30, 2019 19:49
Demangle the entire symbol table of a swift binary
nm __BINARY__ | awk '{ print $3 }' | xargs xcrun swift-demangle {} \; | less
@jerrymarino
jerrymarino / clean_modules.sh
Created September 6, 2018 00:54
Clearing clang's implicit module map for safe, incremental module enabled builds
#!/bin/bash
# This program cleans out the implcit module cache and modulemaps.
# Remove modulemaps to prevent loading lingering invalid modulemaps
# ( Genfiles is not cleared for each incremental build )
set -e
SCRIPTPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
WORKSPACE_DIR="$SCRIPTPATH/../"
EXEC_ROOT=$($WORKSPACE_DIR/tools/bazelwrapper info execution_root)
@jerrymarino
jerrymarino / gist:b7b8bfa7a3779ddf4f9662efc1c133f9
Created July 1, 2018 18:42
[Bash 1 liner] Delete all git branches besides the current one
# List all of the current branches - invert * as it represents the current one
# and will cause many issues
for B in $(git branch --list | grep --invert '*'); do git branch -D $B; done
# Additional ideas are cleaning up the remote ( i.e. ):
for B in $(git branch -a --list | grep --invert '*'); do git push origin : $B; done
@jerrymarino
jerrymarino / gist:9de95355173b77b559e388a2682fec65
Created June 23, 2018 18:00
Transform and compile raw SIL
#!/bin/bash
# Path to the swift compiler
SWIFT=(~/myswift/build/Ninja-DebugAssert/swift-macosx-x86_64/bin/swift)
SWIFTC=(~/myswift/build/Ninja-DebugAssert/swift-macosx-x86_64/bin/swiftc)
IFS='' read -d '' -r SOURCE <<"EOF"
struct Some {
let attr = 0
}
@jerrymarino
jerrymarino / UnsafeCallable.swift
Created June 17, 2018 04:06
How to call Swift functions by address
func helloWorld(a: Int) {
print("Hello world!", 1)
}
// Converting to an address:
// - Erase the type to an Object so swift doesn't complain
// - Bitcast
var erasedFunc = helloWorld as AnyObject
let address = unsafeBitCast(erasedFunc, to: Int.self)
@jerrymarino
jerrymarino / gist:cce9767cb4dda276ef86793b4a6d2288
Created June 10, 2018 16:34
Insert content into vim buffer programmatically
" Insert content into vim buffer programmatically
" Exe:
:exe ":normal i" . "some"
" FeedKeys:
:call feedkeys("i". "some")
@jerrymarino
jerrymarino / PythonVimPluginExample.vim
Created May 22, 2018 04:44
How to setup a vim plugin using python 2 or python 3
" Basic example of using Python with vim
" This is basic vim plugin boilerplate
let s:save_cpo = &cpo
set cpo&vim
function! s:UsingPython3()
if has('python3')
return 1
endif