Skip to content

Instantly share code, notes, and snippets.

View shahdhiren's full-sized avatar

Dhiren Shah shahdhiren

View GitHub Profile
@shahdhiren
shahdhiren / swift4-plist-extract.swift
Created February 2, 2019 14:20 — forked from db42/swift4-plist-extract.swift
Swift 4 recipes: Extract data from a property list
//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 {
return
}
@shahdhiren
shahdhiren / Export clob field from Oracle SQL Developer
Last active September 27, 2021 10:05
Export Clob data from Oracle
spool clob_export.sql
select /*insert*/ * from <TABLE_NAME> where <FIELD>='88c820c4-b295-466b-a1a3-beb55434e0e9';
spool off
#Stackoverflow: https://stackoverflow.com/questions/42244941/how-to-export-clob-field-datas-in-oracle-sql-developer
@shahdhiren
shahdhiren / DropAllUserTables.sql
Last active May 4, 2018 06:11
Drop all user tables in Oracle
BEGIN
FOR cur_rec IN (SELECT object_name, object_type
FROM user_objects
WHERE object_type IN
('TABLE',
'VIEW',
'PACKAGE',
'PROCEDURE',
'FUNCTION',
'SEQUENCE',
@shahdhiren
shahdhiren / Symbolicate Xcode Crashlogs
Last active July 30, 2018 20:53
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
shahdhiren / Convert Date Format (From-To) Swift 3
Last active February 6, 2017 06:36
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 = fromDateFormatter.date(from: dateString!)
if formattedDate != nil {
let toDateFormatter = DateFormatter()
toDateFormatter.dateFormat = to
formattedDateString = toDateFormatter.string(from: formattedDate!)
@shahdhiren
shahdhiren / Print all fonts in iOS - Swift
Created January 20, 2017 09:47
Print all fonts in iOS - Swift
func printFonts() {
let fontFamilyNames = UIFont.familyNames
for familyName in fontFamilyNames {
print("------------------------------")
print("Font Family Name = [\(familyName)]")
let names = UIFont.fontNames(forFamilyName: familyName )
print("Font Names = [\(names)]")
}
}
@shahdhiren
shahdhiren / P12toPEM.txt
Created September 9, 2016 14:57
Convert P12 file for Push Notification to PEM format
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
shahdhiren / Install App file on Simulator
Last active October 24, 2022 16:25
Install iOS app on simulator
Apple has introduced an interesting tool with Xcode 6!
simctl
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
shahdhiren / Change a User Default Login Shell
Created February 8, 2016 13:12
Change the Shell in Mac OS X Terminal
Change the user login default shell to zsh:
chsh -s /bin/zsh
ksh:
chsh -s /bin/ksh
tcsh:
chsh -s /bin/tcsh
bash (default):
Problem:
--------
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.
Solution:
---------
As an alternative to this bug's solution, try to run below terminal command:
sudo killall -KILL appleeventsd