Id
int64
34.6M
60.5M
Title
stringlengths
15
150
Body
stringlengths
33
36.7k
Tags
stringlengths
3
112
CreationDate
stringdate
2016-01-01 00:21:59
2020-02-29 17:55:56
Y
stringclasses
3 values
58,037,309
Am I being Hacked? GalliumOS + Chromium
<p>I am using GalliumOS (Ubuntu 16.04 derivative) and Chromium Browser.</p> <p>In the last week I have been informed by two major websites, Amazon and Coinbase, that the computer I have been using for the last two years is a "new device" and must be confirmed.</p> <p>In both instances reconfirming the device via email solved the problem and I kind of forgot about it.</p> <p>Then just now, whilst using Coinbase I was logged out because of an auth token error. I then had to log back in. 2 stage auth token is working fine.</p> <p>Is someone trying to hack me or perhaps one of the two above mentioned sites? (I am sure someone somewhere is trying to hack them both ALL THE TIME... is someone getting close????)</p>
<security><authentication><chromium><chromebook>
2019-09-21 04:35:49
LQ_CLOSE
58,038,468
How to access object within a json object in angular 2+
I am a beginner of angular. I tried to access this json object using console.log(this.selected[0].delivery.shipping_type); Selected is an array and i am trying to show the 0th element of selected.How to access shipping_type within delivery.console.log returns this error: Cannot read property 'shipping_type' of undefined. ``` selected[0]= {createdAt: "2019-09-20T01:47:27.291Z" delivery.address: "21 Woodlands Crossing, Singapore 738203" delivery.contact_no: "738203" delivery.postal_code: "738203" delivery.recepient: "Dhania" delivery.shipping_fee: 5 delivery.shipping_type: "regular" delivery.unit_no: "#03-07", __v: 0 _id: "5d842faf06f2a639183226c0"} ```
<javascript><json>
2019-09-21 08:17:48
LQ_EDIT
58,038,833
Get Max value comparing multiple columns and return specific values
<p>I have a Dataframe like:</p> <pre><code>Sequence Duration1 Value1 Duration2 Value2 Duration3 Value3 1001 145 10 125 53 458 33 1002 475 20 175 54 652 45 1003 685 57 687 87 254 88 1004 125 54 175 96 786 96 1005 475 21 467 32 526 32 1006 325 68 301 54 529 41 1007 125 97 325 85 872 78 1008 129 15 429 41 981 82 1009 547 47 577 52 543 83 1010 666 65 722 63 257 87 </code></pre> <p>I want to find the maximum value of Duration in (Duration1,Duration2,Duration3) and return the corresponding Value &amp; Sequence.</p> <p>My Desired Output:</p> <pre><code>Sequence,Duration3,Value3 1008, 981, 82 </code></pre>
<python><python-3.x><pandas><dataframe>
2019-09-21 09:07:31
HQ
58,041,765
Is there a way to create a Scatterplot in manim?
<p>I am wondering if there is a way to create a Scatterplot in manim.</p> <p>Has anyone ever done it? if yes, what is the best way to do it?</p>
<python><manim>
2019-09-21 15:42:37
LQ_CLOSE
58,043,287
How can I create five pointed stars in canvas using function?
<p>how can I create this 3 stars in canvas using </p> <pre><code>function filledStar(x,y,a){code} filledStar(40,50,75); filledStar(130,120,100); filledStar(250,220,150); </code></pre> <p>should show:</p> <p><a href="https://i.stack.imgur.com/Kw0Of.jpg" rel="nofollow noreferrer">3starsIMG</a></p> <p>Thanks</p>
<javascript><canvas>
2019-09-21 19:05:17
LQ_CLOSE
58,043,922
Awk & bash: syntax error near unexpected token `('
<p>When I paste this command into the terminal (ubuntu 18.04):</p> <pre><code>cat file.txt | awk -F, BEGIN { OFS = FS } {if ($2 == "") $2 = last2; else last2 = $2 print} </code></pre> <p>I get:</p> <pre><code>bash: syntax error near unexpected token `(' </code></pre> <p>How to fix this?</p>
<bash><shell><awk>
2019-09-21 20:39:25
LQ_CLOSE
58,044,236
Does random.randint() generate the random number? All my guesses are always wrong?
<p>I have set the guess_limit to 6 and random.randint(0, 6), even if I guess 1,2,3,4,5,6, it will always return "Out of guesses!" So my question is does random.randint() is calling the function or there is no random number if the function is not called. Please help</p> <pre class="lang-py prettyprint-override"><code>import random guess = "" guess_limit = 6 guess_count = 0 out_of_guesses = False hiden_number = random.randint(1, 6) while guess != hiden_number and not (out_of_guesses): if guess_count &lt; guess_limit: guess = input("Enter the number: ") guess_count += 1 else: out_of_guesses = True if out_of_guesses: print("Out of guesses!") else: print("You Win") </code></pre> <pre><code> Enter the number: 1 Enter the number: 2 Enter the number: 3 Enter the number: 4 Enter the number: 5 Enter the number: 6 Out of guesses! </code></pre> <p>"If the random.randint(1, 6) range is 1 to 6 how is it possible that I am missing to guess the random number"</p>
<python><python-3.7>
2019-09-21 21:25:01
LQ_CLOSE
58,044,476
Permisiion to restrict aws cloudformation
I want to create permissions for cloudformation. I have to provide delete permission. How can i restrict in a way so that it can only delete resources which created by cloudformation.
<amazon-web-services><amazon-cloudformation><amazon-iam>
2019-09-21 22:06:43
LQ_EDIT
58,048,121
In angular 2+ how do I communicate between sibling components
<p>I have 3 components I want them to interact with each other.</p> <p>Tried with services it is not not solving my problem. Need help on it </p>
<angular>
2019-09-22 10:06:24
LQ_CLOSE
58,048,596
Is it possible to write a code of c++ one input swap Without using any CONDITIONAL statement?
Is it possible to write a code of c++ like if we enter 9 then the program return 6 and if we input 6 the program return us 9 as output? Without using any CONDITIONAL statement?
<c++>
2019-09-22 11:08:08
LQ_EDIT
58,050,217
How i can count "\n\n" in a string with python?
this ist my string: (info: i parse it with python from an array to string with str(myString) ) myString = "[('das ist ein Test', 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam\norem ipsum dolor sit amet\n\norem ipsum dolor sit amet\n\norem ipsum dolor sit amet\n\norem ipsum dolor sit amet')]" when i try: print(myString.count("\n\n")) i get the answer: 0 but i should be 3
<python>
2019-09-22 14:36:18
LQ_EDIT
58,050,651
how to make a batch file create a batch file that can still contain percentage values
i'm trying to create a batch file that creates a batch file, but as it seems i can't get the first batch file to also send over percentage value's (fx. %example%), so how do i make the first batch file create the second batch file but that file is still able to contain percentage value's? Also if you find any other errors in my script please correct it :) Also while i'm here, as you can see I've put an "example, please help!" underneath the ":prep" I can't seem to figure out the ">nul" thing, no matter how many "^" i put it won't save to the last sector (which is "gnome.bat") it will however save to the "setup.bat" but not any further, so please also help me with that The error is under ":Prep" here's my full script: (not even close to being done with the script...) @echo off title Annoying Menu mode 150 color a :begin cls echo Welcome to "Annoying Menu" echo This menu is made to prank your friends echo All pranks that you make on your friends are completely your own responsibility echo Please be aware that this menu contains what could be consideret "Virus" echo No harm will however be done to either your, or your freinds pc echo Please read through all the instructions before use, of the menu... echo --------------------------------------------------------------------------------------- echo 1. Please select a password to cancel the prank, by pressing "3" (only numbers) echo 2. Please make sure that the setup files are ready to be transferred, by pressing "1" echo 3. Now you are ready to send off the setup file to one of your freinds echo --------------------------------------------------------------------------------------- echo type "1" to create setup file echo type "2" to prepare setup files for use echo type "3" to download it on your own pc echo type "4" to select password to cancel the prank (please only use numbers) echo type "5" to test password echo type "exit" to close the menu echo --------------------------------------------------------------------------------------- echo. set /p opt= Option: if %opt%==1 goto create if %opt%==2 goto prep if %opt%==3 goto UD if %opt%==4 goto pass_select if %opt%==5 goto testpass if %opt%==exit goto end cls echo please enter a valid number to continue... echo. pause goto begin :create break>"C:\Users\%Username%\Desktop\setup.bat" echo. echo setup file created, please prepare the setup file before use, by pressing "2" in the main menu echo. pause goto begin :prep @echo @echo off> setup.bat @echo title quick_setup>> setup.bat @echo color a>> setup.bat @echo mode 150>> setup.bat @echo :begin>> setup.bat @echo break^>"C:\Users\%Username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\gnome.bat">> setup.bat @echo cd C:\Users\%Username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup>> setup.bat (Example, please help!) @echo @echo ping localhost -n 2 ^>nul^>^> gnome.bat>> setup.bat) @echo @echo set /a time=%clock%-1^>^> gnome.bat>> setup.bat @echo @echo if %clock% EQU 0 goto Timesup^>^> gnome.bat>> setup.bat @echo @echo :Timesup^>^> gnome.bat>> setup.bat) goto begin (Not Done!) :UD (Not Done!) :pass_select cls echo Please enter a password that will be used to cancel the prank (please only use numbers) echo. set /p pas= Set Password: set /a pss=%pas% cls echo the password has now been set to %pss% echo to enter a new password simply select "3" again and choose a new password echo. pause goto begin :testpass cls echo we are now ready to test your newly set password (if not you've set a password, please do so first) echo. echo type "1" to start the test echo type "2" to set a password/new password echo type "exit" to go back to the main menu echo. set /p lll= Option: if %lll%==1 goto test if %lll%==2 goto pass_select if %lll%==exit goto begin cls echo please enter a valid number to continue... echo. pause goto testpass :test cls echo please enter password to continue... echo type "exit" to go back to main menu echo. set /p tes= Password: if %tes%==%pss% goto completetest if %tes%==exit goto begin cls echo either you typed the wrong password or it didn't work, please try to set a new password if the same thing happens twice... echo. pause goto test :completetest cls echo The test was successful! echo you're password works as intended echo. pause goto begin :end
<windows><batch-file><cmd><windows-10>
2019-09-22 15:26:38
LQ_EDIT
58,050,723
There is no viewcontroller.swift file when I start the project
<p>I tried to start the project and play around with viewcontroller but I do not see it. Only appdelegate and scenedelegeate and contentview. The code below was supposed to be added to viewcontroller but I do not know where to add. It keeps giving me a error message saying unresolved identifier present and action. please help.</p> <pre><code> @IBAction func hello() { // add alert let alert = UIAlertController(title: "hello", message: "daaaammmmmn", preferredStyle: .alert) let okAction = UIAlertAction(title: "ok", style: .default, handler: nil) alert.addAction(action) present(alert, animated: true, completion: nil) } </code></pre> <p><a href="https://i.stack.imgur.com/CxDJH.jpg" rel="nofollow noreferrer"> </a></p>
<ios><swift><xcode><xcode11>
2019-09-22 15:34:00
LQ_CLOSE
58,053,083
How to Calculate and Displays NFL Passer Rating?
<p>I am trying to do this homework problem but I am having difficulties setting it up and understanding how to start and accomplish these results.</p> <p>This is the screenshot of the formulas:</p> <p><img src="https://screenshot.net/pdg9piy?" alt="screenshot of the formulas"></p> <p>[link if the image is not showing] <a href="https://screenshot.net/pdg9piy?" rel="nofollow noreferrer">https://screenshot.net/pdg9piy?</a></p> <p>So far I've declared the variables for the formulas, created a scanner and tried to write the formula. This is what I have so far:</p> <pre><code> //declaring variables float a_CompletionPercentage, b_YardsPerAttempt, c_TouchdownsPerAttempt, d_InterceptionsPerAttempt; float PasserRating; double Completion, Attempts, Touchdowns, Yards, Interceptions; Scanner in = new Scanner(System.in); //create Scanner Object //PlayerName input System.out.print("Enter the full name of the quarterback: "); //prompt asks for player name String PlayerName = in.nextLine(); //set string PlayerName as user's input //attempts input System.out.print("Enter the number of attempts: "); //prompt asks for # of attempts Attempts = in.nextDouble(); //set variable Attempts as user's input for # of attempts //completion input System.out.print("Enter the number of completions: "); Completion = in.nextDouble(); //yards input System.out.print("Enter the number of yards: "); Yards = in.nextDouble(); //touchdowns input System.out.print("Enter the number of touchdowns: "); Touchdowns = in.nextDouble(); //interceptions input System.out.print("Enter the number of interceptions: "); Interceptions = in.nextDouble(); //calculations a_CompletionPercentage = (((float)(Completion/Attempts)- 0.3f) * 5f); //formula for completion percentage b_YardsPerAttempt = (((float)(Yards/Attempts)- 3f) * 5f); //formula for yards per attempt c_TouchdownsPerAttempt = ((float)(Touchdowns/Attempts) * 20f); //formula for touchdowns per attempt d_InterceptionsPerAttempt = (2.375f - ((float)(Interceptions/Attempts) * 25f)); //formula for interceptions per attempt PasserRating = (((a_CompletionPercentage + b_YardsPerAttempt + c_TouchdownsPerAttempt + d_InterceptionsPerAttempt)/6)*100f); //formula for passing rate //Displays result System.out.println("The passer rating for " + PlayerName + " is " + PasserRating); </code></pre> <p>I am not sure if my variables were declared correctly and my formula is not working.</p> <p>These are some sample outputs that I should be getting: Output Sample 1:</p> <p>Enter the full name of the quarterback: Jameis Winston</p> <p>Enter the number of attempts: 35</p> <p>Enter the number of completions: 22</p> <p>Enter the number of yards: 345</p> <p>Enter the number of touchdowns: 4</p> <p>Enter the number of interceptions: 1</p> <p>The passer rating for Jameis Winston is 121.72619047619047</p> <p>But I am getting 664.58325 and not 121.72619047619047.</p> <p>PLEASE HELP!</p> <p>THANK YOU SO MUCH FOR ANYONE THAT TAKES THE TIME TO HELP ME WITH THIS!</p>
<java>
2019-09-22 20:20:16
LQ_CLOSE
58,053,133
Laravel - What is the most used tool for create automated code for CRUD?
<p>I know another frameworks in PHP that got tools for create automated the code for a CRUD. In Laravel what is the most used tool for this?</p> <p>Thanks</p>
<php><laravel><crud>
2019-09-22 20:27:48
LQ_CLOSE
58,053,220
How can I compare a letter from a string in C?
<pre><code>char* str = "Hello" if ( str[0] == 'a' ) { printf("OK"); } </code></pre> <p>I tried this but get an error, how am i suppose to comapre them?</p>
<c>
2019-09-22 20:38:56
LQ_CLOSE
58,053,606
Python. How i can iterate over tuples with dict inside
I have some dicts inside tuple a = ({'row_n': 1, 'row_section': None, 'nomenclature_platform_id': 'qwe', 'nomenclature_name': 'name', 'TM': ' ', 'no_category': 'orig_num Номер', 'article': 'num артикля', 'size_measures_multi': [('1', 'cm', 'brutto'), ('123', 'm', 'netto_brutto_unknown'), ('1233', 'm', 'netto_brutto_unknown')]}, {'row_n': 2, 'row_section': None, 'nomenclature_platform_id': '34110', 'nomenclature_name': 'Fuel MAX', 'TM': 'Fuel MAX', 'no_category': 'MAGNETICYW', 'article': 'MAGNETICYW', 'size_measures_multi': [('1', 'm', 'netto_brutto_unknown'), ('21', 'm', 'netto_brutto_unknown'), ('28', 'm', 'netto_brutto_unknown')]}) I wont make tuples from key nomenclature_platform_id and every first element from list of tuples, which contain in key 'size_measures_multi', for example > ('qwe', '1', '123', '1233') > ('34110', '1','21','28') I try make list comprihansion inside tuple tuple(a['nomenclature_platform_id'], [item[0] for item in row['size_measures_multi']]) But i have not expected result > ('qwe', ['1', '123', '1233']) > ('34110', ['1','21','28']) Why my code work wrong and how i can fix it? I will be grateful for the help
<python>
2019-09-22 21:41:02
LQ_EDIT
58,053,949
Prevent view controller from stacking IOS 13 (swift)
<p>I am working on an app and recently updated to my Xcode. With this update the way view controllers are presented is changed and I want to revert it back to its old ways. They used to display over the other ones but now they "stack". </p> <p>I would like the iPhone on the left, while what I currently have is the iPhone on the right. <a href="https://i.stack.imgur.com/BPuWH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BPuWH.png" alt="enter image description here"></a>Thanks. </p>
<ios><swift><xcode><ios13>
2019-09-22 22:51:00
LQ_CLOSE
58,054,061
A definition of the ^ operation in javascript
<p>Can't seem to find a definition anywhere.</p> <p>Typing into the console I can see...</p> <pre><code> 5^4 = 1 5^3 = 6 5^2 = 7 </code></pre> <p>Any ideas why?</p>
<javascript>
2019-09-22 23:20:19
LQ_CLOSE
58,054,691
Unable to build react native project after updating to xcode 11.0
<p>I have a react native project running on react native version 0.59.8 , and xcode version 10.3. Somehow my xcode got updated to version 11.0 and after that i am unable to build the project using <code>react-native run-ios</code> command.</p> <p>I have tried cleaning up the build and building again. But that doesn't help.</p> <p>I am getting the following error:</p> <pre><code>CoreData: annotation: Failed to load optimized model at path '/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/Frameworks/InstrumentsPackaging.framework/Versions/A/Resources/XRPackageModel.momd/XRPackageModel 9.0.omo' error Could not find iPhone X simulator. </code></pre> <p>How to fix this issue?</p>
<ios><xcode><react-native><core-data><xcode11>
2019-09-23 01:27:32
HQ
58,055,430
Trying to build user reviews based site
<p>Im trying to build a website based on wordpress that users could add reviews on their products. Therefore i need 1. an option for the user to fill up form with details (that i have chosen) about the product. 2. an option to add reviews on the same product - just like a comment but with more options.</p> <p>good example is the site "Trailspace"</p> <p>appreciate any tips and suggestions! </p> <p>Thanks</p>
<wordpress><woocommerce><product>
2019-09-23 03:50:16
LQ_CLOSE
58,055,770
Spring Boot project in IntelliJ community edition
<p>I am new to IntelliJ Community edition. Can anyone help me with creating spring boot project in intelliJ Community edition. For ultimate edition there is spring-boot initializer but I cannot find anything for community edition. I followed this links but cannot find any solutions</p> <p><a href="https://www.youtube.com/watch?v=397QPCAjm0o" rel="noreferrer">enter link description here</a></p> <p><a href="https://sivalabs.in/2016/09/getting-started-springboot-intellij-idea-community-edition/" rel="noreferrer">enter link description here</a></p>
<java><spring-boot><gradle><intellij-idea>
2019-09-23 04:44:02
HQ
58,055,941
I have 7 days between 2 dates.I want to get days between 2 dates which is StartDate>='2019-08-01' and EndDate<='2019-08-30' that should return 1 day?
**this is the query in sql** select LeaveId,UserId,StartDate,EndDate,Days from TblLeaveRequest where UserId=218 [![ ha][1]][1] [1]: https://i.stack.imgur.com/9wR38.png
<sql><sql-server>
2019-09-23 05:05:16
LQ_EDIT
58,056,000
How do I convert the the middle number coming from an presser in vb.net to asterisk in form of an account number
<p>Am working on a banking app and I want to send sms to the users and I want the account number to be in this form 2719**5849 and the account number is coming from a textbox </p>
<vb.net>
2019-09-23 05:13:20
LQ_CLOSE
58,057,528
Python printing only "Even! You lost $300" and nothing else
` import random dice1 = random.randint(1, 6) dice2 = random.randint(1, 6) print(dice1, dice2) user_in = "Odd" odd = [1, 3, 5, 7, 9, 11] even = [2, 4, 6, 8, 10, 12] def cho_han(dice1, dice2, money1, user_in): if (dice1 + dice2 == odd) and user_input == "Odd": return "Odd! You Won $" + str(money1 * 2) elif (dice1 + dice2 == odd) and user_in != "Odd": return "Odd! You lost $" + str(money1) elif (dice1 + dice2 == even) and user_in == "Even": return "Even! You Won $" + str(money1 * 2) else: return "Even! You lost $" + str(money1) print(cho_han(dice1, dice2, 300, user_in)) ` No matter what I put in for the variable user_in it will always print "Even! You lost $300" Sorry for having such a minor problem I'm new to python and programming in general and am just trying to learn. Thanks for anyone who can help!
<python><python-3.x><if-statement>
2019-09-23 07:27:04
LQ_EDIT
58,058,024
Change the dictionary on c# model
<p>I have a dictionary and I need to change the dictionary on c# model.How to do it?</p> <pre><code>var number = new Dictionary&lt;string, int&gt; { {"One", 1}, {"Two", 2}, {"Three", 3} }; </code></pre> <p>Model:</p> <pre><code>public class Number { public double One{ get; set; } public double Two { get; set; } public double Three { get; set; } } </code></pre>
<c#>
2019-09-23 08:02:31
LQ_CLOSE
58,059,822
Android emulator Failed to create Vulkan instance
<p>When creating new Android emulator in Ubuntu shows following error, does this affect my vulkan game development?</p> <pre><code>queryCoreProfileSupport: swap interval not found emulator: ERROR: VkCommonOperations.cpp:496: Failed to create Vulkan instance. emulator: WARNING: Ignoring invalid http proxy: Bad format: invalid port number (must be decimal) </code></pre> <p>My AVD device specification are added below.</p> <p><a href="https://i.stack.imgur.com/cfeIB.png" rel="noreferrer"><img src="https://i.stack.imgur.com/cfeIB.png" alt="enter image description here"></a></p>
<android><android-emulator><vulkan>
2019-09-23 09:54:07
HQ
58,060,745
EXCEL MACRO - FILTERS
Greetings. I am trying to write a MACRO in EXCEL. I have multiple sheets and I want to filter based on the YELLOW fill color. How do I write macro for this ? My apologies if my question sounds dumb but I really want to learn MACROS in Excel. Best regards, Babar
<excel><vba><filter>
2019-09-23 10:47:45
LQ_EDIT
58,061,171
read vars from csv file using ansible
Hello Team Please see my existing code and this is working fine as expected from below us can see that i have statically defined the vars for list3 and list4 I want to dynamically read these vars from a csv file. is that possible? - hosts: localhost gather_facts: false tasks: - name: "set fact for snow" set_fact: list2: "{{ hostvars['192.168.10.20']['list1'] }}" - include_tasks: loop1.yml vars: list3: - dev-cn-c1 - dev-cn-c2 - dev-cn-c3 - dev-cn-c7 - dev-cn-c8 - dev-cn-c3 - dev-cn-c10 loop: "{{ list2 }}" loop_control: loop_var: outer_item when: - outer_item.type == 'CpmiGatewayCluster' - list3|intersect(outer_item.names)|length > 0 - debug: msg: "{{ list2 }}" - include_tasks: loop2.yml vars: list4: - dev-cn-c1 - dev-cn-c2 - dev-cn-c3 - dev-cn-c7 - dev-cn-c8 - dev-cn-c3 - dev-cn-c10 loop: "{{ list2 }}" loop_control: loop_var: outer_item when: - outer_item.type == "simple-gateway" - list4|intersect(outer_item.name)|length > 0 see sample csv file cat int.csv devicename,location dev-cn-c1,32 dev-cn-c2,32 dev-cn-c3,56 dev-cn-c4,56
<ansible><ansible-2.x><ansible-inventory><ansible-facts>
2019-09-23 11:11:55
LQ_EDIT
58,062,346
Extracting Value from JSON variable
<p>I'm trying to extract a value called "balanceStr" from a web scraper I'm making, but I'm not having much luck!</p> <p>Here's where I got so far:</p> <pre><code>import requests import json url = "https://www.hpbscan.org/HpbScan/addrs/getAddressDetailInfo" headers = {'Content-Type': 'application/json;charset=utf-8'} body = '["0x7EC332476fCA4Bcd20176eE06F16960b5D49333e"]' data = requests.post(url, data=body, headers=headers) json_data = (json.loads(data.text)) #print(json_data) print(json_data['balanceStr']) </code></pre> <p>If I just print(json_data) this is the output, but I'm just trying to get the value of balanceStr (36885.403...) in a variable so that I can use it like print(currentbalance)</p> <pre><code>[ "000000", "\u6210\u529f", { "addrs": { "accountType": null, "address": "0x7ec332476fca4bcd20176ee06f16960b5d49333e", "assetRankingOrder": "150", "balance": 36885403823844342504238, "balanceStr": "36885.40382384", "createTimestamp": 1569209857000, "fromCount": 22, "lastestBlock": 3951440, "map": {}, "number": 229, "percentRate": "0.0369%", "startBlock": 51601, "toCount": 15 }, "hpbInstantPrice": { "changePercent": "-6.65%", "cnyPrice": "1.9890", "id": 1, "map": {}, "updateTime": 1569210840000, "usdPrice": "0.2791" }, "nonce": 22 } ] </code></pre> <p>When I print(json_data['balanceStr']) this is the error I'm getting:</p> <pre><code> print(json_data['addrs']) TypeError: list indices must be integers or slices, not str </code></pre> <p>Any help would be much appreciated!</p>
<python><json><python-3.x>
2019-09-23 12:22:04
LQ_CLOSE
58,062,554
How to line break long large title in iOS 13?
<p>As title, is there a way to split long large titles in UINavigationBar?</p> <p>I tried all those methods, working for iOS 11 but none of them seem work to me on iOS 13</p> <p><a href="https://stackoverflow.com/questions/47901318/how-to-set-multi-line-large-title-in-navigation-bar-new-feature-of-ios-11/51295457">How to set multi line Large title in navigation bar? ( New feature of iOS 11)</a></p>
<uinavigationbar><uinavigationitem><ios13>
2019-09-23 12:33:18
HQ
58,063,485
Convert Object Json to Array Json
I have JSON: { "confirmationTypes": [ { "confirmationTypeCode": "A" }, { "confirmationTypeCode": "B" } ] } I need JSONArray about structure array = [confirmationTypes] Example: [ { "confirmationTypes": [ { "confirmationTypeCode": "A" }, { "confirmationTypeCode": "B" } ] } ] Can it be somehow converted? Is there any simple way to solve this problem?
<java><android>
2019-09-23 13:23:12
LQ_EDIT
58,064,088
Why is my python script crashing on my server?
<p>Hey I currently run a python script on my windows server. After 10-24h the script crashes and I don't know why. Is there an easy opportunity to get to know where its coming from? I thought about using an IDE, but my server is probably to small and its kind of an overkill. Is there an opportunity to write the error in a txt file or so when the code crashes? Thanks for your help!</p>
<python><server>
2019-09-23 13:55:48
LQ_CLOSE
58,064,393
Change Date Format and keep it as a date
<p>How to turn DD/MM/YYYY 00:00:0000 to YYYY-MM-DD 00:00:0000 and keep it as date format and not string in c#</p> <p>i have tried many options but still did not find the right one.</p>
<c#>
2019-09-23 14:12:35
LQ_CLOSE
58,065,428
Vanilla Rails 6.0: "error Command "webpack" not found"
<h2>System:</h2> <p>Ruby: 2.6.3p62 (rvm)<br> Rails: 6.0<br> OS: macOS 10.14.6</p> <h2>Setup</h2> <p>A fresh Rails 6.0 application:</p> <pre><code>$ rails new testshop2 $ cd testshop2 $ rails g controller Page index $ rails s =&gt; Booting Puma =&gt; Rails 6.0.0 application starting in development =&gt; Run `rails server --help` for more startup options Puma starting in single mode... * Version 3.12.1 (ruby 2.6.3-p62), codename: Llamas in Pajamas * Min threads: 5, max threads: 5 * Environment: development * Listening on tcp://localhost:3000 Use Ctrl-C to stop </code></pre> <p>When I browse to `<a href="http://localhost:3000/page/index" rel="noreferrer">http://localhost:3000/page/index</a>' the system throughs this error:</p> <pre><code>Started GET "/page/index" for ::1 at 2019-09-23 17:06:12 +0200 (0.4ms) SELECT sqlite_version(*) Processing by PageController#index as HTML Rendering page/index.html.erb within layouts/application Rendered page/index.html.erb within layouts/application (Duration: 1.8ms | Allocations: 206) [Webpacker] Compiling… [Webpacker] Compilation failed: error Command "webpack" not found. Completed 500 Internal Server Error in 2021ms (ActiveRecord: 0.0ms | Allocations: 640080) ActionView::Template::Error (Webpacker can't find application in /Users/stefan/Github/sandbox/testshop2/public/packs/manifest.json. Possible causes: 1. You want to set webpacker.yml value of compile to true for your environment unless you are using the `webpack -w` or the webpack-dev-server. 2. webpack has not yet re-run to reflect updates. 3. You have misconfigured Webpacker's config/webpacker.yml file. 4. Your webpack configuration is not creating a manifest. Your manifest contains: { } ): 6: &lt;%= csp_meta_tag %&gt; 7: 8: &lt;%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %&gt; 9: &lt;%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %&gt; 10: &lt;/head&gt; 11: 12: &lt;body&gt; app/views/layouts/application.html.erb:9 </code></pre> <p>How can I fix this? It says <code>error Command "webpack" not found.</code> but shouldn't Rails install everything needed automatically?</p>
<ruby-on-rails><webpack><ruby-on-rails-6>
2019-09-23 15:13:37
HQ
58,067,075
Error: Initializer 'init(_:)' requires that 'Binding<String>' conform to 'StringProtocol'
<p>I am getting the above error and couldn't figure out how to solve it. I have an array of objects that contain a boolean value, and need to show a toggle for each of these boolean.</p> <p>Below is the code.</p> <pre><code>class Item: Identifiable { var id: String var label: String var isOn: Bool } class Service: ObservableObject { var didChange = PassthroughSubject&lt;Void, Never&gt;() var items: [Item] { didSet { didChange.send(()) } } } struct MyView: View { @ObservedObject var service: Service var body: some View { List { ForEach(service.items, id: \.self) { (item: Binding&lt;Item&gt;) in Section(header: Text(item.label)) { // Error: Initializer 'init(_:)' requires that 'Binding&lt;String&gt;' conform to 'StringProtocol' Toggle(isOn: item.isOn) { Text("isOn") } } } } .listStyle(GroupedListStyle()) } } </code></pre>
<swift><swiftui><combine>
2019-09-23 17:01:51
HQ
58,068,938
Running Program on Server
<p>I want to build a system where users can upload their own Python code. The code will then be run and marked for correctness. The result should be outputted to the user.</p> <p>I have very limited knowledge of servers and can't find the right place to start. What would be the easiest way to approach this problem and where should I start?</p>
<python><server>
2019-09-23 19:24:44
LQ_CLOSE
58,069,404
State Error CS0501 'MoviesController.Random()' must declare a body because it is not marked abstract, extern, or partial WebApplication1
<p>** I can’t find the error, I’ve already completely redone the project, but this error still gets out, what is the problem of the guys. **</p> <pre><code> using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using WebApplication1.Models; namespace WebApplication1.Controllers { public class MoviesController : Controller { // GET: Movies/Random public ActionResult Random(); public ActionResult ByReleaseDate(int year, int month) { enter code here return Content(year + "/" + month); } } </code></pre>
<c#>
2019-09-23 19:59:19
LQ_CLOSE
58,071,781
Is there an iPhone SE simulator for Xcode 11, iOS 13?
<p>I'm running Xcode 11.0 on macOS Mojave (10.14.6) and though the iPhone SE is <a href="https://support.apple.com/en-us/HT210327" rel="noreferrer">officially supported on iOS 13</a>, it doesn't appear in the list of simulators. </p> <p><a href="https://i.stack.imgur.com/rtlgE.png" rel="noreferrer"><img src="https://i.stack.imgur.com/rtlgE.png" alt="enter image description here"></a></p> <p>It can't be added nor downloaded, as far as I can see. Any ideas? </p>
<ios><ios-simulator><xcode11><iphone-se>
2019-09-24 01:01:22
HQ
58,072,397
I want to open a page when a button is pressed in React js
I am creating a function in react js where a user will be redirected to the dashboard when he click sign in. handleSubmit(){ this.props.history.push('/blog-overview'); } When i click on the button, the page is refreshed rather than redirecting to that path specified.
<javascript><reactjs>
2019-09-24 02:45:47
LQ_EDIT
58,073,612
Just some quick questions on using string input (Eclipse)
We have to make a program on printing initials, which seems pretty easy ik, but I don't know how to cut the string when the input is all on one line using the scanner class in.nextline();. I cant seem to find a way to cut the string using only string methods. Also another problem arose when I have to also be able to adjust if their isn't a middle name either. if anyone can help me or lead me in the right direction that would be nice.
<java><string>
2019-09-24 05:29:23
LQ_EDIT
58,073,931
Json Respone include function in php
I have one PHP code which has JSON response. I need to separate the **['name' => $message->getName(), 'mes' => $message->getMes(), 'update_time' => $message->getUpdateTime()->format('Y-m-d H:i:s')]** into a independent function. When I need I can call it. But, I don't know how to do. this is my controller /** * @Route("/message/board/reset/{id}", name = "message_reset", requirements = {"id" = "\d+"}) */ public function editMeg($id) { $entityManager = $this->getDoctrine()->getEntityManager(); $message = $entityManager->find('MegBundle:message', $id); $UserN = $message->getName(); $UserM = $message->getMes(); return new JsonResponse(['result' => 'ok', 'ret' => ['name' => $message->getName(), 'mes' => $message->getMes(), 'update_time' => $message->getUpdateTime()->format('Y-m-d H:i:s')]]); } I hope this is reasonable and has ways to do it. I appreciate any help.
<php><json><symfony>
2019-09-24 06:02:12
LQ_EDIT
58,074,934
swfit - why global static variable is not init?
## Problem ## * SomeTimes (maybe thread) ***kIndexMinID , kIndexMaxID*** value is **"0"** ## Code ## ``` // test.swift let kIndexMinID :Int = 100 let kIndexMaxID :Int = 200 ``` ## Question ## * why not init value? (when init?) * how to global variable init ?
<swift><xcode><swift3>
2019-09-24 07:14:56
LQ_EDIT
58,076,625
Login with Google Not working in the server
Login with Google using Google+ API is not working in the server, but working correctly in the localhost. it is not redirecting to domains.php file after authentication. getting the below like URL in the browser bar. site.com/domains/domains.php?code=4%2FsrQHdwzRfgdf4isoIuxgfddgRvhgfdfg0WbQ6eV5gfyj7I8ER Error: Fatal error: Uncaught Google_AuthException: Error fetching OAuth2 access token, message: 'invalid_grant' in /home/myjobs/public_html/domain/login_with_google/src/auth/Google_OAuth2.php Anybody tell me the solution.
<php><google-api>
2019-09-24 08:58:58
LQ_EDIT
58,076,937
How can i redirect a webpage to another webpage permanently through cpanel
How can redirect a webpage to another webpage permanently using cpanel Ex: www.abc/contactUs.php redirect to www.abc/contactus.php Your quick response appreciated.
<php><cpanel>
2019-09-24 09:17:03
LQ_EDIT
58,077,568
Get file path from URI on Android 10,
<p>I need to pick files from the device, </p> <p>Here is my code, </p> <pre><code> Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("*/*"); String[] mimeTypes = {"image/*", "application/pdf"}; intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes); startActivityForResult(intent, PICK); </code></pre> <p>The picked URIs url always like this on Android 10 devices, </p> <pre><code>content://com.android.providers.downloads.documents/document/msf:75878 </code></pre> <p>I tried many different solutions to get the file path from this URI but with no luck, </p> <p>Note: my app works perfectly on pre-Android 10 devices and I am able to get the picked files paths.</p>
<android><filepicker><android-10.0>
2019-09-24 09:50:37
HQ
58,078,868
Selenium tests broken by recent update of safari to version 13?
<p>does anybody have a problem of selenium tests failing on new safari version 13. Ran the same tests on chrome and firefox and it works fine. Also tested it on older version of safari and it works fine.</p> <p>I didn't manage to pin point exactly where it fails. One case I did notice is that on safari 13 selenium click on <code>&lt;div role='button' aria-haspopup='true'&gt;....&lt;/div&gt;</code> invokes no action(in my case opens a popup menu). And test proceeds to the next line of code. <strong>note</strong> however at this point I am not claiming that this kind of click always fails, it's just where I noticed it in my tests. </p> <p>If anyone came across this kind of issue on safari 13 please provide your input. Thanks</p>
<selenium><safari><webdriver>
2019-09-24 11:03:10
HQ
58,078,991
Unable To Run Unit Tests in Xcode 11: The run destination * is not valid for tests you have chosen to perform
<p>Pretty sure my tests were running fine before I updated from Xcode 10.3 to Xcode 11. Now when I try to run a test I get the following error. </p> <p><a href="https://i.stack.imgur.com/OWRDI.png" rel="noreferrer"><img src="https://i.stack.imgur.com/OWRDI.png" alt="Xcode Error Alert"></a> The run destination iPhone 5s is not valid for tests you have chosen to perform. Please select a run destination which supports the tests that you wish to perform.</p> <p>As an experiment, I tried creating a brand new test target and running the example tests that it gives you and the error is the same. I've also tried with different simulators. </p>
<ios><xcode><xctest><xcode11><xctestcase>
2019-09-24 11:10:42
HQ
58,079,367
App crash while calling RecyclerView says PID: 32217
logs are like this > E/AndroidRuntime: FATAL EXCEPTION: main > Process: com.example.notes, PID: 32217 > android.view.InflateException: Binary XML file line #11: Attempt to invoke virtual method 'boolean > java.lang.String.equals(java.lang.Object)' on a null object reference > Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on > a null object reference > at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764) > at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730) > at android.view.LayoutInflater.rInflate(LayoutInflater.java:863) > at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) > at android.view.LayoutInflater.inflate(LayoutInflater.java:515) > at android.view.LayoutInflater.inflate(LayoutInflater.java:423) > at com.example.notes.adapters.NotesRecyclerAdapter.onCreateViewHolder(NotesRecyclerAdapter.java:34) > at com.example.notes.adapters.NotesRecyclerAdapter.onCreateViewHolder(NotesRecyclerAdapter.java:18) > at androidx.recyclerview.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:6794) > at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5975) > at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5858) > at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5854) > at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2230) > at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1557) > at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1517) > at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:612) > at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3924) > at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:3641) > at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4194) > at android.view.View.layout(View.java:20967) > at android.view.ViewGroup.layout(ViewGroup.java:6440) > at androidx.coordinatorlayout.widget.CoordinatorLayout.layoutChild(CoordinatorLayout.java:1183) > at androidx.coordinatorlayout.widget.CoordinatorLayout.onLayoutChild(CoordinatorLayout.java:870) > at androidx.coordinatorlayout.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:889) > at android.view.View.layout(View.java:20967) > at android.view.ViewGroup.layout(ViewGroup.java:6440) > at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) > at android.widget.FrameLayout.onLayout(FrameLayout.java:261) > at android.view.View.layout(View.java:20967) > at android.view.ViewGroup.layout(ViewGroup.java:6440) > at androidx.appcompat.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:446) > at android.view.View.layout(View.java:20967) > at android.view.ViewGroup.layout(ViewGroup.java:6440) > at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) > at android.widget.FrameLayout.onLayout(FrameLayout.java:261) > at android.view.View.layout(View.java:20967) > at android.view.ViewGroup.layout(ViewGroup.java:6440) > at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1791) > at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1635) > at android.widget.LinearLayout.onLayout(LinearLayout.java:1544) > at android.view.View.layout(View.java:20967) > at android.view.ViewGroup.layout(ViewGroup.java:6440) > at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) > at android.widget.FrameLayout.onLayout(FrameLayout.java:261) > at com.android.internal.policy.DecorView.onLayout(DecorView.java:955) > at android.view.View.layout(View.java:20967) > at android.view.ViewGroup.layout(ViewGroup.java:6440) > at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:3092) > at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2779) > at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1863) > 2019-09-24 16:50:58.474 32217-32217/? E/AndroidRuntime: at > android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8072) > at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911) > at android.view.Choreographer.doCallbacks(Choreographer.java:723) > at android.view.Choreographer.doFrame(Choreographer.java:658) > at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897) > at android.os.Handler.handleCallback(Handler.java:790) > at android.os.Handler.dispatchMessage(Handler.java:99) > at android.os.Looper.loop(Looper.java:164) > at android.app.ActivityThread.main(ActivityThread.java:7000) > at java.lang.reflect.Method.invoke(Native Method) > at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441) > at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408) NotesRecyclerAdapter.java public class NotesRecyclerAdapter extends RecyclerView.Adapter<NotesRecyclerAdapter.NotesViewHolder> { private static final String TAG = "NotesRecyclerAdapter"; private ArrayList<Note> mNotes ; public NotesRecyclerAdapter(ArrayList<Note> mNotes) { this.mNotes = mNotes; } @NonNull @Override public NotesViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { Log.d(TAG, "onCreateViewHolder: started"); View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.note_list_item, parent, false); Log.d(TAG, "onCreateViewHolder: created"); return new NotesViewHolder(view); } @Override public void onBindViewHolder(@NonNull NotesViewHolder holder, int position) { Log.d(TAG, "onBindViewHolder: started "); holder.notes_tv.setText(mNotes.get(position).getTitle()); holder.time_tv.setText(mNotes.get(position).getTimeStamp()); } @Override public int getItemCount() { Log.d(TAG, "getItemCount: start"); return mNotes.size(); } public class NotesViewHolder extends RecyclerView.ViewHolder{ TextView notes_tv, time_tv; public NotesViewHolder(@NonNull View itemView) { super(itemView); notes_tv = itemView.findViewById(R.id.notes_tv); time_tv = itemView.findViewById(R.id.time_tv); Log.d(TAG, "NotesViewHolder: "); } } } this is the MainActivity.java public class MainActivity extends AppCompatActivity { private static final String TAG = "MainActivity"; //ui components RecyclerView mRecyclerView; //var private NotesRecyclerAdapter mAdapter; private ArrayList<Note> noteArrayList = new ArrayList<>(); verticalSpacingItemDecorator verticalSpace; @Override protected void onCreate(Bundle savedInstanceState) { Log.d(TAG, "onCreate: Activity created "); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mRecyclerView = findViewById(R.id.recycler_view); initRecyclerView(); insertFakeData(); Log.d(TAG, "onCreate: done"); } public void insertFakeData() { for(int i = 0; i<=5; i++) { Note note = new Note(); note.setTitle("title 1" ); note.setContent("content #: 1"); note.setTimeStamp("jan "); noteArrayList.add(note); } //to tell adapter to chk data set mAdapter.notifyDataSetChanged(); Log.d(TAG, "insertFakeData: inserted"); } public void initRecyclerView() { Log.d(TAG, "initRecyclerView: started"); LinearLayoutManager layoutManager = new LinearLayoutManager(this); layoutManager.setOrientation(LinearLayoutManager.VERTICAL); mRecyclerView.setLayoutManager(layoutManager); verticalSpace = new verticalSpacingItemDecorator(10); mRecyclerView.addItemDecoration(verticalSpace); mAdapter = new NotesRecyclerAdapter(noteArrayList); //setting adapter with empty dataset mRecyclerView.setAdapter(mAdapter); Log.d(TAG, "initRecyclerView: done"); } } Not able to find the solution , by debugging, i found that onBindViewHolder() is never being called
<android><android-recyclerview>
2019-09-24 11:33:07
LQ_EDIT
58,079,484
comparing table records and return the extra
<p>Table1 has 10001 records and table2 has 10000 records. How do I get the extra record in table1 ?</p>
<sql>
2019-09-24 11:39:15
LQ_CLOSE
58,080,353
Application is running inside IIS process but is not configured to use IIS server .NET Core 3.0
<p>I have migrated our application from .NET Core 2.2 to version 3.0. Actually I created the new application in 3.0 from scratch and then copied source code files. Everything looks great but when I try to run the application within Visual Studio 2019 I get the exception: </p> <blockquote> <p>Application is running inside IIS process but is not configured to use IIS server</p> </blockquote> <p>Here is my Program.cs</p> <pre><code>public static class Program { public static void Main(string[] args) { CreateHostBuilder(args).Build().Run(); } public static IHostBuilder CreateHostBuilder(string[] args) =&gt; Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder =&gt; { webBuilder.UseContentRoot(Directory.GetCurrentDirectory()); webBuilder.UseKestrel(); webBuilder.UseIISIntegration(); webBuilder.UseStartup&lt;Startup&gt;(); }); } </code></pre> <p>The error occurs at the line: CreateHostBuilder(args).Build().Run(); It worked fine in .NET Core 2.2 but it doesn't want to run as 3.0. I cannot find anything else that should be done. Something new in the Startup.cs? I don't know.</p>
<asp.net-core-3.0>
2019-09-24 12:28:26
HQ
58,081,105
Cant find clear example for futter_share_me packgae
<p>I cant find example for flutter_share_me package , becuse I dont understand what is url and msg in package , can you please give me an example ?</p>
<flutter><dart>
2019-09-24 13:10:59
LQ_CLOSE
58,082,430
Replace bars by line break in javascript
<p>I want replace '/' by a line break in javascript.</p> <p>I have this string:</p> <pre><code>L-V:DE 08:30 A 14:30 Y DE 16:30 A 20:00/S:DE 09:30 A 13:00/Festivos:SIN SERVICIO </code></pre> <p>I want to turn it into:</p> <pre><code>L-V:DE 08:30 A 14:30 Y DE 16:30 A 20:00 S:DE 09:30 A 13:00 Festivos:SIN SERVICIO </code></pre>
<javascript>
2019-09-24 14:20:56
LQ_CLOSE
58,083,935
sql- query update in c#
My database, Student, has 4 columns which are ID, Name, FamilyName and Age. I ask user to give specific ID and then one of the columns to update with query. my update query CommandText is as follow: public void Update (OleDbConnection connection, string Name, int ID) { _command.Connection = connection; _command.CommandText = String.Format("UPDATE Student SET Name = Name WHERE ID = ID"); _command.ExecuteNonQuery(); } in main() by the use of a switch I am trying to manage which column the user wants to update. like this: Console.WriteLine("which do you want to edit, name, family name or age?"); var answer2 =Console.ReadLine().Trim().ToLower(); switch(answer2) { case "name": my question is, in my query in CommanText is that possible to write "UPDATE Student SET Name = Name || FamilyName = Name || Age = Name WHERE ID = ID"
<c#><sql-update>
2019-09-24 15:45:18
LQ_EDIT
58,084,788
SwiftUI: Tabview, keep state when changing tab
<p>I create an application, with several tabs, for each tab there is a webview.</p> <p>My webview:</p> <pre><code>struct WebView : UIViewRepresentable { let request: URLRequest func makeUIView(context: Context) -&gt; WKWebView { return WKWebView() } func updateUIView(_ uiView: WKWebView, context: Context) { uiView.load(request) } } </code></pre> <p>The problem when im changing tab, the web view recreate again. I want create the webviews only once, then every time I change tab, it keeped state And webview will not recharge each time</p> <p>My code:</p> <pre><code>struct ContentView: View { var body: some View { TabView { WebView(request: URLRequest(url: URL(string: "https://www.google.com/")!)) .tabItem { Image(systemName: "1.circle") Text("Messenger") }.tag(0) WebView(request: URLRequest(url: URL(string: "https://facebook.com/login")!)) .tabItem { Image(systemName: "2.circle") Text("Trello") }.tag(1) } } } </code></pre>
<swift><swiftui>
2019-09-24 16:41:09
HQ
58,085,354
CONVERT OBJECT IN DATETIME
<p>I should convert this : '1986-07-11T00:00:00.000-02:00' (it's an object) into a datetime so that i can do evaluations after evaluation. How can I do that?</p> <p>Thanks </p>
<python><data-science>
2019-09-24 17:21:37
LQ_CLOSE
58,087,446
What are the iPhone 11 / 11 Pro / 11 Pro Max media queries
<p>What are the correct CSS media queries used to target Apple's 2019 devices?</p> <p>The iPhone 11, iPhone 11 Pro and iPhone 11 Pro Max.</p>
<css><iphone><media-queries>
2019-09-24 20:06:38
HQ
58,088,256
Beginner encryption program
<p>Been trying to get the encryption to perform the operation and store the value for each of the 4 variables, and then print each of these 4 separate variables. Where am I going wrong? encrypt only wants to work on one of the calculations.</p> <pre><code>int main(void) { int a, b, c, d, encrypt; printf("Enter integer 1:\n"); scanf("%d", &amp;a); printf("Enter integer 2:\n"); scanf("%d", &amp;b); printf("Enter integer 3:\n"); scanf("%d", &amp;c); printf("Enter integer 4:\n"); scanf("%d", &amp;d); encrypt = (a += 7) % 10, (b +=7) % 10, (c +=7) % 10, (d +=7) % 10; printf("The encrypted value is: %d%d%d%d\n", encrypt); //scanf("%d", &amp;encrypt); return 0; } </code></pre>
<c>
2019-09-24 21:16:38
LQ_CLOSE
58,089,057
Is there a way of extracting xpath and text from webpage and save to file?
<p>I am looking for handy tool to extract UIElement's Object Type and Xpath/ID/Name from webpage or any alternative instead of Inspecting the element from Browser? Also any alternative to extract text from Webpage. I want to save this in a separate Excel or Text file. Any suggestion how to go about it?</p> <p>I am saving it manually by inspecting the UIElement object on the webpage and saving it (space separated) on to file. Then reading it using a dictionary.</p>
<c#><html><selenium><dictionary><xpath>
2019-09-24 22:52:48
LQ_CLOSE
58,090,006
programming to add a google sheet to someones drive by selecting there name in the sheet
Hi I am trying to create a system for work for when im choosing out of a list of people that i am the sales rep filling out the sheet on a copy. Just seeing if theres a way also that when i choose my name that it also adds that sheet to my own drive
<google-apps-script>
2019-09-25 01:30:46
LQ_EDIT
58,090,177
Identity asp.net core 3.0 - IdentityDbContext not found
<p>My app broke with the 3.0 release of .NET core with reference errors for <code>IdentityDbContext</code>. I'm looking through documentation for Identity on core 3.0 but it implies that IdentityDbContext should be there. It's the only error I'm getting with a couple <code>DbContext</code> errors.</p> <p>I have a pretty simple API, no MVC views, just a data server that gives back JSON objects. It's based on Identity so it has the users and roles and claims. And it's starting to take advantage of that. My main DbContext extends <code>IdentityDbContext&lt;ApplicationUser&gt;</code> but after switching target platform to 3.0 after the upgrade, it says it doesn't exist and gives me compile errors. Has anyone run into this? Am I missing something? The migration and breaking changes pages don't seem to have anything addressing my issue.</p> <p>DbContext looks like this:</p> <pre class="lang-cs prettyprint-override"><code>using System; using Microsoft.AspNetCore.Identity; //using Microsoft.AspNetCore.Identity.EntityFrameworkCore; &lt;- this no longer works either using Microsoft.EntityFrameworkCore; //&lt;- this I had to download as a package using App.Constants; using App.Models.Identity; namespace App.Models { public class AppContext : IdentityDbContext&lt;ApplicationUser&gt; //&lt;- error is right here { ... my models } } </code></pre>
<c#><asp.net-core><asp.net-core-3.0>
2019-09-25 01:56:52
HQ
58,090,178
What database to choose from?
<p>Realm Database or MySQL or MongoDB or the standard Firebase. </p> <p>I am curious why would anyone choose one over another. I am in a group project and one of the members in the group suggested that we should use Realm Database over Firebase. He tried to explain to me the reason but I was not able to comprehend. </p> <p>What has your experience been like? Is one database more user-friendly over another? Firebase seems to have very nice documentation. </p> <p>Which one would you guys suggest?</p>
<mongodb><firebase><realm>
2019-09-25 01:56:53
LQ_CLOSE
58,090,666
Bagging model machine learning
I have the following line of code: # Setting the values ​​for the number of folds num_folds = 10 seed = 7 # Separating data into folds kfold = KFold(num_folds, True, random_state = seed) # Create the unit model (classificador fraco) cart = DecisionTreeClassifier() # Setting the number of trees num_trees = 100 # Creating the bagging model model = BaggingClassifier(base_estimator = cart, n_estimators = num_trees, random_state = seed) # Cross Validation resultado = cross_val_score(model, X, Y, cv = kfold) # Result print print("Acurácia: %.3f" % (resultado.mean() * 100)) This is a ready-made code that I got from the internet, which is obviously predefined for testing my cross-validated TRAINING data and knowing the accuracy of the bagging algorithm. I would like to know if I can apply it to my TEST data (data without output 'Y') The code is a bit confusing and I can't model it. I'm looking for something like: # Training the model model.fit(X, Y) # Making predict Y_pred = model.predict(X_test) I want to use the trained bagging model on top of the training data in the test data and make predictions but I don't know how to modify the code
<python><scala><machine-learning><supervised-learning>
2019-09-25 03:14:44
LQ_EDIT
58,090,981
c++ : invoking tcl proc from c++ in multithreaded mode
I am working in c++. My function func() is being called by multiple threads. ( each thread will call this function only once) From inside the func(), I want each thread to call a TCL proc named tcl_proc_name ( which takes no arguments ) For this, I did like this Tcl_Eval( Tcl_CreateInterp() , “tcl_proc_name”); But it somehow this code is not able to invoke the tcl proc. Is I’am missing something. Please help. Regards
<c++><multithreading><tcl>
2019-09-25 04:01:38
LQ_EDIT
58,092,085
how can I pass the array data coming from api to one ViewController to another ViewController?
I'm new in iOS I'm trying to pass my array data to another view controller through prepare segue to the another viewcontroller. ```Swift class FirstVc { var location = [Any]() self.clientrequest.request(url: "http://api.details.in/api/users/alllocation", method: .GET, completion: { res , err in let decode = try! JSONDecoder().decode(SelectLocation.self, from:json) self.location = decode.states //I'm getting all locations here print(self.location) }) } override func prepare(for segue: UIStoryboardSegue, sender: Any?) { if segue.destination is SecondVc { let vc = segue.destination as? SecondVc //here I'm assigning the variable vc?.mineSpillere2 = self.location } } class SecondVc{ @IBOutlet weak var selectState: UILabel! var mineSpillere2 = [Any]() override func viewDidLoad() { selectState.text = mineSpillere2 as? String } } ```
<ios><swift>
2019-09-25 06:09:52
LQ_EDIT
58,093,765
i am getting 401 unauthorized response
getThingsApi() { let uri = 'https://testapiserver/api/things/'; let req = { method: "GET", headers: { Authorization: 'Basic cC5qYWltdXJ1Z2FuLm1jYUBnbWFpbC5jb206MTIzNDU2', } }; console.log('InputRequest::' + JSON.stringify(req)); fetch(uri, req) .then(response => response.json()) .then(responseJson => { console.log('ResponseAxis::' + JSON.stringify(responseJson)); }) .catch(error => { console.log("Error::" + JSON.stringify(error)); }); } when i run above code , its working fine codesandbox.io..but not working in react native app. Could you please suggest me..what i did wrong..
<javascript><reactjs><fetch><single-page-application>
2019-09-25 07:56:24
LQ_EDIT
58,094,325
how to upload image to azure DB
I read and found that the best way to upload is using blob (create container) I want to use it with node.js how can I upload for example an image to blob using node.js code?
<node.js><azure><azure-storage-blobs>
2019-09-25 08:32:19
LQ_EDIT
58,095,570
Python dictionary wih key value pair as value for a key
I want to know how to create a dictionary with key value pair and value should have another values. For (eg): {key:{value1 : [a,b,c] , value2 : [d,e,f] , value3 : [g,h,i] } } I tried, a = {} a.setdefault(key,{})[value] = a a.setdefault(key,{})[value] = b a.setdefault(key,{})[value] = c then a returns, { key: {value : c } } For value last one added is only getting. Can anyone help for this? Thanks in advance
<python><dictionary><python-3.6>
2019-09-25 09:43:59
LQ_EDIT
58,096,533
can I loop some data json with nested value in golang
i got a problem when nested data json in golang, when I got a new data json ORDER_TRX_H_ID the result must looping with new ORDER_TRX_H_ID, but my result always show last data. u can try my code [https://play.golang.org/p/aHUoYZlEQs4][1] [1]: https://play.golang.org/p/aHUoYZlEQs4 My result always show last data { "DTM_CRT": "2019-08-28T16:25:15.757Z", "ORDER_TRX_H_ID": "1", "QUESTION": { "ALAMAT_KTP": "Bogor", "FULLNAME": "Fariz" }, "QUICK_DATA_H_ID": "1" } my expected result { "DTM_CRT": "2019-08-28T16:25:15.757Z", "ORDER_TRX_H_ID": "1", "QUESTION": { "ALAMAT_KTP": "jalandisana", "FULLNAME": "RUBEN" }, "QUICK_DATA_H_ID": "1" }, { "DTM_CRT": "2019-08-28T16:25:15.757Z", "ORDER_TRX_H_ID": "2", "QUESTION": { "ALAMAT_KTP": "Bogor", "FULLNAME": "Fariz" }, "QUICK_DATA_H_ID": "2" }
<json><go>
2019-09-25 10:39:32
LQ_EDIT
58,098,006
changing the date format from 1-3-2019 to 01-03-2019
I don't know to format the dates which are inserted as "7-1-2019" to "07-01-2019" can someone help me with that? I was trying with this [, rq_date_inserted1:= as.Date(rq_date_inserted1, "%d/%mm/%Y")] but thats not working properly as after doing so some of the dates are not recognized;/
<r><date><format><data.table>
2019-09-25 12:07:26
LQ_EDIT
58,098,054
Extracting a substring to the last-nth delimiter C++
<p>I am trying in C++ to find </p> <ol> <li>the most performant</li> <li>the most elegant </li> </ol> <p>code that takes a string and an integer and for a given delimiter, let's say ".", results to the nth from the last substring.</p> <p>Example Input:</p> <p>string "a.b.c.d.e" and delimFromEndLevel = 1 => string "a.b.c.d"</p> <p>string "a.b.c.d.e" and delimFromEndLevel = 2 => string "a.b.c"</p> <p>etc.</p> <p>Starting point is the following code:</p> <pre><code>void elaborateParent( const std::string&amp; input, unsigned int levels ) { std::size_t cutOffIndex = std::string::npos; while (levels &gt; 0) { cutOffIndex = input.rfind('.', cutOffIndex); if (cutOffIndex == std::string::npos) std::cout &lt;&lt; "Not enough levels to go up!" &lt;&lt; std::endl; levels--; if (levels&gt;0) { if (cutOffIndex&gt;0) cutOffIndex--; else std::cout &lt;&lt; "Not enough levels to go up!" &lt;&lt; std::endl; } } std::string result = input.substr(0, cutOffIndex); std::cout &lt;&lt; "Elaboration parent result: '" &lt;&lt; result &lt;&lt; "'" &lt;&lt; std::endl; } </code></pre>
<c++><c++11><c++17>
2019-09-25 12:10:33
LQ_CLOSE
58,098,241
Python: Copying all despite of one attributes/fields of one to another named tuple
What's the shortest way to copy all despite of one attribute/field from one to another named tuple? This question is related to the question [Python: Copying named tuples with same attributes / fields](https://stackoverflow.com/questions/40980775/python-copying-named-tuples-with-same-attributes-fields).
<python><python-3.x><namedtuple>
2019-09-25 12:19:43
LQ_EDIT
58,099,515
How to solve Incorrect syntax near 'xml'?
i`m new in programming and i`m working on an administration program, and when writing one of it`s features I encountered this error. I think that this is a simple problems, tho I really question my begginer skills. Here`s the code. Forgott to mention that I`m working in Microsoft SQL Server Management Studio CODE: create procedure wIaTertiDemo @sesiune varchar(50), parXML xml as begin try declare @utilizator varchar(500) exec wIaUtilizator @sesiune @utilizator output select codfiscal, denumire as @dentert, adresa from tertiDemo for xml raw --create table tertiDemo(codfiscal varchar(50), denumire varchar(500), adresa varchar(500) end try BEGIN CATCH DECLARE @mesajEroare varchar(1000) SET @mesajEroare = ERROR_MESSAGE()+ '(' +OBJECT_NAME(@@PROCID) + ')' RAISERROR (@mesajEroare, 16,1) END CATCH ERRORS: Msg 102, Level 15, State 1, Procedure wIaTertiDemo, Line 1 [Batch Start Line 0] Incorrect syntax near 'xml'. Msg 102, Level 15, State 1, Procedure wIaTertiDemo, Line 6 [Batch Start Line 0] Incorrect syntax near '@utilizator'. Msg 102, Level 15, State 1, Procedure wIaTertiDemo, Line 8 [Batch Start Line 0] Incorrect syntax near '@dentert'.
<sql><sql-server><syntax><syntax-error><ssms>
2019-09-25 13:26:05
LQ_EDIT
58,100,546
Cannot create platform OpenGL context
<p>On my ubuntu 18.04, when I start android emulator:</p> <pre><code>$ANDROID_HOME/emulator/emulator -avd pixel Warning: QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled ((null):0, (null)) emulator: INFO: QtLogger.cpp:66: Warning: QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled ((null):0, (null)) </code></pre> <p>Just standard Android workflow... I can't believe this is unic issue... </p>
<android><ubuntu><emulation>
2019-09-25 14:18:40
HQ
58,103,766
Why Angular method binding firing continiously?
<pre><code>@Component({ selector: 'calc', template: '&lt;p *ngIf="isCalculatable()"&gt;&lt;/p&gt;' }) export class CalcComponent { isCalculatable(){ console.log("yes"); return true; } } </code></pre> <p>When I use this component <code>&lt;calc&gt;&lt;/calc&gt;</code>, it writes "yes" to console continiously. I mean <code>isCalculatable()</code> method firing. So I am using this method so many times in my applicaitons. May this stuation be performance issue?</p>
<angular><angular7>
2019-09-25 17:32:46
LQ_CLOSE
58,103,897
Which css property gets applied?
<pre><code> @media(max-width:1920px) { .callbacks_tabs { left: 45%; } } @media(max-width:1440px) { .callbacks_tabs { left: 50%; } } </code></pre> <p>With above code for screen-width of for ex.- 1200px which property get applied?</p>
<html><css>
2019-09-25 17:41:43
LQ_CLOSE
58,104,790
how to conver Linq to sql
How can I can I write this sql queryt to linq select c.Name as 'Name', s.Status from (select * , ROW_NUMBER() over (partition by CustomerID order by Date desc) rn from CustomerStatus) detail inner join Status s on detail.Status = s.Id inner join Customers c on detail.CustomerId = c.Id where detail.rn = 1 Here I am unable to convert this sql to linq how can do this??
<c#><sql><linq>
2019-09-25 18:46:53
LQ_EDIT
58,111,181
How to make child z-index more than parent or any other way to achieve the effect?
<p><a href="https://i.stack.imgur.com/oq7q1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oq7q1.png" alt="a "></a></p> <p>I'm trying to develop the following effect. Where parents are two sections like this and child is an image. How to achieve this without using absolute?</p> <pre><code>&lt;section&gt; &lt;img /&gt; &lt;/section &lt;section&gt; ..more content &lt;/section&gt; </code></pre> <p>But I got to know that child's z-index cannot be more than parent than whats the way round this?</p>
<html><css><z-index>
2019-09-26 06:59:36
LQ_CLOSE
58,111,377
This error only getting in Android 10, work fine in other versions. If anyone knows please tell me the solution..Urget
Here is the Error: android.database.sqlite.SQLiteException: near "GROUP": syntax error (code 1 SQLITE_ERROR): , while compiling: SELECT _id, bucket_display_name, bucket_id, _id, orientation FROM images WHERE ((is_pending=0) AND (is_trashed=0) AND (volume_name IN ( 'external_primary' ))) AND ((1) GROUP BY 1,(2)) ORDER BY date_modified DESC
<java><android><android-sqlite>
2019-09-26 07:12:59
LQ_EDIT
58,111,484
How to get specific key values from an multi dimensional array in PHP
I currently have the following array: <pre> Array ( [2] => Array ( [id] => 2 [type] => 2 [name] => R-1 Agency [parent] => 1 [children] => Array ( [3] => Array ( [id] => 3 [type] => 3 [name] => R-1-W-1 [parent] => 2 [children] => Array ( [11] => Array ( [id] => 11 [type] => 4 [name] => mdf,lk [parent] => 3 [children] => Array ( ) ) ) ) ) ) [38] => Array ( [id] => 38 [type] => 2 [name] => sndflk [parent] => 1 [children] => Array ( [40] => Array ( [id] => 40 [type] => 3 [name] => new one [parent] => 38 [children] => Array ( ) ) ) ) ) </pre>
<php><arrays><recursion><multidimensional-array><counting>
2019-09-26 07:19:49
LQ_EDIT
58,112,072
showNotification in react-admin doesn't work, Still
<p><a href="https://codesandbox.io/s/simple-6nzp0" rel="nofollow noreferrer">https://codesandbox.io/s/simple-6nzp0</a> please see /src/posts/postEdit.js line 73. no notification show.</p> <p>Could you add a working code on the sandbox?</p> <p>though there are other discussion: <a href="https://stackoverflow.com/questions/54062100/shownotification-in-react-admin-doesnt-work">showNotification in react-admin doesn&#39;t work</a> <a href="https://github.com/marmelab/react-admin/issues/3402" rel="nofollow noreferrer">https://github.com/marmelab/react-admin/issues/3402</a> they all did not work.</p> <p>I need a working code on the sandbox so I know what I miss.</p> <p>Thanks.</p>
<react-admin>
2019-09-26 07:55:43
LQ_CLOSE
58,112,183
Publising Failed - We are unable to create an authentication session
<p>I am trying to upload an iOS App to the App Store in Visual Studio on my Mac.</p> <p>However, I am getting this error shown in the image.</p> <p><a href="https://i.stack.imgur.com/PjRsI.png" rel="noreferrer"><img src="https://i.stack.imgur.com/PjRsI.png" alt="enter image description here"></a></p> <p>Any idea how to fix this problem?</p>
<ios><visual-studio><xamarin>
2019-09-26 08:03:10
HQ
58,112,592
Current Date to milliseconds with 10 digits in Swift
<p>I need to convert current date into milliseconds with 10 digits only for example: 26/09/2019 current date to 1569592800 milliseconds in swift and store it in variable to use it in project<br> I want to use it in this function: </p> <pre><code>func fetchPopularGames(for platform: Platform, completion: @escaping (Result&lt;[Game], Error&gt;) -&gt; Void) { iGDB.apiRequest(endpoint: .GAMES, apicalypseQuery: "fields name, first_release_date, id, popularity, rating, involved_companies.company.name, cover.image_id; where (platforms = (49,130,48,6) &amp; first_release_date &gt; 1569592800); sort first_release_date asc; limit 50;", dataResponse: { bytes in guard let gameResults = try? Proto_GameResult(serializedData: bytes) else { return } let games = gameResults.games.map { Game(game: $0) } DispatchQueue.main.async { completion(.success(games)) } }, errorResponse: { error in DispatchQueue.main.async { completion(.failure(error)) } }) } </code></pre> <p>especially in this part in the query first_release_date > 1569592800 </p>
<ios><swift>
2019-09-26 08:28:25
LQ_CLOSE
58,114,826
ASAuthorizationAppleIDButton not responding to touchUpInside events
<p>I've experienced strange bug in Latest Xcode 11.0 My code:</p> <pre><code>let button = ASAuthorizationAppleIDButton(type: .default, style: .black) button.translatesAutoresizingMaskIntoConstraints = false button.cornerRadius = 10 button.addTarget(self, action: #selector(appleSignInButtonSelected(_:)), for: .touchUpInside) </code></pre> <p>Selector never called, but if I change event to touchDown, everything works. </p>
<ios><swift><apple-sign-in>
2019-09-26 10:30:34
HQ
58,115,820
Is it possibleto write a C program that functions differently according to argv[0]
Is it possible to write a C program that functions differently according to argv[0]? In fact, I am working on an exercise from a C textbook. The exercise is to write a program that converts upper case to lower or lower case to upper, depending on the name it is invoked with, as found in argv[0].
<c><argv>
2019-09-26 11:27:23
LQ_EDIT
58,116,215
How to replace part of text with html text
I want to replace matching keyword in text with same keyword but wrapped with `<span></span>` example : This is the sample text to be searched replaced text should be line This is the <span class="match">sample</span>text to be searched i am using following code but its not working protected String getTitle(object title) { string sTitle = title.ToString(); Regex regex = null; string pattern = @"(\b(?:" + _Keyword.ToString().Trim() + @")\b)(?![^<]*?>)"; regex = new Regex(pattern); sTitle = regex.Replace(sTitle, "<span class='keyword-highlight'>" + _Keyword + "</span>"); return sTitle; } above code replace whole text with keyword not just the matching part
<c#><asp.net>
2019-09-26 11:50:04
LQ_EDIT
58,117,890
How to test components using new react router hooks?
<p>Until now, in unit tests, react router match params were retrieved as props of component. So testing a component considering some specific match, with specific url parameters, was easy : we just had to precise router match's props as we want when rendering the component in test (I'm using enzyme library for this purpose).</p> <p>I really enjoy new hooks for retrieving routing stuff, but I didn't find examples about how to simulate a react router match in unit testing, with new react router hooks ?</p>
<react-router>
2019-09-26 13:26:42
HQ
58,118,286
How to prevent page refresh or default prompt box in chrome
In my Quiz application have 10 questions in a page and all are input controls, i enter required answer ,during the time refresh a page without submitting, the browser gives a below pop up. Solution: I want an customize pop up (instead of chrome pop up) to say u need to finsih all the quiz and submit. or disable the refresh . How to do that, is there any better solution. [![enter image description here][1]][1] [1]: https://i.stack.imgur.com/IM3uD.png
<javascript><jquery><dom-events>
2019-09-26 13:47:30
LQ_EDIT
58,119,075
multiple boolean tests within one method
<p>I have a class with different boolean properties set and the method <code>test()</code> checks all these properties and returns a boolean value. </p> <p><strong>Which is the fastest way?</strong></p> <p><strong>version 1:</strong></p> <pre><code>public boolean test(){ if(!test1) return false; if(!test2) return false; if(!test3) return false; if(!test4) return false; if(!test5) return false; if(!test6) return false; if(!test7) return false; return true; } </code></pre> <p><strong>version 2:</strong></p> <pre><code>public boolean test(){ return test1 &amp;&amp; test2 &amp;&amp; test3 &amp;&amp; test4 &amp;&amp; test5 &amp;&amp; test6 &amp;&amp; test7; } </code></pre> <p><strong>version 3:</strong></p> <pre><code>public boolean test(){ Predicate&lt;Boolean&gt; test1 = c -&gt; getTest1(); Predicate&lt;Boolean&gt; test2 = c -&gt; getTest2(); Predicate&lt;Boolean&gt; test3 = c -&gt; getTest3(); Predicate&lt;Boolean&gt; test4 = c -&gt; getTest4(); Predicate&lt;Boolean&gt; test5 = c -&gt; getTest5(); Predicate&lt;Boolean&gt; test6 = c -&gt; getTest6(); Predicate&lt;Boolean&gt; test7 = c -&gt; getTest7(); return test1.and(test2).and(test3).and(test4).and(test5).and(test6).and(test7).test(true); } </code></pre> <p>I would prefer version 1, because it`s the cleanest way, however, which one is the fastest?</p>
<java>
2019-09-26 14:29:59
LQ_CLOSE
58,119,557
Google map mileage function to return mileage between to addresses
For each loop quit working. public static function getMiles($to, $from) { $from = urlencode($from); $to = urlencode($to); $data = file_get_contents("https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial&origins=$from&destinations=$to&key=AIzaSyAX8D-kve7_xjQSkJP2tF_o2LxNl2McTNc"); $time = 0; $distance = 0; /* return as an object for easier notation */ $json=json_decode( $data, false ); $origins = $json->origin_addresses; $destinations=$json->destination_addresses; /* if there are multiple rows, use a loop and `$rows[$i]` etc */ $elements=$json->rows[0]->elements; foreach( $elements as $i => $obj ){ } //extract the mileage as meters $miles = $obj->distance->value; //converting the meters to miles $distance= round(($miles * '0.000621371192'), 1); //returning miles return $distance; } The end result is to return mileage between 2 addresses. Error message is "'Invalid argument supplied for foreach()'"
<php><google-maps><yii2><google-distancematrix-api>
2019-09-26 14:56:21
LQ_EDIT
58,120,706
Is math.sqrt or **.5 more Pythonic?
<p>Is using math.sqrt() or **.5 more pythonic? For example, is writing math.sqrt(2) or 2**.5 more pythonic?</p> <p>Influences to being pythonic include (1) being more readable, (2) being more common and (3) being faster or more efficient.</p>
<python>
2019-09-26 16:02:16
LQ_CLOSE
58,121,571
I want to give serial no in my Query according to Group , how i can write for this query
AS per my below query it print group by data , but i want to give seq serial no per group like for first group 1 , 2 , 3 and then next group again 1, 2 , 3 like this **select tour_no,version_no,itinerary_detail_no from itinerary_detail group by tour_no,version_no,itinerary_detail_no order by count(*) desc**
<sql><oracle><group-by>
2019-09-26 17:00:48
LQ_EDIT
58,121,822
C# problems with for loop
<p>can someone tell me why this doesn't work. I want to display randomly ten chemical elements, but it always displays the same elements. Thanks for help!</p> <pre><code> var random = new Random(); var list = new List&lt;string&gt; { "Hg" , "B", "H", "Mg" }; int index = random.Next(list.Count); for (int i = 0; i &lt; 10; i++) { Console.WriteLine(list[index]); } </code></pre>
<c#><loops><for-loop>
2019-09-26 17:21:16
LQ_CLOSE
58,123,268
How to replace a substring with another string in a column in pandas
<p>I have a column as below:</p> <pre><code>df['name'] 1 react trainer 2 react trainers 3 react trainer's </code></pre> <p>I need to replace the string trainers/trainer's to trainer:</p> <pre><code>1 react trainer 2 react trainer 3 react trainer </code></pre>
<python><pandas>
2019-09-26 19:07:28
LQ_CLOSE
58,124,413
How to solve the following mathematical operation on a given number?
<p>I have tried to write a code in python which will accept a number of any number of digits like abcde and will give the result as a-b+c-d+e.<strong><em>If the number is 5624 then result will be 5-6+2-4 ie -3</em></strong>.I would like to get the answer where my problem is and how to solve that problem modifying my code.</p> <p><strong>I would like the method I have approached to it. No other method to solve the same problem.</strong> </p> <pre><code>num=(input("enter a number")) l=len(num)-1 p=l num = int(num) q=num for x in range(0,l+1): q=q/10; r=q%10; a[p]=r p-=1 for y in range(0,l): if (y/2==0): sum=sum +a[y] else: sum=sum-a[y] print(sum) </code></pre> <p><strong><em>It is giving me error saying my list assignment index is going out of range.</em></strong></p>
<python><algorithm>
2019-09-26 20:35:23
LQ_CLOSE
58,126,900
Questions about custom switch button in Swift
<p>I want to make a switch button like the picture.</p> <p><a href="https://i.stack.imgur.com/4sYPi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4sYPi.png" alt="enter image description here"></a></p> <p>Is there a library or method in ios that allows this switch button?</p>
<ios><swift>
2019-09-27 02:18:02
LQ_CLOSE
58,126,978
How can i solve this issue ? is it of tflearn or my python versio. (version 3.7.4)
**PROBLEM REGARDING TFLEARN AND PYTHON 3.7.4** i believe that my code is fine but i am facing tflearn OR TENSORFLOW issue in my python 3.7.4 how can i solve it?[1st image is here][1] [2nd image is here][2] [1]: https://i.stack.imgur.com/1APL6.jpg [2]: https://i.stack.imgur.com/G4ISZ.jpg
<python><python-3.x><tensorflow>
2019-09-27 02:30:39
LQ_EDIT
58,127,263
Why is a function literal returning an int not assignable to a function returning interface{}?
<p>I couldn't reason why this code does <a href="https://play.golang.org/p/yOzukoJhJ4N" rel="nofollow noreferrer">not</a> compile:</p> <pre><code>package main import "math/rand" type ooThinAir func() interface{} func Int() ooThinAir { return func() int { return rand.Intn(100) } } func main() { } // fails with: cannot use func literal (type func() int) as type ooThinAir in return argument </code></pre> <p>given, according to the GoLang Spec, <a href="https://golang.org/ref/spec#Interface_types" rel="nofollow noreferrer">that</a> all types implement the empty interface <code>interface{}</code>. Why is the function literal <em>not</em> assignable to type <code>ooThinAir</code>? </p>
<go>
2019-09-27 03:06:54
LQ_CLOSE
58,129,000
How to display the values using the submit button on the html web page
For example when i give an input saying "Good Morning" in the submit button. I should be able to view my input on the Html web page.
<javascript><html>
2019-09-27 06:31:30
LQ_EDIT
58,129,637
How to get a JSON String from JSONObject?
<p>I want to get a JSON String from the created JSONObject, which looks like a String when you want to create a JSONObject from that String.</p> <p>I can write a method, I just cannot believe there isn't have a better solution.</p> <pre><code>import org.json.JSONObject; public class JSONString { JSONObject jsonObject = new JSONObject(); jsonObject.append("symbol", "AAPL"); jsonObject.append("price", "211.17"); // this is the String what I want to get from the jsonObject variable String wantedResultString = "{\n" + " \"symbol\" : \"AAPL\",\n" + " \"price\" : 211.17\n" + "}"; } </code></pre>
<java><json>
2019-09-27 07:16:48
LQ_CLOSE