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.

Advice on how to approach small-scale restaurant reservation system

3 March 2026 @ 10:06 pm

First Year CS Student here I work for a small seafood restaurant business while learning CS on the side and I was thinking about developing a reservation system for them instead of getting them to subscribe to one (plus makes a good side project) I was thinking about developing a full stack project, however the computer that has the POS system installed cannot access the internet (it does have Chrome installed tho) so I am trying to figure out the best way to deploy this locally One option I’m considering is building the app as a simple HTML/JavaScript page and running it locally in Chrome. I could move the file between computers using a USB drive store the reservation data using localStorage. Would this approach make sense, or is there a better way to handle this? Would appreciate the advice, just looking for some guidance :)

Unable to call private method for System.Security.Cryptography.X509Certificates.SubjectAlternativeNameBuilder

3 March 2026 @ 9:51 pm

SubjectAlternativeNameBuilder doesn't provide a method to add Registered Id attribute so, I'm trying to use reflection to achieve my goal: var assembly = typeof(SubjectAlternativeNameBuilder).Assembly; var generalNameAsnType = assembly.GetType("System.Security.Cryptography.Asn1.GeneralNameAsn"); var generalNameAsn = Activator.CreateInstance(generalNameAsnType); generalNameAsnType.GetField("RegisteredId", BindingFlags.Instance | BindingFlags.NonPublic) .SetValue(generalNameAsn, "1.3.6.1.4.1.311.20.2.3"); var methodInfo = typeof(SubjectAlternativeNameBuilder).GetMethod("AddGeneralName"); var san = new SubjectAlternativeNameBuilder(); methodInfo.Invoke(san, \[generalNameAsn\]); But I'm getting NullReferenceException at the last line. And for some reason I can't debug into methodInfo.Invoke. If I try I see the following

How can i make my telegram bot get into Groups

3 March 2026 @ 9:48 pm

I'm building a Telegram bot using python-telegram-bot (v20+) that needs to: Join or be added to multiple Telegram groups focused on cybersecurity (threat intel, hacking tutorials, CVE discussions, etc. Monitor all incoming messages in those groups and detect: URLs / links Video files or media attachments Plain message text containing cybersecurity-related keywords Save all detected content to a database or structured file (preferably SQLite or a CSV log) for later review

Java.awt and itext.FontFactory font refactoring: What's the best way to refactor a large code base to a new font?

3 March 2026 @ 9:25 pm

I am working with a large legacy application. Throughout the application, there are calls to generate PDFs with iText, or to generate text headers for charts etc. which utilize java.awt.Font to load the proper font. Previously this was always run on Windows servers, but now we're putting the application on Linux servers, and ideally it would look the same regardless of the operating system. I've selected a series of replacement fonts that we can use on both operating systems, but I'm a bit stumped on the best way to implement this "refactoring". For iText, I'm fine just manually updating them by hand, since there are fewer places it's used. Unfortunately the java.awt.Font issue is messier to resolve because it's all over the place. My plan originally, was that I was hoping I could add the fonts to the java.awt at runtime (which I have done successfully already), and then reassociate the old font family names to the new

Trying to stop code that calls getUi() on a mobile device [duplicate]

3 March 2026 @ 9:24 pm

I'm trying to prevent code that calls SpreadsheetApp.getUi() when my spreadsheet is accessed on a mobile device. I'm getting timeout errors, as I think getUi() is still being called and the following .alert() is likely causing the timeout error. Did I make a mistake, or is no error being raised on a mobile device when getUi() is called? Variable message has already been declared with var message earlier in the code . try { if (editedCell == 'F2') { ss.uncheck(); message = SpreadsheetApp.getUi(); message.alert('Enter the number of players in cell D2, up to 8.\nThen enter the player names starting in cell B1, then C1, up to I1.\nMake sure that at least one player cell background is cyan, \nThis colour is meant to be a visual reminder of whose deal it is.\nEnter the score of each player below each player name, starting in row 4.\nThe total of each player will appear in the yell

pattern recognition with times series

3 March 2026 @ 9:00 pm

I am working on a time series analysis project based on 5 years of electricity consumption data from a company (millions of rows stored in CSV files). My goal is to detect the most recurrent consumption pattern (motif) in this dataset. However, I am facing several challenges: The subsequences may have variable lengths (the pattern duration is not fixed). I need to automatically identify the start and end timestamps of each detected subsequence. The dataset is very large (millions of data points), so scalability is important. What would be the best approach or algorithm to: Detect the most frequent or representative motif? Handle variable-length subsequences? Efficiently determine the start and end indices of each motif occurrence? I am considering similarity-based methods (e.g., DTW) but I am unsure how to efficiently apply them at s

How to use ASLR linker settings when calling third party DLLs?

3 March 2026 @ 6:55 pm

Just spent a couple of frustrating days trying to trace down a problem with my apps, which have worked perfectly for years, but then starting having problems when compiled on a new machine with the latest Delphi compiler. The problem finally was isolated to the linker ASLR settings, which are enabled by default on the new machine, but were turned off on the old machine. The symptoms are random access violations and return errors from functions called in third party DLLs, specifically the National Instruments and FTDI instrument drivers, but others as well. What function are these settings trying to address, and why are they enabled by default if they are incompatible with external DLL calls? I guess they are a security measure, am I using them incorrectly?

How to change vertical alignment of individual items in SwiftUI HStack?

3 March 2026 @ 6:07 pm

I have the following code. struct ContentView: View { @State var textInput: String = "Testing" private let inputCornerRadius: CGFloat = 24 var body: some View { HStack(alignment: .bottom, spacing: 8) { TextField("Chat", text: $textInput, axis: .vertical) .lineLimit(1...9) .textFieldStyle(.plain) Button(action: send) { Image(systemName: "paperplane.fill") .foregroundStyle(.background) .imageScale(.medium) .padding(10) .background( Circle() .fill(Color(.label)) ) } } .padding(.vertical, 8) .padding(.leading, 10) .padding(.trailing, 6) .background( RoundedRectangle(cornerRadius: inputCornerRad

SwiftUI: how to handle side effects when a view's property is updated?

3 March 2026 @ 5:47 pm

I know this piece of code works: let name: String //let's say a view has a property name var body: some View { TextField("Name", text: $name) .onReceive(Just(name)) { value in //use onreceive with Just to get an callback event whenever the name is changed. print(value) } } But I want to know if Apple has a session discussing how to handle this specific scenario. In their Data Essentials with SwiftUI, they only mentioned using @State and @ObservableObject and such. So I don't know if what I am doing is somehow sketchy. Theoretically the view's body is computed every time the name property is updated, and maybe that means the onReceive get recomputed, but since onReceive is not a View, but an extension function on the View itself, I am not sure if the logic applies. If theres a session where Apple discusses t

How to switch over a large number of cases with an extremely skewed distribution in an efficient way?

3 March 2026 @ 5:23 pm

We have a service that when sending messages to us, includes a uint8_t error code. With several hundred possible codes. In our application, we translate this into about 8 categories of errors in an enum class, i.e. enum class error_type { A, B, C, ...}. This is very straightforward to do, some variant of: error_type translate_error_type(uint8_t error_code) { switch(error_code) { case 0: return error_type::A; case 1: return error_type::D; // ... hundreds of more cases to deal with. Unforturnely not a good translation between error_codes and our internal classes over ranges of error_code values to make optimization easy. } } In real data though, about 5 cases almost completely dominate. How would you write this function so a compiler (gcc11 in this specific case) would generate better code than a single huge jump table to optimize for latency i