Skip to content

Instantly share code, notes, and snippets.

# SRT config.
listen 1935;
max_connections 1000;
daemon off;
srs_log_tank console;
http_api {
enabled on;
listen 1985;
@johan149
johan149 / install_dev_srs.sh
Last active November 8, 2023 23:02
Install SRS dev docker
# run this on the clean CLI
# bash <(curl -sL https://gist.githubusercontent.com/johan149/8eba975312814db14155ba9e56010946/raw/d0b6eeaa14291d4395c059890eff04bff385f678/install_dev_srs.sh)
# install docker
sudo apt update
sudo apt -y install apt-transport-https ca-certificates curl software-properties-common aria2
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
sudo apt update
apt-cache policy docker-ce
# run this on the clean CLI
# bash <(curl -sL https://gist.githubusercontent.com/johan149/8f87901f55d91edc662b869fbe0d9d45/raw/524f9c1422c73617eceeb3ad309ae3c8ae41bd10/install_docker_ubuntu.sh)
#!/bin/sh
set -o errexit
set -o nounset
IFS=$(printf '\n\t')
# bash <(curl -sL https://gist.githubusercontent.com/johan149/dd4b23649f95c48d65ee106e9c463386/raw/fc9f88db1fcfbb1e79e6a6c8197ac254471d2977/install_cuda_12.2.0_ubuntu2204.sh)
# Remove current cuda version
sudo apt-get --purge remove -y "*cuda*" "*cublas*" "*cufft*" "*cufile*" "*curand*" "*cusolver*" "*cusparse*" "*gds-tools*" "*npp*" "*nvjpeg*" "nsight*" "*nvvm*"
sudo apt-get --purge remove -y "*nvidia*" "libxnvctrl*"
sudo apt-get autoremove -y
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-ubuntu2204.pin
sudo mv cuda-ubuntu2204.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/12.2.0/local_installers/cuda-repo-ubuntu2204-12-2-local_12.2.0-535.54.03-1_amd64.deb
@johan149
johan149 / install_docker_debian.sh
Last active July 2, 2023 06:52
install docker & docker compose in debian
# run this on the clean CLI
# bash <(curl -sL https://gist.githubusercontent.com/johan149/ee626c4b524b744c1a307255d6c0bf26/raw/1b3cb0533156744ab4cb46be9768341218e1a873/install_docker_debian.sh)
# install docker
#!/bin/bash
apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common sudo
curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg | sudo apt-key add -
# bash <(curl -sL https://gist.githubusercontent.com/johan149/dfbc121b2eacbf2f7044fa500aa8e518/raw/f9f8fcebddc7744504b3daf4fdf30b44b1649de5/install_cuda_12.1.1_ubuntu2024.sh)
# Remove current cuda version
sudo apt-get --purge remove -y "*cuda*" "*cublas*" "*cufft*" "*cufile*" "*curand*" "*cusolver*" "*cusparse*" "*gds-tools*" "*npp*" "*nvjpeg*" "nsight*" "*nvvm*"
sudo apt-get --purge remove -y "*nvidia*" "libxnvctrl*"
sudo apt-get autoremove -y
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin
sudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/12.1.1/local_installers/cuda-repo-ubuntu2004-12-1-local_12.1.1-530.30.02-1_amd64.deb
# SRT config.
listen 1935;
max_connections 1000;
daemon off;
srs_log_tank console;
http_api {
enabled on;
listen 1985;
#!/bin/bash
check_internet_connection() {
return $(ping -c 1 www.google.com > /dev/null)
}
while [ 1 ]; do
check_internet_connection
# already have internet connection
if [ $? -eq 0 ]; then
echo "$(date +%Y-%m-%d\ %H:%M:%S) "internet connection state online"
@johan149
johan149 / ping.py
Last active January 26, 2023 09:58
import urllib.request, subprocess, json, time, sys, re
pings = 1
batchSize = 100
mode = "ipv4"
target = ""
if len(sys.argv) >= 2:
args = re.findall("((-c|-p|-l)\s?([0-9A-Za-z]+)|-6)",' '.join(sys.argv[1:]))
for arg in args:
@johan149
johan149 / cping
Last active January 26, 2023 09:07
#!/bin/bash
printf "Vultr/Choopa Ping Test:\n\n"
# https://www.vultr.com/resources/faq/#downloadspeedtests
for DC in NJ-US IL-US GA-US FL-US TX-US HON-HI-US SJO-CA-US LAX-CA-US MEX-MX WA-US TOR-CA FRA-DE AMS-NL PAR-FR LON-GB MEL-AU SYD-AU SGP HND-JP SEL-KOR JNB-ZA BLR-IN DEL-IN BOM-IN OSK-JP MAD-ES STO-SE WAW-PL SCL-CL SAO-BR
do
printf "$DC: \t$(ping -i .2 -c 10 -q $DC-ping.vultr.com | awk -F/ '/^round|^rtt/{print $5}') ms\n" | expand -t 20
done