StackOverflow.com

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

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

Lines disappear when toggling others

6 June 2026 @ 11:47 am

By looking at other scripts and the Pine user manual I managed to get quite far but there is one little bug in can't get rid of. This indicator shows (is the goal) vertical lines on a specific time on both previous days and the following instance of the current day. For previous days I'm using xloc = xloc.bar_index For the upcoming line on the current day I'm using UNIX with xloc = xloc.bar_time The problem is that previous lines disappear when 'Show future Line' is togled on. I thought that using the same variable ShowLine1 as condition for both previous and future lines was the reason but no and I'm now stuck. One other issue with the script (or maybe the cause) is that the script doesn't check whether the UNIX timestamp for the line has already been passed by the live time resulting in both the bar_index and bar_time lines being drawn on top of each other. //@version=6 indic

Increment and decrement bug on stack game [closed]

6 June 2026 @ 11:26 am

I want the current X position is equal to the old x position, but sometimes it's += 2 and -= 2 depending on if you place it while moving left or right Output: -------------------- -------------------- -------------------- -------------------- ----------#--------- ----------##-------- ----------###------- ----------####------ ----------#####----- ----------#####----- 15 0 old = 4 current = 5 real width: 0 old = 9 current = 11 [[9, 5], [11, 5], [9, 4], [11, 3], [9, 2], [11, 1]] Traceback (most recent call last): import msvcrt import os import time map = [] block_loc = [] x = 15 width = 5 i = 10 i_clear = 10 clocks = 0.2 current = -1 old = -2 real_width = 5 LEFT_RIGHT_FLAG = 0 def initialize_map(): for y in range(10): row = [] for x in range(20): row.append("\033[31m-\033[0m") map.append(row) def generate_map():

How to re-arrange / swizzle element pairs in a flat array using numpy?

6 June 2026 @ 11:22 am

I'm working with a continuous, 1-dimensional ndarray of coordinates in the form [x1, y1, z1, x2, y2, z2, ...]. I need to now swap the order from X,Y,Z to X,Z,Y, so that the output array has the form [x1, z1, y1, x2, z2, y2, ...]. Is there simple way using one of numpy's array operations to achieve that, without creating a second array to swizzle the indices? Or is creating a second index array the best way to achieve this?

Android Studio jump to location within file

6 June 2026 @ 11:12 am

In Android Studio when building an app one might get error message such as Launching lib/main.dart on Linux in debug mode... Building Linux application... ERROR: lib/main.dart:20:1: Error: 'crip' isn't a type. ERROR: crip CERAPPPPPPPP ERROR: ^^^^ ERROR: lib/main.dart:20:6: Error: Expected ';' after this. ERROR: crip CERAPPPPPPPP How can one highlight the error message and jump directly to the location in the relevant file? This seems standard IDE technology. It would also be useful for processing the output from the tools 'Dart analyse'

Vercel and supabase, error 500(Website from loveable)

6 June 2026 @ 9:19 am

I’m deploying a TanStack Start (Vite + React 19) project to Vercel, but the production site returns a 500 Internal Server Error. Locally everything works fine, but on Vercel the app crashes immediately on load. Error from Vercel logs: Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'tslib' imported from /var/task/_libs/supabase__auth-js.mjs What I’ve already tried: Installed tslib (npm install tslib) Confirmed tslib is in package.json dependencies Clean reinstall (node_modules + lockfile deleted) Redeployed with cache cleared Verified Supabase environment variables in Vercel: SUPABASE_URL SUPABASE_ANON_KEY VITE_SUPABASE_URL

How to find name matches exact, partial or no match from two list

6 June 2026 @ 7:42 am

I need to match two name lists and identify if the record is found in another list with full, partial or no match and extract the row id for the match. For simplicity, the lists are unique but the substring match could be duplicates. Input tables are dt1 <- data.table(nmlist = c('nm1 ln1','nm2 ln2','nm2 ln3','nm4 ln4')) dt2 <- data.table(chknm = c('nm1 ln1','nm2','ln3','nm5 ln5')) Using dt2 as pivot and matching with dt1, expected output is given below. Index is based on the rowid of dt1 (first occurence of the matching row). Appreciate any reference or suggestion. dtout <- data.table(chknm = c('nm1 ln1','nm2','ln3','nm5 ln5'), match = c('exact','partial','partial','nomatch'), index = c(1,2,3,NA))

Identify Column Clicked in Gtk.Treeview

6 June 2026 @ 5:03 am

I have been trying to the column number / id of the column that is clicked in a Gtk.Treeview (in Python...but that is really irrelevant). I looked at the following sites: https://docs.gtk.org/gtk3/method.TreeView.set_headers_clickable.html GtkTreeView Column Header Click Event https://docs.gtk.org/gtk3/class.TreeViewColumn.html https://docs.gtk.org/gtk3/method.TreeViewColumn.clicked.html and they all seem to indicated that it is only possible to get_sort_column_id(). But I do NOT want to sort, I just want to run some code to identify the column numbe

SQL Basics: Create a FUNCTION (DATES)

5 June 2026 @ 4:07 pm

I'm trying to solve a problem on the platform Codewars: For this challenge you need to create a basic Age Calculator function which calculates the age in years on the age field of the peoples table. The function should be called agecalculator, it needs to take 1 date and calculate the age in years according to the date NOW and must return an integer. You may query the people table while testing but the query must only contain the function on your final submit. people table schema id name age My solution is: CREATE FUNCTION agecalculator(age DATE) RETURNS TABLE(age_in_years INT) AS $$ BEGIN RETURN QUERY SELECT EXTRACT(YEAR FROM JUSTIFY_INTERVAL(NOW() - age))::INT AS age_in_years; END; $$ LANGUAGE plpgsql; But it's wrong. I'm getting one row more than it should be. Test Results: tests should ret

Order of loading classes in PHP

5 June 2026 @ 8:47 am

Please explain the mechanism of loading classes in PHP, and why the first example does not cause an error, but the second does? From documentation: Classes should be defined before instantiation (and in some cases this is a requirement). Under what conditions is this requirement mandatory? Example 1: namespace { echo (new \Foo\Bar)->someattr; echo (new Egg)->someattr; exit(0); class Egg { public $someattr = 2; } } namespace Foo { class Bar { public $someattr = 1; } } /* 1 2 */ Example 2: namespace { echo (new \Foo\Bar)->someattr . PHP_EOL; echo (new Egg)->someattr . PHP_EOL; exit(0); class Egg extends \Foo\Bar { public $someattr = 2; } } namespace Foo { class Bar { public $someattr = 1; } } /

CMD title issues

4 June 2026 @ 5:13 am

I'm developing a little C++ key bind application. One of the key binds I'm adding is Ctrl+Alt+E. What I want it to do is find if I have a focused CMD window and get the current working directory (CWD) and open a file explorer in that directory. With this function: static std::string GetConsoleCwd() { HWND fw = GetForegroundWindow(); if (!fw) return ""; char cls[64]{}; GetClassNameA(fw, cls, sizeof(cls)); if (strcmp(cls, "ConsoleWindowClass") != 0 && strcmp(cls, "CASCADIA_HOSTING_WINDOW_CLASS") != 0) return ""; char title[MAX_PATH]{}; GetWindowTextA(fw, title, sizeof(title)); if (!title[0]) return ""; std::string t(title); // Try to find any substring that looks like a valid path // Look for "X:\" pattern (drive letter + colon + backslash) siz