Skip to content

Instantly share code, notes, and snippets.

View cnicodeme's full-sized avatar

Cyril Nicodème cnicodeme

View GitHub Profile
@cnicodeme
cnicodeme / fixes.md
Last active May 8, 2024 18:03
List of 5,000 Most Frequently Used Domain Name Prefixes and Suffixes - Ordered By Length
@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:
@cnicodeme
cnicodeme / links.md
Last active March 15, 2024 22:30
Big list of useful links
@cnicodeme
cnicodeme / sachilds.py
Last active November 1, 2023 17:24
Generate statistics for Cloudwatch based on the number of SpamAssassin Childs activity
# -*- config:utf-8 -*-
import boto3, asyncio, sys, os, datetime
def get_sa_max_children(default=12):
try:
options = None
with open('/etc/default/spamassassin', 'r') as f:
for line in f:
if line.find('OPTIONS=') == 0:
@cnicodeme
cnicodeme / unsplash.sh
Created July 3, 2023 14:45
I script that would run hourly to change the background wallpaper on Linux for images coming from Unsplash. They disabled source.unsplash.com so it doesn't work anymore.
#!/bin/bash
# They stopped "source.unsplash.com" service
# So that script doesn't work anymore unfortunately ...
# If started as root, then re-start as user "gavenkoa":
if [ "$(id -u)" -eq 0 ]; then
exec sudo -H -u YOUR_USERNAME $0 "$@"
fi
@cnicodeme
cnicodeme / clearhunt.js
Created April 5, 2023 06:53
Remove all the "AI" and "GPT" from ProductHunt.com. Clears the UI too.
(function () {
const sidebar = document.querySelector('.sidebarWithSeparator')
if (sidebar) sidebar.remove()
const question = document.querySelector('[data-test="homepage-questions-card"]')
if (question) question.remove()
const containers = document.querySelectorAll('.layoutContainer')
if (containers.length == 2) { containers[0].remove() }
@cnicodeme
cnicodeme / health.py
Created March 6, 2023 11:22
Gets basics server health informations
#!/usr/bin/python
#
# Inspired by https://gist.github.com/MrHamel/1b640a81ded45bfbac564d2fd4f9532c, but updated for Python3
# Thanks!
#
import json, psutil
def update_top_info():
top_data = {}
@cnicodeme
cnicodeme / fees.py
Created February 6, 2023 15:18
Generate a list of incomes and Stripe fees, per months
import requests, datetime
STRIPE_PRIVATE_KEY='' # Indicate your Stripe private key here
params = {
'limit': 100,
'created[gte]': int(datetime.datetime(year=2022, month=1, day=1, hour=0, minute=0, second=0).timestamp()) # if you want to filter starting in the year 2022
}
operations = {}
@cnicodeme
cnicodeme / tag.py
Created December 30, 2022 09:06
Tags MP3 files to their appropriate ID3 tag based on their path and filename.
# -*- coding: utf-8 -*-
import argparse, glob, os
try:
from mutagen.easyid3 import EasyID3
except ImportError:
print('"mutagen" package is required for this to work.')
print('Please install it using pip or any other package manager')
exit(0)
@cnicodeme
cnicodeme / requirements.py
Last active September 21, 2022 13:27
Will parse the local requirements.txt and prompt for updates when there is.
#!/usr/bin/python
# -*- coding:utf-8 -*-
# Parse the given requirements.txt file (defaults to the local one) and find updates from Pypi.
# Optional parameter "dry" will only show the changes without applying them.
from importlib.metadata import version
from importlib.metadata import PackageNotFoundError
from pkg_resources import Requirement
import requests, datetime, sys, subprocess, argparse