Skip to content

Instantly share code, notes, and snippets.

@ohnit
ohnit / Print a class's methods
Last active December 11, 2019 17:26
LLDB Scripts
# print out names of a class's methods by using the class's name.
# change the name of the class on the first line. Copy, paste, and press enter
po NSString *$className = @"UIView";
po id $myClass = objc_getClass((const char *)[$className cStringUsingEncoding:4]); unsigned int $outCount; Method *$methods = (Method *)class_copyMethodList ($myClass, &$outCount); NSMutableArray *$array = [[NSMutableArray alloc] init];
po for(NSUInteger $i = 0; $i < $outCount; $i++) { Method $method = $methods[$i];NSString *$methodName = [NSString stringWithCString:(char *)sel_getName((SEL)method_getName($method))];[$array addObject:$methodName]; }
po $array
@ohnit
ohnit / bumpBuildTo
Last active May 15, 2020 20:50
Change Xcode Build and Version numbers for all targets
#! /bin/bash
# See "To Use" instructions at at bottom of file
bumpBuildForSchemeTo() {
local scheme=$1
local buildNumber=$2
filePath=$(xcodebuild -workspace "$workspace" -scheme "$scheme" -configuration Debug -showBuildSettings | grep "^\s*INFOPLIST_FILE" | awk '{print $3}')
@ohnit
ohnit / git-clean-merged
Last active September 14, 2022 14:18
Clean up local git branches that have been deleted on remote
#! /bin/bash
# deletes local branches that have been deleted on remote
# this version requires that `git fetch -p` is used to prune remote branches from your local repo
declare force
force=false
if [ $# -gt 0 ]; then
@ohnit
ohnit / git-clean-merged_old
Created February 25, 2020 18:18
Delete local git branches that have been merged
#! /bin/bash
# deletes branches (other than `master` or `develop`) that have already been merged into your
# current branch. I prefer this: https://gist.github.com/ohnit/150cb10459328e4695956567da5840b8
confirm() {
# call with a prompt string or use a default
read -r -p "${1:-Are you sure? [y/N]} " response
case "$response" in
[yY][eE][sS]|[yY])
# Recurses a json object and creates a list of breadcrumbs strings
#
# For example:
# jq '.stuff | breadcrumbs(.children?; .name)'
# This will recurse in every object containg a "children" key and for each object
# found, it will add its "name" field to the breadcrumb trail
#
# Parameters:
# - get_children: function which given an object, should return array of its children
# - get_name: function which given an object, should return a string to be added to the breadcrumb trail
@ohnit
ohnit / elixir-check
Last active January 9, 2024 16:27
Diffs credo and dialyzer outputs with the output saved when it was run on the last commits
#! /bin/bash
# Diffs credo and dialyzer outputs with the output saved when it was run on the last commits
DIFF_TOOL="code --diff"
EDITOR="code"
check_dirty() {
if [ -n "$(git status --porcelain)" ]; then
echo true
@ohnit
ohnit / hush-for
Created January 18, 2021 18:30
Turn on 'Do Not disturb' for a time period on macOS
#!/bin/bash
# See `showUsage` for desciption
# requires `gsed` via `brew install gnu-sed`
# requires `dnd` via `npm install --global do-not-disturb-cli`
function showUsage() {
cat <<EOS
Usage: $(basename "${0}") "<time_description>"
@ohnit
ohnit / disable_educative_notetaking.js
Created February 28, 2021 15:12
Turn off selection popup on Educative.io
// ==UserScript==
// @name Turn off educative notetaking
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Remove popup when you select text
// @author ohnit
// @match https://www.educative.io/courses/*
// @grant none
// ==/UserScript==
### Keybase proof
I hereby claim:
* I am ohnit on github.
* I am ohnit (https://keybase.io/ohnit) on keybase.
* I have a public key whose fingerprint is 4685 5F5C C0CC 7222 50DD 103D 38E3 D2C5 35A3 8165
To claim this, I am signing this object:
@ohnit
ohnit / using_elixir_with_debugging_proxy.md
Created March 30, 2023 16:34
Using a Debugging Proxy with Elixir

Using a Debugging Proxy with Elixir

You can use a debugging proxy (such as ProxyMan or Charles Proxy) to see outgoing calls coming from your Elixir project. Unfortunately, Elixir doesn't look at your system's proxy settings, so you have to set the proxying manually in your networking library. Here I am using Tesla with Hackney.

use Tesla

adapter(Tesla.Adapter.Hackney, proxy: {"localhost", 9090}, ssl_options: [{:verify, :verify_none}])

# plug Tesla.Middleware.Compression