Random snippets of all sorts of code, mixed with a selection of help and advice.
sharing to LinkedIn using curl and PHP - post photo AND URL to click through
5 June 2026 @ 11:36 pm
I am building an app to make posts to a LinkedIn page, written in PHP, using the curl library. I have successfully:
Authenticated (scopes: w_member_social, openid, profile, email
Registered and uploaded my image, and got the URN back (urn:li:digitalmediaAsset:CODE)
But I am having trouble making a post that shows the image and lets you click on it to get to the right place (or any place). My JSON looks like:
{
"author": "urn:li:person:SUBCODE",
"lifecycleState": "PUBLISHED",
"specificContent": {
"com.linkedin.ugc.ShareContent": {
"shareCommentary": {
"text": "TEST LISTING SHARE - IGNORE! - share commentary"
},
"shareMediaCategory": "IMAGE",
"media": [
{
"status": "RE
Can paternalistic protection cause greater harm than the risks it seeks to prevent? Philosophical perspectives on "harm by shielding"
5 June 2026 @ 11:19 pm
I am exploring the ethical tensions in paternalism—the idea that intervening to protect someone from harm (for their own good) can itself constitute a form of harm.
Core Problem
Philosophically, is it coherent (or even common) that well-intentioned protective actions—whether by parents, governments, friends, or institutions—can inflict greater or more insidious damage than the original risk they aim to avert? This seems to invert the intuitive logic of protection and raises questions about autonomy, unintended consequences, and the nature of harm itself.
Examples
Personal/Relational: "Helicopter parenting" or overprotective relationships that shield a person from failure, disappointment, or minor risks, but result in stunted emotional growth, learned helplessness, or resentment (e.g., as discussed in psychological and virtue-ethics literature).
Societal/Political
How could I go about creating my tile based 2D graphics engine?
5 June 2026 @ 11:13 pm
I'm trying to create a tile based 2D graphics engine that I can create gui apps on and games, the NES and Famicom are my inspiration. I'm not a pro at programming but my idea to have this work is to split the screen into a grid and be able to assign each part a sprite from a tile map. But I'm trying to accomplish this without using an already existing game library like Pygame. I plan on using Python but I'm open to try another language. Any ideas on how to get create this kind of grid and be able to read the tilemaps and place the tiles would be amazing.
Also first time asking a question on here, please let me know if its formatted bad or if this isn't the kind of question I should be asking. Thanks.
Verificacao Manual OAuth Proprietario Site [closed]
5 June 2026 @ 10:54 pm
Boa tarde.
Eu não estava conseguindo realizar a verificação automática do meu site para aprovação do OAuth utilizado no Login com Google. Por esse motivo, alterei o processo para a verificação manual.
Após a análise manual, fui informado pela equipe do Google que o site não estava validado como sendo de minha propriedade. Pesquisando sobre o assunto, identifiquei que era necessário adicionar um registro TXT ao domínio e vinculá-lo ao Google Search Console. Realizei esse procedimento.
Desde então, a validação permanece parada e não encontrei nenhuma opção para solicitar uma nova verificação. Como o processo foi encaminhado para análise manual, o botão para reenviar ou solicitar uma nova validação não está mais disponível.
Gostaria de saber como posso solicitar uma nova análise agora que a propriedade do domínio já foi devidamente verificada.
async/await locking where await Task.Run does not in .NET Framework MVC application [closed]
5 June 2026 @ 9:16 pm
I have a .NET Framework 4.8.1 ASP.NET MVC application. This is a POST method on a System.Web.Mvc.Controller. If I call AnotherMethodAsync directly with await, the application locks up on that line and never returns. However, if I wrap the call to AnotherMethodAsync in a Task.Run, it works as expected. Each of these behaviors occurs with 100% consistency, no randomness. I do not believe I should have to use Task.Run to run an async method from another async method. What could possibly be going on that I can fix?
Also, I did try with .ConfigureAwait(false), but it also freezes, but I wouldn't want to use it anyway, if it means I would lose context.
This one works:
public async Task<JsonResult> ExecuteMethod(string Input1, string Input2)
{
var response = await Task.Run(async () =>
{
return await AnotherMethodAsync();
});
Use of variable inside a trigger causing error "Cannot continue the execution because the session is in the kill state."
5 June 2026 @ 2:49 pm
Problem is specific to compatibility level 170 from what I can see.
With a trigger like this:
CREATE OR ALTER TRIGGER CH_REPRO
ON CH
INSTEAD OF UPDATE
AS
BEGIN
DECLARE @cirObj INT = 101;
SELECT U.cir
FROM inserted AS I
LEFT JOIN TC AS U ON U.cir = I.itemno
AND I.objectno = @cirObj;
END;
Runing any update such as
UPDATE CH
SET bearer = bearer;
results in an error:
Msg 596, Level 21, State 1, Line 24
Cannot continue the execution because the session is in the kill state.
Msg 0, Level 20, State 0, Line 24
A severe error occurred on the current command. The results, if any, should be discarded.
The view or table CH seems irrelevant to the issue, but in this case was defined as
DROP TABLE IF EXISTS CH;
CREATE TABLE CH
(
bcport int,
channel int,
bearer int,
objectno int,
itemno in
Object contiguity: consequence on in place construction
5 June 2026 @ 2:12 pm
overview of the issue
In C++, theoretically, only some types of objects are guaranteed to be "contiguous" and, if my analysis is correct, it leads to issues when trying to do placement new of non-contiguous objects inside a storage.
To understand the question, I am feeling obliged to give lots of context.
technical context
While (re)reading accessing object representation (which is now scheduled for C++29!), I stumbled about another issue that flew under my radar: Making More Objects Contiguous (issue that seems stalled). So far, only trivially copyable or standard layout types are guaranteed to be contiguous: https://eel.is/c++draft/intro.object#8.
I have then an issue: I couldn't find
Check if String only contains latin letters including accents
4 June 2026 @ 10:10 pm
I want to check if a String only has latin letters (a-z / A-Z), but it may also contain letters with accents (á, à, ã, â, é, è, etc). What is the best way to do this?
If possible, I'd prefer to use the Pattern class, since I'm a bit familiar with it. But any solution is welcome.
Are there Alternatives to Bun that weren't written with AI assistance?
4 June 2026 @ 9:04 pm
I'm philosophically anti AI, and recently found out that Bun was rewritten with AI. I don't want to use any tool that was written with AI assistance.
I have been using Bun for a CLI that reads and writes to the the file system. Can someone offer me an alternative that doesn't go against my philosophical stance?
Implementing a custom comparer that treats the numbers as integers rather than strings
2 June 2026 @ 7:52 pm
I have a C# application with SQL database. I am taking a calendar day of the week, i.e., 1, 5, 10, 11 etc; and am converting it to an integer and inserting into SQL table defined as an 'int'.
However, because Microsoft sorts numbers as text by default, it displays the number "11" before "2" because the first character "1" is less than "2".
When I researched how to get around this, it was suggested to use a Custom Comparer that treats the numbers as integers rather than strings. Please see the following URL to see the CC.
https://duckduckgo.com/?q=In+C%23%2C+how+can+I+make+the+integer+number+11+appear+after+the+integer+number+1+in+a+list&t=newext&ia=web
My question is this. How do I implement this new Custom Comparer, so that with