Skip to content

Instantly share code, notes, and snippets.

View regnerjr's full-sized avatar

John Regner regnerjr

View GitHub Profile
@regnerjr
regnerjr / Setup.md
Last active September 22, 2016 23:06
Setup Charles Proxy on a device to capture ssl traffic.

A series of strange incantations

If you are using ssl for your site (and you probably should be) you'll need to install the charles certificate on your device.

Just navigate to http://www.charlesproxy.com/getssl and say yes and install to all the prompts.

Now in order to send the traffic from your phone to your Mac, you need two things, your phone and computer (hosting charles) need to be on the same network, probably wifi. You need to set you computer to act as a web proxy for your phone. You'll need your computer's IP address for this. The quickest way to get this is to Option-Click on the WiFi icon in the menu bar.

Follow these instructions to set the computer's ip address as your http proxy on the device

@regnerjr
regnerjr / keybase.md
Created August 6, 2016 19:00
Keybase.io verify that this I am john_regner on keybase , regnerjr here.

Keybase proof

I hereby claim:

  • I am regnerjr on github.
  • I am john_regner (https://keybase.io/john_regner) on keybase.
  • I have a public key ASAwMP8kJOGidXgPVRQiBWG9XExLZegFyCc3y9QnbfNp1Qo

To claim this, I am signing this object:

@regnerjr
regnerjr / SwitchingFromSVNToGit.md
Last active June 24, 2016 17:05
A guide for those new to git

The Car analogy

SVN is great in the way that a classic car (think 1960's Mustang) is great. Built to last. Simple to operate and fix. Pretty much reliable.

We are looking at a transition to git Git is like that new Chevy Camaro. Fuel Injected, computerized traction control, power steering, and much more. The good news is that any driver can get into either car and know how to drive. You don't really need to be scared away by the more powerful features. You just get in and start driving. As time goes on you might, choose to use some of the more powerful features, but for now lets just get working.

First steps

Before beginning work with SVN you will need to copy of the code on your machine. svn checkout http://some_amazing_url.com Similary for git you will need a copy from the server git clone http://some_amazing_url.com

for simplifications

Q: How can we simplify this code?

let items = ["one", "two", "three", "four"]
for (_, thing) in items.enumerate() {
    print(thing.characters.count)
}
xcode_plugin_update_uuid () {
local xcode plugin
for xcode in /Applications/Xcode*.app
do
uuid=$(defaults read "$xcode/Contents/Info" DVTPlugInCompatibilityUUID)
echo "$xcode - $uuid"
for plugin in ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins/*.xcplugin
do
echo "Updating $plugin"
defaults write "$plugin/Contents/Info" DVTPlugInCompatibilityUUIDs -array-add $uuid
@regnerjr
regnerjr / BoolExtensions.swift
Created June 28, 2015 22:48
Method chaining and reducing if statements
extension BooleanLiteralType {
func if_true(block: () -> () ) -> BooleanLiteralType{
if self {
block()
}
return self
}
func if_false(block: () -> ()) -> BooleanLiteralType {
if !self {
block()
@regnerjr
regnerjr / intToBinary.swift
Created June 2, 2015 16:06
A couple functions for doing Integer to Binary Conversion in swift.
import UIKit
func intToBin(num: Int, padding: Bool = true ) -> String {
var binString = String(num, radix:2)
if padding {
binString = padStringTo4DigitChunks(binString)
}
return binString
}
@regnerjr
regnerjr / uniqueChars.c
Created May 8, 2015 17:57
Given a string, returns only the unique characters. i.e. abacb -> abc
#include <stdio.h>
#include <stdlib.h>
int in(char value, char* list){
for (char *i = list; *i != '\0'; i++){
if ( *i == value ){
return 1;
}
}
return 0;
@regnerjr
regnerjr / getDateFor.swift
Last active August 29, 2015 14:17
A Function for returning the next NSDate which matches given Day, Hour, Minute, Useful for getting an NSDate to represent Sunday at 4:00 am. This works no matter what the date is now.
import UIKit
import Swift
import XCPlayground
// we want to schedule a timer to fire on Sunday at 4:00am.
// NSTimer takes a fire date.
// NSTimer.init(fireDate date: NSDate, interval seconds: NSTimeInterval, target target: AnyObject, selector aSelector: Selector, userInfo userInfo: AnyObject?, repeats repeats: Bool)
//
// So how do we get the date for the next coming Sunday at 4:00am ?
// Date Components of course!
@regnerjr
regnerjr / uniq.swift
Created March 27, 2015 00:52
A simple rewriting of the uniq command line tool.
#!/usr/bin/env xcrun swift -F $(xcode-select)/Platforms/MacOSX.platform/Developer/Library/Frameworks
import Foundation
//need to process any arguements here
//
// uniq [-c | -d | -u] [-i] [-f num] [-s chars] [input_file [output_file]]
// MARK: Standard In , Standard Out
func getStandardInput() -> String? {