on-internet

Scratch implementation of ridge regression

I am trying to implement Ridge regression but I feel like I am missing something with the Python operators. Here is my code: import numpy as np x = np.random.rand(10, 2) y = np.random.rand(10, 1) lambda_reg = 0.1 alpha = 0.1 num_iterations = 100000 X_train = np.hstack((np.ones((x.shape[0], 1)), x)) def ridge_regression_gradient_descent(X, y, lambda_reg, alpha, num_iterations): n, p = X.shape B = np.zeros(p) # Gradient descent loop for _ in range(num_iterations): y_pred = X.dot(B).reshape(-1, 1) gradient_B0 = - (1/n) * np.sum(y - y_pred) gradient_B = - (1/n) * (X[:, 1:].T @ (y - y_pred)) + lamb

Join the discussion →

Data API Builder with Azure Static Web Apps

Trying to understand Data API Builder (DAB) and if its right for my use case. Based off a simple address book example, there is a table "Addresses" that would have columns: User (the user of the address book, likely an ID linked from a User table) Name Email Address In a standard web application (front end + back end) to get a list off all addresses belong to the app User, a back end function would take a User ID (de-crypted from the User authentication) and return all address linked to the User. In the DAB example, the front end will be filtering/querying the address table based on the User I

Join the discussion →

Arabic "Majed" voice randomly not showing in SpeechSynthesis (TTS) API

Browsers with the SpeechSynthesis provide Arabic through one voice "Majed" as ar-001 or ar-SA and it usually works on all browsers except ones that use WebKit I noticed. On Webkit based browsers, especially iPhones & iPads, that specific voice doesn't appear randomly sometimes! How can I make sure that an Arabic language can always be present/used? Sample: Here's a codepen where you can try it yourself. For the SAME device, when I go to that page the first time, Majed appears, but it didn't appear a few times later. You can also just open a developer console on any page and put in window.speec

Join the discussion →

In Django REST Framework, why does raising serializers.ValidationError return errors in different format in validate() and create() methods?

I am working on a DRF project and have a serializer like: class SomeSerializer(serializers.Serializer): number_field = serializers.IntegerField(required=False, min_value=25, max_value=100) In my settings.py, I have REST_FRAMEWORK = { other settings.... 'EXCEPTION_HANDLER': 'apps.utils.exceptions.custom_exception_handler', } In the custom exception handler, I handle ValidationError as follows: def custom_exception_handler(exc, context): # Call REST framework's default exception handler first response = exception_handler(exc, context) messages = None code = None detail = None if response is not

Join the discussion →

Using a constructor as parameter to Array.map

I need to map an array of objects to an array of other objects. Here is an example: class A {} class B { constructor(a: A) { // ...do something } } let a_arr: A[] = []; // now I want to create a B[] from the A[] If I use an anonymous function, it compiles without error: let b_arr: B[] = a_arr.map((item) => new B(item)); But that anonymous function seems useless—I suppose we can directly use the constructor: let b_arr: B[] = a_arr.map(B.constructor); Unfortunately, the above line didn't pass compilation: sh$ tsc t.ts t.ts:11:28 - error TS2345: Argument of type 'Function' is not assignable to pa

Join the discussion →

Setting of MainPage equivalent after deprecation

I have a Xamarin Forms app that I am updating to use Maui 9. In my app, there are a couple of places where I need to change the top-level page. I was able to do this by setting the MainPage property of the app. The release notes for Maui 9 say to override CreateWindow to set MainPage at the start of the app, and use Application.Current.Windows[0].Page to get the page, but I can see no other way of setting MainPage... can anyone suggest how I can achieve the equivalent of setting MainPage (other than overriding CreateWindow)?

Join the discussion →

How do I know whether I need to clear security during an international transfer?

On some international-to-international connections, you need to clear security on others you do not. Examples: coming from the US you go through security in London Heathrow, Paris CDG or Doha but not in Frankfurt, Zurich or Tokyo. The basic rule here is: "You need to clear transfer security unless the airport has a waiver for your departure country". But so far I have found no reliable information on what waivers are in place at which airport. Which brings me to my question How do I find out whether I need to pass through transfer security for a specific route or not? Transfer security is a ma

Join the discussion →

finding option id of single select field in github projects by using `gh` cli

I want to update a single select field by using gh command. However, the problem is to find single-select-option-id gh project item-edit --id $id \ --single-select-option-id <option-id> \ --field-id $field_id \ --project-id $project_id variable source result $id gh project item-list ✔️ $field_id gh project field-list ✔️ <option-id> ❓ ✖️ I couldn't manage to fetch the id of this single select field. Is there a solution for this?

Join the discussion →

How to pass the "xsl:initial-template" in Altova XMLSpy 2024

I want to process JSON by XSLT 3.0. I am using Altova XMLSpy 2024. I can't seem to find how to initiate the processing without at least one dummy XML file and a <xsl:template match="/">. Where do I pass the name of my initial template in XMLSpy? And how can I make a <xsl:template name="xsl:initial-template"> picked up by the processor inside XMLSpy without requiring a dummy XML input file? @MartinHonnen was so kind as to provide an answer to an earlier question of mine which included a template <xsl:template match="/" name="xsl:initial-template"> but I could not get it to work in XMLSpy withou

Join the discussion →

VSCode under Windows keeps popping up a terminal window asking to update WSL even though I uninstalled the WSL extension

I'm using Windows 11 24H2. I installed VSCode on it before I upgraded from Win 10. The VSCode version is 1.93.1. I used to have the WSL extension in VSCode, but I uninstalled it. Still, every time I start VSCode, it keeps popping up a terminal window asking me to "update" WSL. Even though, WSL itself is also no longer installed on my PC (anymore). This is what I see in the pop-up: Windows Subsystem for Linux must be updated to the latest version to proceed. You can update by running 'wsl.exe --update'. For more information please visit https://aka.ms/wslinstall Press any key to install Windows

Join the discussion →

apollo-client-maven-plugin: How to flatten fragments in generated models

I'm using the apollo-client-maven-plugin version 7.1.0, and I'm trying to flatten fragments in my response models, but I'm encountering an issue where the fragments are wrapped in a nested object. Here’s the GraphQL query I’m using: fragment AuthenticationFragment on SessionInfo { role sessionGUID token } mutation loginAsGuest { login( lang: { key: "FRA" } ) { ...AuthenticationFragment } } The expected response (from a GraphQL client like Postman) is: { "data": { "login": { "role": "XXX", "sessionGUID": "XXX", "token": "XXXX" } } } However, when using the Apollo Java Client, the response looks

Join the discussion →

Specifying $and logic in a CASL rule

I understand from the CASL docs that logic operators like $and, $or etc. have not been implemented in CASL for mongoose $or can easily be specified by separate can rules with the same action and subject But I don't understand quite how to implement $and. The docs only mention that combination of cannot rules allows to mimic $not and $and operators. Moreover as we discussed in this guide, all properties inside conditions object are checked by AND logic, this is another way to mimic $and operator What exactly does that mean? I have actually no idea how to implement a rule like this correctly: ca

Join the discussion →

Tbb based row sum of an armadillo matrix

Following the tbb example for parallel_reduce here with a basic datatypes, I wanted to try and implement a tbb version of a row sum of an Armadillo matrix. (I realize the use of arma::sum for this purpose, but this was an attempt at getting to know tbb, Armadillo and how they work together a bit better. ) The following code was aimed to loop over columns of a matrix X, and add the column values to a running total vector. It compiles fine but crashes at run time. I am wondering where I am going wrong. Is the X.col(j) use is incorrect? Thank you! arma::vec parallelRowsumTBB_withArma(arma::mat X)

Join the discussion →

How to Generate PDF Thumbnails for Frontend Display in a Next.js + Sanity Application?

I am building an application using Next.js and Sanity, where users can upload PDFs via Sanity. On the frontend, I want to display these PDFs as thumbnails (just the front page of the PDF is enough). Users should be able to click on the thumbnail to either view the full PDF in a viewer or download it. I’ve successfully set up the Sanity backend for uploading and retrieving PDFs. However, I’m struggling to find a library or approach that can generate thumbnails from PDFs to display them on the frontend. Requirements: Generate a thumbnail (first page) of the PDF. Display the thumbnail on the fron

Join the discussion →

What kind of visa is necessary for transiting Turkey by land?

Turkey offers a transit e-visa, which is easy to obtain, but only allows the person to stay within the airport. What kind of visa is neccessary for someone, who wants to fly to Istanbul and take a bus to another country (transit by land)? Source: https://turkey-e-visas.com/news/turkey-transit-visa-for-nepalese-citizens/ Passport: Nepal, Residency: Dubai

Join the discussion →

"Open in terminal" hangs in Visual Studio 2022

I'm using latest version of Visual Studio 2022 and when I right click on a solution and click "Open in Terminal" the terminal panel opens but nothing happens, it just stays blank with a blinking cursor but never reaches the command prompt, like this: Any idea about how I can diagnose or fix this?

Join the discussion →

Understanding error messages in Rcpp code with structures and functions

I'm getting a couple of error messages when I run the following code that I do not understand - expected initializer before 'add_f' no matching function for call to 'try_grid::try_grid(Rcpp::NumericMatrix&, Rcpp:: NumericMatrix&, int&) Can someone explain what I am doing incorrectly? cpp file: #include <Rcpp.h> using namespace Rcpp; //Declaring a structure struct try_grid { NumericMatrix x; NumericMatrix y; int size; } // Declaring function Void add_f(const try_grid&); // [[Rcpp::export]] NumericMatrix plussomething(NumericMatrix samp, NumericMatrix tramp, int size) { // Declaring and defining

Join the discussion →

How to Restrict PowerShell SDK to Limit Script Access to Specific Callback Methods in a C# Application?

In my C# application I want to use the PowerShell SDK to allow user-provided PS scripts to interact with limited parts of the application through callbacks. I want to restrict what these scripts can do, ideally allowing only specific methods to be called on a provided callback interface, without giving full access to system resources or sensitive .NET types. Here’s a simplified code example: var iss = InitialSessionState.CreateRestricted(SessionCapabilities.Language); iss.LanguageMode = PSLanguageMode.FullLanguage; // ConstrainedLanguage would inhibit the callbacks // Add specific cmdlets, for

Join the discussion →

GitLab, IntelliJ and MacBook: Incorrect credentials. Request response: Bad credentials

I am trying to connect IntelliJ to a GitLab account on a Macbook. I follow these steps: go to Settings then **GitHub** then + Then filling Server and token For the server field, it's defaulted to github.com and cannot be changed For the token, I use the access token generated in Gitlab But I get the following error: Incorrect credentials. Request response: Bad credentials I also tried to follow the following steps: Settings then **GitLab** then + Then filling Server and token For the server field, I use the <gitlab repo url> For the token, I use the access token generated in GitLab But, again,

Join the discussion →

How much time is recommended between two visits to India on a tourist e-visa?

I am a Norwegian citizen currently in India on a tourist e-visa. My visa lists the following conditions: e-Visa Validity period is 5 Years from the date of issuance of this ETA. Activities Permitted : Recreation/Sight-Seeing Continuous stay in India on each entry should not exceed 90 days. Maximum stay in India in one calendar year on an e-Tourist Visa or paper Tourist Visa or both, shall be restricted to 180 days. Multiple entries will be granted within the e-Visa validity period stamped on your passport. I am approaching a continuous stay of 90 days, so I will soon have to leave India. Howev

Join the discussion →

Flask App Works Locally But Fails to Deploy on Google Cloud Run: "Failed to Start and Listen on the Port"

Problem: I'm trying to deploy a Flask app with a pre-trained machine learning model (stored as a model.pkl file in the same directory) to Google Cloud Run. The container runs perfectly fine locally, but fails when deploying to Cloud Run with the following error: ERROR: (gcloud.run.deploy) Revision 'mymodel-service-00015-svm' is not ready and cannot serve traffic. The user-provided container failed to start and listen on the port defined provided by the PORT=8080 environment variable. Commands I'm Using: Building the Docker image: docker build --no-cache -t gcr.io/dehaproject2024/mymodel:latest

Join the discussion →

Branch.io OG Tags Not Displaying on LinkedIn but Work on Facebook and Slack

Problem Description: I'm encountering an issue with Open Graph (OG) tags not displaying correctly when sharing Branch.io links on LinkedIn. The same links work as expected on Facebook and Slack, showing the appropriate image, title, and description in previews. However, on LinkedIn, the preview shows a generic image instead of the correct OG metadata. Link Details: Here’s a sample link for testing: Link: https://heroicminds.test-app.link/episode/test This link renders correctly on Facebook and Slack, showing the correct image and title. Steps Taken: Used LinkedIn’s Post Inspector to test the l

Join the discussion →

Warning about unsafe for trimming and AOT compatibility if passed across the WinRT ABI (List)

I have a simple .NET 8 (C#) class library that reads some registry values. It was created and built in Visual Sudio 2022 (64 Bit) v17.11.5. Project file: <PropertyGroup> <TargetFramework>net8.0-windows10.0.26100.0</TargetFramework> <ImplicitUsings>disable</ImplicitUsings> <Nullable>enable</Nullable> </PropertyGroup> Methods: public static RegistryKey? GetRegistryKey () => Registry .CurrentUser .OpenSubKey("Software") ?.OpenSubKey("ODBC") ?.OpenSubKey("ODBC.INI") ?.OpenSubKey("ODBC Data Sources"); public static IEnumerable<string> GetDataSources1 () { using var key = DataProviderOdbc.GetRegistr

Join the discussion →

Como adicionar caractere no final do input, enquanto o usuário digita?

O exercício em questão é calcular um desconto de 5% em qualquer produto, dai fiz o código abaixo. preco = float(input('Digite o valor do produto: R$')) desc = preco*0.05 print(f'\nSe o produto custa R${(preco):.2f} depois do desconto de R${(desc):.2f}(5%)' f' o produto custará R${(preco-desc):.2f} Quero fazer um código onde digitaram a porcentagem há ser calculada, porém só consigo deixa o símbolo de % antes da entrada, quero que o símbolo % fique atrás do que é digitado porc = float(input('Digite de quantos porcento é o desconto: %'))

Join the discussion →

How can a bot forward messages to a Telegram group

I need to make a bot that should forward messages sent to him in the group. How can this be done, I have searched a lot of information, nothing helps I tried to forward the group ID, maybe I did something wrong, but when the bot wrote to me that the message had been sent, nothing appeared in the group. (if the bot was an admin in the group and had access to messages)

Join the discussion →

How much knowledge and effort is required to see Northern Lights?

Since I will be heading to Norway next week and there seems to be heightened solar activity recently, I've been reading articles online about seeing the northern lights. I have read at least 20 articles and one of the most common recurring phrase is hunting for northern lights. Numerous articles recommend booking a tour to get a chance at spotting them. Those tours appear quite pricey to me for the few hours that they last. How hard is to for someone who has never seen the northern lights to spot them? In photos, they look like gigantic phenomena and seem like they would be hard to miss! Are t

Join the discussion →

How to institute logging from Poly ResiliencePipeline for success after failure

In C# I'm using Polly Version=8.4.1 and a reusable retry ResiliencePipeline via ResiliencePipelineBuilder. return new ResiliencePipelineBuilder() .AddRetry(new RetryStrategyOptions { MaxRetryAttempts = 5, DelayGenerator = {blah(blah, blah);}, ShouldHandle = args => { blahblah(blah); } }).Build(); I want to be able to add logging for when the operation initially fails but subsequently succeeds. Something like: {operations} recovered after 3 tries, in 22 seconds I believe in older versions of Polly this would be accomplished by injecting handling via the OnSuccess operation. How is this done in

Join the discussion →

Westjet airport lounge access

I've got some WestJet lounge vouchers available on my WestJet rewards account (from my WestJet credit card) and was going to use them to grab dinner before my flight. However I am flying from Calgary to Heathrow, and it seems the Westjet lounge is only available for domestic travellers. Their website lists a bunch of other lounges, saying this: Platinum, Gold and Silver WestJet Rewards members may be eligible for complimentary lounge access based on their tier benefits and each lounges entry requirement. See individual lounge access below. Guests seated in Business on our Boeing 787-9 Dreamlin

Join the discussion →

Prevent optimization of arithmetic computation

I need to implement this paper Page 5, there is a function void Split(double a, double *x, double *y) { double z = a * ((1 << r) + 1); *x = z - (z - a); *y = a - *x; } With -O3 (which I need for the rest of the program, gcc sees that z - (z - a) can be simplified to a (but only when function is inlined) : Split(double, double*, double*): movsd .LC0(%rip), %xmm1 mulsd %xmm0, %xmm1 movapd %xmm1, %xmm2 subsd %xmm0, %xmm2 subsd %xmm2, %xmm1 subsd %xmm1, %xmm0 movsd %xmm1, (%rdi) movsd %xmm0, (%rsi) ret .LC3: .string "%lf -- %lf\n" main: subq $8, %rsp movl $.LC3, %edi movl $2, %eax movsd .LC1(%rip)

Join the discussion →

renovate rebase and merge automatically approved PRs

My team and I need want renovate to be able to automatically rebase et merge PRs, once it has been approved by us. I found some documentation on how to automatically approve PRs and merge but I cannot find something about rebasing and merging only the ones that are approved, without rebasing the ones that are not. Any help ? Thanks

Join the discussion →
Older stories