Skip to content

Instantly share code, notes, and snippets.

Avatar

Cyril Nicodème cnicodeme

View GitHub Profile
View aiosmtpd.py
import ssl
import socket
import asyncio
import logging
import collections
import time
from asyncio import sslproto
from email._header_value_parser import get_addr_spec, get_angle_addr
from email.errors import HeaderParseError
@cnicodeme
cnicodeme / migrate.py
Created Aug 30, 2018
Migration script to do raw SQL requests
View migrate.py
# Add this import:
from sqlalchemy.sql import text
def upgrade():
# ...
conn = op.get_bind()
conn.execute(text('UPDATE ...'))
# ...
@cnicodeme
cnicodeme / pdfshift.php
Last active Mar 22, 2021
PDFShift PHP curl_ request
View pdfshift.php
<?php
/**
* Example of usage:
* ```
* pdfshift('your_api_key', array(
* 'source' => 'http://www.example.com',
* 'use_print' => true
* ));
*/
function pdfshift($apiKey, $params) {
@cnicodeme
cnicodeme / deploy.sh
Last active May 3, 2018
Deploy a new NGinx serrver with git, Auto deploy, Supervisor+uWSGI
View deploy.sh
#!/bin/bash
read -e -p "Project Name: " project_name
mkdir -p "/var/www/$project_name/project.git"
cd "/var/www/$project_name/project.git"
git init --bare
cd "/var/www/$project_name/"
@cnicodeme
cnicodeme / spamd.py
Last active Dec 8, 2017
Postfix SPAM checker with deletion
View spamd.py
# -*- config:utf-8 -*-
import socket, select, re, logging
from io import BytesIO
divider_pattern = re.compile(br'^(.*?)\r?\n(.*?)\r?\n\r?\n', re.DOTALL)
first_line_pattern = re.compile(br'^SPAMD/[^ ]+ 0 EX_OK$')
@cnicodeme
cnicodeme / server.sh
Last active Feb 19, 2021
server-nginx-flask.sh
View server.sh
#!/bin/bash
# First of all, we check if the user is root
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
# Changing the password of the root user
read -e -p "Do you want to change the root password? [Y/n] : " change_password
@cnicodeme
cnicodeme / server.sh
Created Jun 28, 2017
Installation script - automated - for an Nginx server with MySQL on Debian
View server.sh
#!/bin/bash
#
# --------------------------------------------------------------------
# This is a free shell script under GNU GPL version 3.0 or above
# Copyright (C) 2005 ReFlectiv project.
# Feedback/comment/suggestions : http://www.reflectiv.net/
# -------------------------------------------------------------------------
#
# This script automatically set up a new *Debian* server (IMPORTANT : Debian!), by doing these actions :
#
@cnicodeme
cnicodeme / google_dataflow_xlsx.py
Created Dec 9, 2016
My first attempt at processing an Xlsx file on Google DataFlow service.
View google_dataflow_xlsx.py
import logging, argparse
import apache_beam as beam
from apache_beam.io import gcsio
from apache_beam.utils.options import PipelineOptions
from openpyxl import load_workbook
# @See https://cloud.google.com/dataflow/model/custom-io-python#ptransform-wrappers
@cnicodeme
cnicodeme / install.sh
Created Nov 15, 2016
Installation script for Fedora 24
View install.sh
#!/bin/bash
dnf -y remove cheese evolution libreoffice* shotwell empathy
# Installing repositories
dnf -y install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
dnf -y install https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
dnf -y install http://rpms.famillecollet.com/fedora/remi-release-24.rpm
# Installing Google Chrome repository