Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Engineer Sheldon Wang SheldonWangRJT

🎯
Focusing
View GitHub Profile
@SheldonWangRJT
SheldonWangRJT / Convert .mov or .MP4 to .gif.md
Last active Feb 18, 2021
Convert Movie(.mov) file to Gif(.gif) file in one command line in Mac Terminal
View Convert .mov or .MP4 to .gif.md

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.

View iOS Swift - Cancellable Task with GCD.md

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 / Map, FlatMap (CompactMap), Reduce, Filter & Sort.md
Last active Dec 4, 2020
Swift Map, FlatMap (CompactMap), Reduce, Filter & Sort
View Map, FlatMap (CompactMap), Reduce, Filter & Sort.md

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 / WWDC18-416.md
Last active Nov 5, 2020
WWDC18 Notes by Sheldon - Session 416 - iOS Memory Deep Dive
View WWDC18-416.md

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 / How-to-sort-a-List<Object>-in-JAVA?.md
Created Jul 20, 2018
How to sort a List<Object> in JAVA in the best way?
View How-to-sort-a-List<Object>-in-JAVA?.md

How to sort a List<Object> in JAVA in a better way / the best way?

This is some notes written by Sheldon. I mainly focused on iOS programming but I also do JAVA and C# backend, you can find me with #iOSBySheldon in Github, Youtube, Facebook, etc.

High order functions with lambda is very easy in Swift (see article Here) but not that easy in languages like Objective-C or C++. In JAVA we can do it but since JAVA has too many versions, there are a lot different ways to do it, and there is always a better one you can choose.

Assuming we have a class like:

class Student {
    private int age;
@SheldonWangRJT
SheldonWangRJT / iOS Create a Carthage Supported Framework.txt
Last active Jan 24, 2020
iOS Create a Carthage Supported Framework
View iOS Create a Carthage Supported Framework.txt
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 / iOS Dynamic vs. Static Library & Framework.md
Last active Nov 12, 2019
iOS Dynamic vs. Static Library / Framework
View iOS Dynamic vs. Static Library & Framework.md

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 Nov 11, 2019
iPhone device names, types, resolutions, aspect ratio, scale, PPI
View iPhone_device_names_types_resolutions.md

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 / iOS-MacOS-Tricks-to-Debug-Detecting-Ambiguous-Auto-Layouts-Issues.md
Last active Oct 24, 2019
iOS/MacOS Tricks to Debug/Detecting Ambiguous Auto Layouts Issues
View iOS-MacOS-Tricks-to-Debug-Detecting-Ambiguous-Auto-Layouts-Issues.md

iOS/MacOS Tricks to Debug/Detecting Ambiguous Auto Layouts Issues

#iOSBySheldon #AutoLayout

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

This time I will bring you some tricks directly from Apple’s document regarding the ways to debug / detecting ambiguous warning (⚠️) for Auto Layouts in iOS and MacOS. To kick things off, I do want mention that Ambiguous Warning for Auto Layout means that the configuration you add into your storyboard or xib file has no conflicts (otherwise it will show ❗️in storyboard). However, it has multiple ways to fulfill your auto layout, so that the system will randomly choose a fine solution to render your view, which maybe correct, maybe wrong, in other words, very inconsistent.

“There are a few methods you can call to help identify ambiguous layouts. All of these methods should be used only for debugging. Set a breakpoint somewhere where you can access the view hierarchy, and then call one of the following methods fr

@SheldonWangRJT
SheldonWangRJT / tag_operations.md
Created Oct 15, 2019
[Git] Create & delete tag (both local and remote)
View tag_operations.md

You can find me by #iOSBySheldon on Github, Facebook, Youtube, etc.

Often used git tag operations

To create and push a tag

Assuming the tag name that we want to create is abc

# to create tag locally
$ git tag abc