This file contains 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 | |
import PlaygroundSupport | |
PlaygroundPage.current.needsIndefiniteExecution = true | |
let credential = URLCredential(user: “username@gmail.com”, password: “password”, persistence: URLCredential.Persistence.forSession) | |
let protectionSpace = URLProtectionSpace(host: "example.com", port: 443, protocol: "https", realm: "Restricted", authenticationMethod: NSURLAuthenticationMethodHTTPBasic) | |
URLCredentialStorage.shared.setDefaultCredential(credential, for: protectionSpace) | |
let config = URLSessionConfiguration.default |
This file contains 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
# You have to restart the core audio be pasting the following line into termnal | |
sudo kill `ps -ax | grep 'coreaudiod' | grep 'sbin' |awk '{print $1}'` |
This file contains 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
extension CGPath { | |
func apply(action: @escaping (CGPathElement)->()) { | |
var action = action | |
apply(info: &action) { | |
let action = $0!.bindMemory(to: ((CGPathElement)->()).self, capacity: 1).pointee | |
action($1.pointee) | |
} | |
} | |
} |
This file contains 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 | |
import Photos | |
extension PHPhotoLibrary { | |
// MARK: - PHPhotoLibrary+SaveImage | |
// MARK: - Public | |
func savePhoto(image:UIImage, albumName:String, completion:((PHAsset?)->())? = nil) { | |
func save() { |
This file contains 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
erase_sim: | |
./reset_sim.sh 2>/dev/null; true |
This file contains 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 SwiftUI | |
struct PagerManager<Content: View>: View { | |
let pageCount: Int | |
@Binding var currentIndex: Int | |
let content: Content | |
//Set the initial values for the variables | |
init(pageCount: Int, currentIndex: Binding<Int>, @ViewBuilder content: () -> Content) { | |
self.pageCount = pageCount |
This file contains 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 ContentView: View { | |
@State private var currentPage = 0 | |
var body: some View { | |
//Pager Manager | |
VStack{ | |
PagerManager(pageCount: 2, currentIndex: $currentPage) { | |
Text("First page") | |
Text("Second page") |
This file contains 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 CustomActivity: UIActivity { | |
override class var activityCategory: UIActivityCategory { | |
return .action | |
} | |
override var activityType: UIActivityType? { | |
guard let bundleId = Bundle.main.bundleIdentifier else {return nil} |
This file contains 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
+ (UIColor *) colorFromHexCode:(NSString *)hexString { | |
NSString *cleanString = [hexString stringByReplacingOccurrencesOfString:@"#" withString:@""]; | |
if([cleanString length] == 3) { | |
cleanString = [NSString stringWithFormat:@"%@%@%@%@%@%@", | |
[cleanString substringWithRange:NSMakeRange(0, 1)],[cleanString substringWithRange:NSMakeRange(0, 1)], | |
[cleanString substringWithRange:NSMakeRange(1, 1)],[cleanString substringWithRange:NSMakeRange(1, 1)], | |
[cleanString substringWithRange:NSMakeRange(2, 1)],[cleanString substringWithRange:NSMakeRange(2, 1)]]; | |
} | |
if([cleanString length] == 6) { | |
cleanString = [cleanString stringByAppendingString:@"ff"]; |
This file contains 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
- (void)viewDidLoad { | |
[super viewDidLoad]; | |
// Do any additional setup after loading the view, typically from a nib. | |
NSString *info = @"http://codeafterhours.wordpress.com"; | |
// Generation of QR code image | |
NSData *qrCodeData = [info dataUsingEncoding:NSISOLatin1StringEncoding]; // recommended encoding | |
CIFilter *qrCodeFilter = [CIFilter filterWithName:@"CIQRCodeGenerator"]; | |
[qrCodeFilter setValue:qrCodeData forKey:@"inputMessage"]; |