Skip to content

Instantly share code, notes, and snippets.

View ry60003333's full-sized avatar

Ryan Rule-Hoffman ry60003333

View GitHub Profile
@mgersty
mgersty / httpredirect.example.swift
Last active April 5, 2022 02:19
Swift code demonstrating the capture of a 302 redirect via delegates
import Foundation
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
class DelegateToHandle302:NSObject, URLSessionTaskDelegate {
func urlSession(_ session: URLSession, task: URLSessionTask, willPerformHTTPRedirection response: HTTPURLResponse, newRequest request: URLRequest, completionHandler: @escaping (URLRequest?) -> Void) {
print(response.description)
PlaygroundPage.current.finishExecution()
}

FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.


Effective Engineer - Notes

What's an Effective Engineer?

@lucacesari
lucacesari / WorkingProcessWaitFor.java
Created August 27, 2015 14:26
Java Process hanging waitFor() fix
Process p = Runtime.getRuntime().exec("my-long-command");
BufferedInputStream in = new BufferedInputStream(process.getInputStream());
byte[] bytes = new byte[4096];
while (in.read(bytes) != -1) {}
process.waitFor();