Sherry L
[LeetCode] Learning Python with the Leetcode Beginner Guide

I got a RaspberryPi long time ago but never had the chance to play with it. Recently I finally started looking into doing some small IoT projects. And before getting into that, with the growing interest of image-processing and scraping and… endless things to learn (😂), I decide to learn Python, which is also the language recommended by the RaspberryPi developer community.

I have been coding along an Udemy Python course to learn the basics, and want to get familiar with this language as fast as possible. To get my hands dirty, I figure I should expose myself to this language more than just course exercises. Since I have learned some syntaxes and with the problem solving skills I had from my day-to-day experience working with JavaScript, I decided to boost my familiarity of Python with the Leetcode Beginners Guide.

This guide is a good starter with basic data structures. I have come across one of the interesting problem sets, where Python’s simplicity surprises me. So here is my solving process for 1342. Number of Steps to Reduce a Number to Zero:

[Projects] Run Express + MariaDB app with docker-compose

I have long been curious about containerizing techniques, but as a Jr. Backend Developer, I barely have the chance to even modify the Dockerfiles of our company projects, which was set up by the DevOps engineer loooong time ago. Since we all use the same distribution/version of Linux in the office, pull code from Gitlab repos, and having a dedicated QA server for developing, there are minimal chances/reasons for one to actually set up docker containers to run the shared project and develop with local data.

So here I am, self-taught from Udemy and the Docker official docs, finally having the chance to develop my OWN projects with Docker! 😂 This post is a detailed note on my first time running an Express + MariaDB app with docker-compose.

Use Docker 🐋 to start an Express app

We can run an app in a container based on its image, which contains the binaries required. In order to do that, we must build an image for our node app. Here we have a very basic Express app listening on port 3000:

// index.js
const express = require('express')
const app = express()
const PORT = process.env.PORT || 3000

app.use(express.json())
app.use(express.urlencoded({ extended: false }))

app.listen(PORT, () => {
  console.log(`Express app is now running on port ${PORT}...`)
})

Normally we can just run node index.js to start the server. This time we’re running our node app in a Docker container.

[LeetCode] SQL Study Plan_Day 2

#1873 Calculate Special Bonus

Notes

CASE
    WHEN condition1 THEN result1
    WHEN condition2 THEN result2
    WHEN conditionN THEN resultN
    ELSE result
END;
SELECT CustomerName, City, Country
FROM Customers
ORDER BY
(CASE
    WHEN City IS NULL THEN Country
    ELSE City
END);
  • Usage of NOT LIKE with Wildcards in SQL:
    In this case we are looking for words that do not start with a ‘M.’ Therefore we should use ‘M%’ with the NOT LIKE to include them.

SQL Wildcards

  • Usage of remainders:
    In this case we are looking for odd numbers, which means it has a remainder of 1 if divided by 2. There are several ways to indicate a remainder statement:
    1. MOD statement:
      SELECT MOD(9, 2);   // 1, odd number
      
    2. x % y
      SELECT MOD(employee_id, 2) != 0
      
[LeetCode] Problem Solving Pattern_Frequency Counter

I am currently studying the Udemy course JavaScript Algorithms and Data Structures Masterclass and want to jot down some notes. This post is dedicated to the problem solving pattern - Frequency Counters.

Scenarios

In some problem sets we can see questions like “how many times has a, b, c occurred,” “find the most frequently appeared element” popping up. And that is the sign of frequency counters.

Key Takeaways

  • Use objects or sets to collect values/frequencies of values
  • Try to avoid nested loops or O(N^2) operations with arrays/strings

Basics

Here is a Code snippet of a basic function same(), and validAnagram().

Exercise 1, Exercise 2

[Work] 解決問題的過程

前言

「解決問題」可以說是工程師的日常,例如 需求下來了,準備實作功能時,如何去規劃?知道程式碼有 bug,要找出它並修好,使服務正常上線、服務 performance 不佳,想找出徵節點並加以改善等等。

雖然每天都在重複以上情境,卻沒留下什麼紀錄。我想藉由最近一次解決問題的經驗,來剖析自己面對問題時的思考、與後續採取動作的流程,做一次詳細的紀錄。