Skip to content

Instantly share code, notes, and snippets.

View mrsarm's full-sized avatar
🏠
Working from home

Mariano Ruiz mrsarm

🏠
Working from home
View GitHub Profile
@mrsarm
mrsarm / hist.py
Last active October 12, 2018 01:30
File Bytes Histogram Display: Python 3 script to get histogram from passed file. The result is displayed graphically.
#!/usr/bin/env python3
import matplotlib.pyplot as plt
import numpy as np
from sys import argv
content = bytearray(open(argv[1], 'rb').read())
freq, bins, patches = plt.hist(content, 256)
plt.xlabel("Symbol"); plt.ylabel("Frequency")
plt.grid(True)
@mrsarm
mrsarm / uncomment
Last active September 29, 2017 11:59
uncomment: print a file without comments and blank lines. This is an alias to add in your ~/.bashrc
alias uncomment='egrep -v "^\s*(#|;)|^$"'
@mrsarm
mrsarm / backup-duplicity.sh
Last active August 29, 2015 14:06
Backup Duplicity Script: perform files backup with `duplicity` tool, in local mode or through the network
#!/bin/bash
#
# Backup file script.
#
# The backup is performed with `duplicity`,
# in local mode or through the network with
# SCP, SFTP.., so all the tools must be
# installed in both hosts (source and destination).
#
# The initial archive contains all
@mrsarm
mrsarm / backup-duplicity-remove.sh
Last active August 29, 2015 14:10
Script to remove old backup files made with duplicity
#!/bin/bash
#
# Script to remove old backup files made with duplicity.
#
# See the `duplicity` home page for more information:
# http://duplicity.nongnu.org
#
# Author: (2014) Mariano Ruiz <[email protected]>
#
@mrsarm
mrsarm / crontab-backup-duplicity
Created December 3, 2014 17:33
Crontab configuration to run duplicity backup scripts periodically
#
# Run backup process with duplicity tool.
#
# Check log file in /var/log/backup-duplicity.log
#
# Run incremental backup every 3 hours
0 */3 * * * root /backup/bin/backup-duplicity
# Remove all backups older than 15 days at 00:52 AM, every Saturday (every 7 days)
@mrsarm
mrsarm / backup-pgbarman-cron.sh
Last active August 29, 2015 14:11
Script to execute the 'cron' task with Barman Postgres backup system
#!/bin/bash
#
# Script to execute the 'cron' task with Barman Postgres backup
# system.
#
# Do NOT confuse this with a **crontab** task: this script
# only do the archive of the continuous WAL files sent
# by PostgreSQL, but it's a good practise execute this
# script periodically with the Unix Cron system.
#
@mrsarm
mrsarm / backup-pgbarman.sh
Created December 15, 2014 19:00
Script to backup PostgreSQL with Barman
#!/bin/bash
#
# Script to backup PostgreSQL with Barman.
#
# After the backup is performed, this script
# also delete the oldest backup found.
#
# See the `PG Barman` home page for more information:
# http://www.pgbarman.org
#
@mrsarm
mrsarm / crontab-pgbarman
Created December 15, 2014 21:29
Crontab configuration to run PG Barman backup scripts periodically
#
# Run backup process with PG Barman tool.
#
# Check log file in /var/log/backup-pgbarman.log
#
# Run WAL archiving backup every hours
10 */1 * * * barman /var/lib/barman/bin/backup-pgbarman-cron
# Run full backup, every days
@mrsarm
mrsarm / ini.nanorc
Last active August 29, 2015 14:18
/usr/share/nano/ini.nanorc: rc file for .ini, .conf, .cnf and .properties files
## nanorc file for .ini and .conf files.
##
syntax "ini" "(\.(ini|conf|cnf|properties)|rc)$"
## Symbols
color green "(\{|\}|\(|\)|\;|\]|\[|`|\\|\$|<|>|!|=|&|\|)"
## Strings
color brightyellow ""(\\.|[^"])*"" "'(\\.|[^'])*'"
## Comments
icolor brightblue "^[[:space:]]*#.*$"
icolor cyan "^[[:space:]]*##.*$"
@mrsarm
mrsarm / mysite.com.conf
Created April 8, 2015 02:03
/etc/nginx/sites-available/mysite.com.conf: Reverse Proxy configuration site for Nginx
server {
listen 80;
server_name mysite.com www.mysite.com;
access_log /var/log/nginx/mysite.com.access.log;
error_log /var/log/nginx/mysite.com.error.log;
location / {
proxy_pass http://127.0.0.1:8080;
}
include /etc/nginx/proxy.conf;