Skip to content

Instantly share code, notes, and snippets.

View shepting's full-sized avatar

Steven Hepting shepting

View GitHub Profile
@shepting
shepting / SimpleChildTimelineViewController.m
Created January 26, 2016 02:11
Some users have requested a sample implementation to make a child viewcontroller showing a timeline of Tweets.
#import <TwitterKit/TwitterKit.h>
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor lightGrayColor];
// Standard TWTRTimelineViewController setup
@shepting
shepting / NodeTraversal.swift
Last active November 24, 2015 22:55
Print out a tree of nodes with multiple children each.
//
// main.swift
// NodeTraversal
//
// Created by Steven Hepting on 11/16/15.
// Copyright © 2015 Steven Hepting. All rights reserved.
// Algorithm from http://bit.ly/1kSdSvc
//
import Foundation
@shepting
shepting / NetworkEnabler.swift
Last active June 8, 2018 17:03
Xcode Playgrounds will fail network requests when Charles is running since ATS will fail. With an Xcode project you can update the Info.plist but Playgrounds don't have any such option. This is that option.
// When using Charles, the network requests will always fail unless you can bypass ATS.
public class NetworkEnabler: NSObject, NSURLSessionDelegate {
public func URLSession(session: NSURLSession, didReceiveChallenge challenge: NSURLAuthenticationChallenge, completionHandler: (NSURLSessionAuthChallengeDisposition, NSURLCredential?) -> Void) {
completionHandler(.UseCredential, NSURLCredential(trust: challenge.protectionSpace.serverTrust!))
}
}
// Then later when making a request:
let enabler = NetworkEnabler()
let session = NSURLSession(configuration: NSURLSession.sharedSession().configuration, delegate: enabler, delegateQueue: nil)
@shepting
shepting / upload.m
Created January 28, 2015 23:50
Upload an image using Twitter Fabric
[[Twitter sharedInstance] logInWithCompletion:^(TWTRSession *session, NSError *error){
// Ensure the auth worked
if (session) {
NSLog(@"Twitter Session %@ / %@ found", session.authToken, session.authTokenSecret);
} else {
NSLog(@"Login error: %@", error);
}
// Get a random image
UIImage *corgiImage = [UIImage imageNamed:@"Corgis_Small.jpeg"];

Keybase proof

I hereby claim:

  • I am shepting on github.
  • I am stevenhepting (https://keybase.io/stevenhepting) on keybase.
  • I have a public key whose fingerprint is 8148 34C8 3A9B E695 9FB2 D301 5FED 5668 FAF9 8F49

To claim this, I am signing this object:

@shepting
shepting / rot13.swift
Last active August 29, 2015 14:08 — forked from jeremy-w/rot13.swift
// Playground - noun: a place where people can play
import UIKit
let lettersArray = Array("ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")
func rot13(input: String) -> String {
return reduce(input, "", { result, letter in
if let i = find(lettersArray, letter) {
return result + String(lettersArray[i + 13])
@shepting
shepting / last_two_weeks.sh
Last active August 29, 2015 14:06
Last Two Weeks of Git Commits
git log --author=Steven --since=2.weeks --no-merges --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'
@shepting
shepting / rot13.swift
Last active August 29, 2015 14:05 — forked from jeremy-w/rot13.swift
Simple ROT13 function
// Playground - noun: a place where people can play
let lettersArray = Array("ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")
func rot13(input: String) -> String {
return reduce(input, "") { result, letter in
if let i = find(lettersArray, letter) {
return result + lettersArray[i + 13]
} else {
return result + letter
@shepting
shepting / .lldbinit
Created June 13, 2014 01:10
Sample LLDBInit
# Print all the views in the window
command regex rd 's/^[[:space:]]*$/po [[[UIApplication sharedApplication] keyWindow] recursiveDescription]/' 's/^(.+)$/po [%1 recursiveDescription]/'
# Print all the view controllers in the window
command regex rvc 's/^[[:space:]]*$/po [[[UIApplication sharedApplication] keyWindow] recursiveDescription]/' 's/^(.+)$/po [%1 _viewControllerForAncestor]/'
# Print an autolayout trace
command alias at expr -o -- [[UIWindow keyWindow] _autolayoutTrace]
# Load the dynamic code for Reveal
@shepting
shepting / button_switch.js
Created March 13, 2014 22:24
BeagleBone Black sample button/transistor switch code
var b = require('bonescript');
var switchIn = "P9_21";
var transistorOut = "P9_41";
b.pinMode(transistorOut, b.OUTPUT);
b.pinMode(switchIn, b.INPUT);
setInterval(toggle, 100);
console.log("started");