Skip to content

Instantly share code, notes, and snippets.

@andrewwoz
andrewwoz / ns.swift
Last active October 15, 2019 05:58
[Number systems in Swift] #algorythms
func numberToBaseString(number:Int,base:Int) -> String {
var inner_func:(Int,Int,String) -> String = { (_,_,_) -> String in return "" }
inner_func = { (number:Int,base:Int,result:String) -> String in
if number < base {
return String(number) + result
}else{
let rem = number % base
let reducedNumber = (number - rem) / base
@andrewwoz
andrewwoz / waterfall.swift
Last active October 15, 2019 05:59
[Waterfall in swift] #swift
import Foundation
func + <K,V>(left: Dictionary<K,V>, right: Dictionary<K,V>)
-> Dictionary<K,V>
{
var map = Dictionary<K,V>()
for (k, v) in left {
map[k] = v
}
for (k, v) in right {
@andrewwoz
andrewwoz / demeter-law.md
Last active February 17, 2021 04:14
[Demeter Law] #clean_code

demeter-law-swift

The Law of Demeter in swift.

The Law of Demeter for methods attempts to minimize coupling between classes in any program. In short, the intent of this "law" is to prevent you from reaching into an object to gain access to a third object's methods.

###Good example

@andrewwoz
andrewwoz / multiple_ssh_setting.md
Last active October 15, 2019 06:00 — forked from jexchan/multiple_ssh_setting.md
[Multiple SSH keys for different github accounts] #git

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@andrewwoz
andrewwoz / generate_CSR.sh
Last active October 15, 2019 05:59
[Certificate Signing Request (CSR) from command line] #codesign
$ openssl genrsa -out mykey.key 2048
$ openssl req -new -key mykey.key -out CertificateSigningRequest.certSigningRequest -subj "/emailAddress=yourAddress@example.com, CN=Your Name Dev Key, C=GB"
@andrewwoz
andrewwoz / csr_request_content.sh
Last active October 15, 2019 06:01
[Output content of CSR] #codesign
$ openssl req -text -noout -in CertificateSigningRequest.certSigningRequest
@andrewwoz
andrewwoz / code_signing_identities.sh
Last active October 15, 2019 06:01
[Find all certificates for code signing] #codesign
security find-identity -v -p codesigning
@andrewwoz
andrewwoz / cert_info.sh
Last active October 15, 2019 06:01
[Get details about certificate] #codesign
$ openssl x509 -in ios_development.cer -inform DER -text -noout
@andrewwoz
andrewwoz / generate_p12.sh
Last active October 15, 2019 06:02
[Export `.cer` certificate to `.p12` certificate with private key in it] Good for backup and shring with other developers #codesign
$ openssl x509 -in #XXXXX#.cer -inform DER -out mycert.pem -outform PEM
$ openssl pkcs12 -export -inkey my.key -in mycert.pem -out mycert.p12
@andrewwoz
andrewwoz / p12info.sh
Last active October 15, 2019 06:02
[Get information about certificate and private key from .p12 certificate format] #codesign
$ openssl pkcs12 -info -in mycert.p12