Skip to content

Instantly share code, notes, and snippets.

View samdmarshall's full-sized avatar
💭
I will be slow to respond.

Samantha Demi samdmarshall

💭
I will be slow to respond.
View GitHub Profile
#import <Foundation/Foundation.h>
#include <mach-o/dyld.h>
uint32_t check_image(const struct mach_header *mh) {
struct mach_header *imageHeader;
uint32_t index;
for (index = 0; index < _dyld_image_count(); index++) {
imageHeader = (struct mach_header *)_dyld_get_image_header(index);
if ((int)memcmp(imageHeader, mh, sizeof(struct mach_header)) == 0) {
#import <Foundation/Foundation.h>
#include <objc/objc-api.h>
#include <objc/runtime.h>
#include <malloc/malloc.h>
#include <mach/mach.h>
@interface TEST : NSObject
@end
@implementation TEST
@samdmarshall
samdmarshall / problem.org
Last active April 1, 2021 20:30
unable to get a list of staged files via pygit2

Background

i am trying to create a prepare-commit-msg hook that will automatically populate and format my commit messages into an org document that has a level 1 heading for each staged file in the commit. so for example, this is one i did by hand, but basically like this: https://github.com/samdmarshall/dotfiles/commit/6016f773b6e596defe810bded704372672fdfb28 where each staged file has it’s own heading and is tagged according to the status of that staged file. so when i’m finished in my commit editor, the contents of my .git/COMMIT_EDITMSG looks like this:

#+title: git@github.com/somebody/somerepo.git @ develop
#+author: <git.config["user.name"]>
#+email: <git.config["user.email"]>
#+date: <timestamp of running =git commit=>
cutting a new release
# =======
# Imports
# =======
import json
import strformat
import asyncdispatch
import threadproxy
# =======
# Imports
# =======
import json
import strformat
import asyncdispatch
import threadproxy
# =======
# Imports
# =======
import json
import strformat
import asyncdispatch
import threadproxy
@samdmarshall
samdmarshall / Read Me
Last active January 17, 2018 13:49
Fat Static Library build script for iOS and OS X
This script is for generating a single static library out of iOS (device and sim) and OS X versions of the same code.
https://gist.github.com/samdmarshall/7516723
To use:
1. Create separate targets for each platform in xcode.
(The iOS device and simulator target can be the same one)
2. Add a new target of type "Mac" and "Aggregate". This can be found under "Other" in the target types list.
3. Add a new build phase to this target, "Add Run Script Phase to this Target"
4. Open Terminal.app, run this script, specifying the path to the output path of the build script
EX: ./BuildScriptGenerator.sh -o ~/Desktop
// Intention: query a dictionary for a key-value pair, take the value as a path that needs to be expanded (tilde -> abspath)
// and then make it available to use.
let path_value = arguments["path"] ?? "" // the `?? ""` makes this a `String` and not an `Any`
var path = NSString.init(string:"\(keychain_path_value)") // this will accept an `Any` or a `String` as the type to
// subsitute when creating the `NSString` type object
if !path.isEqual(to:"") { // "if the string has contents, then expand the path"
path = path.expandingTildeInPath as NSString // cast `as NSString` is necessary because it returns a `String`
}

Install Homebrew

Installation instructions: here

Install Tor

$ brew install tor

Enabling the default config file

sudo mv /usr/local/etc/tor/torrc.sample /usr/local/etc/tor/torrc

Setup Automatic SOCKS proxy

string(REPLACE " " ";" BUILD_ARCHITECTURES $ENV{ARCHS})
set(CMAKE_OSX_ARCHITECTURES ${BUILD_ARCHITECTURES})
execute_process(COMMAND xcrun --show-sdk-path --sdk $ENV{PLATFORM_NAME} OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE CMAKE_OSX_SYSROOT)