Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Mostly on gitlab.com/dweinstein these days...

David Weinstein dweinstein

💭
Mostly on gitlab.com/dweinstein these days...
View GitHub Profile
@dweinstein
dweinstein / build-libevent-ios.sh
Created Feb 1, 2016 — forked from ursachec/build-libevent-ios.sh
libevent build script for iOS
View build-libevent-ios.sh
#!/bin/bash
set -u
# Setup architectures, library name and other vars + cleanup from previous runs
ARCHS=("armv7" "armv7s" "i386")
SDKS=("iphoneos" "iphoneos" "macosx")
LIB_NAME="libevent-2.0.21-stable"
TEMP_DIR="$(pwd)/tmp"
TEMP_LIB_PATH="$(pwd)/tmp/${LIB_NAME}"
@dweinstein
dweinstein / forwarding-example.md
Created Jan 28, 2016 — forked from f1sherman/forwarding-example.md
Port Forwarding Example in OS X El Capitan
View forwarding-example.md

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

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

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

rdr-anchor "forwarding"
load anchor "forwarding" from "/etc/pf.anchors/myname"
View docker-nuke-graph-directory.sh
#!/bin/sh
set -e
dir="$1"
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.'
echo
@dweinstein
dweinstein / app_transport_http_error.md
Last active Sep 30, 2015
iOS App Transport No More free HTTP
View app_transport_http_error.md

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";
    print_me(string);
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 () {
loc_0x8d4:
push (r4, r5, r6, r7, r8, sb, lr)
r4 = r0
r7 = [pc + 0x240]
sp -= 0x44
r2 = [pc + 0x240]
r0 = 4
r7 += pc
@dweinstein
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
dweinstein / LICENSE
Last active Mar 30, 2016
mega rename class based on source, etc.
View LICENSE
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 - https://gist.github.com/3712874
# A Powerline-inspired theme for ZSH
#
# # README
#
# In order for this theme to render correctly, you will need a
# [Powerline-patched font](https://github.com/Lokaltog/powerline-fonts).
#
You can’t perform that action at this time.