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.

Parsing '@' character in 7 bit pdu

4 May 2026 @ 12:32 pm

Good afternoon everyone. I'm writing an SMS message parser. Everything works fine, except for one thing. In some cases, the '@' character is parsed as 0x00 instead of 0x40. I tried several code samples, and they all returned the same results. The online PDU parser, however, assembles the packet correctly. Here's the code I'm using: for (i = 0; i < length; i++) { int byte_idx = i * 7 / 8; int bit_idx = i * 7 % 8; offset--; uint16_t ch = xCurrentSms.cText[offset + byte_idx] >> bit_idx; if (bit_idx > 0) { ch |= (uint16_t)xCurrentSms.cText[offset + byte_idx + 1] << (8 - bit_idx); } xCurrentSms.cText[b++] = (uint8_t)(ch & 0x7F); I get the following sequence: F0 7B 2F 26 9B D1 6A B6 78 94 05 9F F7 00 A6 DD 2F D4 7A E9 76 After conversion, the result should be pw=123456qQ,ps=@&;?!-/:; however, a null appears in place of '@'. Although if you count, '@' is located in the array

White-labeling with CloudFront — alternatives to adding multiple root domains as alternate domain names?

4 May 2026 @ 12:31 pm

I have a CloudFront distribution serving a React app from S3 with an alternate domain app.mycompany.com and an ACM certificate attached. This works fine. I want to implement white-labeling — allowing clients to use their own custom domains (e.g. app.clientdomain.com) to point to the same CloudFront distribution and serve the same app. Problem I already know CloudFront does not allow adding domains from different root domains to the same distribution. When I try, I get: Domain must share the root domain mycompany.com Current setup CloudFront + S3 serving a single-page React app ACM certificate in us-east-1 DNS managed via a third-party provider (DNS only, no proxy) Clients will have their own domains on various DNS providers

FamilyActivitySelection token stability — are stored tokens long-term reliable?

4 May 2026 @ 12:28 pm

We came across reports on Medium and Apple Developer Forums suggesting that ApplicationToken and ActivityCategoryToken values issued by the FamilyControls framework are not guaranteed to be stable, that iOS may silently re-issue new tokens for the same apps after OS or app updates, making any previously stored tokens invalid. We are storing FamilyActivitySelection tokens encoded via JSONEncoder to a backend for long-term use, and relying on them inside a DeviceActivityMonitorExtension to restore and apply shields when a schedule fires. What we're trying to understand is: is this token instability still an active problem in iOS 16/17/18/26, and when a token does become invalid, does JSONDecoder actually throw a DecodingError giving us a clear signal, or does it decode successfully and ManagedSettingsStore just silently ignore the stale tokens with no error at all? On Medium, We Found That The Token Mutation Problem One of the more painful bugs in real produ

Creating an Android app that makes a phone work like a gamepad using ADB

4 May 2026 @ 12:22 pm

I need your help. I have an Android TV Box that I use in a retrogaming setup. At the moment, I don't have a gamepad, so I'm going to buy it. In the meantime, I learned searching on Google that there's a method to send mouse and keyboard input to Android TV with ADB debugging; so I thought "Can I create an app with a gamepad interface that sends signals that can be associated with game controls (e.g., circle, square, L1, R1, etc.)?" So I made some drafts for an Android app and I noticed that the analog joysticks don't work. Searching on the web didn't help. Is there a way to implement an analog joystick with axes?

How to make sure a macro is run in the correct workbook

4 May 2026 @ 12:19 pm

I have multiple VBA-wise identical workbooks that contain different sets of data. I have a macro that enables me to switch between worksheets within a workbook using a keyboard shortcut (Ctrl + tab, Ctrl + shift + tab) similarly to a web browser. All works well when I only have one workbook open. However, if I open (and close) more than one workbook, things get messed up. The macro still works as it should, but another workbook is opened if I've had one open (and already closed it). What makes this more complicated to understand without much knowledge about VBA is the fact that the script always works, i.e. it switches the tab in the right workbook, but the other file is opened before the tab is changed. For example: Open file A Open file B Close file B Run the macro in file A --> File B opens up --> The tab is changed in file A (as it should) If both files are open, the macro works as it should. The problem only occurs w

Register an HKCU key with CustomAction in a Visual Setup Project?

4 May 2026 @ 12:17 pm

In my solution.slnx file, I have the following C# code projects: - A simple VSTO .NET Framework 4.8.1 project. (Currently, it's working well.) - A simple ExcelDna project that adds some extension utility functions, such as SumByStyle, to Excel. It has built 32-bit and 64-bit package.xll files, and I've ensured these files are moved to the correct path that Excel can read, and they all work correctly (if I add them manually in Excel). - An Installer-SetupProject project (Microsoft Visual Studio Installer Projects 2022, latest version 3.0.0) to package them. To dynamically write to the Registry for AutoLoad xll in Excel, without requiring any additional user action after installation (using VSTO and ExcelDna), I added a C# ClassLibrary project. I implemented code inherited from Installer and overridden bot

Which Android 'background work' feature to use for sending information?

4 May 2026 @ 12:12 pm

I am currently developing an Android application with Kotlin and Jetpack Compose that should repeatedly (~once per minute) collect some information about my phone (battery, temperature, current network connection status) and upload that, when online, to a server. This should, of course, happen independently of whether or not the screen is on, and, ideally, persist between device restarts and OOM-killings. Android offers mutiple ways to 'do things in the background', of which I have, so far, come across WorkManager with a PeriodicWorkRequest (runs at most once per 15min) JobScheduler with JobInfo.setPeriodic a background Service (subject to system limitations) AlarmManager (here, 'the background' just means the screen needn't turn on and the app needn't open, i.e. WorkManager is still an option) I do not care about battery consumption or backwards compatibility (with version below Andr

Spring Boot JWT authentication returns 403 Forbidden despite valid token

4 May 2026 @ 11:59 am

I am working on a Spring Boot application with JWT authentication and React front-end. I implemented authentication using Spring Security and JWT. The login works correctly and I receive a valid token, however when I try to access protected endpoints I get a 403 Forbidden error. Here is my situation: User logs in successfully JWT token is generated and sent to frontend Token is included in Authorization header (Bearer token) But accessing protected routes returns 403 Example request: Authorization: Bearer \<my_token\> Security config (simplified): JWT filter added Authentication manager configured Roles: USER, ADMIN Expected behavior: Access should be granted with a valid token. Actual behavior: 403 Forbidden What could be causing thi

Why are certain sorting algorithms faster and better at certain things?

4 May 2026 @ 11:41 am

I know that there are many different types of sorting algorithms. But how do I know what algorithms do better jobs at certain questions and which ones take longer to run but are better at other things? Can someone tell me what sorting types are the best and which are not so good?

Auto incrementing a value [closed]

4 May 2026 @ 11:07 am

How to auto increment a value in SQL database every 30 days? I want to create a system that automatically add monthly bill to current balance every 30 days/month.