drop db contents
SET FOREIGN_KEY_CHECKS=0;
TRUNCATE `db_name`.`table_name`;
SET FOREIGN_KEY_CHECKS=1;
wipe db
php artisan migrate:fresh
Happie coding
Tuesday, May 7, 2019
Monday, May 7, 2018
Thursday, November 17, 2016
Hide status bar
In Swift 3, to hide the status bar, simply add the following to your view controller.
override var prefersStatusBarHidden: Bool {
return true
}
However, sometimes you might just want to do it in a completion block, or within some animation block. In that case, add
UIApplication.shared.isStatusBarHidden = true
And toggle off when desired
Friday, November 4, 2016
Check optional + empty string together
Apart from checking nil from an optional string, it's pretty common for us to check whether or not that optional as an empty string. e.g: ""
I found this wonderful solution, credits to StackOverflow once more.
Source: http://stackoverflow.com/questions/29381994/swift-check-string-for-nil-empty
I found this wonderful solution, credits to StackOverflow once more.
(string ?? "").isEmpty
Source: http://stackoverflow.com/questions/29381994/swift-check-string-for-nil-empty
Thursday, October 13, 2016
How to figure out the font to assign it programatically in swift
Assigning fonts to texts programatically can be a pain due to the parameters passed being a hardcoded string, hence no auto completion, what's worse is the font's name isn't always the same as the filename. Furthermore fonts are grouped by font families, which may contain multiple fonts.
Firstly, run print(UIFont.familyNames) to print out every single family name in an array.
["Copperplate", "Heiti SC", "Times New Roman"]
You can then
print(UIFont.fontNames(forFamilyName: "Times New Roman"))
Which outputs to
["TimesNewRomanPSMT", "TimesNewRomanPS-BoldItalicMT", "TimesNewRomanPS-ItalicMT", "TimesNewRomanPS-BoldMT"]
Then you can finally let font = UIFont(name: "TimesNewRomanPS-BoldMT", size: 16)
Wednesday, September 21, 2016
Remove unwanted message from Xcode 8 console logs
1- From xCode menu open: Product > Scheme > Edit Scheme
2- On your Environment Variables set
Note that the value is disable NOT false
OS_ACTIVITY_MODE
= disable
Note that the value is disable NOT false
Tuesday, September 20, 2016
Corner Radius in Swift 2.3 and above
Since Swift 2.3 onwards, it is now required to define the corner radius of your views after your view has loaded, hence, move the corner radius value assignment to viewDidLayoutSubviews() else your view will just not be visible from your app, even though it's viewable in the story board or the view hierarchy.
As for views in a table view cell, I've seen people getting their views rounded by assigning cornerRadius inside layoutSubviews(), but I didn't have any success with that, the following worked for me even though I personally don't like it.
As for views in a table view cell, I've seen people getting their views rounded by assigning cornerRadius inside layoutSubviews(), but I didn't have any success with that, the following worked for me even though I personally don't like it.
Add self.layoutIfNeeded() right after super.awakeFromNib() to force layout
Subscribe to:
Posts (Atom)