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 / claude_3.5_sonnet_artifacts.xml
Created December 28, 2024 20:34 — forked from dedlim/claude_3.5_sonnet_artifacts.xml
Claude 3.5 Sonnet, Full Artifacts System Prompt
<artifacts_info>
The assistant can create and reference artifacts during conversations. Artifacts are for substantial, self-contained content that users might modify or reuse, displayed in a separate UI window for clarity.
# Good artifacts are...
- Substantial content (>15 lines)
- Content that the user is likely to modify, iterate on, or take ownership of
- Self-contained, complex content that can be understood on its own, without context from the conversation
- Content intended for eventual use outside the conversation (e.g., reports, emails, presentations)
- Content likely to be referenced or reused multiple times
@sangdth
sangdth / redis-commands.md
Last active December 14, 2023 12:56
My list of most used Redis commands
@sangdth
sangdth / ErrorBoundary.tsx
Created February 25, 2023 08:59
Implementation of an error boundary in React functional component
import { useState, useEffect } from 'react';
function ErrorBoundary({ fallback, children }) {
const [error, setError] = useState(null);
useEffect(() => {
if (error) {
// log the error or send it to a server
console.error(error);
}
@sangdth
sangdth / fnm2.md
Last active September 28, 2022 21:09
Auto install current global npm packages after fnm install

The fnm still does not support -reinstall-packages-from like nvm, so I wrote this script for me while waiting.

#!/bin/sh

# Remember to alias fnm='fnm2' for convinient

# TODO: How to make the (which fmn) work here instead of hard coded path?
/opt/homebrew/bin/fnm $*
@sangdth
sangdth / ssh-add.md
Created June 20, 2022 02:53
ssh-add

Still don't know why I have to do this once in a while

Error message:

# Access denied.
# fatal: Could not read from remote repository.

# Please make sure you have the correct access rights
# and the repository exists.
@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
@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 / fmain.md
Last active December 5, 2024 18:14
Companies can market their ideas, but I have the right to decide whether to buy or not.

Config

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

Usage

git fmain
@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 / 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