This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @Desc : All of my data are seeded using this testing database(https://github.com/datacharmer/test_db) just import it to your local database server | |
*/ | |
const knex = require("knex") | |
const db = knex(require("./knexfile")["development"]) | |
const { bgCyan, bgRed, redBright, bold, underline } = require("colorette") // To add colors for stdout text | |
db.from("departments").select("*").first().then(res => { | |
console.log(bgCyan("Basic select:")) | |
console.log(res) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/!bin/bash | |
# 1) Change the variables to your desired environment | |
# 2) Use the . ./load_env.sh dev to run the script | |
# . load_env.sh dev ==> load dev environment variables | |
# . load_env.sh staging ==> load staging environment variables | |
# . load_env.sh production ==> load production environment variables | |
echo "Loading your database environment variables to your shell session..." | |
if [[ "${1}" == "dev" ]]; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create table table_name ( | |
id integer primary key | |
name varchar(255) | |
); | |
insert into table_name (column1,c2) values ('','') ; | |
drop user '<user_name>'@'localhost'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"encoding/json" | |
) | |
/* terms: | |
- Marshaling = Encoding | |
links: | |
- https://www.sohamkamani.com/golang/json/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
func worker(id int , jobs <- chan int, results chan <- int ){ | |
for j:= range jobs { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func MapKeys[K comparable, V any](m map[K]V) []K { | |
r := make([]K, 0, len(m)) | |
for k := range m { | |
r = append(r, k) | |
} | |
return r |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
func addMsg(ch chan string, msg string){ | |
time.Sleep(10 * time.Second) | |
ch <- msg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
s:= struct { | |
name string | |
age int | |
}{ | |
name:"Hello", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Inserting | |
user system total real | |
Numeric 0.070000 0.010000 0.080000 ( 0.586738) | |
UUID 0.070000 0.020000 0.090000 ( 3.101085) | |
Retrieving by id | |
user system total real | |
Numeric 0.810000 0.980000 1.790000 ( 6.831551) | |
UUID 0.830000 0.990000 1.820000 ( 6.981944) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Inserting | |
user system total real | |
Numeric 0.070000 0.010000 0.080000 ( 0.586738) | |
UUID 0.070000 0.020000 0.090000 ( 3.101085) | |
Retrieving by id | |
user system total real | |
Numeric 0.810000 0.980000 1.790000 ( 6.831551) | |
UUID 0.830000 0.990000 1.820000 ( 6.981944) |
OlderNewer