Skip to content

Instantly share code, notes, and snippets.

# 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 -
# 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 / sping
Last active January 26, 2023 08:58
#!/bin/bash
# to use run the following
# wget -qO - https://gist.githubusercontent.com/johan149/754f95421610f62f585d863f216e0b23/raw/2578b078826e66c59e0bb68384c67aac67f0016d/sping | bash
declare -a list
list[0]=nj-us-ping.vultr.com
list[1]=il-us-ping.vultr.com
list[2]=ga-us-ping.vultr.com
@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
# This file is copied from: https://github.com/k4yt3x/simple-http-server/blob/master/Dockerfile
# LICENS: BSD 2-Clause "Simplified" License
# please see https://github.com/k4yt3x/simple-http-server/blob/master/LICENSE for more details
FROM rust:1.61-alpine3.15 as builder
# branch name or tag
ARG BRANCH
RUN apk add --no-cache --virtual .build-deps git make musl-dev openssl-dev perl pkgconfig \
&& git clone -b $BRANCH https://github.com/TheWaWaR/simple-http-server.git /simple-http-server \
&& RUSTFLAGS='-C link-arg=-s' cargo build \
@johan149
johan149 / inet
Last active January 25, 2023 07:34
#!/bin/sh
# get internal IP, mac address, and public ip
# To install run the following
# sudo wget -qO /usr/local/bin/inet https://gist.githubusercontent.com/johan149/0598c69f193f34058cf77fa3c3b68551/raw/efcdcc0e0a8862e7de68f244af2cb0a20e33e06a/inet && sudo chmod a+x /usr/local/bin/inet
#to run just type and hit enter 'inet'
echo 'eno1'
eth1=eno1