Skip to content

Instantly share code, notes, and snippets.

View up1's full-sized avatar

Somkiat Puisungnoen up1

View GitHub Profile
@up1
up1 / 1.txt
Last active July 18, 2024 01:57
NodeJS 22.5 + SQLite
$npx node-nightly --experimental-sqlite demo-sqlite.js
Downloading the nightly version, hang on...
node-nightly is available on CLI!
[ { key: 1, value: 'hello' }, { key: 2, value: 'world' } ]
@up1
up1 / 1.txt
Last active July 8, 2024 07:27
Go :: error management
$go run demo-error.go
Wrapping Step1Error
Wrapping Step2Error
@up1
up1 / 1.txt
Last active July 7, 2024 17:10
Basic of tRPC
$curl --location --globoff 'http://localhost:3000/trpc/greeting?input={%22name%22%3A%22somkiat%22}' \
--header 'Cookie: Cookie_1=value' | jq
{
"result": {
"data": "Hello somkiat"
}
}
@up1
up1 / 1.swift
Last active July 6, 2024 04:34
Swift Testing 2024
import Testing
struct DemoTest {
@Test("Human readable",
.tags(.group01))
func advances_by_months() {
#expect(2023.dec.advanced(by: 1) == 2024.jan)
#expect(2023.jan.advanced(by: -1) == 2022.dec)
}
}
@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