I hereby claim:
- I am alextanhongpin on github.
- I am alextanhongpin (https://keybase.io/alextanhongpin) on keybase.
- I have a public key ASBBjA5fR2Pv8scOYwIw0gSPnE43c7o8FW1UlCCCmfClvwo
To claim this, I am signing this object:
| const Promise = require('bluebird') | |
| function doWork (val) { | |
| return new Promise(resolve => { | |
| setTimeout(() => { | |
| resolve(val) | |
| }, 2000) | |
| }) | |
| } |
| const conditions = [ | |
| ['', '', ''], | |
| ['A', '', ''], | |
| ['', 'B', ''], | |
| ['', '', 'C'], | |
| ['A', 'B', ''], | |
| ['', 'B', 'C'], | |
| ['A', '', 'C'], | |
| ['A', 'B', 'C'], | |
| ].forEach(([param1, param2, param3]) => { |
| // Majority vote algorithm | |
| // Objective: Given an array of integer, write an algorithm to find the majority element in it (if exist) | |
| // Majority element: If an element appears more than n / 2 times in array where n is the size of the array | |
| function BoyerMoore () { | |
| let i = 0 | |
| let m | |
| return { | |
| vote (x) { | |
| if (i === 0) { |
| const collection = ['food', 'car', 'paper', 'javascript', 'blockchain'] | |
| function search (keyword) { | |
| return collection.filter((val) => val.toLowerCase().includes(keyword.toLowerCase())) | |
| } | |
| function autocorrectSearch (keyword) { | |
| if (!search(keyword).length) { | |
| const output = collection.filter((val) => { | |
| const keywords = keyword.split('') |
I hereby claim:
To claim this, I am signing this object:
| const faker = require('faker') | |
| const mysql = require('mysql2/promise') | |
| // function createRow () { | |
| // return { | |
| // column: faker.database.column(), | |
| // type: faker.database.type(), | |
| // collation: faker.database.collation(), | |
| // engine: faker.database.engine() |
| import "net/http/httputil" | |
| func main() { | |
| dump := func(r *http.Request) { | |
| output, err := httputil.DumpRequest(r, true) | |
| if err != nil { | |
| fmt.Println("Error dumping request:", err) | |
| return | |
| } | |
| fmt.Println(string(output)) |
| # Elastic Beanstalk Managed | |
| # Elastic Beanstalk managed configuration file | |
| # Some configuration of nginx can be by placing files in /etc/nginx/conf.d | |
| # using Configuration Files. | |
| # http://docs.amazonwebservices.com/elasticbeanstalk/latest/dg/customize-containers.html | |
| # | |
| # Modifications of nginx.conf can be performed using container_commands to modify the staged version | |
| # located in /tmp/deployment/config/etc#nginx#nginx.conf |
| // return precise time in milliseconds, good for benchmarking | |
| const PreciseTime = () => { | |
| const hrTime = process.hrtime() | |
| // time is an array [seconds, nanoseconds] | |
| return hrTime[0] * 1000 + hrTime[1] / 1000000000 | |
| } | |
| module.exports = PreciseTime |
| package main | |
| import ( | |
| "fmt" | |
| ) | |
| func main() { | |
| var a []string= []string{"a", "b"} | |
| var b []string = []string{"c", "d"} | |
| fmt.Println("Hello, playground", append(a, b...)) |