Skip to content

Instantly share code, notes, and snippets.

View trungnt13's full-sized avatar
:octocat:
Coding, coding, ... and still coding

TrungNT trungnt13

:octocat:
Coding, coding, ... and still coding
View GitHub Profile
@trungnt13
trungnt13 / vscode_convert_keybindings.py
Last active April 26, 2023 08:48
[Code] Convert vscode MacOS keybindings to Linux/Windows keybindings
"""
19/04/2023: MacOS
- cmd+shift+y: select all selected occurence
- cmd+ctrl+o: outline
20/04/2023: Search Editor (MacOS)
- ctrl+f: open
- ctrl+0 or 9: focus Next or prev
- cmd+[ or ]: next or prev input box
- better split vertical and horizontal (> 2 editor tabs)
24/04/2023: diff editor (MacOS)
@trungnt13
trungnt13 / tmux_config.sh
Last active May 3, 2023 19:23
Tmux autocomplete and configuration
#!/bin/bash
########## Check for tmux and bash-completion installed
if [[ "$(uname)" == "Darwin" ]]; then
if ! command -v brew >/dev/null 2>&1; then
echo "Homebrew is not installed. Please install Homebrew and try again."
exit 1
else
# Install tmux if not installed
if ! command -v tmux >/dev/null 2>&1; then
@trungnt13
trungnt13 / mermaid.md
Last active December 19, 2023 21:37
[CheatSheet] mermaid diagram, tree, graph, etc
@trungnt13
trungnt13 / .clang-tidy
Last active April 14, 2023 12:48
[CheatSheet] Clang Tidy
Checks: 'clang-diagnostic-*,clang-analyzer-*,-modernize-*,-clang-diagnostic-#pragma-messages,-readability-identifier-naming,-clang-diagnostic-switch'
WarningsAsErrors: '*'
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle: none
CheckOptions:
- key: cert-dcl16-c.NewSuffixes
value: 'L;LL;LU;LLU'
- key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
value: '1'
@trungnt13
trungnt13 / .clang-format
Last active April 14, 2023 12:48
[CheatSheet] Clang Format
# Refer to the following link for the explanation of each params:
# http://releases.llvm.org/8.0.0/tools/clang/docs/ClangFormatStyleOptions.html
Language: Cpp
# BasedOnStyle: Google
AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true
AlignConsecutiveBitFields: true
AlignConsecutiveDeclarations: false
AlignConsecutiveMacros: true
@trungnt13
trungnt13 / CurlWget.md
Last active April 14, 2023 12:26
[CheatSheet] Curl and Wget
@trungnt13
trungnt13 / postgres-cheatsheet.md
Created October 7, 2022 09:50 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@trungnt13
trungnt13 / midas_loss.py
Created June 12, 2022 20:08 — forked from dvdhfnr/midas_loss.py
Loss function of MiDaS
import torch
import torch.nn as nn
def compute_scale_and_shift(prediction, target, mask):
# system matrix: A = [[a_00, a_01], [a_10, a_11]]
a_00 = torch.sum(mask * prediction * prediction, (1, 2))
a_01 = torch.sum(mask * prediction, (1, 2))
a_11 = torch.sum(mask, (1, 2))