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,541,916
How can I improve this JavaScript code?
<pre><code>for(var i = 1; i &lt;= 20; i++){ switch (i) { case 3: case 6: case 9: case 12: case 18: console.log("Fizz"); break; case 5: case 10: case 20: console.log("Buzz"); break; case 15: console.log("FizzBuzz"); break; default: console.log(i); } } </code></pre> <p>I am supposed to print numbers from 1-20.</p> <p>These are the conditions.</p> <p>if a number is divisible by 3, then i need to print "Fizz"</p> <p>If a number is divisible by 5, then I need to print "Buzz"</p> <p>if a number is divisible by both 3 and 5, then I need to print "FizzBuzz".</p> <p>I came up with the aforementioned code, but I think it can be improved.</p>
<javascript><loops>
2016-09-17 01:02:48
LQ_CLOSE
39,542,435
bootstrap 4 pull-xs-right not working as expected
<p>I have this html using <a href="http://v4-alpha.getbootstrap.com/components/utilities/" rel="noreferrer">bootstrap 4 utilities</a> to pull the buttons to the right of the screen. And it does do this.</p> <p>However, the buttons do not push down the content below it as expected. They end up overlayed on top of the content below.</p> <p>If I do not use <code>pull-xs-right</code> then the buttons are left aligned, but they do push the items below.</p> <p>Is there some other class I need to apply?</p> <pre><code> &lt;div class="pull-xs-right"&gt; &lt;button click.delegate="saveEdit()" type="submit" class="k-button k-primary"&gt; Save &lt;/button&gt; &lt;button click.delegate="cancel()" class="k-button"&gt; Cancel &lt;/button&gt; &lt;/div&gt; </code></pre>
<css><bootstrap-4>
2016-09-17 02:55:19
HQ
39,542,708
How to reset Observable.interval
<p>How can I construct an observable which emits at some predetermined interval, but also can be made to emit when a second observable emits, at which point the interval will be "reset" to start emitting again at the original interval starting from the point of the second ping?</p> <p>For example, let's say the interval is 10 minutes. The observable would emit at 10, 20, 30, etc. But let's say the second observable at emits at time 15. Then the overall observable should ping at 10, 15, 25, 35, etc.</p>
<rxjs>
2016-09-17 03:58:05
HQ
39,543,108
How do I Set Timer Control According to User entry in C# windows application?
<p>I need help regarding timer control, I wanted to set time after user entry i.e. after form run's user enter in textbox 10:30 AM then timer on label will start from 10:30 AM to continue..</p>
<c#><c#-4.0><c#-3.0><c#-2.0>
2016-09-17 05:19:22
LQ_CLOSE
39,543,606
R - Getting Column of Dataframe from String
<p>I am trying to create a function that allows the conversion of selected columns of a data frame to categorical data type (factor) before running a regression analysis.</p> <p>Question is how do I slice a particular column from a data frame using a string (character).</p> <p>Example:</p> <pre><code> strColumnNames &lt;- "Admit,Rank" strDelimiter &lt;- "," strSplittedColumnNames &lt;- strsplit(strColumnNames, strDelimiter) for( strColName in strSplittedColumnNames[[1]] ){ dfData$as.name(strColName) &lt;- factor(dfData$get(strColName)) } </code></pre> <p>Tried:</p> <pre><code>dfData$as.name() dfData$get(as.name()) dfData$get() </code></pre> <p>Error Msg: Error: attempt to apply non-function</p> <p>Any help would be greatly appreciated! Thank you!!!</p>
<r><dataframe><regression><logistic-regression>
2016-09-17 06:33:53
LQ_CLOSE
39,543,615
Incorparation of AWK in perl
Hai i have a BLAST out file in tab limited format.like this p=BAC58264.1 CP014046.1 100.00 435 0 0 1 435 804117 8045 862 p=BAC58264.1 CP014046.1 100.00 160 0 0 3 372 444601 4443 32 p=BAC58264.1 BA000031.2 100.00 435 0 0 1 435 805024 371 862 i want to sort that like this based on the 3th column p=BAC58264.1 CP014046.1 100.00 435 0 0 1 435 804117 8045 862 p=BAC58264.1 BA000031.2 100.00 435 0 0 1 435 805024 371 862 i usually did this by this awk code "$4>=435">BLASTSORT how to incorporate this awk code in a perl programme
<perl><awk>
2016-09-17 06:34:37
LQ_EDIT
39,543,903
Javascript timer shouldn't reset
I want to reload the page and timer Shouldn't be rest on page reload to next part , is there any way to achieve this functionality ?
<javascript><jquery>
2016-09-17 07:08:10
LQ_EDIT
39,543,968
Got an exception while running the query in hql
@Query("select new map(count(t.status) as allCount,sum(case when t.status='Approved' then 1 else 0 end) as approvedCount, " + "sum(case when t.status='Overdue' then 1 else 0 end) as overdueCount," + "sum(case when t.status='Rejected' then 1 else 0 end) as rejectedCount," + "sum(case when t.status='Awaiting Approval' then 1 else 0 end) as awaitingApprovalCount," + "sum(case when t.status='Not Submitted' then 1 else 0 end) as notSubmittedCount) " + "from Timesheet as t where t.emplId=:employeeId and (t.startDate between date_add(:startDate, interval -6 day) and date_add(:endDate,interval 6 day))" + "and (t.endDate between date_add(:startDate, interval -6 day) and date_add(:endDate,interval 6 day))") where it throws an exception as org.hibernate.hql.internal.ast.QuerySyntaxException : Expecting CLOSE, found 'day' near line 1.
<java><hibernate><jpa><spring-data-jpa>
2016-09-17 07:14:56
LQ_EDIT
39,544,839
MongoDB select via java
MongoClient mongo = new MongoClient(); DB db = mongo.getDB("mytest"); DBCollection col = db.getCollection("testt"); //read example DBObject query = BasicDBObjectBuilder.start("$gte", "06/01/2016 00:00:00").add("$lte", "10/01/2016 00:00;00").get(); DBCursor cursor = col.find(query); while(cursor.hasNext()){ System.out.println("docc:"); System.out.println(cursor.next()); } **I am getting below exception while selecting data from MongoDB in java** com.mongodb.MongoQueryException: Query failed with error code 2 and error message 'unknown top level operator: $gte' on server 127.0.0.1:27017 at com.mongodb.operation.FindOperation$1.call(FindOperation.java:493) at com.mongodb.operation.FindOperation$1.call(FindOperation.java:483) at com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:241) at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:214) at com.mongodb.operation.FindOperation.execute(FindOperation.java:483) at com.mongodb.operation.FindOperation.execute(FindOperation.java:80) at com.mongodb.Mongo.execute(Mongo.java:818) at com.mongodb.Mongo$2.execute(Mongo.java:805) at com.mongodb.DBCursor.initializeCursor(DBCursor.java:851) at com.mongodb.DBCursor.hasNext(DBCursor.java:152) at MongoFetch.main(MongoFetch.java:55)
<java><mongodb>
2016-09-17 08:51:33
LQ_EDIT
39,545,037
Updating user by UserManager.Update() in ASP.NET Identity 2
<p>I use <code>ASP.NET Identity 2</code> in an <code>MVC 5</code> project and I want to update <code>Student</code> data by using <code>UserManager.Update()</code> method. However, as I inherit from <code>ApplicationUser</code> class, I need to map <code>Student</code> to <code>ApplicationUser</code> before calling update method. On the other hand, when using the approach that I also used for creating new Student, there is an error due to concurrency as I create a new instance rather than update. As I am bored to solve the problem using <code>AutoMapper</code>, I need a stable fix to solve the problem without <code>AutoMapper</code>. Could you please clarify me how to solve this problem? I pass the <code>StudentViewModel</code> to the Update method in the Controller and then I need to map it to Student and then pass them to the <code>UserManager.Update()</code> method as <code>ApplicationUser</code>. On the other hand I am wondering if I should retrieve and send the password on Controller stage instead of passing to View for security concern? Could you also inform me about this issue (during User Update I do not update password and I have to keep the user's password in the database). Any help would be appreciated.</p> <p><strong>Entity Classes:</strong></p> <pre><code>public class ApplicationUser : IdentityUser&lt;int, ApplicationUserLogin, ApplicationUserRole, ApplicationUserClaim&gt;, IUser&lt;int&gt; { public string Name { get; set; } public string Surname { get; set; } //code omitted for brevity } public class Student: ApplicationUser { public int? Number { get; set; } } </code></pre> <p><br/></p> <p><strong>Controller:</strong></p> <pre><code>[HttpPost] [ValidateAntiForgeryToken] public JsonResult Update([Bind(Exclude = null)] StudentViewModel model) { if (ModelState.IsValid) { ApplicationUser user = UserManager.FindById(model.Id); user = new Student { Name = model.Name, Surname = model.Surname, UserName = model.UserName, Email = model.Email, PhoneNumber = model.PhoneNumber, Number = model.Number, //custom property PasswordHash = checkUser.PasswordHash }; UserManager.Update(user); } } </code></pre>
<c#><asp.net-mvc><asp.net-identity><automapper><asp.net-identity-2>
2016-09-17 09:13:54
HQ
39,545,436
Mobile Info App Android
<p>I want to <strong>develop</strong> android app that's tells the info of <strong>mobiles</strong>. My app contains information of </p> <ul> <li>Model</li> <li>Manufacture</li> <li>Device</li> <li>Product</li> <li>Brand</li> <li>Android Version</li> <li>API level</li> <li>Build ID</li> <li>Finger Print</li> <li>List item</li> </ul> <p><a href="https://i.stack.imgur.com/HOZJr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HOZJr.png" alt="Appp look like this"></a></p> <p>App look like this</p> <p>I don't know how to start this app. I want the idea to start this app.I would really appreciate any kind of help regarding this Thankx.</p>
<android><mobile><hardware>
2016-09-17 09:57:29
LQ_CLOSE
39,545,775
How to sumit 3 forms of 3 diffrent pages at once
I have 3 forms in 3 different pages, and submit button is on the 3rd page, how can I submit all 3 forms simultaneously by clicking on submit button. Is there any solution in javascript or jquery. page-1 <form id="firstForm"> <input type="checkbox" name="answ1" value="answ1" autocomplete="off"/> </form> page-2 <form id="secondForm"> <input type="checkbox" name="answ2" value="answ2" autocomplete="off"/> <input type="checkbox" name="answ3" value="answ3" autocomplete="off"/> <input type="checkbox" name="answ4" value="answ4" autocomplete="off"/> </form> page-3 <form id="ThirdForm"> <input type="checkbox" name="answ5" value="answ5" autocomplete="off"/> <input type="checkbox" name="answ6" value="answ6" autocomplete="off"/> <input type="checkbox" name="answ7" value="answ7" autocomplete="off"/> <button type="submit">submit</button> </form>
<javascript><jquery><ajax><html>
2016-09-17 10:32:19
LQ_EDIT
39,545,866
how to store xml tag values in database using java
I have written a code to read an xml file without specifying tagnames. I have used getElementBytagname(*) which reads every tag and give me output. But now i want to insert those tag values in database columns. For eg. Suppose i have a tagname <merchantId>101</merchantId> this value need to be stored in database column name as merchantId. Can somebody please help me out?
<java><database>
2016-09-17 10:42:14
LQ_EDIT
39,546,278
No provider for RouterOutletMap
<h1>Newest Angular 2.0.0 and via newest angular-cli 1.0.0-beta.14, node: 6.6.0, os: linux x64</h1> <h1>What I do:</h1> <p>1) Create new project</p> <pre><code>ng new angular-test ng g component projects ng g component typings </code></pre> <p>2) Add simple routing</p> <p>/src/app/app.component.html</p> <pre><code> &lt;router-outlet&gt;&lt;/router-outlet&gt; </code></pre> <p>/src/app/app.module.ts</p> <pre><code>export const ROUTES: Routes = [ { path: '', redirectTo: '/projects', pathMatch: 'full' }, { path: 'projects', component: ProjectsComponent, }, { path: '/typings', component: TypingsComponent }, { path: '**', redirectTo: '' } ]; @NgModule({ declarations: [ AppComponent, ProjectsComponent, TypingsComponent ], imports: [ BrowserModule, FormsModule, HttpModule, RouterModule.forChild(ROUTES) ], providers: [], bootstrap: [AppComponent] }) export class AppModule { } </code></pre> <h1>What I get:</h1> <pre><code>EXCEPTION: Error in ./AppComponent class AppComponent - inline template:3:0 caused by: No provider for RouterOutletMap! ORIGINAL EXCEPTION: No provider for RouterOutletMap! </code></pre> <p><a href="https://i.stack.imgur.com/vRffx.png" rel="noreferrer"><img src="https://i.stack.imgur.com/vRffx.png" alt="enter image description here"></a></p> <h1>How I tried to fix this</h1> <p>I tried to add RouterOutletMap to providers in AppModule, exception don't throw, but app don't redirect to projects and don't show nesting components</p>
<angular>
2016-09-17 11:24:47
HQ
39,548,053
How to resolve : unexpected error occured Initializing Android Designer" in VS 2015 with Xamarin
<p>Bringing up a new PC with Xamarin and VS 2015 Pro I received the following error:</p> <blockquote> <p>An unexpected error occurred trying to initialize Android Designer. Please verify the Android SDK path and the Java Development Kit path on Tools->Options->Xamarin->Android Settings menu. Please see the logs for more details.</p> </blockquote> <p>I verified the SDK's are installed correctly. VS didn't generate any kind of Activity Log so I believe the log must lie elsewhere. Anyone know where I can find this log to find out more about what is wrong ?</p>
<android><visual-studio><xamarin><android-designer>
2016-09-17 14:42:05
HQ
39,548,318
Ajax forgot password error syntax
<p>I am having a syntax error for a form I have changed from PHP to using Jquery/Ajax. I am trying to test if form will work and submit to reset the password.</p> <p>I keep getting the below error</p> <p>syntax error, unexpected $end in <b>/home/a4358077/public_html/mod/forgotajax.php </b> on line <b>38</b><br /></p> <p>My code is -</p> <pre><code>&lt;?php require_once('../inc/autoload.php'); $objForm = new Form(); $objValid = new Validation($objForm); $objUser = new User(); // forgot password form if ($objForm-&gt;isPost('email')) { $objValid-&gt;_expected = array('email'); $objValid-&gt;_required = array('email'); $email = $objForm-&gt;getPost('email'); if (empty($email) || !$objValid-&gt;isEmail($email)) { $objValid-&gt;add2Errors('email'); } else { $user = $objUser-&gt;getByEmail($email); if (!empty($user)) { if ($objValid-&gt;isValid()) { if ($objUser-&gt;forgotUser($user)) { $url = !empty($url) ? $url : '/?page=forgotsuccess'; echo json_encode(array('error' =&gt; false, 'url' =&gt; $url)); } else { $url = !empty($url) ? $url : '/?page=forgot-failed'; //$message = 'Error in registration, Please contact administrator'; // failure $objValid-&gt;add2Errors('login'); echo json_encode(array('error' =&gt; true, 'validation' =&gt; $objValid-&gt;_error_messages)); } } else { echo json_encode(array('error' =&gt; true)); } </code></pre> <p>I have tried fixing the code but cannot figure out where to either put a curly brace.</p> <p>Any help is much appreciated. </p> <p>Thanks</p>
<php><jquery><ajax>
2016-09-17 15:06:04
LQ_CLOSE
39,548,380
React & Draft.js - convertFromRaw not working
<p>I'm using Draft.js to implement a text editor. I want to save the content of the editor to a DB and later retrieve it and inject it in an editor again, e.g. when revisiting the editor page.</p> <p><strong>First, these are the relevant imports</strong></p> <pre><code>import { ContentState, EditorState, convertToRaw, convertFromRaw } from 'draft-js'; </code></pre> <p><strong>How I Save the Data to the DB (located in a parent Component)</strong></p> <pre><code>saveBlogPostToStore(blogPost) { const JSBlogPost = { ...blogPost, content: convertToRaw(blogPost.content.getCurrentContent())}; this.props.dispatch(blogActions.saveBlogPostToStore(JSBlogPost)); } </code></pre> <p>Now when I check the DB, I get the following Object:</p> <pre><code>[{"_id":null,"url":"2016-8-17-sample-title","title":"Sample Title","date":"2016-09-17T14:57:54.649Z","content":{"blocks":[{"key":"4ads4","text":"Sample Text Block","type":"unstyled","depth":0,"inlineStyleRanges":[],"entityRanges":[]}]},"author":"Lukas Gisder-Dubé","__v":0,"tags":[]}] </code></pre> <p>So far so good I guess, I tried some other stuff and the Object in the Database is definitely converted. For example, when I save the content without calling the convertToRaw()-method, there are a lot more fields.</p> <p><strong>Setting the Data as new EditorState</strong></p> <p>To retrieve the Data from the DB and set it as EditorState, I also tried a lot. The following is my best guess:</p> <pre><code>constructor(props) { super(props); const DBEditorState = this.props.blogPost.content; console.log(DBEditorState); // logs the same Object as above this.state = { ...this.props.blogPost, content: EditorState.createWithContent( convertFromRaw(DBEditorState) )}; } </code></pre> <p>When rendering the component i get the following error:</p> <pre><code>convertFromRawToDraftState.js:38 Uncaught TypeError: Cannot convert undefined or null to object </code></pre> <p>Any help is greatly appreciated!</p>
<javascript><reactjs><draftjs>
2016-09-17 15:12:09
HQ
39,548,747
Fabricjs How to scale object but keep the border (stroke) width fixed
<p>I'm developing a diagram tool based on fabricjs. Our tool has our own collection of shape, which is svg based. My problem is when I scale the object, the border (stroke) scale as well. My question is: How can I scale the object but keep the stroke width fixed. Please check the attachments.<br> <a href="https://i.stack.imgur.com/3UVMc.png" rel="noreferrer"><img src="https://i.stack.imgur.com/3UVMc.png" alt="small version"></a></p> <p><a href="https://i.stack.imgur.com/QCMLM.png" rel="noreferrer"><img src="https://i.stack.imgur.com/QCMLM.png" alt="scaled version"></a></p> <p>Thank you very much! </p>
<fabricjs>
2016-09-17 15:50:44
HQ
39,549,111
The iPhone 4 and iPhone 4s simulators disappeared after upgrading to Xcode 8. How do I get them back?
<p>I have these iPhone simulators:</p> <ul> <li>iPhone 5</li> <li>iPhone 5s</li> <li>iPhone 6</li> <li>iPhone 6 Plus</li> <li>iPhone 6s</li> <li>iPhone 6s Plus</li> <li>iPhone 7</li> <li>iPhone 7 Plus</li> <li>iPhone SE</li> </ul> <p>What happened to the iPhone 4 and iPhone 4s?</p>
<xcode><xcode8>
2016-09-17 16:28:04
HQ
39,549,215
What is the difference between a node, stage, and step in Jenkins pipelines?
<p>I'm trying to understand how to structure my Jenkins 2.7 pipeline groovy script. I've read through the <a href="https://github.com/jenkinsci/pipeline-plugin/blob/master/TUTORIAL.md" rel="noreferrer">pipeline tutorial</a>, but feel that it could expand more on these topics.</p> <p>I can understand that a pipeline can have many <code>stage</code>s and each <code>stage</code> can have many <code>step</code>s. But what is the difference between a <code>step();</code> and a method call inside a <code>stage</code>, say <code>sh([script: "echo hello"]);</code>. Should <code>node</code>s be inside or outside of <code>stage</code>s? Should the overall properties of a job be inside or outside a <code>node</code>?</p> <p>Here is my current structure on an ubuntu master node:</p> <pre><code>#!/usr/bin/env groovy node('master') { properties([ [$class: 'BuildDiscarderProperty', strategy: [$class: 'LogRotator', numToKeepStr: '10']] ]); stage 'Checkout' checkout scm stage 'Build' sh([script: "make build"]); archive("bin/*"); } </code></pre>
<jenkins><jenkins-pipeline>
2016-09-17 16:38:25
HQ
39,549,230
Java - lop to search keys words in list of String
I have list of user tweets (usersTweets), i need to find a tweets with specific keys words (listOfkeyWord), and add matches to (includeKeyWord). there can be many of word in (keyWord = "ten,six,seven,...). String keyWord = "one,two"; List<String> usersTweets = new ArrayList<String>(); usersTweets.add("three nine one two"); usersTweets.add("seven one"); usersTweets.add("three nine ten one"); usersTweets.add("...."); List<String> includeKeyWord = new LinkedList<String>(); if (keyWord.contains(",")) { List<String> listOfkeyWord = new ArrayList<String>(Arrays.asList(keyWord.split(","))); for (String tweet : usersTweets) { if (tweet.contains(listOfkeyWord)) { includeKeyWord.add(tweet); } } }
<java><for-loop>
2016-09-17 16:39:40
LQ_EDIT
39,549,331
Reshape numpy (n,) vector to (n,1) vector
<p>So it is easier for me to think about vectors as column vectors when I need to do some linear algebra. Thus I prefer shapes like (n,1). </p> <p>Is there significant memory usage difference between shapes (n,) and (n,1)? </p> <p>What is preferred way? </p> <p>And how to reshape (n,) vector into (n,1) vector. Somehow b.reshape((n,1)) doesn't do the trick. </p> <pre><code>a = np.random.random((10,1)) b = np.ones((10,)) b.reshape((10,1)) print(a) print(b) [[ 0.76336295] [ 0.71643237] [ 0.37312894] [ 0.33668241] [ 0.55551975] [ 0.20055153] [ 0.01636735] [ 0.5724694 ] [ 0.96887004] [ 0.58609882]] [ 1. 1. 1. 1. 1. 1. 1. 1. 1. 1.] </code></pre>
<python><numpy>
2016-09-17 16:48:45
HQ
39,549,424
How to create unique keys for React elements?
<p>I am making a React app that allows you to make a list and save it, but React has been giving me a warning that my elements don't have a unique key prop (elements List/ListForm). How should I create a unique key prop for user created elements? Below is my React code</p> <pre><code>var TitleForm = React.createClass({ handleSubmit: function(e) { e.preventDefault(); var listName = {'name':this.refs.listName.value}; this.props.handleCreate(listName); this.refs.listName.value = ""; }, render: function() { return ( &lt;div&gt; &lt;form onSubmit={this.handleSubmit}&gt; &lt;input className='form-control list-input' type='text' ref='listName' placeholder="List Name"/&gt; &lt;br/&gt; &lt;button className="btn btn-primary" type="submit"&gt;Create&lt;/button&gt; &lt;/form&gt; &lt;/div&gt; ); } }); var ListForm = React.createClass({ getInitialState: function() { return {items:[{'name':'item1'}],itemCount:1}; }, handleSubmit: function(e) { e.preventDefault(); var list = {'name': this.props.name, 'data':[]}; var items = this.state.items; for (var i = 1; i &lt; items.length; i++) { list.data.push(this.refs[items[i].name]); } this.props.update(list); $('#'+this.props.name).remove(); }, handleClick: function() { this.setState({ items: this.state.items.concat({'name':'item'+this.state.itemCount+1}), itemCount: this.state.itemCount+1 }); }, handleDelete: function() { this.setState({ itemCount: this.state.itemCount-1 }); }, render: function() { var listItems = this.state.items.map(function(item) { return ( &lt;div&gt; &lt;input type="text" className="list-form" placeholder="List Item" ref={item.name}/&gt; &lt;br/&gt; &lt;/div&gt; ); }); return ( &lt;div&gt; &lt;form onSubmit={this.handleSubmit} className="well list-form-container"&gt; {listItems} &lt;br/&gt; &lt;div onClick={this.handleClick} className="btn btn-primary list-button"&gt;Add&lt;/div&gt; &lt;div onClick={this.handleDelete} className="btn btn-primary list-button"&gt;Delete&lt;/div&gt; &lt;button type="submit" className="btn btn-primary list-button"&gt;Save&lt;/button&gt; &lt;/form&gt; &lt;/div&gt; ) } }); var List = React.createClass({ getInitialState: function() { return {lists:[], savedLists: []}; }, handleCreate: function(listName) { this.setState({ lists: this.state.lists.concat(listName) }); }, updateSaved: function(list) { this.setState({ savedLists: this.state.savedLists.concat(list) }); }, render: function() { var lst = this; var lists = this.state.lists.map(function(list) { return( &lt;div&gt; &lt;div key={list.name} id={list.name}&gt; &lt;h2 key={"header"+list.name}&gt;{list.name}&lt;/h2&gt; &lt;ListForm update={lst.updateSaved} name={list.name}/&gt; &lt;/div&gt; &lt;/div&gt; ) }); var savedLists = this.state.savedLists.map(function(list) { var list_data = list.data; list_data.map(function(data) { return ( &lt;li&gt;{data}&lt;/li&gt; ) }); return( &lt;div&gt; &lt;h2&gt;{list.name}&lt;/h2&gt; &lt;ul&gt; {list_data} &lt;/ul&gt; &lt;/div&gt; ) }); var save_msg; if(savedLists.length == 0){ save_msg = 'No Saved Lists'; }else{ save_msg = 'Saved Lists'; } return ( &lt;div&gt; &lt;TitleForm handleCreate={this.handleCreate} /&gt; {lists} &lt;h2&gt;{save_msg}&lt;/h2&gt; {savedLists} &lt;/div&gt; ) } }); ReactDOM.render(&lt;List/&gt;,document.getElementById('app')); </code></pre> <p>My HTML:</p> <pre><code>&lt;div class="container"&gt; &lt;h1&gt;Title&lt;/h1&gt; &lt;div id="app" class="center"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre>
<reactjs>
2016-09-17 16:57:11
HQ
39,549,531
Comparing corresponding values of two lines in a file using awk
<pre><code>name1 20160801|76 20160802|67 20160803|49 20160804|35 20160805|55 20160806|76 20160807|77 20160808|70 2016089|50 20160810|75 20160811|97 20160812|90 20160813|87 20160814|99 20160815|113 20160816|83 20160817|57 20160818|158 20160819|61 20160820|46 20160821|1769608 20160822|2580938 20160823|436093 20160824|75 20160825|57 20160826|70 20160827|97 20160828|101 20160829|96 20160830|95 20160831|89 name2 20160801|32413 20160802|37707 20160803|32230 20160804|31711 20160805|32366 20160806|35532 20160807|36961 20160808|45423 2016089|65230 20160810|111078 20160811|74357 20160812|71196 20160813|71748 20160814|77001 20160815|91687 20160816|92076 20160817|89706 20160818|126690 20160819|168587 20160820|207128 20160821|221440 20160822|234594 20160823|200963 20160824|165231 20160825|139600 20160826|145483 20160827|209013 20160828|228550 20160829|223712 20160830|217959 20160831|169106 </code></pre> <p>I have the line position of two lines in a file say line1 and line2. These lines may be anywhere in the file but I can access the line position using a search keyword based on name(the first word) in each line</p> <p>20160801 means yyyymmdd and has an associated value separated by | I need to compare the values associated with each of the date for the given two lines.</p> <p>I am a newbie in awk. I am not understanding how to compare these two lines at the same time.</p>
<awk>
2016-09-17 17:06:26
LQ_CLOSE
39,549,646
what is the command to get the starting character of file in unix
Below is the filename -rwxrwxrwx 1 user1 users 268 Sep 16 18:06 script what should be the command to grep the first character here based on that i want to conclude it as file or directory or a softlink. can we use the wildcard "^" to get this info please?
<bash><shell><grep><wildcard>
2016-09-17 17:16:47
LQ_EDIT
39,550,442
Enable AWS S3 MFA delete with the console
<p>Is it possible to enable AWS S3 MFA delete with the console? How? </p> <p>I don't manage to find any way to do it, neither have found any answer googling.</p>
<amazon-web-services><amazon-s3>
2016-09-17 18:41:31
HQ
39,550,857
AVFoundation Import Warnings after XCODE 8 upgrade
<p>Obj C project; just updated to Xcode 8 and iOS/10. App seems to work fine, however, getting warnings --</p> <p>"Missing submodule 'AVFoundation.AVSpeechSynthesis'" "Missing submodule 'AVFoundation.AVAudioSession'"</p> <p>These messages appear on the #import statements for AVAudioSession &amp; AVSpeechSynthesis.</p> <p>Does anyone know what's going on with this?</p> <p>TIA</p>
<avfoundation><warnings><ios10><xcode8>
2016-09-17 19:25:07
HQ
39,551,029
If else statement for finding the index of a character in a string
<p>For some reason without the else statement the code finds the indexes of the characters in the string. However, when I add the else statement to declare if a character is not found. All it does is give me the else statement even if the character is in the string.</p> <pre><code>#Function takes a character and a string and returns the index of the character #found in the string. def whereIsItS(letter, word): #Start finding the index of characters in the string starting at 0. letInWord = 0 #For loop to find specific characters in a string. for l in word: #If the letter is found it returns the index of the letter. if l == letter: #Moves to the next character in the string. letInWord += 1 else: return "It is not there." #Returns the index of the character found the string. return word.index(letter) </code></pre> <p>I just can't seem to figure out why it works without the else statement, but not with the else statement.</p>
<python><string><python-3.x><indexing><character>
2016-09-17 19:45:08
LQ_CLOSE
39,551,669
Trying to run a C program on unix but a little confused with how input file is handled
I've tried to search for this but I'm having trouble figuring how to phrase my question so I figured I'd just ask here. So I'm trying to run a C program in a unix environment and I have an input file as well. The teacher said we can run it by typing in "gcc programName ./a.out inputFile" or "gcc programName ./a.out inputFile > viewFile" My question is how is this handled within the C program? Like is the input file being added as a parameter for main (or like its name or something) or is it acting like it's reading from system.in or something else? I'm getting a message saying that there's an error opening the input file and I have "int main(int argc, char* argv[])". If someone could explain what's going on and how the input file is handled, I'd really appreciate it.
<c><shell><unix><input>
2016-09-17 20:57:47
LQ_EDIT
39,551,937
Binary operator '===' cannot be applied to operands of type 'Any?' and 'UIBarButtonItem!'
<p>The following code used to be able to compile in swift 2.2, no longer in swift 3.0. How do we fix this? </p> <blockquote> <p>Error: Binary operator '===' cannot be applied to operands of type 'Any?' and 'UIBarButtonItem!'</p> </blockquote> <pre><code>override func prepare(for segue: UIStoryboardSegue, sender: Any?) { if sender === saveButton { // Error! // ... } else if sender === closeButton { // Error! // ... } } </code></pre>
<swift><swift3>
2016-09-17 21:31:05
HQ
39,552,682
Base R horizontal legend - with multiple rows
<p>I wish to create a horizontal legend with multiple rows using base R (not ggplot). There is an option for multiple columns but not multiple rows in legend(). Is there a way to do this? Example to play with below where the horizontal legend it too wide for the plot.</p> <pre><code>MyCol &lt;- topo.colors(20) barplot(rep(1,20), yaxt="n", col=MyCol) x &lt;- 1:20 MyLab &lt;- paste("Zone",x) legend("bottom",MyLab,fill=MyCol,horiz=T) </code></pre>
<r>
2016-09-17 23:27:47
HQ
39,552,822
Area links don't generate in asp.net-core-mvc
<p>Following this guide I've been creating an Admin area: <a href="https://docs.asp.net/en/latest/mvc/controllers/areas.html" rel="noreferrer">https://docs.asp.net/en/latest/mvc/controllers/areas.html</a></p> <p>I can navigate to the admin pages by directly typing in the url, however I can't get links to generate</p> <p>I've tried placing the following on the Admin index.cshtml:</p> <pre><code>&lt;p&gt;&lt;a asp-action="Index"&gt;Admin Index&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a asp-controller="Home" asp-action="Index"&gt;Admin Index&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a asp-area="Admin" asp-controller="Home" asp-action="Index"&gt;Admin Index&lt;/a&gt;&lt;/p&gt; </code></pre> <p>Yet the all end up being non clickable anchors (no href)</p> <p>In fact, when I view source, I actually still see the "asp-action" etc tags</p> <pre><code>&lt;a asp-action="Index"&gt;Admin Index&lt;/a&gt; </code></pre> <p>MVC doesn't seem to be processing the link helper tags?</p> <p>Any idea what I've missed? Perhaps a configuration step somewhere?</p> <p>Thanks</p>
<asp.net-core><asp.net-core-mvc>
2016-09-17 23:54:17
HQ
39,553,079
Difference between lib and dist folders when packaging library using webpack?
<p>Ive just published my first package (a react component) to npm but im having some trouble understanding the difference between what the <code>lib</code> directory is compared to the <code>dist</code>.</p> <p>Currently I generate both <code>lib</code> and <code>dist</code> however my package "main" points to the <code>dist</code> unminified js file which has been built using webpack and output as UMD. The lib folder is built using <code>babel</code> taking the <code>src</code> and outputting to <code>lib</code>.</p> <p>The dist folder contains both [unminified/minified].js files as well as [unminified/minified].css files.</p> <p>My main confusion is with the lib folder since imports from there currently wouldn't work seeing as I just transform <code>src -&gt; lib</code> meaning the scss references are still there and the scss files aren't transformed either.</p> <p>I use CSS Modules (css-loader, styles-loader, postcss-loader etc) to generate my CSS files and this is where the confusion is since, wouldn't I also need to use webpack to generate my <code>lib</code> folder seeing as the <code>scss</code> files/import references need to be transformed to <code>css</code>?</p> <p><strong>Are you meant to have both lib and dist or is the UMD build in dist fulling the same purpose as that of having a lib folder?</strong></p> <p><strong>If you are supposed to have both how would I achieve this, since I couldnt find any info regarding generating the lib folder when using CSS modules within your js files and still maintaing the same folder structure of that of src (while still generating dist)?</strong></p>
<node.js><reactjs><npm><webpack>
2016-09-18 00:51:55
HQ
39,553,105
Drawing curved SVG arrow lines from div to div
<p>I want to draw two curved arrow lines using SVG to connect two elements to indicate they go back and forth, like this:</p> <p><a href="https://i.stack.imgur.com/sH53l.png" rel="noreferrer"><img src="https://i.stack.imgur.com/sH53l.png" alt="enter image description here"></a></p> <p>I've read a bit about SVG but I'm not totally sure how to create a line that's vertical. </p> <p>Second, if SVG takes coordinates, do I have to find the coordinate position of the elements before creating the SVG drawing? Does it have to be re-drawn if the window size is adjusted?</p>
<javascript><html><css><dom><svg>
2016-09-18 00:57:29
HQ
39,553,946
How to get user friend list from facebook using graph api
<p>Recently I have a requirement for getting all user's friend in facebook. I am successfully able to generate auth_code (with scope: <code>user_friends</code>) , access_token. </p> <p>Now When I am calling to <code>{user-id}/friends</code> <a href="https://developers.facebook.com/docs/graph-api/reference/v2.7/user/friends" rel="nofollow">end point</a> , It is not returning users all friends, It only returns on the friends who are authenticated with that app. Is there any way in the new graph api to get all the friends of a user.</p>
<ruby-on-rails><facebook><facebook-graph-api>
2016-09-18 03:58:58
LQ_CLOSE
39,554,285
Spring Test returning 401 for unsecured URLs
<p>I am using Spring for MVC tests</p> <p>Here is my test class</p> <pre><code>@RunWith(SpringRunner.class) @WebMvcTest public class ITIndexController { @Autowired WebApplicationContext context; MockMvc mockMvc; @MockBean UserRegistrationApplicationService userRegistrationApplicationService; @Before public void setUp() { this.mockMvc = MockMvcBuilders .webAppContextSetup(context) .apply(springSecurity()) .build(); } @Test public void should_render_index() throws Exception { mockMvc.perform(get("/")) .andExpect(status().isOk()) .andExpect(view().name("index")) .andExpect(content().string(containsString("Login"))); } } </code></pre> <p>Here is the MVC config</p> <pre><code>@Configuration @EnableWebMvc public class MvcConfig extends WebMvcConfigurerAdapter { @Override public void addViewControllers(ViewControllerRegistry registry) { registry.addViewController("/").setViewName("index"); registry.addViewController("/login/form").setViewName("login"); } } </code></pre> <p>Here is the security config</p> <pre><code>@Configuration @EnableWebSecurity public class SecurityConfig extends WebSecurityConfigurerAdapter { @Autowired @Qualifier("customUserDetailsService") UserDetailsService userDetailsService; @Override protected void configure(HttpSecurity http) throws Exception { http.authorizeRequests() .antMatchers("/resources/**", "/signup", "/signup/form", "/").permitAll() .anyRequest().authenticated() .and() .formLogin() .loginPage("/login/form").permitAll().loginProcessingUrl("/login").permitAll() .and() .logout().logoutSuccessUrl("/login/form?logout").permitAll() .and() .csrf().disable(); } @Autowired public void configureGlobalFromDatabase(AuthenticationManagerBuilder auth) throws Exception { auth.userDetailsService(userDetailsService); } } </code></pre> <p>When I run my test it fails with the message:</p> <pre><code>java.lang.AssertionError: Status expected:&lt;200&gt; but was:&lt;401&gt; at org.springframework.test.util.AssertionErrors.fail(AssertionErrors.java:54) at org.springframework.test.util.AssertionErrors.assertEquals(AssertionErrors.java:81) at org.springframework.test.web.servlet.result.StatusResultMatchers$10.match(StatusResultMatchers.java:664) at org.springframework.test.web.servlet.MockMvc$1.andExpect(MockMvc.java:171) at com.marco.nutri.integration.web.controller.ITIndexController.should_render_index(ITIndexController.java:46) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) </code></pre> <p>I understand that it fails due to the fact that the url is protected with spring security, but when I run my application I can access that url even without being authenticated.</p> <p>Am I doing something wrong?</p>
<java><spring><spring-mvc><spring-boot><spring-test>
2016-09-18 05:00:27
HQ
39,554,423
Bash script to return correct value on Updates statement
<p>I've written a small script to check for Updates. I'm looking for it to output 1 of 3 answers:</p> <ol> <li>If there are no updates, return "Your system is up to date"</li> <li>If there is only one update avaiable, return "There is 1 Update available"</li> <li>If there is more than one update, return "There are $NUMOFUPDATES Updates available"</li> </ol> <p>Here is what I have so far:</p> <pre><code>#!/bin/bash # Check for Updates # Variables NUMOFUPDATES=$(LANG=C apt-get upgrade -s |grep -P '^\d+ upgraded'|cut -d" " -f1) UPDATEY1="There is 1 Update available" UPDATEY2="There are $NUMOFUPDATES Updates available" UPDATEN="Your system is up to date" if [ $NUMOFUPDATES -gt 0 ]; then echo "\${color3}"$UPDATEY2 # Number of updates available elif [ $NUMOFUPDATES -eq 1 ]; then echo "\${color3}"$UPDATEY1 # Number of updates available else echo "\${color2}"$UPDATEN # System is up to date fi exit 0 </code></pre> <p>What it is not doing, is showing if there is only 1 update, it's not returning "There is 1 Update available" it's returning "There are $NUMOFUPDATES Updates available"</p> <p>I feel like I'm close to the solution. Can someone please help me find a solution to this?</p> <p>Thank you.</p>
<linux><bash><ubuntu><updates>
2016-09-18 05:27:59
LQ_CLOSE
39,554,583
How can I call a function in javascript that contains a period in it's name?
<p>If I have the following object:</p> <pre><code>var helloWorldFunctions = { 'hello.world': function () { return 'hello world'}, 'helloWorld' : function () { return 'hello world'} } </code></pre> <p>I can call the second 'helloWorld' function in the object by doing:</p> <pre><code>helloWorldFunctions.helloWorld() </code></pre> <p>How can I call the first 'hello.world' function? Naturally, doing the following gives me a type error:</p> <pre><code>helloWorldFunctions.hello.world() </code></pre>
<javascript>
2016-09-18 05:53:16
LQ_CLOSE
39,555,064
Extracts incomplete cases from a data set in r
<p>from this example: </p> <pre><code> ## x ## v1 v2 v3 ##1 90 55 NA ##2 NA 45 8 ##3 85 NA 5 ##4 NA 33 7 ##5 55 30 4 ##6 60 20 3 ##7 75 15 2 ##8 80 23 6 # ici is where Incomplete case indicator ici=(function (x) return(is.na(x))) ici(x) v1 v2 v3 ## [1,] FALSE FALSE TRUE ## [2,] TRUE FALSE FALSE ## [3,] FALSE TRUE FALSE ## [4,] TRUE FALSE FALSE ## [5,] FALSE FALSE FALSE ## [6,] FALSE FALSE FALSE ## [7,] FALSE FALSE FALSE ## [8,] FALSE FALSE FALSE # Extracts incomplete cases from a data set ic=(function (x, drop) return(x[ici(x)]))(x, drop) ic(x) ## Error: could not find function "ic" </code></pre> <p>from the last run ( Error: could not find function "ic") why it give me this and how I solve this broblem with function ic</p>
<r>
2016-09-18 07:09:54
LQ_CLOSE
39,556,443
Using Tesseract for handwriting recognition
<p>I was just wondering how accurate can tesseract be for handwriting recognition if used with capital letters all in their own little boxes in a form.</p> <p>I know you can train it to recognise your own handwriting somewhat but the problem in my case is I need to use it across multiple handwritings. Can anyone point me in the right direction? </p> <p>Thanks a lot. </p>
<android><ocr><tesseract><handwriting>
2016-09-18 10:05:42
HQ
39,557,488
python bot telegram-send a message to bot
I'm working on my first bot of telegram in Python. Currently I have done the send of a message and the send of an answer with bot.sendMessage(). Perfectly. But now I would like that after the send of a specific command the bot stays in listening to another message. I tell you an example :) I send "/add" and the bot says to me: ok, tell me your torrent link. At this point I send to bot another message with the link torrent and the bot saves it into a python variable and then I can use it to do the specific command. I hope that someone help me. Thanks.
<python><bots><python-telegram-bot>
2016-09-18 12:07:49
LQ_EDIT
39,557,772
Data type mismatch in criteria expression. i can find the solution
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim con As New OleDb.OleDbConnection Dim str As String = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=..\VisitorPass.accdb" Dim sql As String sql = "Update Visitor set [password]='" & txtPassword.Text & "',FirstName='" & txtFirstName.Text & "',LastName='" & txtLastName.Text & "',Gender='" & txtGender.Text & "',MobileNo='" & txtMobileNO.Text & "',DateOfBirth='" & txtDateOfBirth.Text & "',VisitorAddress='" & txtVisitorAddress.Text & "'where ID='" & lblID2.Text & "'" con = New OleDbConnection(str) Dim cmd As New OleDbCommand(sql, con) con.Open() cmd.ExecuteNonQuery() Dim obj1 As New VisitorProfile obj1.StringPass = txtName.Text MsgBox("profile is updated") obj1.Show() con.Close() Me.Close() End Sub
<sql><vb.net><ms-access>
2016-09-18 12:46:43
LQ_EDIT
39,558,117
Increment double pointer by 1
I'm learning c pointers. There i have incremented double pointer by 1. then i could get as follows current ptr_double =0x0128 then i incremented it by 1 so ptr_double plus 8 bytes , That is 0x0128+8 which gives `0x0130` , But i'm unable to understand how `0x0130` comes. Please be kind enough to explain me. I know its stupid question. But i couldn't understand so far.
<c><pointers><hex>
2016-09-18 13:24:14
LQ_EDIT
39,558,515
How to get the Gradient and Hessian | Sympy
<p>Here is the situation: I have a symbolic function <strong>lamb</strong> which is function of the elements of the variable z and the functions elements of the variable h. Here is an image of the lamb symbolic function</p> <p><a href="https://i.stack.imgur.com/ESNXb.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ESNXb.png" alt="enter image description here"></a>.</p> <p>Now I would like the compute the Gradient and Hessian of this function with respect to the variables eta and xi. Of course I googled for it but I could not find a straight way for doing this. What I found is <a href="http://docs.sympy.org/dev/modules/vector/fields.html" rel="noreferrer">here</a>, but as I said it does not seen to be the best approach for this situation. Any idea? Bellow, the source code. Thanks.</p> <pre><code>from sympy import Symbol, Matrix, Function, simplify eta = Symbol('eta') xi = Symbol('xi') x = Matrix([[xi],[eta]]) h = [Function('h_'+str(i+1))(x[0],x[1]) for i in range(3)] z = [Symbol('z_'+str(i+1)) for i in range(3)] lamb = 0 for i in range(3): lamb += 1/(2*sigma**2)*(z[i]-h[i])**2 simplify(lamb) </code></pre>
<python-3.x><sympy>
2016-09-18 14:09:02
HQ
39,558,549
Disable Firebase in development mode in Android
<p>I am using Firebase in my android project. Wanted to know how to disable it in development mode. All crashes and usage/events are being logged and messing up with actual analytics.</p> <p>Any better way to disable this in development mode?</p>
<android><firebase><firebase-analytics>
2016-09-18 14:12:38
HQ
39,558,642
Does Gensim library support GPU acceleration?
<p>Using Word2vec and Doc2vec methods provided by Gensim, they have a distributed version which uses BLAS, ATLAS, etc to speedup (details <a href="http://rare-technologies.com/word2vec-in-python-part-two-optimizing/" rel="noreferrer">here</a>). However, is it supporting GPU mode? Is it possible to get GPU working if using Gensim?</p>
<optimization><gpu><gensim><deeplearning4j>
2016-09-18 14:20:48
HQ
39,558,725
Scanning integers in C in xCode
so I am trying to scan some integers in C (so taking in the user's first and last name, departure and arrival locations) but I am getting this error that the type of declaration I've made is inconsistent. I'm a little new to C still so bear with me as this may be a trivial thing. Thanks in advance. Here's what I am trying to do: #include <stdio.h> int main (void) { char lastName, firstName, depart, arrive; printf("Please enter passenger's last name: "); scanf("%s", &lastName); printf("Please enter passenger's first name: "); scanf("%s", &firstName); printf("Which airport are you departing from? "); scanf("%s", &depart); printf("Which airport will you be heading to? "); scanf("%s", &arrive); printf("LAST NAME: %s FIRST NAME: %s FROM: %s TO: %s", lastName, firstName, depart, arrive); return 0; }
<c>
2016-09-18 14:28:44
LQ_EDIT
39,559,689
where do I find the project id for the gitlab api?
<p>I use gitlab on their servers. I would like to download my latest built artifacts (build via gitlab-ci) via the API like this </p> <p><code>curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.com/api/v3/projects/1/builds/8/artifacts"</code></p> <p>Where do I find this project id? Or is this way of using the API not intended for hosted gitlab projects?</p> <p>BW Hubert</p>
<api><gitlab><gitlab-ci>
2016-09-18 16:01:41
HQ
39,560,181
Extraction of ssn no.,date,email address from a file in Python
1.**My file contains below contents: rexp.txt** `adf fdsf hh h fg h 1995-11-23 dasvsbh 2000-04-12 gnym,mnbv 2001-02-17 dascvfbsn bjhmndgfh xgfdjnfhm244-44-2255 fgfdsg gfjhkh fsgfdh 455-44-6577 dkjgjfkld sgf dgfdhj sdg 192.6.8.02 fdhdlk dfnfghr fisdhfih dfhghihg 154.56.2.6 fdhusdgv aff fjhgdf fdfdnfjgkpg fdf hgj fdnbk gjdhgj dfdfg raeh95@gmail.com efhidhg fdfuga reg@gmail.com ergudfi rey@gmail.com iugftudfh dgufidjfdg teeeee@gmail.comugfuhlfhs fgufif p` 2.I want to extract ssn number,date,email line by line.I'm expeccting codings which loops throughout every line and returns expected string 3.***correct the coding in python*** `import re def cfor_date(str): t=re.search(r'(\d{4}-\d{2}-\d{2})',str) return t def cfor_ssn(str): f=re.search(r'(\d{3}-\d{2}-\d{4})',str) return f def cfor_gm(str): g=re.search(r'([\w\.-]+@gmail[\w{3}\.-]+)',str) return g f = open("rexp.txt","r").read() lines = f.splitlines() for line in iter(lines): x=line.split(" ") print x if (cfor_date(x)) != None: # i feel problem here r=cfor_ssn(x) print r`
<python><fileparsing>
2016-09-18 16:45:25
LQ_EDIT
39,560,277
Vector declaration "expected parameter declarator"
<p>I have a line of code inside a class's private member variables:</p> <pre><code>vector&lt;double&gt; dQdt(3) </code></pre> <p>When compiling in xcode, this gives an error "expected parameter declarator." I think I provided sufficient info. I don't see anything wrong with this declaration. </p>
<c++><vector>
2016-09-18 16:54:29
HQ
39,561,112
Getting Boolean from ResultSet
<p>ResultSet#getBoolean seems to return false when it's null.<br> Is there an easy way to get a <code>Boolean</code> (not <code>boolean</code>) from a <code>ResultSet</code>?</p>
<java><mysql><sql><resultset>
2016-09-18 18:22:00
HQ
39,561,125
BS4 web scraping is not returning anything.
My code: res=requests.get('https://www.flickr.com/photos/') res.raise_for_status() soup = bs4.BeautifulSoup(res.text, 'html.parser') linkItem = soup.select('div.photo-list-photo-interaction a[ref^=/photos]') print(linkItem) is not returning any values. After Inspecting element, the photos are inside a <div class "photo-list-photo-interaction">. So above soup.select should worked. But it doesn't. any ideas?. Thank you
<python>
2016-09-18 18:22:55
LQ_EDIT
39,561,181
Binding the value in a textarea
<p>I'm trying to do the simplest two way binding in Angular2. I would like to share a variable between my component and it's template.</p> <p>My template is:</p> <pre><code>&lt;textarea [(ngModel)]="currentQuery"&gt;&lt;/textarea&gt; </code></pre> <p>And my component is:</p> <pre><code>import { Component } from '@angular/core'; import { ViewChild } from '@angular/core'; import { OnInit } from '@angular/core'; @Component({ moduleId: module.id, selector: 'vs-home', templateUrl: 'home.component.html' }) export class HomeComponent { private currentQuery: string = ''; } </code></pre> <p>According to the docs this should work but I'm getting:</p> <pre><code>Error: Uncaught (in promise): Error: Template parse errors: Can't bind to 'ngModel' since it isn't a known property of 'textarea'. (" &lt;div class="query-bar-container"&gt; &lt;textarea [ERROR -&gt;][(ngModel)]="currentQuery"&gt;&lt;/textarea&gt; &lt;!-- &lt;button type="button" class="btn btn-default" (click"): HomeComponent@2:15 </code></pre>
<angular><typescript><angular2-ngmodel>
2016-09-18 18:27:23
HQ
39,561,197
How i load up css file from inside a method ..?
/* This is Controller.java Class .. i want load up another css file from inside a method. I tried blow codes but unluckly dont work.now i how to load up another css file ? [N.B: sorry,for my bad english] @FXML private Button mbut1; @FXML private void menubut1(ActionEvent event) { mbut1.getStylesheets().add(getClass().getResource("dinner.css" ).toExternalForm());
<css><javafx>
2016-09-18 18:29:43
LQ_EDIT
39,561,303
undefined reference to `WinMain'
<p>I am taking a course in c++ and I've copied the code and done exactly the same as the tutor in the course did in the lecture, however when I do so I get a long error "...undefined reference to `WinMain'" and I don't know what to do. </p> <p>I am using Eclipse Neon on Windows 10 (and Cygwin, I don't know if it's relevant) and this is my code:</p> <p>`</p> <pre><code>#include &lt;iostream&gt; #include &lt;SDL.h&gt; using namespace std; int main() { cout &lt;&lt; "!!!Hello World!!!" &lt;&lt; endl; // prints !!!Hello World!!! return 0; </code></pre> <p>} ` The code works and runs without the "#include ", but when I add this line of code the error pops up when I run it (so I guess that's where the problem is). When the tutor in the course run this code it works and prints out the text correctly. Can someone please tell me how I get rid of this error and get this simple program to run?</p>
<c++><eclipse><sdl><winmain>
2016-09-18 18:41:21
LQ_CLOSE
39,561,503
How to encrypt memory block in C?
I need a function which takes a start address as first parameter and a size as second and it should xor that range in memory at runtime. How can I accomplish that? My naive approach was this: void EncryptDecrypt(DWORD StartAddress, DWORD dwSize) { DWORD *Start = &StartAddress; DWORD size = StartAddress + dwSize; DWORD *End = &size; while(*Start < *End) { *Start++ ^= 0x83; } } But it fails when needs to decrypt. How to fix it?
<c><function><pointers><memory><xor>
2016-09-18 19:02:13
LQ_EDIT
39,561,541
Trouble with my troubleshooting guide(python)
Okay I'm having some issues with my code, after the point I tried to make my code a little bit more advanced after phone not turning on solution, it started to glitch out, need some help on this, got no idea how I can avoid this. print("Welcome to Bobby Dazler's trobleshooting for mobile phones. Please answer the questions concerning your issue with yes or no, unless specified to write something else. If your issue is none of these listed please enter other or don't know") solutions1="Place the phone into rice for 24 hours if this does not fix the issue please contact your manufacturer for a repair." solutions2="Check the battery is in correctly and attempt to charge the phone for atleast one hour, if this fails please contact your manufacturer." solutions3="Move to a different area, turn the phone on and off, if this fails please contact your service provider." solutions4="Turn the phone off silent mode, do this by either; manually going into the your phone's settings or use the buttons on the side of the phone to turn it off silent mode." solutions5="Use the buttons on the side of the phone to adjust the volume accordingly." solutions6="Contact your manufacturer to arrange a time to fix your cracked phone." solutions7="Delete some applications(apps) to make some more space for your phone." solutions8="Contact your manufacturer/insurance company to get your buttons replaced" solutions9="Charge your phone fully and hold down the button to attempt to turn it on, if this fails please contact your manufacturer to arrange for a repair." solutions10="Contact your manufacturer to fix your problem" solutions11="Reinsert the sim card and make sure the sim card is placed the right way upon entering the phone." print("cracked screen, phone not turning on, bad reception, phone doesn't ring, low volume, can't take photos or download applications, broken/missing buttons, sim card not working, water damage") questions = input("What problem are you having with your mobile phone? Please select one, please choose on the options and reply in a lower case") if questions== "cracked screen": print(solutions6) if questions=="low volume": print(solutions5) if questions=="phone not turning on": print(solutions2) questions = input("Did that fix your issue?") if questions=="no" or "No": print("Okay here's another solution") print(solutions9) questions=input("Did that fix your issue?") if questions=="no" or "No": print("Okay please try this") print(solutions10) if questions=="bad reception": print(solutions3) if questions=="phone doesn't ring": print(solutions4) if questions=="can't take photos or download applications": print(solutions7) if questions=="broken/missing buttons": print(solutions8) if questions=="sim card not working": print(solutions11) if questions=="water damage": print(solutions11) else: questions=input("Does the phone turn on?") if questions=="Yes" or "yes": print("Okay here is another question") if questions=="No" or "no": print(solutions10)
<python-3.x><if-statement>
2016-09-18 19:05:40
LQ_EDIT
39,561,643
Urgent Assignment assistance error message
So I'm working on an assignment, using codeblocks for c language. first year student, trying to solve an error message. user must choose between the following projectiles. each projectile has a blast radius and this is the code i have so far: userProjectileChoice = myProjectiles[3]; myProjectiles[0].projectileName = "cannonBall"; myProjectiles[0].blastRadius = 10; myProjectiles[1].projectileName = "highExplosiveShell"; myProjectiles[1].blastRadius = 1; myProjectiles[2].projectileName = "mortarBomb"; myProjectiles[2].blastRadius = 1000; i need to use the struct as it is required. error message: incompatible types when assigning to type 'int' from type 'struct' please help
<c>
2016-09-18 19:15:28
LQ_EDIT
39,561,650
Looping vector in C++ causes invalid iterations
<p>I have written a small program that takes inputs as string which is stored in a vector. </p> <p>Looping through the vector causes many empty strings being printed before actual output. I have copied the sample lines below.</p> <pre><code>int main(){ int totalStrings; string inputs; vector&lt;string&gt; testCases(totalStrings); cin&gt;&gt;totalStrings; while(cin&gt;&gt;inputs) testCases.push_back(inputs); for(vector&lt;string&gt;::iterator it=testCases.begin();it!=testCases.end();++it) printCustom(*it); return 0; } </code></pre> <p>I tried printing the size of the string in the printCustom function. I had hundreds of zero printed before the actual input </p>
<c++><vector>
2016-09-18 19:16:04
LQ_CLOSE
39,562,748
docker-compose start "ERROR: No containers to start"
<p>I am trying to use Docker Compose (with Docker Machine on Windows) to launch a group of Docker containers. </p> <p>My docker-compose.yml:</p> <pre><code>version: '2' services: postgres: build: ./postgres environment: - POSTGRES_PASSWORD=mysecretpassword frontend: build: ./frontend ports: - "4567:4567" depends_on: - postgres backend: build: ./backend ports: - "5000:5000" depends_on: - postgres </code></pre> <p><code>docker-compose build</code> runs successfully. When I run <code>docker-compose start</code> I get the following output:</p> <pre><code>Starting postgres ... done Starting frontend ... done Starting backend ... done ERROR: No containers to start </code></pre> <p>I did confirm that the docker containers are not running. How do I get my containers to start?</p>
<docker><docker-compose>
2016-09-18 21:15:09
HQ
39,562,887
How to implement method swizzling swift 3.0?
<p>How can I implement method swizzling in <strong>Swift 3.0</strong> ?</p> <p>I've read <a href="http://nshipster.com/swift-objc-runtime/" rel="noreferrer">nshipster article</a> about it, but in this code's chunk </p> <pre><code>struct Static { static var token: dispatch_once_t = 0 } </code></pre> <p>the compiler gives me an error</p> <blockquote> <p>dispatch_once_t is unavailable in Swift: Use lazily initialized globals instead</p> </blockquote>
<ios><swift><xcode><swift3><swizzling>
2016-09-18 21:32:00
HQ
39,563,155
How to add autofocus to AVCaptureSession? SWIFT
<p>I'm using AVFoundation to recognize text and perform OCR. How do I add autofocus? I don't want to have the yellow square thing when user taps the screen, I just want it to automatically focus on the object, a credit card for example.</p> <p>Here is my session code.</p> <pre><code>func setupSession() { session = AVCaptureSession() session.sessionPreset = AVCaptureSessionPresetHigh let camera = AVCaptureDevice .defaultDeviceWithMediaType(AVMediaTypeVideo) do { input = try AVCaptureDeviceInput(device: camera) } catch { return } output = AVCaptureStillImageOutput() output.outputSettings = [ AVVideoCodecKey: AVVideoCodecJPEG ] guard session.canAddInput(input) &amp;&amp; session.canAddOutput(output) else { return } session.addInput(input) session.addOutput(output) previewLayer = AVCaptureVideoPreviewLayer(session: session) previewLayer!.videoGravity = AVLayerVideoGravityResizeAspect previewLayer!.connection?.videoOrientation = .Portrait view.layer.addSublayer(previewLayer!) session.startRunning() } </code></pre>
<ios><swift><avfoundation><avcapturesession><autofocus>
2016-09-18 22:11:39
HQ
39,563,327
Vector with a variable range does not work
Here is my function: when I do this: `std::list<int> pigeonhole[100];` it works, but i need a variable here. when I put this, std::list<int> pigeonhole(range); the following part fails; it says no operator "[]" matches these operands : pigeonhole[arr[i]-min].push_back(arr[i]); same thing with this part: `pigeonhole[i]` void pigeonholeSort(int arr[], int n) { int min = arr[0], max = arr[0]; for (int i = 1; i < n; i++) { if (arr[i] < min) min = arr[i]; if (arr[i] > max) max = arr[i]; } int range = max - min +1; std::list<int> pigeonhole(range); for (int i = 0; i < n; i++) pigeonhole[arr[i]-min].push_back(arr[i]); int index = 0; for (int i = 0; i < max; i++) { list<int>::iterator it; for (it = pigeonhole[i].begin(); it != pigeonhole[i].end(); ++it) arr[index++] = *it; } }
<c++><list>
2016-09-18 22:43:26
LQ_EDIT
39,563,547
How to instantiate and apply directives programmatically?
<p>I know that in ng2 we have <code>ComponentFactoryResolver</code> that can resolve factories that we can apply to a <code>ViewContainerRef</code>.</p> <p>But, is there something similar for directives? a way to instantiate them and apply them to the projected content from a component?</p>
<angular><projection><angular-directive><angular2-template>
2016-09-18 23:21:05
HQ
39,563,843
How to extract the source code from a *.jar file on a Mac?
<p>I'm very confused. I downloaded a *.jar file as a bit of software. So, I would like to extract the source code to look at it</p> <p>I used the command <code>jar xf filename.jar</code></p> <p>which returned two more <code>*.jar</code> files and a <code>*.class</code> file. I still cannot open these in the terminal with standard text editors. </p> <p>Perhaps this is not open source software? Is there an alternative to see what has been done here?</p>
<java><jar><extraction>
2016-09-19 00:21:40
HQ
39,564,802
Why does Webpack's DefinePlugin require us to wrap everything in JSON.stringify?
<pre><code>new webpack.DefinePlugin({ PRODUCTION: JSON.stringify(true), VERSION: JSON.stringify("5fa3b9"), BROWSER_SUPPORTS_HTML5: true, TWO: "1+1", "typeof window": JSON.stringify("object") }) </code></pre> <p><a href="https://github.com/webpack/docs/wiki/list-of-plugins#defineplugin" rel="noreferrer">https://github.com/webpack/docs/wiki/list-of-plugins#defineplugin</a></p> <p>This seems very unusual, unnecessary and "dev-error-prone".</p> <p>Is it type-checking concerns?</p>
<javascript><webpack>
2016-09-19 03:09:42
HQ
39,564,928
How do i add features like upload, preview and download in android cloud app
currently i am working on a cloud app with aws and i have successfully configured sign in and sign up process all i want to know is how to cach that data from cloud and preview it without downloading. please add scripts for that. Thanks
<android><amazon-web-services><cloud>
2016-09-19 03:27:29
LQ_EDIT
39,564,936
What version of org.json is built into Android?
<p>I'm using an open source library that depends on <code>org.json:json:20090211</code>. Evidently there are some API differences between version <code>20090211</code> and whatever version is provided by Android. When I enable ProGuard minimization, I see this warning:</p> <blockquote> <p>Warning: com.esri.core.geometry.JSONObjectEnumerator: can't find referenced method 'java.lang.String[] getNames(org.json.JSONObject)' in library class org.json.JSONObject</p> </blockquote> <p>That method is present in the current reference implementation of <a href="https://github.com/stleary/JSON-java/blob/master/JSONObject.java" rel="noreferrer"><code>JSONObject</code></a>, so I assume it was added sometime before version <code>20090211</code>, as opposed to removed after it, which means the version included in Android is older. I'd like to diff that version against <code>20090211</code> and see what needs to be done to make the library that depends on <code>20090211</code> compatible with Android.</p> <p><strong>What version of org.json is included in Android?</strong></p> <p>(I know I could rename <code>org.json</code> and change the dependency to the renamed version, but I'd like to avoid that if possible. Such a change is unlikely to be accepted upstream.)</p>
<android><org.json>
2016-09-19 03:29:13
HQ
39,565,023
django QueryDict only returns the last value of a list
<p>Using django 1.8, I'm observing something strange. Here is my javascript:</p> <pre><code>function form_submit(){ var form = $('#form1_id'); request = $.post($(this).attr('action'), form.serialize(), function(response){ if(response.indexOf('Success') &gt;= 0){ alert(response); } },'text') .fail(function() { alert("Failed to save!"); }); return false; } </code></pre> <p>and here are the parameters displayed in views.py</p> <pre><code>print request.POST &lt;QueryDict: {u'form_4606-name': [u''], u'form_4606-parents': [u'4603', u'2231', u'2234']}&gt; </code></pre> <p>but I cannot extract the parents:</p> <pre><code>print request.POST['form_4606-parents'] 2234 </code></pre> <p>Why is it just giving me the last value? I think there is something wrong with the serialization, but I just cannot figure out how to resolve this.</p>
<django>
2016-09-19 03:42:38
HQ
39,565,230
Google Chrome clears CSS styles for current page when opening link in new tab or opening a new window
<p>This is odd one, I was troubleshooting for 3 days.</p> <p>Only happening in <code>Chrome Version 53.0.2785.116 m (64-bit)</code> on Windows.</p> <p>Web server must have header set (meta tag doesn't work in this case):</p> <p>Apache's .htaccess: <code>Header set Cache-Control "no-cache"</code> or nginx: <code>add_header Cache-Control no-cache;</code> </p> <p>You can't recreate it using jsfiddle or built-in code snippet, because css file must be loaded separately using <code>&lt;link href='style.css' rel='stylesheet' type='text/css'&gt;</code>. (but I will include code in snippet anyways).</p> <p>Steps to recreate:</p> <ol> <li>Visit: <a href="http://test.xmpsoft.net/">http://test.xmpsoft.net/</a></li> <li>Click on link 1 (should reload the page);</li> <li>Click on link 2 (should bring up new tab with the same page);</li> <li>Switch to the original tab and repeat same steps;</li> <li>All CSS styles are gone from the original tab.</li> <li>If not, repeat same steps again.</li> </ol> <p>Please assist to make sure where is nothing wrong with the code before I submit it to Google.</p> <p>Thanks.</p> <p>P.S. There is another way or recreating it (that's why I mentioned 'new window' in my Title: Visit same page, reload it, right click -> Inspect (new Development Tools window opens), switch back to the page (repeat if not able to recreate).</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-css lang-css prettyprint-override"><code>.menu div { display: inline-block; width: 15em; height: 15em; } .red { background-color: red; } .yellow { background-color: yellow; } .green { background-color: green; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta http-equiv='Content-Type' content='text/html; charset=utf-8'&gt; &lt;title&gt;Chrome bug&lt;/title&gt; &lt;link href='style.css' rel='stylesheet' type='text/css'&gt; &lt;/head&gt; &lt;body&gt; &lt;div class='menu'&gt; &lt;div class='red'&gt;Red&lt;/div&gt; &lt;div class='yellow'&gt;Yellow&lt;/div&gt; &lt;div class='green'&gt;Green&lt;/div&gt; &lt;/div&gt; &lt;a href='/'&gt;1. Reload this page&lt;/a&gt;&lt;br&gt; &lt;a href='/' target='_blank'&gt;2. Open same page in new tab&lt;/a&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> </div> </div> </p>
<html><css><google-chrome>
2016-09-19 04:09:24
HQ
39,565,285
why my android name has a erro in manifest layout?
<activity android:name=".MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".ContentView" android:label="@string/title_activity_content_view" > </activity> </application> </manifest> i have problem and RED error in android name (.ContenView & MainActivity) how can i fix it? i have Unfortunately when run program
<android><android-manifest>
2016-09-19 04:16:51
LQ_EDIT
39,565,353
"Safari cannot open the page because the address is invalid" message appears when I try to launch my app from a website
<p><strong>Device : iPhone 5 / iOS 9.3</strong> </p> <p>I have an <strong>iOS app</strong> which I need to launch from a <strong>website</strong>. I was able to do it via custom URL scheme.</p> <p>When I click the "<strong>Open App</strong>" button in the website, an alert dialog appears that says "<strong>Safari wants to open MyApp</strong>" with OK &amp; Cancel buttons.</p> <p>Clicking <strong>OK</strong> : everything is just fine. The app gets launched from the website perfectly.</p> <p>Clicking <strong>Cancel</strong> : First time, it just dismisses preventing the app being launched, which is correct.</p> <p>When I click on the "<strong>Open App</strong>" button once again from the website, I expect the same "Safari wants to launch MyApp" alert dialog to appear <strong>once again</strong>, <strong>which is not happening.</strong> </p> <p><strong>Instead</strong>, it shows a dialog that says "<strong>Cannot Open Page - Safari cannot open the page because the address is invalid</strong>" with an OK button.</p> <p>My assumption was, every time when you click on that link in the website (that can launch the app via custom url scheme), I should be prompted with "safari wants to open MyApp" alert dialog all the time. </p> <p>What am I missing here ? Appreciate your help in advance.</p>
<ios><safari><iphone-5><ios9.3>
2016-09-19 04:26:24
HQ
39,565,424
Swift UIViewReportBrokenSuperviewChain cause by Layer manipulation
<p>I run into a problem after migrating my code to Swift 3. I guess iOS10 raises new issues now and it's actually not related to Swift itself.</p> <p>The error:</p> <pre><code>*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'View has lost track of its superview, most likely through unsupported use of CALayer API on the view's layer. If this isn't a crash yet, it will be in the near future. Problem view: &lt;UIToolbar: 0x102552d80; frame = (0 0; 375 683); alpha = 0.97; opaque = NO; layer = &lt;CALayer: 0x1700383e0&gt;&gt; Expected parent: &lt;MyModelView: 0x10250ecd0; frame = (0 -16; 375 683); hidden = YES; layer = &lt;CALayer: 0x17003d4a0&gt;&gt; Break on UIViewReportBrokenSuperviewChain to debug.' </code></pre> <p>The code triggering the issue is :</p> <pre><code>[c presentViewController:tabBarViewController animated:NO completion:^{ </code></pre> <p>The sub code responsible for the problem seems to be:</p> <pre><code>- (void)addBlurView { CGRect viewBounds = [[UIScreen mainScreen]applicationFrame]; self.myModelView = [[MyModalView alloc] initWithFrame:CGRectMake(viewBounds.origin.x, -16, viewBounds.size.width, viewBounds.size.height+36)]; if(![self toolbar]) { _toolbar = [[UIToolbar alloc] initWithFrame:[self.myModelView bounds]]; [_toolbar setBarStyle:UIBarStyleBlack]; _toolbar.alpha = 0.97; [self.myModelView.layer insertSublayer:_toolbar.layer atIndex:0]; } [self.view addSubview:self.myModelView]; } </code></pre>
<ios><xcode><ios10>
2016-09-19 04:34:11
HQ
39,565,786
pass javascript variable value to c++ vatiable
I'm using g++ to edit a html webpage, so How do I pass a Javascript variable value to C++ variable by using a Javascript function? e.x. function convert(val){//conversion}
<javascript><html><c++><g++>
2016-09-19 05:12:41
LQ_EDIT
39,566,042
Measurable indicator for usability
<p>I am starting a new project and I have the problem with the measurability of the requirement usability.</p> <p>With is an good atomic measurable indicator for usability?</p>
<requirements-management>
2016-09-19 05:39:21
LQ_CLOSE
39,566,361
UISwitch setOn(:, animated:) does not work as document
<p>As Apple's document write, <code>UISwitch</code>'s function <code>setOn(on: Bool, animated: Bool)</code> does not send action. It works fine before iOS 10, but it will send action after I call it in iOS 10. I call it in "ValueChanged" event to force switch back, so I got this event action twice. is it a bug in iOS 10?</p>
<ios10><uiswitch>
2016-09-19 06:07:40
HQ
39,566,767
i am using 'com.android.support:appcompat-v7:22.0.1' android studio
protected void setupView(){ // TourGuide can only be setup after all the views is ready and obtain it's position/measurement // so when this is the 1st time TourGuide is being added, // else block will be executed, and ViewTreeObserver will make TourGuide setup process to be delayed until everything is ready // when this is run the 2nd or more times, if block will be executed if (ViewCompat.isAttachedToWindow(mHighlightedView)){ startView(); } else { final ViewTreeObserver viewTreeObserver = mHighlightedView.getViewTreeObserver(); viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { //noinspection deprecation mHighlightedView.getViewTreeObserver().removeGlobalOnLayoutListener(this); } else { mHighlightedView.getViewTreeObserver().removeOnGlobalLayoutListener(this); } startView(); } }); } } getting error Error:(198, 23) error: cannot find symbol method isAttachedToWindow(View)
<android>
2016-09-19 06:36:49
LQ_EDIT
39,566,769
Install npm packages in Python virtualenv
<p>There are some npm packages which I would like to install in a Python virtualenv. For example: </p> <ul> <li><a href="https://www.npmjs.com/package/pdfjs-dist" rel="noreferrer">https://www.npmjs.com/package/pdfjs-dist</a></li> <li><a href="https://www.npmjs.com/package/jquery-ui" rel="noreferrer">https://www.npmjs.com/package/jquery-ui</a></li> </ul> <p>Up to now I only found the complicated way to get these installable in a virtualenv: Create a python package for them.</p> <p>Is there no simpler way to get npm packages installed in a Python virtualenv?</p>
<python><npm><installation><pip>
2016-09-19 06:36:59
HQ
39,567,279
How to get name of color from hexa code in java?
I use openCV for color identification and I get color in hexa form like #FF0000 Nnow I want to convert it in string. I have search alot but I didnt find any useful code please help and tell me if anyone knows the answer.
<java><android><android-studio>
2016-09-19 07:09:46
LQ_EDIT
39,567,387
Lists turn immidiatly to "global" - python
<p>The title is not the issue. this issue i already solved by understanding the "immutable and mutable" -thing. But, I wanted to know a bit better about it. What are exactly allow the object to be acceced by another function if i dont tuch him and make shadow of the first one created. I show you with code:</p> <pre><code>def text(): print x x = 6 text() </code></pre> <p>This example whill work well, because i didnt created a new object of immutable. but this:</p> <pre><code>def text(): print x text() x = 6 </code></pre> <p>This will not work because the integer is not a global variable.</p> <p>What is exactly happend when i created a new object without globaled it? to where in the memory this objects goes that allowed me to approach to it by another scope. why its so different then just a global?</p>
<python>
2016-09-19 07:16:18
LQ_CLOSE
39,567,434
Spring Boot application gives 404 when deployed to Tomcat but works with embedded server
<p>Guided by <a href="https://spring.io/guides/gs/serving-web-content/" rel="noreferrer">Serving Web Content with Spring MVC</a>, I'm creating a Spring Boot web application that I can run using both the embedded Tomcat instance as well as on a standalone Tomcat 8 server.</p> <p>The application works as expected when executed as <code>java -jar adminpage.war</code> and I see the expected outcome when I visit <code>http://localhost:8080/table</code>. However, when I deploy to a Tomcat 8 server (by dropping <code>adminpage.war</code> into the <code>webapps</code> directory), I get a 404 error when I visit <code>https://myserver/adminpage/table</code>.</p> <p>The <code>catelina.log</code> and <code>localhost.log</code> files contain nothing helpful on the Tomcat server.</p> <p>Can anyone suggest where I've made a misconfiguration? I've not had the same problems in the past when deploying RESTful services with Spring Boot, but this is my first foray into a web application.</p> <p>My application files:</p> <p><code>src/main/java/com/.../Application.java</code></p> <pre><code>@SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } } </code></pre> <p><code>src/main/java/com/.../MainController.java</code></p> <pre><code>@Controller public class MainController { @RequestMapping("/table") public String greeting(Model model) { model.addAttribute("name", "Fooballs"); return "table"; } } </code></pre> <p><code>src/main/resources/templates/table.html</code></p> <pre class="lang-html prettyprint-override"><code>&lt;!DOCTYPE HTML&gt; &lt;html xmlns:th="http://www.thymeleaf.org"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt; &lt;/head&gt; &lt;body&gt; &lt;p th:text="'Hello, ' + ${name} + '!'" /&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p><code>pom.xml</code></p> <pre class="lang-xml prettyprint-override"><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt; &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt; &lt;groupId&gt;com.foo&lt;/groupId&gt; &lt;artifactId&gt;adminpage&lt;/artifactId&gt; &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt; &lt;packaging&gt;war&lt;/packaging&gt; &lt;parent&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt; &lt;version&gt;1.4.0.RELEASE&lt;/version&gt; &lt;/parent&gt; &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-tomcat&lt;/artifactId&gt; &lt;scope&gt;provided&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-thymeleaf&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-devtools&lt;/artifactId&gt; &lt;optional&gt;true&lt;/optional&gt; &lt;/dependency&gt; &lt;/dependencies&gt; &lt;properties&gt; &lt;java.version&gt;1.8&lt;/java.version&gt; &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt; &lt;/properties&gt; &lt;build&gt; &lt;finalName&gt;adminpage&lt;/finalName&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt; &lt;/plugin&gt; &lt;/plugins&gt; &lt;/build&gt; &lt;/project&gt; </code></pre>
<java><maven><spring-mvc><tomcat><spring-boot>
2016-09-19 07:19:22
HQ
39,567,446
How to call local .dll files in Electron App
<p>i have an issue how to call sample .dll files into my Electron App. I have sample .dll files in my folder, the thing is how to access my sample.dll file and how to call my sample.dll function and gets results. Any tutorials or steps to follow please sample code to start </p>
<javascript><node.js><electron>
2016-09-19 07:20:05
HQ
39,567,555
New build disappears after uploading it to iTunes Connect
<p>I'm trying to upload a build to iTunesConnect with Xcode 8. Xcode shows me that the uploading is successful. In Activity tab of iTunesConnect I see that my build is appears and it's marked as "processing...". But after a few minutes this build disappears and I cannot find it anywhere. I tried to upload it again by Xcode 8, but it says the build is already uploaded to iTunesConnect. So when I tried to upload build with increased version it says OK, but I still cannot see the build in iTunesConnect. I tried to upload with Application Loader, but there is the same issue.</p>
<ios><app-store-connect><xcode8>
2016-09-19 07:27:15
HQ
39,567,760
Can not run the java file sample in android studio, any one can help me? thx
I just download the sample file in android developers site(https://developer.android.com/training/multiscreen/index.html), then open this using android studio. But I found the run button is disable and I can't find any way to execute this.(just like this http://chuantu.biz/t5/34/1474269694x3394677986.jpg) Any one can tall me how to run this file in android developers?Thank so much
<java><android><android-studio>
2016-09-19 07:39:10
LQ_EDIT
39,568,096
JavaScript RegExp in replace() not working
<p>I have this code</p> <pre><code>var str = "Some text :$0"; var i = 0; alert(str.replace(new RegExp("\:\$" + i, "g"), 'here')); </code></pre> <p>see <a href="https://jsfiddle.net/3zyr03h0/" rel="nofollow">here</a>.</p> <p>Why is it not working? If I do it like this <code>/\:\$:0/g</code> instead of using the <code>RegExp</code> object then it works but I can't use a variable in the pattern that way. Whats wrong?</p>
<javascript><regex>
2016-09-19 07:59:15
LQ_CLOSE
39,568,174
Cant access value returned from PHP script
My PHP script returns response like {"message":"","response":{"key1":"value1","key2":"value2"}} How can I access/print the value of key1/key2 in Swift 2.2?
<ios><json><swift>
2016-09-19 08:04:19
LQ_EDIT
39,568,301
How can I find all public comments for a Github user?
<p>Until recently I was able to find all my public comments using a link on my profile page. I was using this functionality to keep track of all issues where I have commented, but not contributed anything. It was under a section called "Public Activity".</p> <p>This function seems to have been removed. I can not find anything about it on the <a href="https://help.github.com/categories/setting-up-and-managing-your-github-profile/" rel="noreferrer">help page about profiles</a>.</p> <p>Does anybody have any information on when and why this was removed?</p>
<github><user-profile>
2016-09-19 08:12:30
HQ
39,568,719
REST API GET with sensitive data
<p>I'm designing api with method that should be an <strong>idempotent</strong>, and should not modify any data on the server. It should be method that process request and return response for given parameters. </p> <p>One of the parameters is sensitive data. It's not an option to use additional encryption. Data is already encrypted, but security requirements are very demanding and even encrypted data should be treated very carefully.</p> <p>According to REST spec, idempotent query method should be implemented as a GET HTTP method. Problem in this case is sensitive data that shouldn't be pass as a GET parameter in URL. Only option in HTTP standard is to pass sensitive data in a body part of HTTP request.</p> <p>My question is what is better? Broke rest api design, and send query request as a POST, or pass encrypted data in URL? Maybe is there better solution I don't see?</p>
<rest><http><encryption><get><idempotent>
2016-09-19 08:35:48
HQ
39,569,982
Why does the std::copy_if signature not constrain the predicate type
<p>Imagine we have the following situation: </p> <pre><code>struct A { int i; }; struct B { A a; int other_things; }; bool predicate( const A&amp; a) { return a.i &gt; 123; } bool predicate( const B&amp; b) { return predicate(b.a); } int main() { std::vector&lt; A &gt; a_source; std::vector&lt; B &gt; b_source; std::vector&lt; A &gt; a_target; std::vector&lt; B &gt; b_target; std::copy_if(a_source.begin(), a_source.end(), std::back_inserter( a_target ), predicate); std::copy_if(b_source.begin(), b_source.end(), std::back_inserter( b_target ), predicate); return 0; } </code></pre> <p>Both the call to <code>std::copy_if</code> generate a compile error, because the correct overload of <code>predicate()</code> function cannot be infered by the compiler since the <code>std::copy_if</code> template signature accepts any type of predicate:</p> <pre><code>template&lt;typename _IIter, typename _OIter, typename _Predicate&gt; _OIter copy_if( // etc... </code></pre> <p>I found the overload resolution working if I wrap the <code>std::copy_if</code> call into a more constrained template function:</p> <pre><code>template&lt;typename _IIter, typename _OIter, typename _Predicate = bool( const typename std::iterator_traits&lt;_IIter&gt;::value_type&amp; ) &gt; void copy_if( _IIter source_begin, _IIter source_end, _OIter target, _Predicate pred) { std::copy_if( source_begin, source_end, target, pred ); } </code></pre> <p>My question is: why in the STL is it not already constrained like this? From what I've seen, if the <code>_Predicate</code> type is not a function that returns <code>bool</code> and accepts the iterated input type, it is going to generate a compiler error anyway. So why not putting this constrain already in the signature, so that overload resolution can work?</p>
<c++><c++11><stl><stl-algorithm>
2016-09-19 09:42:27
HQ
39,570,099
Group Numbers based on Level in sql server database
Hi I have requirement in sql server database where i have to group the data as mentioned below. If the Level is more than 2 then it has to be grouped under level 2 (ex: 1.1.1,1.1.2 are rolled up under 1.1.) and if there isn't any level 2 available then have to create a second level based on the level 3 Numbers (ex: 1.2.1) Source Required Column Col1 Col 2 1 1 1.1. 1.1. 1.1.1. 1.1. 1.1.1. 1.1.2. 1.1. 1.1.2. 1.2.1 1.2. 1.2.1 1.3. 1.3. 1.3.1. 1.3. 1.3.1. 1.3.2. 1.3. 1.3.2. 1.4.1. 1.4. 1.4.1.. Thanks
<sql><sql-server><tsql>
2016-09-19 09:47:57
LQ_EDIT
39,570,217
How can handle principal/mirror status in for-each and switch condition in powershell
i am new in powershell i have one query # Load SMO extension [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") | Out-Null; # Servers to check #$sqlservers = @("$svr","$svr\$inst"); $sqlservers = get-content 'servers.txt' foreach($server in $sqlservers) { $srv = New-Object "Microsoft.SqlServer.Management.Smo.Server" $server; # Get mirrored databases $databases = $srv.Databases | Where-Object {$_.IsMirroringEnabled -eq $true}; #Write-Host $databases; Write-Host "=================================="; # $test= $databases | Select-Object -Property Name, MirroringStatus| Format-Table -AutoSize; $databases | Select-Object -Property MirroringStatus | Format-Table -AutoSize ; Foreach ($status in $databases) {Switch ($databases.MirroringPartnerInstance) { 1{ $status. + "Disconnected" } 2{ $status. + "Suspended" } 2{ $status. + "Synchronizing" } 3{ $status. + "Not Synchronized" } } } i want code like this is some one know pls help me it is an urgent
<sql-server><sql-server-2008><powershell>
2016-09-19 09:53:53
LQ_EDIT
39,570,860
Questions in using eclipse
when I use eclipse if neon to type javascript file ,I often come to white color which covers the words I typing as this pictures[enter image description here][1] I have to close this file and open again ,It will be disappear,but it will appear soon. how should I solve this question? [1]: http://i.stack.imgur.com/7zn6l.png
<javascript><java><eclipse>
2016-09-19 10:24:44
LQ_EDIT
39,572,106
Finding repeated lines in Python
<p>I've got a txt file which has some lines, I want to find out: <br>Does this file have the same lines?</p> <p>For example, These are my lines:</p> <pre> 7924265e2024daa24f801290d070a519 f1cbfec6b396152da87e6a4279a4ad81 8d1a705ed05f734a03e890db5467ea0a 021128daa2fb3dc8b7c5af9e49e24439 e2ec22e390c5910eb4e952208bb1c47d 8d1a705ed05f734a03e890db5467ea0a 7f65a7f8a160431cc8f69cd1f04b0aba d8e5f74f296cd47a30915bbbd2418d66 005f8b973ebe30fd19b1bf802ffb6b32 </pre>
<python><file>
2016-09-19 11:29:22
LQ_CLOSE
39,573,571
.NET Core console application, how to configure appSettings per environment?
<p>I have a .NET Core 1.0.0 console application and two environments. I need to be able to use <code>appSettings.dev.json</code> and <code>appSettings.test.json</code> based on environment variables I set at run time. This seems to be quite straight forward for ASP.NET Core web applications, via dependency injection and IHostingEnvironment and the EnvironmentName env. variable, however how should I wire things up for the console application (besides writing my own custom code that uses <code>Microsoft.Framework.Configuration.EnvironmentVariables</code>)? </p> <p>Thank you. </p>
<c#><console-application><.net-core>
2016-09-19 12:46:43
HQ
39,573,575
Want to compare two csv files in java and want to have the complete details removed of one csv file from the other by comparing the 1st column
public class CompareCSV { public static void main(String args[]) throws FileNotFoundException, IOException { String path="C:\\csv\\"; String file1="file1.csv"; String file2="file2.csv"; String file3="file3.csv"; ArrayList<String> al1=new ArrayList<String>(); ArrayList<String> al2=new ArrayList<String>(); BufferedReader CSVFile1 = new BufferedReader(new FileReader("/C:/Users/bida0916/Desktop/macro.csv")); String dataRow1 = CSVFile1.readLine(); while (dataRow1 != null) { String[] dataArray1 = dataRow1.split(","); for (String item1:dataArray1) { al1.add(item1); } dataRow1 = CSVFile1.readLine(); } CSVFile1.close(); BufferedReader CSVFile2 = new BufferedReader(new FileReader("C:/Users/bida0916/Desktop/Deprecated.csv")); String dataRow2 = CSVFile2.readLine(); while (dataRow2 != null) { String[] dataArray2 = dataRow2.split(","); for (String item2:dataArray2) { al2.add(item2); } dataRow2 = CSVFile2.readLine(); } CSVFile2.close(); for(String bs:al2) { al1.remove(bs); } int size=al1.size(); System.out.println(size); try { FileWriter writer=new FileWriter("C:/Users/bida0916/Desktop/NewMacro.csv"); while(size!=0) { size--; writer.append(""+al1.get(size)); writer.append('\n'); } writer.flush(); writer.close(); } catch(IOException e) { e.printStackTrace(); } } } I want to compare two csv files in java and want to have the complete details removed of one csv file from the other by comparing the first column of both the files. Currently I am getting a csv file with one column only having all details jumbled up.
<java>
2016-09-19 12:46:49
LQ_EDIT
39,574,991
How to detect merged cells in excel with openpyxl
<p>I'm trying to read data from excel sheet that contains merged cells. When reading merged cells with openpyxl the first merged cell contain the value and the rest of the cells are empty.</p> <p>I would like to know about each cell if it merge and how many cells are merged but I couldn't find any function that do so. The sheet have empty others cells, so I can't use that.</p> <p>Will appreciate any help, I prefer openpyxl module but other modules can work,too.</p> <p>Thank you all! </p>
<python><excel><merge>
2016-09-19 13:55:54
HQ
39,575,037
Zoom to specified markers react-native-maps
<p>There is a section in the <a href="https://github.com/airbnb/react-native-maps#zoom-to-specified-markers" rel="noreferrer">react-native-maps</a> docs for zooming to an array of markers, however there are no code examples on how to do this either in the docs or in the examples folder (from what I can find)</p> <p>Can anyone provide an example of how to do this?</p>
<google-maps><reactjs><react-native><maps><apple-maps>
2016-09-19 13:58:28
HQ
39,575,200
How to unit test this Redux thunk?
<p>So I have this Redux action creator that is using <code>redux thunk</code> middleware:</p> <p><strong>accountDetailsActions.js:</strong></p> <pre><code>export function updateProduct(product) { return (dispatch, getState) =&gt; { const { accountDetails } = getState(); dispatch({ type: types.UPDATE_PRODUCT, stateOfResidence: accountDetails.stateOfResidence, product, }); }; } </code></pre> <p>How do I test it? I'm using the <code>chai</code> package for testing. I have found some resources online, but am unsure of how to proceed. Here is my test so far:</p> <p><strong>accountDetailsReducer.test.js:</strong></p> <pre><code>describe('types.UPDATE_PRODUCT', () =&gt; { it('should update product when passed a product object', () =&gt; { //arrange const initialState = { product: {} }; const product = { id: 1, accountTypeId: 1, officeRangeId: 1, additionalInfo: "", enabled: true }; const action = actions.updateProduct(product); const store = mockStore({courses: []}, action); store.dispatch(action); //this is as far as I've gotten - how can I populate my newState variable in order to test the `product` field after running the thunk? //act const newState = accountDetailsReducer(initialState, action); //assert expect(newState.product).to.be.an('object'); expect(newState.product).to.equal(product); }); }); </code></pre> <p>My thunk doesn't do any asynchronous actions. Any advice?</p>
<javascript><redux><chai>
2016-09-19 14:06:28
HQ
39,575,398
Rails: uniq vs. distinct
<p>Can someone briefly explain to me the difference in use between the methods <code>uniq</code> and <code>distinct</code>?</p> <p>I've seen both used in similar context, but the difference isnt quite clear to me.</p>
<ruby-on-rails><activerecord>
2016-09-19 14:16:31
HQ
39,575,943
Coding a Javascript hidden message
I've been asked by a web company to give them around 30 lines of HTML/javascript code to be used for a wall display. The code would need to be a real piece of valid code that would execute in a modern browser and display a message of around 30 words or less (e.g. a clever/cheeky brand message for the company). One big `document.write()` statement would do this, but they are looking for something that would conceal the message more. Essentially they are looking to make a visual puzzle that conceals their message from anyone without an intermediate understanding of JS. To a layperson it should just look like random code. I'm looking for ideas/suggestions on how to do this. I've tried using automatic javascript minifiers or obfuscators online but these generally output code that is completely unreadable to a human, what I want is for it to be difficult for a human/coder to read but not impossible. Supposing the message to be hidden was: > "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent > quis ipsum ipsum. Donec quis lectus et ante gravida ultricies at." What might be a good/interesting way to do this? HTML/CSS, JS & JQuery are all allowed. (Moderators, please move this question to somewhere more appropriate if it's not right for stack overflow)
<javascript><jquery><html><css>
2016-09-19 14:42:58
LQ_EDIT