Skip to content

Instantly share code, notes, and snippets.

View chriswebb09's full-sized avatar

Christopher Webb chriswebb09

View GitHub Profile
class LLNode<T> {
var value: T
var next: LLNode?
weak var previous: LLNode?
init(value: T) {
self.value = value
}
}
import UIKit
class ViewController: UIViewController {
let viewOne = UIView()
let viewTwo = UIView()
let intermediaryView = UIView()
let viewSuper = UIView()
override func viewDidLoad() {
import UIKit
typealias JSON = [String : Any]
fileprivate let imageCache = NSCache<NSString, UIImage>()
extension NSError {
static func generalParsingError(domain: String) -> Error {
return NSError(domain: domain, code: 400, userInfo: [NSLocalizedDescriptionKey : NSLocalizedString("Error retrieving data", comment: "General Parsing Error Description")])
}
}
@chriswebb09
chriswebb09 / APIClient.swift
Created April 18, 2017 04:02
Monitoring Downloads
import UIKit
typealias JSON = [String: Any]
final class iTunesAPIClient: NSObject {
var activeDownloads: [String: Download]?
weak var defaultSession: URLSession? = URLSession(configuration: .default)
// MARK: - Main session used
@chriswebb09
chriswebb09 / ImageDownloadProtocol.swift
Last active September 3, 2019 22:08
Download on Thread
import UIKit
protocol ImageDownloadProtocol {
func downloadImage(from url: URL, completion: @escaping (UIImage?) -> Void)
}
extension ImageDownloadProtocol {
func downloadImage(from url: URL, completion: @escaping (UIImage?) -> Void) {
let session = URLSession(configuration: .default)
DispatchQueue.global(qos: .background).async {
func palindrome(string: String) -> Bool {
var replacedString = string.replacingOccurrences(of: " ", with: "")
replacedString = replacedString.components(separatedBy:.punctuationCharacters).joined()
return replacedString.lowercased() == String(replacedString.lowercased().reversed())
}
class ViewController: UIViewController, ARSCNViewDelegate, ARSessionDelegate {
@IBOutlet weak var sceneView: ARSCNView!
override func viewDidLoad() {
super.viewDidLoad()
}
func run() {
let configuration = ARWorldTrackingConfiguration()
def main():
crawl = WebCrawler()
new_data = crawl.request_resource()
if new_data is not None:
for url in new_data:
print(url)
def request_resource(self):
r = requests.get(self.url)
urls = re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', r.text)
return urls
def __init__(self):
print(sys.argv[0])
if sys.argv[1].startswith("http://") or sys.argv[1].startswith("https://"):
self.url = sys.argv[1]
else:
self.url = "https://" + sys.argv[1]