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
55,686,526
Best practice for reading styles of element JSDOM
<p>To get style attributes from an element using JSDOM, I use the following:</p> <pre><code>window.getComputedStyle(element) </code></pre> <p>It's the only example I've found. Using <code>element.style.someAttribute</code> does not seem to return anything.</p> <p>Is usinging <code>getComputedStyle</code> the best way to find the values of attributes?</p> <p>ty!</p>
<javascript><html><testing><jsdom>
2019-04-15 09:49:12
LQ_CLOSE
55,689,748
How to parse below JSON response in android
{ "status": true, "data": { "1": "Business People", "2": "Actors", "3": "Musicians", "4": "Sports People", "5": "Artists", "6": "Politicians" }, "message": "Get data successfully." }
<android><json><parsing><response>
2019-04-15 12:59:16
LQ_EDIT
55,690,252
find element and click via 'name attribute'
I have the below html mark-up I am trying to access and click via python... for some reason copying the xpath and doing this is **not** working: self.driver.find_element(By.XPATH, '//*`[@id="isc_8D"]/table/tbody/tr/td/table/tbody/tr/td[2]/img')` It seems the 'name' attribute is the only unique identifier below; how could I find element by name attribute and click in python? i.e. **name="isc_NXicon"** <img src="http://website:8080/DBWEBSITE/ui/sc/skins/Enterprise/images/TabSet/close.png" width="12" height="12" align="absmiddle" style="vertical-align:middle" name="isc_NXicon" eventpart="icon" border="0" suppress="TRUE" draggable="true">
<python><selenium-webdriver><xpath><css-selectors><webdriverwait>
2019-04-15 13:27:05
LQ_EDIT
55,690,279
error: expected ';', ',' or ') before numeric constant
<p>I am making a stack class, and trying to make an object of it and using it in another class. However, it mentions that there is an error. here's my code of intializing the stack object in the class:</p> <pre><code>class functions{ public: int m[5]; int c=0; stack_x mem(5); </code></pre>
<c++><class><stack>
2019-04-15 13:28:22
LQ_CLOSE
55,690,287
Can comments be started in the first line before a query in oracle sql
As in i just want to execute a query with a comment: Ex: /*Selects all columns and rows*/ SELECT * FROM "SNAPLOGIC"."CUSTCOMM1" or -- comment select * from "SNAPLOGIC"."CUSTCOMM1" Can we execute in oracle sql? Note: These statement can be executed in tools like dbeaver etc.,
<sql><oracle><snaplogic>
2019-04-15 13:28:55
LQ_EDIT
55,691,069
How to fix '_react["default"].memo is not a function. (In '_react["default"].memo(connectFunction)' error in React native?
<p>I am trying to connect Redux mapStateToProps() and mapActionCreators() to Login Screen through Container and I am using React navigation.</p> <p>After build my app the following error message appears:</p> <blockquote> <p>_react["default"].memo is not a function. (In '_react["defaults"].memo(connectFunction)', '_react["defaults"].memo' is undefined.</p> </blockquote> <p>I searched for a while but what I have gotten is that React.memo() helps us control when our components rerender but I don't use any code related to React.memo().</p> <p>Login Screen: (screens/LoginScreen/index.js)</p> <pre><code>import React from 'react'; import {Dimensions, View} from 'react-native'; //Get width of mobile screen var width = Dimensions.get("window").width; var height = Dimensions.get("window").height; export default class LoginScreen extends React.Component { constructor(props){ super(props); this.state = { } } render() { return ( &lt;View style={styles.container}&gt; &lt;Text&gt;Log In page&lt;/Text&gt; &lt;/View&gt; ); } } LoginScreen.defaultProps = { } const styles = { container: { flex: 1 } } </code></pre> <p>Login screen container: (containers/LoginContainer/index.js)</p> <pre><code>import {connect} from "react-redux"; import LoginScreen from "../../screens/LoginScreen"; const mapStateToProps = (state) =&gt;({ }); const mapActionCreators = { }; export default connect(mapStateToProps, mapActionCreators)(LoginScreen); </code></pre> <p>Top level navigation: (navigations/TopLevelSwitchNav.js)</p> <pre><code>import {createSwitchNavigation, createAppContainer} from 'react-navigation'; import LoginScreen from '../containers/LoginContainer'; import MainTabNav from './MainTabNav'; const TopLevelSwitchNav = createSwitchNavigation({ Login: { screen: LoginScreen, navigationOptions: { header: null } }, MainTab: { screen: MainTabNav, navigationOptions: { header: null } } }, { initialRouteName: Login, navigationOptions: { header: null } }); export default createAppContainer(TopLevelSwitchNav); </code></pre> <p>Dependencies:</p> <pre><code>"dependencies": { "expo": "^32.0.0", "react": "16.5.0", "react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz", "react-navigation": "^3.8.1", "react-redux": "^7.0.2", "redux": "^4.0.1", "redux-logger": "^3.0.6", "redux-persist": "^5.10.0", "redux-persist-transform-filter": "^0.0.18", "redux-thunk": "^2.3.0" }, </code></pre>
<reactjs><react-native><redux><react-redux><expo>
2019-04-15 14:10:09
HQ
55,692,290
R: Reading multiple .dat files as a list and saving as .RDATA files
I want to import multiple `.DAT` files from a directory and make them as a list elements and then save them as `.RDATA` files. I tried the following code files <- dir(pattern = "*.DAT") library(tidyverse) Data1 <- files %>% map(~ read.table(file = ., fill = TRUE)) which works sometimes and fails others. The files are also available on [this link][1]. I want to read all files and them save them as `.RDATA` with the same names. Any help will be highly appreciated. Thanks [1]: https://www2.stat.duke.edu/courses/Spring03/sta113/Data/Hand/Hand.html
<r><purrr><read.table><rdata><dat-protocol>
2019-04-15 15:14:54
LQ_EDIT
55,692,572
How do I create a file in the same directory as the executable when run by root?
<p>I have a program written in C that creates and reads a config file. It assumes that the config file is in the same directory as it is.</p> <p>The program is run by fcron as root. If root runs this program, then the config file is created in root's home directory. It needs to be created in the user's directory where the program is.</p> <p>I don't know enough about user management in linux to solve this, so the only way I can think to solve this is to get the executable's path by modifying argv[0].</p> <p>Is there a better way?</p>
<c><linux>
2019-04-15 15:30:22
LQ_CLOSE
55,692,930
Javascript Growth Population Problem --> Code Returning Wrong Answer
I have the following problem: In a small town the population is p0 = 1000 at the beginning of a year. The population regularly increases by 2 percent per year and moreover 50 new inhabitants per year come to live in the town. How many years does the town need to see its population greater or equal to p = 1200 inhabitants? Below is my code: function nbYear(p0, percent, aug, p) { for (var i=0; p0 < p; i++){ p0 = p0 * (1 + percent/100) + aug; return i } } nbYear(1000, 2, 50, 1200) My solution return 0 which is wrong. The correct answer is 3. I know if I removed the {}, it will give me the right answer. But I want to understand what is wrong with my code ... why is it returning 0?
<javascript><function><for-loop><rate>
2019-04-15 15:50:26
LQ_EDIT
55,693,241
How to securely connect to Cloud SQL from Cloud Run?
<p>How do I connect to the database on Cloud SQL without having to add my credentials file inside the container?</p>
<google-cloud-sql><google-cloud-run>
2019-04-15 16:08:40
HQ
55,695,162
Is asp.net mvc and asp.net mvc core is same or merged
I want to start learning `ASP.NET MVC`just after reading first article I got doubt that Is `asp.net mvc` and `asp.net mvc core` is totally different and using different code functionalities OR these two are same now? I know that `core` is new release of *Microsoft*, so is it running separate or directly merged to `mvc`. I am thinking if core is different than we have four types of different applications to develop like `asp.net`, `asp.net core`, `asp.net mvc`, `asp.net core`. If I am learning `mvc` does it mean I am learning `mvc core` or do `mvc core` have different tutorials, code, projects etc..
<c#><asp.net><asp.net-mvc><asp.net-core>
2019-04-15 18:23:07
LQ_EDIT
55,695,257
Leading 0 is being removed
<p>I have a problem I've never come across before in the 14 months I've been using Laravel.</p> <p>I have a user registration system. A pretty basic requirement for any application right. I have the usual credentials name, username, email, password, and a phone number.</p> <p>If I submit the number in the following format 086123456. The leading 0 is being removed from what is saved in the DB. The phone_number field is a integer.</p> <p>Any idea what is going on here.</p> <p>User Model</p> <pre><code>&lt;?php namespace App; use Illuminate\Notifications\Notifiable; use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Foundation\Auth\User as Authenticatable; use App\Property; use Tymon\JWTAuth\Contracts\JWTSubject; class User extends Authenticatable implements JWTSubject { use Notifiable; protected $fillable = [ 'first_name', 'last_name', 'username', 'email', 'phone_number', 'password', ]; protected $hidden = [ 'password', 'remember_token', ]; protected $casts = [ 'email_verified_at' =&gt; 'datetime', ]; public function properties() { return $this-&gt;hasMany(Property::class); } public function getJWTIdentifier() { return $this-&gt;getKey(); } public function getJWTCustomClaims() { return []; } } </code></pre> <p>Register Function</p> <pre><code> public function register() { $user = User::create(['first_name' =&gt; request('first_name'), 'last_name' =&gt; request('last_name'), 'username' =&gt; request('username'), 'email' =&gt; request('email'), 'phone_number' =&gt; request('phone_number'), 'password' =&gt; bcrypt(request('password'))]); return response()-&gt;json($user); } </code></pre>
<php><laravel><laravel-5><php-7>
2019-04-15 18:28:36
LQ_CLOSE
55,695,474
Javascript HTML Redirect
<p>Code Purpose Question</p> <p>I am trying to determine the purpose of the line: window.location = "<a href="https://google.com" rel="nofollow noreferrer">https://google.com</a>";</p> <pre><code>&lt;&lt;!-- For IE &lt;= 9 --&gt; &lt;!--[if IE]&gt; &lt;script type="text/javascript"&gt; window.location = "https://google.com"; &lt;/script&gt; &lt;![endif]--&gt; &lt;!-- For IE &gt; 9 --&gt; &lt;script type="text/javascript"&gt; if (window.navigator.msPointerEnabled) { window.location = "http://bobabend.com/index-old-as-of-3-7-2019.html"; } </code></pre>
<javascript><html>
2019-04-15 18:43:47
LQ_CLOSE
55,695,954
Delete record from database - C#
I'm trying to delete record from data base MSSQL by entering the ID and hit delete btn. i didn't get any error and it give recorded deleted successful but once i check database i see the record doesn't deleted protected void btnDelete_Click(object sender, EventArgs e) { try { if (txtImgID.Text == "") { Response.Write("Enter Image Id To Delete"); } else { SqlCommand cmd = new SqlCommand(); SqlConnection con = new SqlConnection(); //con = new SqlConnection(ConfigurationManager.ConnectionStrings ("GMSConnectionString").ConnectionString); con = new SqlConnection(ConfigurationManager.ConnectionStrings["GMSConnectionString"].ConnectionString); con.Open(); cmd = new SqlCommand("delete from certf where id=" + txtImgID.Text + "", con); lblsubmitt.Text = "Data Deleted Sucessfully"; } } catch (Exception) { lblsubmitt.Text = "You haven't Submited any data"; } } }
<c#><sql><asp.net><database>
2019-04-15 19:19:50
LQ_EDIT
55,696,240
Update multiple rows in sql server 9.0.5000
I'mk currently creating a script automatically with a program that copies files from one place to another, and I used to do the following: UPDATE d SET Path= t.Path FROM dbo.tableOperation d JOIN ( VALUES (1,'Path 1'), (2,'Path 2') ) t (IdRegister, Path) ON t.IdRegister = d.IdRegister And on the version of SQL server (10.50.1600) it was working fine, but I found some issues when trying to execute the script on the server I have to update the data (9.0.50000). I have to update tenths of thousands rows at a time, how can I do it?
<sql><sql-server-2005>
2019-04-15 19:43:21
LQ_EDIT
55,698,113
AWS Security Groups -- Name vs. Group Name
<p>In AWS Security Groups, what is the difference between "Name" and "Group Name"? It's confusing because when one creates a "Security Group", "Name" would seem to be interpreted as "name of the security group"...but then there is "Group Name". Seems redundant to the point of confusion. "Group Name" seems to be the more substantive and important field.</p> <p>The "Name" field can be changed by clicking the pencil icon as shown in the screenshot below:</p> <p><a href="https://i.stack.imgur.com/BTP4U.png" rel="noreferrer"><img src="https://i.stack.imgur.com/BTP4U.png" alt="enter image description here"></a></p> <p>But the "Group Name" cannot be edited and can be specified only at the time of creation:</p> <p><a href="https://i.stack.imgur.com/shovG.png" rel="noreferrer"><img src="https://i.stack.imgur.com/shovG.png" alt="enter image description here"></a></p> <p>I've been simply setting Name to be the same as Group Name for consistency and simplicity. I can't find any guidance on best practices for the "Name" field and how or if it should be named relative to the "Group Name" field (the pop-up help on AWS simply describes required naming syntax). Is "Name" just a convenience field which has little to zero significance (since it can be easily changed at any point)? What are the programmatic and functional effects of these names?</p>
<amazon-web-services><amazon-ec2>
2019-04-15 22:33:49
HQ
55,698,151
Is bool booly; the same as bool booly = false; when declared?
<p>Is there any difference functionally between this:</p> <pre><code>bool boolean; </code></pre> <p>and:</p> <pre><code>bool boolean = false; </code></pre> <p>?</p>
<c#>
2019-04-15 22:37:56
LQ_CLOSE
55,699,623
Elasticsearch 7 : Root mapping definition has unsupported parameters (mapper_parsing_exception)
<p>When trying to insert the following mapping in Elasticsearch 7</p> <pre><code>PUT my_index/items/_mapping { "settings":{ }, "mappings":{ "items":{ "properties":{ "products":{ "properties":{ "classification":{ "type":"text", "fields":{ "raw":{ "type":"keyword", "ignore_above":256 } } }, "original_text":{ "type":"text", "store":false, "fields":{ "raw":{ "type":"keyword", "ignore_above":256 } } } } }, "title":{ "type":"text", "fields":{ "raw":{ "type":"keyword", "ignore_above":256 } }, "analyzer":"autocomplete" }, "image":{ "properties":{ "type":{ "type":"text", "fields":{ "raw":{ "type":"keyword", "ignore_above":256 } } }, "location":{ "type":"text", "store":false, "fields":{ "raw":{ "type":"keyword", "ignore_above":256 } } } } } } } } } </code></pre> <p>I get an error of the form:</p> <pre><code>{ "error": { "root_cause": [ { "type": "mapper_parsing_exception", "reason": "Root mapping definition has unsupported parameters: </code></pre> <p>What is causing this error?</p>
<elasticsearch>
2019-04-16 02:14:59
HQ
55,700,018
oh my god! I can not find R.java in the latest Android Studio?
I am using the latest Android Studio , BUT i can not find the location of R.java file,i already googled this problem,never could help me.where is R.java? I really can not find it
<android-studio>
2019-04-16 03:12:11
LQ_EDIT
55,700,638
i am trying to convert this javascript code to php code but not working
i want to convert this javascript code to php code function testPattern(iString) { var iPattern = /[0-9]{2}[a-zA-Z]{5}[0-9]{4}[a-zA-Z]{1}[1-9A-Za-z]{1}[Zz1-9A-Ja-j]{1}[0-9a-zA-Z]{1}/; var patt = new RegExp(iPattern), isPatternValid = patt.test(iString); return isPatternValid; } i tried this php code but not working function testPattern($iString) { $iPattern ="/[0-9]{2}[a-zA-Z]{5}[0-9]{4}[a-zA-Z]{1}[1-9A-Za-z]{1}[Zz1-9A-Ja-j]{1}[0-9a-zA-Z]{1}/"; $isPatternValid = preg_match($ipattern, $istring); return $isPatternValid; }
<javascript><php><regex>
2019-04-16 04:37:16
LQ_EDIT
55,700,722
How to create a slant button looks like this in xcode?
i want the result to be exact as the given image how can i create a slant button like the image given below https://i.stack.imgur.com/0GRjd.jpg i don't want to use image as backgroud.
<swift><xcode>
2019-04-16 04:46:03
LQ_EDIT
55,702,343
Timer counter in finite loop in php
<p>I want a timer counter in php example 1567 which will increment every second and it goes till infinite even if some body refresh the page it counter will not starts from 1567 .but it should starts for where its is end.</p>
<php>
2019-04-16 07:00:45
LQ_CLOSE
55,702,389
What will be the output of String.substring(String.length)
public class Str { public static void main(String[] args) { String str = "abced"; String s = str.substring(str.length()); System.out.println(s); } } index of character 'e' is 4 but i am trying to get whole String from length 5 ,if i execute the above code, why it is not throwing the indexOutOfBounds exception.
<java><string>
2019-04-16 07:03:50
LQ_EDIT
55,703,343
What is the best way to count in a for loop?
<p>I find myself in the need of counting through lists with the help of for loops. What I end up doing is this:</p> <pre><code>L = ['A','B','C','D'] n = 0 for i in L: print(L[n]) n += 1 </code></pre> <p>I was wondering if there is a better way for doing this, without having to declare an extra variable <code>n</code> every time?</p> <p>Please keep in mind that this is just a simplified example. A solution like this would not suffice (although in this example the results are the same):</p> <pre><code>L = ['A','B','C','D'] for i in L: print(i) </code></pre>
<python>
2019-04-16 08:03:46
LQ_CLOSE
55,704,707
How to create jquery accordion out of this code
i am having problem to enable accordion on this code structure. I have tried the following code but it is not working. <li><?php echo get_field('faq_question_1');?> <span class="readLinkTag"><a class="click_acc" href="#">READ MORE <i class="fa fa-chevron-circle-down"></i></a></span></li> <div class="abc"><?php echo get_field('faq_question_1_content');?></div> var allPanels = $('.abc').hide(); $('.click_acc').click(function() { //alert("thanks"); allPanels.slideUp(); $(this).parent().next().slideDown(); return false; });
<javascript><jquery><html><css>
2019-04-16 09:20:10
LQ_EDIT
55,707,415
I'm Creat android layout but after running on my real device i'm getting unique view of same layout please help me as soon as possible
I have an main activity in which I have creating layout in XML in android studio and setting width and height properly as per my need but after executing my code on my device I'm getting a different view of the same layout. and also i want to do scroll up my layout when my keyboard is active but after adding **android:windowSoftInputMode="adjustResize"** not help me please if any one have some perfect solution please let me know I have search a lot but not getting any kind of help on community <RelativeLayout android:id="@+id/lay_zcrt_img" android:layout_width="match_parent" android:layout_height="fill_parent" android:background="@drawable/splash1"> <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_marginTop="45dp" android:background="@drawable/login_layout_border"> <ImageView android:layout_width="250dp" android:layout_height="120dp" android:layout_margin="4dp" android:src="@drawable/login_logo" /> </RelativeLayout> <android.support.v7.widget.CardView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_marginLeft="35dp" android:layout_marginTop="230dp" android:layout_marginRight="35dp" android:background="@drawable/lay_login_border" app:cardCornerRadius="14dp"> <RelativeLayout android:layout_width="350dp" android:layout_height="300dp" android:layout_gravity="center"> <TextView android:id="@+id/txt_title" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_marginTop="15dp" android:gravity="center" android:text="Login" android:textColor="#000" android:textSize="25dp" /> <EditText android:id="@+id/edt_phone_number" android:layout_width="300dp" android:layout_height="65dp" android:layout_marginTop="55dp" android:layout_below="@+id/txt_title" android:layout_centerHorizontal="true" android:gravity="center_horizontal|center_vertical" android:hint="Mobile" android:inputType="number" android:maxLength="10" /> <Button android:id="@+id/btn_login" android:layout_width="300dp" android:layout_height="55dp" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:layout_marginLeft="25dp" android:layout_marginRight="25dp" android:layout_marginBottom="8dp" android:background="@drawable/btn_corner" android:gravity="center_horizontal|center_vertical" android:text="Submit" android:textAlignment="center" android:textColor="#fff" /> </RelativeLayout> </android.support.v7.widget.CardView> </RelativeLayout> here you can see from images I search a lot on a community but not getting any single article related to this please if anyone is here to solve then help [This is my android studio layout][1] [This is my real device view][2] [1]: https://i.stack.imgur.com/40etr.jpg [2]: https://i.stack.imgur.com/nntFO.jpg
<java><android><android-layout>
2019-04-16 11:45:54
LQ_EDIT
55,709,373
Why's my code wrong when looking for duplicates?
<p>I'm trying to solve this Leetcode problem <a href="https://leetcode.com/problems/contains-duplicate-ii/" rel="nofollow noreferrer">https://leetcode.com/problems/contains-duplicate-ii/</a></p> <p>I'm not sure why my code's incorrect. I've followed the problem and tried to write it out as best as I could but it didn't work.</p> <p>Can someone point out what I did wrong?</p> <pre><code>class Solution { public boolean containsNearbyDuplicate(int[] nums, int k) { boolean flag = false; int ans = 0; for(int i = 0; i &lt; nums.length; i++) { for(int j = i + 1; j &lt; nums.length; j++) { if(nums[i] == nums[j]) { flag = true; } if(flag) { ans = Math.abs(nums[i] - nums[j]); } if(ans &lt;= k) { return true; } } } return false; } } </code></pre>
<java><algorithm><debugging>
2019-04-16 13:28:46
LQ_CLOSE
55,709,568
Does Spring @Autowired create new instance of parameters for each bean?
<blockquote> <p><strong>Does Spring create new instances of constructor parameters of the same type for different beans?</strong></p> </blockquote> <p>For example, I have two REST controllers:</p> <p><strong>First:</strong></p> <pre class="lang-java prettyprint-override"><code>@RestController @RequestMapping ("/getHwidData") public class GetHwidDataController { private final ApiKeysDatabase apiKeysDb; private final BanwareDatabase banwareDb; @Autowired public GetHwidDataController(ApiKeysDatabase apiKeysDb, BanwareDatabase banwareDb) { this.apiKeysDb = apiKeysDb; this.banwareDb = banwareDb; } } </code></pre> <p><strong>Second:</strong></p> <pre class="lang-java prettyprint-override"><code>@RestController @RequestMapping ("/setHwidData") public class SetHwidDataController { private final ApiKeysDatabase apiKeysDb; private final BanwareDatabase banwareDb; @Autowired public SetHwidDataController(ApiKeysDatabase apiKeysDb, BanwareDatabase banwareDb) { this.apiKeysDb = apiKeysDb; this.banwareDb = banwareDb; } } </code></pre> <p>As you may see, both controllers' constructors are <code>@Autowired</code>, and both accept the same object types: an <code>ApiKeysDatabase</code> and a <code>BanwareDatabase</code>.</p> <p>I have some caching and other instance-dependent stuff inside those <code>*Database</code> classes, so I'd like to know: when the two above-stated REST controllers are created, <strong>will their <code>apiKeysDb</code> and <code>banwareDb</code> fields be respectively equal</strong> (hold the same instance of the <code>ApiKeysDatabase</code> and <code>BanwareDatabase</code> objects respectively)? That is,</p> <pre class="lang-java prettyprint-override"><code>GetHwidDataController ctrlOne = ... SetHwidDataController ctrlTwo = ... assertTrue ctrlOne.apiKeysDb == ctrlTwo.apiKeysDb &amp;&amp; ctrlOne.banwareDb == ctrlTwo.banwareDb </code></pre>
<java><spring><spring-boot><autowired>
2019-04-16 13:38:36
LQ_CLOSE
55,709,925
How can i use Chart.js to build Piecharts for Bonita Soft
Please How can i use `Chart.js` to make charts (Pie charts, Bar charts etc) and use in Bonita BPM solution
<angularjs><charts><bonita>
2019-04-16 13:55:22
LQ_EDIT
55,709,975
How to return a vector from a class into another class
<p>I'm trying to use arrays with java and when i return the array froma class it prints [I@7d4991ad (that should be the address), but how to return all the elements?</p> <p>(by the way, I always mess with JavaScript and Java and I don't know which one eclipse is, I apologize)</p> <p>Basically I did a return of the name of the vector with the metod int[]</p> <pre><code>public class TestVettori { private int vector[]; private int length; //function input lengt public void setLength(int newLung) { if(newLung&gt;=1) length=newLung; } //function input public void inputValue(int[] vett) { vector = new int [length]; for(int i=0;i&lt;length;i++) vector[i]=vett[i]; } //function print array **public int[] getVector() { return vector; }** } </code></pre> <pre><code>import java.util.Scanner; public class ProgTestVettori { public static void main(String[] args) { Scanner in= new Scanner (System.in); int lung ; int vett[]; TestVettori vector; System.out.println("Put the length of the array"); lung = in.nextInt(); vett = new int [lung]; vector = new TestVettori(); vector.setLength(lung); for(int i=0;i&lt;lung;i++) { System.out.println("Input the"+(i+1)+" number"); vett[i]=in.nextInt(); } vector.inputValue(vett); **for(int i=0;i&lt;lung;i++) { System.out.println("the "+(i+1)+"° number is"+vector.getVector()); }** in.close(); } } </code></pre> <p>I pasted all the code so you can see all of it: I put the length, let's suppose 3 i put numbers and i should expect numbers from the console, but i get 3 times [I@7d4991ad the address...</p>
<java><arrays><class>
2019-04-16 13:57:48
LQ_CLOSE
55,710,322
How do i use while loop with variables
I want to loop between the choices that user has given as input and the choices are stored as variables, A = "A" S = "S" D = "D" F = "F" action_input = input("\n ") action_input1 = action_input.title() while (action_input1 not in [A, S, D, F]) : if action_input1 == A : print("\n Required Result is : " + str(Ac)) elif action_input1 == S : print("\n Required Result is : " + str(Sc)) elif action_input1 == D : print("\n Required Result is : " + str(Dc)) elif action_input1 == F : print("\n Required Result is : " + str(Fc)) else : print("\n Please enter from the choices given above")
<python><python-3.x>
2019-04-16 14:15:01
LQ_EDIT
55,711,565
How combine multiples images from a sequence of them, using any language code?
I'm setting up a wiki, for a game, and i need to put gifs for make the site more easy to understand. But i hava a problema, to make the gifs, i need to merge some images, and with i go one by one i never and this work. So what code i need, our program for make this work more fast? I'm tried some codes with pithon, and i don't have sucess. The only way i can make work was using a Paint our photoshop for combine this images. I tried this code: import numpy as np from PIL import Image images_list = [] for i in range(1,4): #insert last number of photo images_list.append(str(i)+'.PNG') count = 1; directory = "C:/Users/Windows/Desktop/BloodStoneSprites/sprites1" #change to directory where your photos are ext = ".PNG" new_file_name = "vimage-" new_directory = "C:/Users/Windows/Desktop/BloodStoneSprites/Uniao" # change to path of new directory where you want your photos to be saved for j in range(0,len(images_list),2): name = new_file_name + str(j) + ext two_images_list = [images_list[j],images_list[j+1]] imgs = [ Image.open(i) for i in two_images_list ] min_img_shape = sorted( [(np.sum(i.size), i.size ) for i in imgs])[0][1] imgs_comb = np.hstack( (np.asarray( i.resize(min_img_shape) ) for i in imgs ) ) imgs_comb = Image.fromarray( imgs_comb) imgs_comb.save(new_directory+'/'+name ) count +=1 And here is some of images i need to combine: https://imgur.com/a/BBNGjuf
<python><c++><png><gif><animated-gif>
2019-04-16 15:19:29
LQ_EDIT
55,712,074
Convert string like "10/2" to integer value in swift
<p>How can I convert a string value like "100/2" or "-200/2" or "" to integer value.</p> <p>I have tried converting with Int("100/2")</p>
<swift>
2019-04-16 15:47:44
LQ_CLOSE
55,713,312
I have created a button but cant find which command to use
i have already created a button using this code; btnLuxury=Button(f1,padx=16,pady=8,bd=16, fg="black",font=('arial', 16,'bold'),width=10, text="Luxury", bg="powder blue", command = Luxury).grid(row=8,column=3) but when i click on it, it does nothing. now i want it to display the amount 8000 in the text box of total amount. what do i type after def, now
<python><button><tkinter><command>
2019-04-16 17:06:40
LQ_EDIT
55,713,975
What is the difference between arr and *arr?
<p>What is the difference between these 2 prints, I got the same address in both of them : </p> <pre><code>int main(void) { int arr[2][3] = {{1,2,3},{4,5,6}}; printf("%p\n", arr); printf("%p\n", *(arr)); } </code></pre>
<c><arrays><pointers>
2019-04-16 17:50:57
LQ_CLOSE
55,714,472
Top margin pulls top element
<p>Container is pulled down when inner element puts top margin so white section appear at the top of page. How can i prevent that white section ? </p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>.container { background: red; height: 500px; } .inner { margin-top: 100px; height: 50px; background: yellow; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>Why there is white section in here ?? &lt;div class="container"&gt; &lt;div class="inner"&gt;&lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
<html><css>
2019-04-16 18:26:51
LQ_CLOSE
55,715,075
What does this smiley mean?
My friend texted me `_=_=>_(_);_(_)` and told me that if I can figure out what it meant then I am a very smart person. He told me that it's written in a language called javascript and that if I need any help then I can ask a question on this website. I have no idea what this means. What does this smiley mean?
<javascript>
2019-04-16 19:07:37
LQ_EDIT
55,715,763
TypeScript version mismatch in Visual Studio 2019
<p>I am thoroughly confused by Typescript versioning as it relates to Visual Studio 2019. I have a .NET Core 2.2.x project which utilizes Typescript. When I edit any .ts file, I get the following warning (in the error list):</p> <blockquote> <p>Your project is built using TypeScript 3.4, but the TypeScript language service version currently in use by Visual Studio is 3.4.3. Your project may be using TypeScript language features that will result in errors when compiling with this version of the TypeScript compiler. To remove this warning, install the TypeScript 3.4.3 SDK or update the TypeScript version in your project's properties.</p> </blockquote> <p>It claims that my project is built using TypeScript 3.4, but package.json specifically lists <code>"typescript": "3.4.3"</code>. </p> <p><a href="https://i.stack.imgur.com/7WQoj.png" rel="noreferrer"><img src="https://i.stack.imgur.com/7WQoj.png" alt="enter image description here"></a></p> <p>Then it asks to install TypeScript SDK 3.4.3, which I have from <a href="https://marketplace.visualstudio.com/items?itemName=TypeScriptTeam.typescript-343-vs2017" rel="noreferrer">here</a>. I also <code>npm install -g typescript</code> previously, so running <code>tsc -v</code> yields <code>Version 3.4.3</code>.</p> <p>What am I missing?</p>
<visual-studio><typescript><visual-studio-2019>
2019-04-16 19:58:47
HQ
55,715,837
how to sum all column values in multi-dimensional array have same value of keys?
<p>i have array multi-dimensional like this and i want sum all column "quota" values have same id and same ip and same visited ip</p> <pre><code>$array = array( "0" =&gt; array( "id" =&gt; 1, "ip" =&gt; 10.40.47.5, "visited_ip" =&gt; 10.40.40.10, "quota" =&gt; 20, ), "1" =&gt; array( "id" =&gt; 2, "ip" =&gt; 10.40.47.20, "visited_ip" =&gt; 10.40.40.10, "quota" =&gt; 10, ), "2" =&gt; array( "id" =&gt; 1, "ip" =&gt; 10.40.47.5, "visited_ip" =&gt; 10.40.40.10, "quota" =&gt; 30, ) ); </code></pre> <p>and i want result like this </p> <pre><code>$array = array( "0" =&gt; array( "id" =&gt; 1, "ip" =&gt; 10.40.47.5, "visited_ip" =&gt; 10.40.40.10, "quota" =&gt; 50, ), "1" =&gt; array( "id" =&gt; 2, "ip" =&gt; 10.40.47.20, "visited_ip" =&gt; 10.40.40.10, "quota" =&gt; 10, ), ); </code></pre> <p>i need your help </p>
<php><arrays>
2019-04-16 20:03:57
LQ_CLOSE
55,716,322
Flutter: SizedBox Vs Container, why use one instead of the other?
<p>When I start to think about those two componentes I find myself arguing about why should I one instead of the other. Some questions that come to my mind: </p> <ol> <li><p>What are the differences between a Container and SizedBox?</p></li> <li><p>I understand that Container can have other parameters like padding or decoration, but if I will not use those, why should I use a SizedBox instead of a Container?</p></li> <li><p>There are performance differences between them?</p></li> </ol>
<flutter>
2019-04-16 20:42:28
HQ
55,716,956
How to deploy simultaneously several critical bugs with gitflow process as soon as possible?
So we use the gitflow process for a safe and sound CID (https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow) But something's wrong.. Lets say we have 10 critical bugs on prod - they must be fixed asap. So 10 bugs are assigned to 10 devs. Dev 1 creates a hotfix 0.0.1, commits the fix to it, fix gets uploaded to staging env and handovered to QA for verifing. In that time dev 2 wants to create hotfix 0.0.2 for his bug, but he cant as gitflow forbids creating new hotfix if one exists already. So he either have to wait for closing hotfix/0.0.1 or commit to the same hotfix. Of course the normal choice is to commit to that hotfix/0.0.1, because his bug is critical and cant wait fix for bug 1 So does every other 10 devs with their 10 critical bugs. QA verifies bug 1 and confirm for deployment. But hotfix can't be closed and deployed, because the other 9 bugs are not tested or just not working So to be closed, every bug in that hotfix must be working and confirmed. In our case this takes time, a lot of time - 1,2 weeks, luckily - as more and more things needs to be fixed asap on production. So devs commit to that branch more and more, getting the first bugs to be put on hold even more. So eventually, after all those bugs are fixed and confirmed it is time to finally close the hotfix and deploy those critical bugs on prod...with quite of a big time delay. But there is also another big problem - THE MERGE with dev branch, where other devs do their work (like minor bugfixings for next release). A horrible, several-hours lasting merge. So we obviosly do something wrong...what could be a solution for this? For our hotfixes to be on time and to not have terrible merges to dev One solution we were thinking, is to put a limit in the hotfix for the number of bugs which it should contain - for example 5 bugs max, other bugs must wait until those are fixed This, though, means that only lead-dev should commit to hotfix, as he must ensure the limit (it is hard to control otherwise) But this way bugs are still put on hold and fast-deployment is not achieved What would be the normal procedure? Please share your ideas.
<continuous-deployment><git-flow>
2019-04-16 21:38:20
LQ_EDIT
55,717,386
Why does List<T>.Add throw an index out of range exception?
<p>When I call <code>List&lt;T&gt;.Add(T)</code> it throws this exception:</p> <pre><code>System.IndexOutOfRangeException: Index was outside the bounds of the array. at System.Collections.Generic.List`1.Add(T item) at ConsoleApp5.Program.AddToList(Int32 seed) </code></pre> <p>I've also see this exception thrown by <code>Enumerable.Any</code> against the same list.</p>
<c#><.net>
2019-04-16 22:21:58
LQ_CLOSE
55,717,923
Google maps won't work on my website despite good API key
<p>I had a website with google map, but few weeks ago google maps on my website stop working. I created google maps api key and entered it in my Joomla btgoogle maps module, but maps still won't work. What can be the problem?</p> <p>URL Link: <a href="http://studiomob.rs/index.php/en/contact" rel="nofollow noreferrer">http://studiomob.rs/index.php/en/contact</a></p>
<google-maps><joomla><api-key>
2019-04-16 23:34:57
LQ_CLOSE
55,718,164
How to loop until all lines read from a file
I'm trying to set up a score system where I need to input all the scores from a text file into an 'array of records'. I'm fairly new to Python and hope for a simple solution. In my program, the array of records would technically class as a list of namedtuples. Currently I have: Player = namedtuple("Player", ["name", "result", "difficulty", "score"]) Playerlist = [] while str(f.readline) != '': player = Player( f.readline(), f.readline(), f.readline(), f.readline()) Playerlist.append(player) I tried to print(Playerlist[0]), but nothing shows up. I have also tried to print(Playerlist[0]) without any loop and got the expected result, though I won't have stored all the data from the text file into my program.
<python><list><loops><file-handling><namedtuple>
2019-04-17 00:09:46
LQ_EDIT
55,718,716
Looping through downloaded files to print specific file and overall folder name
All i am trying to do is have a simple for-loop go through my documents and provide me with a dataframe that consists of a column of folder names, and then another column of the files within that folder. For example, lets say i have a folder called "Muffins" which has a lot of different recipes for muffins (e.g., banana, blueberry, etc.) which would be the file names. I want the for-loop to to shoot out a dataframe that has Column 1 = muffins and Column 2 = to the individual recipe name. Food Recipe Muffins Banana Muffins Blueberry Muffins Chocolate etc. etc. I know this is really simple, but i have been at this for 3 hours now and have been out of the R game for awhile. Please help!
<r><for-loop>
2019-04-17 01:38:27
LQ_EDIT
55,723,772
How to run react-native run-ios with specific target
<p>Is there a way to run a specific target with command</p> <pre><code>react-native run-ios </code></pre> <p>for Android I'm using following</p> <pre><code>react-native run-android --variant=targetRelease </code></pre>
<react-native><react-native-cli>
2019-04-17 09:02:28
HQ
55,723,978
In a C# console app, how would I create 'images' for playing cards in a blackjack game?
<p>I'm working on a simple C# blackjack console application game for my school and I was given an example to look at. This example somehow draws a picture of the card in the console window and I can't figure out how to replicate this without specifying hundreds of Console.Write's for each of the 52 unique cards. </p> <p><a href="https://i.stack.imgur.com/88P7U.png" rel="nofollow noreferrer">in game scene</a> This is what it looks like when you're actually playing the game. Quite nice.</p> <p><a href="https://i.stack.imgur.com/C3TBN.png" rel="nofollow noreferrer">shuffle and show deck</a> There is also an option from the main menu to shuffle and display all 52 cards.</p> <p>So what is this wizardry? Did they actually spend a TON of time hard-coding how every single unique card prints out? I sure hope not. This is what I'm trying to replicate and I'm at a loss for ideas besides hard-coding. Thanks for your help.</p>
<c#><image><console-application><blackjack>
2019-04-17 09:13:19
LQ_CLOSE
55,724,395
How to make Internet browser?
<p>I made a simple browser app using Webview, but Existing android Browser apps like Chrome, Microsoft Edge, Firefox.</p> <p>How are these apps made? Simply same using Webview??</p>
<android><browser>
2019-04-17 09:33:10
LQ_CLOSE
55,724,642
React useEffect Hook when only one of the effect's deps changes, but not the others
<p>I have a functional component using Hooks:</p> <pre><code>function Component(props) { const [ items, setItems ] = useState([]); // In a callback Hook to prevent unnecessary re-renders const handleFetchItems = useCallback(() =&gt; { fetchItemsFromApi().then(setItems); }, []); // Fetch items on mount useEffect(() =&gt; { handleFetchItems(); }, []); // I want this effect to run only when 'props.itemId' changes, // not when 'items' changes useEffect(() =&gt; { if (items) { const item = items.find(item =&gt; item.id === props.itemId); console.log("Item changed to " item.name); } }, [ items, props.itemId ]) // Clicking the button should NOT log anything to console return ( &lt;Button onClick={handleFetchItems}&gt;Fetch items&lt;/Button&gt; ); } </code></pre> <p>The component fetches some <code>items</code> on mount and saves them to state.</p> <p>The component receives an <code>itemId</code> prop (from React Router).</p> <p>Whenever the <code>props.itemId</code> changes, I want this to trigger an effect, in this case logging it to console.</p> <hr> <p>The problem is that, since the effect is also dependent on <code>items</code>, the effect will also run whenever <code>items</code> changes, for instance when the <code>items</code> are re-fetched by pressing the button.</p> <p>This can be fixed by storing the previous <code>props.itemId</code> in a separate state variable and comparing the two, but this seems like a hack and adds boilerplate. Using Component classes this is solved by comparing current and previous props in <code>componentDidUpdate</code>, but this is not possible using functional components, which is a requirement for using Hooks.</p> <hr> <p><strong>What is the best way to trigger an effect dependent on multiple parameters, only when one of the parameters change?</strong></p> <hr> <p><em>PS. Hooks are kind of a new thing, and I think we all are trying our best to figure out how to properly work with them, so if my way of thinking about this seems wrong or awkward to you, please point it out.</em></p>
<javascript><reactjs><react-hooks>
2019-04-17 09:44:55
HQ
55,725,390
java.lang.StackOverflowError: stack size 8MB: Aftertextchanged
<p>I have multiple edit texts in activity and using textwatcher to take/observe user input. Using methods for each editexts for writing functionality. sometimes i had to use same method for multiple edittexts where it is causing the java.lang.StackOverflowError: stack size 8MB error.Kindly someone help me or anyone suggest me how to use same method for multiple edittext watchers. it will be helpful. </p>
<android><android-textwatcher>
2019-04-17 10:23:17
LQ_CLOSE
55,725,419
Is there a way to return true if the user allows location sharing and false if denied?
<p>I need a javascript function that returns true if the user is sharing the location in the site and return false if not.</p>
<javascript>
2019-04-17 10:24:36
LQ_CLOSE
55,726,149
Data separation from single column
I have data in single column like different sets: Original data Class: Country1 Object: State1 Description: DEsc1 Object: State2 Description: DEsc2 Object: State3 Description: DEsc3 Object: State4 Description: DEsc4 Class: Country2 Object: State1 Description: DEsc1 Object: State2 Description: DEsc2 Object: State3 Description: DEsc3 Object: State4 Description: DEsc4 Class: Country3 Object: State1 Description: DEsc1 Object: State2 Description: DEsc2 Object: State3 Description: DEsc3 Object: State4 Description: DEsc4 Class: Country4 Object: State1 Description: DEsc1 Object: State2 Description: DEsc2 Object: State3 Description: DEsc3 Object: State4 Description: DEsc4 I am looking for Excel VBA macro code , which will clean and organize my data. Expected Data Class Object Description Country1 Object1 DEsc1 Country1 Object2 DEsc2 Country1 Object3 DEsc3 Country1 Object4 DEsc4 Country2 Object1 DEsc1 Country2 Object2 DEsc2 Country2 Object3 DEsc3 Country2 Object4 DEsc4 Country3 Object1 DEsc1 Country3 Object2 DEsc2 Country3 Object3 DEsc3 Country3 Object4 DEsc4 Country4 Object1 DEsc1 Country4 Object2 DEsc2 Country4 Object3 DEsc3 Country4 Object4 DEsc4
<excel><vba>
2019-04-17 11:07:40
LQ_EDIT
55,726,196
Program to calculate the number of zeros in an array
<p>myArray = [1,0,2,4,5,10,4,0,3,0] How to calculate the number of zeros in the the above array?</p>
<python>
2019-04-17 11:10:13
LQ_CLOSE
55,726,886
React Hook : Send data from child to parent component
<p>I'm looking for the easiest solution to pass data from a child component to his parent.</p> <p>I've heard about using Context, pass trough properties or update props, but I don't know which one is the best solution.</p> <p>I'm building an admin interface, with a PageComponent that contains a ChildComponent with a table where I can select multiple line. I want to send to my parent PageComponent the number of line I've selected in my ChildComponent.</p> <p>Something like that :</p> <p>PageComponent :</p> <pre><code>&lt;div className="App"&gt; &lt;EnhancedTable /&gt; &lt;h2&gt;count 0&lt;/h2&gt; (count should be updated from child) &lt;/div&gt; </code></pre> <p>ChildComponent : </p> <pre><code> const EnhancedTable = () =&gt; { const [count, setCount] = useState(0); return ( &lt;button onClick={() =&gt; setCount(count + 1)}&gt; Click me {count} &lt;/button&gt; ) }; </code></pre> <p>I'm sure it's a pretty simple thing to do, I don't want to use redux for that.</p>
<reactjs><react-hooks>
2019-04-17 11:47:43
HQ
55,730,343
Android Studio test between two emulators
<p>Okay so, I have two emulators running. I want to write a test where one device calls the other device using VOIP. My goal is to automate VOIP testing.</p> <p>A <code>successCount</code> variable is defined inside the test class to validate whether the test was successful or not.</p> <p>Steps I need to take in my test class:</p> <ol> <li>Login into the SIP server with device A.</li> <li>Login into the SIP server with device B.</li> <li>Device A calls device B (increase success count by 1).</li> <li>Device B answers the call (increase success count by 1).</li> <li>Device B hangsup after 5 seconds (increase success count by 1).</li> <li>Assert that success count is equal to 3.</li> </ol> <p>Now the issue I have is the sequence of the steps on the devices. I need to tell device A to call device B after that device B has been logged into the SIP server for example. Currently I'm unable to accomplish this in an instrumented or unit test.</p> <p>Does anyone know a solution to sequentially execute (unit/instrumented) test code in two device emulators in Android Studio? Is this even possible?</p>
<android><android-studio><device-emulation>
2019-04-17 14:45:37
LQ_CLOSE
55,730,971
Is it safe to link gcc 6, gcc 7, and gcc 8 objects?
<p><a href="https://stackoverflow.com/q/46746878/2069064">Is it safe to link C++17, C++14, and C++11 objects</a> asks about linking objects compiled with different language standards, and Jonathan Wakely's excellent answer on that question explains the ABI stability promises that gcc/libstdc++ make to enusure that this works.</p> <p>There's one more thing that can change between gcc versions though - the language ABI via <a href="https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Dialect-Options.html" rel="noreferrer"><code>-fabi-version</code></a>. Let's say, for simplicity, I have three object files:</p> <ul> <li><code>foo.o</code>, compiled with gcc 6.5 c++14</li> <li><code>bar.o</code>, compiled with gcc 7.4 c++14</li> <li><code>quux.o</code>, compiled with gcc 8.3 c++17</li> </ul> <p>All with the respective default language ABIs (i.e. 10, 11, and 13). Linking these objects together is safe from the library perspective per the linked answer. But are there things that could go wrong from a language ABI perspective? Is there anything I should be watching out for? Most of the language ABI changes seem like they wouldn't cause issues, but the calling convention change for empty class types in 12 might?</p>
<c++><gcc><c++17>
2019-04-17 15:16:51
HQ
55,732,293
Ho to convert CSV file into SQL file easily?
<p>I want to convert the data in a CSV file into SQL queries. What is the easiest and the fastest method to convert a CSV into an SQL file?</p>
<mysql><csv>
2019-04-17 16:33:18
LQ_CLOSE
55,732,876
React Navigation Header in Functional Components with Hooks
<p>I am trying to inject custom headers to React functional components that are using Hooks.</p> <p>So for example I have the following React functional component with some hooks:</p> <pre><code>function StoryHome(props) { const [communityObj, setCommunityObj] = useState({ uid: null, name: null, }); ... } StoryHome.navigationOptions = { title: 'Stories', headerTitleStyle: { textAlign: 'left', fontFamily: 'OpenSans-Regular', fontSize: 24, }, headerTintColor: 'rgba(255,255,255,0.8)', headerBackground: ( &lt;LinearGradient colors={['#4cbdd7', '#3378C3']} start={{ x: 0, y: 1 }} end={{ x: 1, y: 1 }} style={{ flex: 1 }} /&gt; ), headerRightContainerStyle: { paddingRight: 10, }, headerRight: ( &lt;TouchableOpacity onPress={navigation.navigate('storiesList')}&gt; &lt;Ionicons name="ios-search-outline" size={25} color="white" left={20} /&gt; &lt;/TouchableOpacity&gt; ) }; export default StoryHome; </code></pre> <p>So this sort of works, except with the <code>TouchableOpacity</code> part. </p> <p>First, I don't get the <code>Ionicon</code> to render correctly and second, I don't have access to the <code>navigation</code> object outside of the functional component.</p> <p>I would love to continue using Hooks but can't seem to figure this one out.</p>
<reactjs><react-native><header><react-navigation>
2019-04-17 17:13:43
HQ
55,732,916
What is wrong with my Blackjack game code?
<p>The code works mostly well, however, after trying the play again command I made it exits the program and doesn't cycle as expected. The code causing issues is below.</p> <pre><code>play_again = 'y' or 'n' draw_again = 'hit' or 'hold' print("This is a simple game of blackjack. The main objective is to stay under or equal to 21 in value.") print("Number cards are worth their number. Face cards are worth 11. Aces are worth either 1 or 11") print("If you want to draw again type hit. To finish type hold.") play_game = input("would you like to play? (y/n):") if play_game == 'y': shuffleDeck() print ("your starting hand is") drawFaceUp() drawFaceUp() draw_again = input("hit, or hold (hit/hold):") while draw_again == 'hit': print("your next card is") drawFaceUp() draw_again = input("hit, or hold (hit/hold):") if draw_again == 'hold': score = input("Enter your score &lt;score number&gt;:") if score &lt;= '15': print("good job, but try and get a little closer to 21 next time") play_again = input("Play again? (y/n):") if play_again == 'y': newDeck() shuffleDeck() print ("your starting hand is") drawFaceUp() drawFaceUp() draw_again = input("hit, or hold (hit/hold):") while draw_again == 'hit': print("your next card is") drawFaceUp() draw_again = input("hit, or hold (hit/hold):") if draw_again == 'hold': score = input("Enter your score &lt;score number&gt;:") elif play_again == 'n': print ("end of program") elif score &gt; '15' and score &lt; '21': print("Nice. you should test you luck again.") play_again = input("Play again? (y/n):") if play_again == 'y': newDeck() shuffleDeck() print ("your starting hand is") drawFaceUp() drawFaceUp() draw_again = input("hit, or hold (hit/hold):") while draw_again == 'hit': print("your next card is") drawFaceUp() draw_again = input("hit, or hold (hit/hold):") if draw_again == 'hold': score = input("Enter your score &lt;score number&gt;:") elif play_again == 'n': print("end of program") elif score == '21': print("you got a perfect score. see if you can do it again.") play_again = input("Play again? (y/n):") if play_again == 'y': newDeck() shuffleDeck() print ("your starting hand is") drawFaceUp() drawFaceUp() draw_again = input("hit, or hold (hit/hold):") while draw_again == 'hit': print("your next card is") drawFaceUp() draw_again = input("hit, or hold (hit/hold):") if draw_again == 'hold': score = input("Enter your score &lt;score number&gt;:") elif play_again == 'n': print("end of program") elif play_game == 'n': print("end of program") </code></pre> <p>I expect the game to be able to endlessly cycle until told not to. the actual output causes the game to close after 2 rounds of playing.</p>
<python>
2019-04-17 17:16:01
LQ_CLOSE
55,733,120
I get an error when I run my query even though the syntax is corret
I have a table named CUSTOMERS I have a column inside the table named CITY I want to retrieve the city that has the most customers, in other words the most frequent CITY in table CUSTOMERS. I get an error message as following: ORA-00904: "COUNTRY": invalid identifier SELECT COUNTRY, COUNT(COUNTRY) AS `value_occurrence` FROM CUSTOMERS GROUP BY COUNTRY ORDER BY `value_occurrence` DESC LIMIT 1;
<sql><oracle><oracle-apex>
2019-04-17 17:32:23
LQ_EDIT
55,733,903
Javascript CSS HTML how to align a text and a button element in the div right next to each other?
I am trying to implement a text and a button right next to each other in the center of a relatively small height div. I current made a div with width 100% and a height of 70px and appended a text that is centered in the middle of the div. I want to make a button that will be right next to the text. Here is the code: ``` var temp = document.createElement("div"); temp.setAttribute("id", "bar"); $("#bar").css("width", "100%"); $("#bar").css("height", 70); $("#bar").css("background-color", "white"); $("#bar").css({ "display": "flex", "justify-content": "center", "align-items" : "center", "font-size": "20px", "font-weight" : "bold" }); $("#bar").append("SOME TEXT"); ``` Wanted result: [[---------{"SOME TEXT" *button*}---------]] That {"SOME TEXT" *button*} should be in the middle of that div. Any helps would be much appreciated.
<javascript><jquery><html><css>
2019-04-17 18:28:37
LQ_EDIT
55,734,312
Configuring Cypress, cypress-react-unit-test, and React
<p>I want to test our React components independently using the package <code>cypress-react-unit-test</code>. After several days, I have been unable to get it to work with the existing React Webpack configuration. I get the error: <code>TypeError: path argument is required to res.sendFile</code> when I open the file through Cypress' window.</p> <p>I am using the file from their example repo for testing: <a href="https://github.com/cypress-io/cypress-example-recipes/blob/master/examples/unit-testing__react/greeting.jsx" rel="noreferrer">https://github.com/cypress-io/cypress-example-recipes/blob/master/examples/unit-testing__react/greeting.jsx</a></p> <p>We do use TypeScript, but I wanted to get this working first.</p> <p>I have tried overwriting <code>path</code> as it is defaulting to <code>undefined</code>, but I'm getting the same error.</p> <pre><code>{ options: { path: "/my/home/dir/" } } </code></pre> <p>In my <code>cypress/plugins/index.js</code> file I have:</p> <pre><code>const wp = require("@cypress/webpack-preprocessor"); const webpackConfig = require("../../node_modules/react-scripts/config/webpack.config")("development"); module.exports = on =&gt; { const options = { webpackOptions: webpackConfig }; on("file:preprocessor", wp(options)); }; </code></pre> <p>I'm obviously missing something, but I don't know Webpack well enough. I would be grateful for any pointers! Thanks!</p>
<reactjs><webpack><webpack-4><cypress>
2019-04-17 18:59:03
HQ
55,735,406
I am unable to raise exceptions correctly in my flask app
<p>In my flask app, I am unable to throw an error due to the following line of code.</p> <p>Note that MyException is a class that is subclass of the Exception class, and it imports status from the flask_api.</p> <pre><code>raise MyException( status.HTTP_400_BAD_REQUEST, "File does not exist: " + file_path ) </code></pre> <p>However, this yields the following error in my terminal when I get to this error in my webpage:</p> <pre><code>TypeError: 'tuple' object is not callable The view function did not return a valid response. The return type must be a string, tuple, Response instance, or WSGI callable, but it was a tuple. </code></pre> <p>Am I unable to raise exceptions in flask?</p>
<python><exception><flask>
2019-04-17 20:20:14
LQ_CLOSE
55,736,443
how to pick from an array depending on a certain number
<p>Lets say you use indexOf on an array to find all cases that say apple. If it comes back with three cases at positons 1, 2 and 3. </p> <p>Now lets say there is an array = [10, 20, 30 ,40 ,50 ,60 ,70 ,80 ,90 ,100]</p> <p>is there a way to use them cases 1,2 and 3 which come to 6. So is there a a way to go to position 6 "70" and produce that number. Depending on what the indexOf provides, is there a way to select that number from the array. Also if the indexOF produced 3.5 would there be a way to get 35 aka position 3.5.</p>
<javascript><arrays><indexof>
2019-04-17 21:48:00
LQ_CLOSE
55,736,509
Android Studio Install Disappears
<p>I'm trying to install the latest Android Studio.</p> <p>Environment:</p> <p>Windows7 64-bit JDK v12</p> <p>I run the installer, and then it disappears after the initial setup progress dialog. Is there any way to troubleshoot this?</p> <p><a href="https://youtu.be/y1ueVCxyhdo" rel="nofollow noreferrer">Video of the install is here</a></p>
<android-studio>
2019-04-17 21:55:19
LQ_CLOSE
55,737,199
How do we see full commands in the output of docker history command?
<p>How do we see full commands in the third column (CREATED BY) in the output of docker history command?</p> <pre><code>$ docker history docker.company.net/docker-base-images/image:1.0 IMAGE CREATED CREATED BY SIZE c0bddf343fc6 7 days ago /bin/sh -c #(nop) LABEL com.company.build.r… 0B &lt;missing&gt; 7 days ago /bin/sh -c #(nop) ARG commit 0B &lt;missing&gt; 7 days ago /bin/sh -c #(nop) ARG date 0B &lt;missing&gt; 7 days ago /bin/sh -c #(nop) ARG repo 0B &lt;missing&gt; 7 days ago /bin/sh -c #(nop) ARG org 0B &lt;missing&gt; 7 days ago /bin/sh -c #(nop) ARG version 0B &lt;missing&gt; 7 days ago /bin/sh -c #(nop) USER [company] 0B &lt;missing&gt; 7 days ago /bin/sh -c apk --no-cache add openjdk8-jre-b… 72.2MB &lt;missing&gt; 7 days ago /bin/sh -c #(nop) USER [root] 0B &lt;missing&gt; 7 days ago /bin/sh -c #(nop) USER [company:company] 0B &lt;missing&gt; 7 days ago |5 commit=d64d27b07439e6cfff7422acafe440a946… 3.92MB &lt;missing&gt; 7 days ago /bin/sh -c #(nop) LABEL com.company.build.r… 0B &lt;missing&gt; 7 days ago |5 commit=d64d27b07439e6cfff7422acafe440a946… 4.85kB &lt;missing&gt; 7 days ago /bin/sh -c #(nop) ARG commit 0B &lt;missing&gt; 7 days ago /bin/sh -c #(nop) ARG date 0B &lt;missing&gt; 7 days ago /bin/sh -c #(nop) ARG repo 0B &lt;missing&gt; 7 days ago /bin/sh -c #(nop) ARG org 0B &lt;missing&gt; 7 days ago /bin/sh -c #(nop) ARG version 0B &lt;missing&gt; 5 weeks ago /bin/sh -c #(nop) CMD ["/bin/sh"] 0B &lt;missing&gt; 5 weeks ago /bin/sh -c #(nop) ADD file:88875982b0512a9d0… 5.53MB </code></pre> <p>The third column (CREATED BY) is abbreviating the commands which makes it hard to reconstruct the original Dockerfile. Is it possible to get the full commands in the third column?</p> <p>Thanks for reading.</p>
<docker><dockerfile>
2019-04-17 23:16:31
HQ
55,737,546
Access nth child of ViewChildren Querylist (Angular)
<p>I'm trying to access the nth child of a viewchildren querylist.</p> <p>Below is my TS:</p> <pre><code>@ViewChildren(PopoverDirective) popovers: QueryList&lt;PopoverDirective&gt;; console.log(this.popovers) </code></pre> <p>The console.log shows changes, first, last, length and _results.</p> <p>How can I access the nth child (i.e., 3rd, instead of first)?</p> <p>When I try to do this with _results (i.e., this.popovers._results[2]), I get an error.</p> <p>Thank you.</p>
<angular><viewchild>
2019-04-18 00:14:46
HQ
55,738,556
Checking number of parameters passed in a function
I'm writing a bash function that takes a directory D as a parameter. If given no parameter, D should be ".", if 2 or more parameters are passed in, the function should output an error and exit the program. But my function is not working. Please help!! ```` dir=$@ if [ $# -e 1 ]; then dir=$1 else if [ $# -e 0 ]; then dir="." else echo "Too many operands." exit 1 fi ````
<bash><shell>
2019-04-18 03:03:50
LQ_EDIT
55,739,379
Execute a function until 5 minutes WPF
In a WPF form I'm calling doSomeFunction() method in a while loop. This will run until x = y. This is working fine. while (x != y) { doSomeFunction(); } I need to add additional function, that need to check this condition until 5 minutes only. After the 5 minutes if x != y I need to return. How can I do this in WPF?
<c#><wpf><timer>
2019-04-18 04:57:15
LQ_EDIT
55,739,690
String Values is geting the values from the other string
I'm having problem on string values, im generating on the funcion "gerarconta" that make random numbers for the following variables: "cb->cocom[numcontas].senha" with 4 numbers as caracters, "cb->cocom[numcontas].agencia" and "cb->cocom[numcontas].numconta" with 3 caracters. The problem is that the value of the first is saving on the other variables for exemplo : cb->cocom[numcontas].senha = 1213 cb->cocom[numcontas].agencia = 545 cb->cocom[numcontas].numconta = 187545 an this happens everytime i use printf. ``` //AEP 30/04/2019 //Algoritmo para um sistema bancário //Created by Jordão Qualho da silva //. //Last Update 16/04/2019 21:37 //------------------------------------------------------------------------------ //Bibliotecas #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <windows.h> #include <locale.h> #include <math.h> #include <conio.h> //------------------------------------------------------------------------------ int num=0; //numero de pessoas inseridas int numcontas=0; //numero de contas inseridas int tipoconta=-1; //-1=inicio 0=comum 1=especial 2=poupanca //------------------------------------------------------------------------------ void gotoxy(int x, int y){ SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),(COORD){x-1,y-1}); //muda o cursor para a posição x,y } //------------------------------------------------------------------------------ void fazerjanela (int ci,int li,int lf,int cf){ //faz uma janela c=coluna l=linha i=incial f=final int i,y; for ( i = ci+1; i < cf; i++) { gotoxy(i,ci);printf("%c",196 ); } for ( i = ci+1; i < cf; i++) { gotoxy(i,lf);printf("%c",196 ); } for ( i = li; i < lf; i++) { gotoxy(ci,i);printf("%c",179 ); } for ( i = li; i < lf; i++) { gotoxy(cf,i);printf("%c",179 ); } gotoxy(ci,li);printf("%c",218 ); gotoxy(cf,lf);printf("%c",217 ); gotoxy(cf,li);printf("%c", 191); gotoxy(ci,lf);printf("%c", 192); gotoxy(cf,lf+1);printf("\n"); } //------------------------------------------------------------------------------ typedef struct Pessoa{ char nome [100]; char endereco [100]; char telefone [12]; float renda; int tipopessoa; //1=fisica e 2=Juridica char cpf [20],cnpj [20]; }pe; typedef struct Historico{ char numconta [10];//verificar depois char data [8]; char tipodoc [20]; float valor; }hist; typedef struct Contacomum{ char senha [4]; char numconta [3]; char agencia [3]; float saldo; hist historicos [100]; pe pessoas [100]; int pessoa; }cc; typedef struct Contaespecial{ char senha [50]; char numconta [10]; char agencia [10]; float saldo; hist historicos [100]; pe pessoas [100]; int pessoa; float limite; }ce; typedef struct contapoupanca{ char senha [50]; char numconta [10]; char agencia [10]; float saldo; hist historicos [100]; pe pessoas [100]; int pessoa; }cp; typedef struct contabancaria{ cp copou [20]; ce coesp [20]; cc cocom [20]; }cb; //------------------------------------------------------------------------------ void gerarconta (cb *cb){ int i=0; //semente para o numero randomico com o tempo do sistema atual srand((unsigned)time(NULL)); FILE *arq; arq = fopen("Contas.txt","w"); if (tipoconta==0) { //gerando senha de 4 digitos aleatoria for ( i = 0; i < 4; i++) { cb->cocom[numcontas].senha[i]=48+(rand()%10); }gotoxy (5,5); printf("%s",cb->cocom[numcontas].senha); for ( i = 0; i < 3; i++) { cb->cocom[numcontas].agencia[i]=48+(rand()%10); }gotoxy (5,6); printf("%s",cb->cocom[numcontas].agencia); for ( i = 0; i < 3; i++) { cb->cocom[numcontas].numconta[i]=48+(rand()%10); }gotoxy (5,7); printf("%s",cb->cocom[numcontas].numconta); gotoxy (20,5); printf("%s",cb->cocom[numcontas].senha); gotoxy (20,6); printf("%s",cb->cocom[numcontas].agencia); gotoxy (20,7); printf("%s",cb->cocom[numcontas].numconta); getch(); /*fprintf(arq,"%s %s %s", cb->cocom[numcontas].senha, cb->cocom[numcontas].agencia, cb->cocom[numcontas].numconta);fclose (arq);*/ } if (tipoconta==1) { for ( i = 0; i < 4; i++) { cb->coesp[numcontas].senha[i]=rand()%10; } for ( i = 0; i < 3; i++) { cb->coesp[numcontas].agencia[i]=rand()%10; } for ( i = 0; i < 3; i++) { cb->coesp[numcontas].numconta[i]=rand()%10; } } if (tipoconta==2) { for ( i = 0; i < 4; i++) { cb->copou[numcontas].senha[i]=rand()%10; } for ( i = 0; i < 3; i++) { cb->copou[numcontas].agencia[i]=rand()%10; } for ( i = 0; i < 3; i++) { cb->copou[numcontas].numconta[i]=rand()%10; } } } //------------------------------------------------------------------------------ void transformarnome (char *nome){ int i,tam; tam = strlen (nome); for (i = 0; i < tam; i++) { if (nome [i] == '.') { nome[i]=' '; } } } //------------------------------------------------------------------------------ void transformarnomevolta (char *nome){ int i,tam; tam = strlen (nome); for (i = 0; i < tam; i++) { if (nome [i] == ' ') { nome[i]='.'; } } } //------------------------------------------------------------------------------ void transformarCPF (char *cpf){ int i,tam; cpf[13]=cpf[10];cpf[12]=cpf[9];cpf[11]='-'; cpf[10]=cpf[8]; cpf[9]=cpf[7]; cpf[8]=cpf[6];cpf[7]='.'; cpf[6]=cpf[5]; cpf[5]=cpf[4]; cpf[4]=cpf[3];cpf[3]='.'; } //------------------------------------------------------------------------------ void criarpessoafisica (cb *cb){ int tam, flag=0; FILE *arq; int i=0; arq = fopen("Pessoas.txt","a"); cb->cocom[numcontas].pessoas[num].tipopessoa = 1; system("cls"); fazerjanela(1,1,15,50); gotoxy (15,2); printf("Cadastro de Pessoa Fisica"); gotoxy (3,4); printf("Pesssoa N00%i ", num+1); gotoxy (3,6); printf("Nome: ");fflush (stdin); scanf("%[^\n]s", &cb->cocom[numcontas].pessoas[num].nome); gotoxy (3,7); printf("Endereco: ");fflush (stdin); scanf("%[^\n]s", &cb->cocom[numcontas].pessoas[num].endereco ); gotoxy (3,8); printf("Telefone: ");fflush (stdin); scanf("%[^\n]s", &cb->cocom[numcontas].pessoas[num].telefone ); gotoxy (3,9); printf("Renda Mensal: ");fflush (stdin); scanf("%f", &cb->cocom[numcontas].pessoas[num].renda ); do { gotoxy (3,12); printf(" "); gotoxy (3,14); printf(" "); gotoxy (3,10); printf(" "); gotoxy (3,10); printf("CPF: ");fflush (stdin); scanf("%[^\n]s", &cb->cocom[numcontas].pessoas[num].cpf ); tam = strlen (cb->cocom[numcontas].pessoas[num].cpf); if (tam != 11) { gotoxy (3,12); printf("Error 404: CPF Invalido !"); gotoxy (3,14); system ("PAUSE"); flag=1; }else{ flag=0; } } while(flag); gotoxy (3,12); printf("Pessoa cadastrada com sucesso !"); gotoxy (3,14); system("PAUSE"); system ("cls"); transformarnomevolta (&cb->cocom[numcontas].pessoas[num].nome); transformarnomevolta (&cb->cocom[numcontas].pessoas[num].endereco); transformarCPF(&cb->cocom[numcontas].pessoas[num].cpf ); fprintf(arq,"\n%s %s %s %.1f %s %i", cb->cocom[numcontas].pessoas[num].nome, cb->cocom[numcontas].pessoas[num].endereco, cb->cocom[numcontas].pessoas[num].telefone, cb->cocom[numcontas].pessoas[num].renda, cb->cocom[numcontas].pessoas[num].cpf, cb->cocom[numcontas].pessoas[num].tipopessoa); fclose (arq); } //------------------------------------------------------------------------------ void criarpessoajuridica (cb *cb) { int tam, flag=0; FILE *arq; int i=0; arq = fopen("Pessoas.txt","a"); cb->cocom[numcontas].pessoas[num].tipopessoa = 2; system("cls"); fazerjanela(1,1,15,50); gotoxy (15,2); printf("Cadastro de Pessoa Juridica"); gotoxy (3,4); printf("Pesssoa N000%i ", num+1); gotoxy (3,6); printf("Nome: ");fflush (stdin); scanf("%[^\n]s", &cb->cocom[numcontas].pessoas[num].nome); gotoxy (3,7); printf("Endereco: ");fflush (stdin); scanf("%[^\n]s", &cb->cocom[numcontas].pessoas[num].endereco ); gotoxy (3,8); printf("Telefone: ");fflush (stdin); scanf("%[^\n]s", &cb->cocom[numcontas].pessoas[num].telefone ); gotoxy (3,9); printf("Renda Mensal: ");fflush (stdin); scanf("%f", &cb->cocom[numcontas].pessoas[num].renda ); gotoxy (3,10); printf("CNPJ: ");fflush (stdin); scanf("%%[^\n]s", &cb->cocom[numcontas].pessoas[num].cnpj ); gotoxy (3,12); printf("Pessoa cadastrada com sucesso !"); gotoxy (3,14); system("PAUSE"); system ("cls"); fprintf(arq,"%s %s %s %f %s", cb->cocom[numcontas].pessoas[num].nome, cb->cocom[numcontas].pessoas[num].endereco, cb->cocom[numcontas].pessoas[num].telefone, cb->cocom[numcontas].pessoas[num].renda, cb->cocom[numcontas].pessoas[num].cnpj, cb->cocom[numcontas].pessoas[num].tipopessoa); num++; } //------------------------------------------------------------------------------ void cadastrarpessoa (cb *cb){ int pos1=1; char opc; do{ system("cls"); fazerjanela (1,1,15,50); gotoxy (6,5); printf("Que tipo de pessoa deseja cadastrar ?"); gotoxy (6,8); printf(" Pessoa Fisica"); gotoxy (25,8); printf(" Pessoa Juridica"); gotoxy (40,14);printf(" Voltar"); switch (pos1){ case 1: gotoxy(6,8); printf("-> Pessoa Fisica");break; case 2: gotoxy(25,8); printf("-> Pessoa Juridica");break; case 3: gotoxy(40,14); printf("-> Voltar");break; } opc=getch(); if (opc==-32){ //tecla especial necessita pegar segundo valor opc=getch(); switch (opc) { case 75:pos1--; break; //SETA PRA CIMA case 77:pos1++; break; //SETA PRA BAIXO } } if (pos1==0) pos1=3; if (pos1==4) pos1=1; if (opc == 13) //ENTER switch (pos1){ case 1: criarpessoafisica (&cb); opc=27; break; case 2: criarpessoajuridica (&cb); opc=27; break; case 3: opc=27; break; } } while (opc!=27); } //------------------------------------------------------------------------------ void criarcontacomum(cb *cb){ int pos1=1; char opc; tipoconta = 0; do{ system ("cls"); fazerjanela(1,1,15,50); gotoxy (2,4); printf("-----------------(Conta Comum)------------------"); gotoxy (5,7); printf(" Cadastrar Nova Pessoa "); gotoxy (5,9); printf(" Usar Pessoa Existente "); gotoxy (2,12); printf("------------------------------------------------"); gotoxy (42,14); printf(" Sair"); switch (pos1){ case 1: gotoxy(5,7); printf("-> Cadastrar Nova Pessoa "); break; case 2: gotoxy(5,9); printf("-> Usar Pessoa Existente "); break; case 3: gotoxy(42,14);printf("-> Sair"); break; } opc=getch(); if (opc==-32){ //tecla especial necessita pegar segundo valor opc=getch(); switch (opc) { case 72:pos1--; break; //SETA PRA CIMA case 80:pos1++; break; //SETA PRA BAIXO } } if (pos1==0) pos1=3; if (pos1==4) pos1=1; if (opc == 13) //ENTER switch (pos1){ case 1: cadastrarpessoa (&cb); gerarconta (&cb); num++; numcontas ++; break; case 2: break; case 3: opc=27; break; } } while (opc!=27); } //------------------------------------------------------------------------------ void criarcontaespecial(cb *cb){ } //------------------------------------------------------------------------------ void criarcontapoupanca(cb *cb){ } //------------------------------------------------------------------------------ void criarconta(cb *cb) { int pos1=1; char opc ; do{ system ("cls"); fazerjanela(1,1,15,50); gotoxy (2,4); printf("--------------------(Conta)---------------------"); gotoxy (5,6); printf(" Conta Comum "); gotoxy (5,8); printf(" Conta Especial "); gotoxy (5,10); printf(" Conta Poupanca "); gotoxy (2,12); printf("------------------------------------------------"); gotoxy (42,14); printf(" Sair"); switch (pos1){ case 1: gotoxy(5,6); printf("-> Conta Comum"); break; case 2: gotoxy(5,8); printf("-> Conta Especial"); break; case 3: gotoxy(5,10); printf("-> Conta Poupanca" ); break; case 4: gotoxy(42,14);printf("-> Sair"); break; } opc=getch(); if (opc==-32){ //tecla especial necessita pegar segundo valor opc=getch(); switch (opc) { case 72:pos1--; break; //SETA PRA CIMA case 80:pos1++; break; //SETA PRA BAIXO } } if (pos1==0) pos1=4; if (pos1==5) pos1=1; if (opc == 13) //ENTER switch (pos1){ case 1: criarcontacomum (&cb); break; case 2: criarcontaespecial (&cb); break; case 3: criarcontapoupanca (&cb); case 4: opc=27; break; } } while (opc!=27); } //------------------------------------------------------------------------------ void acessarconta(cb *cb){ } //------------------------------------------------------------------------------ /*void lerarquivo (cb *cb){ FILE *arq; int i=0; arq = fopen("Pessoas.txt","r"); system ("cls"); while ( !feof(arq)) { fscanf(arq,"%s" "%s" "%f" "%s",&cb->contacomum[0]->pessoas[i].nome,&cb->contacomum[0]->pessoas[i].endereco,&cb->contacomum[0]->pessoas[i].renda,&cb->contacomum[0]->pessoas[i].cpf); transformarnome (&cb->contacomum[0]->pessoas[i].nome); transformarnome (&cb->contacomum[0]->pessoas[i].endereco); i++;num++; } }*/ //------------------------------------------------------------------------------ /*void procurarpessoa (cb *cb){ int opcao,i,col=5; if (num > 0) { system ("cls"); fazerjanela(1,1,15,50); gotoxy (13,2); printf("Pessoas Inseridas: %i", num-1); for ( i = 0; i < num; i++) { gotoxy (3,(i+4)); printf("%i. %s",(i+1),cb->pessoas[i].nome); } gotoxy (3,(i+5)); printf("Insira o numero da pessoa que desja editar: " ); fflush (stdin);scanf("%i", &opcao); system ("cls"); fazerjanela(1,1,12,50); opcao=opcao-1; gotoxy (16,3); printf("Pesssoa Fisica N00%i ", opcao+1); gotoxy (3,6); printf(" Nome: %s", cb->pessoas[opcao].nome); gotoxy (3,7); printf("Endereco: %s", cb->pessoas[opcao].endereco ); gotoxy (3,8); printf(" Renda: %.1f", cb->pessoas[opcao].renda ); gotoxy (3,9); printf(" CPF: %s", cb->pessoas[opcao].cpf ); gotoxy (3,11); system ("PAUSE"); } }*/ //------------------------------------------------------------------------------ int main() { system("mode con:cols=50 lines=17"); cb contabancaria; int pos1=1; char opc; //lerarquivo (&contabancaria); //arumar <<<<<<<<<<<<<<<<<<<<<<<<<<<<<------ do{ system("cls"); fazerjanela (1,1,15,50); gotoxy (2,4); printf("--------------------(Conta)---------------------"); gotoxy (5,8); printf(" Criar "); gotoxy (31,8); printf(" Acessar "); gotoxy (2,12); printf("------------------------------------------------"); gotoxy (42,14); printf(" Sair"); switch (pos1){ case 1: gotoxy(5,8); printf("-> Criar"); break; case 2: gotoxy(31,8); printf("-> Acessar"); break; case 3: gotoxy(42,14);printf("-> Sair"); break; } opc=getch(); if (opc==-32){ //tecla especial necessita pegar segundo valor opc=getch(); switch (opc) { case 75:pos1--; break; //SETA PRA ESQUERDA case 77:pos1++; break; //SETA PRA DIREITA } } if (pos1==0) pos1=3; if (pos1==4) pos1=1; if (opc == 13) //ENTER switch (pos1){ case 1: criarconta(&contabancaria); break; case 2: acessarconta(&contabancaria); break; case 3: opc=27; break; } } while (opc!=27); system("cls"); printf("\nPrograma Finalizado com suscesso !\n"); } ```
<c><arrays><string><algorithm><variables>
2019-04-18 05:34:24
LQ_EDIT
55,740,995
Infinite loop after memory de-allocation
I have some issues with my code during my memory deallocaiton process. Here is the error I am getting: [![I make it to the part where my memory should be deallocated but instead of deallocation I get an infinite loop][1]][1] bool LinkedList::addArtist(){ cout << "Enter artist name: "; char *name = new char[0](); cin >> name; cin.ignore(1); '/n'; cout << "Enter artists top story: "; char *topStory = new char[0]; cin >> topStory; cin.ignore(1); '/n'; cout << "Enter artist description: "; char *description = new char[0]; cin >> description; cin.ignore(1); '/n'; this->addAtBeginning(*&name, *&topStory, *&description); cout << "made it out" << endl; delete[] name; delete[] topStory; delete[] description; return true; } as you can see I get the "made it out" notification yet my program gets frozen and doesn't allow me to do anything. Any thoughts? [1]: https://i.stack.imgur.com/TOUDh.png
<c++><arrays><string><memory-management><dynamic>
2019-04-18 07:21:04
LQ_EDIT
55,741,103
search keyword not found any result
I want to search **keyword like %$keyword%** than the resulting black . not show result missing PHP code. I have one table 'ads_post' and use field cat_name, city_name please check it and help me... **search-result.php** <?php if(isset($_GET['submit'])){ $keyword = $_GET['keywoed']; $query = "select * from ads_post where cat_name like '%$keywoed%' or city_name like '%$keywoed%'"; $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { while($row = mysqli_fetch_assoc($result)) { echo "cat Name: " . $row["cat_name"]. "<br>"; } } else { echo "0 results"; } mysqli_close($conn); } ?> **html form here** <form action="search-result.php" method="get" > <input class="form-control" name="keyword" placeholder="Search any keyword..?"> <input type="submit" value="search"> </form>
<php>
2019-04-18 07:27:53
LQ_EDIT
55,741,266
When will following method throw 2
I am curious to find out under what circumstances following method will return 2 instead of 1. ``` private int splitString(String strToSplit) { int num = strToSplit.split("[\\W_]+").length; if (num == 0) { System.out.println("Value is :: " + 2); return 2; } return 1; } ``` Thanks in advance.
<java><string><split>
2019-04-18 07:40:03
LQ_EDIT
55,742,304
Include sudo password in linux executable file
<p>I have this code in a linux executable file to start atom from there:</p> <pre><code>#! /bin/bash sudo atom </code></pre> <p>I wanted to include sudo password after that lines of code, so the program will run automatically.</p>
<linux>
2019-04-18 08:44:14
LQ_CLOSE
55,743,481
Regression Problem: How to solve the problem of highly decimal input features
<p>I have the following input data structure:</p> <pre><code> X1 | X2 | X3 | ... | Output (Label) 118.12341 | 118.12300 | 118.12001 | ... | [a value between 0 &amp; 1] e.g. 0.423645 </code></pre> <p>Where I'm using <code>tensorflow</code> in order to solve the regression problem here of predicting the future value of the <code>Output</code> variable. For that i built a feed forward neural network with three hidden layers having <code>relu</code> activation functions and a final output layer with one node of <code>linear activation</code>. This network is trained with back-propagation using <code>adam</code> optimizer.</p> <p>My problem is that after training the network for some thousands of epochs, I realized that this <strong>highly decimal</strong> values in both input features and the output, resulted in predictions near to the second decimal place only, for example:</p> <pre><code>Real value = 0.456751 | Predicted value = 0.452364 </code></pre> <p>However this is not accepted, where i need a precision to the forth decimal place (at least) to accept the value.</p> <p><strong>Q:</strong> Is there any trustworthy technique to solve this problem properly for getting better results (maybe a transformation algorithm)?</p> <p>Thanks in advance.</p>
<tensorflow><machine-learning><keras><neural-network><data-analysis>
2019-04-18 09:51:07
LQ_CLOSE
55,743,909
What is the diffference between these three types of variable declaration in javascript?
<p>I am new to JS and i have facing some issue on declaration of the Variables in three ways</p> <p><a href="https://i.stack.imgur.com/P3xCX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/P3xCX.png" alt="These are test cases i have tried"></a></p> <p>as my understanding </p> <pre><code>a = "a"; </code></pre> <p>and </p> <pre><code>var a = "var a"; </code></pre> <p>are (global declaration) same thing </p> <p>but </p> <pre><code>let a = "let a" </code></pre> <p>is declare as local variable </p> <p>so as i have tested some combinations </p> <pre><code>let a ="let a" a ="a" </code></pre> <p>workes </p> <p>but </p> <pre><code>let a = "let a" var a = "var a" </code></pre> <p>not works </p> <p>could you tell me why is that ?</p>
<javascript>
2019-04-18 10:16:11
LQ_CLOSE
55,744,772
How to convert date to string date in php?
<p>I am trying to convert a date '2019-04-18' to something like this '18 Apr 2019' in php.</p> <pre><code>$date=date_create("2019-04-18"); echo date_format($date,'jS F Y'); </code></pre> <p>It is giving me output like this :</p> <pre><code>18th April 2019 </code></pre> <p>But i need output to be '18 Apr 2019' ie: 3 letters of month</p>
<php><string><date><format>
2019-04-18 11:11:34
LQ_CLOSE
55,745,536
testing with a session data to display a photo in a blade page
i want to test "sexe" to display a photo. I use the session but nothing happens that's the controller: public function store () { request()->validate([ 'username'=>['required'], 'sexe'=>['required'] , 'role'=>['required'] , ]); $enfant= new enfant(); $enfant->username=request('username'); $enfant->role=request('role'); $enfant->sexe=request('sexe'); $enfant->parent_id=Auth::user()->id; $enfant->save(); $sexe = session()->get( 'sexe' ); return redirect ('/themes', compact('enfants'))->with([ 'sexe' => $sexe ]); } and that's the view {{ session()->get( 'sexe' ) }} @if ( 'sexe'=='f' ) <img src="images/avatarF.png" class="profile" style="width: 160px ; height: 160px;"> @endif @if ( 'sexe'=='h' ) <img src="images/avatarG.png" class="profile" style="width: 1600px ; height: 160px; margin-top: 0px;"> @endif
<php><mysql><laravel><session>
2019-04-18 11:56:13
LQ_EDIT
55,747,046
PHP Accessing nested json elements in square brackets
<p>I am trying to access the amount property in the below json file. </p> <pre><code>{ "id": "evt_1EQZxID5bcg", "data": { "object": { "id": "cs_0G452PD7eY8ddrtuyo0KZ5sSRk", "display_items": [ { "amount": 300, "currency": "gbp", "custom": { "name": "Purchase" }, "type": "custom" } ], "livemode": false, "payment_method_types": [ "card" ], "subscription": null, "success_url": "" } }, "livemode": false, "request": { "idempotency_key": null }, "type": "checkout.session.completed" } </code></pre> <p>I have tried using this code to access the peroperty</p> <pre><code>$object-&gt;data-&gt;object-&gt;display_items-&gt;amount </code></pre> <p>However, this returns no data.</p> <p>I am thinking this has to do with the square brackets, but when I try access that alone I get an array.</p>
<php><json>
2019-04-18 13:26:26
LQ_CLOSE
55,747,314
Jquery trigger reset not clear all inputs
I need to clear all the inputs inside form But when I execute trigger reset function. It clears text fields but not the textarea fields <form id="frm" action=""> <div class="col-md-4"> <input name="" type="text" placeholder="Alan Adını Giriniz" value="" class="form-control" id="txtCokluDomain"> </div> <div class="col-md-4"><input type="button" id="liteyeEkle" class="btn btn-success" value="Ekle"> </div> </div> <div class="row"> <div class="col-md-4 "> <textarea name="" id="textAreaDomainListesi" cols="35" rows="10"></textarea> </div> </div> </form>
<jquery>
2019-04-18 13:41:04
LQ_EDIT
55,747,383
Assembly.Load .NET Core
<p>I have an assembly that was dynamically generated using <code>AssemblyBuilder.DefineDynamicAssembly</code>, yet when i try to load it, i get the following error:</p> <blockquote> <p>System.IO.FileNotFoundException: 'Could not load file or assembly 'test, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.'</p> </blockquote> <p>This is the full code to reproduce:</p> <pre><code>var name = new AssemblyName("test"); var assembly = AssemblyBuilder.DefineDynamicAssembly(name, AssemblyBuilderAccess.Run); var assembly2 = Assembly.Load(name); </code></pre> <p>I am using .NET Core 2.0, 2.1 and 2.2.</p> <p>Can somebody please explain why this happens and any possible solutions?</p>
<c#><.net-core><.net-assembly>
2019-04-18 13:45:07
HQ
55,748,639
Set value in dependency of Helm chart
<p>I want to use the <a href="https://github.com/helm/charts/tree/master/stable/postgresql" rel="noreferrer">postgresql chart</a> as a requirements for my Helm chart.</p> <p>My <code>requirements.yaml</code> file hence looks like this:</p> <pre><code>dependencies: - name: "postgresql" version: "3.10.0" repository: "@stable" </code></pre> <p>In the postgreSQL Helm chart I now want to set the username with the property <code>postgresqlUsername</code> (see <a href="https://github.com/helm/charts/tree/master/stable/postgresql" rel="noreferrer">https://github.com/helm/charts/tree/master/stable/postgresql</a> for all properties).</p> <p>Where do I have to specify this property in my project so that it gets propagated to the postgreSQL dependency?</p>
<postgresql><kubernetes><google-kubernetes-engine><kubernetes-helm>
2019-04-18 14:53:09
HQ
55,750,711
How can I make a page private with code login on php?
<p>I'm working on a new website for a business I'd like to start and I got stuck in one of its pages. I actually want one page to be private unless you log in with a code, and I don't know how to deal with it. </p> <p>I've thought of using PHP for comparing both login form pass and a MySQL pass uploaded by me before but I'm not really used to work with PHP so I get stuck on it every time I try it. Could anyone, please, suggest me a piece of code for making it private? </p> <p>Thank you.</p>
<php><mysql><sql>
2019-04-18 17:03:22
LQ_CLOSE
55,751,706
this code was supposed to get in a loop and when it was invalidit should have been asked for the informations again and again but it doesnt
while True: for i in text: print (ord(i)) print (i , "=" , chr (ord(i) +n)) password = (password + chr (ord(i) + n)) if (text.lower() != text): print ("only lower case.") elif (n<2 or n>15): print ("your code must be between 2 and 15, including them.") return False else: print(text , "=>" , password)
<python>
2019-04-18 18:15:41
LQ_EDIT
55,752,945
Keeping Borland Delphi DFM files in sync with their PAS files
“I have a Borland Delphi project with a lot of DFM files and matching PAS files. I can compile the PAS by just rebuilding the project, but how do I rebuild and keep the DFM files in sync with their PAS files? Right now I am getting a lot of "[Variable.field] does not have a corresponding component. Remove the declaration?" ”
<delphi>
2019-04-18 19:55:09
LQ_EDIT
55,753,301
How do you populate two Lists with one text file based on an attribute?
<p>I have a text file with 40000 lines of data.</p> <p>The data is formatted as such:</p> <pre><code>Anna,F,98273 Christopher,M,2736 Robert,M,827 Mary,F,7264 Anthony,M,8 ... </code></pre> <p>I want to create two Lists based on a char value. The char indicates gender and I want to create a "female (f)" List and a "male (m)" List. <strong>How do I create two lists from one file based on this char value?</strong></p> <p>I have a class with a constructor already set up to create a List of all the data. I have already successfully created one List and am able to sort it based on any given attribute. If creating two Lists is not the best way to organize this data please give me alternatives. </p> <p>I have thought about compiling all the data into one List and then sorting it based on the char so females are first and then males. I would then have to sort it based on the number associated with the name. The issue I run into here is I need to display the top 10 (any given int works here as it will be inputted by the user) female names with the highest numbers alongside the top male names with the highest numbers. I am not sure how to call on these values as I cannot (to my knowledge) use the index to indicate rank if both genders are in the same List. To me, this method seems much more complicated than simply creating two Lists and is not ideal.</p>
<c#><arrays><list><populate><jagged-arrays>
2019-04-18 20:27:24
LQ_CLOSE
55,753,866
Regex to get event start and end times
I'm webscraping with webscraper.io and From 'Time: 12:00 PM to 9:00 PM' I'm trying to grab '12:00 PM' and '9:00 PM'. I'm trying to get them as separate items, so I think two regex expressions are in order. Any regex wizards willing to lend a hand? I tried this: https://forum.sublimetext.com/t/regex-match-everything-after-this-word/20764 to grab everything after 'to' but it isn't working for some reason.
<regex>
2019-04-18 21:20:08
LQ_EDIT
55,754,451
How to ignore a whole line of text that starts with // using a scanner class and delimiters
I am trying to read data from a .txt file, i need to be ignoring any line that starts with a // or a blank line but i can't seem to get the delimiter to work correctly. public void readVehicleData() throws FileNotFoundException { FileDialog fileBox = new FileDialog(myFrame, "Open", FileDialog.LOAD); fileBox.setVisible(true); String filename = fileBox.getFile(); File vehicleData = new File(filename); Scanner scanner = new Scanner(vehicleData).useDelimiter("\"(,\")?"); while( scanner.hasNext() ) { String lineOfText = scanner.nextLine(); System.out.println(lineOfText); } scanner.close(); } // this is a comment, any lines that start with // // (and blank lines) should be ignored AA, TF-63403, MJ09TFE, Fiat A, TF-61273, MJ09TFD, Fiat A, TF-64810, NR59GHD, Ford B , TF-68670,MA59DCS, Vauxhall B, TF-61854, MJ09TFG, Fiat B, TF-69215, PT09TAW, Peugeot C, TF-67358, NR59GHM, Ford This is the .txt file i am trying to read
<java>
2019-04-18 22:30:10
LQ_EDIT
55,755,214
How can I correctly implement setTimeout?
<p>I'm trying to use <code>setTimeout</code> to perform <code>document.write</code> after a certain delay after a form is submitted. For now, the delay is a static 3000ms. However, when I try to implement it, <code>document.write</code> happens instantly. How can I implement setTimeout correctly?</p> <p>This is for a website. Form submission happens before this block of code runs, and variables are passed from what is submitted.</p> <pre><code> function findInterval(){ var delay = document.forms["options"]["delay"].value; min = Math.ceil(min); max = Math.ceil(max); var result = Math.floor(Math.random() * (max - min + 1)) + min; var total = parseInt(delay) + parseInt(result); setTimeout(document.write(total), 3000); } </code></pre> <p>My understanding is that my code should wait 3 seconds, then do <code>document.write(total)</code> but that's not the case. What am I doing wrong?</p>
<javascript>
2019-04-19 00:32:33
LQ_CLOSE
55,755,889
Bufferoverflow, snprintf instead char resizes?
<p>I have a hard time to understand why the below code is not resulting in a bufferoverflow and instead some how seems to resize the char example from 1 to 16.</p> <p>I checked the snprintf documentation but nothing to be found about this.</p> <pre><code>//set char example size 1 char example[1]; //set example to args-&gt;arg2 which is a 15 character + 1 null byte. //trying to put something to big into something too small, in my mind causing not a resize but a bof. snprintf(example, 16, "%s", args-&gt;arg2); fprintf(stdout,"[%s],example); </code></pre> <p>The fprintf in the end does not display 1 character nor does char example overflows but instead it seems to be resized and displays the full string of 16.</p> <p>What am i misunderstanding here ?</p>
<c><printf><buffer-overflow>
2019-04-19 02:33:47
LQ_CLOSE
55,757,793
The target process exited without raising CoreCLR started event error with .NET Core 2.2
<p>I want to debug empty WebApi Project based on .NET Core 2.2.</p> <p>I installed <code>Core 2.2 SDK x86</code> and changed target framework to 2.2:</p> <pre><code>&lt;Project Sdk="Microsoft.NET.Sdk.Web"&gt; &lt;PropertyGroup&gt; &lt;TargetFramework&gt;netcoreapp2.2&lt;/TargetFramework&gt; &lt;/PropertyGroup&gt; </code></pre> <p>When i starting to debug this project, <code>IIS</code> starts, but in route <code>api/values</code> i see nothing (it loading forever) and i get this error:</p> <blockquote> <p>The target process exited without raising a CoreCLR started event.Ensure that the target process is configured to use .NET Core. This may be expected if the target process did not run on .NET Core</p> </blockquote> <p>In my solution <code>WPF</code> and <code>Class Library</code> projects exist. I wanted to make <code>WebApi</code> for it. Like i said, its empty base project genereted by <code>Visual Studio 2019</code>. I just installed <code>Core 2.2</code> why i get that error and what im doing wrong?</p> <p><a href="https://i.stack.imgur.com/gt8jT.png" rel="noreferrer"><img src="https://i.stack.imgur.com/gt8jT.png" alt="enter image description here"></a></p>
<c#><asp.net-core><asp.net-core-webapi><visual-studio-2019><.net-core-2.2>
2019-04-19 06:55:57
HQ
55,757,805
Add Xcode Developer Account from the Command Line
<p>I am trying to use <code>xcodebuild -allowProvisioningUpdates</code> on a machine that I only have access via the command line (Azure Devops macOS Hosted Machine).</p> <p>Unfortunately, according to <code>man xcodebuild</code> in order to use <code>-allowProvisioningUpdates</code> it seems that "Requires a developer account to have been added in Xcode's Accounts preference pane."</p> <p>Giving this, is there a way do add the account via the command line?</p> <p>Thank you, Cosmin</p>
<ios><command-line><provisioning-profile><xcodebuild>
2019-04-19 06:57:27
HQ
55,759,822
How to compare words in a string/python dictionary?
<p>I have a dictionary item in the form</p> <pre><code> {"value for money": ["rescheduled", "cost", "low", "high", "simplicity", "booking", "price-performance", "satisfied", "satisfaction", "pricing", "prices"]} </code></pre> <p>I need to check whether the a string like "I love simplicity" contains any word from this dictionary.</p> <p>Can't figure how to define the code for this.</p>
<python><string><dictionary>
2019-04-19 09:43:38
LQ_CLOSE
55,760,907
.Net Core warning No XML encryptor configured
<p>When I start my service (API on .Net Core 2.2 in Docker container) I've got a warning:</p> <blockquote> <p>No XML encryptor configured. Key {daa53741-8295-4c9b-ae9c-e69b003f16fa} may be persisted to storage in unencrypted form.</p> </blockquote> <p>I didn't configure DataProtection. I've found solutions to configure DataProtection but I don't need to save this key. For me if the key will only be persisted until the application restarts - it's Ok. But I don't need to see this warning in logs</p> <p>Any ideas? How can we do it?</p> <p>My startup Class looks like there:</p> <pre><code>public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } public void ConfigureServices(IServiceCollection services) { services.AddMemoryCache(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.AddApiVersioning(o =&gt; o.ApiVersionReader = new HeaderApiVersionReader("api-version")); } public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApplicationLifetime lifetime) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseMvc(); lifetime.ApplicationStarted.Register(OnApplicationStarted); lifetime.ApplicationStopping.Register(OnShutdown); } public void OnApplicationStarted() { Console.Out.WriteLine($"Open Api Started"); } public void OnShutdown() { Console.Out.WriteLine($"Open Api is shutting down."); } } </code></pre> <p><em>Maybe it's help too</em> my packages in the project</p> <pre><code>&lt;ItemGroup&gt; &lt;PackageReference Include="BouncyCastle.NetCore" Version="1.8.5" /&gt; &lt;PackageReference Include="Microsoft.AspNetCore.App" /&gt; &lt;PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="3.1.2" /&gt; &lt;PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" /&gt; &lt;PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.5.4" /&gt; &lt;PackageReference Include="Oracle.ManagedDataAccess.Core" Version="2.18.6" /&gt; &lt;/ItemGroup&gt; </code></pre>
<c#><.net-core><.net-core-2.2>
2019-04-19 11:07:53
HQ
55,760,997
Category and Sub category in one row in sql
How we can show category and sub category in one row in sql.Both columns are present in same table.If anyone knows please help. Thanks in advance!!!!!
<sql><sql-server>
2019-04-19 11:15:14
LQ_EDIT
55,761,829
Index match within range
At first it looked like a easy one, however I'm stuck on trying to find a way how to solve. The idea is to find C3 which matches C1 and falls in the given range C2. Basicaly B 40 shuold return -0.15. Any sugesstions ? [1]:https://imgur.com/a/9m1w1PZ "case"
<excel><vba>
2019-04-19 12:25:34
LQ_EDIT
55,763,428
React Native Error: ENOSPC: System limit for number of file watchers reached
<p>I have setup a new blank react native app.</p> <p>After installing few node modules I got this error. </p> <p><a href="https://i.stack.imgur.com/x4zCh.png" rel="noreferrer"><img src="https://i.stack.imgur.com/x4zCh.png" alt="enter image description here"></a></p> <p>I know it's related to no enough space for watchman to watch for all file changes.</p> <p>I want to know what's the best course of action to take here ? </p> <p>Should I ignore <code>node_modules</code> folder by adding it to <code>.watchmanconfig</code> ? </p>
<react-native><watchman>
2019-04-19 14:30:17
HQ
55,763,503
Warning: session_destroy(): Trying to destroy uninitialized session[session_start() used]
<p>i know my code is very beginner because i am just started php. so sorry at beginning</p> <p>I already read stack other questions and answers about</p> <p><strong>Warning: session_destroy(): Trying to destroy uninitialized session</strong></p> <p>all answers just mentioned that i need to use <strong><em>session_start()</em></strong> before using </p> <p><strong><em>session_destroy();</em></strong></p> <p>but they are not explaining why this warning occurs even i already used <strong><em>session_start()</em></strong> i am just trying to login then dashboard page appears where user can click on logout button to logout</p> <p>whole application is working fine only problem is when i click on logout button in dashboard.php it go to logout page and show warning which above mentioned</p> <p>login.php</p> <pre><code>&lt;?php session_start(); } ?&gt; &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Login Page&lt;/title&gt; &lt;link rel="stylesheet" type="text/css" href="style.css"&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="header"&gt; &lt;h1 align="center"&gt;Login&lt;/h1&gt; &lt;/div&gt; orm action="" method="post"&gt; &lt;table align="center"&gt; &lt;tr&gt; &lt;td align="right"&gt;&lt;input type="email" name="email" placeholder="Email" required&gt;&lt;/td&gt; &lt;td class="s1"&gt;*&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="right"&gt;&lt;input type="password" name="pass" placeholder="Password" pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,12}" title="Must contain at least one number and one uppercase and lowercase letter, and at least 8 or more characters" required&gt;&lt;/td&gt; &lt;td class="s1"&gt;*&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="right"&gt;&lt;input type="submit" value="Login"&gt;&lt;td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;p align="center"&gt;&lt;strong&gt;Or&lt;/strong&gt;&lt;/p&gt; &lt;p align="center"&gt;Create New acount &lt;strong&gt;&lt;input type="button" value="Sign Up" onclick="location.href='sign_up.php'"&gt;&lt;/strong&gt;&lt;/p&gt; &lt;br&gt; &lt;br&gt; &lt;br&gt; &lt;br&gt; &lt;br&gt; &lt;div class="footer"&gt; &lt;p&gt;&lt;span class="s1"&gt;*&lt;/span&gt; indicates mandatory feild&lt;p&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; &lt;?php require 'connection.php'; // connection if($_SERVER['REQUEST_METHOD'] === 'POST') { $email = $_POST['email']; $pass = $_POST['pass']; // getting username from database and storing into session variable /// $sql =mysqli_query($conn,"SELECT name FROM users WHERE email='$email'"); $sql1 = mysqli_fetch_assoc($sql); $user_name = $sql1['name']; // setting session variables $_SESSION['user_name']= $cookie_name; $_SESSION['timeout']=time(); // check email exists or not $query=mysqli_query($conn,"SELECT email FROM users WHERE email='$email'"); if(mysqli_num_rows($query) &gt; 0) { //check email and password correct or not $query1=mysqli_query($conn,"SELECT email, password FROM users WHERE email='$email' AND password='$pass'"); if(mysqli_num_rows($query1) &gt; 0) { // login success header("location:dashboard.php"); // ----&gt; alternative way to redirect to dashboard.php /*echo "&lt;script type='text/javascript'&gt; window.location.href = 'dashboard.php' &lt;/script&gt;";*/ } else { // incorrect password echo "&lt;p align='center' style='color:#ff6262'&gt;your password is incorrect!&lt;br&gt;Please try again&lt;/p&gt;"; } } else { // email not exist echo "&lt;p align='center' style='color:#ff6262'&gt;&lt;b&gt;Email you are entering does not exist in our database&lt;br&gt;&lt;/b&gt;&lt;/p&gt;"; } } ?&gt; </code></pre> <p>dashboard.php</p> <pre><code>&lt;?php session_start(); ?&gt; &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt; &lt;?php require 'connection.php'; echo $_SESSION['user_name']; ?&gt; &lt;/title&gt; &lt;link rel="stylesheet" type="text/css" href="style.css"&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="header"&gt; &lt;h1 align="center"&gt;&lt;?php echo "Welcome: ".ucfirst($_SESSION['user_name']); ?&gt;&lt;/h1&gt; &lt;/div&gt; &lt;table&gt; &lt;tr&gt; &lt;td align="right"&gt;Change User Name:&lt;/td&gt;&lt;td&gt;&lt;input type="button" onclick="location.href='user.php'" value="click here"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td align="right"&gt;Change Password:&lt;/td&gt;&lt;td&gt;&lt;input type="button" onclick="location.href='pass.php'" value="click here"&gt;&lt;/td&gt; &lt;/tr colspan="2"&gt; &lt;tr&gt;&lt;td align="right"&gt;&lt;input type="button" value="Logout" onclick="location.href='logout.php'"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; &lt;/body&gt; &lt;/html&gt; &lt;?php if (isset($_SESSION['timeout']) &amp;&amp; (time() - $_SESSION['timeout'] &gt; 60)) { session_unset(); // unset $_SESSION variable for the run-time session_destroy(); // destroy session data in storage header("location:logout.php"); } $_SESSION['timeout'] = time(); ?&gt; </code></pre> <p>logout.php</p> <pre><code>&lt;?php session_start(); ?&gt; &lt;?php session_unset(); if(!session_unset()) { echo "session not unset"; } else { echo "session unset"; } session_destroy(); if(!session_destroy()) { echo "session not destroyed"; } else { echo "session destroyed"; } //header(location:login.php); ?&gt; </code></pre> <p>some other suggest me to use cookies but i don't know how to relate cookies with session anyone who can help.</p>
<php><html><mysql>
2019-04-19 14:35:56
LQ_CLOSE
55,765,225
I want to get all the group(key) in my spinner then after that school no(key) into another spinner from firebase database
I'm a beginner & currently in a learning phase, please help me with this problem This post might look like a duplicate to you but it's none of the previous questions had this much keys. I want to get all the `group no 1` in my spinner then after that all the `school no` of group no 1 into another spinner from firebase database Here's my database [![enter image description here][1]][1] here's my code >java public class Collection extends AppCompatActivity { TextView ttl, tgat, tsch; Button btnshw, btngt; Spinner sping; DatabaseReference d2ref; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_collection); tgat = (TextView) findViewById(R.id.texigat); tsch = (TextView) findViewById(R.id.texisch); //tcls = (TextView) findViewById(R.id.texiclass); ttl = (TextView) findViewById(R.id.texirs); btnshw = (Button) findViewById(R.id.bshow); btngt = (Button) findViewById(R.id.bgat); sping = (Spinner) findViewById(R.id.spingat); btnshw.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { d2ref = FirebaseDatabase.getInstance().getReference().child("2018-19").child("Gat No 14") .child("School no 109").child("Standard 2nd"); d2ref.addValueEventListener(new ValueEventListener() { @Override public void onDataChange(@NonNull DataSnapshot dataSnapshot) { String rs = dataSnapshot.child("Rupees").getValue().toString(); ttl.setText(rs); } @Override public void onCancelled(@NonNull DatabaseError databaseError) { } }); } }); btngt.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { d2ref = FirebaseDatabase.getInstance().getReference().child("2018-19"); ValueEventListener eventListener = new ValueEventListener() { @Override public void onDataChange(@NonNull DataSnapshot dataSnapshot) { final List<String> gatno = new ArrayList<String>(); for (DataSnapshot dsnap : dataSnapshot.child("Gat No 14").getChildren()) { String gat = dsnap.getKey(); gatno.add(gat); } ArrayAdapter<String> adapter = new ArrayAdapter<String>(Collection.this, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); sping.setAdapter(adapter); /*I wasn't able to get the value in 1st spinner so I didn't wrote program for second spinner*/ } @Override public void onCancelled(@NonNull DatabaseError databaseError) { } }; d2ref.addListenerForSingleValueEvent(eventListener); } }); } } Please help me with this. [1]: https://i.stack.imgur.com/kFb7u.png
<android><firebase-realtime-database><android-spinner>
2019-04-19 16:59:26
LQ_EDIT
55,765,762
Why is a tuple of falsey objects truthy?
<p>Came across this in a recent project and was curious as to why this is the case.</p> <pre><code>test_ = None test_1 = [] test_2 = ([], None) if test_: print('hello') if test_1: print('hello') if test_2: print('hello') &gt; hello </code></pre>
<python><python-3.x>
2019-04-19 17:47:37
LQ_CLOSE