Skip to content

Instantly share code, notes, and snippets.

View vkostechko's full-sized avatar

Viacheslav vkostechko

  • Warsaw, Poland
View GitHub Profile
extension Dictionary {
static func union(dic: Dictionary, other: Dictionary?) -> Dictionary {
var mutableCopy = dic
mutableCopy.add(other: other)
return mutableCopy
}
mutating func add(other: Dictionary?) -> Void {
guard let other = other else { return }
let filePath = Bundle.main.pathForResource("YOUR_FILE_NAME", ofType: "json", inDirectory: nil)
if let filePath = filePath {
do {
let fileUrl = URL(fileURLWithPath: filePath)
let jsonData = try Data(contentsOf: fileUrl, options: .mappedIfSafe)
let json = try? JSONSerialization.jsonObject(with: jsonData)
} catch {
print(error)
fatalError("Unable to read contents of the file url")
extension URLRequest {
public var curlString: String {
// Logging URL requests in whole may expose sensitive data,
// or open up possibility for getting access to your user data,
// so make sure to disable this feature for production builds!
#if !DEBUG
return ""
#else
var result = "curl -k "
extension UIView {
func roundCorners(_ corners: UIRectCorner, radius: CGFloat) {
let path = UIBezierPath(roundedRect: self.bounds, byRoundingCorners: corners, cornerRadii: CGSize(width: radius, height: radius))
let mask = CAShapeLayer()
mask.path = path.cgPath
self.layer.mask = mask
}
}
@vkostechko
vkostechko / Emoji.json
Created December 1, 2017 13:13 — forked from 0xced/Emoji.json
Extract emoji by category using the EmojiFoundation framework
{
"People" : [
"😀",
"😃",
"😄",
"😁",
"😆",
"😅",
"😂",
"🤣",
@vkostechko
vkostechko / cocoapods
Last active October 25, 2018 14:18
cocoapods common commands
to remove your current version you could just run:
sudo gem uninstall cocoapods
to update repo
pod repo update
you can install a specific version of cocoa pods via the following command:
sudo gem install cocoapods -v 0.25.0
+ (NSString *)localizedStrinByKey:(NSString *)key forLanguage:(NSString *)languageCode
{
NSLog(@"language: %@", languageCode);
NSString *path = [[ NSBundle mainBundle ] pathForResource:languageCode ofType:@"lproj"];
NSBundle *bundle = [NSBundle bundleWithPath:path];
return [bundle localizedStringForKey:key value:NSLocalizedString(key, nil) table:nil];
}