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 / rotater.py
Created September 8, 2016 11:34
Make backup and rotate files.
#!/bin/env ptyhon
# -*- coding: utf-8 -*-
# ======================================================================================================================
# Rotater
# This script make backup in tar.gz format and remove files in target folder older
# than today and builds a report file in where this script file path is.
# Set this script as daily cronjob at midnight.
# Author: Sencer HAMARAT
# E-Mail: sencerhamarat@gmail.com
# ======================================================================================================================
@RecNes
RecNes / getBlockLists.sh
Created September 14, 2016 10:53 — forked from johntyree/getBlockLists.sh
Make one large blocklist from the bluetack lists on iblocklist.com
#!/usr/bin/env sh
# Download lists, unpack and filter, write to stdout
curl -s https://www.iblocklist.com/lists.php \
| sed -n "s/.*value='\(http:.*=bt_.*\)'.*/\1/p" \
| xargs wget -O - \
| gunzip \
| egrep -v '^#'
@RecNes
RecNes / netextender
Created September 19, 2016 13:50
upstart init.d script for running Dell SonicWALL NetExtender as a service. Script should be in /etc/init.d/netextender Configuration goes in /etc/default/netextender Than run: sudo update-rc.d netextender defaults
#!/bin/sh
# defaults for NetExtender Dell VPN Client
# sourced by /etc/init.d/netextender
# should be placed in /etc/default/netextender
# Enable or disable the daemon
ENABLE_DAEMON=1
# Path to daemon
DAEMON=/usr/sbin/netExtender
@RecNes
RecNes / pause_sketch_for_console.ino
Created December 4, 2016 11:29
How to make wait/pause the sketch for Arduino IDE serial console to open.
void setup() {
Serial.begin(9600);
// Wait for the users to turn on the serial monitor and press the enter key to continue.
while (!Serial.available()) {
; // Wait for enter key;
}
// put your setup code here, to run once:
}
@RecNes
RecNes / locofomufowisalofo
Created October 26, 2017 11:49
Logrotate configuration for multiple folders with same log folder. It applies to log files which are created by unstoppable services.
/var/www/*/*/logs/*.log
{
olddir old_logs
daily
rotate 365
dateext
nocreate
copytruncate
missingok
delaycompress
@RecNes
RecNes / disk_usage_mail_alert.py
Last active June 20, 2018 08:32
Disk space usage email alert
#!/usr/bin/env python
"""
Developen on: Python 2.7.13
"""
__author__ = 'Sencer Hamarat'
__license__ = "Creative Commons Attribution-ShareAlike 3.0 Unported License"
__version__ = "1.3"
__maintainer__ = "Sencer Hamarat"
__status__ = "Production"
@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
@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 / cli_percentage.py
Last active June 20, 2018 08:37
Display percentage of process to on one line of stdout in python
object_list_length = len(ObjectList)
for i, object in enumerate(ObjectList):
percentage = int(((i + 1) * 100 / object_list_length))
percent_str = ""
for k in range(0, int(percentage / 5)):
percent_str += ":"
sys.stdout.write("\r%s -- %s | %s %% %s " % (str(i + 1),
str(object_list_length),
str(percentage),
@RecNes
RecNes / ram_usage.sh
Last active June 20, 2018 08:40
This script will displays or sends email for RAM usage statistics of python scripts
#!/usr/bin/env sh
#title : ram_usage.sh
#description : Shell script for displaying RAM and Thread statistics of python scripts.
#author : Sencer HAMARAT "sencerhamarat(at)gmail.com"
#date : 20161014
#version : 0.4
#usage : sh ram_usage.sh
#==============================================================================
#!/usr/bin/env bash
SERVERNAME=$(hostname -f)