Skip to content

Instantly share code, notes, and snippets.

@mmaridev
mmaridev / blacklist.py
Created October 12, 2018 20:49
Python 3 script to update an ipset blacklist from postfix's log
#!/usr/bin/python3
import os
import ipaddress
import sys
DRY_RUN = "--dry-run" in sys.argv
@mmaridev
mmaridev / python3webcalculator.py
Last active October 25, 2018 16:13
Python 3 web calculator with POST
#!/usr/bin/python3
# This is a script written as homework for computer science
# (c) 2018 Marco Marinello <mmarinello@sezf.it>
# Import modules
from http.server import BaseHTTPRequestHandler,HTTPServer
import views
# Import settings
try:
@mmaridev
mmaridev / base.html
Last active October 27, 2018 07:44
Bootstrap 4 / Django 2.1 starter template
{% load i18n static %}
<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.1/css/all.css" integrity="sha384-5sAR7xN1Nv6T6+dT2mhtzEpVJvfS3NScPQTrOxhwjIuvcA67KV2R5Jz6kr4abQsz" crossorigin="anonymous">
@mmaridev
mmaridev / index.html
Last active December 12, 2018 16:16
Chat client based on twisted/autobahn (without history)
<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.1/css/all.css" integrity="sha384-5sAR7xN1Nv6T6+dT2mhtzEpVJvfS3NScPQTrOxhwjIuvcA67KV2R5Jz6kr4abQsz" crossorigin="anonymous">
<script
@mmaridev
mmaridev / logo_keyring.scad
Created December 12, 2018 19:48
OpenSCAD Project to extrude a png logo on a circular keyring
cylinder(2, d=32);
difference() {
translate([-12,-9,-2]) {
scale(0.17,0.17,1)
surface(file="/tmp/logo.png");
}
translate([-20,-20,-3])
cube([40,40,3]);
translate([-20,-20,4])
@mmaridev
mmaridev / 000-default.conf
Created December 12, 2018 19:57
Apache Rewrite redirection to https excluding let's encrypt folder
<VirtualHost *:80>
ServerName you.example.org
ServerAlias www.you.example.org
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error_you_sezf_it.log
CustomLog ${APACHE_LOG_DIR}/access_you_sezf_it.log combined
RewriteEngine On
RewriteCond %{HTTPS} off
@mmaridev
mmaridev / settings_local.py
Created December 31, 2018 09:47
Local settings for django site with mariadb
ALLOWED_HOSTS = ["you.example.org"]
DEBUG = True
DATABASES = {
"default": {
"ENGINE": "django.db.backends.mysql",
"NAME": "",
"USER": "",
"PASSWORD": "",
@mmaridev
mmaridev / ws2.php
Created January 20, 2019 13:15
WeatherWing human variables converter
<?php
$fileaddr = "http://localhost/meteo/clientraw.txt";
$content = implode('', file ($fileaddr));
$vals = explode(" ", $content);
//Gestione della direzione del vento (da tabella5.php)
function direzioneVento ($gradi)
@mmaridev
mmaridev / django_apache.conf
Created February 24, 2019 19:52
Apache 2 configuration to run django apps
<VirtualHost *:80>
ServerName example.org
ServerAdmin you@example.org
DocumentRoot /var/www/html
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/?(.well-known)/
RewriteRule ^(.*) https://%{HTTP_HOST}%{REQUEST_URI}
@mmaridev
mmaridev / virus.py
Created March 13, 2019 16:30
Block your UNIX friends script
#!/usr/bin/python3
# Copyright (c) 2018 Marco Marinello <mmarinello@sezf.it>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the