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 22, 2024 02:05
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 / WWDC18-416.md
Last active May 17, 2024 10:09
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 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)
@SheldonWangRJT
SheldonWangRJT / sleep_in_ios.md
Last active May 19, 2023 19:06
Shat is the difference among sleep() , usleep() & [NSThread sleepForTimeInterval:]?

#iOSBySheldon #objective-c #swift #unitTest #uiTest #sleep

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

The only reason that I wrote this short quick note is that, the answers on the internet is somewhat misleading.

If we are running sleep() usleep() or [NSThread sleepForTimeInterval:] in your main app, there should not be any difference. Because the first two functions are just functions that from c and the third one is from objective-c.

However,

  • You probably should NOT call them in your main app, because for delay operations you should more use (in Swift)
@SheldonWangRJT
SheldonWangRJT / iOS Dynamic vs. Static Library & Framework.md
Last active November 14, 2022 04:07
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
@SheldonWangRJT
SheldonWangRJT / iPhone_device_names_types_resolutions.md
Last active August 6, 2022 16:03
iPhone device names, types, resolutions, aspect ratio, scale, PPI

iOS Device Types, Names, Resolutions (points)

DEVICE TYPE PRODUCT NAME RESOLUTION (PIXEL) UIKIT SIZE (POINT) ASPECT RATIO (H:W) UIKIT SCALE PIXEL PER INCH (PPI)
iPhone1,1 iPhone 320 x 480 320 x 480 1.5 1.0 163
iPhone1,2 iPhone 3G 320 x 480 320 x 480 1.5 1.0 163
iPhone2,1 iPhone 3GS 320 x 480 320 x 480 1.5 1.0 163
iPhone3,1 iPhone 4 (GSM) 320 x 480 640 x 960 1.5 2.0 326
iPhone3,3 iPhone 4 (CDMA) 320 x 480 640 x 960 1.5 2.0 326
iPhone4,1 iPhone 4S 320 x 480 640 x 960 2.0 1.5 326
@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 / iOS CPU and GPU basics.md
Last active June 17, 2022 03:22
iOS CPU and GPU basics

iOS CPU and GPU basics

#iOSBySheldon #CPU #GPU #60FPS #CADisplayLink

Apple always encourage us as iOS developers to try to maintain our apps running with a 60 frames per second rate (60 FPS) to make sure the best user experience. Most of the time, this comes for free because the hardwares are getting better and better.

But in some cases you may need to dig deeper if your app as a significant frame drops to fix it for the users, which leads to my post today - the basic of CPU and GPU in iOS. Whenever I encounter this kind of question, I always want to find the answer directly from Apple’s official document. I was able to find this article here. I mean this article is written mainly for #Metal and iOS game developers but I found all the info that we need. As always, I will try to summarize the best part of the article.

@SheldonWangRJT
SheldonWangRJT / Map, FlatMap (CompactMap), Reduce, Filter & Sort.md
Last active March 21, 2022 20:04
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