~

Throw away pastebin

Just a place to throw away some text.

.gitignore

# macOS
.DS_Store

# Window
*.exe

# IntelliJ
.idea

# VSCode
.vscode

# Go
coverage.out
vendor

# GoReleaser
dist

GitHub Actions

dependabot.yml:

version: 2
updates:
  - package-ecosystem: "gomod"
    directory: "/"
    schedule:
      interval: "daily"
  - package-ecosystem: "github-actions"
    directory: "/"
    schedule:
      interval: "daily"

go.yml:

name: Go

on:
  push:
    branches:
      - main
    paths:
      - "**.go"
      - "go.mod"
      - "go.sum"
  pull_request:
    branches:
      - main
    paths:
      - "**.go"
      - "go.mod"
      - "go.sum"

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  test:
    name: Test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-go@v4
        with:
          go-version: "stable"
      - run: go test -race -failfast ./...
  build:
    name: Build
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-go@v4
        with:
          go-version: "stable"
      - run: go build .
  golangci-lint:
    name: golangci-lint
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - uses: actions/setup-go@v4
        with:
          go-version: "stable"
      - uses: golangci/golangci-lint-action@v3
        with:
          version: latest

Go

.golangci.yml:

run:
  timeout: 5m
  tests: false
  skip-dirs:
    - ".*test.*"
    - ".*mock.*"
    - ".*example.*"
    - ".*utils.*"
  skip-files:
    - ".*Mock.*"
    - ".*_mock.*"

output:
  sort-results: true

linters:
  disable-all: true
  enable:
    # Default
    - errcheck
    - gosimple
    - govet
    - ineffassign
    - staticcheck
    - typecheck
    - unused
    # Custom
    - errchkjson
    - errname
    - errorlint
    - execinquery
    - forcetypeassert
    - gocritic
    - goerr113
    - gofumpt
    - gosec
    - importas
    - makezero
    - nilnil
    - noctx
    - prealloc
    - reassign
    # - rowserrcheck
    - sqlclosecheck
    - unconvert
    # - wastedassign
  fast: true

linters-settings:
  # Default
  govet:
    check-shadowing: false
    disable-all: true
    enable:
      - assign
      - atomic
      - bools
      - buildtag
      - composites
      - copylocks
      - fieldalignment
      - httpresponse
      - loopclosure
      - lostcancel
      - nilfunc
      - printf
      - unmarshal
      - unreachable
      - unusedresult
  staticcheck:
    checks: ["all", "-SA1019"]
  # Custom
  gocritic:
    disabled-checks:
      - ifElseChain
      - singleCaseSwitch
      - unnamedResult
      - whyNoLint
    enabled-tags:
      - diagnostic
      - style
  gosec:
    excludes:
      - G101
      - G112
      - G402
      - G404
      - G501
      - G505
    exclude-generated: true
  reassign:
    patterns:
      - ".*"

.goreleaser.yml:

before:
  hooks:
    - go mod tidy
builds:
  - main: .
    goos:
      - linux
      - windows
      - darwin
    goarch:
      - amd64
      - arm64
universal_binaries:
  - replace: true
archives:
  - format_overrides:
      - goos: windows
        format: zip
changelog:
  skip: false
  use: github

Git clean up

# Delete untracked
git clean -fdx

git gc

Delete .DS_Store

With find:

find . -name ".DS_Store" -print -type f -delete

With fd:

fd -H '^\.DS_Store$' -tf -X rm

fdupes

Remove duplicated files:

fdupes -rdN .

rsync

# Result is dst/src
rsync -avzP src dst

# Result is dst/* with * is from src
rsync -avzP src/ dst

Commonly flags:

Be careful flags (need dry run if not sure):

F2

Rename:

# If want dry run, remove -x
f2 -r "{mtime.YYYY}{mtime.MM}{mtime.DD}.{mtime.H}{mtime.mm}{mtime.ss}{ext}" -x

Instaloader

args.txt:

--no-video-thumbnails
--no-captions
--no-metadata-json
--stories
--fast-update
--sanitize-paths
--abort-on=302,400,429
--no-iphone

login.txt:

--login=your_insta_username
--sessionfile=where/sessionfile/store

Run:

instaloader +login.txt +args.txt +targets.txt

gRPCurl

grpcurl -proto path/file.proto \
    -d '{"key": "value", "timestamp": "1997-04-01T00:00:00Z"}' \
    internal-social.zalopay.vn:443 \
    pkg.Service/GetData
Feel free to ask me via email or Mastodon.
Source code is available on GitHub Codeberg sourcehut Treehouse GitLab