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 / Better use OSLog in iOS 17+.md
Last active August 1, 2023 14:31
OSLog in iOS is OP!(Over Power)
@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 / tag_operations.md
Created October 15, 2019 00:58
[Git] Create & delete tag (both local and remote)

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
@SheldonWangRJT
SheldonWangRJT / OpenGL_larning_resources.md
Last active September 30, 2019 23:39
A Few OpenGL Learning Resources

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

About

I have been working with OpenGL ES related stuff in iOS. With Metal taking over iOS GPU rendering, it seems not too smart to start learning if you are very new, however, regardless OpenGL, Metal, they are both doing the similar stuff, which is GPU grapical rendering. If you knew one, you will easily know the other.

This is not a tutorial, it is more like a reference book for myself and u the reader.

Tutorials

  1. GLKit Tutorials (Swift)
@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 / CreateLocalHTTPSServer.md
Last active March 8, 2019 21:53
Create local HTTPS server

Create local HTTPS Server

I was required to test some files that have to be hosted under a HTTPS server. Although at the end of the day, I used Azure to deploy a simple webservice, but the process to create a local HTTPS server is still interesting enough to let me write it down.

Notice before you start

There are two things you need to keep in mind before u keep doing this:

  • Although we will be using openssl to create a certificate, it is not a trusted certificate, I don't know if this will fulfil your need of HTTPS or not.
  • It will require sudo, make sure you are admin of your machine
@SheldonWangRJT
SheldonWangRJT / jack-johnson.json
Last active November 13, 2018 18:28
SampleJSONTracks
{
"resultCount":50,
"results":[
{
"wrapperType":"track",
"kind":"song",
"artistId":909253,
"collectionId":879273552,
"trackId":879273565,
"artistName":"Jack Johnson",
@SheldonWangRJT
SheldonWangRJT / How to write verilog in macOS?.md
Created September 28, 2018 03:31
How to write verilog in macOS? #VHDL #Verilog

Software to use:

  1. terminal app - iverilog
  2. macOS waveform app - GTKWave

iverilog can be download using homebrew. $ brew install icarus-verilog GTKWave can be downloaded here: http://gtkwave.sourceforge.net/

To See Waveform in macOS for VHDL

@SheldonWangRJT
SheldonWangRJT / iOS-MacOS-Tricks-to-Debug-Detecting-Ambiguous-Auto-Layouts-Issues.md
Last active October 24, 2019 22:39
iOS/MacOS Tricks to Debug/Detecting Ambiguous Auto Layouts Issues

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

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;