Posts

Showing posts from August, 2021

How to deep clone the Class that contains DynamicObject in C#?

public class DynamicDictionary : System.Dynamic.DynamicObject { Dictionary<string, object> dictionary = new Dictionary<string, object>(); public override bool TryGetMember(GetMemberBinder binder, out object result) { string name = binder.Name; return dictionary.TryGetValue(name, out result); } public override bool TrySetMember(SetMemberBinder binder, object value) { dictionary[binder.Name] = value; return true; } public override System.Collections.Generic.IEnumerable<string> GetDynamicMemberNames() { return this.dictionary?.Keys; } } public class SerializeExtensions { public string Name { get; set; } public DynamicDictionary DynamicObj { get; set; } } Please consider the above like my class. I have a List of SerializeExtensions collection. Now I have to deep clone this list of collections. This has been properly cloned when I am using the below code. JsonConvert.DeserializeObj...

rails 6 dynamic bootstrap modal using js.erb error

I'm trying to display bootstrap modal with dynamically, so every time user click on record it shows modal with that record information. I don't want to show modal for all record every time I reload the page. I got this error in browser console. SyntaxError: Unexpected token '===' Controller events_controller.rb def pay @event = Event.find(params[:id]) respond_to do |format| format.js{} end end View index.html.erb <%= link_to pay_path(id: event.id), remote: true, class: "", method: :patch do %> Paid <i class="fe fe-dollar-sign"></i> <% end %> Pay view _pay.html.erb <!-- Modal: pay invoice --> <div class="modal fade show" id="pay_invoice" tabindex="-1" role="dialog" aria-hidden="true"> <div class="modal-dialog modal-dialog-vertical" role="document"> <div class="modal-content"...

Insert a level o in the existing data frame such that 4 columns are grouped as one

Image
I want to do multiindexing for my data frame such that MAE,MSE,RMSE,MPE are grouped together and given a new index level. Similarly the rest of the four should be grouped together in the same level but different name > mux3 = pd.MultiIndex.from_product([list('ABCD'),list('1234')], > names=['one','two'])###dummy data > df3 = pd.DataFrame(np.random.choice(10, (3, len(mux))), columns=mux3) #### dummy data frame > print(df3) #intended output required for the data frame in the picture given below from Recent Questions - Stack Overflow https://ift.tt/3kG3xmo https://ift.tt/3BkwbjI

Keep Jenkins child process running after build completes

Image
I am trying to figure out how to keep a process running after the Jenkins build completes. I have a build step that is suppose to close the current node.exe process and start it again by calling "npm start". This is the contents of restart_node.bat Taskkill /IM node.exe /F cd C:\node call npm start I can see that is successfully stops and starts a new process, but as soon as the build completes.. the node.exe process gets killed. How can I leave it running after the build? from Recent Questions - Stack Overflow https://ift.tt/3t1NxPj https://ift.tt/38qYSPy

3000 tests - Major performance issues. What can be done?

Our react project has ~3000 jest tests. Most of them are just typical "render without crashing". When we run npm test , the amount of memory used slowly climbs all the way to 22 Gb. On machines with only 16 Gb, the tests grind the entire machine to a halt and take a very long time to finish. What we have tried that has not worked or made the issue worse: --maxWorkers=50% or --maxWorkers=4 etc --runInBand (way too slow) --detectLeaks (half our tests have memory leaks according to this experimental option, but we have no idea what they are or even if they are the cause of this problem) The only thing that works is running the tests on a machine with a large amount of RAM (>= 32Gb). Any idea on how we can reduce the amount of memory used by these tests? from Recent Questions - Stack Overflow https://ift.tt/3jt0Aq0 https://ift.tt/eA8V8J

Unhandled Exception: Null check operator used on a null value in insert method

My app is a todo app, and I need to use a local database, I used sqflite lib and path lib, and i have some obstacles. in the main.dart : void main() async{ WidgetsFlutterBinding.ensureInitialized(); final database=openDatabase( join(await getDatabasesPath(),'todo.db'), onCreate: (db,version){ return db.execute('Create table todos(id INTEGER, title TEXT, dateTime DateTime, timeOfDay TimeOfDay)'); }, version: 1, ); runApp(MyApp()); } in Add Todo screen i have a task title ,a date time and a time of day and i have a button to save this information into the database by this code: TextButton( onPressed: ()async{ await insertTodo(Todo(0, 'num1', selectedDate , selectedTime)); //save(); }, selectTime(BuildContext context)async{ final TimeOfDay? selectedT=await showTimePicker( context: context, initialTime: selectedTime, ); if(selectedT !...

How to tilt hover in CSS

I use this css style for hover: .hvr-link{display:inline-block;vertical-align: middle; -webkit-transform: perspective(1px) translateZ(0); transform: perspective(1px) translateZ(0); box-shadow: 0 0 1px rgba(0, 0, 0, 0); position: relative; -webkit-transition-property: color; transition-property: color; -webkit-transition-duration: 0.3s; transition-duration: 0.3s; } .hvr-link:before { content: ""; position: absolute; z-index: -1; top: 0; bottom: 0; left: 0; right: 0; background: #424141; -webkit-transform: scaleY(0); transform: scaleY(0); -webkit-transform-origin: 50%; transform-origin: 50%; -webkit-transition-property: transform; transition-property: transform; -webkit-transition-duration: 0.3s; transition-duration: 0.3s; -webkit-transition-timing-function: ease-out; transition-timing-function: ease-out; } .hvr-link:hover, .hvr-link:focus, .hvr-link:active{color: white;} .hvr-link:hover:before, .hvr-link:focus:before, .hvr-l...

How to destroy Ionic Component on redirect

I have Ionic 4 Angular app. It has a three-tab structure. The tabs router module looks like this: { path: 'tab1', loadChildren: () => import('../tab1/tab1.module').then((m) => m.Tab1PageModule), }, { path: 'tab2', loadChildren: () => import('../tab2/tab2.module').then((m) => m.Tab2PageModule), }, { path: 'tab3', loadChildren: () => import('../tab3/tab3.module').then((m) => m.Tab3PageModule), } On each tab I have different components which I want to be destroyed by a redirect to another tab. But the Component destroy event doesn't happen. In my case Tab1 has this list: <ion-list> <ion-item routerLink="invites">Invites</ion-item> <ion-item>Friend Requests</ion-item> </ion-list> 'Invites' click takes me to the InvitesComponent . After that, if I click Tab2 InvitesComponent will stay there in its l...

Optimize postgres query avg by month

we have a report based on avg prices basically, we filter those prices based on code and date and use UNION for each month Table example: date code price 2020-01-01 'FS-H21' 150 2020-01-01 'FS-G21' 155 2020-01-02 'FS-H21' 151 2020-01-03 'FS-G21' 148 and the query example: SELECT period, code, avg(closure) FROM period_prices WHERE code = 'FS-F21' AND period BETWEEN '2020-01-01' AND '2020-01-31' GROUP BY period, code UNION SELECT period, code, avg(closure) FROM period_prices WHERE code = 'FS-F21' AND period BETWEEN '2020-02-01' AND '2020-02-29' GROUP BY period, code ... Reproduced table and query at sample query ... I would like some advice on how can i improve the performance of that query, or if there is a better way to achieve this! thanks from Recent Questions - Stack Overflow https://ift.tt/3mMxwvU https://ift.tt/eA8V8J

How do I get historical foreign exchange data on an hourly basis?

My code works. However, I'm receiving the output for each day. I wanted it to give me data for all business hours library(priceR) cur <- historical_exchange_rates("CAD", to = "USD", start_date = "2010-01-01", end_date = "2021-08-29") print (cur) date one_CAD_equivalent_to_x_USD 1 2010-01-01 0.956718 2 2010-01-02 0.956718 3 2010-01-03 0.956718 4 2010-01-04 0.960639 5 2010-01-05 0.962288 I want the output to show date, time and the rate date BH conversion(CAD to USD) 2010-01-01 9:00:00 0.956718 from Recent Questions - Stack Overflow https://ift.tt/3DutpKE https://ift.tt/eA8V8J

Bests fit for a centered child image which parent container dimensions are unknown?

Image
How do I achieve the best fit for a vertically and horizontally centered image which parent container dimensions are unknown? See the below layouts ( codepen for reference): The child image fits its parent container as expected when at least one dimension of the child exceeds one dimension of the parent, but I cannot get the image to stretch and fill the parent when the image is smaller in both dimensions than its container (see 150x150 and 150x50 cases). Hod do I achieve best fit for all cases using CSS only? My css for reference (see link to codepen above): .parent { position: relative; background: gray; display: inline-block; } .square { width: 200px; height: 200px; } .tall { width: 200px; height: 300px; } .wide { width: 300px; height: 200px; } .child { position: absolute; top: 50%; transform: translateY(-50%); left: 0; right: 0; margin: auto; max-width: 100%; max-height: 100%; } from Recent Questions - Stack Overflow https://ift.tt/3gJ6a...

How to filter and sort nested objects? ReactJS

Data sample: const people = [ 1:{ id : 1, name: 'James', age: 31, toBeDeleted: false, position: 2 }, 2:{ id : 2, name: 'John', age: 45, toBeDeleted: true, position: 3 }, 3:{ id : 3, name: 'Paul', age: 65, toBeDeleted: false, position: 1 } ]; I try this way, but it doesn't work : const sorted = Object.values(people) .filter((people) => people.toBeDeleted !== true) .sort((a, b) => a.position - b.position); If I delete the id keys, then my code works. In result must be array like this : const people = [ { id : 3, name: 'Paul', age: 65, toBeDeleted: false, position: 1 }, { id : 1, name: 'Jame...

Problems when rotating the view matrix (OpenGL)

Image
Setting: I have a view matrix which in the beginning is the identity matrix. R,U,F = X, Y, Z axes. I rotate the view matrix by creating a matrix from the given X,Y,Z rotation angles. Problem: When I first rotate the view matrix by some Z angle (e.g. 45°) and subsequently rotate it by some Y angle, my scene doesn't rotate horizontally (e.g. from left to right), but in the direction given by the view matrix' Y axes. What I had expected was that the view matrix, which is "tilted sideways" 45° whould then be rotated by my Y angle. Here is some Python code: viewer = CCamera () viewer.UpdateAngles (0,0,45) # bank 45°, i.e. tilt the scene viewer.UpdateAngles (0,10,0) # should rotate the scene sideways, simulating a change of heading What happens is that the scene is rotated diagonally, i.e. around the Y axis of the "tilted" view angle. import numpy as np class CCamera: def __init__ (self, name = ""): self.orientation = CMatrix () ...

Handling Infinity in JavaFX numerical TextField

I have a JavaFX TextField specialized to accept numbers, including scientific notation. It does pretty much everything I want. But, because it accepts scientific notation, it is easy for a user to enter a number beyond the range that can be represented by a double . When they do, the TextField displays "Infinity" (or "-Infinity"). When that happens the field can no longer be edited to correct the problem. The contents cannot be selected and deleted either. Tapping the "Escape" key does not return to the previous contents. Here is an SSCCE, based closely on the answer by James_D to this question a few years ago. import java.text.DecimalFormatSymbols; import java.util.function.UnaryOperator; import java.util.regex.Pattern; import javafx.application.Application; import javafx.beans.value.ObservableValue; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.TextField; import javafx.scene.control.TextFormatter; import javafx....

Convert date column to columns 'start' and 'end' using regex

Image
I have a pandas DataFrame with some text and dates as strings. pd.DataFrame({'dates': ['start 01.01.2020', # Only start date 'start 10.10.2019, end 20.20.2019', '01.05.2019', # Only start date '01.11.2019-04.11.2019']}) I want to create two new columns; start and end . Some rows have both start and end date , but some rows only have start date . For rows with only start date, the start and end date is the same. The resulting table should look like this: So far I've tried to extract the dates using regex, but I cannot seem to figure it out. from Recent Questions - Stack Overflow https://ift.tt/3jv4RJw https://ift.tt/3sZNLqb

Why mdev or udev does not create disk nodes when used kernel is from any distribution

I created a minimal linux init with just busybox to do experiments or use it to recover my work linux. But i got stuck and was fustruted alot that i could not find any disks in /dev. I tried both mounting udev as devtmpfs and tmpfs with mdev -s. Both none seemed to work. Lickily i tried compiling a kernel and booting it i realised kernel was the issue. I also noticed my pluged mouse light was off as if the pc was turned off I tried kernel from both debian and ubuntu. But same result. Now im happy with what i got. But using custom kernel means i cant make use of the already existing drivers on a target linux when i do chroot. So i wanna know why the kernels that come with distros does not generate disk blocks from Recent Questions - Stack Overflow https://ift.tt/2WBZFeh https://ift.tt/eA8V8J

looping through a list of dataframes, writing each element of that list to a new .csv file on disk

I have a list of dataframes and am attempting to export each using the pandas.df.to_csv method to a folder on disk. However, only the last item in the list of dataframes is being written to disk as a .csv Please see code below: import pandas as pd import os import datetime from pathlib import Path CSV_Folder = Path('C:\PA_Boundaries\Tests') Output = r'C:/PA_Boundaries/test_output' today = datetime.date.today() date = today.strftime('%Y%m%d') try: dfs = [] for file in os.listdir(CSV_Folder): df = pd.read_csv(CSV_Folder / file) dfs.append(df) new_dfs = [] for df in dfs: new_df = pd.DataFrame() new_df['Original Addr string'] = df['StreetConc'] new_df['Addr #'] = df['AddNum'] new_df['Prefix'] = df['StPreDir'] new_df['Street Name'] = df['StName'] new_df['StreetType'] = df['StType'] new_df[...

Render component of logged client type using React Hooks

I am new to react and react hooks. I am currently working on a coupon project with a back end using spring boot. I am able to be using a login form using react hooks which successfully logs in with credentials. My issue is how do I redirect to the specific component once logged in depending on the client type. e.g if I log in as a CUSTOMER . react will redirect me to Customer component. In my project I have 3 different client types. ADMINISTRATOR COMPANY CUSTOMER I am not entirely sure on what approach I should use for this method Login form: import { Button } from "../Button/Button"; import "./Login.scss"; import loginImage from "../Assets/login.png"; import { NavLink, useHistory } from "react-router-dom"; import { useForm } from "react-hook-form"; import Select from 'react-select'; import CredentialsModel from "../../Models/CredentialsModel"; import axios from "axios"; import globals from "../.....

How to handle aggregated query results with SQLAlchemy, pydantic and FastAPI

I would like to create an API that returns the aggregated values for each department as a response. I am new to FastAPI and pydantic and would appreciate any support. It seems the part where the query results are mapped in pydantic is not working well. get method in main.py @app.get("/api/{client_id}", response_model=List[schemas.Overview]) def read_overview(client_id: str, db: Session = Depends(get_db)): db_overview = crud.get_overview(db, client_id=client_id) if db_overview is None: raise HTTPException(status_code=404, detail="Overview not found") return db_overview crud.py Get the data corresponding to the three department codes, 1000001, 1000002, and 2000001, aggregated by client_id and deptCode. from sqlalchemy.orm import Session from sqlalchemy import func from . import models, schemas import datetime def get_overview(db: Session, client_id: str): text = '1000001,1000002,2000001' depts = text.split(',') tbl...

Is there any potential problem with double-check lock for C++?

Here is a simple code snippet for demonstration. Somebody told me that the double-check lock is incorrect. Since the variable is non-volatile, the compiler is free to reorder the calls or optimize them away( For details , see codereview.stackexchange.com/a/266302/226000). But I really saw such a code snippet is used in many projects indeed. Could somebody shed some light on this matter? I googled and talked about it with my friends, but I still can't find out the answer. #include <iostream> #include <mutex> #include <fstream> namespace DemoLogger { void InitFd() { if (!is_log_file_ready) { std::lock_guard<std::mutex> guard(log_mutex); if (!is_log_file_ready) { log_stream.open("sdk.log", std::ofstream::out | std::ofstream::trunc); is_log_file_ready = true; } } } extern static bool is_log_file_ready; extern static std::mut...

How to secure web api to validate openid token generated by Client application?

OpenId Connect configuration in start up.cs file of Client app : services.AddAuthentication(options => { options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme; options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; }) .AddCookie() .AddOpenIdConnect(options => { options.ClientId = azureAdConfig.ClientId; options.ClientSecret = azureAdConfig.ClientSecret; options.Authority = string.Format(https://login.microsoftonline.com/, azureAdConfig.Tenant); options.ResponseType = OpenIdConnectResponseType.CodeIdToken; options.Resource = azureAdConfig.ResourceURI_Graph; options.Events = new AuthEvents(azureAdConfig, connectionStringsConfig); }); I want to p...

how to put data into Excel table with for loop pandas?

Image
Following my previous question , now i'm trying to put data in a table and convert it to an excel file but i can't get the table i want, the excel file contains just the last hotel in my list if anyone can help or explain what's the cause of it, this is the final output i want to get this the data i'm printing Byzance Nabeul : Chambre Double - {'All Inclusive soft': ('208', '166', '25%'), 'Demi Pension': 138} Palmyra Club Nabeul Nabeul : Double Standard - {'All Inclusive soft': ('225', '180', '25%')} and here is my code #!/usr/bin/env python # coding: utf-8 import time from time import sleep import ast import xlwt from selenium import webdriver from selenium.webdriver.support.ui import WebDriverWait, Select from selenium.common.exceptions import StaleElementReferenceException, NoSuchElementException from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common....

Outlook VBA extract text from custom flags

I am fairly new to MS Outlook 2016 VBA. I handle a considerable number of emails every day on a 24x7 basis. I keep on flagging emails with custom text to enable me to track emails and correlate each with the other. Unfortunately, however, I do not understand as to how to write an Outlook VBA to extract emails that are flagged along with custom texts in each flagged email in a folder. I could manage to follow VBA code available at VBA Express forum . The code is as follows: Sub CountItems() Dim objMainFolder As Outlook.folder Dim lItemsCount As Long 'Select a folder Set objMainFolder = Outlook.Application.Session.PickFolder If objMainFolder Is Nothing Then MsgBox "You choose select a valid folder!", vbExclamation + vbOKOnly, "Warning for Pick Folder" Else 'Initialize the total count lItemsCount = 0 Call LoopFolders(objMainFolder, lItemsCount) End If 'Display a message for the total count...

I need help deploying my vue app on netlify

I've done this many times in the past, I'm getting this error in the netlify logs. The repo I am attempting to deploy is https://github.com/yanyamz/Key_Visual_Arts . I checked to see if it was within size limitations of Netlify and it is, totally 15mb or so vs the 20+mb that you can deploy on netlify. 12:03:03 PM: Build ready to start 12:03:04 PM: build-image version: fa439ad1ab9393b2c0d449d8d7c033927683f4b0 12:03:04 PM: build-image tag: v4.3.0 12:03:04 PM: buildbot version: 0f2f658d862cfe72bae7cc05c6a8de0426a5a0e2 12:03:04 PM: Fetching cached dependencies 12:03:05 PM: Failed to fetch cache, continuing with build 12:03:05 PM: Starting to prepare the repo for build 12:03:05 PM: No cached dependencies found. Cloning fresh repo 12:03:05 PM: git clone https://github.com/yanyamz/Key_Visual_Arts 12:03:07 PM: Preparing Git Reference refs/heads/main 12:03:07 PM: Parsing package.json dependencies 12:03:08 PM: ​ ❯ Initial build environment baseRelDir: true branch: main context: produc...

How do i write a function that takes as an argument it's returned value and so on for a determined number of times [closed]

I want to write a function in python that takes as argument a value1 and returns value2 then takes this value2 as argument and returns value3 and so on untill i reach value27 from Recent Questions - Stack Overflow https://ift.tt/3jqPRfP https://ift.tt/eA8V8J

How to display stored data in bullets or any other html tag?

Image
I am getting data from database and storing it in react state which contains data form of different html tags for example < p >hello this is data</ p > < ul >< li >hello</ li >< li >hello</ li >< li >hello</ li ></ ul > when i want to render this data {this.state.data} instead of showing this data in bullets react is simply rendering this as it is. How to render this data in bullets as following hello hello from Recent Questions - Stack Overflow https://ift.tt/3gEF5AI https://ift.tt/3ztotU0

How to set locale in postgres using docker-compose?

I've tried multiple ways of changing the locale to en_GB and nothing seems to work. My current docker-compose.yml version: '3.9' services: db: image: postgres restart: always build: context: . dockerfile: ./Dockerfile ports: - 5432:5432 volumes: - ./pg-data:/var/lib/postgresql/data environment: POSTGRES_USER: ${POSTGRES_USER} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} POSTGRES_DB: ${POSTGRES_DB} PGDATA: ${PGDATA} # LANG: 'en_GB.UTF-8' adminer: depends_on: - db image: adminer restart: always ports: - 8080:8080 volumes: pg-data: An official postgres image docs says to create a Dockerfile with: FROM postgres RUN localedef -i en_GB -c -f UTF-8 -A /usr/share/locale/locale.alias en_GB.UTF-8 ENV LANG en_GB.utf8 However this has no effect whatsoever.. Tried setting enviorment variable LC_* and LANG however this throws build error of enviorment variables...

A custom similarity function in elasticsearch

I want to make a custom "similarity". Actually, I just want to improve the default Okapi BM25 from ES doc . I want to add one more condition to Okami BM25's logic. This condition equals if count the number of occurrences of the searched_word in the doc > 3 return 0.0 else OkamiBM25() in pseudocode it looks like: score(D, Q)=0 if the count of the searched_word > 3 in the doc . In my understanding, I have to make a custom "similarity" following the official ES doc recommendations and after it implements the formula of Okapi BM25 Wiki . As I understand I can describe it as the Okapi BM25 formula from Wiki above and in the return statement return=0 if searched_word > 3 . But I'm wondering is it possible to wrap the default implementation of Okapi BM25 into my custom "similarity" function and then make a condition something like that return doc.freq > 3 ? 0.0 : OkapiBm25(); Unfortunately, I was not able to find such an example from Re...

Is there a way to delete a scheduled task if you only know the filename of the application the task will run

I need to delete a scheduled task on a large number of machines preferably using only the command line. The problem is that the tasks were manually added on every computer, so the name of the task is not consistent between each one. I was hoping I could delete the task using the name of the exe file that the task runs, but this does not appear to be an option of the schtasks command. I thought I was making progress using this command, but its not returning the name of the task for it to then be deleted. for /f "tokens=3 delims=\" %%x in ('schtasks /query /fo:list ^| findstr ^^PrintTask.exe') do schtasks /Delete /TN "%%x" /F from Recent Questions - Stack Overflow https://ift.tt/3ztBWLA https://ift.tt/eA8V8J

What causes cdk bootstrap to hang?

I am trying to use the cdk bootstrap command. >$env:CDK_NEW_BOOTSTRAP=1 >npx cdk bootstrap --cloudformation-execution-policies arn:aws:iam::aws:policy/AdministratorAccess aws://1234.../us-east-1 I get the output: CDK_NEW_BOOTSTRAP set, using new-style bootstrapping. Bootstrapping environment aws://1234.../us-east-1... I just hangs at this point. On one attempt I came back more than an hour later and it was still stuck. An s3 bucket with the prefix cdk did show up but has no files. I've attempted to run it a few times but it's always the same. What can cause it to get stuck this way? from Recent Questions - Stack Overflow https://ift.tt/3zrzIfy https://ift.tt/eA8V8J

I can't get JSON to display what are my missing?

I'm developing a JSON webpage that would basically display all data returned by the server. However, it doesn't work. I tried everything taht I could think of, but it still doesn't work. Please help. I didn't receave any error or warnings. The webpage is just nothingness. The data should be display in a tag but it is not. let arrayForData = []; function showFamilyInfo() { fetch('users.json') .then(function(response) { response.json() .then(function(data) { let parseData = data; console.log(parseData); parseData.forEach(function(element) { for (let i in parseData[element]) { arrayForData.push(`' <p> ${element[i]}: ${i.FirstName} ${element[i]}: ${i.LastName} ${element[i]}: ${i.Age} ${element[i]}:${i.Gender} </p> '`); } }); document.getElementById('demo').innerHTML = arrayForData.join(); }) .catch(function(error) ...

Vue 3 on page refresh

this is my first try on vue 3. im making a to-do list app. my data is saved in vuex but at the same time i cant see it on the screen. i can see the same things when i do it in vue 2 but i cant see it in vue 3. The screen does not update even though . call getters with computed. Template: <template> <div class="row mt-5"> <div class="col-xs-12 col-md-4"> <div class="card text-center"> <div class="card-middle" v-for="item in getTask(1)"> <div class="card-content" :style="{ 'background-color': item.color }"> <h4></h4> </div> </div> </div> </div> <div class="col-xs-12 col-md-4"> <div class="card text-center"> <div class="card-middle" v-for="item in getTask(3)"> <...

The method 'getString' was called on null. Receiver: null Tried calling: getString("name")

I am having a error The method 'getString' was called on null. Receiver: null Tried calling: getString("name") I already instantiated firebaseFirestore = FirebaseFirestore.instance; sharedPreferences = await SharedPreferences.getInstance(); class _HomePageState extends State<HomePage> { HomepageBloc _bloc; ScrollController _scrollController = ScrollController(); TextEditingController _userNameSearchController = TextEditingController(); String userName = sharedPreferences.getString(SharedPreferencesKey.name); String userToken = sharedPreferences.getString(SharedPreferencesKey.token); @override void initState() { super.initState(); _bloc = HomepageBloc(userToken); } @override void dispose() { super.dispose(); _bloc.dispose(); } I don't know why I am getting this error, it would be wonderful if this error can be solved from Recent Questions - Stack Overflow https://ift.tt/38n2IJv https://ift.tt/eA8V8J

What function should I use to change image using left and right arrow keys

I have a gallery. of images, I need to change the image when the user will press the arrow keys after the modal popup. left arrow key to change the image to the left and the right arrow key for right. I'm pretty new to JavaScript so I couldn't understand what function should I use to change the images to left and right. I tried .modal { width: 58%; height: 100%; top: 0; position: fixed; display: none; background-color: rgba(22, 22, 22, 0.5); margin-left: 300px; max-width: 779px; min-width: 779px; } .modal-content { margin: auto; display: block; width: 80%; max-width: 700px; } .mySlides { display: none; } .mySlides { display: none; } .cursor { cursor: pointer; } .cursor { cursor: pointer; } .prev { cursor: pointer; position: relative; top: -149px; padding: 16px; margin-top: -50px; color: white; font-weight: bold; font-size: 20px; border-radius: 0 3px 3px 0; user-select: none; -webkit-user-select: none; left: -10...

How to access Context within a Class Component for react native?

I want to use my Context in a class component (MyEventsScreen), but whenever I do so, I get an error saying it is an invalid hooks call. Here is MyEventsScreen.js (I've simplified it to be brief): import { useAuthState } from "../contexts/authContext"; export default class MyEventsScreen extends Component { render() { return ( <View> <Text></Text> </View> } I have my authContext.js here: import React from "react"; import { authReducer } from "../reducers/authReducer"; const AuthStateContext = React.createContext(); const AuthDispatchContext = React.createContext(); function AuthProvider({ children }) { const [state, dispatch] = React.useReducer(authReducer, { isLoading: true, isSignout: false, userToken: null, email: null, userID: null, }); return ( <AuthStateContext.Provider value={state}> <AuthDispatchContext.Provider value={dispatch}> ...

filesystem value_type pointer to string?

I have a directory_iterator and I want the filename but I can't seem to get anything to work, it just throws an error saying that value_type* cannot be converted into a string . I can't cast it to a string and std::to_string() doesn't work either! for (auto& p : std::experimental::filesystem::directory_iterator(dir)) { auto path = p.path().filename().c_str(); char f[50] = "Json/"; std::strcpy(f, path); std::ifstream comp(f, std::ifstream::binary); } from Recent Questions - Stack Overflow https://ift.tt/3zud7yX https://ift.tt/eA8V8J

Docker Unauthorized when pulling

I have tried pulling my files numerous times on Windows 10, but right when it begins extracting a certain large file (1.3G), it halts and says 'unauthorized'. I have tried fixing this issue by going to Docker -> Setting -> Shared, but 'Shared' does not pop up. I even created an account on hub.docker.com, logged on, then ran it, but the same thing happened. As a last resort, I then uninstalled docker and reinstalled it - still does not work. Has anyone encounter these issues/does anyone know what to do from here? Thank you Edit for clarification I am pulling from dockerhub: https://hub.docker.com/r/jimiucb1/i526-aml The command is: docker pull jimiucb1/i526-aml from Recent Questions - Stack Overflow https://ift.tt/38kTygC https://ift.tt/eA8V8J

Block django allauth default signup/login url

I am rendering my django-allauth signin/signup form through custom URLs. from allauth.account.views import LoginView, SignupView urlpatterns = [ ... url(r'^customurl/login/', LoginView.as_view(), name="custom_login" ), url(r'^customurl/signup/', SignupView.as_view(), name="custom_singup" ), ... ] These are working fine. The problem is django-allauth default singin/singup urls working also. How can I block default signin/signup URLs? from Recent Questions - Stack Overflow https://ift.tt/3BoJCiA https://ift.tt/eA8V8J

How can I set label location in Pine Script so its on the line and not above or below it?

Image
I want the value to be placed on the line and not below bar. How do I do that? I only see abovebar and belowbar in pine-script manual. Above and below is making my chart look very messy. if isBullEngulf bullEngulfOpen := line.new(bar_index - 1, open[1], bar_index, open[1], extend=extend.right, color=color.black) bullEngulfLow := line.new(bar_index - 1, low < low[1] ? low : low[1], bar_index, low < low[1] ? low : low[1], extend=extend.right, color=color.green) bullEngulfLowPrice = line.get_y1(bullEngulfLow) offset = input(15, maxval=900, title="Label Offset",step=5) tl = offset *(time - time[1]) bullEngulfLowLabel := label.new(x = t1 + time, y = na, text="\n"+tostring(bullEngulfLowPrice), style=label.style_none,size=size.normal,textcolor=color.white, yloc=yloc.belowbar) //bullEngulfLowLabel := label.new(x = bar_index, y = na, text="\n"+tostring(bullEngulfLowPrice), style=label.style_none,size=size.nor...

Matplotlib: how to draw an axes title at the left-most position?

Image
I'm drawing my axes title with the method ax.set_title("Horizontal Bars", ha="left", x=0, fontsize=16) and it draw as below: How do I draw it in the left-most position, as the "title here" in red above? from Recent Questions - Stack Overflow https://ift.tt/3mIeCpD https://ift.tt/2WzCG3u

What does __latent_entropy is used for in C

Please I would like to understand in which case do we use the keyword __latent_entropy in a C function signature. I saw some google results talking about a GCC plugin, but I don't still understand what is its impact. Thanks from Recent Questions - Stack Overflow https://ift.tt/3sXTQn7 https://ift.tt/eA8V8J

Dynamically adding functions to array columns

I'm trying to dynamically add function calls to fill in array columns. I will be accessing the array millions of times so it needs to be quick. I'm thinking to add the call of a function into a dictionary by using a string variable numpy_array[row,column] = dict[key[index containing function call]] The full scope of the code I'm working with is too large to post here is an equivalent simplistic example I've tried. def hello(input): return input dict1 = {} #another function returns the name and ID values name = 'hello' ID = 0 dict1["hi"] = globals()[name](ID) print (dict1) but it literally activates the function when using globals()[name](ID) instead of copy pasting hello(0) as a variable into the dictionary. I'm a bit out of my depth here. What is the proper way to implement this? Is there a more efficient way to do this than reading into a dictionary on every call of numpy_array[row,column] = dict[key[index containing function c...

Is There A Way To Attach Relationship(One-One, One-Many, Many-Many) When Importing Data From Excel In Laravel?

Is there a way to attach relationship in laravel directly in just one function? For example I had Three Table in Database: users(first table), user_role(relationship table), and roles(second table) In controller, AdminController.php I had this: public function import_student(Request $request) { $user = Auth::user(); $this->validate($request, [ 'file' => 'required|mimes:csv,xls,xlsx' ]); $file = $request->file('file'); $nama_file = rand().$file->getClientOriginalName(); $file->move('file_student',$nama_file); Excel::import(new UserImport, public_path('/file_student/'.$nama_file)); Session::flash('sukses','Data Siswa Berhasil Diimport!'); return redirect()->back(); } and in import, UserImport.php I had this: use App\User; use Maatwebsite\Excel\Concerns\ToModel; use Maatwebsite\Excel\Concerns\WithMultipleSheets; use Maatwebsite\Excel\Concerns\WithConditionalS...

Pivot table into cross reference table

I have a list of students who are assigned into groups 4 different groups for 3 weeks or more. Here is the table. student week 1 week 2 week 3 A 1 4 2 B 2 2 1 C 3 4 4 D 4 3 3 E 1 1 2 F 2 2 1 G 3 1 4 H 4 3 3 I 1 1 2 J 2 2 1 I want to pivot that table and see how many times a student worked with another student in a group. For example, student A worked with student J twice and student B worked with student F three times, whereas B and C never worked together. How can I generate a pivot table in excel like the one below? The values in the table below show many times a student has been in the same group with another student. FIELD1 A B C D E F G H I J A - 2 2 2 B - - 3 3 C - - - 2 D - - - - 2 E - - - - - 2 F - - - - - - 3 G - - - - - - - H - - - - - - - - I - - - - - - - - - ...

allow inbound traffic in network security group in azure for a dynamic IP

We need to allow a platform traffic to reach our systems (as I know adding a static public IP in our network security group in azure), but they mention that they don't have a static public IP or a range of IPs to whitelist, but instead a static domain name What I found in azure documentation and some questions is that filtering traffic based on FQDN is impossible for now in network security group resource ! Is there any other possibility to achieve this ? The Azure firewall seems just working for outbound rules (as I understand from azure documentation) Still waiting, help please !! from Recent Questions - Stack Overflow https://ift.tt/3mCf8po https://ift.tt/eA8V8J

Selecting a large range of values to recode in R

I want to recode a large number of variables across multiple columns. Here is an example df df <- data.frame( id_number = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), age = c(10, 11, 12, 13, 14, 15, 16, 17, 18, 19), abc1 = c(501, 502, 503, 504, 505, 506, 507, 508, 509, 510), abc2 = c(501, 502, 501, 501, 502, 501, 502, 503, 501, 502), abc3 = c(501, 506, 501, 501, 510, 501, 510, 501, 501, 501), abc4 = c(507, 505, 501, 501, 501, 501, 501, 501, 501, 501) ) df The columns abc1:abc4 has values 501:510 and I am trying to recode 501:508 as 91, 509 as 92 and 510 as 93 across all these columns at once. Here is what I tried - library(dplyr) df1 <- df %>% mutate(across( abc1:abc4, ~ recode( .x, `501:508` = 91L, `509` = 92L, `510` = 93L ) )) But I get an error x NAs introduced by coercion ℹ Input ..1 is across(abc1:abc4, ~recode(.x, `501:508` = 91L, `509` = 92L, `510` = 93L)) .NAs introduced by coercionProblem with mutate() input .....

Binding not Updating on DependencyProperty - no XAML binding failure shown

I'm creating a fairly basic calendar control - showing time slots during the day, kind of like the Outlook calendar does. The full XAML for my control is pretty simple so I'll post in full: <UserControl x:Class="AJSoft.Controls.Diary.Calendar.CalendarTimeStrip" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:AJSoft.Controls.Diary.Calendar" Name="ucCalendarTimeStrip" > <ListBox ItemsSource="{Binding ElementName=ucCalendarTimeStrip, Path=TimeItemsSource, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" /> </UserControl> Like I said - simple. I normally don...