Skip to content

Instantly share code, notes, and snippets.

View diije's full-sized avatar

Julien Deneuville diije

View GitHub Profile
@diije
diije / fancy-diff
Created January 3, 2024 14:00
Fancy Diff
#!/usr/bin/env bash
#
# Diff wrapper piping with diff-so-fancy
#
# Prerequiste: install diff-so-fancy
# https://github.com/so-fancy/diff-so-fancy
#
# Setup:
# - save this script somewhere
# - `chmod +x` the file
@diije
diije / verify.py
Last active April 6, 2023 09:26
Verify a list of Googlebot IPs in Python
import ipaddress
import requests
def verify_googlebot_ips(
list_of_ips,
google_ips_list_url="https://developers.google.com/static/search/apis/ipranges/googlebot.json",
):
"""Checks if each IP address in given list is in Google's official list of IP ranges.
Args:
- list_of_ips: list of ipv4 or ipv6 to check,
@diije
diije / make_sitemap.py
Created December 1, 2022 15:27
Python script to generate a XML sitemap from a list of URLs
import argparse
from validator_collection import validators, errors # pip install validator-collection
import requests # pip install requests
import time
def main(args):
with open(args.input) as f:
urls = f.readlines()
sitemap_urls = []
@diije
diije / seo-monitoring.py
Last active March 30, 2022 15:54
Simple SEO tests with Python, Requests and Requests-HTML
import requests
from requests_html import requests_html
if __name__ == '__main__':
# Define test data
test_data = [
{
"url": "https://www.example.com/",
"status": 200,
"title": "Example Domain",
@diije
diije / pandas-head-and-others.py
Created August 6, 2021 13:12
Display k first rows of Pandas dataframe and sum of other rows
# Number of rows to keep
k = 8
# Keep k first rows + transpose df
temp = df.head(k).T
# If df has more than k rows, sum remaining rows
if len(df) > k:
temp['Other rows'] = df.tail(len(df)-k).sum()
@diije
diije / .zshrc
Last active May 30, 2018 13:32
ZSH setup: shows pyenv and git branch in prompt + fishshell-like autocomplete
############################################################################
# Uses oh-my-zsh: https://github.com/robbyrussell/oh-my-zsh/
# Uses spaceship: https://github.com/denysdovhan/spaceship-prompt
# Uses zsh-autosuggestions: https://github.com/zsh-users/zsh-autosuggestions
############################################################################
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
@diije
diije / example.py
Created May 1, 2018 12:43
Converting from Networkx to Python-Igraph
import networkx as nx
Gnx = nx.path_graph(4) # Create a random NX graph
nx.write_graphml(G,'graph.graphml') # Export NX graph to file
import igraph as ig
Gix = ig.read('graph.graphml',format="graphml") # Create new IG graph from file
@diije
diije / functions.php
Created May 18, 2017 14:30
WordPress : Afficher le widget des articles récents sur toutes les pages sauf la page d'accueil. (Thème : 2017)
<?php
if ( ! function_exists('dfr_recent_articles') ) {
function dfr_recent_articles() {
if(!(is_home() || is_front_page())) {
echo '<section id="dfr_widget" class="widget widget_recent_entries">';
echo '<h2 class="widget-title">Articles R&eacute;cents</h2>';
echo '<ul>';
$lastposts = get_posts();
@diije
diije / functions.php
Created May 18, 2017 14:30
WordPress : Afficher le widget des articles récents sur toutes les pages sauf la page d'accueil.
<?php
if ( ! function_exists('dfr_recent_articles') ) {
function dfr_recent_articles() {
if(!(is_home() || is_front_page())) {
echo '<section id="dfr_widget" class="widget widget_recent_entries">';
echo '<h2 class="widget-title">Articles R&eacute;cents</h2>';
echo '<ul>';
$lastposts = get_posts();
@diije
diije / VirtualHost
Created February 17, 2017 16:26
Custom Apache access log format for better SEO logs analysis
CustomLog ${APACHE_LOG_DIR}/custom-access.log "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %D \"%{If-Modified-Since}i\""