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,834,405
What is the Play 2.5.x equivalent to acceptWithActor[String, JsValue]?
<p>Before I migrated to Play 2.5.x I used <code>WebSocket.acceptWithActor</code> frequently. Now I can't get my web sockets to stay open when using different input and output, in my case, input is String, output is JsValue.</p> <p>My receiver before Play 2.5.x:</p> <pre><code>object Application extends Controller { def myWebSocket = WebSocket.acceptWithActor[String, JsValue] { request =&gt; out =&gt; MyActor.props(out) } </code></pre> <p>My receiver in Play 2.5.x:</p> <pre><code>@Singleton class Application @Inject() (implicit system: ActorSystem, materializer: Materializer) extends Controller { implicit val messageFlowTransformer = MessageFlowTransformer.jsonMessageFlowTransformer[String, JsValue] def myWebSocket = WebSocket.accept[String, JsValue] { request =&gt; ActorFlow.actorRef(out =&gt; MyActor.props(out)) } } </code></pre> <p>In my actor <code>preStart</code> is called immediately followed by <code>postStop</code>, so this is obviously incorrect, but I can't seem to find any solution in the documentation (<a href="https://www.playframework.com/documentation/2.5.x/ScalaWebSockets" rel="noreferrer">https://www.playframework.com/documentation/2.5.x/ScalaWebSockets</a>). If I use <code>WebSocket.accept[String, String]</code> the socket stays open.</p> <p>What am I doing wrong?</p>
<scala><playframework><akka>
2016-10-03 14:48:05
HQ
39,834,449
Showing/hiding unlimited number of divs based on time
I have this simple JavaScript yet: $("body").children("div").each( function( ) { $(this).hide(); }); The goal is: - hide every direct children divs (completed :) - show first direct children div - hide that first div, show second - hide that second div, show third etc. - no matter how many divs there is it - time for how long div stays displayed bassed on variable How can I do that?
<javascript><jquery><html><list>
2016-10-03 14:50:25
LQ_EDIT
39,834,698
Emit an event when a specific piece of state changes in vuex store
<p>I have a vuex store with the following state:</p> <pre><code>state: { authed: false ,id: false } </code></pre> <p>Inside a component I want to watch for changes to the <code>authed</code> state and send an AJAX call to the server. It needs to be done in various components.</p> <p>I tried using <code>store.watch()</code>, but that fires when either <code>id</code> or <code>authed</code> changes. I also noticed, it's different from <code>vm.$watch</code> in that you can't specify a property. When i tried to do this:</p> <pre><code>store.watch('authed',function(newValue,oldValue){ //some code }); </code></pre> <p>I got this error:</p> <p><code>[vuex] store.watch only accepts a function.</code></p> <p>Any help is appreciated!</p>
<vue.js><vuex>
2016-10-03 15:03:52
HQ
39,834,758
Regex exclude &#
<p>How to determine that string doesn't contain both symbols &amp;# together using regular expression ?</p>
<regex>
2016-10-03 15:07:21
LQ_CLOSE
39,835,021
Pandas random sample with remove
<p>I'm aware of <code>DataFrame.sample()</code>, but how can I do this and also remove the sample from the dataset? (<em>Note: AFAIK this has nothing to do with sampling with replacement</em>)</p> <p>For example here is <strong>the essence</strong> of what I want to achieve, this does not actually work:</p> <pre><code>len(df) # 1000 df_subset = df.sample(300) len(df_subset) # 300 df = df.remove(df_subset) len(df) # 700 </code></pre>
<python><pandas>
2016-10-03 15:20:13
HQ
39,835,549
Uses of a Virtual destructor in C++(other than desctruction order correctness)
<p>Every C++ programmer knows that, virtual destructor is used to ensure the proper destruction order of objects in inheritance hierarchy.</p> <p>Where else "Virtual Destructors" are used/can be used in realtime scenarios?</p>
<c++><virtual><virtual-destructor>
2016-10-03 15:49:15
LQ_CLOSE
39,835,555
python : convert the key of a dictionnary into a string
I would like to convert the keys of my dictionary as strings to print the title of my plot and to setup a path... I tried str(key) but it didn't worked... dicohist = { 'Cost': df.costcheck1, 'Cost2': df.costcheck2,} for key in dicohist: histo = Series.hist(dicohist[key],bins=300) histo.set_xlabel("cost in dol") histo.set_ylabel("number of subject") histo.set_title(key) fig = histo.get_figure() fig.savefig('/path/%s.png'%(key))
<python><string><dictionary>
2016-10-03 15:49:30
LQ_EDIT
39,835,650
How do you get the HTTP host with Laravel 5
<p>I'm trying to get the hostname from an HTTP request using Laravel 5, including the subdomain (e.g., <code>dev.site.com</code>). I can't find anything about this in <a href="https://laravel.com/docs/5.3/requests#request-path-and-method" rel="noreferrer">the docs</a>, but I would think that should be pretty simple. Anyone know how to do this?</p>
<php><laravel><http><laravel-5>
2016-10-03 15:54:51
HQ
39,835,855
Location of the Nginx default index.html file on MAC OS
<p><a href="https://i.stack.imgur.com/k3gGi.png" rel="noreferrer"><img src="https://i.stack.imgur.com/k3gGi.png" alt="enter image description here"></a></p> <p>I have successfully installed nginx on my MAC with homebrew</p> <pre><code>brew install nginx </code></pre> <p>but i can't find from where is this default page called.</p> <p>In nginx.conf under location says</p> <pre><code>root html; </code></pre> <p>and i can't find it. Please help.</p>
<macos><nginx>
2016-10-03 16:06:45
HQ
39,837,058
UITextChecker with Swift 3
<p>I'm trying to make use of Apple's UITextChecker in Xcode 8 to automatically search for spelling errors in a string of words and give suggestions as to replacements. I'm relatively new to referencing Apple API's so any help would be appreciated.</p> <p>Thanks!</p>
<ios><swift><xcode><swift3><xcode8>
2016-10-03 17:22:54
LQ_CLOSE
39,837,246
Is it safe to show the AWS cognito pool ID in my html?
<p>I am building a serverless website with AWS Cognito, Lambda, S3 and a dozen more of their services. My HTML/JS in my login page has the cognito pool ID. How safe is this? I know that it is best practise to hide sensitive stuff. But this is not client-server. Its all client if im honest. I do access some sensitive data via a lambda call. But even this call requires some plain-text sensitive inputs like the user ID. </p> <pre><code> &lt;script src="https://sdk.amazonaws.com/js/aws-sdk-2.3.7.min.js"&gt; &lt;/script&gt; &lt;script&gt; AWS.config.region = 'XX-XXXX-1'; AWS.config.credentials = new AWS.CognitoIdentityCredentials({ IdentityPoolId: 'XX-XXXX-1:XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX' }); var lambda = new AWS.Lambda(); &lt;/script&gt; </code></pre> <p>I really dont like the poolID visible. An attacker can copy this and brute force my cognito IDs. Any ideas to hide it?</p>
<amazon-web-services><amazon-s3><aws-lambda><aws-sdk><amazon-cognito>
2016-10-03 17:33:00
HQ
39,837,678
Why no Array.prototype.flatMap in javascript?
<p><code>flatMap</code> is incredibly useful on collections, but javascript does not provide one while having <code>Array.prototype.map</code>. Why?</p> <p>Is there any way to emulate <code>flatMap</code> in javascript in both easy and efficient way w/o defining <code>flatMap</code> manually?</p>
<javascript><functional-programming>
2016-10-03 18:00:35
HQ
39,838,735
@CreationTimestamp and @UpdateTimestamp
<p>This is my blog class </p> <pre><code>@Entity @Component @Table public class Blog implements Serializable { /** * */ private static final long serialVersionUID = 1L; @Id private String id; private String name; private String Description; @CreationTimestamp private Date createdOn; @UpdateTimestamp private Date updatedOn; public String getId() { return id; } public void setId(String id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getDescription() { return Description; } public void setDescription(String description) { Description = description; } public Date getCreatedOn() { return createdOn; } public void setCreatedOn(Date createdOn) { this.createdOn = createdOn; } public Date getUpdatedOn() { return updatedOn; } public void setUpdatedOn(Date updatedOn) { this.updatedOn = updatedOn; } } </code></pre> <p>timestamps createdOn and updatedOn are stored successfully when new blog is created but when existing blog is updated updatedOn field is updated whereas createdOn field becomes null. I want createdOn field to retain the timestamp on which it is created. Can someone help out ?</p>
<hibernate><jpa><annotations>
2016-10-03 19:09:15
HQ
39,838,751
Printing all the integers from 0 to n in in descending order order using recursive method
<p>I made a little program to practice recursions, but I can't get it to work as intended as you can see. In its current state, the program kinda works but not like I want it to. </p> <p>What I am looking for is to print values from int N to 0 in descending order rather than from 10 to N as it is currently in the code.</p> <pre><code>private static void DescendingRecursion(int n) { if (n == 10) // Base case return; else { DescendingRecursion(n + 1); Console.Write(n + " "); } } static void Main(string[] args) { DescendingRecursion(0); } </code></pre> <p>(output: 9 8 7 6 5 4 3 2 1 0)</p>
<recursion>
2016-10-03 19:10:24
LQ_CLOSE
39,839,001
Does the "new" Facebook Marketplace have a listing API?
<p>Facebook recently launched a slightly better, and certainly more prominent, Marketplace to sell goods locally. Is there an API for adding listings or does anyone know if there will be an API?</p>
<facebook>
2016-10-03 19:27:30
HQ
39,839,051
Using redux-form I'm losing focus after typing the first character
<p>I'm using <code>redux-form</code> and on blur validation. After I type the first character into an input element, it loses focus and I have to click in it again to continue typing. It only does this with the first character. Subsequent characters types remains focuses. Here's my basic sign in form example:</p> <pre><code>import React, { Component } from 'react'; import { connect } from 'react-redux'; import { Field, reduxForm } from 'redux-form'; import * as actions from '../actions/authActions'; require('../../styles/signin.scss'); class SignIn extends Component { handleFormSubmit({ email, password }) { this.props.signinUser({ email, password }, this.props.location); } renderAlert() { if (this.props.errorMessage) { return ( &lt;div className="alert alert-danger"&gt; {this.props.errorMessage} &lt;/div&gt; ); } else if (this.props.location.query.error) { return ( &lt;div className="alert alert-danger"&gt; Authorization required! &lt;/div&gt; ); } } render() { const { message, handleSubmit, prestine, reset, submitting } = this.props; const renderField = ({ input, label, type, meta: { touched, invalid, error } }) =&gt; ( &lt;div class={`form-group ${touched &amp;&amp; invalid ? 'has-error' : ''}`}&gt; &lt;label for={label} className="sr-only"&gt;{label}&lt;/label&gt; &lt;input {...input} placeholder={label} type={type} className="form-control" /&gt; &lt;div class="text-danger"&gt; {touched ? error: ''} &lt;/div&gt; &lt;/div&gt; ); return ( &lt;div className="row"&gt; &lt;div className="col-md-4 col-md-offset-4"&gt; &lt;form onSubmit={handleSubmit(this.handleFormSubmit.bind(this))} className="form-signin"&gt; &lt;h2 className="form-signin-heading"&gt; Please sign in &lt;/h2&gt; {this.renderAlert()} &lt;Field name="email" type="text" component={renderField} label="Email Address" /&gt; &lt;Field name="password" type="password" component={renderField} label="Password" /&gt; &lt;button action="submit" className="btn btn-lg btn-primary btn-block"&gt;Sign In&lt;/button&gt; &lt;/form&gt; &lt;/div&gt; &lt;/div&gt; ); } } function validate(values) { const errors = {}; if (!values.email) { errors.email = 'Enter a username'; } if (!values.password) { errors.password = 'Enter a password' } return errors; } function mapStateToProps(state) { return { errorMessage: state.auth.error } } SignIn = reduxForm({ form: 'signin', validate: validate })(SignIn); export default connect(mapStateToProps, actions)(SignIn); </code></pre>
<validation><reactjs><redux><redux-form>
2016-10-03 19:31:02
HQ
39,839,123
How to add js and css files in ASP.net Core?
<p>I've been assigned to migrate an application from MVC into ASP.net Core, I'm new to ASP.net Core. In MVC we have <code>BundleConfig.cs</code> and in there we add references to our css and js files, how does it work in ASP.net Core? Let's say that I created a <code>test.js</code> and a <code>MyStyle.css</code> class, which is the best way to add references to it in every view? Should I place the <code>.js</code> and <code>.css</code> files inside <code>wwwroot/js</code> and <code>wwwroot/css</code>?</p>
<c#><jquery><css><asp.net-mvc><asp.net-core-mvc>
2016-10-03 19:35:44
HQ
39,839,542
Why isn't this "if statement" working?
<p>I have built a weather app that works perfectly. I decided to add in icons that change with the weather id variable from an API which has been assigned. It works for the first id in the if statement, but when I add else if statements inside it don't work for the else if parts here is my code: </p> <pre><code> //weather icons check if(weatherId=800){ $('#type').css('background-image', 'url(http://publicdomainvectors.org/photos/weather-clear.png)'); } else if(weatherId&gt;=801 &amp;&amp; weatherId&lt;=804){ $('#type').css('background-image','url(http://publicdomainvectors.org/tn_img/stylized_basic_cloud.png)'); } else if(weatherId&gt;=300 &amp;&amp; weatherId&lt;=531){ $('#type').css('background-image','url(http://publicdomainvectors.org/tn_img/sivvus_weather_symbols_4.png)'); } </code></pre> <p>am I missing something in this statement??? </p>
<javascript><jquery><if-statement><range>
2016-10-03 20:04:43
LQ_CLOSE
39,839,584
C Compiling Error while printing
I am a noob at C. My code: #include <stdio.h> int main() { int M, N, O, P; printf("Enter the value of M\n"); scanf("%d", &M); N = 3*M^2; O = M + N; P = M + M; printf("The value of %d \n", M + %d \n", M equals %d \n", P %d \n", N %d \n", O); return 0; } The error: > test.c: In function 'main': > test.c:9: error: expected expression before '%' token > test.c:9: error: stray '\' in program > test.c:9: error: stray '\' in program I can't figure out how to properly print the values of M,N,O,P and test alongside with it. And have been searching for a while too. Please let me know if you see the problem. Thanks. Shahriar
<c>
2016-10-03 20:07:23
LQ_EDIT
39,839,737
Add an anchor to Laravel redirect back
<p>In a Laravel controller I have this redirect:</p> <pre><code> return redirect()-&gt;back(); </code></pre> <p>Which returns me to my previous page (say <a href="http://domain/page" rel="noreferrer">http://domain/page</a>). However, I want to make the page jump to a particular anchor (say #section). So ultimately this page should be opened: <a href="http://domain/page#section" rel="noreferrer">http://domain/page#section</a>. How can I make this happen? I tried appending the anchor to the redirect but that doesn't work. </p>
<php><laravel><redirect>
2016-10-03 20:18:45
HQ
39,839,764
Sublime Text 3, how to add to right click?
<p>How do I add Sublime Text just like how Edit with Notepad++ is there it's nothing big but it saves time.</p> <p><a href="https://i.stack.imgur.com/mGOPJ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/mGOPJ.png" alt="enter image description here"></a></p>
<sublimetext3>
2016-10-03 20:20:19
HQ
39,839,770
Make flex element ignore child element
<p>Is it possible to make a flex element ignore a child element so it's size does not affect the other elements?</p> <p>For example, I have a wrapper with <code>display: flex</code>. It has a header, content, and footer.</p> <pre><code>&lt;div class="wrapper"&gt; &lt;header&gt;&lt;/header&gt; &lt;article&gt;&lt;/article&gt; &lt;footer&gt;&lt;/footer&gt; &lt;/div&gt; </code></pre> <p>I want the wrapper to ignore the header tag (the header will be fixed to the top of the window). The article will be set to <code>flex: 1</code> so it takes up the rest of the space, forcing the footer to the bottom of the page. Here is some sample CSS:</p> <pre><code>.wrapper { display: flex; flex-direction: column; height: 100%; padding-top: 50px; /* Accounts for header */ } header { height: 50px; position: fixed; top: 0; width: 100%; } article { flex: 1; } footer { height: 50px; } </code></pre> <p>I know I could just move the header outside of the wrapper but I have a lot of existing code that will make that a bit more difficult. Is what I am asking even possible?</p>
<css><html><flexbox>
2016-10-03 20:20:33
HQ
39,841,607
What permission is required to create a Service Hook in Visual Studio Team Services?
<p>In Visual Studio Team Services on the tab for "Service Hooks", some of our project team members get an message that says "You do not have sufficient permissions to view or configure subscriptions." </p> <p>What permission or group do they need to be assigned in order to create a Service Hook for a given project?</p>
<azure-devops>
2016-10-03 22:47:09
HQ
39,842,013
Fetch post with body data not working params empty
<p>I am trying to rewrite my ajax call to fetch:</p> <p>Ajax:</p> <pre><code> $.post({ context: this, url: "/api/v1/users", data: { user: { email: email, password: password } } }).done((user) =&gt; { }).fail((error) =&gt; { }) </code></pre> <p>Fetch:</p> <pre><code> fetch('/api/v1/users', { method: 'POST', headers: { "Content-Type": "application/json" }, body: { "user" : { "email" : email, "password" : password } } }) .then(res =&gt; { if (res.status !== 200) { { console.log("error") }) } else { res.json().then(data =&gt; { console.log(data) }) } }) </code></pre> <p>I am getting an error empty params ~ bad request from my server.</p> <p>I also found this way to do it, but in this code below I am getting an error: Unexpected token.</p> <pre><code> var payload = { "user" : { "email" : email, "password" : password } }; var data = new FormData(); data.append( "json", JSON.stringify( payload ) ); fetch('/api/v1/users', { method: 'POST', headers: { "Content-Type": "application/json" }, body: data }) </code></pre> <p>How can I rewrite the ajax request to fetch?</p>
<ajax><fetch>
2016-10-03 23:34:27
HQ
39,842,181
Problems with Uploading Script
<p>I have a simple script that can upload files on my server and insert the details into database.</p> <p>With code below I am getting two errors..</p> <ol> <li><p>"Notice: Undefined variable: sExt in" .. I tried to fix the issue with if empty statement, but without sucess..</p></li> <li><p>Script import numbers (1,2,3...) into Mysql if the upload filed is empty.... I tried to fix the issue with the code below, but also without success..</p> <p>"if($_FILES['files']['name']!="")"...</p></li> </ol> <p>Any advice? </p> <p>Thank you..</p> <p>My code:</p> <pre><code>&lt;?php include_once('db.php'); if (isset($_FILES['files'])) { $uploadedFiles = array(); foreach ($_FILES['files']['tmp_name'] as $key =&gt; $tmp_name) { $errors = array(); $file_name = md5(uniqid("") . time()); $file_size = $_FILES['files']['size'][$key]; $file_tmp = $_FILES['files']['tmp_name'][$key]; $file_type = $_FILES['files']['type'][$key]; if($file_type == "image/gif"){ $sExt = ".gif"; } elseif($file_type == "image/jpeg" || $file_type == "image/pjpeg"){ $sExt = ".jpg"; } elseif($file_type == "image/png" || $file_type == "image/x-png"){ $sExt = ".png"; } if (!in_array($sExt, array('.gif','.jpg','.png'))) { $errors[] = "Image types alowed are (.gif, .jpg, .png) only!"; } if ($file_size &gt; 2097152000) { $errors[] = 'File size must be less than 2 MB'; } $query = "INSERT into user_pics (`person_id`,`pic_name`,`pic_type`) VALUES('1','$file_name','$sExt')"; $result = mysqli_query($link,$query); $desired_dir = "user_data/"; if (empty($errors)) { if (is_dir($desired_dir) == false) { mkdir("$desired_dir", 0700); } if (move_uploaded_file($file_tmp, "$desired_dir/" . $file_name . $sExt)) { $uploadedFiles[$key] = array($file_name . $sExt, 1); } else { echo "Files Uploaded !" . $_FILES['files']['name'][$key]; $uploadedFiles[$key] = array($_FILES['files']['name'][$key], 0); } } else { print_r($errors); } } foreach ($uploadedFiles as $key =&gt; $row) { if (!empty($row[1])) { $codestr = '$file' . ($key+1) . ' = $row[0];'; eval ($codestr); } else { $codestr = '$file' . ($key+1) . ' = NULL;'; eval ($codestr); } } } ?&gt; &lt;form action="" method="POST" enctype="multipart/form-data"&gt; &lt;input type="file" name="files[]" accept="image/*"&gt; &lt;br/&gt; &lt;input type="file" name="files[]" accept="image/*"&gt; &lt;br/&gt;&lt;br/&gt; &lt;input type="submit"/&gt; &lt;/form&gt; </code></pre>
<php><mysql>
2016-10-03 23:51:45
LQ_CLOSE
39,842,324
whats the correct way of inserting label in an Ionic FAB list
<p>i want to insert a label so that matches every FAB icon on the Fab list whats the correct way of doing it. the way i did it it doesn't work</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;ion-fab left middle&gt; &lt;button ion-fab color="dark"&gt; &lt;ion-icon name="arrow-dropup"&gt;&lt;/ion-icon&gt; &lt;ion-label&gt;here&lt;/ion-label&gt; &lt;/button&gt; &lt;ion-fab-list side="top"&gt; &lt;button ion-fab&gt; &lt;ion-icon name="logo-facebook"&gt;&lt;/ion-icon&gt; &lt;ion-label&gt;here&lt;/ion-label&gt; &lt;/button&gt; &lt;button ion-fab&gt; &lt;ion-icon name="logo-twitter"&gt;&lt;/ion-icon&gt; &lt;/button&gt; &lt;button ion-fab&gt; &lt;ion-icon name="logo-vimeo"&gt;&lt;/ion-icon&gt; &lt;/button&gt; &lt;button ion-fab&gt; &lt;ion-icon name="logo-googleplus"&gt;&lt;/ion-icon&gt; &lt;/button&gt; &lt;/ion-fab-list&gt; &lt;/ion-fab&gt;</code></pre> </div> </div> </p>
<ionic-framework><ionic2><ionic-view>
2016-10-04 00:11:28
HQ
39,843,904
How to increase padding or margin between menu item icon and title in app toolbar?
<p>I'm having a problem with an item in my action bar: <a href="https://i.stack.imgur.com/4VqOR.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4VqOR.png" alt="enter image description here"></a></p> <p>The refresh icon is too close to the title "REFRESH". It looks awkward.</p> <p>I am aware that one approach to fix this it to edit the image to forcibly add padding to it, or wrap it in an XML drawable that does so.</p> <p>It seems like I should not have to add space in the image itself to fix this. I feel that there should be an easy way to change a padding or margin attribute to fix the problem. I'm surprised they are so close together here.</p> <p>Any ideas?</p>
<android><android-layout>
2016-10-04 03:54:25
HQ
39,845,526
How to serve an angular2 app in a node.js server
<p>I'm building a web app using Angular2, to create the project I'm using Angular2 CLI webpack. Angular2 app uses other external packages also (Eg: Firebase). In addition to that, I need to create a REST API running on node.js</p> <p>How can I serve both of Angular2 app and REST API using node.js server</p>
<node.js><angular><angular2-cli>
2016-10-04 06:29:29
HQ
39,845,764
SQL(Need to print all the duplicate value ID's)
Empid----Name 1 aa 2 bb 3 cc 4 aa 5 bb I need to get output to print EmpId number for which name's are repeated output Required: 1,2,4,5. Thanks in advance
<sql>
2016-10-04 06:43:25
LQ_EDIT
39,846,649
How to use Let's Encrypt with Docker container based on the Node.js image
<p>I am running an <a href="http://expressjs.com/" rel="noreferrer">Express</a>-based website in a Docker container based on the <a href="https://hub.docker.com/_/node/" rel="noreferrer">Node.js image</a>. How do I use <a href="https://letsencrypt.org/" rel="noreferrer">Let's Encrypt</a> with a container based on that image?</p>
<node.js><docker><https><lets-encrypt>
2016-10-04 07:33:45
HQ
39,847,019
HttpUrlConnection setting Range in Android is ignored
<p>I'm trying get a 206 response from my server using Android.</p> <p><strong>Here's the code.</strong></p> <pre><code>@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_splash); new AsyncTask&lt;Void, Void, Void&gt;() { @Override protected Void doInBackground(Void... params) { try { URL url = new URL("http://aviddapp.com/10mb.file"); HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); urlConnection.setRequestProperty("Range", "bytes=1-2"); urlConnection.connect(); System.out.println("Response Code: " + urlConnection.getResponseCode()); System.out.println("Content-Length: " + urlConnection.getContentLength()); Map&lt;String, List&lt;String&gt;&gt; map = urlConnection.getHeaderFields(); for (Map.Entry&lt;String, List&lt;String&gt;&gt; entry : map.entrySet()) { System.out.println("Key : " + entry.getKey() + " ,Value : " + entry.getValue()); } InputStream inputStream = urlConnection.getInputStream(); long size = 0; while(inputStream.read() != -1 ) size++; System.out.println("Downloaded Size: " + size); }catch(MalformedURLException mue) { mue.printStackTrace(); }catch(IOException ioe) { ioe.printStackTrace(); } return null; } }.execute(); } </code></pre> <p>Here's the output:</p> <pre><code>I/System.out: Respnse Code: 200 I/System.out: Content-Length: -1 I/System.out: Key : null ,Value : [HTTP/1.1 200 OK] I/System.out: Key : Accept-Ranges ,Value : [bytes] I/System.out: Key : Cache-Control ,Value : [max-age=604800, public] I/System.out: Key : Connection ,Value : [Keep-Alive] I/System.out: Key : Date ,Value : [Tue, 04 Oct 2016 07:45:22 GMT] I/System.out: Key : ETag ,Value : ["a00000-53e051f279680-gzip"] I/System.out: Key : Expires ,Value : [Tue, 11 Oct 2016 07:45:22 GMT] I/System.out: Key : Keep-Alive ,Value : [timeout=5, max=100] I/System.out: Key : Last-Modified ,Value : [Tue, 04 Oct 2016 07:36:42 GMT] I/System.out: Key : Server ,Value : [Apache/2.4.12 (Unix) OpenSSL/1.0.1e-fips mod_bwlimited/1.4] I/System.out: Key : Transfer-Encoding ,Value : [chunked] I/System.out: Key : Vary ,Value : [Accept-Encoding,User-Agent] I/System.out: Key : X-Android-Received-Millis ,Value : [1475567127403] I/System.out: Key : X-Android-Response-Source ,Value : [NETWORK 200] I/System.out: Key : X-Android-Sent-Millis ,Value : [1475567127183] I/System.out: Downloaded Size: 10485760 </code></pre> <p><strong>Now I'm doing the same thing is pure java.</strong></p> <pre><code>public static void main(String... args) { try { URL url = new URL("http://aviddapp.com/10mb.file"); HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); urlConnection.setRequestProperty("Range", "bytes=1-2"); urlConnection.connect(); System.out.println("Respnse Code: " + urlConnection.getResponseCode()); System.out.println("Content-Length: " + urlConnection.getContentLength()); Map&lt;String, List&lt;String&gt;&gt; map = urlConnection.getHeaderFields(); for (Map.Entry&lt;String, List&lt;String&gt;&gt; entry : map.entrySet()) { System.out.println("Key : " + entry.getKey() + " ,Value : " + entry.getValue()); } InputStream inputStream = urlConnection.getInputStream(); long size = 0; while(inputStream.read() != -1 ) size++; System.out.println("Downloaded Size: " + size); }catch(MalformedURLException mue) { mue.printStackTrace(); }catch(IOException ioe) { ioe.printStackTrace(); } } </code></pre> <p><strong>Here's the output</strong></p> <pre><code>Respnse Code: 206 Content-Length: 2 Key : Keep-Alive ,Value : [timeout=5, max=100] Key : null ,Value : [HTTP/1.1 206 Partial Content] Key : Server ,Value : [Apache/2.4.12 (Unix) OpenSSL/1.0.1e-fips mod_bwlimited/1.4] Key : Content-Range ,Value : [bytes 1-2/10485760] Key : Connection ,Value : [Keep-Alive] Key : Last-Modified ,Value : [Tue, 04 Oct 2016 07:36:42 GMT] Key : Date ,Value : [Tue, 04 Oct 2016 07:42:17 GMT] Key : Accept-Ranges ,Value : [bytes] Key : Cache-Control ,Value : [max-age=604800, public] Key : ETag ,Value : ["a00000-53e051f279680"] Key : Vary ,Value : [Accept-Encoding,User-Agent] Key : Expires ,Value : [Tue, 11 Oct 2016 07:42:17 GMT] Key : Content-Length ,Value : [2] Downloaded Size: 2 </code></pre> <p>As you can see I'm getting diffrent response codes in both cases. It seems like Android is not passing <code>Range</code> to the server maybe? What's happening here?</p> <p><em>PS: I'm getting a 206 if the file size is 1mb.</em></p>
<java><android><httpurlconnection>
2016-10-04 07:54:35
HQ
39,847,884
Can I get PyCharm to suppress a particular warning on a single line?
<p>PyCharm provides some helpful warnings on code style, conventions and logical gotchas. It also provides a notification if I try to commit code with warnings (or errors).</p> <p>Sometimes I consciously ignore these warnings for particular lines of code (for various reasons, typically to account for implementation details of third-party libraries). I want to suppress the warning, but just for that line (if the warning crops up on a different line where I'm not being deliberate, I want to know about it!)</p> <p>How can I do that in PyCharm? (Following a universal Python convention strongly preferable.)</p>
<python><pycharm><compiler-warnings><suppress-warnings>
2016-10-04 08:45:31
HQ
39,847,962
jQuery click() - not working more than once
Beginner stuff :) I want to add auto-scrolling to header images here: https://listify-demos.astoundify.com/classic/listing/the-drake-hotel/ So `document.querySelector('.slick-next').click();` can do the click and I'm trying to get it working in a loop. Running the following in JS console: function myscroller() { document.querySelector('.slick-next').click(); } for (var i = 1; i < 10; ++i) { myscroller(); } I thought it's supposed to click the next button 10 times, but it clicks it only once. What's that I'm missing?
<javascript><wordpress>
2016-10-04 08:50:00
LQ_EDIT
39,848,550
How to cancel DispatchQueue.main.asyncAfter(deadline: time) in Swift3?
<h2>Description:</h2> <p>I'm currently using the following code to see if the user has stopped typing in the searchBar. I would like to cancel it everytime the user immediately starts typing after <code>0.5</code> seconds. </p> <p><strong>Code:</strong></p> <pre><code>DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { // your function here } </code></pre> <h2>Question:</h2> <p>How do I cancel <code>DispatchQueue.main.asyncAfter</code> if the user starts typing again in <code>Swift3</code> ?</p> <h2>What I've tried:</h2> <p>I previously tried implementing :</p> <pre><code>NSObject.cancelPreviousPerformRequests(withTarget: self) self.perform(Selector(("searchForText:")), with: searchString, afterDelay: 0.5) </code></pre> <p>However the delay does not seem to work properly. </p> <p><strong>More code:</strong></p> <pre><code>//In class SearchViewController: UITableViewController, UISearchResultsUpdating func updateSearchResults(for searchController: UISearchController) { let searchString: String = searchController.searchBar.text! //This is what I previously tried.. which doesn't work... //NSObject.cancelPreviousPerformRequests(withTarget: self) //self.perform(Selector(("searchForText:")), with: searchString, afterDelay: 0.5) //A struct with the first example code shown above. Utils.Dispatch.delay(secondsToDelay: 1){ print("1 second has passed ! " + searchString) } } </code></pre>
<swift><swift3><tvos>
2016-10-04 09:18:58
HQ
39,848,576
Load a new package in ghci using stack
<p>Is there a way to load a package(s) using Stack in GHCI and play around with it ?</p> <p>So, that when the <code>ghci</code> is loaded, we can import the modules and see it's type signature, etc.</p>
<haskell><haskell-stack>
2016-10-04 09:20:21
HQ
39,848,672
What's the design purpose of Gradle doFirst and doLast?
<p>For example I have the Gradle script like:</p> <pre><code>myTask_A { doFirst { println "first string" } doLast { println "last string" } } </code></pre> <p>The following two tasks have exactly the same execution result:</p> <pre><code>myTask_B { doFirst { println "first string" println "last string" } } myTask_C { doLast { println "first string" println "last string" } } </code></pre> <p>What's the design purpose of the the doFirst &amp; doLast as any of above tasks produces the same result?</p>
<gradle>
2016-10-04 09:24:10
HQ
39,849,572
Interval calculation in Python
<p>I am writing a program where I need to calculate the total watch time of a movie.</p> <pre><code>1st watch = (0,10) 2nd Watch =(13,18) 3rd watch =(15,23) 4th watch =(21,26) </code></pre> <p>Total movie watched=10+5+5+3=23 min</p> <p>How can I implement this in Python</p>
<python>
2016-10-04 10:08:55
LQ_CLOSE
39,849,619
Cannot install kurento-media-server-6.0 in Ubuntu Linux 16.04
<p>Cannot install kurento-media-server-6.0 in Ubuntu Linux 16.04 its always showing dependencies problem as below.</p> <pre><code>sudo apt-get install kurento-media-server-6.0 Reading package lists... Done Building dependency tree Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation: The following packages have unmet dependencies: kurento-media-server-6.0 : Depends: kms-core-6.0 (&gt;= 6.6.1) but it is not going to be installed Depends: libboost-filesystem1.55.0 but it is not installable Depends: libboost-log1.55.0 but it is not installable Depends: libboost-program-options1.55.0 but it is not installable Depends: libboost-system1.55.0 but it is not installable Depends: libboost-thread1.55.0 but it is not installable Depends: libglibmm-2.4-1c2a (&gt;= 2.36.2) but it is not installable Depends: libsigc++-2.0-0c2a (&gt;= 2.0.2) but it is not installable Depends: gstreamer1.5-plugins-bad (&gt;= 1.7.0~0) but it is not going to be installed Depends: gstreamer1.5-plugins-good (&gt;= 1.7.0~0) but it is not going to be installed Depends: gstreamer1.5-plugins-ugly (&gt;= 1.7.0~0) but it is not going to be installed Depends: kms-elements-6.0 (&gt;= 6.6.1) but it is not going to be installed Depends: kms-filters-6.0 (&gt;= 6.6.1) but it is not going to be installed E: Unable to correct problems, you have held broken packages. </code></pre> <p>How to install kurento-media-server-6.0 in Ubuntu Linux 16.04</p>
<ubuntu><webrtc><kurento>
2016-10-04 10:10:59
HQ
39,849,951
How can I convert this function to nodejs
<p>I have this php function for encrypt data, how can I convert it to NodeJS?</p> <pre><code>&lt;?php function Encrypt($input, $key_seed){ $input = trim($input); $block = mcrypt_get_block_size('tripledes', 'ecb'); $len = strlen($input); $padding = $block - ($len % $block); $input .= str_repeat(chr($padding),$padding); // generate a 24 byte key from the md5 of the seed $key = substr(md5($key_seed),0,24); $iv_size = mcrypt_get_iv_size(MCRYPT_TRIPLEDES, MCRYPT_MODE_ECB); echo "--" . $iv_size . "\n"; $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); // encrypt $encrypted_data = mcrypt_encrypt(MCRYPT_TRIPLEDES, $key, $input, MCRYPT_MODE_ECB, $iv); // clean up output and return base64 encoded return base64_encode($encrypted_data); } </code></pre> <p>Help me please! Thank you!</p>
<php><node.js><encryption>
2016-10-04 10:28:58
LQ_CLOSE
39,850,118
Client doesn't have permission to access the desired data in Firebase
<p>I have a page that is calling <code>addCheckin()</code> method which is inside a controller. In the controller, I am trying to create a reference as follows:</p> <pre><code>var ref = firebase.database().ref("users/" + $scope.whichuser + "/meetings/" +$scope.whichmeeting + "/checkins"); </code></pre> <p><code>$scope.whichuser</code> and <code>$scope.whichmeeting</code> are the <code>$routeParams</code> that I am passing from another route. Here's my checkin controller-</p> <pre><code>myApp.controller("CheckinsController", ['$scope','$rootScope','$firebaseArray','$routeParams','$firebaseObject', function($scope,$rootScope,$firebaseArray,$routeParams,$firebaseObject){ $scope.whichuser = $routeParams.uid; $scope.whichmeeting = $routeParams.mid; var ref = firebase.database().ref("users/" + $scope.whichuser + "/meetings/" +$scope.whichmeeting + "/checkins"); $scope.addCheckin = function(){ var checkinInfo = $firebaseArray(ref); var data={ firstname:$scope.firstname, lastname:$scope.lastname, email:$scope.email, date:firebase.database.ServerValue.TIMESTAMP } checkinInfo.$add(data); } }]);/*controller*/ </code></pre> <p>There are two errors that I am getting here-</p> <p>Error 1:</p> <p><code>Error: permission_denied at /users/Vp2P1MqKm7ckXqV2Uy3OzTnn6bB3/meetings: Client doesn't have permission to access the desired data.</code></p> <p>Error 2:</p> <p><code>Error: permission_denied at /users/Vp2P1MqKm7ckXqV2Uy3OzTnn6bB3/meetings/-KT5tqMYKXsFssmcRLm6/checkins: Client doesn't have permission to access the desired data.</code></p> <p>And this is what I am tring to achieve-</p> <p><a href="https://i.stack.imgur.com/WKNiI.png" rel="noreferrer"><img src="https://i.stack.imgur.com/WKNiI.png" alt="enter image description here"></a></p>
<angularjs><firebase><firebase-realtime-database><firebase-authentication><angularfire>
2016-10-04 10:37:25
HQ
39,850,603
How to implement push notification for iOS 10[Objective C]?
<p>Can anyone help me with implementing push notification for iOS 10 as i have implemented following code but still getting problem in it:</p> <pre><code>#define SYSTEM_VERSION_GRATERTHAN_OR_EQUALTO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) if(SYSTEM_VERSION_GRATERTHAN_OR_EQUALTO(@"10.0")) { UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; center.delegate = self; [center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error){ if(!error){ [[UIApplication sharedApplication] registerForRemoteNotifications]; } }]; } else { // Code for old versions } </code></pre> <p>I am getting error suggesting that </p> <blockquote> <p>Unknown receiver UIUserNotificationCenter</p> </blockquote> <p>Thank you in advance!</p>
<ios><objective-c><push-notification><appdelegate><nsusernotification>
2016-10-04 11:02:30
HQ
39,850,646
SonarQube Runner vs Scanner
<p>What is the difference btw Sonar Runner and Sonar Scanner?.</p> <p>And which version of "Sonarqube" and Sonar runner is required for JDK7?</p>
<sonarqube><sonar-runner>
2016-10-04 11:04:39
HQ
39,850,716
We need to rename highlighted tabs in Bitrix 24 self hosted due to business requirement.
We need to rename highlighted tabs in Bitrix 24 self hosted due to business requirement. Location: CRM>Quotes Requirement: <br> 1) Exact steps to edit/rename fields<br> 2) If possible, screenshot would be more helpful<br> 3) Location of lebels in Control Panel.<br> Please advice.<br> Thanks,
<bitrix>
2016-10-04 11:08:26
LQ_EDIT
39,850,893
Make a Tuple from two dictionaries in python
suppose i have a dictionary a={1:2,2:3} and b={3:4,4:5} I want to make a tuple such that t=({1:2,2:3},{3:4,4:5}) please help!
<python><dictionary><tuples>
2016-10-04 11:17:37
LQ_EDIT
39,851,106
How to Check Duplicate value SQL table ?
I am using SQL server.Import data from Excel . i have Following Fields column Entity ExpenseTypeCode Amount Description APSupplierID ExpenseReportID 12 001 5 Dinner 7171 90 12 001 6 Dinner 7171 90 12 001 5 Dinner 7273 90 12 001 5 Dinner 7171 95 12 001 5 Dinner 7171 90 I added Sample Data. Now I want select Duplicate Records .which Rows have all columns value same i want fetch that row. suppose above My table Fifth Row duplicate . i have more four thousands Query . i want select Duplicate records .Above I mention . please How to select using Query ?
<sql><sql-server>
2016-10-04 11:28:50
LQ_EDIT
39,853,057
change the background color of a given field only in a form
<p>Is it possible to target a particular text field in a form and change it's background &amp; foreground color. Likewise different colors for different fields too.</p> <p>It needs to use css and not js and also there is to be no inline html/code present.</p> <p>Thanks all.</p>
<html><css>
2016-10-04 13:01:37
LQ_CLOSE
39,853,162
reCAPTCHA with Content Security Policy
<p>I'm trying to make reCAPTCHA work along with a strict Content Security Policy. This is the basic version I have, which works correctly:</p> <p>HTML</p> <pre><code>&lt;script src='//www.google.com/recaptcha/api.js' async defer&gt;&lt;/script&gt; </code></pre> <p>HTTP Headers</p> <pre><code>Content-Security-Policy: default-src 'self'; script-src 'self' www.google.com www.gstatic.com; style-src 'self' https: 'unsafe-inline'; frame-src www.google.com; </code></pre> <p>However, I would like to get rid of the <code>unsafe-inline</code> in the <code>style-src</code> section. On the <a href="https://developers.google.com/recaptcha/docs/faq#im-using-content-security-policy-csp-on-my-website-how-can-i-configure-it-to-work-with-recaptcha" rel="noreferrer">documentation</a>, it is written that:</p> <blockquote> <p>We recommend using the nonce-based approach documented with CSP3. Make sure to include your nonce in the reCAPTCHA api.js script tag, and we'll handle the rest.</p> </blockquote> <p>But I can't make it work... This is what I tried:</p> <p>HTML</p> <pre><code>&lt;script src='//www.google.com/recaptcha/api.js' nonce="{NONCE}" async defer&gt;&lt;/script&gt; </code></pre> <p>HTTP Headers</p> <pre><code>Content-Security-Policy: default-src 'self'; script-src 'self' https: 'nonce-{NONCE}'; style-src 'self' 'nonce-{NONCE}'; child-src www.google.com; </code></pre> <p>And this is the error I get on Chrome 53:</p> <blockquote> <p>Refused to apply inline style because it violates the following Content Security Policy directive: "style-src 'self' https: 'nonce-{NONCE}'". Either the 'unsafe-inline' keyword, a hash ('sha256-MammJ3J+TGIHdHxYsGLjD6DzRU0ZmxXKZ2DvTePAF0o='), or a nonce ('nonce-...') is required to enable inline execution.</p> </blockquote> <p>What I am missing?</p>
<recaptcha><content-security-policy>
2016-10-04 13:06:44
HQ
39,853,422
jQuery replace click() with document.ready()
<p>SO I found this jquery function: <a href="http://codepen.io/niklas-r/pen/HsjEv" rel="nofollow">http://codepen.io/niklas-r/pen/HsjEv</a></p> <p>html: </p> <pre><code>&lt;p id="el"&gt;0%&lt;/p&gt; &lt;button id="startCount"&gt;Count&lt;/button&gt; </code></pre> <p>JS:</p> <pre><code>$("#startCount").on("click", function (evt) { var $el = $("#el"), value = 56.4; evt.preventDefault(); $({percentage: 0}).stop(true).animate({percentage: value}, { duration : 2000, easing: "easeOutExpo", step: function () { // percentage with 1 decimal; var percentageVal = Math.round(this.percentage * 10) / 10; $el.text(percentageVal + '%'); } }).promise().done(function () { // hard set the value after animation is done to be // sure the value is correct $el.text(value + "%"); }); }); </code></pre> <p>It increment numbers with animation. It doesnt work though, when I replace click with document.ready(). How do I make it work?</p>
<javascript><jquery>
2016-10-04 13:17:37
LQ_CLOSE
39,853,599
How can I view someone's comment history on GitHub?
<p>It's easy to see someone's <em>commit</em> history on GitHub, at least the recent one, but is there a way to see all <em>comments</em> they've made there?</p>
<github>
2016-10-04 13:26:13
HQ
39,854,821
Compiling C++ in OSX terminal: Undefined symbols for architecture x86_64
<p>I'm writing code for a class project and I did it all in Xcode, which worked fine. I was able to compile w/ arguments in Xcode and get output. However, when I try to compile it in terminal, I keep getting this error (I'm also not sure if I'm compiling it correctly):</p> <pre><code>francis-mbp:CS280-Assignment1 fren$ gcc /Users/fren/Desktop/CS280-Assignment1/main.cpp -o main /Users/fren/Desktop/CS280-Assignment1/main.cpp:31:32: warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions] list&lt;string&gt;::iterator iter=lineToPrint.begin(); ^ /Users/fren/Desktop/CS280-Assignment1/main.cpp:32:19: warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions] int charLimit = 60; ^ 2 warnings generated. Undefined symbols for architecture x86_64: "std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;::compare(char const*) const", referenced from: _main in main-b9d962.o "std::__1::locale::has_facet(std::__1::locale::id&amp;) const", referenced from: std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::basic_filebuf() in main-b9d962.o "std::__1::locale::use_facet(std::__1::locale::id&amp;) const", referenced from: std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp; std::__1::endl&lt;char, std::__1::char_traits&lt;char&gt; &gt;(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;) in main-b9d962.o std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::imbue(std::__1::locale const&amp;) in main-b9d962.o std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp; std::__1::__put_character_sequence&lt;char, std::__1::char_traits&lt;char&gt; &gt;(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;, char const*, unsigned long) in main-b9d962.o std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::basic_filebuf() in main-b9d962.o "std::__1::ios_base::getloc() const", referenced from: std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp; std::__1::endl&lt;char, std::__1::char_traits&lt;char&gt; &gt;(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;) in main-b9d962.o std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp; std::__1::__put_character_sequence&lt;char, std::__1::char_traits&lt;char&gt; &gt;(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;, char const*, unsigned long) in main-b9d962.o "std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;::erase(unsigned long, unsigned long)", referenced from: Line::addWord(std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;) in main-b9d962.o "std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;::__init(char const*, unsigned long)", referenced from: Line::addWord(std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;) in main-b9d962.o Line::printLine(int) in main-b9d962.o _main in main-b9d962.o "std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;::__init(char const*, unsigned long, unsigned long)", referenced from: std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt; std::__1::operator+&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;(std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt; const&amp;, char const*) in main-b9d962.o "std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;::__init(unsigned long, char)", referenced from: std::__1::ostreambuf_iterator&lt;char, std::__1::char_traits&lt;char&gt; &gt; std::__1::__pad_and_output&lt;char, std::__1::char_traits&lt;char&gt; &gt;(std::__1::ostreambuf_iterator&lt;char, std::__1::char_traits&lt;char&gt; &gt;, char const*, char const*, char const*, std::__1::ios_base&amp;, char) in main-b9d962.o "std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;::append(char const*, unsigned long)", referenced from: std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt; std::__1::operator+&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;(std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt; const&amp;, char const*) in main-b9d962.o "std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;::assign(char const*)", referenced from: Line::addWord(std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;) in main-b9d962.o _main in main-b9d962.o "std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;::push_back(char)", referenced from: _main in main-b9d962.o "std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;::basic_string(std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt; const&amp;)", referenced from: Line::addWord(std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;) in main-b9d962.o std::__1::list&lt;std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;, std::__1::allocator&lt;std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt; &gt; &gt;::push_back(std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt; const&amp;) in main-b9d962.o std::__1::list&lt;std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;, std::__1::allocator&lt;std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt; &gt; &gt;::insert(std::__1::__list_const_iterator&lt;std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;, void*&gt;, std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt; const&amp;) in main-b9d962.o Line::checkBack() in main-b9d962.o _main in main-b9d962.o "std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;::basic_string(std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt; const&amp;, unsigned long, unsigned long, std::__1::allocator&lt;char&gt; const&amp;)", referenced from: Line::addWord(std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;) in main-b9d962.o "std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;::~basic_string()", referenced from: Line::addWord(std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;) in main-b9d962.o std::__1::list&lt;std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;, std::__1::allocator&lt;std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt; &gt; &gt;::pop_back() in main-b9d962.o std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt; std::__1::operator+&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;(std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt; const&amp;, char const*) in main-b9d962.o Line::printLine(int) in main-b9d962.o std::__1::list&lt;std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;, std::__1::allocator&lt;std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt; &gt; &gt;::pop_front() in main-b9d962.o std::__1::list&lt;std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;, std::__1::allocator&lt;std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt; &gt; &gt;::push_back(std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt; const&amp;) in main-b9d962.o std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt; std::__1::operator+&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;(std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt; const&amp;, char const*) in main-b9d962.o std::__1::list&lt;std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;, std::__1::allocator&lt;std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt; &gt; &gt;::insert(std::__1::__list_const_iterator&lt;std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;, void*&gt;, std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt; const&amp;) in main-b9d962.o Line::printLine(int) in main-b9d962.o Line::popBack(int) in main-b9d962.o ... ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) francis-mbp:CS280-Assignment1 fren$ </code></pre> <p>Here's the code for my project (doesn't include main bc of character limit): </p> <pre><code>#include &lt;iostream&gt; #include&lt;string&gt; #include&lt;vector&gt; #include&lt;sstream&gt; #include&lt;fstream&gt; #include&lt;algorithm&gt; #include&lt;queue&gt; #include&lt;list&gt; #include&lt;iterator&gt; #include&lt;ctype.h&gt; using namespace std; /* Class defining data structure that holds linked list containing words to be output Contains words on a per-line basis (Empties after each line is printed) Handles list operations */ class Line { public: list&lt;string&gt; lineToPrint; list&lt;string&gt;::iterator iter=lineToPrint.begin(); int charLimit = 60; string spaceToInsert; int totalChars; int totalSpaces; int numWords; int placesForSpaces; int spacePerPlace; int extraSpaces; void addWord (string word); void reset (void); void changeLimit (int newLimit); void printLine (int endOfParagraph); void calculateSpaces(void); void newParagraph(void); void popBack(int type); string checkBack(void); }; void Line::addWord(string word) { cout &lt;&lt; "adding word: " &lt;&lt; word &lt;&lt; endl; string firstHalfWord; string secondHalfWord; int numToTruncate; int splittingWord = 1; lineToPrint.push_back(word); totalChars += word.length(); numWords ++; calculateSpaces(); if(((totalChars &gt; charLimit) &amp;&amp; (numWords &gt;= 1)) || ((totalSpaces &lt; placesForSpaces) &amp;&amp; (spacePerPlace == 0))) { splittingWord = 0; lineToPrint.pop_back(); numToTruncate = totalChars - (charLimit - placesForSpaces - 1); if(numToTruncate &gt; word.length()) { cout &lt;&lt; numToTruncate &lt;&lt; " " &lt;&lt; word.length(); cout &lt;&lt; "error" &lt;&lt; endl; } else { secondHalfWord = word.substr(word.length() - numToTruncate); firstHalfWord = word.erase(word.length() - numToTruncate) + "-"; } lineToPrint.push_back(firstHalfWord); totalChars -= (word.length() + secondHalfWord.length()); totalChars += firstHalfWord.length(); calculateSpaces(); } if((spacePerPlace &lt;= 2 &amp;&amp; extraSpaces&lt;= placesForSpaces)||(spacePerPlace == 3 &amp;&amp; extraSpaces == 0)) { if(spacePerPlace == 1){ spaceToInsert = " "; } else if (spacePerPlace == 2) { spaceToInsert = " "; } else if (spacePerPlace == 3) { spaceToInsert = " "; } iter++; for(int j = placesForSpaces; j &gt; 0; j--) { //cout &lt;&lt; "inserting " &lt;&lt; spacePerPlace &lt;&lt; " spaces!" &lt;&lt; endl; lineToPrint.insert(iter, spaceToInsert); totalSpaces -= spacePerPlace; if(extraSpaces != 0){ lineToPrint.insert(iter, " "); totalSpaces --; extraSpaces --; } iter++; } printLine(1); } if(splittingWord == 0 &amp;&amp; secondHalfWord.length() &gt; charLimit){ iter = lineToPrint.begin(); addWord(secondHalfWord); } else if (splittingWord == 0 &amp;&amp; secondHalfWord.length() &lt;= charLimit) { lineToPrint.push_back(secondHalfWord); totalChars += secondHalfWord.length(); numWords ++; } iter = lineToPrint.begin(); splittingWord = 1; } //Resets the list and variables for calculating spaces to insert void Line::reset(void) { lineToPrint.clear(); totalChars = 0; totalSpaces = 0; numWords = 0; placesForSpaces = 0; } //Changes the variable limit used in space insert calculations void Line::changeLimit(int newLimit) { //cout &lt;&lt; "Changing Limit to: " &lt;&lt; newLimit &lt;&lt; endl; charLimit = newLimit; } //Makes calculations for variables used in space insertion calculations void Line::calculateSpaces(void) { //cout &lt;&lt; "calculating spaces..." &lt;&lt; endl; totalSpaces = charLimit - totalChars; if (numWords == 1 &amp;&amp; totalChars &gt;= charLimit) { placesForSpaces = 0; spacePerPlace = 0; } else { if(numWords == 1){ placesForSpaces = 1; } else { placesForSpaces = numWords - 1; } spacePerPlace = totalSpaces/placesForSpaces; extraSpaces = totalSpaces%placesForSpaces; } //cout &lt;&lt; "totalChars: "&lt;&lt; totalChars &lt;&lt;" totalSpaces: "&lt;&lt; totalSpaces &lt;&lt; " numWOrds: " &lt;&lt; numWords &lt;&lt; " placesFOrSpaces: " &lt;&lt; placesForSpaces &lt;&lt; " spacePerPlace: " &lt;&lt; spacePerPlace &lt;&lt; " extraSpaces: " &lt;&lt; extraSpaces &lt;&lt; endl; } //Prints the list (with spaces included) //Takes int argument; 0 = end of paragraph, 1 = not end of paragraph void Line::printLine(int endOfParagraph) { //p1cout &lt;&lt; "character limit: " &lt;&lt; charLimit &lt;&lt; endl; if(endOfParagraph == 1) { cout &lt;&lt; "printing line NOT end of paragraph" &lt;&lt; endl; for(list&lt;string&gt;::iterator it = lineToPrint.begin(); it != lineToPrint.end(); it++){ cout &lt;&lt; *it; lineToPrint.pop_front(); } } else if (endOfParagraph == 0) { iter++; cout &lt;&lt; "printing line end of paragraph" &lt;&lt; endl; if (numWords != 1) { for(int i = placesForSpaces; i &gt;0; i--) { lineToPrint.insert(iter, " "); iter++; } } iter = lineToPrint.begin(); for(list&lt;string&gt;::iterator it = lineToPrint.begin(); it != lineToPrint.end(); it++){ cout &lt;&lt; *it; lineToPrint.pop_front(); } } cout &lt;&lt; endl; totalChars = 0; totalSpaces = 0; numWords = 0; placesForSpaces = 0; } //Prints a new line to separate paragraphs void Line::newParagraph(void){ cout &lt;&lt; endl; } //Returns the string held in the back of the list string Line::checkBack(void) { return lineToPrint.back(); } //Removes a string off the back of the list void Line::popBack(int type) { if(type == 1){ string wordToPop = checkBack(); cout &lt;&lt; "word to pop : " &lt;&lt; wordToPop &lt;&lt; endl; int length = wordToPop.length(); cout &lt;&lt; "length of w2pop : " &lt;&lt; length &lt;&lt;endl; totalChars -= length; } //cout &lt;&lt; "popping from back: " &lt;&lt; checkBack(); lineToPrint.pop_back(); numWords --; } </code></pre> <p>Thanks to any help</p>
<c++><xcode><macos><compiler-errors><compiler-warnings>
2016-10-04 14:23:43
LQ_CLOSE
39,854,929
Firebase Cloud Messaging AppDelegate Error
<p>This is code in the Firebase Docs.</p> <pre><code>if #available(iOS 10.0, *) { let authOptions : UNAuthorizationOptions = [.Alert, .Badge, .Sound] UNUserNotificationCenter.currentNotificationCenter().requestAuthorizationWithOptions( authOptions, completionHandler: {_,_ in }) // For iOS 10 display notification (sent via APNS) UNUserNotificationCenter.currentNotificationCenter().delegate = self // For iOS 10 data message (sent via FCM) FIRMessaging.messaging().remoteMessageDelegate = self } else { let settings: UIUserNotificationSettings = UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: nil) application.registerUserNotificationSettings(settings) } </code></pre> <p>I didn't modified any line of code. But Xcode says "Use of undeclared type <code>UNAuthorizationOptions</code>, <code>UNUserNotificationCenter</code>, <code>FIRMessagingDelegate</code>"</p> <p>and I have one more line.</p> <pre><code>NotificationCenter.defaultCenter.addObserver(self,selector: #selector(self.tokenRefreshNotification),name: kFIRInstanceIDTokenRefreshNotification,object: nil) </code></pre> <p>It says "Value of Type AppDelegate has no member <code>tokenRefreshNotification</code>"</p> <p>I just copied and pasted my code from firebase docs but there is error!</p>
<ios><swift><firebase><swift3><firebase-cloud-messaging>
2016-10-04 14:28:15
HQ
39,855,439
why my output in json data contain extra curly braces
The main problem of this code is that it provides extra curly braces .. <?php header('Content-Type: json'); include('config.php'); for($i=1990;$i<=2016;$i++){ $sum=0; $data1=array(); $result=mysql_query("select * from crimedetails where crime_year=$i"); while($row=mysql_fetch_array($result)) { $sum+=$row['crime_mudered']; $data['crime_mudered']=$sum; $data['crime_year']=$row['crime_year']; } $data3[]=$data; } array_push($data1,$data3); print json_encode($data1); ?> [enter image description here][1] [1]: http://i.stack.imgur.com/fbdBs.png
<php><mysql><json>
2016-10-04 14:50:55
LQ_EDIT
39,855,619
NoMethodError (undefined method `permit' for #<Array:0x007f51c020bd18>
<p>I am getting this error and using Rails 5.</p> <blockquote> <p>NoMethodError (undefined method <code>permit' for #&lt;Array:0x007f51cf4dc948&gt; app/controllers/traumas_controller.rb:99:in</code>trauma_params' app/controllers/traumas_controller.rb:25:in `create_multiple'</p> </blockquote> <p>Controller params are as below.</p> <blockquote> <p>Started POST "/traumas/create_multiple" for 127.0.0.1 at 2016-10-04 20:09:36 +0530 Processing by TraumasController#create_multiple as JS<br> Parameters: {"utf8"=>"✓", "fields"=>[{"contusions"=>"1", "burns"=>"", "at_scene"=>"At Scene", "emergency_detail_id"=>"96", "trauma_region"=>"Head-Back"}], "commit"=>"Submit"}</p> </blockquote> <p>I am trying to create record as below in controller:</p> <pre><code> def create_multiple trauma_params params[:fields].each do |values| u = Trauma.create(values) end end def trauma_params params.require(:fields).permit(:fields =&gt; []) end </code></pre> <p>Please help me to resolve this issue.</p> <p>Thanks in advance.</p> <p>Kiran.</p>
<ruby-on-rails-5><nomethoderror>
2016-10-04 14:58:15
HQ
39,856,001
Xcode 8 beta simulator fails to run app after accidentally running Xcode8 simulator
<p>"Failed to initiate service connection to simulator"</p> <p>Tried to clean app, reinstall it, delete derived data, reset simulator settings, restart xCode. I've also heard other people solved problems with their simulators by recreating the simulator. I tried that as well. When I press create, I get the very same error message: "Error returned in reply: Connection invalid"</p> <p><a href="https://i.stack.imgur.com/ImzkA.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ImzkA.png" alt="Failed to initiate service connection to simulator"></a></p>
<xcode><connection><ios-simulator>
2016-10-04 15:16:00
HQ
39,856,013
Convert String[][] to String[]
<p>I have a <code>String[][]</code> (Double Array) and want it to convert it into a simple <code>String[]</code> (one array). Thanks for any help.</p>
<java><android><arrays><string>
2016-10-04 15:16:35
LQ_CLOSE
39,856,280
tkinter programm opens with cmd
<p>I writed a program with Python 3.5.2 using Tkinter (and IDLE). When I debug it, the window comes up. And the window too, where we can see the Error. But if i don't debug it and open it by double-clicking, the window comes up with cmd. If I close the cmd, my window closes too.</p> <pre><code>win = Tk() win.geometry("450x500") win.title(just a title) win.wm_iconbitmap(just a path) win.resizable(False, False) </code></pre> <p>How can I fix it? Thanks...</p> <p>(Sorry for the bad English :) )</p>
<python><tkinter><cmd>
2016-10-04 15:28:32
LQ_CLOSE
39,856,376
My todo list is bugged
Can some one help me? i'm trying to code a **simple todolist with JS** i'm begginer on this language, my tasks were adding ok, but when i created a button to complete the task it bugged everything. Here's my code <!DOCTYPE html> <html> <head> <title>TODO</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <h1>TODOLIST</h1> <input id="task"><button id="add">Add</button> <hr> <h2>todo</h2> <ul id="todos"></ul> <h2>done</h2> <ul id="done"></ul> <script src="todo.js"></script> </body> </html> JS: function get_todos() { var todos = new Array; var todos_str = localStorage.getItem('todo'); if (todos_str !== null) { todos = JSON.parse(todos_str); } return todos; } function get_dones(){ var dones = new Array; var dones_str = localStorage.getItem('done'); if (dones_str !== null){ dones = JSON.parse(dones_str); } return dones; } function add() { var task = document.getElementById('task').value; var todos = get_todos(); todos.push(task); localStorage.setItem('todo', JSON.stringify(todos)); show(); return false; } function remove() { var id = this.getAttribute('id'); var todos = get_todos(); todos.splice(id, 1); localStorage.setItem('todo', JSON.stringify(todos)); show(); return false; } function show() { var todos = get_todos(); var dones = get_dones(); var html; for(var i=0; i<todos.length; i++) { html += '<li>' + todos[i] + '<button class="remove" id="' + i + '">Delete</button> <button class="done" id="' + i + '">Done</button></li>'; }; document.getElementById('todos').innerHTML = html; var html; for(var i=0; i<dones.length; i++) { html += '<li>' + dones[i] + '<button class="remove" id="' + i + '">Delete</button> <button class="done" id="' + i + '">Done</button></li>'; }; document.getElementById('dones').innerHTML = html; var buttons = document.getElementsByClassName('remove'); for (var i=0; i < buttons.length; i++) { buttons[i].addEventListener('click', remove); }; var buttons = document.getElementsByClassName('done'); for (var i=0; i < buttons.length; i++) { buttons[i].addEventListener('click', done); }; function done(){ var id = this.getAttribute('id'); var done = get_dones(); localStorage.setItem('done', JSON.stringify(dones)); show(); return false; } document.getElementById('add').addEventListener('click', add); show();
<javascript><html>
2016-10-04 15:33:29
LQ_EDIT
39,856,397
Excel Macro that displays a message when a symbol is missing in a cell
I have created an Excel template for my users to enter data in. As a precautinary measure, I'd like my template to display an alert message (for a specific column of cells only) if something has been entered by a user but a symbol is missing. For example: The column 'Email' will contain a list of email addresses that the user must enter. If the user enters an email address that does NOT contain an '@', I'd like an error message to appear telling the user that the email address has not been entered correctly. As I am still new to Excel VBA, any help on how to build a macro for this will be highly appreciated. Thank you.
<vba><excel>
2016-10-04 15:34:10
LQ_EDIT
39,856,927
How to turn off autoscaling in Kubernetes with the kubectl command?
<p>If I set to autoscale a deployment using the kubectl autoscale command (<a href="http://kubernetes.io/docs/user-guide/kubectl/kubectl_autoscale/" rel="noreferrer">http://kubernetes.io/docs/user-guide/kubectl/kubectl_autoscale/</a>), how can I turn it off an go back to manual scaling?</p>
<scale><kubernetes>
2016-10-04 16:00:53
HQ
39,857,093
Update one column based on the first 3 letters of another
<p>can someone help show me how to update one field in my table based on the first 3 letters in another field in MySql?</p> <p>in my tblpeople I have a column called location, in it are various codes but where the code starts VOL- then I need to update the country column to USA, if it starts HOM- then update to Canada and finally HOME to united kingdom</p>
<mysql>
2016-10-04 16:09:18
LQ_CLOSE
39,857,590
React-native <Picker /> on android crashes app after render
<p>Here the component:</p> <pre><code>&lt;Picker selectedValue={'item1'} onValueChange={(value) =&gt; onDismiss(value)}&gt; &lt;Picker.Item key={'item1'} label={'item1'} value={'item1'} /&gt; &lt;Picker.Item key={'item2'} label={'item2'} value={'item2'} /&gt; &lt;Picker.Item key={'item3'} label={'item3'} value={'item3'} /&gt; &lt;/Picker&gt; </code></pre> <p>nothing unusual, no additional libraries just RN^0.29.0 Works absolutely fine in debug mode, but if it being rendered in production, app crashes right after render (i see the rendered scene for a moment and then fatal crash).</p> <p>I'm sure that was not happening some time ago, but rolling back doesn't help. I do not know what have cause this issue or when exactly it appeared.</p> <p>I've tried to do <code>cd android &amp;&amp; ./gradlew clean</code>, i've tried to remove some properties etc - nothing helps.</p> <p>However, while i was building-rebuilding prod app (<code>react-native run-android --variant=release</code>) about 40 times, it actually worked few times: render ended up succesfully, then i'm leaving the scene with picker, and when i'm trying to get there again (render Picker again, it starts crashing). No idea what it is. As you see, i've even hardcoded items there, but it doesn't help.</p> <p>Any guesses? </p>
<android><react-native>
2016-10-04 16:38:24
HQ
39,858,067
Python Iteration Homework
<p>I have 2 questions I need to ask for help with. One question I don't entirely understand so if someone could help me to that would be great. </p> <p>Question One (the one I don't entirely understand):</p> <blockquote> <p>One definition of e is</p> </blockquote> <p><a href="http://i.stack.imgur.com/DAd4A.png" rel="nofollow">Formula for e</a></p> <blockquote> <p>This can be calculated as my_e = 1/math.factorial(0) + 1/math.factorial(1) + 1/math.factorial(2) + 1/math.factorial(3) + …</p> <p>Let n be the input number of the math.factorial() function. n successively takes on 0, 1, 2, 3 and so on. Find the smallest n such that the absolute value of (my_e – math.e) is less than or equal to 10-10. That is, abs(my_e - math.e) &lt;= (10 ** -10).</p> </blockquote> <p>I just don't entirely understand what I am being asked to do. Clarification would be great. Thanks!</p> <p>Question 2:</p> <blockquote> <p>Ask the user to type in a series of integers. Sum them up and print out the sum and the number of integers the user has entered.</p> </blockquote> <p><a href="http://i.stack.imgur.com/MDzXx.png" rel="nofollow">My code</a></p> <p>So what should happen is after I enter the numbers I want to enter and hit the enter key, it should calculate and print out "sum = 25 count = 3". The screenshot shows what error message I am getting.</p> <p>Any help you have is welcomed and greatly appreciated.</p>
<python><math><iteration>
2016-10-04 17:09:13
LQ_CLOSE
39,858,471
Angular 2 - How to pass URL parameters?
<p>I have created a single page mortgage calculator application in Angular 2, which acts like a learning playground for me (trying to get more accustomed to technology stack currently used at work)... It's running at <a href="http://www.mortgagecalculator123.com">http://www.mortgagecalculator123.com</a> if you want to look at it. I've made it open source with a Fork Me link right on the page if you want to look at it.</p> <p>Anyhow, what I want to do, is to be able to pass variables to my app, straight from the URL, so they can be consumed by my Angular 2 app. Something like this: <a href="http://www.mortgagecalculator123.com/?var1=ABC&amp;var2=DEF">http://www.mortgagecalculator123.com/?var1=ABC&amp;var2=DEF</a></p> <p>I've tried following, in my app.component.ts, I've added following:</p> <pre><code>import { Router, ActivatedRoute, Params } from '@angular/router'; AppComponent { private var1: string; private var2: string; constructor( private route: ActivatedRoute, private router: Router ) {} ngOnInit() { this.route.params.forEach((params: Params) =&gt; { this.var1 = params['var1']; this.var2 = params['var2']; }); console.log(this.var1, this.var2); } ... } </code></pre> <p>But this won't work, when I run <strong>npm start</strong>, I get following error:</p> <p><strong>aot/app/app.component.ngfactory.ts(45,30): error TS2346: Supplied parameters do not match any signature of call target.</strong></p> <p><a href="https://i.stack.imgur.com/Zf0SM.jpg"><img src="https://i.stack.imgur.com/Zf0SM.jpg" alt="enter image description here"></a></p> <p>Thank you, any help would be much appreciated.</p>
<javascript><node.js><angular><npm>
2016-10-04 17:34:32
HQ
39,858,856
Json object to Parquet format using Java without converting to AVRO(Without using Spark, Hive, Pig,Impala)
<p>I have a scenario where to convert the messages present as Json object to Apache Parquet format using Java. Any sample code or examples would be helpful. As far as what I have found to convert the messages to Parquet either Hive, Pig, Spark are being used. I need to convert to Parquet without involving these only by Java.</p>
<java><json><hadoop><parquet>
2016-10-04 17:58:32
HQ
39,858,872
VisualVM Calibration Step Hangs with Windows 10
<p>Situation:</p> <p>I have installed VisualVM 1.3.8 on my Windows 10 Anniversary Edition (and not using the one that came with the JDK 8).</p> <p>I would like to use this to Profile a Java (Play) App.</p> <p>What Happens:</p> <p>When starting the CPU profiling, it first asks that I need to calibrate, and when that happens it hangs at the stage.</p> <p><a href="http://i.stack.imgur.com/Tas82.png" rel="noreferrer">The Display showing the hanging</a></p> <p>What I Have Tried:</p> <p>I tried this on MacOS 8, and it does go through the calibration steps OK.</p> <p>I have edited the etc/visualvm.conf to disable the d3d pipline feature.</p> <p>visualvm_default_options="-J-Dsun.java2d.d3d=false -J-client -J-Xms24m -J-Xmx256m -J-XX:+IgnoreUnrecognizedVMOptions -J-Dnetbeans.accept_license_class=com.sun.tools.visualvm.modules.startup.AcceptLicense -J-Dsun.jvmstat.perdata.syncWaitMs=10000 -J-Dsun.java2d.noddraw=true"</p> <p>The Goal:</p> <p>Get the calibration process to complete.</p>
<java><code-profiling>
2016-10-04 17:59:22
HQ
39,859,159
How to control the number of layer in nested for-loop in python?
<p>Given a list like <code>alist = [1, 3, 2, 20, 10, 13]</code>, I wanna write a function <code>find_group_f</code>, which can generate all possible combination of elements in <code>alist</code> and meanwhile I can dynamically control the number <code>k</code> of element in each group. For instance, if the number <code>k</code> is <code>2</code>, the function is equal to:</p> <pre><code>for e1 in alist: for e2 in alist[alist.index(e1)+1:]: print (e1, e2) </code></pre> <p>While the number <code>k</code> is 3, it would be like:</p> <pre><code>for e1 in alist: for e2 in alist[alist.index(e1)+1:]: for e3 in alist[alist.index(e2)+1:]: print (e1, e2, e3) </code></pre> <p>I wonder how can I implement like this? Thanks in advance!</p>
<python><algorithm>
2016-10-04 18:17:34
LQ_CLOSE
39,859,224
How to use HTML5 color picker in Django admin
<p>I'm trying to implement the HTML5 colorpicker in Django's admin page.</p> <p>Here is my model:</p> <pre><code>#model.py ... class Category(models.Model): ... color = models.CharField(max_length=7) </code></pre> <p>Here is the form:</p> <pre><code>#form.py from django.forms import ModelForm from django.forms.widgets import TextInput from .models import Category class CategoryForm(ModelForm): class Meta: model = Category fields = '__all__' widgets = { 'color': TextInput(attrs={'type': 'color'}), } class CategoryAdminForm(ModelForm): form = CategoryForm </code></pre> <p>And finally the admin:</p> <pre><code>#admin.py ... from .forms import CategoryAdminForm ... class CategoryAdmin(admin.ModelAdmin): form_class = CategoryAdminForm filter_horizontal = ('questions',) fieldsets = ( (None, { 'fields': (('name', 'letter'), 'questions', 'color') }), ) </code></pre> <p>However, the type for the field is still text. How do I change the type for the input field to color in the admin page?</p>
<python><django><html>
2016-10-04 18:21:26
HQ
39,859,260
Loaded runtime CuDNN library: 5005 (compatibility version 5000) but source was compiled with 5103 (compatibility version 5100)
<p>I've the following error. I'm using a conda installation of tensorflow. I'm struggling to try to use it with my GPU.</p> <p><code> Loaded runtime CuDNN library: 5005 (compatibility version 5000) but source was compiled with 5103 (compatibility version 5100). If using a binary install, upgrade your CuDNN library to match. If building from sources, make sure the library loaded at runtime matches a compatible version specified during compile configuration. F tensorflow/core/kernels/conv_ops.cc:526] Check failed: stream-&gt;parent()-&gt;GetConvolveAlgorithms(&amp;algorithms) Aborted (core dumped) </code></p> <p>which nvcc returns <code>/usr/local/cuda-7.5/bin/nvcc</code></p> <p>nvcc version returns <code>Cuda compilation tools, release 7.5, V7.5.17</code></p> <p>I tried downloading CuDNN v5.1 and did the following but it didn't work either ``` sudo cp lib* /usr/local/cuda-7.5/lib64/ sudo cp include/cudnn.h /usr/local/cuda-7.5/include/ sudo ldconfig</p> <p>```</p> <p>I tried on the other folder too <code> sudo cp lib* /usr/local/cuda/lib64/ sudo cp include/cudnn.h /usr/local/cuda/include/ sudo ldconfig </code></p>
<tensorflow>
2016-10-04 18:24:28
HQ
39,859,787
how to keep spaces with escape sequences stringbuilder c#
I have a `stringbuilder` setup with escape sequences to show a ASCII like art to text. Here is my code: sb.AppendLine(@" _____ ______ ___ ___ ________ "); sb.AppendLine(@" |\ _ \ _ \|\ \|\ \|\ ___ \ "); sb.AppendLine(@" \ \ \\\__\ \ \ \ \\\ \ \ \_|\ \ "); sb.AppendLine(@" \ \ \\|__| \ \ \ \\\ \ \ \ \\ \ "); sb.AppendLine(@" \ \ \ \ \ \ \ \\\ \ \ \_\\ \ "); sb.AppendLine(@" \ \__\ \ \__\ \_______\ \_______\ "); sb.AppendLine(@" \|__| \|__|\|_______|\|_______| "); sb.AppendLine(@" "); And here is the output: _____ ______ ___ ___ ________ |\ _ \ _ \|\ \|\ \|\ ___ \ \ \ \\\__\ \ \ \ \\\ \ \ \_|\ \ \ \ \\|__| \ \ \ \\\ \ \ \ \\ \ \ \ \ \ \ \ \ \\\ \ \ \_\\ \ \ \__\ \ \__\ \_______\ \_______\ \|__| \|__|\|_______|\|_______| How can I keep my strings just as I typed them?
<c#><asp.net><whitespace><ansi-escape>
2016-10-04 18:57:04
LQ_EDIT
39,859,992
How can I use Pipe symbol "|" from Java to Batch file?
<p>I'm using java in eclipse to call a .bat file using Runtime method. I have two options, send a variable or multiple variables. My unique option is to separate it with pipe "|".</p> <p>when I send a unique variable it assumes correct and run the .bat file, but when I add the symbol "|" to the string it doesn't open the .bat file, even when I only show what I send. (the problem actually I think, somehow the pipe cut the runtime process).</p> <p>The problem is that I need to send something like: 1st example .- a (Just a character it works fine.) 2nd example .- a|b|c|d|e (more than 1 variable separated by pipe, the .bat never opens)</p>
<java><eclipse><batch-file><cmd><runtime>
2016-10-04 19:10:36
LQ_CLOSE
39,860,084
While loops help countinng
I am having a hard time making a code for a while loop that asks a user to enter two numbers then displays the first number and all the numbers inbetween the second number. Please help!
<c#>
2016-10-04 19:16:38
LQ_EDIT
39,860,739
How to get first and last element in an array in java?
<p>If I have an array of doubles: </p> <pre><code>[10.2, 20, 11.1, 21, 31, 12, 22.5, 32, 42, 13.6, 23, 32, 43.3, 53, 14, 24, 34, 44, 54, 64, 15.1, 25, 35, 45, 55, 65.3, 75.4, 16, 26, 17.5,] </code></pre> <p>and I want to get the first element and last element so that</p> <pre><code>firstNum = 10.2 lastNum = 17.5 </code></pre> <p>how would I do this?</p>
<java><arrays>
2016-10-04 19:56:51
HQ
39,861,340
NgModule vs Component
<p>So I'm learning angular2 now and reading ngbook2 about the modules. Modules contain components, but also can import different modules with their public components.</p> <p>And the question is: What is the scope of the module component (in this meaning scope as parts of an application, not the reach of variables inside). Is module the whole application or just some part like header, containing its components?</p> <p>What is the typicaly used convention?</p>
<angular>
2016-10-04 20:38:23
HQ
39,861,390
What's the best approach to animate frame changes on NSView?
<p>Ideally I'd need something like <code>UIView.animateWithDuration</code>, however I know that this is not an API that's available on macOS. What's the best way to manipulate the actual frame of an NSView and animate the changes?</p> <p>I tried going for <code>CABasicAnimation</code>, however that's performed on a CALayer rather than the view itself.</p> <p>What I need is to animate the actual view frame... (or maybe that's a bad practice and there's an alternative?)</p> <p>So for that reason, after a bit of digging I found <code>NSAnimationContext</code>. That however seems to simply interpolate / fade between two states which is not the feel I am going for.</p> <p>Here's a small sample of the code I have:</p> <pre><code>override func mouseDown(with event: NSEvent) { let newSize = NSMakeRect(self.frame.origin.x, self.frame.origin.y - 100, self.frame.width, self.frame.height + 100) NSAnimationContext.runAnimationGroup({ (context) -&gt; Void in context.duration = 0.5 self.animator().frame = newSize }, completionHandler: { Swift.print("completed") }) } </code></pre>
<swift><macos><cocoa><caanimation><nsanimationcontext>
2016-10-04 20:41:42
HQ
39,861,440
Indentation error basic program
<p>Hello I am beginner to python and am trying to learn, this is what i keep hitting when i execute the below code, where is the mistake</p> <pre><code>#!/usr/bin/python def main(): num1=input("Enter the 1st #\t\t") print "First # is\t:", num1 print num2=input("Enter the 2nd #\t\t") print "Second # is\t:",num2 print num3=input("Enter the 3rd #\t\t") print "3rd #is:,\t",num3 if(num1&gt;num2) and (num1&gt;num3): print"Highest # is:\t",num1 elif(num2&gt;num3) and (num2 &gt;num1): print"Highest # is:\t",num2 else: print "The WINNER IS\n" print num3 main() </code></pre> <p>Error:</p> <pre><code>python 1.py File "1.py", line 4 num1=input("Enter the 1st #\t\t") ^ IndentationError: expected an indented block </code></pre> <p>Where is the indentation that i am missing?</p>
<python>
2016-10-04 20:45:26
LQ_CLOSE
39,861,900
RESTEASY003145: Unable to find a MessageBodyReader of content-type application/json and type class org.keycloak.representations.AccessTokenResponse
<p>I'm trying to test Keycloak REST API. Instaled the version 2.1.0.Final. I can access the admin through browser with SSL without problems.</p> <p>I'm using the code above:</p> <pre><code>Keycloak keycloakClient = KeycloakBuilder.builder() .serverUrl("https://keycloak.intra.rps.com.br/auth") .realm("testrealm") .username("development") .password("development") .clientId("admin-cli") .resteasyClient(new ResteasyClientBuilder().connectionPoolSize(10).build()) .build(); List&lt;RealmRepresentation&gt; rr = keycloakClient.realms().findAll(); </code></pre> <p>And got the error:</p> <pre><code>javax.ws.rs.ProcessingException: RESTEASY003145: Unable to find a MessageBodyReader of content-type application/json and type class org.keycloak.representations.AccessTokenResponse javax.ws.rs.client.ResponseProcessingException: javax.ws.rs.ProcessingException: RESTEASY003145: Unable to find a MessageBodyReader of content-type application/json and type class org.keycloak.representations.AccessTokenResponse at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.extractResult(ClientInvocation.java:141) at org.jboss.resteasy.client.jaxrs.internal.proxy.extractors.BodyEntityExtractor.extractEntity(BodyEntityExtractor.java:60) at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientInvoker.invoke(ClientInvoker.java:104) at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientProxy.invoke(ClientProxy.java:76) at com.sun.proxy.$Proxy20.grantToken(Unknown Source) at org.keycloak.admin.client.token.TokenManager.grantToken(TokenManager.java:85) at org.keycloak.admin.client.token.TokenManager.getAccessToken(TokenManager.java:65) at org.keycloak.admin.client.token.TokenManager.getAccessTokenString(TokenManager.java:60) at org.keycloak.admin.client.resource.BearerAuthFilter.filter(BearerAuthFilter.java:52) at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.invoke(ClientInvocation.java:413) at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientInvoker.invoke(ClientInvoker.java:102) at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientProxy.invoke(ClientProxy.java:76) at com.sun.proxy.$Proxy22.findAll(Unknown Source) at br.com.rps.itsm.sd.SgpKeycloakClient.doGet(SgpKeycloakClient.java:71) at javax.servlet.http.HttpServlet.service(HttpServlet.java:687) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:284) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:263) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:174) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:793) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: javax.ws.rs.ProcessingException: RESTEASY003145: Unable to find a MessageBodyReader of content-type application/json and type class org.keycloak.representations.AccessTokenResponse at org.jboss.resteasy.core.interception.ClientReaderInterceptorContext.throwReaderNotFound(ClientReaderInterceptorContext.java:42) at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.getReader(AbstractReaderInterceptorContext.java:75) at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:52) at org.jboss.resteasy.plugins.interceptors.encoding.GZIPDecodingInterceptor.aroundReadFrom(GZIPDecodingInterceptor.java:59) at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:55) at org.jboss.resteasy.client.jaxrs.internal.ClientResponse.readFrom(ClientResponse.java:251) at org.jboss.resteasy.client.jaxrs.internal.ClientResponse.readEntity(ClientResponse.java:181) at org.jboss.resteasy.specimpl.BuiltResponse.readEntity(BuiltResponse.java:213) at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.extractResult(ClientInvocation.java:105) </code></pre> <p>I added the dependencies above, but do not solve my problem:</p> <pre><code> &lt;dependency&gt; &lt;groupId&gt;org.jboss.resteasy&lt;/groupId&gt; &lt;artifactId&gt;resteasy-client&lt;/artifactId&gt; &lt;version&gt;3.0.19.Final&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.jboss.resteasy&lt;/groupId&gt; &lt;artifactId&gt;resteasy-jackson-provider&lt;/artifactId&gt; &lt;version&gt;3.0.19.Final&lt;/version&gt; &lt;/dependency&gt; </code></pre> <p>Any clues?</p>
<java><jackson><resteasy><keycloak>
2016-10-04 21:16:49
HQ
39,862,926
Debugging not showing the proper result
<p>I am trying to learn the javascript debugging and I am followint the article here[linke here][1]</p> <p>[1]: <a href="http://meeech.amihod.com/getting-started-with-javascript-debugging-in-chrome/" rel="nofollow">http://meeech.amihod.com/getting-started-with-javascript-debugging-in-chrome/</a> I was able to follow along the tutorial.My code is</p> <pre><code>&lt;script&gt; var value="hang"; function test(){ setInterval(function(){ switch(value){ case'hang': document.body.innerHtml="Hang in there"; break; case'up': document.body.innerHTML="Up"; break; default: document.body.innerHTML="No good!"; } },1000); }; &lt;/script&gt; </code></pre> <p>Ater inspecting in debugger,it shows that it reached to <code>document.body.innerHtml="Hang in there";</code>But my html page isnot showing the output <strong>Hang in there</strong> Though it may seem simple question, I am not getting into it. Please help. Also I cannot find <strong>Add to watch option</strong> on right click as stated in tutorial.</p>
<javascript>
2016-10-04 22:48:15
LQ_CLOSE
39,863,149
Simple python: palindrome function (returns true if palindrome, false if not palindrome)
<p>Good evening folks,</p> <p>I'm working on an assignment for a course in Python. Our job is to write a function that returns True if the string it takes is a palindrome, otherwise it returns False. The following code reports False to the console for nonpalindromes, but does not report anything to the console when it is a palindrome. I hypothesize it's getting lost in either the recursive call or the second elif statement, but I really don't know where it's going wrong. Any help greatly appreciated :) Here's the code:</p> <pre><code>def middle(word): return word[1:-1] def last(word): return word[-1] def first(word): return word[0] def isPalindrome(word): if(len(word)&lt;1): print("You entered a blank word!") elif(len(word)==1): return True elif(first(word)==last(word)): if(middle(word)==''): return True isPalindrome(middle(word)) else: return False </code></pre>
<python><palindrome>
2016-10-04 23:15:21
LQ_CLOSE
39,863,538
Using operator keyword in a switch statement
<p>So I am trying to use the "operator" keyword in this switch statement but when I do I get the error "error: expected type-specifier before â:â token operator:" I am not getting any error for the digit keyword. Any ideas?</p> <pre><code>for (i=0; i &lt; pf.length(); i++) { int opn1; int opn2; int result; char token = pf[i]; switch (token) { digit: { chast.push(token); break; } operator: { opn2 = chast.top(); chast.pop(); opn1 = chast.top(); chast.pop(); result = evaluate(opn1, token, opn2); chast.push(result); break; } } } </code></pre>
<c++><linux>
2016-10-05 00:05:41
LQ_CLOSE
39,863,718
How can I log outside of main Flask module?
<p>I have a Python Flask application, the entry file configures a logger on the app, like so:</p> <pre><code>app = Flask(__name__) handler = logging.StreamHandler(sys.stdout) app.logger.addHandler(handler) app.logger.setLevel(logging.DEBUG) </code></pre> <p>I then do a bunch of logging using </p> <p><code>app.logger.debug("Log Message")</code></p> <p>which works fine. However, I have a few API functions like:</p> <pre><code>@app.route('/api/my-stuff', methods=['GET']) def get_my_stuff(): db_manager = get_manager() query = create_query(request.args) service = Service(db_manager, query) app.logger.debug("Req: {}".format(request.url)) </code></pre> <p>What I would like to know is how can I do logging within that <code>Service</code> module/python class. Do I have to pass the app to it? That seems like a bad practice, but I don't know how to get a handle to the app.logger from outside of the main Flask file...</p>
<python><logging><flask>
2016-10-05 00:31:36
HQ
39,863,725
Is it possible to append spaces and a certain amount of spaces to a string?
<p>Here is my current code. The question is exactly in the title. (I'm looking to be able to align my triangle correctly) </p> <pre><code>def Triangle(height): if height % 2 == 0: print "Please enter a height that is odd" else: stringTriangle = "x" for x in range(height): print stringTriangle for x in range(1): stringTriangle+="xx" </code></pre>
<python><string>
2016-10-05 00:32:26
LQ_CLOSE
39,863,760
Android AsyncTask vs Thread + Handler vs rxjava
<p>I know this is the question which was asked many many times. However there is something I never found an answer for. So hopefully someone can shed me some light.</p> <p>We all know that AsyncTask and Thread are options for executing background tasks to avoid ANR issue. It is recommended that asynctask should only be used for short-running tasks while thread can be used for long-running tasks. The reasons why asynctask shouldn't be used for long tasks are well-known which is about the possible leak caused by asynctask since it may continue running after an activity's destroyed. That is convincing. However, it also leads to some other questions:</p> <ol> <li>Isn't thread also independent from activity lifecycle? Thus, the risk with asynctask can also be applied to thread. So why thread is suitable for long-running tasks?</li> <li>Looks like the risk of asynctask is only applicable when using it with activity. If we use it in service (not IntentService since IntentService stops after its work's completed), and as long as we can guarantee to cancel the asyntask when the service's stopped, can we use it for long-running tasks? and doesn't it means it's risk free to use asynctask in services?</li> <li>I've played with rxjava for a while and really like it. It eliminates the need of worrying about threading (except you have to decide in which thread to subscribe and observe the emitted data). From what I can see, rxjava (in conjunction with some other libs like retrofits) seems to be a perfect replacement of asynctask and thread. I'm wondering if we could completely forget about them or there is any specific case that rxjava can't achieve what asynctask and thread can do that I should be aware of?</li> </ol> <p>Thanks</p>
<android><multithreading><android-asynctask><rx-java><android-handler>
2016-10-05 00:37:07
HQ
39,863,893
Load a Select from Radio in Flask/Python using Javascipt / jQuery
I'm trying to **load a input select control when the user select a radio option** in the form. The fields are built with flask-wtf, and populated dinamically in the view *(no problem with that)*: class FormRecord(Form): type = RadioField('Type') category = SelectField('Category') The JS script would execute the view that populate my select control: <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> $(document).ready(function() { $("#type").change(function() { $.ajax({ type: "POST", url: "{{ url_for('select_type') }}", data: {cat: $("#type").val()}, success: function(data) { $("#category").html(data); } }); }); }); <!-- end snippet --> It seems the javascript is not working correctly, but what I am doing wrong ? ...
<javascript><jquery><flask>
2016-10-05 00:57:10
LQ_EDIT
39,863,966
how to write xpath for web element on eBay web page having exactly same tags and attibutes
I am trying to write xapath for electronics link on eBay page but there seems to be two links with exactly same tags and attributes <a class="rt" _sp="p2057337.m1381.l3250" href="http://www.ebay.com/rpp/electronics">Electronics</a> I am using this xpath **//a[Text()='Electronics'] this path is giving me 2 nodes and i am not sure what else to use plzz help kindly refer to image attached for reference [electronics link][1] [electronics link][2] [1]: http://i.stack.imgur.com/0UGKM.png [2]: http://i.stack.imgur.com/URP6k.png
<xpath><selenium-webdriver>
2016-10-05 01:08:25
LQ_EDIT
39,864,385
How to access/expose kubernetes-dashboard service outside of a cluster?
<p>I have got the following services:</p> <pre><code>ubuntu@master:~$ kubectl get services --all-namespaces NAMESPACE NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE default kubernetes 100.64.0.1 &lt;none&gt; 443/TCP 48m kube-system kube-dns 100.64.0.10 &lt;none&gt; 53/UDP,53/TCP 47m kube-system kubernetes-dashboard 100.70.83.136 &lt;nodes&gt; 80/TCP 47m </code></pre> <p>I am attempting to access kubernetes dashboard. The following response seems reasonable, taking into account curl is not a browser.</p> <pre><code>ubuntu@master:~$ curl 100.70.83.136 &lt;!doctype html&gt; &lt;html ng-app="kubernetesDashboard"&gt; &lt;head&gt; &lt;meta charset="utf-8"&gt; &lt;title&gt;Kubernetes Dashboard&lt;/title&gt; &lt;link rel="icon" type="image/png" href="assets/images/kubernetes-logo.png"&gt; &lt;meta name="viewport" content="width=device-width"&gt; &lt;link rel="stylesheet" href="static/vendor.36bb79bb.css"&gt; &lt;link rel="stylesheet" href="static/app.d2318302.css"&gt; &lt;/head&gt; &lt;body&gt; &lt;!--[if lt IE 10]&gt; &lt;p class="browsehappy"&gt;You are using an &lt;strong&gt;outdated&lt;/strong&gt; browser. Please &lt;a href="http://browsehappy.com/"&gt;upgrade your browser&lt;/a&gt; to improve your experience.&lt;/p&gt; &lt;![endif]--&gt; &lt;kd-chrome layout="column" layout-fill&gt; &lt;/kd-chrome&gt; &lt;script src="static/vendor.633c6c7a.js"&gt;&lt;/script&gt; &lt;script src="api/appConfig.json"&gt;&lt;/script&gt; &lt;script src="static/app.9ed974b1.js"&gt;&lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>According to the documentation the right access point is <a href="https://localhost/ui" rel="noreferrer">https://localhost/ui</a>. So, I am trying it and receive a bit worrying result. <strong>Is it expected response?</strong></p> <pre><code>ubuntu@master:~$ curl https://localhost/ui curl: (60) server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none More details here: http://curl.haxx.se/docs/sslcerts.html curl performs SSL certificate verification by default, using a "bundle" of Certificate Authority (CA) public keys (CA certs). If the default bundle file isn't adequate, you can specify an alternate file using the --cacert option. If this HTTPS server uses a certificate signed by a CA represented in the bundle, the certificate verification probably failed due to a problem with the certificate (it might be expired, or the name might not match the domain name in the URL). If you'd like to turn off curl's verification of the certificate, use the -k (or --insecure) option. </code></pre> <p>Trying the same without certificate validation. For curl it might be OK. but I have got the same in a browser, which is connecting though port forwarding via vagrant forwarded_port option.</p> <pre><code>ubuntu@master:~$ curl -k https://localhost/ui Unauthorized </code></pre> <p><strong>What I am doing wrong? and how to make sure I can access the UI?</strong> Currently it responds with Unauthorized.</p> <p>The docs for the dashboard tell the password is in the configuration:</p> <pre><code>ubuntu@master:~$ kubectl config view apiVersion: v1 clusters: [] contexts: [] current-context: "" kind: Config preferences: {} users: [] </code></pre> <p>but it seems I have got nothing... <strong>Is it expected behavior? How can I authorize with the UI?</strong></p>
<kubernetes>
2016-10-05 02:07:05
HQ
39,864,420
Cannot read property 'x' of undefined
<p>So I have been trying to put together a simple little text based RPG and I just finished creating objects for the buttons and the different types of characters. When I stopped for the day and saved, I had no errors, but I came back on today and received the error "Cannot read property 'x' of undefined." The error had no lines of code listed, and I had no errors listed other than that. I only have used 'x' in the Button object so I assume the issue is somewhere in this block of code:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>//selection buttons var Button = function(config) { this.x = config.x || 5; this.y = config.y || 2; this.width = config.width || 390; this.height = config.height || 96; this.vrtx = config.vrtx || 50; //curve on the corners this.lable = config.lable || "Click Here"; this.r = config.r || 100; this.b = config.b || 100; this.g = config.g || 100; }; Button.prototype.draw = function() { strokeWeight(5); stroke(this.r / 2, this.b / 2, this.g / 2); fill(this.r, this.b, this.g); rect(this.x, this.y, this.width, this.height, this.vrtx); fill(0, 0, 0); textSize(27); textAlign(LEFT, TOP); text(this.label, this.x + 10, this.y + this.height / 4); }; var btn1 = new Button( /*customize button*/ );</code></pre> </div> </div> </p> <p>Just incase it isn't in that section, here i the rest of the code:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>//classes var mage; var warrior; var rogue; var cleric; //stats var manaLvl; var strengthLvl; var stealthLvl; var xpLvl = 10; var enemyCount = 0; //# of enemies defeted var lvl; //player's level //player stats and level up var character = function(health, armour, packSize, packItems, mana, strength, stealth, xp) { this.health = health; this.defArmour = armour; this.packSize = packSize; this.packItems = packItems; this.mana = mana; this.strength = strength; this.stealth = stealth; this.xp = xp; }; Character.prototype.lvlUp = function() { this.health += 2; this.packSize += 1; this.mana += manaLvl; this.strength += strengthLvl; this.stealth += stealthLvl; enemyCount = 0; }; character.prototype.xpGain = function() { this.xp = enemyCount * xpLvl; if (this.xp === 100) { character.lvlUp(); } }; character.prototype.packStorage = function() { if (this.packItems &lt; this.packSize) { //allow player to store items } }; //selection buttons var Button = function(config) { this.x = config.x || 5; this.y = config.y || 2; this.width = config.width || 390; this.height = config.height || 96; this.vrtx = config.vrtx || 50; //curve on the corners this.lable = config.lable || "Click Here"; this.r = config.r || 100; this.b = config.b || 100; this.g = config.g || 100; }; Button.prototype.draw = function() { strokeWeight(5); stroke(this.r / 2, this.b / 2, this.g / 2); fill(this.r, this.b, this.g); rect(this.x, this.y, this.width, this.height, this.vrtx); fill(0, 0, 0); textSize(27); textAlign(LEFT, TOP); text(this.label, this.x + 10, this.y + this.height / 4); }; var btn1 = new Button( /*customize button*/ ); //class selection if (mage === true) { var lvl = new character(10, 5, 10, 20, 5, 5); manaLvl = 3; strengthLvl = 1; stealthLvl = 1; } else if (warrior === true) { var lvl = new character(20, 20, 5, 20, 5, 5); manaLvl = 1; strengthLvl = 3; stealthLvl = 1; } else if (rogue === true) { var lvl = new character(15, 10, 10, 20, 5, 5); manaLvl = 1; strengthLvl = 2; stealthLvl = 2; } else if (cleric === true) { var lvl = new character(15, 10, 15, 5, 10, 15); manaLvl = 2; strengthLvl = 2; stealthLvl = 1; } var draw = function() { btn1.draw(); };</code></pre> </div> </div> </p> <p>If anyone knows what the issue is I would be very thankful for your help!</p>
<javascript><object><methods>
2016-10-05 02:13:08
LQ_CLOSE
39,864,526
vue is not defined on the instance but referenced during render
<p>I'm trying to build a simple app in vue and I'm getting an error. My onScroll function behaves as expected, but my sayHello function returns an error when I click my button component</p> <blockquote> <p>Property or method "sayHello" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option. (found in component )</p> </blockquote> <pre><code>Vue.component('test-item', { template: '&lt;div&gt;&lt;button v-on:click="sayHello()"&gt;Hello&lt;/button&gt;&lt;/div&gt;' }); var app = new Vue({ el: '#app', data: { header: { brightness: 100 } }, methods: { sayHello: function() { console.log('Hello'); }, onScroll: function () { this.header.brightness = (100 - this.$el.scrollTop / 8); } } }); </code></pre> <p>I feel like the answer is really obvious but I've tried searching and haven't come up with anything. Any help would be appreciated.</p> <p>Thanks.</p>
<javascript><vue.js>
2016-10-05 02:28:17
HQ
39,864,596
My dud keeps falling through barrier
in unity i made a test sprite with this script but my dud falls through the ground when i jump fast or at random but stays on wail he is moving slow but falls through wen jumping/landing fast. Any help will be appreciated :) using UnityEngine; using System.Collections; public class code : MonoBehaviour { //void FixedUpdate() { /*if (Input.GetKey (KeyCode.LeftArrow)) { int Left = 1; } if (Input.GetKey (KeyCode.RightArrow)) { int Right = 1; } if (Input.GetKey(KeyCode.UpArrow)) { } */ public float speed1 = 6.0F; public float jumpSpeed = 8.0F; public float gravity = 20.0F; private Vector3 moveDirection = Vector3.zero; void FixedUpdate() { CharacterController controller = GetComponent<CharacterController>(); // is the controller on the ground? if (controller.isGrounded) { //Feed moveDirection with input. moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")); moveDirection = transform.TransformDirection(moveDirection); //Multiply it by speed. moveDirection *= speed1; //Jumping if (Input.GetButton("Jump")) moveDirection.y = jumpSpeed; if (Input.GetKey (KeyCode.UpArrow)) moveDirection.y = jumpSpeed; } //Applying gravity to the controller moveDirection.y -= gravity * Time.deltaTime; //Making the character move controller.Move(moveDirection * Time.deltaTime); } }
<c#><unity3d>
2016-10-05 02:37:40
LQ_EDIT
39,864,957
Find the kth smallest element in two sorted arrays with complexity of (logn)^2
<p>S and T are two sorted arrays with n elements (integer) each ,describe an algorithm to find the kth smallest number in the union of two arrays(assuming no duplicates) with time complexity of (logn)^2. Note that it is fairly easy to find an algorithm with complexity of logn. </p>
<arrays><algorithm><sorting>
2016-10-05 03:27:51
LQ_CLOSE
39,865,571
Trying to make a point to point calculator. Unsupported operand types?
<p>Im trying to make a program which calculates the distance between two user inputted points. How can I fix this so that it works? So far I have this</p> <pre><code>import math p1 = [int(input("PLease enter point 1x\n")), (input("Please enter point 1y\n"))] p2 = [int(input("PLease enter point 2x\n")), (input("Please enter point 2y\n"))] distance = math.sqrt( ((p1[0]-p2[0])**2)+((p1[1]-p2[1])**2) ) print(distance) </code></pre> <p>The error that it spits out at me is: TypeError: unsupported operand type(s) for -: 'str' and 'str'</p> <p>Am I going about this in the right way at all?</p>
<python><string><python-3.x><math><operand>
2016-10-05 04:43:20
LQ_CLOSE
39,865,822
Creating an object from a class
<p>For example</p> <pre><code>Dictionary webster = new Dictionary(); </code></pre> <p>what does each dictionary mean technically? I understand that I'm creating a object that has its methods and variables. But what causes this?</p> <p>Furthermore I am learning about Data structures.. Same exact question really but can the left and right side be different? Ex</p> <pre><code>ArrayList&lt;String&gt; list = new LinkedList&lt;String&gt;(); </code></pre> <p>I know </p> <pre><code>ArrayList&lt;String list = new ArrayList&lt;String&gt;(); works </code></pre> <p>but like I said I'm confused on what each side brings when my object is created..</p>
<java>
2016-10-05 05:08:10
LQ_CLOSE
39,865,829
What is the difference between managed-schema and schema.xml
<p>I have below questions in solr 6.</p> <ol> <li>What is the main difference between managed-schema and schema.xml</li> <li>What are the benefits and disadvantages while using managed-schema and schema.xml(classic).</li> </ol> <p>And could you please help me in understanding what is recommended in solr6?</p> <p>Regards,</p> <p>Shaffic</p>
<solr><schema><managed>
2016-10-05 05:09:07
HQ
39,866,000
java try-with-resource not working with scala
<p>In Scala application, am trying to read lines from a file using java nio try-with-resource construct.</p> <p>Scala version 2.11.8<br> Java version 1.8</p> <pre><code>try(Stream&lt;String&gt; stream = Files.lines(Paths.get("somefile.txt"))){ stream.forEach(System.out::println); // will do business process here }catch (IOException e) { e.printStackTrace(); // will handle failure case here } </code></pre> <p>But the compiler throws error like<br> ◾not found: value stream<br> ◾A try without a catch or finally is equivalent to putting its body in a block; no exceptions are handled.</p> <p>Not sure what is the problem. Am new to using Java NIO, so any help is much appreciated.</p>
<java><scala><try-with-resources>
2016-10-05 05:25:23
HQ
39,866,089
Get string characters until number reached
<p>Basically, I want to get the letters of the string from the first character until a number is reached.</p> <p>Example</p> <p>Input: asdfblabla2012365adsf</p> <p>Output: asdfblabla</p>
<php><regex><string>
2016-10-05 05:32:51
LQ_CLOSE
39,866,869
How to ask permission to access gallery on android M.?
<p>I have this app that will pick image to gallery and display it to the test using Imageview. My problem is it won't work on Android M. I can pick image but won't show on my test.They say i need to ask permission to access images on android M but don't know how. please help.</p>
<java><android>
2016-10-05 06:30:17
HQ
39,866,890
Track user location through mobile number
<p>I want to create an application, when I enter any mobile number it should give me current location of that number. Guys please help me if it is possible then tell me how it is possible ?</p>
<android><google-maps><mobile><geolocation><locationmanager>
2016-10-05 06:31:42
LQ_CLOSE
39,867,325
iOS 10 bug: UICollectionView received layout attributes for a cell with an index path that does not exist
<p>Running my app in a device with iOS 10 I get this error:</p> <p><em>UICollectionView received layout attributes for a cell with an index path that does not exist</em></p> <p>In iOS 8 and 9 works fine. I have been researching and I have found that is something related to invalidate the collection view layout. I tried to implement that solution with no success, so I would like to ask for direct help. This is my hierarchy view:</p> <pre><code>-&gt;Table view -&gt;Each cell of table is a custom collection view [GitHub Repo][1] -&gt;Each item of collection view has another collection view </code></pre> <p>What I have tried is to insert</p> <pre><code> [self.collectionView.collectionViewLayout invalidateLayout]; </code></pre> <p>In the</p> <pre><code>- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView </code></pre> <p>of both collection views. </p> <p>Also I have tried to invalidate layout before doing a reload data, does not work...</p> <p>Could anyone give me some directions to take?</p>
<ios><uicollectionview><ios10><uicollectionviewlayout>
2016-10-05 06:58:34
HQ
39,867,602
no internet inside docker-compose service
<p><strong>I cannot reach external network from docker-compose containers.</strong></p> <p>Consider the following docker-compose file:</p> <pre><code>version: '2' services: nginx: image: nginx </code></pre> <p>Using the simple <code>docker run -it nginx bash</code> I manage to reach external IPs or Internet IPs (<code>ping www.google.com</code>). </p> <p>On the other hand if I use docker-compose and attach to the container, I cannot reach external IP addresses / DNS.</p> <p>docker info:</p> <pre><code>Containers: 0 Running: 0 Paused: 0 Stopped: 0 Images: 1 Server Version: 1.12.1 Storage Driver: aufs Root Dir: /var/lib/docker/aufs Backing Filesystem: extfs Dirs: 7 Dirperm1 Supported: true Logging Driver: json-file Cgroup Driver: cgroupfs Plugins: Volume: local Network: bridge null host overlay Swarm: inactive Runtimes: runc Default Runtime: runc Security Options: apparmor seccomp Kernel Version: 4.4.0-38-generic Operating System: Ubuntu 16.04.1 LTS OSType: linux Architecture: x86_64 CPUs: 2 Total Memory: 3.859 GiB Name: *** ID: **** Docker Root Dir: /var/lib/docker Debug Mode (client): false Debug Mode (server): false Registry: https://index.docker.io/v1/ WARNING: No swap limit support WARNING: bridge-nf-call-iptables is disabled WARNING: bridge-nf-call-ip6tables is disabled Insecure Registries: 127.0.0.0/8 </code></pre> <p>docker-compose 1.8.1, build 878cff1</p> <p>daemon.json file:</p> <pre><code>{ "iptables" : false, "dns" : ["8.8.8.8","8.8.4.4"] } </code></pre>
<docker><docker-compose><docker-networking>
2016-10-05 07:13:39
HQ
39,868,041
How to change port number of Appache server in ubuntu
I want to change my port number 80 to some other number of my Appache server . how it possible in ubuntu
<apache>
2016-10-05 07:38:09
LQ_EDIT
39,868,491
How to Clear() all elements from Entity Framework ICollection?
<p>I have problems removing all elements from a collection in entity framework using Clear()</p> <p>Consider the often used example with Blogs and Posts.</p> <pre><code>public class Blog { public int Id {get; set;} public string Name {get; set;} public virtual ICollection&lt;Post&gt; Posts { get; set; } } public class Post { public int Id { get; set; } // foreign key to Blog: public int BlogId { get; set; } public virtual Blog Blog { get; set; } public string Title { get; set; } public string Text { get; set; } } public class BlogContext : DbContext { public DbSet&lt;Blog&gt; Blogs {get; set;} public DbSet&lt;Post&gt; Posts {get; set;} } </code></pre> <p>A Blog has many Posts. A Blog has an ICollection of Posts. There is a straightforward one-to-many relation between Blogs and Posts.</p> <p>Suppose I want to remove all Posts from a Blog</p> <p>Of course I could do the following:</p> <pre><code>Blog myBlog = ... var postsToRemove = dbContext.Posts.Where(post =&gt; post.BlogId == myBlog.Id); dbContext.RemoveRange(postsToRemove); dbContext.SaveChanges(); </code></pre> <p>However, the following seems easier:</p> <pre><code>Blog myBlog = ... myBlog.Posts.Clear(); dbContext.SaveChanges(); </code></pre> <p>However this leads to an InvalidOperationException:</p> <p><em>The operation failed: The relationship could not be changed because one or more of the foreign-key properties is non-nullable. When a change is made to a relationship, the related foreign-key property is set to a null value. If the foreign-key does not support null values, a new relationship must be defined, the foreign-key property must be assigned another non-null value, or the unrelated object must be deleted.</em></p> <p>What is the proper way to clear the collection? Is there a fluent API statement for this?</p>
<c#><entity-framework><icollection>
2016-10-05 08:02:32
HQ