Skip to content

Instantly share code, notes, and snippets.

View up1's full-sized avatar

Somkiat Puisungnoen up1

View GitHub Profile
@up1
up1 / Dockerfile
Created July 2, 2024 01:35
Go :: gomod download vs tidy
FROM golang:1.22.4-alpine3.19 as builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -v
@up1
up1 / test.js
Created June 28, 2024 16:21
Playwright + Clock API
// Initialize clock and let the page load naturally.
await page.clock.install({ time: new Date('2024-02-02T08:00:00') });
await page.goto('http://localhost:3333');
// Pretend that the user closed the laptop lid and opened it again at 10am,
// Pause the time once reached that point.
await page.clock.pauseAt(new Date('2024-02-02T10:00:00'));
// Assert the page state.
await expect(page.getByTestId('current-time')).toHaveText('2/2/2024, 10:00:00 AM');
@up1
up1 / 1.txt
Last active June 20, 2024 14:59
TypeSpec 2024
// ติดตั้ง library
$npm install -g @typespec/compiler
// สร้าง project
$tsp init
TypeSpec compiler v0.57.0
? Please select a template › - Use arrow-keys. Return to submit.
❯ Empty project min compiler ver: 0.57.0 - Create an empty project.
Generic REST API min compiler ver: 0.57.0
@up1
up1 / 1.txt
Last active June 19, 2024 05:57
Tips:: .NET version
$dotnet --list-sdks
6.0.406 [/usr/local/share/dotnet/sdk]
6.0.410 [/usr/local/share/dotnet/sdk]
6.0.412 [/usr/local/share/dotnet/sdk]
7.0.200 [/usr/local/share/dotnet/sdk]
7.0.201 [/usr/local/share/dotnet/sdk]
7.0.304 [/usr/local/share/dotnet/sdk]
7.0.306 [/usr/local/share/dotnet/sdk]
8.0.100-preview.3.23178.7 [/usr/local/share/dotnet/sdk]
8.0.100-preview.5.23303.2 [/usr/local/share/dotnet/sdk]
@up1
up1 / 1.txt
Last active June 11, 2024 09:30
Cypress tips :: manage tab or window
// HTML
<div class="demo">
<a href="/windows/new" ,="" target="_blank">Click Here</a>
</div>
// Test with cypress
describe("Demo spec", () => {
it("check data after click link", () => {
// Arrange
cy.visit("your target");
@up1
up1 / 1.txt
Last active June 9, 2024 05:10
MSTest 3.4 + Playwright
$dotnet --version
9.0.100-preview.4.24267.66
$dotnet new list
These templates matched your input:
Template Name Short Name Language Tags
-------------------------------------------- -------------------------- ---------- --------------------------------
API Controller apicontroller [C#] Web/ASP.NET
ASP.NET Core Web API (native AOT) webapiaot [C#] Web/Web API/API/Service
@up1
up1 / docker-compose.yml
Created June 8, 2024 16:01
Grafana Alloy
services:
alloy:
image: grafana/alloy:latest
command: run --server.http.listen-addr=0.0.0.0:12345 --storage.path=/var/lib/alloy/data /etc/alloy/config.alloy
ports:
- 12345:12345
volumes:
- ./config.alloy:/etc/alloy/config.alloy
@up1
up1 / 1.txt
Last active June 8, 2024 05:07
Java23 :: Markdown Comment
$java -version
openjdk version "23-ea" 2024-09-17
OpenJDK Runtime Environment (build 23-ea+25-2094)
OpenJDK 64-Bit Server VM (build 23-ea+25-2094, mixed mode, sharing)
$javadoc -d doc Demo.java
Loading source file Demo.java...
Constructing Javadoc information...
Building index for all the packages and classes...
Standard Doclet version 23-ea+25-2094
@up1
up1 / 1.txt
Last active June 3, 2024 07:39
CDS :: Spring Boot 3.3.0
$./mvnw clean package
$java -jar target demo.jar
Started Demo33Application in 1.49 seconds (process running for 2.434)
Memory footprint at startup: 40-70 MB
@up1
up1 / 1.txt
Last active May 27, 2024 15:50
Docker image digest
$docker image ls --digests
REPOSITORY TAG DIGEST IMAGE ID CREATED SIZE
nginx 1.25.5 sha256:a484819eb60211f5299034ac80f6a681b06f89e65866ce91f356ed7c72af059c 8dd77ef2d82e 3 weeks ago 193MB
nginx latest sha256:a484819eb60211f5299034ac80f6a681b06f89e65866ce91f356ed7c72af059c 8dd77ef2d82e 3 weeks ago 193MB
$docker image inspect nginx:1.25.5 --format '{{.RepoDigests}}'
[nginx@sha256:a484819eb60211f5299034ac80f6a681b06f89e65866ce91f356ed7c72af059c]