Skip to content

Instantly share code, notes, and snippets.

View mypapit's full-sized avatar
🤒
Out sick

Mohammad Hafiz bin Ismail (mypapit) mypapit

🤒
Out sick
View GitHub Profile
#!/bin/bash
# semi-automatic script to check nvidia gpu temperature, and then trigger the fan for 15 minutes.
# intended to run within other scripts or in crontab
# Query GPU temperature
export DISPLAY=:0
TEMP=$(nvidia-smi --query-gpu=temperature.gpu --format=csv,noheader,nounits)
echo "$TEMP"
# Check if TEMP is greater than 60
if [ "$TEMP" -gt 60 ]; then
FROM nvcr.io/nvidia/tensorflow:25.02-tf2-py3
# Set non-interactive mode for clean installs
ENV DEBIAN_FRONTEND=noninteractive
# Install system dependencies
RUN apt-get update && apt-get install -y \
python3-pip \
python3-opencv \
graphviz \
#This won't work on RTX50-series
conda create --name workshop python=3.9
conda activate workshop
conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1.0
pip install --upgrade pip
pip install "tensorflow<2.11" tensorflow_hub seaborn pandas matplotlib opencv-python pillow imutils pydot graphviz librosa visualkeras keract tensorflowjs numpy==1.26.4 scikit-learn=1.3.0
# this is for using conda
conda create -n tensorflow python=3.10
conda activate tensorflow
conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1.0
# Anything above 2.10 is not supported on the GPU on Windows Native
#ensure numpy 1.26 is installed (tensorflow 2.10 compat)
python -m pip install tensorflow==2.10 scikit-learn==1.6.1 numpy=1.24.4
#https://github.com/bigbeartechworld/big-bear-casaos/tree/master/Apps/pterodactyl-panel
bash -c "$(wget -qLO - https://raw.githubusercontent.com/bigbeartechworld/big-bear-scripts/master/start-pterodactyl-panel/run.sh)"
#conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia.
import torch
device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
# Assuming that we are on a CUDA machine, this should print a CUDA device:
print(device)
@mypapit
mypapit / nginxlogip.sh
Last active February 8, 2024 01:54
Analyze the log file to find the IP that accessed the webserver server the most
#!/bin/bash
# Check if a log file was specified
if [ "$#" -ne 1 ]; then
echo "Usage: $0 access.log"
exit 1
fi
LOG_FILE="$1"
import random
#this is to generate fake mykad numbers
def generate_mykad_number():
# Generate date of birth (YYMMDD)
year = str(random.randint(50, 99)) # assuming a range for adult ages
month = str(random.randint(1, 12)).zfill(2)
day = str(random.randint(1, 28)).zfill(2) # using 28 to avoid issues with February
dob = year + month + day
@mypapit
mypapit / gist:c30ca56d06ed7002b7fe4848e661edc7
Created December 24, 2023 22:55
request-cerbot-certonly.sh
sudo certbot certonly --webroot -w /path/to/your/web/root -d fakap.net
@mypapit
mypapit / ojs3-proxy-sites-available.conf
Created April 28, 2023 02:15
How to run OJS 3 on Apache HTTPD behind nginx reverse proxy smoothly
# Mohammad Hafiz bin Ismail <[email protected]>
# blog.mypapit.net
# this is for Ubuntu/Debian Apache server config
#/etc/apache2/sites-available/your-ojs.conf
<VirtualHost *:9080>
ServerAdmin [email protected]
ServerName ojs-site.example.com