Posts

Showing posts from January, 2022

Prepare new list based on conditions from two object lists using stream

I am working in spring boot application, working with lists. I have these classes : public class MyModel { private String pptId; private String pptTitle; private String modelNumber; } public class FullData { private String pptTitle; private String modelNumber; private String pptDetails; private String price; ............... .............. } List sourceModelList = This is full list MyModel(1,'ppt1','a1') MyModel(1,'ppt1','a2') MyModel(2,'ppt2','a1') MyModel(2,'ppt2','a3') MyModel(2,'ppt2','a4') MyModel(3,'ppt3','a1') MyModel(3,'ppt3','a3') MyModel(3,'ppt3','a5') I have filtered FullData list but that is filtered from some processing List filteredFullDataList = it is unique list FullData(null,'a1','pptDetails1','300') FullData(null,,'a2','pptDetails21','70') FullData(nu...

How do insert data into a table that already exists?

I'm trying to insert data into a table that already exists, but I cant find anything on how to do this. I only found how to insert this data into a new table. Syntax error at or near Insert Tutorial I visited SELECT film_category.film_id, film_category.category_id, rental_duration, rental_rate INSERT INTO category_description FROM film_category LEFT JOIN FILM ON film_category.film_id = film.film_id from Recent Questions - Stack Overflow https://ift.tt/qB6VOS4HU https://ift.tt/Mhf8FyP6J

What does explicitly-defaulted move constructor do?

I'm new to C++ and need some help on move constructors. I have some objects that are move-only, every object has different behaviours, but they all have a handle int id , so I tried to model them using inheritance, here 's the code #include <iostream> #include <vector> class Base { protected: int id; Base() : id(0) { std::cout << "Base() called " << id << std::endl; } virtual ~Base() {} Base(const Base&) = delete; Base& operator=(const Base&) = delete; Base(Base&& other) noexcept = default; Base& operator=(Base&& other) noexcept = default; }; class Foo : public Base { public: Foo(int id) { this->id = id; std::cout << "Foo() called " << id << std::endl; } ~Foo() { std::cout << "~Foo() called " << id << std::endl; } Foo(const Foo&) = delete; Foo& operator=(const Foo...

How to map json response to the model with different field names

I am using an ASP.NET Core 6 and System.Text.Json library. For example, I'm getting a response from the some API with the following structure { "items": [ { "A": 1, "User": { "Name": "John", "Age": 21, "Adress": "some str" }, }, { "A": 2, "User": { "Name": "Alex", "Age": 22, "Adress": "some str2" }, } ] } And I want to write this response to the model like List<SomeEntity> , where SomeEntity is public class SomeEntity { public int MyA { get; set; } // map to A public User MyUser { get; set; } // map to User } public class User { public string Name { get; set; } public string My...

How can I load the spData-package?

I want to load in the map data, which is found in spData . I tried to install the package: install.packages("spData") Then I tried to load the package: library(spData) When I do this I get the following error: Error: package or namespace load failed for ‘spData’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]): namespace ‘terra’ 1.4-22 is being loaded, but >= 1.5.12 is required How do I solve this? from Recent Questions - Stack Overflow https://ift.tt/Jf2gXuH1S https://ift.tt/Mhf8FyP6J

Got unexpected field names: ['is_dynamic_op']

I am working on a low light video processing project where I am getting some errors in some areas, For this code... params = trt.DEFAULT_TRT_CONVERSION_PARAMS._replace( precision_mode='FP16', is_dynamic_op = True) I am getting this error... > --------------------------------------------------------------------------- ValueError Traceback (most recent call > last) <ipython-input-8-326230ed5373> in <module>() > 2 params = trt.DEFAULT_TRT_CONVERSION_PARAMS._replace( > 3 precision_mode='FP16', > ----> 4 is_dynamic_op = True) > 5 > 6 # Convert the model > > /usr/lib/python3.7/collections/__init__.py in _replace(_self, **kwds) > 414 result = _self._make(map(kwds.pop, field_names, _self)) > 415 if kwds: > --> 416 raise ValueError(f'Got unexpected field names: {list(kwds)!r}') > 417 return re...

How to completely download anaconda bz2 files and dependencies for offline package installation?

I want to install an anaconda package in offline mode. I have tried to download bz2 files in other pc using this command: conda install packagename --download-only and moved the bz2 file into offline pc and installed it using conda install *.bz2 . It works for simple package. But for complex package like atoti with a lot of dependencies, it seems that it cant be completely installed as other packages in offline pc are not compatible with atoti . Is there any way to download all packages .bz2 files at once? from Recent Questions - Stack Overflow https://ift.tt/QGr0Ol1Rh https://ift.tt/Mhf8FyP6J

Both Require and import not working javascript

I am trying to create a cli tool to make a todo list. For some reason I can't figure out I'm unable to use either require or import when trying to import the Chalk package for highlighting terminal outputs here is what I have for my index.js file #! /usr/bin/env node const { program } = require("commander"); const list = require("./commands/list.js"); program.command("list").description("List all the TODO tasks").action(list); program.parse(); Here is my list.js file #! /usr/bin/env node const conf = new (require("conf"))(); const chalk = require("chalk"); function list() { const todoList = conf.get("todo-list"); if (todoList && todoList.length) { console.log( chalk.blue.bold( "Tasks in green are done. Tasks in yellow are still not done." ) ); todoList.forEach((task, index) => { if (task.done) { console.log(chalk.greenBright(`${ind...

Spring Data JpaRepository saveAndFlush not working in @Transactional test method

Using JPA Spring Data I have created a couple of entities Ebook and Review, which are linked by a ManyToOne relationship from Review towards Ebook. I have tried to insert a review for an existent ebook, but the result is not being reflected in the database (Postgres DB), even though I am using a saveAndFlush inside a @Transactional. I retrieve inserted review correctly, it is just that is not saving the record in the table. Entities: Ebook: @Entity public class Ebook { @Id @SequenceGenerator( name="ebook_sequence", sequenceName = "ebook_sequence", allocationSize = 1 ) @GeneratedValue ( strategy = GenerationType.SEQUENCE, generator ="ebook_sequence" ) private Long idEbook; private String title; } Review: @Entity public class Review { @Id @SequenceGenerator( name="sequence_review", sequenceName = "sequence_review",...

JSON data type in entity class in php [duplicate]

I am using symfony/doctrine orm in my php and database is mysql. As of now I am creating manual table in mysql by using below command. create table FileUpload (id int , countryCode varchar(30),fileData json); I want Doctrine to create this table and datatype of filedata should be json . As of now in my entity class I am taking datatype as string. what datatype I should take in entity class so that in DB data with JSON datatype should be created? What modification I need to do in below my existing class? FileUpload.php <?php namespace App\Entity; use ApiPlatform\Core\Annotation\ApiResource; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; /** * @ORM\Entity * @ORM\Table(name="FileUpload") */ class FileUpload { /** * @ORM\Column(type="string") * @ORM\Id */ private $countryCode; /** * @ORM\Column(type = "string") */ private $fileData; public function __c...

How does Entity Framework map to tables in SQL?

How does EF handle the mapping to the SQL tables? I understand the general idea, but I changed the name of my model in C#, but it's still pointing to the table when using the context object. I expected it to break, but I am guessing it is cached somewhere? Is that how it is handled deep inside EF somewhere? More detail: This is persistent when the console app stops, and then restarts. The model has a different name, but EF still somehow goes to the table. from Recent Questions - Stack Overflow https://ift.tt/kgQU4Ex9h https://bit.ly/3GblJNq

Monitor active warps and threads during a divergent CUDA run

I implemented some CUDA code. It runs fine but the alogrithm inherently produces a strong thread divergence. This is expected. I will later try to reduce divergence. But for the moment I would be happy to be able to measure it. Is there an easy way (prefereably using a runtime API call or a CLI tool) to check how many of my initially scheduled warps and/or threads are still active? from Recent Questions - Stack Overflow https://ift.tt/r9u2LYw8M https://bit.ly/3GblJNq

Move subtitle to left direction (aligning to y axis area) in ggplot2

Image
Given sample data and ggplot plotting code below: df <- data.frame(Seller=c("Ad","Rt","Ra","Mo","Ao","Do"), Avg_Cost=c(5.30,3.72,2.91,2.64,1.17,1.10), Num=c(6:1)) text <- "Real estate agents often refer to a home's curb appeal, the first impression it makes on potential buyers. As a would-be seller, it's important to take as dispassionate a look as possible at the outside of your home." ggplot(df, aes(x=reorder(Seller, Num), y=Avg_Cost)) + geom_bar(stat='identity') + coord_flip() + labs( title = 'Costs of Selling a Home', subtitle = stringr::str_wrap(text, 80) ) + theme( plot.title = element_text(hjust = 0.5), plot.subtitle = element_text(hjust = 0), plot.margin = unit(c(0.1, 0, 0, 0), "cm") ) Result: I attempt to slightly adjust subtitle to left direction (as the red arrow shows), the final subtitle will be relocated i...

how are compose services implemented?

I am wondering how compose implements services. To my understanding, each thing that compose does could be done with the docker CLI. For example, creating container, binding volumes, exposing ports and joining them on networks. The one thing that is a blackbox in my understanding is how compose achieves the concept of a service as a unit. So that when you specify replicas under the deploy key, you get DNS round-robin kind of load balancing, similar to when you specify --endpoint-mode dnsrr in with swarm. Can this actually be achieved with CLI commands, or does compose do some tricks with the SDK? In both cases, my question would be what exactly happens there? from Recent Questions - Stack Overflow https://ift.tt/3uafMOn https://ift.tt/eA8V8J

Oracle instant client failing on ubuntu-based agent despite correct TNS_ADMIN path

I am attempting to perform an SQL query using oracle-instantclient-basic-21.5 through an Ubuntu 20.04.3 agent hosted by Azure Devops. The query itself (which reads: python query_data ) works when I am running it on my own machine with specs: Windows 10 Path=C:\oracle\product\11.2.0.4\client_x64\bin;...;... TNS_ADMIN=C:\oracle\product\tns Python 3.8.5 using sqlalchemy with driver="oracle" and dialect = "cx_oracle" I am running the following: pool: vmImage: 'ubuntu-latest' steps: - script: | sudo apt install alien displayName: 'Install alien' - script: | sudo alien -i oracle-instantclient-basic-21.5.0.0.0-1.x86_64.rpm displayName: 'Install oracle-instantclient-basic' - script: | sudo sh -c 'echo /usr/lib/oracle/21/client64/ > /etc/ld.so.conf.d/oracle-instantclient.conf' sudo ldconfig displayName: 'Update the runtime link path' - script: | sudo cp tns/TNSNAMES.ORA /usr/lib/oracle/21/...

sum of column based on another column will show on another

Image
Can you help me with my DataGridView? I need to show sum of column based on another column. For example, I have Part number 1,2,3. QTY for PN is always 1 because of the serial number given. PN 1 has 10qty (10rows). I need to sum it based on that PN and put the sum value at the end cell. Please see below sample: It is excel I know, but just please bear with me pretend it is DataGridView. Total sum is based on sum of cost for the same PN. from Recent Questions - Stack Overflow https://ift.tt/32LgNBu https://ift.tt/3G8ikPx

Leaflet big GeoJson file Ajax filter best performance

I have four 2MB geoJson files with four Layer to load like LayerBoon = L.geoJSON.ajax(URL, {pointToLayer:returnBoonMarker, filter:filtertext}); with a filter function and this button click function $("#btnFindText").click(function(){ SeachTXT = $("#txtFind").val(); LayerSt.refresh(); LayerPr.refresh(); LayerHL.refresh(); LayerBoon.refresh(); }) every Layer have to re-filter by clicking the button. when filtering, is it possible not to reload the file each time, keep it in cache and filter it again? from Recent Questions - Stack Overflow https://ift.tt/3Hixwv2 https://ift.tt/eA8V8J

how to collect from stream using multiple conditions

I'm trying to sort a list of Message object, this entity contain multiple attributs but only 4 are useful for us in this case : Integer : Ordre String : idOras Date : sentDate Integer : OrdreCalcule (a concatination of Ordre and sentDate "YYYYmmDDhhMMss" ) if this case, the conditions of selection are the following : if two Messages have the same Ordre : if they have the same idOras -> collect the newest one (newest sentDate) and remove the others if they have different idOras -> collect both of them sorted by sentDate ASC if two Messages have different Ordre : collect both of them sorted by Ordre for now I'm using this stream : orasBatchConfiguration.setSortedZbusOrasList(messageList.stream() .collect(Collectors.groupingBy(Message::getIdOras, Collectors.maxBy(Comparator.comparing(Message::getOrdreCalcule)))) .values() .stream() .map(Optional::get) .sorted(Compara...

How to add columns names to a spatialpolygon based on column from a dataframe?

Dummy SpatialPolygon: x_coord y_coord [1,] 16.48438 59.73633 [2,] 17.49512 55.12207 [3,] 24.74609 55.03418 [4,] 22.59277 61.14258 [5,] 16.48438 59.73633 library(sp) p = Polygon(xym) ps = Polygons(list(p),1) sps = SpatialPolygons(list(ps)) plot(sps) Dummy dataframe: df <- data.frame (date= c("2021", "2015", "2018"), value= c(100, 147, 25)) Basic question but how can I add the columns names of the dataframe to the spatial polygon (I don't need to add some value, I just want my spatialpolygon to have the field "date" and "value") from Recent Questions - Stack Overflow https://ift.tt/3KJqAZX https://ift.tt/eA8V8J

sort and group the dictionary data using Python based on common value

I have list of dictionary. I want to arrange it based on weekday and group by common load value for that weekday, hour and load also need to add end time based on common load values. Merge the start time and end time only if they are in a sequence. hours will start from 00:00 till 23:00. While grouping last hour's end time will be 24:00. example is given below in required_output. few example of required output given below. data = [{"masterpeakLoadId":12,'hour': '01:00', 'day': 'Friday', 'load': 1.0}, {"masterpeakLoadId":31,'hour': '05:00', 'day': 'Friday', 'load': 71.0}, {'masterpeakLoadId':37, 'hour': '06:00', 'day': 'Friday', 'load': 71.0}, {'masterpeakLoadId':54, 'hour': '11:00', 'day': 'Friday', 'load': 5.0}, {'masterpeakLoadId':59, 'hour': '12:00', ...

Deploying Uniswap v2 / Sushiswap or similar in Brownie, Hardhat or Truffle test suite

I am writing an automated test suite that needs to test functions against Uniswap v2 style automated market marker: do swaps and use different order routing. Thus, routers need to be deployed. Are there any existing examples of how to deploy a testable Uniswap v2 style exchange in Brownie? Because Brownie is a minority of smart contract developers, are there any examples for Truffle or Hardhat? I am also exploring the option of using a mainnet fork, but I am not sure if this operation is too expensive (slow) to be used in unit testing. from Recent Questions - Stack Overflow https://ift.tt/3IDEf2A https://ift.tt/eA8V8J

django admin The outermost 'atomic' block cannot use savepoint = False when autocommit is off

When I try to delete an item from a table generated by django admin, it throws this error Environment: Request Method: POST Request URL: http://127.0.0.1:8000/admin/sybase_app/packageweight/?q=493 Django Version: 1.8 Python Version: 3.6.9 Installed Applications: ('django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'blog', 'sybase_app') Installed Middleware: ('django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'd...

Typed events in Vue 3?

Currently I am manually casting an event: const emit = defineEmits<{ (e: 'update:modelValue', value: string | number): void }>() // [..] <input type="text" :value="modelValue" @input="emit('update:modelValue', ($event.target as // manually HTMLInputElement).value)" // casted /> Is there any better way than this? Any way around having to cast it? Hint: I am not using v-model here because the shown code is part of a component (on which v-model will be used then) from Recent Questions - Stack Overflow https://ift.tt/3fXP1EG https://ift.tt/eA8V8J

Google app engine Django app is crashing intermittently but the log files aren't showing me why

I have a Django 4.0 application running on google app engine, and for the most part it works fine. However I have a particular page which seems to crash the application after I load the page several times. On my laptop I don't see this behavior, so I'm trying to debug what is going wrong when it is running on GAE but I don't have much visibility into what is happening. Watching the logs doesn't tell me anything interesting, just that the workers are shutting down and then that they are restarting: gcloud app logs tail -s default 2022-01-26 16:02:38 default[fixeddev] 2022-01-26 08:02:38,933 common.views INFO Application started 2022-01-26 16:03:40 default[fixeddev] "GET /organization/clean_up_issues/ HTTP/1.1" 200 2022-01-26 16:03:56 default[fixeddev] "GET /organization/clean_up_issues/ HTTP/1.1" 200 2022-01-26 16:04:10 default[fixeddev] "GET /organization/clean_up_issues/ HTTP/1.1" 500 2022-01-26 16:04:15 default[fixeddev] [2022-...

html css tree vertical alignment (using flex, row, flex-start)

This is a django + html, css and very minimal or no JS question of a Tree display using nested UL/LI (so far) have found out already the work of displaying tree vertical/horizontal is done, (current issue) aim is to display a dynamic tree or static tree using nested UL in multiple format or options for the end-users with different options (they may choose for easier visualization) like vertical tree, horizontal tree and goal on the left side or right side. so far those are achieved currently the issue in working on the following to display vertically aligned horizontal tree with flex, and unable to succeed with the display as the wrap of the one tree path is making some impact on the next connectors (still trying to figure out which css selector and associated property will help to clear the gap) Please find the attached screen shot and also the code enter image description here Latest Results Screenshot enter image description here CSS code: <style> body { ...

try-catch instead of if in edge cases

Would it be a good idea to replace the if statements with try-catch in the following usecases (performance and readability wise?): Example 1 public static void AddInitializable(GameObject initializable) { if(!HasInstance) { // this should only happen if I have forgotten to instantiate the GameManager manually Debug.LogWarning("GameManager not found."); return; } instance.initializables.Add(initializable); initializable.SetActive(false); } public static void AddInitializable2(GameObject initializable) { try { instance.initializables.Add(initializable); initializable.SetActive(false); } catch { Debug.LogWarning("GameManager not found."); } } Example 2 public static void Init(int v) { if(!HasInstance) {// this should happen only once instance = this; } instance.alj = v; } public static void Init2(int v) { try { instance.alj = v; } ...

Downloading google forms through python

I was trying to downloading Google Forms through Google Drive API but it turned out to be not possible. Now I am thinking of downloading the responses in a spreadsheet Mimetype but doesn't sure about how to do so. Or, would the Google Form API fulfill my request? Thanks. from Recent Questions - Stack Overflow https://ift.tt/3qZI10q https://ift.tt/eA8V8J

Avoid "where" clause grouping when applying multiple where clauses inside the same scope

I have this scope in my Model: function extraFiltersScope($query){ $query->where('first_name', 'test')->orWhere('name', 'testing'); return $query; } I'm applying the clause like this: $query = User::where('age', 30')->extraFilters()->toSql(); Expected SQL would be: select * from users where age=30 and first_name='test' or name='testing' I'm getting this: select * from users where age=30 and (first_name='test' or name='testing') It seems that that's the normal behavior since both "where" clauses are being applied inside the same scope. Is there a workaround to tell the builder to now group them? Of course, my logic is much more complex than this, otherwise I could simply have a scope method for each one. I need to apply several filters on the same scope but without nesting. Thanks. from Recent Questions - Stack Overflow https://ift.tt/3tVCYzX https://ift.tt...

Get a list of every Layer, in every Service, in every Folder in an ArcGIS REST endpoint

I have two ArcGIS REST endpoints for which I am trying to get a list of every layer: https://rdgdwe.sc.egov.usda.gov/arcgis/rest/services https://services1.arcgis.com/RLQu0rK7h4kbsBq5/ArcGIS/rest/services These are not my organization's endpoints so I don't have access to them internally. At each of these endpoints there can be folders, services, and layers, or just services and layers. My goal is to get a list of all layers. So far I have tried: endpoints=(["https://rdgdwe.sc.egov.usda.gov/arcgis/rest/services", "https://services1.arcgis.com/RLQu0rK7h4kbsBq5/ArcGIS/rest/services"]) for item in endpoints: reqs = requests.get(item, verify=False) # used this verify because otherwise I get an SSL error for endpoints[0] soup =BeautifulSoup(reqs.text, 'html.parser') layers = [] for link in soup.find_all('a'): print(link.get('href')) layers.append(link) However this doesn't account for ...

Is it possible to show an image in Java console?

I want to make a Java application that shows an image in the console, but I cannot find anything on the topic. How would I do this? from Recent Questions - Stack Overflow https://ift.tt/3KJy0fO https://ift.tt/eA8V8J

Adding quotes to text in line using Python

I am using Visual Studio Code to replace text with Python. I am using a source file with original text and converting it into a new file with new text. I would like to add quotes to the new text that follows. For example: Original text: set vlans xxx vlan-id xxx New text: vlan xxx name "xxx" (add quotes to the remaining portion of the line as seen here) Here is my code: with open("SanitizedFinal_E4300.txt", "rt") as fin: with open("output6.txt", "wt") as fout: for line in fin: line = line.replace('set vlans', 'vlan').replace('vlan-id', 'name') fout.write(line) Is there a way to add quotes for text in the line that follows 'name'? Edit: I tried this code: with open("SanitizedFinal_E4300.txt", "rt") as fin: with open("output6.txt", "wt") as fout: for line in fin: line ...

OAuth authorization flow for private API with Microsoft AD

Our company is using Microsoft AD for user management and authentication, also the authorization is done using the AD groups/roles. In the most 3rd party applications the users can authenticate with their AD accounts. Now we are developing new applications, which should use an internal API. Therefor we created a new enterprise app in our Microsoft tenant and defined a couple of roles. On the client side it is the normal flow - users authenticate with their accounts and the client receives the access token it should send to the API. And here is the point where I am not sure what is the best way to implement it. Since all the users already exist in the AD, there is no need to only use access token to get the user identifier and create/link the user in the internal database - I want to use the AD users and to be able to verify the roles and use them in the services behind the API gateway "as is". But the roles are not stored in the access token, so I assume, I have to request th...

I am making a post request through laravel-vue on the browser and I am getting a 401, but it works on postman with the exact headers & paramaters

this is the function that is triggered once the form button is clicked add_book: function(){ axios.post('http://127.0.0.1:8000/api/v1/books', { headers: { 'Content-Type': 'application/json', 'Accept': 'application/json', 'Authorization': 'Bearer' this.token, }, params: { 'name': this.name, 'description': this.description, 'publication_year': this.publication_year, } }).then((response => { if (response.status == 201){ this.name = ""; this.description = ""; this.publication_year = ""; console.log('a new book is added'); } })).catch((error) => { console.log(error); ...

Missing import(Rcpp) in NAMESPACE leads to C++ library error during R CMD check

Summary I am working on an R package that uses Rcpp. I took over the project with many issues and I am trying to fix them. The problem with this is that I don't know how to create a minimal example for reproduction in this situation because the package is quite large and I was not involved in the early setup. I would appreciate suggestions on how to go about it, I am new to writing packages in R/Rcpp. I got it into a state that it passes automated R CMD checks both on macOS and Linux in Github Actions. There is a deprecated file named "R/simulate.R" that contains one function that is no longer used. I am trying to remove this file. The relevant lines are: ... #' @useDynLib mvMAPIT #' @export #' @import CompQuadForm #' @import doParallel #' @import Rcpp #' @import RcppArmadillo #' @import Matrix #' @import mvtnorm #' @import PHENIX simulate <- function(...) {...} I used devtools::document() to update the autogenerated files in ...

Replace colors in image by closest color in palette using numpy

I have a list of colors, and I have a function closest_color(pixel, colors) where it compares the given pixels' RGB values with my list of colors, and it outputs the closest color from the list. I need to apply this function to a whole image. When I try to use it pixel by pixel, (by using 2 nested for-loops) it is slow. Is there a better way to achieve this with numpy? from Recent Questions - Stack Overflow https://ift.tt/3FUsfYZ https://ift.tt/eA8V8J

ForEach in SwiftUI: Error "Missing argument for parameter #1 in call"

I'm still trying to create a calendar app and ran into another problem I wasn't able to find a solution for online. Xcode throws the error "Missing argument for parameter #1 in call" in line 2 of my code sample. I used similar code at other places before, but I can't find the difference in this one. Also this code worked before and started throwing this error after I moved some code to the new View DayViewEvent after getting the error "The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions", which I hoped to fix it and would be clean code anyway. For reference: events is an optional array of EKEvents (hence the first if) and selectedDate is (obviously) a Date. Any help is greatly appreciated! if let events = events { ForEach(events, id: \.self) { event in if !event.isAllDay { DayViewEvent(selectedDate: selectedDate, event: event) } } } ...

How to delete data from file and move all info back

I created a file with fopen and I deleted the first value from the file and I want to take all of the values that are in the file and move them to the start of the file. Example: File: [Info,data,string] Wanted: [data,string,] What is happening: [,data,string] Any help will be great. from Recent Questions - Stack Overflow https://ift.tt/32tTLPp https://ift.tt/eA8V8J

With nestjs / node / npm project how to override a transitive dependency

I have a nestjs / node / npm project and trying to override a transitive dependency due to security vulnerability. The project that seems to include it is: "@nestjs/common": "7.6.18", And that project includes axios 0.21.1 , I want to upgrade to axios 0.21.2 In my package.json I tried using the overrides feature with the following. }, "overrides": { "axios": "0.21.2" }, "jest": { But then I get this entry when I run npm list . npm list --depth=4 │ ├─┬ axios@0.21.1 invalid: "0.21.2" from node_modules/@nestjs/common And only seems to include axios 0.21.2 . How do I upgrade a transitive dependency? I am mostly using the nest wrappers: nest build, etc npm --version - 8.3.1 node --version - v17.4.0 from Recent Questions - Stack Overflow https://ift.tt/35jOBqe https://ift.tt/eA8V8J

How to call a method in another module JavaScript?

I have a class with method performing login LoginPage.js class loginPage { fillCredentials(username, password) { cy.get('[id=username]').type(username); cy.get('[id=password]').type(password); return this; } clickLogin() { cy.contains("Login").click(); } } export default loginPage; I have another spec file for testing: login.spec.js import {fillCredentials,clickLogin} from '../../support/PageObjects/loginPage' describe('User Onboarding Emails', () => { it('Verification email', () => { cy.visit('/') fillCredentials('username','password') clickLogin() }); }); However, it is giving an error of (0 , _loginPage.fillCredentials) is not a function I know its a wrong way of calling a method. Is there any way I can use the methods without creating an instance of class to access methods from Recent Questions - Stack Overflow https://ift.tt/3nJaINe https://ift.tt/e...

Registering and Resolving a Service with delegate type constructor parameter using Structuremap

I have following service class: public class MyService : IService { public MyService(Func<string,bool> question) { .... } ... } When I use this service in my WinForms application I want to pass following code as MyService constructor parameter (string question) => { var questionForm = new SimpleQuestionForm(question); if(questionForm.ShowDialog() == DialogResult.OK) return true; else return false; } How can I tell to the StructureMap that what is my question delegate? from Recent Questions - Stack Overflow https://ift.tt/3rFkCAB https://ift.tt/eA8V8J

How can I reindex elasticsearch?

I am using jhipster 7.5.0 and I tryed to install generator-jhipster-elasticsearch-reindexer , but seems it does not work with this jhipster version. I am trying to reindex all elasticsearch indexes manually, but I do not know how can I do that. from Recent Questions - Stack Overflow https://ift.tt/3qTSEBZ https://ift.tt/eA8V8J

Rotating and scaling an image around a pivot, while scaling width and height separately in Pygame

Image
I have a set of keyframes in a list that look like this: [{ "duration" : 20, "position" : [0,0], "scale" : [1, 1], "angle" : 0, "rgba" : [255,255,255,255] }, { "duration" : 5, "position" : [0,0], "scale" : [1, 1.5], "angle" : 50, "rgba" : [255,255,255,255] }] The idea is being able to do the corresponding transformations every frame. Notice that scale is separated between width and height. The problem comes form trying to scale width and height independently, while still rotating around a pivot. I tried modifying some code from: ( How to rotate an image around its center while its scale is getting larger(in Pygame) ) def blitRotate(surf, image, pos, originPos, angle, zoom): # calcaulate the axis aligned bounding box of the rotated image w, h = image.get_size() box ...

Playwright : How to run the same test on multiple url in the same browser on different tabs and in parallel

I'm looking to run the same test for serverals url (~20) and I want to be the quickest as possible. I would like to run my 20 tests in parallel in one browser and in a new tab (page) for each but I can't achieve it. Here my code that open a new browser for each test : const urlList: string[] = [ 'url1', 'url2', ... ]; test.describe.parallel("Same test for multiple url", async () => { let context; test.beforeAll(async ({ browser }) => { context = await browser.newContext(); }); for (const url of urlList) { test(`${url}`, async () => { let page = await context.newPage(); await page.goto(url); }); } }); from Recent Questions - Stack Overflow https://ift.tt/32p2P82 https://ift.tt/eA8V8J

To understand the regular expression used in Webpack's SplitChunksPlugins CacheGroup [duplicate]

I'm trying to migrate Webpack 3 to Webpack 4 which forces us to use Split Chunks Plugin . Split Chunks Plugin uses cacheGroups object as a way to group the chunks together. In any of those cache groups, there is a test property which says vendors: { test: /[\\/]node_modules[\\/]/, priority: -10 } My question is what is [\\/] in the regular expression. I know forward slashes should be escaped because they are regular expression's reserved characters but IMO, it should be vendors: { test: /\/node_modules\//, priority: -10 } Can anyone please explain the difference? from Recent Questions - Stack Overflow https://ift.tt/3tNaJmS https://ift.tt/eA8V8J

Getting the categoryId of a post in Graphql

This is my Graphql query for getting posts from headless wordpress: export const GET_POSTS = gql` query GET_POSTS( $uri: String, $perPage: Int, $offset: Int, $categoryId: Int ) { posts: posts(where: { categoryId: $categoryId, offsetPagination: { size: $perPage, offset: $offset }}) { edges { node { id title excerpt slug featuredImage { node { ...ImageFragment } } categories { edges { node { categoryId name } } } } } pageInfo { offsetPagination { total } } } } ${ImageFragment} `; When i do this: console.log("DATAAAA", data.posts.edges); i get: DATAAAA [ { node: { id: 'cG9zdDo0MA==', title: 'postttt', excerpt: '<p>dlkfjdsflkdslkdjfkldsf</p>\n', slug: 'postttt', featu...

Bootstrap tooltip not triggering on badge

I have a Laravel app for which I'm trying to trigger a Bootstrap tooltip on a badge, but am getting the following error in the console: Uncaught ReferenceError: Tooltip is not defined I'm importing Popper and JavaScript components in resources/js/bootstrap.js as per the Bootstrap 5 documentation : import Modal from "bootstrap/js/dist/modal.js"; import Collapse from "bootstrap/js/dist/collapse.js"; import Tooltip from "bootstrap/js/dist/tooltip.js"; import Popper from "@popperjs/core/dist/umd/popper"; try { window.Popper = Popper; /* window.Popper = require("@popperjs/core"); # This doesn't work either */ window.$ = window.jQuery = require("jquery"); require("bootstrap"); } catch (e) {} I'm initialising the tooltips using the following code from the documentation in resources/js/main.js with a DOMContentLoaded event listener around it: document.addEventListener("DOMCon...

File reader finding the average of the values from a txt file of the rows and columns without using arrays

I am given a txt file 7x3 grid of values and I'm supposed to find the average of each rows (7) and columns (3) without using arrays. The professor has guided us to printing the grid out but I'm not sure what to do next. public static void main (String [] args){ try{ File file = new File("Cal.txt"); Scanner scanFile = new Scanner(file); for (int i = 0; i < 7; i++){ String string = scanFile.nextLine(); System.out.println(string); } }catch(Exception e) { System.out.println("Error occured..."); } } The grid: 40.0 30 10 25 76 1120 0 1301 1823 630 300 1000 102 1100 1900 982 200 239 200 720 100 from Recent Questions - Stack Overflow https://ift.tt/3GSyfTe https://ift.tt/eA8V8J

HttpMessageConverter for Single Object and List of Object

I have an Object (here: Property) and I want to add csv export ability to my Spring Backend for single and list of objects. I added this to my config: @Override public void configureContentNegotiation(ContentNegotiationConfigurer configurer) { configurer.(more config).mediaType("csv", new MediaType("text", "csv")); } @Override public void extendMessageConverters(List<HttpMessageConverter<?>> converters) { converters.add(new PropertyConverter()); converters.add(new StatsConverter()); } and the Property Converter looks like this: public class PropertyConverter extends AbstractGenericHttpMessageConverter<Property> { private static final Logger LOGGER = LoggerFactory.getLogger(PropertyConverter.class); public PropertyConverter() { super(new MediaType("text", "csv")); } @Override protected void writeInternal(Property property, Type type, HttpOutputMessage outputMessage) thro...

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'user_id' cannot be null?

I got this error when try to seed database. Laravel 7. BlogPost Model class BlogPost extends Model { protected $fillable = [ 'title', 'slug', 'user_id', 'category_id', 'excerpt', 'content_raw', 'content_html', 'is_published', 'published_at', 'updated_at', 'created_at', ]; public function category() { return $this->belongsTo(BlogCategory::class); } public function user() { return $this->belongsTo(User::class); } } User model class User extends Authenticatable { use Notifiable; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'name', 'email', 'password', ]; /** * The attributes that should be hidden for arrays. * * @var array ...

Select data and name when pointing it chart with ggplotly

I did everything in ggplot, and it was everything working well. Now I need it to show data when I point a datapoint. In this example, the model (to identify point), and the disp and wt ( data in axis). For this I added the shape (same shape, I do not actually want different shapes) to model data. and asked ggplot not to show shape in legend. Then I convert to plotly. I succeeded in showing the data when I point the circles, but now I am having problems with the leyend showing colors and shapes separated with a comma... I did not wanted to make it again from scrach in plotly as I have no experience in plotly and this is part of a much larger shiny proyect, where the chart adjust automatically the axis scales and adds trend lines the the chart among other things (I did not include for symplicity) that I do not know how to do it in plotly. Many thanks in advance. I have tryed a million ways for a couple of days now, and did not succeed. # choose mtcars data and add rowname as column a...

How can I convert a hash representation in an escaped string to an actual hash?

I have a field stored in a MySQL db that is a string, but it is storing a representation of a hash. I'm wondering how I could convert this string into a hash. I have tried a bunch of different things with gsub and JSON.parse to no avail. Here is a reference to what I'm trying to convert: => "{:address=>\"\", :city=>\"\", :country=>\"\", :zip=>\"\", :state=>\"\", :industry=>\"\", :org=>\"\", :job_title=>\"\", :purchasing_time_frame=>\"\", :role_in_purchase_process=>\"\", :no_of_employees=>\"\", :comments=>\"\", :custom_questions=>[{\"title\"=>\"License Number\", \"value\"=>\"345g3245\"}, {\"title\"=>\"License Type\", \"value\"=>\"Legal\"}], :create_time=>\"2022-01-17T22:49:26Z\"}" from Recent Question...

Filtering, subsetting, and matching data from two separate data frames based on the ID and the period between the dates in R

I have two data frames: The first contains information on hospitalization and has 3706 observations: 1 2019-08-22 15:06:00 2019-10-09 12:00:00 1565 2 2019-08-22 16:15:00 2019-09-12 12:33:00 3 3 2019-08-22 20:00:00 2019-10-08 12:00:00 1408 4 2019-08-23 14:00:00 2019-11-22 13:40:00 1566 5 2019-08-23 15:30:00 2019-10-14 16:20:00 1567 6 2019-08-24 12:30:00 2019-09-19 12:11:00 268 7 2019-08-26 14:15:00 2019-09-24 13:50:00 1568 8 2019-08-26 15:50:00 2019-10-29 13:47:00 161 9 2019-08-26 17:51:00 2019-09-19 14:00:00 1569 10 2019-08-26 19:30:00 2020-01-20 16:10:00 1570 11 2019-08-26 20:45:00 2019-09-17 11:00:00 1571 12 2019-08-26 21:10:00 2020-01-10 14:30:00 702 13 2019-08-27 14:25:00 2019-09-24 11:10:00 1572 14 2019-08-27 16:46:00 2019-08-30 15:18:00 1573 15 2019-08-27 19:45:00 2019-09-02 13:45:00 1574 16 20...