Skip to content

Instantly share code, notes, and snippets.

View thuan1412's full-sized avatar
🇻🇳

thuan1412

🇻🇳
View GitHub Profile
#!/usr/bin/env bash
log="/tmp/kitty-nvim-selection.log"
log() {
printf '[%s] %s\n' "$(date '+%y-%m-%d %h:%m:%s')" "$*" >>"$log"
}
# log "=== script started ==="
# log "tty: $(tty 2>&1)"
@thuan1412
thuan1412 / gist:e5286947adbae13119c6487b9a35bf9b
Last active August 19, 2026 13:09
nvim-with-remote-server
_NVR_REAL_NVIM="$(command -v nvim)"
nvim() {
local code_dir="$HOME/code"
# Outside ~/code → use the real nvim.
if [[ "$PWD" != "$code_dir"/* ]]; then
command nvim "$@"
return $?
fi
# First directory under ~/code is the project.
class UnionJoin:
def __init__(self,n):
# parent node point to itself
self.parent = [i for i in range(n)]
self.size = [0 for _ in range(n)]
self.count = n
def union(self,p, q):
# parent of p is parent of parent of q
parent_p = self.find_parent(p)
<!DOCTYPE html>
<html>
<head>
<title>Iframe Example</title>
</head>
<body>
<iframe
id="inner-iframe"
style="position: absolute; left: 500px; top: 200px; pointer-events: none"
>
package main
import (
"context"
"fmt"
"time"
)
func handle(ctx context.Context, name string) {
for {
package main
import (
"context"
"fmt"
"time"
"github.com/redis/go-redis/v9"
)
@thuan1412
thuan1412 / fan-in.go
Last active February 12, 2023 15:08
Go Concurrency Pattern
package main
import "sync"
func main() {
}
func fanIn(
done <-chan interface{},
channels ...<-chan interface{},
@thuan1412
thuan1412 / raw.go
Last active June 25, 2022 15:13
Dependency Injection in Go
package main
import "fmt"
type IRepo interface {
Get() string
}
type Repo struct {
Name string
<?php
global $conn;
// Hàm kết nối database
function connect_db()
{
// Gọi tới biến toàn cục $conn
global $conn;
// Nếu chưa kết nối thì thực hiện kết nối
<!-- <?php
require 'students.php';
$students = get_all_students();
disconnect_db();
?> -->
<!DOCTYPE html>
<html>
<head>
<title>Danh sách cong ty</title>