Skip to content

Instantly share code, notes, and snippets.

View cnicodeme's full-sized avatar

Cyril Nicodème cnicodeme

View GitHub Profile
@cnicodeme
cnicodeme / create-user.sql
Last active April 25, 2024 15:09
Create a new Mysql user with restricted access
# 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;
# To dump the database with the master relay details:
@jomido
jomido / call_later.py
Last active January 2, 2021 05:50
An asyncio call_later that works with both sync and async functions...woot
import asyncio
def maybeAsync(callable, *args, **kwargs):
"""
Turn a callable into a coroutine if it isn't
"""
body {
color: #212121;
font-family: "Helvetica Neue", "Calibri Light", Roboto, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
letter-spacing: 0.02em;
}
@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 / migrate.py
Created August 30, 2018 12:07
Migration script to do raw SQL requests
# Add this import:
from sqlalchemy.sql import text
def upgrade():
# ...
conn = op.get_bind()
conn.execute(text('UPDATE ...'))
# ...
@cnicodeme
cnicodeme / links.md
Last active March 15, 2024 22:30
Big list of useful links