Skip to content

Instantly share code, notes, and snippets.

View NeoyeElf's full-sized avatar
:octocat:
golang, gogogo

刘文哲 NeoyeElf

:octocat:
golang, gogogo
View GitHub Profile
@NeoyeElf
NeoyeElf / silceElementsMove.go
Last active March 20, 2021 02:33
move slice elements to certain position
func sliceToMap(slice []string) map[string]interface{} {
res := make(map[string]interface{}, len(slice))
for _, v := range slice {
res[v] = nil
}
return res
}
// move elements to the front of the element at index i of the slice
// if i >= len(originSlice), means move the elements to the end of slice
@NeoyeElf
NeoyeElf / benchmark.js
Created May 17, 2019 06:31
worker threads vs fork process
const Benchmark = require('benchmark')
const doThreadsJob = require('./microjob')
const doProcessJob = require('./workform')
var suite = new Benchmark.Suite;
suite
.add('worker threads', {
defer: true,
fn: function (deferred) {
@NeoyeElf
NeoyeElf / migration.js
Last active July 10, 2018 09:45
将atext和doc_histories中大于threshold的content上传至oss
const oss = require('./index')
const mysql = require('mysql')
const fs = require('fs')
const { v4: uuid } = require('uuid')
const EventEmitter = require('events')
const ATEXT_TRACE_FILE = 'atext_trace_id.log'
const DOC_HISTORIES_TRACE_FILE = 'docHistories_trace_id.log'
const rollbackWriterStream = fs.createWriteStream('rollback.sql')
const emitter = new EventEmitter()