Skip to content

Instantly share code, notes, and snippets.

View cnicodeme's full-sized avatar

Cyril Nicodème cnicodeme

View GitHub Profile
@cnicodeme
cnicodeme / api.md
Last active July 11, 2022 09:17
ImprovMX documentation

ImprovMX API

This is the documentation of our API endpoint at ImprovMX.com. This lets you list, create, edit and remove domain and email aliases that you can forward to programatically.

For more information, visit ImprovMX.com

URL

The base url's ImprovMX api can be accessed at

@cnicodeme
cnicodeme / autodeploy.py
Created May 31, 2022 13:24
Autodeploy script for Github webhook, using Sanic server.
#!/bin/python
"""
This scripts creates a new server listing at APP_PORT (default at 9001).
Can be put behind a Caddy server or directly facing the Internet by changing the APP_HOST value too
It receives a WEBHOOK request from Github, and based on the data, updates the local code if the push was made on the "prod" branch.
Then update the requirements.txt and update the database.
"""
@cnicodeme
cnicodeme / server.sh
Last active April 11, 2022 14:38
server-nginx-flask.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 / pdfshift.php
Last active December 6, 2021 13:30
PDFShift PHP curl_ request
<?php
/**
* Example of usage:
* ```
* pdfshift('your_api_key', array(
* 'source' => 'http://www.example.com',
* 'use_print' => true
* ));
*/
function pdfshift($apiKey, $params) {
@cnicodeme
cnicodeme / langs.py
Last active March 4, 2021 10:12
Dictionnary of languages code (ISO-639-1) to their corresponding lang (Source: Wikpedia)
# Warning: This file looses the direction of the value (LTR/RTL)
#
{
"aa": "Afaraf",
"ab": "\u0410\u04a7\u0441\u0443\u0430",
"ae": "Avesta",
"af": "Afrikaans",
"ak": "Akan",
"am": "\u12a0\u121b\u122d\u129b",
@cnicodeme
cnicodeme / pdfshift.js
Created December 23, 2020 14:54
Convert a PDF using NodeJS and Axios
const axios = require('axios');
const fs = require('fs');
function pdfshift(api_key, data) {
return new Promise((resolve, reject) => {
let asJson = false
if ('filename' in data || 'webhook' in data) {
asJson = true
}
@cnicodeme
cnicodeme / aiosmtpd.py
Created February 26, 2019 23:08
ImprovMX handler
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 / pocket.py
Created April 4, 2020 17:35
Update your reading list by running this local script.
#!/usr/bin/python3
"""
This the CLI script to add tags to your reading list
You will need a Pocket application. You can create one at:
https://getpocket.com/developer/apps/new
/!\ Don't forget to set the variables defined after.
Requires Python3 and the "requests" library.
@cnicodeme
cnicodeme / sparkpost.py
Created March 11, 2020 15:44
Sparkpost script to send email using Flask
# -*- coding:utf-8 -*-
from flask import current_app
import mimetypes, requests, os
mimetypes.init()
def guess_mimetype(name):
type_found = mimetypes.guess_type(name)
@cnicodeme
cnicodeme / twitter.py
Created March 11, 2020 15:18
Custom implementation of the Twitter OAuth API.
# -*- coding:utf-8 -*-
from urllib.parse import parse_qs, quote
import oauth2, time, requests, json
"""
Usage:
# To setup the access:
# GET /twitter/authorize