pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
5,853,762
0
<p>You could do something like this. You can find more help in the CI docs</p> <pre><code>$this-&gt;db-&gt;select('M.*, p.name as page_name', FALSE); $this-&gt;db-&gt;from('omc_menu as M'); $this-&gt;db-&gt;join('omc_page as P', 'M.page_id = P.id', 'left'); $this-&gt;db-&gt;where('M.parentid', '0', FALSE); $this-&gt;db-&gt;order_by('M.parentid,M.order','ASC'); </code></pre>
11,737,817
1
What is the simplest language which support template&context mechanism? <p>I need to find the easiest way to automatically build ebooks from downloaded articles.</p> <p>I want to automatically generate TOC, which will be based on HTML template.</p> <p>I know that python django has template &amp; context mechanism, however django is a little to complicated for people to which I am preparing this whole mechanism. I don't need all web-related features.</p>
29,890,438
0
bootstrap CSS @media not working in laravel <p>I am a newbie in Laravel. In my project, I try to load <code>bootstrap</code> correctly to blade template. Everythings is fine except CSS @media, view is only rendered with normal CSS class in bootstrap but not CSS class in media. This is my code: This is <code>index.blade.php</code> view: </p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="utf-8" /&gt; &lt;title&gt; Laravel Sample Site &lt;/title&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt; &lt;link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.css"&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="row"&gt; &lt;div class="col-md-6" style="background-color:yellow;height:100px;"&gt;&lt;/div&gt; &lt;div class="col-md-6" style="background-color:red;height:100px;"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p><code>media-queries</code> are included in bootstrap css.</p> <p>And this is my public structure:</p> <pre><code>public/ /bootstrap/ /css /js /font /assets /css /js /font /images </code></pre> <p>As expect, View must contain 2 column with same width but when I run View only contain 2 row (exactly means bootstrap css layout not work)</p>
4,879,275
0
<p>Always make sure you've loaded the html first before actually calling the selectable function.</p> <pre><code>$(function() { var html = ''; html += '&lt;ul id="selectable"&gt;'; html += '&lt;li&gt;1&lt;/li&gt;'; html += '&lt;li&gt;2&lt;/li&gt;'; html += '&lt;li&gt;3&lt;/li&gt;'; html += '&lt;/ul&gt;'; $('#dialog').html(html).dialog(); $('#selectable').selectable(); }); </code></pre> <p>here's a <a href="http://jsfiddle.net/N4spA/" rel="nofollow">jsfiddle example</a></p>
3,872,183
0
<p>Sure. Just try it out:</p> <pre><code>$strTitle = Parser::GetFirstItem()-&gt;Title; </code></pre> <p>Not entirely sure when this was introduced. 5? 5.1? 5.2? Will have to check.</p> <p><strong>Update:</strong> Seems to have been a PHP 5 feature from the start.</p>
28,707,280
0
<p>You can use css3 transition and keyframes on adding class with js and then remove class after animation done (removeclass with setTimeout on same duration with css transition).</p>
8,523,438
0
<p>It does create a zombie instance.</p> <p>You need to unbind your first instance.</p> <p>Check this post out for more details. <a href="http://lostechies.com/derickbailey/2011/09/15/zombies-run-managing-page-transitions-in-backbone-apps/" rel="nofollow">http://lostechies.com/derickbailey/2011/09/15/zombies-run-managing-page-transitions-in-backbone-apps/</a></p>
7,643,089
0
<p>I couldn't get anything to pass all my tests for CSV Parsing, so I ended up writing something simple to do it. <a href="https://gist.github.com/1258207" rel="nofollow">AnotherCsvParser</a></p> <p>It does everything I need... but should be easy to fork and extend to your needs too.</p> <p>Given:</p> <pre><code> public class ABCD { public string A; public string B; public string C; public string D; } </code></pre> <p>It assumes the columns are in the order the fields are defined..(but would be easy to extend to read an attribute or something)</p> <p>This works:</p> <pre><code> var output = NigelThorne.CSVParser.ReadCSVAs&lt;ABCD&gt;( "a,\"b\",c,d\n1,2,3,4\n\"something, with a comma\",\"something \\\"in\\\" quotes\",\" a \\\\ slash \",\n,,\"\n\","); </code></pre> <p>Such that: </p> <pre><code> Assert.AreEqual(4, output.ToArray().Length); var row1 = output.ToArray()[0]; Assert.AreEqual("a", row1.A); Assert.AreEqual("b", row1.B); Assert.AreEqual("c", row1.C); Assert.AreEqual("d", row1.D); </code></pre> <p>Note: It's probably not very fast with lots of data either.. again not a problem for me. </p>
5,151,363
0
creating multiple users for a c#.net winform application using sql server express <p>i have a single sql database in sql server express.</p> <p>i have a login MAINLOGIN, for this database.</p> <p>i want insertion of data in this database through multiple users, U1,U2,U3, each having different userids &amp; passwords. </p> <p>These users would be created by MAINLOGIN , manually or via the winform application.</p> <p>So while creating MAINLOGIN , i would give him permission to further create logins.</p> <p>For this what should i do?</p> <p>i cannot create MULTIPLE users, because for one database, only one user can be created under one login.</p> <p>so should i create multiple logins, L1,L2,L3, then map, U1, U2, U3 to them.</p> <p>Or, is there a better way to do this? like application roles etc. </p> <p>i dont want to use windows authentication. because if i know the system password, then i could simply connect sql via the application and insert wrong data.</p>
28,409,037
0
<p>If we simplify your example we will get:</p> <pre><code> val interests = Seq[String]().map { x =&gt; Option[Map[String, String]](Map("k" -&gt; "v")) }.fold(Map[String, String]())(_) </code></pre> <p>This means that we are trying to <code>fold</code> <code>Seq[Option[Map[String, String]]]</code> with initial value <code>Map[String, String]()</code>:</p> <pre><code>def fold[A1 &gt;: A](z: A1)(op: (A1, A1) =&gt; A1): A1 = foldLeft(z)(op) </code></pre> <p>From <code>fold</code> definition we can see that compiler expects that <code>Option[Map[String, String]]</code> (each value in folding) and <code>Map[String, String]</code> (init value) should be of the same type. </p> <p>If you inspect <code>Option</code> hierarchy you will see:</p> <p><code>Option</code> -> <code>Product</code> -> <code>Equals</code></p> <p>For <code>Map</code> we have the following:</p> <p><code>Map</code> -> <code>GenMap</code> -> <code>GenMapLike</code> -> <code>Equals</code> (traits hierarchy is complicated, may be another chains exist).</p> <p>So we can see tha the nearest common type is <code>Equals</code>.</p> <p>Second part of your puzzle is <code>(_)</code>. </p> <p>This is treated by compiler as an argument of lambda:</p> <pre><code>val interests = x =&gt; /*omited*/.fold(Map[String, String]())(x) </code></pre> <p>As we saw <code>x</code> is <code>(A1, A1) =&gt; A1</code>. And in our case it is:</p> <pre><code>(Equals, Equals) =&gt; Equals </code></pre> <p>The result of <code>fold</code> is <code>A1</code> which is also <code>Equals</code>.</p> <p>As a result lambda type is:</p> <pre><code>((Equals, Equals) =&gt; Equals) /*&lt;&lt; arg*/ =&gt; /*result &gt;&gt;*/ Equals </code></pre> <p><strong>UPDATE:</strong></p> <p>To solve your problem I think you should use:</p> <pre><code>.flatten.reduce(_ ++ _) </code></pre>
15,775,625
0
<p>While not explicitly documented for the <a href="http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeSpotPriceHistory.html" rel="nofollow">DescribeSpotPriceHistory</a> API action, this restriction is at least mentioned for the <a href="http://aws.amazon.com/console/" rel="nofollow">AWS Management Console</a> (which uses that API in turn), see <a href="http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-spot-instances-history.html" rel="nofollow">Viewing Spot Price History</a>:</p> <blockquote> <p>You can view the Spot Price history over a period from one to 90 days based on the instance type, the operating system you want the instance to run on, the time period, and the Availability Zone in which it will be launched.</p> </blockquote> <ul> <li>Since anybody could have retrieved and logged the entire spot price history ever since this API is available (and without a doubt quite some users and researchers have done just that; even the AWS blog listed some dedicated <a href="http://aws.typepad.com/aws/2009/12/thirdparty-aws-tracking-sites.html" rel="nofollow">Third-Party AWS Tracking Sites</a>, but these are all defunct at first sight), this restriction admittedly seems a bit arbitrary, but is certainly pragmatic from a strictly operational point of view, i.e. you have all the information you need to base future bids upon (esp. given AWS has only ever reduced prices so far, and regularly does so in fact much to the delight of its customers).</li> </ul> <p>Likewise there's no option to change the frequency, so you'd need to resort to client side code for the hourly aggregation.</p>
10,081,738
1
How to convert '[' to '[' use python <p>I use this :</p> <pre><code> title=title.replace(u'【',u'[').replace(u'】',u'[') </code></pre> <p>But Error:</p> <pre><code>UnicodeDecodeError: 'ascii' codec can't decode byte 0xe3 in position 0: ordinal not in range(128) </code></pre>
34,746,293
0
How to set InstanceContextMode through Custom Behavior implementing IServiceBehavior <p>Is there a way to set the <strong>InstanceContextMode</strong> through a custom service behavior implementing <strong>IServiceBehavior</strong> --> <strong>ApplyDispatchBehavior</strong></p>
18,712,778
0
<p>It's not possible in C#.</p> <p>Use a bunch of <code>if</code>s instead.</p>
35,728,967
0
<p>You have to wrap the call to <code>self.mail_processor.poll_history_feed</code> in a try/except block and log the error for convenience.</p> <pre><code>def safe_poll_history_feed(self): try: self.mail_processor.poll_history_feed() except Exception: cherrypy.engine.log("Exception in mailprocessor monitor", traceback=True) </code></pre> <p>And then use the <code>safe_poll_history_feed</code> method</p>
3,641,370
0
In C, is there a cross-platform way to store what a variable might contain for quick reloading of its contents? <p>The idea is that an application may contain a struct of large arrays that are filled up via a slow external library. So, what if that could be easily stored to a file for fast reference, at least after it has been run once? If it's not possible to be done easily in a cross platform way, is it easy to be done locally 'after a first run'?</p>
30,677,861
0
Using Html.TextBox with custom property in mvc5 <p>if we have the below code,</p> <pre><code>&lt;input id="Name" name="Name" type="text" data-bind="value: Name" class="title width-7" /&gt; </code></pre> <p>we can translate it using <code>@Html.TextBoxFor</code> to:</p> <pre><code>@Html.TextBoxFor(m =&gt; m.Name, new { data_bind="value: Name", @class = "title width-7" }) </code></pre> <p>now I have this line that i can't translate the 'placeholder' attribute with <code>@Html.TextBoxFor</code>, how can I do that??</p> <pre><code> &lt;input type="email" class="form-control" id="exampleInputEmail3" placeholder="Enter email"&gt; </code></pre> <p>thanks...</p>
10,551,178
0
<p>You've in the preprocessing servlet <strong>already</strong> set the <code>queryResult</code> in the request scope. </p> <pre><code>request.setAttribute("queryResult",result); </code></pre> <p>So you do <strong>not</strong> need to use <code>&lt;jsp:useBean&gt;</code> at all. Remove the following line altogether:</p> <pre><code>&lt;jsp:useBean id="queryResult" class="uges.servlets.MyQuery" scope="request"/&gt; </code></pre> <p>Because your servlet has set it as a request attribute, the object is <strong>already</strong> in EL available by <code>${queryResult}</code>. But due to the strange design of the class itself, it's hard to properly access it in EL, so you'll ineed need to resort to old school <em>scriptlets</em>. You only need to obtain it first by <code>request.getAttribute("queryResult")</code>.</p> <p>For a better design approach, check the <a href="http://stackoverflow.com/tags/servlets/info">servlets tag wiki page</a> and <a href="http://stackoverflow.com/questions/5003142/jsp-using-mvc-and-jdbc/5003701#5003701">JSP using MVC and JDBC</a>.</p>
22,518,120
0
UPDATE using html form (edit button) php/mysql <p>I'm trying to figure out how to UPDATE a post in my db using html form. I have a page with a form using INSERT that successfully uploads data to my db. I also have another page presenting that data using SELECT. On this page I would like to have an Edit button, sending me to a similar page with the original form but this with the data from the db already inserted into the form, for easy editing and updating. Basically I don't know where to start and I need your help! It's an album database btw.</p> <p><strong>form page</strong></p> <pre><code>&lt;form method="post" action="spara2.php" name="std"&gt; &lt;label&gt;Cover:&lt;/label&gt;&lt;br&gt; &lt;input id="file" type="file" name="file"&gt;&lt;br&gt; &lt;label&gt;Title:&lt;/label&gt;&lt;br&gt; &lt;input type="text" name="std_title" size="58"/&gt;&lt;br&gt; &lt;label&gt;Artist:&lt;/label&gt;&lt;br&gt; &lt;input type="text" name="std_artist" size="58"/&gt;&lt;br&gt; &lt;label for="select"&gt;&lt;br&gt; Year:&lt;/label&gt;&lt;br&gt; &lt;select name="std_year"&gt; &lt;option value="2014"&gt;2014&lt;/option&gt; &lt;option value="2013"&gt;2013&lt;/option&gt; &lt;option value="2012"&gt;2012&lt;/option&gt; &lt;option value="2011"&gt;2011&lt;/option&gt; &lt;option value="2010"&gt;2010&lt;/option&gt; &lt;option value="2009"&gt;2009&lt;/option&gt; &lt;option value="2008"&gt;2008&lt;/option&gt; &lt;option value="2007"&gt;2007&lt;/option&gt; &lt;option value="2006"&gt;2006&lt;/option&gt; &lt;/select&gt;&lt;br&gt; &lt;label&gt;Description:&lt;/label&gt;&lt;br&gt; &lt;textarea name="std_beskriv" cols="45" rows="7"&gt; &lt;/textarea&gt;&lt;br&gt; &lt;label&gt;Tracks:&lt;/label&gt;&lt;br&gt; &lt;textarea name="std_lista" cols="45" rows="7"&gt; &lt;/textarea&gt;&lt;br&gt; &lt;label&gt;Spotify HTTP Link:&lt;/label&gt;&lt;br&gt; &lt;input type="text" name="std_spotify" size="58"/&gt;&lt;br&gt; &lt;br&gt; &lt;label for="reset"&gt;&lt;/label&gt;&lt;input type="reset" value="Reset"/&gt; &lt;label for="save"&gt;&lt;/label&gt;&lt;input type="submit" name="std_save" value="Save"/&gt; &lt;/form&gt; </code></pre> <p> </p> <p>My db is called album and the table musik. I want a similar page but with the data from the db inserted into it. My table has:</p> <ol> <li>id</li> <li>title</li> <li>artist</li> <li>year</li> <li>beskriv</li> <li>tracks</li> <li>spotify</li> <li>date</li> </ol> <p>Since there's a lot of posts in the db how can I select specific entry's so that I can edit one album at a time?</p> <p>Hope you can understand what i'm after.</p> <p>Thanks!</p>
38,391,571
0
<p>Well, needless to answer the comments, as the code worked beautifully after I opened the project up this morning.</p> <p>There has to be some kind of bug in JDeveloper when creating new packages and files, odd thing is I restarted the web service to make sure that the new folders would integrate, but by the looks of it JDeveloper needs, at the very least, to be restarted in order to integrate new folders/files.</p> <p>Definitely this IDE is a great let down from Oracle.</p> <p>Thank you all for your comments.</p>
27,409,557
0
<p>Your math problem is right here:</p> <pre><code> writeStream.Write(buffer, 0, bytesRead); bytesRead = responseStream.Read(buffer, 0, Length); var progress = bytesRead * 100.0 / writeStream.Length; bw.ReportProgress((int)progress,SummaryText); </code></pre> <p>The return value from <code>responseStream.Read</code> is the number of bytes you read <em>in that one read</em>. It's not the total number of bytes read since you started reading from the file.</p> <p>Also, dividing the number of bytes read by the total number written (i.e. <code>writeStream.Length</code>) isn't telling you anything useful.</p> <p>If you want to update a progress bar, you have to know how many total bytes there are in the file, and how many total bytes you've read up to this point. So if the file is 1,000,000 bytes long, and you've read 450,000 bytes <em>total</em>, the progress would be 45% (i.e. 450000/1000000).</p> <p>In your code, you have to get the file size from the FTP server. That's the total number of bytes you're going to download. Then you need keep track of how many bytes you've read up to this point. The basic idea is:</p> <pre><code>int totalBytesToBeRead = ??; // somehow get length. responseStream.Length doesn't work. int totalBytesRead = 0; int bytesRead = -1; while (bytesRead != 0) { bytesRead = responseStream.Read(...); // now add to the total totalBytesRead += bytesRead; var progress = totalBytesRead * 100.0 / totalBytesToRead; } </code></pre> <h2>Update</h2> <p>The problem appears to be that <code>FtpWebRequest</code> doesn't supply a <code>ContentLength</code>, so you need some other way to get the length. The only thing that comes to mind is to request the length up front by doing a separate <code>FtpWebRequest</code> with the <code>GetFileSize</code> method. See <a href="http://stackoverflow.com/questions/4175874/get-file-size-on-an-ftp-in-c-sharp">Get File Size On An FTP in C#</a> for an example.</p>
24,180,379
0
Creating relations in parse.com with multiple classes (JavaScript SDK) <p>Using parse.com and JavaScript SDK.</p> <p>I've read alot about this, but cannot find any examples that fit my issue I'm trying to solve.</p> <p>Here is what I'm attempting to achieve.</p> <p>I want class "FriendRequest" to have a one to many relation with "myBadges". The child objects held in "myBadges" will be increasing overtime.</p> <p>The child objects are generated by a function that runs when the user selects a badge and uses "Yes, do it now!" to store it in "myBadges".</p> <p>At the moment I can only seem to create a relationship within the active class that the function uses. This means I have a relation set up in "myBadges" that just points to the User class, not to the class "FriendRequest".</p> <p>The relation is in this part of code</p> <pre><code> success: function(results) { // The object was saved successfully. userbadges.relation('BadgeConnect').add(userbadges); userbadges.save(); </code></pre> <p>So the problem I'm trying to solve is to move the relation link from the "myBadges" class to the "FriendRequest" class???</p> <p>An example answer how how to achieve this would be great to help me learn the correct approach.</p> <p>FULL CODE.</p> <pre><code>&lt;script type="text/javascript"&gt; Parse.initialize("xxxx", "xxxxx"); var MyBadges = Parse.Object.extend("myBadges"); var friendRequest = Parse.Object.extend("FriendRequest"); var userbadges = new MyBadges(); var friendRequest = new friendRequest(); var user = Parse.User.current(); $(document).ready(function() { $("#send").click(function() { var badgeselected = $('#badgeselect .go').attr("src"); userbadges.set("BadgeName", badgeselected); userbadges.set("uploadedBy", user); //userbadges.set('BadgeName'); //userbadges.save(); userbadges.save(null, { success: function(results) { // The object was saved successfully. userbadges.relation('BadgeConnect').add(userbadges); userbadges.save(); //location.reload(); }, error: function(contact, error) { // The save failed. // error is a Parse.Error with an error code and description. alert("Error: " + error.code + " " + error.message); } }); }); }); </code></pre>
11,175,798
0
How to count characters of other langauges in edittext <p>I am trying to count Unicode characters like Arabic or Chinese in a edittext. I manage to count normal characters using this example: <a href="http://stackoverflow.com/a/9867992/1282492">http://stackoverflow.com/a/9867992/1282492</a></p> <p>I want to limit normal characters to 160 and Unicode characters to 80, is there anyway i can do this?</p>
19,390,323
0
Why is my copy constructor not working with new invocation and has same memory address? <p>Am i able to use a copy constructor with the new keyword? My code also shows the 2 obj pointers have the same memory address? </p> <pre><code>#include &lt;iostream&gt; using namespace std; class Person{ public: int age; Person() { } Person(const Person&amp; p ) : age(p.age) { } }; int main() { Person *p = new Person(); p-&gt;age = 15; Person *y = p; // Person *z = new Person(p); why no work??? // p and y have the same memory addres?? std::cout &lt;&lt; p; std::cout &lt;&lt; y; return 0; } </code></pre>
18,925,739
0
<p>This is likely because you're trying to output to a <code>url</code> as opposed to a local document...</p> <p>Your ouput path:</p> <pre><code>http://website.com/Images/accents/generated/imagename.jpg </code></pre> <p>This won't work... The output has to be local, try something like:</p> <pre><code>./Images/accents/generated/imagename.jpg </code></pre>
40,496,659
0
<p>As I see it you have a couple of alternatives. One of them is: </p> <p><strong>CUBE object</strong></p> <ul> <li>set a <code>boolean</code> variable on your cubes. <code>boolean hasBeenHit</code> or similar. This starts att <code>false</code>. </li> <li>Give the cube a <code>OnTriggerEnter()</code> where it sets the <code>hasBeenHit = true</code>.</li> <li>Make a public getter for <code>hasBeenHit</code>.</li> </ul> <p><strong>Ball object</strong></p> <ul> <li>In <code>OnTriggerEnter(Collider other)</code> check if <code>other</code> is a cube.</li> <li>If it is a cube, check if its <code>hasBeenHit</code> is <code>true</code> or <code>false</code>.</li> <li>If it is <code>false</code>, increment <code>count</code></li> </ul>
31,090,313
0
<p>I think it's gradle's fault. Go and click build from the top options, then select clean project.</p> <p>Since I cannot see the rest of the code, I assume this is the problem.</p>
37,386,171
0
<p>Working for MongoID 5.x. With the mongo shell and MongoID is straightforward:</p> <ol> <li><p>Pick up your object id</p> <p><code>ModelName.first.id # then copy your_id</code></p></li> <li><p>Run mongo console</p> <p><code>mongo</code></p></li> <li><p>Get the size in bytes of the document</p> <p><code>Object.bsonsize(db.modelname.find({"_id": ObjectId("your_id")}))</code></p></li> </ol>
38,509,599
0
<p>You probably want to use a <a href="https://developer.android.com/reference/android/text/SpannableString.html" rel="nofollow">SpannableString</a> for this, which allows individual parts of a string to be rendered differently in a TextView.</p> <p>Like so:</p> <pre><code> SpannableString str = new SpannableString("Highlighted. Not highlighted."); str.setSpan(new BackgroundColorSpan(Color.YELLOW), 0, 11, 0); textView.setText(str); </code></pre>
4,562,133
0
<p>Have a look at this post. </p> <p><a href="http://stackoverflow.com/questions/3777611/iphone-send-mail-in-background-when-didupdatetolocation-occurs">iphone send mail in background when didUpdateToLocation occurs</a></p>
14,752,765
0
<p>What I surmise according to your question... </p> <blockquote> <p>CREATE TABLE PEOPLE(ID INTEGER,PERSON VARCHAR(20),USERID INTEGER); CREATE TABLE TASKS(ID INTEGER,TASK VARCHAR(20),USERID INTEGER); CREATE TABLE TASKPERSON(ID INTEGER,PERSONID INTEGER,TASKID INTEGER);</p> <p>INSERT INTO PEOPLE VALUES(1,"RAHUL",1); INSERT INTO TASKS VALUES(1,NULL,1); INSERT INTO TASKPERSON VALUES(1,1,NULL);</p> <p>INSERT INTO PEOPLE VALUES(1,"RAUNAK",1); INSERT INTO TASKS VALUES(1,"R",1); INSERT INTO TASKPERSON VALUES(1,1,33);</p> <p>INSERT INTO PEOPLE VALUES(2,"PARTH",2); INSERT INTO TASKS VALUES(2,"P",2); INSERT INTO TASKPERSON VALUES(2,2,22);</p> <p>INSERT INTO PEOPLE VALUES(3,"KANISHK",3); INSERT INTO TASKS VALUES(3,"K",3); INSERT INTO TASKPERSON VALUES(3,3,33);</p> <p>INSERT INTO PEOPLE VALUES(4,"HEENA",4); INSERT INTO TASKS VALUES(4,NULL,4); INSERT INTO TASKPERSON VALUES(4,4,NULL);</p> </blockquote> <p>When not including "NOT IN", you will retrieve the list of those people who are not allocated.</p> <pre><code>SELECT P.*,P.ID FROM PEOPLE P LEFT JOIN TASKPERSON TP ON P.ID=TP.PERSONID WHERE P.USERID=1 AND TP.PERSONID IN(SELECT TP.PERSONID FROM TASKPERSON TP WHERE TP.PERSONID=1 AND TP.TASKID=33) GROUP BY P.ID </code></pre>
17,698,511
0
<p>This means that the font you are using simple doesn't support your chosen characters. I'm facing this problem and trying to find some solution, but at the moment with no results. </p>
2,808,430
0
<p>HTMLEntities seems to work but you have an encoding problem. The terminal you're printing on is probably set up for a latin charset and barfs on the utf-8 characters output by your script.</p> <p>In what environment are you running ruby ?</p> <p>The reason '&amp;' displays correctly is that it's an ascii character and thus will display the same in most encodings.The problem is that it's not supposed to happen alone in an xml document and could pose problems later when you feed your decoded file to hpricot. I believe the proper way would be to parse with hpricot and then pass what you're extracting from the document to HTMLEntity.</p>
25,609,155
0
<p>I think it is not correct to call <code>prepareMap(Lang, Long)</code> and <code>addData()</code> after to the call <code>query.getInBackground(...)</code> because "In background" means in a different Thread. You should reorder your calls like this:</p> <pre><code>ParseQuery&lt;ParseObject&gt; query = ParseQuery.getQuery("resdb"); query.getInBackground(obj, new GetCallback&lt;ParseObject&gt;() { @Override public void done(ParseObject object, ParseException e) { if (e == null) { restName = object.getString("name"); restCuisine = object.getString("cuisine"); restLocation = object.getString("location"); restAddress = object.getString("address"); // Update your info after to get the rest info prepareMap(Lang, Long); addData(); } else { e.printStackTrace(); } } }); </code></pre> <p>I hope this help you!</p>
821,106
0
<p>You can throw in </p> <pre><code>return false </code></pre> <p>wherever you want the code execution in your action to stop</p>
14,093,088
0
<p>You can't really just get the title, you can get the whole document and then weed out the elements you need: I like to use <a href="http://simplehtmldom.sourceforge.net/manual.htm#section_find" rel="nofollow">Simple Html Dom Parser</a></p> <pre><code>$html = file_get_html('http://www.google.com/'); $title = $html-&gt;find('title'); </code></pre>
14,048,204
0
Delphi - Graphics32, draw antialiased rounded rectangle <p>How can I draw an anti-aliased rounded corners rectangle using Graphics32?</p> <p>I managed to make a normal rectangle with TPolygon onto the bitmap32 canvas, but I cant find any reference to drawing rounded corners. Would appreciate some code.</p>
10,874,316
0
<p>I would suggest to read the following article about SSL sockets in Erang that contains complete code of the SSL echo server and client.</p> <p><a href="http://erlycoder.com/89/erlang-ssl-sockets-example-ssl-echo-server-ssl-client-" rel="nofollow">Erlang SSL sockets example - ssl server &amp; client)</a></p>
9,149,850
0
Imported a SQL Server database, and it says login failed for a user that doesn't exist <p>I have a asp.net web application that I was hosting somewhere.</p> <p>I backed up the database and restored it locally.</p> <p>Now when I run the application, it says <code>myapp_user123011</code> doesn't exist.</p> <p>When looking at the security section for the db and the database server, I don't see that user anywhere.</p> <p>My <code>web.config</code> was changed to use the <code>sa</code> account.</p> <p>Not sure where this user could be referenced?</p> <p>I'm guessing this database user was imported into my database server (SQL Server 2008 R2) but for some reason isn't showing up in the user list in the security sections).</p> <p>How can I search and delete this user if this is the case?</p> <p>(Note: I have searched the entire solution for that username and it doesn't exist)</p>
8,893,012
0
<p>You can earn money from impressions (ads being displayed) but it is very small amounts per thousand impressions. You will earn slightly more from clicks.</p> <p>Don't filter unless you have personal (eg ethical/moral) or competitive objections to the type of content being displayed to give yourself the best chance of earning revenue.</p>
16,677,238
1
Flattening an array in Flask API <p>I'm making an API with flask that takes as a POST message body a nested array, and then returns a list of the values. An example would be curl …. –d ”(([[1, [], [2, 3]], [[4]], 5])” would return [1,2,3,4,5]. The flattening script works in the command line, but when I POST to the API, I get some weird results. Code is here:</p> <pre><code>app = Flask(__name__) app.config.from_object(__name__) app.config.from_envvar('PHIGITAL_SETTINGS', silent=True) @lru_cache(maxsize=500) def flatten(l): flattened = [] for el in l: if isinstance(el, (list, tuple)): flattened.extend(flatten(el)) else: flattened.append(el) return flattened @app.route('/flatten', methods=['POST']) def flatten_api(): if request.method == 'POST': try: return jsonify({"response" : flatten(request.data)}) except Exception as e: return jsonify({"response" : "ERROR: %s" % str(e)}) if __name__ == '__main__': app.run() </code></pre> <p>Testing this in Postman gets me the response: { "response": [ "[", "[", "1", ",", " ", "[", "]", ",", " ", "[", "2", ",", " ", "3", "]", "]", ",", " ", "[", "[", "4", "]", "]", ",", " ", "5", "]" ] }</p> <p>Which is obviously not correct. I thought that it might have to do with the fact that request.data is a string, so I tried using ast.literal_eval to make request.data a list, but then I get the error "unhashable type: 'list'" when I try to call flatten on ast.literal_eval(request.data). I'm totally stumped and any help would be greatly appreciated.</p> <p>Also, is it possible in Flask to return just a value, rather than a key value pair? I'd rather return just [1,2,3,4,5] rather than {"response": [1,2,3,4,5]}</p>
7,037,957
0
<p>You need</p> <pre><code>$select = $this-&gt;select() -&gt;from(array('mpp' =&gt; 'menu_profiles_products'), array('NAME' =&gt; 'p.name', 'PRICE' =&gt; 'p.price*mp.added_value/100')) -&gt;join(array('p' =&gt; 'products'), 'p.id = mpp.product_id') -&gt;join(array('mp' =&gt; 'menu_profiles'), 'mp.id = mpp.profile_id') -&gt;where('mpp.profile_id = ?', $profileID); $adapter = new Zend_Paginator_Adapter_DbTableSelect($select); return $adapter; </code></pre> <p>OR if you want use Zend_Db_Select</p> <pre><code>$select = $this-&gt;getDefaultAdapter()-&gt;select() -&gt;from(array('mpp' =&gt; 'menu_profiles_products'), array('NAME' =&gt; 'p.name', 'PRICE' =&gt; 'p.price*mp.added_value/100')) -&gt;join(array('p' =&gt; 'products'), 'p.id = mpp.product_id') -&gt;join(array('mp' =&gt; 'menu_profiles'), 'mp.id = mpp.profile_id') -&gt;where('mpp.profile_id = ?', $profileID); $adapter = new Zend_Paginator_Adapter_DbSelect($select); return $adapter; </code></pre>
25,727,282
0
<p>Another option is placing an error container outside of your form group ahead of time. The validator will then use it if necessary.</p> <pre><code>&lt;div class="form-group"&gt; &lt;label class="control-label" for="new-task-due-date"&gt;When is the task due?&lt;/label&gt; &lt;div class="input-group date datepicker"&gt; &lt;input type="text" id="new-task-due-date" class="required form-control date" name="dueDate" /&gt; &lt;span class="input-group-addon"&gt; &lt;span class="glyphicon glyphicon-calendar"&gt;&lt;/span&gt; &lt;/span&gt; &lt;/div&gt; &lt;label for="new-task-due-date" class="has-error control-label" style="display: none;"&gt;&lt;/label&gt; &lt;/div&gt; </code></pre>
1,371,301
0
<p>Outside of Java, in-browser OpenGL is really in its infancy. Google's launched a really cool API and plugin for it though. It's called O3D:</p> <p><a href="http://code.google.com/apis/o3d/" rel="nofollow noreferrer">http://code.google.com/apis/o3d/</a></p> <p>Article about the overall initiative: <a href="http://www.macworld.com/article/142079/2009/08/webgl.html" rel="nofollow noreferrer">http://www.macworld.com/article/142079/2009/08/webgl.html</a></p>
12,277,340
0
<p>I've tried to produce a "simpler" query that works and so far nothing.</p> <p>If I stick with your basic structure I can offer a slight improvement. Try this:</p> <pre><code>public static IObservable&lt;T&gt; FirstOrLastAsync&lt;T&gt;( this IObservable&lt;T&gt; source, Func&lt;T, bool&gt; pred) { return Observable.Create&lt;T&gt;(o =&gt; { var hot = source.Publish(); var store = new AsyncSubject&lt;T&gt;(); var d1 = hot.Subscribe(store); var d2 = hot .Where(x =&gt; pred(x)) .Concat(store) .Take(1) .Subscribe(o); var d3 = hot.Connect(); return new CompositeDisposable(d1, d2, d3); }); } </code></pre> <p>It's not hugely better, but I like it better than using <code>Amb</code>. It's just a tad cleaner I think.</p>
40,849,566
0
<blockquote> <p>so is it possible to get the view object of a android default screen? </p> </blockquote> <p>No. That app runs in another process. Its objects cannot magically transport themselves to your process.</p> <blockquote> <p>i want to know how can i get content of device default screen content from my application</p> </blockquote> <p>On Android 5.0+, with user permission, you can use the media projection APIs to take screenshots.</p>
25,641,015
0
<p>All MongoDB queries produce "key/value" pairs in the result document. All MongoDB content is basically a BSON document in this form, which is just "translated" back to native code form by the driver to the language it is implemented in.</p> <p>So the aggregation framework alone is never going to produce a bare array of just the values as you want. But you can always just transform the array of results, as after all it is only an array</p> <pre><code>var result = db.collection.aggregate(pipeline); var response = result.result.map(function(x) { return x._id } ); </code></pre> <p>Also note that the default behavior in the shell and a preferred option is that the aggregation result is actually returned as a cursor from MongoDB 2.6 and onwards. Since this is in list form rather than as a distinct document you would process differently:</p> <pre><code>var response = db.collection.aggregate(pipeline).map(function(x) { return x._id; }) </code></pre>
23,709,649
0
MsSql server 2008 r2 Data Syncronization <p>I'm working on a project in C#.NET (WPF) with 2 SQL Server 2008 R2 databases. I need to update new/changed data from local db to online db. Client system has low bandwidth connection. So I need a solution to upload a file to sync.</p> <p>Can anyone tell me how I can do this? Programming example will be more beneficial for me.</p>
37,933,880
0
WiX Bootstrapper <p>I am trying to create an installer for a simple .NET WPF C# app. I am using VS 2013, and WiX 3.10.2. Following the steps in the Wix Tutotial/ .NET/ Bootstrapping I have created a Boostrap.exe which chains .NET web installer and the app Setup.msi.</p> <p><strong>EDIT</strong>: My goal is to understand how to configure the WiX Bootstrap and Setup projects for small updates, minor upgrades, and major upgrades scenarios.</p> <p>Out of the box, everything seems to work nice when I run a fresh install. However, when I run a fresh built Bootstrap.exe over an already existing installation a duplicate entry appears in the Apps &amp; features and no file is changed in the app target location - contrary to the expectation that the same entry should remain in the Apps &amp; features and the target location should be updated. <strong>EDIT</strong>: Looks like there may not be a way to change REINSTALLMODE? </p> <p>If I add a Product Id and then change the version of the Setup (minor upgrade), the Bootstrap fails with User cancelled installation? The log file shows "Error 0x80070642: Failed to perform minor upgrade of MSI package." <strong>EDIT</strong>: Inside the MSI log a SecureRepair fails with error code 39439E438 (?) probably because the stored hash value does not match the current... but that should be expected in a minor upgrade MSI, right?</p> <p>Are there recommended configurations between the Boostrapper and Setup WiX projects such that the small update, minor upgrade, and major upgrade use cases can be handled properly, or does the WiX Bootstrapper support ONLY major upgrades?</p> <p>I will continue to investigate and I'll post updates to my findings; </p> <p>Any hints are greatly appreciated, Thanks!</p> <p>Here are the source files which I barely changed from the WiX wizard generated code:</p> <p>--- Product.wxs ---</p> <pre><code>&lt;Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"&gt; &lt;Product Id="*" Name="SetupProject1 1.0.0.0" Language="1033" Version="1.0.0.0" Manufacturer="Acme" UpgradeCode="4c8a8cbf-e3d0-410c-8a8d-7e67eb4e7ff7"&gt; &lt;Package InstallerVersion="200" Compressed="yes" InstallScope="perUser" InstallPrivileges="limited" /&gt; &lt;MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." /&gt; &lt;MediaTemplate /&gt; &lt;Feature Id="ProductFeature" Title="SetupProject1" Level="1"&gt; &lt;ComponentGroupRef Id="ProductComponents" /&gt; &lt;/Feature&gt; &lt;/Product&gt; &lt;Fragment&gt; &lt;Directory Id="TARGETDIR" Name="SourceDir"&gt; &lt;Directory Id="LocalAppDataFolder"&gt; &lt;Directory Id="AcmeFolder" Name="Acme"&gt; &lt;Directory Id="INSTALLFOLDER" Name="WpfApplication1" /&gt; &lt;/Directory&gt; &lt;/Directory&gt; &lt;/Directory&gt; &lt;/Fragment&gt; &lt;Fragment&gt; &lt;ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER"&gt; &lt;Component Id="ProductComponent" Guid="8CA0B70F-39DA-4B4B-9104-46C58E26FCF4"&gt; &lt;CreateFolder/&gt; &lt;RemoveFolder Id="RemoveAcmeFolder" Directory="AcmeFolder" On="uninstall"/&gt; &lt;RemoveFolder Id="RemoveINSTALLFOLDER" On="uninstall" /&gt; &lt;RegistryValue Root="HKCU" Key="Software\Acme\WpfApplication1" Name="Version" Type="string" Value="[ProductVersion]" KeyPath="yes" /&gt; &lt;File Source="$(var.WpfApplication1.TargetPath)" KeyPath="no" /&gt; &lt;/Component&gt; &lt;/ComponentGroup&gt; &lt;/Fragment&gt; </code></pre> <p></p> <p>--- Bundle.wxs ---</p> <pre><code>&lt;Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:bal="http://schemas.microsoft.com/wix/BalExtension"&gt; &lt;Bundle Name="Bootstrapper1 1.0.0.0" Version="1.0.0.0" Manufacturer="Acme" UpgradeCode="e1092cbb-9134-42fc-a9f2-652f95f361fd"&gt; &lt;BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense" /&gt; &lt;Chain&gt; &lt;MsiPackage Name="Acme Setup" SourceFile="$(var.SetupProject1.TargetPath)" Vital="yes" /&gt; &lt;/Chain&gt; &lt;/Bundle&gt; </code></pre> <p></p>
40,132,812
0
splitting string into integer and string C++ <p>As a part of my project, I am expected to receive input in the following format.</p> <p>AXXX AXXX AXXX .....</p> <p>where A is a letter (any capital), and XXX is any integer (note that this number does not have to be limited to 3 digits). The letter is associated with some functionality (e.g. A means Add XXX to a list of numbers). I want to make a function that can read each term in the input and recognise what actions need to be taken (e.g. if I put A123 A983 A828 i know that i want to store the numbers 123 983 and 828 on a list). I hope that this was not confusing. If you are wondering why I am doing this, my project is on linked lists and requires input from the user to add nodes to the linked list. </p>
38,328,767
0
Access Query Hangs w/ Where instead of Join on Memo field <p>Access 2013</p> <pre><code>UPDATE [1 Clean Reasons], Data, [Final Crosswalk] SET [Final Crosswalk].CR_ID = [1 Clean Reasons].[CR_ID] WHERE (((Data.Reason)=[1 Clean Reasons].[Reason])); </code></pre> <p>I'm trying to build a record ID crosswalk table, "Final Crosswalk", I need to join Data.Reason = 1 Clean Reasons.Reason, but it's a memo field - thus the Where statement.</p> <p>I can view this query, but I can't get it to export or update. I'm assuming it's an issue with the resource requirements of the Where statement (the table has ~1M records).</p>
28,315,276
0
<p>If you want use generators to make async then you code is valid. ES6 contains only promises to async operations. ES7 will have async/await. You can also use a good library: <a href="https://github.com/kriskowal/q" rel="nofollow">https://github.com/kriskowal/q</a> or use only native promises Promise.All without generators.</p>
39,484,772
0
Classes do not change <p>I have faced with a strange problem. Once I change the <code>.java</code> file - it seems that tests are using still the previous version of that file (<code>.class</code>). </p> <p>From my point of view the class should be removed from <code>.build</code> folder and be recompiled from the new version of the .java file, but this only happens when I manually start build from Gradle. </p> <p>Can I somehow turn on the autorebuild solution for <code>.java</code> files on change? Or can I do this event without gradle? I'm using Intellij Idea.</p>
2,984,891
0
<p>Taking a look at another client's code is helpful (if not confusing): <a href="http://src.chromium.org/viewvc/chrome/trunk/src/net/http/" rel="nofollow noreferrer">http://src.chromium.org/viewvc/chrome/trunk/src/net/http/</a></p> <p>I'm currently doing something like this too. I find the best way to increase the efficiency of the client is to use the asynchronous socket functions provided. They're quite low-level and get rid of busy waiting and dealing with threads yourself. All of these have <code>Begin</code> and <code>End</code> in their method names. But first, I would try it using blocking, just so you get the semantics of HTTP out of the way. Then you can work on efficiency. Remember: Premature optimization is evil- so get it working, then optimize all of the stuff!</p> <p>Also: Some of your efficiency might be tied up in your use of <code>ToArray()</code>. It's known to be a bit expensive computationally. A better solution might be to store your intermediate results in a <code>byte[]</code> buffer and append them to a <code>StringBuilder</code> with the correct encoding.</p> <p>For gzipped or deflated data, read in all of the data (keep in mind that you might not get all of the data the first time you ask. Keep track of how much data you have read in, and keep on appending to the same buffer). Then you can decode the data using <code>GZipStream(..., CompressionMode.Decompress)</code>.</p> <p>I would say that doing this is not as difficult as some might imply, you just have to be a bit adventurous!</p>
17,502,297
0
<p>Your <code>&lt;h3&gt;</code> causes that. Put this:</p> <pre><code>h3{ margin:0; padding:0; } </code></pre>
11,149,742
0
Regarding help text over hover in asp.net <p>net website i want to put help tex with question mark..how is that possible.. I have seen this in few of sites like they have (?) when hover on it it shows some help text..How can i do this.. please help me out</p>
33,198,826
0
<p>Assuming you are under control of the content that you display in that <code>WKWebView</code>, you should set the right viewport for it. That will most likely disable this behaviour.</p> <p>How about:</p> <pre><code>&lt;meta id="viewport" name="viewport" content="width=device-width; user-scalable=false" /&gt; </code></pre>
38,067,164
0
how to switch to a new database <p>I want to deploy my django project to the production environments, and associated it with an new empty database, and I did as follows :</p> <ol> <li>Create an new empty database</li> <li>Updated settings.py and pointed the database name to the new one</li> <li>Deleted the migrations folder under my App </li> <li>Run python manage.py runserver and no errors returned</li> <li>Run python manage.py makemigrations and python manage.py migrate</li> </ol> <p>but only auth related tables created ( like <code>auth_user</code> , <code>auth_group</code> ... ), no databases tables created for my Apps</p> <p>How should I do for this situation to move to the new database for my project?</p>
1,268,901
0
<p>Delphi installation comes with a Demo named 'Bitmap' (you can find the project in Help dir.).</p> <p>It uses the following method to draw a tiled image:</p> <pre><code>procedure TBmpForm.FormPaint(Sender: TObject); var x, y: Integer; begin y := 0; while y &lt; Height do begin x := 0; while x &lt; Width do begin // Bitmap is a TBitmap. // form's OnCreate looks like this: // Bitmap := TBitmap.Create; // Bitmap.LoadFromFile('bor6.bmp'); // or you can use Canvas.Draw(x, y, Image1.Picture.Bitmap), // instead of Canvas.Draw(x, y, Bitmap); // Canvas.Draw(x, y, Bitmap); //Bitmap is a TBitmap. x := x + Bitmap.Width; // Image1.Picture.Bitmap.Width; end; y := y + Bitmap.Height; // Image1.Picture.Bitmap.Height; end; end; </code></pre> <p>Hope that helps!</p>
23,471,177
0
<p>Generally speaking, <code>final</code> would be more appropriate.</p> <p>The important thing about modifiers is that the alter the reference, not the object referenced. e.g.</p> <pre><code>final int[] a = { 0 }; a[0] = 5; // ok, not final a = b; // not ok as it is final </code></pre> <p>similarly</p> <pre><code>volatile int[] a = { 0 }; a[0] = 5; // not a volatile write a = b; // volatile write. </code></pre>
18,048,789
0
<p>I had similar problem and it is solved by </p> <ol> <li><p>Installing g++ The GNU C++ complier using ubuntu software centre and </p></li> <li><p>Changing in -</p></li> </ol> <p>Window -> Preferences -> C/C++ -> Build -> Settings -> Discovery -> CDT GCC Build in Complier Settings [Shared]</p> <pre><code>From: ${COMMAND} -E -P -v -dD "${INPUTS}" To : /usr/bin/${COMMAND} -E -P -v -dD "${INPUTS}" </code></pre> <p>I hope it helps.</p>
16,272,644
0
iOS app - how to get data from app store? <p>I need to develop an app that is going to search for apps in the app store and suggest the best of them to the user depending on the query. So my question is:</p> <p>Is it possible to retrieve data from the app store? If so, how?? Maybe someone can point to the right direction. Thank you very much in advance!</p> <p>P.S. My app is like <a href="https://itunes.apple.com/us/app/appdeals-get-paid-apps-for/id350030137?mt=8" rel="nofollow">this one</a>.</p>
19,228,447
0
<p>I would just use LINQ to XML in the simplest possible way:</p> <pre><code>var query = from file in files let doc = XDocument.Load(file) from customer in doc.Descendants("Customer") select new { Company = (string) customer.Element("Company"), Ship = (string) customer.Element("Ship") }; </code></pre> <p>I'd expect that to be pretty quick already - but you should work out what your exact performance requirements are, then test them. (You almost certainly don't need "the most efficient" way - you need a <em>sufficiently</em> efficient way, whilst keeping the code readable.)</p> <p>Note that if you want the values to be propagated out of the current method, you should create your own class to represent the company/ship pair.</p>
39,106,254
0
<p>Applications to not get restore state functionality magically but they support APIs that help doing it. Some applications do it well, others less well and others not at all.</p> <p>In practice, for the applications that support it, it works quite reliably, provided the logout went cleanly and you've not out of diskspace or something similar fatal.</p>
40,362,391
0
<p>PyGame doc: <a href="http://www.pygame.org/docs/ref/font.html#pygame.font.Font.render" rel="nofollow noreferrer">Font.render()</a></p> <blockquote> <p>The text can only be a single line: newline characters are not rendered. </p> </blockquote>
24,578,360
0
<p>I had the same problem. With me it was, that I installed from Ubuntu repositories and followed the tutorials that suggested installation of elasticsearch/elasticsearch-cloud-aws/1.4.0.</p> <p>If you have done that than</p> <p><code>cd /usr/share/elasticsearch sudo bin/plugin -remove elasticsearch/elasticsearch-cloud-aws/1.4.0</code></p> <p>and to install the working version, do</p> <pre><code>cd /usr/share/elasticsearch sudo bin/plugin -install elasticsearch/elasticsearch-cloud-aws/2.2.0 </code></pre>
21,686,883
0
<p>There are many ways. But as a beginner i would like to just add alert in each function:</p> <pre><code>$( document ).ready(function() { $("a").on('click', function() { $('c').css('opacity', '0.8'); alert('inside first'); }); $("ul#main li a").on('click', function() { $('c').toggle('.menu'); alert('inside first'); }); $("nav a").on('click', function() { callSomeFunctions(); alert('inside first'); }); }); </code></pre> <p>Also, working link: <a href="http://jsfiddle.net/wRZN6/" rel="nofollow">http://jsfiddle.net/wRZN6/</a></p>
33,513,863
0
<p>Make firstName as a public variable with getter/setter added, then you will be able to access the properties, By default, if no access modifier is present then CLR treats it as Private </p> <pre><code>public string FirstName { get; set; } </code></pre>
2,826,213
0
<p>In the <code>foreach</code> loop, you already know that <code>node</code> is a <code>/a/b</code> in the original document - so to get just <em>its</em> <code>c</code> children simply use a <strong>relative</strong> xpath:</p> <pre><code>node.SelectNodes("c") </code></pre>
26,268,269
0
Insertion sort while removing duplicates in C++ <p>I am having trouble with my insertion sort method. It loops over an array of elements of a custom struct that holds the word and the number of occurrences. The array length is fixed at 1000. The sort removes duplicates. It think the problem is in the swap when a duplcate is found but I am using the same function for the sorting swap. I have played with it for a while and I just can seem to get it to work.</p> <p>My program outputs the entire list, using length variable and outputs the following:</p> <pre><code>word occurences hello 500 hello 500 </code></pre> <p>I know that the array holds 1000 elements of the word hello, so this output if confusing me.</p> <pre><code>void sortAndRemoveDuplicates(Word WordArray [],int &amp;length){ /* Description: Sort the word array, removing duplicates */ for(int index=0;index&lt;length-1;index++){ int idxMin=index; for(int idx=index;idx&lt;length;idx++){ if(WordArray[idx].word&lt;WordArray[idxMin].word){ idxMin=idx; } } // if duplicate if(WordArray[idxMin].word==WordArray[index-1].word){ WordArray[index-1].wordCount++; swap(WordArray[idxMin],WordArray[index]); length--; index--; } if(idxMin!=index){ swap(WordArray[idxMin],WordArray[index]); } } }; void swap(Word &amp;x, Word &amp;y){ /* Description: Swap two words */ Word temp; temp=x; x=y; y=temp; }; void printResults (string &amp;filename, int &amp;charCount, int &amp;lineCount, int wordCount, Word WordArray[],int &amp;length){ /* Description: Print the results of the program to cout */ cout&lt;&lt;"\tResults\n"; cout&lt;&lt;"Filename: "&lt;&lt;filename&lt;&lt;"\n"; cout&lt;&lt;"Character Count: "&lt;&lt;charCount&lt;&lt;"\n"; cout&lt;&lt;"Line Count: "&lt;&lt;lineCount&lt;&lt;"\n"; cout&lt;&lt;"Word Count:"&lt;&lt;wordCount&lt;&lt;"\n"; cout&lt;&lt;"\tWord\tCount\n"; int i=0; while(i&lt;(length)){ cout&lt;&lt;"\t"; cout&lt;&lt;WordArray[i].word&lt;&lt;"\t"&lt;&lt;WordArray[i].wordCount&lt;&lt;"\n"; i++; } }; </code></pre> <p>Thanks</p>
6,349,513
1
Parsing XML Entity with python xml.sax <p>Parsing XML with python using xml.sax, but my code fails to catch Entities. Why doesn't skippedEntity() or resolveEntity() report in the following: </p> <pre><code>import os import cStringIO import xml.sax from xml.sax.handler import ContentHandler,EntityResolver,DTDHandler #Class to parse and run test XML files class TestHandler(ContentHandler,EntityResolver,DTDHandler): #SAX handler - Entity resolver def resolveEntity(self,publicID,systemID): print "TestHandler.resolveEntity: %s %s" % (publicID,systemID) def skippedEntity(self, name): print "TestHandler.skippedEntity: %s" % (name) def unparsedEntityDecl(self,publicID,systemID,ndata): print "TestHandler.unparsedEntityDecl: %s %s" % (publicID,systemID) def startElement(self,name,attrs): # name = string.lower(name) summary = '' + attrs.get('summary','') arg = '' + attrs.get('arg','') print 'TestHandler.startElement(), %s : %s (%s)' % (name,summary,arg) def run(xml_string): try: parser = xml.sax.make_parser() stream = cStringIO.StringIO(xml_string) curHandler = TestHandler() parser.setContentHandler(curHandler) parser.setDTDHandler( curHandler ) parser.setEntityResolver( curHandler ) parser.parse(stream) stream.close() except (xml.sax.SAXParseException), e: print "*** PARSER error: %s" % e; def main(): try: XML = "&lt;!DOCTYPE page[ &lt;!ENTITY num 'foo'&gt; ]&gt;&lt;test summary='step: &amp;num;'&gt;Entity: &amp;not;&lt;/test&gt;" run(XML) except Exception, e: print 'FATAL ERROR: %s' % (str(e)) if __name__== '__main__': main() </code></pre> <p>When run, all I see is:</p> <pre><code> TestHandler.startElement(), step: foo () *** PARSER error: &lt;unknown&gt;:1:36: undefined entity </code></pre> <p>Why don't I see the resolveEntity print for &amp;num; or the skipped entry print for &amp;not;?</p>
18,784,452
0
<p>Keep a counter using <code>long</code>, take the modulus, you don't have to worry about overflow as it will increase by 60 per second and your code needs to run for <code>292471208678</code> years before overflow.</p> <pre><code>long alphacntr = 0; .... public void update(){ alphacntr += 3; int alpha = alphacntr%256; .... } </code></pre>
11,823,032
0
Javascript onclick even on a div not working <p>I have a div and when a user clicks on it using the <code>onclick</code> event, i'm calling a function:</p> <pre><code> function test(a) { alert(a); } &lt;div onclick="javascript:test('zaswde');"&gt;sdfasdasdadasdasds&lt;/div&gt;​ </code></pre> <p><strong>Update</strong></p> <pre><code> &lt;ul&gt; &lt;li&gt; &lt;div&gt; &lt;div onclick="javascript:alert('v'); "&gt;&lt;/div&gt; &lt;/div&gt; &lt;div &gt;&lt;/div&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p>Can't i use <code>onclick</code> on the div element? ​</p>
31,757,787
0
<p>I was missing the Accept Header. Now it is working fine.</p>
5,765,950
0
<p>If you look at the very first line of your crash report, it states you are passing a nil string to NSURL's <strong>initFileURLWithPath</strong> method:</p> <pre class="lang-none prettyprint-override"><code>'NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter' </code></pre> <p>From Apple documentation. </p> <p><strong>Passing nil for this parameter produces an exception.</strong></p> <p>So make sure to check your NSString before sending to <strong>initFileURLWithPath</strong> method,</p> <pre><code>NSURL* targetFileURL = nil ; if(targetFilePath != nil) { targetFileURL = [[NSURL alloc] initFileURLWithPath:targetFilePath]; } </code></pre>
30,818,461
0
<p>Maybe GetBytes method doesn't work as you expect. This linqpad works fine for me:</p> <pre><code>void Main() { var result = ByteArrayToStructure&lt;Message&gt;(CreateMessageByteArray()); result.Dump(); } [StructLayout(LayoutKind.Sequential, Pack = 1)] struct Message { public int id; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 10)] public string text; } private static byte[] CreateMessageByteArray() { int id = 69; byte[] intBytes = BitConverter.GetBytes(id); string text = "test"; byte[] stringBytes = Encoding.UTF8.GetBytes(text); IEnumerable&lt;byte&gt; rv = intBytes.Concat(stringBytes); return rv.ToArray(); } static T ByteArrayToStructure&lt;T&gt;(byte[] bytes) where T : struct { var handle = GCHandle.Alloc(bytes, GCHandleType.Pinned); var result = (T)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(T)); handle.Free(); return result; } </code></pre> <p>Output:</p> <pre><code>id 69 text test </code></pre>
37,109,774
0
Unable to start emulator on Android Studio 2.1 <p>I am unable to start my emulator on <strong>Android Studio 2.1</strong> and getting the following <strong>error</strong>:</p> <pre><code>Cannot launch AVD in emulator. Output: emulator: WARNING: Increasing RAM size to 1024MB init: Could not find wglGetExtensionsStringARB! getGLES1ExtensionString: Could not find GLES 1.x config! emulator: WARNING: VM heap size set below hardware specified minimum of 48MB Failed to obtain GLES 1.x extensions string! emulator: WARNING: Setting VM heap size to 256MB Hax is enabled Hax ram_size 0x40000000 HAX is working and emulator runs in fast virt mode. Could not initialize emulated framebufferaudio: Failed to create voice `goldfish_audio_in' qemu-system-i386.exe: warning: opening audio input failed console on port 5554, ADB on port 5555 emulator: ERROR: Could not initialize OpenglES emulation, use '-gpu off' to disable it. </code></pre> <p>Getting same error in the <em>console</em> of <strong>AVD</strong></p> <p>I am trying to run with this following <strong>configurations</strong> : <a href="https://i.stack.imgur.com/vCuOf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vCuOf.png" alt="Emulator Config"></a></p> <p>My <em>android-studio has the following details</em>: <a href="https://i.stack.imgur.com/bQhRq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bQhRq.png" alt="About android studio"></a></p> <p>Any help will be appreciated.</p>
13,790,050
0
<p>There is also a new control bus component in camel 2.11 which could do what you want (<a href="http://camel.apache.org/controlbus.html" rel="nofollow">source</a>)</p> <pre><code>template.sendBody("controlbus:route?routeId=foo&amp;action=stop", null); </code></pre>
22,457,484
0
<p>The size of the main undocked window cannot be modified by resizing it manually. It is sized so that it is exactly large enough to contain its children. So, you can do what you want by moving the component palette to the desired location. When you do so the main window will increase in size so that the component palette fits.</p> <p>Judging by your screenshot, your toolbars are drawn in a way to indicate that they are locked and cannot be dragged. That's not functionality that is present in the plain vanilla Delphi IDE, so I suspect that you have used functionality from either GExperts or CnPack to lock your toolbars. Obviously you'll need to unlock them in order to move them.</p> <p>Finally, I should point out that the inability to resize the main window vertically is not new. Classic Delphi versions (e.g. Delphi 7) behaved in exactly the same way. So I think that the fundamental issue is not related to a Delphi version upgrade, but rather is related to you having locked your toolbars.</p>
9,988,288
0
<p>You can try using datetime and handle the exceptions to decide valid/invalid date : Example : <a href="http://codepad.org/XRSYeIJJ">http://codepad.org/XRSYeIJJ</a></p> <pre><code>import datetime correctDate = None try: newDate = datetime.datetime(2008,11,42) correctDate = True except ValueError: correctDate = False print(str(correctDate)) </code></pre>
27,926,989
0
<p>I think this must works, put your php name file in the url and add the done() function to your code</p> <pre><code>&lt;script type="text/javascript"&gt; $("#submit").click(function(){ var foo = $(this).val(); $.ajax({ url:'YourPhpNameFile.php', type: "POST", data: { 'name':foo }, }).done(function( msg ) { alert('success'); }); }); &lt;/script&gt; </code></pre> <p>or put</p> <pre><code>location.reload(); </code></pre> <p>on the success() function.</p> <p>Hope this helps you! Greetings.</p>
919,586
0
<p>You could get the textarea by</p> <pre><code>$('textarea') </code></pre> <p>If it's the only one on your page.</p> <p>You just need to call submit on the form that the textarea is contained within</p> <p><strong>EDIT:</strong></p> <p>After reading your update, you just want to validate that the textarea is not blank before submitting the form. You just need to set up the validation</p> <pre><code>var textArea = $('#results'); //Get the textarea if (textArea.val() == "") { textArea.show(); textArea.focus(); return false; } // perform the form submit here as textarea is not blank </code></pre> <p>Could you post the whole object where you have got the code beginning with</p> <pre><code> case "Save": </code></pre> <p>from? It would probably be a good idea to use that object to perform the submit.</p> <p><strong>EDIT 2:</strong></p> <p>In regard to your comment about the page being refreshed, submitting the form causes the page to be POSTed. It sounds like you want to POST data using AJAX. </p> <p>Take a look at jQuery's <a href="http://docs.jquery.com/Ajax/jQuery.ajax#options" rel="nofollow noreferrer"><code>$.ajax()</code></a> command</p>
38,905,946
0
<p><code>model.write</code> cannot just append to an existing file.</p> <p>In order to add to your existing file, you need to first <em>read</em> the file into your model, then add the additional data to your model, and then finally write the model back to it. </p>
28,229,434
0
<p>try this. it works for me.</p> <pre><code> $("#txtPaid").keyup(function () { var val1 = parseInt(document.getElementById('&lt;%=lblGrandTotal.ClientID %&gt;').innerHTML); var val2 = parseInt(document.getElementById('&lt;%=txtPaid.ClientID %&gt;').value); if (val1 != null &amp;&amp; val1.toString() != "NaN" &amp;&amp; val2 != null &amp;&amp; val2.toString() != "NaN") { $("#&lt;%=lblBalance.ClientID %&gt;").html(val1 - val2); } else { $("#&lt;%=lblBalance.ClientID %&gt;").html("0"); } }); </code></pre>
16,427,725
0
<p>I'd check that <code>localStorage</code> is defined prior to any action that depends on it:</p> <pre><code>if (typeof localStorage !== 'undefined') { var x = localStorage.getItem('mod'); } else { // localStorage not defined } </code></pre> <p><strong>UPDATE:</strong></p> <p>If you need to validate that the feature is there and that it is also not turned off, you have to use a safer approach. To be perfectly safe:</p> <pre><code>if (typeof localStorage !== 'undefined') { try { localStorage.setItem('feature_test', 'yes'); if (localStorage.getItem('feature_test') === 'yes') { localStorage.removeItem('feature_test'); // localStorage is enabled } else { // localStorage is disabled } } catch(e) { // localStorage is disabled } } else { // localStorage is not available } </code></pre>
7,894,221
0
How to log into git bitbucket repository from jenkins <p>I have a GIT repository on bitbucket, which I want my Jenkins Server to access automatically. This is only possible using public/private key authentication. So I created a key pair and uploaded the public key to bitbucket. The public and the private key are on my server in the .ssh folder of the tomcat user running jenkins. I am able to clone my project when I am logged in as that user on the server.</p> <p>However I am unable to get jenkins to actually check out the code from bitbucket. It always says:</p> <pre><code>Permission denied (publickey). fatal: The remote end hung up unexpectedly </code></pre> <p>Well I assume that this happens because when accessing the repository over ssh I need to provide the passphrase for my private key and jenkins is unable to do this automatically. I read that it is possible to avoid beeing asked for the passphrase by providing a config file inside the .ssh folder containing the following content:</p> <pre><code>Host bitbucket.org IdentityFile ~/.ssh/id_dsa </code></pre> <p>I did so, but as soon as I provide that file I can no longer clone the repository from bitbucket. Not even directly from the server, getting the same error message as shown above.</p> <p>Did anyone manage to make this setup work? I also read the following thread here on stackoverflow that was of no use to me: <a href="http://stackoverflow.com/questions/6323434/how-do-i-set-a-private-ssh-key-for-hudson-jenkins-to-access-bitbucket">How do i set a private ssh key for hudson / jenkins to access bitbucket?</a> and I checked that tomcat really runs under user tomcat6 by creating an empty test project that simply runs "whoami". So I am pretty much out of ideas for fixing the problem.</p>
31,326,213
0
<p>Pass all the arguments with <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply" rel="nofollow"><code>.apply</code></a> and <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments" rel="nofollow"><code>arguments</code></a>:</p> <pre><code>function delegate(func) { var args = [].slice.call(arguments, 1); return func.apply(this, args); } </code></pre> <p>Demo: <a href="http://jsfiddle.net/DerekL/8xkhrtg7/" rel="nofollow">http://jsfiddle.net/DerekL/8xkhrtg7/</a></p>
34,135,545
0
Connection refuse Watir webdriver with phantomjs <p>I have a problem with Watir gem that is running in threads. Basically it looks like this: I am creating threads (let's say there are three of them). Then I am creating new browser, visiting web pages and trying to close this browser. Everything works fine for like 2-3 hours, then I am getting this error (browser.close is causing this): </p> <pre><code>Errno::ECONNREFUSED: Connection refused - Connection refused initialize at org/jruby/ext/socket/RubyTCPSocket.java:124 open at org/jruby/RubyIO.java:1123 block in connect at /home/ubuntu/.rvm/rubies/jruby-9.0.4.0/lib/ruby/stdlib/net/http.rb:883 timeout at org/jruby/ext/timeout/Timeout.java:128 connect at /home/ubuntu/.rvm/rubies/jruby-9.0.4.0/lib/ruby/stdlib/net/http.rb:882 do_start at /home/ubuntu/.rvm/rubies/jruby-9.0.4.0/lib/ruby/stdlib/net/http.rb:867 start at /home/ubuntu/.rvm/rubies/jruby-9.0.4.0/lib/ruby/stdlib/net/http.rb:856 start at /home/ubuntu/.rvm/rubies/jruby-9.0.4.0/lib/ruby/stdlib/net/http.rb:583 stop at /home/ubuntu/.rvm/gems/jruby-9.0.4.0/gems/selenium-webdriver-2.48.1/lib/selenium/webdriver/phantomjs/service.rb:75 quit at /home/ubuntu/.rvm/gems/jruby-9.0.4.0/gems/selenium-webdriver-2.48.1/lib/selenium/webdriver/phantomjs/bridge.rb:73 quit at /home/ubuntu/.rvm/gems/jruby-9.0.4.0/gems/selenium-webdriver-2.48.1/lib/selenium/webdriver/common/driver.rb:171 close at /home/ubuntu/.rvm/gems/jruby-9.0.4.0/gems/watir-webdriver-0.9.1/lib/watir-webdriver/browser.rb:136 </code></pre> <p>And this is the code:</p> <pre><code>THREAD_COUNT.times.map { Thread.new(links) do |links| while link = mutex.synchronize { links.pop } counter = 0 sleep(rand 1..50) browser = Watir::Browser.new :phantomjs, :args =&gt; %w(--ssl-protocol=tlsv1 --ignore-ssl-errors=yes) begin result = function(browser) rescue counter += 1 retry if counter &gt; 2 end browser.close end end }.each(&amp;:join) </code></pre> <p>I am running this on ubuntu and jruby 9.0.4.0 As suggested here, I added sleep <a href="http://stackoverflow.com/questions/26859919/opening-several-threads-with-watir-webdriver-results-in-connection-refused-err">Opening several threads with watir-webdriver results in &#39;Connection refused&#39; error</a> But it's not working</p>
13,927,364
0
WPF textbox with image <p>I'm doing a WPF login interface. In my login panel, I have one login <code>TextBox</code> and a <code>PasswordBox</code>. As what shown in the first image below, there is a little human logo in the login textbox and a lock in the password box. I set the image into the textbox background, and then when i try to insert some word into the login box, the words will overide the human logo(image B). Any advice to make it right?</p> <p>My XAML:</p> <pre><code> &lt;TextBox Width="380" Height="25" HorizontalAlignment="Center" Foreground="WhiteSmoke" BorderBrush="Transparent" &gt; &lt;TextBox.Background&gt; &lt;ImageBrush ImageSource="/icon/user_login.png" AlignmentX="Left" Stretch="None"&gt;&lt;/ImageBrush&gt; &lt;/TextBox.Background&gt; &lt;/TextBox&gt; </code></pre> <p>Image A:</p> <p><img src="https://i.stack.imgur.com/IzKP1.jpg" alt="enter image description here"></p> <p>Image B:</p> <p><img src="https://i.stack.imgur.com/4iyFe.jpg" alt="enter image description here"></p>
9,966,782
0
<p>No, there is no way to access anonymous classes from anywhere, except from inside them (i.e. otherwise than by <code>this</code> reference). Or by an explicitly declared variable.</p> <pre><code>final Runnable r1 = new Runnable() {...}; Runnable r2 = new Runnable() { public void run() { synchronized(r1) {...} } }; </code></pre>
27,659,445
0
<p>You have misspelled method-signature:</p> <pre><code>&lt;cc:attribute name="goToLastPage" method-signtature="java.lang.String action()" required="true"/&gt; </code></pre>
38,498,956
0
<p>Try running Windows Update which will installing/fix any missing files</p> <p><a href="https://answers.unrealengine.com/questions/322203/vs2015-prerequisites-failed-to-install.html" rel="nofollow">VS2015 Prerequisites failed to install</a></p>
19,787,046
0
<p>Check that you've specified TokenCell as the custom class for your UITableView cells:</p> <p>(Here are 2 images to illustrate - I can't show inline images as I am new to StackOverflow!)</p> <p><a href="http://i.stack.imgur.com/tNpo4.png" rel="nofollow">1. image - highlight the cell in your Main.storyboard</a></p> <p><a href="http://i.stack.imgur.com/IVzrt.png" rel="nofollow">2. image - set the class to TokenCell, then save</a></p>
30,729,325
0
<p>Consider the following query to solve your problem:</p> <pre><code>SELECT COUNT(*) AS `count` FROM test t WHERE `date` &lt; '2015-01-05' AND allocation = 'Same'; </code></pre> <p>Let's assume that the given date is '2015-01-05'. The idea here is to select all dates that are less than '2015-01-05' which means its previous days. Since allocation must be 'Same' so it's also included in condition section of statement.</p>
37,757,795
0
<p>Use the id of the select and jquery to populate an array. Like the following</p> <pre><code>var arr=new Array(); $("#dropdwonid option").each(function() { arr.push($(this).text()); }); </code></pre>
24,701,101
1
Run MRJob from IPython notebook <p>I'm trying to run mrjob example from IPython notebook</p> <pre><code>from mrjob.job import MRJob class MRWordFrequencyCount(MRJob): def mapper(self, _, line): yield "chars", len(line) yield "words", len(line.split()) yield "lines", 1 def reducer(self, key, values): yield key, sum(values) </code></pre> <p>then run it with code</p> <pre><code>mr_job = MRWordFrequencyCount(args=["testfile.txt"]) with mr_job.make_runner() as runner: runner.run() for line in runner.stream_output(): key, value = mr_job.parse_output_line(line) print key, value </code></pre> <p>and getting the error:</p> <pre><code>TypeError: &lt;module '__main__' (built-in)&gt; is a built-in class </code></pre> <p>Is there way to run mrjob from IPython notebook?</p>
5,251,115
0
<p>A couple of comments regarding the OP's analysis:</p> <p>I'm assuming you have already constructed your treemaps/sets and are just extracting elements from the finished (preprocessed) in-memory representation. </p> <p>Let's say <em>n</em> is the number of genres. Let's say <em>m</em> is the max number of games per genre.</p> <p>The complexity of getting the right 'genre map' is <code>O(lg n)</code> (a single <code>get</code> for the supertree). The complexity of iterating over the games in that genre depends on how you do it:</p> <pre><code> for (GameRef g : submap.keySet()) { // do something with supermap.get(g) } </code></pre> <p>This code yields <code>O(m)</code> 'get' operations of <code>O(lg m)</code> complexity each, so that's <code>O(m lg(m))</code>.</p> <p>If you do this:</p> <pre><code>for (Map.Entry e : submap.entrySet()) { // do something with e.getValue() } </code></pre> <p>then the complexity is <code>O(m)</code> loop iterations with constant <code>(O(1))</code> time access to the value.</p> <p>Using the second map iteration method, your total complexity is <code>O(lg(n) + m)</code></p>
2,081,044
0
<p>This is a jQuery call and it gets called when a document gets loaded.</p> <p>more info at <a href="http://docs.jquery.com/Core/jQuery#callback" rel="nofollow noreferrer">http://docs.jquery.com/Core/jQuery#callback</a></p>
19,200,839
0
<p>I solved my problem by creating a compound border attribute every time I set the border color, like this:</p> <pre><code> change: function(hex) { //console.log(hex + ' - ' + opacity); var curObj = window.curObj; var inner = '#' + $(curObj).attr("id") + ' .object_inner'; $(inner).css('border-color', hex); //hack for chrome to get around htmlpurifier bug dropping border-color defined in rgb on IMG tags. var border_all = $(inner).css('border'); if (border_all == '') { //ff returns empty string so we'll have to uild our own compound object var width = $(inner).css('border-top-width'); var color = $(inner).css('border-top-color'); $(inner).css('border','solid '+width+' ' + color); } else { //but for chrome it is enough to pull the compound out, then set it hard. The browser does the work. $(inner).css('border',border_all); } } </code></pre>
12,713,655
0
<p>I was calling QDialog::destroy() to close the window instead of QDialog::close(). This caused a null pointer exception when Qt was finishing QDialog::exec() and caused a crash on Windows. Changing the call to close() fixed the problem.</p> <p>Thanks HostileFork for the advice</p>