Skip to content

Instantly share code, notes, and snippets.

View SheldonWangRJT's full-sized avatar
🎯
Focusing

Engineer Sheldon Wang SheldonWangRJT

🎯
Focusing
View GitHub Profile
@SheldonWangRJT
SheldonWangRJT / Convert .mov or .MP4 to .gif.md
Last active May 13, 2026 12:44
Convert Movie(.mov) file to Gif(.gif) file in one command line in Mac Terminal

This notes is written by Sheldon. You can find me with #iOSBySheldon in Github, Youtube, Facebook, etc.

Need

Convert .mov/.MP4 to .gif

Reason

As a developer, I feel better to upload a short video when I create the pull request to show other viewers what I did in this PR. I tried .mov format directly got after finishing recording screen using Quicktime, however, gif offers preview in most web pages, and has smaller file size.

This is not limited to developer, anyone has this need can use this method to convert the files.

@SheldonWangRJT
SheldonWangRJT / Git - Revert a Merge.txt
Last active March 28, 2026 15:39
Git - Common Used Commands
Git - Revert a Merge
#iOSBySheldon
Reverting a commit is usually not hard, specially with the help of Source Tree, if, you are reverting a simple commit on a branch. What you need to do is just to right click the commit you want to revert and then choose "Reverse Commit".
However, if the commit you want to revert is a "Merge", it will be a little bit harder. If you do the same thing in Source Tree, right click - "Reverse Commit", it will give you an error that Source Tree cannot revert it because there are two branches involved.
Let's name the merge-from branch as "F" and "merge-to" branch as "T".
Here is the solution for it (only can be done in Terminal, at least today):
@SheldonWangRJT
SheldonWangRJT / Something About iOS Crashes.md
Last active March 28, 2026 15:39
Dealing with the Crash Log Files (.crash), dSYM, EXC_BAD_ACCESS, EXC_CRASH and so on.

Something About iOS Crashes

#iOSBySheldon Apps are crashing all the time. No matter how good you write your app, it will crash in some cases.

When apps crashed, iOS will automatically generate a crash log file, the file has the extension as .crash. A crash file contains a lot of info like which version, which build, which device your app is crashing on. And the most important part of a crash file a the stack trace that indicates which function of your code in which file is crashing.

However, to find out which function of your code is crashing is not that straight forward from the crash log files. Because when we build our app, Xcode compiles our code files into binaries that changes the looking of our code. Therefore, to find out which line of code is crashing, we need a file to kinda to the translation for us, in iOS, this "translation" needs to be handled by debug-symbols files, which is also called dSYM files. (.dSYM)

Please see [1] as the image that indicates the whole process of creating the bu

@SheldonWangRJT
SheldonWangRJT / Map, FlatMap (CompactMap), Reduce, Filter & Sort.md
Last active March 28, 2026 15:39
Swift Map, FlatMap (CompactMap), Reduce, Filter & Sort

High Order Functions in iOS Swift

Written by Sheldon, please find me with #iOSBySheldon in Github, Youtube, Facebook, etc.

It is exaggerating to say we don't need to use for loop or while loop any more but we can take advantage of the Swift language built in functions to do loops. If I give you a question now. Q: Assuming we have an optional nested array, please calculate the production of the values that are less than 5. let numbers: [[Int]?] = [[1, 3], nil, [2], [5, 10], nil, [4]], what is your best approach to do it?

And you know the solution that I am talking about is following Swift functions:

  1. Map
  2. FlatMap / CompactMap
@SheldonWangRJT
SheldonWangRJT / Git - How to Rebase and Squash Commits
Created March 24, 2018 00:23
Git - How to Rebase and Squash Commits
Git - Rebase and Squashing
#iOSBySheldon
It is pretty often that you notice your feature branch has way too many commits right be fore you merge to the Master branch.
If you see your git history of your branch, it might be like:
History:
Commit xxxx1 "modified 2 more tests"
Commit xxxx2 "updated first test"
@SheldonWangRJT
SheldonWangRJT / WWDC18-416.md
Last active July 24, 2025 13:34
WWDC18 Notes by Sheldon - Session 416 - iOS Memory Deep Dive

WWDC18 Notes - Session 416 - iOS Memory Deep Dive

All session list link: Here
Session Link: Here
Demo starts @ 25:30 in the video.
Download session slides: Here

This notes is written by Sheldon after watching WWDC18 session 416. You can find me with #iOSBySheldon in Github, Youtube, Facebook, etc.

@SheldonWangRJT
SheldonWangRJT / iOS Dynamic vs. Static Library & Framework.md
Last active November 2, 2024 06:08
iOS Dynamic vs. Static Library / Framework

iOS Dynamic vs. Static Library / Framework

Find me on Github, Facebook, Youtube, etc by #iOSBySheldon.

Concept

Library and Framework are not same but close. Frameworks are just libraries with linking (binding). In other words, frameworks are just libraries that are bundled into targets. Therefore, their file extensions are different.

File Format

  • Static Library - xxxx.a
  • Dynamic Library - xxxx.dylib

iOS Swift - Cancellable Task with GCD

#iOSBySheldon

I think most of you guys know GCD pretty well. Basically, GCD is a high level API to handle multi-threading operations. We use GCD almost on daily basis to switch thread and execute codes like:

DispatchQueue.main.async { //execute some codes here } 
//switch to main queue and execute codes asynchronously

DispatchQueue.main.sync { //execute some codes here } 
//switch to main queue and execute codes synchronously
@SheldonWangRJT
SheldonWangRJT / iOS Create a Carthage Supported Framework.txt
Last active August 28, 2023 09:28
iOS Create a Carthage Supported Framework
iOS Create a Carthage Supported Framework
#iOSBySheldon
A little bit Background of Carthage:
- Carthage works like Cocoapods, but a little bit simpler.
* When creating a Cocoapods supported framework need a .podspec file to do some config, which is not required by Carthage.
* When using a Cocoapods supported framework, a workspace file will be automatically created, the umbrella header will be setup in a pod project inside workspace. It feels simple, but the whole process creates a lot files including a "giant" workspace.
* When using a Carthage supported framework, it will just download the framework, and its dependencies if any, to a folder. All we need to do is to drag and drop it to the binary linking section in the project build setting tab, for the first time. It sounds complicated but it makes the project clean.
- Carthage is written in Swift.
- Carthage internally uses `-xcodebuild` to build dependency.
@SheldonWangRJT
SheldonWangRJT / Better use OSLog in iOS 17+.md
Last active August 1, 2023 14:31
OSLog in iOS is OP!(Over Power)