pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
38,237,320
0
Header Troubles on my Website <p>Before I posted anyone question, and I got some criticism, so I'm trying to format a better question now. Yeah. So, I'm making a website, and I have a header for navigation. However, in CSS, I put the header with div class = "header" to color:black;. I don't know why the background isn't black and is not there. I made a jsfiddle. As you can see when you go on the jsfiddle , the header is non-existent, and when you scroll down, as you can see, the header is not white. Does anyone know how to make the header solid, or is there inconsistencies in the hierarchy?</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>.header { position:relative; top:-20px; left:0px; width:100%; background-color:#000000; border-left: 5px solid white; } .header ul li a { color: black; position: fixed; top: 13px; font-weight: bold; text-decoration: none; //background: #000000; } ul { list-style-type: none; } a#strawpoll { right: 215px; } a#previousblogs { right: 95px; } a#aboutme { right: 15px; } h1 { text-align: left; position: fixed; left: 10px; top: -10px; color: black; } body { position: relative; top: 60px; font-family: 'Raleway', sans-serif; background-image: //url('https://cms-images.idgesg.net/images/article/2015/11/black-100630491-orig.jpg'); background-size: cover; color: white; text-align: center; color: black; } a:link { color: black; text-decoration: none; } .header a:hover { text-decoration: underline; } a:visited { color: black; text-decoration: none; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;title&gt;My Blog&lt;/title&gt; &lt;meta charset="utf-8"/&gt; &lt;link rel="stylesheet" type="text/css" href="blog.css"&gt; &lt;link rel="icon" href="http://images4.fanpop.com/image/photos/22600000/Smiley-Face-smiley-faces-22608094-1000-1000.png"&gt; &lt;link href="https://fonts.googleapis.com/css?family=Raleway" rel="stylesheet"&gt; &lt;link type="text/css" rel="stylesheet" href="jquery.mmenu.css" /&gt; &lt;body&gt; &lt;div class="header"&gt; &lt;div class = "navbar"&gt; &lt;ul&gt; &lt;li&gt;&lt;a id = "strawpoll" href ="#"&gt; Strawpoll &lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a id = "previousblogs" href ="#"&gt; Previous Blogs &lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a id = "aboutme" href ="#"&gt; About Me &lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;script src="app.js"&gt;&lt;/script&gt; &lt;h1&gt;&lt;a href ="#"&gt;My Life&lt;/a&gt;&lt;/h1&gt; &lt;/div&gt; &lt;p&gt; texttext, yeah, I put this here to increase the page length, so that I can show you guys the header is not filled in. starting from here its all reandom stuff. &lt;p&gt; bopbopbopbopbopbopbob &lt;/p&gt; &lt;p&gt; bopbopbopbopbopbopbob &lt;/p&gt;&lt;p&gt; bopbopbopbopbopbopbob &lt;/p&gt;&lt;p&gt; bopbopbopbopbopbopbob &lt;/p&gt;&lt;p&gt; bopbopbopbopbopbopbob &lt;/p&gt;&lt;p&gt; bopbopbopbopbopbopbob &lt;/p&gt;&lt;p&gt; bopbopbopbopbopbopbob &lt;/p&gt;&lt;p&gt; bopbopbopbopbopbopbob &lt;/p&gt;&lt;p&gt; bopbopbopbopbopbopbob &lt;/p&gt;&lt;p&gt; bopbopbopbopbopbopbob &lt;p&gt; bopbopbopbopbopbopbob &lt;/p&gt;&lt;p&gt; bopbopbopbopbopbopbob &lt;/p&gt; &lt;/p&gt;&lt;p&gt; bopbopbopbopbopbopbob &lt;/p&gt; sapodksadksa daa &lt;/p&gt;</code></pre> </div> </div> </p> <p>Here is the <a href="https://jsfiddle.net/695y5wjg/3/" rel="nofollow">jsfiddle</a></p> <p>Add in the comments if I'm unclear. Hopefully I am.</p>
6,145,345
0
Complex ARel query <p>I've got a complicated query that I can't wrap my head around (using either sql or ActiveRecord) Here are my models:</p> <pre><code>class Contact has_many :profile_answers end class ProfileAnswer belongs_to :contact belongs_to :profile_question end class ProfileQuestion has_many :profile_answers end </code></pre> <p>I'm trying to find the number of ProfileAnswers for two contacts that have the same <code>value</code> for a particular ProfileQuestion. In other words:</p> <blockquote> <p>Get the total number of profile answers that two contacts have answered with the same value for a particular profile_question</p> </blockquote> <p>I don't want to make multiple queries and filter as I know this is possible with Sql only, i just don't know how to do it</p> <p>I had considered a self join of <code>profile_answers</code> on <code>profile_question_id</code> then filtering by <code>value</code> being equal, but i still can't wrap my head around that. Any help is greatly appreciated.</p>
3,268,493
0
<p>When you build with the DLL version of the CRT (/MDd for example), errno is a macro. Translating it to a function call to obtain the shared value of errno. Fix it like this:</p> <pre><code>int err = errno; </code></pre> <p>so you can inspect the value of err.</p>
5,032,531
0
Why does casting the same two numbers to Object make them not equal? <p>I have following code snippet but I am getting wrong output.</p> <pre><code>class Program { static void Main(string[] args) { var i = 10000; var j = 10000; Console.WriteLine((object) i == (object) j); } } </code></pre> <p><strong>I was expecting true but I am getting false</strong></p>
34,239,560
0
<p>Cygwin is not an isolated environment like for example a virtual machine inside VirtualBox. It works on the same filesystem as other Windows applications. Its files could be accessed through any file manager (e.g: Total Commander), and it can access any other file including your home folder in Windows.</p> <p>Only one thing makes confusion: cygwin uses UNIX-like paths but Windows uses DOS paths. There is a translation method to convert them vica-versa. <a href="https://www.cygwin.com/cygwin-ug-net/cygpath.html" rel="nofollow">cygpath</a> utility can do this translation automatically, but it could be done by head as well. Here is some example:</p> <pre><code>############################################# # converting to Windows path format: ############################################# $ cygpath --windows / C:\cygwin $ cygpath --windows /home C:\cygwin\home $ cygpath --windows /home/username C:\cygwin\home\username $ cygpath --windows /cygdrive/c C:\ ############################################# # converting to Cygwin (UNIX) path format: ############################################# $ cygpath --unix 'C:\Users\username' /cygdrive/c/Users/username $ cygpath --unix 'C:\Windows' /cygdrive/c/Windows $ cygpath --unix 'D:\Games' /cygdrive/d/Games </code></pre>
5,735,389
0
<p>Logically, that copy/paste is exactly what happens. I'm afraid there isn't any more to it. You don't need the <code>;</code>, though.</p> <p>Your specific example is covered by the spec, section <strong>6.10.2 Source file inclusion</strong>, paragraph 3:</p> <blockquote> <p>A preprocessing directive of the form</p> <p><strong><code># include</code></strong> <code>"</code><em>q-char-sequence</em><code>"</code> <em>new-line</em></p> <p>causes the replacement of that directive by the entire contents of the source file identified by the specified sequence between the <code>"</code> delimiters.</p> </blockquote>
14,790,298
0
Set up access control to allow non-registered members to see intro text, but not full text <p>I need to set up ACL permissions on a web site I am developing such that guests can see the intro-text of an article, but cannot see the full-text unless they are registered.</p> <p>The site is using Joomla 3.0.</p> <p>How can I do that?</p>
11,809,582
0
<p>In your Android app, you expect a JSONArray:</p> <pre><code>// store incoming stream in an array JSONArray jArray = new JSONArray(streamToString(instream)); </code></pre> <p>However, in your PHP file you only output multiple separate JSON objects instead of a real array. I think, you should collect all items from the database in an PHP array first and then encode and output it only once.</p> <p>My PHP skills are a bit rusted, but I hope this one will work:</p> <pre><code>//store # of rows returned $num_rows = mysql_num_rows($query); if ($num_rows &gt;= 1) { $output = array(); while($results = mysql_fetch_assoc($query)) { // append row to output $output[] = results } mysql_close(); // shouldn't that be outside the if block? //encode the returned data in JSON format echo json_encode($output); } </code></pre> <p>I would expect the output then to be like this (maybe without indentation):</p> <pre><code>[ {"nid":"1","vid":"1","type":"goal","language":"","title":"test","uid":"1","status":"1","created":"1342894493","changed":"1342894493","comment":"2","promote":"1","moderate":"0","sticky":"1","tnid":"0","translate":"0"}, {"nid":"2","vid":"2","type":"goal","language":"","title":"test2","uid":"1","status":"1","created":"1342894529","changed":"1342894529","comment":"2","promote":"1","moderate":"0","sticky":"1","tnid":"0","translate":"0"}, {"nid":"5","vid":"5","type":"goal","language":"","title":"run","uid":"1","status":"1","created":"1343506987","changed":"1343506987","comment":"2","promote":"1","moderate":"0","sticky":"1","tnid":"0","translate":"0"}, {"nid":"9","vid":"9","type":"goal","language":"","title":"run to the hills","uid":"1","status":"1","created":"1343604338","changed":"1343605100","comment":"2","promote":"0","moderate":"0","sticky":"0","tnid":"0","translate":"0"} ] </code></pre>
29,279,147
0
<p>I would probably choose not to do it this way, but a deferred/promise can indeed be used as a queuing device.</p> <p>You need a slight(?) variation of what you already tried.</p> <pre><code>self.queue = $.when();//A resolved promise, used to form a queue of functions in a .then() chain. self.save = function(data) { var dfrd = $.Deferred();//A Deferred dedicated to this particular save. self.queue = self.queue.then(function() { return $.post("/example_save_endpoint", data) //Make the AJAX call, and return a jqXHR to ensure the downstream queue waits for this jqXHR to resolve/reject. .then(dfrd.resolve, dfrd.reject) //Resolve/reject the Deferred for the caller's benefit .then(null, function() { //Force failure down the success path to ensure the queue is not killed by an AJAX failure. return $.when();//Return a resolved promsie, for the queue's benefit. }); }); return dfrd.promise();//allow the caller to do something when the AJAX eventually responds } </code></pre> <p><em>For explanation, see comments in code</em></p>
36,190,743
0
<p>RecyclerView setLayoutManager expects RecyclerView.LayoutManager type as input so change</p> <pre><code>final LinearLayoutManager layoutManager = new LinearLayoutManager(this); </code></pre> <p>with</p> <pre><code>final RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this); </code></pre> <p>and remove </p> <pre><code>layoutManager.setOrientation(LinearLayoutManager.VERTICAL); layoutManager.generateDefaultLayoutParams(); </code></pre> <p>take a look at developer page for proper usage <a href="http://developer.android.com/training/material/lists-cards.html" rel="nofollow">http://developer.android.com/training/material/lists-cards.html</a></p>
38,716,459
0
Make a variable unusable/unaccessible in scope halfway <p>Let's say I have this code:</p> <pre><code>for (int i = 0; i &lt; x.size(); i++) { auto &amp;in = input[i]; auto &amp;func = functions[i]; auto &amp;out = output[i]; // pseudo-code from here: unaccessiable(i); i = func(in); // error, i is not declared out = func(i); // error, i is not declared // useful when you mistake in/out for i } </code></pre> <p>I need to achieve effect that a variable is not accessible or usable after a certain line in the code. (in this code, after the <code>unaccessiable(i)</code>) Specifically I want to disable the iterator of a for's loop.</p> <p>NOTE: This is only for code correctness, and nothing beyond that. So lambdas (non-compile-time solutions) are just performance hindering.</p>
11,511,701
0
Notify a User if Exception happens not in Activity class <p>My <code>Activity</code> holds a member <code>member_one</code> which holds another member <code>member_two</code> which can throw an <code>Exception</code>. I need to show user a <code>Toast</code> if this <code>Exception</code> happens. In order to show a <code>Toast</code> I need to throw <code>Exception</code> from <code>member_tow</code> to <code>member_one</code> and then from <code>member_one</code> to my <code>Activity</code>. This approach leads to big changes and I don't want to do so. May be I just think wrong, is there any easy way to handle the exception?</p>
2,493,329
0
<p>Regression Testing. Partly automated, partly manual, depending on the tools, time and money.</p> <p>Normally you should different levels of testing, and even though as software developers we would like to automate everything, some things have to be verified by hand, by having a collection of test cases executed by testers.</p> <p><a href="http://en.wikipedia.org/wiki/Regression_testing" rel="nofollow noreferrer">The Wikipedia article on regression testing is a good read</a>.</p> <p>From the whole collection of tests that most be checked by hand, it is normally worthwhile to select the minimum set that guarantee the functionality of the system to reduce costs. The balance, of course, is a fine one and depends a lot on how much the code was actually changed. Good modularization of the software product helps a lot on having good regression testing.</p>
23,266,215
0
<p>The solutions depends on the level of interaction you want that "toggle" to happen.</p> <p>If you want to achieve this toggle for every user on its own, you're good to go with sessions.</p> <p>If you want to have the toggle application-wide (every user toggles one single value) you'll have to use any kind of persistence layer (e.g. a database, a file) to store the current state of you <code>$i</code> value in it.</p>
39,947,263
0
<p>You should use a framework to help you, as well as possibly use a template that is built with these frameworks. </p> <p><a href="http://materializecss.com/" rel="nofollow">http://materializecss.com/</a></p> <p><a href="https://templateflip.com/material-design-html5-templates-free-download/" rel="nofollow">https://templateflip.com/material-design-html5-templates-free-download/</a></p> <p>You will learn a lot!</p>
11,809,636
0
<p>You have an empty string for an <code>href</code> on the overview link. So, it's attempting to "follow" to that <code>href</code>, which obviously doesn't exist.</p>
31,696,229
0
Required Appropriate query to find out the result <p>I need a desired result with the less number of execution time. I have a table which contains many rows (over 100k) , in this table a field name is notes varchar2(1800). It contains following values:</p> <pre><code>notes CASE Transfer Surnames AAA : BBBB Case Status ACCOUNT TXFERRED TO BORROWERS Completed Date 25/09/2022 Task Group 16 Message sent at 12/10/2012 11:11:21 Sender : [email protected] Recipient : [email protected] Received : 21:31 12/12/2002 </code></pre> <p>Rows should return with the values of(ACCOUNT TXFERRED TO BORROWERS).</p> <p>I have used the following queries but it takes a long time(72150436 sec) to execute:</p> <ol> <li><p><code>Select * from cps_case_history where (dbms_lob.instr(notes, 'ACCOUNT TFR TO UFSS') &gt; 1)</code></p></li> <li><p><code>Select * from cps_case_history where notes like '%ACCOUNT TFR TO UFSS%'</code></p></li> </ol> <p>Could you please share us the exact query which will take less time to execute.</p>
4,780,462
0
MVVM and SettingsBase <p>Hi i'm currently implement MVVM in a WPF app i'm developing. I implemented the ViewModel and the Views by using 2 separate projects. Only the View is referencing from the ViewModel. However, i've come to a point where i need the information in the Settings class(auto generated by Visual Studio using the Settings dialogue in the Project's Properties) to the ViewModel. How do i do that since ViewModel shouldn't reference the View's classes and also Settings class has a internal modifier. </p> <p>need your suggestions on this one...i'm using mvvm-light which has the Locator pattern..</p> <p>thanks</p>
34,576,192
0
Find similar folder names recursively in bash <p>How could I find similar folder names recursively in bash command line? </p> <p>I don't know specific name, I want all similar folders grouped by similarity. In other words, I need the bash to search each one by all folder names.</p> <p>I use bash in OS X terminal.</p> <p>Similar folder means: folders which have at least one same word. For example, below folder names:</p> <p>"Example"</p> <p>"John Example"</p> <p>"Example (200)"</p> <p>"12 Example"</p>
9,775,020
0
Black lines missing in the box holding the axes of a MATLAB plot <p>When plotting on a figure in MATLAB, I have noticed that parts of the black box that holds the axes are missing (the left and bottom one):</p> <p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <img src="https://i.stack.imgur.com/mNHJj.png" alt="enter image description here"></p> <p>I have tried issuing:</p> <pre><code>box off box on </code></pre> <p>commands with no success. Do you know what I can do to get the corresponding black lines on the axes?</p> <h2>Note:</h2> <p>I am using the OpenGL renderer:</p> <pre><code>set(0,'DefaultFigureRenderer','opengl'); </code></pre>
39,938,019
0
<p>This technique is usually used for multiple axis in a figure. In this context it is often required to have a colorbar <strong>that corresponds in size with the result from imshow.</strong> This can be achieved easily with the <a href="http://matplotlib.org/1.4.3/mpl_toolkits/axes_grid/index.html" rel="nofollow noreferrer">axes grid</a> tool kit:</p> <pre><code>import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.axes_grid1 import make_axes_locatable data = np.arange(100, 0, -1).reshape(10, 10) fig, ax = plt.subplots() divider = make_axes_locatable(ax) cax = divider.append_axes('right', size='5%', pad=0.05) im = ax.imshow(data, cmap='bone') fig.colorbar(im, cax=cax, orientation='vertical') plt.show() </code></pre> <p><a href="https://i.stack.imgur.com/Ec3b9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ec3b9.png" alt="Image with proper colorbar in size"></a></p>
26,776,278
0
<p>If you want you can just focus using jquery</p> <pre><code>$('#insertform input').first().focus(); </code></pre>
15,437,939
0
<p>Your string has backslashes which are read in Python as escape codes. These are when a character preceded by a backslash is changed into a special character. For example, <code>\n</code> is a newline. You will need to either escape them (with another backslash) or just use a raw string.</p> <pre><code>r'C:\Software\api\render\3bit\sim&gt;' </code></pre>
4,882,084
0
<pre><code>Answer.update_all(["user_id = ?", @user.id], ["answered_by = ? and user_id == ?", @user.email, 0]) </code></pre>
38,072,830
1
ImportError: No module named Npp when using Python plugins for Notepad++, <p>while writing a Python-based script in Notepad++, which converts the encoding for a large number of CSV files, I encountered a hiccup early in the entire process - I am always returned the following error</p> <p><strong>ImportError: No module named Npp</strong></p> <p>This occurs when I use the <strong>Execute</strong> (F6) command in NppExec &amp; <strong>Run File in Python Interactive</strong> command in PyNPP. I already set the Run, Execute &amp; other commands to be -</p> <p><em>cd C:\Python27 python "C:\Users\XYZ\AppData\Roaming\Notepad++\plugins\config\PythonScript\scripts\fin.py"</em></p> <p>Further, when I click by the following process, Plugins > Python Script > Scripts > fin, nothing happens at all. Would really appreciate any help I get on this matter! Thanks in advance.</p>
30,383,240
0
How to rename list of Excel sheets with a list of names <p>I need to create profiles for a large list of clients. Each client has an ID number and I need to create a sheet in a workbook for each client, with the ID number for each client as the name for their respective sheets. I also have a sheet template that I would rather use to help create profiles in a uniform and professional manner. My question is: is there a way I can create a copy of the template for each of my clients and rename them with each of the ID's on my list, all at once?</p>
3,915,637
0
<p>Do yourself a favour and buy another 2Gb RAM. I'm running the 32 bit kernel (i.e. the smaller one) right now on my MBP and the kernel itself has 800Mb RAM wired. For you that would leave 1.2Gb in total for everything else. That's not enough. Believe me, if you buy the extra RAM, not only will your Java process be better, but <em>everything</em> will seem much snappier.</p>
35,725,481
0
Display custom taxonomy in DESC within the original loop <p>I have a problem. I would like the have the posts of this loop show in descending order. But for a plugin I have to stick to the original loop. So I can't use new WP_Query or query_posts because this overrides the original loop.</p> <p>This is my loop.</p> <pre><code>&lt;div id="main-filter"&gt; &lt;!-- Start the Loop. --&gt; &lt;?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?&gt; &lt;!-- Test if the current post is in category 3. --&gt; &lt;!-- If it is, the div box is given the CSS class "post-cat-three". --&gt; &lt;!-- Otherwise, the div box is given the CSS class "post". --&gt; &lt;?php if ( in_category( '3' ) ) : ?&gt; &lt;div class="post-cat-three"&gt; &lt;?php else : ?&gt; &lt;div class="post post-item"&gt; &lt;?php endif; ?&gt; &lt;!-- Display the Title as a link to the Post's permalink. --&gt; &lt;div class="ref-wrap"&gt; &lt;div class="col-sm-2 thumb-mobile"&gt; &lt;?php the_post_thumbnail(array(200,200)); // Declare pixel size you need inside the array ?&gt; &lt;/div&gt; &lt;div class="col-sm-10"&gt; &lt;div class="entry"&gt; &lt;?php $bedrijf = get_field('naam_bedrijf'); ?&gt; &lt;?php $feest = get_field('feest'); ?&gt; &lt;?php $geschreven = get_field('geschreven_door'); ?&gt; &lt;?php $datum = get_field('datum_referentie'); ?&gt; &lt;?php $tekst = get_field('volledige_tekst'); ?&gt; &lt;?php $link = get_field('mylink'); ?&gt; &lt;?php echo '&lt;p&gt;Bedrijfsnaam: ' . $bedrijf . '&lt;/p&gt;'; ?&gt; &lt;?php $post_object = get_field('mylink'); if( $post_object ): $post = $post_object; setup_postdata( $post ); ?&gt; &lt;p&gt;Feest type: &lt;a style="color:#ff6600" href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/p&gt; &lt;?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?&gt; &lt;?php endif; ?&gt; &lt;?php echo '&lt;p&gt;Naam: ' . $geschreven . '&lt;/p&gt;'; ?&gt; &lt;?php echo '&lt;p&gt;Datum: ' . $datum . '&lt;/p&gt;'; ?&gt; &lt;?php echo '&lt;p class="mobile-j"&gt;' . $tekst . '&lt;/p&gt;'; ?&gt; &lt;?php echo '&lt;p&gt;' . wp_review_show_total() . '&lt;/p&gt;'; ?&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div style="clear:both;"&gt;&lt;/div&gt; &lt;!-- Display a comma separated list of the Post's Categories. --&gt; &lt;/div&gt; &lt;!-- closes the first div box --&gt; &lt;!-- Stop The Loop (but note the "else:" - see next line). --&gt; &lt;?php endwhile; else : ?&gt; &lt;!-- The very first "if" tested to see if there were any Posts to --&gt; &lt;!-- display. This "else" part tells what do if there weren't any. --&gt; &lt;p&gt;&lt;?php _e( 'Sorry, no posts matched your criteria.' ); ?&gt;&lt;/p&gt; &lt;!-- REALLY stop The Loop. --&gt; &lt;?php endif; ?&gt; &lt;?php wp_pagenavi(); ?&gt; &lt;/div&gt; </code></pre> <p>Is there anyway I can order this loop in DESC?</p> <p>** Little edit: I don't know if this matters but this is the custom taxonomy: referentie_type</p>
29,501,967
0
<p>You forgot to put the <code>END</code> delimiter</p> <pre><code>DELIMITER @ CREATE EVENT update_stats ON SCHEDULE EVERY 15 MINUTE ON COMPLETION PRESERVE ENABLE DO BEGIN UPDATE stats JOIN temp_stats ON stats.unique_key = temp_stats.unique_key SET stats.clicks = stats.clicks + temp_stats.clicks; TRUNCATE temp_stats; END@ DELIMITER ; </code></pre>
394,146
0
Displaying polymorphic classes <p>I have an existing app with a command-line interface that I'm adding a GUI to. One situation that often comes up is that I have a list of objects that inherit from one class, and need to be displayed in a list, but each subclass has a slightly different way of being displayed.</p> <p>Not wanting to have giant switch statements everywhere using reflection/RTTI to do the displaying, each class knows how to return its own summary string which then gets displayed in the list:</p> <pre><code>int position = 0; for (vector&lt;DisplayableObject&gt;::const_iterator iDisp = listToDisplay.begin(); iDisp != listToDisplay.end(); ++iDisp) cout &lt;&lt; ++position &lt;&lt; ". " &lt;&lt; iDisp-&gt;GetSummary(); </code></pre> <p>Similar functions are there to display different information in different contexts. This was all fine and good until we needed to add a GUI. A string is no longer sufficient - I need to create graphical controls.</p> <p>I don't want to have to modify every single class to be able to display it in a GUI - especially since there is at least one more GUI platform we will want to move this to.</p> <p>Is there some kind of technique I can use to separate this GUI code out of the data objects without resorting to RTTI and switch statements? It would be nice to be able to take out the GetSummary functions as well.</p> <p>Ideally I'd be able to have a heierarchy of display classes that could take a data class and display it based on the runtime type instead of the compile time type:</p> <pre><code>shared_ptr&lt;Displayer&gt; displayer = new ConsoleDisplayer(); // or new GUIDisplayer() for (vector&lt;DisplayableObject&gt;::const_iterator iDisp = listToDisplay.begin(); iDisp != listToDisplay.end(); ++iDisp) displayer-&gt;Display(*iDisp); </code></pre>
39,959,947
0
Count truthy objects in an array <p>I'd like to count truthy objects in an array. Since I can pass a block to count, the most idiomatic way I found was this:</p> <pre><code>[1, nil, 'foo', false, true].count{ |i| i } =&gt; 3 </code></pre> <p>But I was wondering if there was a better way, especially using the syntax <code>count(&amp;:something)</code>, because passing a full block here looks like overkill to me.</p> <p>AFAIK, there is no <code>truthy?</code> method in Ruby, so I couldn't find how to achieve this.</p>
10,159,652
0
default argument function signature change <p>I have a function whose current signature is f(a,b=0). I want to add another argument c. I want my function in such a way so that I can call f(a,b) which is currently the behavior and f(a,c). One way is to overload the function and duplicate the function code. I do not want to call f(a,b) from f(a,c). I am working in C++.</p> <p>Is there any standard design pattern or a solution which can avoid this code duplication ?</p>
20,040,647
0
Android Widget Programming <p>I have 4 different types of widgets in my app. For each of the widget type, I have a Class derived from AppWidgetProvider and a service which handles the periodic update to the widget.</p> <p>Now I have to create different sizes widget for each type. If I keep 3 sizes for each widget, do I have to create 12 classes / services ? Is there a better way ?</p> <p>Any help / link to sample is welcome thanks in advance</p>
28,228,735
0
Launching activity from shortcut always launches main activity also <p>I have built an app which changes the users wallpaper. I wish to add an Android shortcut so a user can change their wallpaper without having to fully open the app (the main use case is to tie it to a gesture in something like Nova Launcher, which allows you to select a shortcut for each gesture).</p> <p>I have it all working, with one massive issue. Every time the shortcut is fired, my custom action occurs, but then the main launch activity ALSO launches! This is obviously not desired, and I cannot figure out what is going on.</p> <p>Here is the ShortcutActivity code: </p> <pre><code>public class ShortcutActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Intent intent = getIntent(); final String action = intent.getAction(); if (Intent.ACTION_CREATE_SHORTCUT.equals(action)) { setupShortcut(); finish(); return; } else { Toast.makeText(this, "Do something interesting.", Toast.LENGTH_SHORT).show(); finish(); } } void setupShortcut() { Intent shortcutIntent = new Intent("CHANGE"); shortcutIntent.setClass(this, getClass()); Intent intent = new Intent(); intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.shortcut_title)); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); Parcelable iconResource = Intent.ShortcutIconResource.fromContext(this, R.drawable.ic_launcher); intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource); setResult(RESULT_OK, intent); } } </code></pre> <p>Here is my (simplified) manifest:</p> <pre><code>&lt;application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/title_activity" android:theme="@style/AppTheme"&gt; &lt;activity android:name=".WallpaperSettings" android:label="@string/title_activity_wallpaper_settings"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;activity android:name=".ShortcutActivity" android:theme="@android:style/Theme.NoDisplay" android:label="@string/shortcut_title"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.CREATE_SHORTCUT" /&gt; &lt;category android:name="android.intent.category.DEFAULT" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;/application&gt; </code></pre> <p>Is this even possible to do without trigger the main launcher activity?</p>
18,834,610
0
<p>As @zapl mentioned, only 4 to 5 times slower is about what you should expect in the first place. However, there are things to optimize:</p> <ol> <li><p>You could benchmark the 'pain' loop codeblock, and rewrite than in NEON. NEON <strong>intrinsics</strong> should be about 2-4 times faster than unoptimized c/c++ code. NEON <strong>assembly</strong> is often faster than <strong>intrinsics</strong>, but harder to write.</p></li> <li><p>Use the latest GCC 4.7 and enable GCC's 'loop unroll' and 'loop vectorization' (not 100% sure GCC does implement loop vectorization for the ARM platform).</p></li> <li><p>Use multi-threading (C++11). Almost all mobile processors have multiple cores. Running on four cores is about 2-3.5 times faster than running on a single core.</p></li> <li><p>Help the CPU's branch predictor make better judgement on what to process next, by moving if-statements outside of loops. </p></li> </ol> <p>For example:</p> <pre><code>for(int i = 0; i &lt; total; i++) { if (i &lt; middle) // first part else // second part } </code></pre> <p>Replace by:</p> <pre><code>for(int i = 0; i &lt; middle; i++) // first part for(int i = middle; i &lt; total; i++) // second part </code></pre>
39,732,169
0
<p>Does the compiler really let you assign <code>object</code> to <code>Customer</code> without a cast? </p> <p>Anyway, <code>DataContext</code> won't be initialized yet in the constructor. </p> <p>You could handle the <code>DataContextChanged</code> event, which will be raised whenever <code>DataContext</code> changes -- in this case, that'll probably just be when it's assigned in the course of instantiating the <code>DataTemplate</code> that creates <code>MyUserControl</code>. And that's just what you want. </p> <p>XAML</p> <pre><code>&lt;UserControl ... DataContextChanged="MyUserControl_DataContextChanged" ... </code></pre> <p>C#</p> <pre><code>private Customer _customer; void MyUserControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { _customer = (Customer)DataContext; } </code></pre> <p>Or you could just cast <code>DataContext</code> to <code>Customer</code> whenever you need to use it. Check for <code>null</code>, of course. You didn't say what you're doing with <code>Customer</code> so it's hard to be sure when you would need to do something with it. </p>
40,248,292
0
<p>Try the appropriately named <code>array_reverse</code> function!</p> <pre><code>&lt;?php if(function_exists('fetch_feed')) { include_once(ABSPATH . WPINC . '/feed.php'); // include the required file $feed = fetch_feed('http://sample.com.au/events/feed/'); // specify the source feed $limit = $feed-&gt;get_item_quantity(25); // specify number of items $items = $feed-&gt;get_items(0, $limit); // create an array of items $semti = array_reverse($items); // &amp; flip it } if ($limit == 0) echo '&lt;div&gt;The feed is unavailable.&lt;/div&gt;'; else foreach ($semti as $item) : ?&gt; &lt;p&gt;&lt;b&gt;&lt;a href="&lt;?php echo esc_url( $item-&gt;get_permalink() ); ?&gt;" target="_blank"&gt; &lt;?php echo esc_html( $item-&gt;get_title() ); ?&gt;&lt;/a&gt;&lt;/b&gt; &lt;?php echo esc_html( $item-&gt;get_date('| j F | g:i a') ); ?&gt;&lt;br&gt; &lt;?php echo sanitize_text_field( $item-&gt;get_content() ); ?&gt; &lt;/p&gt; &lt;?php endforeach; ?&gt; </code></pre> <p><a href="http://php.net/manual/en/function.array-reverse.php" rel="nofollow">From PHP.net</a>:</p> <blockquote> <h3>array_reverse</h3> <p>Return an array with elements in reverse order</p> <p><code>array array_reverse ( array $array [, bool $preserve_keys = false ] )</code></p> <p>Takes an input array and returns a new array with the order of the elements reversed.</p> </blockquote>
18,307,197
0
<p>Actually, I made it to solve the problem. Whoever uses backbone, node.js, and require.js, remember to include jquery and jquery UI as libraries with require, and when creating dynamic elements with backbone such as:</p> <pre><code>$('#content').append(html); inside backbone call jquery UI $('.drag').draggable(); </code></pre>
30,947,492
0
<p>I totally agree with @Holden on that! </p> <p>Mocking RDDS is difficult; executing your unit tests in a local Spark context is preferred, as recommended in the <a href="http://spark.apache.org/docs/latest/programming-guide.html#unit-testing">programming guide</a>.</p> <p>I know this may not technically be a unit test, but it is hopefully close enough. </p> <blockquote> <p><strong>Unit Testing</strong></p> <p>Spark is friendly to unit testing with any popular unit test framework. Simply create a SparkContext in your test with the master URL set to local, run your operations, and then call SparkContext.stop() to tear it down. Make sure you stop the context within a finally block or the test framework’s tearDown method, as Spark does not support two contexts running concurrently in the same program.</p> </blockquote> <p>But if you are really interested and you still want to try mocking RDDs, I'll suggest that you read the <a href="https://github.com/apache/spark/blob/3c0156899dc1ec1f7dfe6d7c8af47fa6dc7d00bf/core/src/test/scala/org/apache/sparktest/ImplicitSuite.scala">ImplicitSuite</a> test code.</p> <p>The only reason they are pseudo-mocking the RDD is to test if <code>implict</code> works well with the compiler, but they don't actually need a real RDD.</p> <pre><code>def mockRDD[T]: org.apache.spark.rdd.RDD[T] = null </code></pre> <p>And it's not even a real mock. It just creates a null object of type RDD[T]</p>
29,636,020
0
<p>I have recently installed Chef Server 12 on Ubuntu 14.04.2 and could launch the Chef Management Console too (unfortunately i was stuck with some other issue so couldn't proceed further on this). </p> <p>You may refer this <a href="https://www.digitalocean.com/community/tutorials/how-to-set-up-a-chef-12-configuration-management-system-on-ubuntu-14-04-servers" rel="nofollow">link</a> for detailed steps. </p>
2,659,755
0
<p>Implement your own printf (on top of vsnprintf to take care of the dirty details) that writes to the console:</p> <pre><code>#include &lt;stdarg.h&gt; int printf(const char *fmt, ...) { char buffer[LARGESIZE]; int rv; va_list ap; va_start(ap, fmt); rv = vsnprintf(buffer, sizeof(buffer), fmt, ap); va_end(ap); Console.WriteLine(buffer); return rv; } </code></pre>
10,146,804
0
How to close a jframe without closing the main program? <p>i designed java desktop application in that application when i press a button another Jframe is shown that draws a tree but when i close the Jframe whole operation is close but i only want to close that Jfarme what should i do? here is the jframe codes:</p> <pre><code>public class DrawTree extends JFrame{ public int XDIM, YDIM; public Graphics display; @Override public void paint(Graphics g) {} // override method // constructor sets window dimensions public DrawTree(int x, int y) { XDIM = x; YDIM = y; this.setBounds(0,0,XDIM,YDIM); this.setVisible(false); this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); display = this.getGraphics(); // draw static background as a black rectangle display.setColor(Color.black); display.fillRect(0,0,x,y); display.setColor(Color.red); try{Thread.sleep(500);} catch(Exception e) {} // Synch with system } // drawingwindow public static int depth(BinaryNode N) // find max depth of tree { if (N==null) return 0; int l = depth(N.left); int r = depth(N.right); if (l&gt;r) return l+1; else return r+1; } // internal vars used by drawtree routines: private int bheight = 50; // branch height private int yoff = 30; // static y-offset // l is level, lb,rb are the bounds (position of left and right child) private void drawnode(BinaryNode N,int l, int lb, int rb) { if (N==null) return; try{Thread.sleep(100);} catch(Exception e) {} // slow down display.setColor(Color.green); display.fillOval(((lb+rb)/2)-10,yoff+(l*bheight),20,20); display.setColor(Color.red); display.drawString(N.element+"",((lb+rb)/2)-5,yoff+15+(l*bheight)); display.setColor(Color.blue); // draw branches if (N.left!=null) { display.drawLine((lb+rb)/2,yoff+10+(l*bheight),((3*lb+rb)/4),yoff+(l*bheight+bheight)); drawnode(N.left,l+1,lb,(lb+rb)/2); } if (N.right!=null) { display.drawLine((lb+rb)/2,yoff+10+(l*bheight),((3*rb+lb)/4),yoff+(l*bheight+bheight)); drawnode(N.right,l+1,(lb+rb)/2,rb); } } // drawnode public void drawtree(BinaryNode T) { if (T==null) return; int d = depth(T); bheight = (YDIM/d); display.setColor(Color.white); display.fillRect(0,0,XDIM,YDIM); // clear background drawnode(T,0,0,XDIM); }} </code></pre> <p>and another question</p> <p>when i new a object from my tree class,i want to access that object in all my button codes so where i should define that or better to say , how i should define that object that can access in all my codes??</p>
11,768,616
0
<p>It would appear that <strong>it does not work</strong>:</p> <pre><code>using System.Runtime.Serialization; using System.IO; using System; namespace ConsoleApplication1 { class Program { static void Main() { IHelloV1 yoyoData = new YoyoData(); var serializer = new DataContractSerializer(typeof(YoyoData)); byte[] bytes; using (var stream = new MemoryStream()) { serializer.WriteObject(stream, yoyoData); stream.Flush(); bytes = stream.ToArray(); } IHelloV1 deserialized; using (var stream = new MemoryStream(bytes)) { deserialized = serializer.ReadObject(stream) as IHelloV1; } if (deserialized != null &amp;&amp; deserialized.Yoyo == yoyoData.Yoyo) { Console.WriteLine("It works."); } else { Console.WriteLine("It doesn't work."); } Console.ReadKey(); } } public interface IHelloV1 { #region Instance Properties [DataMember(Name = "Yoyo")] string Yoyo { get; set; } #endregion } [DataContract(Name = "YoyoData", Namespace = "http://hello.com/1/IHelloV1")] public class YoyoData : IHelloV1 { public string Yoyo { get; set; } public YoyoData() { Yoyo = "whatever"; } } } </code></pre> <p>BUT, if you throw that attribute on the class property instead of the interface property, it does work.</p>
9,176,507
0
<p>Firstly, you'd need unique identifiers for all of your input fields, hidden or not. Then assigning values to them would be a lot easier. You're really close, and I'd only change a few things to get it working, mostly to do with the IDs of the elements you're using:</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function() { $('.auto').autocomplete({ source: "search.php", ... select: function(event, ui) { // figure out which auto we're using and get it's // associated hidden field... var element_id = $(this).attr('id'); var hidden_element_id = element_id + "_hidden"; // set the appropriate fields' values... $(this).val(ui.item.label); $("#"+hidden_element_id).val(ui.item.value); return false; } ... }); }); &lt;/script&gt; &lt;p&gt;Type the name of a band: &lt;input type="text" class="auto" id="auto1" /&gt;&lt;/p&gt; &lt;p&gt;Type the name of a band: &lt;input type="text" class="auto" id="auto2" /&gt;&lt;/p&gt; &lt;input name="hidden" id="auto1_hidden" type="hidden" /&gt; &lt;input name="hidden" id="auto2_hidden" type="hidden" /&gt; </code></pre> <p>One of the easier ways to associate hidden fields with visible counterparts...you get the ID of the element that's currently being autofilled, then grab its hidden field counterpart by just appending '_hidden' onto its ID attribute...make sense?</p> <p>Don't forget to change the ID attributes of the fields! Hope this helps!</p>
13,144,933
0
Form Authentication / Profiles slow on Azure Cloud, fine locally <p>I'm using MVC 4 on Azure, and it loads very slowly (over a minute). Here are the load times of a few pages: <img src="https://i.stack.imgur.com/nzmy3.png" alt="http://i.imgur.com/V4brS.png"> (the 6.9 minutes was when I tried loading 7 tabs with different pages)</p> <p>This problem does not occur when I'm using the Azure emulator, locally. </p> <p>I've tried using an extra large instance, and using remote desktop to run the site locally, and it was just as slow. Also I have tried using IIS Express and normal IIS, and nothing there either.</p> <p>I created a completely fresh MVC project using the "Internet application" template, which includes security, and it is very slow as well, so I'm pretty sure the other things I'm using in my project are not causing the problem. Here are the load times with just the default MVC project: <img src="https://i.stack.imgur.com/YUd25.png" alt="enter image description here"></p> <p>I was originally using separate affinity regions for my membership DB and my website, but I've tried using matching affinity groups on both the blank MVC template with forms authentication and my project.</p> <p>Revisiting pages doesn't improve their speed significantly.</p> <p>I also tried creating just a MVC site without authentication, with a 10x5000 table generated:</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;table&gt; &lt;thead&gt; &lt;tr&gt; @for (int i = 0; i &lt; 10; i++) { &lt;th&gt;@i &lt;/th&gt; } &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; @for(int i = 0; i &lt; 5000; i++) { &lt;tr&gt; @for(int j = 0; j &lt; 10; j++) { &lt;td&gt;Row @i , column @j&lt;/td&gt; } &lt;/tr&gt; } &lt;/tbody&gt; &lt;/table&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>This loads fine, both locally and on the cloud. Even from a cold start it is only ~10-15 seconds.</p> <p>So I'm fairly certain that the issue lies in the Profile/Membership/Authentication of ASP.NET, but only while it is deployed to Azure (since I'm using the same SQL Azure database with Universal Providers when running locally, and there aren't these slowdowns).</p> <p>I expected this problem to be more common, but the only thing that really seemed relevant was this: <a href="http://social.msdn.microsoft.com/Forums/en-US/windowsazuremanagement/thread/7d3323d8-571b-4b8f-9fdb-bd5ccc6c39b7" rel="nofollow noreferrer">social.msdn.microsoft.com/Forums/en-US/windowsazuremanagement/thread/7d3323d8-571b-4b8f-9fdb-bd5ccc6c39b7</a> (possibly this: <a href="http://stackoverflow.com/questions/10791433/saving-changes-very-slow-via-datacontext">stackoverflow.com/questions/10791433/saving-changes-very-slow-via-datacontext</a>)</p> <p>I'm working through the things to try, as suggested in that thread, at: <a href="http://windowsazure.com/en-us/manage/windows/best-practices/" rel="nofollow noreferrer">windowsazure.com/en-us/manage/windows/best-practices/</a></p>
25,078,449
0
<p>Put your FOR loops in two different anonymous blocks, then do a <code>SPOOL OFF</code> followed by <code>SPOOL INV.CSV</code> between them. The first should go to one file and the second to the other.</p>
20,850,329
0
<p>CDF is a framework for managing CSS &amp; JavaScript dependencies and optimizations your web application. It allows for each individual component in your web application to declare what CSS and JavaScript files they require instead of relying on a single master page to include all dependencies for all modules and of course handles all optimizations: minification, compression, caching, and so on....</p> <p>Currently available at <a href="https://github.com/Shandem/ClientDependency" rel="nofollow">github</a></p>
37,767,155
0
<p>But my problem is the order, to copy is ok. i would want to copy that range but before from some sheet and then from others, regarding the name contained in that cell</p>
14,874,100
0
<p>This should work, but beware that it is very <a href="http://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address">simplified</a>:</p> <pre><code>(?:[^&lt;]*&lt;)?([^&gt;]+).* </code></pre> <p>Answer of email will be in <code>$1</code>.</p> <p>For example, in Perl use:</p> <pre><code>$email =~ s/(?:[^&lt;]*&lt;)?([^&gt;]+).*/$1/; </code></pre> <p>See <a href="http://fiddle.re/ub81" rel="nofollow">RegexPlanet online demo</a>.</p>
25,586,073
0
Bcrypt, what is meant salt and cost? <p>I was always using MD5 for encrypting passwords, but I read that it's should no more be used, and instead use bcrypt.. </p> <p>I'm using zendframework 2 , where I found it describing bcrypt configurations as follows:</p> <pre><code>$bcrypt = new Bcrypt(array( 'salt' =&gt; 'random value', 'cost' =&gt; 11 )); </code></pre> <p>what is the salt and what is the cost ? and how could them be used?</p>
36,149,857
0
<p>I assume you have some sort of <code>list</code> of data inside your <code>adapter</code>. If yes, delete the item on the corresponding position of the deleted row.</p> <p>Also, try to call <code>viewHolder.setIsRecyclable(false);</code></p> <p>Your <code>onSwiped</code> should somehow look like this:</p> <pre><code>@Override public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) { // your original stuff here, db deletion etc. // don't forget to delete the data inside the adapter viewHolder.setIsRecyclable(false); adapter.notifyItemRemoved(pos); } </code></pre> <p>According to your comment, you are using <a href="https://gist.github.com/quanturium/46541c81aae2a916e31d" rel="nofollow">this adapter</a>? If so, I think you also need to call <code>swapCursor</code> or <code>changeCursor</code>. Have you seen <a href="http://stackoverflow.com/questions/16937839/android-how-to-requery-a-cursor-to-refresh-listview-after-deleting-database-row">this question</a>?</p> <p>Also, in your question, you are also using <code>adapter.notifyItemRangeChanged</code>, <code>adapter.notifyItemRemoved</code> should be enough.</p>
22,411,466
0
How to read specific node from XML column in stored procedure <p>I am pulling data from a variety of tables in a tsql stored procedure and one of the fields is an XML column. Each child node of this XML has 2 subnodes: Question and Answer. </p> <p>The xml structure looks like this:</p> <p><code>&lt;QuestionXML&gt; &lt;QuestionCollection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt; &lt;Questions&gt; &lt;QuestionModel&gt; &lt;Question&gt;Color&lt;/Question&gt; &lt;Answer&gt;Blue&lt;/Answer&gt; &lt;/QuestionModel&gt; &lt;QuestionModel&gt; &lt;Question&gt;Tall&lt;/Question&gt; &lt;Answer&gt;False&lt;/Answer&gt; &lt;/QuestionModel&gt; &lt;/Questions&gt; &lt;/QuestionCollection&gt; &lt;/QuestionXML&gt;</code></p> <p>I need to find the question node whose name matches the string I pass in, and I would like to retrieve the value of its Answer sibling. </p> <p>Part 1: I would like to use the required XML syntax that is the equivalent of: (SELECT Answer FROM Questions Where Question='Color') AS 'COLOR'</p> <p>Part 2: I would like to select my XML value from an XML column that is the result of a nested SELECT statement.</p> <p>( SELECT Answer</p> <p>FROM (SELECT F.QuestionXML FROM XMLTable F WHERE F.PIN = @PIN) </p> <p>Where Question='Color' ) AS 'COLOR'</p> <p>I am unable to get the XML syntax right.</p> <p>If anyone could get the XML syntax correct for me, I think I can get Part 2 working on my own.</p> <p>Thanks</p>
39,260,486
0
Is it okay to attach async event handler to System.Timers.Timer? <p>I have already read SO post <a href="http://stackoverflow.com/questions/36661338/how-to-call-an-async-method-from-within-elapsedeventhandler">here</a> and article <a href="http://theburningmonk.com/2012/10/c-beware-of-async-void-in-your-code/" rel="nofollow">here</a> I have a timer event that fires every once in a while and i want to do some asynchronous processing inside the handler, so something along the lines of:</p> <pre><code> Timer timer = new Timer(); timer.Interval = 1000; timer.Elapsed += timer_Elapsed; // Please ignore this line. But some answers already given based on this line so I will leave it as it is. timer.Elapsed += async (sender, arguments) =&gt; await timer_Elapsed(sender, arguments); private async Task timer_Elapsed(object sender, ElapsedEventArgs e) { await Task.Delay(10); } </code></pre> <p>The code above compiling and working. </p> <p>But I am not sure why the code is compiling. The <code>ElapsedEventHandler</code> expected signature is </p> <pre><code> void timer_Elapsed(object sender, ElapsedEventArgs e) </code></pre> <p>However my method returns <code>Task</code> instead of <code>void</code> since <code>async void</code> is not recommended. but that does not match with <code>ElapsedEventHandler</code> signature and its still compiling &amp; working?</p> <p>Is it okay to call asyn method on Timer.Elapsed? the code will be executed inside windows service.</p> <p><strong>Update 1</strong> </p> <blockquote> <p>async void is "not recommended", with one very important exception: event handlers.</p> </blockquote> <p>Does it matter if its asynchronous event handler or synchronous event hander? </p> <p>MSDN Article <a href="http://%60https://msdn.microsoft.com/en-us/magazine/jj991977.aspx%60" rel="nofollow">here</a>csays </p> <blockquote> <p>Void-returning async methods have a specific purpose: to make asynchronous event handlers possible.</p> </blockquote> <p>Timer.Elapsed is I think synchronous event handler can I still attach <code>async void</code> to it?</p>
26,789,012
0
<p>Ok, so assuming that my corporate domain name is bar.com, everything seems to route fine as long as all host entries that reference "bar" always followed it with ".com" </p> <p>If I tried to enter <code>foo.bar.net</code> or <code>foo.bar.org</code> or <code>foo.bar.floop</code> as my host, I get "No Response from DNS Server" errors. If I enter <code>foo.bar.com</code> the host resolves. </p> <p>While I received these errors as "Vital Security Proxy Errors", a developer on my team that is helping me test this received Trustwave errors instead. </p> <p>This seems to be something specific to our network security policies.</p>
10,113,767
0
<p>One thing to note is that <code>include</code> will add a second db access to do the preloading. You should check what that one looks like (it should contain a big <code>IN</code> statement on the <code>player_ids</code> from <code>players_to_teams</code>).</p> <p>As for how to avoid using <code>include</code>, if you just need the name from <code>players</code>, you can do it like this: </p> <pre><code>PlayersToTeam.select("players_to_teams.id, players.FirstName AS player_name").joins(:player).limit(10).order("players.FirstName") </code></pre>
10,687,414
0
joomla- js file calling <pre><code>&lt;script type="text/javascript" src="&lt;?php echo $this-&gt;baseurl ?&gt;/templates/eurostar/js/jquery-1.5.min.js" /&gt;&lt;/script&gt; </code></pre> <p>any error?</p> <p>but if I just type <code>&lt;</code> which file automatically closing again and again,</p> <p>Why repeating this closing tag - <code>&lt;/script&gt; &lt;/script&gt; &lt;/script&gt;</code></p>
34,418,139
0
<p>Here's a similar approach, using regular expressions instead:</p> <pre><code>import re def convert_string(s): return map(int, re.findall(r'[0-9]+', s)) </code></pre> <p>Or using a list comprehension:</p> <pre><code>import re def convert_string(s): return [int(num) for num in re.findall(r'[0-9]+', s)] </code></pre> <p>This is a more general approach and will work for any character (in this case '|') that separates the numbers in the input string.</p>
23,104,114
0
Filtering in maven-war-plugin does not exclude directory <p>This is a followup of my yesterday question <a href="http://stackoverflow.com/questions/23082104/conditionally-exclude-some-resources-in-maven-from-war">Conditionally exclude some resources in maven from war</a>. I was able to rearrange both development and production wars but filtering copies a directory <code>properties</code> to the war though it shall be excluded according to <a href="https://maven.apache.org/plugins/maven-war-plugin/examples/adding-filtering-webresources.html" rel="nofollow">documentation</a>. I could use <code>packagingExcludes</code> option, but I wonder why <code>excludes</code> does not work. Thank you for explanation.</p> <pre><code>&lt;plugin&gt; &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt; &lt;configuration&gt; &lt;classifier&gt;dev&lt;/classifier&gt; &lt;webappDirectory&gt;${project.build.directory}/${project.build.finalName}-dev&lt;/webappDirectory&gt; &lt;filters&gt; &lt;filter&gt;${project.basedir}/configurations/properties/config_dev.prop&lt;/filter&gt; &lt;/filters&gt; &lt;webResources&gt; &lt;resource&gt; &lt;directory&gt;configurations&lt;/directory&gt; &lt;filtering&gt;true&lt;/filtering&gt; &lt;targetPath&gt;WEB-INF/classes&lt;/targetPath&gt; &lt;excludes&gt; &lt;exclude&gt;**/properties&lt;/exclude&gt; &lt;/excludes&gt; &lt;/resource&gt; &lt;/webResources&gt; &lt;/configuration&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;package-prod&lt;/id&gt; &lt;phase&gt;package&lt;/phase&gt; &lt;configuration&gt; &lt;classifier&gt;prod&lt;/classifier&gt; &lt;webappDirectory&gt;${project.build.directory}/${project.build.finalName}-prod&lt;/webappDirectory&gt; &lt;packagingExcludes&gt;WEB-INF/classes/*.jks,WEB-INF/classes/acquirer.properties&lt;/packagingExcludes&gt; &lt;filters&gt; &lt;filter&gt;${project.basedir}/configurations/properties/config_prod.prop&lt;/filter&gt; &lt;/filters&gt; &lt;webResources&gt; &lt;resource&gt; &lt;directory&gt;configurations&lt;/directory&gt; &lt;filtering&gt;true&lt;/filtering&gt; &lt;targetPath&gt;WEB-INF/classes&lt;/targetPath&gt; &lt;excludes&gt; &lt;exclude&gt;**/properties&lt;/exclude&gt; &lt;/excludes&gt; &lt;/resource&gt; &lt;/webResources&gt; &lt;/configuration&gt; &lt;goals&gt; &lt;goal&gt;war&lt;/goal&gt; &lt;/goals&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; </code></pre>
9,860,286
0
<p>It's just an assumption, but according to <a href="http://developer.android.com/reference/android/app/Fragment.html#Lifecycle" rel="nofollow">Android Developers</a>:</p> <blockquote> <p>onStart() makes the fragment visible to the user (based on its containing activity being started).</p> </blockquote> <p>So width and height will be calculated only <strong>after</strong> your fragment will become visible.</p> <p>But, maybe, I'm not right.</p>
12,387,188
0
<p>To get you started, here is my script to order today's lunch from our local canteen:</p> <pre><code>URL="https://lunch.com/lunch/cgi-bin/order.cgi" O="order=Order" A="amount_%d=%%d&amp;amount_foil_container_%d=%%d" function order_lunch() { if [[ -n "$@" ]]; then curl -u "$USER":"$PASSWORD" \ -d $(printf $(printf "$O&amp;$A&amp;$A&amp;$A&amp;$A" 0 0 1 1 2 2 3 3) \ "${@:2:8}") \ "$URL"; else echo "Nothing to order."; fi; } </code></pre> <p>Where input is a string in the following format</p> <pre><code>2012-08-23 1 0 0 0 0 0 0 0 </code></pre> <p>where each field denotes a different dish, i.e. a 1 in the first position after the date is "1 pasta"</p> <p>Good luck.</p>
39,184,263
0
Catch image data via WI-FI <p>I have a device that takes pictures and send to an iPhone app via WI-FI. The iPhone has to connect to the device's WIFI, and when the device takes a picture it saves to camera roll of the iPhone if the app is in the foreground. However if the app is in the background, nothing happens.</p> <p>My question is, can I catch this image data with another app that I create? I assume the data arrives to the iPhone via WI-FI when the app is in the background also.</p> <p>Thank you for your help.</p>
7,073,024
0
<p>There is absolutely no difference. Try to run this code:</p> <pre><code>(function() { return setTimeout(function(){console.log(1)}, 500); })(); (function() { setTimeout(function(){console.log(2)}, 500); return; })(); </code></pre> <p><code>return</code> doesn't affect on setTimeout call in JS interpreter.</p>
20,189,448
0
<p>You share methods in a module, and you place such a module inside the <code>lib</code> folder.</p> <p>Something like <code>lib/fake_data.rb</code> containing</p> <pre><code>module FakeData def random_address [Faker::Address.street_address, Faker::Address.city].join("\n") end module_function end </code></pre> <p>and inside your rake task just require the module, and call <code>FakeData.random_address</code>.</p> <p>But, if it is like a seed you need to do every time you run your tests, you should consider adding this to your general <code>before all</code>.</p> <p>E.g. my <code>spec_helper</code> looks like this:</p> <pre><code># Requires supporting ruby files with custom matchers and macros, etc, # in spec/support/ and its subdirectories. Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } RSpec.configure do |config| config.use_transactional_fixtures = true config.infer_base_class_for_anonymous_controllers = false config.order = "random" include SetupSupport config.before(:all) do load_db_seed end end </code></pre> <p>and the module <code>SetupSupport</code> is defined in <code>spec/support/setup_support.rb</code> and looks as follows:</p> <pre><code>module SetupSupport def load_db_seed load(File.join(Rails.root, 'db', 'seeds.rb')) end end </code></pre> <p>Not sure if you need to load the seeds, or are already doing this, but this is the ideal spot to also generate needed fake data.</p> <p>Note that my setup support class is defined in <code>spec/support</code> because the code is only relevant to my specs, I have no rake task also needing the same code.</p>
88,789
0
<p>.aspx doesn't fulfill the MVC pattern because the aspx page (the 'view') is called before the code behind (the 'controller').</p> <p>This means that the controller has a 'hard dependency' on the view, which is very much against MVC principles.</p> <p>One of the core benefits of MVC is that it allows you to test your controller (which contains a lot of logic) without instantiating a real view. You simply can't do this in the .aspx world. </p> <p>Testing the controller all by itself is much faster than having to instantiate an entire asp.net pipeline (application, request, response, view state, session state etc).</p>
17,947,245
0
<p>It's all explained in the documentation of <a href="https://developer.blackberry.com/cascades/reference/bb__data__jsondataaccess.html" rel="nofollow"><code>JsonDataAccess</code></a>. You'll have to do something like this:</p> <pre><code>// Create a data model with sorting keys for title GroupDataModel *model = new GroupDataModel(QStringList() &lt;&lt; "title"); // Load the JSON data JsonDataAccess jda; QVariant list = jda.load("yourfile.json")["result"].toVariantList(); // Add the data to the model model-&gt;insertList(list.value&lt;QVariantList&gt;()); // Add your model to a ListView listView-&gt;setDataModel(model); </code></pre>
34,635,060
0
<p>You are missing a closing <code>}</code> for <code>#nav-wrapper</code>. Add <code>text-align: center;</code> to <code>#nav</code></p>
20,294,620
1
Python: Run multiple instances at once with different value set for each instance <p>I'm starting up in Python and have done a lot of programming in the past in VB. Python seems much easier to work with and far more powerful. I'm in the process of ditching Windows altogether and have quite a few VB programs I've written and want to use them on Linux without having to touch anything that involves Windows.</p> <p>I'm trying to take one of my VB programs and convert it to Python. I think I pretty much have.</p> <p>One thing I never could find a way to do in VB was to use Program 1, a calling program, to call Program 2 and run in it multiple times. I had a program that would search a website looking for new updated material, everything was updated numerically(1234567890_1.mp3, for example). Not every value was used and I would have to search to find which files existed and which didn't. Typically the site would run through around 100,000 possible files a day with only 2-3 files actually being used each day. I had the program set up to search 10,000 files and if it found a file that existed it downloaded it and then moved to the next possible file and tested it. I would run this program, simultaneously 10 times and have each program set up to search a separate 10,000 file block. I always wanted to set up it so I could have a calling program that would have the user set the Main Block(1234) and the Secondary Block(5) with the Secondary Block possibly being a range of values. The calling program then would start up 10 separate programs(6, err 0-9 in reality) and would use Main Block and Secondary Block as the values to set up the call for each of the 10 Program 2s. When each one of the 10 programs got called, all running at the same time, they would be called with the appropriate search locations so they would be searching the website to find what new files had been added throughout the previous day. It would only take 35-45 minutes to complete each day versus multiple hours if I ran through everything in one long continuous program.</p> <p>I think I could do this with Python using a Program 1(set) and Program 2(read) .txt file. I'm not sure if I would run into problems possibly with changing the set value before Program 2 could have read the value and started using it. I think I would have a to add a pause into the program to play it safe... I'm not really sure.</p> <p>Is there another way I could pass a value from Program 1 to Program 2 to accomplish the task I'm looking to accomplish?</p>
28,848,097
0
<p>Yes, <code>x</code> is not initialized.</p> <pre><code>int x=0; // just initialize it </code></pre>
37,579,090
0
For completely programmatically created UIView/UIViewController, what should be in loadView vs viewDidLoad? <p>For experimentation purposes, I am trying something completely in code.</p> <p>I have a custom root <code>UIView</code>/<code>UIViewController</code> subclass pair called RootView and RootViewController respectively.</p> <p>I also have a <code>GLKView</code>/<code>GLKViewController</code> subclass pair called RenderView and RenderViewController.</p> <p>Both <code>UIViewController</code> subclasses create their managed views in their <code>loadView</code> overrides.</p> <p>Setting up the main RootViewController/RootView is simple. In my AppDelegate subclass, I create the main window and assign the rootViewController proeprty like so...</p> <pre><code>#import "AppDelegate.h" #import "RootViewController.h" @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { CGRect screenBounds = [[UIScreen mainScreen] bounds]; // Set up the window UIWindow* mainWindow = [[UIWindow alloc] initWithFrame:screenBounds]; mainWindow.rootViewController = [RootViewController new]; self.window = mainWindow; [mainWindow makeKeyAndVisible]; return YES; } @end </code></pre> <p>The RootView appears on screen exactly as one would expect.</p> <p>What I'm wondering however is about view hierarchy initialization. RootViewController has a property to hold an instance of RenderViewController, and its RenderView will be (initially) placed in the frame which is stored in a second property of RootViewController called renderViewFrame.</p> <p>My question is where is the proper place to set up that hierarchy?</p> <p>The documentation states that's exactly what <code>UIViewController</code>'s <code>loadView</code> is for so this is what I'm doing there...</p> <pre><code>- (void)loadView { self.view = [[RootView alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Set up the RenderViewController RenderViewController* renderViewController = [RenderViewController new]; [self addChildViewController:renderViewController]; renderViewController.view.frame = self.renderViewFrame; [self.view addSubview:renderViewController.view]; self.renderViewController = renderViewController; } </code></pre> <p>...and it works, but I've seen some people say no, I should move everything relating to creating RenderView/RenderViewController to RootViewController's <code>viewDidLoad</code> and not <code>loadView</code>, but no one can say why. I mean it is part of the hierarchy and that's specifically what <code>loadView</code> is for.</p> <p>And if I'm right, then why would I/anyone need to use <code>viewDidLoad</code> at all if we're already doing initialization in <code>loadView</code>, or is that just an artifact from when memory could unload the views all the way back in iOS6?</p>
32,590,012
0
Iterating over states doesn't work for me <p>I have an item with multiple <code>StateGroup</code>s:</p> <p><code>MyObject.qml</code></p> <pre><code> import QtQuick 2.0 Item { id: root property alias myStates: myStateGroup.states // .. StateGroup { id: myStateGroup states: [ State { name: "first" }, State { name: "second" }, State { name: "third" } ] } } </code></pre> <p>I want to iterate over the state names: (in another file)</p> <pre><code>Component.onCompleted: { for (var i in instance.myStates) { console.log(JSON.stringify(i)) console.log(i.name) //.... } } </code></pre> <p>What I get is</p> <pre><code>"0" undefined "1" undefined "2" undefined </code></pre> <p>I want to iterate over the names of the states. What am I doing wrong that I get integers instead of <code>State</code>s? I know I could use a simple C-like for, but this looks really awful. I'd like to use the <code>for ... in</code> syntax.</p>
5,372,978
0
<p>A recursive solution is probably a good solution. The function would only find the permutations of the first two arrays and then once combined into a single array, you would call this function again with the new combined array instead of the original arrays.</p> <p>Eventually you would only have 1 array left and that would be the final result array.</p>
18,977,024
0
Sencha touch 2 application not working on android mobile version 4 <p>I am trying to run sencha app on android mobile with api level 15 to support application from version 4. It is not going to the home screen,it's stuck at the loading screen only. It works perfectly on api level 17(4.2.2)/18(4.3). I have installed android sdk for api level 14(4),15(4.0.3). I am using sencha touch 2.2.1 and Sencha Cmd 3.1.2.342.</p> <p>Any possible reason for this behavior , or have I missed any thing please help.</p>
1,501,144
0
Handling mail: rails vs php vs perl vs? <p>This is my very first question in stack overflow and I am quite excited. Liked a lot the interface of this site and the buoyant community!</p> <p>I am building a rails app that receives text as an email and creates a post.</p> <p>I ask or your expert opinion on which is the best option to receive the mail message and process it?</p> <p>To send the mail to the application:</p> <ul> <li>A1: X accesses a POP/IMAP account periodically (30s cronjob?) and processes the message</li> <li>A2: the message is piped from the mailserver to the application X</li> </ul> <p>To process the application</p> <ul> <li>B1: rails with MMS2R</li> <li>B2: PHP that processes the message and sends a POST in rails</li> <li>B3: PERL that processes the message and sends a POST to rails</li> </ul> <p>Which combination A+B would you recommend for a big volume of mails?</p> <p>Any other A or B option?</p> <p>Thank you very much and good luck with all your scripting!</p>
16,157,624
0
<p>Does this solve your task?</p> <pre><code>@echo off for /f "delims=" %%a in (file_list.txt) do ( &gt;&gt;run.txt echo open %%a and save as pdf ) </code></pre>
1,799,936
0
onchange attribute won't call function <p>I have an HTML document (<a href="http://www.wikiupload.com/download_page.php?id=196262" rel="nofollow noreferrer">here</a>), which creates an iframe-based media player for a collection of songs within albums (I just used letters to define these albums and songs in the mymusic array, for simplicity).</p> <p>Focusing on the top 3 iframes, the way I have set out the user interaction is to generate the HTML for forms of available albums and songs using Javascript, and write them to the iframes in the body. If you run it and make a selection in the <strong>Albums</strong> menu, you will see that the options in the <strong>Songs</strong> menu correspond with the <code>mymusic</code> array, so this works.</p> <p>However, when I choose a song, the function <code>nowplaying(trackindex,albumindex)</code> should be called using an <code>onchange</code> event in the <strong>Songs</strong> form, the same way as in the form generated using <code>showinitial()</code> ... but the function does not get called.</p> <p>I have ruled out the coding of <code>nowplaying</code> itself as a cause, because even when I change <code>nowplaying</code> to <code>alert("hello")</code>, it does not get called. So this leads me to think the problem is with the <code>onchange</code> attribute in "anything", but I can't see the problem. The way I coded it is no different to before, and that worked fine, so why won't this work?</p> <p>Any help would be much appreciated! </p>
39,104,359
0
<p>Just check for carriage return character and new line, if the line index grows, but there is no carriage return or new line char (depending on OS) there IS a multiline string. Im not sure if this can be done with grep but should be quite easy to implement with any programming language or even bash</p>
26,425,531
0
<p>Okay so, I had a similar problem where I needed two buttons centered at the top of the page. Due to the problem I just dropped it to one button (it was easier that way). Since I'm having the same problem now with three buttons, I can't drop them to one, so I reverted back to the two original buttons that caused me a problem and came up with this...</p> <pre><code>&lt;div class="row start-btns"&gt; &lt;div class="col-lg-6 col-lg-offset-3 test"&gt; &lt;div class="row"&gt; &lt;div class="col-lg-5 pull-left start-btn"&gt;Get Started&lt;/div&gt; &lt;div class="col-lg-5 pull-right tour-btn"&gt;Tour The Site&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;!-- End .row .start-btns --&gt; @mixin btns { background: $yellow; color: $cream; font-weight: 700; font-size: 1.3em; text-transform: uppercase; text-align: center; padding: 12px 0px; } .call-btn, .start-btn, .tour-btn { @include btns; } .start-btn { margin-right: 1em; } </code></pre> <p>Having the parent ".test" span 6 cols and centered allowed me to nest another row with two buttons spanning 5 cols (actually 3 due to nesting) and pull one left and other right. This gives the effect that both buttons are spanning 3 columns and centered perfectly with a 10px spacing.</p>
21,405,644
0
<p>You can use file API methods to set proper permissions using following methods.</p> <pre><code>setReadable(readable, ownerOnly) / setReadable(readable) setWritable(writable, ownerOnly) / setWritable(writable) setExecutable(executable, ownerOnly) / setExecutable(executable) </code></pre> <p>Regards,</p>
19,983,513
0
<p>And who said you can have only one window ? :) </p> <p>See if my answer <a href="http://stackoverflow.com/a/19983002/1134595">on this similar question</a> can help.</p> <p>This approach is working very well for me. As long as you don't have to worry about multiple displays or state restoration, this linked code should be enough to do what you need: you don't have to make your logic look backwards or rewrite existing code, and can still take advantage of the UISplitView in a deeper level within your application - without (AFAIK) breaking Apple guidelines.</p>
2,821,393
0
<p>"<strong>Premature optimization is the root of all evil.</strong>"<br> I doubt you'd have to care about a once in a lifetime initialization...<br> That is unless you call it a zillion times, then I suggest you redesign your code.</p>
32,592,653
0
<p>Nesting listviews is not support in Xamarin.Forms. You can try, but the inner one will not be scrollable and therefor useless.</p> <p>If ListA has a list of ListB's, would it suite your needs to do grouping? <a href="https://i.stack.imgur.com/gj7ZW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gj7ZW.png" alt="Here is a quick image showing how grouping would look."></a></p> <p>Essentially, you are grouping your lists of B within items of A (where in that image I showed your list A is a list of mobile devices and your lists of B are specific types within the generic OS).</p> <p>To do this, when you create your listview and set your data template/source, you must now also set IsGroupingEnabled to true and GroupHeaderTemplate to the datatemplate created to show how it will be displayed visually (exactly the same as you normally would make a datatemplate with custom viewcells).</p> <p>The only difference now is instead of your source being a list of A or a list of B, it is an list A (which extends ObservableCollection) which contains a list B.</p> <p>You basically need to make your A viewmodel extend ObserableCollection so A is A but A is also a list/can be used as a list.</p> <p>Now you just feed your list A (where each A has a list B) as the source of your ListView.</p>
3,881,137
0
Class instance variables inside of class cause compiler errors <p>The compiler is giving me the following complaints about the following class:</p> <pre><code>class AguiWidgetBase { //variables AguiColor tintColor; AguiColor fontColor; //private methods void zeroMemory(); virtual void onPaint(); virtual void onTintColorChanged(AguiColor color); void (*onPaintCallback)(AguiRectangle clientRect); void (*onTintColorChangedCallback)(); public: AguiWidgetBase(void); ~AguiWidgetBase(void); void paint(); void setTintColor(AguiColor color); AguiColor getBackColor(); }; Warning 13 warning C4183: 'getBackColor': missing return type; assumed to be a member function returning 'int' c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\agui\AguiWidgetBase.h 26 Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\agui\AguiWidgetBase.h 11 Error 3 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\agui\AguiWidgetBase.h 11 Error 5 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\agui\AguiWidgetBase.h 12 Error 6 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\agui\AguiWidgetBase.h 12 Error 11 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\agui\AguiWidgetBase.h 26 Error 12 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\agui\AguiWidgetBase.h 26 Error 1 error C2146: syntax error : missing ';' before identifier 'tintColor' c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\agui\AguiWidgetBase.h 11 Error 10 error C2146: syntax error : missing ';' before identifier 'getBackColor' c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\agui\AguiWidgetBase.h 26 Error 4 error C2146: syntax error : missing ';' before identifier 'fontColor' c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\agui\AguiWidgetBase.h 12 Error 8 error C2061: syntax error : identifier 'AguiRectangle' c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\agui\AguiWidgetBase.h 17 Error 7 error C2061: syntax error : identifier 'AguiColor' c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\agui\AguiWidgetBase.h 16 Error 9 error C2061: syntax error : identifier 'AguiColor' c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\agui\AguiWidgetBase.h 25 </code></pre> <p>This should be working, I'm including the headers for those classes.</p> <p>This is the h file:</p> <pre><code>//integer Point class class AguiPoint { int x; int y; public: int getX(); int getY(); void setX(int x); void setY(int y); void set(int x, int y); AguiPoint(int x, int y); AguiPoint(); std::string toString(); std::string xToString(); std::string yToString(); }; //floating version of Agui Point class AguiPointf { float x; float y; public: float getX(); float getY(); void setX(float x); void setY(float y); void set(float x, float y); AguiPointf(float x, float y); AguiPointf(AguiPoint p); AguiPointf(); std::string toString(); std::string xToString(); std::string yToString(); }; //Integer rectangle class class AguiRectangle { int x; int y; int width; int height; public: bool isEmpty(); int getTop(); int getLeft(); int getBottom(); int getRight(); AguiPoint getTopLeft(); AguiPoint getBottomRight(); }; class AguiColor { unsigned char r; unsigned char g; unsigned char b; unsigned char a; void verifyColorBounds(); public: AguiColor(int r, int g, int b, int a); AguiColor(float r, float g, float b, float a); AguiColor(); int getR(); int getG(); int getB(); int getA(); }; </code></pre> <p>Thanks</p> <p>I include the main header in the WidgetBase and the main header includes the base types before it includes the widgetbase</p>
17,181,978
0
<p>Without using a local variable, in most invocations we have effectively</p> <pre><code>if(field!=null) // true return field; </code></pre> <p>so there are two volatile reads, which is slower than one volatile read.</p> <p>Actually JVM can merge the two volatile reads into one volatile read and still conform to JMM. But we expect JVM to perform a good faith volatile read every time it's told to, not to be a smartass and try to optimize away any volatile read. Consider this code</p> <pre><code>volatile boolean ready; do{}while(!ready); // busy wait </code></pre> <p>we expect JVM to really load the variable repeatedly.</p>
32,577,164
0
<p>There are two possible answers to your question depending on your exact intent. If I were to guess, the word you're looking for is: <a href="https://en.wikipedia.org/wiki/Morphology_(linguistics)" rel="nofollow">morphology</a> but it could also be <a href="https://en.wikipedia.org/wiki/Phonology" rel="nofollow">phonology</a>. However, I don't think "phonology" fits your second example.</p> <p>The thing you seem to be describing are various parts of <a href="https://en.wikipedia.org/wiki/Grammar" rel="nofollow">grammar</a>. Grammar is the study of <a href="https://en.wikipedia.org/wiki/Syntax" rel="nofollow">syntax</a>, phonology and morphology.</p> <p>Syntax describes the general structure of the language. How words fit together.</p> <p>Phonology describes how sounds fit together in the language. How many vowels there are, the consonants, the types of consonants etc.</p> <p>Morphology describes how words are formed in the language. Does the language modify words with tenses? Does the language modify words with gender? Does the language not modify words at all but instead use other words? etc.</p>
22,603,170
0
How to add an event handler for dynamically created QML elements? <p>I dynamically added some qml components to my gui according to <a href="http://kunalmaemo.blogspot.kr/2011/04/creating-qml-element-dynamically-on.html">this blog post</a>. How can I add event handlers for those newly created components?</p>
25,999,368
1
Shifting to Python 3.4.1 on Mac 10.7.5 - how best to get at my modules? <p>So, I want to start using Python 3.4.1. I've got it installed on my machine, etc, and it'll print("hello world!") and according to this post, which seems sensible, I need to leave 2.7 in place for backwards compatibility: <a href="http://stackoverflow.com/questions/5846167/how-to-change-default-python-version">how to change default python version?</a></p> <p>OK great, now, what's the best way to make Python 3 "see" all my great modules I've got installed for 2.7? All my old buddies like Pandas and XLRD are like "No module named Pandas."</p> <p>And yes, all my libraries are in</p> <p>Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages</p> <p>I suspect a lot of reinstallation in my future … </p>
37,923,955
0
Are there any functional differences between a (PaaS) website and a (IaaS) VM running IIS? <p>We're moving our operation to Azure soon but we'll be going for a IaaS to effectively emulate our existing physical data center setup. This is largely because our (.NET) website has not been tested using the Azure Website platform and so we can't guarentee it'll work as expected however I'm curious as to how a running a website via a Web Site service (PaaS) would be any different to running it on an IaaS style VM which runs IIS. Isn't it functionally the same? Is it really necessary to test for both PaaS and IaaS deployments?</p>
3,286,057
0
How to do an inner join in Android? <p>I would like to do an inner join on my database in my Android app. Is this even possible? What about a left join? I know cursor joiner exists but the documentation isn't clear at all. Can anyone provide any further insight? </p> <p>Thanks</p>
16,730,331
0
<p>There is no issue with the first approach. I presume you are trying to iterate over few <code>DataTimerPicker</code> controls. If so, can you check the <code>Name</code> property of each <code>DataTimerPicker</code> control instances. I suppose it should be, datetimeBi1,datetimeBi2,datetimeBi3 ( just guessing after seeing your code).</p> <p>Meantime, you can also check the immediate parent of your child controls ( DateTimePicker).</p>
37,199,952
0
How to implement confirmation or preview in rails? <p>I am calling JSON api from my rails app. User inputs a name in a form, Then i call JSON API and find if the name has any matches there. Sometimes its just one so i create entry with the data provided in JSON. But most of the times there are multiple results on the JSON, How do i implement "Hey i found multiple results for same name, which one were you looking for?" and then the users chooses which one he/she was intending and then it creates an entry in database. </p> <p>I wrote a simple script to test out the JSON.</p> <pre><code>data = JSON.load response if data['results'].empty? #if the JSON data is empty puts "There was no movie found. Did you spell the movie name correctly?" elsif data['results'].count &gt; 1 #if JSON Data has more than one result data['results'].each do |movie| Movie::Movies &lt;&lt; Movie.new(movie['id'], movie['title'], movie['release_year'], (imdb_url + movie['imdb']).to_s, movie['rating'], movie['poster_120x171'], movie['poster_240x342'], movie['poster_400x570']) end Movie::Movies.each do |movie| puts "#{movie.title} : #{movie.release_year}" end else #IF JSON has only one entry movie = Movie.new(data['results'][0]['id'], data['results'][0]['title'], data['results'][0]['release_year'], (imdb_url + data['results'][0]['imdb']).to_s, data['results'][0]['rating'], data['results'][0]['poster_120x171'], data['results'][0]['poster_240x342'], data['results'][0]['poster_400x570']) end </code></pre> <p>And here is my controller at the moment. It can only handle the first record from the Hash provided by JSON. I have no clue on how to handle the situation if there are multiple results. </p> <pre><code> def create require 'rest_client' require 'json' imdb_url = 'http://www.imdb.com/title/' movie_title = movie_params['title'].delete(' ') response = RestClient.get "http://api-public.guidebox.com/v1.43/US/xxxxxxxxxxxxxxxx&lt;api-key&gt;/search/movie/title/#{movie_title}" data = JSON.load response @movie = Movie.new #i am doing this because my for was giving error. if data['results'].empty? flash[:alert] = "Did you spell the Title correctly? Or Maybe we could not find the movie you are looking for." render 'new' elsif data['results'].count &gt; 2 #Display all results to the user for them to pick what they really intended and create an entry of whaterver they choose. else @movie = Movie.new(gb_id: data['results'][0]['id'], title: data['results'][0]['title'], release_year: data['results'][0]['release_year'], imdb_link: (imdb_url + data['results'][0]['imdb']).to_s, rating: data['results'][0]['rating'], small_img: data['results'][0]['poster_120x171'], med_img: data['results'][0]['poster_240x342'], large_img: data['results'][0]['poster_400x570']) if @movie.save flash[:notice] = 'Movie has been successfully Added.' redirect_to @movie else flash[:alert] = "Something went wrong. Please try again." render 'new' end end end </code></pre> <p>Also in my create action i had to call the <code>@movie = Movie.new</code> again because the form was giving me errors.</p>
37,210,832
0
How to retrieve elements place visually under div <p>I'm trying to retrieve an array of images placed under a absolute-positioned div in jQuery or javascript. A sort of selection. I've tried with ".getElementsByPoint", but as it only allows x,y, I'm a little bit confused how I'm gonna incorperate the height and width, and get everything in the area.</p> <p>Hope someone have some suggestions, to pull me out of my trouble.</p> <p>I've painted a quick picture to illustrate what I mean.</p> <p><a href="https://i.stack.imgur.com/ONaMp.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ONaMp.jpg" alt="enter image description here"></a></p>
2,328,602
0
<p>Manually: You can use String.Split() method to split your entire file. Here is an example of what i use in my code. In this example, i read the data line by line and split it. I then place the data directly into columns. </p> <pre><code> //Open and read the file System.IO.FileStream fs = new System.IO.FileStream("myfilename", System.IO.FileMode.Open); System.IO.StreamReader sr = new System.IO.StreamReader(fs); string line = ""; line = sr.ReadLine(); string[] colVal; try { //clear of previous data //myDataTable.Clear(); //for each reccord insert it into a row while (!sr.EndOfStream) { line = sr.ReadLine(); colVal = line.Split('\t'); DataRow dataRow = myDataTable.NewRow(); //associate values with the columns dataRow["col1"] = colVal[0]; dataRow["col2"] = colVal[1]; dataRow["col3"] = colVal[2]; //add the row to the table myDataTable.Rows.Add(dataRow); } //close the stream sr.Close(); //binds the dataset tothe grid view. BindingSource bs = new BindingSource(); bs.DataSource = myDataSet; bs.DataMember = myDataTable.TableName; myGridView.DataSource = bs; } </code></pre> <p>You could modify it to do some loops for columns if you have many and they are numbered. Also, i recommend checking the integrity first, by checking that the number of columns read is correct.</p>
36,710,381
0
<p>So what's the actual file encoding? Open up a hex editor and look at the byte values for <code>insan�n</code> (especially the broken character). Then when you have the byte value, you can find the actual encoding. Now you've just tried two wrong encodings at random.</p>
16,302,588
0
adb devices doesn't show my device <p>I'm trying to run my application from eclipse on my Samsung Galaxy Tab, however it doesn't show up in the 'Choose a running android device' I then tried changing the running configuration to 'Launch on all compatible devices/AVDs' and picked active devices, I however got the following error:</p> <blockquote> <p>No active compatible AVD's or devices found. Relaunch this configuration after connecting a device or starting an AVD.</p> </blockquote> <p>I then tried typing adb devices in the command prompt to get an empty list, I then tried</p> <pre><code>adb kill-server adb start-server </code></pre> <p>which didn't work either.</p> <p>I also set</p> <pre><code>android:debuggable="true" </code></pre> <p>and updated the device usb_driver in android-sdks\extras\google, and it mentioned that it was already up to date. So all my attempts were in vain. Any help would be much much appreciated.</p>
36,982,958
0
How to get the value of TextViews from an ArrayAdapter to another Class <p>In order to pass data from my Custom Adapter to another class I tried these two methods and none worked for me.</p> <pre><code> String SGetNumVol=Num_Vol.getText().toString(); String SGetComment=Commentaire.getText().toString(); String SGetAirpDepart=Aeroport.getText().toString(); String SGetDestination=Destination.getText().toString(); String SGetCompanie=code_Compagnie.getText().toString(); Intent intent =new Intent(c,DetailVol.class); Bundle bundle = intent.getExtras(); GetNumVol= bundle.getString(SGetNumVol); GetComment= bundle.getString(SGetComment); GetAirpDepart= bundle.getString(SGetAirpDepart); GetDestination= bundle.getString(SGetDestination); GetCompanie= bundle.getString(SGetCompanie); </code></pre> <p>and recieving it like</p> <pre><code> Intent i = getIntent(); Bundle b = i.getExtras(); if(b!=null) { String a =(String) b.get(CustomAdapter.GetAirpDepart); Airportdep.setText(a); String c =(String) b.get(CustomAdapter.GetDestination); dest.setText(c); String e =(String) b.get(CustomAdapter.GetNumVol); Num.setText(e); String f=(String) b.get(CustomAdapter.GetComment); com.setText(f); String j =(String) b.get(CustomAdapter.GetCompanie); Comp.setText(j); } </code></pre> <p>Second Method is like :</p> <pre><code> //SecondTest Intent i = new Intent(c, DetailVol.class); String SGetNumVol=Num_Vol.getText().toString(); String SGetComment=Commentaire.getText().toString(); String SGetAirpDepart=Aeroport.getText().toString(); String SGetDestination=Destination.getText().toString(); String SGetCompanie=code_Compagnie.getText().toString(); i.putExtra("SGetNumVol", SGetNumVol); i.putExtra("SGetComment", SGetComment); i.putExtra("SGetAirpDepart",SGetAirpDepart); i.putExtra("SGetDestination",SGetDestination); i.putExtra("SGetCompanie", SGetCompanie); </code></pre> <p>recieving : </p> <pre><code> //SecondTest if (savedInstanceState == null) { Bundle extras = getIntent().getExtras(); if(extras == null) { NumVol= null; Comment= null; AirDepart= null; Destination= null; Companie= null; } else { NumVol= extras.getString("SGetNumVol"); Comment= extras.getString("SGetComment"); AirDepart= extras.getString("SGetAirpDepart"); Destination= extras.getString("SGetDestination"); Companie= extras.getString("SGetCompanie"); } } else { NumVol= (String) savedInstanceState.getSerializable("SGetNumVol"); Comment= (String) savedInstanceState.getSerializable("SGetComment"); AirDepart= (String) savedInstanceState.getSerializable("SGetAirpDepart"); Destination= (String) savedInstanceState.getSerializable("SGetDestination"); Companie= (String) savedInstanceState.getSerializable("SGetCompanie"); } </code></pre> <p>The first returning NullPointerException and the second just pass without any error but it doesn't return values from Custom Adapter. I hope I explained it well, does anybody know how can I correct this? </p>
11,897,019
0
ExpressJS Redirect Method <p>If I use the <code>res.redirect( url )</code> will the redirection method also append the previous parameters to where it will be redirected?</p> <p>It means if I passed/send request with a json parameters using POST method then I redirect the request to another server, will that other server (where it is redirected) receives the json parameters?</p>
4,326,159
0
<p>in your solution consider changing</p> <pre><code>&lt;Trigger Property="MenuItem.Header" Value="enums:AnEnum.ItemA" &gt; </code></pre> <p>to </p> <pre><code>&lt;Trigger Property="MenuItem.Header" Value="{x:Static enums:AnEnum.ItemA}" &gt; </code></pre> <p>in your example you check that header is equal to <strong>sting "enums:AnEnum.ItemA"</strong> not to enum AnEnum member ItemA.</p>
12,633,018
0
localPlayerDidSelectChallenge method gets called even if player doesn't tap GKChallenge banner <p>When a player receives a <code>GKChallenge</code>, the <code>GKChallengeEventHandler</code> calls <code>localPlayerDidReceiveChallenge</code> on the delegate implementing the <code>GKChallengeEventHandlerDelegate</code> protocol, then immediately after, calls <code>localPlayerDidSelectChallenge</code>, every time.</p> <p>The docs say that for <code>localPlayerDidSelectChallenge</code> to be called, one of two things must happen:</p> <ul> <li>The user taps the challenge banner</li> <li>The user opens the app in response to receiving a challenge notification</li> </ul> <p>But it seems to be called every time, even if the app is open already and without the user ever touching the banner!</p>
37,523,082
0
Execution failed for task ':app:transformClassesWithMultidexlistForDebug' <p><strong>ERROR</strong> Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.</p> <blockquote> <p>com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 1</p> </blockquote> <p><strong>my gradle file</strong></p> <pre><code>apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "24.0.0 rc3" defaultConfig { applicationId "com.example.sagar.shavanma" minSdkVersion 15 targetSdkVersion 23 versionCode 1 versionName "1.0" multiDexEnabled true } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: '*.jar') testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.3.0' compile 'com.android.support:design:23.3.0' compile 'com.android.support:support-v4:23.3.0' compile 'com.android.support:cardview-v7:23.3.0' compile 'com.github.nirhart:parallaxscroll:1.0' compile 'com.google.code.gson:gson:2.6.2' compile 'com.mcxiaoke.volley:library:1.0.19' } </code></pre> <p><strong>Gridle</strong></p> <p>:app:preBuild UP-TO-DATE :app:preDebugBuild UP-TO-DATE :app:checkDebugManifest :app:preReleaseBuild UP-TO-DATE :app:prepareComAndroidSupportAnimatedVectorDrawable2330Library UP-TO-DATE :app:prepareComAndroidSupportAppcompatV72330Library UP-TO-DATE :app:prepareComAndroidSupportCardviewV72330Library UP-TO-DATE :app:prepareComAndroidSupportDesign2330Library UP-TO-DATE :app:prepareComAndroidSupportMultidex101Library UP-TO-DATE :app:prepareComAndroidSupportRecyclerviewV72330Library UP-TO-DATE :app:prepareComAndroidSupportSupportV42330Library UP-TO-DATE :app:prepareComAndroidSupportSupportVectorDrawable2330Library UP-TO-DATE :app:prepareComAndroidVolleyVolley100Library UP-TO-DATE :app:prepareComGithubNirhartParallaxscroll10Library UP-TO-DATE :app:prepareDebugDependencies :app:compileDebugAidl UP-TO-DATE :app:compileDebugRenderscript UP-TO-DATE :app:generateDebugBuildConfig UP-TO-DATE :app:generateDebugAssets UP-TO-DATE :app:mergeDebugAssets UP-TO-DATE :app:generateDebugResValues UP-TO-DATE :app:generateDebugResources UP-TO-DATE :app:mergeDebugResources UP-TO-DATE :app:processDebugManifest UP-TO-DATE :app:processDebugResources UP-TO-DATE :app:generateDebugSources UP-TO-DATE :app:compileDebugJavaWithJavac Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. :app:compileDebugNdk UP-TO-DATE :app:compileDebugSources :app:prePackageMarkerForDebug :app:transformClassesWithJarMergingForDebug :app:collectDebugMultiDexComponents :app:transformClassesWithMultidexlistForDebug ProGuard, version 5.2.1 Reading program jar [G:\Projects\Shavanma\app\build\intermediates\transforms\jarMerging\debug\jars\1\1f\combined.jar] Reading library jar [C:\Users\shree\AppData\Local\Android\sdk\build-tools\24.0.0-preview\lib\shrinkedAndroid.jar] Preparing output jar [G:\Projects\Shavanma\app\build\intermediates\multi-dex\debug\componentClasses.jar] Copying resources from program jar [G:\Projects\Shavanma\app\build\intermediates\transforms\jarMerging\debug\jars\1\1f\combined.jar] :app:transformClassesWithMultidexlistForDebug FAILED Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.</p> <blockquote> <p>com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 1</p> </blockquote>
10,677,670
0
<p>There are many places to find interesting data online: The <a href="http://data.worldbank.org/" rel="nofollow">world bank</a> has released an extensive set of data you can download and use for free. You can also extract some of the structured data from wikipedia through the service <a href="http://dbpedia.org/About" rel="nofollow">DBpedia</a>. If you want to use more specific data from either corporate or governmental institutions (how much did your government spend last year? Where does the crimes find place?) check out Open Knowledge Foundations data repository at <a href="http://thedatahub.org/" rel="nofollow">The Data Hub</a>.</p>