Skip to content

Instantly share code, notes, and snippets.

View rameerez's full-sized avatar
creating

rameerez rameerez

creating
View GitHub Profile
@rameerez
rameerez / telegram-mtproxy.md
Last active April 9, 2024 11:33
Telegram Proxy How-To: complete and up-to-date MTProxy tutorial

How to set up a Telegram Proxy (MTProxy)

This tutorial will teach you how to set up a Telegram MTProxy on an Ubuntu 22.04 sever using AWS Lightsail, although you can use any other Linux distribution and cloud provider.

Using a Telegram proxy is a safe, easy and effective way of overcoming Telegram bans. It's useful, for example, to keep using Telegram under tyrannical regimes, or to circumvent judges' decisions to block Telegram.

Telegram proxies are a built-in feature in all Telegram apps (both mobile and desktop). It allows Telegram users to connect to a proxy in just one or two clicks / taps.

Telegram proxies are safe: Telegram sends messages using their own MTProto secure protocol, and the proxy can only see encrypted traffic – there's no way for a proxy to decrypt the traffic and read the messages. The proxy does not even know which Telegram users are using the proxy, all the proxy sees is just a list of IPs.

@rameerez
rameerez / download_controlnet.py
Created February 15, 2024 02:39
Download all CrontrolNet models to Automatic1111
# Meant to be ran inside a `download.ipynb` notebook inside
# the `/workspace/stable-diffusion-webui/extensions/sd-webui-controlnet/models/` folder
# of an Automatic1111 installation
# !pip install requests
import requests
import os
# List of file names to download
@rameerez
rameerez / aws-ubuntu-server-ec2-instance-setup-for-rails-docker-kamal-deployment.sh
Last active January 16, 2024 02:18
Configure an AWS EC2 instance running Ubuntu Server to deploy Rails apps using Kamal (Docker)
#!/bin/bash
/usr/bin/env curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker ${USER}
mkdir -p /letsencrypt &&
touch /letsencrypt/acme.json &&
chmod 600 /letsencrypt/acme.json
@rameerez
rameerez / aws-amazon-linux-al2023-ec2-instance-setup-for-rails-docker-kamal-deployment.sh
Last active January 14, 2024 20:27
Configure an AWS EC2 instance running Amazon Linux 2023 to deploy Rails apps using Kamal (Docker)
#!/bin/bash
# This scrips takes a clean AWS Amazon Linux 2023 AMI and installs and configures
# everything needed to deploy a Rails app to it using Kamal.
# The resulting state is a clean instance ready to accept Kamal (Dockerized) apps.
# --- AESTHETICS ---
# Define the color code for green for echo messages
@rameerez
rameerez / webmaster_handbook.md
Last active January 14, 2024 00:24
Rails Webmaster's Handbook: useful snippets for a Rails + PostgreSQL server admin

Rails Webmaster's Handbook

Snippets and commands I need to use constantly but that I forget every single time when doing server admin work.

This is an opinionated handbook for Ubuntu Server only

Linux

Change machine name

Goal: make the prompt say ubuntu@easily-identifiable-machine-name instead of the deafult EC2 names like ubuntu@ip-172-168-1-41

@rameerez
rameerez / remove-site.sh
Last active December 26, 2023 03:40
Remove site from Apache conf
#!/bin/bash
# Ensure the script is run as root
if [ "$(id -u)" -ne 0 ]; then
echo -e "${RED}ERROR: This script must be run as root.${NC}"
exit 1
fi
# Define aesthetics
RED='\033[0;31m'
@rameerez
rameerez / set-up-new-site.sh
Last active December 26, 2023 03:31
Bash script to set up a new site on a LAMP-based Ubuntu server (Wordpress, PHP, etc.)
#!/bin/bash
# Ensure the script is run as root
if [ "$(id -u)" -ne 0 ]; then
echo -e "\e[31mERROR: This script must be run as root.\e[0m"
exit 1
fi
# Define aesthetics
GREEN='\033[0;32m'
@rameerez
rameerez / setup_lamp.sh
Last active December 26, 2023 03:23
Script to set up a new LAMP instance from a base Ubuntu 22.04 LTS EC2 instance on AWS
#!/bin/bash
# Ensure the script is run as root
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
# Define aesthetics
GREEN='\033[0;32m'
@rameerez
rameerez / lambda_function.py
Last active December 25, 2023 18:39
AWS Lambda function to send Telegram messages when CloudWatch alarms trigger
# You need to give the Lambda the following permissions.
# Head to the Lambda page, and under Configuration > Permissions > Resource-based policy statements add a new policy statement:
# - Select "AWS Service"
# - On "Service", choose "Other"
# - Statement ID: AlarmAction
# - Principal: lambda.alarms.cloudwatch.amazonaws.com
# - Source ARN: arn:aws:cloudwatch:us-east-1:YOUR_ACCOUNT_ID:alarm:*
# - Action: lambda:InvokeFunction
#
# The same result can be achieved with `aws-cli`:
@rameerez
rameerez / lambda_function.py
Last active December 25, 2023 01:02
AWS Lambda function to forward UptimeRobot up / down events to a Telegram group chat
# Needed previous configuration:
#
# - In UptimeRobot, configure a new **Webhook** Alert Contact with this POST payload:
# ```
# {
# "monitorID": "*monitorID*",
# "monitorURL": "*monitorURL*",
# "monitorFriendlyName": "*monitorFriendlyName*",
# "alertType": "*alertType*",
# "alertTypeFriendlyName": "*alertTypeFriendlyName*",