Skip to content

Instantly share code, notes, and snippets.

Avatar

Erick Vavretchek erickva

  • Sydney
View GitHub Profile
View ViewStyle.swift
import Foundation
import UIKit
struct ViewStyle<T> {
let style: (T) -> Void
}
let filled = ViewStyle<UIButton> {
$0.setTitleColor(.white, for: .normal)
$0.backgroundColor = .red
View SmartCashj
val mainParams = MainNetParams.get()
// Create transaction
val tx = Transaction(mainParams)
val wallet = Wallet(mainParams)
// decode private key
val privateKey = BIP38PrivateKey.fromBase58(mainParams, encryptedKey).decryptWithParams(decryptKey, 2048, 8, 8)
@erickva
erickva / JSON2Dictionary.swift
Last active Jul 12, 2016
This is a recursive function that transforms any JSON object into a Dictionary, ready to be saved into Firebase: Simple magic!
View JSON2Dictionary.swift
//JSON is created using the awesome SwiftyJSON pod
func json2dic(j: JSON) -> [String:AnyObject] {
var post = [String:AnyObject]()
for (key, object) in j {
post[key] = object.stringValue
if object.stringValue == "" {
post[key] = json2dic(object)
}
}
return post
View Target Deploy
//Swift
var secret: String {
var _secret = ""
#if TARGET_NAME_HERE
_secret = "5Phtn5oNbLL8gwHDhtJxNRVW64hqwe9oNML08a4oDhtnxNRVW688COlZFSWs"
#else
_secret = "fs5dUMzKL82KLe9oNML08a4oDhtn5oNbLL8gwHDhR3tJxNRVW688COlZFSWS"
#endif
return _secret
}
@erickva
erickva / Arrays_Sort_Rem_Duplicates.m
Created Jun 28, 2016
Delete Duplicates and Sort Array of Objects in Objective-C
View Arrays_Sort_Rem_Duplicates.m
NSOrderedSet *orderedSet = [NSOrderedSet orderedSetWithArray:_lastMessages];
NSArray *arrayWithoutDuplicates = [orderedSet array];
NSSortDescriptor *dateDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"date_" ascending:YES];
NSArray *sortDescriptors = [NSArray arrayWithObject:dateDescriptor];
NSArray *sortedEventArray = [arrayWithoutDuplicates sortedArrayUsingDescriptors:sortDescriptors];
_lastMessages = [sortedEventArray mutableCopy];
@erickva
erickva / Date-String.swift
Last active Jul 12, 2016
String to Date - Date to String
View Date-String.swift
//String to NSDate
var dateString = "01-02-2010"
var dateFormatter = NSDateFormatter()
//// this is imporant - we set our input date format to match our input string
dateFormatter.dateFormat = "dd-MM-yyyy"
var dateFromString = dateFormatter.dateFromString(dateString)
//NSDate to String
var formatter: NSDateFormatter()
formatter.dateFormat = "dd-MM-yyyy"
You can’t perform that action at this time.