Skip to content

Instantly share code, notes, and snippets.

View radamhu's full-sized avatar
🎯
Focusing

Ádám Roland radamhu

🎯
Focusing
View GitHub Profile
import json
from typing import List
def run(args: List[str]):
filename = args[0]
with open(filename, "r") as f:
data = json.loads(f.read())
original_entries = data['items']
@radamhu
radamhu / wsl2-network.ps1
Last active July 28, 2022 05:18 — forked from daehahn/wsl2-network.ps1
WSL 2 TCP NETWORK FORWARDING
# WSL2 network port forwarding script v1
# for enable script, 'Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser' in Powershell,
# for delete exist rules and ports use 'delete' as parameter, for show ports use 'list' as parameter.
# written by Daehyuk Ahn, Aug-1-2020
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
# Display all portproxy information
If ($Args[0] -eq "list") {
netsh interface portproxy show v4tov4;
@radamhu
radamhu / ansible-find-filenames.yml
Created June 24, 2022 19:24 — forked from Finkregh/ansible-find-filenames.yml
ansible: get files from directory - only names without path
- name: "get files from dir"
find:
paths: "/some/dir/foo"
register: found_files
- name: print file names without path
debug:
msg: "{{ found_files['files'] | map(attribute='path') | map('regex_replace','^.*/(.*)$','\\1') | list }}"
@radamhu
radamhu / dailyBackupMySQL.sh
Last active July 15, 2022 14:16 — forked from AlexPashley/dailyBackup.sh
SHELL: Simple Shell Script to create database backups
# Backup mysql databases into seperate files
USER="mysql-username"
PASSWORD="mysql-password"
OUTPUTDIR="/path/to/db/backup/dir"
MYSQLDUMP="/usr/bin/mysqldump"
MYSQL="/usr/bin/mysql"
NOW=$(date +"%m-%d-%Y")
MSG="Just to let you know that a full backup of db has been made onto the VPS.Kind Regards"
# Remove previous backups
@radamhu
radamhu / synology-blocklist-update
Created April 7, 2021 08:00 — forked from olbat/synology-blocklist-update
Synology DonwloadStation blocklist update script
#!/bin/bash
set -euo pipefail
BLOCKLIST_URL='https://list.iblocklist.com/?list=bt_level1&fileformat=p2p&archiveformat=gz'
BLOCKLIST_FILE=/var/packages/DownloadStation/etc/download/blocklists/level1
echo "Clean old blocklist"
rm -f $(dirname $BLOCKLIST_FILE)/*
echo "Download new blocklist"
@radamhu
radamhu / gist:5fe6f0b8980f530dd29e7045e77bcbed
Last active September 6, 2020 08:44 — forked from okor/gist:4236979
Git Cheat Sheet

lazygit "My commit msg"

function lazygit() {
    git add .
    git commit -a -m "$1"
    git push
}

How do I reduce the pack file size?

@radamhu
radamhu / stars
Created July 17, 2020 09:07 — forked from kensoh/stars
TagUI flow to print the list of your starred repos
// created this flow file to archive my starred repos
// it prints the list of starred repos by github user
// you can get TagUI here (macOS / Windows / Linux)
// https://github.com/kelaberetiv/TagUI#set-up
// usage #1 - copy or download this file, then run
// tagui stars github_userid quiet chrome
// usage #2 - if you want to run this gist directly
@radamhu
radamhu / OneNote-to-MD.md
Created April 3, 2020 07:43 — forked from heardk/OneNote-to-MD.md
Convert notes from OneNote into Markdown

Converting One Note to Markdown

This is an example of how to convert notes from OneNote into Markdown to use in other, less annoying Note applications. I am using PowerShell on Windows here, but other shell/scripting environments would work as well. If you want separate .md files, you'll need to export your OneNote pages separately. Exporting a section, or a selection of pages creates a single .docx file.

  • Download and install Pandoc
  • Export each of your note pages to a .docx (Word) format using OneNote export from the File menu
  • Gather all of these .docx files into a directory
  • Open directory in File Explorer
  • Open Powershell from the File Explorer using File -> Open Windows Powersell
  • Run the following command:
@radamhu
radamhu / fail2ban-allstatus.sh
Created March 12, 2020 19:20 — forked from kamermans/fail2ban-allstatus.sh
Show status of all fail2ban jails at once
#!/bin/bash
JAILS=`fail2ban-client status | grep "Jail list" | sed -E 's/^[^:]+:[ \t]+//' | sed 's/,//g'`
for JAIL in $JAILS
do
fail2ban-client status $JAIL
done
@radamhu
radamhu / odoo_calculate_workers.sh
Last active June 3, 2021 20:12
Analyzes the characteristics of the server and helps calculate the number of workers and memory for each
#!/bin/bash
# CONST 1GB
CONST_1GB="1024*1024*1024"
# VARIABLE WORKERS
CMD_W=0