Random snippets of all sorts of code, mixed with a selection of help and advice.
How can I get BBFC ratings in python?
9 November 2025 @ 2:42 pm
I am trying to write code to give me BBFC film ratings. I am using selenium to do this but would be happy with any solution that works reliably. After a lot of work I finally came up with this code:
# pip install -U selenium
from selenium import webdriver
from selenium.webdriver.firefox.service import Service as FirefoxService
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import json, re, time
from urllib.parse import quote_plus, urlparse
RATING_RE = re.compile(r"\b(R18|18|15|12A|12|PG|U)\b", re.I)
# -------------------- Browser --------------------
def start_driver(headless=True):
opts = webdriver.FirefoxOptions()
if headless:
opts.add_argument("--headless")
opts.page_load_strategy = "eager" # faster: don't wait for images/fonts
opts.set_preference("permissions.default.ima
How can i make two funtions different arguments share a function body?
9 November 2025 @ 2:34 pm
I need to make a linked list implementation without using STL. push_front function has two overloads: one with const T&, other with T&&, but implementation is the same.
Only thing I came up with is using a #define macro. Is there any other way?
Current implementation:
#define pushFront { \
/*
* Implementation
*/
}
void push_front(const T& value) pushFront
void push_front(T&& value) pushFront
#undef pushFront
Snakemake: Error submitting jobscript (exit code 126)
9 November 2025 @ 2:30 pm
I am trying to run a snakemake pipeline on an SGE cluster.
I am using Snakemake 9.13.4, using cluster-generic-submit-cmd and the submit profile from https://github.com/Snakemake-Profiles/sge.
I am getting the following error: Error submitting jobscript (exit code 126).
I have tried chmod in case it was permissions error but it's not that.
The snakemake command is:
snakemake -s /path/workflow.smk --cores 1 --profile /path/sge --workflow-profile /path/gif/config.yaml --jobs unlimited --configfile /path/config.yaml
/path/gif/config.yaml:
resources:
h_vmem: 16*1024
h_rt: "200:00:00"
options:
N: "gif_processing"
I want to fix a "int' object is not subscriptable" error
9 November 2025 @ 2:28 pm
I'm using genetic algorithm for knapsack problem and when I wanted to debug it says : int' object is not subscriptable
it just pointed this 3 spots in the code and in the end it just said this is the error, also it referenced the first error in the fitness def twice
import random
value = [20, 30, 40, 50, 90, 5, 250, 100]
weight = [5, 10, 50, 25, 36, 71, 61, 48,]
inventory = 100
popSize = 10
gens = 100
mutationRate = 0.1
numberOfItems = len(value)
def fitness(individual):
---> totalval = sum(value[i] for i in range(numberOfItems)if individual[i] == 1)
totalW = sum(weight[i] for i in range(numberOfItems)if individual[i] == 1)
if totalW > inventory :
return 0
else :
return totalval
def createItem() :
return[random.randint(0,1) for i in range(numberOfItems)]
def createPop() :
return[random.randint(0,1) for i in range(popSize)]
def selection(pop) :
players = random.sample(pop, 3)
---> players.sort(ke
Error in firebase cloud functions document trigger using V2 functions: Failed to decode protobuf and create a before snapshot
9 November 2025 @ 2:28 pm
I am migrating my Firebase Cloud Functions project from v1 to v2.
Since Auth triggers are not yet available in v2, I still have auth triggers in v1 — but all my Firestore triggers are now v2.
One of my Firestore v2 triggers fails immediately on invocation with this error:
TypeError: Cannot read properties of undefined (reading 'cloud')
at Function.decode (/Users/.../node_modules/firebase-functions/protos/compiledFirestore.js:1529:130)
at createBeforeSnapshotFromProtobuf (/Users/.../node_modules/firebase-functions/lib/common/providers/firestore.js:73:52)
at createBeforeSnapshot (/Users/.../node_modules/firebase-functions/lib/v2/providers/firestore.js:187:65)
at makeChangedFirestoreEvent (/Users/.../node_modules/firebase-functions/lib/v2/providers/firestore.js:235:37)
at func (/Users/.../node_modules/firebase-functions/lib/v2/providers/firestore.js:316:32)
at /usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulato
Does the Dart language server support code completion for switch statements?
9 November 2025 @ 2:27 pm
Does the Dart language server support code completion for switch statement?
I am asking about the Dart extension for vscode.
In the switch statement I enter the case clause and code completion does not work.
I get the impression that this feature is not implemented.
Maybe I am wrong and I am doing something wrong?
How can I determine what the problem is?


Profiling application using perf with clion docker toolchain
9 November 2025 @ 2:27 pm
Clion offers a perf integration for profiling applications. Getting this to work when using a docker toolchain is not described online. Is it possible to do this, and how does one manage the different dependencies between the docker toolchain and the local system?
What I have done so far is download perf locally (apt-get install linux-tools-generic). It does not make sense to download it into the docker toolchain image itself because docker uses the local system's kernel. Then I set the "Perf executable" path to my local system perf in the clion gui.
When I try then to profile an application I got the error that the docker container could not launch at all, because it tried to find the perf executable path from the local system. To solve that I mounted the "/usr/lib/linux-tools/5.15.0-139-generic/perf" folder into the container using the clion gui.
Then when I try to launch it again, perf starts to start, but stops instant
ESP32S3 Parallel ILI9488 problem with color in new TFT_eSPI
9 November 2025 @ 2:22 pm
i hope someone can help me
I was using Bodmers TFT_eSPI with Arduino boards 2.017, then decided it was time toupgrade to boards 3.X
after searching for a while I found this androidCryptos git site with an updated TFT_eSPI which works with boards 3.X
I copied my user_settings.h file to the new lib to keep things the same and added #define USE_HSPI_PORT to it
one problem i have found:
colors do not seem to work the same as they did in Bodmers
if i use tft.invertDisplay(false);
I am getting a screen that it has been washed with white and some graphics printed on top
if i use tft.invertDisplay(true);
I am getting a screen that it has been washed with blue and some graphics printed on top
as in the 3 pics below
I would be very grateful to anyone who has either sorted this for themselves or can point me in the right direction]
thanks in advance
Dave
How to enhance this python code to scrape website via selenium?
9 November 2025 @ 2:19 pm
I want to enhance the following python code to scrape website via selenium:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.support.ui import Select
import pandas as pd
import time
# define the website to scrape and path where the chromediver is located
website = 'https://www.adamchoi.co.uk/overs/detailed'
path = '/Users/frankandrade/Downloads/chromedriver' # write your path here
service = Service(executable_path=path) # selenium 4
driver = webdriver.Chrome(service=service) # define 'driver' variable
# open Google Chrome with chromedriver
driver.get(website)
# locate and click on a button
all_matches_button = driver.find_element(by='xpath', value='//label[@analytics-event="All matches"]')
all_matches_button.click()
# select dropdown and select element inside by visible text
dropdown = Select(driver.find_element(by='id', value='country'))
dropdown.select_by
PgAdmin4, disable autoopen [closed]
9 November 2025 @ 2:17 pm
How to stop or minimize the queries count PgAdmin4 (ver 9.9 specifically) executes on the startup or on connect to the server? I have got a lot of servers and databases on the list and PgAdmin lags unbearably. I know its not directly a programming question but the tag exists so what else can be posted under it?