Skip to content

Instantly share code, notes, and snippets.

View diije's full-sized avatar

Julien Deneuville diije

View GitHub Profile
@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 / 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 / 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 / verify.py
Last active June 15, 2024 01:13
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 / 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