Random snippets of all sorts of code, mixed with a selection of help and advice.
TikTok Automated Upload bot wont publish Videos
29 April 2025 @ 12:42 pm
ikTok Upload Bot Automation Failing at Final Step?
I’m currently developing an automated upload bot for TikTok Studio (https://www.tiktok.com/tiktokstudio/upload) using Selenium, to upload multiple videos in a batch.
The bot is already quite advanced and works in almost all aspects – however, it fails at the final step: clicking the “Post” button, even though it appears visually active (red) on the page.
⸻
What Works So Far:
• Automatic login using saved cookies (cookies.pkl)
• Upload page is opened successfully, and the upload area is correctly detected
• .mp4 files are uploaded one after another via
• The loading bar disappears → TikTok visually indicates the video is ready to post
⸻
The Problem:
Once the upload is finished, the “Post” button becomes visible and looks active (red).
But Selenium cannot click it. It th
How to create repo inside the organization with Github actions?
29 April 2025 @ 12:41 pm
I want to create repos inside my organization,but I want to send it to different directory
My repo is in
mygroup/pt
I want repo to be created in my group
I found http://github.com/marketplace/actions/create-a-repository-in-an-organization
I do not see how I can change a folder here.
Grafana: Variables Not Recognized in Query Results Despite Using Lowercase (ClickHouse)
29 April 2025 @ 12:39 pm
I'm using variables in Grafana queries with ClickHouse, but the variable ${var_name:raw} isn't recognized in the results. The query runs without errors, but no data shows up in the graph.
Here’s the query:
SELECT
predictiondate,
'${var_name:raw}' as "ANN01: 48H"
FROM
aidb.${plant_name:raw}_table;
The parameter is passed as WT01 (uppercase).
The column name in the table is lowercase (wt01), and even when using LOWER('${var_name:raw}'), I still don't get any results in the graph.
Replacing the variable with the hardcoded value wt01 works fine.
Any suggestions on why the variable isn't working in the query results?
New(ish) to Pyomo - How Do I Structure This Model?
29 April 2025 @ 12:35 pm
I'm relatively new to both Python and Pyomo. I'm building an optimization script as one of my first projects. ChatGPT is hallucinating and I cannot find an example of how to properly set up the model to save my life, so long story short I've been trying to figure this out on my own and failing miserably.
Problem description
I essentially have an inventory purchasing problem with one indexed variable X that indicates the number of units to be purchased at certain times and locations with varying levels of value per dollar, purchasing at least 1 of each unit and no more than the limited number of units available to purchase.
My script is feeding several lists extracted from a Pandas dataframe into the model to define that index. In my use case these lists are coming from table columns that are anywhere from 100-10,000ish rows long.
So for a simplified example:
# master lists
unit_cost = [100, 150, 85, 230, 350, 700, 155, 205
Can't import MPAndroidChart libraries into Activity declaring in TOML and build.gradle (app)
29 April 2025 @ 12:33 pm
I'm in Sdk 35. I've declared MPAndroidChart in my Android project:
in TOML as mpandroidchart = "3.1.0" and mpandroidchart = { group = "com.github.PhilJay", name = "MPAndroidChart", version.ref = "mpandroidchart" }
in build.gradle (app) as implementation(libs.mpandroidchart)
That works. But now i can't import libraries in my Activity (using Java) like
import com.github.mikephil.charting.charts.LineChart;
import com.github.mikephil.charting.charts.BarChart;
I've tried this inside dependencyResolutionManagement: maven { url 'https://jitpack.io' } in my settings.gradle, but it doesn't accept that ("Unexpected tokens (use ';' to separate expressions on the same line") nor that maven { url (https://jitpack.io) }
I've tried to look for help, but everyone says I need this maven { url
Wrap each base class in a template class
29 April 2025 @ 12:24 pm
My project breaks down mocks into multiple classes so that they can be maintained in separate files, but then combines together in tests using multiple inheritance, so that you can refer to them using single name. This makes sense to us since each mock is a singleton implementing a global function coming from C API.
Ezample:
class foo_mock;
class bar_mock;
class baz_mock;
class my_test_mock :
public foo_mock,
public bar_mock,
public baz_mock
{};
Unfortunately, due to GMock StrictMock uninteresting function call does not fail a test , when we want a strict mock, instead of just testing::StrictMock<my_test_mock>, you have to wrap each base separately:
class my_test_mock :
public testing::StrictMock&
How to enclose consecutive groups of matching elements in tags with XSLT 1.0/1.1?
29 April 2025 @ 12:18 pm
I'm dealing with XML documents that have 2 classes of elements: simple and to_enclose (the latter may be absent from the document). The former need to be copied as-is, the consecutive groups of the latter enclosed in <enclosure> tags (a group can be 1 or more elements). The only solution I came up with is using big xsl:choose block and brittle/ugly tag construction with xsl:text, don't even want to post it here.
Example:
<?xml version="1.0" encoding="UTF-8"?>
<mydoc>
<t class="to_enclose">text01</t>
<t class="simple">text02</t>
<t class="to_enclose">text03</t>
<t class="to_enclose">text04</t>
<t class="to_enclose">text05</t>
<t class="simple">text06</t>
<t cla
Efficiently calculate time to first 'purchase' event per user in Pandas DataFrame
29 April 2025 @ 12:16 pm
How can I compute time to first target event per user using Pandas efficiently (with edge cases)?
I'm analyzing user behavior using a Pandas DataFrame that logs events on an app. Each row includes a user_id, event_type, and timestamp. I want to calculate the time (in seconds) from each user's first recorded event to their first occurrence of a target event (e.g., "purchase").
However, there are a few requirements that complicate things:
Some users never trigger the target event, so I want to exclude or mark them as NaN.
The timestamp column is a datetime.
I’d like this to be vectorized and efficient (not using for loops).
I want to return a DataFrame with user_id and seconds_to_first_purchase.
import pandas as pd
data = [
{'user_id': 'u1', 'event_type': 'login', 'timestam
I'm trying to model a bolt in CadQuery python
29 April 2025 @ 12:11 pm
I'm trying to build a CAD model of a bolt, but I can't figure out how to cut off the tops of the corners at the top of the head at a 45-degree angle.
I want to get this result
What did I do for this?
At first I tried this:
import cadquery as cq
from math import sqrt, tan, radians
head_diameter = 10.0
head_height = 5.0
shaft_diameter = 5.0
shaft_length = 20.0
R = head_diameter / 2
r = R * sqrt(3)/2
chamfer_size = (R - r) / tan(45)
bolt_head = (
cq.Workplane("XY")
.polygon(6, 2*R)
.extrude(head_height)
.translate((0, 0, -1 * (head_height/2)))
)
bolt_head = bolt_head.edges("Z").chamfer(1)
bolt_shaft = (
cq.Workplane("XY")
.circle(shaft_diameter/2)
.extrude(-shaft_length)
)
bolt = bolt_head.union(bolt_shaft)

Blazor Server .NET 9 Preview: CS1061 Error for AddAuthenticationStateSerialization on IServiceCollection
29 April 2025 @ 11:50 am
Issue:
I'm developing a Blazor Server application targeting .NET 9. I'm using standard Cookie Authentication and trying to configure authentication state handling for prerendering.
My goal is to ensure the user's identity is available during the initial render after a forced reload post-login. I attempted to use the .NET 8+ recommended service AddAuthenticationStateSerialization.
However, when I add the following line to my Program.cs:
// Correctly called directly on builder.Services
builder.Services.AddAuthenticationStateSerialization();
I get the following compile error:
Error CS1061: 'IServiceCollection' does not contain a definition for 'AddAuthenticationStateSerialization' and no accessible extension method 'AddAuthenticationStateSerialization' accepting a first argument of type 'IServiceCollection' could be found (are you missing a using directive or an assembly reference?)