Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I will be slow to respond.

Samantha Demi samdmarshall

💭
I will be slow to respond.
View GitHub Profile
@samdmarshall
samdmarshall / problem.org
Last active Apr 1, 2021
unable to get a list of staged files via pygit2
View problem.org

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
View example2v2.nim
# =======
# Imports
# =======
import json
import strformat
import asyncdispatch
import threadproxy
View example2.nim
# =======
# Imports
# =======
import json
import strformat
import asyncdispatch
import threadproxy
View example1.nim
# =======
# Imports
# =======
import json
import strformat
import asyncdispatch
import threadproxy
View code.swift
// 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`
}
View installing tor on OS X.md

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

View building_for_ios.cmake
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)
View gist:582ef33ca1ae6f700ea2ef9723ef6ad8
+-o repo-root/
+-o android/
+-o core/
| +-o lib/
| +-o json/
| +-o json.cpp
| +-o json.hpp
| +-o test.cpp
+-o ios/
| +-o Podfile
View list comp.py
# so instead of doing this:
my_list = list()
for key in dictionary:
if dictionary[key] == 'foo':
my_list.append(key)
# you can use list comprehension to write code like this:
my_list = [key for key in dictionary if dictionary[key] == 'foo']
# both produce the same list of keys, but i think that using list comprehension is a lot more readable.
@samdmarshall
samdmarshall / # mercurial - 2016-08-16_09-12-46.txt
Created Aug 16, 2016
mercurial on Mac OS X 10.11.6 - Homebrew build logs
View # mercurial - 2016-08-16_09-12-46.txt
Homebrew build logs for mercurial on Mac OS X 10.11.6
Build date: 2016-08-16 09:12:46