Saturday, September 19, 2020

Convert OpenSSH Private Key to RSA

 To convert OpenSSH private key to RSA, (i.e id_rsa) simply run this command:

ssh-keygen -p -N "" -m -pem -f /.ssh/id_rsa

 


Monday, September 7, 2020

Ruby on Rails API App with PostgreSQL

 To create a new Ruby on Rails app with PostgreSQL, simply run the following command:

rails new ExampleApp --api --database=postgresql



Sunday, June 7, 2020

Tuesday, November 28, 2017

Sublime Text as default text editor for git

To set Sublime Text as default text editor for git instead of nano, just run the following command at Terminal:

git config --global core.editor $(which subl)


Tuesday, October 24, 2017

Swift Table View selectable but not highlighted

In swift, sometimes I prefer not to disable selection because I am using didSelectAtIndexPath... But at the same time I don't want the cell to be highlighted, so I do:
let clearView = UIView()
clearView.backgroundColor = UIColor.clear
UITableViewCell.appearance().selectedBackgroundView = clearView

Wednesday, May 11, 2016

Swift sleep function

In swift, sleep is going to block the main thread and make the app unresponsive... You can use NSTimer but the fire time is not that accurate... I prefer:
let seconds = 3.0
let delay = seconds * Double(NSEC_PER_SEC)
let dispatchTime = dispatch_time(DISPATCH_TIME_NOW, Int64(delay))
dispatch_after(dispatchTime, dispatch_get_main_queue(), {
     // code to be executed after the delay
})