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
39,436,870
Why drag and drop is not working in Selenium Webdriver?
<p>I am trying to drag an element into another element using Selenium WebDriver but it's not working. I tried all the solutions which I can find on internet but none of the solutions seems to be working for me. </p> <pre><code>WebElement sourceelement = driver.findElement(By.cssSelector("XXX")); WebElement destelement = driver.findElement(By.cssSelector("YYY")); </code></pre> <p>Code1:-</p> <pre><code>Actions builder = new Actions( _controls.getDriver()); builder.dragAndDrop(sourceelement, destelement); </code></pre> <p>Code2:- </p> <pre><code>Actions builder = new Actions(_controls.getDriver()); Action dragAndDrop = builder.clickAndHold(sourceelement).moveToElement(destelement).release(destelement).build(); Thread.sleep(2000); dragAndDrop.perform() </code></pre> <p>Code3:-</p> <pre><code>Point coordinates1 = sourceelement.getLocation(); Point coordinates2 = destelement.getLocation(); Robot robot = new Robot(); robot.mouseMove(coordinates1.getX(), coordinates1.getY()); robot.mousePress(InputEvent.BUTTON1_MASK); robot.mouseMove(coordinates2.getX(), coordinates2.getY()); robot.mouseRelease(InputEvent.BUTTON1_MASK); Thread.sleep(2000); </code></pre> <p>Code4:-</p> <pre><code>final String java_script = "var src=arguments[0],tgt=arguments[1];var dataTransfer={dropEffe" + "ct:'',effectAllowed:'all',files:[],items:{},types:[],setData:fun" + "ction(format,data){this.items[format]=data;this.types.append(for" + "mat);},getData:function(format){return this.items[format];},clea" + "rData:function(format){}};var emit=function(event,target){var ev" + "t=document.createEvent('Event');evt.initEvent(event,true,false);" + "evt.dataTransfer=dataTransfer;target.dispatchEvent(evt);};emit('" + "dragstart',src);emit('dragenter',tgt);emit('dragover',tgt);emit(" + "'drop',tgt);emit('dragend',src);"; ((JavascriptExecutor)_controls.getDriver()).executeScript(java_script, sourceelement, destelement); Thread.sleep(2000); </code></pre> <p>None of the above code is working for me. All the above runs without any error but drag and drop is not happening in the application. Anyone having any other solution ? Thanks.</p>
<java><selenium>
2016-09-11 14:02:14
HQ
39,437,191
What is faster in C#, an if statement, or a virtual function call to a function that does nothing? And why?
<p>Say you have a class called <code>MyClass</code> which has a certain behavior encapsulated using a reference (<code>myBehavior</code>) to another class called <code>Behavior</code>. By default <code>MyClass</code> should have no behavior.</p> <p>For instances which hadn't set <code>myBehavior</code> to anything after it was initialized - Would it be more speed efficient if <code>myBehavior</code> was initialized to <code>null</code>, and each time it was needed checked with <code>if(myBehavior)</code> or would it be faster if it were initialized to an instance of a <code>NullBehavior</code>, derived from <code>Behavior</code>, which does nothing? and why?</p> <pre><code>class MyClass { Behavior myBehavior = null; void doSomething() { if(myBehavior) { myBehavior.performAction(); } } } </code></pre> <p>or:</p> <pre><code>class NullBehavior : Behavior { override void performAction() { // don't do anything } } class MyClass { Behavior myBehavior = new NullBehavior(); // or equals some static universal instance of NullBehavior void doSomething() { myBehavior.performAction(); } } </code></pre>
<c#><performance><if-statement><virtual-functions>
2016-09-11 14:39:24
LQ_CLOSE
39,437,239
How can I remove a value from array in java script?
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;code&gt; &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Java Script Array methods&lt;/title&gt; &lt;script type="text/javascript"&gt; var ArrStr = ["Yallappa","Rajesh","Kiran"]; function LoadArr(){ document.getElementById("Arr").innerHTML = ArrStr; } function But1Click(){ ArrStr.push(document.getElementById("TxtBox").value); document.getElementById("Arr").innerHTML = ArrStr; } function But2Click(){ var Indx = ArrStr.indexOf(document.getElementById("Arr").value); alert(Indx); if(indx &gt; -1){ arrstr.splice(document.getelementbyid("arr").value,1); } document.getelementbyid("arr").innerhtml = arrstr; } &lt;/script&gt; &lt;/head&gt; &lt;body onLoad="LoadArr()"&gt; &lt;h2 id="Arr"&gt;&lt;/h2&gt;&lt;br&gt; &lt;input type="text" id="TxtBox"/&gt;&lt;br&gt; &lt;input type="button" onclick="But1Click()" text="Push into Array" value="Push into Array"/&gt;&lt;br&gt; &lt;input type="button" onclick="But2Click()" text="Remove from Array" value="Remove From Array"/&gt; &lt;/body&gt; &lt;/html&gt; &lt;/code&gt;</code></pre> </div> </div> I wanted to add and remove text from the textbox based on the button click events. And display the array of strings in h2 tag. In this I am able to add a new string in array, but I am not able to remove string. Why please explain me?</p>
<javascript>
2016-09-11 14:44:30
LQ_CLOSE
39,437,541
In a Oracle Schema I want to know how many Tables, Procedures, Functions are there? How to find?
<p>In a Oracle Schema I want to know how many Tables, Procedures, Functions are there? How to find?</p>
<sql><oracle><plsql>
2016-09-11 15:13:16
LQ_CLOSE
39,437,572
Gradle - equivalent of test {} configuration block for android
<p>Gradle has the test configuration block </p> <p><a href="https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html" rel="noreferrer">https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html</a></p> <p>```</p> <pre><code>apply plugin: 'java' // adds 'test' task test { // enable TestNG support (default is JUnit) useTestNG() // set a system property for the test JVM(s) systemProperty 'some.prop', 'value' // explicitly include or exclude tests include 'org/foo/**' exclude 'org/boo/**' // show standard out and standard error of the test JVM(s) on the console testLogging.showStandardStreams = true // set heap size for the test JVM(s) minHeapSize = "128m" maxHeapSize = "512m" // set JVM arguments for the test JVM(s) jvmArgs '-XX:MaxPermSize=256m' // listen to events in the test execution lifecycle beforeTest { descriptor -&gt; logger.lifecycle("Running test: " + descriptor) } // listen to standard out and standard error of the test JVM(s) onOutput { descriptor, event -&gt; logger.lifecycle("Test: " + descriptor + " produced standard out/err: " + event.message ) } } </code></pre> <p>where one can set all sorts of test configuration (I am mostly interested in the heap size). Is there something similar for android projects?</p>
<android><unit-testing><gradle>
2016-09-11 15:16:10
HQ
39,437,814
Variable value different outside of if statement
<p>In this block of code, at line thirteen, I incremented correctAnswers by 1. However, once the if statement has broke, The value is just one (or zero sometimes) when it prints the percentage. Can anyone tell me what is wrong with my code?</p> <pre><code>private static void multiplicationTest(int maxNumber, int minNumber) { int i = 1; while(i != 11) { int firstNumber = (minNumber + (int)(Math.random() * ((maxNumber - minNumber) + 1)) ), secondNumber = (minNumber + (int)(Math.random() * ((maxNumber - minNumber) + 1)) ); int inputAnswer, answer = (firstNumber * secondNumber); int correctAnswers = 0; System.out.print("Question " + i + ".)\t" + firstNumber + " * " + secondNumber + " = "); inputAnswer = input.nextInt(); if(inputAnswer == answer) { correctAnswers++; System.out.print("\tcorrect\n"); } else { System.out.print("\tincorrect --- " + firstNumber + " * " + secondNumber + " = " + answer + "\n"); } if(i == 10) { System.out.println("\nYou scored " + correctAnswers + " out of 10 - " + (correctAnswers * 10) + "%."); } i++; } } </code></pre>
<java>
2016-09-11 15:41:34
LQ_CLOSE
39,438,055
Unable to send messages to google firebase
Everything is setup on my android project from installing android studio, enabling the firebase, then assigning the context to my oncreate() method and then giving reference to my database URL . Everything runs fine but when i try to send a sample message to my database from a edittext nothing gets updated on it. i am totally new to firebase. maybe im missing basic things but what, i cant figure out.
<android><firebase><firebase-cloud-messaging>
2016-09-11 16:06:34
LQ_EDIT
39,438,094
Best way to have global css in Vuejs
<p>What is the best way to have a global css file in Vuejs for all components? (Default css like bg color, button styling, etc)</p> <ul> <li>import a css file in the index.html</li> <li>do @import in main component</li> <li>put all the css in the main component (but that would be a huge file)</li> </ul>
<css><import><vue.js>
2016-09-11 16:10:47
HQ
39,438,104
Matrix in C! Please help and explain
SO if you already have a set 4x4 matrix. Ex. Matrix A = [1 2 3 4; 5 6 7 8;` 9 10 11 12; 13 14 15 16] how would you covert that into coding? Also what would there positions be in code? For instance to get number 1 one matrix A would the code be A[1][1]? If you can explain I will appreciate it!! main(){ int matrixA[4][4] = [{"1","2","3","4"}; {"1","0","1","1"}; {"1","1","0","1"}; {"1","1","1","0"}]; printf(matrix A); return 0; }
<c><matrix>
2016-09-11 16:11:43
LQ_EDIT
39,438,129
How to make the program run in .exe mode explained below
<p>I just have written a code in C# its a web browser using Visual Studio 2015 How do i make it compiled to .exe file and etc, like chrome mozilla etc. Help appriciated.</p>
<c#>
2016-09-11 16:14:16
LQ_CLOSE
39,438,176
When is it useful to use "strict wildcard" in Haskell, and what does it do?
<p>I was looking at some Haskell source code and came across a pattern match with <code>!_</code>, the code is here: <a href="http://hackage.haskell.org/package/base-4.9.0.0/docs/src/GHC.List.html#unsafeTake">http://hackage.haskell.org/package/base-4.9.0.0/docs/src/GHC.List.html#unsafeTake</a></p> <pre><code>take n xs | 0 &lt; n = unsafeTake n xs | otherwise = [] -- A version of take that takes the whole list if it's given an argument less -- than 1. {-# NOINLINE [1] unsafeTake #-} unsafeTake :: Int -&gt; [a] -&gt; [a] unsafeTake !_ [] = [] unsafeTake 1 (x: _) = [x] unsafeTake m (x:xs) = x : unsafeTake (m - 1) xs </code></pre> <p>I don't really understand how the "strict wildcard" works and why it's useful for this function (or any other function).</p>
<haskell><pattern-matching><wildcard><strictness>
2016-09-11 16:21:01
HQ
39,438,606
change navigation bar title font - swift
<p>I have a title in my navigation bar and a i want to change it to custom font. I've found this line of code, but it's for when you have a navigation controller.</p> <pre><code>self.navigationController?.navigationBar.titleTextAttributes = [ NSFontAttributeName: UIFont(name: "LeagueGothic-Regular", size: 16.0)!, NSForegroundColorAttributeName: UIColor.whiteColor()] </code></pre> <p>But i don't have any navigation controller. I added navigation bar manually to my view. </p> <p><a href="https://i.stack.imgur.com/RTzau.png" rel="noreferrer"><img src="https://i.stack.imgur.com/RTzau.png" alt="enter image description here"></a></p> <p><a href="https://i.stack.imgur.com/4OPPM.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4OPPM.png" alt="enter image description here"></a></p> <p>how can i change comment font?</p>
<ios><swift><navigationbar>
2016-09-11 17:10:30
HQ
39,438,962
How can I serialize a jgrapht simple graph to json?
<p>I have a simple directed graph from jgrapht and I am trying to serialize it into a JSON file using jackson as follows:</p> <pre><code>ObjectMapper mapper = new ObjectMapper(); File output = new File("P:\\tree.json"); ObjectWriter objectWriter = mapper.writer().withDefaultPrettyPrinter(); objectWriter.writeValue(output,simpleDirectedGraph); </code></pre> <p>However I get this error:</p> <pre><code>Exception in thread "main" com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class org.jgrapht.graph.AbstractBaseGraph$ArrayListFactory and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: org.jgrapht.graph.SimpleDirectedGraph["edgeSetFactory"]) at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.failForEmpty(UnknownSerializer.java:69) at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.serialize(UnknownSerializer.java:32) at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:693) at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:675) at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:157) at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:130) at com.fasterxml.jackson.databind.ObjectWriter$Prefetch.serialize(ObjectWriter.java:1387) at com.fasterxml.jackson.databind.ObjectWriter._configAndWriteValue(ObjectWriter.java:1088) at com.fasterxml.jackson.databind.ObjectWriter.writeValue(ObjectWriter.java:909) at ms.fragment.JSONTreeGenerator.main(JSONTreeGenerator.java:45) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) </code></pre> <p>I have seen that there is a GmlExporter but I am interested in json...how can I do that?</p>
<java><json><serialization><jgrapht>
2016-09-11 17:48:36
HQ
39,439,115
How to execute click function before the blur function
<p>I've got a simple issue but I can't seem to figure out any solution.</p> <p>Basically I've got an input that toggles a dropdown when focused, and when it's not focused anymore it should close the dropdown.</p> <p>However, the problem is that if you click on an item in the dropdown, the <code>blur</code> function is executed before the <code>click</code> function of the item, causing the <code>click</code> function not to run at all since the dropdown closes before the click is registered. </p> <p>How can I solve this?</p> <pre><code>&lt;input (focus)="showDropdown()" (blur)="myBlurFunc()"&gt; &lt;ul&gt; &lt;li *ngFor="let item of dropdown" (click)="myClickFunc()"&gt;{{item.label}}&lt;/li&gt; &lt;/ul&gt; </code></pre>
<angular>
2016-09-11 18:05:40
HQ
39,440,008
Differences Between Drivers for ODBC Drivers
<p>I was setting up the System DSN (64 bit) for my database in SQL server 2016 with Windows 10 64 bit pro. While I was asked to choose the driver to set up a data source, there are the following selections:</p> <ul> <li>ODBC Driver 13 for SQL Server</li> <li>SQL Server</li> <li>SQL Server Native Client 11.0</li> <li>SQL Server Native Client RDA 11.0</li> </ul> <p>It seemed I can set up the data source with all of these drivers. Then which one should I choose in terms of speed and efficiency? What's the difference between them?</p> <p>Thanks,</p> <p>Jason</p>
<sql-server><odbc><dsn>
2016-09-11 19:47:00
HQ
39,440,105
Null Pointer Exception when adding GroundOverlay to gMap
<p>i'm working on a project for indoor navigation and need to add a groundOverlay with the floorplan of the building. I've followed the guidelines on the Documentation from Google dev site. But its giving me NullPointerException when i try to add the overlay to the map. Heres my code:</p> <pre><code>@Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; mMap.setIndoorEnabled(true); mMap.setOnIndoorStateChangeListener(this); mMap.setPadding(0,0,50,0); mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(-28.666957, -55.994823), 19)); //add mapOverlay LatLngBounds iffBounds = new LatLngBounds( new LatLng(-28.667177,-55.995104), new LatLng(-28.667061,-55.994443) ); GroundOverlayOptions iffMap = new GroundOverlayOptions() .image(BitmapDescriptorFactory.fromResource(R.raw.piso_1)) .positionFromBounds(iffBounds); mapOverlay = mMap.addGroundOverlay(iffMap); } </code></pre> <p>I have tried debbuging the code and i can't see anything wrong, everything is being correctly instantiated, but when it executes the last line</p> <pre><code>mapOverlay = mMap.addGroundOverlay(iffmap); </code></pre> <p>My app crashes.</p> <p>Here's the StackTrace from logCat:</p> <pre><code>E/AndroidRuntime: FATAL EXCEPTION: main Process: br.com.imerljak.vegvisir, PID: 2390 java.lang.NullPointerException: null reference at maps.w.c.a(Unknown Source) at maps.ad.g$a.&lt;init&gt;(Unknown Source) at maps.ad.g.a(Unknown Source) at maps.ad.w.&lt;init&gt;(Unknown Source) at maps.ad.u.a(Unknown Source) at vo.onTransact(:com.google.android.gms.DynamiteModulesB:182) at android.os.Binder.transact(Binder.java:380) at com.google.android.gms.maps.internal.IGoogleMapDelegate$zza$zza.addGroundOverlay(Unknown Source) at com.google.android.gms.maps.GoogleMap.addGroundOverlay(Unknown Source) at br.com.imerljak.vegvisir.MapsActivity.onMapReady(MapsActivity.java:62) at com.google.android.gms.maps.SupportMapFragment$zza$1.zza(Unknown Source) at com.google.android.gms.maps.internal.zzt$zza.onTransact(Unknown Source) at android.os.Binder.transact(Binder.java:380) at xz.a(:com.google.android.gms.DynamiteModulesB:82) at maps.ad.u$5.run(Unknown Source) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5312) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696) </code></pre> <p>PS: if anyone has any tips that will help me developing this app (like a good API for indoor navigation) i will be grateful :)</p>
<java><android><google-maps>
2016-09-11 19:59:29
LQ_CLOSE
39,440,190
A workaround for Python's missing frozen-dict type?
<p>In Python, when you want to use lists as keys of some dictionary, you can turn them into tuples, which are immutable and hence are hashable.</p> <pre><code>&gt;&gt;&gt; a = {} &gt;&gt;&gt; a[tuple(list_1)] = some_value &gt;&gt;&gt; a[tuple(list_2)] = some_other_value </code></pre> <p>The same happens when you want to use <strong>set</strong> objects as keys of some dictionary - you can build a <strong>frozenset</strong>, that is again immutable and hence is hashable.</p> <pre><code>&gt;&gt;&gt; a = {} &gt;&gt;&gt; a[frozenset(set_1)] = some_value &gt;&gt;&gt; a[frozenset(set_2)] = some_other_value </code></pre> <p>But it seems that for dictionary there is no equivalent.</p> <p>A first idea I thought about (and found it bad finally), is to use <code>str(some_dict)</code> as a key. But, dictionaries always use different hash functions, so strings of equal dictionaries may be different.</p> <p>Is there any workaround known as a good practice, or does anyone have other ideas how to use dictionary-like objects as keys of other dictionaries?</p>
<python><dictionary><immutability>
2016-09-11 20:10:17
HQ
39,440,253
How to return a string from pandas.DataFrame.info()
<p>I would like to display the output from <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.info.html" rel="noreferrer"><code>pandas.DataFrame.info()</code></a> on a <code>tkinter</code> text widget so I need a string. However <code>pandas.DataFrame.info()</code> returns <code>NoneType</code> is there anyway I can change this?</p> <pre><code>import pandas as pd import numpy as np data = np.random.rand(10).reshape(5,2) cols = 'a', 'b' df = pd.DataFrame(data, columns=cols) df_info = df.info() print(df_info) type(df_info) </code></pre> <p>I'd like to do something like:</p> <pre><code>info_str = "" df_info = df.info(buf=info_str) </code></pre> <p>Is it possible to get <code>pandas</code> to return a string object from <code>DataFrame.info()</code>?</p>
<python><pandas>
2016-09-11 20:17:36
HQ
39,440,336
In member function errors c++
<p>I am receiving some errors when compiling my code. </p> <pre><code>circleTypeImp.cpp: In member function âdouble circleType::getRadius() constâ: circleTypeImp.cpp:10: error: argument of type âdouble (circleType::)()constâ does not match âdoubleâ circleTypeImp.cpp: In member function âdouble circleType::setAreaCircle() constâ: circleTypeImp.cpp:15: error: invalid use of member (did you forget the â&amp;â ?) circleTypeImp.cpp: In member function âdouble circleType::setCircumference() constâ: circleTypeImp.cpp:20: error: invalid use of member (did you forget the â&amp;â ?) pointTypeImp.cpp: In member function âvoid pointType::setXCoordinate(double)â: pointTypeImp.cpp:9: error: âxâ was not declared in this scope pointTypeImp.cpp: In member function âvoid pointType::setYCoordinate(double)â: pointTypeImp.cpp:14: error: âyâ was not declared in this scope pointTypeImp.cpp: At global scope: pointTypeImp.cpp:23: error: prototype for âdouble pointType::getXCoordinate(double)â does not match any in class âpointTypeâ pointTypee.h:15: error: candidate is: double pointType::getXCoordinate() const pointTypeImp.cpp:28: error: prototype for âdouble pointType::getYCoordinate(double)â does not match any in class âpointTypeâ pointTypee.h:16: error: candidate is: double pointType::getYCoordinate() const </code></pre> <p>I have overlooked my code and I cant seem to see what is wrong with it. If someone could point it out to me what is needing to be done, I'd appreciate it. I am not looking for someone to do it for me, I am just needing some help figuring it out. </p> <pre><code>//main.cpp #include "pointTypee.h" #include "circleTypee.h" #include &lt;iostream&gt; using namespace std; int main() { pointType p; circleType c; double rad; double area; double circum; double x; double y; cout &lt;&lt; "Enter the x coordinate " &lt;&lt; endl; cin &gt;&gt; x; cout &lt;&lt; endl; cout &lt;&lt; "Enter the y coordinate " &lt;&lt; endl; cin &gt;&gt; y; cout &lt;&lt; endl; cout &lt;&lt; "The X &amp; Y coordinates are: (" &lt;&lt; x &lt;&lt; "," &lt;&lt; y &lt;&lt; ")" &lt;&lt; endl; cout &lt;&lt; "The area of the circle is: "; //Add cout &lt;&lt; "The circumference of the circle is: "; //Add } //PointType.cpp #include "pointTypee.h" #include &lt;string&gt; #include &lt;iostream&gt; void pointType::setXCoordinate (double xcoord) { xcoord = x; } void pointType::setYCoordinate (double ycoord) { ycoord= y; } void pointType::print() const { cout &lt;&lt; "The center point is at (" &lt;&lt; xcoord &lt;&lt; "," &lt;&lt; ycoord &lt;&lt; ")" &lt;&lt; endl; cout &lt;&lt; endl; } double pointType::getXCoordinate(double xcoord) { return xcoord; } double pointType::getYCoordinate(double ycoord) { return ycoord; } pointType::pointType(double xcoord, double ycoord) { xcoord=0; ycoord=0; } //pointType.h #ifndef POINTTYPEE_H #define POINTTYPEE_H #include &lt;string&gt; using namespace std; class pointType { public: void print() const; void setXCoordinate(double xcoord); void setYCoordinate(double ycoord); double getXCoordinate() const; double getYCoordinate() const; pointType(void); pointType(double xcoord, double ycoord); ~pointType(void); private: double xcoord; double ycoord; }; #endif //circleType.h #ifndef CIRCLETYPEE_H #define CIRCLETYPEE_H #include "pointTypee.h" class circleType : public pointType { public: //circleType(double xcoord, double ycoord, double radius); void print() const; double setAreaCircle() const; double setCircumference() const; double getRadius() const; circleType(double xcoord, double ycoord, double radius); ~circleType(void); circleType(); //virtual ~circleType(); private: double radius() const; static double pie; }; #endif //circleTypeImp.cpp #include "circleTypee.h" #include "pointTypee.h" #include &lt;string&gt; #include &lt;iostream&gt; double circleType::getRadius()const { return radius; } double circleType::setAreaCircle () const { return 3.14 * radius * radius; } double circleType::setCircumference() const { return 3.14 * 2 * radius; } circleType::circleType() { //circleType::circleType(); } circleType::~circleType() { } double pie = 3.14; </code></pre>
<c++><derived-class>
2016-09-11 20:28:39
LQ_CLOSE
39,440,396
I believe I am getting confused with the pointers in my program.
Below I created a function that enters a while loop. In the while loop an if statement is called to traverse the list and check the numbers to see which one is the largest and which one is the smallest. When I run the program only one `printf()` is called, and prints the same `printf()` more than once. It seems to pick two numbers and print them under the same `printf()` function.I know that `firstNumber = firstNumber->next;` is supposed to traverse the list. Isn't `secondNumber = secondNumber->next->next;` supposed to point to the next number in the list? typedef struct A_NewNumber { struct A_NewNumber *next; double newNum; } NewNumber; void NumberSize(NewNumber *start){ NewNumber *firstNumber = start; NewNumber *secondNumber = start; if(start != NULL){ while (secondNumber != NULL && secondNumber->next != NULL){ secondNumber = secondNumber->next->next; firstNumber = firstNumber->next; if(secondNumber > firstNumber){ printf("The biggest number is:%lf \n",secondNumber->newNum); }else{ printf("The smallest number is:%lf \n",firstNumber->newNum); } firstNumber = firstNumber->next; } } }
<c>
2016-09-11 20:35:09
LQ_EDIT
39,440,756
Share App application shortcut [UIApplicationShortcutIconTypeShare]
<p>I've seen a lot of apps use the <code>UIApplicationShortcutIconTypeShare</code> application shortcut to share their app right from the home screen. It launches a UIActivityViewController right from the home screen without opening the app. How do you do that?</p>
<ios><objective-c><uiactivityviewcontroller><uiapplicationshortcutitem>
2016-09-11 21:19:45
HQ
39,441,129
Error in merge sorting of linked list
<p>I am trying to do a merge sorting practice on linked list sort and I couldn't figure the reason that the code doesn't work, my compiler doesn't give any useful error message. Can't someone point it out for me? thanks!</p> <pre><code> #include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;iostream&gt; using namespace std; struct listnode { struct listnode * next; int key; }; //function prototypes void seperate(struct listnode * node, struct listnode ** front, struct listnode ** back); struct listnode * merge(struct listnode * node_1, struct listnode * node_2); //merge sorted seperated linked list void mergeSort(struct listnode ** node) { struct listnode * head = * node; struct listnode * node_1; struct listnode * node_2; if ((head == NULL) || (head-&gt;next == NULL)) { return; } seperate(head, &amp;node_1, &amp;node_2); mergeSort(&amp;node_1); mergeSort(&amp;node_2); * node = merge(node_1, node_2); } //sort sepearted linked list struct listnode * merge(struct listnode * node_1, listnode * node_2) { struct listnode * return_result = NULL; if (node_1 == NULL) { return (node_2); } else if (node_2 = NULL) { return (node_1); } if (node_1-&gt;key &lt;= node_2-&gt;key) { return_result = node_1; return_result-&gt;next = merge(node_1-&gt;next, node_2); } else { return_result = node_2; return_result-&gt;next = merge(node_1, node_2-&gt;next); } return return_result; } //function to seperate linked list void seperate(struct listnode * node, struct listnode ** front, struct listnode ** back) { struct listnode * fast; struct listnode * slow; if (node == NULL || node-&gt;next == NULL) { *front = node; * back = NULL; } else { slow = node; fast = node-&gt;next; while (fast != NULL) { fast = fast-&gt;next; if (fast != NULL) { slow = slow-&gt;next; fast = fast-&gt;next; } } * front = node; * back = slow-&gt;next; slow-&gt;next = NULL; } }// merge sort of linked list completed //test functions to push and print the linked list void push(struct listnode ** head, int data) { struct listnode * added_node = (struct listnode * )malloc(sizeof(struct listnode)); added_node-&gt;key = data; added_node-&gt;next = (*head); (*head) = added_node; } void printList(struct listnode * node) { while (node != NULL) { cout &lt;&lt; node-&gt;key; node = node-&gt;next; } } int main() { struct listnode * node1 = NULL; push(&amp;node1, 3); push(&amp;node1, 30); push(&amp;node1, 23); push(&amp;node1, 1); push(&amp;node1, 0); push(&amp;node1, 9); mergeSort(&amp;node1); cout &lt;&lt; endl; printList(node1); return 0; } </code></pre>
<c++>
2016-09-11 22:12:37
LQ_CLOSE
39,441,484
pandas: groupby and aggregate without losing the column which was grouped
<p>I have a pandas dataframe as below. For each Id I can have multiple Names and Sub-ids.</p> <pre><code>Id NAME SUB_ID 276956 A 5933 276956 B 5934 276956 C 5935 287266 D 1589 </code></pre> <p>I want to condense the dataframe such that there is only one row for each id and all the names and sub_ids under each id appear as a singular set on that row</p> <pre><code>Id NAME SUB_ID 276956 set(A,B,C) set(5933,5934,5935) 287266 set(D) set(1589) </code></pre> <p>I tried to groupby id and then aggregate over all the other columns </p> <pre><code>df.groupby('Id').agg(lambda x: set(x)) </code></pre> <p>But in doing so the resulting dataframe does not have the Id column. When you do groupby the id is returned as the first value of the tuple but I guess when you aggregate that is lost. Is there a way to get the dataframe that I am looking for. That is to groupby and aggregate without losing the column which was grouped.</p>
<python><pandas><dataframe><group-by>
2016-09-11 23:03:57
HQ
39,441,746
Searching and sorting java
So i am trying to solve this following question in java for practice as I am a beginneer and trying to strengthen my java skills. Here is the question... __________________________________________________ According to our suggested 16 week course schedule, this programming project should be completed no later than the Monday of Week 13. It is worth 8 per cent of your final grade. Please refer to your Assignment Instructions document on your Home Page for details on the submission of your work. Your overall course assessment information is found in your Course Guide. 1. The Shell sort is a variation of the bubble sort. Instead of comparing adjacent values, the Shell sort adapts a concept from the binary search to determine a ‘gap’ across which values are compared before any swap takes place. In the first pass, the gap is half the size of the array. For each subsequent pass, the gap size is cut in half. For the final pass(es), the gap size is 1, so it would be the same as a bubble sort. The passes continue until no swaps occur. Below is the same set of values as per the bubble sort example in Chapter 18 (p.681), showing the first pass: 9 6 8 12 3 1 7 ‐‐ size of array is 7, so gap would be 3 9 6 8 12 3 1 7 ‐‐ 9 and 12 are already in order, so no ^---------^ 9 6 8 12 3 1 7 ‐‐ 6 and 3 are not in order, so swap ^---------^ 9 3 8 12 6 1 7 ‐‐ 8 and 1 are not in order, so swap ^---------^ 9 3 1 12 6 8 7 ‐‐ 12 and 7 are not in order, so swap ^---------^ 9 3 8 7 6 1 12 ‐‐ end of pass 1  __________________________________ I dont want anyone to give me the direct code but would appreciate a opinion on how to tackle the question as I am having a hard time getting it started. Please keep in mind that I am a begineer so know really advanced methods! Thanks for your time
<java><sorting><search><bubble-sort>
2016-09-11 23:48:57
LQ_EDIT
39,441,764
what's the difference between google.appengine.ext.ndb and gcloud.datastore?
<p>ndb: (from google.appengine.ext import ndb)</p> <p>datastore: (from gcloud import datastore)</p> <p>What's the difference? I've seen both of them used, and hints they both save data to google datastore. Why are there two different implementations?</p>
<google-app-engine><google-cloud-datastore><app-engine-ndb><google-app-engine-python>
2016-09-11 23:53:34
HQ
39,442,570
R Studio: ctrl+shift+enter runs the entire code instead of the selected lines only
<p>I am using R Studio and I have encountered a problem: ctrl+shift+enter is running the entire code instead of the selected lines only. I can always use "Run", but I am used to ctrl+shift+enter... Anybody has any clue on how to fix this?</p>
<r><rstudio>
2016-09-12 02:17:27
LQ_CLOSE
39,442,963
TortoiseSVN error The XML response contains invalid XML and Malformed XML: no element found
<p>My TortoiseSVN Checkout and Update error </p> <p><strong>The XML response contains invalid XML Malformed XML: no element found</strong></p> <p>What do you do Please help me.</p>
<xml><svn><tortoisesvn>
2016-09-12 03:28:53
HQ
39,442,982
Wordpress cronjob every 3 minutes
<p>there are many post on stackoverflow with this topic but (i dont know why) nothing will work for me.</p> <p>What i have</p> <pre><code>function isa_add_every_three_minutes( $schedules ) { $schedules['every_three_minutes'] = array( 'interval' =&gt; 180, 'display' =&gt; __( 'Every 3 Minutes', 'textdomain' ) ); return $schedules; } add_filter( 'cron_schedules', 'isa_add_every_three_minutes' ); function every_three_minutes_event_func() { // do something } wp_schedule_event( time(), 'every_three_minutes', 'every_three_minutes_event_func' ); </code></pre> <p>Any ideas what i'm doing wrong?</p>
<php><wordpress><cron>
2016-09-12 03:31:06
HQ
39,443,066
C++: Convert Win32 textbox input into ASCII integers, do some math, convert back into characters that can be printed in another Win32 textbox
This is hopefully, someday, going to be an encryption program. I decided to get fancy and make a window with two text boxes and two buttons; one text box for input, one text box for output, one button for encryption, one button for decryption. I'm using text boxes because unfortunately, a user can't copy and paste out of message boxes, and nobody wants to memorize or write down 200 pairs of numbers. My current problem is with getting the correct data type conversions happening before and after I do the math. My IDE is Code::Blocks, my compiler is GNU GCC. This first part is basically just initial setup. #if defined(UNICODE) && !defined(_UNICODE) #define _UNICODE #elif defined(_UNICODE) && !defined(UNICODE) #define UNICODE #endif #include <iostream> #include <windows.h> #include <tchar.h> #define ID_BTNENCRYPT 1 #define ID_TXTMSG 2 #define ID_TXTRTN 3 #define ID_BTNDECRYPT 4 const char g_szClassName[] = "MyWindowClass"; HWND button; HWND button2; HWND textbox; HWND textreturn; LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { //Creates buttons and text boxes switch(msg) { case WM_CREATE: { button = CreateWindow("button", "Encrypt Message", WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, 240, 560, 200, 30, hwnd, (HMENU) ID_BTNENCRYPT, GetModuleHandle(NULL), NULL); button2 = CreateWindow("button", "Decrypt Message", WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, 240, 600, 200, 30, hwnd, (HMENU) ID_BTNDECRYPT, GetModuleHandle(NULL), NULL); textbox = CreateWindow("EDIT", "Enter your message here:", WS_BORDER | WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL, 30, 30, 620, 270, hwnd, (HMENU) ID_TXTMSG, GetModuleHandle(NULL), NULL); textreturn = CreateWindow("EDIT", "", WS_VISIBLE | WS_CHILD | WS_BORDER | WS_VSCROLL | ES_MULTILINE, 30, 310, 620, 200, hwnd, (HMENU) ID_TXTRTN, GetModuleHandle(NULL), NULL); break; } case WM_COMMAND: { //Executes commands upon the clicking of buttons switch (LOWORD(wParam)){ First button. I want to take text input through a text box, change the characters to integers, do fun math with my integers, and put them back into a char array to be printed in another text box. case ID_BTNENCRYPT: { int len = GetWindowTextLength(textbox) + 1; char* text = new char[len]; GetWindowText(textbox, &text[0], len); I don't know why this does not work int x = 0; int INTmessage[len]; int ENClen = (len * 2); char *ENCmessage = new char[ENClen]; while (x < len) { INTmessage[x] = int(&text[x]) - 32; x++; } int z = 0; int y = 0; while (z < ENClen) { I figure it has something to do with how I'm calling ENCmessage. I know that it should be &ENCmessage but &BlahBlahBlah can't go on the left side of the equal sign. ENCmessage[z] = char(INTmessage[y] % 9); ENCmessage[z + 1] = char(INTmessage[y] % 10); z += 2; y++; } /*int w = 0; //This stuff didn't work, ignore it. //char *textx = new char[ENClen]; char *ltr = new char[ENClen]; while (w < ENClen) { ltr[w] = (ENCmessage[w]); w++; }*/ SetWindowText(textreturn, ""); SetWindowText(textreturn, &ENCmessage[0]); I wish this output what I want it to but I get a bunch of very strange symbols, and get different symbols each time I run the same text through. ::MessageBox(hwnd, "Message Encrypted", "SUCCESS!", MB_OK); } } switch (LOWORD(wParam)){ case ID_BTNDECRYPT: { //This is a whole different party for a different time. int len = GetWindowTextLength(textbox) + 1; char* text = new char[len]; GetWindowText(textbox, &text[0], len); ::MessageBox(hwnd, "Message Decrypted", "SUCCESS!", MB_OK); } } break; } case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return 0; } Here is my window creation if you need to see it. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { FreeConsole(); WNDCLASSEX wc; HWND hwnd; MSG Msg; wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH) (COLOR_WINDOW - 2); wc.lpszMenuName = NULL; wc.lpszClassName = g_szClassName; if (!RegisterClassEx(&wc)) { ::MessageBox(NULL, "Window Registration Status: Hopelessly F***ed", "", MB_OK); return 0; } hwnd = CreateWindowEx( WS_EX_CLIENTEDGE, g_szClassName, "enCRPEtion: Free Encryption Software", WS_OVERLAPPEDWINDOW, 0, 0, 700, 700, NULL, NULL, hInstance, NULL); if (hwnd == NULL) { ::MessageBox(NULL,"Window Creation Status: Gone to $h!t", "", MB_OK); } ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd); while(GetMessage(&Msg, NULL, 0, 0) > 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; }
<c++><winapi><textbox>
2016-09-12 03:43:59
LQ_EDIT
39,443,283
Write a MATLAB code to compute and determine the convergence rate
Write a MATLAB code to compute and determine the convergence rate of : (exp(h)-(1+h+1/2*h^2))/h with h=1/2, 1/2^2,..., 1/2^10 my code was: h0=(0.5)^i; TOL=10^(-8); N=10; i=1; flag=0; table=zeros(30,1); table(1)=h0 while i < N h=(exp(h0)-(1+h0+0.5*h0^2))/h0; table (i+1)=h; if abs(h-h0)< TOL flag=1; break; end i=i+1; h0=h; end if flag==1 h else error('failed'); end The answer I received does not make quite any sense. Please help.
<matlab><rate><numerical-analysis><convergence>
2016-09-12 04:16:25
LQ_EDIT
39,444,414
logical operators in if statements c++
<p>The current code at the bottom works but I can't combine the if statements without shifting the ascii values to a position that I don't want them to be. The encryption is supposed to be only alphabet values. Capital and lowercase z's are supposed to loop around to an A. I have a teacher but she doesn't know so I would be grateful for any help. Thanks &lt;3</p> <p>This doesn't work...</p> <pre><code>if (sentence[i] == 'z' || 'Z') { sentence[i] = sentence[i] - 26; } </code></pre> <p>And this doesn't work </p> <pre><code>if (sentence[i] == 'z' || sentence[i] == 'Z') { sentence[i] = sentence[i] - 26; } </code></pre> <p>This works.</p> <pre><code>if (sentence[i] == 'z') { sentence[i] = sentence[i] - 26; } if (sentence[i] == 'Z') { sentence[i] = sentence[i] - 26; } </code></pre> <p>Full code. </p> <pre><code>#include &lt;iostream&gt; #include &lt;string&gt; using namespace std; class EncryptionClass { string sentence; public: //constructors EncryptionClass(string sentence) {setString(sentence);} EncryptionClass() {sentence = "";} //get and set string getString() {return sentence;} void setString(string sentence) {this-&gt; sentence = sentence;} //encrypt void encryptString() { for(int i = 0; i &lt; sentence.length(); i++) { if (isalpha(sentence[i])) { if (sentence[i] == 'z') { sentence[i] = sentence[i] - 26; } if (sentence[i] == 'Z') { sentence[i] = sentence[i] - 26; } sentence[i] = sentence[i] + 1; } } } }; int main() { string sentence; cout &lt;&lt; "Enter a sentence to be encrypted. "; getline(cin, sentence); cout &lt;&lt; endl; EncryptionClass sentence1(sentence); cout &lt;&lt; "Unencrypted sentence." &lt;&lt; endl; cout &lt;&lt; sentence1.getString() &lt;&lt; endl &lt;&lt; endl; sentence1.encryptString(); cout &lt;&lt; "Encrypted sentence." &lt;&lt; endl; cout &lt;&lt; sentence1.getString() &lt;&lt; endl; cin.get(); return 0; } </code></pre>
<c++><string><if-statement><logical-operators>
2016-09-12 06:24:12
LQ_CLOSE
39,444,664
I wnt to connect php and mysql database
<pre><code>&lt;?php $host ="localhost"; $user = "root"; $pass = ""; $db = "StuDet"; $conn = mysql_connect($host,$user,$pass); mysql_select_db($db,$conn); @mysql_select_db($database) or die ("Unable to select database"); ?&gt; </code></pre> <p>I have a doubt in line "$conn = mysql_connect($host,$user,$pass);" </p>
<php><mysql>
2016-09-12 06:45:08
LQ_CLOSE
39,445,488
Using the ‘stage’ step without a block argument is deprecated
<p>When building a Jenkins pipeline job (Jenkins ver. 2.7.4), I get this warning:</p> <pre><code>Using the ‘stage’ step without a block argument is deprecated </code></pre> <p>How do I fix it?</p> <p>Pipeline script snippet:</p> <pre><code>stage 'Workspace Cleanup' deleteDir() </code></pre>
<jenkins><jenkins-pipeline>
2016-09-12 07:42:17
HQ
39,445,501
Insert specific ID in identity field
<p>Is it possible to insert specific value in identity field in a SQL table?</p> <p>I deleted some rows and imported them again, but I need to insert some exceptions with exact IDs.</p>
<sql-server>
2016-09-12 07:43:00
HQ
39,445,613
Determine List.IndexOf ignoring case
<p>Is there a way to get the index of a item within a List with case insensitive search?</p> <pre><code>List&lt;string&gt; sl = new List&lt;string&gt;() { "a","b","c"}; int result = sl.IndexOf("B"); // should be 1 instead of -1 </code></pre>
<c#><list>
2016-09-12 07:50:05
HQ
39,445,912
Client characteristics [JAVA]
<p>I am trying to write my first client-server program in java but as I am new there are a few things that got me really confused. Is there any way to give specific characteristics to the client? For example I want each client who connects to have an id and a sum of money that will be changed by the server. Is something like this possible? If so how?<br> Also, I want to put some commands from the clients in a queue in order to make sure they are served in the correct order. How can I do that if each client has its own thread? In what part of the code should I initialise the queue?</p>
<java><multithreading><server><client>
2016-09-12 08:11:21
LQ_CLOSE
39,446,477
how to calculate row average in panda data frame ?
I have pandas df with column, T max & T min. I want to calculate T mean on next column. I did with this df['T mean']= df[['T max','T min']].mean(axis=1) but didnt worked out. I got T max as T mean. Could anybody help me?
<python-3.x><pandas><dataframe><mean>
2016-09-12 08:48:26
LQ_EDIT
39,446,706
How to change a Div background url which is inside a <a> tag?
I have 6 div tags with background images, inside a <a> tags. What I want to do is highlight or change the relevant background image of the div tag once clicked it. <td><a href="../pages/index.php"><div id="dashboardDiv" style="background:url(../images/home.png) no-repeat center";)></div></a></td> <td></td> <td><a href="../pages/suppliers.php"><div id="suppliersDiv" style="background:url(../images/Suppliers.png) no-repeat center";)></div></a></td> <td></td> <td><a href="../pages/customers.php"><div id="customersDiv" style="background:url(../images/customers.png) no-repeat center";)></div></a> </td> <td></td> <td><a href="../pages/purchases.php"><div id="purchasesDiv" style="background:url(../images/Purchases.png) no-repeat center";)></div></a> </td> <td></td> <td><a href="../pages/sales.php"> <div id="salesDiv" style="background:url(../images/Sales.png) no-repeat center";)></div></a></td> <td></td> <td><a href="../pages/inventory.php"><div id="inventoryDiv" style="background:url(../images/Inventory.png) no-repeat center";)></div></a></td> <td></td> <td><a href="../pages/reports.php"><div id="reportsDiv" style="background:url(../images/Reports.png) no-repeat center";)></div></a></td> <td></td> </tr> CSS: #dashboardDiv{ border:thin; float:left; height: 133px; width: 133px; }
<html><css>
2016-09-12 09:02:11
LQ_EDIT
39,446,741
how to get rid of NaN value in R
<p>I have a variable in R. I am going to do PCA analysis. but I have a lot of NaN values. do you guys know how to get rid of them?</p> <p>my data looks like this:</p> <pre><code> 11819 11820 11821 s1 1.1547005 NaN 1.1547005 s2 -0.5773503 NaN -0.5773503 s4 -0.5773503 NaN -0.5773503 </code></pre> <p>11819, 11820 and 11821 are col names and s1, s2 and s4 are row names. thanks</p>
<r><nan>
2016-09-12 09:03:45
LQ_CLOSE
39,447,571
Async library best practice: ConfigureAwait(false) vs. setting the synchronization context
<p>It's well-known that in a general-purpose library, <code>ConfigureAwait(false)</code> should be used on every await call to avoid continuing on the current SynchronizationContext.</p> <p>As an alternative to peppering the entire codebase with <code>ConfigureAwait(false)</code>, one could simply set the SynchronizationContext to null once, at the public surface method, and restore it before returning to the user. In other words:</p> <pre><code>public async Task SomeSurfaceMethod() { var callerSyncCtx = SynchronizationContext.Current; SynchronizationContext.SetSynchronizationContext(null); try { // Do work } finally { SynchronizationContext.SetSynchronizationContext(callerSyncCtx); } } </code></pre> <p>This could also be wrapped in a <code>using</code> for better readability.</p> <p>Is there a disadvantage to this approach, does it not end up producing the same effect?</p> <p>The major advantage is obviously readability - the removal of all <code>ConfigureAwait(false)</code> calls. It may also reduce the likelihood of forgetting a <code>ConfigureAwait(false)</code> somewhere (although analyzers mitigate this, and it could be argued that developers could just as well forget changing the SynchronizationContext).</p> <p>A somewhat exotic advantage is not embedding the choice of capturing the SynchronizationContext or not in all methods. In other words, in one case I may want to run method X with a SynchronizationContext, while in another I may want to run the same method without one. When <code>ConfigureAwait(false)</code> is embedded everywhere that isn't possible. Granted, this is quite a rare requirement, but I bumped into it while working on Npgsql (triggering this question).</p>
<c#><asynchronous><async-await>
2016-09-12 09:48:00
HQ
39,447,909
Access span text jquery
I need to change a text in a span. <span class="count_bottom"><i class="blue"><i class="fa fa-sort-asc"></i>12% </i> From last seen</span> I only need to change `From last seen` text according to button click event. How can I do this?
<javascript><jquery><html><text><siblings>
2016-09-12 10:08:04
LQ_EDIT
39,448,465
Why data frame column names different using = and <- in R
<p>Can any body explain why the below two data frames <code>df1</code> and <code>df2</code> are differing in their column names</p> <pre><code> df1 &lt;- data.frame(a = 1:5, b = 11:15) df1 # a b # 1 1 11 # 2 2 12 # 3 3 13 # 4 4 14 # 5 5 15 df2 &lt;- data.frame(a &lt;- 1:5, b &lt;- 11:15) df2 # a....1.5 b....11.15 # 1 1 11 # 2 2 12 # 3 3 13 # 4 4 14 # 5 5 15 </code></pre>
<r><dataframe>
2016-09-12 10:40:27
LQ_CLOSE
39,448,740
Facebook login in laravel 5.2 can't hold the session after redirect
<p>I am using Facebook PHP SDK to log my user.</p> <p>I created a guard called login for this</p> <p><strong>Here is my config file of auth.php</strong></p> <pre><code>'guards' =&gt; [ 'web' =&gt; [ 'driver' =&gt; 'session', 'provider' =&gt; 'users', ], 'api' =&gt; [ 'driver' =&gt; 'token', 'provider' =&gt; 'users', ], 'admin'=&gt;[ 'driver'=&gt;'session', 'provider'=&gt;'adminusers', ], 'verify'=&gt;[ 'driver'=&gt;'session', 'provider'=&gt;'verify', ], 'login'=&gt;[ 'driver'=&gt;'session', 'provider'=&gt;'users' ] ], </code></pre> <p>to access Facebook api i created a class in App\services namespace called it Facebook </p> <p><strong>App\Services\Facbook.php</strong></p> <pre><code>&lt;?php namespace App\Services; use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Config; use App\Extensions\Facebook\FacebookLaravelPersistentDataHandler; use Facebook\Facebook as FB; use App; class Facebook{ protected $fb; protected $helper; protected $permission; protected $log; protected $canvashelper; protected $persistentDataHandler; function __construct() { $this-&gt;fb = new FB([ 'app_id'=&gt;Config::get('facebook.app_id'), 'app_secret'=&gt;Config::get('facebook.app_secret'), 'default_graph_version' =&gt; Config::get('facebook.default_graph_version'), 'persistent_data_handler' =&gt; new FacebookLaravelPersistentDataHandler(), ]); $this-&gt;helper = $this-&gt;fb-&gt;getRedirectLoginHelper(); $this-&gt;permission = Config::get('facebook.permission'); $this-&gt;log = new Logging(Config::get('facebook.logfile'),'Facebook Log'); $this-&gt;canvashelper = $this-&gt;fb-&gt;getCanvasHelper(); $this-&gt;persistentDataHandler = new FacebookLaravelPersistentDataHandler(); } public function FBAuthUrl() { if($this-&gt;isFBAuth()) { return $this-&gt;helper-&gt;getLogoutUrl($this-&gt;persistentDataHandler-&gt;get('facebook_access_token'),route('facebook.logout')); } else { return $this-&gt;helper-&gt;getLoginUrl(route('facebook.callback'),$this-&gt;permission); } } public function LoginCallback() { $accessToken = $this-&gt;helper-&gt;getAccessToken(); if(isset($accessToken)) { $this-&gt;persistentDataHandler-&gt;set('facebook_access_token',(string) $accessToken); } } public function isFBAuth() { return $this-&gt;persistentDataHandler-&gt;has('facebook_access_token'); } public function getFBUser() { if($this-&gt;isFBAuth()) { $this-&gt;fb-&gt;setDefaultAccessToken($this-&gt;persistentDataHandler-&gt;get('facebook_access_token')); /*,user_birthday,user_tagged_places*/ $response = $this-&gt;fb-&gt;get("/me?fields=id,name,first_name,last_name,age_range,link,gender,locale,picture,timezone,updated_time,verified,email"); return $response-&gt;getGraphUser(); } else { return false; } } public function logout() { $this-&gt;persistentDataHandler-&gt;delete('facebook_access_token'); $this-&gt;persistentDataHandler-&gt;delete('state'); } } </code></pre> <p>And Here is my UserController Where i write my login logic</p> <pre><code> class UserController extends Controller { ..... /* * Facebook login callback function * @param Object App\services\Facebook * return redirect */ public function fbLogin(Facebook $facebook) { $facebook-&gt;LoginCallback(); /* * get the usergraphnode from facebook */ $fbUser = $facebook-&gt;getFBUser(); /* * Convert UserGraphNode User To Eloquent User */ $user = $this-&gt;getFBLoggedUser($fbUser); /* * Here Log the user in laravel System */ Auth::guard('login')-&gt;login($user); //dump(Auth::guard($this-&gt;guard)-&gt;user()); dump(session()-&gt;all()); return reidrect('/'); } public function getFBLoggedUser($fbUser) { if(User::where('email','=',$fbUser-&gt;getField('email'))-&gt;count()) { $user = User::where('email','=',$fbUser-&gt;getField('email'))-&gt;first(); if($user-&gt;fb_app_id){ $user-&gt;fb_app_id = $fbUser-&gt;getField('id'); $user-&gt;save(); } } else { $user = $this-&gt;FBregister($fbUser); } return $user; } /** * Register The user logged in from Facebook * * @param \Facebook\GraphNodes\GraphUser; * * return \App\Models\User */ public function FBregister($fbUser) { $user = new User(); $user-&gt;fname = $fbUser-&gt;getField('first_name'); $user-&gt;lname = $fbUser-&gt;getField('last_name'); $user-&gt;gender = $fbUser-&gt;getField('gender'); $user-&gt;email = $fbUser-&gt;getField('email'); $user-&gt;fb_app_id = $fbUser-&gt;getField('id'); $picture = $fbUser-&gt;getField('picture'); if($picture-&gt;isSilhouette()){ $user-&gt;profile_image = $picture-&gt;getUrl(); } $user-&gt;save(); return $user; } ......... } </code></pre> <p>On Successful Facebook login redirect i am calling UserController@fbLogin after calling <code>Auth::guard()-&gt;login()</code> i dump session it successfully show a <code>login_login_randomstring=&gt;UserId</code> i session . but When i redirect it all session data lost.</p> <p>But the weird thing is that it only happen when it calling through facebook redirect. If i use this function like normal login routes it works perfactaly like this </p> <p><strong>in route.php</strong> </p> <pre><code>Route::get('/login','UserController@login'); </code></pre> <p><strong>and in UserController</strong></p> <pre><code>function login(){ $user = User::find(12); Auth::guard('login')-&gt;login($user); return redirect('/'); } </code></pre> <p>Using this method i can easily access Session data after redirecting from here but in facebook case it doesn't happening.</p> <p>I stuck here for two days please anyone can help me</p> <p><strong><em>[Note: Please don't mention in your answer that i should grouped my routes in web middleware. ]</em></strong></p>
<php><facebook-graph-api><laravel-5.2><facebook-php-sdk>
2016-09-12 10:55:25
HQ
39,449,665
Xcode 8 can't archive "Command /usr/bin/codesign failed with exit code 1"
<p>I've got a serious problem on Xcode 8 on macOS Sierra. when I try to build my app, I get the following issue.</p> <pre><code>CodeSign /Users/me/Library/Developer/Xcode/DerivedData/MyApp-gnoiiwnelmxzdidnijaswisrwdqe/Build/Products/Debug-iphonesimulator/MyApp.app cd /Users/me/Desktop/MyAppFolder1/MyAppFolder2/MyAppxcode export CODESIGN_ALLOCATE=/Users/me/Downloads/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate export PATH="/Users/me/Downloads/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Users/me/Downloads/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" Signing Identity: "-" /usr/bin/codesign --force --sign - --timestamp=none /Users/me/Library/Developer/Xcode/DerivedData/MyApp-gnoiiwnelmxzdidnijaswisrwdqe/Build/Products/Debug-iphonesimulator/MyApp.app /Users/me/Library/Developer/Xcode/DerivedData/MyApp-gnoiiwnelmxzdidnijaswisrwdqe/Build/Products/Debug-iphonesimulator/MyApp.app: resource fork, Finder information, or similar detritus not allowed Command /usr/bin/codesign failed with exit code 1 </code></pre> <p>then I did <a href="https://forums.developer.apple.com/thread/48905">https://forums.developer.apple.com/thread/48905</a> in the terminal as the following and it worked. but once I clean, the issue comes back.</p> <pre><code>cd /Users/me/Library/Developer/Xcode/DerivedData/MyApp-gnoiiwnelmxzdidnijaswisrwdqe/Build/Products/Debug-iphonesimulator/MyApp ls -al@ * xattr -c * </code></pre> <p>and this solution doesn't work for archive with the following issue. is there any solution for it?</p> <pre><code>CodeSign /Users/me/Library/Developer/Xcode/DerivedData/MyApp-gnoiiwnelmxzdidnijaswisrwdqe/Build/Intermediates/ArchiveIntermediates/MyApp/InstallationBuildProductsLocation/Applications/MyApp.app cd /Users/me/Desktop/MyAppFolder1/MyAppFolder2/MyAppxcode export CODESIGN_ALLOCATE=/Users/me/Downloads/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate export PATH="/Users/me/Downloads/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Users/me/Downloads/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" Signing Identity: "iPhone Developer: My Name (**********)" Provisioning Profile: "iOS Team Provisioning Profile: com.**********.*********" (********-****-****-****-************) /usr/bin/codesign --force --sign **************************************** --entitlements /Users/me/Library/Developer/Xcode/DerivedData/MyApp-gnoiiwnelmxzdidnijaswisrwdqe/Build/Intermediates/ArchiveIntermediates/MyApp/IntermediateBuildFilesPath/MyApp.build/Release-iphoneos/MyApp.build/MyApp.app.xcent --timestamp=none /Users/me/Library/Developer/Xcode/DerivedData/MyApp-gnoiiwnelmxzdidnijaswisrwdqe/Build/Intermediates/ArchiveIntermediates/MyApp/InstallationBuildProductsLocation/Applications/MyApp.app /Users/me/Library/Developer/Xcode/DerivedData/MyApp-gnoiiwnelmxzdidnijaswisrwdqe/Build/Intermediates/ArchiveIntermediates/MyApp/InstallationBuildProductsLocation/Applications/MyApp.app: resource fork, Finder information, or similar detritus not allowed Command /usr/bin/codesign failed with exit code 1 </code></pre>
<ios><xcode><macos><build><archive>
2016-09-12 11:50:53
HQ
39,450,126
how to have 2 relative layouts devided by half in activity?
i want to devide my screen in half vertically, and do a diffrent color in each half, i was trying to use this sulotion mentioned in here> http://stackoverflow.com/questions/19983335/android-2-relative-layout-divided-in-half-screen but it doesn't work for me. this is my layout: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:baselineAligned="false" android:orientation="horizontal" app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:context=".activities.alignmentActivities.Add_New_Project_Activity" tools:showIn="@layout/app_bar_add__new__project_"> <RelativeLayout android:layout_width="0dp" android:layout_height="wrap_content" android:background="#f00000" android:layout_weight="1"> </RelativeLayout> <RelativeLayout android:layout_width="0dp" android:background="#00b0f0" android:layout_height="wrap_content" android:layout_weight="1"> </RelativeLayout> </LinearLayout> how can i achieve the desired effect of 2 layouts each takes half the screen vertical \ what am i doing wrong then the example mentioned in the link ?
<android><android-studio><layout>
2016-09-12 12:17:34
LQ_EDIT
39,450,185
Wiki Documentation Site with Source Control & Release Management
<p>I've been searching for information on available wiki software, using pages such as <a href="https://en.wikipedia.org/wiki/Comparison_of_wiki_software" rel="nofollow">https://en.wikipedia.org/wiki/Comparison_of_wiki_software</a>, and am looking for a solution which will meet a number of requirements, but haven't been able to find anything suitable yet. I am looking to create a documentation site in a form similar to TechNet, MSDN, or <a href="https://documentation.red-gate.com" rel="nofollow">https://documentation.red-gate.com</a>, and although this could be done with either a SharePoint site or a traditional wiki such as MediaWiki, these are generally for open, community edited content which evolves rapidly, or internal company documentation where the presence of errors and incomplete content is not considered an issue. In this case the documentation is to be visible to customers online and would only be edited by our staff, so it would be preferable for its content to be in source control and using managed releases to different environments (i.e. a DEV site where our staff edit the content, a TEST site for proof reading and a LIVE site, online for the public) so that half-written content, or content which has not been proof read is not immediately visible as it is in a standard wiki, but the ability to allow staff to edit the documentation quickly in a wiki-style format is also important.</p> <p>I am aware that projects such as Sandcastle, Document! X and Doxygen, which generate MSDN style documentation directly from the source code, but do not intend this to be a documentation site generated from source code comments, but one containing written articles. In essence, I am looking for software which provides:</p> <ul> <li>The ease of use of a wiki - anyone can log into the DEV site and add/edit content.</li> <li>Source control of all the content, presumably Markdown files and images, not in a database, where the source control (TFS) is automatically updated/files checked out/checked in, by the aforementioned 'easy edit' wiki capabilities.</li> <li>As a result of the above, the ability to 'release' the documentation to test and production environments, as you might do with any other web site solution.</li> </ul> <p>Additional examples would be sites such as <a href="http://uk.mathworks.com/help" rel="nofollow">http://uk.mathworks.com/help</a> or <a href="https://docs.python.org/3/tutorial/introduction.html" rel="nofollow">https://docs.python.org/3/tutorial/introduction.html</a>. Can anyone provide information on whether such a solution is available, or an explanation of how sites such as MSDN, TechNet or the RedGate documentation site are managed and the applications used for them?</p>
<tfs><version-control><wiki><release-management>
2016-09-12 12:20:39
LQ_CLOSE
39,450,777
How to get first image form json response
How to get first image form the response from below response ["147038089457a43b5e47d2a_job1.jpg","147038089457a43b5e48065_job2.jpg","147038089457a43b5e4829c_jobo_3.jpg"] i have tried ng-repeat is not working here
<javascript><angularjs><json>
2016-09-12 12:52:23
LQ_EDIT
39,450,987
eclipse failing to print the output becouse of some error
Im starting leanining java but even why i did everything as the guy in tutorial it is saying that i ahve an error. this is my code: class code{ public static void main(String args[]) { System.out.println("coding..."); } } the output is this : Exception in thread "main" java.lang.Error: Unresolved compilation problem: at code.code.main(code.java:2) Hope u ll help me sort this out **thanks**.
<java><eclipse>
2016-09-12 13:03:58
LQ_EDIT
39,451,060
Python Count the number of periods (.) there are in the file
<p>Count the number of periods (.) there are in the file.</p> <p>Use the built-in function <code>count()</code> on the file after you have converted it to a string.</p> <p>Answer with the result as an integer.</p> <p>I've no idea to do this..please help!</p>
<python><python-3.x>
2016-09-12 13:07:13
LQ_CLOSE
39,451,358
How to know which user answered a Jenkins-Pipeline input step?
<p>I have a Jenkinsfile script that tests for the possibility to perform an SVN merge and then asks the user for the permission to commit the merge.</p> <p>I would like to know the username that answers the "input" step in order to write it into the commit message.</p> <p>Is this possibile?</p> <p>This is what hypothetically I would like to do:</p> <pre><code>outcome = input message: 'Merge trunk into branch?', ok: 'Merge' echo "User that allowed merge: ${outcome.user}" </code></pre>
<jenkins><versioning><jenkins-pipeline>
2016-09-12 13:21:39
HQ
39,451,829
I am passing a vector to a function. Program is compiling but when I am running it, it is showing segmentation fault(core dump).
<p>I want to sort a text file using merge sort. I am using vector to process the text file. This program is compiling correctly but when I am running it, it is showing segmentation fault(core dumped) error. I tried many thing but all in vain. Can anyone help me in this. Thanks in advance.</p> <pre><code>vector&lt;string&gt; sV; void merge(vector&lt;string&gt; &amp; sV, int l, int m, int r) { int i, j, k; int n1 = m - l + 1; int n2 = r - m; vector&lt;string&gt; sV1; vector&lt;string&gt; sV2; for (i = 0; i &lt; n1; i++) sV1[i] = sV[l+1]; for (j = 0; j &lt; n2; j++) sV2[j] = sV[m + 1 + j]; i = 0; j = 0; k = l; while (i &lt; n1 &amp;&amp; j &lt; n2) { if (sV1[i] &lt;= sV2[j]) { sV[k] = sV1[i]; i++; } else { sV[k] = sV2[j]; j++; } k++; } while (i &lt; n1) { sV[k] = sV1[i]; i++; k++; } while (j &lt; n2) { sV[k] = sV2[j]; j++; k++; } } void mergeSort(vector&lt;string&gt; &amp; sV, int l, int r) { if (l &lt; r) { int m = l+(r-l)/2; mergeSort(sV, l, m); mergeSort(sV, m+1, r); merge(sV, l, m, r); } } int main() { string word; char ch, ch1; ifstream tin("a1.txt"); ofstream outp("out.txt"); if(!tin.is_open()) cout &lt;&lt; "Unable to open file :) \n"; while(tin &gt;&gt; word) sV.push_back(word); mergeSort(sV, 0, sV.size() - 1); for (size_t i = 0; i &lt; sV.size(); i++) { outp&lt;&lt; sV[i] &lt;&lt; " "; } return 0; } </code></pre>
<c++><segmentation-fault><stdvector><coredump>
2016-09-12 13:45:39
LQ_CLOSE
39,452,007
How to use Scrollspy & Affix in Angular 2
<p>I noticed that you cannot use in angular 2 components bootstrap feature like <code>data-spy="affix"</code> </p> <p>Does anyone know how to use affix and scrollspy in angular 2? (<a href="http://www.w3schools.com/bootstrap/tryit.asp?filename=trybs_scrollspy_affix&amp;stacked=h" rel="noreferrer">Example</a>)</p>
<twitter-bootstrap><angular>
2016-09-12 13:54:50
HQ
39,452,030
Jenkins Pipeline: is it possible to avoid multiple checkout?
<p>I've moved a few old Jenkins jobs to new ones using the <a href="https://jenkins.io/doc/pipeline/">pipeline feature</a> in order to be able to integrate the Jenkins configuration within the git repositories. It's working fine but I'm asking myself if there is a way to reduce the number of checkout that happens while building.</p> <p><strong>Setup</strong></p> <ul> <li>I have a Jenkins multibranch job which is related to my git repository</li> <li><p>I have a Jenkinsfile in my git repository</p> <pre><code>#!groovy node { stage 'Checkout' checkout scm // build project stage 'Build' ... } </code></pre></li> </ul> <p><strong>Problem</strong></p> <p>When I push to my remote branche <em>BRANCH_1</em>, the multibranch jenkins job is triggered and my understanding is that the following steps happen:</p> <ul> <li>the multibranch job makes a <code>git fetch</code> for the branch indexing and triggers the job corresponding to my remote branch: <em>BRANCH_1_job</em></li> <li><em>BRANCH_1_job</em> makes a <code>git checkout</code> to retrieve the Jenkinsfile of the triggered branch</li> <li>the Jenkinsfile is executed and makes a <code>checkout scm</code> itself. If I don't do it, I can not build my project because no source are available.</li> </ul> <p>So for building my branch, I end up with one <code>git fetch</code> and two <code>git checkout</code>.</p> <p><strong>Questions</strong></p> <ul> <li>Do I understand the process correctly? Or did I miss something?</li> <li>Is there a way to reduce the number of <code>git checkout</code>? When I check the <a href="https://github.com/jenkinsci/pipeline-examples/tree/master/jenkinsfile-examples">official examples</a>, they all make a checkout scm as first step. I would personally think that I don't have to do it because the jenkins job already had to make a checkout to retrieve the Jenkinsfile (so my sources have to be here somehow).</li> <li>Don't you think these multiple checkouts can cause bad performance as soon as the git repo contains a big number of refs?</li> </ul> <p>Thanks you all</p>
<git><jenkins><jenkins-pipeline>
2016-09-12 13:55:35
HQ
39,452,083
Using promise function inside Javascript Array map
<p>Having an array of objects [obj1, obj2]</p> <p>I want to use Map function to make a DB query (that uses promises) about all of them and attach the results of the query to each object.</p> <pre><code>[obj1, obj2].map(function(obj){ db.query('obj1.id').then(function(results){ obj1.rows = results return obj1 }) }) </code></pre> <p>Of course this doesn't work and the output array is [undefined, undefined]</p> <p>What's the best way of solving a problem like this? I don't mind using other libraries like async</p>
<javascript><arrays><promise>
2016-09-12 13:57:39
HQ
39,452,169
How to remove Controller and method URL in codeignitor
This is my current URL http://www.example.com/agent/index/$id, and i want to change this http://www.example.com/demo_name(by agent name) Please suggest your answer.
<php><codeigniter><url><codeigniter-2>
2016-09-12 14:01:45
LQ_EDIT
39,452,256
How do i search divs for text from a select form and change diplay of the divs to none?
I'm trying to hide divs based on a value in a dropdown selector. I'm not sure where I have went wrong. here is my code. document.getElementById("SearchFilter").onchange = function() { var matcher = new RegExp(document.getElementById("SearchFilter").value, "gi"); for (var i = 0; i < document.getElementsByClassName("v-product").length; i++) { if (matcher.test(document.getElementsByClassName("tipue_search_content_text")[i].innerHTML)) { document.getElementById("v-product").style.display = "inline-block"; } else { document.getElementById("v-product").style.display = "none"; } }
<javascript><html><css>
2016-09-12 14:05:19
LQ_EDIT
39,452,457
Replace line containing string with Python
<p>I'm trying to search through a file for a line that contain certain text and then replace that entire line with a new line.</p> <p>I'm trying to use:</p> <pre><code>pattern = "Hello" file = open('C:/rtemp/output.txt','w') for line in file: if pattern in line: line = "Hi\n" file.write(line) </code></pre> <p>I get an error saying:</p> <pre><code>io.UnsupportedOperation: not readable </code></pre> <p>I'm not sure what I'm doing wrong, please can someone assist.</p>
<python><replace>
2016-09-12 14:15:33
LQ_CLOSE
39,452,487
Hi guys, im new here, i need a little help on making an an algorithm that displays all the even numbers between 0 and 1000.
I need help, i need to pass it tomorrow morning and I'm having a little problem.***emphasized text***
<algorithm><pseudocode>
2016-09-12 14:17:39
LQ_EDIT
39,453,097
How to return gzipped content with AWS API Gateway
<p>We have developed an application that offers serveral rest services and supports <code>Accept-Encoding</code> header to return compressed content through <code>Content-Encoding:gzip</code> header value. </p> <p>This application is deployed on ec2 instances on aws and when we send a request with <code>Accept-Encoding</code> value set the response is correctly built.</p> <p>We want to expose this api by using api gateway but it is just working for not compressing requests. When we send a request asking for gzipped content the <code>Content-Encoding</code> header is set correctly but the response content is corrupt.</p> <p>Do we have to set some special parameter or configuration in integration response or method response steps?</p> <p>Regards.</p>
<aws-api-gateway><http-accept-encoding>
2016-09-12 14:48:38
HQ
39,453,740
Regex with HTML
In this scenario, I would like to capture dgdhyt2464t6ubvf through regex. Please can you help me. Thank you so much! <br />For API key "fnt56urkehicdvd", use API key secret: <br /> <br /> dgdhyt2464t6ubvf <br /> <br />Note that it's normal to
<regex>
2016-09-12 15:21:48
LQ_EDIT
39,454,185
Is it possible to use Webpack-Hot-Middleware with NGINX on server side?
<p>I am working on a project for a client and I need to use webpack's Hot Module Replacement feature. I am using an express (node) application behind NGINX. I am using many javascript frameworks to design the application, React happens to be one of them. </p> <p>I will be using the HMR feature. </p> <p>I have a webpack.config.js like this :</p> <pre><code>var webpack = require('webpack'); var ExtractTextPlugin = require("extract-text-webpack-plugin"); var merge = require('webpack-merge'); var validate = require('webpack-validator'); var CleanWebpackPlugin = require('clean-webpack-plugin'); var styleLintPlugin = require('stylelint-webpack-plugin'); //breaking up into smaller modules //commons module //first var start = { context : __dirname , //entry point defination entry : { app : ['./require.js','webpack-hot-middleware/client?https:127.0.0.1:8195'], vendor : ['angular','angular-animate','angular-messages','angular-aria','angular-route','angular-material','react','react-dom',''webpack-hot-middleware/client?https:127.0.0.1:8195''] }, //output defination output : { path : './public/dist', publicPath: 'https://127.0.0.1:8195/public/dist/', filename : 'app.bundle.js' }, module: { preLoaders: [ { test: /\.(js|jsx)$/, exclude: /(node_modules|bower_components)/, loaders: ['eslint'] } ], loaders: [ {test: /\.js$/, loader: 'ng-annotate!babel?presets[]=es2015!jshint', exclude: /node_modules/}, { test: /\.css$/, exclude: /(node_modules|bower_components)/, loader: ExtractTextPlugin.extract("style-loader", "css") }, { test: /\.less$/, exclude: /(node_modules|bower_components)/, loader: ExtractTextPlugin.extract("style", "css!less") }, { test: /\.scss$/, exclude: /(node_modules|bower_components)/, loader: ExtractTextPlugin.extract("style", "css!sass") }, { test: /\.jsx?$/, exclude: /(node_modules|bower_components)/, loaders: ['react-hot', 'babel'], }, { test: /\.woff2$/, loader: 'url' } ] }, plugins: [ new webpack.optimize.CommonsChunkPlugin(/* chunkName= */"vendor", /* filename= */"vendor.bundle.js"), new webpack.DefinePlugin({ "process.env": { NODE_ENV: JSON.stringify("production") } }), new ExtractTextPlugin("styling.css", {allChunks: true}), new ExtractTextPlugin("styling.css", {allChunks: true}), new ExtractTextPlugin("styling.css", {allChunks: true}), //new webpack.optimize.UglifyJsPlugin({ //compress: { // warnings: false // }, //}), // new webpack.optimize.DedupePlugin(), // new webpack.optimize.OccurrenceOrderPlugin(), new webpack.HotModuleReplacementPlugin(), new webpack.NoErrorsPlugin() ], //target: 'web' }; var config; // Detect how npm is run and branch based on that //choose modules //all modules switch(process.env.npm_lifecycle_event) { case 'build': config = merge(start); break; default: config = merge(start); } //export config module.exports = validate(config); </code></pre> <p>My app.js file includes : </p> <pre><code>app.set('views', path.join(__dirname, 'views')); app.set('view engine', 'ejs'); //webpack development server integration app.use(require("webpack-dev-middleware")(compiler, { noInfo: false, stats: { colors: true, chunks: true, 'errors-only': true }, headers: { "X-Custom-Header": "yes" }, publicPath: webpackConfig.output.publicPath })); app.use(require("webpack-hot-middleware")(compiler, { log: console.log })); </code></pre> <p>My NGINX file includes </p> <pre><code>location / { ... proxy_pass https://127.0.0.1:8195; ... ... } </code></pre> <p>When I open <a href="https://127.0.0.1:8195" rel="noreferrer">https://127.0.0.1:8195</a>. Then files are created and served up. Express listens on 8195 port. But when I open the <a href="https://domain-name.com" rel="noreferrer">https://domain-name.com</a>, the files aren't served but NGINX doesn't show 502 error. </p>
<javascript><node.js><express><webpack-hmr><webpack-hot-middleware>
2016-09-12 15:47:22
HQ
39,454,233
Add RelativeLayout with buttons below RecyclerView
<p>I need to add a RelativeLayout below my RecyclerView and was able to do so, except that the button under TOTAL(R.id.total_amount_tv) does not show:</p> <p><a href="https://i.stack.imgur.com/0I5kT.png" rel="noreferrer"><img src="https://i.stack.imgur.com/0I5kT.png" alt="enter image description here"></a> </p> <p>I can easily scroll through the items and it doesn't affect my RelativeLayout. I just need the button to be visible.</p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@android:color/white" android:weightSum="1"&gt; &lt;android.support.v7.widget.RecyclerView android:id="@+id/order_recycler" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="40dp" tools:context=".ShoppingCartActivity" /&gt; &lt;RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginBottom="10dp" android:layout_marginLeft="10dp" android:layout_marginRight="10dp"&gt; &lt;TextView android:id="@+id/total_tv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:text="@string/total" android:textSize="20sp" android:textStyle="bold|italic" /&gt; &lt;TextView android:id="@+id/total_amount_tv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentEnd="true" android:layout_alignParentRight="true" android:layout_alignTop="@+id/total_tv" android:textSize="20sp" android:textStyle="bold|italic" /&gt; &lt;Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_below="@+id/total_amount_tv" android:layout_marginTop="51dp" android:background="@color/accent" android:onClick="onClickSendOrder" android:text="@string/order_btn" android:textColor="@android:color/white" android:textSize="20sp" /&gt; &lt;/RelativeLayout&gt; &lt;/RelativeLayout&gt; </code></pre>
<android><android-layout><android-recyclerview><android-relativelayout>
2016-09-12 15:50:12
HQ
39,454,332
Finding the closest span with a specific class inside a div using jquery
I want to find the closest span with class error_span how will i do that using jquery <div class="form-group row"> <div class="col-sm-4"><label for="reimburse_price" class="control label">Amount</label></div> <div class="col-sm-8"> <div><input type="text" name="reimburse_price" min="1" placeholder='0.00' class="form-control numberOnly" id="reimburse_price" required></div> <div><span class="small text-danger error_span"></span></div> </div> </div>
<javascript><jquery><html>
2016-09-12 15:55:38
LQ_EDIT
39,454,507
Spring JdbcTemplate execute vs update
<p>What is the difference between <code>execute(String sql)</code> and <code>update(String sql)</code> in <a href="http://docs.spring.io/spring/docs/3.0.x/javadoc-api/org/springframework/jdbc/core/JdbcTemplate.html" rel="noreferrer"><code>JdbcTemplate</code></a>?</p> <p>If my statement is a straight <code>CRUD</code> and not an object creation DDL (as the execute javadoc implies), does it make sense to use execute vs the seemingly more lightweight update?</p>
<spring><jdbc>
2016-09-12 16:06:16
HQ
39,454,586
Pie Chart Legend - Chart.js
<p>I need help to put the number of the pie chart in the legend</p> <p><a href="http://i.stack.imgur.com/grBpc.png" rel="noreferrer">Chart Image</a></p> <p>If i hover the chart with mouse i can see the number relative to each item</p> <p>i want to display it in the legend either </p> <p>the important code so far:</p> <pre><code>var tempData = { labels: Status, datasets: [ { label: "Status", data: Qtd, backgroundColor: randColor }, ] }; var ctx = $("#pieStatus").get(0).getContext("2d"); var chartInstance = new Chart(ctx, { type: 'pie', data: tempData, options: { title: { display: true, fontsize: 14, text: 'Total de Pedidos por Situação' }, legend: { display: true, position: 'bottom', }, responsive: false } }); </code></pre> <blockquote> <p>"Qtd","randColor" are "var" already with values</p> </blockquote>
<chart.js><pie-chart><legend-properties>
2016-09-12 16:12:18
HQ
39,455,224
Is it possible to map only a portion of an array? (Array.map())
<p>I am building a project using React.js as a front-end framework. On one particular page I am displaying a full data set to the user. I have an Array which contains this full data set. It is an array of JSON objects. In terms of presenting this data to the user, I currently have it displaying the whole data set by returning each item of data using Array.map().</p> <p>This is a step in the right direction, but now I need to display only a portion of the data-set, not the whole thing, I also want some control in terms of knowing how much of the total data set has been displayed, and how much of the data set is yet to be displayed. Basically I am building something like a "view more" button that loads more items of data to the user. </p> <p>Here is what I am using now where 'feed' represents my Array of JSON objects. (this displays the whole data set.)</p> <pre><code> return ( &lt;div className={feedClass}&gt; { feed.map((item, index) =&gt; { return &lt;FeedItem key={index} data={item}/&gt; }) } &lt;/div&gt; ); </code></pre> <p>I am wondering if it is possible to use .map() on only a portion of the array without having to break up the array before hand? I know that a possible solution would be to hold the full data set, and break it off into portions, and then .map() those portions, but is there a way to .map() a portion of the array without having to break it up?</p> <p>Any and all feedback is appreciated. Thanks!</p>
<javascript><arrays><json><reactjs>
2016-09-12 16:56:54
HQ
39,455,741
gcc: error trying to exec 'cc1plus': execvp: No such file or directory
<p>I'm trying to install this python module, which requires compilation (on Ubuntu 16.04). I'm struggling to understand exactly what's causing it stall; what am I missing?</p> <pre><code>(xenial)chris@localhost:~$ pip install swigibpy Collecting swigibpy Using cached swigibpy-0.4.1.tar.gz Building wheels for collected packages: swigibpy Running setup.py bdist_wheel for swigibpy ... error Complete output from command /home/chris/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-162vhh_i/swigibpy/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmptqb6ctskpip-wheel- --python-tag cp35: running bdist_wheel running build running build_py creating build creating build/lib.linux-x86_64-3.5 copying swigibpy.py -&gt; build/lib.linux-x86_64-3.5 running build_ext building '_swigibpy' extension creating build/temp.linux-x86_64-3.5 creating build/temp.linux-x86_64-3.5/IB creating build/temp.linux-x86_64-3.5/IB/PosixSocketClient gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DIB_USE_STD_STRING=1 -IIB -IIB/PosixSocketClient -IIB/Shared -I/home/chris/anaconda3/include/python3.5m -c IB/PosixSocketClient/EClientSocketBase.cpp -o build/temp.linux-x86_64-3.5/IB/PosixSocketClient/EClientSocketBase.o -Wno-switch gcc: error trying to exec 'cc1plus': execvp: No such file or directory error: command 'gcc' failed with exit status 1 ---------------------------------------- Failed building wheel for swigibpy Running setup.py clean for swigibpy Failed to build swigibpy Installing collected packages: swigibpy Running setup.py install for swigibpy ... error Complete output from command /home/chris/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-162vhh_i/swigibpy/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-yv9u0wok-record/install-record.txt --single-version-externally-managed --compile: running install running build running build_py creating build creating build/lib.linux-x86_64-3.5 copying swigibpy.py -&gt; build/lib.linux-x86_64-3.5 running build_ext building '_swigibpy' extension creating build/temp.linux-x86_64-3.5 creating build/temp.linux-x86_64-3.5/IB creating build/temp.linux-x86_64-3.5/IB/PosixSocketClient gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DIB_USE_STD_STRING=1 -IIB -IIB/PosixSocketClient -IIB/Shared -I/home/chris/anaconda3/include/python3.5m -c IB/PosixSocketClient/EClientSocketBase.cpp -o build/temp.linux-x86_64-3.5/IB/PosixSocketClient/EClientSocketBase.o -Wno-switch gcc: error trying to exec 'cc1plus': execvp: No such file or directory error: command 'gcc' failed with exit status 1 ---------------------------------------- Command "/home/chris/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-162vhh_i/swigibpy/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-yv9u0wok-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-162vhh_i/swigibpy/ </code></pre>
<python><gcc>
2016-09-12 17:34:37
HQ
39,455,917
How to change Android talkback instructions for double tap and long press
<p>I have a view that has a long press action handler. I use the content description to set the message Talkback speaks when the view gets focus.</p> <p>Currently it says my content description right after getting a focus, and after a short pause says:</p> <blockquote> <p>Double tap to activate, double tap and hold for long press</p> </blockquote> <p>I want to change this message into something like</p> <blockquote> <p>Double tap to <strong>"action 1"</strong>, double tap and hold for <strong>"action 2"</strong></p> </blockquote> <p>Is there a way to do so?</p> <p>I looked into <code>onPopulateAccessibilityEvent()</code>, it gets <code>TYPE_VIEW_ACCESSIBILITY_FOCUSED</code> event, but I wasn't able to change the desired message. </p> <p>Am I missing something simple?</p>
<android><accessibility><talkback><android-a11y>
2016-09-12 17:47:02
HQ
39,456,177
Java- String Manipulation
i am struggeling slightly and ask for some idea: i would like to remove all digits at the start of a string. example: "123string67" to "string67" Just the digits at the start, not at the end or the middle maybe there is an easy regex command, if not it just can be just done by an own function many thanks for your help
<java><regex>
2016-09-12 18:03:37
LQ_EDIT
39,456,309
Using boto to invoke lambda functions how do I do so asynchronously?
<p>SO I'm using boto to invoke my lambda functions and test my backend. I want to invoke them asynchronously. I have noted that "invoke_async" is deprecated and should not be used. Instead you should use "invoke" with an InvocationType of "Event" to do the function asynchronously. </p> <p>I can't seem to figure out how to get the responses from the functions when they return though. I have tried the following: </p> <pre><code>payload3=b"""{ "latitude": 39.5732160891, "longitude": -119.672918997, "radius": 100 }""" client = boto3.client('lambda') for x in range (0, 5): response = client.invoke( FunctionName="loadSpotsAroundPoint", InvocationType='Event', Payload=payload3 ) time.sleep(15) print(json.loads(response['Payload'].read())) print("\n") </code></pre> <p>Even though I tell the code to sleep for 15 seconds, the response variable is still empty when I try and print it. If I change the invokation InvokationType to "RequestResponse" it all works fine and response variable prints, but this is synchronous. Am I missing something easy? How do i execute some code, for example print out the result, when the async invokation returns??</p> <p>Thanks.</p>
<python><amazon-web-services><boto><aws-lambda>
2016-09-12 18:13:02
HQ
39,457,205
Xcode 8 Warning: no rule to process file of type net.daringfireball.markdown for architecture x86_64
<p>I get the above warning in Xcode 8 for a CHANGELOG.md file in my cocoapod source. How do I clear it?</p>
<xcode><cocoapods><markdown><x86-64><compiler-warnings>
2016-09-12 19:14:54
HQ
39,457,305
Android testing: Waited for the root of the view hierarchy to have window focus
<p>In Android Ui testing, I want to click on a spinner item in a dialog, but it pop up with this error: </p> <pre><code>va.lang.RuntimeException: Waited for the root of the view hierarchy to have window focus and not be requesting layout for over 10 seconds. If you specified a non default root matcher, it may be picking a root that never takes focus. Otherwise, something is seriously wrong. Selected Root: Root{application-window-token=android.view.ViewRootImpl$W@2dac97c7, window-token=android.view.ViewRootImpl$W@2dac97c7, has-window-focus=false, layout-params-type=1, layout-params-string=WM.LayoutParams{(0,0)(fillxfill) sim=#10 ty=1 fl=#81810100 pfl=0x8 wanim=0x1030461 surfaceInsets=Rect(0, 0 - 0, 0) mwfl=0x0}, decor-view-string=MultiPhoneDecorView{id=-1, visibility=VISIBLE, width=1600, height=2560, has-focus=true, has-focusable=true, has-window-focus=false, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=1}} . All Roots: Root{application-window-token=android.view.ViewRootImpl$W@3c913e1, window-token=android.view.ViewRootImpl$W@21b23506, has-window-focus=true, layout-params-type=1002, layout-params-string=WM.LayoutParams{(310,600)(722x480) gr=#10000033 sim=#1 ty=1002 fl=#1860200 fmt=-3 wanim=0x10302db surfaceInsets=Rect(0, 0 - 0, 0) mwfl=0x0}, decor-view-string=PopupViewContainer{id=-1, visibility=VISIBLE, width=722, height=480, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=1}} Root{application-window-token=android.view.ViewRootImpl$W@3c913e1, window-token=android.view.ViewRootImpl$W@3c913e1, has-window-focus=false, layout-params-type=2, layout-params-string=WM.LayoutParams{(0,0)(wrapxwrap) gr=#11 sim=#20 ty=2 fl=#1800002 pfl=0x8 fmt=-3 wanim=0x1030462 surfaceInsets=Rect(0, 0 - 0, 0) mwfl=0x10}, decor-view-string=DecorView{id=-1, visibility=VISIBLE, width=1136, height=1058, has-focus=true, has-focusable=true, has-window-focus=false, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=1}} Root{application-window-token=android.view.ViewRootImpl$W@2dac97c7, window-token=android.view.ViewRootImpl$W@2dac97c7, has-window-focus=false, layout-params-type=1, layout-params-string=WM.LayoutParams{(0,0)(fillxfill) sim=#10 ty=1 fl=#81810100 pfl=0x8 wanim=0x1030461 surfaceInsets=Rect(0, 0 - 0, 0) mwfl=0x0}, decor-view-string=MultiPhoneDecorView{id=-1, visibility=VISIBLE, width=1600, height=2560, has-focus=true, has-focusable=true, has-window-focus=false, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=1}} at android.support.test.espresso.base.RootViewPicker.get(RootViewPicker.java:99) at android.support.test.espresso.ViewInteractionModule.provideRootView(ViewInteractionModule.java:69) at android.support.test.espresso.ViewInteractionModule_ProvideRootViewFactory.get(ViewInteractionModule_ProvideRootViewFactory.java:23) at android.support.test.espresso.ViewInteractionModule_ProvideRootViewFactory.get(ViewInteractionModule_ProvideRootViewFactory.java:9) at android.support.test.espresso.base.ViewFinderImpl.getView(ViewFinderImpl.java:68) at android.support.test.espresso.ViewInteraction$1.run(ViewInteraction.java:120) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:6117) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194) </code></pre> <p>I have tried </p> <pre><code>onData(allOf(is(instanceOf(String.class)),containsString("A4"))).inRoot(isPlatformPopup()).perform(click()); </code></pre> <p>and</p> <pre><code>onView(withText(containsString("A4"))).inRoot(isFocusable()).check(matches(isDisplayed())); </code></pre> <p>and</p> <pre><code>onView(withText(containsString("A4"))).inRoot(withDecorView(not(getActivity().getWindow().getDecorView()))).check(matches(isDisplayed())); </code></pre> <p>but none of them works... Can anyone tell me how to get the ralavant root please?</p>
<android><automated-tests><android-uiautomator><android-espresso>
2016-09-12 19:21:15
HQ
39,457,603
How to integrate Capistrano with Docker for deployment?
<p>I am not sure my question is relevant as I may try to mix tools (Capistrano and Docker) that should not be mixed.</p> <p>I have recently dockerized an application that is deployed with Capistrano. Docker compose is used both for development and staging environments.</p> <p>This is how my project looks like (the application files are not shown):</p> <pre><code>Capfile docker-compose.yml docker-compose.staging.yml config/ deploy.rb deploy staging.rb </code></pre> <p>The Docker Compose files creates all the necessary containers (Nginx, PHP, MongoDB, Elasticsearch, etc.) to run the app in development or staging environment (hence some specific parameters defined in <code>docker-compose.staging.yml</code>).</p> <p>The app is deployed to the staging environment with this command:</p> <pre><code>cap staging deploy </code></pre> <p>The folder architecture on the server is the one of Capistrano:</p> <pre><code>current releases 20160912150720 20160912151003 20160912153905 shared </code></pre> <p>The following command has been run in the <code>current</code> directory of the staging server to instantiate all the necessary containers to run the app:</p> <pre><code>docker-compose -f docker-compose.yml -f docker-compose.staging.yml up -d </code></pre> <p>So far so good. Things get more complicated on the next deploy: the <code>current</code> symlink will point to a new directory of the <code>releases</code> directory:</p> <ul> <li>If <code>deploy.rb</code> defines commands that need to be executed inside containers (like <code>docker-compose exec php composer install</code> for PHP), Docker tells that the containers don't exist yet (because the existing ones were created on the previous release folder).</li> <li>If a <code>docker-compose up -d</code> command is executed in the Capistrano deployment process, I get some errors because of port conflicts (the previous containers still exist).</li> </ul> <p>Do you have an idea on how to solve this issue? Should I move away from Capistrano and do something different?</p> <p>The idea would be to keep the (near) zero-downtime deployment that Capistrano offers with the flexibility of Docker containers (providing several PHP versions for various apps on the same server for instance).</p>
<docker><deployment><docker-compose><capistrano3>
2016-09-12 19:39:06
HQ
39,457,706
C++ stuck in while loop
<p>Hello I am doing a very simple while loop in C++ and I can not figure out why I am stuck in it even when the proper input is give.</p> <pre><code>string itemType = ""; while(!(itemType == "b") || !(itemType == "m") || !(itemType == "d") || !(itemType == "t") || !(itemType == "c")){ cout&lt;&lt;"Enter the item type-b,m,d,t,c:"&lt;&lt;endl; cin&gt;&gt;itemType; cout&lt;&lt;itemType&lt;&lt;endl; } cout&lt;&lt;itemType; </code></pre> <p>if someone can point out what I am over looking I'd very much appreciate it. It is suppossed to exit when b,m,d,t or c is entered.</p>
<c++>
2016-09-12 19:45:23
LQ_CLOSE
39,457,795
Cant Run Android application on eclipse
i have problem with eclipse and i hope to help me to solve it !! so, my problem is i cant run my android appliction on eclipse when i click run it show to me this form and dont have android application choise ! this is a screenshot [picture][1] [1]: http://i.stack.imgur.com/exEmo.png so, any idea to solve this problem ???? Hello ! i have problem with eclipse and i hope to help me to solve it !! so, my problem is i cant run my android appliction on eclipse when i click run it show to me this form and dont have android application choise ! this is a screenshot [picture][1] [1]: http://i.stack.imgur.com/exEmo.png so, any idea to solve this problem ????
<java><android><eclipse>
2016-09-12 19:52:52
LQ_EDIT
39,458,175
Teleprompter app in Xcode using Swift
<p>I have finished an online course in iOS development on Udemy and I'm ready to start developing my first (real) app.</p> <p>My goal is to make a teleprompter app similar to: <a href="https://itunes.apple.com/dk/app/video-teleprompter-lite/id1031079244?mt=8" rel="nofollow">https://itunes.apple.com/dk/app/video-teleprompter-lite/id1031079244?mt=8</a></p> <p>To start with, I would like to create just the moving text. I have looked at various concepts such as Core Animation, Text View, Segue from one view controller to another etc. But none of them seem to be able to display the moving text in the proper "teleprompter way". </p> <p>I would really appreciate suggestions as to how to start/which relevant concepts to look at in this context. </p>
<swift><core-animation>
2016-09-12 20:18:37
LQ_CLOSE
39,458,193
Using List/Tuple/etc. from typing vs directly referring type as list/tuple/etc
<p>What's the difference of using <code>List</code>, <code>Tuple</code>, etc. from <code>typing</code> module:</p> <pre><code>from typing import Tuple def f(points: Tuple): return map(do_stuff, points) </code></pre> <p>As opposed to referring to Python's types directly:</p> <pre><code>def f(points: tuple): return map(do_stuff, points) </code></pre> <p>And when should I use one over the other?</p>
<python><python-3.5><typing><type-hinting>
2016-09-12 20:19:59
HQ
39,458,207
iTunes Connect and Xcode 8: your app has changed to invalid binary
<p>Last week, with Xcode 7, I was able to upload without any issue. But today I am getting the message your app has changed to invalid binary.</p> <p>I have seen that now with Xcode 8 a new icon 20x20 2x and 3x is added. I added one, but still getting the error.</p> <p>Does anyone had similar problem? </p>
<xcode><binary><app-store-connect>
2016-09-12 20:20:57
HQ
39,458,679
Q: javafx fxml jdbc getting database data to ListView
<p>I'm making a program using scene builder to create UI, but I got problem how to load a database to ListView at beginning of the program, I just have no clue how to do it. I created method in Controller class, but I can run it only by button or something like this. My program looks like: <a href="http://pastebin.com/y9VCAVWF" rel="nofollow">http://pastebin.com/y9VCAVWF</a></p> <p>I would appreciate any help</p>
<java><jdbc><javafx><fxml>
2016-09-12 20:57:22
LQ_CLOSE
39,459,526
Do not understand how loop is determining how many asterix to print
I am a beginner at learning Java. I have stumbled upon a problem that I can not figure out. How is the loop in the code determining how many asterisk to print out. I keep looking at this part of the code.. asterisk < myArray[counter] Could someone please explain in the simplest of terms how this works, because every time i think of the counter, i see it as nothing but the index that it is pointing to at that time in the loop. Thank you in advance. Full code below.. public class Main { public static void main(String[] args) { int[] myArray = {12, 7, 9, 11, 23}; System.out.println("Value Distribution"); //Start of outer for loop for( int counter = 0; counter < myArray.length; counter++){ //Start of inner for loop for( int asterisk = 0; asterisk < myArray[counter]; asterisk++) System.out.print("*"); System.out.println(); }//End of outer for loop
<java>
2016-09-12 22:09:42
LQ_EDIT
39,460,182
Decode Base64 to Hexadecimal string with javascript
<p>Needing to convert a Base64 string to Hexadecimal with javascript.</p> <p>Example: </p> <pre><code>var base64Value = "oAAABTUAAg==" </code></pre> <p>Need conversion method </p> <p>Output (Decoded data (hexadecimal)) <code>A0000005350002</code></p> <p>I know this is correct because I can use this website <a href="http://tomeko.net/online_tools/base64.php?lang=en" rel="noreferrer">http://tomeko.net/online_tools/base64.php?lang=en</a></p> <p>and punch in Base64 string of <code>oAAABTUAAg==</code> and get <code>A0000005350002</code></p> <p>What have I tried? </p> <p><a href="https://github.com/carlo/jquery-base64" rel="noreferrer">https://github.com/carlo/jquery-base64</a><br> <a href="https://jsfiddle.net/gabrieleromanato/qaght/" rel="noreferrer">https://jsfiddle.net/gabrieleromanato/qaght/</a></p> <p>I have found a lot of questions </p>
<javascript><jquery><hex><base64>
2016-09-12 23:30:20
HQ
39,460,272
MAMP Pro 4 and Sophos Warning about Adminer Database Manager
<p>I have been using Sophos Anti-Virus on the Mac for several years now with good results. Recently when attempting to download the new MAMP Pro 4.x, I received a Sophos alert that the MAMP installer contains the Adminer Database Manager, which it identifies as known Adware and PUA.</p> <p>Has anyone experienced a similar warning, and is there any reason for concern about this warning?</p> <p>The only real information I can find about Adminer is this:</p> <p><a href="http://philipdowner.com/2012/01/using-adminer-with-mamp-on-mac-os-x/" rel="noreferrer">http://philipdowner.com/2012/01/using-adminer-with-mamp-on-mac-os-x/</a></p> <p>This post indicates that Adminer is some type of script designed to be an alternative to PHPMyAdmin.</p> <p>Can I just remove Adminer after installing?</p> <p>-- Lee</p>
<mamp><adminer>
2016-09-12 23:41:34
HQ
39,460,503
Javascript Syntax Error {
<p>The if statement is broken and just returns "Syntax Error {" no matter how I format it. I still get a syntax error for something on it. PS. IM PROBABLY JUST AN IDIOT</p> <pre><code>var userChoice = prompt("Do you choose rock, paper or scissors"); var computerChoice = Math.random(); console.log(computerChoice); if (computerChoice &lt; .33){ computerchoice = "rock"; } else if (computerChoice &lt; .66){ computerChoice = "paper"; } else (computerChoice &lt; 1){ computerChoice = "scissors"; } </code></pre>
<javascript>
2016-09-13 00:18:16
LQ_CLOSE
39,461,076
How to change active bootstrap tab with javascript
<p>I have tried to change the active tab and failed to use the javascript onclick element correctly. Here's the code:</p> <pre><code>&lt;ul class="nav nav-tabs" style="text-align: left;"&gt; &lt;li class="active"&gt;&lt;a href="#first" data-toggle="tab"&gt;First&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#second" data-toggle="tab"&gt;Second&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#third" data-toggle="tab"&gt;Third&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;div class=“tab-content"&gt; &lt;div id="first" class="tab-pane fade in active”&gt; Text &lt;a href="#second" class="btn btn-primary btn-lg" onclick=“CHANGE ACTIVE TAB TO SECOND” data-toggle="tab"&gt;Second&lt;/a&gt; &lt;a href="#third" class="btn btn-primary btn-lg" onclick=“CHANGE ACTIVE TAB TO THIRD” data-toggle=“tab"&gt;Third&lt;/a&gt; &lt;/div&gt; &lt;div id="second" class="tab-pane fade in”&gt; Text &lt;/div&gt; &lt;div id="third" class="tab-pane fade in”&gt; Text &lt;/div&gt; &lt;/div&gt; </code></pre> <p>How could I be able to use the buttons to change the active tab to their associated id? Please advise.</p> <p>Have a great day!</p>
<javascript><jquery><html><twitter-bootstrap>
2016-09-13 01:44:47
HQ
39,461,556
Changing state without changing browser history in angular ui-router
<p>Assume that we have a logic like this:</p> <ul> <li>From state A, change to state B.</li> <li>Whenever we arrive to state B, the app always redirect us to state C by calling <code>$state.go(stateC)</code></li> <li>Now we are in state C</li> </ul> <p>My question is how to go back to state A from state C (given the fact that state A can be any state we don't know at run-time, meaning user can access state B from any other states)</p>
<angularjs><angular-ui-router><browser-history>
2016-09-13 02:52:56
HQ
39,462,531
IOS Swift to retrieve data liner from webpage
Need help here.. my webpage displays a constructive data in a single line, specifically to let xcode to retrieve it. [{"long":"1234..45","lat":"345.12"}] this information is in a page Click here to see "www.gogrex.com/Sandbox/startloc.json" How do I retrieve it into my xcode as a JSON? I have looked thru many examples but still cannot solve it. thanks a million
<ios><swift>
2016-09-13 05:07:30
LQ_EDIT
39,462,617
Java IO: Resource file getting modified in IDE but not in jar
<p>I am successfully able to read and write to a file in eclipse. I am also able to read from a file in the jar. However, I am not able to write to the file in the jar. It is located in a class folder called res. I have also unzipped the jar file and it contains the file I need to write to but it is not modified after the first run.</p> <p>How can I do this?</p> <p>I have tried <code>BufferedWriter</code> and <code>PrintWriter</code> but no effect. I tried using<code>FileOutputStream</code> but I cannot construct it using <code>getClass().getResourceAsStream(path)</code> as it returns an <code>InputStream</code>.</p>
<java><io><outputstream>
2016-09-13 05:17:00
LQ_CLOSE
39,463,220
Does deep nesting flexbox layout cause performance issue?
<p>I have been working on a ReactJS project where I create most of the components using flexbox layout. Since with react, we can have deeply nested components, so my layout is having nested flexbox layout. </p> <p>Now my question is, does this have any issue with performance? On a single page, there are many components and each component have 3 to 4 level nested flexbox layout. Will that cause a performance issue?</p>
<css><reactjs><flexbox>
2016-09-13 06:09:01
HQ
39,463,232
Iterating over object values in JavaScript
<p>What is the most efficient / elegant way to iterate object values in JavaScript? </p> <p>As an example, assume the following object: <code>let myObj = {p1: "v1", p2: "v2"}</code></p>
<javascript>
2016-09-13 06:09:39
LQ_CLOSE
39,463,360
How do you create reusable Animations in Angular 2
<p>I'm playing with the Animation API, and I'd like to create a reusable animation like say sliding in content for top level router views. I managed to get through the funky meta data syntax (which is actually pretty cool once get past the crazy idea of using metadata) to get the animations mostly working.</p> <pre><code> @Component({ //moduleId: module.id, selector: 'album-display', templateUrl: './albumDisplay.html', animations: [ trigger('slideIn', [ state('*', style({ transform: 'translateX(100%)', })), state('in', style({ transform: 'translateX(0)', })), state('out', style({ transform: 'translateX(-100%)', })), transition('* =&gt; in', animate('600ms ease-in')), transition('in =&gt; out', animate('600ms ease-in')) ]) ] }) export class AlbumDisplay implements OnInit { slideInState = 'in'; ... } </code></pre> <p>And then assigning that to my top level element in the component:</p> <pre><code> &lt;div class="container" [@slideIn]="slideInState"&gt; </code></pre> <p>So this works, but how can I make this reusable? I don't want to stick this meta data onto every view. Since this is metadata I'm not sure how you could make this reusable.</p>
<angular><angular2-animation>
2016-09-13 06:18:51
HQ
39,463,866
Why functionss work perfectly good without return at the end
<p>I have a question related to function without return statement at the end of definition. How it works? It can return something becouse the value to return is allocated on the stack with random number when we call the func? Check the example below:</p> <pre><code>#include &lt;iostream&gt; using namespace std; int fun1(){ cout &lt;&lt; "Fun1" &lt;&lt; endl; } char fun2(){ cout &lt;&lt; "Fun2" &lt;&lt; endl; } short fun3(){ cout &lt;&lt; "Fun3" &lt;&lt; endl; } float fun4(){ cout &lt;&lt; "Fun4" &lt;&lt; endl; } double fun5(){ cout &lt;&lt; "Fun5" &lt;&lt; endl; } int main() { cout &lt;&lt; fun1() &lt;&lt; " " &lt;&lt; endl; cout &lt;&lt; fun2() &lt;&lt; " " &lt;&lt; endl; cout &lt;&lt; fun3() &lt;&lt; " " &lt;&lt; endl; cout &lt;&lt; fun4() &lt;&lt; " " &lt;&lt; endl; cout &lt;&lt; fun5() &lt;&lt; " " &lt;&lt; endl; } </code></pre>
<c++><function><return>
2016-09-13 06:53:13
LQ_CLOSE
39,464,062
Unexpected value 'DecoratorFactory' imported by the module 'TempModule'
<p>In my sample application I have written a feature module "TempModule" and below is the code.</p> <pre><code>import { NgModule } from '@angular/core'; import { CommonModule} from '@angular/common'; import { TempOneComponent } from './temp.one.component'; import { TempTwoComponent } from './temp.two.component'; import { tempRouting } from './temp.routing'; @NgModule({ declarations: [ TempOneComponent, TempTwoComponent], imports: [ NgModule, CommonModule, tempRouting] }) export class TempModule {} </code></pre> <p>I am referring to the TempModule in root module , below is the root module code</p> <pre><code>import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { FormsModule } from '@angular/forms'; //-- routing import import { routing, appRoutingProviders} from './app.routing'; //-- root component import import { AppComponent } from './app.component'; import { AppAboutComponent } from './app-about.component'; import { AppCreatTicketComponent } from './tickets/ app.create-ticket.component'; import { AppOpenTicketComponent } from './tickets/app.open-ticket.component'; import { AppSearchTicketComponent } from './tickets/ app.search-ticket.component'; import { AppDashboardComponent } from './tickets/app.dashboard.component'; import { AppUsersComponent } from './users/app.users.component'; import { TempModule } from './tempModule/temp.module'; @NgModule({ declarations: [AppComponent , AppAboutComponent , AppCreatTicketComponent, AppOpenTicketComponent, AppSearchTicketComponent, AppDashboardComponent, AppUsersComponent ], imports: [BrowserModule , FormsModule , routing, TempModule ], providers: [appRoutingProviders], bootstrap: [AppComponent] }) export class AppModule {} </code></pre> <p>When I run the application , "Unexpected value 'DecoratorFactory' imported by the module 'TempModule'" is displayed in browser console.</p> <p>Any idea what could be the reason for this error ?</p>
<angular>
2016-09-13 07:06:18
HQ
39,464,479
IndexOutOfRangeException was unhandled c#
I'm getting an error IndexOutOfRangeException was unhandled at the line " int euros = int.Parse(values[1])". My .csv file looks: name, 1, 2 name1, 3, 4 name2, 5, 6
<c#><indexoutofrangeexception><unhandled>
2016-09-13 07:31:37
LQ_EDIT
39,464,567
How do I get an imageView and textview to both fill the layout when Im setting the imageView bitmap programmatically?
What I want is for `qrcodetext` to fit and display all the text in `qrcode_layout` and have `qrimageView` to fill the rest of `qrcode_layout`? But my layout below has the entire `qrimageView` cover `qrcode_layout`. <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_height="match_parent" android:layout_width="match_parent" android:orientation="vertical" android:id="@+id/qrcodelayout"> <LinearLayout android:layout_height="wrap_content" android:layout_width="wrap_content" android:orientation="vertical"> <ImageView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/qrimageView" android:layout_gravity="center_horizontal" android:layout_marginTop="8dp" /> </LinearLayout> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/qrcodetext" android:gravity="center" android:layout_gravity="center_horizontal" android:layout_marginTop="4dp" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content"/> </LinearLayout> </RelativeLayout>
<android><android-layout>
2016-09-13 07:36:54
LQ_EDIT
39,464,597
ReplaceOne throws duplicate key exception
<p>My app receives data from a remote server and calls <code>ReplaceOne</code> to either insert new or replace existing document with a given key with <code>Upsert = true</code>. (the key is made anonymous with <code>*</code>) The code only runs in a single thread.</p> <p>However, occasionally, the app crashes with the following error:</p> <pre><code>Unhandled Exception: MongoDB.Driver.MongoWriteException: A write operation resulted in an error. E11000 duplicate key error collection: ****.orders index: _id_ dup key: { : "****-********-********-************" } ---&gt; MongoDB.Driver.MongoBulkWriteException`1[MongoDB.Bson.BsonDocument]: A bulk write operation resulted in one or more errors. E11000 duplicate key error collection: ****.orders index: _id_ dup key: { : "****-********-********-************" } at MongoDB.Driver.MongoCollectionImpl`1.BulkWrite(IEnumerable`1 requests, BulkWriteOptions options, CancellationToken cancellationToken) at MongoDB.Driver.MongoCollectionBase`1.ReplaceOne(FilterDefinition`1 filter, TDocument replacement, UpdateOptions options, CancellationToken cancellationToken) --- End of inner exception stack trace --- at MongoDB.Driver.MongoCollectionBase`1.ReplaceOne(FilterDefinition`1 filter, TDocument replacement, UpdateOptions options, CancellationToken cancellationToken) at Dashboard.Backend.AccountMonitor.ProcessOrder(OrderField&amp; order) at Dashboard.Backend.AccountMonitor.OnRtnOrder(Object sender, OrderField&amp; order) at XAPI.Callback.XApi._OnRtnOrder(IntPtr ptr1, Int32 size1) at XAPI.Callback.XApi.OnRespone(Byte type, IntPtr pApi1, IntPtr pApi2, Double double1, Double double2, IntPtr ptr1, Int32 size1, IntPtr ptr2, Int32 size2, IntPtr ptr3, Int32 size3) Aborted (core dumped) </code></pre> <p>My question is, why is it possible to have dup key when I use <code>ReplaceOne</code> with <code>Upsert = true</code> options?</p> <p>The app is working in the following environment and runtime:</p> <pre><code>.NET Command Line Tools (1.0.0-preview2-003121) Product Information: Version: 1.0.0-preview2-003121 Commit SHA-1 hash: 1e9d529bc5 Runtime Environment: OS Name: ubuntu OS Version: 16.04 OS Platform: Linux RID: ubuntu.16.04-x64 </code></pre> <p>And <code>MongoDB.Driver 2.3.0-rc1</code>.</p>
<mongodb><mongodb-.net-driver>
2016-09-13 07:38:34
HQ
39,464,834
Anyone knows of a good tutorial on using gtk2+ with opengl?
I am writing a C program that makes use of fixed pipeline opengl and freeglut. However, I would like to use a complete toolkit like GTK+ instead of freeglut. I cannot use GTK3+ as it is not compatible with old opengl code, so I would like to use gtk2+. Howver I cannot find any tutorials on combining gtk2+ with opengl. Anyone knows of any good tutorials on gtk2+ plus old opengl?
<c><opengl><gtk>
2016-09-13 07:52:57
LQ_EDIT
39,465,953
how to make interrupt every 6hrs
<p>For my data logger project , I must store temperature values at every 6 hrs. I observe that ticker maximum time is 30 mins. Is there any way we can make interrupt at long duaration like 6hrs or 10hrs??.</p> <p>thank you.</p>
<c++><c><embedded><mbed>
2016-09-13 08:55:23
LQ_CLOSE
39,465,990
How to write integration tests with spring-cloud-netflix and feign
<p>I use Spring-Cloud-Netflix for communication between micro services. Let's say I have two services, Foo and Bar, and Foo consumes one of Bar's REST endpoints. I use an interface annotated with <code>@FeignClient</code>:</p> <pre><code>@FeignClient public interface BarClient { @RequestMapping(value = "/some/url", method = "POST") void bazzle(@RequestBody BazzleRequest); } </code></pre> <p>Then I have a service class <code>SomeService</code> in Foo, which calls the <code>BarClient</code>.</p> <pre><code>@Component public class SomeService { @Autowired BarClient barClient; public String doSomething() { try { barClient.bazzle(new BazzleRequest(...)); return "so bazzle my eyes dazzle"; } catch(FeignException e) { return "Not bazzle today!"; } } } </code></pre> <p>Now, to make sure the communication between services works, I want to build a test that fires a real HTTP request against a fake Bar server, using something like WireMock. The test should make sure that feign correctly decodes the service response and reports it to <code>SomeService</code>.</p> <pre><code>public class SomeServiceIntegrationTest { @Autowired SomeService someService; @Test public void shouldSucceed() { stubFor(get(urlEqualTo("/some/url")) .willReturn(aResponse() .withStatus(204); String result = someService.doSomething(); assertThat(result, is("so bazzle my eyes dazzle")); } @Test public void shouldFail() { stubFor(get(urlEqualTo("/some/url")) .willReturn(aResponse() .withStatus(404); String result = someService.doSomething(); assertThat(result, is("Not bazzle today!")); } } </code></pre> <p>How can I inject such a WireMock server into eureka, so that feign is able to find it and communicate with it? What kind of annotation magic do I need?</p>
<java><netflix-eureka><spring-cloud-netflix><wiremock><feign>
2016-09-13 08:57:25
HQ
39,466,462
Git commit lost after merge
<p>We have 3 branches (A, B, C) as below:</p> <pre><code>---\--A1--\------Am------Merge1---An---Merge2--- \ \ / / \ \--C1---C2---/ / \ / \--B1--------------Bn---------/ </code></pre> <p>The problem appears at Merge2. Some commit on branch C ( <strong>not all but some</strong>, let's say C2) is lost on branch A after Merge2, which is present between Merge1 and Merge2.</p> <p>When doing Merge2, there is only one file conflict, which not relates to the lost commit (C2). And we resolve the confilict and finish the merge successfully.</p> <p><strong>It seems like C2 is reversed by Merge2 on branch A, without any log.</strong></p> <p>What happened? What might be the cause to this situation?</p>
<git>
2016-09-13 09:22:21
HQ
39,466,785
JAVASCRIPT (HELP)
Can you help me, please ( function getChar that takes 1 parameter - an array of words. I must concatenate the nth letter from each word which should be returned as a string( for example : getChar(["javascript", "is cool", "123"]). returned value js3) what"S wrong? function getChar(arr) { return arr.mao(function(v,i,a){ return v[i];}).join(" "); }
<javascript><arrays><string><helpers>
2016-09-13 09:39:11
LQ_EDIT