Skip to content

Instantly share code, notes, and snippets.

View RecNes's full-sized avatar
🎯
Focusing

Sencer H. RecNes

🎯
Focusing
View GitHub Profile
@RecNes
RecNes / remove_old_hourly_backups.py
Last active June 20, 2018 08:35
Remove old hourly backups
#!/usr/bin/env python
import shutil
import os
from datetime import datetime
print(" ".join(("-"*20, "Removing Hourly Backups Older Than Today", "-"*20)))
path_to_backups = '/var/backups/sqlbackups'
today = datetime.today().date()
@RecNes
RecNes / repeatedly_mount.py
Last active June 20, 2018 08:33
Script for automatic file system check and mount usb disk for raspberry pi raspbian
"""
Please READ carefuly first and use at your OWN RISK!
This script is repeatedly try to mount EXT4 partition to given point.
Any other FS types are igored while writing this script. Works ONLY EXT4!
Before mounting, checks and corrects the file system errors. THIS MAY CAUSE LOSS OF DATA!
Append cronjob such as:
15 * * * * /usr/bin/python /root/repeatedly_mount.py
import os
import time
def get_console_width():
"""
Returns the width of console.
NOTE: The below implementation works only on Linux-based operating systems.
If you wish to use it on another OS, please make sure to modify it appropriately.
"""
@RecNes
RecNes / sort_query_set_objects.py
Last active July 24, 2020 14:33
Sort object list in python
def sort_query_set_objects(query_set, attr=None):
"""
Convert queryset to a list array and sort by field with order ASC/DESC.
Use when you have to apply ordering to queryset but don't want to do it via database.
:param query_set: queryset
:param attr: query object attribute (field) name with order direction. Usage is same as order_by()
:return: list array w/wo sorted
"""
object_list = list(query_set)
@RecNes
RecNes / README.md
Created August 27, 2021 08:18 — forked from hofmannsven/README.md
Git Cheatsheet
@RecNes
RecNes / exe_jailer.bat
Last active October 30, 2025 08:18
Network jailer for EXE files. Save as batch faile and execute under the folder where the executable you want to jail.
@ setlocal enableextensions
@ cd /d "%~dp0"
for /R %%f in (*.exe) do (
netsh advfirewall firewall add rule name="Blocked: %%f" dir=out program="%%f" action=block
netsh advfirewall firewall add rule name="Blocked: %%f" dir=in program="%%f" action=block
)
pause