Skip to content

Instantly share code, notes, and snippets.

View WaltXin's full-sized avatar
🍀

Walt WaltXin

🍀
View GitHub Profile
@WaltXin
WaltXin / .md
Last active June 20, 2018 15:12
About

My name is walt, I am a programmer

@WaltXin
WaltXin / .md
Last active March 31, 2019 22:48
Java Knowledge

Java basic knowledge

Primitive type and Autoboxing/Unboxing

Eg: int vs Integer
int is primitive type, while Integer is a class (eg: Integer.parseInt("1") is a call of Integer's class method)
All primitive type in Java has an equivalent wrapper class:

  • byte -> Byte
  • short -> Short
  • int -> Integer
  • long -> Long
@WaltXin
WaltXin / .md
Last active June 28, 2018 20:12
Design Pattern

Design Pattern

Observer

An application calls an Observable object's notifyObservers method to have all the object's observers notified of the change.
Usage: Weather notification, wechat notification Observer

Singleton

Restrict the instantiation of a class to one object. eg:Login system.
Singleton

1.Eager Initialization

The instance of Singleton class is created at the time of class loading

@WaltXin
WaltXin / .js
Last active July 26, 2018 15:29
GNIB
// change to the date range you want yyyy/mm/dd
var fromDate = new Date('2018/08/05');
var toDate = new Date('2018/10/25');
fromDate.setHours(0, 0, 0, 0);
toDate.setHours(0, 0, 0, 0);
var intervalId = null;
var weirdSound= new Audio("https://www.freesound.org/data/previews/256/256458_4772965-lq.mp3");
var monthNames = ["January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"
@WaltXin
WaltXin / .md
Last active October 4, 2019 13:39
How to use GNIB js file
@WaltXin
WaltXin / .md
Last active June 12, 2021 05:42
TinyURL design
  1. Use sequenced ID
public class Codec {

    String chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    String prefix = "https://www.amz/";
    HashMap<String, String> map = new HashMap<>();
    int count = 1;
    
    private String genShortUrl() {

https://leetcode.com/problems/max-area-of-island/ Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surrounded by water.

Find the maximum area of an island in the given 2D array. (If there is no island, the maximum area is 0.)

Example 1:

[

 [0,0,1,0,0,0,0,1,0,0,0,0,0],
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<JetCodeStyleSettings>
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
</JetCodeStyleSettings>
<codeStyleSettings language="kotlin">
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
</codeStyleSettings>
</code_scheme>
</component>
@WaltXin
WaltXin / prepare_env.sh
Created August 16, 2025 03:24
prepare insforge ec2
#!/usr/bin/env bash
# prepare_env.sh — Prepare prerequisites for your init.sh on Amazon Linux 2023
# Works for: al2023-ami-2023.8.20250808.1-kernel-6.1-x86_64
set -euo pipefail
log(){ echo -e "[$(date +'%F %T')] $*"; }
log "[0] 清理可能干扰的第三方 Docker 仓库(如果有)..."
sudo rm -f /etc/yum.repos.d/docker-ce.repo || true