Skip to content

Instantly share code, notes, and snippets.

View fjourdren's full-sized avatar

Flavien JOURDREN fjourdren

View GitHub Profile
@fjourdren
fjourdren / apache_download_tree.py
Created February 5, 2024 17:08
This script automatically downloads files from a web directory while skipping over unwanted links, streamlining the process of bulk file retrieval from an Apache file server.
import os
import requests
from bs4 import BeautifulSoup
from urllib.parse import urljoin
from collections import deque
def should_skip_link(href):
# Define all conditions to skip a link
return href in {'../', '/', '?C=N;O=D', '?C=M;O=A', '?C=S;O=A', '?C=D;O=A', '', '#'} or href.startswith('..') or href.startswith('/')
@fjourdren
fjourdren / middleware.ts
Created November 7, 2023 19:11
NextJS www redirection for SEO
import { NextResponse } from 'next/server'
import type { NextRequest } from 'next/server'
export function middleware(request: NextRequest) {
const url = request.nextUrl.clone()
// Redirect to www with port only in production
if (
process.env.NODE_ENV === 'production' &&
!url.hostname.startsWith('www.')
docker run --name=mk-mysql -p3306:3306 -e MYSQL_ROOT_PASSWORD=secret-pw -d mysql:latest
docker exec -it mk-mysql bash
mysql -u root -p
secret-pw
CREATE DATABASE MYSQLTEST;
ALTER USER 'root' IDENTIFIED WITH mysql_native_password BY 'secret-pw';
const amqp = require('amqplib');
class AMQPTalker {
private static connection: any;
private static channel: any;
// create amqp connection
private static async getConnection(): Promise<Record<any, any>> {
if(AMQPTalker.connection == undefined || AMQPTalker.channel == undefined) {
@fjourdren
fjourdren / LAMP_install.sh
Last active June 18, 2018 18:15
Fast LAMP installation script PHP7.0
apt-get -y install mysql-server mysql-client
apt-get -y install apache2 php7.0 libapache2-mod-php7.0
apt-get -y install php7.0-mysql php7.0-curl php7.0-gd php7.0-intl php-pear php-imagick php7.0-imap php-memcache php7.0-pspell php7.0-recode php7.0-sqlite3 php7.0-tidy php7.0-xmlrpc php7.0-xsl php7.0-mbstring php-gettext
apt-get -y install php7.0-opcache php-apcu
apt-get -y install phpmyadmin
adduser $USER www-data
chown -R www-data.www-data /var/www
chmod -R 770 /var/www
systemctl restart apache2
apt-get -y install composer git
@fjourdren
fjourdren / devstack-install.sh
Created January 30, 2018 14:58
Easy devstack intall
#!/bin/bash
apt-get update
apt -y dist-upgrade
apt install -y sudo vim vim-nox lynx zip binutils wget openssl ssl-cert ssh
apt install -y bridge-utils git python-pip
pip install --upgrade pip
pip install -U os-testr
@fjourdren
fjourdren / request-promise.js
Created January 30, 2018 12:13
Example function request in a promise
request: async function(method, url, headers) {
return new Promise((resolve, reject) => {
request({
uri: url,
method: method,
timeout: 10000,
followRedirect: true,
maxRedirects: 10,
headers: headers,
}, function(error, response, body) {
@fjourdren
fjourdren / twitter_autoFollow.js
Created January 26, 2018 13:07
Autoclick (follow, unfollow) twitter. Insert in your browser console.
/**************************************************
* TO USE ON YOUR SUGGESTIONS https://twitter.com/who_to_follow/suggestions
**************************************************/
setInterval(function() {
var t = $(".content-main").find(".follow-button button.follow-text:visible");
if(!t[0]){
window.scrollTo(0,$(document).height());
} else {
t.trigger("click");
}
@fjourdren
fjourdren / iptables-default.sh
Last active January 21, 2018 19:28
Reset iptables
#!/bin/sh
#IPv4
iptables -F
iptables -X
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
@fjourdren
fjourdren / Docker-clear.sh
Created January 21, 2018 12:24
Stops & destroys docker container + volumes and removes images
#!/bin/sh
# Stop containers
docker stop $(docker ps -a -q)
# remove containers
# docker rm $(docker ps -a -q)
# remove containers and volumes
docker rm -v $(docker ps -a -q)