Skip to content

Instantly share code, notes, and snippets.

View sangdth's full-sized avatar
📖
Docendo discimus

Sang Dang sangdth

📖
Docendo discimus
View GitHub Profile
@sangdth
sangdth / nextjs-google-app-engine.md
Last active October 18, 2021 12:03
Google App Engine problem with read-only file system error

If you are using type-graphql in your project, and trying to deploy to Google App Engine, you probably will encounter the read-only file system error: Error: EROFS: read-only file system, open './src/schema.gql'

This is because Google App Engine has quite different way to handle file system: https://cloud.google.com/appengine/docs/standard/python3/using-temp-files

In my Nestjs app, I'm using @nestjs/graphql module wrapper, in which automatic generate schema.gql file at /src folder by default, and Google App Engine allows only /tmp folder.

@sangdth
sangdth / vim-fold.md
Last active November 5, 2020 08:42
Setup folding for vim

Setting in your .vimrc:


" Fold by syntax because there are indent is not always correct
set foldmethod=syntax

" Beware, there are lot of instructions tell you use `set nofoldenable` to avoid folding at start
" but then when you start using `z c`, it will start the fold method and automatic fold ALL the code.
" Using this with `foldlevel` give the same effect but does not have that problem.
set foldenable
@sangdth
sangdth / v-block.md
Last active November 10, 2020 11:22
Delete/Insert in V-Block

To select a block, use ctr-v.

  • To delete, use x or d.
  • To insert, use shift + i, (normal i doesn't work.)
    • then type the thing you need.
  • press Esc to see the magic.
@sangdth
sangdth / auto-generate-git-branch-from-jira.md
Last active April 6, 2023 16:59
Generate git branch based on Jira tasks

Required:

Setup:

  1. Install Jira CLI, generate the API token and follow the initiation process. Make sure you can see a list of issues by using jira issue list.
  2. Install fzf and setup some default configs if you like.
  3. Put this code below into your .zshrc (I'm not sure about .bashrc, did not test it.
@sangdth
sangdth / prepare-commit-msg.md
Last active July 15, 2021 09:41
Automatically prepend git commit with JIRA code from branch name

In my company we use Jira, and our branch's name follows this convention CODE-123-Something-descriptive-after And I want to have that code automatically whenever I commit with message. So, you can exclude the grep part if you want to get the whole branch name

Copy the script below, name it prepare-commit-msg and put it under git/hooks folder. Make sure you make it executable by chmod 755 your/path/prepare-commit-msg

#!/bin/bash

if [ -z "$BRANCHES_TO_SKIP" ]; then
@sangdth
sangdth / gist:cd633c55c49f38814c5c3210d03cd40a
Created August 26, 2021 13:25
Add surround with visual select in vim-surround
- Select the text.
- Press `S` then things you want, like `]` or `)`
- Profit!
https://github.com/tpope/vim-surround/issues/220
@sangdth
sangdth / general-guidelines.md
Last active January 30, 2022 06:59
For my projects management

Some good practices I'd like to stick with it

  • Recommend using Sourcetree client, but you can choose anything.
  • We use GitHub flow for simplicity. Reason here. In short:
    • Always branch from master.
    • Name the branch accordingly, read below for more information.
    • After passing all tests, ask for reviews.
    • Merge back to master. Enjoy productivity!
  • PR’s name format: CODE-123-Descriptive-task-name-here
@sangdth
sangdth / fmain.md
Last active December 13, 2023 20:15
If you can’t measure it, you can’t improve it. – Peter Drucker

Config

git config --global alias.fmain '!git checkout -b master && git branch -D main'

Usage

git fmain
@sangdth
sangdth / config
Created April 24, 2022 19:11
ssh config
Host sangdth-github
HostName github.com
User sangdth
PreferredAuthentications publickey
IdentityFile /path/to/.ssh/id_ed25519_github
UseKeychain yes
AddKeysToAgent yes
@sangdth
sangdth / prepare-commit-msg
Created May 24, 2022 19:16
Extract Jira code from branch name
#!/bin/bash
# Copy this file into .git/hooks/prepare-commit-msg file
# Usage: Your branch must follow the name convention: `CODE-123-Lorem-ipsum-telnet`
# This hook will try to extract the `CODE-123` and add it into your commit message.
# For example, `git commit -m "fix something"` will create a commit message content:
# `CODE-123 fix something`
COMMIT_MSG_FILE=$1