Skip to content

Instantly share code, notes, and snippets.

View Alireza2n's full-sized avatar

Alireza Amouzadeh Alireza2n

View GitHub Profile
@Alireza2n
Alireza2n / docker-compose.yml
Created April 16, 2022 04:37
Simple docker-compose file to run your own private registry
version: '3'
services:
registry:
restart: always
image: registry
environment:
- REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm
- REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd
- REGISTRY_HTTP_SECRET=<Some random string>
ports:
@Alireza2n
Alireza2n / check_pjsip_endpoint.py
Last active July 15, 2021 13:21 — forked from jfinstrom/asterisk.py
Checks for Availablity of a PJSIP endpoint to use with Nagios or similar software, requires python3. Based on portions of jfinstrom/asterisk.py but rewritten using asterisk command.
#!/home/user/check_peers/venv/bin/python
"""
Based on portions of jfinstrom/asterisk.py but rewritten using asterisk command,
checks for Availablity of a PJSIP endpoint to use with Nagios or similar software, requires python3.
Usages: ./check_pjsip_endpoint.py <ext> (e.g. ./check_pjsip_endpoint.py 200)
Output: Endpoint 200 is Available at 200/sip:200@172.16.16.16:5060;transport=ud, is not in use and RTT is 26.426.
"""
import subprocess
@Alireza2n
Alireza2n / README-setup-tunnel-as-systemd-service.md
Created March 11, 2019 10:11 — forked from drmalex07/README-setup-tunnel-as-systemd-service.md
Setup a secure (SSH) tunnel as a systemd service. #systemd #ssh #ssh-tunnel #ssh-forward

README

Create a template service file at /etc/systemd/system/secure-tunnel@.service. The template parameter will correspond to the name of target host:

[Unit]
Description=Setup a secure tunnel to %I
After=network.target
@Alireza2n
Alireza2n / uwsgi.ini
Created February 3, 2019 07:47
UWSGI ini file for use with uwsgi and systemD
[uwsgi]
chdir=/home/alireza/app # Replace with your own project root
module=app.wsgi:application # Replace with your own app name
virtualenv =/home/alireza/app/.venv # Replace with path of your own virtualenv
env=DJANGO_SETTINGS_MODULE=app.settings.prod # Replace with your own settings module
master=true
chmod-socket = 666
socket = /tmp/my_app.sock # Replace with any name you like
processes = %(%k * 2)
enable-threads = true
@Alireza2n
Alireza2n / sample-nginx-config-django.conf
Created August 31, 2018 15:06
sample-nginx-config-django
server {
listen 80;
server_name ABCD.COM; #Replace with own domain
charset utf-8;
server_tokens off;
location /static/ {
alias /home/alireza/my-django-app/static/; # Path to your django static files folder
}
@Alireza2n
Alireza2n / select_option_for_select2.py
Last active October 22, 2021 17:49
a function to interact with select2 element using Selenium and Python (inspired by https://stackoverflow.com/a/17757761/8504344 and tested on firefox)
def select_option_for_select2(driver, id, text=None):
element = driver.find_element(By.XPATH, '//*[@id="{}"]/following-sibling::*[1]'.format(id))
element.click()
if text:
element = driver.find_element(By.CSS_SELECTOR, "input[type=search]")
element.send_keys(text)
try:
element.send_keys(Keys.ENTER)
@Alireza2n
Alireza2n / postgres-db-on-tmpfs.yml
Last active May 22, 2019 15:49
A docker compose file to quickly run a Postgresql instance on localhost, using tmpfs (ram) as main data storage. Optionally loads *.sql files in docker-entrypoint-initdb.d into newly created database. This is meant for fast development and NOT production.
version: "3"
services:
db:
image: postgres:10
restart: "no"
ports:
- 5432:5432
volumes:
- ./docker/db/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d:ro
environment:
@Alireza2n
Alireza2n / sample-app-uwsgi.ini
Created July 3, 2018 04:38
Sample ini config for uwsgi package (ubuntu) to run Django apps
[uwsgi]
chdir=/home/alireza/app # Replace with your own project root
processes=10
module=app.wsgi:application # Replace with your own app name
master=true
vacuum=True
daemonize=/var/log/uwsgi/app/app.log # Replace with your own app name
virtualenv =/home/alireza/app/.venv # Replace with path of your own virtualenv
enable-threads=true
env=DJANGO_SETTINGS_MODULE=app.settings.prod # Replace with your own settings module
@Alireza2n
Alireza2n / admin.py
Created May 16, 2018 04:49 — forked from reorx/admin.py
Django Admin: hide permission for UserAdmin, exclude useless permissions for GroupAdmin
# coding: utf-8
from django.contrib import admin
from django.contrib.auth.models import Group, User
from django.contrib.auth.admin import GroupAdmin, UserAdmin
from django.utils.translation import ugettext_lazy as _
class CustomUserAdmin(UserAdmin):
fieldsets = (
@Alireza2n
Alireza2n / squidanonymousproxy.md
Created May 15, 2018 02:34 — forked from RobinDev/squidanonymousproxy.md
Install a SQUID anonymous proxy
  1. Install SQUID
apt-get install squid
  1. Create an user
htpasswd -md /etc/squid3/users myuserlogin`