Skip to content

Instantly share code, notes, and snippets.

@crossgate10
crossgate10 / main.go
Last active December 4, 2023 09:39
use goroutine to check all TTLs of redis keys
package main
import (
"context"
"sync"
"time"
"github.com/redis/go-redis/v9"
"github.com/rs/zerolog/log"
_ "net/http/pprof"
@crossgate10
crossgate10 / git-bash-fish.md
Last active June 5, 2024 02:13 — forked from rafaelpadovezi/git-bash-fish.md
Using fish shell with git bash on windows

Using fish shell with git bash on windows

To install fish shell on windows the options are:

  • Cygwin
  • WSL
  • MSYS2

Since git bash is based on MSYS2 it seems a good fit to install fish. The problem is that git bash is a lightweight version of MSYS2 which does not include pacman as a package management, used to install fish.

This OS thread has great suggestions on how to solve this problem including using the full MSYS2. But the best solution for me was this answer by Michael Chen which installs pacman on git bash.

@crossgate10
crossgate10 / Commit Formatting.md
Created January 7, 2023 02:45 — forked from brianclements/Commit Formatting.md
Angular Commit Format Reference Sheet

Commit Message Format

This specification is inspired by and supersedes the [AngularJS commit message format][commit-message-format].

We have very precise rules over how our Git commit messages must be formatted. This format leads to easier to read commit history.

Each commit message consists of a header, a body, and a footer.

@crossgate10
crossgate10 / Makefile
Last active May 3, 2023 03:19
Setup a new Mac
.PHONY: setup
setup:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
#### 重灌常用
brew install docker docker-compose neovim yj yq git git-gui go fzf bat ripgrep autojump the_silver_searcher clang-format cmake fish htop node wget jq python
#### 重灌常用-cask
brew install --cask lens microsoft-edge iterm2 postman bloomrpc tor-browser sublime-text visual-studio-code telegram another-redis-desktop-manager appcleaner drawio jetbrains-toolbox notion spectacle
#### neovim config Ref. https://github.com/rafi/vim-config
make setup-nvim-prerequisites
// js 最高就到 56 位,加上雙引號改成字串
var resp = responseBody.replace(/([0-9]{8,100})/g, '\"$1\"');
var jsonData = JSON.parse(resp);
postman.setEnvironmentVariable("accountID", jsonData.data.accountID);
@crossgate10
crossgate10 / mongo_bulkwrite_in_datagrip
Created August 30, 2021 05:51
mongo_bulkwrite_in_datagrip
var bulkOps = [];
var allDocs = db.ranking.find().toArray();
allDocs.forEach(doc => {
var bettingOddsVal = parseFloat(doc.betting_odds).toFixed(2);
bulkOps.push({
updateOne: {
filter: { _id: doc._id },
update: { $set: { betting_odds_val: bettingOddsVal } }
}
});
@crossgate10
crossgate10 / main.go
Created August 26, 2021 10:01 — forked from montanaflynn/main.go
Example of using Golang errgroup with context.WithTimeout()
package main
import (
"context"
"fmt"
"io"
"log"
"net/http"
"os"
"time"
vscode - File Watcher setting for proto format
{
    "filewatcher.commands": [
        {
            "match": "\\.proto*",
            "isAsync": true,
            "cmd": "clang-format -style=\"{BasedOnStyle: Google, IndentWidth: 4, ColumnLimit: 0, AlignConsecutiveAssignments: true, AlignConsecutiveAssignments: true}\" -i ${file}",
            "event": "onFileChange"
        }        
@crossgate10
crossgate10 / Dockerfile
Last active May 30, 2021 06:19
for gnuplot run in Win10 with Docker for Windows instead of WSL. Refer here --->> https://github.com/remuslazar/docker-gnuplot)
FROM alpine:latest
RUN apk --no-cache --virtual .fontsinstaller add msttcorefonts-installer fontconfig \
&& update-ms-fonts \
&& fc-cache -f \
&& apk del .fontsinstaller
Run rm /var/cache/apk/*; exit 0
ENV GDFONTPATH=/usr/share/fonts/truetype/msttcorefonts/
# Install gnuplot from source, to make sure we do have GD support etc.