Skip to content

Instantly share code, notes, and snippets.

Avatar

Cyril Nicodème cnicodeme

View GitHub Profile
@cnicodeme
cnicodeme / fixes.md
Last active Apr 16, 2021
List of 5,000 Most Frequently Used Domain Name Prefixes and Suffixes - Ordered By Length
View fixes.md
@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 / langs.py
Last active Mar 4, 2021
Dictionnary of languages code (ISO-639-1) to their corresponding lang (Source: Wikpedia)
View langs.py
# 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 / 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 / pdfshift.js
Created Dec 23, 2020
Convert a PDF using NodeJS and Axios
View pdfshift.js
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 / create-user.sql
Last active Jun 19, 2020
Create a new Mysql user with restricted access
View create-user.sql
# Difference unicode/general : http://stackoverflow.com/a/367725/330867
CREATE DATABASE dbname CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'dbuser'@'localhost' IDENTIFIED BY 'dbpass';
GRANT USAGE ON * . * TO 'dbuser'@'localhost' IDENTIFIED BY 'dbpass' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
GRANT SELECT , INSERT , UPDATE , DELETE , CREATE , DROP , INDEX , ALTER , REFERENCES, LOCK TABLES ON `dbname` . * TO 'dbuser'@'localhost';
FLUSH PRIVILEGES;
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 / pocket.py
Created Apr 4, 2020
Update your reading list by running this local script.
View pocket.py
#!/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 Mar 11, 2020
Sparkpost script to send email using Flask
View sparkpost.py
# -*- coding:utf-8 -*-
from flask import current_app
import mimetypes, requests, os
mimetypes.init()
def guess_mimetype(name):
type_found = mimetypes.guess_type(name)