Skip to content

Instantly share code, notes, and snippets.

Mostly on these days...

David Weinstein dweinstein

Mostly on these days...
View GitHub Profile
dweinstein /
Created Feb 1, 2016 — forked from ursachec/
libevent build script for iOS
set -u
# Setup architectures, library name and other vars + cleanup from previous runs
ARCHS=("armv7" "armv7s" "i386")
SDKS=("iphoneos" "iphoneos" "macosx")
dweinstein /
Created Jan 28, 2016 — forked from f1sherman/
Port Forwarding Example in OS X El Capitan

Add the following to /etc/pf.anchors/myname:

rdr pass on lo0 inet proto tcp from any to any port 80 -> port 4000
rdr pass on lo0 inet proto tcp from any to any port 443 -> port 4001

Add the following to /etc/pf-myname.conf:

rdr-anchor "forwarding"
load anchor "forwarding" from "/etc/pf.anchors/myname"
set -e
if [ -z "$dir" ]; then
echo 'This script is for destroying old /var/lib/docker directories more safely than'
echo ' "rm -rf", which can cause data loss or other serious issues.'
dweinstein /
Last active Sep 30, 2015
iOS App Transport No More free HTTP

2015-09-29 19:57:14.354 xxxx[3879:33484] App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.

View gist:49d7c74764c685bf0b47

This example creates strings in four different ways that all work with the print_me function. The key to making this all work is passing values by reference. Rather than passing owned_string as a String to print_me, we instead pass it as &String. When the compiler sees a &String being passed to a function that takes &str, it coerces the &String into a &str. This same coercion takes places for the reference counted and atomically referenced counted strings. The string variable is already a reference, so no need to use a & when calling print_me(string). Knowing this, we no longer need to have .to_string() calls littering our code.

fn print_me(msg: &str) { println!("msg = {}", msg); }

fn main() {
    let string = "hello world";
View -
/ (fcn) sym.subsystem_control_shutdown 576
| ;-- sym.subsystem_control_shutdown:
| 0x000008d4 2de9f043 push.w {r4, r5, r6, r7, r8, sb, lr}
| 0x000008d8 0446 mov r4, r0
| 0x000008da 904f ldr r7, [pc, 0x240] ; [0xb1c:4]=0x333 "lize"
| 0x000008dc 91b0 sub sp, 0x44
| 0x000008de 904a ldr r2, [pc, 0x240] ; [0xb20:4]=0x371 "i_unwind_cpp_pr0"
| 0x000008e0 0420 movs r0, 4
| 0x000008e2 7f44 add r7, pc
| 0x000008e4 8f4e ldr r6, [pc, 0x23c] ; [0xb24:4]=0x16ca
View -
function sym.subsystem_control_shutdown () {
push (r4, r5, r6, r7, r8, sb, lr)
r4 = r0
r7 = [pc + 0x240]
sp -= 0x44
r2 = [pc + 0x240]
r0 = 4
r7 += pc
dweinstein / .aliases
Created Jun 23, 2015
android apk certificate information signature signed
View .aliases
apk_keyinfo () {
unzip -p "$1" META-INF/CERT.RSA | openssl pkcs7 -inform DER -noout -print_certs -text
dweinstein / LICENSE
Last active Mar 30, 2016
mega rename class based on source, etc.
The MIT License (MIT)
Copyright (c) 2015 David Weinstein
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
View agnoster-custom.zsh-theme
# vim:ft=zsh ts=2 sw=2 sts=2
# agnoster's Theme -
# A Powerline-inspired theme for ZSH
# In order for this theme to render correctly, you will need a
# [Powerline-patched font](