Skip to content

Instantly share code, notes, and snippets.

@nguyenhoaibao
nguyenhoaibao / workerpool.go
Created May 29, 2019 06:51 — forked from linxGnu/workerpool.go
We will publish this code soon. This code is a worker pool power many products at LINE Corp. Please respect to the copyright.
// Copyright 2019 LINE Corporation
//
// LINE Corporation licenses this file to you under the Apache License,
// version 2.0 (the "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at:
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
@nguyenhoaibao
nguyenhoaibao / vim.md
Last active September 28, 2020 04:38
Convert currencies object to Go switch case

Currencies from this: https://gist.github.com/Fluidbyte/2973986

Vim regex:

  • %s/"\([A-Z]\+\)":\s{\n\s*"symbol":\s\(.\+\),/case \2:\r\treturn \1/g
  • g/name\|symbol\|decimal\|rounding\|code\|}/d

  • Regex:
  1. vim: %s/.*=\s\([0-9]\+\);/\1,/g
  2. sed: sed -i 's/.\+\s=\s\([0-9]\+\);/\1,/g'
@nguyenhoaibao
nguyenhoaibao / how.md
Last active March 19, 2018 04:13
Using multiple keys with multiple repos
  • Gen 2 or multiple keys
ssh-keygen -t rsa -C key01@example
ssh-keygen -t rsa -C key02@example
  • Setup ssh config
db.filerows.aggregate({
"$match": {
'profile.id': {
$in: [
"100003103024205",
"100009684765639",
"100000265992314",
"1362923905",
"1604622591",
"100000007665456"
{
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
{
"range": {
"meta.created_time": {
"gte": "2016-01-01T00:00:00.000Z",
"_index": "newtopic5531d086fb5daa240956d1b5",
"_type": "fbPageComment",
"_id": "1724985931066279_1725214984376707",
"_score": 1,
"_source": {
"parentId": "1378455622385980_1724985931066279",
"parentDate": "2015-12-03T13:50:59.000Z",
"title": "Các bạn đã sẵn sàng để nhận 100.000đ mã nạp tiền điện thoại OnOnPay từ GrabTaxi chưa nhỉ?\n\nHãy sạc đủ pin để điện thoại mình có thể hoạt động trong những ngày sắp tới đi nha! Bởi vì các Grabbers nào đã đủ tiêu chuẩn nhận quà khi hoàn thành đủ 7 chuyến đi thành công GrabTaxi trong khoảng thời gian 17/11 - 30/11, chỉ trong tuần này thôi sẽ nhận được tin nhắn kèm mã nạp tài khoản điện thoại OnOnPay với trị giá 100.000đ. Do danh sách nhận quà lần này hơi \"khủng\", nên GrabTaxi phải chuẩn bị thật chu đáo. Dù gì đi nữa thì cũng sắp sửa nhận được tin nhắn rồi đó, nên đừng có mà tắt điện thoại để rồi lỡ có trục trặc gì thì tin nhắn mang niềm vui đến từ GrabTaxi cũng đến trễ theo luôn à nha... \nGrabbers khi nào nhận được quà thì quay lại đây thông báo để GrabTaxi
@nguyenhoaibao
nguyenhoaibao / Query 1
Last active August 10, 2016 17:45
Elasticsearch Query Example
{
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
{
"or": [
{
"nested": {
@nguyenhoaibao
nguyenhoaibao / Elasticsearch
Last active August 29, 2015 14:07
[elasticsearch] search co dau
/**
* settings
*
*/
curl -XPOST localhost:9200/lazada/ -d '{
"settings": {
"number_of_shards": 1,
"analysis": {
"tokenizer" : {
"my_edge_ngram_tokenizer" : {