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.

How can I structure Redux Toolkit so that write/update reducers are loaded only in my widget configuration app but excluded from the embed runtime?

27 March 2026 @ 9:41 am

Context - My company runs a platform where users configure embeddable widgets on our website - I am in the process of migrating it to Redux Toolkit - In the configurator, slices (1 per widget) need many reducers that update state (for example, setX actions for background color or border radius, widget specific logic). There are hundreds of these settings in the entire app - In the embedded version, state is server-provided/read-only so those setter reducers are unnecessary - I want to reduce bundle size and avoid shipping editor-only reducers to the embed runtime - I want the same Redux store to drive both versions - User can embed up to 3 widgets (out of N available) on one page with a single `<script>` tag which would be rendered into shadow DOM - Due to the way legacy systems are configured RTK Query is not an option so async logic will be done in thunks - The app is written in React/Typescript

sp_send_dbmail runs into "Failed to initialize sqlcmd library with error number -2147417850. "

27 March 2026 @ 9:39 am

I was tasked with debugging a legacy system issue at work. A lot of our stored procedures send emails via sp_send_dbmail using the @query parameter to attach data. However, in our Production environment, as soon as that parameter is filled with anything other than NULL or an empty string—even a benign 'SELECT 1;' or '--Test'—the email fails to queue, and SSMS immediately throws this error: Failed to initialize sqlcmd library with error number -2147417850. The Context & Constraints: Both Test and Prod are running the exact same version of SQL Server 2022 (CU22). The script works perfectly in Test, but fails in Prod. There are absolutely no entries written into msdb.dbo.sysmail_allitems when this error occurs. The procedure aborts entirely. I know the modern architectural fix is to execute the query

Rascal TypePal Language Server (even after packaging as VSIX) slow startup in VSCode – how to reduce initialization time?

27 March 2026 @ 9:34 am

I’ve built a custom language server using Rascal MPL’s parametric language server (util::LanguageServer) with TypePal for semantic analysis, and packaged it's .rsc dependencies in a jar as a VSCode extension (VSIX). The extension works correctly after installation, but I’m experiencing a noticeable delay on VSCode startup before the language server becomes active. Setup Rascal MPL (using TypePal for type checking) Language server created via util::LanguageServer Packaged .rsc dependencies into java as a VSIX extension Installed locally in VSCode Problem After launching VSCode: There is a delay before the language server initializes What I’ve Observed The delay seems to happen during Rascal runtime initialization and/or loading of modules TypePal analysis works fine once everythin

Custom Field building in Garmin Monkey C

27 March 2026 @ 9:32 am

I am trying to create a custom field in my Garmin App, yet - it doesn't seem to work properly. I verified that the field is being created in runtime - but then it doesn't appear on the activity reports in .fit files. This is my xml file: <resources> <fitContributions> <fitField id="0" displayInActivitySummary="true" sortOrder = "0" precision="0" dataLabel="@Strings.jumps_label" unitLabel="@Strings.jumps_units" /> </fitContributions> </resources> this is my init code: function resumeActivity() { if(_session == null) { _session = ActivityRecording.createSession({ :name => "Skateboarding" }); _customJumpsCounterField = _session.createField( "Jumps", JUMPS_COUNTER_FIELD_ID, FitContributor.DATA_TYPE_UINT32,

NumPy sorting issue

27 March 2026 @ 9:31 am

I've written a code which imports values into Python from a CSV file. I treat the data in various stages and everything works great until I decide to sort it. The original dataset, a reads: a = ['27622000' '21731000' '15969000' '10795000' '6740700' '3914000' '2119400' '1105000' '584200' '293420' '7836700' '4577100' '2502800' '1307700' '662020' '328020' '159110' '76451' '36528' '17000' '1097400' '542300' '264240' '127210' '60799' '28603' '13239' '5932.7' '2546.4' '1035.4' '148800' '70291' '32856' '15083' '6772.4' '2912.1' '1198.4' '465.64' '170.48' '57.957' '23321' '10567' '4669.8' '1980.7' '799.96' '305.02' '108.46' '35.823' '10.317' '2.6763' '4281.1' '1804.6' '727.56' '277.04' '98.374' '31.673' '9.0643' '2.3084' '0.56351' '0.15655' '800.37' '330.07' '119.93' '38.918' '11.377' '2.998' '0.73989' '0.19126' '0.060255' '0.025337' '167.43' '58.87' '18.492' '4.9108' '1.2305' '0.3694' '0.12245' '0.048883' '0.018582' '0.012778' '11.358' '5.6482'

Is it possible to switch productFlavors(stage, prod and qa) dynamically

27 March 2026 @ 9:16 am

I have a requirement to implement an option to switch in between the build variant dynamically, so tried to find the way but no luck.

I want to run google ml kit ocr to read and extract hand written text from an medical form

27 March 2026 @ 9:10 am

Medical Form on which OCR needs to be done This is the form and i want to run the ocr so that it fetchs the hand written text from this form i have made the app via google anti gravity please tell me which offline ocr will work the best. I need the exact code or file so that i can integrate it on my app.

PrimeFaces p:commandButton ajax="false" inside a p:confirmDialog not calling action

27 March 2026 @ 9:00 am

I have the requirement to basically use a PrimeFaces p:confirmDialog to ask a simple Yes-No question. The original idea was to use a p:commandButton ajax="true", call an action to update the status and stay on the same page (use a PF @form UI update + display a message to the user): <p:confirmDialog global="true" showEffect="fade" hideEffect="fade" responsive="true" style="max-width: 1000px;"> <p:commandButton value="No" styleClass="ui-button-secondary ui-confirmdialog-no" type="button" /> <p:commandButton value="Yes" ajax="true" action="#{ergebnisTextbausteinStatusBean.finalizeStatus()}" process="@this"

Who defines the preconditions in Design by Contract?

27 March 2026 @ 8:44 am

was studying DbC but I can't figure out who actually defines the preconditions of a transaction contract. I understand that the client must ensure the validity of the preconditions; otherwise, any postcondition generated by the transaction is considered correct by the programmer, even if the program crashes. But is the actual creation of the preconditions done by the programmer, or is it more of a project-based thing, that is, it comes from both (client and supplier)?

Javascript AudioContext play sound like musical instrument

27 March 2026 @ 7:05 am

I can play simple tone using code below. But how can I generate sound like a musical instrument (piano, flute etc...) ? function playTone(freq, duration, delay= 0) { const osc = ctx.createOscillator(); osc.type = "sine"; osc.frequency.value = freq; const gain = ctx.createGain(); gain.gain.setValueAtTime(0.2, ctx.currentTime + delay); osc.connect(gain).connect(ctx.destination); osc.start(ctx.currentTime + delay); osc.stop(ctx.currentTime + delay + duration); }