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,975,890
Image processing i.e. matching similar images in java
<p>Is there a way where i can match some sort of screenshots with earlier stored images in my system. Consider 2 images i want to compare A and B. A is full screenshot of monitor whereas B corresponds to a particular window say a small image. My problem is to find whether A contains B or not?</p>
<java><image><image-processing><image-scaling>
2016-06-22 18:38:41
LQ_CLOSE
37,975,954
How can I determine which server I'm connected to?
I'm a rookie so I'm not really acquainted with how this really works. I've downloaded SQL Server 2016 and once I log onto the Management Studio, it asks me to connect to a particular server. Now I've no idea which server I'm connected to. I've tried everything. Turned the firewall off, used cmd commands, (tells me that my access has been denied), registered a new server from within the studio (but I feel as if I'm not connected to any as nothing shows up) I'm really confused
<networking><ssms><sql-server-2016>
2016-06-22 18:42:48
LQ_EDIT
37,976,076
Regex "is not a constant" error in Golang
<p>I'm trying to write a regex in Golang to verify that a string only has alphanumerics, periods, and underscores. However, I'm running into an error that I haven't seen before and have been unsuccessful at Googling.</p> <p>Here's the regex:</p> <pre><code>pattern = regexp.MustCompile(`^[A-Za-z0-9_\.]+`) </code></pre> <p>Here is the error:</p> <pre><code>const initializer regexp.MustCompile("^[A-Za-z0-9_\\.]+") is not a constant </code></pre> <p>What does "not a constant" mean and how do I fix this?<br> Thanks.</p>
<regex><go>
2016-06-22 18:50:14
HQ
37,976,468
Saving and retrieving date in Firebase
<p>I have a model with the following structure </p> <pre><code>public class OfferModel { private String mImageUrl; private String mOfferCode; private String mOfferTitle; private String mOfferDescription; private boolean mIsRunning; private String mCreatorUid; private Date mStartDate; } </code></pre> <p>Everything else works fine on saving. It saves in Firebase Realtime database as</p> <pre><code>startDate date: 22 day: 3 hours: 23 minutes: 20 month: 5 seconds: 50 time: 1466617850476 timezoneOffset: -330 year: 116 </code></pre> <p>But when I try to retrieve it, the date gives the following error - </p> <pre><code>java.lang.ClassCastException: java.util.HashMap cannot be cast to java.util.Date at com.localvine.models.OfferModel.&lt;init&gt;(OfferModel.java:37) at com.localvine.managers.OfferManager$1.onDataChange(OfferManager.java:62) at com.google.android.gms.internal.zzafp.zza(Unknown Source) at com.google.android.gms.internal.zzagp.zzSu(Unknown Source) at com.google.android.gms.internal.zzags$1.run(Unknown Source) at android.os.Handler.handleCallback(Handler.java:615) </code></pre> <p>I understand that Firebase doesn't support Java Date object, but since it's saving them in a map, how can I get back the date from that map? Is there any proper way of saving and retrieving dates in Firebase Android?</p>
<java><android><date><firebase>
2016-06-22 19:13:20
HQ
37,976,626
Why should one use Dapper ? Also can anyone comment on Dapper Vs ADO.NET Pros and Cons
<p>I would like to understand on when would some one really need to think of using Dapper. Also i would like to understand the Pros and Cons of comparing Dapper Vs ADO.NET</p>
<c#><orm><ado.net><dapper>
2016-06-22 19:23:57
HQ
37,976,832
How to list tables affected by cascading delete
<p>I'm trying to perform a cascading delete on 15+ tables but I'm not certain that all of the requisite foreign keys have been configured properly. I would like to check for missing constraints without manually reviewing each constraint.</p> <p>Is there a way to obtain a list of tables that will be affected by a cascading delete query?</p>
<postgresql>
2016-06-22 19:36:41
HQ
37,977,320
How to mock a Kotlin singleton object?
<p>Given a Kotlin singleton object and a fun that call it's method</p> <pre><code>object SomeObject { fun someFun() {} } fun callerFun() { SomeObject.someFun() } </code></pre> <p>Is there a way to mock call to <code>SomeObject.someFun()</code>?</p>
<mocking><mockito><kotlin><powermock><powermockito>
2016-06-22 20:07:37
HQ
37,978,998
how to make nested list go down?
I have a list inside another and want to have the parent list of elements aligned horizontally and the child list of elements aligned vertically below the <li>. But what happens is that the child's father <li> list is at the top with the list below and the rest <li> of the parent list are below aligned with the end of the child list.[enter image description here][1] [1]: http://i.stack.imgur.com/9KtRV.png
<html><css><css-position><nested-lists>
2016-06-22 22:00:51
LQ_EDIT
37,979,115
Is it better to change a background image on a responsive site with javascript or css with media queries
<p>Working within the confines of our very large scale cms we have come across several instances where we need to set the background images of certain divs from within a content item for maintenance purposes. What this means is we can not put the background-image elements into the main css. There are 2 versions of every background image - mobile and desktop. The solutions we can do are either to write a block into the page and put the css there using @media queries, or to add the background image paths into data-background-sm/ data-background-lg attributes and use javascript to swap them at breakpoints.</p> <p>What are peoples opinion on which is faster/better/more 'acceptable'?</p>
<javascript><html><css><media-queries><responsive>
2016-06-22 22:12:44
LQ_CLOSE
37,979,759
Limit lines in a textarea?
<p>I've got a form that people can fill out and the results of the form are displayed on a page. The form is limited to 2000 characters, however there's nothing limiting how many line breaks there can be, so someone could just put one character per line and get 2000 line breaks, which clutters up the page pretty badly. I'm looking to limit the number of lines that they can type into the textarea so the limits are 2000 characters or 40 lines, whichever comes first.</p> <p>I would also need this to be protective of people pasting large amounts of text into the form as well. I looked at a lot of other posts about this but none of the answers worked when I tried them. Thanks!</p>
<javascript><php><jquery><html>
2016-06-22 23:17:46
LQ_CLOSE
37,980,177
How can I reuse a double in C#
Hello I am trying to write a code which will ask a question the client dims for a crate once the client replies it will ask if you need to add more crate, if the client says yes how would I repeat the same code? I think I need top add a loop here but I'm not sure how to reuse the same variable. Thank you for your help. Ed Console.WriteLine("Please enter the crate Length for your incoming shipment: "); double l = new double(); l = double.Parse(Console.ReadLine()); Console.WriteLine("Enter the crate Width for your incoming shipment: "); double w = new double(); w = double.Parse(Console.ReadLine()); Console.WriteLine("Enter the crate Height for your incoming shipmet"); double h = new double(); h = double.Parse(Console.ReadLine()); double totalDims = new double(); totalDims = l * w * h; double volKg = new double(); volKg = totalDims / 366; Console.WriteLine("Your total Vol Kg is {0:0.00}", +volKg); Console.ReadLine(); Console.Write("Are there any additional crates y/n? "); char a = new char(); a = char.Parse(Console.ReadLine()); char y = default(char); while (a == y) { //Crate Dimensions Entered Console.WriteLine("Please enter the crate Length for your incoming shipment: "); double l = new double(); l = double.Parse(Console.ReadLine()); Console.WriteLine("Enter the crate Width for your incoming shipment: "); double w = new double(); w = double.Parse(Console.ReadLine()); Console.WriteLine("Enter the crate Height for your incoming shipmet"); double h = new double(); h = double.Parse(Console.ReadLine()); } }
<c#>
2016-06-23 00:06:02
LQ_EDIT
37,980,655
Why is Python datetime time delta not found?
<p>I am trying to make an array of dates in mmddyyyy format. The dates will start on the current day and then go two weeks into the future. So it all depends on the starting date. When I run my code I get an error that states:</p> <pre><code>Traceback (most recent call last): File "timeTest.py", line 8, in &lt;module&gt; day = datetime.timedelta(days=i) AttributeError: type object 'datetime.datetime' has no attribute 'timedelta' </code></pre> <p>I am not sure why this is happening because after searching online, I noticed that people are using the 'timedelta' in this way.</p> <p>Here is my code:</p> <pre><code>import time from datetime import datetime, date, time, timedelta dayDates = [] today = datetime.now() dayDates.append(today.strftime("%m%d%Y")) for i in range(0,14): day = today + datetime.timedelta(days=i) print day </code></pre>
<python><timedelta><python-datetime>
2016-06-23 01:07:44
HQ
37,981,055
Bootstrap Css positioning an element to the right of a "container"
<p>I have created this jsFiddle to represent my problem. </p> <p><a href="https://jsfiddle.net/L3p70zd8/" rel="nofollow">https://jsfiddle.net/L3p70zd8/</a></p> <pre><code>&lt;must put code to post jsFiddle link&gt; </code></pre> <p>I am building a carousel. The width of the content of the carousel is to be limited by the bootstrap container (the pink bit). However, I want the nav buttons to the left and right of the carousel to be outside the width of the container.</p> <p>I have achieved this on the left button using a negative margin but cannot figure out how to achieve the same result on the right button. I am open to changing the structure of the html.</p>
<html><css><twitter-bootstrap>
2016-06-23 01:55:01
LQ_CLOSE
37,981,269
How to search string values in GraphQL
<p>How do you query using GraphQL in a manor similar to SQL's <code>like</code> operator?</p> <p>Example: What users have a first name starting with <code>jason</code>?</p> <p><code>select * from users where first_name like "jason%"</code></p>
<graphql>
2016-06-23 02:19:52
HQ
37,981,595
How can I generate a 100% random number between 1 and the max of a 32 bit int in C#
<p>I would like to generate a random number that populates an int in C#. </p> <p>I have heard that sometimes random numbers are not reliable. Would this be a problem for me to generate a random number?</p> <p>Can someone comment on this and suggest a very reliable way to generate a random number between 1 and the max of a 32 bit int?</p>
<c#>
2016-06-23 02:59:45
LQ_CLOSE
37,981,668
How are webpages linked?
<p>I'm having trouble figuring out how two pages are linked. For example if I have the following code:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;button onclick='myfunction()'&gt;Click me&lt;/button&gt; &lt;body&gt; &lt;script&gt; function myfunction() { //some code to take user to the next page } &lt;/script&gt; &lt;style&gt; some style code &lt;/style&gt; </code></pre> <p>How is the code for the second html file called?</p> <p>Do all the contents of all webpages reside in one big html file where elements are hidden depending on the what they've clicked on? For example - the <code>div</code>'s shown on the 'home page' would be shown, while other ones hidden, if you click on a 'home' tab; essentially reformatting the elements on a page for a given file.</p>
<javascript><html><css><web>
2016-06-23 03:08:20
LQ_CLOSE
37,981,820
Docker Store Vs Docker Hub
<p>Did anyone actually figure out the difference between "Docker Store" that Docker introduced at DockerCon2016 and "Docker Hub"? </p> <p>Is Docker just trying to make a fancy version of Docker hub to have something like Apple Store, Android Store etc? or are there any specific use cases it is trying to solve by introducing this? I think, it can very well use Docker hub for providing trusted, validated etc. enterprise images as it is now providing official images. Then why "Docker Store" ??? </p>
<security><docker>
2016-06-23 03:27:56
HQ
37,982,177
Is this RFID card? How to write and read data to this card?
<p>I've been tasked to write and read data to this card. Vendor gave me Intelligent Tablet Payment Terminal i9300 and expect to write and read data to this card below. Intelligent Tablet Payment Terminal i9300 is Android based. It comes with its own SDK which poorly documented. What card is this and how do I even begin?</p> <p><a href="https://i.stack.imgur.com/DHuVf.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DHuVf.jpg" alt="enter image description here"></a></p>
<android><rfid>
2016-06-23 04:08:55
LQ_CLOSE
37,982,476
How to sort a map by value in javascript?
<pre><code>var map = new Map(); map.set("orange",10); map.set("apple",5); map.set("banana",20); map.set("cherry",13); </code></pre> <p>How to sort this map by value?</p>
<javascript><sorting><dictionary>
2016-06-23 04:39:59
HQ
37,984,304
how to save a scikit-learn pipline with keras regressor inside to disk?
<p>I have a scikit-learn pipline with kerasRegressor in it:</p> <pre><code>estimators = [ ('standardize', StandardScaler()), ('mlp', KerasRegressor(build_fn=baseline_model, nb_epoch=5, batch_size=1000, verbose=1)) ] pipeline = Pipeline(estimators) </code></pre> <p>After, training the pipline, I am trying to save to disk using joblib...</p> <pre><code>joblib.dump(pipeline, filename , compress=9) </code></pre> <p>But I am getting an error:</p> <blockquote> <p>RuntimeError: maximum recursion depth exceeded</p> </blockquote> <p>How would you save the pipeline to disk?</p>
<python><machine-learning><scikit-learn><keras><joblib>
2016-06-23 06:57:01
HQ
37,984,355
Does Firebase Analytics Work Offline?
<p>I know Firebase in general works offline, and syncs whenever an opportunity. Does the same thing apply to Firebase-Analytics for mobile (Android, iOS) apps?</p> <p>If yes (or partially yes) - how long can the user be offline?</p>
<firebase><firebase-analytics>
2016-06-23 06:59:54
HQ
37,984,423
Send specific key ASCII code to Bash
I want to force on bash "Tab" clicking from my C# code. I'm able to send any STRING value to the Bash and get the output, but how can I send the specific key to bash? I want to send "TAB". Can I type into bash console some specific string to have this kind of solution? I've tried `$'\t'`, some `echo` combinations etc, but I can't force bash to, for example, list the files in current directories. Thanks for any advice.
<c#><terminal><key><ascii>
2016-06-23 07:03:20
LQ_EDIT
37,985,051
Android alternative to GCM Push Notifications
<p>I develop a messenger application. To deliver messages used GCM and Websockets, when app in background websocket is closed and only gcm can push message to device.<br> I tested my app on some devices and seems it works fine.<br><br> But on the Play Market I have many comments about "messages not delivered when app in background". <br></p> <p><strong>What is the best way to do that messages are always guaranteed delivered when app is background?</strong> <br> <br> May be I need use background Service that always contains websocket connection? <br> How it is done in Whatsapp messenger?</p>
<java><android><service><websocket><google-cloud-messaging>
2016-06-23 07:36:05
LQ_CLOSE
37,985,900
Eager load model using with but giving it another name - Laravel 5.2
<p>Is it possible to use eager loading using the with method but giving it another name? Something like:</p> <pre><code>-&gt;with('documents as product', 'documents.documents as categories') </code></pre> <p>I have a documents table that can be product or categories, eager loading is working but not that friendly to retrieve the documents by just the document name instead of what it really is.</p>
<php><laravel><laravel-5.2>
2016-06-23 08:18:56
HQ
37,986,882
I have jason object But I am unabled to access 'name' element in this?
This is the jason data <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> {"0":{"restaurant":"Bayleaf","order":"HIHUN10","delivery at":"04:43 PM 2016-06-22","type":"Home Delivery","name":"dEEPAK rAI","address":"12356,Lucknow,226010","phone":"9120276440","total":"Rs 831.60","pay by":"Cash On Delivery","picked by":"By Administrator","date":"06\/22\/2016","status":"Waiting","action":"pending"},"1":{"restaurant":"Jungliee","order":"HIHUN9","delivery at":"03:40 PM 2016-06-21","type":"Home Delivery","name":"dEEPAK rAI","address":"12356,Lucknow,226010","phone":"9120276440","total":"Rs 465.00","pay by":"Cash On Delivery","picked by":"Dummy","date":"06\/21\/2016","status":{"Accepted":1,"Processing":2,"Delivered":3,"Completed":4,"Failed":5},"action":"view"},"2":{"restaurant":"Naushijaan","order":"HIHUN8","delivery at":"11:10 AM 2016-06-18","type":"Home Delivery","name":"dEEPAK rAI","address":"12356,Lucknow,226010","phone":"9120276440","total":"Rs 545.00","pay by":"Cash On Delivery","picked by":"By Administrator","date":"06\/18\/2016","status":{"Processing":2,"Delivered":3,"Completed":4,"Failed":5},"action":"view"},"3":{"restaurant":"Aahaar","order":"HIHUN7","delivery at":"11:32 AM 2016-06-12","type":"Home Delivery","name":"sk mishra","address":"520viram khand,Lucknow,226010","phone":"9198979962","total":"Rs 450.00","pay by":"Cash On Delivery","picked by":"Dummy","date":"06\/12\/2016","status":{"Completed":4,"Failed":5},"action":"view"},"4":{"restaurant":"Bayleaf","order":"HIHUN6","delivery at":"08:29 PM 2016-06-11","type":"Home Delivery","name":"Dharmraj","address":"D-242Office G 19 Sector 63,Lucknow,201003","phone":"7428069025","total":"Rs 606.60","pay by":"Cash On Delivery","picked by":"By Administrator","date":"06\/11\/2016","status":{"Completed":4,"Failed":5},"action":"view"},"5":{"restaurant":"Bayleaf","order":"HIHUN5","delivery at":"08:17 PM 2016-06-11","type":"Home Delivery","name":"Dharmraj","address":"D-242Office G 19 Sector 63,Lucknow,201003","phone":"7428069025","total":"Rs 606.60","pay by":"Cash On Delivery","picked by":"By Administrator","date":"06\/11\/2016","status":{"Completed":4,"Failed":5},"action":"view"}} <!-- end snippet -->
<jquery><json>
2016-06-23 09:00:41
LQ_EDIT
37,986,923
Hide NavigationBar when scrolling tableView in CollectionView?
<p>I have collectionViewController and collectionViewCell include TableView.CollectionView is horizontal layout.I want hide navigationbar when scroll the tableView. Is there any idea about that.</p>
<ios><swift><uitableview><uicollectionview><uinavigationbar>
2016-06-23 09:02:19
HQ
37,986,984
ruby on rails jsonb column default value
<p>I have a model ProjectKeyword where I use jsonb datatype in the column <code>:segemnted_data</code></p> <pre><code>class ProjectKeyword &lt; ApplicationRecord belongs_to :project belongs_to :keyword has_many :project_keyword_dimensions has_many :dimensions, through: :project_keyword_dimensions validates :project_id, :keyword_id, presence: true end </code></pre> <p>Migration </p> <pre><code>class AddSegemtnedDataToProjectKeywords &lt; ActiveRecord::Migration[5.0] def change add_column :project_keywords, :segmented_data, :jsonb, default: '{}' add_index :project_keywords, :segmented_data, using: :gin end end </code></pre> <p>My problem is when I create new <code>project_keyword</code> instance the default value of the <code>segmented_data</code> is a string not a hash and I cannot update this field or merge with another hash For example</p> <pre><code>[12] pry(#)&gt; new_pr_keyword = ProjectKeyword.new(project_id: 1671333, keyword_id: 39155) =&gt; #&lt;ProjectKeyword:0x007fd997641090 id: nil, project_id: 1671333, keyword_id: 39155, segmented_data: "{}"&gt; [13] pry(#)&gt; new_pr_keyword.save! =&gt; true [14] pry(#)&gt; new_pr_keyword.segmented_data.update({'new_data' =&gt; 'some_data'}) NoMethodError: undefined method `update' for "{}":String from (pry):14:in `block (3 levels) in &lt;top (required)&gt;' </code></pre> <p>But when I asign <code>hash</code> value to the field <code>segmented_data</code> before update then <code>update</code> method works fine.</p> <p>For example </p> <pre><code>[15] pry(#)&gt; new_pr_keyword.segmented_data = {'new_data' =&gt; 'some_data'} =&gt; {"new_data"=&gt;"some_data"} [16] pry(#)&gt; new_pr_keyword.save! =&gt; true [17] pry(#)&gt; new_pr_keyword.segmented_data.update({'new_data_2' =&gt; 'some_data_2'}) =&gt; {"new_data"=&gt;"some_data", "new_data_2"=&gt;"some_data_2"} [18] pry(#)&gt; new_pr_keyword.save! =&gt; true </code></pre> <p>The question is how to make default value of segmented_data to be a Hash class not a String so method update then will work straight away on this field, after object just was created.</p>
<ruby-on-rails><postgresql><activerecord><jsonb>
2016-06-23 09:04:38
HQ
37,987,193
IntelliJ + Spring Web MVC
<p>I have problem with IntelliJ 2016.1.3 and Spring Web MVC integration. Steps I've made:</p> <ol> <li>File -> New -> Project... -> Maven (no archetype)</li> <li>GroupId = test ArtifactId = app</li> <li>Project name = App and Finish.</li> <li>I added to pom.xml &lt; packaging > war &lt; /packaging ></li> <li><p>I added to pom.xml dependencies <br/></p> <pre> &ltdependency&gt &ltgroupId&gtorg.springframework&lt/groupId&gt &ltartifactId&gtspring-webmvc&lt/artifactId&gt &ltversion&gt4.1.6.RELEASE&lt/version&gt &lt/dependency&gt &ltdependency&gt &ltgroupId&gtjavax.servlet&lt/groupId&gt &ltartifactId&gtjstl&lt/artifactId&gt &ltversion&gt1.2&lt/version&gt &lt/dependency&gt &ltdependency&gt &ltgroupId&gtjavax.servlet&lt/groupId&gt &ltartifactId&gtjavax.servlet-api&lt/artifactId&gt &ltversion&gt3.1.0&lt/version&gt &ltscope&gtprovided&lt/scope&gt &lt/dependency&gt </pre></li> <li><p>Next I added modules into project (right click on project name -> Add Framework Support... ). I selected Spring MVC and Download (Configure... - selected all items).</p></li> <li><p>I created controller class HomeController.class</p> <pre> package test.app; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @Controller public class HomeController { @RequestMapping(value="/") public String test() { return "test"; } } </pre></li> <li><p>I created webapp\WEB-INF and put there web.xml</p> <pre> &ltweb-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"&gt &ltservlet&gt &ltservlet-name&gtWebServlet&lt/servlet-name&gt &ltservlet-class&gtorg.springframework.web.servlet.DispatcherServlet&lt/servlet-class&gt &ltinit-param&gt &ltparam-name&gtcontextConfigLocation&lt/param-name&gt &ltparam-value&gt/WEB-INF/dispatcher-servlet.xml&lt/param-value&gt &lt/init-param&gt &lt/servlet&gt <pre><code>&amp;ltservlet-mapping&amp;gt &amp;ltservlet-name&amp;gtWebServlet&amp;lt/servlet-name&amp;gt &amp;lturl-pattern&amp;gt/&amp;lt/url-pattern&amp;gt &amp;lt/servlet-mapping&amp;gt </code></pre> &lt/web-app&gt </pre></li> <li><p>Into webapp\WEB-INF I put dispatcher-servlet.xml</p> <pre> &lt?xml version="1.0" encoding="UTF-8"?&gt &ltbeans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd"&gt <pre><code>&amp;ltmvc:annotation-driven /&amp;gt &amp;ltcontext:component-scan base-package="test.app" /&amp;gt &amp;ltbean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&amp;gt &amp;ltproperty name="prefix" value="/WEB-INF/views/" /&amp;gt &amp;ltproperty name="suffix" value=".jsp" /&amp;gt &amp;lt/bean&amp;gt </code></pre> &lt/beans&gt </pre></li> <li><p>Finally I added test.jsp file into webapp\WEB-INF\views. In addition I had to add module dependency (F4 -> modules -> dependencies -> + -> library -> from maven -> typed javax.servlet:jstl:1.2)</p></li> <li>Next step should be run application. I had to edit configurations (down arrow next to green arrow) -> + -> TomcatServer -> Local and I got warning No artifacts marked for deployment. Unfortunatelly I can't fix this problem. I have Fix button but after I press this I get Deployment tab and don't what to do.</li> </ol> <p>Please help me with deployment configuration and tell me is my way of creating spring web application in IntelliJ good or have you got another better way. I need step by step tutorial because I watched some movies on youtube and I saw options I haven't in my Intellij or they are hidden and I can't find them. Best regards </p>
<java><spring><maven><spring-mvc><intellij-idea>
2016-06-23 09:12:46
HQ
37,987,301
How to run multiple QTest classes?
<p>I have a subproject where I put all my <code>QTest</code> unit tests and build a stand-alone test application that runs the tests (i.e. I run it from within Qt Creator). I have multiple test classes that I can execute with <code>qExec()</code>. However I don't know what is the proper way to execute multiple test classes.</p> <p>Currently I do it in this way (MVCE):</p> <h2>tests.pro</h2> <pre><code>QT -= gui QT += core \ testlib CONFIG += console CONFIG -= app_bundle TEMPLATE = app TARGET = testrunner HEADERS += test_foo.h SOURCES += main.cpp </code></pre> <h2>main.cpp</h2> <pre><code>#include &lt;QtTest&gt; #include &lt;QCoreApplication&gt; #include "test_foo.h" int main(int argc, char** argv) { QCoreApplication app(argc, argv); TestFooClass testFoo; TestBarClass testBar; // NOTE THIS LINE IN PARTICULAR. return QTest::qExec(&amp;testFoo, argc, argv) || QTest::qExec(&amp;testBar, argc, argv); } </code></pre> <h2>test_foo.h</h2> <pre><code>#include &lt;QtTest&gt; class TestFooClass: public QObject { Q_OBJECT private slots: void test_func_foo() {}; }; class TestBarClass: public QObject { Q_OBJECT private slots: void test_func_bar() {}; }; </code></pre> <p>However the <a href="http://doc.qt.io/qt-5/qtest.html#qExec" rel="noreferrer">documentation for <code>qExec()</code></a> says this is the wrong way:</p> <blockquote> <p>For stand-alone test applications, this function should not be called more than once, as command-line options for logging test output to files and executing individual test functions will not behave correctly.</p> </blockquote> <p>The other major downside is that there is <strong>no single summary for all the test classes</strong>, only for individual classes. This is a problem when I have dozens of classes that each have dozens of tests. To check if all tests passed I have to scroll up to see all the "Totals" of what passed/failed of each class, e.g.:</p> <pre><code>********* Start testing of TestFooClass ********* PASS : TestFooClass::initTestCase() PASS : TestFooClass::test_func_foo() PASS : TestFooClass::cleanupTestCase() Totals: 3 passed, 0 failed, 0 skipped, 0 blacklisted ********* Finished testing of TestFooClass ********* ********* Start testing of TestBarClass ********* PASS : TestBarClass::initTestCase() PASS : TestBarClass::test_func_bar() PASS : TestBarClass::cleanupTestCase() Totals: 3 passed, 0 failed, 0 skipped, 0 blacklisted ********* Finished testing of TestBarClass ********* </code></pre> <p>I'm also surprised my <code>qExec() || qExec()</code> works considering that the <a href="http://doc.qt.io/qt-5/qtest.html#qExec" rel="noreferrer">documentation</a> says if a test failed <code>qExec()</code> returns a non-zero value, which should mean all the following <code>qExec()</code> calls wouldn't happen, but this seems not to be the case.</p> <p>What is the proper way to run multiple test classes? And so that I can see at a glance if any of the hundreds of unit tests I have have failed.</p>
<c++><qt><unit-testing><qtestlib>
2016-06-23 09:18:31
HQ
37,987,576
How to scale Lambda when /tmp is reused?
<p>I have a lambda function that reads from DynamoDB and creates a large file (~500M) in /tmp that finally uploaded to s3. Once uploaded the lambda clears the file from /tmp (since there is a high probability that the instance may be reused)</p> <p>This function takes about 1 minute to execute, even if you ignore the latencies.</p> <p>In this scenario, when i try to invoke the function again, in &lt; 1m, i have no control if i will have enough space to write to /tmp. My function fails.</p> <p>Questions: 1. What are the known work arounds in these kind of scenario? (Potentially give more space in /tmp or ensure a clean /tmp is given for each new execution) 2. What are the best practices regarding file creation and management in Lambda? 3. Can i attach another EBS or other storage to Lambda for execution ? 4. Is there a way to have file system like access to s3 so that my function instead of using /tmp can write directly to s3?</p>
<amazon-web-services><scalability><aws-lambda>
2016-06-23 09:29:32
HQ
37,987,655
hi there, i m trying to generate a random number generator in viusal C++, and everything seems to working except the reset button
i m trying to generate a random number generator in viusal C++, and everything seems to working except the reset button #pragma endregion private: System::Void MyForm_Load(System::Object^ sender, System::EventArgs^ e) { // Reset button System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) ; { // clear label fields this->label1->Text = "0"; this->label2->Text = "0"; this->label3->Text = "0"; this->label4->Text = "0"; this->label5->Text = "0"; this->label6->Text = "0"; this->label7->Text = "0"; // set button state this->button1->Enabled = false; this->button2->Enabled = true; } this is the code i placed into the reset button.
<visual-studio-2013><c++-cli>
2016-06-23 09:32:33
LQ_EDIT
37,988,629
What does <- mean in scala with yeild?
<p>I'm pretty new to scala and come up with the following construction:</p> <pre><code>val value= for { p1 &lt;- getList() p2 &lt;- parser.parse(p1) //parser.parse(String) Returns some useful value } yield p2 value.asJava </code></pre> <p>Where</p> <pre><code>def getList(): List[String] = { //compiled code } </code></pre> <p>I don't quite understand what's going on in the first piece of code. Searching for <strong><em>scala left arrow operator</em></strong> did't shed the light on this. Can't you explain it?</p>
<scala><operators>
2016-06-23 10:11:11
LQ_CLOSE
37,989,049
I'm getting the error in angularJs
"angular.js:13550Error: [$injector:unpr] http://errors.angularjs.org/1.5.5/$injector/unpr?p0=DTOptionsBuilderProvider%20%3C-%20DTOptionsBuilder%20%3C-%20playbackController at n (http://localhost:63721/Scripts/angular.min.js:64:374)" Following is the code of my controller myApp.controller('playController',['DTOptionsBuilder','DTColumnBuilder', function (DTOptionsBuilder, DTColumnBuilder) { this.standardOptions = DTOptionsBuilder .fromSource('Scripts/datatables.standard.json') //Add Bootstrap compatibility .withDOM("<'dt-toolbar'<'col-xs-12 col-sm-6'f><'col-sm-6 col-xs-12 hidden-xs'l>r>" + "t" + "<'dt-toolbar-footer'<'col-sm-6 col-xs-12 hidden-xs'i><'col-xs-12 col-sm-6'p>>") .withBootstrap(); this.standardColumns = [ DTColumnBuilder.newColumn('id').withClass('text-danger'), DTColumnBuilder.newColumn('name'), DTColumnBuilder.newColumn('phone'), DTColumnBuilder.newColumn('company'), DTColumnBuilder.newColumn('zip'), DTColumnBuilder.newColumn('city'), DTColumnBuilder.newColumn('date') ]; }]);
<javascript><angularjs>
2016-06-23 10:29:54
LQ_EDIT
37,989,534
How to install Docker on 32bit machine having Ubuntu 12.04?
<p>I have followed the <a href="https://docs.docker.com/engine/installation/linux/ubuntulinux/" rel="noreferrer">docker installation doc</a> for installing it on my machine which is a 32 bit machine running Ubuntu 12.04</p> <p>The step</p> <pre><code>$ sudo apt-get install docker-engine </code></pre> <p>fails saying</p> <pre><code>E: Unable to locate package docker-engine </code></pre> <p>It should have been installed, right?</p> <p>Also I came to know that, Docker currently only supports 64bit platforms. </p> <pre><code>$ wget -qO- https://get.docker.io/ | sh Error: you are not using a 64bit platform. Docker currently only supports 64bit platforms. </code></pre> <p>Is there a way to I install it and make it work on 32bit machine?</p>
<docker><ubuntu-12.04><32-bit>
2016-06-23 10:52:21
HQ
37,990,752
Empty class size in python
<p>I just trying to know the rationale behind the empty class size in python, In C++ as everyone knows the size of empty class will always shows 1 byte(as far as i have seen) this let the run time to create unique object,and i trying to find out what size of empty class in python:</p> <pre><code>class Empty:pass # i hope this will create empty class </code></pre> <p>and when i do </p> <pre><code>import sys print ("show",sys.getsizeof(Empty)) # i get 1016 </code></pre> <p>I wonder why the <code>Empty</code> takes this much 1016(bytes)? and also does the value(1016) it returns is this a standard value that never change(mostly) like C++?, Do we expect any zero base class optimization from python interpreter?Is there any way we can reduce the size of am Empty(just for curiosity sake)?</p>
<python>
2016-06-23 11:48:13
HQ
37,991,113
How to get the list of all available timezone using moment-timezone
<p>I am trying to get the list of all the available timezones using moment-timezone in node js like this - </p> <pre><code>var moment = require('moment-timezone'); var timeZones = moment.tz.names(); console.log(timeZones); </code></pre> <p>I am getting the timezones in this format - </p> <pre><code>'Europe/Mariehamn', 'Europe/Minsk', 'Europe/Monaco', 'Europe/Moscow', 'Europe/Nicosia', 'Europe/Oslo', 'Europe/Paris', 'Europe/Podgorica', 'Europe/Prague', 'Europe/Riga', 'Europe/Rome', </code></pre> <p>But I want to get the timezones in this format - </p> <pre><code>(GMT +01:00) Africa/Brazzaville (GMT +01:00) Africa/Casablanca (GMT +01:00) Africa/Douala (GMT +01:00) Africa/El_Aaiun (GMT +01:00) Africa/Kinshasa (GMT +01:00) Africa/Lagos (GMT +01:00) Africa/Libreville (GMT +01:00) Africa/Luanda (GMT +01:00) Africa/Malabo (GMT +01:00) Africa/Ndjamena (GMT +01:00) Africa/Niamey </code></pre> <p>How do I get ?</p>
<timezone><momentjs>
2016-06-23 12:03:58
HQ
37,991,520
Always run cmd via ConEmu as administrator
<p>I'm using <strong>ConEmu</strong> and I want to <strong>always</strong> have my cmds run as <strong>administrator</strong>.</p> <p>I've <strong>changed</strong> the settings that forces all my cmds to run through ConEmu, so typing 'cmd' in the Windows Run will open ConEmu (Settings -> Integration -> Default term -> Force ConEmu as default terminal)</p> <p>I've <strong>tried</strong> changing the (Settings -> Startup -> Command line) to <code>cmd.exe -new_console:a</code> which works for shortcuts but doesn't change the default (running cmd from Run or opening a new tab inside ConEmu)</p> <p>Thanks</p>
<cmd><admin><conemu>
2016-06-23 12:22:46
HQ
37,992,225
Config your IIS server to use the "Content-Security-Policy" header
<p>I need to add custom headers in IIS for "Content-Security-Policy", "X-Content-Type-Options" and "X-XSS-Protection".</p> <p>I get the procedure to add these headers but i am not sure what should be the value of these keys. <a href="https://technet.microsoft.com/pl-pl/library/cc753133(v=ws.10).aspx" rel="noreferrer">https://technet.microsoft.com/pl-pl/library/cc753133(v=ws.10).aspx</a></p> <p><a href="http://content-security-policy.com/" rel="noreferrer">http://content-security-policy.com/</a></p> <p>Please suggest. Thanks</p>
<security><iis><xss>
2016-06-23 12:53:10
HQ
37,992,365
How to set the elevation of an AppBarLayout programmatically in the Android Support Library v24.0.0?
<p>When upgrading from the Android Support Library v23.4.0 to v24.0.0, setting the elevation to 0 programmatically to an AppBarLayout stopped working:</p> <pre><code>appBayLayout.setElevation(0); </code></pre> <p>It does work when setting the elevation in the XML.</p>
<android><android-support-library><android-support-design>
2016-06-23 12:58:44
HQ
37,993,576
ReactJS apply multiple inline styles
<p>Let's say I have the following styles:</p> <pre><code>const styles = StyleSheet.create({ padding: { padding: 10 }, margin: { margin: 10 } }); </code></pre> <p>and I want to apply both of them to a react component?</p>
<reactjs><react-native><react-jsx>
2016-06-23 13:49:57
HQ
37,993,765
Last Date Attended from 2 Tables MS SQL
I have searched the forum, and couldn't find an answer. So I apologize if this is out there. This seems simple in my mind, however, I can't seem to get the correct code. I have 2 tables. STUDENT_TERMS_VIEW table holds the STTR_STUDENT, STTR_TERM and TERMS table, holds the TERM_END_DATE. I need to find a way to select the student's last term based on MAX(TERM_END_DATE), but I get STTR_TERM duplicate rows per student. I need to get 1 row per student and their last term attended. thanx [View SQL Image][1] [1]: http://i.stack.imgur.com/vjGLQ.png
<sql-server>
2016-06-23 13:57:26
LQ_EDIT
37,994,201
Error: evaluation nested too deeply: infinite recursion / options(expressions=)? in R on Mac
<pre><code>sum &lt;- function(data){ sum(data) } median &lt;- function(data){ median(data) } floor &lt;- function(data){ floor(data) } evaluate &lt;- function(func, dat){ func(dat) } </code></pre> <p>This is my code. The goal I want to achieve are as followings </p> <ol> <li><p>evaluate(sum, c(2, 4, 6)) should evaluate to 12;</p></li> <li><p>evaluate(median, c(7, 40, 9)) should evaluate to 9;</p></li> <li>evaluate(floor, 11.1) should evaluate to 11;</li> </ol> <p>But I always got the error as below</p> <pre><code>Error: evaluation nested too deeply: infinite recursion / options(expressions=)? Error during wrapup: evaluation nested too deeply: infinite recursion / options(expressions=)? </code></pre>
<r>
2016-06-23 14:14:37
LQ_CLOSE
37,994,315
How to create an empty java trust store?
<p>I want to make a https client in java which initially does not have any CA certs to trust. Since I don't want the JVM to use the default cacerts file I should make an empty trust store and point it to the JVM.<br> How can I make an empty trust store?</p>
<java><ssl><truststore>
2016-06-23 14:18:48
HQ
37,994,332
Angular 2 - Http Get request - pass json Object
<p>How can I do a http get request and pass an json Object</p> <p>This is my json-Object</p> <pre><code>{{firstname:"Peter", lastname:"Test"} </code></pre> <p>and this Object I want to pass in the http request to get a list Of matched persons.</p> <p>how is it possible? This example just shows a simple get request with a json result. How do I have to modify it?</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>//Component: person:Person; persons:Person []; .... //Whre can I pass the person, here in the service?? getMatchedPersons(){ this.httpService.getMatchedPersons().subscribe( data =&gt; this.persons = data, error =&gt; aller(error) ); ); //SERVICE //pass parameters?? how to send the person object here? getMatchedPersons(){ return this.http.get('url').map(res =&gt; res.json()); }</code></pre> </div> </div> </p>
<javascript><http><angular>
2016-06-23 14:19:37
HQ
37,994,640
How to filter a column in Oracle Sql Developer with two matches
<p>I am learning sqldeveloper slowly and I know how to filter based on a single matching string: just copy/paste the string you would like to match, or double click on it if you are lucky.</p> <p>Now I would like to query based on two different strings, let's say 'ABC' or 'DEF', how would one do that in the 'Filter' option (right click on column) ?</p> <p><a href="https://i.stack.imgur.com/FtxGN.png" rel="noreferrer"><img src="https://i.stack.imgur.com/FtxGN.png" alt="Complex filtering"></a></p>
<oracle-sqldeveloper>
2016-06-23 14:32:47
HQ
37,994,820
Android studio AlertDialog ProgressBar lock
<p>I need to lock my AlertDialog. Now, when my alertDialog is enable and when i click on the screen, my alertdialog closed. I need to wait the end of the progress bar to close my alertDialog. How i can do this? Thank</p>
<android><android-alertdialog>
2016-06-23 14:40:27
LQ_CLOSE
37,995,628
How to implement Material Design Choreographing surface animations
<p>I wonder how to implement the Choreographing surface animations (like <a href="https://material.google.com/motion/choreography.html#choreography-creation">https://material.google.com/motion/choreography.html#choreography-creation</a> in Choreographic surface section).</p> <p>I actually used both Alpha animation and Translate animation but it seems like it is not exactly what we can see on the material design site.</p> <p>Did someone have a good example of how to do this ?</p>
<android><animation><material-design>
2016-06-23 15:16:12
HQ
37,995,648
Golang map internal implementation - how does it search the map for a key?
<p>I've read in "The Go Programming Language" that a "given key can be retrieved ... using a constant number of key comparisons on average, no matter how large the hash table." I'm not sure what that means in terms of its implementation internally though. Does that mean it searches through every key until it finds a match or is some type of binary (or other) search algorithm used internally?</p> <p>For example, if I have a map with 2,000 keys, does it "on average" need to look at 1,000 to find a match or does it look at only 11 (log2 n) as it would with binary search?</p> <p>Thanks, Ben</p>
<dictionary><go>
2016-06-23 15:17:01
HQ
37,995,772
Set Class if json Array is 0
<p>I try to build a User bar like in Facebook "New Friend Requests" ore "New Pms"</p> <p>This is now my HTML Template Code:</p> <pre><code>&lt;li class="icon-element pms"&gt; &lt;div class="icon" ng-include="iconPm"&gt;&lt;/div&gt; &lt;span class="counter"&gt;{{account.newPms}}&lt;/span&gt; &lt;/li&gt; </code></pre> <p>In the span is {{account.newPms}} this can be 0. If it is 0, then i want to set a class in the li namend "is-zero"</p> <p>I found some in other topics like:</p> <pre><code>&lt;li ng-if="account.newPms == '0'&gt;&lt;/li&gt; </code></pre> <p>but how i can set the class in the li if it is 0?</p> <p>best regards!</p>
<javascript><angularjs><if-statement>
2016-06-23 15:22:19
LQ_CLOSE
37,996,026
use RecyclerView like vertical viewpager
<p>is this possible to use recyclerview like verticalpager .<br> what I want is when a user scrolls always the first item offset from the top be zero. like when you scroll in viewpager. is this possible?</p>
<android><android-recyclerview>
2016-06-23 15:34:03
HQ
37,996,118
php divide with 'easy' numbers
<p>I'm working on a program in PHP that lets you train for making calculations without a calculator. The problem I run into is that when generating random numbers for the sums you can get awkward numbers like 4 divided by 7. Is there an easy way to generate easy sums like 9 divided by 3?</p> <p>Thanks!</p>
<php>
2016-06-23 15:38:37
LQ_CLOSE
37,996,419
How to force `.andExpect(jsonPath()` to return Long/long instead int for int number for jackson parser
<p>I have a simple test to my RestController. I expect that <code>$[1].parent_id</code>returns Long as an object and not integer primitive. It will return Long if <code>parent_id</code> is in a long number range and > integer number range (such as : 2147483650L).</p> <pre><code>@RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = Application.class) @WebAppConfiguration @WebAppConfiguration public class TransactionServiceControllerTest { @Before public void setup() throws Exception { this.mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build(); // I copy this from my RestController class this.transactions = Arrays.asList( new Transaction(100d, "car", null), new Transaction(100d, "table", 12L) ); } @Test public void readSingleBookmark() throws Exception { mockMvc.perform(MockMvcRequestBuilders.get("/transaction/")) .andExpect(content().contentType(contentType)) // ok .andExpect(jsonPath("$", hasSize(2))) // ok //omitted andExpect(jsonPath("$[1].parent_id",is(this.transactions.get(1).getParentId()))); } //assertion fail Expected: is &lt;12L&gt; but: was &lt;12&gt; </code></pre> <p>Result from another test :</p> <pre><code>Expected: is &lt;12L&gt; but: was &lt;2147483650L&gt; //return Long instead int </code></pre> <p>this is my JacksonConfiguration</p> <pre><code>@Configuration public class JacksonConfiguration { @Bean @Primary public ObjectMapper objectMapper() { final ObjectMapper objectMapper = new ObjectMapper(); //supposed to be this is the magic trick but it seems not.. objectMapper.enable(DeserializationFeature.USE_LONG_FOR_INTS); objectMapper.setSerializationInclusion(JsonInclude.Include.NON_ABSENT); objectMapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE); return objectMapper; } } </code></pre> <p>And my POJO</p> <pre><code>public class Transaction { private double ammount; private String type; private Long parentId; public Transaction(Double ammount, String type, Long parentId) { //omitted } //setter and getter omitted } </code></pre> <p>MyRestController</p> <pre><code>@RestController @RequestMapping("transaction") public class TransactionServiceController { @RequestMapping(method = RequestMethod.GET) List&lt;Transaction&gt; getTransaction() { return Arrays.asList( new Transaction(100d, "car", null), new Transaction(100d, "table", 12L) ); } } </code></pre> <p>And Application.java</p> <pre><code>@SpringBootApplication public class Application { public static void main(String[] args){ SpringApplication.run(Application.class,args); } } </code></pre>
<json><jackson><spring-test><spring-rest>
2016-06-23 15:53:13
HQ
37,996,485
Using Jackson to map object from specific node in JSON tree
<p>Is it possible to have Jackson's <code>ObjectMapper</code> unmarshall only from a specific node (and 'down') in a JSON tree?</p> <p>The use case is an extensible document format. I want to walk the tree, and then publish the current path to an extensible set of plugins, to see if the user is using and plugins that know what to do with that part of the document.</p> <p>I'd like for plugin authors to not have to deal with the low-level details of <code>JsonNode</code> or the streaming API; instead, just be passed some context and a specific <code>JsonNode</code>, and then be able to use the lovely and convenient <code>ObjectMapper</code> to unmarshall an instance of their class, considering the node passed as the root of the tree.</p>
<java><json><jackson>
2016-06-23 15:55:51
HQ
37,996,561
String Manipulation [PYTHON]
Say if i converted a string into lowercase, how would I convert it back to the original string the user entered ? [PYTHON] I have been searching for a particular python function that will convert the string back to the original string. I have used .swapcase() but unfortunately it didn't work. Please bare in mind that the .lower() is needed. Thank you.
<python><string>
2016-06-23 15:59:34
LQ_EDIT
37,997,465
Remove element from collection during iteration with forEach
<p>Recently, I wrote this code without thinking about it very much:</p> <pre><code>myObject.myCollection.forEach { myObject.removeItem($0) } </code></pre> <p>where <code>myObject.removeItem(_)</code> removes an item from <code>myObject.myCollection</code>.</p> <p>Looking at the code now, I am puzzled as to why this even works - shouldn't I get an exception along the lines of <code>Collection was mutated while being enumerated</code>? The same code even works when using a regular for-in loop!</p> <p>Is this expected behaviour or am I 'lucky' that it isn't crashing?</p>
<swift>
2016-06-23 16:48:45
HQ
37,997,766
Enums support with Realm?
<p>I'm working on an android app and Realm, and I need to create an enum attribute for one of my objects; but I discovered in this <a href="https://github.com/realm/realm-java/issues/776" rel="noreferrer">post</a> that Realm doesn't support enum yet. </p> <p>My object is like this:</p> <pre><code>public class ShuttleOption extends RealmObject { private int Id; private String Label; private ShuttleTypes OriginShuttleType; } </code></pre> <p>and my enum class (ShuttleTypes) corresponds with:</p> <pre><code>HOME = 1; </code></pre> <p>and </p> <pre><code>WORK = 2; </code></pre> <p>Can anybody suggest me how to do it?</p>
<java><android><enums><realm>
2016-06-23 17:05:00
HQ
37,998,281
React Redux unexpected key passed to create store
<p>I am getting the error <code>Unexpected key "characters" found in initialState argument passed to createStore. Expected to find one of the known reducer keys instead: "marvelReducer", "routing". Unexpected keys will be ignored.</code> </p> <p>rootReducer : </p> <pre><code> import { combineReducers } from 'redux'; import { routerReducer } from 'react-router-redux'; import marvelReducer from './marvelReducer'; const rootReducer = combineReducers({ marvelReducer, routing: routerReducer }); export default rootReducer; </code></pre> <p>marvelReducer : </p> <pre><code>import { FETCH_MARVEL } from '../constants/constants'; import objectAssign from 'object-assign'; export default function marvelReducer(state = [], action) { switch (action.type) { case FETCH_MARVEL: return objectAssign({}, state, {characters: action.data}); default: return state; } } </code></pre> <p>store : </p> <pre><code>import { createStore } from 'redux'; import { syncHistoryWithStore } from 'react-router-redux'; import { browserHistory } from 'react-router'; import rootReducer from '../reducers/index'; const initialState = { characters: [] }; const store = createStore(rootReducer, initialState); export const history = syncHistoryWithStore(browserHistory, store); if (module.hot) { module.hot.accept('../reducers/', () =&gt; { const nextRootReducer = require('../reducers/index').default; store.replaceReducer(nextRootReducer); }); } export default store; </code></pre> <p>I have very similar code in another application and it's working fine. Not sure what's going on here</p>
<javascript><reactjs><redux>
2016-06-23 17:33:52
HQ
37,998,592
Why can't I use the wildcard (?) as type of parameter, field, local variable, or as return type of a method?
<p>The Oracle <a href="https://docs.oracle.com/javase/tutorial/java/generics/wildcards.html" rel="noreferrer">doc about Wildcards in generics</a> says,</p> <blockquote> <p>The wildcard can be used in a variety of situations: as the <strong>type of a parameter</strong>, <strong>field</strong>, or <strong>local variable</strong>; sometimes as a <strong>return type</strong> (though it is better programming practice to be more specific).</p> </blockquote> <p>I have tried all four in the following class, and got compiler errors on each one. Why? What am I doing wrong?</p> <pre><code>public class MainClass { private ? instanceFieldWithWildCardType;//ERROR private static ? staticFieldWithWildCardType;//ERROR private void methodWithWildCardParam(? param) {}//ERROR private void methodWithWildCardLocalVariable() { ? localVariableWithWildCardType;//ERROR } private ? methodWithWildCardReturnType() {//ERROR return null; } private void methodWithWildCardParam(? param) {}//ERROR } </code></pre>
<java><generics><wildcard><bounded-wildcard><unbounded-wildcard>
2016-06-23 17:51:48
HQ
37,998,848
How is character encoding specified in a multipart/form-data HTTP POST request?
<p>The HTML 5 specification describes an <a href="http://www.w3.org/TR/2014/REC-html5-20141028/forms.html#multipart-form-data" rel="noreferrer">algorithm</a> for selecting the character encoding to be used in a multi-part form submission (e.g. UTF-8). However, it is not clear how the selected encoding should be relayed to the server so that the content can be properly decoded on the receiving end.</p> <p>Often, character encodings are represented by appending a "charset" parameter to the value of the <code>Content-Type</code> request header. However, this parameter does not appear to be defined for the <code>multipart/form-data</code> MIME type:</p> <p><a href="https://tools.ietf.org/html/rfc7578#section-8" rel="noreferrer">https://tools.ietf.org/html/rfc7578#section-8</a></p> <p>Each part in a multipart form submission may provide its own <code>Content-Type</code> header; however, RFC 7578 notes that "in practice, many widely deployed implementations do not supply a charset parameter in each part, but rather, they rely on the notion of a 'default charset' for a multipart/form-data instance". </p> <p>RFC 7578 goes on to suggest that a hidden "_charset_" form field can be used for this purpose. However, neither Safari (9.1) nor Chrome (51) appear to populate this field, nor do they provide any per-part encoding information.</p> <p>I've looked at the request headers produced by both browsers and I don't see any obvious character encoding information. Does anyone know how the browsers are conveying this information to the server?</p>
<html><post><utf-8><multipartform-data>
2016-06-23 18:07:04
HQ
37,999,630
How to get a standalone / unmanaged RealmObject using Realm Xamarin
<p>Is there a way that when I read an object from Realm that it can become a standalone or unmanaged object? In EF, this is called no tracking. The usage for this would be when I want to implement more business logic on my data objects before they are updated on the persistent data storage. I may want to give the RealmObject to a ViewModel, but when the changes come back from the ViewModel, I want to compare the disconnected object to the object in the datastore to determine what was changed, so If there was a way that I could disconnect the object from Realm when I give it to the ViewModel, then I can better manage what properties have changed, using my biz logic to do what I need, then save the changes back to realm. </p> <p>I understand Realm does a lot of magic and many people will not want to add a layer like this but in my app, I cant really have the UI directly updating the datastore, unless there is a event that is raised that I can subscribe too and then attach my business logic this way.</p> <p>I only saw one event and it does not appear to perform this action.</p> <p>Thanks for your assistance.</p>
<xamarin><realm>
2016-06-23 18:53:19
HQ
37,999,652
Increasing php array by 1 inside jQuery each function
<p>I'm struggle to find an answer for this so was hoping to hear from the community.</p> <pre><code>$('.slick-dots button').each(function(index) { $(this).html('&lt;?php echo $headings[0]; ?&gt;') }); </code></pre> <p>Within the above .each function, I am trying to increase $headings[0] by one on each loop.</p> <p>Hopefully I'm missing something pretty simple and I've not gone down an impossible route?</p>
<php><jquery>
2016-06-23 18:54:47
LQ_CLOSE
37,999,657
How to get a value from the Row object in Spark Dataframe?
<p>for </p> <pre><code>averageCount = (wordCountsDF .groupBy().mean()).head() </code></pre> <p>I get</p> <blockquote> <p>Row(avg(count)=1.6666666666666667)</p> </blockquote> <p>but when I try:</p> <pre><code>averageCount = (wordCountsDF .groupBy().mean()).head().getFloat(0) </code></pre> <p>I get the following error:</p> <blockquote> <p>AttributeError: getFloat --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) in () 1 # TODO: Replace with appropriate code ----> 2 averageCount = (wordCountsDF 3 .groupBy().mean()).head().getFloat(0) 4 5 print averageCount</p> <p>/databricks/spark/python/pyspark/sql/types.py in <strong>getattr</strong>(self, item) 1270 raise AttributeError(item) 1271<br> except ValueError: -> 1272 raise AttributeError(item) 1273 1274 def <strong>setattr</strong>(self, key, value):</p> <p>AttributeError: getFloat</p> </blockquote> <p>What am I doing wrong?</p>
<apache-spark><pyspark><spark-dataframe>
2016-06-23 18:55:23
HQ
37,999,878
combination of data frame columns in regression r
<p><br> I have a data frame with colnames A, B, C, D with numeric values. I am trying to generate a linear regression model using variables and trying all the possible combination like A, A+B, A+C, B, B+C ....<br> I am having trouble generating combinations with data frame.</p> <pre><code>Data frame DependentVar A B C D </code></pre> <p>I am trying to generate something like this:<br> Combinations of independent variables like:</p> <pre><code>var &lt;- A,B,C,D,A+B,A+C,A+D,B+C,B+D,C+D,A+B+C,A+B+D and so on.. for (v in var){ models &lt;- lm (DependentVar ~ eval(parse(text=v)), data=data) r2 &lt;- append(summary(models)$r.squared) } </code></pre> <p>Output like dataframe:</p> <pre><code>Variable combination Model R2 A 0.8 B 0.7 . . </code></pre> <p>and so on <br> Any help will be greatly appreciated! </p>
<r>
2016-06-23 19:09:14
LQ_CLOSE
38,000,624
Integrating SVN with kwallet
<p>I can't for my life make SVN read the password stored at kwallet and use it to stop asking when I do anything. Google has not helped finding the answer, so I turn back to you. </p> <p>I'm running right now Kubuntu 16.04 fully upgraded, SVN is version 1.9.3 (r1718519), and it says that it has support for KWALLET</p> <p>The following authentication credential caches are available:</p> <pre><code>* Plaintext cache in /home/ssol/.subversion * Gnome Keyring * GPG-Agent * KWallet (KDE) </code></pre> <p>My <code>.subversion/config</code> has the following configuration:</p> <pre><code>[auth] password-stores = kwallet </code></pre> <p>My <code>.subversion/servers</code> has the following configuration:</p> <pre><code>[global] store-passwords = yes </code></pre> <p>KWallet is installed, the Wallet manager says Version 15.12.3. I only have 1 wallet, the default <code>kdewallet</code> with a bunch of folders there. I know it works because I use it with <code>ksshaskpass</code> and it works flawless. On Subversion, something is not working right. </p> <p>After I added the configurations, I did an svn update on a project I have, it asked for the password. After typing it, the annexed prompt popped, to allow subversion to connect to the wallet. I type the wallet password and allowed it. But no entry was update inside the wallet. </p> <p>I tried a second type, it asked again for the same prompt. And, this time, SVN saved the password as a <strong>plain-text inside the .subversion/auth/svn.simple/</strong>.</p> <p>So, what am I doing wrong?</p>
<svn><kde>
2016-06-23 19:52:07
HQ
38,000,717
How do I format my output as a 4-by-4 matrix?
<pre><code>class By { public static void main(String args[]) throws InterruptedException { String key = "Hello world";// plaintext byte[] x = key.getBytes(); StringBuilder sb = new StringBuilder(); for (int i = 0; i &lt; x.length; i++) { int b = (int) x[i]; sb.append(Integer.toHexString(b)); } System.out.println(sb.toString()); } } This program output is: 48656c6c6f20776f726c64 I need my output to be a 4-by-4 matrix as such: 1st row is:: 48 6f 72 00 2nd row is:: 65 20 6c 00 3rd row is:: 6c 77 64 00 4th row is:: 6c 6f 00 00 </code></pre> <p>How do I write code for this in java?Please anyone show me the code to get my required output.</p>
<java>
2016-06-23 19:57:01
LQ_CLOSE
38,001,324
How can I assign a specific maven profile to an intellij run configuration?
<p>I have multiple projects loaded into my project structure and they all use different maven profiles. I know I can switch up the profiles using the Maven Projects tab but I would like to assign a specific profile to go along with a specific run configuration.</p>
<maven><intellij-idea><maven-profiles>
2016-06-23 20:34:24
HQ
38,001,898
What fonts can I use with pygame.font.Font?
<p>I thought that pygame.font.Font was to load .ttf fonts, and that you can't load a font without having the .ttf file in the same directory, but I have seen a video where someone load a font without having the .ttf font in the same directory. I want to know what fonts can I use with pygame.font.Font without having the .ttf file in the same directory</p>
<pygame>
2016-06-23 21:08:12
HQ
38,002,327
How can I check if my pm2 app NODE_ENV is getting set?
<p>So I just deployed a site with node and pm2 for the first time and I'm going back and doing some optimization and reading best practices, etc.</p> <p>I read that you can get a lot of benefit by setting <code>NODE_ENV=production</code>.</p> <p>I found this in the pm2 docs:</p> <pre><code>[process.json] "env_production" : { "NODE_ENV": "production" } ... $ pm2 start process.json --env production </code></pre> <p>So, I did it but I have no idea if it is working. While trying to figure out how to check it I learned to try:</p> <pre><code>$ node &gt; process.env.NODE_ENV &gt; undefined </code></pre> <p>So, that's not a good sign.. but, with my limited understanding of how the low level stuff works, I can guess that maybe pm2 launches each app as a separate node process? So maybe I'm not in the right process when I try to check it.</p> <p>Also, I don't know if I have to make a new ~/.pm2/dump.pm2 file because maybe whenever that is maybe overriding the options I set? (because I used <code>pm2 startup</code>).</p> <p>How do I check if my pm2 app's NODE_ENV is set?</p>
<node.js><express><pm2>
2016-06-23 21:40:00
HQ
38,002,543
apt-get update' returned a non-zero code: 100
<p>I am trying to create a docker image from my docker file which has following contains</p> <pre><code>FROM ubuntu:14.04.4 RUN echo 'deb http://private-repo-1.hortonworks.com/HDP/ubuntu14/2.x/updates/2.4.2.0 HDP main' &gt;&gt; /etc/apt/sources.list.d/HDP.list RUN echo 'deb http://private-repo-1.hortonworks.com/HDP-UTILS-1.1.0.20/repos/ubuntu14 HDP-UTILS main' &gt;&gt; /etc/apt/sources.list.d/HDP.list RUN echo 'deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/azurecore/ trusty main' &gt;&gt; /etc/apt/sources.list.d/azure-public-trusty.list RUN gpg --keyserver pgp.mit.edu --recv-keys B9733A7A07513CAD RUN gpg -a --export 07513CAD | apt-key add - RUN gpg --keyserver pgp.mit.edu --recv-keys B02C46DF417A0893 RUN gpg -a --export 417A0893 | apt-key add - RUN apt-get update </code></pre> <p>Which failing with following error </p> <pre><code>root@sbd-docker:~/ubuntu# docker build -t hdinsight . Sending build context to Docker daemon 3.072 kB Step 1 : FROM ubuntu:14.04.4 ---&gt; 8f1bd21bd25c Step 2 : RUN echo 'deb http://private-repo-1.hortonworks.com/HDP/ubuntu14/2.x/updates/2.4.2.0 HDP main' &gt;&gt; /etc/apt/sources.list.d/HDP.list ---&gt; Using cache ---&gt; bc23070c0b18 Step 3 : RUN echo 'deb http://private-repo-1.hortonworks.com/HDP-UTILS-1.1.0.20/repos/ubuntu14 HDP-UTILS main' &gt;&gt; /etc/apt/sources.list.d/HDP.list ---&gt; Using cache ---&gt; e45c32975e28 Step 4 : RUN echo 'deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/azurecore/ trusty main' &gt;&gt; /etc/apt/sources.list.d/azure-public-trusty.list ---&gt; Using cache ---&gt; 1659cdcab06e Step 5 : RUN gpg --keyserver pgp.mit.edu --recv-keys B9733A7A07513CAD ---&gt; Using cache ---&gt; ca73b2bfcd21 Step 6 : RUN gpg -a --export 07513CAD | apt-key add - ---&gt; Using cache ---&gt; 95596ad10bc9 Step 7 : RUN gpg --keyserver pgp.mit.edu --recv-keys B02C46DF417A0893 ---&gt; Using cache ---&gt; f497deeef5b5 Step 8 : RUN gpg -a --export 417A0893 | apt-key add - ---&gt; Using cache ---&gt; d01dbe7fa02e Step 9 : RUN apt-get update ---&gt; Running in 89d75799982f E: The method driver /usr/lib/apt/methods/https could not be found. The command '/bin/sh -c apt-get update' returned a non-zero code: 100 root@sbd-docker:~/ubuntu# </code></pre> <p>I am running this on Ubuntu 14.04.4</p> <p>I tried restarting the docker, cleaning up all docker images, installing <code>apt-transport-https</code> but nothing worked.</p> <p>I dont know whats wrong here.</p>
<ubuntu><docker><dockerfile>
2016-06-23 21:55:45
HQ
38,002,591
Google Chrome default console context
<p>Lately when opening the Google Chrome developer console, the context has been wrong. </p> <p>I load a page, press Ctrl + Shift + J and get this: <a href="http://i.imgur.com/2eTJgD0.png">http://i.imgur.com/2eTJgD0.png</a></p> <p>It changes extensions sometimes but it should be 'top'. </p> <p>I can change the context manually each time but this is getting kind of annoying to do.</p>
<google-chrome><google-chrome-devtools>
2016-06-23 21:58:38
HQ
38,004,130
Generating code for property initialisers from an object instance
Can we use Roslyn to generate the object initialisers only from an instance of object? Not trying to decompile the object as in this post : http://stackoverflow.com/questions/29567489/can-roslyn-generate-source-code-from-an-object-instance Would it work with complex/nested objects?
<c#><code-generation><roslyn>
2016-06-24 00:57:32
LQ_EDIT
38,004,673
Connection Pool for rails 5
<p>I am having this issue with rails 5 rc1. Does anyone have any idea how to configure it in the environment files and what is the default connection pool size for rails 5 active record.</p> <pre><code> Puma caught this error: could not obtain a connection from the pool within 5.000 seconds (waited 5.000 seconds); all pooled connections were in use (ActiveRecord::ConnectionTimeoutError) /home/bsethi/.rvm/gems/ruby-2.2.2/gems/activerecord-5.0.0.rc1/lib/active_record/connection_adapters/abstract/connection_pool.rb:202:in `block in wait_poll' /home/bsethi/.rvm/gems/ruby-2.2.2/gems/activerecord-5.0.0.rc1/lib/active_record/connection_adapters/abstract/connection_pool.rb:193:in `loop' /home/bsethi/.rvm/gems/ruby-2.2.2/gems/activerecord-5.0.0.rc1/lib/active_record/connection_adapters/abstract/connection_pool.rb:193:in `wait_poll' /home/bsethi/.rvm/gems/ruby-2.2.2/gems/activerecord-5.0.0.rc1/lib/active_record/connection_adapters/abstract/connection_pool.rb:154:in `internal_poll' /home/bsethi/.rvm/gems/ruby-2.2.2/gems/activerecord-5.0.0.rc1/lib/active_record/connection_adapters/abstract/connection_pool.rb:278:in `internal_poll' /home/bsethi/.rvm/gems/ruby-2.2.2/gems/activerecord-5.0.0.rc1/lib/active_record/connection_adapters/abstract/connection_pool.rb:148:in `block in poll' </code></pre>
<ruby-on-rails><ruby-on-rails-5>
2016-06-24 02:18:00
HQ
38,005,961
Linear Layout is not properly show the component when using in the android studio
this is code <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:layout_width="100dp" android:layout_height="wrap_content" android:text="Email:" android:textSize="30dp" android:paddingLeft="0dp" android:paddingTop="10dp"/> <EditText android:layout_width="150dp" android:layout_height="wrap_content" android:layout_marginTop="4dp" android:singleLine="true" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Login" android:paddingTop="10dp"/> <LinearLayout android:layout_width="fill_parent" android:layout_height="match_parent" android:orientation="vertical"> <TextView android:layout_width="200dp" android:layout_height="100dp" android:text="Home" /> <TextView android:layout_width="200dp" android:layout_height="200dp" android:text="About" /> </LinearLayout> </LinearLayout> i want to practice on layout on android studio and facing the error while implementing the code [this is the text which goes outside the mobile screen] [1][ i don't know why blue box goes outside the mobile screen][2] [1]: http://i.stack.imgur.com/hBSPK.jpg [2]: http://i.stack.imgur.com/A18wh.jpg click on number 1 and number 2 which appear on blue color to see the image plese somebody suggest solution thank you
<android>
2016-06-24 05:08:18
LQ_EDIT
38,007,290
Facebook Messenger Bot - How to disable bot and allow human to chat
<p>so this is something I've been trying to think through for about 16 hours. I am coding with PHP / CuRl / etc - the bot works and everything is fine. My current issue is figuring out how to disable the bot and allow a human to begin chatting with the customer/sender.</p> <p>Has anyone successfully, created a route for this ? I mean it's pretty hard from what I see, you'd have to disable etc etc. A lot of effort for my clients.</p> <p>Thanks for any input.</p>
<facebook><messenger><facebook-messenger>
2016-06-24 06:52:59
HQ
38,008,148
What are the condiions in which JVM throw notserializableexception?
<p>Can any on explain me in which condition JVM throw notserializableexception.</p> <p>exmaple </p> <pre><code>class Emp implemenst Serializable { Address address = new Address(); } class Address { Strign address; } </code></pre> <p>in above case does JVM will throw the exception because address class is not serializable?</p> <p>can anybody explain?</p>
<java><serialization>
2016-06-24 07:43:13
LQ_CLOSE
38,008,617
How to reference CSS from libraries installed via npm?
<p>So for example say I installed something:</p> <pre><code>npm install --save something </code></pre> <p>and it downloads into</p> <pre><code>./node_modules/something/ </code></pre> <p>and it has a folder in there perhaps called <code>styles</code> and <em>in</em> that folder you have <code>something.css</code>. How would I include that css file in my html document (if my html document was along-side the <code>node-modules</code> folder?</p> <p>I mean I <em>could</em> do this in my html head:</p> <pre><code>&lt;link rel="stylesheet" href="./node_modules/something/styles/something.css" type="text/css" media="screen" /&gt; </code></pre> <p>But it feels wrong to go dig in your <code>node_modules</code> directory for stuff. Especially if the html document perhaps needs to get minified and then thrown into some <code>./dist/</code> directory. Because then the path to <code>something.css</code> is off.. </p> <p>Isn't there a way to simply just go:</p> <pre><code>&lt;link rel="stylesheet" href="something.css" type="text/css" media="screen" /&gt; </code></pre> <p>in your html document - regardless of where it's sitting in your project structure - and it'll just know where to go find that css file?</p>
<javascript><html><css><node.js><npm>
2016-06-24 08:10:35
HQ
38,008,713
Problems with Java Arrays.sort() on sub-arrays -- is this a bug?
<p>I have noticed odd behavior when using Java Arrays.sort() on sub-arrays. Here is a demo program. Is this a bug in Java?</p> <pre><code>package sorted_subsegments; import java.util.Arrays; public class sortTest { public static void main(String[] args) { int A[] = {3, 2, 1}; System.out.format("A: %s\n", Arrays.toString(A)); Arrays.sort(A, 0, 1); System.out.format(" after sub array sort on A: %s\n", Arrays.toString(A)); System.out.println("Should be A: [2, 3, 1]"); Arrays.sort(A); System.out.format(" whole array sort on A: %s\n", Arrays.toString(A)); } } </code></pre>
<java><arrays><sorting><sub-array>
2016-06-24 08:18:23
LQ_CLOSE
38,009,034
How can i add a difficulty to my game
**i want to add a difficulty in my game, for example when i click a category like category "A" it will show a decision button to pick a "normal or hard" in the next layout. sorry for my bad english**
<java><android>
2016-06-24 08:38:13
LQ_EDIT
38,009,869
How to specify wildcard artifacts subdirectories in .gitlab-ci.yml?
<p>I'm using GitLab CI to build a C# solution and try to pass some build artifacts from one build stage to another.</p> <p>The problem is, that the artifacts are not located in a single directory but in different subdirectories, which however all have the same names <code>bin/</code> or <code>obj/</code>.</p> <p>My <code>.gitlab-ci.yml</code> looks like the following:</p> <pre><code>... stages: - build - test build: stage: build script: CALL %MSBuild% ... artifacts: paths: - /**/bin/ - /**/obj/ expire_in: 6 hrs test: stage: test dependencies: - build ... </code></pre> <p>I tried to capture the artifacts using different ways, e.g.</p> <pre><code>**/bin/ **/obj/ </code></pre> <p>(invalid syntax), or</p> <pre><code>.*/bin/ .*/obj/ </code></pre> <p>but that one did not find any artifacts, just as <code>/**/bin/</code> and <code>/**/obj/</code>, giving me following errors:</p> <pre><code>Uploading artifacts... WARNING: /**/bin/: no matching files WARNING: /**/obj/: no matching files </code></pre> <p><strong>How can I specify a subdirectory pattern to be scanned for artifacts? Or is this even possible at all?</strong></p> <p>Simply using</p> <pre><code>artifacts: untracked: true </code></pre> <p>is not an option, because of a huge untracked <code>packages/</code> subdirectory, which causes artifacts upload to fail because of a too large archive:</p> <pre><code>Uploading artifacts... untracked: found 4513 files ERROR: Uploading artifacts to coordinator... too large archive id=36 responseStatus=413 Request Entity Too Large token=... FATAL: Too large </code></pre>
<yaml><gitlab-ci><gitlab-8>
2016-06-24 09:22:40
HQ
38,010,544
polymorphic_allocator: when and why should I use it?
<p><a href="http://en.cppreference.com/w/cpp/memory/polymorphic_allocator">Here</a> is the documentation on <em>cppreference</em>, <a href="http://eel.is/c++draft/memory.polymorphic.allocator.class">here</a> is the working draft.</p> <p>I must admit that I didn't understand what's the real purpose of <code>polymorphic_allocator</code> and when/why/how I should use it.<br> As an example, the <a href="http://eel.is/c++draft/vector.syn"><code>pmr::vector</code></a> has the following signature:</p> <pre><code>namespace pmr { template &lt;class T&gt; using vector = std::vector&lt;T, polymorphic_allocator&lt;T&gt;&gt;; } </code></pre> <p>What does the <code>polymorphic_allocator</code> offer? What does the <code>std::pmr::vector</code> offer as well in regard of the old-fashioned <code>std::vector</code>? What can I do now that I wasn't able to do till now?<br> What's the real purpose of that allocator and when should I use it actually?</p>
<c++><allocator><c++17>
2016-06-24 09:54:23
HQ
38,011,677
Shuffle an array in a specific format
I need to shuffle an array in such a way that in each shuffle third element of the array should change to the first one For Eg : My array is array(1,2,3,4,5,6,7,8,9); in first shuffle I want the array to array(4,5,6,7,8,9,1,2,3) next array(7,8,9,1,2,3,4,5,6) and so on... Hope any one will help me Thanks in advance !
<php>
2016-06-24 10:52:55
LQ_EDIT
38,011,702
How to clone multiple children with React.cloneElement?
<p>I try to clone React elements like this, to pass the parent props to them (the props are not assigned in this example):</p> <pre><code>React.createElement('div', { style: this.props.style }, React.cloneElement(this.props.children, null) ) </code></pre> <p>This however returns following error:</p> <blockquote> <p>Uncaught Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.</p> </blockquote> <p>If there is only one child or if I pass React.cloneElement(this.props.children[0], null), there is no error and the desired element is rendered.</p> <p>How can I clone multiple elements?</p>
<javascript><reactjs>
2016-06-24 10:54:02
HQ
38,011,771
how to implement if else functionality in Sql
i have an SQL query in which i have customer_id, User_id and name, the values will be provided from java class while calling the query. the scenario here is if i have customer_id then i should only consider customer_id and need not consider user_id and name, if customer_id is null then i have to consider user_id and if user_id id null i have to consider name right now this logic is implemented in java if else statement i want this logic to be moved to SQL query itself, following is the code String query = "SELECT * FROM CUSTOMER WHERE " if(customer!=null && customer.length!=0) query = query+"AND CUSTOMER_ID LIKE '"+customer+"%'"; else if(user!=null && user.length!=0) query = query+"AND USER_ID LIKE '"user+"%'"; else if(name!=0 && name.length!=0) query = query + "AND NAME LIKE '"+name+"%'"; Thanks in advance
<java><mysql><sql-server>
2016-06-24 10:57:24
LQ_EDIT
38,012,042
PHP's $_SERVER: QUERY_STRING
<p>on <a href="http://php.net/manual/en/reserved.variables.server.php" rel="nofollow">http://php.net/manual/en/reserved.variables.server.php</a>, it says</p> <p>" 'QUERY_STRING' The query string, if any, via which the page was accessed. "</p> <p>I've been having trouble comprehending that. As I understand it, the query string is simply there as input to the page. The script which the URL addresses uses the query string to do its work and generate whatever appropriate response it is designed to do. </p> <p>I could understand, however, how that response (i.e. the webpage the script sends back) is said to be gotten via the query string, since the values in the query string were used to formulate it.. , but not the initial script that processed it. </p> <p>It's a semantics issue.. appreciate your explanations.</p>
<php>
2016-06-24 11:11:43
LQ_CLOSE
38,012,381
Duplicate a view programmatically from an already existing view
<p>I was trying the following code and was getting an error because there is no such constructor defined.</p> <p><code>View v = new View(findViewById(R.id.divider));</code></p> <p>Is there any simple way to copy a view into another?</p>
<android><android-view>
2016-06-24 11:29:51
HQ
38,012,507
How i can read all data in this response?
<p>I have this JSON object</p> <pre><code>{ "0": { "id": "44", "date": "2016-06-24 10:53:08", "client_id": "44", "status": "waiting", "price": null, "paid": null, "client": false, "items": { "beirut": { "52": { "id": "52", "type": "Kerosene", "quantity": "50", "price": "20100", "address": "beirut" } } } }, "1": { "id": "42", "date": "2016-06-24 10:43:35", "client_id": "44", "status": "waiting", "price": null, "paid": null, "client": false, "items": { "beirut": { "50": { "id": "50", "type": "Super 98", "quantity": "60", "price": "34900", "address": "beirut" } } } }, "status": "ok" } </code></pre> <p>I want to <strong>read</strong> all data from that response in <strong>javascript</strong>.</p> <p>This is returned in a <code>jquery.ajax</code> call as <code>datatype:jsonp</code>. I am able to access <strong>data</strong> and that displays all the stores in html page.</p> <p><strong>How can I read this properly?</strong></p>
<javascript><jquery><json>
2016-06-24 11:36:10
LQ_CLOSE
38,012,604
It was suppose to be displayed in a table form but it displays in one line in the console after compilation
#include <iostream> using namespace std; int main (){ int array1[5][5]={{1,1,1,1,0},{1,1,1,0,2},{1,1,0,2,2},{1,0,2,2,2},{0,2,2,2,2}}; for ( int row = 0 ; row < 5 ; row ++){ for ( int col = 0 ; col < 5 ; col ++) { cout<< array1[row][col]<< " "; } } cout<<endl; }
<c++><multidimensional-array><output>
2016-06-24 11:40:52
LQ_EDIT
38,012,641
PhP/MySQL - how to add parameters like ?q=blabla to url
<p>I know this question must be very, very basic since even beginners are asking more advanced questions, but I can't find the answer.. I have searched for hours on this, so please condone my ignorance.</p> <p><strong>What I have</strong>: localhost:8888/site/document.php</p> <p>It loads some data from my MySQL database on this page, such as q = office.</p> <p><strong>What I want</strong>: localhost:8888/site/document.php?q=office</p> <p>Thanks in advance!</p>
<php><mysql><url>
2016-06-24 11:43:11
LQ_CLOSE
38,012,797
Google App Engine 502 (Bad Gateway) with NodeJS
<p>I have a full web application using NodeJS, MongoDB (Mongoose as the driver) and ExpressJS.</p> <p>The project works perfectly on my local machine. Today I decided to move everything to production. I'm using Google App Engine to host my application, and Compose (formally MongoHQ) to host my database.</p> <p>App Engine servers my application perfectly, although my API does not seem to work. My API is served from <code>example.com/api</code>, and each request (<code>GET</code>, <code>POST</code>, <code>DELETE</code> and <code>PUT</code>) all returns a 502 (Bad Gateway) error.</p> <p>I tried running my application on my local machine while connected to my remote MongoDB database and that worked perfectly fine. So it must be a problem with App Engine or NodeJS, not with MongoDB.</p> <p>I have tried checking all error logs within Google Cloud, although there are no errors.</p> <p>Why is App Engine/NodeJS serving my application's static content perfectly fine, although not allowing any requests to my API?</p>
<node.js><google-app-engine>
2016-06-24 11:51:25
HQ
38,013,468
Suggestion based on user's search
<p>I have this problem: in my website the user writes in an input bar the name of an ArtWork. Then, usign the Google APIs, I give him the title, the image as well as other useful details.</p> <p>But on my website I've also uploaded e-books containing useful information to use during the search. My question is: is there a way that makes the system suggest the user the most useful e-books based on his search (for ex.: if I type in Andy Warhol, I would only like to see e-books that talk about Modern Art and not those that talk about Greek or Roman art).</p> <p>Thanks in advance for your help!</p>
<javascript><php><mysql><json>
2016-06-24 12:28:00
LQ_CLOSE
38,014,048
Mockito on Android, Context.getString(id) and NullPointerException
<p>I've just started learning a Mockito testing framework, I followed official tutorial from: <a href="https://developer.android.com/training/testing/unit-testing/local-unit-tests.html" rel="noreferrer">developer.android.com</a></p> <p>The code is:</p> <pre><code>private static final String FAKE_STRING = "HELLO WORLD"; @Mock Context mMockContext; @Test public void readStringFromContext_LocalizedString() { // Given a mocked Context injected into the object under test... when(mMockContext.getString(R.string.hello_world)) .thenReturn(FAKE_STRING); ClassUnderTest myObjectUnderTest = new ClassUnderTest(mMockContext); // ...when the string is returned from the object under test... String result = myObjectUnderTest.getHelloWorldString(); // ...then the result should be the expected one. assertThat(result, is(FAKE_STRING)); } </code></pre> <p>I wrote following ClassUnderTest:</p> <pre><code>public class ClassUnderTest { private Context context; public ClassUnderTest(Context context) { this.context=context; } public String getHelloWorldString() { return context.getString(R.string.hello_world); } </code></pre> <p>}</p> <p>and after running I'm getting NullPointerException:</p> <pre><code> java.lang.NullPointerException at android.content.Context.getHelloWorldString(Context.java:293) at com.darekk.draggablelistview.unit_tests.MockitoTest.readStringFromContext_LocalizedString(MockitoTest.java:46) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.mockito.internal.runners.JUnit45AndHigherRunnerImpl.run(JUnit45AndHigherRunnerImpl.java:37) at org.mockito.runners.MockitoJUnitRunner.run(MockitoJUnitRunner.java:62) at org.junit.runners.Suite.runChild(Suite.java:128) at org.junit.runners.Suite.runChild(Suite.java:27) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at org.junit.runner.JUnitCore.run(JUnitCore.java:115) at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:59) at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:262) at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1619) </code></pre> <p>When I replace android Context with my own class it works.</p> <p>Platform: IntelliJ IDEA Community Edition 15.0.6</p> <p>I really appreciate any help.</p>
<android><unit-testing><testing><mockito>
2016-06-24 12:59:17
HQ
38,014,072
FullScreen Webview in iPhone 6
<p>I am new to iPhone development , Trying to embed webview using Storyboard but getting those black strips on top and bottom , I did set autoLayout also, I need to remove those. TIA</p> <p><a href="http://i.stack.imgur.com/lVrSd.png" rel="nofollow">Screenshot</a></p>
<ios><iphone>
2016-06-24 13:00:34
LQ_CLOSE
38,014,124
error while executing phyton code
from os import popen from string import split, join from re import match import subprocess import os # execute the code and pipe the result to a string rtr_table = [elem.strip().split() for elem in popen("route print").read().split("Metric\n")[1].split("\n") if match("^[0-9]", elem.strip())] #print "Active default gateway:", rtr_table[0][2] x=rtr_table[0][2] #x has a.a.a.a y = x[:x.rfind(".")] # y has a.a.a # in order to test in range of 1 to 255 for the default gateway for i in range(1,255): #ping by sending 1 packet and wait for 500 milli seconds test = "ping -n 1 -w 500 %s.%d" % (y,i) process = subprocess.Popen(test, shell=True, stdout=subprocess.PIPE) # give it time to respond process.wait() # optional check (0 --> success) #print process.returncode # read the result to a string result_str = process.stdout.read() # test it ... # print result_str #from arp we get mac address and corresponding ip address and state as we use '-a' lines=os.popen('arp -a') for line in lines: print line sh-4.3$ python main.py File "main.py", line 20 test = "ping -n 1 -w 500 %s.%d" % (y,i) ^ IndentationError: expected an indented block please go through the above code and please identify the error it looks like in test ="ping " line is getting some IndentationError please help me regarding this error.
<python><python-2.7><python-3.x>
2016-06-24 13:02:59
LQ_EDIT
38,014,471
Explanation stored procedure
I Am trying to understand a stored procedure, but i don't get it. I'm totally new to stored procedures. I have ordered a book about t-sql but it didn't arrived yet. I'm litterally stuck. Can someone please explain to me what the following stored procedure, exactly does? [Stored procedure][1] I know that ALTER stands for, modifying the stored procedure, @ Region and @ State are the parameters. Begin is where the stored procedure starts When do you have to use '' , like in the first select statement? What exaclty is the LO. and PR. ? [1]: http://i.stack.imgur.com/xQP1G.png
<sql-server><tsql>
2016-06-24 13:20:03
LQ_EDIT
38,014,567
i m beginner of Advance java("program jdbc")
java.sql.SQLSyntaxErrorException: ORA-01745: invalid host/bind variable name at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:440) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396) at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:837) at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:445) at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:191) at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:523) at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:207) at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1010) at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1315) at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3576) at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3657) at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeUpdate(OraclePreparedStatementWrapper.java:1350) at ImageRerive.main(ImageRerive.java:70)
<java><oracle><jdbc>
2016-06-24 13:24:56
LQ_EDIT
38,014,900
AngularJS + jQuery: jQuery returns only native dom objects
I have a huge problem. I want to select a DOM-Element using jQuery. This happens inside an AngularJS http-request. It works when runtime has past but when I call the function immediately aufer the page load, jQuery returns only a nativ JS DOM-Object. The code is nothing special. It's only: $http({ "methode" : "GET", "url" : <URL>, "cache" : true }) .success(function(data){ ... var jQueryElement = jQuery("#" + params.elemId); jQueryElement[0].previousElementSibling.children[1].classList.add("active"); ... }); This request is inside a function of an angularjs controller. How I said before, when it's called directly after the pageload jQuery( ... ) only returns a nativ DOM-object. Does someone know how to fix this?
<javascript><jquery><angularjs><http><web>
2016-06-24 13:42:55
LQ_EDIT
38,015,200
How to minify JavaScript like Google Analytics?
<p>Most of you are probably familiar with this little tracking code offered by Google Analytics.</p> <pre><code>&lt;script&gt; ( function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) } )(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-00000000-0', 'auto'); ga('send', 'pageview'); &lt;/script&gt; </code></pre> <p>The interesting part is that this little excerpt contains arguments that form the word isogram. This script also uses arguments to declare variables to shave off some bits from the final file size. Arguably, you would not use this pattern when writing the code (?), so my question is, how does Google minify its code and are these techniques available to mere mortals, too?</p> <p>I found online this <a href="http://code.stephenmorley.org/javascript/understanding-the-google-analytics-tracking-code/" rel="noreferrer">example</a> by Stephen Morley that includes a code that looks like something you'd write before minifying it. I took that code and run it through Google's very own <a href="https://closure-compiler.appspot.com/home" rel="noreferrer">Closure Compiler</a> on advanced optimisation. As expected, the resulting code is nothing like the actual script used by Google Analytics.</p> <pre><code>(function(){window.b="ga";"ga"in window||(window.a=function(){window.a.q.push(arguments)},window.a.q=[]);window.a.c=(new Date).getTime();var c=document.createElement("script");c.src="//www.google-analytics.com/analytics.js";c.async=!0;var d=document.getElementsByTagName("script")[0];d.parentNode.insertBefore(c,d)})(); </code></pre> <p>This time, the code is less DRY and bigger, even without the two extra commands.</p> <p>So to clarify, I am curious how the Google engineers arrived to the above result (I do not think their code actually looks like the one in Stephen's example), and could this process be replicated even if you are not a part of Google? Thank you in advance!</p>
<javascript><google-analytics><minify><google-closure-compiler><bundling-and-minification>
2016-06-24 13:58:05
HQ
38,016,051
How do I get consistent values with influxdb non_negative_derivative?
<p>Using grafana with influxdb, I am trying to show the per-second rate of some value that is a counter. If I use the <code>non_negative_derivative(1s)</code> function, the value of the rate seems to change dramatically depending on the time width of the grafana view. I'm using the <code>last</code> selector (but could also use <code>max</code> which is the same value since it is a counter).</p> <p>Specifically, I'm using:</p> <p><code>SELECT non_negative_derivative(last("my_counter"), 1s) FROM ...</code></p> <p>According to the <a href="https://docs.influxdata.com/influxdb/v0.13/query_language/functions/#non-negative-derivative" rel="noreferrer">influxdb docs non-negative-derivative</a>:</p> <blockquote> <p>InfluxDB calculates the difference between chronological field values and converts those results into the rate of change per unit.</p> </blockquote> <p>So to me, that means that the value at a given point should not change that much when expanding the time view, since the value should be <em>rate of change per unit</em> (1s in my example query above).</p> <p>In graphite, they have the specific <code>perSecond</code> function, which works much better:</p> <p><code>perSecond(consolidateBy(my_counter, 'max'))</code></p> <p>Any ideas on what I'm doing wrong with the influx query above?</p>
<influxdb><grafana>
2016-06-24 14:40:17
HQ
38,016,082
loop never ends in sql server using While Exists
[Question is in the image][1] [1]: http://i.stack.imgur.com/0Gdd7.jpg I was unable to post the code so had to put it in the form of image. Thanks
<sql><sql-server><while-loop>
2016-06-24 14:41:18
LQ_EDIT
38,016,410
how can I have a checkbox as selected in Javascript?
I have some items to be selected,they are checkboxes with their certain titles in a table .I want to onclick on an item(I mean each "td") then the function do its job but besides I want the checkbox of that selected "td" t be checked .how can I do it with javascript? note:I am learning javascript so please don't answer with a jquery solution. the code below is an example of each items <td id="1" onclick="chb('1')" ><input type="checkbox" />title</td>
<javascript><html><checkbox>
2016-06-24 14:59:05
LQ_EDIT