By elliot silver on Jul 03, 2021 04:02 am I am trying to make a sign in page to my app using firebase but it says "Cannot find 'ContentView' in scope" and I don't know why Here is my RecipyApp.swift import SwiftUI import Firebase @main struct RecipyApp: App{ @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate var body: some Scene{ let viewModel = AppViewModel WindowGroup{ ContentView() .environmentObject(viewModel) } } } class AppDelegate: NSObject, UIApplicationDelegate{ func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { FirebaseApp.configure() return true } } Here is my ContentView.swift import SwiftUI import FirebaseAuth class AppViewModel: ObservableObject{ let auth = Auth.auth() @Published var signedIn = false var isSignedIn: Bool { return auth.currentUser != nil } func singIn(email: String, password: String){ auth.signIn(withEmail: email, password: password) { [weak self] result, error in guard result != nil, error == nil else{ return } DispatchQueue.main.async { self?.signedIn = true } } func singUp(email: String, password: String){ auth.createUser(withEmail: email, password: password) { [weak self] result, error in guard result != nil, error == nil else{ return } DispatchQueue.main.async { self?.signedIn = true } } } struct ContentView: View { @EnvironmentObject var viewModel: AppViewModel var body: some View { NavigationView{ if viewModel.signedIn{ Text("Signed In") } else{ SignInView() } } .onAppear { viewModel.signedIn = viewModel.isSignedIn } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } } } struct SignInView: View { @State var email = "" @State var password = "" @EnvironmentObject var viewModel: AppViewModel var body: some View { VStack{ TextField("Email Address", text: $email) .padding() .background(Color(.secondarySystemBackground)) SecureField("Password", text: $password) .padding() .background(Color(.secondarySystemBackground)) Button(action: { guard !email.isEmpty, !password.isEmpty else{ return } viewModel.singIn(email: email, password: password) }, label: { Text("Sign In") .frame(width: 200, height: 50) .background(Color.blue) .foregroundColor(.white) .cornerRadius(8) }) } .padding() Spacer() } } } struct SignUpView: View { @State var email = "" @State var password = "" @EnvironmentObject var viewModel: AppViewModel var body: some View { VStack{ TextField("Email Address", text: $email) .padding() .background(Color(.secondarySystemBackground)) SecureField("Password", text: $password) .padding() .background(Color(.secondarySystemBackground)) Button(action: { guard !email.isEmpty, !password.isEmpty else{ return } $viewModel.singUp(email: email, password: password) }, label: { Text("Create Account") .frame(width: 200, height: 50) .background(Color.blue) .foregroundColor(.white) .cornerRadius(8) }) } .padding() Spacer() } } Why do I get this error because I have a ContentView struct? Please any help would be appreciated as it has currently stopped development Read in browser »  By Meet patel on Jul 03, 2021 04:02 am I have one array of JSON object. [{ Email: 'aa@gmail.com', status: 'Success' } { Email: 'bb@gmail.COM', status: 'Fail' } { Email: 'aa@gmail.COM', status: 'Fail' } { Email: 'cc@gmail.com', status: 'Success' }] Now I want list of Email that have different value in status with same Email. from above example I can expect email aa@gmail.com because at first position aa@gmail.com have value Success and at third position aa@gmail.com have value Fail. How can achieve that in Java Script? Read in browser »  By caramel1995 on Jul 03, 2021 04:02 am Why the regex ^data_.+(?!_n)$ matches the string data_haha_n when there's a _n at the end of the string? Won't regex (being greedy by default) try to match as much as possible due to the .+ and after that found out it still need to match the negative lookahead _n, then perform reverse looping twice, and try to perform a match in order to determine if the last 2 characters are _n or not? Read in browser »  By Andy Min on Jul 03, 2021 04:02 am using System.Collections; using System.Collections.Generic; using UnityEngine; public class Enemy : MonoBehaviour { public float moveSpeed = 0.5f; // Use this for initialization void Start() { } void MoveControl() { float yMove = moveSpeed * Time.deltaTime; transform.Translate(0, -yMove, 0); } // Update is called once per frame void Update() { MoveControl(); } } Read in browser »  By Geeky Person on Jul 03, 2021 04:01 am bool isValid(int x, int y, vector<vector<int>> &arr) { if (x >= 0 && x <= arr.size() && y >= 0 && y <= arr[0].size() && arr[x][y] == 1) return true; return false; } - I am getting segmentation fault on this ( x <= arr.size() and y<=arr[0].size() ) of the code.
- Can you guys please explain why I am getting this even if I am not accessing the out of bound value and I am just comparing it.
Read in browser »  By cyco lo on Jul 03, 2021 04:01 am I have 3000 text files in a directory and each .txt file contain single column data. i want to arrange them side by side to make it a mxn matrix file. For this i tried printf "%s\n" *.txt | sort -n | xargs -d '\n' paste However it gives error paste: filename.txt: Too many open files please suggest a better solution for the same using python. Read in browser »  By LePyka on Jul 03, 2021 04:01 am I'm trying for some time to create a barplot in R or Ggplot2, where the bars have no fill, but differ exclusively over the linetype (solid, dotted). Unfortunately, I haven't found a solution yet, and I haven't found a working solution in old posts either. This is my Barplot so far. ggplot(DWP1, aes(x = reorder(word, n), y = n,reorder(word,-n)))+ theme_void() + geom_col(aes(fill = word), width = 0.1, position = position_dodge(-0.9), linetype="dotted")+ geom_text(aes(label = word), position = position_dodge(0.1), hjust=0, vjust = -1.2, size = 2)+ coord_flip() + scale_fill_manual(values=c("black", "black", "black"))+ scale_y_continuous(expand = expansion(mult = c(0, .1))) + # scale_linetype_manual("", values=c(Nutzer2Format))+ Zeile unnötig glaube ich theme(axis.line.y = element_line(), plot.margin = unit(rep(0, 4), "pt")) + guides(fill = "none") I would appreciate 1-2 tips on how to make it so that the bars are not filled, but the border is "dotted". Thank you very much and have a great weekend! Read in browser »  By Sachin Liyanage on Jul 03, 2021 04:01 am Is it okay to update to Windows 11? According to me, I think it's still unstable because what we are going to install is a developer preview, not even a beta version. So is it okay to wait for a stable version or should I install this version? Read in browser »  By Alejandro A on Jul 03, 2021 04:00 am I have two dfs that have same columns and contain same information, but from different sources: df_orders = pd.DataFrame({'id':[1,2,3],'model':['A1','A3','A6'], 'color':['Red','Blue','Green']}) df_billed = pd.DataFrame({'id':[1,6,7],'model':['A1','A7','B1'], 'color':['Purple','Pink','Red']}) Then I do a merge left on the df_billed by ids and add sufixes as column names overlap: merge_df = pd.merge(df_billed,df_orders,on='id',how='left',suffixes=('_order','_billed')) Results in id|model_order|color_order | model_billed | color_billed 0 1 | A1 | Purple | A1 | Red 1 6 | A7 | Pink | NaN | NaN 2 7 | B1 | Red | NaN | NaN The column order has more priority when the suffix is _order than billed, and somehow I would like to have a dataframe where if no billed info, then we take the order, and the suffixes are removed: id|model_billed | color_billed | 0 1 | A1 | Red | 1 6 | A7 | Pink | 2 7 | B1 | Purple | Ideally I thought of doing a combine_first to coalesce the colums and at the end rename them, but looks a bit dirty in code and looking for another more well-designed solution. Read in browser »  By Frederik on Jul 03, 2021 04:00 am considering a function returning a collection, i.e. ndarray incase the function is missing some data preventing it to generate the ndarray to return if not np.any(x_target): LOG.warn('x_target missing for input param: ....') return None Generically speaking, would it preferable to return None or an empty ndarray? Does it make a difference? Of course throwing an exception could be considered too, since the situation is not that exceptional or severe i decided not to throw an exception. Welcome to disagree. Read in browser »  By Bunsenbrenner14 on Jul 03, 2021 03:58 am So im coding a discord bot right now and this message appeard. I also included all libraries but its not working. Im a python noob so i dont no what to do. Need help. Any suggestions? client = discord.Client() client = commands.Bot(command_prefix = '.') client.remove_command('help') Here the message Message picture Read in browser »  By Ajith Ram on Jul 03, 2021 03:57 am in my case , i need to add one file and one String value to formData. File Value is appending but string value is not appending const uploadClickHandler=()=> { const formData = new FormData(); for(let i = 0; i< files.length; i++) { formData.append('file', files[i]) } formData.append('name','ajith') console.log(formData); axios.post('http://localhost:8080/hello/',formData,{ headers: { "Content-Type":"multipart/form-data" } }) In server Side, only file is coming, not string value. Read in browser »  By Fabio Favoretto on Jul 03, 2021 03:56 am I wanted to create a custom function to calculate confidence intervals of a column by creating two columns called lower.bound and upper.bound. I also wanted this function to be able to work within dplyr::summarize() function. The function works as expected in all tested circumstances, but it does not when the column is named "x". When it is it draws a warning and returns NaN values. It only works when the column is specifically declared as .$x. Here is an example of the code. I don't understand the nuance... could you point me to the right direction in understanding this? set.seed(12) # creates random data frame z <- data.frame( x = runif(100), y = runif(100), z = runif(100) ) # creates function to calculate confidence intervals conf.int <- function(x, alpha = 0.05) { sample.mean <- mean(x) sample.n <- length(x) sample.sd <- sd(x) sample.se <- sample.sd / sqrt(sample.n) t.score <- qt(p = alpha / 2, df = sample.n - 1, lower.tail = F) margin.error <- t.score * sample.se lower.bound <- sample.mean - margin.error upper.bound <- sample.mean + margin.error as.data.frame(cbind(lower.bound, upper.bound)) } # This works as expected z %>% summarise(x = mean(y), conf.int(y)) # This does not z %>% summarise(x = mean(x), conf.int(x)) # This does z %>% summarise(x = mean(x), conf.int(.$x)) Thanks! Read in browser »  By Vaidehi Bhopatkar on Jul 03, 2021 03:55 am I am building a dashboard in plotly dash. I am using dcc.dropdown, I have a total of 40 values to show. Now, I want to add select all options in that. I have tried the below code but you have to select one by one option and it considers all options selected. Can anyone please help to find out how to select all values at once? import dash import dash_core_components as dcc import dash_html_components as html from dash.dependencies import Input, Output, State from dash.exceptions import PreventUpdate import dash import dash_core_components as dcc import dash_html_components as html import dash_daq as daq from dash.dependencies import Input, Output, State import plotly.graph_objs as go from dash.exceptions import PreventUpdate xTime=['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun','Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] listofY=['y1','y2','y3','y4','y5','y6','y7','y8','y9','y10'] Table={ 'y1':[20, 14, 25, 16, 18, 22, 19, 15, 12, 16, 14, 17], 'y2':[19, 18, 22, 14, 15, 19, 15, 14, 14, 21, 16, 16], 'y3':[11, 14, 21, 16, 16, 10, 15, 11, 10, 12, 11, 16], 'y4':[14, 10, 27, 14, 16, 14, 15, 18, 14, 12, 12, 16], 'y5':[16, 15, 22, 18, 18, 19, 15, 13, 15, 12, 18, 17], 'y6':[18, 17, 25, 14, 16, 11, 13, 14, 20, 14, 12, 18], 'y7':[11, 14, 22, 14, 13, 19, 15, 17, 14, 12, 17, 19], 'y8':[13, 14, 20, 14, 16, 17, 15, 14, 10, 13, 14, 20], 'y9':[15, 15, 22, 15, 11, 13, 15, 14, 11, 14, 12, 22], 'y10':[10, 11, 22, 14, 16, 21, 15, 14, 10, 12, 11, 16] } app = dash.Dash() app.layout = html.Div([ html.Div([ dcc.Dropdown( id='product-choice', options=[{'label': i, 'value': i} for i in listofY], value=['y1', 'y2', 'y5'], multi=True ), html.Div([ dcc.Checklist( id='select-all', options=[{'label': 'Select All', 'value': 1}], values= ) ], id='checklist-container') ]), html.Div(children=[ dcc.Graph( id='bar-graph-by-model' ), ]), ]) @app.callback( Output('product-choice', 'value'), [Input('select-all', 'values')], [State('product-choice', 'options')]) def test(selectALL, options): if len(selectALL) > 0: return [i['value'] for i in options] else: raise PreventUpdate() @app.callback( Output('checklist-container', 'children'), [Input('product-choice', 'value')], [State('product-choice', 'options'), State('select-all', 'values')]) def tester(chosenValues, availableChoices, selectALL): if len(chosenValues) < len(availableChoices) and len(selectALL) == 0: raise PreventUpdate() elif len(chosenValues) < len(availableChoices) and len(selectALL) == 1: return dcc.Checklist(id='select-all', options=[{'label': 'Select All', 'value': 1}], values=) elif len(chosenValues) == len(availableChoices) and len(selectALL) == 1: raise PreventUpdate() return dcc.Checklist(id='select-all', options=[{'label': 'Select All', 'value': 1}], values=[1]) @app.callback( Output('bar-graph-by-model', 'figure'), [Input('product-choice', 'value')] ) def updategraph(value): traces= for i in value: x=xTime ytemp=Table[i] traces.append(go.Bar( x=x, y=ytemp, name=i, )) return { 'data': traces, 'layout': go.Layout( ) } if __name__ == '__main__': app.run_server(debug=True, port=8051)
Read in browser »  By Bapth on Jul 03, 2021 03:55 am It's the first time I write in the forum so I hope my message is correct! I have a problem, I want to download a json file in the website 'https://meteofrance.com/previsions-meteo-france/paris/75000 ' that give us the weather duting the hour. As the picture display: https://community.jeedom.com/uploads/default/original/3X/6/c/6ca8c10de52042073976f2479dd30be8a89badb0.png But when I want to download the file, thanks to this url : https://rpcache-aa.meteofrance.com/internet2018client/2.0/nowcast/rain, I have an invalid token. ==> I'm not authorized :/ Do you know how I can get the json file? I hope my message has enough details. Bapth Read in browser »  By hamid on Jul 03, 2021 03:55 am I'm making a simple app and learning with practicing how FPS-related methods work in java to make an app with a high fresh rate but, I don't know which one of the methods above should I use. my app have a button and a text field and a simple layout manager that I made which is supposed to change the location of the components according to the primal frame size (using ratio). the layout manager should be able to update the panel (or my frame I don't know really) every time that a component's location changed. also while the user is changing the frame size the components should move smoothly and without being laggy. how can I accomplish all these? right now my problem is shown below which seems that the panel.updateUI() doesn't do anything. as you see there is a black line that appears when you change the frame size slowly. this is how I'm doing this currently: import java.awt.Color; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.Font; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.List; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.SwingWorker; public class Test { private JFrame frame; private SwingWorker<Void, Void> sw; private JTextField txtGi; protected volatile static boolean b = false; private double FPS = 0; protected static volatile JButton btnStart; public static void main(String args) { EventQueue.invokeLater(new Runnable() { public void run() { try { Test window = new Test(); window.frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } public Test() { initialize(); } private void initialize() { frame = new JFrame(); frame.setBounds(100, 100, 230, 230); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setMinimumSize(new Dimension(230, 230)); JPanel panel = new JPanel(); panel.setBounds(0, 0, 216, 193); panel.setBackground(Color.PINK); frame.getContentPane().add(panel); panel.setLayout(null); btnStart = new JButton("Start"); btnStart.setName("btnStart"); btnStart.setFont(new Font("Segoe Print", Font.BOLD | Font.ITALIC, 17)); btnStart.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println(frame.getMinimumSize()); System.out.println( "#sw.isDone(): " + sw.isDone() + " sw.isCancelled(): " + sw.isCancelled() + " b: " + b); } }); btnStart.setBounds(50, 120, 101, 33); panel.add(btnStart); System.out.println("1: " + Thread.currentThread().getName()); frame.validate(); panel.validate(); sw = new SwingWorker<Void, Void>() { @Override protected Void doInBackground() throws Exception { b = true; System.out.println(Thread.currentThread().getName() + " is going to sleep for 250 millis."); System.out.println(frame.isShowing()); while (frame.isShowing() == false) { System.out.println("initializing the frame."); Thread.sleep(320); } System.out.println(frame.isShowing()); int cc = 0; int FC = 0; while (frame.isShowing()) { Thread.sleep(1); panel.updateUI(); long s = System.currentTimeMillis(); System.out.println("2: " + Thread.currentThread().getName()); cc++; Graphical_AI.setComponentLocationWithButton(btnStart); System.out.println("3: " + Thread.currentThread().getName()); if (Graphical_AI.thread1.isAlive()) { System.out.println(); System.out.println("waiting for " + Graphical_AI.thread1.getName() + " to finish!"); System.out.println(); Graphical_AI.thread1.join(); Thread.sleep(1); panel.updateUI(); } Graphical_AI.setComponentLocationWithButton(txtGi); if (Graphical_AI.thread1.isAlive()) { System.out.println(); System.out.println("waiting for " + Graphical_AI.thread1.getName() + " to finish!"); System.out.println(); Graphical_AI.thread1.join(); Thread.sleep(1); panel.updateUI(); } long e = System.currentTimeMillis(); FPS = 1.0 / ((e - s) / 1000.0); FC++; if (FC == 60) { txtGi.setText(String.valueOf("FPS: " + (int) FPS)); FC = 0; } System.out.println("FPS: " + (int) FPS); if (cc == 1000) { Thread.sleep(5); cc = 0; System.gc(); System.out.println("memory optimized."); } } return null; } @Override protected void process(List<Void> chunks) { super.process(chunks); } @Override protected void done() { System.out.println("sw.isDone(): " + sw.isDone() + " b: " + b); super.done(); } }; sw.execute(); txtGi = new JTextField(); txtGi.setName("txtGi"); txtGi.setFont(new Font("Segoe Script", Font.BOLD | Font.ITALIC, 21)); txtGi.setBounds(50, 40, 134, 70); panel.add(txtGi); txtGi.setColumns(10); } } the layout manager: import java.awt.Container; import java.util.ArrayList; import javax.swing.JComponent; import javax.swing.JFrame; public class Graphical_AI { protected static volatile int count = 0; protected static volatile int C_X; protected static volatile int C_Y; protected static double x_C_To_E_ratio; protected static double y_C_To_E_ratio; protected static int C_WIDTH; protected static int C_HEIGHT; protected static int Con_WIDTH; protected static int Con_HEIGHT; protected static volatile int N_C_X; protected static volatile int N_C_Y; protected static Container con; protected volatile static boolean bool = false; protected static volatile ArrayList<Double> al = new ArrayList<Double>(); protected static volatile ArrayList<String> al_for_O_names = new ArrayList<String>(); protected static volatile String C_Name; protected static volatile String C_O_Name; protected volatile static boolean bool2 = false; protected static volatile Thread thread1; protected static void analyzeJComponentSize(JComponent comp) throws InterruptedException { System.out.println("W: " + comp.getWidth() + " H: " + comp.getHeight()); Thread.sleep(30); } protected static void analyzeJFrameSize(JFrame frame) throws InterruptedException { System.out.println("W: " + frame.getWidth() + " H: " + frame.getHeight()); Thread.sleep(30); } protected static void setComponentLocationWithButton(JComponent comp) throws InterruptedException { thread1 = Thread.currentThread(); thread1 = new Thread(new Runnable() { @Override public void run() { System.out.println("count: " + count); C_Name = comp.getName(); System.out.println("C_Name: " + C_Name); if (count == 0) { C_O_Name = comp.getName(); System.out.println("C_O_Name: " + C_O_Name); con = comp.getParent(); Con_WIDTH = con.getWidth(); Con_HEIGHT = con.getHeight(); System.out.println("** (double) Con_WIDTH: " + (double) Con_WIDTH); System.out.println("** (double) Con_HEIGHT: " + (double) Con_HEIGHT); x_C_To_E_ratio = (double) con.getWidth() / (double) comp.getX(); y_C_To_E_ratio = (double) con.getHeight() / (double) comp.getY(); if (bool2 == false) { al.add(x_C_To_E_ratio); al.add(y_C_To_E_ratio); al_for_O_names.add(comp.getName()); bool2 = true; } System.out.println("** x_C_To_E_ratio: " + x_C_To_E_ratio); System.out.println("** y_C_To_E_ratio: " + y_C_To_E_ratio); System.out.println("** (double) con.getWidth() / (double) comp.getX(): " + (double) con.getWidth() / (double) comp.getX()); C_X = comp.getX(); C_Y = comp.getY(); C_WIDTH = comp.getWidth(); C_HEIGHT = comp.getHeight(); System.out.println("** C_WIDTH: " + C_WIDTH + ", " + C_HEIGHT); System.out.println("** (double) con.getWidth() / (double) C_X): " + (double) con.getWidth() + " / " + (double) C_X); count++; } if (C_Name != al_for_O_names.get(0)) { count = 0; System.out.println("%% C_Name: " + C_Name); System.out.println("%% C_O_Name: " + C_O_Name); System.out.println("%% al_for_O_names.get(0): " + al_for_O_names.get(0)); System.out.println("%% count became to:" + count); al_for_O_names.remove(0); al_for_O_names.add(comp.getName()); } else { System.out.println("*ELSE STATEMENT*"); count = 1; } if (count == 0) { C_Name = comp.getName(); System.out.println("$$ C_Name: " + C_Name); con = comp.getParent(); Con_WIDTH = con.getWidth(); Con_HEIGHT = con.getHeight(); System.out.println("$$ (double) Con_WIDTH: " + (double) Con_WIDTH); System.out.println("$$ (double) Con_HEIGHT: " + (double) Con_HEIGHT); x_C_To_E_ratio = (double) con.getWidth() / (double) comp.getX(); y_C_To_E_ratio = (double) con.getHeight() / (double) comp.getY(); if (bool2 == false) { al.add(x_C_To_E_ratio); al.add(y_C_To_E_ratio); bool2 = true; } System.out.println("$$ x_C_To_E_ratio: " + x_C_To_E_ratio); System.out.println("$$ y_C_To_E_ratio: " + y_C_To_E_ratio); System.out.println("$$ (double) con.getWidth() / (double) comp.getX(): " + (double) con.getWidth() / (double) comp.getX()); C_X = comp.getX(); C_Y = comp.getY(); C_WIDTH = comp.getWidth(); C_HEIGHT = comp.getHeight(); System.out.println("$$ C_WIDTH: " + C_WIDTH + ", " + C_HEIGHT); System.out.println("$$ (double) con.getWidth() / (double) C_X): " + (double) con.getWidth() + " / " + (double) C_X); count++; } try { System.out.println("## after if count block ## comp W: " + comp.getWidth() + " comp H: " + comp.getHeight() + "\ncomp.getLocation(): " + comp.getLocation() + " comp.getLocationOnScreen(): " + comp.getLocationOnScreen()); System.out.println("con W: " + con.getWidth() + ", con H: " + con.getHeight()); if (x_C_To_E_ratio != al.get(0) || y_C_To_E_ratio != al.get(1)) { x_C_To_E_ratio = al.get(0); y_C_To_E_ratio = al.get(1); Thread.sleep(2); } if (((double) con.getWidth() / (double) C_X) > x_C_To_E_ratio + 0.025) { Thread.sleep(2); System.out.println((((double) con.getWidth() / (double) C_X)) + " ,,, " + x_C_To_E_ratio); while (((double) con.getWidth() / (double) C_X) > x_C_To_E_ratio + 0.025) { C_X += 1; N_C_X = C_X; if (((double) con.getWidth() / (double) C_X) < x_C_To_E_ratio + 0.025) { System.out.println("## in if bigger ## "); break; } System.out.println("## in if bigger ## C_X: " + C_X + ", N_C_X " + N_C_X); System.out.println("## in if bigger ## (double) con.getWidth() / (double) C_X: " + (double) con.getWidth() + " / " + (double) C_X); System.out.println("## in if bigger ## ((double) con.getWidth() / (double) C_X): " + ((double) con.getWidth() / (double) C_X) + ", x_C_To_E_ratio:" + x_C_To_E_ratio + ", ((double) con.getWidth() / (double) C_X) == x_C_To_E_ratio: " + (((double) con.getWidth() / (double) C_X) == x_C_To_E_ratio)); if (((double) con.getWidth() / (double) C_X) == x_C_To_E_ratio || ((double) con.getWidth() / (double) C_X) - x_C_To_E_ratio < 0.002) { bool = true; System.out.println("## in if bigger ## GI.bool: " + bool); System.out.println("## in if bigger ## W: " + comp.getWidth() + " H: " + comp.getHeight() + "\ncomp.getLocation(): " + comp.getLocation() + " comp.getLocationOnScreen(): " + comp.getLocationOnScreen() + " Con_WIDTH: " + Con_WIDTH + " Con_HEIGHT: " + Con_HEIGHT + " con.getWidth(): " + con.getWidth() + " con.getHeight(): " + con.getHeight()); System.out.println("## in if bigger ## $GI.bool: " + bool + " $Test.b: " + Test.b); break; } comp.setBounds(N_C_X, comp.getY(), C_WIDTH, C_HEIGHT); } } else if (((double) con.getWidth() / (double) C_X) < x_C_To_E_ratio - 0.025) { Thread.sleep(2); System.out.println((((double) con.getWidth() / (double) C_X)) + " *** " + x_C_To_E_ratio); while (((double) con.getWidth() / (double) C_X) < x_C_To_E_ratio - 0.025) { C_X -= 1; N_C_X = C_X; if (((double) con.getWidth() / (double) C_X) > x_C_To_E_ratio - 0.025) { break; } System.out.println("C_X: " + C_X + ", N_C_X " + N_C_X); System.out.println("(double) con.getWidth() / (double) C_X): " + (double) con.getWidth() + " / " + (double) C_X); System.out.println("((double) con.getWidth() / (double) C_X): " + ((double) con.getWidth() / (double) C_X) + ", x_C_To_E_ratio:" + x_C_To_E_ratio + ", ((double) con.getWidth() / (double) C_X) == x_C_To_E_ratio: " + (((double) con.getWidth() / (double) C_X) == x_C_To_E_ratio)); if (((double) con.getWidth() / (double) C_X) == x_C_To_E_ratio || ((double) con.getWidth() / (double) C_X) - x_C_To_E_ratio > -0.002) { bool = true; System.out.println("GA.bool: " + bool); System.out.println("W: " + comp.getWidth() + " H: " + comp.getHeight() + "\ncomp.getLocation(): " + comp.getLocation() + " comp.getLocationOnScreen(): " + comp.getLocationOnScreen() + " Con_WIDTH: " + Con_WIDTH + " Con_HEIGHT: " + Con_HEIGHT + " con.getWidth(): " + con.getWidth() + " con.getHeight(): " + con.getHeight()); System.out.println("$GA.bool: " + bool + " $T.b: " + Test.b); break; } comp.setBounds(N_C_X, comp.getY(), C_WIDTH, C_HEIGHT); } } } catch (InterruptedException e) { e.printStackTrace(); } } }); thread1.start(); } } ** Now the components don't seem to be laggy when you moving them while I appreciate it if you have any better solution. ** I don't want to use the pack() method or any prebuilt layout manager. ** I've already read a lot of similar questions but I didn't find my answer. Read in browser »  By Urnm on Jul 03, 2021 03:55 am I want to get the numbers in units section. But I don't no how to do it. $no = 120510021; I Need a output like "021" Is there any special functions or anything Read in browser »  By MadMike on Jul 03, 2021 03:53 am I'm a student and have been attempting to create a program in JavaScript to create a function and generate a random integer (whole number) between 1 and 9. I have created two different programs for this in my testing but while using Visual Studio Code it doesn't print the generated number. Please see code below and if you have any questions please let me know. function random_num() { let random_num = Math.floor(Math.random() * 9) +1; return random_num; } console.log(random_num); function random_num(min, max) { min = Math.ceil(1); max = Math.floor(9); return Math.floor(Math.random() * (max - min)) + min; } console.log(random_num); Thanks in advance! Read in browser »  By Akshay Natu on Jul 03, 2021 03:53 am I want to get better at SQL Server/T-SQL, and I've been trying to sharpen my skills in it by solving challenges, and I found a hard one online. It has been kicking my butt for a while and my brain is fried trying to get it right. You have two tables, a Ticket table and a StatusChange table, which are as follows: Ticket table: |Id|Summary| |--|------| |1|"My Computer won't turn on" |2|"Could you print the date out in my timezone on Report XYZ?" |3|"Could you create a new version of the XYZ report that has 2 new columns?" |4|"Where is the password reset link?" StatusChange table: |TicketId|Timestamp|OldStatus|NewStatus| |--------|---------|---------|---------| |1|2014-01-01 00:00|NULL|"New" |1|2014-01-01 01:15|"New"|"In Progress" |2|2014-01-01 02:32|NULL|"New" |3|2014-01-01 04:53|NULL|"New" |2|2014-01-01 05:07|"New"|"In Progress" |2|2014-01-01 06:14|"In Progress"|"Closed" |4|2014-01-01 07:22|NULL|"New"| |1|2014-01-01 08:25|"In Progress"|"Closed" |2|2014-01-01 09:32|"Closed"|"Reopened" |3|2014-01-01 10:55|"New"|"In Progress" |4|2014-01-01 11:05|"New"|"Closed" The exercise is to write a SQL query to calculate the total amount of time, IN MINUTES, each ticket spent in each available status. The result is expected to have a row for each ticket row in the Ticket Table and a column for each potential status (New, In Progress, Closed, Reopened), with values for the number of minutes spent in that status. For comparison, if you run the report with the current date of '2014-01-01 12:00' (i.e., use this date as the end date for the current statuses), you should expect results as follows: Expected Result: (the numbers are in minutes) |Id|Summary|New|In Progress|Closed|Reopened |--|-------|---|-----------|------|-------| |1|"My Computer won't turn on"|75|430|215|NULL |2|"Could you print the date out in my timezone on Report XYZ?"|155|67|198 |148 |3|"Could you create a new version of the XYZ report that has 2 new columns?"|362|65|NULL|NULL |4|"Where is the password reset link?"|223|NULL|55|NULL I would have preferred to figure it out on my own, but I've not had much luck so far. Any insight would be appreciated, thanks. Read in browser »  By StuckDuck on Jul 03, 2021 03:50 am I'm making a UWP Windows app in C# using WinUI 3.0 and a few days ago I started getting this kind of error: CS0433 The type 'NavigationView' exists in both 'Microsoft.UI.Xaml, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime' and 'Microsoft.UI, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime' This is the snippet from the auto generated code that causes the error: [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.UI.Xaml.Markup.Compiler"," 0.0.0.0")] private global::Microsoft.UI.Xaml.Controls.NavigationView settingsNavPane; Until now, I solved instances of this issue by deleting /bin and /obj's contents, but the problem seems to persist. I'm aware this is a compiler error, so I tried adding a reference to the .csproj file: <References> <Reference Include="Microsoft.UI.Xaml.dll"/> </References> I don't know if I'm missing something obvious, but this didn't solve the problem either. How do I fix this? Read in browser »  By figbar on Jul 03, 2021 03:46 am This is a broader question about the use of different variable declarations in react native functional components (as opposed to class components), specially the use of let vs const, and how they are effected by renders and such. For this question, when I say 'render' or 're-render' I am talking about the execution of the render function (like 'MyFunctionalComponent' below), not necessarily a UI update/change. From my understanding, unlike plain js, a const variable is not exactly 'constant' in react/react native, and can be changed (with hooks?) like so: export default function MyFunctionalComponent() { const [test, setTest] = useState(false); const testFunction = () => { //some sort of function, maybe called by a button press setTest(true); //this can change test, but something like 'test = true' throws an error } } However let can take on similar behavior from my understanding: export default function MyFunctionalComponent() { let test = false const testFunction = () => { //some sort of function, maybe called by a button press test = true; } } However, most react native examples and tutorials and such I have looked at, always seem to use the const syntax, even though it seems to involve much more code. Why? Personal preference, or necessity? Does the const way of doing things somehow re-render/re-call MyFunctionalComponent with a new value for the const variable? Next, I'm not sure the exact behavior that is causing this, but sometimes when using the const syntax inside the functional component, the variables change and save state between render calls, and sometimes, a const variable is reset to its default state every time the render is called. (I know this part is vague, so feel free to ignore it if there is not enough detail) Why does this happen? Similarly, I have seen different behavior when consts are created outside of the functional component instead of within... does scope work as you would expect with these? Are they (still?) re-instantiated on new render calls? Does 'setState' call an re-render? Shortening the previous question, why do some of my const's preserve their state on re-renders, while some seem to reset to their defaults? Where does var fall into this, does it act the same as in regular js, or is it affected by react as well? (I feel like I have a grasp of the differences in these variable declarations in regular js, but this const behavior with react making me question it all). So overall the question is basically, what are the differences/advantages of let, var, and const, specifically in react/react native, and how do those differ from regular javascript? Lastly, does it differ between class components and functional components in react native? Thank you for reading this long question. Read in browser »  By Ali Bdeir on Jul 03, 2021 03:28 am export const useMyCustomHook = () => { const uiLoad = useUiLoad(false); useEffect(() => { // ... }, [...]); } uiLoad is a custom hook (as is, obviously, useMyCustomHook). This works fine if I don't add uiLoad to the useEffect dependency array. If I do include it, it infinitely re-renders. Here's my code for the uiLoad hook: const baseDispatch = { type: SET_LOADING } export const useUiLoad = (initial: boolean = false) => { const dispatch = useDispatch<Dispatch<UIAction>>(); const loaded = useRef(false); useEffect(() => { if (initial && !loaded.current) { console.log('Called'); dispatch({ type: SET_LOADING, loadbarShowing: true }); loaded.current= true; } }, [dispatch, initial]) return (loading: boolean) => { const data: UIAction = { ...baseDispatch, loadbarShowing: loading } dispatch(data); } } As far as I know, hooks don't change on re-render. So the questions are: Why is uiLoad changing on every rerender? Using the useWhatChanged debugger tool I can find that it is, indeed, changing everytime the component re-renders. Don't hooks stay the same every render? Or does that not apply to custom hooks? Is the only solution here supressing the warning using // eslint-disable-next-line? Read in browser »  By Aditya Singh Rathore on Jul 03, 2021 03:08 am I am trying an online coding test problem which requires me to output the answer rounded to 6 decimal places. I attempted itin C++ and used Round double to 3 points decimal to calculate the final result. When writing output, I do cout << fixed << setprecision(6) << ans <<'\n'; But my answers were wrong. I used python do the same question because it has an inbuilt round for floats. Followingwas my code for outputting the final answer. val = round(ans, 6) a,b = str(val).split('.') n = 6 - len(b) b = b + '0'*n ans = a+'.'+b print(ans) It worked. How can I achieve same using C++ ? Edit: I am using double in C++ and floatin python. Read in browser »  By Peter Steel on Jul 03, 2021 03:00 am I am trying to implement a class where i can call SharedPreferences funtions. import 'package:shared_preferences/shared_preferences.dart'; class UserPreferences { static SharedPreferences _preferences; static const _keyToken = 'token'; static Future init() async { _preferences = await SharedPreferences.getInstance(); } static Future setToken(String token) async => await _preferences.setString(_keyToken, token); static String getToken() => _preferences.getString(_keyToken); } But i am getting following error: The non-nullable variable '_preferences' must be initialized. Try adding an initializer expression.
Read in browser »  By Mike on Jul 03, 2021 02:02 am I have several UIKit-based iOS apps that are already distributed on the AppStore that I would like to update, and I consider switching to SwiftUI. My question is: what would happen for users who already own the app but are running iOS versions older than iOS13? Will the app become totally unavailable for them or will they keep the ability to use their old UIKit version? Thank you very much ! Read in browser »  By Felix Kiptoo on Jul 02, 2021 01:01 pm { "BestDeals" : { "best_deal_01" : { "pant_id" : "chicken_01", "image" : "https://live.staticflickr.com/65535/48580764482_ae213e429e_o.jpg", "color_id" : "color_01", "name" : "ROASTED QUARTER CHICKEN" }, "best_deal_02" : { "pant_id" : "soups_01", "image" : "https://live.staticflickr.com/65535/48581028192_bee4339120_o.jpg", "color_id" : "color_03", "name" : "LOTUS ROOT" }, "best_deal_03" : { "pant_id" : "finger_01", "image" : "https://live.staticflickr.com/65535/48581054857_81760286f8_o.jpg", "color_id" : "color_04", "name" : "THAI STYLE SALAD" }, "best_deal_04" : { "pant_id" : "fish_01", "image" : "https://live.staticflickr.com/65535/48580945016_107b8ebb69_o.jpg", "color_id" : "menu_05", "name" : "ASAM FISH HEAD" } }, "MostPopular" : { "popular_01" : { "pant_id" : "chicken_01", "image" : "https://live.staticflickr.com/65535/48580764482_ae213e429e_o.jpg", "color_id" : "menu_01", "name" : "ROASTED QUARTER CHICKEN" }, "popular_02" : { "pant_id" : "soups_01", "image" : "https://live.staticflickr.com/65535/48581028192_bee4339120_o.jpg", "color_id" : "menu_03", "name" : "LOTUS ROOT" }, "popular_03" : { "pant_id" : "finger_01", "image" : "https://live.staticflickr.com/65535/48581054857_81760286f8_o.jpg", "color_id" : "menu_04", "name" : "THAI STYLE SALAD" }, "popular_04" : { "pant_id" : "fish_01", "image" : "https://live.staticflickr.com/65535/48580945016_107b8ebb69_o.jpg", "color_id" : "menu_05", "name" : "ASAM FISH HEAD" } }[firebase database][1] logcatmodelRefview
Read in browser »  Recent Articles:
|
No comments:
Post a Comment