Skip to content

Instantly share code, notes, and snippets.

@lechuhuuha
lechuhuuha / main.go
Created August 23, 2025 17:24
auto-marshals
package main
import (
"database/sql"
"database/sql/driver"
"encoding/json"
"fmt"
"log"
_ "github.com/lib/pq"
@lechuhuuha
lechuhuuha / Capacity pitfall.go
Created August 23, 2025 15:35
slice pitfall
package main
import "fmt"
func main() {
a := [5]int{1, 2, 3, 4, 5}
s1 := a[0:3] // len=3 cap=5
s2 := a[3:5] // len=2 cap=2
fmt.Println("initial a :", a) // [1 2 3 4 5]
@lechuhuuha
lechuhuuha / main.go
Created August 23, 2025 14:59
value-receive and pointer-receive method
package main
import "fmt"
type Counter struct{ n int }
// ---------------------
// ⬇ value-receiver method
// ---------------------
func (c Counter) Value() int { return c.n }
package main
import (
"fmt"
"time"
)
func main() {
unbuf := make(chan int) // 0-capacity ➜ send blocks until a receiver is ready
buf := make(chan int, 2) // capacity = 2
@lechuhuuha
lechuhuuha / main.go
Created August 23, 2025 09:55
Q: What’s the difference between buffered and unbuffered channels?
package main
import (
"fmt"
"time"
)
func main() {
unbuf := make(chan int) // 0-capacity ➜ send blocks until a receiver is ready
buf := make(chan int, 2) // capacity = 2
@lechuhuuha
lechuhuuha / setup.txt
Last active December 1, 2024 14:33
Setup minio + elasticsearch + apache tika + mongodb
### Elasticsearch
sysctl -w vm.max_map_count=262144
sudo sysctl -p
1. docker network create elastic
2. docker pull docker.elastic.co/elasticsearch/elasticsearch:8.16.0
3. docker run -d --name es01 --net elastic -p 9200:9200 -it -m 2GB docker.elastic.co/elasticsearch/elasticsearch:8.16.0
1. docker logs -f es01
1. Đợi logs ra password và token
4. export ELASTIC_PASSWORD="your_password"
@lechuhuuha
lechuhuuha / text.txt
Created November 12, 2024 01:44
install collab office local
mở command line trên windows
chạy dưới quyền administrator
wsl --install -d Ubuntu-22.04
sau khi cài xong
nhấn nút windows
tìm kiếm Ubuntu rồi mở
<script lang="ts" setup>
import { AliasListResponse, IAlias } from '@/interfaces/IAlias';
import { t } from '@/plugins/i18n';
import { ListAliasRequest } from '@/request/alias/request';
import { AliasStore } from '@/stores/alias-store';
import { ref } from 'vue';
const route = useRoute();
const aliasStore = AliasStore();
const params = ref<{ nodeId: string }>(route.params as { nodeId: string });
package http
import (
"embed"
"errors"
"io/fs"
"net/http"
"path/filepath"
"github.com/gin-contrib/static"
@lechuhuuha
lechuhuuha / testdns2.py
Last active August 29, 2024 01:52
use mutil threading for calling socket request to domains, skip any domains that does not respond after 30 seconds
#!/usr/bin/env python3
"""
Compares output of URLFWD records to URL Redirects
$ python3 check_url_redirects.py <apikey>
Prerequisites:
Python 3 install
pip install requests pydig