Skip to content

Instantly share code, notes, and snippets.

@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

#/bin/bash
# Clone, compile & install
git clone --single-branch --branch Super-with-Scrolling https://github.com/rbreaves/x11vnc.git
# Enable all sources
sudo sed -i '/^#\sdeb-src /s/^#//' "/etc/apt/sources.list"
cd ./x11vnc
sudo apt update
@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

package main
import (
"bytes"
"encoding/binary"
"flag"
"io"
"io/ioutil"
"log"
"os"
@calvinlfer
calvinlfer / script.sh
Last active March 2, 2022 06:52
Pushing Jenkins ThinBackup backups to S3
#!/bin/bash -l
# find latest backup
thinbackup_path="$JENKINS_HOME/thinBackup"
latest_backup_folder=$(ls -t $thinbackup_path | head -n1)
full_path="$thinbackup_path/$latest_backup_folder"
echo "Latest backup is located at ${full_path}"
# pack it up
backup_name="$latest_backup_folder.tar.gz"
@mjdietzx
mjdietzx / waya-dl-setup.sh
Last active March 13, 2024 15:08
Install CUDA Toolkit v8.0 and cuDNN v6.0 on Ubuntu 16.04
#!/bin/bash
# install CUDA Toolkit v8.0
# instructions from https://developer.nvidia.com/cuda-downloads (linux -> x86_64 -> Ubuntu -> 16.04 -> deb (network))
CUDA_REPO_PKG="cuda-repo-ubuntu1604_8.0.61-1_amd64.deb"
wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/${CUDA_REPO_PKG}
sudo dpkg -i ${CUDA_REPO_PKG}
sudo apt-get update
sudo apt-get -y install cuda
@roylee0704
roylee0704 / dockergrep.sh
Created December 9, 2016 08:24
how to grep docker log
docker logs nginx 2>&1 | grep "127."
# ref: http://stackoverflow.com/questions/34724980/finding-a-string-in-docker-logs-of-container
@cecilemuller
cecilemuller / letsencrypt_2020.md
Last active April 15, 2024 02:19
How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SSL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SLL rating)


Virtual hosts

Let's say you want to host domains first.com and second.com.

Create folders for their files:

@geraintluff
geraintluff / base64-web-safe.js
Created October 9, 2015 15:36
Convert base64 to and from web-safe variant
// Convert from normal to web-safe, strip trailing "="s
function webSafe64(base64) {
return base64.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
}
// Convert from web-safe to normal, add trailing "="s
function normal64(base64) {
return base64.replace(/\-/g, '+').replace(/_/g, '/') + '=='.substring(0, (3*base64.length)%4);
}
@MLnick
MLnick / HyperLogLogStoreUDAF.scala
Last active March 16, 2022 05:31
Experimenting with Spark SQL UDAF - HyperLogLog UDAF for distinct counts, that stores the actual HLL for each row to allow further aggregation
class HyperLogLogStoreUDAF extends UserDefinedAggregateFunction {
override def inputSchema = new StructType()
.add("stringInput", BinaryType)
override def update(buffer: MutableAggregationBuffer, input: Row) = {
// This input Row only has a single column storing the input value in String (or other Binary data).
// We only update the buffer when the input value is not null.
if (!input.isNullAt(0)) {
if (buffer.isNullAt(0)) {