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
37,534,077
What is the difference between boto3 list_objects and list_objects_v2?
<p>I'm trying to list objects in an Amazon s3 bucket in python using <code>boto3</code>.</p> <p>It seems <code>boto3</code> has 2 functions for listing the objects in a bucket: <code>list_objects()</code> and <code>list_objects_v2()</code>. </p> <p>What is the difference between the 2 and what is the benefit of using one over the other? </p>
<python><amazon-s3><boto3>
2016-05-30 21:54:55
HQ
37,534,266
JavaNullPointer Exception on ArrayList Add Function
<p>Hope you are doing well</p> <p>i am facing issue while adding object to ArrayList i need your kind assistance in solving this problem each time when i am going to add something to selectedContacts ArrayList i got nullPointerException</p> <pre><code>ArrayList&lt;ContactInfo&gt; selectedContacts = new ArrayList&lt;&gt;(); public ArrayList&lt;ContactInfo&gt; getSelectedContacts() { int i = 0; while (contacts.get(i).isCheck()==true) { ContactInfo info = contacts.get(i); if(info != null) selectedContacts.add(info); i++; } return selectedContacts; } </code></pre> <p>ContactInfo.Java</p> <pre><code>public class ContactInfo { String name; String number; String email; boolean check; public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public void setCheck(boolean check) { this.check = check; } public void setName(String name) { this.name = name; } public void setNumber(String number) { this.number = number; } public boolean isCheck() { return check; } public String getName() { return name; } public String getNumber() { return number; } } </code></pre>
<android><arraylist>
2016-05-30 22:17:14
LQ_CLOSE
37,534,548
How to access a gmail account I own using Gmail API?
<p>I want to run a node script as a cronjob which uses Gmail's API to poll a gmail account I own.</p> <p>I am following <a href="https://developers.google.com/gmail/api/quickstart/nodejs#prerequisites" rel="noreferrer">these quickstart instructions</a>:</p> <p><a href="https://i.stack.imgur.com/0EgAo.png" rel="noreferrer"><img src="https://i.stack.imgur.com/0EgAo.png" alt="quickstart"></a></p> <p>I'm stuck on the first step. When requesting credentials for a cron script it tells me that "User data cannot be accessed from a platform without a UI because it requires user interaction for sign-in":</p> <p><a href="https://i.stack.imgur.com/LUh8X.png" rel="noreferrer"><img src="https://i.stack.imgur.com/LUh8X.png" alt="enter image description here"></a> </p> <p>The docs are confusing in general, and mention "service accounts," "OAuth," and other things -- I cannot tell which apply to my use-case and which don't. I've used many SaaS APIs, and the typical workflow is to login to your account, get an API key and secret, and use those in your script to access the API. It seems this is <em>not</em> the paradigm used by the Gmail API, so I'd appreciate any guidance or links to clearer instructions.</p>
<gmail><gmail-api>
2016-05-30 22:54:41
HQ
37,535,053
R Word Count - matching all combination of one string in another string
<p>I am trying to count all combinations of matching/fuzzy matching first string column to second string column in a data frame</p> <p>Eg:<br> string1 = "USA Canada UK Australia Japan India" string2 = "USA Canada India UK Australia China Brazil France"</p> <p>Expected results </p> <ul> <li><p>Single word match count = 5 (USA Canada UK Australia India) matched </p></li> <li><p>Two word match count = 2 (USA Canada, UK Australia) consecutive words matched </p></li> <li><p>Three word match count = 0 </p></li> <li><p>Four word match count = 0 </p></li> <li><p>Five word match count = 0 </p></li> <li><p>Six word match count = 0 </p></li> <li><p>In total = 5 + 2 = 7</p></li> </ul> <p>Thank you for your time and great someone can help to write this function or point me to use any existing package</p>
<r>
2016-05-31 00:15:35
LQ_CLOSE
37,535,241
Generating A List of Possible Moves
I am trying to generate a list of possible moves for a checkers-like game. For example, at the start of the game the board would look like [[1,1,1], [0,0,0], [2,2,2]]. My function would take the color (one for white, or two for black) and move the pieces either one space forward, or one space diagonal to capture another piece. So the first possible list of moves with white going first would be [[0,1,1], [1,0,0], [2,2,2], [1,0,1], [0,1,0, [2,2,2] etc. etc. So far I have: def generateMoves(color, board): newboard = [] subboard = [] board = [[1, 1, 1], [0, 0, 0], [2, 2, 2]] x = 0 for i in board: while x < len(board): subboard.append(board[x]) newboard.append(subboard) x += 1 return newboard but I can't figure out what modifications I need to make to it to calculate the new list of possible moves.
<python>
2016-05-31 00:43:14
LQ_EDIT
37,535,314
List topic in c++, output Explanation
This is a question from a past paper that I am having issues with, the question and output is displayed below but I don't understand how this is achieved. Can someone please explain. int main (){ int a[5] = { 1 }, b[] = { 3, -1, 2, 0, 4 }; for (int i = 0; i<5; i++) { if (!(a[i] = b[i])) // note: = not == break; cout << a[i] << endl; } } Output: 3 -1 2
<c++><if-statement><for-loop>
2016-05-31 00:56:03
LQ_EDIT
37,535,315
Where are logs located?
<p>I'm debugging a JSON endpoint and need to view internal server errors. However, my <code>app/storage/logs</code> dir is empty and it seems there are no other directories dedicated to logs in the project. I've tried googling the subject to no avail.</p> <p>How can I enable logging, if it's not already enabled and view the logs?</p>
<laravel><logging><laravel-5><laravel-5.2>
2016-05-31 00:56:11
HQ
37,535,397
calculating average and variance in c++
<p>I need help with my code... I have no idea whats wrong or how to fix it. I think it has something with declaring my variables and referencing but I am not entirely sure how to fix the bugs. Please help! </p> <pre><code>#include &lt;iostream&gt; #include &lt;iomanip&gt; #include &lt;cmath&gt; using namespace std; double calculate_average(int test_values[], int&amp; size, int&amp; sum, double&amp; average) { int i; for (i = 0; i &lt; size; i++) { sum += test_values[i]; }; return average = sum / i; }; double var(int test_values[], int size, double average, double&amp; variance) { for (int j = 0; j &lt; size; j++) { variance += pow((test_values[j] - average), 2); }; return variance; }; int main() { int test_values[] = { 89, 95, 72, 83, 99, 54, 86, 75, 92, 73, 79, 75, 82, 53 }; int size = sizeof(test_values); int sum; double average, variance; int calculate_average(int test_values[], int size, int sum, double average); int var(int test_values[], int size, double average, double variance); cout &lt;&lt; fixed &lt;&lt; showpoint &lt;&lt; setprecision(2); cout &lt;&lt; test_values &lt;&lt; endl; cout &lt;&lt; average &lt;&lt; endl; cout &lt;&lt; variance &lt;&lt; endl; return 0; } </code></pre>
<c++>
2016-05-31 01:08:36
LQ_CLOSE
37,535,441
Extract Last Word in String with Swift
<p>What is the way of extracting last word in a String in Swift? So if I have "Lorem ipsum dolor sit amet", return "amet". What is the most efficient way of doing this?</p>
<ios><string><swift>
2016-05-31 01:15:30
HQ
37,537,049
Why doesn't sumBy(selector) return Long?
<p><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/sum-by.html" rel="noreferrer">sumBy(selector)</a> returns Int</p> <p><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/sum-by-double.html" rel="noreferrer">sumByDouble(selector)</a> returns Double</p> <p>Why doesn't sumBy return Long? Is there a workaround for this?</p>
<kotlin>
2016-05-31 04:50:20
HQ
37,537,680
sql how to execute 2 select statement in a single query ,,,it is showing me
I want to count column first: as total number of instances of each column , second ,count total number of instances based on condition I am using this Select group_name, Definition_Range ,count([group_name]) as Number_of_Clients from [Computer Status] where Definition_Range =' 0-10 Days' group by group_name,(select count([group_name]) as Total_Clients from [Computer Status] group by group_name)
<sql><sql-server>
2016-05-31 05:46:28
LQ_EDIT
37,537,745
How to save HTML form data on local machine
<p>Have HTML form in that some user information is filled.want to save that information on local machine. How to do that?</p>
<asp.net-mvc>
2016-05-31 05:51:15
LQ_CLOSE
37,538,127
Date picker card for Facebook Messenger bot
<p>I know that there are various CTA cards that Facebook bot can use as seen <a href="https://developers.facebook.com/blog/post/2016/04/12/bots-for-messenger/" rel="noreferrer">here</a>.</p> <p>What I really need is a datepicker card that can be sent to the user where they can choose a date and send it back. Is this possible using Facebook bots?</p>
<facebook>
2016-05-31 06:15:48
HQ
37,538,230
how to change class from data frame to spatial polygon?
I have found the same in here <http://stackoverflow.com/questions/29736577/how-to-convert-data-frame-to-spatial-coordinates>. But in my case, I got very large data and i can do like the answer given. So anyone can help me to change classfrom data.frame to spatial polygon?
<r><dataframe><geospatial><sp>
2016-05-31 06:21:31
LQ_EDIT
37,538,243
Replacing zeros after period
I have a string a="1,2,3,4.2300" I need to replace the last two zeros which follows after '.' for an example, it has to replace the values this way. If "1,2,3,4.2300" then 1,2,3,4.23 If "1,2,3,4.20300" then 1,2,3,4.203 How could I do this in Ruby? I tried with converting into Float but it terminates the string when I encounter a ','. Can I write any regular expression for this?
<ruby>
2016-05-31 06:22:36
LQ_EDIT
37,538,758
select the option with the highest data-sale attribute
<p>kind a new to jquery and cant get my head around on this one. any help would be much appreciate.</p> <p>add checked attribute to the radio input with the highest data-attribute. </p> <p><strong>But</strong> :</p> <p><strong>A</strong>. if the radio input in the bottom of the list has an attribute disabled="disabled" select the second highest option.</p> <p>e.g.</p> <pre><code>&lt;ul class="sales"&gt; &lt;li&gt;&lt;input type="radio" data-sale="20"/&gt;&lt;/li&gt; &lt;li&gt;&lt;input type="radio" data-sale="50"/&gt;&lt;/li&gt; &lt;li&gt;&lt;input type="radio" data-sale="55"/&gt;&lt;/li&gt; &lt;li&gt;&lt;input type="radio" checked="checked" data-sale="60"/&gt;&lt;/li&gt;&lt;!--add checked attribute--&gt; &lt;li&gt;&lt;input type="radio" disabled="disabled" data-sale="90"/&gt;&lt;/li&gt; </code></pre> <p> </p> <p><strong>B</strong>. if the disabled attribute is not in the bottom of the list, still checked the highest radio.</p> <p>e.g.</p> <pre><code>&lt;ul class="sales"&gt; &lt;li&gt;&lt;input type="radio" data-sale="20"/&gt;&lt;/li&gt; &lt;li&gt;&lt;input type="radio" data-sale="50"/&gt;&lt;/li&gt; &lt;li&gt;&lt;input type="radio" disabled="disabled" data-sale="55"/&gt;&lt;/li&gt; &lt;li&gt;&lt;input type="radio" data-sale="60"/&gt;&lt;/li&gt; &lt;li&gt;&lt;input type="radio" checked="checked" data-sale="90"/&gt;&lt;/li&gt;&lt;!--add checked attribute--&gt; </code></pre> <p> </p> <p>naturally the html apply the checked in the very first radio in the list. in this case the data-sale = 20</p> <p>i have to append that data-sale attribute to a container span.</p> <p>thanks appreciate your help.</p>
<javascript><jquery><html><input><radio-button>
2016-05-31 06:53:12
LQ_CLOSE
37,539,099
Obtain a php var in another page in the current page
I would create an ajax code that load a php page every x seconds and it obtain a specific php var in the loaded page and assign the value of the obtained var to a javascript var, sorry for my bad english.
<javascript><php><ajax>
2016-05-31 07:10:19
LQ_EDIT
37,539,935
looping over array Ruby cucumber
I am trying to write a test in Cucumber using Ruby. I have an array: contacts = Array.new(arg1, arg2, arg3, arg4) And I want to create a loop that will take that array and fill in a field with that array. Kind of like: while contacts.index[0] < contacts.index[3] fill_in('field', with: contacts) ... contacts +=1 end I can't seem to get this to work, it tells me I've got the wrong number of arguments ArgumentError: wrong number of arguments (4 for 0..2) Is there something blindingly obvious I'm missing? Thanks
<arrays><ruby>
2016-05-31 07:52:27
LQ_EDIT
37,539,973
CSV File Generation is too slow
<p>Hi i am using the following code to generate the CSV file using the java servlet but it is taking 40mins to generate a CSV file with no. of rows 3000. is there any other optimized code which can speed up my CSV generation to 1 or 2 mins. My code is here :</p> <pre><code>protected void getCSVReportGererated(HttpServletRequest req, HttpServletResponse res) throws IOException{ ResultSet rs = null; String reportSQL = getReportSQL(); PreparedStatement ps = null; Connection con = DriverManager.getConnection("jdbc:derby://localhost:1527/testDb","username", "password"); try{ ps = conn.prepareStatement(reportSQL); ps.execute(); rs = ps.getResultSet(); res.setContentType("text/csv"); SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy-HHMM"); Date dt = new Date(); String reportName = "my_report"+sdf.format(dt)+".csv"; res.setHeader("Content-disposition", "attachment; " + "filename=" + reportName); ArrayList&lt;String&gt; rows = new ArrayList&lt;String&gt;(); rows.add("col1,col2,col3,col4,col5,col6,col7,col8,col9,col10"); rows.add("\n"); String row = null; while(rs.next()){ row = String.format("%04d", Integer.parseInt(rs.getString(1)))+","+String.format("%05d", Integer.parseInt(rs.getString(2)))+","+rs.getString(3)+","+rs.getString(4)+","+rs.getString(5)+","+rs.getString(6)+","+rs.getString(7)+","+rs.getString(8)+","+rs.getString(9)+","+rs.getString(10); rows.add(row); rows.add("\n"); } Iterator&lt;String&gt; iter = rows.iterator(); while (iter.hasNext()){ String outputString = (String) iter.next(); res.getOutputStream().print(outputString); } res.getOutputStream().flush(); }catch(SQLException e){ e.printStackTrace(); }finally{ try { if (ps != null) ps.close(); if (conn != null) conn.close(); if(rs != null) rs.close(); } catch (SQLException e) { e.printStackTrace(); } } } </code></pre>
<java><performance><csv><servlets>
2016-05-31 07:54:04
LQ_CLOSE
37,540,604
How to clear master.dbo.sysprocesses ?
I see all connection session by query statement: Select * From master.dbo.sysprocesses And i try to clear by statement: Delete From master.dbo.sysprocesses or Truncate table master.dbo.sysprocesses or update but not allow. [How to clear master.dbo.sysprocesses][1] Please help me know how to clear or update ***master.dbo.sysprocesses*** ? Thank you very much! [1]: http://i.stack.imgur.com/q1AmQ.png
<sql><sql-server>
2016-05-31 08:28:46
LQ_EDIT
37,540,616
Do we have any possibility to stop request in OkHttp Interceptor?
<p>In our app we met with one special case - if our <code>App.specialFlag == true</code>, we need stop any request from our code. And we think, that the best approach in this situation is include special <code>Interceptor</code> which will stop any our requests, something like this:</p> <pre><code>if (App.specialFlag) { // Somehow stop request } else { return chain.proceed(chain.request()); } </code></pre> <p>Also, we should note, that we use <code>RxJavaCallAdapterFactory</code> for wrapping responses into <code>Observable</code>s.</p> <p>But we don't see any methods for stopping request in OkHttp Interceptors. </p> <p>We came up with two ways to solve our issue:</p> <p>a) Create special <code>ApiService.class</code> for wrapping every request in our API like this:</p> <pre><code>public Observable&lt;User&gt; getUserDetails() { if (App.specialFlag) { return Observable.just(null); } return api.getUserDetails(); } </code></pre> <p>But we think that it is ugly and cumbersome solution.</p> <p>b) Throw a <code>RuntimeException</code> in Interceptor, then catch it in every place we use our API. </p> <p>The second solution is also not good, because we need to include a lot of <code>onErrorResumeNext</code> operators in our chains.</p> <p>May be someone knows, how to handle our situation in more 'clever' way?..</p> <p>Thanks in advance!</p>
<android><retrofit><rx-java><okhttp>
2016-05-31 08:29:25
HQ
37,540,683
How see total app installs on iTunes Connect?
<p>I see on iTunes Connect in AppAnalytics/SalesAndTrends sections only app units (that means the difference of app installs from previous week/month). Where can I see the total app installs number? Thanks </p>
<ios><app-store-connect><itunes-store>
2016-05-31 08:32:51
HQ
37,540,753
How do I generate a list of the text with that has given color with MS Word?
I am looking for a way to create a new document containing all the text with a specific format from my document. See below for what I wrote so far, but I'm stuck at two points: - how do I stop my loop when end of document is reached? - how do I add intelligence to my code to avoid a static loop, and rather do a "scan all my document"? ---- Option Explicit Sub Macro1() Dim objWord As Application Dim objDoc As Document Dim objSelection As Selection Dim mArray() As String Dim i As Long Dim doc As Word.Document For i = 1 To 100 ReDim Preserve mArray(i) With Selection.Find .ClearFormatting .Font.Color = wdColorBlue .Text = "" .Replacement.Text = "" .Forward = True .Wrap = wdFindStop .Format = True .Execute End With mArray(i) = Selection.Text Next Set objWord = CreateObject("Word.Application") Set objDoc = objWord.Documents.Add objWord.Visible = True Set objSelection = objWord.Selection For i = 1 To 100 objSelection.TypeText (mArray(i)) Next End Sub Any help appreciated.
<vba><ms-word><format><find-replace>
2016-05-31 08:36:21
LQ_EDIT
37,541,106
Angular 2 radio button events
<p>What are those events called in Angular 2 when radio button is selected or unselected.</p> <p>Something like </p> <pre><code>&lt;input type="radio" (select)="selected()" (unselect)="unselected()" /&gt; </code></pre> <p>So when I click one radio button in a group, it will fire <code>selected()</code> for the new selection and <code>unselected()</code> for the previous selection.</p>
<javascript><html><css><dom><angular>
2016-05-31 08:53:39
HQ
37,542,085
Django - 'datetime.date' object has no attribute 'tzinfo'
<p>Here is my code that I use to make the datetime timezone aware. I tried to use the recommended approach from the Django docs. </p> <pre><code>tradeDay = day.trade_date + timedelta(hours=6) td1 = pytz.timezone("Europe/London").localize(tradeDay, is_dst=None) tradeDay = td1.astimezone(pytz.utc) </code></pre> <p>I get the tz_info error. How can I datetime a tz_info attribute? </p> <blockquote> <p>USE_TZ = True in settings.py</p> </blockquote>
<python-2.7><datetime><timezone><django-1.8>
2016-05-31 09:37:16
HQ
37,543,203
deep copy arraylist in java
Is this way of overriding `clone` correct? I am getting a runtime error every time. Also can anybody suggest a way to write copy constructor in this class. public class Pair { final StringBuffer x; final StringBuffer y; public Pair(StringBuffer x, StringBuffer y) { this.x = x; this.y = y; } public StringBuffer getX(){ return x; } public StringBuffer getY(){ return y; } public Pair clone(){ Pair p = new Pair(new StringBuffer(), new StringBuffer()); try{ p = (Pair)super.clone(); } catch (CloneNotSupportedException e) { throw new Error(); } return p; } }
<java><deep-copy>
2016-05-31 10:29:55
LQ_EDIT
37,544,306
Travis: different `script` for different branch?
<p>I'd like to setup deployment based on branches using Travis-CI and Github.</p> <p>I.e. - if we made build from <code>develop</code> - then exec <code>/deploy.rb</code> with DEV env hostname, if <code>master</code> - then <code>./deploy.rb</code> with PROD hostname and so on.</p> <p>Only one idea I found - is to check <code>$TRAVIS_BRANC</code> variable and then execute script, like:</p> <pre><code>language: php install: - true script: - test $TRAVIS_BRANCH = "develop" &amp;&amp; ./ci/deploy.rb envdev.tld - test $TRAVIS_BRANCH = "master" &amp;&amp; ./ci/deploy.rb envprod.tld </code></pre> <p>But this solution looks a bit weird as for me. Any other possibilities to realize that?</p> <p>Any tips/links appreciated.</p>
<travis-ci>
2016-05-31 11:20:43
HQ
37,544,406
Spring Security OAuth2 - How to use OAuth2Authentication object?
<p>I have OAuth2 authorization server which provides user information:</p> <pre><code>public class User implements Serializable, UserDetails { private Long userID; private String username; private String password; private String fullName; private String email; private String avatar; private boolean enabled; // etc } @RestController @RequestMapping("/api") public class APIController { @RequestMapping("/me") public User me(@AuthenticationPrincipal User activeUser) { return activeUser; } } </code></pre> <p>Also I've implemented OAuth2 client as separate Spring Boot application.</p> <pre><code>@Configuration @EnableOAuth2Sso public class OAuth2ClientConfig extends WebSecurityConfigurerAdapter { @Override public void configure(HttpSecurity http) throws Exception { http.logout() .and() .antMatcher("/**").authorizeRequests() .antMatchers("/login").permitAll() .anyRequest().authenticated(); } } </code></pre> <p><strong>application.yml</strong></p> <pre><code>security: user: password: none oauth2: client: clientId: acme clientSecret: acmepassword accessTokenUri: http://localhost:9080/sso/oauth/token userAuthorizationUri: http://localhost:9080/sso/oauth/authorize resource: userInfoUri: http://localhost:9080/sso/api/me </code></pre> <p>User authenticates successfully:</p> <pre><code>@Controller public class MainController { @RequestMapping(value = "/") public String index(Principal principal) { System.out.println(principal); // org.springframework.security.oauth2.provider.OAuth2Authentication@c2e723e8: Principal: superadmin; Credentials: [PROTECTED]; Authenticated: true; Details: remoteAddress=&lt;ADDRESS&gt;, sessionId=&lt;SESSION&gt;, tokenType=bearertokenValue=&lt;TOKEN&gt;; Granted Authorities: {userRoleID=1, authority=ROLE_SUPERUSER} OAuth2Authentication auth = (OAuth2Authentication) principal; System.out.println(auth.getUserAuthentication().getDetails()); // {userID=1, username=superadmin, password=***, fullName=SuperUser, email=superadmin@example.org, avatar=null, enabled=true ... return "index"; } } </code></pre> <p>But I can't understand how to use provided OAuth2Authentication object in my application. It almost useless.</p> <p>When I'm trying to use any Thymeleaf security tag</p> <pre><code>&lt;span sec:authentication="principal.fullName"&gt;Username&lt;/span&gt; &lt;span sec:authentication="principal.authorities"&gt;Authorities&lt;/span&gt; &lt;span sec:authentication="principal.userAuthentication.details.fullName"&gt;Usernames&lt;/span&gt; </code></pre> <p>.. the following exception occurs:</p> <pre><code>Error retrieving value for property "property name here" of authentication object of class org.springframework.security.oauth2.provider.OAuth2Authentication </code></pre> <p>Standard Spring Security methods <code>isUserInRole()</code> not working too:</p> <pre><code>System.out.println(servletRequest.isUserInRole("ROLE_SUPERUSER")); // false </code></pre> <p>Should I implement custom Thymeleaf security dialect and hasRole() method? Or maybe simpler solution exists?</p>
<java><spring-mvc><spring-security><spring-boot><spring-security-oauth2>
2016-05-31 11:25:36
HQ
37,544,410
sonar-maven-plugin: extending sonar.sources in multi-module project
<p>I want to extend <code>sonar.sources</code>, which by default is <code>pom.xml,src/main/java</code>, by <code>src/main/resources</code> in order to check XML files that are located there.</p> <p>This seemingly simple task turned out to be difficult since I have a multi-module maven project (> 100 modules, nested) with a lot of them don't have a <code>src/main/resources</code> folder and most of them not even a <code>src</code> folder (e.g. for packaging=pom). This leads to a build error if I set <code>sonar.sources</code> to <code>pom.xml,src/main/java,src/main/resources</code> or <code>pom.xml,src/main</code>:</p> <pre><code>[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.5:sonar (default-cli) on project xyz-parent: The directory 'C:\...\submodule\src\main\resources' does not exist for Maven module ... Please check the property sonar.sources -&gt; [Help 1] </code></pre> <p>The sonar-maven-plugin itself uses <code>${project.build.sourceDirectory}</code> to do it right in every module.</p> <p>I tried to use regular expressions to set <code>sonar.sources</code> to <code>src/main</code> by cutting off <code>/java</code> (or <code>\java</code> on Windows) via</p> <pre><code>&lt;plugin&gt; &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt; &lt;artifactId&gt;build-helper-maven-plugin&lt;/artifactId&gt; &lt;version&gt;1.7&lt;/version&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;regex-property&lt;/id&gt; &lt;goals&gt; &lt;goal&gt;regex-property&lt;/goal&gt; &lt;/goals&gt; &lt;configuration&gt; &lt;name&gt;sonar.sources&lt;/name&gt; &lt;value&gt;${project.build.sourceDirectory}&lt;/value&gt; &lt;regex&gt;[/\\]+java$&lt;/regex&gt; &lt;replacement&gt;&lt;/replacement&gt; &lt;failIfNoMatch&gt;false&lt;/failIfNoMatch&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; </code></pre> <p>But this does nothing and I have no idea to which lifecycle phase I should bind it to have it executed.</p> <p>Or is there a way to avoid the error due to missing directory in <code>sonar.sources</code>? According to <a href="https://github.com/SonarSource/sonar-maven/blob/master/src/main/java/org/sonarsource/scanner/maven/bootstrap/MavenProjectConverter.java#L433" rel="noreferrer">current sonar-maven source</a> missing directories are only ignored if the POM has <code>pom</code> packaging but not for <code>ear</code> or <code>jar</code> modules without resources.</p> <p>Or should I ensure <code>src/main</code> exists before sonar start? What hook may I use for that?</p>
<java><maven><sonarqube>
2016-05-31 11:25:39
HQ
37,546,045
SQL group_by query
<p>I have a table name users. Assume in the table I have the following fields :</p> <p>User id , UUID1 , UUID2</p> <p>I am trying to build the following SQL query the will return : .number of rows including both the same UUID1 and UUID2. not that UUID1 equal UUID2 but just number of row including both (GROUP BY) and in addition the number of rows contains UUID1 or UUID2 (Separately, no grouping).</p> <p>So I would like to have a table output as followed : UUID1 , UUID2, Number_of_Rows_Contain_both, Number_Of_Rows_Contains_Only_Only_One</p> <p>Any idea how can I generate such a query ?</p>
<sql>
2016-05-31 12:40:43
LQ_CLOSE
37,546,086
Cannot find var in python
<p>At the beginning of my program, I am defining a simple object which sets the configuration for how I am going to call a service. Like so : </p> <pre><code>document_conversion = DocumentConversionV1( username='xxx', password='xxx', version='2016-05-31') </code></pre> <p>I then want to call a service on all files in a directory. I try to do it like so, but I believe the config object cannot be found - it seems to be out of scope, I get this error: </p> <pre><code>NameError: name 'config' is not defined </code></pre> <p>Here is what I have directly after the object creation : </p> <pre><code>yourpath = 'C:\\Users\\Desktop\\working_folder\\' for root, dirs, files in os.walk(yourpath, topdown=False): for name in files: print(os.path.join(root, name)) config['conversion_target'] = DocumentConversionV1.ANSWER_UNITS with open(join(dirname(__file__), os.path.join(root, name)), 'r') as document: print(json.dumps(document_conversion.convert_document(document=document, config=config), indent=2)) </code></pre> <p>I've tried defining the config object within the for loop/within the with clause, but it still seems to not work. Curiously, if I remove the for loop from the above, it does seem to work (if ran on one file, rather than a folder).</p> <p>Any ideas what could be the problem here ?</p> <p>Thanks</p>
<python><loops><python-3.x><scope><pycharm>
2016-05-31 12:42:33
LQ_CLOSE
37,546,656
Handling oauth2 redirect from electron (or other desktop platforms)
<p>This is mostly a lack of understanding of oauth2 and probably not specific to electron, however I'm trying to wrap my head around how someone would handle an oauth2 redirect url from a desktop platform, like electron?</p> <p>Assuming there is no webservice setup as part of the app, how would a desktop application prompt a user for credentials against a third party oauth2 service, and then authenticate them correctly?</p>
<javascript><oauth-2.0><electron>
2016-05-31 13:08:05
HQ
37,546,770
Python, choose logging files' directory
<p>I am using the Python logging library and want to choose the folder where the log files will be written.</p> <p>For the moment, I made an instance of TimedRotatingFileHandler with the entry parameter filename="myLogFile.log" . This way myLogFile.log is created on the same folder than my python script. I want to create it into another folder.</p> <p>How could I create myLogFile.log into , let's say, the Desktop folder?</p> <p>Thanks, Matias </p>
<python><logging>
2016-05-31 13:13:25
HQ
37,547,748
Why this code doesn't print some value?
i don't understand why when i try to print values in "archivio[]" with "stampa" function,this program prints "studente","matricola","nome","cognome" correctly, but doesn't print values from "stampaEsami". #include <stdio.h> #include <stdlib.h> #define MAXSTUDENTI 20 #define MAXSTRINGA 100 #define MAXESAMI 25 /* run this program using the console pauser or add your own getch, system("pause") or input loop */ typedef char Stringa[MAXSTRINGA]; typedef enum { uno, due, tre, FC } AnnoCorso; typedef struct { Stringa nomeEsame; int voto; } Esame; typedef struct { Esame listaEsami[MAXESAMI]; int numeroEsami; }ListaEsame; typedef struct { int matricola; Stringa nome; Stringa cognome; AnnoCorso anno; ListaEsame esami; } Studente; void init(Studente[], int); void acquisisciEsami(Studente, int); void stampa(Studente[], int); void stampaEsami(ListaEsame); void init(Studente archivio[], int n){ int i; int nEsami; for(i = 0; i < n; i++){ printf("Studente n. %d\n", i+1); printf("Inserire matricola: "); scanf("%d", &archivio[i].matricola); printf("Inserire nome: "); scanf("%s", &archivio[i].nome); printf("Inserire cognome: "); scanf("%s", &archivio[i].cognome); printf("Inserire il numero di esami svolti: "); scanf("%d", &archivio[i].esami.numeroEsami); nEsami = archivio[i].esami.numeroEsami; if(nEsami != 0) { acquisisciEsami(archivio[i], nEsami); } } } void acquisisciEsami(Studente studente, int n){ int i; for(i = 0; i < n; i++) { printf("Inserire nome esame:"); scanf("%s", studente.esami.listaEsami[i].nomeEsame); printf("Inserire voto esame:"); scanf("%d", &studente.esami.listaEsami[i].voto); } } void stampa(Studente archivio[], int n){ printf("\nGli studenti presenti in archivio sono:\n"); int i; for(i = 0; i < n; i++){ printf("Studente n. %d:\n", i+1); printf("Matricola: %d\n", archivio[i].matricola); printf("Nome: %s\n", archivio[i].nome); printf("Cognome: %s\n", archivio[i].cognome); stampaEsami(archivio[i].esami); } } void stampaEsami(ListaEsame esami){ int i = 0; int n = esami.numeroEsami; for(i = 0; i < n; i++){ printf("Nome esame: %s\n", esami.listaEsami[i].nomeEsame ); printf("Voto esame: %d\n", esami.listaEsami[i].voto); } } int main(int argc, char *argv[]) { Studente studenti[MAXSTUDENTI] ; int n; printf("Inserire il numero di studenti da memorizzare in archivio:\n "); scanf("%d", &n); init(studenti, n); stampa(studenti, n); return 0; }
<c>
2016-05-31 13:55:13
LQ_EDIT
37,548,045
Django Oauth Toolkit Application Settings
<p>Django Oauth Toolkit docs don't describe the redirect uris, authorization grant type, or client type fields when registering your application.</p> <p>The tutorial says to set client type to confidential, grant type to password, and leave uris blank.</p> <p>What do the other options do?</p> <p>e.g. What is client type public vs confidential? What do the grant type password, credentials, authorization, implicit do? And what are the redirect uris for?</p> <p>I have found sparse information about them but no actual explanations as they pertain to django rest framework and django oauth toolkit.</p>
<django><oauth><django-rest-framework>
2016-05-31 14:07:49
HQ
37,548,734
tsc throws `TS2307: Cannot find module` for a local file
<p>I've got a simple example project using TypeScript: <a href="https://github.com/unindented/ts-webpack-example" rel="noreferrer">https://github.com/unindented/ts-webpack-example</a></p> <p>Running <code>tsc -p .</code> (with <code>tsc</code> version 1.8.10) throws the following:</p> <pre><code>app/index.ts(1,21): error TS2307: Cannot find module 'components/counter'. components/button/index.ts(2,22): error TS2307: Cannot find module 'shared/backbone_base_view'. components/button/index.ts(3,25): error TS2307: Cannot find module 'shared/backbone_with_default_render'. components/counter/index.ts(2,22): error TS2307: Cannot find module 'shared/backbone_base_view'. components/counter/index.ts(3,25): error TS2307: Cannot find module 'shared/backbone_with_default_render'. components/counter/index.ts(4,27): error TS2307: Cannot find module 'shared/backbone_with_subviews'. components/counter/index.ts(5,20): error TS2307: Cannot find module 'components/button'. </code></pre> <p>It complains about all imports of local files, like the following:</p> <pre><code>import Counter from 'components/counter'; </code></pre> <p>If I change it to a relative path it works, but I don't want to, as it makes my life more difficult when moving files around:</p> <pre><code>import Counter from '../components/counter'; </code></pre> <p>The <code>vscode</code> codebase does not use relative paths, but everything works fine for them, so I must be missing something in my project: <a href="https://github.com/Microsoft/vscode/blob/0e81224179fbb8f6fda18ca7362d8500a263cfef/src/vs/languages/typescript/common/typescript.ts#L7-L14" rel="noreferrer">https://github.com/Microsoft/vscode/blob/0e81224179fbb8f6fda18ca7362d8500a263cfef/src/vs/languages/typescript/common/typescript.ts#L7-L14</a></p> <p>You can check out my GitHub repo, but in case it helps here's the <code>tsconfig.json</code> file I'm using:</p> <pre><code>{ "compilerOptions": { "target": "es5", "module": "commonjs", "noImplicitAny": false, "removeComments": false, "preserveConstEnums": true, "sourceMap": true, "outDir": "dist" }, "exclude": [ "dist", "node_modules" ] } </code></pre> <p>Funny thing is, building the project through <code>webpack</code> using <code>ts-loader</code> works fine, so I'm guessing it's just a configuration issue...</p>
<typescript>
2016-05-31 14:40:37
HQ
37,548,837
python , changing dictionary values with iteration
<p>I have the following:</p> <pre><code>max_id = 10 for i in range(max_id): payload = "{\"text\": 'R'+str(i),\"count\":\"1 \",}" print(payload) </code></pre> <p>I want to iterate through this , and have the value of text be set to "R1", "R2" ... Upon debugging the output is:</p> <pre><code>{"text": 'R'+str(i),"count":"1",} </code></pre> <p>What am I doing wrong?</p>
<python>
2016-05-31 14:44:29
LQ_CLOSE
37,549,004
detect if pressing a mouse button and wich WinForm c#
I don't want to click on a button or the form, I just want to know if user is pressing the left mouse button while the cursor is in the form. I've tried this: private void PlayForm_KeyDown(object sender, KeyEventArgs e) { if(e.KeyCode == Keys.LButton) { ... } } but it doesn't work. I also tried `PlayForm_Click()` but it works only when the click is on the 'canvas' if there's something else on top it won't work
<c#><winforms>
2016-05-31 14:51:41
LQ_EDIT
37,550,584
Error using Jack compiler - app/build/intermediates/packaged/debug/classes.zip' is an invalid library
<p>I am getting these errors while using Jack compiler, but I don't understand what is the problem:</p> <pre><code>Error:Library reading phase: file '/Users/daniele.vitali/Development/android-studio/INTROCKAND/app/build/intermediates/packaged/debug/classes.zip' is an invalid library com.android.jack.api.v01.CompilationException: Library reading phase: file '/Users/daniele.vitali/Development/android-studio/INTROCKAND/app/build/intermediates/packaged/debug/classes.zip' is an invalid library at com.android.jack.api.v01.impl.Api01ConfigImpl$Api01CompilationTaskImpl.run(Api01ConfigImpl.java:113) at com.android.builder.core.AndroidBuilder.convertByteCodeUsingJackApis(AndroidBuilder.java:1821) at com.android.builder.core.AndroidBuilder.convertByteCodeUsingJack(AndroidBuilder.java:1694) at com.android.build.gradle.internal.transforms.JackTransform.runJack(JackTransform.java:222) at com.android.build.gradle.internal.transforms.JackTransform.transform(JackTransform.java:196) at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:174) at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:170) at com.android.builder.profile.ThreadRecorder$1.record(ThreadRecorder.java:55) at com.android.builder.profile.ThreadRecorder$1.record(ThreadRecorder.java:47) at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:169) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.doExecute(AnnotationProcessingTaskFactory.java:244) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:220) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.execute(AnnotationProcessingTaskFactory.java:231) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:209) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46) at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35) at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64) at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58) at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52) at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52) at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53) at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185) at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66) at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:25) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:110) at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37) at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37) at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23) at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43) at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32) at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37) at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30) at org.gradle.initialization.DefaultGradleLauncher$4.run(DefaultGradleLauncher.java:154) at org.gradle.internal.Factories$1.create(Factories.java:22) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:52) at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:151) at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:32) at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:99) at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:93) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:62) at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:93) at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:82) at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:94) at org.gradle.tooling.internal.provider.runner.BuildModelActionRunner.run(BuildModelActionRunner.java:46) at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35) at org.gradle.tooling.internal.provider.runner.SubscribableBuildActionRunner.run(SubscribableBuildActionRunner.java:58) at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35) at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:43) at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28) at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:78) at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:48) at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:52) at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74) at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72) at org.gradle.util.Swapper.swap(Swapper.java:38) at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.health.DaemonHealthTracker.execute(DaemonHealthTracker.java:47) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:66) at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:72) at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.health.HintGCAfterBuild.execute(HintGCAfterBuild.java:41) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50) at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:246) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54) at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Error:com.android.jack.JackAbortException: Library reading phase: file '/Users/daniele.vitali/Development/android-studio/INTROCKAND/app/build/intermediates/packaged/debug/classes.zip' is an invalid library at com.android.jack.incremental.IncrementalInputFilter.&lt;init&gt;(IncrementalInputFilter.java:201) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at com.android.sched.util.config.ReflectFactory.create(ReflectFactory.java:90) at com.android.jack.Jack.buildSession(Jack.java:846) at com.android.jack.Jack.run(Jack.java:475) at com.android.jack.api.v01.impl.Api01ConfigImpl$Api01CompilationTaskImpl.run(Api01ConfigImpl.java:102) ... 93 more Error:com.android.jack.library.LibraryReadingException: Library reading phase: file '/Users/daniele.vitali/Development/android-studio/INTROCKAND/app/build/intermediates/packaged/debug/classes.zip' is an invalid library at com.android.jack.incremental.IncrementalInputFilter.&lt;init&gt;(IncrementalInputFilter.java:199) ... 101 more Error:com.android.jack.library.LibraryFormatException: file '/Users/daniele.vitali/Development/android-studio/INTROCKAND/app/build/intermediates/packaged/debug/classes.zip' is an invalid library ... 102 more :app:transformJackWithJackForDebug FAILED Error:Execution failed for task ':app:transformJackWithJackForDebug'. &gt; com.android.build.api.transform.TransformException: com.android.jack.api.v01.CompilationException: Library reading phase: file '/Users/daniele.vitali/Development/android-studio/INTROCKAND/app/build/intermediates/packaged/debug/classes.zip' is an invalid library Information:BUILD FAILED Information:Total time: 1 mins 53.934 secs Information:5 errors Information:0 warnings Information:See complete output in console </code></pre> <p>I am using Android Studio 2.2 Preview 2 with the following dependencies:</p> <pre><code>ext { //Android config compileSdkVersion = 23 buildToolsVersion = '24.0.0 rc4' minSdkVersion = 16 targetSdkVersion = 23 //Libraries supportLibrariesVersion = '24.0.0-beta1' lombokVersion = '1.16.8' guavaVersion = '19.0' gsonVersion = '2.6.2' butterKnifeVersion = '8.0.1' rxAndroidVersion = '1.2.0' firebaseVersion = '9.0.1' frescoVersion = '0.10.0' jUnitVersion = '4.12' mockitoVersion = '2.0.54-beta' hamcrestVersion = '2.0.0.0' daggerVersion = '2.4' googlePlayServicesVersion = '9.0.1' circularImageViewVersion = '2.0.0' bottomBarVersion = '1.3.4' } </code></pre> <p>I am using also Gradle plugin 2.2.0 alpha 2 and com.google.gms:google-services:3.0.0</p> <p>Any help is highly appreciated.</p>
<android><android-jack-and-jill>
2016-05-31 16:03:49
HQ
37,550,993
RStudio installation failure under Debian sid: libgstreamer dependency problems
<p>I use Debian sid (amd64), rolling updates as often as weekly. I downloaded recently the desktop version 0.99.902 of RStudio from their offical site and issued (as root, of course):</p> <p>dpkg -i rstudio-0.99.902-amd64.deb</p> <p>to no avail:</p> <p>dpkg: dependency problems prevent configuration of rstudio: rstudio depends on libgstreamer0.10-0; however: Package libgstreamer0.10-0 is not installed. rstudio depends on libgstreamer-plugins-base0.10-0; however: Package libgstreamer-plugins-base0.10-0 is not installed.</p> <p>Newer versions (1.0-0) of these 2 packages are installed on the system, but those older ones (0.10-0) are not available anymore on the official Debian repos.</p> <p>What should be done to have RStudio installed and fully operational under Debian sid? I have, of course, installed R debs, from official Debian repositories, without any issues...</p> <p>Thanks for any help!</p>
<r><debian><rstudio><gstreamer>
2016-05-31 16:24:02
HQ
37,551,130
Matlab repmat into long single dismension array?
<p>I'm trying to take: </p> <pre><code>a = [1 2 3] </code></pre> <p>and repeat it 5 times to get: </p> <pre><code>b = [1 2 3 1 2 3 1 2 3 1 2 3 1 2 3] </code></pre> <p>but when I try: </p> <pre><code>b = repmat(a, 5, 1) </code></pre> <p>instead I get: </p> <pre><code> b = 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 </code></pre> <p>I could probably do it with a for loop but I'd like to do it correctly if possible. Any suggestions? Thanks in advance</p>
<arrays><matlab><dimensions>
2016-05-31 16:32:33
LQ_CLOSE
37,551,576
How to make a phone call in Xamarin.Forms by clicking on a label?
<p>Hello I have an app i'm working on in Xamarin.Forms that gets contact info from a web service and then displays that info in labels however I want to make the label that lists the phone number to make a call when clicked. How do I go about doing this?</p> <p>Heres in my XAML:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="ReadyMo.ContactInfo"&gt; &lt;ContentPage.Content&gt; &lt;Frame Padding="0,0,0,8" BackgroundColor="#d2d5d7"&gt; &lt;Frame.Content&gt; &lt;Frame Padding="15,15,15,15" OutlineColor="Gray" BackgroundColor="White"&gt; &lt;Frame.Content&gt; &lt;ScrollView Orientation="Vertical" VerticalOptions="FillAndExpand"&gt; &lt;StackLayout Padding="20,0,0,0" Orientation="Horizontal" HorizontalOptions="CenterAndExpand"&gt; &lt;StackLayout Orientation="Vertical" VerticalOptions="FillAndExpand"&gt; &lt;Label Text="Emergency Coordinators" HorizontalOptions="Center" FontFamily="OpenSans-Light" FontSize="20" TextColor="#69add1"&gt; &lt;/Label&gt; &lt;Label x:Name="CountyName" HorizontalOptions="Center" FontFamily="OpenSans-Light" FontSize="16" TextColor="#69add1"&gt; &lt;/Label&gt; &lt;Label x:Name="FirstName" HorizontalOptions="Center"&gt; &lt;/Label&gt; &lt;Label x:Name ="LastName" HorizontalOptions="Center"&gt; &lt;/Label&gt; &lt;Label x:Name="County" HorizontalOptions="Center"&gt; &lt;/Label&gt; &lt;Label x:Name ="Adress" HorizontalOptions="Center"&gt; &lt;/Label&gt; &lt;Label x:Name ="City" HorizontalOptions="Center"&gt; &lt;/Label&gt; //This is the label that displays the phone number! &lt;Label x:Name="Number" HorizontalOptions="Center"&gt; &lt;/Label&gt; &lt;/StackLayout&gt; &lt;/StackLayout&gt; &lt;/ScrollView&gt; &lt;/Frame.Content&gt; &lt;/Frame&gt; &lt;/Frame.Content&gt; &lt;/Frame&gt; &lt;/ContentPage.Content&gt; &lt;/ContentPage&gt; </code></pre> <p>heres my code behind:</p> <pre><code>using Newtonsoft.Json; using ReadyMo.Data; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Net.Http; using System.Text; using System.Threading.Tasks; using Xamarin.Forms; namespace ReadyMo { public partial class ContactInfo : ContentPage { private County item; public ContactInfo() { InitializeComponent(); var contactpagetext = ContactManager.GetContactString(item.id); } public ContactInfo(County item) { InitializeComponent(); this.item = item; //var contactpagetext = ContactManager.GetContactString(item.id).Result; //Emergency Coordinators Code ContactInfoModel TheContactInfo = ContactManager.CurrentContactInfo; CountyName.Text = TheContactInfo.name; FirstName.Text = TheContactInfo.First_Name; LastName.Text = TheContactInfo.Last_Name; Adress.Text = TheContactInfo.Address1; City.Text = TheContactInfo.Address2; Number.Text = TheContactInfo.BusinessPhone; } } } </code></pre> <p>Thanks in advance!</p>
<c#><xamarin><xamarin.android><xamarin.forms>
2016-05-31 16:56:59
HQ
37,551,900
Index and length must refer to a location within the string when I try to add an extra digit?
<p>Hello so I have a program that generates a Key when you fill in some info in some text boxes. When ever I generate a key that adds an extra 1 or 0 it tells me Index and length must refer to a location within the string, this is the code: </p> <pre><code>public virtual string GenerateKey(string BreedPub) { return GenerateKey() + BreedPub.Substring(0, 3); } </code></pre> <p>and I think it's conflicting with this:</p> <pre><code>public override string GenerateKey(string BreedPub) { string key = null; if (Pedigree == "1") { key = GenerateKey() + BreedPub.Substring(0, 3) + "1"; } else { key = GenerateKey() + BreedPub.Substring(0, 3) + "0"; } return key; </code></pre> <p>now i've tried to change the substring to (0,4) or doing this:</p> <pre><code>public virtual string GenerateKey(string BreedPub) { if (Pedigree == "1") { return GenerateKey() + BreedPub.Substring(0, 3) + "1"; } else if (Pedigree == "0") { return GenerateKey() + BreedPub.Substring(0, 3) + "0"; } else { return GenerateKey() + BreedPub.Substring(0, 3); } } </code></pre> <p>but it still gives me the same error message, what could I be doing wrong?</p>
<c#>
2016-05-31 17:17:01
LQ_CLOSE
37,552,403
dumb-init No such file or directory
<p>I am trying to use dumb-init to run a script that tests a jetty servlet in my docker container, but whenever I try to call dumb-init it fails with the message:</p> <pre><code>local-test | [dumb-init] /var/lib/jetty/testrun.bash: No such file or directory </code></pre> <p>But if I use bash instead of dumb-init it happily runs. The file exists and has the correct permissions. I even stripped out the execution and just left the bang and an echo statement and it fails the same way. The script looks like:</p> <pre><code>#!/bin/dumb-init /bin/bash echo "Tests Running!" </code></pre> <p>Any thoughts?</p>
<docker><dockerfile>
2016-05-31 17:46:08
HQ
37,552,524
how to input JSON data with dynamic data array
person 1 input data with data array like this : {"type":"1","name":"John", "phone":"898171"} person 2 not set the phone, like this : {"type":"1","name":"Lisa"} // only write 2 array... I have source code in my controller like this : $data = json_decode(file_get_contents('php://input'), true); if(!$data['phone']->iSEmpty){ echo "you haven't set the phone number!" } but is not working.. error when second person input data.. "Undefined index: phone" Sorry for my bad english btw...
<php><arrays><json><laravel>
2016-05-31 17:54:02
LQ_EDIT
37,552,876
Swift Custom NavBar Back Button Image and Text
<p>I need to customise the look of a back button in a Swift project.</p> <p>Here's what I have: <a href="https://i.stack.imgur.com/WBW7p.png" rel="noreferrer"><img src="https://i.stack.imgur.com/WBW7p.png" alt="Default Back Button"></a></p> <p>Here's what I want: <a href="https://i.stack.imgur.com/KaGCs.png" rel="noreferrer"><img src="https://i.stack.imgur.com/KaGCs.png" alt="Custom Back Button"></a></p> <p>I've tried creating my own UIBarButtonItem but I can't figure out how to get the image to be beside the text, rather than as a background or a replacement for the text.</p> <pre><code>let backButton = UIBarButtonItem(title: "Custom", style: .Plain, target: self, action: nil ) //backButton.image = UIImage(named: "imageName") //Replaces title backButton.setBackgroundImage(UIImage(named: "imageName"), forState: .Normal, barMetrics: .Default) // Stretches image navigationItem.setLeftBarButtonItem(backButton, animated: false) </code></pre>
<ios><swift><uinavigationcontroller><uikit><uibarbuttonitem>
2016-05-31 18:15:45
HQ
37,552,957
Shopping cart help PHP : Unique user
<p>I have one unresolved issue. I have a shopping cart on my local website.</p> <p>Any type of user can make a order. With registered - it's ok, understandable. But what i can do, if user is not authorized, has disabled cookies and javascript? How should i make unique 'quest' user? I thought about IP addr, but it can be dynamic or You can visit web site through proxy, so that is not a solution?</p> <p>Any ideas?</p>
<php><shopping-cart><cart><shop>
2016-05-31 18:20:15
LQ_CLOSE
37,552,980
How to bring credentials into a Docker container during build
<p>I'm wondering whether there are best practices on how to inject credentials into a Docker container during a <code>docker build</code>. In my Dockerfile I need to fetch resources webservers which require basic authentication and I'm thinking about a proper way on how to bring the credentials into the container without hardcoding them.</p> <p>What about a .netrc file and using it with <code>curl --netrc ...</code>? But what about security? I do no like the idea of having credentials being saved in a source repository together with my Dockerfile.</p> <p>Is there for example any way to inject credentials using parameters or environment variables?</p> <p>Any ideas?</p>
<docker><dockerfile><docker-build>
2016-05-31 18:21:32
HQ
37,553,185
IndexOutOfRange even when it is in range WPF
I have a very interesting question. String[] values = new String[3]; values = line.Split(';'); Console.Write("Val:" + values[0] + ", " + values[1] + ", " + values[2]); Could someone tell me why I get an "IndexOutOfRangeException" when it is in range? EDIT: The line has 3 sectors, for example "1:2:3". The console writes out the Val: ... but in the output i still get an IndexOutOfRangeException.
<arrays><wpf>
2016-05-31 18:34:02
LQ_EDIT
37,554,118
ggplot inserting space before degree symbol on axis label
<p>I'd like to put a degree symbol on the x axis but the result has an extra space that I can't seem to get rid of. The text should read 'Temperature (*C)', not 'Temperature ( *C)'. I've tried two different solutions but can't seem to get rid of the space.</p> <pre><code>ggdat&lt;-data.frame(x=rnorm(100),y=rnorm(100)) #neither of these approaches work xlab &lt;- expression(paste('Temperature (',~degree,'C)',sep='')) xlab &lt;- expression('Temperature ('*~degree*C*')') ggplot(data=ggdat,aes(x=x,y=y)) + geom_point() + labs(x=xlab) </code></pre> <p><a href="https://i.stack.imgur.com/SILdo.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/SILdo.jpg" alt="Scatter plot"></a></p> <p>Any help is appreciated!</p> <p>Ben</p>
<r><ggplot2>
2016-05-31 19:29:24
HQ
37,555,195
Is it possible to stream video from https:// (e.g. YouTube) into python with OpenCV?
<p><a href="http://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_gui/py_video_display/py_video_display.html" rel="noreferrer">This link</a> has a tidy little example of how to use python's OpenCV library, <code>cv2</code> to stream data from a camera into your python shell. I'm looking to do some experiments and would like to use the following YouTube video feed: <code>https://www.youtube.com/watch?v=oCUqsPLvYBQ</code>. </p> <p>I've tried adapting the example as follows: </p> <pre><code>import numpy as np import cv2 cap = cv2.VideoCapture('https://www.youtube.com/watch?v=oCUqsPLvYBQ') while(True): # Capture frame-by-frame ret, frame = cap.read() # Display the resulting frame cv2.imshow('frame',frame) if cv2.waitKey(1) &amp; 0xFF == ord('q'): break </code></pre> <p>Which produces the error: </p> <pre><code>WARNING: Couldn't read movie file https://www.youtube.com/watch?v=oCUqsPLvYBQ OpenCV Error: Assertion failed (size.width&gt;0 &amp;&amp; size.height&gt;0) in imshow, file /tmp/opencv20160107-29960-t5glvv/opencv-2.4.12/modules/highgui/src/window.cpp, line 261 </code></pre> <p>Is there a simple fix that would allow me to stream this video feed into my python shell via <code>cv2</code>? Not absolutely committed to <code>cv2</code>, either, if there are other libraries out there that will accomplish the same purpose. </p>
<python><opencv><video><youtube>
2016-05-31 20:37:18
HQ
37,555,281
Create kubernetes pod with volume using kubectl run
<p>I understand that you can create a pod with Deployment/Job using kubectl run. But is it possible to create one with a volume attached to it? I tried running this command:</p> <pre><code>kubectl run -i --rm --tty ubuntu --overrides='{ "apiVersion":"batch/v1", "spec": {"containers": {"image": "ubuntu:14.04", "volumeMounts": {"mountPath": "/home/store", "name":"store"}}, "volumes":{"name":"store", "emptyDir":{}}}}' --image=ubuntu:14.04 --restart=Never -- bash </code></pre> <p>But the volume does not appear in the interactive bash.</p> <p>Is there a better way to create a pod with volume that you can attach to?</p>
<kubernetes><kubectl>
2016-05-31 20:44:02
HQ
37,555,416
Amazon S3 static hosting with Namecheap DNS - How to correctly route non-www prefixed url
<p>I have been reading other posts to try to get down to the bottom of this issue... but I need some clarification.</p> <p>I am able to get all of my domain requests to hit my Amazon S3 bucket perfectly when entering www.FOO.com/MyDirectory</p> <p>If I enter FOO.com/MyDirectory without the www it will fail. </p> <p>What is the proper method to make url requests without the www route correctly to the same Amazon S3 bucket? </p> <p>Any tips would help greatly. Thanks</p>
<amazon-web-services><amazon-s3><dns>
2016-05-31 20:53:01
HQ
37,555,670
AWS Lambda can't connect to RDS instance, but I can locally?
<p>I am trying to connect to my RDS instance from a lambda. I wrote the lambda locally and tested locally, and everything worked peachy. I deploy to lambda, and suddenly it doesn't work. Below is the code I'm running, and if it helps, I'm invoking the lambda via a kinesis stream.</p> <pre><code>'use strict'; exports.handler = (event, context, handlerCallback) =&gt; { console.log('Recieved request for kinesis events!'); console.log(event); console.log(context); const connectionDetails = { host: RDS_HOST, port: 5432, database: RDS_DATABASE, user: RDS_USER, password: RDS_PASSWORD }; const db = require('pg-promise')({promiseLib: require('bluebird')})(connectionDetails); db .tx(function () { console.log('Beginning query'); return this.query("SELECT 'foobar'") .then(console.log) .catch(console.log) .finally(console.log); }) .finally(() =&gt; handlerCallback()); }; </code></pre> <p>Here is the logs from cloud watch if it helps:</p> <pre><code>START RequestId: *********-****-****-****-********* Version: $LATEST 2016-05-31T20:58:25.086Z *********-****-****-****-********* Recieved request for kinesis events! 2016-05-31T20:58:25.087Z *********-****-****-****-********* { Records: [ { kinesis: [Object], eventSource: 'aws:kinesis', eventVersion: '1.0', eventID: 'shardId-000000000000:**********************************', eventName: 'aws:kinesis:record', invokeIdentityArn: 'arn:aws:iam::******************:role/lambda_kinesis_role', awsRegion: 'us-east-1', eventSourceARN: 'arn:aws:kinesis:us-east-1:****************:stream/route-registry' } ] } 2016-05-31T20:58:25.283Z *********-****-****-****-********* { callbackWaitsForEmptyEventLoop: [Getter/Setter], done: [Function], succeed: [Function], fail: [Function], logGroupName: '/aws/lambda/apiGatewayRouteRegistry-development', logStreamName: '2016/05/31/[$LATEST]******************', functionName: 'apiGatewayRouteRegistry-development', memoryLimitInMB: '128', functionVersion: '$LATEST', getRemainingTimeInMillis: [Function], invokeid: '*********-****-****-****-*********', awsRequestId: '*********-****-****-****-*********', invokedFunctionArn: 'arn:aws:lambda:us-east-1:*************:function:apiGatewayRouteRegistry-development' } END RequestId: *********-****-****-****-********* REPORT RequestId: *********-****-****-****-********* Duration: 20003.70 ms Billed Duration: 20000 ms Memory Size: 128 MB Max Memory Used: 22 MB 2016-05-31T20:58:45.088Z *********-****-****-****-********* Task timed out after 20.00 seconds </code></pre>
<javascript><amazon-web-services><amazon-rds><aws-lambda><amazon-kinesis>
2016-05-31 21:09:55
HQ
37,556,751
Could you please explain this statement by providing an implementation of the design pattern it alludes to?
<p>The <a href="https://msdn.microsoft.com/en-us/library/1c9txz50%28v=vs.110%29.aspx" rel="nofollow">Managed Threading Best Practices</a> page states:</p> <p><em>Avoid providing static methods that alter static state. In common server scenarios, static state is shared across requests, which means multiple threads can execute that code at the same time. This opens up the possibility of threading bugs. <strong>Consider using a design pattern that encapsulates data into instances that are not shared across requests.</strong> Furthermore, if static data are synchronized, calls between static methods that alter state can result in deadlocks or redundant synchronization, adversely affecting performance.</em></p> <p>I understand all the rest except for the one sentence that is in bold.</p> <p>How would you do this without essentially changing the field from a static one to an instance one? Isn't that saying, "In a server scenario, avoid using static class-level members as much as you can?"</p> <p>If it isn't, could you please provide an implementation of the design pattern it is alluding to?</p>
<c#><.net><multithreading>
2016-05-31 22:35:57
LQ_CLOSE
37,557,643
How to create a variable that library code can use and a user can set?
<p>1) I want to use variable <code>n_threads</code> inside my library code (that is distributed in shared library form on Windows and Linux) in multiple <code>.cpp</code> files.</p> <p>2) I want to make library user to set it. </p> <p>How to do such thing in C++?</p> <ul> <li>I tried global file with <code>static</code> variables - it leads to each <code>.cpp</code> file having its copy; </li> <li>I have tried just to keep it in a namespace which leads to variable being already defined in other translation units and thus library not compiling</li> <li>I have tried <code>external</code> (which works on Linux with <code>.so</code> and does compile on Windows MSVC14) which leads to library not compiling due to unresolved externals.</li> </ul> <p>What can be done to make global variable used in multiple library <code>.cpp</code> files be setable from outside (from library user code)?</p>
<c++><variables><scope><singleton><shared-libraries>
2016-06-01 00:27:06
LQ_CLOSE
37,558,151
Travis CI Build Failing
<p>I am having an issue with Travis CI - the commits that I push all fail with the same error:</p> <blockquote> <p>0.06s$ curl -sSL "<a href="http://llvm.org/apt/llvm-snapshot.gpg.key">http://llvm.org/apt/llvm-snapshot.gpg.key</a>" | sudo -E apt-key add - gpg: no valid OpenPGP data found. The command "curl -sSL "<a href="http://llvm.org/apt/llvm-snapshot.gpg.key">http://llvm.org/apt/llvm-snapshot.gpg.key</a>" | sudo -E apt-key add -" failed and exited with 2 during . Your build has been stopped.</p> </blockquote> <p>I tried to rebuild a previous commit that built successfully and the same error occurs. Any suggestions as to how to troubleshoot the issue?</p>
<build-process><travis-ci>
2016-06-01 01:41:12
HQ
37,558,329
Matplotlib: set axis tight only to x or y axis
<p>I have a plot look like this:</p> <p><a href="https://i.stack.imgur.com/5ePuJ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/5ePuJ.png" alt="enter image description here"></a></p> <p>Obviously, the left and right side is a waste of space, so I set</p> <pre><code>plt.axis('tight') </code></pre> <p>But this gives me plot like this:</p> <p><a href="https://i.stack.imgur.com/lOPO0.png" rel="noreferrer"><img src="https://i.stack.imgur.com/lOPO0.png" alt="enter image description here"></a></p> <p>The xlim looks right now, but the ylim is too tight for the plot.</p> <p>I'm wondering, if I can only set <code>axis(tight)</code> only to x axis in my case?</p> <p>So the plot may look something like this:</p> <p><a href="https://i.stack.imgur.com/RKKfy.png" rel="noreferrer"><img src="https://i.stack.imgur.com/RKKfy.png" alt="enter image description here"></a></p> <p>It's certainly possible that I can do this manually by</p> <pre><code>plt.gca().set_xlim(left=-10, right=360) </code></pre> <p>But I'm afraid this is not a very elegant solution.</p>
<python><matplotlib>
2016-06-01 02:08:41
HQ
37,558,875
Returning reversed array from a stack
<p>How do I write a method that when passed an array of integers, returns the array reversed, using a stack?</p> <p>I am a total noob at Java please don't ask me for my own attempt as I don't know where to start. Any help would be greatly appreciated.</p>
<java><stack>
2016-06-01 03:23:39
LQ_CLOSE
37,558,899
Efficiently Finding Closest Word In TensorFlow Embedding
<p>Recently, I've been trying to find the closest word to an embedding. The two most notable ways of doing this is by cosine distance or euclidean distance.</p> <p>I'm trying to find how to efficiently compute the cosine distance for a tensor of shape <code>[batch_size x embedding_size]</code></p> <p>One approach is to unpack the tensor and the compute the cosine distance</p> <pre><code> #embedding is shape [vocab_size x embedding size] array_list = tf.unpack(batch_array) word_class_list = tf.unpack(embedding) index_list_of_closest_word = [] for eacharray in array_list: list_of_distances = [] for eachwordclass in word_class_list: list_of_distances.append(cosine_distance(eacharray, eachwordclass)) index_list_of_closest_word.append(tf.argmax(tf.pack(list_of_distances))) </code></pre> <p>However, this approach is terribly inefficient. Is there perhaps a more efficient manner to do this? I know word2vec does this pretty fast and tensorflow, with the power of a gpu, should be able to do these batch calculations in parallel. </p> <p>Thanks!</p>
<distance><tensorflow><embedding>
2016-06-01 03:26:12
HQ
37,559,401
Switching to Camera2 in Android Vision API
<p>I saw that in android vision api (the sample is here: <a href="https://github.com/googlesamples/android-vision" rel="noreferrer">https://github.com/googlesamples/android-vision</a>) camera (camera1) is now deprecated and the recommend is to use camera2.</p> <p>Do you guys have any idea how to re-write CameraSource to use camera2 on android vision?</p> <p>Thanks in advance,</p>
<android><android-vision>
2016-06-01 04:24:43
HQ
37,559,501
Swift protocol generic as function return type
<p>I want to use generic protocol type as a function return type like this:</p> <pre><code>protocol P { associatedtype T func get() -&gt; T? func set(v: T) } class C&lt;T&gt;: P { private var v: T? func get() -&gt; T? { return v } func set(v: T) { self.v = v } } class Factory { func createC&lt;T&gt;() -&gt; P&lt;T&gt; { return C&lt;T&gt;() } } </code></pre> <p>But this code compile with errors complained:</p> <ol> <li>Cannot specialize non-generic type 'P'</li> <li>Generic parameter 'T' is not used in function signature</li> </ol> <p>Is there any way to achieve similar function with Swift?</p>
<swift><generics>
2016-06-01 04:34:13
HQ
37,559,704
kubectl YAML config file equivalent of "kubectl run ... -i --tty ..."
<p>I've been using "kubectl run" with assorted flags to run Jobs interactively, but have recently outgrown what I can do with those flags, and have graduated to using YAML config files to describe my jobs.</p> <p>However, I can't find an equivalent to the "-i" and "--tty" flags, to attach to the Job I'm creating. </p> <p>Is there an equivalent YAML spec for:</p> <pre><code>kubectl run myjob \ -i \ --tty \ --image=grc.io/myproj/myimg:mytag \ --restart=Never \ --rm \ -- \ my_command </code></pre> <p>Or is this maybe not the right approach?</p>
<yaml><kubernetes><interactive><kubectl>
2016-06-01 04:54:00
HQ
37,560,579
how to change a string to date with particular format?
> I have a string like "2016-04-13" i need to change it date format like > 13 April, 2016 how can i do this in javascript new Date(dateString); new Date(year, month[, day[, hour[, minutes[, seconds[, milliseconds]]]]]);
<javascript><date-formatting>
2016-06-01 06:01:48
LQ_EDIT
37,561,067
Java Application JMenuBar for all Jforms
I am new to Java. I have programming experience on other programming languages , especially in PowerBuilder I am writing a Java application with many forms and reports I want to have a menu common for all jforms and reports ( any window on my application ). I thought I could create a basic mainframe with the menu on it and the open any other window inside this main frame. I can't figure this out , only with InternalFrames but this is not what I want. I made my JmenuBar , I put it on JPanel and then I put Jpanel on a maximized JFrame i called "mainframe". Any window from JmenuBar opens in front of "mainframe" Jframe. When I click on "mainframe" any open window goes back of cource , focus is on the "mainframe". I wrote a mouselistener for Jpanel which brings any open window toFront except "mainframe" of cource. That seems to make the job but I have to write the same listener for the JMenuBar and this has the disavantage of windows "flashing" any time they are coming toFront. My truly question is : What is the way you work with JmenuBars? Do I have to put JmenuBar to any JForm I create? How can I have a mainframe ( maybe maximized) with the JMenuBar on it always on back and any other window opens inFront of this frame? What I realy need is a main frame with menu for my application and everything happens inside this frame. Thanks a lot Kostas
<java><swing><jframe>
2016-06-01 06:32:00
LQ_EDIT
37,561,109
How to insert data from other tables when the destination table has primary keys
I need help creating a table the can track a 2% yearly price increase over the years 2010-2016.[My create statement is as follows][1] [1]: http://i.stack.imgur.com/M5hCu.png I have 24 products and the starting price in my Products table that need insert into my new table. In theory I should have 192 records. I need help populating the year column so that it can cycle though 2010-2016 for each product. I also need help referencing the pervious year price for the next years calculation.
<sql><sql-server-2014>
2016-06-01 06:33:59
LQ_EDIT
37,561,547
This is my output ,how to merge the arrays . i wnat like this
Array ( [0] => Array ( [ht_amenity_id] => 1 [ht_amenity_name] => Central Air Conditioning [ht_category] => 1 [ht_cat_name] => General ) [1] => Array ( [ht_amenity_id] => 2 [ht_amenity_name] => Facilities for disabled guests [ht_category] => 1 [ht_cat_name] => General ) [2] => Array ( [ht_amenity_id] => 3 [ht_amenity_name] => Climate control [ht_category] => 2 [ht_cat_name] => Services ) ) this my output .how to merge the array I want like this Array ( [0] => Array ( [ht_amenity_id][0] => 1 [ht_amenity_id][1] => 2 [ht_amenity_name][0] => Central Air Conditioning [ht_amenity_name][1] => Facilities for disabled guests [ht_category] => 1 [ht_cat_name] => General ) [1] => Array ( [ht_amenity_id] => 3 [ht_amenity_name] => Climate control [ht_category] => 2 [ht_cat_name] => Services ) )
<php>
2016-06-01 06:59:24
LQ_EDIT
37,562,700
"tag start is not closed" error in AndroidManifest
<p>I'm making a small app to copy a link of a video from the intent menu, but when i try to compile the app, i get the error "tag start is not closed" in my androidmanifest:</p> <p>the error appears at the end of line 10. Thanks in advance for any replies!</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.reshare.copyurl"&gt; &lt;application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@android:style/Theme.NoDisplay" &lt;activity android:name=".MainActivity" android:excludeFromRecents="true"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.SEND" /&gt; &lt;category android:name="android.intent.category.DEFAULT" /&gt; &lt;data android:mimeType="text/plain" /&gt; &lt;/intent-filter&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.VIEW"/&gt; &lt;category android:name="android.intent.category.DEFAULT"/&gt; &lt;category android:name="android.intent.category.BROWSABLE"/&gt; &lt;data android:scheme="rtsp"/&gt; &lt;/intent-filter&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.VIEW"/&gt; &lt;category android:name="android.intent.category.DEFAULT"/&gt; &lt;category android:name="android.intent.category.BROWSABLE"/&gt; &lt;data android:scheme="http"/&gt; &lt;data android:scheme="https"/&gt; &lt;data android:scheme="content"/&gt; &lt;data android:mimeType="video/mpeg4"/&gt; &lt;data android:mimeType="video/mp4"/&gt; &lt;data android:mimeType="video/3gp"/&gt; &lt;data android:mimeType="video/3gpp"/&gt; &lt;data android:mimeType="video/3gpp2"/&gt; &lt;data android:mimeType="video/webm"/&gt; &lt;data android:mimeType="video/avi"/&gt; &lt;data android:mimeType="application/sdp"/&gt; &lt;/intent-filter&gt; &lt;intent-filter&gt; !-- HTTP live support --&gt;; &lt;action android:name="android.intent.action.VIEW"/&gt; &lt;category android:name="android.intent.category.DEFAULT"/&gt; &lt;category android:name="android.intent.category.BROWSABLE"/&gt; &lt;data android:scheme="http"/&gt; &lt;data android:scheme="https"/&gt; &lt;data android:mimeType="audio/x-mpegurl"/&gt; &lt;data android:mimeType="audio/mpegurl"/&gt; &lt;data android:mimeType="application/vnd.apple.mpegurl"/&gt; &lt;data android:mimeType="application/x-mpegurl"/&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre>
<android>
2016-06-01 07:56:08
LQ_CLOSE
37,563,752
sql server queries for cleansing string data
i have a table with name and address columns. i need to create two new columns that will hold modified values from these two columns, with special characters cleansed. please help with the queries
<sql><sql-server>
2016-06-01 08:48:20
LQ_EDIT
37,564,464
I have this error in Qt creator
when i create a consol program in qt creator i cant run it from my system terminal . "" i am using manjaro linux . And i cant create a gui programs because of this error : home/ramigamal/Programs/qt/Tools/QtCreator/lib/qtcreator/plugins/QtProject/libClangCodeModel.so: Cannot load library /home/ramigamal/Programs/qt/Tools/QtCreator/lib/qtcreator/plugins/QtProject/libClangCodeModel.so: (libtinfo.so.5: cannot open shared object file: No such file or directory)[enter image description here][1] [1]: http://i.stack.imgur.com/N6MCv.png
<c++><qt><qt-creator>
2016-06-01 09:21:38
LQ_EDIT
37,564,851
BackgroumdTask returns null.Why? It should return the string specified in try block
BackgroumdTask returns null.Why? It should return the string specified in try block. @Override protected String doInBackground(Void...Voids) { try { URL url = new URL(json_url); HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection(); InputStream ip = httpURLConnection.getInputStream(); BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(ip)); StringBuilder sb = new StringBuilder(); while ((json_string = bufferedreader.readLine())!= null) { sb.append(json_string + "\n"); } bufferedreader.close(); ip.close(); httpURLConnection.disconnect(); return sb.toString().trim(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; }
<android><android-studio>
2016-06-01 09:36:32
LQ_EDIT
37,567,635
What is faster to find in jQuery - ID's that start with X or a class?
<p>If you have html and throughout you have span elements like this:</p> <pre><code>&lt;span id="element-1" class="elements"&gt;&lt;/span&gt; &lt;span id="element-2" class="elements"&gt;&lt;/span&gt; &lt;span id="element-3" class="elements"&gt;&lt;/span&gt; </code></pre> <p>What is faster to find them:</p> <pre><code>$('.elements') </code></pre> <p>or</p> <pre><code>$('[id^="element-"]') </code></pre>
<javascript><jquery>
2016-06-01 11:41:39
LQ_CLOSE
37,568,716
What is wrong with this code with interface and abstract class?
<pre><code>interface inf1{ //interface definition } abstract class abst{ //abstract definition } public class cls : inf1,abst { } </code></pre> <p>I am getting compilation error, But if i interchange the interface and abstarct class it is compiling.</p>
<c#>
2016-06-01 12:30:46
LQ_CLOSE
37,568,883
Vectors must be the same lengths
<p>I want to plot angles against time. Here the code:</p> <pre><code>clear all close all params.t0 = 0; % start time of simulation params.tend = 10; % end time params.m=2^8; %number of steps in each Brownian path params.deltat=params.tend/params.m; % time increment for each Brownian path params.R=4; % integer number to obtain EM stepsize from Brownian path stepsize params.dt = params.R*params.deltat; %0.01; % time increment for both EM and ode45 params.D=0.001; % diffusion constant deltat= params.tend/params.m; % time increment for each Brownian path params.D=0.1; %diffsuion params.R=4; params.dt = params.R*params.deltat; theta0=pi*rand(1); phi0=2*pi*rand(1); P_initial=[theta0;phi0]; [theta,phi]=difusion_SDE(params); plot([0:params.dt:params.tend],[theta0,theta],'--*') hold on plot([0:params.dt:params.tend],[phi0,phi],'--*') </code></pre> <p>and the function file:</p> <pre><code>function [theta,phi]=difusion_SDE(params) dW=sqrt(params.deltat)*randn(2,params.m); theta0=pi*rand(1); phi0=2*pi*rand(1); P_initial=[ theta0; phi0]; L = params.m/ params.R; pem=zeros(2,L); Ang_rescale=zeros(2,L); Ptemp=P_initial; for j=1:L Winc = sum(dW(:,[ params.R*(j-1)+1: params.R*j]),2); theta=Ptemp(1); phi=Ptemp(2); A=[ params.D.*cot(theta);... 0]; B=[sqrt(params.D) 0 ;... 0 sqrt(params.D)./sin(theta) ]; Ptemp=Ptemp+ params.dt*A+B*Winc; pem(1,j)=Ptemp(1); pem(2,j)=Ptemp(2); Ang_rescale(1,j)=mod(pem(1,j),pi); Ang_rescale(2,j)=mod(pem(2,j),2*pi); theta= Ang_rescale(1,j); phi=Ang_rescale(2,j); end </code></pre> <p>When I run the code, I got this message error Error using plot Vectors must be the same lengths. I appreciate any help to solve this error</p>
<matlab><plot>
2016-06-01 12:39:05
LQ_CLOSE
37,568,909
On line 12- cube(number) = (Indentation Error). How to fix it. Please
Please help me. I have no idea how to fix the indentation error in line 12. def cube(number): number=n cube(n)=n**3 return cube(n) def by_three(number): number=n if n%3==0: cube(number) return cube(number) else: return False
<python>
2016-06-01 12:39:53
LQ_EDIT
37,569,762
Remove value arraylist java from input
<p>I have an array like this:</p> <pre><code>1101 "TV" 5531 "Baju Baru" 1425 "Mesin Cuci" </code></pre> <p>Then i want to remove "TV" from my Arraylist. So i must type "1101" then the value is remove. But if i'm wrong it show "code is invalid".</p> <p>Here is my code:</p> <pre><code>for (int i = 0; i &lt; listBarang.size(); i++) { System.out.println(listBarang.get(i)); } System.out.println("Your code stuff: "); int code = Integer.parseInt(input.next()); listBarang.remove(i); </code></pre> <p>Any answer?</p>
<java><arrays><arraylist>
2016-06-01 13:12:50
LQ_CLOSE
37,570,289
Don't get compilation error when using three dots notation for parameters
<p>I want to generate CSV files. I have a <code>generateCSV</code> method which takes a filename as parameters and a bunch of entries</p> <pre><code>private static void generateCSV(String pFilename, String... pColumns) { try(FileWriter fileWriter = new FileWriter(pFilename,true)) { for(String column : pColumns) { fileWriter.append(column); fileWriter.append(";"); } fileWriter.append("\n"); fileWriter.flush(); } catch (IOException e) { e.printStackTrace(); } } </code></pre> <p>When calling the method with <code>generateCSV("myfile.csv")</code> without the entries i don't get any compilation error. I thought that this notation implies passing 1-N parameters from this object type. No ?</p>
<java><parameters><parameter-passing><optional-parameters>
2016-06-01 13:34:17
LQ_CLOSE
37,570,348
Show date with time when querying oracle DATE data type
<p>When querying an oracle date, I see only the date - not the time. Example</p> <p><code>select D from ALIK_TZ</code></p> <p>Result:</p> <pre><code>D 01-JUN-16 </code></pre> <p>How can I see the time as well?</p>
<sql><oracle><date><datetime-format>
2016-06-01 13:36:52
LQ_CLOSE
37,572,749
Mysql foreign key constraint error when migrate in Laravel
I have create 2 migration file wich on file has a foreign key, when migrate , laravel show this error about Mysql foreign key constraint error when migrate in Laravel
<mysql><laravel-5.2>
2016-06-01 15:19:30
LQ_EDIT
37,575,035
how can I unifiy mdf database connection string across all users ? [windows forms]
I'm developing windows form application and I'm facing a problem that I use connection string path to the mdf database in my computer but when running the app on another computer the path will be different ? how can I figure it our programmatically ؟
<c#><sql-server><winforms>
2016-06-01 17:16:42
LQ_EDIT
37,576,458
{} + "" vs "" + {} - Consistency in Addition
<p>I stumbled across this the other day on reddit. The poster noted that </p> <pre><code>{} + "" </code></pre> <p>is equal to <code>0</code>, while the similar</p> <pre><code>"" + {} </code></pre> <p>is equal to an empty <code>[object Object]</code>.</p> <p>Normal math rules tell me this is odd, but why is it this way?</p>
<javascript>
2016-06-01 18:42:55
LQ_CLOSE
37,576,677
Regex for group. I want to remove 1) comma from a string surrounded by double quotes (") and double quotes as well nee to be removed
Input String Arab World,ARB,"Adolescent fertility rate (births per 1,000 women ages 15-19)",SP.ADO.TFRT,1960,133.56090740552298 Output String Arab World,ARB,Adolescent fertility rate (births per 1,000 women ages 15-19),SP.ADO.TFRT,1960,133.56090740552298 Input String Arab World,ARB,"International migrant stock, total",SM.POP.TOTL,1960,3324685.0 Output String Arab World,ARB,International migrant stock total,SM.POP.TOTL,1960,3324685.0
<regex><regex-group>
2016-06-01 18:55:33
LQ_EDIT
37,577,720
Are all SHA1 implementations alike.
My question is simple -- with 2 seperate SHA1 implemntations am I garunteed to get the sames output for the same input, or is there space for interpretation in the implementation?
<php><r><encoding><cryptography><sha1>
2016-06-01 19:59:11
LQ_EDIT
37,577,841
regex match pattern in a string multiple times
<p>I have the following string "*&amp;abc=123&amp;**&amp;defg=hh&amp;*" and so on the pattern start and end is <em>&amp;&amp;</em> and I would like to have the following when I do regex.matches or regex.split</p> <p>first match = <em>&amp;abc=123&amp;</em> 2 match = <em>&amp;defg=hh&amp;</em></p> <p>appreciate any help</p>
<c#><regex>
2016-06-01 20:07:24
LQ_CLOSE
37,579,058
How can i get my C# application on another computer?
<p>I have created a small C# application on my home computer using Visual Studio 2015 and Id like to use this small application on my computer at work. Can someone point me to a tutorial/video to help me accomplish this? thanks. </p>
<c#><visual-studio>
2016-06-01 21:26:41
LQ_CLOSE
37,579,558
Javascript unbind variables
<p>I have the following code that copy variable value then change its value.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>var a = [{name: 'John Doe'}]; var b = a; document.write(b[0].name + '&lt;br /&gt;'); document.write(a[0].name + '&lt;br /&gt;&lt;br /&gt;'); b[0].name = 'Jane Doe'; document.write(b[0].name + '&lt;br /&gt;'); document.write(a[0].name + '&lt;br /&gt;');</code></pre> </div> </div> </p> <p>But somehow that also change first variable value</p> <p>How do I make variable A to keep its value?</p>
<javascript><arrays>
2016-06-01 22:05:08
LQ_CLOSE
37,580,498
Why won't my jquery work
<p>I have more code but this is the important bit. The rest of it is a JS function and styling.</p> <pre><code> &lt;button onClick="gB()" id="gb"&gt; clickme&lt;/button&gt; &lt;script src="jquery-1.12.2.min.js"&gt; $( document ).ready(function() { $('button').eq(0).trigger('click'); }; </code></pre>
<jquery>
2016-06-01 23:42:11
LQ_CLOSE
37,581,173
Android getIntent() returns current activity
<p>I have a question about getIntent(); Somebody makes activity(Activity A) to call my Activity(Activity B). So it's different package name. The problem is that when I use getIntent(), the return of getIntent is Activity B. so intent.getExtras() is null. What is problem? I think getIntent() should return Activity A. It's good work to start from Activity A to B.</p> <p>Activity A</p> <pre><code>Intent intent = new Intent(); intent.setClassName(B Package, B Activity); intent.putExtra("Test", test); startActivityForResult(intent, REQUEST_OK); </code></pre> <hr> <p>Activity B</p> <pre><code>Intent intent = getIntent(); Log.d(TAG, "" +getIntent()); if(intent.getExtras() != null){ String name = intent.getStringExtra("Test"); } </code></pre> <p>Thanks.</p>
<android><android-intent>
2016-06-02 01:15:59
LQ_CLOSE
37,581,503
<a href="www.example.com">example</a> redirects to mysite.com/www.example.com?
<p>Example: </p> <pre><code>&lt;a href="www.example.com"&gt; Click here to go to www.example.com!&lt;/a&gt; </code></pre> <p>and</p> <pre><code>&lt;a href="http://www.example.com"&gt; Click here to go to www.example.com!&lt;/a&gt; </code></pre> <p>The first one redirects to the following URL: <code>http://www.currentsite.com/www.example.com</code> while the second one works perfectly fine.</p> <p>here's the code I'm using: (ruby on rails)</p> <pre><code>&lt;%=h link_to @user.details.website, @user.details.website, :class =&gt; 'link'%&gt; </code></pre> <p>The only solution I have would be checking for <code>http://</code> and add it if it's not already there.</p>
<html>
2016-06-02 02:03:00
LQ_CLOSE
37,582,014
How to structure a Django website
<p>After creating reusable Django apps do one make an app that glue them together to create a website? Also is it correct to make each menu item and section an app itself in Django? The source code of <a href="https://www.djangoproject.com/" rel="nofollow">https://www.djangoproject.com/</a> is probably the best example of how to correctly structure Django websites if it is available.</p>
<django>
2016-06-02 03:14:07
LQ_CLOSE
37,584,574
string literal doesn't close properly in Java
<p>Why this doesn't work in Java?</p> <pre><code>driver.findElement(By.xpath("//*[@id='mm-0']/div[1]/div/div/div/div[5]/div[1]/div/div[1]/div/div/form/fieldset/div[1]/span/span/input')).click(); </code></pre> <p>this won't have problem in javascript. </p>
<java><maven>
2016-06-02 06:47:23
LQ_CLOSE
37,585,260
How to print $ using String Interpolation
<p>I have just started learning scala .I want to print $ using String Interpolation</p> <pre><code>def main(args:Array[String]){ println("Enter the string") val inputString:String=readLine() val inputAsDouble:Double=inputString.toDouble printf(f" You owe '${inputAsDouble}%.1f3 ") } </code></pre> <p>Input is 2.7255 I get output as .You owe 2.73 while i want it as You owe $2.73 any pointers will be of a great help</p>
<scala>
2016-06-02 07:25:09
LQ_CLOSE
37,585,552
vector allocation error subscript to pointer to incomplete type
<p>i have my product</p> <pre><code>typedef struct proditem *prodItem; </code></pre> <p>and i have a symbol table of products</p> <pre><code>typedef struct tabp *tabP; struct tabp { prodItem vettP; int nP; }; </code></pre> <p>i need to allocate in memory, then :</p> <pre><code>tab-&gt;nP = max; // quantity of products tab-&gt;vettP = malloc(max * sizeof(*prodItem)); </code></pre> <p>but if a try to use the vector tab->vettP have the error:</p> <p><code>tab-&gt;vettP[i]</code> &lt;&lt;-- subscript to pointer to incomplete type</p> <p>can anyone help me?</p>
<c><arrays>
2016-06-02 07:40:46
LQ_CLOSE
37,586,511
History stuck cleared when clicking on recent apps button
I'm working on a launcher app that basically launches other installed apps on the device with an explicit intent and I have a edge case scenario: An Activity (Act) creates an intent of an application (App) and starts it by calling startActivity(intent). App get launched, my Activity going to "stop" state. After a while I want to get back to my application so I click on "back" hard button that closes App and bring my Application to foreground (resume state). This is the wanted behaviour. Here is the edge case: If I click on the "recent applications" hard button (square icon) while on App is launched, history stuck is lost, and when I return to App, and click on "back" hard button - App exists to the Launcher screen and onResume of my application is being called. I searched the web for a solution for couple of hours now, maybe I'll find a solution here. Thanks
<android><android-activity><app-launcher>
2016-06-02 08:29:17
LQ_EDIT
37,588,376
(PHP) Array push string with variable
<p>I'm new to PHP, I tried to use the array push function which I would like to combine the string with variable but it turns out strange result.</p> <p>I applied it to Google Chart which it will create the chart.</p> <pre><code>for($i = 0; $i &lt; $table_counter; $i++){ array_push($pieData1, array( "Available seat(s) of " + $pos_chart[$i], $slot_chart[$i])); } </code></pre> <p>This is the code that I use for array that it use to create the chart. The chart is generated, the header of the chart should be "Available seat(s) of xxx position" but it turns out as "0". </p> <p>So, what I should change?</p>
<php><arrays>
2016-06-02 09:51:23
LQ_CLOSE
37,588,751
SQL: Need to select items by different conditions
<p><strong>My table looks like this -</strong> <a href="https://i.stack.imgur.com/yhpqJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yhpqJ.png" alt="enter image description here"></a></p> <p><strong>Explanation</strong><br> I'm working on an online shop that sells <strong>tours</strong> and <strong>spa</strong>. I'm showing all together on one page.</p> <p></p> <p><strong>What I need to select?</strong><br> 1. All spa products (based on "Spa" column), no conditions.<br> 2. All parent tours that have children with an upcoming date.</p> <p></p> <p><strong>Meaning</strong><br> Products ID 1, 4, 5.</p> <p></p> <p><strong>Why?</strong><br> Product 6 have a child, but from 1999. And although product 1 have one child at 2000, it has another one in 2017. All spa products are selected by default, without conditions.</p> <p><br><i>I hope I made my question clear as I could. I would appreciate any help, my SQL is really bad.</i></p>
<sql>
2016-06-02 10:06:11
LQ_CLOSE
37,589,127
What is the best way to create a simple slideshow into an Android project?
<p>I am absolutly new in <strong>Android</strong> development and I am developing my first app.</p> <p>I have to create something like a <strong>slideshow</strong> that show an image, when the user moove to the right (with the finger on the screen, what's the correct name in Android jargon?) show the next immage, when it moove to the left the previous one is shown.</p> <p>I have found this example, I have to implement something like the result shown in the attached video: <a href="http://androidopentutorials.com/android-image-slideshow-using-viewpager/" rel="nofollow">http://androidopentutorials.com/android-image-slideshow-using-viewpager/</a></p> <p>But my doutbs are:</p> <p>In the prvious tutorial it use 2 external library that have to be added to the project:</p> <ul> <li><strong>Universal Image Loader for Android:</strong> for asynchronous image loading.</li> <li><strong>ViewPagerIndicator:</strong> library to bring circle indicator with ViewPager.</li> </ul> <p>Is it a good solution? Or can I obtain the same behavior without using external library but only stuff provided by the <strong>Android SDK</strong>?</p> <p>I think that the result of the previous tutorial is what I need for my project but I prefer don't use external library and adhere as much as possible to the standard of Android development.</p> <p>Can you give me some suggestion about the right way to implement this feature?</p>
<java><android><android-layout><android-studio><android-sliding>
2016-06-02 10:21:55
LQ_CLOSE
37,589,976
how to iterate array in json
how to iterate array in json $(document).ready(function(){ $('#wardno').change(function(){ //any select change on the dropdown with id country trigger this code $("#wardname > option").remove(); //first of all clear select items var ward_id = $('#wardno').val(); // here we are taking country id of the selected one. $.ajax({ type: "POST", cache: false, url:"get_wardname/"+ward_id, //here we are calling our user controller and get_cities method with the country_id success: function(cities) //we're calling the response json array 'cities' { try{ $.each(cities,function(id,city) //here we're doing a foeach loop round each city with id as the key and city as the value { var opt = $('<option />'); // here we're creating a new select option with for each city opt.val(id[0]); opt.text(id[1]); $('#wardname').append(opt); var opt1 = $('<option />'); // here we're creating a new select option with for each city opt1.val(city[0]); opt1.text(city[1]); $('#koottaymaname').append(opt1); }); //here we will append these new select options to a dropdown with the id 'cities' }catch(e) { alert(e); } }, error: function (jqXHR, textStatus, errorThrown) { alert("jqXHR: " + jqXHR.status + "\ntextStatus: " + textStatus + "\nerrorThrown: " + errorThrown); } }); }); }); // ]]> </script> The output from the code is [{"1":"St. Sebastian"},{"1":"kudumbakoottayma1","2":"kudumbakoottayma2"}] How to iterate into two different drop down list
<javascript><jquery><json>
2016-06-02 11:00:39
LQ_EDIT
37,590,031
Text Allignment in d3
<!-- begin snippet: js hide: false console: true --> <!-- language: lang-js --> var data = [{"seq":"1","start":"Account","end":"Order","relation":"Account","rows":"1"}, {"seq":"2","start":"Account","end":"Attachment","relation":"Parent","rows":"10"} ,{"seq":"3","start":"Order","end":"Account","relation":"Account","rows":"15"} ,{"seq":"4","start":"Attachment","end":"Account","relation":"Parent","rows":"55"} ,{"seq":"5","start":"Attachment","end":"Campaign","relation":"Parent","rows":"45"} ,{"seq":"6","start":"Attachment","end":"Lead","relation":"Parent","rows":"47"} ,{"seq":"7","start":"Lead","end":"Attachment","relation":"Parent","rows":"75"} ,{"seq":"8","start":"Campaign","end":"Attachment","relation":"Parent","rows":"34"}, {"seq":"9","start":"Order","end":"Account","relation":"Account","rows":"99"} ,{"seq":"10","start":"Attachment","end":"Account","relation":"Parent","rows":"12"} ,{"seq":"11","start":"Attachment","end":"Campaign","relation":"Parent","rows":"5"} ,{"seq":"12","start":"Attachment","end":"Lead","relation":"Parent","rows":"75"}]; /* var data =[{"seq":"1","start":"Account","end":"Contact","relation":" Account ","rows":"8"},{"seq":"2","start":"Account","end":"TopicAssignment","relation":"Entity","rows":"0"},{"seq":"1","start":"Account","end":"Order","relation":" Account ","rows":"0"},{"seq":"1","start":"Contact","end":"Account","relation":"Account","rows":"3"},{"seq":"1","start":"TopicAssignment","end":"Account","relation":"Entity","rows":"0"}, {"seq":"1","start":"Order","end":"Account","relation":"Account","rows":"0"}]; */ var ellipseSelected, pathSelected, parentNodeX, parentNodeY, relationshipName, indexEdge, fromData, toData,nodeSelected,startNodeSelected; //flag =1 ,when we have both src and trg var flag = 1; var newCount =0; var edges = d3.selectAll('.edge'); var path = d3.selectAll('.path') var allEllipse = d3.selectAll('ellipse'); var allNodes = d3.selectAll('.node'); var theGraph = document.getElementById('graph0') //getContainer var polygon = document.getElementsByTagName('polygon')[0] //getPolygon to insert after var allEdgesJS = document.getElementsByClassName("edge"); //select all Edges for (var i = 0; i < allEdgesJS.length; i++) { //Loop through edges to move theGraph.insertBefore(allEdgesJS[i], polygon.nextSibling); //insert after polygon } function ellipseAdd() { d3.select(ellipseSelected.parentNode) .append("circle") .attr('cx', parentNodeX) //thisParentBBox.left + thisParentBBox.width/2) .attr('cy', parentNodeY) .attr("r", 10) .attr("stroke-width", 1) .attr("stroke", "white") .style('fill', '#CE2029'); d3.select(ellipseSelected.parentNode) .data([toData]) .append("text") .attr('x', parentNodeX-8) .attr('y', parentNodeY+4).text(0).style('fill','white') .attr("font-size", "8px") .transition() .duration(3000) .tween("text", function(d) { var i = d3.interpolate(fromData, d), prec = (d + "").split("."), round = (prec.length > 1) ? Math.pow(10, prec[1].length) : 1; return function(t) { this.textContent = Math.round(i(t) * round) / round; }; }); } function blinker() { if(flag==0) { //for adding ellipse and text to it ellipseAdd(); } else{ //blink 3 things\ //ellipse ellipseAdd(); d3.select('#' + indexAndEdge[indexEdge].id + ' path').style('opacity', 1) .transition().style('stroke','grey').duration(300).style('opacity', 1) .transition().style('stroke','#CE2029').style('stroke-width', 1) .transition().duration(300).duration(300).style('opacity', 1) .transition().style('stroke','grey').duration(300).style('opacity', 1) .transition().style('stroke','#CE2029').style('stroke-width', 1) .transition().duration(300).duration(300).style('opacity', 1) .transition().style('stroke','grey').duration(300).style('opacity', 1) .transition().style('stroke','#CE2029').style('stroke-width', 1) .transition().duration(300).duration(300).style('opacity', 1) .transition().style('stroke','grey').style('stroke-width',1) .duration(300).style('opacity', 1) .transition().style('stroke',"#ff800e").style('stroke-width', 1); //select current id from array //select current id from array d3.select('#' + indexAndEdge[indexEdge].id + ' polygon') .transition().style('stroke','grey').style('fill','grey').duration(300).style('opacity', 1) .transition().style('fill','#CE2029').style('stroke','#CE2029').style('stroke-width', 2) .transition().duration(300).duration(300).style('opacity', 1) .transition().style('stroke','grey').style('fill','grey').duration(300).style('opacity', 1) .transition().style('fill','#CE2029').style('stroke','#CE2029').style('stroke-width', 2) .transition().duration(300).duration(300).style('opacity', 1) .transition().style('stroke','grey').style('fill','grey').duration(300).style('opacity', 1) .transition().style('stroke','#CE2029').style('fill','#CE2029').style('stroke-width', 2) .transition().duration(300).duration(300).style('opacity', 1) .transition().style('stroke','grey').style('fill','grey').style('stroke-width',1) .duration(300).style('opacity', 1) .transition().style('stroke',"#ff800e").style('fill',"#ff800e").style('stroke-width', 1); //select current id from array d3.select('#' + indexAndEdge[indexEdge].id + ' text').style('opacity', 0) .transition().style('fill','grey').duration(300).style('opacity', 1) .transition().style('fill','#CE2029') .transition().duration(300).duration(300).style('opacity', 1) .transition().style('fill','grey').duration(300).style('opacity', 1) .transition().style('fill','#CE2029') .transition().duration(300).duration(300).style('opacity', 1) .transition().style('fill','grey').duration(300).style('opacity', 1) .transition().style('fill','#CE2029').style('fill','#CE2029') .transition().duration(300).duration(300).style('opacity', 1) .transition().style('fill','grey') .duration(300).style('opacity', 1) .transition().style('fill',"#ff800e"); } } edges.style('opacity', 1); allNodes.style('fill',"white"); path.style('fill',"yellow"); var indexAndEdge = []; var countOnNode = []; edges.each(function(d, i) { var thisEdgeCount = this.id.substring(4); debugger indexAndEdge.push({ //push index you are at, the edge count worked out above and the id index: i, count: thisEdgeCount, id: this.id, start:String(this.childNodes[0].childNodes[0].nodeValue).split("->")[0], destination:String(this.childNodes[0].childNodes[0].nodeValue).split("->")[1], relation:this.childNodes[6].childNodes[0] }) d3.select('#' + indexAndEdge[i].id + ' polygon').style('fill','grey').style('stroke','grey'); d3.select('#' + indexAndEdge[i].id + ' path').style('stroke','grey'); }); d3.selectAll('.node').each(function(d, i) { var thisNodeCount = this.id; debugger countOnNode.push({ //push index you are at, the edge count worked out above and the id id : thisNodeCount, prevData : 0, incrementData : 0, title : this.childNodes[0].childNodes[0].nodeValue , name: String(this.childNodes[4].childNodes[0].nodeValue) }) }); function timer() { setTimeout(function(d) { if (newCount < data.length) { //if we havent gone through all edges if(data[newCount].end.length==0) { flag = 0; for(j=0;j<allNodes[0].length;j++) { //if sourseName matches if(String(allNodes[0][j].childNodes[4].childNodes[0].nodeValue)==data[newCount].start) { ellipseSelected = d3.selectAll('.node')[0][j].childNodes[2]; parentNodeX = ellipseSelected.attributes.cx.value-ellipseSelected.attributes.rx.value +(2*ellipseSelected.attributes.rx.value) ; parentNodeY =ellipseSelected.attributes.cy.value-(ellipseSelected.attributes.ry.value/2); //send the data to interpolate //match id and update prevData ,incrementData for( var l= 0 ; l < countOnNode.length ; l++ ) { if(countOnNode[l].id == d3.selectAll('.node')[0][j].id ) { countOnNode[l].prevData = countOnNode[l].incrementData; countOnNode[l].incrementData = data[newCount].rows; fromData = countOnNode[l].prevData ; toData = countOnNode[l].incrementData; } } blinker(); flag=1; if(flag==1) {break;} } } } else { //check relation and targetNode //check target flag = 1; for(var j=0 ; j < allNodes[0].length ; j++ ) { if(String(allNodes[0][j].childNodes[4].childNodes[0].nodeValue)==data[newCount].end) { ellipseSelected = d3.selectAll('.node')[0][j].childNodes[2]; parentNodeX = ellipseSelected.attributes.cx.value-ellipseSelected.attributes.rx.value +(2*ellipseSelected.attributes.rx.value) ; parentNodeY =ellipseSelected.attributes.cy.value-(ellipseSelected.attributes.ry.value/2); for( var l= 0 ; l < countOnNode.length ; l++ ) { if(countOnNode[l].id == d3.selectAll('.node')[0][j].id ) { countOnNode[l].prevData = countOnNode[l].incrementData; countOnNode[l].incrementData = +data[newCount].rows + +countOnNode[l].prevData; fromData = countOnNode[l].prevData ; toData = countOnNode[l].incrementData; nodeSelected = l; // console.log(" j =" + j + "l "+l+ " fromData " + fromData + " toData "+toData); } } debugger for (var ll = 0; ll < countOnNode.length; ll++) { if (countOnNode[ll].name == data[newCount].start) { debugger; // console.log(data[newCount]); startNodeSelected = ll; } } debugger //set the edge by checking relation for(var k=0 ; k < indexAndEdge.length ; k++) { //if(edges[0][k].childNodes[7].childNodes[0] == indexAndEdge) if((data[newCount].relation.trim() == (String(indexAndEdge[k].relation.nodeValue).trim()) && (( (countOnNode[nodeSelected].title == indexAndEdge[k].destination)&&(countOnNode[startNodeSelected].title == indexAndEdge[k].start))||((countOnNode[nodeSelected].title == indexAndEdge[k].start)&&(countOnNode[startNodeSelected].title == indexAndEdge[k].destination))))) { indexEdge = k; } } blinker(); flag = 0; if(flag==0) { break; } } } } //allEllipse newCount++; timer(); } else { // count =0 ; timer() console.log('end') //end } }, 3000) } timer(); <!-- language: lang-html --> <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.4.11/d3.min.js"></script> <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <!-- Generated by graphviz version 2.38.0 (20140413.2041) --> <!-- Title: graphname Pages: 1 --> <svg width="308pt" height="131pt" viewBox="0.00 0.00 308.09 131.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 127)"> <title>graphname</title> <polygon fill="white" stroke="none" points="-4,4 -4,-127 304.095,-127 304.095,4 -4,4"/> <!-- 0 --> <g id="node1" class="node"><title>0</title> <ellipse fill="#b2dfee" stroke="#b2dfee" cx="51.4971" cy="-105" rx="42.4939" ry="18"/> <text text-anchor="middle" x="51.4971" y="-101.3" font-family="Times New Roman,serif" font-size="14.00">Account</text> </g> <!-- 1 --> <g id="node2" class="node"><title>1</title> <ellipse fill="#b2dfee" stroke="#b2dfee" cx="177.497" cy="-18" rx="51.9908" ry="18"/> <text text-anchor="middle" x="177.497" y="-14.3" font-family="Times New Roman,serif" font-size="14.00">Attachment</text> </g> <!-- 0&#45;&gt;1 --> <g id="edge1" class="edge"><title>0&#45;&gt;1</title> <path fill="none" stroke="#cd0000" d="M81.6636,-83.6496C104.156,-68.4764 134.397,-48.0758 154.846,-34.2806"/> <polygon fill="#cd0000" stroke="#cd0000" points="79.4899,-80.894 73.1573,-89.388 83.4047,-86.697 79.4899,-80.894"/> <text text-anchor="middle" x="143.997" y="-57.8" font-family="Times New Roman,serif" font-size="14.00"> Parent </text> </g> <!-- 2 --> <g id="node3" class="node"><title>2</title> <ellipse fill="#b2dfee" stroke="#b2dfee" cx="32.4971" cy="-18" rx="32.4942" ry="18"/> <text text-anchor="middle" x="32.4971" y="-14.3" font-family="Times New Roman,serif" font-size="14.00">Order</text> </g> <!-- 0&#45;&gt;2 --> <g id="edge2" class="edge"><title>0&#45;&gt;2</title> <path fill="none" stroke="#cd0000" d="M36.6269,-78.2339C35.365,-75.1966 34.2755,-72.0805 33.4971,-69 30.8171,-58.3937 30.5329,-46.1155 30.9355,-36.3806"/> <polygon fill="#cd0000" stroke="#cd0000" points="33.6008,-80.0185 41.0756,-87.527 39.9146,-76.9959 33.6008,-80.0185"/> <text text-anchor="middle" x="61.4971" y="-57.8" font-family="Times New Roman,serif" font-size="14.00"> Account </text> </g> <!-- 3 --> <g id="node4" class="node"><title>3</title> <ellipse fill="#b2dfee" stroke="#b2dfee" cx="177.497" cy="-105" rx="47.3916" ry="18"/> <text text-anchor="middle" x="177.497" y="-101.3" font-family="Times New Roman,serif" font-size="14.00">Campaign</text> </g> <!-- 3&#45;&gt;1 --> <g id="edge3" class="edge"><title>3&#45;&gt;1</title> <path fill="none" stroke="#cd0000" d="M177.497,-76.7339C177.497,-63.4194 177.497,-47.806 177.497,-36.1754"/> <polygon fill="#cd0000" stroke="#cd0000" points="173.997,-76.7989 177.497,-86.799 180.997,-76.799 173.997,-76.7989"/> <text text-anchor="middle" x="198.997" y="-57.8" font-family="Times New Roman,serif" font-size="14.00"> Parent </text> </g> <!-- 4 --> <g id="node5" class="node"><title>4</title> <ellipse fill="#b2dfee" stroke="#b2dfee" cx="271.497" cy="-105" rx="28.6953" ry="18"/> <text text-anchor="middle" x="271.497" y="-101.3" font-family="Times New Roman,serif" font-size="14.00">Lead</text> </g> <!-- 4&#45;&gt;1 --> <g id="edge4" class="edge"><title>4&#45;&gt;1</title> <path fill="none" stroke="#cd0000" d="M251.874,-81.4584C243.735,-72.5603 233.988,-62.4628 224.497,-54 216.904,-47.2291 208.071,-40.4074 200.126,-34.6078"/> <polygon fill="#cd0000" stroke="#cd0000" points="249.277,-83.8042 258.567,-88.8979 254.481,-79.1226 249.277,-83.8042"/> <text text-anchor="middle" x="259.997" y="-57.8" font-family="Times New Roman,serif" font-size="14.00"> Parent </text> </g> </g> </svg> <!-- end snippet --> Here,circle is added to .svg file.And then text to that circle is added. I want to add text at centre of circle and also if number is bigger like 10000 ,it should fit to that circle. I tried with .attr('height', 'auto') .attr('text-anchor', 'middle') But,as position of text is decided on which node is added(present in .svg file) and not on circle position,it is not working. Thank you.
<javascript><d3.js><svg>
2016-06-02 11:03:27
LQ_EDIT
37,590,152
GLSL error: `out' qualifier only valid for function parameters in GLSL 1.10
<p>My shaders have in/out keywords. But I've got GLSL compile error: <code>'out' qualifier only valid for function parameters in GLSL 1.10</code>. Shaders have <code>#version 330</code> directive. Calling <code>glGetString(GL_SHADING_LANGUAGE_VERSION)</code> returns 3.30. </p> <p>Here is my project: <code>github.com/wlad031/ssu-coursework-2016</code>. Input folder contains shaders. Main source files are <a href="http://github.com/wlad031/ssu-coursework-2016/blob/master/src/ShaderProgramControl.cpp" rel="nofollow">src/ShaderProgramControl.cpp</a> and <a href="http://github.com/wlad031/ssu-coursework-2016/blob/master/src/Shader.cpp" rel="nofollow">src/Shader.cpp</a>. Where is my mistake?</p>
<c++><opengl><glsl>
2016-06-02 11:08:29
LQ_CLOSE