Skip to content

Instantly share code, notes, and snippets.

View tao-yi's full-sized avatar
🎯
Focusing

taoyi tao-yi

🎯
Focusing
View GitHub Profile
@tao-yi
tao-yi / go-interview-questions.md
Created March 21, 2022 11:11 — forked from sadhasivam/go-interview-questions.md
Golang Interview Questions
  • Installation: 1- Explain how Go path works? 2- What are the benefits of Go Module (reference its commands)?

  • Concurrency: 1- Explain Concurrency & when to use it? 2- How would you allow communication between goroutines in Go? 3- How would you manage their access to resources?

  1. why do you use Go (my answer was as simple as "why i shouldn't", and some extra points Grimacing face)
@tao-yi
tao-yi / producer_consumer.go
Created August 11, 2021 03:45
golang concurrency
package main
import (
"fmt"
"math/rand"
"sync"
"time"
)
func main() {
@tao-yi
tao-yi / gist:a58542966b2d4b03c2e8348d031f2dd2
Created June 15, 2021 04:01 — forked from benjamingr/gist:0237932cee84712951a2
Promise unhandled rejection tracking global handler hook

Possibly Unhandled Rejection NodeJS Promise Hook

###Unhandled Rejection Tracking

Several promise libraries such as bluebird and when as well as some native promise implementations offer potentially unhandled rejection tracking. This means that the following:

Promise.reject(new Error("err")); // never attach a `catch`
@tao-yi
tao-yi / v8.md
Created April 21, 2021 09:50 — forked from kevincennis/v8.md
V8 Installation and d8 shell usage

Installing V8 on a Mac

Prerequisites

  • Install Xcode (Avaliable on the Mac App Store)
  • Install Xcode Command Line Tools (Preferences > Downloads)
  • Install depot_tools
    • git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
    • sudo nano ~/.bash_profile
  • Add export PATH=/path/to/depot_tools:"$PATH" (it's important that depot_tools comes first here)
@tao-yi
tao-yi / goroutine_select.go
Created November 28, 2020 06:25
select statement in golang
package main
import (
"fmt"
"time"
)
func main() {
c1 := make(chan string)
c2 := make(chan string)
@tao-yi
tao-yi / MergeSort.ts
Created November 4, 2020 14:04
merge sort implementation
/**
* arr [5,4,3,2,1,7] length: 6 mid: 2
* [5,4,3] [2,1,7]
* [5] [4,3] [2] [1,7]
* [4] [3] [1] [7]
*/
function mergeSort(arr: number[], startIndex: number, endIndex: number): number[] {
if (endIndex <= startIndex) return [arr[startIndex]];
const mid = Math.floor((startIndex + endIndex) / 2);
const express = require('express')
const ilog = require('ilog')
const debug = require('debug')('debug')
const axios = require('axios')
const app = express()
app.get("/", async (req,res,next) => {
try {
const {data} = await axios.get('http://jsonplaceholder.typicode.com/users/1')
debug(res.headersSent)
@tao-yi
tao-yi / Makefile
Created July 26, 2020 11:27
golang project makefile
build:
go build -o bin/main main.go
dev:
CompileDaemon \
-build="make build" \
-include=Makefile \
-exclude-dir=.git \
-directory=. \
-color=true \