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
private func imageFrom(url: URL?, data: Data, response: HTTPURLResponse? = nil) -> AnyPublisher<UIImage?, Error> { | |
let type = response?.mimeType | |
if type?.hasPrefix("image/svg") == true || url?.pathExtension.lowercased() == "svg" { | |
return svgFrom(data: data) | |
} | |
return Just(UIImage(data: data)).setFailureType(to: Error.self).eraseToAnyPublisher() | |
} | |
private func svgFrom(data: Data) -> AnyPublisher<UIImage?, Error> { |
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 SwiftUI | |
import CoreLocation | |
let jan = Calendar.current.date(from: DateComponents(year: 2021, month: 1, day: 1, hour: 2, minute: 0))! | |
let styles: [DateFormatter.Style] = [ | |
.none, | |
.short, | |
.medium, |
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 | |
let config = NSURLSessionConfiguration.defaultSessionConfiguration() | |
let userPasswordString = "username@gmail.com:password" | |
let userPasswordData = userPasswordString.dataUsingEncoding(NSUTF8StringEncoding) | |
let base64EncodedCredential = userPasswordData!.base64EncodedStringWithOptions(nil) | |
let authString = "Basic \(base64EncodedCredential)" | |
config.HTTPAdditionalHeaders = ["Authorization" : authString] | |
let session = NSURLSession(configuration: config) |
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
<<<<<<< HEAD | |
if let titleView: UIView = titleViewFromNavBarImagePath(navBarImagePath: navBarImagePath) { | |
titleView.contentMode = .scaleAspectFit | |
let container = UIView(frame: CGRect(x: 0, y: 0, width: 32, height: 32)) | |
titleView.frame = CGRect(x: 0, y: 0, width: 32, height: 32) | |
container.addSubview(titleView) | |
self.navigationItem.titleView = container | |
} | |
else { | |
self.navigationItem.titleView = 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
func testDeleteFolder() { | |
attempt { | |
let session = Session.nas | |
var response: JSONObject? | |
stub(session, "delete-folder") { expectation in | |
try! Folder.deleteFolder(session, folderID: "10396915") | |
.startWithCompletedExpectation(expectation) { value in | |
response = value | |
} |
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
# XCode 5 hides these away: | |
export C_INCLUDE_PATH="$(xcrun --show-sdk-path)/usr/include" | |
export CPLUS_INCLUDE_PATH="$(xcrun --show-sdk-path)/usr/include" | |
export LIBRARY_PATH="$(xcrun --show-sdk-path)/usr/lib:$(xcrun --show-sdk-path)/usr/lib/system:$LIBRARY_PATH" | |
and then you can do rbenv install |
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
class AddIndexOnCompanyIdInConcernsAndDepartmentsAndUsers < ActiveRecord::Migration | |
def change | |
add_index :departments, :company_id | |
add_index :concerns, :company_id | |
add_index :users, :company_id | |
end | |
end |
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
mysql.server start |
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
@implementation MyCustomClass | |
- (id)init | |
{ | |
self = [super init]; | |
if (self) { | |
// custom initializations | |
// use underscore assignment (_date = [NSDate date]) instead of setters and getters |
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
// the following class inherits from UIViewController | |
@implementation MyCustomViewController | |
- (void)setup | |
{ | |
// initialization that can't wait until viewDidLoad | |
} | |
- (void)awakeFromNib |
NewerOlder