on-internet

How can I get a USB HID device to enumerate as a xinputhid.sys compatible device?

I'm trying to get an ESP32-S3 TinyUSB device to show up as an XInput compatible device on Windows. There appears to be three ways to do this: XUSB, XInputHID & GIP, with a recommendation to use XInputHID, which also seems the easiest. The XInputHID Documentation.docx gives a listing of HID descriptors to use, but those by themselves will not cause Windows to load xinputhid.sys. The document also mentioned a compatibility ID “HID_DEVICE_SYSTEM_GAME” that should be given through a Microsoft OS Descriptor, but I cannot seem to get that to work. Firstly, I cannot find any reference, other than a v

Join the discussion →

Custom eslint rule ideas

I planned to write a custom eslint rule for eslint 9, focusing on performance optimizations and suggestions. The custom I've already built: no-sequential-await Can anyone suggest me some legit ideas, I'm looking for idea that is not a predefined rule in eslint.

Join the discussion →

Array FILTER/TRANSFORM lambda using index

Snowflake supports higher order functions like FILTER or TRANSFORM. A lambda expression that defines the filter condition on each array element. The lambda expression must have only one argument specified in the following syntax: <arg> [ <datatype> ] -> <expr> This type of functions may be also known as array_filter/list_filter, array_map, array_transform, apply, etc. Example: SELECT FILTER([10,20,30,40], x -> x > 20); -- [30, 40] My scenario requires to operate on element's index of the array, like choosing every second element. Pseudocode below: SELECT FILTER([10,20,30,40], (x, i) -> i % 2 =

Join the discussion →

Moving from C, how can I implement a doubly linked list in C++ using C++ features?

I'm moving from C to C++ and I'm trying to avoid using C practices in C++. It is said that raw pointers are a C feature, and that in C++ I should use smart pointers instead, yet every example I have seen online for implementing a doubly-linked list starts something like this: class DoublyLinkedList { struct Node { int data; Node* prev; Node* next; }; Node* head; Node* tail; ... }; I struggle to find an elegant way to implement this with smart pointers. I could implement it using shared pointers, but I heard that these should be seldom used and that I should attempt implementing using unique_pt

Join the discussion →

Can the Mac file-picker filter by the whole file name? [duplicate]

I know you can set the Info.plist to match files by extension, MIME type, or UTI. Is there a way to add custom matching, like adding a filter function that looks at the entire name? Edit: This query was flagged as a duplicate. I can't reword the question because these queries aren't the same at all. The other query is about how to select a folder/directory; this one is about filtering by criteria not already given by Apple. For me, the criterion is exact filename, which applies to both regular files and directories. (As examples: "maildir" for a directory, and "mbox" for a regular file.)

Join the discussion →

Adding multiple function plots to a single figure with subplots in MATLAB

I've been trying to run a function three times that plots 2 subplots (6 plots total) onto one single figure. So I've got a function that reads in a dataset and a manipulator, then manipulates it in 2 different ways, then plots in 2 subplots - the function works as it should, I just can't seem to merge the plots when I'm running it in a separate script. Simplified function below: function function_plot(dataset,manipulator) %Manipulates Data figure; subplot(1,2,2); imagesc(data_manipulated1); subplot(1,2,1); imagesc(data_manipulated2); end Simplified script below: function_plot('data.mat',manipu

Join the discussion →

How to work with discriminatedUnion and zodEffects effectively?

I have this zod schema with a discriminatedUnion: const mySchema = baseTypeSchema.extend({ id: z.string(), name: z.string(), specificData: z.discriminatedUnion("type", [specificDataA, specificDataB] as const) }); In addition, I have specific zodObject, such as the one below: const specificDataA = z.object({ type: z.literal("typeA"), isSomeDataRequired: z.boolean(), someData: z.string().optional() }); The issue is that I want to refine specificDataA, like this: const specificDataA = z .object({ type: z.literal("typeA"), isSomeDataRequired: z.boolean(), someData: z.string().optional() }) .refine

Join the discussion →

Laravel Vue Inertia delete confirm returning modal with "1" value

I am having trouble with the delete function for my table items. It keeps returning a modal with a value of 1. I have tried many possible solutions found online, but the issue persists. Controller: public function destroy($id) { $articleCategories = ArticleCategory::findOrFail($id); $articleCategories->delete(); return redirect()->route('article_categories')->with('message', 'Article category deleted successfully.'); } Vue: <script> import Title from "../Layouts/Components/Title.vue"; import PaginationLinks from "../../components/PaginationLinks.vue"; import TableEditButton from "../../compone

Join the discussion →

How to implement email verification using Express JS with React native expo?

I am planning to build a project using an Express JS REST API with React native. I am wondering how email verification is usually handled with this kind of stack. A flow is: User registers with credentials Create a user in the database with an active field set to false The user is sent an email to verify their account (Maybe a code to enter in the app?) If verified set active field to true I am wondering if they are any external libraries to use or whether to create a custom email server to send these emails.

Join the discussion →

Is there a char* type in the LLVM C++ API

I want to make a function starting with a function prototype as usual in the LLVM C++ API and I want one of the accepted arguments of the function to be a char*. Can someone guide me on how I can do that? Thanks! Note: I just want to know if there is a Type::char* or something like that but if not, whats the equivalent.

Join the discussion →

Frappe ERPNext: Custom grand total in Sales Invoice not decreasing on child table row deletions

I'm customizing a Sales Invoice in Frappe/ERPNext to calculate a discounted grand total (15% off qty * rate per item). The total updates correctly on add/edit but doesn't decrease when deleting rows from the 'items' child table. What I've tried: Client-side JS: Triggers on qty, rate, items_add, items_remove, refresh, onload, after_save. Recalculates and refreshes fields. Added a custom "Recalculate & Save" button. Server-side Python: Hook on before_save/before_submit to recalc and persist via frappe.db.set_value. Added debug frappe.msgprint. Custom fields: custom_g_total (Currency, in Sales In

Join the discussion →

Parse Issue (Xcode): Module 'mobile_scanner' not found

I am using the mobile_scanner package in my Flutter project for barcode/QR code scanning. Here is how and where I use it in the code: 1. pubspec.yaml dependencies: flutter: sdk: flutter mobile_scanner: ^3.5.1 # (example version) 2. Usage in my Dart code I import the package normally: import 'package:mobile_scanner/mobile_scanner.dart'; I use it inside a widget, for example: class ScanPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( body: MobileScanner( onDetect: (capture) { final List<Barcode> barcodes = capture.barcodes; for (final barcode in barc

Join the discussion →

Spectral method ODE solver is stable in MATLAB but blows up in R

I am using a spectral method to solve an ordinary differential equation. The following R code and MATLAB code are completely equivalent, but the R code blows up (the values of u that it computes become very large), while the MATLAB code solves for u stably. I suspect this is because numerical computation in R is less stable than in MATLAB. I would appreciate it if someone could analyze the situation in more detail. # R (The result would explode) library(pracma) f<- function(x){ return(exp(x)*(x^2+ 4*x+1)+ exp(5*x)*(x^2-1)^5) } Cheb<- function(N){ #D_cheb of size N+1, corresponding to N sub-int

Join the discussion →

How to set the Elevenlabs webhook type programmatically?

I am using ElevenLabs for transcribing audio (speech to text), and want to create a webhook which will be triggered once audio transcription is complete. I found that you must specify the webhook type into Edit Endpoint into the dashboard in order to make it work. Webhooks My question is that I couldn't do it using the JavaScript SDK and I didn't find the option on the API reference. import { ElevenLabsClient } from "@elevenlabs/elevenlabs-js"; const { webhookId, webhookSecret } = await elevenlabs.webhooks.create({ settings: { authType: "hmac", name: "test-webhook", webhookUrl: "https://www.ex

Join the discussion →

WooCommerce How to Display Stripe Based on PostCode

In WordPress 6.9 version and WooCommerce version 10.3.6, I want to display the Stripe based on the shipping zone. Shipping zone 1 consists of Post code 3000 Shipping zone 2 consists of Post code 4000. ex: Post Code 3000 should display Stripe. Post Code 4000 or any other postcodes should hide Stripe. Currently, I am using woocommerce_available_payment_gateways webhook to display. add_filter('woocommerce_available_payment_gateways', 'payment_gateways_based_on_chosen_shipping_method'); function payment_gateways_based_on_chosen_shipping_method($available_gateways) { $shouldReturnAll = true; if( is

Join the discussion →

Rule exceptions for specific libraries

I am applying Pyright to my project. I want to fix issues however, on specific imports I want to ignore some rules. File or line level rule exceptions are problematic for me. Line level: from mockito import ANY, mock, unstub, when ... when(bob).get_fruit("Apple").thenReturn("Apple") # pyright: ignore[reportUnknownMemberType] I can keep the rule exception on specific situations but I need to repeat that for each line. File level: # pyright: reportUnknownMemberType=false from mockito import ANY, mock, unstub, when ... when(bob).get_fruit("Apple").thenReturn("Apple") Now I don't need to repeat bu

Join the discussion →

Pyright - rules exceptions for specific libraries?

I am currently doing some efforts on applying Pyright throughout my project. Most of the time I want to fix the issues instead of ignoring them, however, in some situations (mainly on specific imports) I always want to ignore some rules. I know that you can have file level or line level rules exceptions but both are problematic for me. For line level, like: from mockito import ANY, mock, unstub, when ... when(bob).get_fruit("Apple").thenReturn("Apple") # pyright: ignore[reportUnknownMemberType] I like that since I can keep the rule exception on specific situations but the issue is that I will

Join the discussion →

Keras: only display NN-architecture without model memory allocation

My goal is to use Keras to visualise the architecture of the model. No training, no inference. For example if I just want to visualise the graph of the network of the classic VGG16-model with model = create_vgg_like_model() then Keras starts to pre-allocate the memory needed and the program crash (see image). PC specs: CPU with 4 cores, 8GB RAM. Due to the "huge" amount of parameters of the model it uses even the swap partition. I tried to play around with cpu_devices = tf.config.list_physical_devices('CPU') if cpu_devices: try: # avoid allocating all memory on the device tf.config.set_visible

Join the discussion →

How to localise the text of a type="submit" button without changing the value it sends to the server?

I am building a multi-lingual website and want to localise the captions shown on buttons in a form. document.querySelector('form').addEventListener('submit', ev => { ev.preventDefault(); console.log('submitted: %o', Object.fromEntries(new FormData(ev.target, ev.submitter).entries())); }); <form action="check.php" method="post"> <input type="submit" name="action" value="Enter"/> <input type="submit" name="action" value="Cancel"/> </form> When I change the @value, that value is also received on the server. I would like to keep processing of the form simpler by handling only the default language

Join the discussion →

How to connect WhatsApp node and webhook URL (error callback URL not validated)

So this thing has been breaking my head for almost a day. How do I connect my n8n WhatsApp on message trigger node to the Meta developer panel? Because when I copy the webhook URL and paste it in meta, it says call back URL error when setting a random verify token: Meta dev panel error image How do I make this connection work? I asked ChatGPT, and it never helped. I would appreciate if someone can throw light in this situation. I would be extremely grateful as I have to submit the project by this week. Here are my WhatsApp node settings: WhatsApp node image

Join the discussion →

Making a case for a defensive infantry wedge formation

Disclaimer: So i'm writing a parody setting of DnD/ASOIF/LOTR so just accept that things might be a bit farcical Background: we have a formation of heavily armoured dismounted knights with cleaver falchions holding a position in a very narrow mountain pass. This pass is maybe 20 metres wide at most. Their opponents are the stereotypical rawhide axe-wielding barbarians. The barbarians are charging down the pass and face first into the knights. No outflanking is possible. For the purposes of this story, i want the knights to be in a quasi-wedge formation ie, formation leader up front, and then b

Join the discussion →

How to generate a simple ARIMA process with statsmodels

I am trying to generate an ARIMA process with statsmodels. I tried already different combinations but nothing works. There is also nothing in the documentation that could solve my problem. The parameters of the ARIMA model should be AR coefficient [0.4], MA coefficient [-0.2] and no differencing. So, the order must be (1, 0, 1). Here is the code from my latest trial: ar_params = np.r_[0.4] ma_params = np.r_[-0.2] order = (len(ar_params), 0, len(ma_params)) model = ARIMA([0], order=order) simdata = model.simulate(nsimulations=2000, params=np.r_[ar_params, ma_params]) I couldn find anything even

Join the discussion →

Understanding Dataset Controls in Delphi While Using SQLite

My Delphi application uses SQLite for its database. My understanding is that the database connection control TFDConnection has a default row count of 50 records. If true, there should only be 50 records displayed in the TDBGrid control on screen at any one time. The next set of 50 (or less) would be shown once you pass the 50th record in the dataset by proceeding to the next or last record. The problem is my application is apparently loading all the database records (currently 148) at one time which exceeds the default record count using select * from tablename. I have tried to setup a "paging

Join the discussion →

In IBKR API, how can I retrieve stock data after a corporate action causing a contract id change?

To retrieve stock data, I always used: Contract contract = new Contract(); //contract instance contract.Symbol = "LRCX”; //ticker here contract.SecType = "STK"; //contract type stock That will point to the LRCX stock. However, IBKR manages the stock data using its unique contract IDs and it assigned a new contract ID to LRCX after its stock split on Oct 3 2024. So that contract instance will only point to LRCX after Oct 3 2024 and shows no such contract exists prior to the date. The current LRCX Conid is 732440574, but pre-split Conid is unknown. When I pull up the chart on IBKR, it shows LRCX

Join the discussion →

set signing date during git commit

git rebase --committer-date-is-author-date --interactive remote/branch preserves (or adjusts) the CommitDate: value. Both CommitDate: and AuthorDate: could also be adjusted with the GIT_COMMITTER_DATE and GIT_AUTHOR_DATE environment variable during git commit-like operations. Is there a way to achieve the same for already signed or to-be-signed commits? git log --show-signature --pretty=fuller shows the time of the git rebase --gpg-sign --committer-date-is-author-date --interactive remote/branch command is used, instead of the "author date".

Join the discussion →

Returning multiple columns and count of duplicates with GROUP BY clause

I'm searching for duplicate values per column and need a count of them and data from some additional columns. Table sample BillNr Name email 1000 Shakira [email protected] 1001 Shakira [email protected] 1002 Shakira [email protected] 2220 Beyonce [email protected] 2221 Beyonce [email protected] 3330 Rihanna [email protected] 3331 RiRi [email protected] 7000 ImNotDbl [email protected] 7777 MeNeither [email protected] 8000 HumptyDumpty [email protected] 9999 NotDblTrbl [email protected] 9999 WhyAreWeAllNotSingle [email protected] This returns the correct result: SELECT Name, email, COUNT(email) FROM table GROUP BY Name, email HAVING COUNT(emai

Join the discussion →
Older stories