This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env Python3.5 | |
# -*- Coding: UTF-8 -*- | |
import requests | |
import json | |
def send_get_request(url, headers, payload): | |
r = requests.get(url, headers=headers, data=payload) | |
return r.json() | |
def send_post_request(url, headers, payload): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct EntryStruct { | |
var name: [String] | |
var id: String | |
} | |
var separateSocial = records.flatMap { [$0.components(separatedBy: ":")] }.map { $0 } | |
var separateName = separateSocial.flatMap { EntryStruct(name: $0.first!.components(separatedBy: ","), id: $0.last!)} | |
var ids = [String]() | |
var updatedEntries = [EntryStruct]() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class DownloadImage { | |
var image: UIImage? | |
var state = ImageState.preparing | |
} | |
enum ImageState { | |
case preparing, downloading, downloaded | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func permutations(input:String, builder: String = "") { | |
var array = input.characters.map { $0 } | |
var length = input.characters.count | |
if length == 0 { print(builder) } | |
for i in 0 ..< length { | |
var lhs = String(array[0 ..< i]) | |
var rhs = String(array[i+1 ..< length]) | |
permutations(input: "\(lhs)\(rhs)", builder: builder + String(array[i])) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
protocol APIClient { | |
func downloadData() | |
func downloadImage() | |
} | |
struct Client:APIClient { | |
var request: URLRequest | |
var networkCall: APIRequest |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
struct Regex { | |
let pattern: String | |
let options: NSRegularExpression.Options! | |
private var matcher: NSRegularExpression { | |
let matcher = try? NSRegularExpression(pattern: self.pattern) | |
return matcher! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
@interface DataStore : NSObject | |
+ (instancetype)sharedManager; | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
@interface APIClient : NSObject | |
@property(strong,nonatomic) NSString *urlString; | |
@property(strong, nonatomic) NSURL *url; | |
@property(strong, nonatomic) NSURLSessionDataTask *downloadTask; | |
-(void)sendAPICallWith:(void (^)(NSDictionary * dictionary))completionHandler; | |
-(id)initWithURLString:(NSString *)url; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'); | |
var server = http.createServer(function(req,res) { | |
res.writeHead(200); | |
res.end('Hello world'); | |
}) | |
server.listen(8080); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
typealias JSONData = [String:Any] | |
struct APIClient { | |
let session = URLSession.shared | |
func createRequest(url: URL) -> URLRequest { | |
return URLRequest(url: url) |
OlderNewer