Skip to content

Instantly share code, notes, and snippets.

View iporsut's full-sized avatar
🏠
Working from home

Weerasak Chongnguluam iporsut

🏠
Working from home
View GitHub Profile
@iporsut
iporsut / todos.go
Last active December 24, 2023 06:14
go1.22 net/http package new feature support path params pattern
package main
import (
"encoding/json"
"net/http"
"slices"
"sync"
)
type TODO struct {
@iporsut
iporsut / go-workshop-day-2.md
Created September 28, 2023 02:15
Go workshop day 2

Agenda วันนี้

  • advanced type
    • array
    • slice
    • map
    • struct
  • for loop with array, slice, map
@iporsut
iporsut / go-workshop-day1.md
Created September 13, 2023 08:56
Go workshop day1

Agenda พรุ่งนี้ basic

  • สร้าง Go project ใหม่โดยการสร้าง module ใหม่สำหรับ Go program
  • โครงสร้าง Go โปรแกรมประกอบด้วย
    • package main
    • func main
    • use other packages by import.
  • go run
  • go build
  • var
@iporsut
iporsut / go1.21highlight.md
Created August 11, 2023 08:32
Go 1.21 Highlight

Go 1.21 Highlight

The Profile Guided Optimization (PGO)

เป็นเทคนิค ในการ optimize binary ที่ได้จาก compiler แบบใหม่ที่ทำให้ประสิทธิภาพเพิ่มขึ้น 2-7% โดยใช้ข้อมูลพฤติกรรมการใช้งาน ผ่านการทำ profiling แล้วเอาข้อมูลจาก profiling มาประกอบการ compile ในรอบถัดไป

Go tool Backward language compatibility

จะใช้ GODEBUG กับ settings เพื่อ turn on / turn off ความสามารถของภาษาที่มีการ breaking change หรือมีพฤติกรรมที่เปลี่ยนไป ทำให้ยังสามารถ compile code ด้วยพฤติกรรมเดิมได้ถ้าต้องการ

Go tool Forward language compatibility

Copy semantic

Go is language that use copy value semantic (no reference semantic like C++ or Rust).

Assignment Statement Copy Value from Right to Left

        num := 10 // copy ค่า 10 ลงหน่วยความจำที่ชื่อไว้ว่า num
        num = 20 // copy ค่า 20 ลงหน่วยความจำที่ชื่อไว้ว่า num
@iporsut
iporsut / go-slice.md
Last active June 11, 2023 12:57
Go Back to Basics: Slice

How to declare slice variable

        var nums []int

What's zero value of slice variable

        var nums []int
@iporsut
iporsut / Program.cs
Last active June 7, 2021 10:13
Example Rabit C# Client
using System;
using System.Text;
using RabbitMQ.Client;
using RabbitMQ.Client.Events;
using System.Threading.Channels;
using System.Threading.Tasks;
namespace Receive
{
class Program
@iporsut
iporsut / index.html
Created June 5, 2021 04:37
HTML display from camera
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Camera</title>
</head>
<body>
<video id="camera" autoplay playsinline></video>
<script>
const videoElement = document.getElementById("camera");
@iporsut
iporsut / Main.hs
Created May 10, 2021 15:33
Haskell persistent-mysql example
module Main where
import Database.Persist
import Database.Persist.TH
import Database.Persist.Sql
import Control.Monad.IO.Class
import Control.Monad.Reader
import Database.Persist.MySQL
import Control.Monad.Logger
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ANSIBlackColor</key>
<data>
YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMS
AAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGjCwwTVSRudWxs0w0ODxARElVO
U1JHQlxOU0NvbG9yU3BhY2VWJGNsYXNzTxAnMC4zMDE5NjA3OTYxIDAuMzAxOTYwNzk2
MSAwLjMwMTk2MDc5NjEAEAKAAtIUFRYXWiRjbGFzc25hbWVYJGNsYXNzZXNXTlNDb2xv