Skip to content

Instantly share code, notes, and snippets.

View mrhalix's full-sized avatar
💭
Call me on telegram

SM. Amin Aleahmad mrhalix

💭
Call me on telegram
View GitHub Profile
@mrhalix
mrhalix / RIPE ASN Parser.py
Last active November 27, 2022 08:58
Parse txt file from https://ftp.ripe.net/ripe/stats/membership/alloclist.txt , and optionally export it as csv
import requests
import re
alloclist = requests.get("https://ftp.ripe.net/ripe/stats/membership/alloclist.txt")
def splitter(text):
splitted = {}
current_company = []
for i in text.split("\n"):
if i == '': continue
if re.match("([A-z][A-z])\.(.*)", i): # means processing a new block
current_company = splitted[i] = []
@mrhalix
mrhalix / gitlabIssueConverter.py
Last active August 1, 2023 12:58
Replace newlines in gitlab issue exported file's description, mostly needed by UTF-8 people
import re
file = open("issues.csv", "r")
text = file.read()
for i in re.findall(r'\".*?\"', text, flags=re.DOTALL):
text = text.replace(i, i.replace("\n", "'----'")) # replace \n with '----' in issue title and description
newf = open('issues-fixed.csv', 'w')
newf.write(text)
newf.close()
@mrhalix
mrhalix / README.md
Last active January 14, 2023 13:46
manifests and kubeconfig template to read-only access to pods on kubernetes

Steps to Generate kubeconfig file

  1. apply manifests
  2. run kubeconfiggen.sh
  3. use registry-cleaner.kubeconfig: KUBECONFIG=/root/registry-cleaner.kubeconfig kubectl get pods -A
@mrhalix
mrhalix / apache.conf.j2
Created February 8, 2023 09:35
Ansible to add a new Apache vhost
<VirtualHost *:{{ http_port }}>
ServerAdmin webmaster@localhost
ServerName {{ http_host }}
ServerAlias www.{{ http_host }}
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
DocumentRoot "/var/www/{{ http_host }}"
</VirtualHost>
@mrhalix
mrhalix / job.yaml
Created February 14, 2023 09:39
A kubernetes cronjob which concurrently runs two commands when it starts, jobs: docker daemon + python script which uses docker pull,tag,push
apiVersion: batch/v1
kind: CronJob
metadata:
name: JOBNAME
namespace: NAMESPACE
spec:
schedule: "0 3 */10 * *"
jobTemplate:
spec:
template:
@mrhalix
mrhalix / base.js
Last active April 20, 2023 17:13
Add menu item in bigbluebutton meeting sidebar / check https://github.com/manishkatyan/bbb-jamboard for more info
var menu = document.querySelector('div[data-test="chatButton"]').parentElement;
var sectionDiv = document.createElement("div");
var iconDiv1 = document.createElement("div");
var iconDiv2 = document.createElement("div");
var iconDiv3 = document.createElement("div");
var iconDiv3 = document.createElement("div");
var iconIcon = document.createElement("i");
var textDiv = document.createElement("div");
var textSpan = document.createElement("span");
var meetingId = document.querySelector('svg[data-test="whiteboard"]').innerHTML.match("\/bigbluebutton\/presentation\/(.*)\/.*\/.*\/svg/")[1];
@mrhalix
mrhalix / bbb-to-scalelite.md
Last active May 25, 2023 17:44
Configure bigbluebuttons to send recordings to scalelite

Run this in bbb-server

SCALELITE_FQDN=scalelite.example.com

wget https://github.com/blindsidenetworks/scalelite/raw/master/bigbluebutton/scalelite_post_publish.rb -P /usr/local/bigbluebutton/core/scripts/post_publish

wget https://github.com/blindsidenetworks/scalelite/raw/master/bigbluebutton/scalelite.yml -P /usr/local/bigbluebutton/core/scripts
sed -i -E "s/^(spool_dir:).+/\1 bigbluebutton@$SCALELITE_FQDN:\/mnt\/scalelite-recordings\/var\/bigbluebutton\/spool/" /usr/local/bigbluebutton/core/scripts/scalelite.yml

mkdir -p /home/bigbluebutton/.ssh
@mrhalix
mrhalix / hetzner.py
Last active May 9, 2023 13:01
Hetzner Price Export
# This script exports price / cost csv out of hetzner api server list
# Just watch requests with network tools and pass the bearer token into request headers:
import json
import requests
def get_servers(page=1):
headers = {
'authority': 'api.hetzner.cloud',
'accept': 'application/json, text/plain, */*',
'accept-language': 'en-US,en;q=0.9,fa;q=0.8',
@mrhalix
mrhalix / icewarp-sortdisabledbyusage.py
Created June 20, 2023 12:27
IceWarp - Sort disabled users by their usage
#-----------------
# I know this is a mess, but it works
#-----------------
import xml.etree.ElementTree as ET
def convert_quota(kb):
if kb > 1024 * 1024:
return str(round(kb / (1024 * 1024), 2)) + " GB"
elif kb > 1024:
return str(round(kb / 1024, 2)) + " MB"
@mrhalix
mrhalix / snappfoodDelivery.py
Created July 8, 2023 12:04
Periodically check if you're in snappfood restaurant delivery area and receive notification on telegram whenever you are, crontab needed
import requests
import json
import time
headers = {
'authority': 'snappfood.ir',
'referer': 'https://snappfood.ir/search?query=%D9%86%D8%A7%D9%86%20%D8%B3%D8%AD%D8%B1&page=0',
'sec-ch-ua': '"Not.A/Brand";v="8", "Chromium";v="114", "Google Chrome";v="114"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',