Skip to content

Instantly share code, notes, and snippets.

@duTianze
duTianze / gist:ec16ab6658e293ab2b1db3b02876763a
Last active December 8, 2023 06:58
python enum with label
from enum import IntEnum
from pydantic import BaseModel
class DropdownCode(BaseModel):
display_code: Optional[str] = Field(None, title="表示コード")
display_name: Optional[str] = Field(None, title="表示名")
class LabelEnum(IntEnum):
@duTianze
duTianze / install_ssh_ubuntu.md
Created May 16, 2024 01:10 — forked from tommypratama/install_ssh_ubuntu.md
Install SSH server on Ubuntu

Install SSH server on Ubuntu

  1. Update apt's package list from the repository

    • sudo apt-get update
  2. Install openssh-server package.

    • sudo apt-get install -y openssh-server
  3. ssh service should be started and enabled by default after installation. Check to confirm.

#!/bin/bash
##Note the below commands may need to be run as a sudo depending on the OS you are using.
# Updates the OPERATING SYSTEM
yum update -y
# Install EPEL, required for NGINX, note you would typically do a yum install -y epel-release but in case of
# AWS Linux you will need to do the following
amazon-linux-extras install epel -y
@duTianze
duTianze / nginxproxy.md
Created May 16, 2024 08:59 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@duTianze
duTianze / gist:d56e11b0600c81b7ea38eaa8aab58c5d
Created May 22, 2024 05:34 — forked from freshjones/gist:b0713263033df8cc9f44
bash script to monitor and do something with docker events
#!/bin/sh
docker events --filter 'event=start' --filter 'event=stop' | while read event
do
container_id=`echo $event | sed 's/.*Z\ \(.*\):\ .*/\1/'`
echo $container_id