Skip to content

Instantly share code, notes, and snippets.


Dhiren Shah shahdhiren

View GitHub Profile
shahdhiren / swift4-plist-extract.swift
Created Feb 2, 2019 — forked from db42/swift4-plist-extract.swift
Swift 4 recipes: Extract data from a property list
View swift4-plist-extract.swift
//Property List file name = regions.plist
let pListFileURL = Bundle.main.url(forResource: "regions", withExtension: "plist", subdirectory: "")
if let pListPath = pListFileURL?.path,
let pListData = FileManager.default.contents(atPath: pListPath) {
do {
let pListObject = try PropertyListSerialization.propertyList(from: pListData, options:PropertyListSerialization.ReadOptions(), format:nil)
//Cast pListObject - If expected data type is Dictionary
guard let pListDict = pListObject as? Dictionary<String, AnyObject> else {
View Export clob field from Oracle SQL Developer
spool clob_export.sql
select /*insert*/ * from <TABLE_NAME> where <FIELD>='88c820c4-b295-466b-a1a3-beb55434e0e9';
spool off
shahdhiren / DropAllUserTables.sql
Last active May 4, 2018
Drop all user tables in Oracle
View DropAllUserTables.sql
FOR cur_rec IN (SELECT object_name, object_type
FROM user_objects
WHERE object_type IN
shahdhiren / Symbolicate Xcode Crashlogs
Last active Jul 30, 2018
Symbolicate Xcode Crashlogs
View Symbolicate Xcode Crashlogs
Symbolicate Xcode Crashlogs
To properly get symbols from your archived app's dSYM file and get useful information from your BugSense crash reports (or any other crash reports for that matter):
1. Copy the stack trace from BugSense into TextEdit or any other text editor.
Make sure to use the "clipboard" icon, rather than simply copying the text.
Otherwise you will not get the actual memory locations of the stack trace, which are necessary to look up the references using atos and symbolicate your stack trace.
2. Open XCode and go to the Organizer
3. Find your archive and right-click it, go to open it in the finder.
shahdhiren / Convert Date Format (From-To) Swift 3
Last active Feb 6, 2017
Convert Date Format (From-To) Swift 3
View Convert Date Format (From-To) Swift 3
func convertDateFormat(from: String, to: String, dateString: String?) -> String? {
let fromDateFormatter = DateFormatter()
fromDateFormatter.dateFormat = from
var formattedDateString: String? = nil
if dateString != nil {
let formattedDate = dateString!)
if formattedDate != nil {
let toDateFormatter = DateFormatter()
toDateFormatter.dateFormat = to
formattedDateString = toDateFormatter.string(from: formattedDate!)
shahdhiren / Print all fonts in iOS - Swift
Created Jan 20, 2017
Print all fonts in iOS - Swift
View Print all fonts in iOS - Swift
func printFonts() {
let fontFamilyNames = UIFont.familyNames
for familyName in fontFamilyNames {
print("Font Family Name = [\(familyName)]")
let names = UIFont.fontNames(forFamilyName: familyName )
print("Font Names = [\(names)]")
shahdhiren / P12toPEM.txt
Created Sep 9, 2016
Convert P12 file for Push Notification to PEM format
View P12toPEM.txt
Development Phase:
Step 1: Create Certificate .pem from Certificate .p12
Command: openssl pkcs12 -clcerts -nokeys -out apns-dev-cert.pem -in apns-dev-cert.p12
Step 2: Create Key .pem from Key .p12
Command : openssl pkcs12 -nocerts -out apns-dev-key.pem -in apns-dev-key.p12
Step 3: Optional (If you want to remove pass phrase asked in second step)
Command : openssl rsa -in apns-dev-key.pem -out apns-dev-key-noenc.pem
shahdhiren / Install App file on Simulator
Last active May 6, 2016
Install iOS app on simulator
View Install App file on Simulator
Apple has introduced an interesting tool with Xcode 6!
simclt allows you to control the simulators running
run xcrun simctl to get the list of available subcommands. Lots of new options to play around.
Now to do what I wanted. Here is the command to launch simulator
shahdhiren / Change a User Default Login Shell
Created Feb 8, 2016
Change the Shell in Mac OS X Terminal
View Change a User Default Login Shell
Change the user login default shell to zsh:
chsh -s /bin/zsh
chsh -s /bin/ksh
chsh -s /bin/tcsh
bash (default):
View “Show In Finder” won't work to open a new finder window
Sometimes it happens that "Show in Finder" does not work to open in new window.
Also, in Xcode when you right click any file and try to "Show in Finder" it does not show up.
As an alternative to this bug's solution, try to run below terminal command:
sudo killall -KILL appleeventsd