superarts / superarts.github.io

www.superarts.org
Other
3 stars 1 forks source link

Random stuff #17

Open superarts opened 1 year ago

superarts commented 1 year ago

How would I rank my skills regarding a programming language:

  1. Have a basic understand of the language and its features
  2. Have learned the langauge and written code for a small size project
  3. Understand the language and have used it professionally (i.e. getting paid for it)
  4. Understand the language and use it regularly in real life projects
  5. Have a solid understanding of the language's feature and professionally use it on a daily basis
  6. Item 5 and on multiple platforms / SDKs / OSes where the language is available, and understand the language's standard and implementation
  7. Know 95% or more of the features of the language and actively follow the development of it
  8. Know 90% or more of the implementation details of the language and actively follow the development of it
  9. Actively participate in the development of the language standards and its implementation
  10. Lead the development of the language standards and its implementation
superarts commented 1 year ago

Gmail is getting weird recently.

I've been using an email forwarding system from my own domain -> my alt gmail -> my main gmail, and I noticed some missing emails recently. It turned out that my alt gmail has been marking some of the emails as spam, and unfortunately they won't be forwarded.

I don't know why Gmail has been blocking emails from my banks and ebay, marking emails from financial institutions is dangerous. There may be some workaround but I don't really have a strong reason to use my alt gmail anyway, so I think I should probably forward my personal email to my gmail directly.

I've set it up and it doesn't seem to work for how, I'll give it a couple of hours and try again. It should be working soon I hope.

superarts commented 10 months ago

Spent 30 min to finish almost everything and another 55 min to fix a test case: https://app.codility.com/c/feedback/6FNBKA-G3V/

image

superarts commented 10 months ago

https://online.swiftplayground.run/

import Foundation

let inflation_rate = 1.04
let savings_rate = 1.02
let savings_amount: Double = 500000
let current_age:Double = 60
let life_expectation:Double = 80
let current_year:Double = 2023

let years_left = life_expectation - current_age
let actual_savings = pow(savings_rate, years_left) * savings_amount
let needed_savings = pow(inflation_rate, years_left) * savings_amount

print("Savings will be $\(actual_savings) when you die.")
print("You need $\(needed_savings) to maintain the same living quality.")

let year_spending = savings_amount * actual_savings / needed_savings / years_left

print("You should spend $\(year_spending) each year to maintain the same quality of living.")

// for age in current_age ..< life_expectation {
//    print("\(current_year + age - current_age): age \(age), ")
//}
superarts commented 8 months ago

Random thoughts about certain topics

SwiftUI

I've been using SwiftUI for 2 years in my most recent project. It's definitely the future of native iOS development, and Android is taking a similar route as well (Jetpack compose). However, SwiftUI is still evolving and we may have to fallback to UIKit for some specific UI design / animation.

There are a lot of good things about SwiftUI, and my favorite part is its reactive nature that drives the data flow, binds data sources and UI representation in a way that is more nature to human's mindset. Although the MVVM design pattern is used by most developers nowadays, potentially we could have some more innovative ones in the future.

Native applications

Most of the projects I've been working on are native projects. Everyone loves the concept of reusing code and cross platform programming, but when it comes down to the actual projects, there is a fundamental issue that is literally unresolvable, which is the main reasons why building native apps are better for a lot of businesses.

What apps do, is essentially calling various frameworks / libraries to implement customized high level business logic. On iOS and Android, frameworks are updated regularly, and on a yearly basis we always expect a lot of major changes. You either adapt to these changes and taking the most advantages of the platform asap, or introduce another layer of framework to sacrifice the native technology and choose a platform solution, base on your business goal. There are also some middle ground that allows you to build certain modules in a cross-platform way, but for the UI part, using the native approach is generally preferred.

Swift

Swift was not released as an ultimate solution. At first (around 2014-2015), the goal was to build a modem programming language that did what objc did, but with better syntax. Back then, most interviewers would ask things about optional chaining, forced unwrapping etc. but not all of them knew that nullability was introduced to objc as well, and the implementations were very different. However, how much does it benefit the high level developers to understand how optional was implemented, versus how to correctly use optional in Swift? I'm still thinking of this kind of questions nowadays.

Anyway, around Swift 3-4, it's pretty much stabilized. API conventions are determined and unified. Old APIs were deprecated in a non-backward compatible way, which is actually a good thing to code quality. And starting from Swift 5, new high level language features are introduced like async / await, some vs any, alongside with frameworks like SwiftUI and combine. It brings challenges to developers who need to deliver features and also catch up with the newest technology, but using the new language features always pay off in the long run.

iOS

I've been working on iOS for 15 years and have 4 years Android experience. There are pros and cons between these 2 from day 1. While learning from each other for more than a decade, these 2 platforms are quite similar now.

There are something good about iOS from the very beginning. For example, objc was a language that got compiled to native x86/arm code directly, which made the code very fast to execute, even it used a string based messaging system internally. Swift uses a completely different runtime but the idea is the same. Android made it up only in the recent few years thanks to the faster CPUs. Another example is the sandbox and strict permission control, and it gets more and more strict. Android is doing the same thing as well.

I personally don't like something from iOS. Some of them are changed, for example the delegate pattern. I think it's an outdated pattern that belongs to the 2000s and it was abused in Apple's tech stack like MVC. Thankfully it has been changed a lot. Another thing Apple perhaps will never change, is the way how the frameworks are bundled by default. This is essentially how OS X and Linux differs. I'm not going to expand this topic but in general, I'm not a big fan of large binaries.

superarts commented 8 months ago

Following Integrate GitLab with Jira and got a "Failed to link group. Please try again." problem. Followed this topic and the problem is solved.

Basically the resolution is to create a site-admins group and add yourself. Note that this is not a prefilled name and you have to enter it yourself.

image

superarts commented 8 months ago

Recently some of my emails from my personal domain got rejected by a bunch of email servers due to DMARC compliance issue. After some investigation, I don't think it can be fixed easily with my domain provider, namesilo.

I tried https://redsift.com/tools/investigate and the following checks failed:

DMARC alignment check

Which makes sense because my setup is simply forwarding names from namesilo to gmail. In this setup, gmail will be sending emails using my personal domain email address as an alias, and it makes sense that there's no way for gmail to represent my personal domain without setting up any sort of certificate (which is not supported by namesilo and gmail as a free service anyway).

A logical solution would be setting up an SMTP server on namesilo, and give credentials to gmail, so that when emails are from my personal domain, gmail could use my SMTP server, which should be able to prove itself to be legit (if there's a way, I haven't dug yet). However, Namesilo doesn't support SMTP, so it's simply not possible.

If I really care about this feature, I would probably need to look for some email hosting services. There may be an use case in future, for example when ebay sends an email to my personal domain, they probably only accept reply from the same email address (and if they would require DMARC I'll be in trouble). But for now, I think I can settle with receiving emails from my personal domain, and sending it from my gmail account.

Around year 2017, after I moved to the US, I started to mainly use my personal domain email as my "main". Now I think about it, I should probably stop doing it because it doesn't really bring much benefit. In year 2022, I moved away from G suite because of Google terminated the free domain hosting service; and now everyone starts to check DMARC, I should probably switch back to gmail and stick with it.

superarts commented 8 months ago

FAQ

Why linking jira with commits?

if you look for commits from MR, linking commits with jira is not that helpful. but a normal user case for me is to run git blame if i’m confused by some code, and if we have jira ticket number in commit message, i can easily locate the jira ticket and find the context / assignee etc.

if we don’t have it, we probably need to go to gitlab and search a MR from a commit hash, which is doable but not as easy as using jira ticket number. plus, it just takes 2 seconds to put it there

Why API versioning is preferred by mobile apps?

Unlike a web app, mobile apps cannot force user to update their app in app store (you can only prevent them from using the app). thus api versioning is usually necessary. Users may not be able to update their client due to old iOS version etc.

Let’s discuss if we should rename API root from /api to /api/v1 across all services.

superarts commented 8 months ago

System Architecture - Technical Design

Why architectural design

The bare minimum of a system

Example: single component systems

Example: a mobile app

Frontend system design

Check my other resources - networking frameworks, testing frameworks, etc.

Backend system design

A single component backend

Production-ready backend

Microservices

SaaS and so on

superarts commented 8 months ago

Localization in iOS

The bottom line is that you should NEVER use hard-coded strings in your codebase, like APIManager.get("/api/user"), or Text("Tap to follow"). I don't think it's even need to be explained.

The problem with Apple's localization approach is that it's outdated. Using a string file to manage texts, without using strong type, was some really old approach.

UPDATE: I was stupid, I need to start using String Catalog.

UPDATE: I still prefer an enum based management system.

superarts commented 8 months ago
superarts commented 8 months ago

image

superarts commented 8 months ago
superarts commented 8 months ago
superarts commented 8 months ago
superarts commented 7 months ago

Didn't log anything I've done here, but still did a ton management stuff. And came up with some new ideas about interviews.

superarts commented 7 months ago

I've been trying to work on iOS work mostly, so nothing to add recently. A lot of integration work, code review, and MVVM vs clean architecture attempts.

I'm also exploring a new process of hiring. So far it turns out to be pretty effective to filter out bad candidates.

superarts commented 7 months ago

A lot of iOS work and some minor backend work & a lot of code review. Finally moving to GitHub from GitLab, not sure why GitLab is way more expensive per person than GitHub.

superarts commented 7 months ago

Running golangci-lint in a container: golang:latest causes a GitHub actions issue:

main.go:1: : error obtaining VCS status: exit status 128
    Use -buildvcs=false to disable VCS stamping. (typecheck)

Not sure why but git ownership is messed up inside the container (#GitHubActions doesn't have #SSH so it's hard to tell why). There's a very ugly workaround git config --global --add safe.directory /__w/YOUR_REPO but I'd be very hesitated to use it. Instead, I decided to get rid of the container and went with:

      - uses: actions/setup-go@v4
        with:
          go-version: '1.21'
          cache: false
      - name: golangci-lint
        uses: golangci/golangci-lint-action@v3
        with:
          version: v1.54
          working-directory: ./YOUR_PATH

go-version could be a problem later, but generally speaking, versions should be fixed in actions anyway. So we should be good.