Skip to content

Instantly share code, notes, and snippets.

View thuan1412's full-sized avatar
🇻🇳

thuan1412

🇻🇳
View GitHub Profile
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>
<?php
require 'congty.php';
// Nếu người dùng submit form
if (!empty($_POST['add_student']))
{
// Lay data
$data['macty'] = isset($_POST['txtmact']) ? (string)$_POST['txtmact'] : '';
$data['ten'] = isset($_POST['txthoten']) ? (string)$_POST['txthoten'] : '';
@thuan1412
thuan1412 / walksync.js
Created August 21, 2021 11:17 — forked from kethinov/walksync.js
List all files in a directory in Node.js recursively in a synchronous fashion
// List all files in a directory in Node.js recursively in a synchronous fashion
var walkSync = function(dir, filelist) {
var fs = fs || require('fs'),
files = fs.readdirSync(dir);
filelist = filelist || [];
files.forEach(function(file) {
if (fs.statSync(dir + file).isDirectory()) {
filelist = walkSync(dir + file + '/', filelist);
}
else {