Skip to content

Instantly share code, notes, and snippets.

View ndkhoa's full-sized avatar

Nguyen Dang Khoa ndkhoa

View GitHub Profile
@ndkhoa
ndkhoa / tien-len-mien-nam-by-bing-gpt.py
Created May 9, 2023 01:16 — forked from huytd/tien-len-mien-nam-by-bing-gpt.py
Card game Thirteen (a.k.a Tiến lên miền nam) made by Bing Chat
# Step 1: Import the random module
import random
# Step 2: Define a class for cards
class Card:
def __init__(self, rank, suit):
self.rank = rank # an integer from 3 to 15 (3 is lowest and 15 is highest)
self.suit = suit.lower() # a string from "spades", "clubs", "diamonds", or "hearts"
def __str__(self):
@ndkhoa
ndkhoa / sample_model.rb
Created June 30, 2022 11:10
Class convention
class ClassName
# Extends / Includes
# Constants
# Attributes
# Associations
# Validates
# Select food_ids
pets = {
dogs: [
{
dog_id: '5d10ffdb-94df-4265-960c-39fa8a86e258',
foods: [
'e2501f63-af85-410e-8f7a-da47ffd5ce0e',
],
},
{
@ndkhoa
ndkhoa / rails http status codes
Created January 7, 2022 09:45 — forked from mlanett/rails http status codes
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing
@ndkhoa
ndkhoa / git.prune.md
Last active August 7, 2025 09:56
Clean up unreachable or orphaned git objects with git prune

Clean up unreachable or orphaned git objects with git prune

Unreachable objects are those that are not accessible by any refs. As an example, say we have made two commits, and reset them to different heads by calling git reset <commit_id> command. Though the git log command will not show the commit info, git still stores it internally as a dangling object.

Find the dangling commit

git fsck --lost-found
@ndkhoa
ndkhoa / tmux-cheatsheet.markdown
Created March 30, 2021 13:57 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@ndkhoa
ndkhoa / docker.disk.image.size.txt
Last active March 15, 2021 03:28
Docker disk image size
# https://docs.docker.com/docker-for-mac/space/
ls -al /Users/okieladev/Library/Containers/com.docker.docker/Data/vms/0/Docker.raw
cl /Users/okieladev/Library/Containers/com.docker.docker/Data/vms/0/Docker.raw
@ndkhoa
ndkhoa / git-acc.txt
Last active December 24, 2020 05:37
Multiple Github Accounts
================================================================================
================================================================================
mkdir ~/git-acc
touch ~/git-acc/khoachilang.sh
touch ~/git-acc/fooderio.sh
========================================
========================================
~/git-acc/khoachilang.sh
#!/bin/bash
@ndkhoa
ndkhoa / handling_multiple_github_accounts.md
Created December 24, 2020 02:53 — forked from Jonalogy/handling_multiple_github_accounts.md
Handling Multiple Github Accounts on MacOS

Handling Multiple Github Accounts on MacOS

The only way I've succeeded so far is to employ SSH.

Assuming you are new to this like me, first I'd like to share with you that your Mac has a SSH config file in a .ssh directory. The config file is where you draw relations of your SSH keys to each GitHub (or Bitbucket) account, and all your SSH keys generated are saved into .ssh directory by default. You can navigate to it by running cd ~/.ssh within your terminal, open the config file with any editor, and it should look something like this:

Host *
 AddKeysToAgent yes

> UseKeyChain yes

@ndkhoa
ndkhoa / Dockerfile
Created December 2, 2020 04:33 — forked from armand1m/Dockerfile
Yarn cache compatible Dockerfile
FROM alpine
RUN apk add --update --no-cache nodejs
RUN npm i -g yarn
ADD package.json yarn.lock /tmp/
ADD .yarn-cache.tgz /
RUN cd /tmp && yarn
RUN mkdir -p /service && cd /service && ln -s /tmp/node_modules