Skip to content

Instantly share code, notes, and snippets.

View shanenoi's full-sized avatar
🚧
building my own culture

Shane Nguyễn shanenoi

🚧
building my own culture
View GitHub Profile
@shanenoi
shanenoi / log.go
Created March 23, 2023 06:53
utils
func LogTmpFile(f func(pipe io.Writer)) {
randomWithSeed := func(seed int64) int {
rand.Seed(seed)
return rand.Intn(100)
}
dir := "/tmp/lll"
err := os.MkdirAll(dir, 0755)
if err != nil {
log.Printf("Error creating directory: %v\n", err)
DROP TABLE IF EXISTS foods CASCADE;
CREATE TABLE foods (
id varchar(40) not null unique default uuid_generate_v4(),
name text,
description text,
img text,
taste_type jsonb not null default '{}',
created_at TIMESTAMP WITHOUT TIME ZONE not null default now(),
updated_at TIMESTAMP WITHOUT TIME ZONE not null default now(),
deleted_at TIMESTAMP WITHOUT TIME ZONE default null
@shanenoi
shanenoi / System Design.md
Created August 15, 2022 02:01 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
package main
import (
"fmt"
)
type NodeTree struct {
Value int
Left *NodeTree
Right *NodeTree
package main
import (
"fmt"
)
type Retryer func() (bool, error)
func Do(retryNumber uint32, fn Retryer) error {
isRepeat := true
package main
import (
"bytes"
"debug/elf"
"fmt"
"io"
"log"
"os"
)
@shanenoi
shanenoi / british-name.js
Created February 5, 2022 06:40
Random British Name
let nm1 = ["Aadam", "Aarav", "Aaron", "Aaryan", "Abel", "Abraham", "Adam", "Adrian", "Aidan", "Aiden", "Alan", "Albert", "Albi", "Albie", "Alby", "Aleksander", "Alex", "Alexander", "Alfie", "Alfred", "Alistair", "Andre", "Andrei", "Andrew", "Angus", "Anthony", "Antonio", "Archer", "Archibald", "Archie", "Arlo", "Aron", "Arthur", "Aryan", "Asher", "Ashley", "Ashton", "Aston", "Austin", "Axel", "Ayaan", "Ayan", "Ayden", "Aydin", "Bailey", "Barnaby", "Barney", "Beau", "Ben", "Benedict", "Benjamin", "Bentley", "Bertie", "Billy", "Blake", "Bobby", "Bradley", "Brandon", "Brayden", "Brian", "Brodie", "Brody", "Brooklyn", "Bruno", "Buddy", "Caelan", "Caleb", "Callum", "Calvin", "Cameron", "Carson", "Carter", "Casey", "Casper", "Cassius", "Cayden", "Charles", "Charlie", "Chase", "Chester", "Christian", "Christopher", "Cian", "Cillian", "Clark", "Clayton", "Coby", "Cody", "Cohen", "Cole", "Connor", "Conor", "Cooper", "Corey", "Cruz", "Damian", "Daniel", "Danny", "Dante", "Darius", "David", "Deacon", "Declan", "Denis",
teacher = ['0211002',
'0211003',
'0211004',
'0211005',
'0211006',
'0211007',
'0211008',
'0211009',
'0211011',
'0211012',
filter_result() {
sed 's/^[^:]*://g;s/^ *//g'
}
model_number=`sudo smartctl -a $1 | grep 'Model Number:' | filter_result`
serial_number=`sudo smartctl -a $1 | grep 'Serial Number:' | filter_result`
firmware_version=`sudo smartctl -a $1 | grep 'Firmware Version:' | filter_result`
namespace_1_size_capacity=`sudo smartctl -a $1 | grep 'Namespace 1 Size/Capacity:' | filter_result`
maximum_data_transfer_size=`sudo smartctl -a $1 | grep 'Maximum Data Transfer Size:' | filter_result`
#!/bin/sh
_ls() { ls -la $1; }
_cat() { cat $@; }
_cd() { cd $1; }
_mkdir() { mkdir $1; }
_pwd() { pwd $1; }
_cp() { cp -r $1 $2; }
_exit() { exit $1; }