Skip to content

Instantly share code, notes, and snippets.

View erickva's full-sized avatar

Erick erickva

  • Sydney
View GitHub Profile
@erickva
erickva / Xcode build number
Created February 7, 2021 20:27 — forked from chml/Xcode build number
Using git commit count as Xcode build number
#
# https://gist.github.com/johankool/c33cffc0727b13f22f25
# Set the build number to the current git commit count.
# If we're using the Dev scheme, then we'll suffix the build
# number with the current branch name, to make collisions
# far less likely across feature branches.
# Based on:
# http://w3facility.info/question/how-do-i-force-xcode-to-rebuild-the-info-plist-file-in-my-project-every-time-i-build-the-project/
# http://blog.jaredsinclair.com/post/97193356620/the-best-of-all-possible-xcode-automated-build#fnref:p97193356620-1
#
import Foundation
import UIKit
struct ViewStyle<T> {
let style: (T) -> Void
}
let filled = ViewStyle<UIButton> {
$0.setTitleColor(.white, for: .normal)
$0.backgroundColor = .red
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 July 12, 2016 00:43
This is a recursive function that transforms any JSON object into a Dictionary, ready to be saved into Firebase: Simple magic!
//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
//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 June 28, 2016 23:20
Delete Duplicates and Sort Array of Objects in Objective-C
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 July 12, 2016 00:46
String to Date - Date to String
//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"