Skip to content

Instantly share code, notes, and snippets.

Avatar

Cyril Nicodème cnicodeme

View GitHub Profile
@MrHamel
MrHamel / health.py
Last active Dec 2, 2020
Server Monitor
View health.py
import requests, json
import os, psutil, re, time
def parse_syslog():
syslog = "/var/log/messages"
if os.path.isfile("/var/log/syslog"):
syslog = "/var/log/syslog"
f = open(syslog, 'r')
@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 / 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
View good-enough.css
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;
}
@jomido
jomido / call_later.py
Last active Jan 2, 2021
An asyncio call_later that works with both sync and async functions...woot
View call_later.py
import asyncio
def maybeAsync(callable, *args, **kwargs):
"""
Turn a callable into a coroutine if it isn't
"""
@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;