Skip to content

Instantly share code, notes, and snippets.

View benoit74's full-sized avatar

benoit74

  • Switzerland
View GitHub Profile
@benoit74
benoit74 / add_pyright_ignore.py
Created February 6, 2024 15:32
Add pyright ignore statements for every diagnosis encountered
import subprocess
import re
import json
def run_pyright():
# Run Pyright and capture the output
result = subprocess.run(["pyright", "--outputjson"], capture_output=True, text=True)
return result.stdout
@benoit74
benoit74 / list_warc_content.py
Created November 16, 2023 07:21
List requests present in WARC files
import glob
from warcio import ArchiveIterator
for warc in glob.glob("output/.tmph919m5n3/collections/crawl-*/archive/*.warc.gz"):
with open(warc, "rb") as fh:
for record in ArchiveIterator(fh):
if record.rec_type == "request":
print(record.rec_headers.get_header('WARC-Target-URI'))
print("DONE")
@benoit74
benoit74 / Explanation.md
Last active January 1, 2024 11:28
Observe Browsertrix Crawler web traffic

One might need to get a better grasp at what Browsertrix is performing in terms of trafic and where it is being blocked.

You might use the following docker compose stack to run:

  • a mitmweb web proxy to intercept all Browsertrix traffic and dump them on file
  • a screencasting Browsertrix crawler to get a grasp on crawler behavior

If you open http://localhost:9037, you will see Browsertrix screencasting of the browser.

mitmdump are placed in the output/mitmdump folder, with one file per minute.

@benoit74
benoit74 / deprecated-pods.py
Last active September 5, 2023 08:59
k8s: Find daemonsets with pod to delete for update, and print the corresponding node names
import json
import subprocess
nodes_str = subprocess.check_output(
["kubectl", "get", "nodes", "-o", "json"]
)
nodes = json.loads(nodes_str)
node_data = {}
for node in nodes.get("items"):
@benoit74
benoit74 / settings.json
Created April 27, 2023 06:50
Visual Studio Code settings for Python with black, isort and flake8
{
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
},
"isort.args": [
"--profile",
@benoit74
benoit74 / first_apply.log
Created April 25, 2023 14:21
Logs for azuread issue with DisableRetries
my-super-secret-machine:/tmp/testbbe$ TF_LOG=debug terraform plan -out plan.out
2023-04-25T14:14:10.817Z [INFO] Terraform version: 1.3.7
2023-04-25T14:14:10.817Z [DEBUG] using github.com/hashicorp/go-tfe v1.9.0
2023-04-25T14:14:10.817Z [DEBUG] using github.com/hashicorp/hcl/v2 v2.15.0
2023-04-25T14:14:10.817Z [DEBUG] using github.com/hashicorp/terraform-config-inspect v0.0.0-20210209133302-4fd17a0faac2
2023-04-25T14:14:10.817Z [DEBUG] using github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734
2023-04-25T14:14:10.817Z [DEBUG] using github.com/zclconf/go-cty v1.12.1
2023-04-25T14:14:10.817Z [INFO] Go runtime version: go1.19.4
2023-04-25T14:14:10.817Z [INFO] CLI args: []string{"terraform", "plan", "-out", "plan.out"}
2023-04-25T14:14:10.817Z [DEBUG] Attempting to open CLI config file: /home/atlantis/.terraformrc
/*
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@benoit74
benoit74 / .block
Last active April 1, 2016 07:53
RTE Dataviz #2
license: gpl-3.0
height: 600
@benoit74
benoit74 / .block
Last active March 31, 2016 13:26
RTE Dataviz #1
license: gpl-3.0
height: 600
#PS C:\Windows\system32>
#Import-Module $env:appdata\boxstarter\Boxstarter.Chocolatey\Boxstarter.Chocolatey.psd1
#Invoke-ChocolateyBoxstarter https://gist.githubusercontent.com/fschafer/f04aef74c5d9e19cf8ae/raw/a06b630d2c4843b283b32db38f95d5c662de3e26/BoxStarter-DEV
#START http://boxstarter.org/package/nr/url?https://gist.githubusercontent.com/benoit74/7d98ed4b958804cac4d8/raw/3195b11b6e533a0df33b950d706ec15e30f38805/BoxStarter-DEV
# Boxstarter options
$Boxstarter.RebootOk=$true # Allow reboots?
$Boxstarter.NoPassword=$false # Is this a machine with no login password?
$Boxstarter.AutoLogin=$true # Save my password securely and auto-login after a reboot