Skip to content

Instantly share code, notes, and snippets.

View ingramchen's full-sized avatar

Ingram Chen ingramchen

View GitHub Profile
@ingramchen
ingramchen / sealed_example.kt
Last active February 23, 2023 03:36
Domain Model Layer Convention (Model 層級管理)

Model 層級管理

Domain Model 層的意義

一個傳統 Java Spring 的應用程式會分為三層 @Controller @Service @Repository,然後依據組織需求,再往下細分。 比方說 Service 層複雜的話,會增加 Gateway、Facade 層,或是我們組織獨有的 CoreService 層

另一個層級大部份 Java 組織會忽略的是 Domain Model 層,絕大多數 Java 開發者會開個 entity 或 model package,然後 將所有的 Entity 往裡面丟。然而該 Entity 只是一堆欄位和 getter/setter 的堆疊,也就是單純的 Table 的對應物件而已, 不具備任何 business logic

@ingramchen
ingramchen / hjkl.js
Created January 23, 2023 11:44
tampermonkey ptt hjkl keyboard
// ==UserScript==
// @name ptt hjkl keyboard
// @namespace http://tampermonkey.net/
// @version 0.1
// @description right hand keyboard to navigate term.ptt.cc
// @author Ingram Chen
// @match https://term.ptt.cc/
// @icon https://www.google.com/s2/favicons?sz=64&domain=ptt.cc
// @grant none
// ==/UserScript==
@ingramchen
ingramchen / nobara-kde.md
Last active September 27, 2024 02:56
Linux tweak memo

Environment

  • Nobara (Fedora 39~)

Chrome

  • download rpm to install
  • force to sRGB profile (particulary in wayland)
  • chrome://flags/#force-color-profile and set to sRGB
@ingramchen
ingramchen / 00-ubuntu-intellij-macosx.md
Last active April 19, 2024 15:42
Use ubuntu/Intellij like macOS X

How to mimic full macOS Intellij behavior in Ubuntu

  • Enviroment
    • Ubuntu 20.04
    • Intellij IDEA 2020

Ubuntu gnome shell shortcuts

@ingramchen
ingramchen / gist:e2af352bf8b40bb88890fba4f47eccd0
Created April 5, 2016 12:58
ffmpeg convert gif to mp4, for best cross browser compatibility
### Full command line options
```
ffmpeg -f gif -i FOO.gif -pix_fmt yuv420p -c:v libx264 -movflags +faststart -filter:v crop='floor(in_w/2)*2:floor(in_h/2)*2' BAR.mp4
```
### Notie
* output mp4 is encoded with h264, support Firefox/Chrome/Safari in Windows, Mac OSX, Android, and iOS.
@ingramchen
ingramchen / gist:adacc38c22f6506c0053
Created February 2, 2015 03:57
Java scan available port
// good for unit test
public static int scanAvailablePort() throws IOException {
try (ServerSocket serverSocket = new ServerSocket(0)) {
return serverSocket.getLocalPort();
}
}
@ingramchen
ingramchen / .gitignore
Last active September 27, 2022 06:43 — forked from BennettSmith/.gitignore
Build protobuf 2.6 static library for iOS, base on BennettSmith's work
protobuf
protobuf-2.6.1
protobuf-master
@ingramchen
ingramchen / gist:21533bbfc0d2dead94a7
Last active April 25, 2016 15:22
思源 ubuntu CJK fonconfig 設定檔
<fontconfig>
<match target="pattern">
<test qual="any" name="family">
<string>serif</string>
</test>
<edit name="family" mode="prepend" binding="strong">
<string>Noto Sans T Chinese</string>
<string>Noto Sans S Chinese</string>
<string>Noto Sans Japanese</string>
<string>Noto Sans Korean</string>
@ingramchen
ingramchen / gist:f2ac2c1c96e8a8717c15
Last active August 29, 2015 14:04
展示 Java 8 與 Java 7 兩者撰寫上差異
package com.liquable.nemo.model;
import static java.util.Arrays.asList;
import static java.util.stream.Collectors.groupingBy;
import static java.util.stream.Collectors.summingLong;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@ingramchen
ingramchen / gist:98d0cc3b325999fa0a7a
Created May 8, 2014 13:17
Embed Tomcat with nio connector
Tomcat tomcat = ....
final Connector nioConnector = new Connector(Http11NioProtocol.class.getName());
nioConnector.setPort(58090);
nioConnector.setSecure(false);
nioConnector.setScheme("http");
nioConnector.setProtocol("HTTP/1.1");
try {
nioConnector.setProperty("address", InetAddress.getByName("localhost").getHostAddress());