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
35,735,454
MySQL JSON_EXTRACT path expression error
<p>The syntax looks right to me, any help would be appreciated!</p> <pre><code>mysql&gt; select fieldnames from tablename limit 5; +--------------------------------------------------------+ | fieldnames | +--------------------------------------------------------+ | {"example-field-1": "val2"} | | {"example-field-2": "val1"} | | {"example-field-1": "val1", "example-field-3": "val1"} | | {"example-field-2": "val1"} | | {"example-field-2": "val2"} | +--------------------------------------------------------+ mysql&gt; select JSON_EXTRACT(fieldnames, '$.example-field-1') from tablename; ERROR 3143 (42000): Invalid JSON path expression. The error is around character position 17 in '$.example-field-1'. </code></pre> <p>MySQL 5.7.10</p>
<mysql><json>
2016-03-01 23:09:54
HQ
35,736,113
What is the appropriate machine learning algorithm for a restaurant's sales prediction?
<p>I want to estimate the sales of a restaurant three days in advance, so that the staff can order fresh ingredients in time. I started off using linear regression, but noticed the following: For the restaurant it is worse, if a customer won't get the food he ordered, compared to the case that food that is eventually thrown away. I figured I might just need a skewed cost function, but I am not sure. Maybe there is something already implemented. </p> <p>Another question: Some days, there are some reservations (pre-orders) for the restaurant, so I know they will need at least a certain amount. How to include that?</p> <p>Thank you!</p>
<python><r><machine-learning><scikit-learn>
2016-03-02 00:10:00
LQ_CLOSE
35,738,040
'str'object has not attribute 'subs'
Here is my python code written in vim editor;whenever i run it via command prompt i get the error 'str'object has not attribute 'subs' from sympy import * x,a_test,b_test,fa_test,fb_test=symbols('x a_test b_test fa_test fb_test') expr=raw_input("enter the equation") print expr print "hello" try: print "hello" inc=0 a=inc fa=expr.subs(x,inc) print "hello" if(fa<0): print "hello" inc+=1 fb=expr.subs(x,inc) if(fb<=0): while(fb<=0): inc+=1 else: print "hello" inc+=1 fb=expr.subs(x,inc) if(fb<=0): while(fb<=0): inc+=1 b=inc print a print b print fa print fb except Exception,e: print e
<python><sympy>
2016-03-02 03:36:58
LQ_EDIT
35,738,251
How I can Check if numbers are in a specific range
I'm beginner:( How I can Check if numbers are in a specific range ? for example I have to find an number between 0 to 500 int k = 200; if (k<=0 && k>500){ if (k<=0 && k>249){
<java><range>
2016-03-02 03:58:12
LQ_EDIT
35,738,415
How do i keep the header cell moving with the tableview cells in Swift 2.0
<p>I am trying to create a tableview which starts the header in the middle of the tableview and then can be scrolled up with the added tableView Cells to the top then stops, and then the tableview cells can just scroll "under" it. I got the header to be in the middle of the tableview, but the tableView Cells just scroll on top of it, and the header doesnt really scroll to the top. it just stay where it is. I want to be able to let the header move as you scroll the list, and then stops when it reaches the top of the list, and then its just the tableView Cells that are moving afterwards.</p> <p>I am using the latest version of XCode</p>
<ios><xcode><swift><uitableview>
2016-03-02 04:18:03
HQ
35,738,680
Avoiding "warning: There are too many unreachable loose objects" during git svn clone/fetch
<p>When running a <code>git svn clone</code> or <code>git svn fetch</code> against a large Subversion repository (100k+ commits), the fetch regularly stops with:</p> <pre><code>Auto packing the repository in background for optimum performance. See "git help gc" for manual housekeeping. error: The last gc run reported the following. Please correct the root cause and remove .git/gc.log. Automatic cleanup will not be performed until the file is removed. warning: There are too many unreachable loose objects; run 'git prune' to remove them. gc --auto: command returned error: 255 </code></pre> <p>In order to recover I have to follow the instructions, run a more aggressive prune and gc, remove the log-file and continue, only to have it happen again after another batch of say 10k commits are read.</p> <p>How can this problem be avoided?</p>
<git><git-svn>
2016-03-02 04:43:23
HQ
35,738,795
Android : Window Manager : android view window leaked
<p>Right after I fix my first problem this one comes up :( please help me fix it..</p> <blockquote> <p>03-02 12:47:02.785 9439-9439/com.ucu.ccs.classrecord E/WindowManager﹕ android.view.WindowLeaked: Activity com.ucu.ccs.classrecord.Login has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{6d17cc4 V.E..... R......D 0,0-1002,348} that was originally added here at android.view.ViewRootImpl.(ViewRootImpl.java:465) at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:277) at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69) at android.app.Dialog.show(Dialog.java:312) at com.ucu.ccs.classrecord.Login$AttemptLogin.onPreExecute(Login.java:158) at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:587) at android.os.AsyncTask.execute(AsyncTask.java:535) at com.ucu.ccs.classrecord.Login.isOnline(Login.java:113) at com.ucu.ccs.classrecord.Login$1.onClick(Login.java:73) at android.view.View.performClick(View.java:5197) at android.view.View$PerformClick.run(View.java:20926) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:5942) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)</p> </blockquote> <p>here is my code:</p> <pre><code>buttonLogin.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String instructor_id = editUser.getText().toString().trim(); String password = editPass.getText().toString().trim(); SharedPreferences preferences = getSharedPreferences("MyApp", MODE_PRIVATE); preferences.edit().putString("password", password).commit(); preferences.edit().putString("inst_id", instructor_id).commit(); if (editUser.getText().toString().equals("") || editPass.getText().toString().equals("")){ Toast.makeText(getApplicationContext(),"Please enter Instructor ID and Password", Toast.LENGTH_LONG).show(); }else { isOnline(); } } }); public boolean isOnline(){ ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); if (networkInfo != null &amp;&amp; networkInfo.isConnectedOrConnecting()){ new AttemptLogin().execute(); }else { checkInternet(); } return false; } class AttemptLogin extends AsyncTask&lt;String, String, String&gt; { boolean failure = false; String inst_id = editUser.getText().toString(); String password = editPass.getText().toString(); @Override protected void onPreExecute() { super.onPreExecute(); pDialog = new ProgressDialog(Login.this); pDialog.setMessage("Attempting login..."); pDialog.setIndeterminate(false); pDialog.setCancelable(true); pDialog.show(); } @Override protected String doInBackground(String... params) { int success; try{ List&lt;NameValuePair&gt; mList = new ArrayList&lt;NameValuePair&gt;(); mList.add(new BasicNameValuePair("instructor_id", inst_id)); mList.add(new BasicNameValuePair("password", password)); Log.d("request!", "starting"); JSONObject json = jsonParser.makeHttpRequest(LOGIN_URL, "POST", mList); Log.d("Login attempt", json.toString()); success = json.getInt(TAG_SUCCESS); if (success == 1) { Log.d("Login Successful!", json.toString()); Intent i = new Intent(Login.this, MainActivity.class); startActivity(i); //finish(); return json.getString(TAG_MESSAGE); }else{ Log.d("Login Failure!", json.getString(TAG_MESSAGE)); return json.getString(TAG_MESSAGE); } }catch (JSONException e){ e.printStackTrace(); } return null; } @Override protected void onPostExecute(String s) { super.onPostExecute(s); session.setLogin(true); pDialog.dismiss(); if (s != null){ Toast.makeText(getApplicationContext(), s, Toast.LENGTH_SHORT).show(); } } } </code></pre>
<android>
2016-03-02 04:53:57
HQ
35,739,103
Using IF in BigQuery SQL
<p><strong>Case</strong>: I have Sales table in BQ and item_num column contains values 1, -1 and 0. I want to count how many cases I have for each value.</p> <p>Tried a simple query below, but count returns exactly the same number for each case.. What I am missing?</p> <pre><code>SELECT count(if(item_num &gt; 0,1, 0)) as buysplus, count(if(item_num &lt; 0,1, 0)) as buysminus, count(if(item_num = 0,1, 0)) as buyszero from MyShop.Sales </code></pre> <p>thanks</p>
<google-bigquery>
2016-03-02 05:22:03
HQ
35,739,361
ITSAppUsesNonExemptEncryption export compliance while internal testing?
<p>I got this message while selecting build for internal testing.it says about setting <strong>ITSAppUsesNonExemptEncryption</strong> in info.plist what does it mean? is it necessary?</p> <p><a href="https://i.stack.imgur.com/M0QBP.png"><img src="https://i.stack.imgur.com/M0QBP.png" alt="enter image description here"></a></p>
<ios><objective-c><app-store-connect>
2016-03-02 05:42:06
HQ
35,739,889
Is Configuration interface in hibernate ?
When i am searching for core interfaces in Hibernate i found that Configuration as a interface. If it is an interface how can we create object for that directly like below. Configuration cfg = new Configuration().configure();
<java><hibernate>
2016-03-02 06:20:17
LQ_EDIT
35,740,077
Given a matrix, how do I determine whether the entries of the matrix are Independent and Identically Distributed (IID)?
<p>The matrix was not generated with a <code>rand</code> function; rather, it was obtained by collecting data from a server. I want to know if there is a method to check if any given matrix, A, has IID entries or not.</p>
<matlab><matrix>
2016-03-02 06:32:33
LQ_CLOSE
35,740,223
What is the output of this python code?
So the code is: X = range(4, 7) Y = range(2) X[2] = Y print X[2][0] print X[2][1] X[2][0] = 9 print Y[0] And the output is 0 1 9 What exactly is the code doing to get that output? Also if the code looked like X = range(4, 7) print X[-1] Then what would the output be because I'm confused about what negative values do.
<python><list><range>
2016-03-02 06:40:48
LQ_EDIT
35,740,773
Error 'Implicit string cast with potential data loss from 'string' to 'AnsiString' in Delphi XE2'
How can I remove this error? String1:= inttoStr(instance.CurrentSpeed); UDPSocket1.Sendln(String1);
<delphi><delphi-xe2>
2016-03-02 07:16:50
LQ_EDIT
35,741,163
How to add an image in an SQL database?
I'm currently working in Microsoft Visual studio and I am doing a project for school where I have to make an app that lets you book seats at a cinema and see the description of the movie you have selected as well as leave/read a review. In my app I have decided that I want to include pictures (basically a poster for each of the movies); I have made my "Movies" table and have "idf" as my primary key. I have added a "poster" column in my table definition and I have set its type to image; my question is, how do I assign a certain image to a movie, so as to have access to it and to be able to display it later using a query of some sort?
<c#><sql-server><database><image>
2016-03-02 07:40:10
LQ_EDIT
35,741,439
Can Android Studio use OpenJDK or does it require Oracle JDK on Linux?
<p>Can Android Studio use OpenJDK 1.8 or does it require Oracle JDK on Linux? It would be easier to use OpenJDK because it comes installed on Fedora.</p> <p>I'm running 64 bit Fedora-23 linux with Android Studio 1.5.1.build AI-141.2456560 on an Intel Haswell i7 chip.</p> <pre><code>$ java -version openjdk version "1.8.0_72" OpenJDK Runtime Environment (build 1.8.0_72-b15) OpenJDK 64-Bit Server VM (build 25.72-b15, mixed mode) $ ./java -version java version "1.8.0_73" Java(TM) SE Runtime Environment (build 1.8.0_73-b02) Java HotSpot(TM) 64-Bit Server VM (build 25.73-b02, mixed mode) $ uname -a Linux localhost.localdomain 4.3.5-300.fc23.x86_64 #1 SMP Mon Feb 1 03:18:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux $ more build.txt AI-141.2456560 </code></pre>
<android><linux><oracle><android-studio><openjdk>
2016-03-02 07:57:02
HQ
35,741,559
hello.sorry i cant assign char "X" in part of String?can you help me?
i cant assign a specific char like "X" in part of my input string. for example i want to assign a default char with substring method in specific range of my input string. how can i assign a specific char in specific range of my input string can you help me? thx
<java><string>
2016-03-02 08:04:00
LQ_EDIT
35,741,722
What's the substitute for ::shadow and /deep/?
<p>The two shadow-piercing combinators have been deprecated as stated in <a href="https://www.chromestatus.com/features/6750456638341120" rel="noreferrer">https://www.chromestatus.com/features/6750456638341120</a><br>Then what's the substitude for achieving the same thing, or this shadow-piercing feature has been completely abandoned?</p>
<web><web-component><shadow-dom>
2016-03-02 08:15:21
HQ
35,741,821
String in to list Python
<p>I have a string, something like:</p> <pre><code>a = "[1, 2, 3]" </code></pre> <p>If there an easy way to convert it in to a list, without using .split(), join() etc.</p> <p>Thanks for any replies.</p>
<python><string><list><python-3.x>
2016-03-02 08:21:08
LQ_CLOSE
35,742,640
Calling sequential on parallel stream makes all previous operations sequential
<p>I've got a significant set of data, and want to call slow, but clean method and than call fast method with side effects on result of the first one. I'm not interested in intermediate results, so i would like not to collect them.</p> <p>Obvious solution is to create parallel stream, make slow call , make stream sequential again, and make fast call. The problem is, ALL code executing in single thread, there is no actual parallelism.</p> <p>Example code:</p> <pre><code>@Test public void testParallelStream() throws ExecutionException, InterruptedException { ForkJoinPool forkJoinPool = new ForkJoinPool(Runtime.getRuntime().availableProcessors() * 2); Set&lt;String&gt; threads = forkJoinPool.submit(()-&gt; new Random().ints(100).boxed() .parallel() .map(this::slowOperation) .sequential() .map(Function.identity())//some fast operation, but must be in single thread .collect(Collectors.toSet()) ).get(); System.out.println(threads); Assert.assertEquals(Runtime.getRuntime().availableProcessors() * 2, threads.size()); } private String slowOperation(int value) { try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } return Thread.currentThread().getName(); } </code></pre> <p>If I remove <code>sequential</code>, code executing as expected, but, obviously, non-parallel operation would be call in multiple threads.</p> <p>Could you recommend some references about such behavior, or maybe some way to avoid temporary collections?</p>
<java><multithreading><java-stream><forkjoinpool>
2016-03-02 09:05:10
HQ
35,742,775
Is it possible to post files to Slack using the incoming Webhook?
<p>I am trying out the Slack's API using the incoming webhook feature, posting messages works flawlessly, but it doesn't seem to allow any file attachments.</p> <p>Looking through I understand I have to use a completely different OAuth based API, but creating more tokens just for the purpose of uploading a file seems odd when posting messages works well, is there no way to upload files to slack with the incoming webook?</p>
<api><slack-api><slack>
2016-03-02 09:11:16
HQ
35,743,376
Cannot find namespace error
<p>I have the following setup:</p> <pre><code>// enums.ts export enum DocumentType { Email = 0, Unknown = 1 } </code></pre> <p>-</p> <pre><code>// remote.ts /// &lt;reference path="./remote.d.ts" /&gt; import enums = require('./enums'); class Remote implements test.IRemote { public docType: enums.DocumentType; constructor() { this.docType = enums.DocumentType.Unknown; } } export = Remote; </code></pre> <p>-</p> <pre><code>// remote.d.ts import * as enums from './enums'; declare module test { export interface IRemote { docType: enums.DocumentType; } } </code></pre> <p>But when I run tsc over this I get <code>Cannot find namespace 'test'</code> from remotes.ts. What am I missing?</p> <p>Other information that might be useful: I've recently upgraded from Typescript 1.5 to Typescript 1.8 and replaced the use of const enums with plain enums as in the example. </p>
<typescript>
2016-03-02 09:39:14
HQ
35,743,426
async constructor functions in TypeScript?
<p>I have some setup I want during a constructor, but it seems that is not allowed</p> <p><a href="https://i.stack.imgur.com/xUSOH.png" rel="noreferrer"><img src="https://i.stack.imgur.com/xUSOH.png" alt="no async const"></a></p> <p>Which means I can't use:</p> <p><a href="https://i.stack.imgur.com/IIlGJ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/IIlGJ.png" alt="await"></a></p> <p>How else should I do this?</p> <p>Currently I have something outside like this, but this is not guaranteed to run in the order I want?</p> <pre><code>async function run() { let topic; debug("new TopicsModel"); try { topic = new TopicsModel(); } catch (err) { debug("err", err); } await topic.setup(); </code></pre>
<constructor><typescript><async-await>
2016-03-02 09:41:30
HQ
35,743,905
pd.read_excel throws PermissionError if file is open in Excel
<p>Whenever I have the file open in Excel and run the code, I get the following error which is surprising because I thought read_excel should be a read only operation and would not require the file to be unlocked?</p> <pre><code> Traceback (most recent call last): File "C:\Users\Public\a.py", line 53, in &lt;module&gt; main() File "C:\Users\Public\workspace\a.py", line 47, in main blend = plStream(rootDir); File "C:\Users\Public\workspace\a.py", line 20, in plStream df = pd.read_excel(fPath, sheetname="linear strategy", index_col="date", parse_dates=True) File "C:\Users\Public\Continuum\Anaconda35\lib\site-packages\pandas\io\excel.py", line 163, in read_excel io = ExcelFile(io, engine=engine) File "C:\Users\Public\Continuum\Anaconda35\lib\site-packages\pandas\io\excel.py", line 206, in __init__ self.book = xlrd.open_workbook(io) File "C:\Users\Public\Continuum\Anaconda35\lib\site-packages\xlrd\__init__.py", line 394, in open_workbook f = open(filename, "rb") PermissionError: [Errno 13] Permission denied: '&lt;Path to File&gt;' </code></pre>
<python><excel><pandas>
2016-03-02 10:01:26
HQ
35,744,529
Protocol Buffer Error on compile during GOOGLE_PROTOBUF_MIN_PROTOC_VERSION check
<p>I'm currently getting an error which points me to these lines in the header file produced by protoc:</p> <pre><code>#if 2006001 &lt; GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. #endif </code></pre> <p>But my protoc version matches the one above:</p> <pre><code>protoc --version libprotoc 2.6.1 </code></pre> <p>What am I doing wrong?</p> <p>Originally my protoc version was 3.0.0 then reinstalled it by syncing back to 2.6.1 and doing the steps; make distclean, ./configure , make, make install to install the desired 2.6.1 version. I needed the older version since that's the one installed in our servers.</p>
<c++><protocol-buffers><protoc>
2016-03-02 10:28:11
HQ
35,745,481
Redis-cli with password
<p>I am using redis and trying to open CLI of redis using this:</p> <pre><code>$redis-cli -h 127.0.0.1 -p 6379 -a mysupersecretpassword </code></pre> <p>and getting and error :</p> <blockquote> <p>(error) NOAUTH Authentication required</p> </blockquote> <p>why so ?</p>
<redis>
2016-03-02 11:08:40
HQ
35,745,543
New option in GCC 5.3: -fno-semantic-interposition
<p>GCC 5.3 has added a new option: <code>-fno-semantic-interposition</code></p> <blockquote> <p>A new -fno-semantic-interposition option can be used to improve code quality of shared libraries where interposition of exported symbols is not allowed.</p> </blockquote> <p>This sounds like this is something useful for C++ projects where interposition can't be used for whatever reason, but where latency is a concern.</p> <p>However, the description is fairly vague. Is anyone able to clarify how this option works exactly?</p>
<c++><gcc><gcc5>
2016-03-02 11:11:20
HQ
35,746,371
Error Duplicate Const Declaration in Switch Case Statement
<p>I have the following code and I get the error 'Duplicate Declaration query_url'.</p> <pre><code> switch(condition) { case 'complex': const query_url = `something`; break; default: const query_url = `something`; break; } </code></pre> <p>I understand that query_url is getting declared twice which isn't right. But i don't know how to resolve this. Can someone please help on what should be the correct way to make this work?</p>
<javascript><ecmascript-6>
2016-03-02 11:48:42
HQ
35,746,695
How can I remove iPad support from AppStore
<p>How I can upload new version into AppStore without iPad support.</p> <p><a href="https://i.stack.imgur.com/PispF.png" rel="noreferrer"><img src="https://i.stack.imgur.com/PispF.png" alt="enter image description here"></a></p>
<ios><iphone><xcode><ipad><app-store>
2016-03-02 12:03:52
HQ
35,746,806
How to get indices of non-diagonal elements of a numpy array?
<p>How to get indices of non-diagonal elements of a numpy array?</p> <pre><code>a = np.array([[7412, 33, 2], [2, 7304, 83], [3, 101, 7237]]) </code></pre> <p>I tried as follows:</p> <pre><code>diag_indices = np.diag_indices_from(a) print diag_indices (array([0, 1, 2], dtype=int64), array([0, 1, 2], dtype=int64)) </code></pre> <p>After that, no idea... The expected result should be:</p> <pre><code>result = [[False, True, True], [True, False, True], [True, True, False]] </code></pre>
<python><numpy>
2016-03-02 12:07:32
HQ
35,746,843
Yii2 loading Jquery in the head of the page
<p>In my Yii2 application i've a script that need Jquery to be loaded in the head of the page.</p> <p>I know there's a parameter that can be setted inside AppAssets.php :</p> <pre><code>public $jsOptions = [ 'position' =&gt; \yii\web\View::POS_HEAD ]; </code></pre> <p>but this will render all the Javascripts Files on the head of the page. Is possibile to load only Jquery on the head?</p> <p>Thanks in advance for all the help</p>
<javascript><jquery><yii2>
2016-03-02 12:09:15
HQ
35,747,476
In Pandas, whats the equivalent of 'nrows' from read_csv() to be used in read_excel()?
<p>Want to import only certain range of data from an excel spreadsheet (.xlsm format as it has macros) into a pandas dataframe. Was doing it this way:</p> <pre><code>data = pd.read_excel(filepath, header=0, skiprows=4, nrows= 20, parse_cols = "A:D") </code></pre> <p>But it seems that nrows works only with read_csv() ? What would be the equivalent for read_excel()?</p>
<python><pandas>
2016-03-02 12:38:10
HQ
35,747,790
why target is not working here
first i make index page containing frame and i name the all frame as nasa google you tube etc . then on search page <input id="main_category_lan1" value="test" /> <a href="javascript: void(0)" onmouseover="window.open('http://nasasearch.nasa.gov/search?utf8=%E2%9C%93&affiliate=nasa&query='+document.getElementById('main_category_lan1').value)",target="nasa" >s</a> <a href="javascript: void(0)" onmouseover="window.open('https://www.youtube.com/results?search_query=lecture '+document.getElementById('main_category_lan1').value)",target="google" >e</a> but this is not working ,every time it open in new tab ,also i want to open both the pages bye a single button . what should i do ? thank you
<javascript><html>
2016-03-02 12:52:20
LQ_EDIT
35,748,099
Passing an arraylist of object from servlet to jsp failed
<p>this things is giving me headache for the past 3 days already. I tried to store the resultset that i get from the database and store inside an arraylist of object then pass it to the jsp for display, but after running the program, it gave me this error: <a href="http://i.stack.imgur.com/c2hI6.png" rel="nofollow">enter image description here</a></p> <p>anyone have any idea how to solve this problem? Thanks in advance! below is my code: menu.java</p> <pre><code>@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); try { Class.forName("com.mysql.jdbc.Driver"); //Create connection object conn = DriverManager.getConnection(request.getServletContext().getInitParameter("url"), request.getServletContext().getInitParameter("username"), request.getServletContext().getInitParameter("password")); String sql = "select name,price,imageurl from food"; stmt = conn.createStatement(); rs = stmt.executeQuery(sql); class food { String name; double price; String imageurl; } ArrayList&lt;food&gt; foodDetail = new ArrayList&lt;food&gt;(); while (rs.next()) { food temp = new food(); temp.name = rs.getString("name"); temp.price = rs.getDouble("price"); temp.imageurl = rs.getString("imageurl"); foodDetail.add(temp); } request.setAttribute("menu", foodDetail); RequestDispatcher req = request.getRequestDispatcher("menu.jsp"); req.forward(request, response); } catch (ClassNotFoundException ex) { Logger.getLogger(Menu.class.getName()).log(Level.SEVERE, null, ex); } catch (SQLException ex) { Logger.getLogger(Menu.class.getName()).log(Level.SEVERE, null, ex); } finally { try { rs.close(); stmt.close(); conn.close(); } catch (SQLException ex) { } } </code></pre> <p>menu.jsp</p> <pre><code>&lt;% class food { String name; double price; String imageurl; } ArrayList&lt;food&gt; foodDetail = (ArrayList&lt;food&gt;) request.getAttribute("menu"); food temp = new food(); java.util.Iterator it = foodDetail.iterator(); while (it.hasNext()) { food z = (food) it.next(); out.println(z.getName()); } %&gt; </code></pre>
<java><jsp><servlets>
2016-03-02 13:06:49
LQ_CLOSE
35,748,162
How to get the text of the selected option using vuejs?
<p>I want to get the text of a selected option input and display it somewhere else. I know how to do it using jQuery but I want to know how can we do it using Vuejs.</p> <p>Here is how we do in jQuery. I mean the text of Selected Option not the value.</p> <pre><code>var mytext = $("#customerName option:selected").text(); </code></pre> <p>Here is my HTML</p> <pre><code> &lt;select name="customerName" id=""&gt; &lt;option value="1"&gt;Jan&lt;/option&gt; &lt;option value="2"&gt;Doe&lt;/option&gt; &lt;option value="3"&gt;Khan&lt;/option&gt; &lt;/select&gt; {{customerName}} </code></pre> <p>Now how can I display the selected option under it. like Jan, Doe, Khan ?</p>
<javascript><vue.js>
2016-03-02 13:10:11
HQ
35,748,906
JvmOverloads annotation for class primary constructor
<p>Why is it prohibited to autogenerate many constructors visible to Java from class primary constructor with default params likes this?</p> <pre><code>@JvmOverloads class Video(private val id: Long, val ownerId: Long, var title: String? = null, var imgLink: String? = null, var videoLink: String? = null, var description: String? = null, var created: Date? = null, var accessKey: String? = null, var duration: Long? = null, var views: Long? = null, var comments: Long? = null) : Entity </code></pre> <blockquote> <p>This annotation is not applicable to target 'class'</p> </blockquote>
<constructor><annotations><kotlin>
2016-03-02 13:41:57
HQ
35,748,933
Error ITMS-90206 Invalid bundle contains disallowed file 'Frameworks'
<p>I have a problem uploading my application into the Store via Xcode, this one in particular.</p> <p><a href="https://i.stack.imgur.com/g1hln.png" rel="noreferrer"><img src="https://i.stack.imgur.com/g1hln.png" alt="Invalid Bundle contains disallowed file frameworks"></a></p> <p>I saw a lot of post about this error, but all are talking about <code>Extension App</code>, that I do not use.</p> <p>I'm using a <code>Custom framework</code> and <code>Cocoapods</code>.</p> <p>You can see here my tree :</p> <p><a href="https://i.stack.imgur.com/mXagh.png" rel="noreferrer"><img src="https://i.stack.imgur.com/mXagh.png" alt="Tree Xcode Project Custom Framework"></a></p> <ul> <li><strong>XXX</strong> is my project app name</li> <li><strong>SharedXXX</strong> is my <code>custom framework</code></li> <li><strong>Pods</strong> is the project created by <code>cocoa pods</code></li> </ul> <p>Here is my cocoa <code>podFile</code> :</p> <pre><code>use_frameworks! link_with 'XXX', 'SharedXXX' source 'https://github.com/CocoaPods/Specs.git' platform :ios, '8.1' workspace 'XXX' xcodeproj 'XXX/XXX.xcodeproj' xcodeproj 'Shared/SharedXXX.xcodeproj' def default_pods pod 'Reveal-iOS-SDK', :configurations =&gt; ['Debug'] pod "SnapKit", '~&gt; 0.17.0' pod "DKChainableAnimationKit", '~&gt; 1.6.0' pod "AsyncSwift" end def shared_pods pod "Alamofire", '~&gt; 3.0' pod 'SwiftyJSON', :git =&gt; 'https://github.com/SwiftyJSON/SwiftyJSON.git' pod 'ReachabilitySwift', :git =&gt; 'https://github.com/ashleymills/Reachability.swift' end target :XXX do xcodeproj 'XXX/XXX.xcodeproj' default_pods shared_pods end target :XXXDev do xcodeproj 'XXX/XXX.xcodeproj' default_pods shared_pods end target :SharedXXX do xcodeproj 'Shared/SharedXXXX.xcodeproj' shared_pods end </code></pre> <p>Build settings for <code>custom framework</code> (<strong>SharedXXX</strong>) :</p> <p><a href="https://i.stack.imgur.com/XE6Wl.png" rel="noreferrer"><img src="https://i.stack.imgur.com/XE6Wl.png" alt="Custom Framework build settings"></a></p> <p>I set the Embedded property to <code>Yes</code></p> <p>General Settings for <code>custom framework</code> (<strong>SharedXXX</strong>) :</p> <p><a href="https://i.stack.imgur.com/Yk639.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Yk639.png" alt="Custom Framework General Settings"></a></p> <p>The framework provided by Cocoapods is linked.</p> <p>And to finish,</p> <p>The General Settings to the main project (App Project : called <strong>XXX</strong> on the tree)</p> <p><a href="https://i.stack.imgur.com/J7oGg.png" rel="noreferrer"><img src="https://i.stack.imgur.com/J7oGg.png" alt="Main project"></a>:</p> <p>Any idea ?</p>
<ios><xcode><cocoapods><ios-frameworks><swift-custom-framework>
2016-03-02 13:43:15
HQ
35,749,288
separate file for routes in express
<p>I was wondering how do I move all of my api routes in express into a separate <code>routes.js</code> file from my <code>server.js</code> file</p> <p>I have a long list of api routes using <code>app.use()</code> for each route. So each route is in its own file, e.g. <code>movies.js</code>, <code>movie.js</code> but when I list these it makes for a long list in <code>server.js</code></p> <p>So I want to remove the list of api endpoints section from the below <code>server.js</code> out to a <code>routes.js</code> file. </p> <p>Here is what I have currently:</p> <p><strong>server.js</strong></p> <pre><code>import path from 'path' import express from 'express' import webpack from 'webpack' import webpackDevMiddleware from 'webpack-dev-middleware' import webpackConfig from './webpack.config.dev' const app = express(); /* api endpoints, can be many more, I want them in routes.js */ app.use('/api/movies', require('./src/api/routes/movies')) app.use('/api/movie', require('./src/api/routes/movie')) app.use(webpackDevMiddleware(webpack(webpackConfig), { publicPath: webpackConfig.output.publicPath })); app.use('/public', express.static(__dirname + '/public')) app.get('*', function(req, res) { res.sendFile(path.join(__dirname, 'index.html')); }); app.listen(3000, 'localhost', function (err) { if (err) { console.log(err); return; } }) </code></pre> <p>An example route </p> <p><strong>movies.js</strong></p> <pre><code>var express = require('express'); var request = require("request"); var router = express.Router(); router.get('/', function(req, res) { res.json({}) }); module.exports = router; </code></pre>
<node.js><express>
2016-03-02 13:59:07
HQ
35,749,571
regular express quetion - what's wrong with my expression?
i have a difficult by build a regex. Suppose there is a html clip as under. I want to use Javascript to cut the <tbody> part with the link of "apple"(which <a> is inside of the <td class="by">) I make the expression : /<tbody.*?text[\s\S]*?<td class="by"[\s\S]*?<a.*?>apple<\/a>[\s\S]*?<\/tbody>/g But the result is different as i wanted. Each match contains more than one block of <tbody>. How it should be? Regards!!!! <tbody id="text_0"> <td class="by"> <a href="xxx">cat</a> </td> </tbody> <tbody id="text_1"> <td class="by"> <a href="xxx">apple</a> </td> </tbody> <tbody id="text_2"> <td class="by"> <a href="xxx">cat</a> </td> </tbody> <tbody id="text_3"> <td class="by"> <a href="xxx">tiger</a> </td> </tbody> <tbody id="text_4"> <td class="by"> <a href="xxx">banana</a> </td> </tbody> <tbody id="text_5"> <td class="by"> <a href="xxx">peach</a> </td> </tbody> <tbody id="text_6"> <td class="by"> <a href="xxx">apple</a> </td> </tbody> <tbody id="text_7"> <td class="by"> <a href="xxx">banana</a> </td> </tbody>
<regex>
2016-03-02 14:11:05
LQ_EDIT
35,749,619
How can I correctly converted this?
I tried a couple of times converting this date format Wed, 02 April 2015 15:50:53 SAST to this format YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ] but with no luck so far. Is there any better way to this, that I might have missed? Will appreciate any help
<django>
2016-03-02 14:12:45
LQ_EDIT
35,749,801
How to validate javascript and html code?
<p>In our application end users are provided with a textbox where they can paste their html or javascript code to create advertisement much like Google advertisement , so I need to validate these html and js source code against malicious code and also proper syntax . So are there any API's available in java to do the same ?</p> <p>Thanks in advance Ali.</p>
<javascript><java><html>
2016-03-02 14:20:31
LQ_CLOSE
35,750,034
OO Design, pass parameters between private methods or access member variable?
<p>Say I have the following class:</p> <pre><code>class MyClass { private int memberVar; public MyClass(int passedInVar) { memberVar = passedInVar; } } </code></pre> <p>In the constructor you pass in an int and assign it to a private member variable.</p> <p>My question is, is it better to pass that int variable around between private methods of the class, or to not pass the int variable as a parameter and instead have each private method directly access the private membervar?</p> <p>i.e. Is this (Example A):</p> <pre><code>class MyClass { private int memberVar; public MyClass(int passedInVar) { memberVar = passedInVar; } public MyPublicMethod() { MyPrivateMethod(memberVar); } public MyPrivateMethod(int variable) { // Do something with passed in variable... } } </code></pre> <p>better than this (Example B):</p> <pre><code>class MyClass { private int memberVar; public MyClass(int passedInVar) { memberVar = passedInVar; } public MyPublicMethod() { MyPrivateMethod(); } public MyPrivateMethod() { // Do something with memberVar... } } </code></pre> <p>The reason I ask is that I find myself switching between the two styles.</p> <p>I find that example the style of example A shows more intent for the code. You can see what is being passed between private methods so it's more obvious what is being affected by that method.</p> <p>Whereas Example B is cleaner because the memberVar isn't being passed between private methods. However the code feels more "side-effecty" because it's not always obvious which private member variables the method is acting on.</p> <p>I'd appreciate your opinions on which approach you consider best.</p>
<c#><oop>
2016-03-02 14:30:09
HQ
35,750,614
Pyspark: get list of files/directories on HDFS path
<p>As in title. I' m aware of textFile but as the name suggests, it works only on text file. I would need to access the files/directories inside a path on HDFS (or local path). I'm using pyspark</p> <p>Thanks for help</p>
<hadoop><apache-spark><pyspark>
2016-03-02 14:53:12
HQ
35,751,151
C language Typedef struct format
Can someone tell me how can I declare a typedef struct in other typedef struct? `typedef struct { char* type; char* destination; float price; typedef struct { int date; int month; int year; }date; }Offer; ` I tried something like this but I don't know if its correctly. I want to declare in typedef struct another typedef struct for date format. Thanks
<c><struct><typedef>
2016-03-02 15:15:21
LQ_EDIT
35,751,367
Convert Dictionary<int, string> to Json
<p>Very simple question. Hope its easy...</p> <pre class="lang-cs prettyprint-override"><code>Dictionary&lt;int, string&gt; dict = PLCCommunicator.getVarForSchakelingen("iOffsetSun", plc); return Json(new { succeeded = true, dict }, JsonRequestBehavior.AllowGet); </code></pre> <p>Is there a way in which the dict can easily be converted? Something like <code>dict.ToJson()</code></p> <p>My controller returns a <code>JsonResult</code>...</p>
<c#><json><dictionary>
2016-03-02 15:24:28
LQ_CLOSE
35,752,155
Laravel: Get URL from routes BY NAME
<p>I'm trying to do something a little different and I couldn't find any way to do it. Maybe my approach is wrong but either way I figured I might find some help here.</p> <p>I have a Laravel 5 project and you know how you can get the current route name by using:</p> <pre><code>\Request::route()-&gt;getName(); </code></pre> <p>So I'm actually looking to do the exact opposite. Maybe not the exact opposite but what I need is to retrieve my route URL based on the name that I gave to that route. Here is my dream scenario.</p> <p>my <b>routes.php:</b></p> <pre><code>Route::any('/hos', "HospitalController@index")-&gt;name("hospital"); </code></pre> <p>What I <strong>would like to do</strong> in my controller that I have no idea how to or even if is possible:</p> <pre><code>// I have no idea if this is possible but thats what I'm trying to accomplish $my_route_url = \Request::route()-&gt;getURLByName("hospital"); echo $my_route_url; // this would echo: "/hos" </code></pre> <p>I might be using the wrong approach here so maybe you guys can help me out and shine some light on the issue.</p> <p>Thanks!</p>
<php><laravel><laravel-5><routes><laravel-routing>
2016-03-02 15:58:59
HQ
35,752,565
What does this mean **&a in C++
<p>What is different between two fucntions bellow?</p> <pre><code>void init1(int **&amp;a, int n) { a = new int *[n]; for (int i = 0; i&lt;n; i++) a[i] = new int [n]; } </code></pre> <p>and</p> <pre><code>void init1(int **a, int n) { a = new int *[n]; for (int i = 0; i&lt;n; i++) a[i] = new int [n]; } </code></pre> <p>Thanks,</p>
<c++><pointers>
2016-03-02 16:15:03
LQ_CLOSE
35,752,640
I don't understand the point of classes in C++
<p>Why do you need public and private portions of a class, why do you need baseline variables when you could accomplish the same thing with global variables. </p>
<c++11>
2016-03-02 16:17:41
LQ_CLOSE
35,753,709
Google Play Services breaks GSM network
<p>Update of Google Play Services is required for hangouts, google+ and other apps. But Google Play Services (8.4.89) breaks GSM network, with this errors:</p> <blockquote> <p>E/WifiManager(2841): mWifiServiceMessenger == null <strong>E/MPlugin(2947): Unsupported class: com.mediatek.common.telephony.IOnlyOwnerSimSupport</strong> E/WifiManager(2947): mWifiServiceMessenger == null E/MPlugin(1814): Unsupported class: com.mediatek.common.telephony.IOnlyOwnerSimSupport E/GmsWearableNodeHelper(1814): GoogleApiClient connection failed: ConnectionResult{statusCode=API_UNAVAILABLE, resolution=null, message=null} 03-02 16:51:54.329: E/MPlugin(2878): Unsupported class: com.mediatek.common.telephony.IOnlyOwnerSimSupport E/ReceiverController(803): filterReceiver() ignored with null action 03-02 16:51:54.676: E/ReceiverController(803): filterReceiver() ignored with null action E/BaseAppContext(2878): Tried to stop global GMSCore RequestQueue. This is likely unintended, so ignoring. E/MPlugin(1814): Unsupported class: com.mediatek.common.telephony.IOnlyOwnerSimSupport 03-02 16:51:56.209: E/MPlugin(3054): Unsupported class: com.mediatek.common.telephony.IOnlyOwnerSimSupport 03-02 16:51:56.285: E/Babel_SMS(3054): canonicalizeMccMnc: invalid mccmnc 03-02 E/Babel_SMS(3054): canonicalizeMccMnc: invalid mccmnc nullnull E/SQLiteLog(3054): (284) automatic index on conversation_participants_view(conversation_id) 03-02 16:51:56.910: E/SQLiteLog(3054): (284) automatic index on</p> </blockquote> <p>After update Google Play Services with Google Market, GSM does not have any coverage, and no SIM is present (according to Android). Mobile is Dual SIM based on Mediatek 6735 with Android 5.1 Uninstalling Google Play Services updates, and rebooting GSM works again. A possible workaround, reboot with original Google Play Services, and after this install Google Play Services updates.</p> <p>Google Play Services bug, incompatible device, ...?</p>
<android><google-play-services>
2016-03-02 17:06:44
HQ
35,754,059
I have a local json file and i want to display its data in listbox
<p>Suppose I have following data in the json file and I want it to render in the same format in my control list box which is in my view file</p> <pre><code>{ "data" :[ { "text" : "abc" } ] } </code></pre>
<javascript><json><sapui5>
2016-03-02 17:24:17
LQ_CLOSE
35,754,539
How to know type of a linker whether it's a static/dynamic in c plus plus
How can we know that which type of linker(static/dynamic) our system is using? Is it decided on type of library(static/dynamic) we have used or is there any other thing?
<linker><language-agnostic>
2016-03-02 17:48:52
LQ_EDIT
35,755,089
Xamarin Forms image not showing
<p>I have a Xamarin Forms (2.0) Android app where I'm trying to show an image. I've got an icon called <code>icon-pages-r1.png</code> which I'm trying to show using the following code:</p> <pre><code>&lt;Image Source="icon-pages-r1.png" /&gt; </code></pre> <p>The image isn't showing though. When I change the source to <code>Icon.png</code> (the default Xamarin icon) it does work.</p> <p>The image is a semi-transparent PNG (thus a colored icon in the middle and transparent around it), it's 46x46 and in Windows it shows fine as item type PNG File. I tried opening the image in Paint and re-saving it (which kills the transparency) but that doesn't work either. The <code>Build Action</code> for the images are <code>AndroidResource</code> with <code>Copy to Output Directory</code> set to <code>Do not copy</code>.</p> <p>Does anyone know why I can't get this image to show in my app?</p>
<android><image><xamarin><xamarin-forms>
2016-03-02 18:18:19
HQ
35,755,191
ORACLE PLSQL TRIGGERS
Why we can NOT perform Commit in Pl_SQL triggers? If triggers are auto commit why we need PRAGMA autonomous transaction used for commit?Please explain .. am fully confused about this.Thanks in advance.
<plsql><oracle11g>
2016-03-02 18:22:41
LQ_EDIT
35,755,297
Chrome extension page action appearing outside of address bar
<p>I wrote a Chrome Extension page action, with the following implementation:</p> <p>In manifest.json:</p> <pre><code> "permissions" : [ "declarativeContent" ], </code></pre> <p>In background.js:</p> <pre><code>chrome.runtime.onInstalled.addListener(function() { // Replace all rules ... chrome.declarativeContent.onPageChanged.removeRules(undefined, function() { // With a new rule ... chrome.declarativeContent.onPageChanged.addRules([ { conditions: [ new chrome.declarativeContent.PageStateMatcher({ pageUrl: { urlMatches: 'www\.somewebsite\.com/(translate|revise)/' }, }) ], // And shows the extension's page action. actions: [ new chrome.declarativeContent.ShowPageAction() ] } ]); }); }); </code></pre> <p>I noticed that in most Chrome browsers, the page action icon appears correctly inside the address and only appears when the matching page is met:</p> <p><a href="https://i.stack.imgur.com/jQZI9.png" rel="noreferrer"><img src="https://i.stack.imgur.com/jQZI9.png" alt="Page action appearing as expected"></a></p> <p>However, in some browsers recently page actions started appearing as enabled/disabled browser actions, i.e. outside the address bar, which is a lot clumsier because the whole idea around page actions icons is that they appear if and only if the page is relevant to them. There is no point showing a disabled page action for most of the time. Actually, it happened to browsers where it used to work well days ago, like if a Chrome update had some side effects.</p> <p><a href="https://i.stack.imgur.com/BbnP3.png" rel="noreferrer"><img src="https://i.stack.imgur.com/BbnP3.png" alt="Page action appearing like a Browser action"></a></p> <p>I presume this is related to some Chrome setting that now shows all extensions there, but is there any way I can force the page action to appear consistently in the address bar and only appear when it can be really useful?</p>
<google-chrome-extension>
2016-03-02 18:29:23
HQ
35,755,391
AJAX functionality in WinForms
<p>I am looking for approach and not any code here - What is the best method to implement ajax like content fetch (from DB) in WinForms ?</p>
<c#><vb.net><winforms>
2016-03-02 18:34:59
LQ_CLOSE
35,755,446
python coin flip program that needs a repeat loop 10 times added and that is where i am stuck
I need to add a repeat loop that repeats the flip 10 times import random def coinflip() return random.randrange(2) if coinflip == 0: print("Heads") else: print("Tails")
<python><python-3.x>
2016-03-02 18:37:44
LQ_EDIT
35,755,572
Visual Studio, Python not auto-indenting
<p>This is probably a simple issue but something is wrong with my Python tools for visual studio. When I first started using VS2015 for Python it would auto-indent whenever I used a colon. Now VS2015 is just acting like a text editor with syntax highlighting. I tried uninstalling and reinstalling the Python tools but that did not work. How do I fix Visual Studio to auto-style as I write Python again?</p>
<python><visual-studio><visual-studio-2015>
2016-03-02 18:45:07
HQ
35,755,862
Why I am getting "System.Web.Mvc.SelectListItem" in my DropDownList?
<p>I believe I have bound my data correctly, but I can't seem to get my text property for each SelectListItem to show properly.</p> <p>My model:</p> <pre><code>public class Licenses { public SelectList LicenseNames { get; set; } public string SelectedLicenseName { get; set; } } </code></pre> <p>Controller: </p> <pre><code>[HttpGet] public ActionResult License() { try { DataTable LicsTable = BW.SQLServer.Table("GetLicenses", ConfigurationManager.ConnectionStrings["ProfressionalActivitiesConnection"].ToString()); ProfessionalActivities.Models.Licenses model = new ProfessionalActivities.Models.Licenses(); model.LicenseNames = new SelectList(LicsTable.AsEnumerable().Select(row =&gt; new SelectListItem { Value = row["Description"].ToString(), Text = "test" })); return PartialView("_AddLicense", model); } catch (Exception ex) { var t = ex; return PartialView("_AddLicense"); } } </code></pre> <p>View:</p> <pre><code>@Html.DropDownList("LicenseNames", new SelectList(Model.LicenseNames, "Value", "Text", Model.LicenseNames.SelectedValue), new { htmlAttributes = new { @class = "form-control focusMe" } }) </code></pre>
<c#><asp.net><asp.net-mvc><html-select>
2016-03-02 18:59:57
HQ
35,756,090
Sorting a 2d array by column
<p>Here is my code, im kinda lost as to how to make this work the way i want to, i have made it so the user will enter a 3x3 2d array, im trying to sort each column but im having a hard time figuring it out and then printing the array while still keeping the original in tack....</p> <pre><code>package newproject; import java.util.Scanner; public class ColumnSorting { public static void main(String [] args){ double a[][]=new double[3][3]; Scanner input = new Scanner(System.in); for(int row=0;row&lt;3;row++){ for(int col=0;col&lt;3;col++){ System.out.println("Enter value: "); a[row][col]=input.nextDouble(); } } displayArray(a); } public static void displayArray(double x[][]) { for (int row=0;row&lt;x.length;row++) { for(int column = 0;column&lt;x[row].length; column++) { System.out.print(x[row][column]+"\t"); } System.out.println(); } } public static double[][] sortColumns(double[][] m){ java.util.Arrays.sort(m, new java.util.Comparator&lt;double[]&gt;() { public int compare(double[] a, double[] b) { return Double.compare(a[0], b[0]); } }); } } </code></pre>
<java><sorting><multidimensional-array>
2016-03-02 19:12:00
LQ_CLOSE
35,756,469
Laravel 5 - Many to Many - Attach versus Save
<p>I have a many to many relationship between two models, users and roles. Is there a difference between saving a relationship using the save() method and using the attach() method?</p> <pre><code>$user-&gt;roles()-&gt;save($role, ['expires' =&gt; $expires]); //using save $user-&gt;roles()-&gt;attach($roleId, ['expires' =&gt; $expires]);// using attach </code></pre> <p>Are the two equivalent? I personally dont see the difference. Thoughts?</p>
<php><laravel><save>
2016-03-02 19:33:29
HQ
35,757,620
How to gracefully remove a node from Kubernetes?
<p>I want to scale up/down the number of machines to increase/decrease the number of nodes in my Kubernetes cluster. When I add one machine, I’m able to successfully register it with Kubernetes; therefore, a new node is created as expected. However, it is not clear to me how to smoothly shut down the machine later. A good workflow would be:</p> <ol> <li>Mark the node related to the machine that I am going to shut down as unschedulable;</li> <li>Start the pod(s) that is running in the node in other node(s);</li> <li>Gracefully delete the pod(s) that is running in the node;</li> <li>Delete the node.</li> </ol> <p>If I understood correctly, even <code>kubectl drain</code> (<a href="https://groups.google.com/forum/#!topic/google-containers/FxOYvJp82T0" rel="noreferrer">discussion</a>) doesn't do what I expect since it doesn’t start the pods before deleting them (it relies on a replication controller to start the pods afterwards which may cause downtime). Am I missing something?</p> <p>How should I properly shutdown a machine?</p>
<kubernetes>
2016-03-02 20:40:04
HQ
35,757,648
Converting individual pieces of assembly to machine code
<p>I am trying to convert assembly to machine code. I have a MINGW compiler where if i type ./convert.exe mov %a then it should output 0x01 0xc0. I am thinking of using a struct listing each assembly code with its corresponding machine value. At the moment i keep getting errors like "request for member opcode in something not a structure". Any help would be appreciated.</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;string.h&gt; struct _Instruction { char mnemonic[10]; unsigned char opcode;} typedef Instruction; Instruction instruction_list[] = { {"mov", 0x01}, {"add", 0x04}, {"sub", 0x05}, {"mul",0x06}, {"div", 0x07}, {"and",0x08}, {"or",0x09}, {"xor",0x0a}, {"cmp",0x0b}, {"",-1}, }; Instruction get_inst(char mnemonic[]); int main2(int argc, char *argv[]) { char* instruction = argv[1]; Instruction get_inst = get_Instruction(instruction); printf("%s ; %s",instruction_list.mnemonic,instruction_list.opcode); return 0; } Instruction get_inst(char mnemonic[]) { int i; for(i=0; instruction_list[i].opcode != -1; i++) { if(!strcmp(instruction_list[i].mnemonic, mnemonic)) { return instruction_list[i]; } } return instruction_list[i]; } </code></pre>
<c><assembly>
2016-03-02 20:41:46
LQ_CLOSE
35,757,877
C++ program to compute the surface area and volume of a cylinder using two separate functions
<pre><code>#include&lt;stdio.h&gt; #include&lt;iostream&gt; using namespace std; class Calculate //class form { int r,h ; public: void getdata() //input data { cout&lt;&lt;"Enter the radius and height"; cin&gt;&gt;r&gt;&gt;h; } void Surfacearea() { float a; a= ( ( 2 * 3.14 * r * r ) + ( 2 * 3.14 * r * h ) ); cout&lt;&lt;"the sa of cylinder is"&lt;&lt;a; } void volume() { float v; v = ( 3.14 * r * r * h ); cout&lt;&lt;"the volume of cylinder is"&lt;&lt;v; } }; Calculate a1,a2,g; int main() { g.getdata(); a1.Surfacearea(); a2.volume(); } </code></pre> <p>I am getting surfacearea and volume as zero,i am unable to find error in code,please help me..........................................................................................................................</p>
<c++>
2016-03-02 20:57:35
LQ_CLOSE
35,758,179
Convert int to BigDecimal with decimal - Java
<p>I'm having a hard time figuring out how to convert this. Here is what I want:</p> <pre><code>int i = 5900; BigDecimal bD = new BigDecimal(i); </code></pre> <p>I need bD to be 59.00 but I can't figure out how to get this result. All I've been able to get is 5900 as type BigDecimal. Any suggestion would help, thanks.</p>
<java><type-conversion><bigdecimal>
2016-03-02 21:13:42
HQ
35,758,588
Max arc4random() value
For some reason I'm not able to find any sort of official doc telling me what the maximum range is for arc4random. I've seen in some non-authoritarian sources that it's 2^32 - 1, a little over 4 billion. Can anyone confirm this? If so, can you link to an official doc showing this number somewhere? I'm trying to generate a random number on my iOS app and need to have a pretty official upper end for the algorithm to work correctly. Thanks in advance!
<ios><arc4random>
2016-03-02 21:36:44
LQ_EDIT
35,758,654
Delphi NAS ForceDirectories
I cannot seem to be able to ForceDirectories on a NAS partition with Delphi. I can create a folder on the NAS with Windows explorer fine. Code is: procedure TForm3.Button1Click(Sender: TObject); var tempDir: String; begin tempDir := 'z:\ttt\ttttest'; if NOT DirectoryExists(tempDir) then if System.SysUtils.ForceDirectories(tempDir) then ShowMessage('Dir: ' + tempDir + ' Forced alright') else ShowMessage('Dir: ' + tempDir + ' Force FAILED with error : '+ IntToStr(GetLastError)); end; Z: is the Western Digital Network Attached Storage which works fine in all other respects. The code returns error 3 every time. Same code works alright on local drives. Delphi Seattle, Windows 10 64 bit.
<delphi><nas><delphi-10-seattle>
2016-03-02 21:41:06
LQ_EDIT
35,758,761
Code Iris plugin on Android Studio
<p>I am trying to make code iris plugin work on Android studio.</p> <p>I press right click -> Create Code Iris graph and then I get a notification that my graph is ready. But I do not know when this graph is stored, what is the name of the file created and how to open it. Any ideas? </p>
<android><android-studio><plugins><uml><class-diagram>
2016-03-02 21:47:58
HQ
35,758,924
How do we query on a secondary index of dynamodb using boto3?
<p>Is there a way at all to query on the <code>global secondary index</code> of dynamodb using <code>boto3</code>. I dont find any online tutorials or resources. </p>
<amazon-web-services><amazon-dynamodb><boto3>
2016-03-02 21:56:38
HQ
35,759,843
Can I use excel logic function "if" in DataTable or dataGridView?
<p>I have a program in VB.NET with a table which would like to run the excel logic function "if" to complete the third column:</p> <p>My code for DT and DGV</p> <pre><code>Dim DGV As New DataGridView Dim DT As New DataTable If DGV.ColumnCount &gt; 0 Then Try DT.Columns.Remove("Nº") DT.Columns.Remove("Q") DT.Columns.Remove("k") DT.Clear() Catch g As DataException Console.WriteLine("Exception Of type {0} occurred.", g.GetType().ToString()) End Try End If DGV.SetBounds(12, 120, 865, 460) Controls.Add(DGV) DT.Columns.Add("Nº", GetType(Int32)) DT.Columns.Add("Q", GetType(Double)) DT.Columns.Add("k", GetType(String)) For I = 1 To 100 DT.Rows.Add(I, I * 3) Next (I) Me.DGV.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.ColumnHeader DGV.ReadOnly = True DGV.DataSource = DT </code></pre> <p>It's possible? Examples in C# also are accepts.</p> <p>Thanks!</p>
<c#><vb.net>
2016-03-02 22:54:04
LQ_CLOSE
35,760,982
React.js - using property initializers for all component methods
<p>I am working on a React Native project and I'm using ES6 classes for React components.</p> <p>Since React components defined via ES6 classes don't have autobinding, the React team <a href="https://facebook.github.io/react/blog/2015/01/27/react-v0.13.0-beta-1.html#autobinding">recommends</a> combining ES7 property initializers with arrow functions to create the same effect.</p> <p>In order to be consistent and prevent confusion with this-binding, I am using ES7 property initializers for all component methods:</p> <pre><code>class Foo extends React.Component { constructor(props) { super(props); ... } componentDidMount = () =&gt; { ... }; bar = () =&gt; { ... }; render = () =&gt; { ... }; } </code></pre> <p>I was wondering -- are there any serious performance caveats to be aware of? In particular, I'm wondering about the render() method.</p> <p>Overall, does this seem like a good approach?</p>
<javascript><reactjs><react-native><babeljs>
2016-03-03 00:35:33
HQ
35,761,888
Why does c++ stick to this kind of symbol system?
<p>The system I mean is the one where anything you want to reference has to be prototyped or defined either above your current line or in a referenced header, not sure if this has a name. </p> <p>I'm cool with headers but sometimes the necessity of forward prototypes forces me into writing really disjointed and hard to manage snippets. </p> <p>I get why it was a thing once upon a time but is there any reason modern c++ can't bring us the convenience of allowing definitions in any order, anywhere like the plethora of newer managed languages?</p>
<c++>
2016-03-03 02:12:05
LQ_CLOSE
35,762,510
Alpine 3.3, Python 2.7.11, urllib2 causing SSL: CERTIFICATE_VERIFY_FAILED
<p>I have this small Dockerfile</p> <pre><code>FROM alpine:3.3 RUN apk --update add python CMD ["python", "-c", "import urllib2; response = urllib2.urlopen('https://www.python.org')"] </code></pre> <p>Building it with <code>docker build -t alpine-py/01 .</code> and then running it with <code>docker run -it --rm alpine-py/01</code> creates the following output</p> <pre><code>Traceback (most recent call last): File "&lt;string&gt;", line 1, in &lt;module&gt; File "/usr/lib/python2.7/urllib2.py", line 154, in urlopen return opener.open(url, data, timeout) File "/usr/lib/python2.7/urllib2.py", line 431, in open response = self._open(req, data) File "/usr/lib/python2.7/urllib2.py", line 449, in _open '_open', req) File "/usr/lib/python2.7/urllib2.py", line 409, in _call_chain result = func(*args) File "/usr/lib/python2.7/urllib2.py", line 1240, in https_open context=self._context) File "/usr/lib/python2.7/urllib2.py", line 1197, in do_open raise URLError(err) urllib2.URLError: &lt;urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)&gt; </code></pre> <p>Yesterday I got bitten by the recent OpenSSL 1.0.2g release, which caused <code>py-cryptograpy</code> to not compile. Luckily the guys from <code>py-cryptography</code> released a new version on PyPI a couple of hours later. The issue was that a function in OpenSSL got a new signature.</p> <p>Could this be related or am I missing something?</p>
<python><ssl><alpine>
2016-03-03 03:13:52
HQ
35,763,928
Error when I tried create new maven module in IntellijIDE 15
<p>I tried add new module to project in IntellijIDE 15 and I have error</p> <pre><code>Failed to create a Maven project 'C:/gitProjects/mayProj/pom.xml' already exists in VFS </code></pre> <p>And in my project create file <code>moduleName.iml</code> but in IDE not shows module folder and in project structure this module is shows.</p>
<maven><intellij-idea>
2016-03-03 05:28:00
HQ
35,764,186
Soundpool load sound A component of name 'OMX.qcom.audio.decoder.aac' already exists, ignoring this one
<p>I have implemented load all sounds in Application onCreate method in background. But when i load sound it gives error like this: </p> <blockquote> <p>E/OMXMaster: A component of name 'OMX.qcom.audio.decoder.aac' already exists, ignoring this one.</p> </blockquote> <p>What is problem here? Anybody have any idea? Thanks in advance</p> <pre><code>private void loadAllSounds() { new Thread(new Runnable() { @Override public void run() { soundPool.load(appContext, R.raw.compose_sound_0, 1); soundPool.load(appContext, R.raw.compose_sound_1, 1); soundPool.load(appContext, R.raw.compose_sound_2, 1); soundPool.load(appContext, R.raw.compose_sound_3, 1); } }).start(); } </code></pre>
<android><audio><soundpool>
2016-03-03 05:49:09
HQ
35,764,196
In need of an IDE to make an app with a powerful Ui
<p>I'm starting to study mobile development and i want to know what is the best language/IDE to develop an app with a powerful UI. I prefer a android native app over a web one, but it can be an hybrid. I've already tried with C# in visual studio and xamarin, but it looks confusing. I want to build those crazy smooth modern and flat UI apps, so what's the best IDE?</p>
<android>
2016-03-03 05:50:25
LQ_CLOSE
35,764,319
ngrok speed became slow
<p>Ive been using <a href="https://ngrok.com/" rel="noreferrer">ngrok</a> to test an app on my phone, with react-native for the past 2 weeks. And so far its been pretty decent and quick. </p> <p>Until today. Now it suddenly takes about 50 seconds for a request to make a roundtrip from my phone, to my localhost and back. Or from my browser, to the ngrok tunnel, back to my localhost.</p> <p>At first I thought, ok ngrok is either down or experiencing slowdowns. But then I decided to hit it with Postman, and with that the request is fast. Around 0.5 seconds. Same when I access the tunnel stats. A replay request is like 1second. </p> <p>Just when I do it over my phone, or browser its now extremely slow. Is there any specific reason this may suddenly be occuring? Can anyone shed any light on where I should even begin looking?</p> <p>I've tried rebooting, and flushing DNS, to no avail.</p>
<tunnel><ngrok>
2016-03-03 05:59:20
HQ
35,764,782
Identify Return Key action in React Native
<p>I have a <code>TextInput</code> which I have enabled <code>multiline</code> as true. Thing is the Keyboard won't hide after Return is pressed. It goes to a new line. So I was hoping to use <a href="https://www.npmjs.com/package/react-native-dismiss-keyboard" rel="noreferrer">react-native-dismiss-keyboard</a>. To exploit this I need to identify the Return key action. How to do this?</p> <pre><code>&lt;TextInput style={styles.additionalTextInput} multiline={true} autoCapitalize="sentences" autoCorrect={true} onChangeText={(text) =&gt; this.setState({text})} keyboardType="default" returnKeyType="done" onKeyPress={(keyPress) =&gt; console.log(keyPress)} placeholder="Enter text here..." /&gt; </code></pre>
<ios><react-native>
2016-03-03 06:32:21
HQ
35,765,106
Symbolic links CMake
<p>I want to rename certain executables in <code>CMakeLists.txt</code> but also want symbolic links from the older names to new files for backward compatibility. How can this be accomplished on systems that support symbolic links?</p> <p>Also what are the alternatives for system that does not support symbolic links?</p> <p>Thanks</p>
<cmake>
2016-03-03 06:53:43
HQ
35,765,217
can anyone tell me what is wrong with my code? im trying to find the sum of the first n integer value, im quite a beginner
#include <iostream> using namespace std; int num(int n){ for(int i= 1 ; i<=n ; i++){ int sum=0; sum += i; cout<<sum; } } i guess this part is clear. int main() { int x; cout<<"enter the value of x "; cin>>x; int answer=num(x); cout<<"the total sum of the first n integer is "<<answer; return 0; } ive tried looking it up but no results found.... ive always had some trouble with the loops.
<c++>
2016-03-03 06:59:47
LQ_EDIT
35,765,407
i want to find the largest Word using 2 dimentional array in java?
package largestvalue; import java.util.*; public class LargestValue { public static void main(String[] args) { String array[][]={{"renas","Mahdy","Rezhwan"}, {"HRashid","Barham","Harem"}, {"zalamek","Mustafa","Sarbast"}}; String Largest=array[0][0]; for (int i=0;i<array.length;i++){ for(int j=0;j<array[i].length;j++){ ** > if(Largest<array[i][j]) **{ [This is the error][1] Largest=array[i][j]+""; } } } System.out.println("The Largest Number int the Array is :"+Largest); } } [1]: http://i.stack.imgur.com/m71Zv.png
<java><string><multidimensional-array>
2016-03-03 07:10:54
LQ_EDIT
35,766,183
JSon to ListView With setOnItemClickListener In ANdroid
*Some One Can Help Me Please Told Me How To Show Room Id In Toast Below Is The Code. Below Code Working But I am Not Able To Show RoomId in Toast.* **MainActivity.java** <!-- begin snippet: js hide: false --> <!-- language: lang-js --> package com.android.listviewexample; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import com.android.volley.AuthFailureError; import com.android.volley.Request; import com.android.volley.RequestQueue; import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.StringRequest; import com.android.volley.toolbox.Volley; import android.support.v7.app.ActionBarActivity; import android.view.View; import android.view.Window; import android.content.Intent; import android.os.Bundle; import android.widget.ListView; import android.widget.AdapterView; import android.widget.SimpleAdapter; import android.widget.Toast; import android.widget.AdapterView.OnItemClickListener; public class MainActivity extends ActionBarActivity { private RequestQueue requestQueue; private static final String URL = "http://192.168.0.1/api/enter.php"; private StringRequest request; @Override protected void onCreate(Bundle savedInstanceState) { this.requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); requestQueue = Volley.newRequestQueue(this); request = new StringRequest(Request.Method.POST, URL, new Response.Listener<String>() { @Override public void onResponse(String response) { try { JSONObject jsonObject = new JSONObject(response); if(jsonObject.names().get(0).equals("success")){ JSONArray success = jsonObject.getJSONArray("success"); for (int i = 0; i < success.length(); i++) { JSONObject succes = success.getJSONObject(i); System.out.println(succes.toString()); } JSONArray rooms = jsonObject.getJSONArray("rooms"); for (int i = 0; i < rooms.length(); i++) { JSONObject room = rooms.getJSONObject(i); String name = room.optString("room"); String roomid = room.optString("roomid"); String outPut = name; roomList.add(createRoom("chatroom", outPut)); ListView listView = (ListView) findViewById(R.id.examplelistView); SimpleAdapter simpleAdapter = new SimpleAdapter(MainActivity.this, roomList, android.R.layout.simple_list_item_1, new String[] {"chatroom"}, new int[] {android.R.id.text1}); listView.setAdapter(simpleAdapter); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent intent = new Intent(getApplicationContext(), FstActivity.class); Bundle b = new Bundle(); int itemPosition = position; b.putString("roomposition", "Position :"+itemPosition); //b.putString("roomid", roomid.toString()); intent.putExtras(b); startActivity(intent); Toast.makeText(getApplicationContext(),"Position :"+itemPosition, Toast.LENGTH_LONG) .show(); } }); } }else { } } catch (JSONException e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { } }){ @Override protected Map<String, String> getParams() throws AuthFailureError { HashMap<String,String> hashMap = new HashMap<String, String>(); hashMap.put("s","e0c93d9bb49efd89f9b70225bd65f157".toString()); return hashMap; } }; requestQueue.add(request); } List<Map<String,String>> roomList = new ArrayList<Map<String,String>>(); private HashMap<String, String>createRoom(String name,String number){ HashMap<String, String> roomName = new HashMap<String, String>(); roomName.put(name, number); return roomName;} } <!-- end snippet --> **activity_main.xml** <!-- begin snippet: js hide: false --> <!-- language: lang-js --> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.android.listviewexample.MainActivity" > <ListView android:id="@+id/examplelistView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_alignParentLeft="true" android:layout_alignParentRight="true" > </ListView> </RelativeLayout> <!-- end snippet --> **192.168.0.1/enter.php** <!-- begin snippet: js hide: false --> <!-- language: lang-js --> {"success":[{"sid":"e0c93d9bb49efd89f9b70225bd65f157","login":"saeed"}],"rooms":[{"roomid":"room12","room":".~=cAsiNo-RooM=~."},{"roomid":"room24","room":".~=MusiC-Masti=~."},{"roomid":"room29","room":".~&quot;LoVeRs_RoOM&quot;~."},{"roomid":"room30","room":".PunjaBi_RocK."},{"roomid":"room31","room":".~&quot;FrienDs_RoOM&quot;~."},{"roomid":"room33","room":".~&quot;Party_All_NiGhT&quot;~."},{"roomid":"room13","room":".~=HuNtEd-RooM=~."}]} <!-- end snippet --> Please Please Help Me How to Show Room Id In TOast And OnItemClickListener :(
<android><android-toast>
2016-03-03 07:52:20
LQ_EDIT
35,766,834
Python: understanding class and instance variables
<p>I think I have some misconception about class and instance variables. Here is an example code:</p> <pre><code>class Animal(object): energy = 10 skills = [] def work(self): print 'I do something' self.energy -= 1 def new_skill(self, skill): self.skills.append(skill) if __name__ == '__main__': a1 = Animal() a2 = Animal() a1.work() print a1.energy # result:9 print a2.energy # result:10 a1.new_skill('bark') a2.new_skill('sleep') print a1.skills # result:['bark', 'sleep'] print a2.skills # result:['bark', 'sleep'] </code></pre> <p>I thought that <code>energy</code> and <code>skill</code> were class variables, because I declared them out of any method. I modify its values inside the methods in the same way (with <code>self</code> in his declaration, maybe incorrect?). But the results show me that <code>energy</code> takes different values for each object (like a instance variable), while <code>skills</code> seems to be shared (like a class variable). I think I've missed something important...</p>
<python>
2016-03-03 08:26:55
HQ
35,767,178
textview position by backgorund imageview
i have background imageview(green with 3 red circle) and 3 textview (A,B,C). how can i put textviews exactly on center of red circles that support multi screen devices , portrait/landscape ? [![enter image description here][1]][1] [1]: http://i.stack.imgur.com/mTaaR.png
<android><layout><textview><imageview>
2016-03-03 08:46:17
LQ_EDIT
35,767,403
Run flow check continuously (flowtype)
<p>I was wondering if someone knew of a good way to continuously run the "flow check" command inside a given repo such that it will re-run anytime a file is updated?</p> <p>Thanks! Thomas</p>
<facebook><flowtype>
2016-03-03 08:58:10
HQ
35,767,643
Using Thread.Sleep in Xamarin.Forms
<p>I want to execute the following</p> <pre><code>MainPage = new ContentPage { Content = new StackLayout { Children = { new Button { Text = "Thread.Sleep", Command = new Command(() =&gt; { Thread.Sleep(1000); MainPage.Animate("", x =&gt; MainPage.BackgroundColor = Color.FromRgb(x, x, x)); }), }, new Button { Text = "Task.Run + Thread.Sleep", Command = new Command(async () =&gt; { await Task.Run(() =&gt; Thread.Sleep(1000)); MainPage.Animate("", x =&gt; MainPage.BackgroundColor = Color.FromRgb(x, x, x)); }) }, new Button { Text = "Device.StartTimer", Command = new Command(() =&gt; Device.StartTimer( TimeSpan.FromSeconds(1), () =&gt; { MainPage.Animate("", x =&gt; MainPage.BackgroundColor = Color.FromRgb(x, x, x)); return false; })), }, } } }; </code></pre> <p>I included <code>System.Threading</code> and <code>System.Threading.Tasks</code>, but I still get</p> <blockquote> <p>The name 'Thread' does not exist in the current context.</p> </blockquote> <p><a href="http://www.xforms-kickstarter.com/#timer-never-miss-an-action" rel="noreferrer">This site</a> suggests that <code>Thread.Sleep</code> can be used in <code>Xamarin.Forms</code>. I have this in a shared project, not a PCL.</p>
<c#><xamarin><xamarin.ios><xamarin.forms><sleep>
2016-03-03 09:09:10
HQ
35,768,622
I want to Display local Images in Image Picker Controller from my project folder.
<p>I am new in objective c.where i need to display the images in a grid form in Image Picker Controller from my project. where i have many images, when the images will display i will click on one of them and it will display on another screen in Image View. i need your help with source code thanks.</p>
<ios><objective-c>
2016-03-03 09:51:14
LQ_CLOSE
35,769,003
Git commit count a day
<p>I have a branch called <code>development</code>. Now I want to know how many commits are happened per day (i.e) each day.</p> <p>I want Toal number of commits (i.e) count of commits in a day.</p> <p>I tried this command, but it is giving all commits count from the branch</p> <pre><code>git shortlog -s -n </code></pre> <p>My question is count number of commits in a day</p>
<git><commit>
2016-03-03 10:06:33
HQ
35,769,133
merge table php and table javascript
I have a table in php and I have another table in javascript . I would like to add Elements of the table php to elements javascript table. I tried with the push method : tabJS.push ( tabPHP ) ; but it does not work , is what you have ideas for my problem thank you
<javascript><php><jquery><arrays>
2016-03-03 10:12:21
LQ_EDIT
35,769,170
SwipeRefreshLayout intercepts with ViewPager
<p>I have a ViewPager wrapped inside a SwipeRefreshLayout. Sometimes, when I swipe to the left/right the SRL get's triggered. This mostly happens when I'm at the top of my fragment. </p> <p>How do I solve this? Do I need to listen to some kind of event in order to disable the SRL during a certain time? I haven't really found anything about it so I doubt this is an actual bug by Google but rather am I implementing something incorrectly? Any ideas on this?</p> <p>That's my layout:</p> <pre><code>&lt;android.support.v4.widget.SwipeRefreshLayout android:id="@+id/mainSwipeContainer" android:layout_width="wrap_content" android:layout_height="match_parent"&gt; &lt;android.support.v4.view.ViewPager android:id="@+id/mainViewPager" android:layout_width="fill_parent" android:layout_height="fill_parent" /&gt; &lt;/android.support.v4.widget.SwipeRefreshLayout&gt; </code></pre> <p>Thanks! Let me know if I'm missing out any information. </p>
<android><android-viewpager><swiperefreshlayout>
2016-03-03 10:13:47
HQ
35,769,469
Sql server Query based on different date and product ids
I want to build the query based on the attached image. [Table Data][1] I want to get the sum of quantity (product Id wise) from "transaction" table where date is greater than the date of first table. for example ProductID 1254 should return 7. [1]: http://i.stack.imgur.com/O753w.jpg Thanks to all
<sql><sql-server>
2016-03-03 10:25:52
LQ_EDIT
35,769,847
An attempt to attach an auto-named database for file D:\Stra.mdf failed.
[we are doing project in our collage while we are executing we getting this error we have registration page while we are click on register we getting this error ][1] [1]: http://i.stack.imgur.com/fAtKN.jpg
<c#><sql-server>
2016-03-03 10:40:50
LQ_EDIT
35,769,966
how to check which dns client is used on an external server?
<p>The issue is that i cannot determine what domain name system external servers use.</p> <p>I want to be able to spot which kind of domain name system client is a server using without having actually access to it.</p> <p>I have tried several commands on n map with domain name system searching script, but the result is not clear. </p> <p>For ports open i can use n map.</p> <p>Is there a solution for domain name system spotting too ?</p>
<dns><bind>
2016-03-03 10:45:49
LQ_CLOSE
35,770,253
returning paired elements in React JSX
<p>The Problem:</p> <p>In React, you want to create a DOM structure by mapping an array, but each item in the array should return 2 elements. e.g.</p> <pre><code>import React from 'react' import _ from 'lodash' let { Component } = React export default class DataList extends Component { render () { let array = [ {def: 'item1', term: 'term1', obj1: 'rand'}, {def: 'item2', term: 'term2'} ] return ( &lt;dl&gt; {_.map(array, (item) =&gt; { return ( &lt;dt&gt;{item.def}&lt;/dt&gt; &lt;dd&gt;{item.term}&lt;/dd&gt; ) })} &lt;/dl&gt; ) } } </code></pre> <p>React doesn't let you render siblings without wrapping them in a container element, which would break the DOM structure here.</p>
<javascript><reactjs><react-jsx>
2016-03-03 10:56:34
HQ
35,770,279
Ruby Regex - get persons name
<p>Given consistent strings like this:</p> <pre><code>Manual stage: &lt;b&gt;Release&lt;/b&gt; by &lt;a href="https://test/builds/browse/user/a0123456"&gt;Joe Bloggs&lt;/a&gt; Changes by &lt;a href="https://test/builds/browse/user/b234556"&gt;John Doe&lt;/a&gt; </code></pre> <p>is there a simple regex I could use to pull the persons name? is there a simple regex I could to pull the ID (which is at the end of the URL e.g. b1234345)?</p> <p>Thanks</p>
<ruby><regex>
2016-03-03 10:57:58
LQ_CLOSE
35,770,339
If else condition in HTML
<p>I have an application where in index.cshtml file I am loading an external javascript file</p> <pre><code>&lt;head&gt; &lt;script scr="External Javascript" type="text/javascript"&gt;&lt;/script&gt; &lt;/head&gt; </code></pre> <p>Now the problem is I want to restrict the loading of the file for a few users. How can I achieve it here?</p>
<javascript><html><javascript-events>
2016-03-03 11:00:23
LQ_CLOSE
35,770,713
Overloaded string methods with string interpolation
<p>Why does string interpolation prefer overload of method with <code>string</code> instead of <code>IFormattable</code>?</p> <p>Imagine following:</p> <pre><code>static class Log { static void Debug(string message); static void Debug(IFormattable message); static bool IsDebugEnabled { get; } } </code></pre> <p>I have objects with very expensive <code>ToString()</code>. Previously, I did following:</p> <pre><code>if (Log.IsDebugEnabled) Log.Debug(string.Format("Message {0}", expensiveObject)); </code></pre> <p>Now, I wanted to have the IsDebugEnabled logic inside <code>Debug(IFormattable)</code>, and call ToString() on objects in message only when necessary.</p> <pre><code>Log.Debug($"Message {expensiveObject}"); </code></pre> <p>This, however, calls the <code>Debug(string)</code> overload.</p>
<c#><c#-6.0><string-interpolation>
2016-03-03 11:17:27
HQ
35,770,945
c# Detect if a file is able to be deleted
<p>i am trying to complete the simple task of detecting if a file is able to be deleted, for example: if a <code>.dll</code> is being used by another program you are not able to delete the <code>.dll</code> - this is what i want to be able to detect. Well yeah hopefully that makes sense.</p> <p>So far I've tried the following with no luck:</p> <pre><code>try { System.IO.File.Delete(@"C:\Program Files\MyTestFiles\testing.dll"); } catch { Console.WriteLine("Unable to delete file"); } </code></pre> <p>and i've tried:</p> <pre><code>System.IO.File.Delete(@"C:\Program Files\MyTestFiles\testing.dll"); if(File.Exists(@"C:\Program Files\MyTestFiles\testing.dll")) { Console.WriteLine("Error: Unable to delete file"); } else { Console.WriteLine("Successfully deleted file!"); } </code></pre>
<c#><file><delete-file>
2016-03-03 11:28:17
LQ_CLOSE
35,771,449
Convert milliseconds into day,hour,minute and second iOS?
<p>I need to convert an milliseconds into Days, Hours, Minutes Second.</p> <p>ex: 5 Days, 4 hours, 13 minutes, 1 second.</p> <p>Thanks</p>
<ios><date><date-arithmetic>
2016-03-03 11:51:35
LQ_CLOSE
35,772,103
QT Applications - Replacing embedded resources
<p>Is it possible to replace embedded resources [e.g. styles, images, text] in a Linux [ELF] binary?</p> <p>I noticed that I can change text but if I type more text or if I remove text, then the segmentation faults start coming up. I have not gone through the ELF spec yet but I am wondering if it is possible.</p> <p>I managed to extract the images from the binary using the <a href="https://github.com/panzi/mediaextract" rel="noreferrer">mediaextract</a> project but I need to do just the opposite without breaking the binary structure.</p>
<c++><linux><qt><binary>
2016-03-03 12:22:27
HQ
35,773,477
No php_mongodb.dll file in this archive?
<p>As it's written on this website: <code>http://www.hongkiat.com/blog/webdev-with-mongodb-part3/</code>, i need to unzip mongo-php-driver archive to get php_mongo.dll, but i can't find it...</p> <p>Any help ?</p> <p>Cheers</p>
<mongodb>
2016-03-03 13:27:05
LQ_CLOSE
35,774,608
AngularJS 1.5 error bootstrap IBM Mobilefirst
<p>I seem to have problems combining an MFP hybrid (no cordova) application and angular 1.5. The same application with angular 1.4.9 works fine, but if I switch to angular1.5 then i get this error:</p> <pre><code>Error: [$injector:modulerr] Failed to instantiate module ng due to: TypeError: Cannot set property 'aHrefSanitizationWhitelist' of null at $$SanitizeUriProvider (http://localhost:10080/Hybrid/apps/services/preview/HelloWorld/android/1.0/default/vendor/angular5.js:17272:35) at new &lt;anonymous&gt; (http://localhost:10080/Hybrid/apps/services/preview/HelloWorld/android/1.0/default/worklight/worklight.js:1033:23) at Object.instantiate (http://localhost:10080/Hybrid/apps/services/preview/HelloWorld/android/1.0/default/vendor/angular5.js:4621:14) at provider (http://localhost:10080/Hybrid/apps/services/preview/HelloWorld/android/1.0/default/vendor/angular5.js:4435:36) at http://localhost:10080/Hybrid/apps/services/preview/HelloWorld/android/1.0/default/vendor/angular5.js:367:32 at forEach (http://localhost:10080/Hybrid/apps/services/preview/HelloWorld/android/1.0/default/vendor/angular5.js:337:20) at Object.provider (http://localhost:10080/Hybrid/apps/services/preview/HelloWorld/android/1.0/default/vendor/angular5.js:4425:9) at ngModule (http://localhost:10080/Hybrid/apps/services/preview/HelloWorld/android/1.0/default/vendor/angular5.js:2476:16) at Object.invoke (http://localhost:10080/Hybrid/apps/services/preview/HelloWorld/android/1.0/default/vendor/angular5.js:4606:19) at runInvokeQueue (http://localhost:10080/Hybrid/apps/services/preview/HelloWorld/android/1.0/default/vendor/angular5.js:4499:35) http://errors.angularjs.org/1.5.0/$injector/modulerr?p0=ng&amp;p1=TypeError%3A%…%2FHelloWorld%2Fandroid%2F1.0%2Fdefault%2Fvendor%2Fangular5.js%3A4499%3A35) </code></pre> <p>anyone a clue what it could be?</p>
<angularjs><ibm-mobilefirst>
2016-03-03 14:15:51
HQ