Posts

Showing posts from March, 2022

How to write firestore rules with session cookies for authentication

I have used this https://firebase.google.com/docs/auth/admin/manage-cookies to implement session cookies into my next.js application. Having no client user authentication, I assume I have to handle all my firestore calls and permissions inside my server-side api; which begs the question. What use do I have of the firestore rules? Is that just obsolete? I'm asking because I don't see a way to authenticate anything with the rules - seeing as the request.auth will always be null? I'm pretty sure I'm getting something wrong here since on that doc for session cookies I see no mention that that will basically invalidate the .rules, yet I'm struggling to implement them.

How to exclude or hide the subfolder name in the URL when you open a webpage using PHP?

Image
I have a website that has an example URL like localhost/projects/mysite/app/index.php, my objective is to exclude the folder name "app" when I open it, and instead, it shows only localhost/projects/mysite/index.php. What is the best way to exclude or hide the sub-folders and show directly the webpage in the address bar/URL? I tried to remove .php in the URL and it succeed. However, I can't find a way to exclude the folder name. Also, here are the steps I have done so far:

Bad return type in lambda expression when using Java's Optional.or() with subclasses

I am trying to use Optional.or to get an object of subclass A or, if empty, an object of subclass B: interface Node {} class InnerNode implements Node {} class LeafNode implements Node {} Optional<InnerNode> createInnerNode() {} Optional<LeafNode> createLeafNode() {} Optional<Node> node = createInnerNode().or(() -> createLeafNode()); When doing this, I get the following compiler error: Bad return type in lambda expression: Optional<LeafNode> cannot be converted to Optional<? extends InnerNode> If I instead use wildcards to explicitly tell the compiler that the Optionals contain an object extending from Node : Optional<? extends Node> optionalInner = createInnerNode(); Optional<? extends Node> optionalLeaf = createLeafNode(); Optional<Node> node = optionalInner.or(() -> optionalLeaf); I get the following compiler error: Bad return type in lambda expression: Optional<capture of ? extends Node> cannot be converted to ...

Chainlink job is not being called by the Solidity Smart Contract using Operator.sol contract

Image
The job spec deployed and running on Chainlink node is being successfully triggered and completed when called using the Solidity smart contract that is using the Oracle.sol contract. But, since the requirement is to return the large response ( https://docs.chain.link/docs/large-responses/ ), so I have to use Operator.sol contract instead of Oracle.sol . Then, the job is not being called. The deployed Operator contract is looking as: The LINK Token and Owner addresses that I have used to deploy the Operator.sol contract are: The LINK Token address is basically taken from the official Chainlink doc ( https://docs.chain.link/docs/fulfilling-requests/ ) mentioning the Kovan Testnet LINK token address: And the owner address is taken from the Account address of the running Chainlink node: And the Solidity smart contract code is: //SPDX-License-Identifier: MIT pragma solidity ^0.8.7; import "@chainlink/contracts/src/v0.8/ChainlinkClient.sol"; contract GenericLarg...

VB.NET Copying myself and then run the copy fails

I'm trying to make it possible to run my project, copy itself to update.exe and then run that update.exe for the purpose of testing the update routine. The problem I'm having is that the exefile is copied succesfully but when update.exe is then starts, it just always crashes. If I abort the update.exe program from the crash, but my main exe still runs, I can then just start update.exe from explorer and all works fine. I can't for life figure out why update.exe crashes if it is started after it was copied from another exefile. Here's the code: Public Class Updater Public sFullname As String Public sExename As String Public sArguments As String Public Sub New() 'Constructor Me.Initiate() Me.FakeUpdate() Me.DoUpdate() 'MsgBox(Me.sFullname) End Sub Private Sub Initiate() Dim sCmdLine As String = Environment.CommandLine() Dim iPos = sCmdLine.IndexOf("""", 2) ...

How do I assign comma separated values from an Inputbox to variables in VBA?

The code is to assign values in the array created by the inputbox into variables created based on the number of comma-separated values in the array. i.e. if 5 comma-separated values (1,2,3,4,5) are entered in the Inputbox the code create 5 variables input1, input2 etc. and assign values from the input. I have tried the following code and it is returning a "subscript out of range" error at input(v) = u Sub test3() Dim strEntries As String, v As Long, item As Variant, inputArray() As String, u As Variant, input() As String strEntries = Application.InputBox("Enter multiple comma separated values. ", "Entries", Type:=2) If strEntries = "False" Then Exit Sub 'User canceled v = 0 inputArray = Split(strEntries, ",") For Each u In inputArray Debug.Print u For v = LBound(inputArray) To UBound(inputArray) input(v) = u Next v v = v + 1 Debug.Print "count =...

Is there a way for Vim to define keywords defined by regular expressions?

I would like to have Vim treat as keywords strings that match: ( "(" <scope> ")" [:_/] ){0,1} <name> where: <scope> = [@+-.] ( ":" <name> )* <name> = [a-zA-Z][a-zA-Z0-9_]* A regex to describe this definition of a keyword might be something like: \(([@_-.]\(:[a-zA-Z][a-zA-Z0-9_]*\)*)\){0,1}[a-zA-Z][a-zA-Z0-9_]* Some concrete examples: (@:a):f (+:b:c)_v (-)/p n Using Vim's set iskeyword does not appear to be able to handle regular expressions. I've considered expressions such as: let @/ =~ '\<'.expand('<cword>').'\> but <cword> doesn't seem up to this task as well. The use case for this is keying in * to search for words matching the regex that are under the cursor. I've also considered whether \%# might be part of the solution; however, that seems to require splitting the regex into pre- and post-parts. Is there a way for Vim to define keywords with regular ...

How can I scrape the content of a news, based on its title?

Image
I have a Listbox where the titles and news time are scraped from 2 links and printed in the Listbox after clicking on the "View Title" button. This works correctly. All ok! Now I would like to select the newspaper title from the Listbox, click on the "View Content" button, and view the news content in a multiline textbox. So I would like to view the content of the news of the selected title in the textbox below. I specify that the title is the same as the link of the news content . But I have a problem with the function to build this: def content(): if title.select: #click on title-link driver.find_element_by_tag_name("title").click() #Download Content to class for every title content_download =(" ".join([span.text for span in div.select("text mbottom")])) #Print Content in textobox textbox_download.insert(tk.END, content_download) So I imagined that to get this, we would have t...

Spark Query using Inner join instead of full join

can anyone explain the below behaviour in spark sql join. It does not matter whether I am using full_join/full_outer/left/left_outer, the physical plan always shows that Inner join is being used.. q1 = spark.sql("select count(*) from table_t1 t1 full join table_t1 t2 on t1.anchor_page_id = t2.anchor_page_id and t1.item_id = t2.item_id and t1.store_id = t2.store_id where t1.date_id = '20220323' and t2.date_id = '20220324'") q1.explain() == Physical Plan == *(6) HashAggregate(keys=[], functions=[count(1)]) +- Exchange SinglePartition +- *(5) HashAggregate(keys=[], functions=[partial_count(1)]) +- *(5) Project +- *(5) SortMergeJoin [anchor_page_id#1, item_id#2, store_id#5], [anchor_page_id#19, item_id#20, store_id#23], Inner :- *(2) Sort [anchor_page_id#1 ASC NULLS FIRST, item_id#2 ASC NULLS FIRST, store_id#5 ASC NULLS FIRST], false, 0 : +- Exchange hashpartitioning(anchor_page_id#1, item_id#2, store_id#5, 200) ...

The Bag of Marbles Phenomena

QUESTION: I have a bag of marbles with a total volume of 33. There are two kinds of marbles in my bag. Blue marbles that have a volume of 3 and red marbles that have a volume of 6. If I have 8 marbles in the bag, how many blue and red marbles do I have? I have been trying to create a code that tells me how many red and blue marbles there are but I cant seem to solve this. Any Ideas? For this specific problem there should be 5 Blue and 3 Red.

Python automatically login to web-based router portal to check sms

Image
I recently purchased a Huawei mobile router which has a web-based portal, but the portal automatically logs me out when I switch tabs (security feature) but I use the portal for text messages and would like to create a script that I could run when using my laptop, There are three web pages involved in this process Portal Login Page: http://192.168.8.1/html/index.html Portal Home Page: http://192.168.8.1/html/content.html#home Portal Sms Page: http://192.168.8.1/html/content.html#sms So I have managed to get somewhere with a python script. from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.chrome.options import Options from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC import time def login_process(): passwordStr = 'myPassword' browser = webdriver.Chrome() browser.set_window_size(900, 800) browser...

Execute server-side shell script on button click

I am trying to execute a shell script that resides in my server. And I need to get the (string) result of this shell script after execution. However, this script should only be triggered only when a certain button in my ReactJS app is pressed. I spent considerable amount of time looking for answer. So far, all the answers point to an idea of creating a web service then have the app call the service on button click. But none of the answers pointed how exactly this is done nor any of the answers point to any article that discusses this approach. (Sorry if this is a basic approach, but I just learned ReactJS last month from Udemy.) Would you mind creating a simple code that demonstrates communication between the 'shell script web service' and a button (onClick)? Or at least provide an article link that discusses this approach? Thanks for any help. EDIT: What I tried so far is How to execute shell command in Javascript . But comments say that this will not work on browser. I gu...

norm of differences of variables in cvxpy

Image
How can I take the following norm in cvxpy sum(norm(x[i] - x[j], p=2), i=1, j>i, i, j = n) where x is (n, 2) variable matrix defined by x = cp.Variable((n, 2)) . For the problem, I am taking n=16. The following is the code I am trying to completely import numpy as np import cvxpy as cp def solver(pts, var, lmb): objective = cp.Minimize(cp.norm(pts - var, 2) + cp.norm(var, 2)) prob = cp.Problem(objective) prob.solve() print(prob.value) return np.round(var.value, 2) pts = np.array([(-2, 3), (-3, 5), (-1, 4), (-3, 7) , (0, 3), (-2, -2), (-3, 8), (3, 1), (1, -2), (2, 6), (-2, 6), (-2, 5), (-4, 3), (-4, 6), (-3, 10), (2, -3)]) n = pts.shape[0] var = cp.Variable((n, 2)) solver(pts, var, 1)

Is there a way to reduce the amount of loops in this class?

Recently started with Java. I have a class where several methods loop over an Arraylist, I am wondering if there would be a way to reduce the amount of loops as they only do one check really. Some sort of way to implement a function and pass predicate? I discovered Lambdas yesterday, but not sure it would be applicable here. public class Stock { private ArrayList<Products> _productList; public Stock(){} public Boolean addProduct(Products product){ return _productList.contains(product) && _productList.add(product); } public int obtainPos(int code){ for(int i=0; i < _productList.size(); i++) if(_productList.get(i).getCode() == code) return i; return -1; } public void removeProduct(int code){ int pos = obtainPos(code); if(pos >=0) _productList.remove(pos); else System.out.println("Error - Product not found."); } public i...

Clarifying Vault key decryption process

Image
I'm trying to understand Vault workflow w.r.t. keys, e.g.: https://www.vaultproject.io/docs/concepts/seal As I understand, unseal (shared) keys are provided on init they're used to acquire the combined key combined key is then used to decrypt a root (master) key (which is apparently stored in the sealed vault) root key is then used to decrypt the data encryption key (or a keyring which contains it?..) the data encryption key is then used to en/decrypt the data in Vault I get the unseal keys on init, how can I inspect the other keys? Is it impossible / are those keys just stored somewhere internally in Vault? Unsealing is the process of obtaining the plaintext root key necessary to read the decryption key to decrypt the data, allowing access to the Vault. Is the data encryption key / keyring also decrypted during the unseal, or is it... maybe decrypted on each Vault operation (so only the root key is stored somewhere in plaintext after the unseal)? Is it ok that t...

React MSAL not working after page refresh

I am using @azure/msal-react and @azure/msal-browser for authentication in our application. So far i have intialized a msal instance and used it to acquire a token and fetch the alias. Everything works until i do a page refresh i want to understand if this is a cache issue i see data is present in local storage regarding msal but still getting null in active account. here you can see the msal instance with configuration (authProvider) AuthProvider.js import * as APIConstants from "./Common/APIConstants"; import { BrowserCacheLocation, PublicClientApplication, LogLevel } from '@azure/msal-browser'; const loggerCallback = (logLevel, message) => { console.log(message); }; const configuration = { auth: { authority: APIConstants.TENANT, clientId: APIConstants.CLIENT_ID, postLogoutRedirectUri: window.location.origin, redirectUri: window.location.origin, validateAuthority: true, navigateToLoginRequestUrl: true, }, cache: { ca...

Why some fields are missing from google calendar event list in NodeJS google calendar api?

I have successfully integrated NodeJS backend with google calendar. I retrieve all events from google calendar successfully. Issue is following: not all fields are present in resulting event list. For example: some fields from organizer are missing altogether. This is my sample response: { "kind": "calendar#event", "etag": "\"---\"", "id": "---", "status": "confirmed", "htmlLink": "---", "created": "2022-03-28T15:32:53.000Z", "updated": "2022-03-28T15:32:53.093Z", "creator": { "email": "tornike.shavishvili@ngt.ge", "self": true }, "organizer": { "email": "tornike.shavishvili@ngt.ge", "self": true }, "start...

Overlapping bar plot in ggplot2

I'm trying to hide a variable in a stacked bar chart in a dataset. Below is the dataset:

How to send solana via my app in vanilla js?

Trying to do a simple send and receive function in Solana with vanilla JS. Below is my send function that works fine, and now I want a receive function. Where the provider would get Solana transferred from my treasury wallet. I'm not sure what approach I should have, just starting out. Is there a way to just move things around in this function? Or do I have to have a totally different approach? Thanks! async function transferSOL() { // Detecing and storing the phantom wallet of the user (creator in this case) var provider = phantom; // Establishing connection var connection = new web3.Connection( web3.clusterApiUrl('devnet'), ); var transaction = new web3.Transaction().add( web3.SystemProgram.transfer({ fromPubkey: provider.publicKey, toPubkey: treasuryWallet.publicKey, lamports: 0.1 * web3.LAMPORTS_PER_SOL - 100 }), ); // Setting the variables for the transaction transaction.feePayer = await provider.publicKey; let ...

How to overwrite pyspark DataFrame schema without data scan?

This question is related to https://stackoverflow.com/a/37090151/1661491 . Let's assume I have a pyspark DataFrame with certain schema, and I would like to overwrite that schema with a new schema that I know is compatible, I could do: df: DataFrame new_schema = ... df.rdd.toDF(schema=new_schema) Unfortunately this triggers computation as described in the link above. Is there a way to do that at the metadata level, without triggering computation or conversions? Edit, note: the schema can be arbitrarily complicated (nested etc) new schema includes updates to description, nullability and additional metadata (bonus points for updates to the type) I would like to avoid writing a custom query expression generator, unless there's one already built into Spark that can generate query based on the schema/ StructType

how do i parse log data and extract time, profit,position,volume from text file into a dataframes and plot profit vs time volume vs time

03/17/17 10:30:01.511363338 W (leg0)1621573201394718152:TRADE:ins=BSE/GBPINR17JUNEFUT,q=1,p=893900000,pos=0,risk_pos=0,cashflow=-89390.000000,pnl=-18.050891,net_pnl=-18.050891,tgt=893935108.275274,market_volume=16229,bbo=91/893900000 893975000/136, qty_behind=91,realized_pnl=-18.050891,unrealized_pnl=0.00000093711,market_volume=16229,bbo=91/893900000 893975000/136, qty_behind=91,realized_pnl=-18.050891,unrealized_pnl=0.000000 My code: import datetime as dt import pandas as pd import numpy as np import re import matplotlib.pyplot as plt filename='C:\Users\Goog\Downloads\loggg.txt' pp=[] pnl=re.compile(r',pnl=(-?[\d]+.\d{6})\b') vol=re.compile(r'market_volume=(\d{5})') result = [] vol1=[] with open(filename) as n: line=n.readline() while line: result +=re.findall(pnl , line) vol1+=re.findall(vol ,line) line = n.readline() print(result,vol1) I need to parse the data only if :trade happens, note this is only one single line of data in the entire log file. im...

Out of bounds exception on array that has not been initialized to a specific size

C# Coding for unity I have several arrays set as such. public float[] arrayName; no set number of elements anywhere in my code I can access the arrays up to 6 no problems but when I get to 7 I get an out of bounds exception. No where in my code does it initialize them to a specific amount and even when I try public float[] arrayName = new float[8] for instance then run a debug log to get the length I still get 7 and cannot access past 6. I am far from an expert. Here is the thing... I also have a couple texture 2d arrays... public Texture2D[] arrayName; which I was having the same problem with but when I set them like this public Texture2D[] arrayName = new Texture2D[8]; all is fine. I am so confused... I have also tried this. public float[] array name = new float[] {1f, 2f, 3f, 4f ,5f, 6f, 7f, 8f} etc. same result Somehow my arrays are being limited to 7. As I am asking this I am going to try creating new arrays which will be initialized like such public float[] ...

ASP.NET MVC 5 : foreach loop sort and write output in specific order

I have a foreach loop in my view and I need it to write data in specific order id HTML sections. The problem is that i don't want HTML section to be seen if there is no data for that section. int idSection1 = 1; int idSection2 = 2; int idSection3 = 3; @foreach (var item in Model.ItemList) { if (itme.IdSection == idSection1) { <div> <h4>Section 1</h4> foreach (var data in Model.ItemList) { if (data.IdSection == 1) { <p>data</p> } idSection1 = idSection1 + 10; } </div> } if (itme.IdSection == idSection2) { <div> <h4>Section 2</h4> foreach (var data in Model.ItemList) { if (data.IdSection == 2) { <p>data</p> } idSection2 = idS...

What does "replacement" mean in imbalanced learn RandomOverSampler?

I am on imbalanced learn's documentation reading about RandomOverSampler. The documentation says that RandomOverSampler is a Class to perform random over-sampling. Object to over-sample the minority class(es) by picking samples at random with replacement. The bootstrap can be generated in a smoothed manner. What does a replacement mean? Does it randomly duplicates samples from minority/majority class or is it something else?

Integrating report viewer in .NET core 3.1 for SSRS Reports (rdl files) [closed]

I have lot of SSRS reports (rdl) and requirement is to integrate in .NET core MVC 3.1 App using Report Viewer control. I didn't find any good solution. I have checked https://github.com/alanjuden/MvcReportViewer but this looks very old one. Please suggest the best way to integrate report viewer control in .NET Core MVC App.

How to build Swift framework with 3rd party SPM dependencies

Image
I've built swift frameworks before, but I've never dealt with one that has 3rd party dependencies. What I have right now is a Swift framework that has a dependency on several Swift packages. When I build it I see MyFramework.framework in the products folder as well as bunch of dependencies. I can make XCFramework out of it, but when integrating (embedding) it into another app I see an error that MyFramework is missing its dependencies (see image below). What am I doing wrong or missing?

How to remove punctuation and capitalization in my palindrome assignment?

The problem is trying to use strings to prove whether a word or phrase is a palindrome. def is_palindrome(input_string): left = 0 right = len(input_string) - 1 while left < right: if input_string[left] != input_string[right]: return False left += 1 right -= 1 return True This what I attempted to do but when typing in my_palindrome("race car") it was proven false when it is supposed to be proven true. Need help on finding code to add to this to make punctuation and capitalization negligible.

C# / WPF - How should I save user-typed data all at once after a submit button click?

I'm learning WPF/C# via self-teaching and am currently building a small WPF app for practice instead of following tutorials, and so far it's been great; however, I have hit a roadblock that I've spent days on. I have a WPF User Control with multiple TextBoxes where a user can type in a title, ingredients, tools, steps, notes, and add an image of what they made. After all of that is filled in, I would like for them to click a 'Submit' button and have that data saved and able to be accessed at another time. Now for one, I don't know how I should go about doing that, I have seen mention of XML, JSON, SQLite, etc. I did try the XML method like so: private void SubmitButton_Click(object sender, RoutedEventArgs e) { Recipe recipe = new Recipe(); recipe.Title = TitleBox.Text; recipe.Step1 = StepBox1.Text; recipe.Step2 = StepBox2.Text; recipe.Step3 = StepBox3.Text; recipe.Step4 = StepBox4...

Can I write all "append" code in a row using "if"?

how can I in python append by condition, can i write like this? 'Segment 2': result['trips'][0]['segments'][2]['bookingClass']) if(len(result['trips'][0]['segments'] == 2, at the moment i try to write all in one row, is this possible? response.append({'Fare Type': result['fareType'], 'Segment 2': result['trips'][0]['segments'][2]['bookingClass']) if(len(result['trips'][0]['segments'] == 2})

importing from chessdotcom gives error as: RuntimeError: There is no current event loop in thread 'ScriptRunner.scriptThread'

import pandas as pd import numpy as np import streamlit as st st.title("Chess Analysis") from chessdotcom import get_player_profile response = get_player_profile("fabianocaruana") player_name = response.json['player']['name'] The error is : You can now view your Streamlit app in your browser. Local URL: http://localhost:8501 Network URL: http://192.168.29.133:8501 2022-03-25 20:23:16.543 Traceback (most recent call last): File "C:\Users\sumit\anaconda3\envs\chess_engine\lib\site-packages\streamlit\scriptrunner\script_runner.py", line 443, in _run_script exec(code, module.__dict__) File "E:\Self Projects\ChessEngine\src\dashboard.py", line 8, in <module> from chessdotcom import get_player_profile File "C:\Users\sumit\anaconda3\envs\chess_engine\lib\site-packages\chessdotcom\__init__.py", line 2, in <module> from chessdotcom.client import * File "C:\Users\sumit\anaconda3\e...

How to add field in laravel backpack add user form

Image
I need to add some fields in the user create page in admin panel. This page includes only name field, I need to add first name and last name field. What is the way...

Sum duplicated rows in SQL Server

Sum repeated values in datatable (VB.NET) or in SQL Server (are better one or other solutions) I have a database in which are reported repeated rows: Description | Price | Q.ty | Tax AAAAAAAAAAA | 10.00 | 20.0 | 5 AAAAAAAAAAA | 10.00 | 12.0 | 5 BBBBBBBBBBB | 18.00 | 09.0 | 5 BBBBBBBBBBB | 18.00 | 12.0 | 5 CCCCCCCCCCC | 13.00 | 15.0 | 5 AAAAAAAAAAA | 17.0 | 19.0 | 5 And I want obtain something like this: Description | Price | Q.ty | Tax AAAAAAAAAAA | 10.00 | 51.0 | 5 BBBBBBBBBBB | 18.00 | 21.0 | 5 CCCCCCCCCCC | 13.00 | 15.0 | 5 I've created a datatable in VB.NET and I tried to sum values in it, and then show summed rows in a datagridview, but without results. Then, I've tried to do this with SQL Server (2019), without results again. Can someone help me, please? My code is: Dim conn as New SqlConnection("*****") Dim cmd2 As New SqlCommand("SELECT Description, Price, SUM(Q.ty), Tax, FROM Prodotti GROUP BY Descrizione", conn) Dim da As New SqlDataAdapte...

Read columns in Excel - write to CSV in different order

I need to understand if there is a possibility, within VB.NET, to be able to read the columns of an Excel file and write them out to a CSV file in a different order. In practice, the Excel file we are sent has 6 columns: "amount", "branch", stock "," proposal "," quantity "," type ". The company management system accepts the text file with the columns in a different order: "branch", "stock", "amount", "quantity", "type", "proposal". This creates a problem for me because when I go to convert it my ERP fails to recognize that the column is in a different position. I arrive at the concrete question, I would like to have the possibility to read the columns and make it possible through a script to be able to position them according to the position I decide. I tried this code for import and convert to txt, but I need another script: Imports System.IO Imports ExcelDataReader ...

Qt Designer Custom Widget Plugin Changing the Displayed Name and accessing custom Enums in Designer

I have created a Custom Widget Plugin and have a series of questions that I am hoping to get some insight on. In the plugin onset's the class name in the name method which also must match what is in the widget class. That makes sense. QString AnalogClockPlugin::name() const { return QStringLiteral("AnalogClock"); } QString AnalogClockPlugin::domXml() const { return " <widget class=\"AnalogClock\" name=\"analogClock\">\n" "</ui>\n"; } However, in Designer one sees "AnalogClock." Is there a way to have it be "Analog Clock" with a space or is one stuck just having the class name displayed? In looking through the examples and docs I am not able to find anything. Second question, say one wants the user to be able to select the type of hands for the clock. For instance, Micky Mouse hands vs Mini Mouse hands. I have set up the enums and everything works in the widget. How does one co...

Interacting regressors in a BQ ML Linear Regression Model

I'm trying to work out how get two regressors to interact when using BigQuery ML. In this example below (apologies for the rough fake data!), I'm trying to predict total_hire_duration using trip_count as well as the month of the year. BQ tends to treat the month part as a constant to add on to the linear regression equation but I actually want it to grow with trip_count . For my real dataset I can't just supply the timestamp as BQML seems to over parametise. I should add, if I supply month as a numeric value I just get a single coefficient that doesn't really work for my dataset (patterns form around parts of the academic year rather than calendar). If the month part is a constant, then as trip_count gets very very large, the constant in the equation y = ax+b becomes inconsequential. It's almost as if I want something like y = ax + bx + c where a is the trip_count and b is a coefficient weighted on what the value of month is. This is quite easy to do ...

I made a tictactoe game but it is crashing once I click on an empty space

I made a tictactoe game but it is crashing once I click on an empty space. I used an Arraylist to change the state of the index when the corresponding place is clicked in the tictactoe grid. For example, if I ticked in the top right cell in the grid the index 2 will change to 1 if the current player is 'O' or to 2 if the current player is 'X'. There is a counter to track who is playing, if the remainder is 0 then 'O' is places or else 'X' is placed. Also,I used a flag 'gstate' to stop the game when one player wins. The problem is that in the beginning the game works but when it comes to any part where I make the checking which player is the winner the game crashes. May anyone please help me. This is the Main Jave code package com.example.tictactoe; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.ImageView; import android.widget.Toast;...

What is the matcher of any object of particular class in mockitokotlin2?

there is any() in mockitokotlin2 but it's any object. I need a matcher for any object of MyClass, like org.mockito.Matchers.any(MyClass::class.java) is it possible?

Making HTTPS requests from ESP32

I am making a post request from my ESP32 S2 Kaluga kit. I have tested the HTTP request while running a server program in my LAN. I am using esp_http_client_handle_t and esp_http_client_config_t from esp_http_client.h to do this. Now, I have a HTTPS api setup in AWS API gateway. I get following error with https now: E (148961) esp-tls-mbedtls: No server verification option set in esp_tls_cfg_t structure. Check esp_tls API reference E (148961) esp-tls-mbedtls: Failed to set client configurations, returned [0x8017] (ESP_ERR_MBEDTLS_SSL_SETUP_FAILED) E (148971) esp-tls: create_ssl_handle failed E (148981) esp-tls: Failed to open new connection E (148981) TRANSPORT_BASE: Failed to open a new connection E (148991) HTTP_CLIENT: Connection failed, sock < 0 How can I solve this? Thank you

Updating information within a list of objects with Flutter Hive

I am working with Hive for the first time to save data within flutter and am halfway there... I have a list of weeks that I am saving within a box, and I am able to save those weeks successfully with: void addWeek({ required double budget, }) { Week newWeek = Week( budget: budget, ); listOfWeeks.add(newWeek); box.add(newWeek); notifyListeners(); } When I close the app and restart it I then can load all those saved weeks within the class constructor with: @HiveType(typeId: 1) class WeekList extends ChangeNotifier { WeekList() { int boxLength = box.length; for (var i = 0; i < boxLength; i++) { listOfWeeks.add(box.get(i)); } } What I am struggling with wrapping my head around is how to access the data and update the data within my list of weeks. The listOfWeeks holds a bunch of objects type Week which looks like this: @HiveType(typeId: 2) class Week extends ChangeNotifier { // Constructor Week({ this.budget = 0.0,...

Reach js-conflux-sdk git repo cannot be read when building from CI Docker container

The step in my Docker file which reads RUN yarn install --frozen-lockfile is failing with the following error text when executed in a .github action. It reads as though there's a problem running git ls remote --tags --heads ssh://git@github.com/reach-sh/js-conflux-sdk.git which further seems to indicate that 'ssh: not found' 'ssh' is definitely present within the build environment, and the reach-sh/js-conflux-sdk repo is not private. I cannot reproduce this on my local machine. What am I missing? #10 [builder 6/7] RUN yarn install #10 sha256:0241e5ad2b01044255a03052e8f2a2540c5fb45a447a1b93c55b90ed86436440 #10 10.84 yarn install v1.22.17 #10 11.81 [1/4] Resolving packages... #10 12.75 [2/4] Fetching packages... #10 13.13 error Command failed. #10 13.13 Exit code: 128 #10 13.13 Command: git #10 13.13 Arguments: ls-remote --tags --heads ssh://git@github.com/reach-sh/js-conflux-sdk.git #10 13.13 Directory: /apps/launchpad-api #10 13.13 Output: #10 13.13 "ssh...

When a method has no return statement, how do I print out it's return value?

EDITED. I am learning about Linked Lists. For each process applied by a Method, it is printed out to the console. So, adding, removing, searching (i.e, displaying the result of a search), are all streamed to stdout , but I cannot seem to do this for the insertion Method even though the insert Method is executed. Some Methods have a return statement, while others rely on the __repr__() for conversion to string, to then be streamed to the console. The insertion Method (not mine, but a course worked example) takes two arguments and does not have a return statement. The most consistent error message I get when attempting to print is TypeError: %d format: a real number is required, not NoneType , or TypeError: not enough arguments for format string , where I have replaced %d with %s . What I do not understand is, why I am unable to display test data for the insert Method, while I can do so for all others. The code, #!/usr/bin/env python3 class Node: data = None next_node = None...

Values of a vector to remain equal to another vector based on conditions

I'm using this dataset . I want to create a variable named neg_gw_shock such that neg_gw_shock = (-gw_level_dev) if gw_level_dev < 0 neg_gw_shock = NA if gw_level_dev >= 0 How can I do that?

How to update a progress Bar in QML by calculating the countdown on the C++ side in the QTWidget?

I basically want to send the progress from the c++ side to update the value of the ProgressBar on the QML size. I am trying to integrate QML into a widget application. The thing is I have my mainwindwo.cpp file like this: MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); QQmlContext *context = ui->quickWidget->rootContext(); QString title = "Progress Bar App"; int progress = 0; context->setContextProperty("_myString",title); //Set Text in QML that says Hello World timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(myFunction())); timer->start(1000); progress = myFunction(); context->setContextProperty("_myProgress", progress); if(progress == 100.0){ timer->stop(); } ui->quickWidget->setSource(QUrl("qrc:/main.qml")); ui->quickWidget->show(); } MainWindow::...