StackOverflow.com

VN:F [1.9.22_1171]
Rating: 9.4/10 (10 votes cast)

Random snippets of all sorts of code, mixed with a selection of help and advice.

Third Party API Integration with Django (JWT) + Next.js (Redux, RTK Query)

30 April 2025 @ 1:11 am

I am creating a NYT News App using Django JWT authentication for registration and login and NextJS, Redux and RTK Query on the frontend. My full stack login/registration system works perfectly and now I want to load the news after logging in. Lets call NYT API json from the backend as raw data. On the frontend I wanna filter out raw news by selecting categories:{} and create a popup in the frontend for the first time users. (These preferences are then stored in DigitalOcean bucket using DigitalOcean functions). I am not sure how to start new api call in the first place and which tools to use. Any help would be appreciated!

Creating cdk pipeline but it deletes itself

30 April 2025 @ 1:08 am

I am new to cdk and trying to create a simple pipeline from udemy course and at first its fine I even saw that the pipeline was being created and when it was almost complete i got a pipeline not found here is my code import * as cdk from 'aws-cdk-lib'; import { CodePipeline, CodePipelineSource, ShellStep } from 'aws-cdk-lib/pipelines'; import { Construct } from 'constructs'; export class CdkCicdStack extends cdk.Stack { constructor(scope: Construct, id: string, props?: cdk.StackProps) { super(scope, id, props); new CodePipeline(this, 'AwesomePipeline', { pipelineName: 'AwesomePipeline', synth: new ShellStep('Synth', { input: CodePipelineSource.gitHub('jameseraynor/cdk-cicd', 'main'), commands: [ 'npm ci', 'npx cdk synth' ], }) }) } } and #!/usr/bin/env node import 'source-map-support/register'; import * as cdk from 'aws-cdk-lib'; import { CdkCicdStack

Resequencing the rows of an R data frame using the native pipe

30 April 2025 @ 1:07 am

Minimal Example df <- data. Frame(x = c(10, NA, 30, 40, 50), y = c(10, 20, NA, 40, 50)) df <- df |> na.omit() |> `colnames<-`(c("You", "Me")) >df You Me 1 10 10 4 40 40 5 50 50 I would like to resequence the rows of the filtered data frame to go from 1 to the number of rows. I know I can do this by writing > rownames(df) <- NULL > df You Me 1 10 10 2 40 40 3 50 50 How can I achieve the same end using the base R pipe just as I have done for colnames? Many thanks in advance Thomas Philips

Jekyll Github pages doesn't load the theme for a page when accessed via a link on the home page

30 April 2025 @ 1:02 am

When testing locally, all the pages render properly. But when loaded to github pages, only the home page renders with the theme. And clicking a link to open a sub-page doesn't load the theme for the sub-page. However, if I load the sub-page directly using its full link in a new browser tab, the theme is applied. Here are the info: Home page: https://deepworkmonk.com Sub-page: https://deepworkmonk.com/blogs/books-i-recommend/ Code: https://github.com/meenaren/DeepWorkMonkWebsite/blob/main/_config.yml How do I fix this issue?

Oracle Netsuite Question: how to combine multiple optional fields with delimiter

30 April 2025 @ 12:53 am

In short, I'm trying to replicate excel's TEXTJOIN function in Oracle Netsuite. More detailed: I have a field in Oracle Netsuite that needs to do the following: Part 1: If certain criteria are met, write in some text for Part 1, else remain blank Part 2: If certain criteria are met, write in some text for Part 2, else remain blank Part 3: .... All the way to Part n There's no guarantee that any of these parts are there. Once all parts are there (or not), I need to join them with a delimiter (the bar "|"). So it could be just "Part 1", or maybe "Part 1|Part 2", or "Part 2|Part 4", or "Part 1|Part 2|Part 3|....|Part n" How do I do this using Oracle Netsuite's Functions? Currently I only need to handle up to 2, but I likely will need to go back and write this up to 11, or even more. Any ideas? Currently I have the following parts: Part 1: CASE WHEN {shiptype} IS NULL THEN '

I am engaging with Capstone project - prepare online learning system for student and teacher logging

30 April 2025 @ 12:53 am

I created my capstone project frontend by Angular.Js backend by Node.Js and Express. Database created by sqlite3.I want to update the files into github repository and autograding for evaluate my progress. I completed backend It is all correct.when I upload the files and checked frontend the autograding given a message like this. run-autograding-tests The process '/usr/bin/git' failed with exit code 128. workflow file at 128 will be test-name: Frontend Search Student setup-command: npm install command: file=./test/student-search.test.js npm run test --prefix ./frontend What are the most possible errors that I can correct this project? I changed the search function for student and try.this is my method search(value: string) { const searchTerm = value.toLowerCase().trim(); if (!searchTerm) { this.getStudentData(); return; } this.service.getStudentData().subscribe((response) => { const allstudents = Object.keys(response).map(key => [resp

How to create a custom Clickable Menu using the Stardew Modding API?

29 April 2025 @ 11:57 pm

I'm making a mod for Stardew Valley and I need to create a menu, specifically an IClickableMenu. I tried looking it up but the internet was useless as ever 🫠 All I got were some people saying it exists but not how to make it Does anybody know how to do this?

High-Performance Asynchronous Processing with Dynamic Task Prioritization and Cancellation [closed]

29 April 2025 @ 11:35 pm

I'm building a high-throughput data processing pipeline in C# using asynchronous programming with Task and async/await. The pipeline needs to handle a large volume of incoming requests; each associated with a dynamically assigned priority and a potential cancellation request. private readonly SemaphoreSlim _concurrencySemaphore = new SemaphoreSlim(10); // Limit to 10 concurrent tasks private readonly BlockingCollection<TaskInfo> _taskQueue = new BlockingCollection<TaskInfo>(); // Task information with dynamic priority public class TaskInfo { public Task Task { get; set; } public CancellationTokenSource CancellationTokenSource { get; set; } public int Priority { get; set; } // Higher value = higher priority } public async Task ProcessTasksAsync() { while (true) { var taskInfo = _taskQueue.Take(); // Blocks until a task is available await _concurrencySemaphore.WaitAsync(); try

Why is this lemma not automatically proved in dafny? How to prove it by hand?

29 April 2025 @ 7:48 pm

In simple words: If A and B are equivalent multisets, then elements not in A are not in B as well. lemma ElementExclusionLemma<T>(seqa: seq<T>, seqb: seq<T>, x: T) ensures multiset(seqa) == multiset(seqb) ==> (x !in seqa ==> x !in seqb) { } Verifier: a postcondition could not be proved on this return path.

Why cannot we use projections that produce non-movable values with constrained algorithms?

29 April 2025 @ 6:48 pm

Consider the following minimal example: #include <algorithm> struct nm { int val; nm(int val) : val(val) {} nm(nm&&) = delete; friend auto operator<=>(const nm&, const nm&) = default; }; int main() { int arr[] = { 1, 2, 3 }; std::ranges::sort(arr, {}, [](int x) { return nm{ x }; }); } This code won't compile (according to the standard) because the std::sortable constraint of std::ranges::sort is not satisfied. This is because std::sortable requires std::projected, which requires std::indirectly_regular_unary_invocable, which in turn requires std::common_reference_with, which indirectly (after a few more steps) requires std::is_convertible<nm, nm>, which is false, because the type nm is not movable. My quest