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,467,362 | Can't run unit tests in Xcode 8 with earlier unit test configuration | <p>I ran into this issue after upgrading to Xcode 8. When running the tests I get this error at run time:</p>
<p><code>/Users/<me>/work/<appname>/Build/Intermediates/<appname>.build/Debug-iphonesimulator/<appname>UnitTests.build/Script-231C35D610AC1F5000D830C2.sh: line 3: /Applications/Xcode.app/Contents/Developer/Tools/RunUnitTests: No such file or directory</code></p>
<p>The sh script in the error message is trying to access the RunUnitTests tool and fails. I assume this tool has been removed in Xcode 8. It seems that for my project Xcode tries to run tests in a way that is no longer supported. If I create a brand new project no such script is created and I can run tests.</p>
<p>Any idea what settings I need to update in my project to get the tests running again? I tried the 'Update to recommended settings' checklist but it doesn't solve this issue.</p>
| <ios><xcode><xctest><xcode8> | 2016-09-13 10:07:12 | HQ |
39,467,452 | How to validate time in laravel | <p>I want to validate time in Laravel. Ex:- I want that when user input the time between 8 PM to 10 PM then it will show the validation error. How can I achieve that in Laravel</p>
| <php><laravel><laravel-validation> | 2016-09-13 10:11:23 | HQ |
39,467,553 | Installed and Activate plugin – but nothing different and no amp pages detected | I have just installed and activated the plugin. All good no issues. I cleared cache and checked my site on a mobile device to see how it now displays and there is no difference.Is there more I need to do after activating the plugin. All replies will be most appreciated. | <wordpress><accelerated-mobile-page> | 2016-09-13 10:16:49 | LQ_EDIT |
39,468,022 | How do I know if my code is running as React Native | <p>I want to be able to export a package for all platforms, but I am using some native bindings with a plain JS fallback. Normally I would notice the difference
checking if object <code>window</code> or <code>exports</code> exist.</p>
<p>How can I achieve this on React Native?</p>
| <javascript><react-native> | 2016-09-13 10:40:02 | HQ |
39,468,170 | Automatic properties documentation for Java application | <p>Are there "Javadoc-like" instruments for configuration properties in Java application?</p>
<p>I'm currently working on Java application, which uses usual Java properties files for configuration. This is an "enterprise app", so we have dozens of properties and it's really difficult to support documentation for them.</p>
<p>So I want to find a tool or framework which makes it possible to describe properties in code, for example with annotations, and then export the documentation to a file. </p>
<p>We already use Javadoc and Swagger for documentation - it's quite convenient. It would be helpful to have something similar for properties.</p>
| <java><properties> | 2016-09-13 10:46:59 | HQ |
39,468,450 | ngModel with a bind function not working in ng2 | <p>If I do in a template of a component something like:</p>
<pre><code><input [(ngModel)]="myProperty"></input>
</code></pre>
<p>then it works, but if I do it with a function in my component it does not:</p>
<pre><code><input [(ngModel)]="getMyProperty()"></input>
</code></pre>
<p><a href="https://plnkr.co/edit/j0FZIIqSH94QEoOJrmsv?p=preview" rel="noreferrer">Here</a> is the plunkr. Tested on RC6. Why?</p>
| <angular><model-binding><angular-ngmodel> | 2016-09-13 11:03:51 | HQ |
39,468,640 | TensorFlow freeze_graph.py: The name 'save/Const:0' refers to a Tensor which does not exist | <p>I am currently trying to export a trained TensorFlow model as a ProtoBuf file to use it with the TensorFlow C++ API on Android. Therefore, I'm using the <a href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/tools/freeze_graph.py" rel="noreferrer"><code>freeze_graph.py</code></a> script.</p>
<p>I exported my model using <code>tf.train.write_graph</code>:</p>
<p><code>tf.train.write_graph(graph_def, FLAGS.save_path, out_name, as_text=True)
</code></p>
<p>and I'm using a checkpoint saved with <code>tf.train.Saver</code>.</p>
<p>I invoke <code>freeze_graph.py</code> as described at the top of the script. After compiling, I run</p>
<pre><code>bazel-bin/tensorflow/python/tools/freeze_graph \
--input_graph=<path_to_protobuf_file> \
--input_checkpoint=<model_name>.ckpt-10000 \
--output_graph=<output_protobuf_file_path> \
--output_node_names=dropout/mul_1
</code></pre>
<p>This gives me the following error message:</p>
<pre><code>TypeError: Cannot interpret feed_dict key as Tensor: The name 'save/Const:0' refers to a Tensor which does not exist. The operation, 'save/Const', does not exist in the graph.
</code></pre>
<p>As the error states I do not have a tensor <code>save/Const:0</code> in my exported model. However, the code of <code>freeze_graph.py</code> says that one can specify this tensor name by the flag <code>filename_tensor_name</code>. Unfortunately I cannot find any information on what this tensor should be and how to set it correctly for my model.</p>
<p>Can somebody tell my either how to produce a <code>save/Const:0</code> tensor in my exported ProtoBuf model or how to set the flag <code>filename_tensor_name</code> correctly?</p>
| <python><tensorflow><protocol-buffers> | 2016-09-13 11:14:08 | HQ |
39,468,841 | Is it possible to start a stopped container from another container | <p>There are two containers A and B. Once container A starts, one process will be executed, then the container will stop. Container B is just an web application (say expressjs). Is it possible to kickstart A from container B ?</p>
| <docker><docker-container> | 2016-09-13 11:25:02 | HQ |
39,469,087 | JavaScript: What's the difference between a positive look ahead and a non-capturing group? | <p>If I get it right then a positive look ahead ( ?= ) as well a non-capturing group ( ?: ) are used for to excluse a part of the string in the final match-results. </p>
<p><strong>What is the difference between the a lookahead and a non-capturing group?</strong></p>
<p>Can anyone explain? Preferable with an easy understandable example?</p>
| <javascript><regex> | 2016-09-13 11:38:32 | LQ_CLOSE |
39,469,701 | SystemJS making ~200 requests for non-existing files | <p>I'm really lost about this. When I load my Angular2 app, I have about 200 requests to my server for non-existing files under <code>node_modules/systemjs</code>. Here's a sample of of those requests:</p>
<pre><code>127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/Subject.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/Observable.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/root.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/toSubscriber.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/Subscriber.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/isFunction.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/Subscription.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/isArray.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/isObject.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/tryCatch.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/errorObject.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/UnsubscriptionError.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/Observer.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/rxSubscriber.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/observable.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/ObjectUnsubscribedError.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/SubjectSubscription.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/from.js.map HTTP/1.1" 404 -
</code></pre>
<p>My Angular2 application works fine, I don't get a single error, everything functions as expected. But those ~200 404 requests are really slowing down the page load. For a reason I really can't understand, those 404 requests don't even show up in my browser's <code>network</code> tab, but Wireshark confirms they are coming from there.</p>
<p>Here is my <code>systemjs.config.js</code>:</p>
<pre><code>/**
* System configuration for Angular 2 samples
* Adjust as necessary for your application needs.
*/
(function (global) {
System.config({
defaultJSExtensions: true,
paths: {
// paths serve as alias
'npm:': 'node_modules/'
},
// map tells the System loader where to look for things
map: {
// our app is within the app folder
app: 'app',
// angular bundles
'@angular/core': 'npm:@angular/core/bundles/core.umd.js',
'@angular/common': 'npm:@angular/common/bundles/common.umd.js',
'@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/http': 'npm:@angular/http/bundles/http.umd.js',
'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
// angular testing umd bundles
'@angular/core/testing': 'npm:@angular/core/bundles/core-testing.umd.js',
'@angular/common/testing': 'npm:@angular/common/bundles/common-testing.umd.js',
'@angular/compiler/testing': 'npm:@angular/compiler/bundles/compiler-testing.umd.js',
'@angular/platform-browser/testing': 'npm:@angular/platform-browser/bundles/platform-browser-testing.umd.js',
'@angular/platform-browser-dynamic/testing': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic-testing.umd.js',
'@angular/http/testing': 'npm:@angular/http/bundles/http-testing.umd.js',
'@angular/router/testing': 'npm:@angular/router/bundles/router-testing.umd.js',
'@angular/forms/testing': 'npm:@angular/forms/bundles/forms-testing.umd.js',
// other libraries
'rxjs': 'npm:rxjs',
'angular2-in-memory-web-api': 'npm:angular2-in-memory-web-api',
'moment': 'npm:moment/moment',
'ng2-bs3-modal': 'npm:ng2-bs3-modal',
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
app: {
main: './main.js',
defaultExtension: 'js'
},
rxjs: {
defaultExtension: 'js'
},
'angular2-in-memory-web-api': {
main: './index.js',
defaultExtension: 'js'
},
}
});
})(this);
</code></pre>
| <javascript><angular><http-status-code-404><systemjs> | 2016-09-13 12:07:56 | HQ |
39,469,810 | How to set stroke color to draw a rectangle on canvas? | <p>I want to draw a round rectangle which its stroke is blue and its fill is red, but I can't find a method in Paint class to set stroke color. How can I do that?</p>
<pre><code> mCanvas.drawColor(mBackgroundColor, PorterDuff.Mode.CLEAR);
mCanvas.setDrawFilter(mPaintFlagsDrawFilter);
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
mPaint.setColor(Color.RED);
mPaint.setStrokeWidth(2);
mPaint.setStrokeCap(Paint.Cap.ROUND);
mRectF.set(0, 0, mWidth, mHeight);
mCanvas.drawRoundRect(mRectF, 10, 10, mPaint);
</code></pre>
| <android><android-canvas> | 2016-09-13 12:13:04 | HQ |
39,470,046 | create an array from elements in a string, elemets start with certain key/sign | <p>I want to abstract an array with text strings that reside in a text, each text element starts with a certain sign or key e.g. $ or &. how can I achieve this?</p>
<p>so "$Huey, $Dewey, and $Louie all live in Duckcity. $Goofy and $Mickey live there too." should result in </p>
<pre><code>string characters = {"Heuy","Dewey", "Louie", "Goofy","Mickey"};
</code></pre>
| <java><arrays><string> | 2016-09-13 12:24:45 | LQ_CLOSE |
39,470,216 | R - aggregating sum row wise | <p>I have a data frame mydf as <code> mydf <- data.frame(month = c('apr', 'may', 'june'),cost = c(100, 150, 200))</code></p>
<p>I wish to get a runningTotal that sums each record cumulatively</p>
<pre><code> month cost runningTotal
1 apr 100 100
2 may 150 250
3 june 200 450
</code></pre>
<p>I tried using dplyr sum but didn't work.
Can someone help me find the most efficient way of doing this
Thanks.</p>
| <r><dplyr> | 2016-09-13 12:32:52 | LQ_CLOSE |
39,470,279 | iOS 10 compatibility to iOS 9 apps | <p>I have launched my iOS app written in swift 2.2 and supports iOS 9 and watch OS 2.2 in app store. iOS 10 is going to be released tomorrow. How will the app work on iOS 10 environment if any users upgrade to it till the app updates on iOS 10 support are pushed to app store?</p>
<p>I know swift 3 has syntax level changes in methods and a lot. Could anyone please suggest me what the best solution is ? </p>
| <ios><apple-watch><xcode8> | 2016-09-13 12:35:42 | LQ_CLOSE |
39,471,035 | Visual Studio not downloading DLL for NuGet package | <p>We have a few NuGet packages on our local TeamCity server, and use these in various projects. I have just come back from holiday, grabbed the latest from source code, and tried to rebuild, only to get a pile of compilation errors due to a missing DLL.</p>
<p>It seems that the DLL for one of our packages was not downloaded from NuGet. I tried starting a new WPF project, and adding three of the packages. All three appear in the packages.config file, but only two of them have the DLLs downloaded. The third has only the *.pdb file downloaded.</p>
<p>No-one else on the team has this problem, and I tried it on my spare machine, and it downloaded fine, so it looks like it's an issue with my machine, Visual Studio or NuGet installation. However, as I can grab other packages from the same source without problem, it doesn't look like it's a global problem with either VS or NuGet.</p>
<p>I realise there isn't much to go on, but I don't know what else to tell you. If anyone can suggest anything, I would be very grateful. As the package source is our own, I can't share that unfortunately.</p>
<p>I'm using Visual Studio Enterprise 2015 Update 3 (build 14.0.25424.00) with NuGet package manager version 3.4.4.1321 on Windows 10 Pro 64 bit (version 1607, build 14393.105). If there's anything else I can add, please let me know.</p>
| <visual-studio-2015><nuget> | 2016-09-13 13:13:15 | HQ |
39,471,075 | When to use GraphQLID instead of GraphQLInt? | <p>It is not clear when to use <a href="http://graphql.org/docs/api-reference-type-system/#graphqlid" rel="noreferrer"><code>GraphQLID</code></a> instead of <a href="http://graphql.org/docs/api-reference-type-system/#graphqlint" rel="noreferrer"><code>GraphQLInt</code></a>.</p>
<p>Consider the following schema:</p>
<pre><code>type User {
id: Int!
firstName: String!
lastName: String!
}
type Query {
user (id: ID!): User
}
</code></pre>
<p>In case of <code>Query.user</code>, it seem to make no difference whether to use <code>GraphQLID</code> or <code>GraphQLInt</code>.</p>
<p>In case of <code>User.id</code>, using <code>GraphQLID</code> will cast the input to string. Using <code>GraphQLInt</code> will ensure that the input is an integer.</p>
<p>This makes the query and type system inconsistent.</p>
<p>The <a href="/questions/tagged/graphql-js" class="post-tag" title="show questions tagged 'graphql-js'" rel="tag">graphql-js</a> <a href="http://graphql.org/docs/api-reference-type-system/#graphqlid" rel="noreferrer">spec</a> simply says:</p>
<blockquote>
<p>A <code>GraphQLScalarType</code> that represents an ID.</p>
</blockquote>
<p>Is this an implementation detail (e.g. should GraphQL client cast <code>GraphQLID</code> to an integer when it can), or is it expected that <code>ID</code> is always a string in <a href="/questions/tagged/graphql" class="post-tag" title="show questions tagged 'graphql'" rel="tag">graphql</a>?</p>
| <graphql><graphql-js> | 2016-09-13 13:15:13 | HQ |
39,471,896 | How to compile all included files into one using Babel? | <p>I am using Babel in my project. The thing is, I have this line of code in my <code>server.js</code>:</p>
<pre><code>import schema from "./data/schema";
</code></pre>
<p>(<code>data/schema.js</code> is in ES2015 syntax).</p>
<p>And when I am trying to compile my <code>server.js</code> with babel, like this:</p>
<pre><code>babel -o server_production.js --minified server.js
</code></pre>
<p>it produces a new file without errors and replaces <code>import</code> instruction with <code>require</code>. But the thing is, when I am trying to run my babel-compiled <code>server.js</code> with <code>node</code>, it complains about <code>data/schema.js</code>, because it wasn't transpiled into ES5, only required (the exact error is <code>Unexpected token "import"</code>, because I am using some other imports in <code>data/schema.js</code>).</p>
<p>So, the question is: how can I compile my file and all the files it <code>import</code>s into one file? I tried <code>babel -o server_production.js --minified data/schema.js server.js</code>, but that didn't work either.</p>
| <javascript><node.js><ecmascript-6><babel> | 2016-09-13 13:55:27 | HQ |
39,472,115 | Each row sharey individually? | <p>I have a two-by-two plot that I am creating dynamically. In the first row I want to plot density functions, in the second row CDFs. I want </p>
<ul>
<li>each of the columns to share x</li>
<li>each of the rows to share y</li>
</ul>
<p>That is, two objects aligned vertically have the same x-axis, and two plots aligned horizontally have the same y-axis.</p>
<p>However, <code>sharex</code> and <code>sharey</code> force them to be the same for all of the subplots. How can I fix this sort of axes sharing? I understand that I could be manually giving each axes a share partner, but that wouldn't work with the generic structure that follows: </p>
<pre><code>fig, axes = plt.subplots(nrows=2, ncols=2, sharex=True)
for i, lam in enumerate(lams):
axesNow = [axs[i] for axs in axes] # pick the ith column from axes
for i, Param.p in enumerate(pp):
axesNow[0].plot(somethingWithPDF)
axesNow[1].plot(somethingWithCDF)
for ax in axes.flatten(): ax.legend()
</code></pre>
<p><a href="https://i.stack.imgur.com/7SxTV.png" rel="noreferrer"><img src="https://i.stack.imgur.com/7SxTV.png" alt="enter image description here"></a></p>
| <python><matplotlib> | 2016-09-13 14:07:25 | HQ |
39,474,029 | cos/sin/tan function gives different result than my calculator | <p>If I enter </p>
<pre><code>cos(90)
</code></pre>
<p>I get</p>
<pre><code>-0.4480736
</code></pre>
<p>But my calculator gives</p>
<pre><code>0
</code></pre>
<p>I don't get it.</p>
<pre><code>?cos
These functions give the obvious trigonometric functions. They
respectively compute the cosine, sine, tangent, arc-cosine,
arc-sine, arc-tangent, and the two-argument arc-tangent.
</code></pre>
<p>Obvious?</p>
| <r> | 2016-09-13 15:40:41 | LQ_CLOSE |
39,474,038 | How to recover my website page ranking, after using google analytics? | <p>My website was ranking in the fifth page when searching company name on google. But after i added key words with meta tag and google analytics code for better seo i lost my website name presence in entire google search results.Now google analytics showing i have more than page visitors than before. But bounce rate is 82%. If you can suggest me what i can do to bring my website name in search results , that would be a great help for me.</p>
<p>thanks,<a href="https://i.stack.imgur.com/rFYmD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rFYmD.png" alt="enter image description here"></a></p>
| <google-analytics><seo><meta-tags><google-ranking> | 2016-09-13 15:41:12 | LQ_CLOSE |
39,475,166 | TypeScript: error when using parseInt() on a number | <p>The JavaScript function <code>parseInt</code> can be used to force conversion of a given parameter to an integer, whether that parameter is a string, float number, number, etc. </p>
<p>In JavaScript, <code>parseInt(1.2)</code> would yield <code>1</code> with no errors, however, in TypeScript, it throws an error during compilation saying: </p>
<pre><code>error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'.
</code></pre>
<p>Am I missing something here or is it an expected behaviour from TypeScript? </p>
| <javascript><typescript> | 2016-09-13 16:47:15 | HQ |
39,475,860 | 3 join tables mysql HELP ME | this is my table
program_join ('program_join_id, member_ID, program_schedule_id');
program_schedule (program_scedule_id, program_id, datetime');
program ('program_id, program_name);
this is my mysql
$mySql = "SELECT
program_join.program_join_id,
member.member_username,
program_join.program_schedule_id
FROM program_join
INNER JOIN member ON
program_join.member_ID=member.member_ID
ORDER BY program_join_id ASC LIMIT $hal, $line";
$myQry = mysql_query($mySql, $DB) or die ("wrong query : ".mysql_error());
$number = $hal;
while ($myData = mysql_fetch_row($myQry)) {
$number++;
$code = $myData[0];
?>
<tr align="center">
<td><?php echo $number;?></td>
<td><?php echo $myData[1];?></td>
<td><?php echo $myData[2];?></td>
result
No username program schedule
1 lalala 1
2 bababba 2
and under the 'program schedule', i want to show the program name that i have from the ' program_join.program_schedule_id'
please help me | <mysql> | 2016-09-13 17:31:30 | LQ_EDIT |
39,476,918 | Change text label asp net | <p>How change text label in asp net visual basic while running procedures or functions.
For example when project is validating something, the label say the same. (Excuse me, I do not speak english)</p>
| <c#><visual-studio><thread-sleep> | 2016-09-13 18:39:14 | LQ_CLOSE |
39,478,032 | Vue.js pass function as prop and make child call it with data | <p>I have a posts list component and a post component.</p>
<p>I pass a method to call from the posts list to the post component, so when a button is click it will be called. </p>
<p>But I want to pass the post id when this function is clicked</p>
<p>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>let PostsFeed = Vue.extend({
data: function () {
return {
posts: [....]
}
},
template: `
<div>
<post v-for="post in posts" :clicked="clicked" />
</div>
`,
methods: {
clicked: function(id) {
alert(id);
}
}
}
let Post = Vue.extend({
props: ['clicked'],
data: function () {
return {}
},
template: `
<div>
<button @click="clicked" />
</div>
`
}</code></pre>
</div>
</div>
</p>
<p>as you can see in Post component you have a click that runs a method he got from a prop, I want to add a variable to that method.</p>
<p>How do you do that?</p>
| <javascript><vue.js><vue-component> | 2016-09-13 19:55:56 | HQ |
39,478,204 | Python while loop console closing | My console is closing every time I start the loop and I don't get why...
index = ""
while not index:
index = int(input("Enter the index that you want: ")) | <python><loops><console> | 2016-09-13 20:08:02 | LQ_EDIT |
39,478,224 | Store and show emojis | <p>I use a TextView to user type a comment, I store it on data base and show on a tableview or label to user. But when the user type a emoji on middle of string, the emojis is stored like a hexa, how to convert this emojis again when I add on label or tableview? </p>
<p>Or I dont need to change anything on my swift code and I need to change my database to store emojis? Or my API PHP?</p>
| <php><mysql><swift> | 2016-09-13 20:09:59 | LQ_CLOSE |
39,478,440 | Python Bigger is Greater optimization | python gurus.
I am trying to finish the below challenge and don't want to use permutation.
https://www.hackerrank.com/challenges/bigger-is-greater
The below code works well for small piece of test data, however it cannot pass 100000 cases. Could any masters help to provide some suggestions to optimize the below code. Much appreciated.
t=int(raw_input())
for _ in range(t):
s=list(raw_input().strip())#change to list
pos = -1#check pos, if pos is smaller, it's bigger lexilogical, so only choose small pos
i_temp=0
for i in reversed(range(len(s))):
for j in reversed(range(i)):
if s[i]>s[j]: #last letter is bigger than previous, in this case , we can swap to previous one, and found bigger one.
if j>pos:
pos=j#new place
i_temp=i
if j<pos:
break #already found good one
if i<pos:
break #already found good one
if pos>=0:
s_tmp=s[pos]
s[pos]=s[i_temp]
s[i_temp]=s_tmp
s1 = s[pos+1:] #get string for smallest
s1.sort()
print ("".join(s[:pos+1]+s1))
else:
print ("no answer")
| <python><algorithm><optimization> | 2016-09-13 20:25:07 | LQ_EDIT |
39,478,956 | How does returning std::make_unique<SubClass> work? | <p>I have a base class and its subclass:</p>
<pre><code>class Base {
public:
virtual void hi() {
cout << "hi" << endl;
}
};
class Derived : public Base {
public:
void hi() override {
cout << "derived hi" << endl;
}
};
</code></pre>
<p>Trying to create a helper function that creates a unique pointer of a Derived object.</p>
<p>1) This one works:</p>
<pre><code>std::unique_ptr<Base> GetDerived() {
return std::make_unique<Derived>();
}
</code></pre>
<p>2) But, this one fails to compile:</p>
<pre><code>std::unique_ptr<Base> GetDerived2() {
auto a = std::make_unique<Derived>();
return a;
}
</code></pre>
<p>3) std::move works:</p>
<pre><code>std::unique_ptr<Base> GetDerived3() {
auto a = std::make_unique<Derived>();
return std::move(a);
}
</code></pre>
<p>4) If I create a Base instance, both work:</p>
<pre><code>std::unique_ptr<Base> GetDerived4() {
auto a = std::make_unique<Base>();
return a;
}
std::unique_ptr<Base> GetDerived5() {
auto a = std::make_unique<Base>();
return std::move(a);
}
</code></pre>
<p>Why (2) fails but others work? </p>
| <c++><move><unique-ptr> | 2016-09-13 21:03:42 | HQ |
39,479,251 | JAVA ISBN-10 Number: Find 10th digit | <p><strong>Question :</strong> </p>
<p>An ISBN-10 consists of 10 digits: d1,d2,d3,d4,d5,d6,d7,d8,d9,d10. The last digit, d10, is a checksum,which is calculated from the other nine digits using
<em>the following formula:</em></p>
<p><strong>(d1 * 1 + d2 * 2 + d3 * 3 + d4 * 4 + d5 * 5 + d6 * 6 + d7 * 7 + d8 * 8 + d9 * 9) % 11</strong></p>
<p>If the checksum is 10, the last digit is denoted as X according to the ISBN-10
convention. </p>
<p>Write a program that prompts the user to enter the first 9 digits and displays the 10-digit ISBN (including leading zeros). Your program should read the input as an integer.</p>
<p><em>Here are sample runs:</em></p>
<p><strong>Enter the first 9 digits of an ISBN as integer: 013601267</strong></p>
<p><strong>The ISBN-10 number is 0136012671</strong></p>
<p><strong>MY CODE:</strong></p>
<pre><code>import java.util.Scanner;
public class ISBN_Number {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int[] num = new int[9];
System.out.println("Enter the first 9 digits of the an ISBN as integer: ");
for (int i = 0; i < num.length; i++) {
for (int j = 1; j < 10; j++) {
num[i] = s.nextInt() * j;
}
}
int sum = 0;
for (int a = 0; a < 10; a++) {
sum += num[a];
}
int d10 = (sum % 11);
System.out.println(d10);
if (d10 == 10) {
System.out.println("The ISBN-10 number is " + num + "X");
} else {
System.out.println("The ISBN-10 number is" + num);
}
}
}
</code></pre>
<p><strong>ISSUE:</strong>
I am new to learning java, hence I am having trouble trying to figure this question out. Can some tell me where I am going wrong because I am not getting the expected outcome. Thank you.</p>
| <java><arrays><if-statement><for-loop><isbn> | 2016-09-13 21:27:04 | LQ_CLOSE |
39,479,799 | how to link an image in my website to open in video player on another page? | <p>I want to link my image that is on my webpage to a video and I want that video will play on another page not on the same page.
so can you help me with it.</p>
| <javascript><php><html> | 2016-09-13 22:18:44 | LQ_CLOSE |
39,480,226 | build.gradle: compile group vs compile, buildscript, classpath | <p>What is the difference between "compile group" and "compile"? Just another way to define a dependency?</p>
<p>Ex:</p>
<pre><code>compile group: 'org.slf4j', name: 'slf4j-jcl', version: '1.7.21'
</code></pre>
<p>And i think this also will work:</p>
<pre><code>compile("org.slf4j:slf4j-jcl:1.7.21")
</code></pre>
<p>Why do i have the declare <code>mavenCentral()</code> again and another dependencies block inside the buildscript block?</p>
<pre><code>buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.0.RELEASE")
}
}
</code></pre>
<p>From my point of view, when you compile something it will be in your classPath?</p>
| <java><gradle> | 2016-09-13 23:02:34 | HQ |
39,480,237 | What is the best way to do payment processing on OS X? | <p>I have seen a million tutorials for Paypal on iOS but I noticed that Paypal doesn't seem to have an SDK for OS X and MAC desktop applications. I have desktop app that I have built in swift and the time has come for some sort of payment processing. If I cannot use Paypal then what is the best form of payment processing for non mobile applications? </p>
| <swift><macos> | 2016-09-13 23:03:59 | LQ_CLOSE |
39,480,272 | Firebase analytics AppMeasurement not enabled | <p>I have followed all the instructions for integrating Firebase analytics correctly in my project. But when I enable debug logging to make sure the events are being sent (using instructions from <a href="https://firebase.google.com/docs/analytics/android/start/" rel="noreferrer">here</a>) I see </p>
<pre><code>E/FA ( 3556): AppMeasurementReceiver not registered/enabled
E/FA ( 3556): AppMeasurementService not registered/enabled
E/FA ( 3556): Uploading is not possible. App measurement disabled
</code></pre>
<p>and obviously the events are not being sent.</p>
<p>Again I have followed all the instructions .</p>
| <android><firebase-analytics> | 2016-09-13 23:10:17 | HQ |
39,480,526 | What is libswiftRemoteMirror.dylib and why is it being included in my app bundle? | <p>I've got an iOS app which I've recently switched to Xcode 8.
As part of that we switched from swift 2.2 to 2.3 (swift 3 will come later).</p>
<p>I've got an automated build pipeline which essentially runs <code>xcodebuild</code> to produce a release binary on a dedicated build machine, and after I sorted all that out (Xcode 8's automatic code signing really screws everything up), now when I upload my app to iTunes connect, it fails with this error:</p>
<blockquote>
<p>ERROR ITMS-90171: "Invalid Bundle Structure - The binary file 'MyApp.app/libswiftRemoteMirror.dylib' is not permitted. Your app can't contain standalone executables or libraries, other than the CFBundleExecutable of supported bundles. Refer to the Bundle Programming Guide at <a href="https://developer.apple.com/go/?id=bundle-structure">https://developer.apple.com/go/?id=bundle-structure</a> for information on the iOS app bundle structure."</p>
</blockquote>
<p>Sure enough, if I unzip the .ipa file and have a look, there's <code>libswiftRemoteMirror.dylib</code> sitting there.</p>
<p>If I archive/export for iTunes via Xcode, then it produces an app bundle which does not have <code>libswiftRemoteMirror.dylib</code>, however all other builds of my app appear to have it. Even just doing a debug build within Xcode, then looking at the output shows that libswiftRemoteMirror.dylib is sitting in my app's bundle, indicating that Xcode itself is definitely putting it there, not any part of my automated build script.</p>
<p>What is this file, why is it being put there, and what should I do about it?
I can modify my build script to delete this file for release builds, but I'm concerned that might affect the code signing process. I'll try it anyway and see what happens, but it feels like that's not quite the right thing to be doing.</p>
<p>Any advice would be appreciated.</p>
| <ios><swift><xcode><app-store-connect><xcode8> | 2016-09-13 23:44:21 | HQ |
39,480,753 | Refreshing Sql Connection Azure AD access token inside long-lived Entity Framework Context | <p>I'm trying to set up a few .NET applications to use certificate-based authentication to Azure Active Directory and then use Active Directory to authorize my access to a Sql Azure DB.</p>
<p>The problem I'm running into is that some parts of the application use a DbContext that might live a little too long. The ADAL library tries to refresh the access token if you request it within 5 mins of it's expiration. Trouble is that some of my DbContexts might live for longer than 5 mins. Hence, halfway through the life of the DbContext the access token is no longer good and when I try to SaveChanges I get a database connection exception.</p>
<p>Apart from refactoring to make my DbContexts live shorter than 5 mins, is there anything I can do to fix this?</p>
<p>One thing I tried was to find some hooks in Entity Framework where I could catch the expired access token exception and then replace the current connection with a newly created one that has a new access token. I tried passing EF a custom connection factory and then using an Execution Strategy to retry when I get an expired token exception. This isn't working for me though because I can't modify or recreate the current connection from a custom execution strategy.</p>
<p>Any ideas would be greatly appreciated.</p>
<p>Thanks!</p>
| <c#><entity-framework><dbcontext><azure-active-directory><adal> | 2016-09-14 00:19:45 | HQ |
39,481,224 | Podio API - C# - Get all Items data for an App or space | <p>We have an app called "Deliverables" in each of the workspaces (there are about 20+ workspaces). Each of these Deliverables have a number of Items under them. What is the best API to use to retrieve,</p>
<ol>
<li>All the deliverables from all the workspaces</li>
<li>All the items under all deliverables, from all the workspaces</li>
</ol>
<p>Thanks</p>
| <c#><podio> | 2016-09-14 01:30:50 | LQ_CLOSE |
39,481,549 | What can I delete from ~/Library/Developer/Xcode folder? | <p>My <code>~/Library/Developer/Xcode</code> folder is over 17 gigs in size. As I work in virtual machine (Parallels 12) with a 64 gig limit in total virtual disk size, I need to recover some disk space.</p>
<p>Amongst the folders such as “Archives”, “DerivedDate”, “Installs”, “iOS Device Logs”, “iOS DeviceSupport”, “Snapshots”, and “UserData”, what might I be able to delete without ruining my project?</p>
| <xcode><xcode7> | 2016-09-14 02:18:21 | HQ |
39,481,691 | GraphQL readiness for .net development | <p>I found GraphQL as an enticing option to decouple front-end development from APIs (potentially a great fit for our company, which does lots of API customization for each customer). However, I can't quite work out if it's ready for a .NET development environment, or whether it's still considered an early technology? I also can't tell if it has bigger problems under the covers (e.g. N+1 issue). Any experience and guidance for GraphQL with a .NET implementation?</p>
| <c#><rest><api><asp.net-web-api><graphql> | 2016-09-14 02:38:32 | HQ |
39,481,942 | Why does this program which finds the smallest triangle number with >500 factors crash? | <p>I have written the program below to solve Project Euler 12, which involves finding the smallest triangle number with over 500 factors.</p>
<p>I don't think there are major errors. I suspect memory optimization may be an issue. That being said, however, I need the unsigned long long int for the large triangle number that will eventually be the answer. I start my natural number sequence at triangleNumbers[0]=10,000,000,000. I know 9,000,000,000 has roughly 300 factors, so 10,000,000,000 was a "best guess."
That being said, however, I assume that 10,000,000,000 is the "first natural number" and continue adding subsequent natural numbers to get the "second" natural number and beyond (so triangleNumbers[1]=10,000,000,000 + 2, triangleNumbers[2]=10,000,000,000 +3, and so forth).</p>
<p>Any suggestions and tips would be appreciated. Thank you for helping a beginner improve.</p>
<pre><code>#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
bool keepRunning=true;
unsigned long long int naturalNumberCount=0;
unsigned long long int j=4;
unsigned long long int sum=0;
vector <unsigned long long int> triangleNumbers(0);
unsigned long long int totalFactors=0;
unsigned long long int trialDivisors=1;
unsigned long long int storer=0;
int main()
{
triangleNumbers[0]=10000000000;
triangleNumbers[1]=10000000002;
triangleNumbers[2]=10000000005;
triangleNumbers[3]=10000000009;
triangleNumbers[4]=10000000014;
//listed first few prime numbers above. j is set at 4 for this reason
naturalNumberCount=5;
//10000000014 is the 5th triangle number, and 5 is the 5th natural num
//need this for recursive relation
//5th triangle number = 4th triangle num + 5 (num + naturalNumberCount
while(keepRunning)
{
for(trialDivisors;trialDivisors<=(unsigned long long int)(sqrt(triangleNumbers[j]));trialDivisors++)
{
if(triangleNumbers[j]%trialDivisors==0)
{
totalFactors++;
if(totalFactors>499)//499 because the number itself will be a divisor of itself, so no need to check
{
keepRunning=false;
break;
}
else
{
keepRunning=true;
}
}
else
{
keepRunning=true;
}
}
//need the below to generate and store the next triangle number (as next element of array)
naturalNumberCount++;//for recursive relation
storer=triangleNumbers[j];//store the (j+1)'th triangle number, since we are changing j itself
j++;//raise j, we gonna add the next value
triangleNumbers[j]=(storer+naturalNumberCount);//the new value (last triangle number + current natural)
totalFactors=0;//reset total factors to preclude any carry-over
}
cout<<triangleNumbers[j]<<flush;
return 0;
}
</code></pre>
| <c++><factorization> | 2016-09-14 03:12:46 | LQ_CLOSE |
39,482,314 | Parameter ScheduleExpression is not valid | <p>I'm trying to setup a Cloudwatch Scheduled Event and my cron expression seems to be invalid, though I can't figure out why.</p>
<p>My cron expression is:</p>
<p>cron(5,15,25,35,45,55 * * * *)</p>
<p>I want it to run on the 5th, 15th, 25th, 35th, 45th and 55th minute of every hour of every day. This seems to coincide with the AWS Scheduled Events documentation here <a href="http://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html" rel="noreferrer">http://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html</a>.</p>
<p>The above documentation allows for minutes to be represented with comma separated values between 0 and 59, and hours, day-of-month (or day-of-week), month and year to be reflected with a * wildcard to reflect ALL.</p>
<p>I have tried setting the cron expression on the Lambda console (when creating the function and choosing Cloudwatch Schedule Event), and in the Cloudwatch console (along with choosing the target of the trigger). Neither worked with my custom cron expression.</p>
<p>I have tried the following:</p>
<pre><code>5,15,25,35,45,55 * * * *
5,15,25,35,45,55 * ? * *
cron(5,15,25,35,45,55 * * * *)
cron(5,15,25,35,45,55 * ? * *)
</code></pre>
<p>Everytime I get an error saying the ScheduleExpression is not valid. I can, however, use one of the premade rate() expressions.</p>
<p>How can I use my own custom cron expression?</p>
<p>Thanks.</p>
| <cron><aws-lambda><amazon-cloudwatch> | 2016-09-14 04:03:16 | HQ |
39,482,690 | Can't open some html files in chrome (mac) | <p>There are some HTML files (no pattern that I've figured out) that I can't open via the terminal, GUI or right clicking Open in Browser via Sublime Text 3. </p>
<p>The default browser to open the file is definitely set to Chrome. When I say to open the file in the browser it takes me to the Chrome window, but doesn't actually open the file I want.</p>
<p>I can open these files in Chrome itself via command + O and in Firefox or Safari by right clicking on the file and selecting them in the GUI.</p>
<p>It'd be great if Chrome would open files when I expect it to. I'd appreciate any help.</p>
| <html><macos><google-chrome> | 2016-09-14 04:51:53 | HQ |
39,482,722 | How to print DataFrame on single line | <p>With:</p>
<pre><code>import pandas as pd
df = pd.read_csv('pima-data.csv')
print df.head(2)
</code></pre>
<p>the print is automatically formatted across multiple lines:</p>
<pre><code> num_preg glucose_conc diastolic_bp thickness insulin bmi diab_pred \
0 6 148 72 35 0 33.6 0.627
1 1 85 66 29 0 26.6 0.351
age skin diabetes
0 50 1.3790 True
1 31 1.1426 False
</code></pre>
<p>I wonder if there is a way to avoid the multi-line formatting. I would rather have it printed in a single line like so:</p>
<pre><code> num_preg glucose_conc diastolic_bp thickness insulin bmi diab_pred age skin diabetes
0 6 148 72 35 0 33.6 0.627 50 1.3790 True
1 1 85 66 29 0 26.6 0.351 31 1.1426 False
</code></pre>
| <python><pandas><dataframe> | 2016-09-14 04:54:27 | HQ |
39,483,437 | how to create an UIImage by pdf file in Xcode | [use the pdf as icon][1]
[1]: http://i.stack.imgur.com/N3OVK.png
when i want to use the pdf icon in project,i do like this
[UIImage imageNamed:@"icon_file_open"];
but is that ok? [UIImage imageNamed:] will always retain the image in memory,is there any other way that i can create the image by pdf? | <ios><objective-c> | 2016-09-14 06:00:49 | LQ_EDIT |
39,483,507 | Am I using the ternary operator? | <p>Here is my code:</p>
<pre><code>echo "<option value=".$crew_rank_id.".(($crew_rank_id == $crew_rank) ? "selected" : "").>".$crew_rank_table."</option>";
</code></pre>
<p>what im trying to do is echo out the selected value from the database in <code>echo</code> </p>
| <php><if-statement><ternary> | 2016-09-14 06:07:29 | LQ_CLOSE |
39,484,120 | Using regex to restrict user input | <p>There is a particular field in my application where a user will be asked to enter a time for a job to be run (like HH:MM) for the MM field, I want the user to enter a number in the range 0-59 ONLY. How should I pattern match this with regexp ?</p>
| <regex> | 2016-09-14 06:49:19 | LQ_CLOSE |
39,484,613 | How to capitalized only first letter of sentence in input fields with javascript? | <p>I want to have only first letter of the sentence to be capitalized in input fields with javascript when i type something. </p>
<p>This is my website <a href="http://web.quick-truck.com/signup" rel="nofollow">link</a> where i want to use it.</p>
<p>Is there any solution for it?</p>
<p>Here is my HTML code:</p>
<pre><code><div class="form-group">
<label for="name" class="label-head">Company Name <sup><span
class="glyphicon glyphicon-asterisk red" aria-hidden="true"></span></sup></label>
<input type="text" class="form-control text-box-length input-lg" id="companyname" placeholder="Enter Your Company Name" data-validation="required" maxlength="50">
</div>
</code></pre>
| <javascript><html> | 2016-09-14 07:18:48 | LQ_CLOSE |
39,484,678 | Module compiled with Swift 2.3 cannot be imported in Swift 3.0 | <p>i add Facebook SDK (Swift) to my project.
And now i update Xcode 8 and Swift 3.
I have error in build time </p>
<pre><code>Module compiled with Swift 2.3 cannot be imported in Swift 3.0
</code></pre>
<p>It is very strange that is not supported.
Has anyone had similar problems?</p>
| <facebook><swift3><xcode8><swift2.3> | 2016-09-14 07:22:31 | HQ |
39,485,351 | Rendering problems in Android studio in the layouts android android-studio | I have installed android studio,and when it started it is showing these messages
Rendering problems The following classes could not be found android.support.design.widget.appbarlayout(Fix build path, Create class) android.support.design.widget.CoordinatorLayout(Fix build path,Create class)
I have searched alot on the Internet but not getting any correct solution Please help. Thank you.
My limits were finished to ask questions. So I edited previous one.
But now I am asking it newly once again.
Please suggest me a solution. | <android><android-layout> | 2016-09-14 08:02:08 | LQ_EDIT |
39,485,452 | Is there any way to emulate perfectly a OnePlus device? | <p>I'm trying to debug a problem that seems to be happening only on OnePlus devices, unfortunately buying this device is not an option for me, so I've been looking on Google how to emulate an OnePlus device but without any success :(</p>
<p>Is there any way I can reproduce the hardware specs and software characteristics on a GOOD android emulator??</p>
| <android-studio><android-emulator><emulation><cyanogenmod><oneplusone> | 2016-09-14 08:07:07 | HQ |
39,485,691 | Need to delete large no files | I need to deletea large no files in a folder (wc is around 2392934). The folder contains files of year 2015 & year 2016.
I want to delete files for year 2015 only and for that I have created a script below:-
echo 'going to gived path'
cd /usr/local/nagios/var/spool/xidpe/
pwd
b=$(ls -lrt | grep '2015' | awk '{print $9}')
echo 'listen tail outcome'
echo 'going to del'
rm -rf $b
exit
but it gives error :- ./test.sh: line 10: /bin/rm: Argument list too long.
I have tried xargs also : b=$(ls -lrt | xargs '2016' | awk '{print $9}')
gives error:- xargs: 2016: No such file or directory
Is there any changes need to be done in my script or any other ways to delete these files(only for year 2015). | <linux> | 2016-09-14 08:21:21 | LQ_EDIT |
39,486,537 | How to check expected intent sent without actually launching activity in Espresso? | <p>I have a UI test which clicks a button, and then launch a new Activity in its onClickListener. The test checks whether expected intent is sent or not.</p>
<p>My problem is, I want to test whether expected intent is sent <strong>without actually launching the activity</strong>. Because I found that new activity initializes its state, and it makes subsequent tests flaky. </p>
<p>I know there are two <a href="https://google.github.io/android-testing-support-library/docs/espresso/intents/index.html" rel="noreferrer">Espresso Intents</a> api, which are <code><a href="https://developer.android.com/reference/android/support/test/espresso/intent/Intents.html#intended(org.hamcrest.Matcher%3Candroid.content.Intent%3E)" rel="noreferrer">intended</a></code> and <code><a href="https://developer.android.com/reference/android/support/test/espresso/intent/Intents.html#intending(org.hamcrest.Matcher%3Candroid.content.Intent%3E)" rel="noreferrer">intending</a></code>, but both fail to meet my needs. <code>intended</code> api actually launches the target activity, and <code>intending</code> api doesn't launch the activity, but it calls <code>onActivityResult</code> callback which I don't want either. Because I'm afraid that code inside <code>onActivityResult</code> may cause another flakiness. Also <code>intending</code> doesn't assert whether matching intent is sent, it just calls <code>onActivityResult</code> callback when matching intent is found, which means I have to check whether <code>onActivityResult</code> is called or not!</p>
<p>Is there any clean way to achieve what I want?</p>
| <android><android-intent><android-activity><android-espresso><android-instrumentation> | 2016-09-14 09:07:26 | HQ |
39,487,186 | Get max + 1 without removing zeroes in SQL server | I have a varchar field contains numbers in this format "00001" , "00002" etc
when I try to get the next number by using Max(Field) + 1 I get an integer "3" for example.
how can I get the resutl "00003" instead of "3"?
What I have tried:
Reply Modify the comment. Delete the comment.
here's an working example I've just figure it out, but i think there's must be an easier way:
SELECT TOP (1) { fn REPEAT(0, LEN(ItemId) - LEN(MAX(ItemId) + 1)) } + CAST(MAX(ItemId) + 1 AS varchar(7)) AS Expr1
FROM Items
GROUP BY ItemId
ORDER BY ItemId DESC
the last query gives the correct result "0004916" | <sql><sql-server> | 2016-09-14 09:38:51 | LQ_EDIT |
39,487,327 | Tracking Android in-app subscription events with Firebase Analytics | <p>We're using Firebase Analytics to track our Android app.
We've connected it to our Google Play account in hopes to receive the automatic <code>in_app_purchase</code> events. What we later realized is that does not support in-app subscriptions: <a href="https://support.google.com/firebase/answer/6317485?hl=en">https://support.google.com/firebase/answer/6317485?hl=en</a></p>
<p>How do we track subscription revenue events?<br>
We thought about using the <code>ecommerce_purchase</code> event (<a href="https://support.google.com/firebase/answer/6317499?hl=en">https://support.google.com/firebase/answer/6317499?hl=en</a>) so we could track the ARPU, ARPPU and LTV of our users. </p>
<p>The problem we are facing is dealing with subscription recurrence. Should we manually send this event each month/year and stop sending once the subscription is cancelled? It seems like a error-prone hack ...</p>
<p>Any other ideas?</p>
<p>Thanks!</p>
| <android><firebase><firebase-analytics><in-app-subscription> | 2016-09-14 09:45:33 | HQ |
39,488,381 | Jquery select multiply of 3 | Hi in my Ul li i want to select only muliply of 3 other wise it will show alert msg. How i achive this
<ul>
<li><input type="checkbox" />a</li>
<li><input type="checkbox"/>b</li>
<li><input type="checkbox"/>c</li>
<li><input type="checkbox"/>d</li>
<li><input type="checkbox" />e</li>
<li><input type="checkbox"/>f</li>
</ul> | <javascript><jquery><html><checkbox> | 2016-09-14 10:40:00 | LQ_EDIT |
39,488,782 | Xcode 8 - Provisioning Profile vs. Provisioning Profile (Deprecated) | <p>I have just updated to Xcode 8 and I now have two options for app signing, Provisioning Profile and Provisioning Profile (Deprecated).</p>
<p><a href="https://i.stack.imgur.com/skJKj.png" rel="noreferrer"><img src="https://i.stack.imgur.com/skJKj.png" alt="enter image description here"></a></p>
<p>Why is one deprecated, and what is the difference between the two?</p>
| <xcode><code-signing><provisioning-profile><xcode8> | 2016-09-14 11:00:31 | HQ |
39,489,211 | "Empty collection literal requires an explicit type" error on Swift3 | <p>I have a variable on my class:</p>
<pre><code>var list = []
</code></pre>
<p>and I use it on a function of my class:</p>
<pre><code>func chargeData (data: NSArray){
list = data
}
</code></pre>
<p>It worked well on my project in <code>Swift 2.3</code> but when I have updated it to <code>XCode8</code> and <code>Swift3</code> it gives to me the following error:</p>
<blockquote>
<p>Empty collection literal requires an explicit type</p>
</blockquote>
<p>so I have added a typecast to my list variable:</p>
<pre><code>var list = [] as! NSArray
</code></pre>
<p>but it gives to me the following alert:</p>
<blockquote>
<p>Forced cast of 'NSArray' to same type has no effect</p>
</blockquote>
<p>I know that an alert does not broke the application but I would like to solve this error in a proper way.</p>
<p>Did someone got the same error and solved it properly?</p>
<p>Thanks in advance!</p>
| <ios><swift3> | 2016-09-14 11:23:56 | HQ |
39,489,229 | Pass variable to html template in nodemailer | <p>I want to send email with nodemailer using html template. In that template I need to inject some dynamically some variables and I really can't do that. My code:</p>
<pre><code>var nodemailer = require('nodemailer');
var smtpTransport = require('nodemailer-smtp-transport');
smtpTransport = nodemailer.createTransport(smtpTransport({
host: mailConfig.host,
secure: mailConfig.secure,
port: mailConfig.port,
auth: {
user: mailConfig.auth.user,
pass: mailConfig.auth.pass
}
}));
var mailOptions = {
from: 'my@email.com',
to : 'some@email.com',
subject : 'test subject',
html : { path: 'app/public/pages/emailWithPDF.html' }
};
smtpTransport.sendMail(mailOptions, function (error, response) {
if (error) {
console.log(error);
callback(error);
}
});
</code></pre>
<p>Let's say I want in emailWithPDF.html something like this:</p>
<pre><code>Hello {{username}}!
</code></pre>
<p>I've found some examples, where was smth like this:</p>
<pre><code>...
html: '<p>Hello {{username}}</p>'
...
</code></pre>
<p>but I want it in separate html file. Is it possible?</p>
| <javascript><html><node.js><express><nodemailer> | 2016-09-14 11:24:35 | HQ |
39,490,150 | How to remotely trigger Jenkins multibranch pipeline project build? | <p>Title mostly says it. How can you trigger a Jenkins multibranch pipeline project build from a remote git repository?</p>
<p>The "Trigger builds remotely" build trigger option does not seem to work, since no tokens that you set are saved.</p>
| <git><jenkins><githooks><multibranch-pipeline> | 2016-09-14 12:11:57 | HQ |
39,490,194 | Command to genarate result in xls/csv? | Below is the command to run the Soap UI project,after run I will be getting xml file results,that i needed in xls/csv
Kindly some one help me.
"/home/user/SmartBear/SoapUI-5.2.1/bin/testrunner.sh" -e$endpoint -rjf $resultfile $projectnew | <soapui><transformation> | 2016-09-14 12:14:02 | LQ_EDIT |
39,490,390 | Alamofire download issue | <p>I am trying to download <a href="https://slove.tulleb.com/uploads/6/6/0/2/66027561/2791411.jpg-1447979839.png">this picture</a> in my code using Alamofire 4.0.0 with Xcode 8.0 and Swift 3.0.</p>
<p>Here is my request:</p>
<pre><code> func download(_ path: String, _ completionHandler: @escaping (Any?) -> ()) {
let stringURL = "https://slove.tulleb.com/uploads/6/6/0/2/66027561/2791411.jpg-1447979839.png"
print("Requesting \(stringURL)...")
_ = Alamofire.download(stringURL)
.responseData { response in
print(response)
if let data = response.result.value {
completionHandler(UIImage(data: data))
} else {
completionHandler(nil)
}
}
}
</code></pre>
<p>I get the following answer from the server:</p>
<blockquote>
<p>FAILURE:
responseSerializationFailed(Alamofire.AFError.ResponseSerializationFailureReason.inputFileReadFailed(file:///private/var/mobile/Containers/Data/Application/50400F41-47FD-4276-8903-F48D942D064A/tmp/CFNetworkDownload_D1Aqkh.tmp))</p>
</blockquote>
<p>I don't have any idea on how to fix this... Is Alamofire new version having some issues or is it me forgetting something somewhere?</p>
<p>Thanks!</p>
| <swift><alamofire> | 2016-09-14 12:23:51 | HQ |
39,490,579 | Python mathematical operators sequence | <pre><code>a=0
b=5
</code></pre>
<p>And when we try to get result of this:</p>
<pre><code>print str((23-11)/a*b)
</code></pre>
<p>We get the divide by zero error.</p>
<blockquote>
<p>Traceback (most recent call last): File "", line 1, in
print str((23-11)/a*b) ZeroDivisionError: integer division or modulo by zero
But if we change positions: </p>
</blockquote>
<pre><code>print str((23-11)/b*a)
</code></pre>
<p>The result is zero:</p>
<blockquote>
<p>0</p>
</blockquote>
<p>Should we get always divide y zero error (because (b*a) is zero)?</p>
| <python><math> | 2016-09-14 12:33:19 | LQ_CLOSE |
39,490,865 | How can I get the FULL list of slack emoji through API? | <p>I am using the slack API to get the full list of emoji, so that when I get a message, I will just replace <code>:squirrel:</code> with the icon.</p>
<p>The method <code>https://slack.com/api/emoji.list</code> works like a charm, but returns 30 icons only. I think this is correct since in the documentation page (<a href="https://api.slack.com/methods/emoji.list" rel="noreferrer">https://api.slack.com/methods/emoji.list</a>) they say:</p>
<blockquote>
<p>This method lists the custom emoji for a team.</p>
</blockquote>
<p>Fair enough, but how can I get the full list of the associations icon-name / icon URL ?</p>
| <slack-api><slack> | 2016-09-14 12:48:07 | HQ |
39,490,895 | looking for a python library to detect post requests inside an url | <p>I'm looking for a library, I don't know if it's exists. I need to parse an url to check if there is a post request form inside it. If there is one, it should list the parameters of that post request. Example process:</p>
<p>-url: <a href="http://www.example.com" rel="nofollow">http://www.example.com</a></p>
<p>-It has a post request form to "saveprofile.php" with parameters "name,lastname,password"</p>
<p>-Save those information to a text file</p>
<p>Do you know any library which achieves this goal?</p>
| <python> | 2016-09-14 12:49:55 | LQ_CLOSE |
39,491,113 | How to use React Router on top of Rails router (not using react-rails gem)? | <p>Now i am making React app on top off Ruby on Rails app (with out react-rails gem) by using <a href="https://github.com/browserify-rails/browserify-rails" rel="noreferrer">browserify-rails</a> to compile js files.</p>
<p>So i tried to us <a href="https://github.com/ReactTraining/react-router" rel="noreferrer">react-router</a> to config router of the app</p>
<p>This is my main.js</p>
<pre><code>import React from 'react';
import ReactDOM from 'react-dom';
import { Router, Route } from 'react-router';
import { browserHistory } from 'react-router';
/*Import Component*/
import DashBoard from './components/dashboard';
import Group from './components/dashboard';
/*
*
* Routes
*
* */
var routes = (
<Router history={browserHistory}>
<Route path="/" component={DashBoard}/>
<Route path="/group" component={Group}/>
</Router>
);
ReactDOM.render(routes , document.querySelector('#main'));
</code></pre>
<p>But when i go to </p>
<pre><code>http://my.app.dev/group
</code></pre>
<p>I got </p>
<pre><code>No route matches [GET] "/group" (From Rails)
</code></pre>
<p>So how can i fix this and make React Router on top off Rails router?</p>
<p>Thanks!</p>
| <javascript><ruby-on-rails><reactjs> | 2016-09-14 12:59:54 | HQ |
39,491,283 | How to log exceptions using logger.net in asp.net | How to log exceptions in asp.net using logger.net.
I searching in google for example regarding logger.net.but i don't find any proper solution.It only store log details not exceptions.
| <asp.net><.net><logger.net> | 2016-09-14 13:08:11 | LQ_EDIT |
39,491,690 | Changing values of 2 textboxes with each other (VS.NET) | <p>I want to know how to change the values of 2 textboxes with each other when I click on a button. vs.net</p>
| <vb.net><visual-studio> | 2016-09-14 13:25:08 | LQ_CLOSE |
39,492,050 | sql 2012 - varchar to date | I am running views against a table that has dates stored as varchar(8) as DDMMYYYY, can someone please tell me how do I convert them to date format?
Thanks | <sql><sql-server> | 2016-09-14 13:42:00 | LQ_EDIT |
39,492,541 | Read json file and get output values using python | i want to fetch the output of below json file using python
Json file
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
{
"Name": [
{
"name": "John",
"Avg": "55.7"
},
{
"name": "Rose",
"Avg": "71.23"
},
{
"name": "Lola",
"Avg": "78.93"
},
{
"name": "Harry",
"Avg": "95.5"
}
]
}
<!-- end snippet -->
I want to get the average marks of the person, when i look for harry
i.e i need output in below or similar format
Harry = 95.5 | <python><json><ioerror> | 2016-09-14 14:07:06 | LQ_EDIT |
39,493,003 | TypeScript Compile Options: module vs target | <p>Trying to have some basic understanding about module and target. </p>
<p>I would like to know the difference between module and target compile options in a typical tsconfig.json</p>
<pre>
{
"compilerOptions": {
"module": "es6",
"sourceMap": true,
"target": "es6"
}
}
</pre>
<p>What happens if I provide the following options:</p>
<p>module: commonjs, target: es6</p>
<p>module: es6, target: commonjs</p>
<p>module: commonjs, target: commonjs</p>
| <typescript><typescript1.8> | 2016-09-14 14:28:32 | HQ |
39,494,063 | *****Newbie***** Pimary keys in db | Thanks folks! This from an online Khan tutorial on sql:
1) How do I know that student_id in students_grades is related to id in student?
2) Why is there no value for primary key in students?
Thanks a lot.
=================================
CREATE TABLE students (id INTEGER PRIMARY KEY,
first_name TEXT,
last_name TEXT,
email TEXT,
phone TEXT,
birthdate TEXT);
INSERT INTO students (first_name, last_name, email, phone, birthdate)
VALUES ("Peter", "Rabbit", "peter@rabbit.com", "555-6666", "2002-06-24");
INSERT INTO students (first_name, last_name, email, phone, birthdate)
VALUES ("Alice", "Wonderland", "alice@wonderland.com", "555-4444", "2002-07-04");
CREATE TABLE student_grades (id INTEGER PRIMARY KEY,
student_id INTEGER,
test TEXT,
grade INTEGER);
INSERT INTO student_grades (student_id, test, grade)
VALUES (1, "Nutrition", 95);
INSERT INTO student_grades (student_id, test, grade)
VALUES (2, "Nutrition", 92);
INSERT INTO student_grades (student_id, test, grade)
VALUES (1, "Chemistry", 85);
INSERT INTO student_grades (student_id, test, grade)
VALUES (2, "Chemistry", 95); | <mysql> | 2016-09-14 15:15:00 | LQ_EDIT |
39,494,087 | how to keep a large number of data.frame in .csv | <p>There are a large number of data.frame (more than 50). How can I save them quickly in .csv?</p>
<pre><code>write.csv()
</code></pre>
<p>50 lines of code, it's awful...</p>
<p>Help me, guys!</p>
| <r> | 2016-09-14 15:16:42 | LQ_CLOSE |
39,494,689 | Is it possible to restrict number to a certain range | <p>Since typescript 2.0 RC (or even beta?) it is possible to use number literal types, as in <code>type t = 1 | 2;</code>. Is it possible to restrict a type to a number range, e.g. 0-255, without writing out 256 numbers in the type?</p>
<p>In my case, a library accepts color values for a palette from 0-255, and I'd prefer to only name a few but restrict it to 0-255:</p>
<pre><code>const enum paletteColor {
someColor = 25,
someOtherColor = 133
}
declare function libraryFunc(color: paletteColor | 0-255); //would need to use 0|1|2|...
</code></pre>
| <typescript><types> | 2016-09-14 15:45:44 | HQ |
39,494,747 | Android Can't compress a recycled bitmap | I'm getting an image from a URL, I want to compress it and save it in the external memory device. I get this error
java.lang.IllegalStateException:
Can't compress a recycled bitmap
at android.graphics.Bitmap.checkRecycled(Bitmap.java:400)
at android.graphics.Bitmap.compress(Bitmap.java:1307)
at this line
mIcon11.compress(Bitmap.CompressFormat.JPEG, 40, bytes);
---------------------------------------------------------------------
String foto = UT_drive_dropbox.AM.getfoto();
Bitmap mIcon11 = null;
try {
InputStream in = new java.net.URL(foto).openStream();
mIcon11 = BitmapFactory.decodeStream(in);
} catch (Exception e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
final Bitmap output = Bitmap.createBitmap(mIcon11.getWidth(),
mIcon11.getHeight(), Bitmap.Config.ARGB_8888);
final Canvas canvas = new Canvas(output);
final int color = Color.RED;
final Paint paint = new Paint();
final Rect rect = new Rect(0, 0, mIcon11.getWidth(), mIcon11.getHeight());
final RectF rectF = new RectF(rect);
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
paint.setColor(color);
canvas.drawOval(rectF, paint);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
canvas.drawBitmap(mIcon11, rect, rect, paint);
mIcon11.recycle();
String fileName = "avatar.jpg";
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
mIcon11.compress(Bitmap.CompressFormat.JPEG, 40, bytes);
File sd = new File(Environment.getExternalStorageDirectory(), getString(R.string.app_name) + File.separator + fileName);
FileOutputStream fileOutputStream = null;
try {
sd.createNewFile();
fileOutputStream = new FileOutputStream(sd);
fileOutputStream.write(bytes.toByteArray());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
if (fileOutputStream != null) {
try {
fileOutputStream.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
| <android><url><bitmap> | 2016-09-14 15:48:47 | LQ_EDIT |
39,495,199 | Subclass.fetchRequest() Swift 3.0, extension not really helping 100%? | <p>according to the new Core Data changes, Xcode generates this subclass for me:</p>
<pre><code>extension Person {
@nonobjc public class func fetchRequest() -> NSFetchRequest<Person> {
return NSFetchRequest<Person>(entityName: "Person");
}
@NSManaged public var name: String?
}
</code></pre>
<p>then in code I was expecting to have this one line working:</p>
<pre><code>let fr = Person.fetchRequest()
</code></pre>
<p>This line of code above however gives me an error:</p>
<pre><code>"Ambiguous use of 'fetchRequest'
</code></pre>
<p>This fixes the issue:</p>
<pre><code>let fr: NSFetchRequest<Person> = Person.fetchRequest()
</code></pre>
<p>So then, I am confused what is the:</p>
<pre><code>NSFetchRequest<Person>
</code></pre>
<p>in the:</p>
<pre><code>@nonobjc public class func fetchRequest() -> NSFetchRequest<Person> {
</code></pre>
<p>return type doing at all?</p>
<p>Shouldn't the return type allow me not to have to specify the:</p>
<pre><code>NSFetchRequest<Person>
</code></pre>
<p>in the let definition??</p>
<pre><code>let fr: NSFetchRequest<Person> = Person.fetchRequest()
</code></pre>
<p>Can anybody help me understand why it is needed even though it's part of the return type already?</p>
| <swift><core-data> | 2016-09-14 16:13:54 | HQ |
39,495,477 | How do you go through a text file and print the next number in python? | <p>How do you go through a text file and print the next ascending number with other information (already able to do this)? </p>
<p>For my code I need to assign a number to something the user inputs and so far I am able to do everything but get the number to print onto the text file. I would like my file to be formatted in the following way:</p>
<p><em>1 abcd</em></p>
<p><em>2 efgh</em></p>
<p>I need the code to go through the text file and see what the highest number is then print the next number with the information. Like I said before I'm having no trouble with the information part just the part on adding the numbers.</p>
<p>I have thought about doing an <em>if</em> statement however that would mean going through a lot of numbers and sooner or later it will need updating with more numbers. As well as this, it would be very time consuming as well as memory consuming.</p>
<p>I have also thought about using a <em>for</em> statement however I haven't been able to find a way of it working.</p>
<p>Any help would be greatly appreciated. Thanks</p>
| <python><text-files> | 2016-09-14 16:29:40 | LQ_CLOSE |
39,495,557 | Writing cross-compatible python2/python3 code in pycharm | <p>I've taken care to make sure library works on both python2 and python3, but pycharm adds some vexatious red squiggles as seen below </p>
<p><a href="https://i.stack.imgur.com/EBCpC.png" rel="noreferrer"><img src="https://i.stack.imgur.com/EBCpC.png" alt="enter image description here"></a></p>
<p>If I switch the project interpreter to python 3.5 instead, the nag just moves onto the other import. <strong>Which inspection is this? I want to turn it off.</strong> </p>
| <python><pycharm> | 2016-09-14 16:33:45 | HQ |
39,495,581 | How to generate alert when clicking Submit button, only when the html form is full using Javascript | <p>I have this html form with many forms of elements. I need to generate the alert "Thank you for your time! Your details have been submitted!" once the submit button is clicked, only when the form is full. When the form is empty I do not want to see this message. So far I've been using onClick event. Can someone please help me on this (I'm trying to implement this using Javascript)</p>
<p>Here's the Javascript code and HTML body</p>
<pre><code><html>
<head>
<title>JS Validation for other types of form input fields</title>
<script type="text/javascript">
function submitClick( ) //function shows message after submitting information
{
alert("Thank you for your time! Your details have been submitted!");
}
function formValidation ( )
{
flag = true;
if (document.myForm.user_name.value == "" )
{
alert ( "Please fill in your Name!" );
flag = false;
}
// Validate letters only as Name
if (!/^[a-zA-Z]*$/g.test(document.myForm.user_name.value))
{
alert("Enter alphabetic characters as Name!");
flag = false;
}
// Validate emails
if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)* (\.\w{2,3})+$/.test(myForm.user_email.value)) //Regular expressions to validate email
{
alert("Enter Valid Email Address!");
flag = false;
}
// Validate Phone number
flag = true;
if (document.myForm.user_phone.value == "" )
{
alert ( "Please fill in your Phone Number!" );
flag = false;
}
if (!/^[0-9]*$/g.test(myForm.user_phone.value))
{
alert("Enter numeric values as Phone Number!");
flag = false;
}
if ((document.myForm.userGender[0].checked == false) && (document.myForm.userGender[1].checked == false ) )
{
alert ( "Please select your gender!" );
flag = false;
}
if (document.myForm.userAge.selectedIndex == 0 )
{
alert ( "Please select your Age from the drop-down list!" );
flag=false;
}
if (document.myForm.termsAndConditions.checked == false )
{
alert ( "Please check the Terms and Conditions box!" );
flag= false;
}
return flag;
}
</script>
</head>
<body bgcolor = "#FFFFFF">
<form name="myForm" method="post" onSubmit=" return formValidation( );">
<h1>Please fill out your details below:</h1>
<p>Name: <input type="text" name="user_name"></p>
<p>Email: <input type="text" name="user_email"></p>
<p>Phone: <input type="text" name="user_phone"></p>
<p>Gender: <input type="radio" name="userGender" value="Male">Male
&nbsp; <input type="radio" name="userGender" value="Female">Female</p>
<p>Age:
<select name="userAge">
<option value="">Please select your age:</option>
<option value="0-17 years">0-17 years</option>
<option value="18-29 years">18-29 years</option>
<option value="30-40 years">30-40 years</option>
<option value="40-64 years">40-64 years</option>
<option value="65+ years">65+ years</option>
</select>
<p>Please tick the checkbox if you agree with our Terms and Conditions:
<input type="checkbox" name="termsAndConditions" value="Yes"> Yes
<p><input type="submit" name="send" value="Submit Details" onClick="submitClick( )"></p>
</form>
</body>
</html>
</code></pre>
| <javascript><html> | 2016-09-14 16:35:20 | LQ_CLOSE |
39,496,017 | Iterate in RUN command in Dockerfile | <p>I have a line that looks something like: </p>
<pre><code>RUN for i in `x y z`; do echo "$i"; done
</code></pre>
<p>...with the intention of printing each of the three items</p>
<p>But it raises <code>/bin/sh: 1: x: not found</code></p>
<p>Any idea what I'm doing wrong?</p>
| <docker><sh><dockerfile> | 2016-09-14 17:02:46 | HQ |
39,496,435 | How to set CGBITMAP_CONTEXT_LOG_ERRORS environmental variable? | <p>While using <code>CGBitmapContextCreate</code> I get error in XCode</p>
<blockquote>
<p>CGBitmapContextCreate: unsupported parameter combination: set
CGBITMAP_CONTEXT_LOG_ERRORS environmental variable to see the details</p>
</blockquote>
<p>How can I set this var? </p>
<p>I tried
<code>launchctl setenv CGBITMAP_CONTEXT_LOG_ERRORS /Users/user/Documents/cgbitmap_errors.log</code> and <code>launchctl setenv CGBITMAP_CONTEXT_LOG_ERRORS 1</code> and restarting XCode with no success. </p>
<p>I also tried combination with <code>defaults write com.apple.dt.Xcode UseSanitizedBuildSystemEnvironment -bool NO</code>, no success too</p>
<p>I restarted computer too</p>
| <ios><xcode><core-graphics> | 2016-09-14 17:31:19 | HQ |
39,496,564 | docker volume custom mount point | <p>I'm new to Docker and I was playing around with <code>docker volume</code>. I wanted to specify the location where <code>docker volume</code> stores the data. Much like when we provide the <code>-v</code> option when we execute <code>docker run</code>. <strong><code>Ex : -v /somefolder/:/var/somefolder</code></strong></p>
<p>How can we set a custom <strong>Mountpoint</strong> when we create a <code>docker volume</code>. I didn't find any options on docs.</p>
<p>When I inspect the volume</p>
<pre><code>[
{
"Name": "sampleproject_mysql_data",
"Driver": "local",
"Mountpoint": "/mnt/sda1/var/lib/docker/volumes/sampleproject_mysql_data/_data",
"Labels": null,
"Scope": "local"
}
]
</code></pre>
<p>I get something like above.</p>
<h2>Is there a way we can set custom Mountpoint. Through <code>docker volume</code> command or through <code>docker-compose.yml</code>?</h2>
| <docker><docker-compose> | 2016-09-14 17:39:57 | HQ |
39,497,020 | How to change all negative numbers to positive python? | <p>In python 3, how can we change a list of numbers (such as 4, 1, -7, 1, -3) and change all of the negative signs into positive signs?</p>
| <python-3.x> | 2016-09-14 18:11:08 | LQ_CLOSE |
39,497,416 | tools to create a website | <p>I am trying to learn JavaScript & AngularJS, had basic idea of HTML & CSS.</p>
<p>I want to create a website like a registration one.</p>
<p><strong>Registration:</strong>
I already made a registration page with first name, last name, email & password.</p>
<p>So now, when any user enter the details and hit register button, the page should display the user full name, email with registration success message.</p>
<p>Also the registration details should be loaded to database.</p>
<p><strong>Login:</strong>
I also made the login page with email and password.</p>
<p>So now, when user hits login with correct credentials, the page should displays logged in with user details.</p>
<p><strong>Database:</strong></p>
<p>I want to know which database can I use? how to use that database? Will this include programming or a tool to create the table?</p>
<p><strong>Tools:</strong></p>
<p>I am looking to work with AngularJS</p>
<p>So for overall about this project, what tools I have to use or install. I have <strong>Mac</strong>.</p>
<p>What tools can help to integrate the files?</p>
| <javascript><html><angularjs><web> | 2016-09-14 18:36:32 | LQ_CLOSE |
39,497,667 | java, quartz and multiple tasks triggered at certain times saved in a database | <p>I'm building a system where users can set a future date(down to hours and minutes) in calendar. At that date a trigger is calling a certain task, unique for every user.</p>
<p>Every user can set a different date. The system will have 10k+ from the start and a user can create more than one trigger.</p>
<p>So assuming I have 10k users each user create on average 3 triggers => 30k triggers with 30k different dates.</p>
<p>All dates are saved in a database.</p>
<p>I'm new to quartz, can this be done in a more optimized way?</p>
<p>I was thinking about making a task run every minute that will get the tasks that will suppose to run in the next hour and remove them from database.</p>
<p>Do you have any better ideas? Did someone used quartz for a large number of triggers.</p>
| <java><quartz-scheduler> | 2016-09-14 18:52:49 | HQ |
39,498,287 | what is the matter my java script | Its not working
what is the problem
i am trying put return values but browser not display anything :(
please help me
i newbie so please help me
<html>
<head></head>
<body>
<script type="text/javascript">
function (){
document.write(100+50);
}
function 2(){
document.write(100-50);
}
function 3(){
document.write(100/50);
}
function show(){
1();
2();
2();
}
show();
</script>
</body>
</html> | <javascript> | 2016-09-14 19:32:22 | LQ_EDIT |
39,498,512 | Strange error with C++ console app when running a for loop | <p>So I was messing around with the dimensions of an array, starting it with [25][25]. I've eventually found the best dimensions of it ([21][25]) but I've forgot to change the condition in the for loop which is displaying the array (Initially it was y<25 and it had to be y<21). The program ran just fine but there was a strange error. What the array was displaying was pretty strange and also it made sounds (the sound is very familiar, although I can't tell exactly what it is. I can guess it is the one you get when you try to open a shortcut which file's destination was deleted but I'm not very sure, as I've said very familiar tho.)<a href="https://i.stack.imgur.com/z6SrE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/z6SrE.png" alt="enter image description here"></a> I have also uploaded a screenshot and you can see the error for yourself ( the 2 lines before the "Process returned 0" one). Any idea why these specific characters tho ( I mean a smiley face? come on.)?</p>
| <c++> | 2016-09-14 19:46:35 | LQ_CLOSE |
39,498,671 | Dynamic certificate pinning | <p>I have an iOS application that will be distributed to multiple customers, each using their own network infrastructure. I would like to add some certificate pinning capabilities, but I need to do it in a dynamic fashion since I cannot ship the app with the cert/pubkey bundled, as doing so would require a different build for each customer.</p>
<p>My idea is to query the per-client configured HTTPS server on app startup, get the certificate, potentially extract the public key and then pin it.</p>
<p>Is it possible to do this in Swift or Objective-C? I have not been able to find relevant code samples or documentation.</p>
| <ios><objective-c><swift><ssl><pinning> | 2016-09-14 19:56:46 | HQ |
39,499,233 | Write to a file with sudo privileges in Python | <p>The following code throws an error if it's run by a non-root user for a file owned by root, even when the non-root user has sudo privileges:</p>
<pre><code>try:
f = open(filename, "w+")
except IOError:
sys.stderr.write('Error: Failed to open file %s' % (filename))
f.write(response + "\n" + new_line)
f.close()
</code></pre>
<p>Is there a way to run <code>open(filename, "w+")</code> with sudo privileges, or an alternative function that does this?</p>
| <python><file-writing><ioerror> | 2016-09-14 20:34:54 | HQ |
39,499,242 | How can I bring a node express app online? | <p>I've built a node express app and now I want to make it available on a website.
What are the steps I need to take?
This may be a very general newbie question, but I've never bought a domain before and I don't know how to get anything on it. Google didn't help much unfortunately.</p>
| <node.js><express><web> | 2016-09-14 20:35:39 | LQ_CLOSE |
39,499,385 | In php class variable one equal second variable? | <p>This is my code:</p>
<pre><code>class Config {
static public $site = 'http://localhost/site/';
static public $style = $site . 'css/style.css';
// ...
}
</code></pre>
<p>This is not work for me. I get white screen.</p>
<pre><code>class Config {
static public $site = 'http://localhost/site/';
static public $style = 'http://localhost/site/css/style.css';
// ...
}
</code></pre>
<p>This is work. I get design and code. Work very well. My question is Why?</p>
| <php> | 2016-09-14 20:46:09 | LQ_CLOSE |
39,500,265 | Manually add legend Items Python matplotlib | <p>I am using matlibplot and I would like to manually add items to the legend that are a color and a label. I am adding data to to the plot to specifying there would lead to a lot of duplicates.</p>
<p>My thought was to do:</p>
<pre><code> ax2.legend(self.labels,colorList[:len(self.labels)])
plt.legend()
</code></pre>
<p>Where self.labels is the number of items I want legend lables for that takes a subset of the large color list. However this yields nothing when I run it.</p>
<p>Am I missing anything?</p>
<p>Thanks</p>
| <python><matplotlib> | 2016-09-14 21:55:58 | HQ |
39,501,074 | Hibernate interceptor and event listeners | <p>I wonder if it's possible to find out what hibernate <em>really</em> did to the database (i.e., committed changes). I'd like to notify another process on certain changes.</p>
<p>I guess that the <a href="https://docs.jboss.org/hibernate/orm/5.0/javadocs/org/hibernate/event/spi/EventType.html">EventType</a>s <code>POST_COMMIT_DELETE</code>, <code>POST_COMMIT_UPDATE</code> and <code>POST_COMMIT_INSERT</code> should do, but given exactly zero documentation, it's only a guess. Can someone confirm? Am I missing any?</p>
<p>I'm also unsure about how to obtain what gets really written. The <code>PostInsertEvent</code> contains both <code>Object entity</code> and <code>Object[] state</code>, which of the two should I trust?</p>
<hr>
<p>A side question: I'm using no XML, no Spring, no JPA, just <code>Configuration</code> and <code>buildSessionFactory</code>. Is this really the way listeners should be registered?</p>
<pre><code> EventListenerRegistry registry = ((SessionFactoryImpl) sessionFactory)
.getServiceRegistry()
.getService(EventListenerRegistry.class);
registry.appendListeners(....);
</code></pre>
<p>I'm asking as its 1. dependent on an implementation detail, 2 totally ugly, 3. nearly perfectly undiscoverable.</p>
| <java><hibernate><transactions><listener> | 2016-09-14 23:23:34 | HQ |
39,501,187 | How does Math.tan(x) actually work? (Javascript) | <p>I'm trying to understand the math behind the Math.tan method but it doesn't make any sense. Can someone please explain to me how it works?</p>
<p>Firstly the mathematical formula to solve for a tangent angle is Tangent = Opposite/Adjacent. Which means I need to know two sides of the triangle to figure out the tangent angle. However the Math.tan method only accept a single argument in radians, not the length of two sides, so I don't understand how it's figuring out the angle of the tangent. </p>
<p>Next in examples they show passing impossibly huge radian values into the method and getting back a value. For example, W3 schools shows the example of <code>Math.tan(90)</code> but 90 radians equals 5,156.6 degrees which is an impossible angle for a corner of a right triangle.</p>
<p>How does this method work, what's happening behind the scenes that turns 90 radians into a tangent angle of -1.995200412208242 </p>
| <javascript><math> | 2016-09-14 23:39:51 | LQ_CLOSE |
39,501,595 | Angular 2 select option (dropdown) - how to get the value on change so it can be used in a function? | <p>I am trying to build a drop down with a few values.</p>
<p>However, on selecting a value, I want to make an API call that takes an id.</p>
<p>In my component.ts, I have an array of values:</p>
<pre><code>values = [
{ id: 3432, name: "Recent" },
{ id: 3442, name: "Most Popular" },
{ id: 3352, name: "Rating" }
];
</code></pre>
<p>In my template, I am using that array as follows:</p>
<pre><code><select>
<option *ngFor="let v of values" [value]="v">
{{v.name}}
</option>
</select>
</code></pre>
<p>However, on picking a value from the drop down, how can I access the <code>id</code> property? I want to use that in my function <code>getPhotosByType(id)</code>.</p>
<p>Thanks</p>
| <javascript><html><angular><typescript> | 2016-09-15 00:36:55 | HQ |
39,501,873 | .txt function not linking to main function | <p>I am making a program with a list of baby names but I've decided to make a seperate function to open the file, this is what I have got so far.</p>
<pre><code>#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void open_file(ifstream& in, char fileName[]);
void find_name(ifstream& in, string name, int numNames);
int main() {
const int NUMNAMES = 1000;
ifstream inStream;
char fileName[30];
string name;
cout << "Enter the name of the file that contains the names: " << endl;
open_file(inStream, fileName);
cout << "Enter the name to search for (capitalize first letter): " << endl;
cin >> name;
find_name(inStream, name, NUMNAMES);
inStream.close();
}
void open_file(ifstream& ) {
string line;
ifstream myfile ("babyNames.txt");
if (myfile.is_open())
{
while ( getline (myfile,line) )
{
cout << line << '\n';
}
myfile.close();
}
else cout << "I/O failure opening file babyNames";
}
</code></pre>
<p>Does anyone know why I am getting so many error messages:</p>
<pre><code>Undefined symbols for architecture x86_64:
"find_name(std::__1::basic_ifstream<char, std::__1::char_traits<char> >&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, int)", referenced from:
_main in Untitled-1b6d2e.o
"open_file(std::__1::basic_ifstream<char, std::__1::char_traits<char> >&, char*)", referenced from:
_main in Untitled-1b6d2e.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
</code></pre>
<p>Does anyone know what I am doing wrong, I feel like it is relatively close I'm just fairly new to streams in c++.</p>
| <c++><function> | 2016-09-15 01:19:40 | LQ_CLOSE |
39,502,417 | Java using else if to assign a value | <p>I'm very new to programming and Java. I'm trying to use else if to assign a value to a variable if they selected the correct input. But whenever I try to compile it, it says it cannot find the variable.</p>
<pre><code>import java.util.Scanner;
public class TDEE
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
double tdee = 0.0;
System.out.print("Please enter your name: ");
String name = in.next();
System.out.print("Please enter your BMR: ");
double bmr = in.nextDouble();
System.out.print("Please enter your Gender (M/F): ");
String gender = in.next();
System.out.println();
// providing menu items
System.out.println("Select your activity level: ");
System.out.println("[0] Resting (Sleeping. Reclining)");
System.out.println("[1] Sedentary (Minimal Movement)");
System.out.println("[2] Light (Sitting, Standing)");
System.out.println("[3] Moderate (Light Manual Labor, Dancing, Riding Bike)");
System.out.println("[4] Very Active (Team Sports, Hard Manual Labor)");
System.out.println("[5] Extremely Active (Full-time Athlete, Heavy Manual Labor)");
System.out.println();
// accept user choice with a Scanner class method
System.out.print("Enter the number corresponding to your activty level(0,1,2,3,4, or 5): ");
String choice = in.next();
System.out.println();
if(choice.equalsIgnoreCase("0"))
{
double activityFactor = 1.0;
}
else if(choice.equalsIgnoreCase("1"))
{
double activityFactor = 1.3;
}
else if(choice.equalsIgnoreCase("2") && "M".equals(gender))
{
double activityFactor = 1.6;
}
else if(choice.equalsIgnoreCase("2") && "F".equals(gender))
{
double activityFactor = 1.5;
}
else if(choice.equalsIgnoreCase("3") && "M".equals(gender))
{
double activityFactor = 1.7;
}
else if(choice.equalsIgnoreCase("3") && "F".equals(gender))
{
double activityFactor = 1.6;
}
else if(choice.equalsIgnoreCase("4") && "M".equals(gender))
{
double activityFactor = 2.1;
}
else if(choice.equalsIgnoreCase("4") && "F".equals(gender))
{
double activityFactor = 1.9;
}
else if(choice.equalsIgnoreCase("5") && "M".equals(gender))
{
double activityFactor = 2.4;
}
else if(choice.equalsIgnoreCase("5") && "F".equals(gender))
{
double activityFactor = 2.2;
}
else
{
System.out.println("You did not choose a valid manu option.");
}
tdee = bmr * activityFactor;
System.out.println();
System.out.println("Name: " + name + " Gender: " + gender);
System.out.println("BMR: " + bmr + " Activity Factor: " + activityFactor);
System.out.println("TDEE: " + tdee);
}
}
</code></pre>
| <java> | 2016-09-15 02:47:29 | LQ_CLOSE |
39,503,096 | Update json data in Swift Table View | Im new to swift programming.I created a simple webservice to connect with swift app.Then i retrieved json data as a list in to the table view and insert data in to the web service. Now I want to update json data row in the table view.Please anyone help me | <ios><json><swift> | 2016-09-15 04:24:31 | LQ_EDIT |
39,503,182 | std::stringstream object unrecognized in std::to_string replacement function | <p>Since std::to_string doesn't work for me, and since I'm working on a very difficult environment at the moment (I'm working on Android using a Linux terminal emulator), I've decided to leave it broken and use a user-made function instead to replace it (I've found it online).</p>
<p>Here's the exact code I'm using:</p>
<pre><code>#include <sstream>
namespace patch {
template <typename T>
std::string to_string(const T &n);
std::stringstream stm;
stm << n;
return stm.str();
}
}
</code></pre>
<p>I'm compiling it using these tags:</p>
<pre><code>g++ -std=c++11 -g -Wall -Wextra -pedantic
</code></pre>
<p>And I'm getting these errors:</p>
<pre><code>unknown type name 'stm'; did you mean 'tm'?
stm << n;
^~~
</code></pre>
<p>(then a note on <code>tm</code> being declared somewhere in <code>include/time.h</code>)</p>
<pre><code>expected unqualified-id
return stm.str();
^
</code></pre>
<p>And then also an "extraneous closing brace" error for the last brace which closes the namespace brace.</p>
<p>As I understand it, it doesn't recognize the line <code>stm << n;</code> as the method <code>operator <<</code> used on a <code>std::stringstream</code> object, but instead as some variable declariation for some reason.</p>
<p>Why exactly am I getting those errors? Is there a way to fix them? If not, what can I use to replace even this solution?</p>
| <c++><c++11><tostring><stringstream> | 2016-09-15 04:35:52 | LQ_CLOSE |
39,503,335 | Indoor positioning android app using wifi signals | <p>Am new to android ,i want to create an android app to track indoor position using ips(wifi signals)
I need to know what are Prerequisites required for and the basic idea to develop it</p>
| <android><android-studio> | 2016-09-15 04:52:35 | LQ_CLOSE |
39,503,390 | Global Exception Handling in Xamarin Cross platform | <p>Can you please let me know how to handle the global exception(without App crash) in Xamarin Cross platform project.</p>
| <xamarin><xamarin.ios><xamarin.android><xamarin.forms><cross-platform> | 2016-09-15 04:56:59 | HQ |
39,503,418 | What is the purpose of Resolving model jre:call:zip:1.0.0? | <p>I try to run a Java program, I see:</p>
<blockquote>
<p>Resolving model jre:call:zip:1.0.0</p>
</blockquote>
<p><a href="https://i.stack.imgur.com/gG1bK.png" rel="noreferrer"><img src="https://i.stack.imgur.com/gG1bK.png" alt="enter image description here"></a></p>
| <java><eclipse> | 2016-09-15 04:59:51 | HQ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.