qid
int64
4
8.14M
question
stringlengths
20
48.3k
answers
list
date
stringlengths
10
10
metadata
list
input
stringlengths
12
45k
output
stringlengths
2
31.8k
275,888
<p>Use HttpWebRequest to download web pages without key sensitive issues</p>
[ { "answer_id": 275905, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 2, "selected": false, "text": "<p>[update: I don't know why, but both examples below now work fine! Originally I was also seeing a 403 on the page2 ...
2008/11/09
[ "https://Stackoverflow.com/questions/275888", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35917/" ]
Use HttpWebRequest to download web pages without key sensitive issues
[update: I don't know why, but both examples below now work fine! Originally I was also seeing a 403 on the page2 example. Maybe it was a server issue?] First, `WebClient` is easier. Actually, [I've seen this before](http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/1393cb0a3...
275,891
<p>I wan't to change the background color of a div dynamicly using the following HTML, CSS and javascript. HTML:</p> <pre><code>&lt;div id=&quot;menu&quot;&gt; &lt;div class=&quot;menuItem&quot;&gt;&lt;a href=#&gt;Bla&lt;/a&gt;&lt;/div&gt; &lt;div class=&quot;menuItem&quot;&gt;&lt;a href=#&gt;Bla&lt;/a&gt;&lt;/...
[ { "answer_id": 275912, "author": "foxy", "author_id": 30119, "author_profile": "https://Stackoverflow.com/users/30119", "pm_score": 7, "selected": true, "text": "<p>Your code looks fine to me.</p>\n\n<p>Make sure the DOM is ready before your javascript is executed by using jQuery's $(cal...
2008/11/09
[ "https://Stackoverflow.com/questions/275891", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35197/" ]
I wan't to change the background color of a div dynamicly using the following HTML, CSS and javascript. HTML: ``` <div id="menu"> <div class="menuItem"><a href=#>Bla</a></div> <div class="menuItem"><a href=#>Bla</a></div> <div class="menuItem"><a href=#>Bla</a></div> </div> ``` CSS: ``` .menuItem{ dis...
Your code looks fine to me. Make sure the DOM is ready before your javascript is executed by using jQuery's $(callback) function: ``` $(function() { $('.menuItem').hover( function(){ $(this).css('background-color', '#F00'); }, function(){ $(this).css('background-color', '#000'); }); }); ```
275,920
<p>I have been trying to set up my Beta 1 MVC app on IIS 6 and cannot get it to run correctly. I have added a Wildcard mapping to the .net isapi DLL as suggested in other blog posts but get the following error when I access the root of the website:</p> <pre><code>The incoming request does not match any route. .. [Http...
[ { "answer_id": 275928, "author": "TheCodeJunkie", "author_id": 25319, "author_profile": "https://Stackoverflow.com/users/25319", "pm_score": 1, "selected": false, "text": "<p>Unfortunatly IIS 6 needs a file extension to map the request to the right handler which means you will have to us...
2008/11/09
[ "https://Stackoverflow.com/questions/275920", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31412/" ]
I have been trying to set up my Beta 1 MVC app on IIS 6 and cannot get it to run correctly. I have added a Wildcard mapping to the .net isapi DLL as suggested in other blog posts but get the following error when I access the root of the website: ``` The incoming request does not match any route. .. [HttpException (0x8...
OK, got it working. The problem was that I was using msbuild automation to package up the files that I needed to deploy, and I was missing global.asax. So it looks like if global.asax is not deployed to the site then none of the routes get hooked up. This means that hitting the website root correctly results in the e...
275,927
<p>I have a form that tries to modify a JComponent's graphics context. I use, for example,</p> <pre><code>((Graphics2D) target.getGraphics()).setStroke(new BasicStroke(5)); </code></pre> <p>Now, immediately after I set the value and close the form, the change is not visible. Am I not allowed to modify a JComponent's ...
[ { "answer_id": 276388, "author": "kasperjj", "author_id": 34240, "author_profile": "https://Stackoverflow.com/users/34240", "pm_score": 3, "selected": true, "text": "<p>There are several problems with that approach. The first is that most components will set these things themselves when ...
2008/11/09
[ "https://Stackoverflow.com/questions/275927", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1155998/" ]
I have a form that tries to modify a JComponent's graphics context. I use, for example, ``` ((Graphics2D) target.getGraphics()).setStroke(new BasicStroke(5)); ``` Now, immediately after I set the value and close the form, the change is not visible. Am I not allowed to modify a JComponent's graphics context? How else...
There are several problems with that approach. The first is that most components will set these things themselves when ever they are asked to repaint themselves. This means that your change will be lost every time the component gets to the point where it would actually use it. But, on an even more fundamental level tha...
275,931
<p>I'm brand new to jQuery and have some experience using Prototype. In Prototype, there is a method to "flash" an element &mdash; ie. briefly highlight it in another color and have it fade back to normal so that the user's eye is drawn to it. Is there such a method in jQuery? I see fadeIn, fadeOut, and animate, but I ...
[ { "answer_id": 275942, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 3, "selected": false, "text": "<p>Would a <del><a href=\"http://enhance.qd-creative.co.uk/demos/pulse/\" rel=\"nofollow noreferrer\">pulse effect</a></del>(of...
2008/11/09
[ "https://Stackoverflow.com/questions/275931", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7961/" ]
I'm brand new to jQuery and have some experience using Prototype. In Prototype, there is a method to "flash" an element — ie. briefly highlight it in another color and have it fade back to normal so that the user's eye is drawn to it. Is there such a method in jQuery? I see fadeIn, fadeOut, and animate, but I don't see...
My way is .fadein, .fadeout .fadein, .fadeout ...... ``` $("#someElement").fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100); ``` ```js function go1() { $("#demo1").fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100)} function go2() { $('#demo2').delay(100).fadeOut().fadeIn('slow') } ``` ```css #demo1, #demo2 { ...
275,944
<p>I have the string </p> <pre><code>a.b.c.d </code></pre> <p>I want to count the occurrences of '.' in an idiomatic way, preferably a one-liner.</p> <p>(Previously I had expressed this constraint as "without a loop", in case you're wondering why everyone's trying to answer without using a loop).</p>
[ { "answer_id": 275969, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 8, "selected": false, "text": "<p>Sooner or later, <em>something</em> has to loop. It's far simpler for you to write the (very simple) loop than to use...
2008/11/09
[ "https://Stackoverflow.com/questions/275944", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4343/" ]
I have the string ``` a.b.c.d ``` I want to count the occurrences of '.' in an idiomatic way, preferably a one-liner. (Previously I had expressed this constraint as "without a loop", in case you're wondering why everyone's trying to answer without using a loop).
My 'idiomatic one-liner' for this is: ``` int count = StringUtils.countMatches("a.b.c.d", "."); ``` Why write it yourself when it's already in [commons lang](http://commons.apache.org/lang/)? Spring Framework's oneliner for this is: ``` int occurance = StringUtils.countOccurrencesOf("a.b.c.d", "."); ```
275,958
<p>I have a list of say 100 unsorted items. Each item belongs to a group. The group the item belongs to is simply a member of the item class.</p> <p>Using C/C++ I'm looking for the most efficient way of scanning through the list of items, checking which group they are in and printing the item to the screen. Here's the...
[ { "answer_id": 275961, "author": "Kasprzol", "author_id": 5957, "author_profile": "https://Stackoverflow.com/users/5957", "pm_score": 1, "selected": false, "text": "<p>You can create a dictionary/hashmap of groups and for each group store a bool saying if a item of that group was printed...
2008/11/09
[ "https://Stackoverflow.com/questions/275958", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7129/" ]
I have a list of say 100 unsorted items. Each item belongs to a group. The group the item belongs to is simply a member of the item class. Using C/C++ I'm looking for the most efficient way of scanning through the list of items, checking which group they are in and printing the item to the screen. Here's the catch tho...
Sort the items according the group value (if it's a *pointer*, then you can use its address, otherwise *lexicographical* sort the *string*). Then loop through that sorted list, taking the first item of each group always. This takes approximately ``` n + n * log(n) ``` I think this is a reasonable alternative betwee...
275,965
<p>when i create an aspx page, the header includes something like this:-</p> <pre><code>&lt;%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="Create.aspx.cs" Inherits="My.Mvc.Views.Blah" %&gt; </code></pre> <p>With ASP.NET MVC apps, do we:</p>...
[ { "answer_id": 275982, "author": "OdeToCode", "author_id": 17210, "author_profile": "https://Stackoverflow.com/users/17210", "pm_score": 2, "selected": false, "text": "<p>You can get rid of this attribute, or set it to false (which is the default). </p>\n\n<p>AutoEventWireup means ASP.NE...
2008/11/09
[ "https://Stackoverflow.com/questions/275965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30674/" ]
when i create an aspx page, the header includes something like this:- ``` <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="Create.aspx.cs" Inherits="My.Mvc.Views.Blah" %> ``` With ASP.NET MVC apps, do we: * need to include this AutoEventWi...
Sorry - the default is true in ASP.NET, so you should explicitly set AutoEventWireup to false in the @ Page directive, or remove it and set it to false in pages section of web.config for MVC.
275,971
<p>I'm pretty new to HQL (well, nHibernate in general) and am currently building a simple app to learn more about it.</p> <p>I've run into problems trying to express the following SQL as HQL though, and would be very grateful for any ideas.</p> <p>Here's the query:</p> <pre><code>select * from parent p where p.id in...
[ { "answer_id": 275982, "author": "OdeToCode", "author_id": 17210, "author_profile": "https://Stackoverflow.com/users/17210", "pm_score": 2, "selected": false, "text": "<p>You can get rid of this attribute, or set it to false (which is the default). </p>\n\n<p>AutoEventWireup means ASP.NE...
2008/11/09
[ "https://Stackoverflow.com/questions/275971", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm pretty new to HQL (well, nHibernate in general) and am currently building a simple app to learn more about it. I've run into problems trying to express the following SQL as HQL though, and would be very grateful for any ideas. Here's the query: ``` select * from parent p where p.id in (select p.parentid from chi...
Sorry - the default is true in ASP.NET, so you should explicitly set AutoEventWireup to false in the @ Page directive, or remove it and set it to false in pages section of web.config for MVC.
275,980
<p>I tried to import mechanize module to my python script like this,</p> <pre><code>from mechanize import Browser </code></pre> <p>But, Google appengine throws HTTP 500 when accessing my script.</p> <p>To make things more clear, Let me give you the snapshot of my package structure,</p> <pre><code>root ....mechanize(wh...
[ { "answer_id": 276350, "author": "Nick Johnson", "author_id": 12030, "author_profile": "https://Stackoverflow.com/users/12030", "pm_score": 0, "selected": false, "text": "<p>When GAE throws a 500, you can see the actual error in the logs on your admin console. If that doesn't help, paste...
2008/11/09
[ "https://Stackoverflow.com/questions/275980", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I tried to import mechanize module to my python script like this, ``` from mechanize import Browser ``` But, Google appengine throws HTTP 500 when accessing my script. To make things more clear, Let me give you the snapshot of my package structure, ``` root ....mechanize(where all the mechanize related files ther...
The mechanize main page says: > > mechanize.Browser is a subclass of mechanize.UserAgentBase, which is, in turn, a subclass of urllib2.OpenerDirector > > > My understanding is that urllib2 is one of the sandboxed modules in GAE, with its functionality being replaced by the Google-provided urlfetch. You'd need to ...
275,994
<p>I need to move backwards through an array, so I have code like this:</p> <pre><code>for (int i = myArray.Length - 1; i &gt;= 0; i--) { // Do something myArray[i] = 42; } </code></pre> <p>Is there a better way of doing this?</p> <p>Update: I was hoping that maybe C# had some built-in mechanism for this like:<...
[ { "answer_id": 275996, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 4, "selected": false, "text": "<p>That's definitely the best way for any array whose length is a signed integral type. For arrays whose lengths ar...
2008/11/09
[ "https://Stackoverflow.com/questions/275994", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14606/" ]
I need to move backwards through an array, so I have code like this: ``` for (int i = myArray.Length - 1; i >= 0; i--) { // Do something myArray[i] = 42; } ``` Is there a better way of doing this? Update: I was hoping that maybe C# had some built-in mechanism for this like: ``` foreachbackwards (int i in m...
While admittedly a bit obscure, I would say that the most typographically pleasing way of doing this is ``` for (int i = myArray.Length; i --> 0; ) { //do something } ```
276,029
<p>I want to write a regular expression that will replace the word Paris by a link, for only the word is not ready a part of a link.</p> <p>Example:</p> <pre><code> i'm living &lt;a href="Paris" atl="Paris link"&gt;in Paris&lt;/a&gt;, near Paris &lt;a href="gare"&gt;Gare du Nord&lt;/a&gt;, i love Paris. </code></...
[ { "answer_id": 276073, "author": "okoman", "author_id": 35903, "author_profile": "https://Stackoverflow.com/users/35903", "pm_score": 0, "selected": false, "text": "<p><strong>Regular expression:</strong></p>\n\n<pre><code>!(&lt;a.*&lt;/a&gt;.*)*Paris!isU\n</code></pre>\n\n<p><strong>Rep...
2008/11/09
[ "https://Stackoverflow.com/questions/276029", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35937/" ]
I want to write a regular expression that will replace the word Paris by a link, for only the word is not ready a part of a link. Example: ``` i'm living <a href="Paris" atl="Paris link">in Paris</a>, near Paris <a href="gare">Gare du Nord</a>, i love Paris. ``` would become ``` i'm living.........near <...
You could search for this regular expression: ``` (<a[^>]*>.*?</a>)|Paris ``` This regex matches a link, which it captures into the first (and only) capturing group, or the word Paris. Replace the match with your link only if the capturing group did not match anything. E.g. in C#: ``` resultString = Regex.Re...
276,033
<p>How would one go about deleting all of the directories in a directory tree that have a certain name if the only access to the server available is via FTP?</p> <p>To clarify, I would like to iterate over a directory tree and delete every directory whose name matches a certain string via FTP. A way to implement this...
[ { "answer_id": 276039, "author": "The Archetypal Paul", "author_id": 21755, "author_profile": "https://Stackoverflow.com/users/21755", "pm_score": 1, "selected": false, "text": "<p>Presumably there's more to this question than it first appears.</p>\n\n<p>FTP supports DIR to list director...
2008/11/09
[ "https://Stackoverflow.com/questions/276033", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3831/" ]
How would one go about deleting all of the directories in a directory tree that have a certain name if the only access to the server available is via FTP? To clarify, I would like to iterate over a directory tree and delete every directory whose name matches a certain string via FTP. A way to implement this in PHP wou...
Here is a starting point- a function that will scan through an FTP directory and print the name of any directory in the tree which matches the pattern. I have tested it briefly. ``` function scan_ftp_dir($conn, $dir, $pattern) { $files = ftp_nlist($conn, $dir); if (!$files) { return; } foreach...
276,040
<p>Generally I connect and retrieve data using the standard way (error checking removed for simplicity):</p> <pre><code>$db = mysql_select_db("dbname", mysql_connect("host","username","passord")); $items = mysql_query("SELECT * FROM $db"); while($item = mysql_fetch_array($items)) { my_function($item[rowname]); } ...
[ { "answer_id": 276059, "author": "Ólafur Waage", "author_id": 22459, "author_profile": "https://Stackoverflow.com/users/22459", "pm_score": 2, "selected": false, "text": "<p>You can use the mysql_fetch_object()</p>\n\n<p><a href=\"http://is2.php.net/manual/en/function.mysql-fetch-object....
2008/11/09
[ "https://Stackoverflow.com/questions/276040", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16511/" ]
Generally I connect and retrieve data using the standard way (error checking removed for simplicity): ``` $db = mysql_select_db("dbname", mysql_connect("host","username","passord")); $items = mysql_query("SELECT * FROM $db"); while($item = mysql_fetch_array($items)) { my_function($item[rowname]); } ``` Where my...
Since version 5.1, PHP is shipped with the PDO driver, which gives a class for prepared statements. ``` $dbh = new PDO("mysql:host=$hostname;dbname=$db", $username, $password); //connect to the database //each :keyword represents a parameter or value to be bound later $query= $dbh->prepare('SELECT * FROM users WHERE i...
276,052
<p>How can I get the current system status (current CPU, RAM, free disk space, etc.) in Python? Ideally, it would work for both Unix and Windows platforms.</p> <p>There seems to be a few possible ways of extracting that from my search:</p> <ol> <li><p>Using a library such as <a href="http://www.psychofx.com/psi/trac/wi...
[ { "answer_id": 276164, "author": "user35952", "author_id": 35952, "author_profile": "https://Stackoverflow.com/users/35952", "pm_score": -1, "selected": false, "text": "<p>I don't believe that there is a well-supported multi-platform library available. Remember that Python itself is writ...
2008/11/09
[ "https://Stackoverflow.com/questions/276052", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35935/" ]
How can I get the current system status (current CPU, RAM, free disk space, etc.) in Python? Ideally, it would work for both Unix and Windows platforms. There seems to be a few possible ways of extracting that from my search: 1. Using a library such as [PSI](http://www.psychofx.com/psi/trac/wiki/) (that currently see...
[The psutil library](https://pypi.python.org/pypi/psutil) gives you information about CPU, RAM, etc., on a variety of platforms: > > psutil is a module providing an interface for retrieving information on running processes and system utilization (CPU, memory) in a portable way by using Python, implementing many funct...
276,066
<p>I need a function count_permutations() that returns the number of permutations of a given range. <em>Assuming that the range is allowed to be modified, and starts at the first permutation,</em> I could naively implement this as repeated calls to next_permutation() as below:</p> <pre><code>template&lt;class Ret, cla...
[ { "answer_id": 276068, "author": "Can Berk Güder", "author_id": 2119, "author_profile": "https://Stackoverflow.com/users/2119", "pm_score": 4, "selected": true, "text": "<p>The number of permutations for a range where all the elements are unique is n! where n is the length of the range.<...
2008/11/09
[ "https://Stackoverflow.com/questions/276066", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5963/" ]
I need a function count\_permutations() that returns the number of permutations of a given range. *Assuming that the range is allowed to be modified, and starts at the first permutation,* I could naively implement this as repeated calls to next\_permutation() as below: ``` template<class Ret, class Iter> Ret count_per...
The number of permutations for a range where all the elements are unique is n! where n is the length of the range. If there are duplicate elements, you can use n!/(n\_0!)...(n\_m!) where n\_0...n\_m are the lengths of duplicate ranges. So for example [1,2,3] has 3! = 6 permutations while [1,2,2] has 3!/2! = 3 permuta...
276,072
<p>I just picked up Agile Web Development with Rails 3rd Ed., and I'm going thru the Depot Application chapters, and I have a question about Product/Item options.</p> <p>If I wanted to modify the product catalog and store so that products could have options (size, color, whatever), where/how would I do that?</p> <p>Let...
[ { "answer_id": 276083, "author": "Can Berk Güder", "author_id": 2119, "author_profile": "https://Stackoverflow.com/users/2119", "pm_score": 0, "selected": false, "text": "<p>I'd drop the <code>button_to</code> helper and use a proper form, submitting the product properties to the <code>a...
2008/11/09
[ "https://Stackoverflow.com/questions/276072", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I just picked up Agile Web Development with Rails 3rd Ed., and I'm going thru the Depot Application chapters, and I have a question about Product/Item options. If I wanted to modify the product catalog and store so that products could have options (size, color, whatever), where/how would I do that? Let's say I'm sell...
Ok, it's 2 days later, and I figured it out. This is what I had to do- 1, in my store view: ==================== ``` <% form_for @product, :url => {:action => "add_to_cart", :id => @product} do |f| %> <select name="productsize" id="productsize"> <option value="L">L</option> <option value="XL">XL</option> ...
276,087
<p>I am working on a web application that is designed to display a bunch of data that is updated periodically with AJAX. The general usage scenario would be that a user would leave it open all day and take a glance at it now and then.</p> <p>I am encountering a problem where the browsers memory footprint is growing ...
[ { "answer_id": 276092, "author": "Mr. Muskrat", "author_id": 2657951, "author_profile": "https://Stackoverflow.com/users/2657951", "pm_score": -1, "selected": false, "text": "<p>I may be wrong but it sounds like you are creating closures around the response object. Each response object w...
2008/11/09
[ "https://Stackoverflow.com/questions/276087", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12983/" ]
I am working on a web application that is designed to display a bunch of data that is updated periodically with AJAX. The general usage scenario would be that a user would leave it open all day and take a glance at it now and then. I am encountering a problem where the browsers memory footprint is growing slowly over ...
The biggest thing you can watch out for is events, and how you assign them. For instance, take this scenario (since you haven't provided one): ``` <div id="ajaxResponseTarget"> ... </div> <script type="text/javascript"> $(someButton).observe('click', function() { new Ajax.Updater($('ajaxResponseTarget...
276,088
<p>My ASP.NET application allows users to upload and download large files. Both procedures involve reading and writing filestreams. What should I do to ensure the application doesn't hang or crash when it handles a large file? Should the file operations be handled on a worker thread for example?</p>
[ { "answer_id": 276098, "author": "Turnkey", "author_id": 13144, "author_profile": "https://Stackoverflow.com/users/13144", "pm_score": 2, "selected": true, "text": "<p>Make sure you properly buffer the files so that they don't take inordinate amounts of memory in the system.</p>\n\n<p>e....
2008/11/09
[ "https://Stackoverflow.com/questions/276088", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27805/" ]
My ASP.NET application allows users to upload and download large files. Both procedures involve reading and writing filestreams. What should I do to ensure the application doesn't hang or crash when it handles a large file? Should the file operations be handled on a worker thread for example?
Make sure you properly buffer the files so that they don't take inordinate amounts of memory in the system. e.g. excerpt from a download application, inside the while loop that reads the file: ``` // Read the data in buffer. length = iStream.Read(buffer, 0, bufferSize); // Write the data to the current output stream...
276,099
<p>I want to read a mac id from command line and convert it to an array of <code>uint8_t</code> values to use it in a struct. I can not get it to work. I have a vector of string for the mac id split about <code>:</code> and I want to use <code>stringstream</code> to convert them with no luck. What I am missing?</p> <...
[ { "answer_id": 276149, "author": "Martin York", "author_id": 14065, "author_profile": "https://Stackoverflow.com/users/14065", "pm_score": 0, "selected": false, "text": "<p>I think you are using the std::hex in the wrong place:</p>\n\n<pre><code>#include &lt;sstream&gt;\n#include &lt;ios...
2008/11/09
[ "https://Stackoverflow.com/questions/276099", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29742/" ]
I want to read a mac id from command line and convert it to an array of `uint8_t` values to use it in a struct. I can not get it to work. I have a vector of string for the mac id split about `:` and I want to use `stringstream` to convert them with no luck. What I am missing? ``` int parseHex(const string &num){ str...
Your problem may be in the output of the parsed data. The "<<" operator makes decisions on how to display data based on the data type passed it, and uint8\_t may be getting interpretted as a char. Make sure you cast the array values to ints when printing, or investigate in a debugger. The sample program: ``` uint8_t ...
276,102
<p>Is there some way to catch exceptions which are otherwise unhandled (including those thrown outside the catch block)?</p> <p>I'm not really concerned about all the normal cleanup stuff done with exceptions, just that I can catch it, write it to log/notify the user and exit the program, since the exceptions in these...
[ { "answer_id": 276110, "author": "EvilTeach", "author_id": 7734, "author_profile": "https://Stackoverflow.com/users/7734", "pm_score": 6, "selected": true, "text": "<p>This can be used to catch unexpected exceptions.</p>\n\n<pre><code>catch (...)\n{\n std::cout &lt;&lt; \"OMG! an unex...
2008/11/09
[ "https://Stackoverflow.com/questions/276102", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6266/" ]
Is there some way to catch exceptions which are otherwise unhandled (including those thrown outside the catch block)? I'm not really concerned about all the normal cleanup stuff done with exceptions, just that I can catch it, write it to log/notify the user and exit the program, since the exceptions in these casese ar...
This can be used to catch unexpected exceptions. ``` catch (...) { std::cout << "OMG! an unexpected exception has been caught" << std::endl; } ``` Without a try catch block, I don't think you can catch exceptions, so structure your program so the exception thowing code is under the control of a try/catch.
276,121
<p>I have been using netbeans as a tool for my java, and i have a problem. I read <a href="http://www.netbeans.org/kb/61/java/gui-db-custom.html" rel="nofollow noreferrer">this tutorial</a> and then i tried to create a table using this SQL:</p> <pre><code>CREATE TABLE CUSTOMERS ( ID INTEGER NOT NULL AUTO_INCREMENT...
[ { "answer_id": 276129, "author": "fmsf", "author_id": 26004, "author_profile": "https://Stackoverflow.com/users/26004", "pm_score": 1, "selected": false, "text": "<p>my sugestion would be the following</p>\n\n<pre><code>CREATE TABLE CUSTOMERS \n( ID INTEGER NOT NULL auto_increment,\nFIRS...
2008/11/09
[ "https://Stackoverflow.com/questions/276121", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have been using netbeans as a tool for my java, and i have a problem. I read [this tutorial](http://www.netbeans.org/kb/61/java/gui-db-custom.html) and then i tried to create a table using this SQL: ``` CREATE TABLE CUSTOMERS ( ID INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, FIRST_NAME VARCHAR(20), LAST_...
You seem to be using MySQL syntax with another database engine. The parts it complained about are precisely the MySQL-specific ones.
276,126
<p>Using ASP.net 2.0, how do I present the information to the user similar to the Questions list on SO where each question has some child items (like the tags).</p> <p>I would probably be making two separate queries, one to first find the list of questions, then another query to find all tags which belonged to the lis...
[ { "answer_id": 276158, "author": "DOK", "author_id": 27637, "author_profile": "https://Stackoverflow.com/users/27637", "pm_score": 1, "selected": false, "text": "<p>If you do two separate queries, you can still make them in one call to the database, and get back two resultsets.</p>\n\n<p...
2008/11/09
[ "https://Stackoverflow.com/questions/276126", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32372/" ]
Using ASP.net 2.0, how do I present the information to the user similar to the Questions list on SO where each question has some child items (like the tags). I would probably be making two separate queries, one to first find the list of questions, then another query to find all tags which belonged to the list of quest...
I would definitely avoid the second approach - you don't want to hit the database everytime you databind a parent item. As DOK says, try and architect your system properly. For me that would mean populating a collection of business objects and binding to it. I do something similar with a custom menu control (note this ...
276,132
<p>I'm setting up an Internet-facing ASP.NET MVC application, on Windows 2008. It uses SQL Server 2008 for its database. I'm looking for best-practices for securing it.</p> <p>I found <a href="http://www.enterprisenetworkingplanet.com/netsecur/article.php/3552711" rel="nofollow noreferrer">this article</a>, but it's a...
[ { "answer_id": 276158, "author": "DOK", "author_id": 27637, "author_profile": "https://Stackoverflow.com/users/27637", "pm_score": 1, "selected": false, "text": "<p>If you do two separate queries, you can still make them in one call to the database, and get back two resultsets.</p>\n\n<p...
2008/11/09
[ "https://Stackoverflow.com/questions/276132", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8446/" ]
I'm setting up an Internet-facing ASP.NET MVC application, on Windows 2008. It uses SQL Server 2008 for its database. I'm looking for best-practices for securing it. I found [this article](http://www.enterprisenetworkingplanet.com/netsecur/article.php/3552711), but it's a bit dated now. How much of that advice is stil...
I would definitely avoid the second approach - you don't want to hit the database everytime you databind a parent item. As DOK says, try and architect your system properly. For me that would mean populating a collection of business objects and binding to it. I do something similar with a custom menu control (note this ...
276,166
<p>table data of 2 columns "category" and "subcategory"</p> <p>i want to get a collection of "category", [subcategories] using code below i get duplicates. Puting .Distinct() after outer "from" does not help much. What do i miss?</p> <pre><code> var rootcategories = (from p in sr.products ...
[ { "answer_id": 276171, "author": "chakrit", "author_id": 3055, "author_profile": "https://Stackoverflow.com/users/3055", "pm_score": 2, "selected": false, "text": "<p>I think you need 2 \"Distinct()\" calls, one for the main categories and another for the subcategories.</p>\n\n<p>This sh...
2008/11/09
[ "https://Stackoverflow.com/questions/276166", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35954/" ]
table data of 2 columns "category" and "subcategory" i want to get a collection of "category", [subcategories] using code below i get duplicates. Puting .Distinct() after outer "from" does not help much. What do i miss? ``` var rootcategories = (from p in sr.products orderby p.catego...
solved with this code ``` var rootcategories2 = (from p in sr.products group p.subcategory by p.category into subcats select subcats); ``` thanks everyone
276,173
<p>What are your favorite C++ coding style idioms? I'm asking about style or coding typography such as where you put curly braces, are there spaces after keywords, the size of indents, etc. This is opposed to best-practices or requirements such as always deleting arrays with <code>delete[]</code>. </p> <p>Here is a...
[ { "answer_id": 276201, "author": "Ather", "author_id": 1065163, "author_profile": "https://Stackoverflow.com/users/1065163", "pm_score": 1, "selected": false, "text": "<p>Write each method or function argument on a separate line such that it can be easily commented.</p>\n\n<pre><code>int...
2008/11/09
[ "https://Stackoverflow.com/questions/276173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18256/" ]
What are your favorite C++ coding style idioms? I'm asking about style or coding typography such as where you put curly braces, are there spaces after keywords, the size of indents, etc. This is opposed to best-practices or requirements such as always deleting arrays with `delete[]`. Here is an example of one of my f...
When creating enumerations, put them in a namespace so that you can access them with a meaningful name: ``` namespace EntityType { enum Enum { Ground = 0, Human, Aerial, Total }; } void foo(EntityType::Enum entityType) { if (entityType == EntityType::Ground) { /*cod...
276,177
<p>In my ASP.NET 1.1 application, I am compressing and replacing the hidden Viewstate variable with an alternate compressed value, stored in a hidden field called __VSTATE. This works well but on a few occasions, submitting a page causes the common "potentially dangerous Request.Form value ..." error.</p> <p>I examine...
[ { "answer_id": 276270, "author": "chakrit", "author_id": 3055, "author_profile": "https://Stackoverflow.com/users/3055", "pm_score": 1, "selected": false, "text": "<p>My first guess is that it looks like a \"OnSomething=\" javascript event declaration.</p>\n\n<p>It's a little weird that ...
2008/11/09
[ "https://Stackoverflow.com/questions/276177", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35955/" ]
In my ASP.NET 1.1 application, I am compressing and replacing the hidden Viewstate variable with an alternate compressed value, stored in a hidden field called \_\_VSTATE. This works well but on a few occasions, submitting a page causes the common "potentially dangerous Request.Form value ..." error. I examined the \_...
My first guess is that it looks like a "OnSomething=" javascript event declaration. It's a little weird that only the capital O triggers the error, did you test on the lowercase o as well? Can you try these: "OnClick=", "abc OnClick=", "onclick=", "abc onclick=", "anw=", "bnw=", ... --- If "OnSomething=x" javascrip...
276,188
<p>C++0x will allow template to take an arbitrary number of arguments. What is the best use of this feature other than implementing tuples ?</p>
[ { "answer_id": 276197, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 2, "selected": false, "text": "<ul>\n<li>Type-safe <code>printf</code></li>\n</ul>\n" }, { "answer_id": 276223, "author": "1800 INFORMAT...
2008/11/09
[ "https://Stackoverflow.com/questions/276188", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19630/" ]
C++0x will allow template to take an arbitrary number of arguments. What is the best use of this feature other than implementing tuples ?
1. **Type-safe printf** 2. Forwarding of arbitrary many constructor arguments in **factory methods** 3. Having **arbitrary** base-classes allows for putting and removing useful **policies**. 4. Initializing by moving **heterogenous typed objects** directly into a container by having a variadic template'd constructor. 5...
276,198
<p>What would be the best way to manage large number of instances of the same class in MATLAB?</p> <p>Using the naive way produces absymal results:</p> <pre><code>classdef Request properties num=7; end methods function f=foo(this) f = this.num + 4; end end end &gt;...
[ { "answer_id": 276530, "author": "Marc", "author_id": 8478, "author_profile": "https://Stackoverflow.com/users/8478", "pm_score": 2, "selected": false, "text": "<p><code>repmat</code> is your friend:</p>\n\n<pre><code>b = repmat(Request, 1000, 1);\n\nElapsed time is 0.056720 seconds\n\n\...
2008/11/09
[ "https://Stackoverflow.com/questions/276198", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28772/" ]
What would be the best way to manage large number of instances of the same class in MATLAB? Using the naive way produces absymal results: ``` classdef Request properties num=7; end methods function f=foo(this) f = this.num + 4; end end end >> a=[]; >> tic,for i=...
This solution expands on [Marc's answer](https://stackoverflow.com/questions/276198/matlab-class-array#276530). Use **repmat** to initialize an array of RequestH objects and then use a loop to create the desired objects: ``` >> a = repmat(RequestH,10000,1);tic,for i=1:10000 a(i)=RequestH;end;toc Elapsed time is 0.3966...
276,206
<p>I have a form made up of multiple, optional subparts - each of which is enclosed in a</p> <pre><code>&lt;div class="details"&gt;&lt;/div&gt; </code></pre> <p>When editing the form I would like to hide those subparts which aren't as yet completed, and obviously I would like to do it unobtrusively. To simplify thing...
[ { "answer_id": 276221, "author": "Cristian Libardo", "author_id": 16526, "author_profile": "https://Stackoverflow.com/users/16526", "pm_score": 4, "selected": true, "text": "<p>No selector love? Not exactly sure it's what you're really looking for but this hides all details elements with...
2008/11/09
[ "https://Stackoverflow.com/questions/276206", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35961/" ]
I have a form made up of multiple, optional subparts - each of which is enclosed in a ``` <div class="details"></div> ``` When editing the form I would like to hide those subparts which aren't as yet completed, and obviously I would like to do it unobtrusively. To simplify things I'm just checking to see if those fi...
No selector love? Not exactly sure it's what you're really looking for but this hides all details elements with an empty input inside. Perhaps it's a clue. ``` <div class="details"> <input type="text" name="surname" /> </div> <script type="text/javascript"> $(".details input[@value='']").parents(".details").h...
276,212
<p>I have a table in a database that represents dates textually (i.e. "2008-11-09") and I would like to replace them with the UNIX timestamp. However, I don't think that MySQL is capable of doing the conversion on its own, so I'd like to write a little script to do the conversion. The way I can think to do it involves ...
[ { "answer_id": 276225, "author": "technophile", "author_id": 23029, "author_profile": "https://Stackoverflow.com/users/23029", "pm_score": 1, "selected": false, "text": "<p>If for some reason you do have to iterate (the other answers cover the situation where you don't), I can think of t...
2008/11/09
[ "https://Stackoverflow.com/questions/276212", "https://Stackoverflow.com", "https://Stackoverflow.com/users/658/" ]
I have a table in a database that represents dates textually (i.e. "2008-11-09") and I would like to replace them with the UNIX timestamp. However, I don't think that MySQL is capable of doing the conversion on its own, so I'd like to write a little script to do the conversion. The way I can think to do it involves get...
Does this not do it? ``` UPDATE MyTable SET MyTimeStamp = UNIX_TIMESTAMP(MyDateTime); ```
276,249
<p>I have this form:</p> <pre><code>&lt;form name="customize"&gt; Only show results within &lt;select name="distance" id="slct_distance"&gt; &lt;option&gt;25&lt;/option&gt; &lt;option&gt;50&lt;/option&gt; &lt;option&gt;100&lt;/option&gt; &lt;option value="10...
[ { "answer_id": 276267, "author": "okoman", "author_id": 35903, "author_profile": "https://Stackoverflow.com/users/35903", "pm_score": 2, "selected": false, "text": "<p>For me your suggestion worked. You could also use</p>\n\n<pre><code>form[name='customize'] select, form[name='customize'...
2008/11/09
[ "https://Stackoverflow.com/questions/276249", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13009/" ]
I have this form: ``` <form name="customize"> Only show results within <select name="distance" id="slct_distance"> <option>25</option> <option>50</option> <option>100</option> <option value="10000" selected="selected">Any</option> </select> miles of zip ...
The comma in the selector string separates completely separate expressions, just like in CSS, so the selector you've given gets the select elements within the form named "customize" and all inputs on the form (as you've described). It sounds like you want something like this: ``` $("form[name='customize'] select, form...
276,253
<p>C#: How do you pass an object in a function parameter?</p> <pre><code>public void MyFunction(TextBox txtField) { txtField.Text = "Hi."; } </code></pre> <p>Would the above be valid? Or?</p>
[ { "answer_id": 276263, "author": "Timothy Carter", "author_id": 4660, "author_profile": "https://Stackoverflow.com/users/4660", "pm_score": 4, "selected": true, "text": "<p>So long as you're not in a different thread, yes the code sample is valid. A textbox (or other windows forms items)...
2008/11/09
[ "https://Stackoverflow.com/questions/276253", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
C#: How do you pass an object in a function parameter? ``` public void MyFunction(TextBox txtField) { txtField.Text = "Hi."; } ``` Would the above be valid? Or?
So long as you're not in a different thread, yes the code sample is valid. A textbox (or other windows forms items) are still objects that can be passed to and manipulated by methods.
276,254
<p>I have a window (derived from JFrame) and I want to disable the close button during certain operations which are not interruptible. I know I can make the button not do anything (or call a handler in a WindowListener) by calling</p> <pre><code>setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); </code></pre> <p>...
[ { "answer_id": 276482, "author": "bdumitriu", "author_id": 35415, "author_profile": "https://Stackoverflow.com/users/35415", "pm_score": 4, "selected": true, "text": "<p>If I understand it correctly, <a href=\"http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6199687\" rel=\"noreferrer\...
2008/11/09
[ "https://Stackoverflow.com/questions/276254", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18308/" ]
I have a window (derived from JFrame) and I want to disable the close button during certain operations which are not interruptible. I know I can make the button not do anything (or call a handler in a WindowListener) by calling ``` setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); ``` but I would like to make it...
If I understand it correctly, [this bug report](http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6199687) indicates that this is currently not possible.
276,266
<p>I tried playing a .wav file using pyaudio. It works great on windows, but doesn't work in Ubuntu when another device is using sound.</p> <blockquote> <p>The error is "IOError: [Errorno Invalid output device (no default output device)] -9996</p> </blockquote> <p>Is there another library I could try to use? An...
[ { "answer_id": 276322, "author": "lpfavreau", "author_id": 35935, "author_profile": "https://Stackoverflow.com/users/35935", "pm_score": 2, "selected": false, "text": "<p>Have you looked at pymedia? It looks as easy as this to play a WAV file:</p>\n\n<pre><code>import time, wave, pymedia...
2008/11/09
[ "https://Stackoverflow.com/questions/276266", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14520/" ]
I tried playing a .wav file using pyaudio. It works great on windows, but doesn't work in Ubuntu when another device is using sound. > > The error is "IOError: [Errorno > Invalid output device (no default > output device)] -9996 > > > Is there another library I could try to use? Another method?
You can use [wxPython](http://wxpython.org/) ``` sound = wx.Sound('sound.wav') sound.Play(wx.SOUND_SYNC) ``` or ``` sound.Play(wx.SOUND_ASYNC) ``` [Here](http://svn.wxwidgets.org/viewvc/wx/wxPython/tags/wxPy-2.8.9.1/wxPython/demo/Sound.py?view=markup) is an example from the wxPython demo.
276,278
<p>Comparing LinkedLists and Arrays while also comparing their differences with sorted and unsorted data</p> <ul> <li>Adding </li> <li>Removing</li> <li>Retrieving </li> <li>Sorting</li> <li>Overall speed</li> <li>Overall memory usage</li> </ul> <p>Actual questions</p> <blockquote> <p>Discuss the feasibility of im...
[ { "answer_id": 276314, "author": "Martin v. Löwis", "author_id": 33006, "author_profile": "https://Stackoverflow.com/users/33006", "pm_score": 2, "selected": false, "text": "<p>Not sure what class this is for, but for a CS program, you will have to do better than \"is slow\" and \"is fas...
2008/11/09
[ "https://Stackoverflow.com/questions/276278", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27570/" ]
Comparing LinkedLists and Arrays while also comparing their differences with sorted and unsorted data * Adding * Removing * Retrieving * Sorting * Overall speed * Overall memory usage Actual questions > > Discuss the feasibility of implementing an unsorted data set as a linked list rather than an array. What would ...
On unsorted vs. sorted. I'll do one, then you really do need to do your homework Stackoverflow markup really needs tables to do this one. You want to say how "expensive" the operation is for the unsorted/array, sorted/array, unsorted/linked-list, sorted/linked-list One final point: "speed of the application" is a hin...
276,281
<p>Is it possible for me to see the amount of processor usage (% of maximum) that the current, python, app is using?</p> <p>Scenario: My host will allow me to run my app as long as it does not consume more then X% of the CPU power, so I would like it to 'keep an eye on itself' and slowdown. So how can I know how muc...
[ { "answer_id": 276289, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 3, "selected": false, "text": "<p>The <code>resource</code> module provides <a href=\"http://www.python.org/doc/2.5.2/lib/node522.html\" rel=\"nofollow ...
2008/11/09
[ "https://Stackoverflow.com/questions/276281", "https://Stackoverflow.com", "https://Stackoverflow.com/users/115/" ]
Is it possible for me to see the amount of processor usage (% of maximum) that the current, python, app is using? Scenario: My host will allow me to run my app as long as it does not consume more then X% of the CPU power, so I would like it to 'keep an eye on itself' and slowdown. So how can I know how much CPU the a...
``` >>> import os >>> os.times() (1.296875, 0.765625, 0.0, 0.0, 0.0) >>> print os.times.__doc__ times() -> (utime, stime, cutime, cstime, elapsed_time) Return a tuple of floating point numbers indicating process times. ``` From the (2.5) manual: > > times( ) > > > Return a 5-tuple of floating point numbers indic...
276,286
<p>When a webpage has moved to a new location, how do I show the moved web page AND return a 301 permanent redirect HTTP response status code in <a href="http://djangoproject.com/" rel="nofollow noreferrer">Django</a>?</p>
[ { "answer_id": 276323, "author": "Peter Rowell", "author_id": 17017, "author_profile": "https://Stackoverflow.com/users/17017", "pm_score": 2, "selected": false, "text": "<p>You can't.</p>\n\n<p>301 is an HTTP return code that is directly acted upon by the browser. Many sites handle thes...
2008/11/09
[ "https://Stackoverflow.com/questions/276286", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11452/" ]
When a webpage has moved to a new location, how do I show the moved web page AND return a 301 permanent redirect HTTP response status code in [Django](http://djangoproject.com/)?
``` from django import http return http.HttpResponsePermanentRedirect('/yournewpage.html') ``` the browser will get the 301, and go to `/yournewpage.html` as expected. the other answer is technically correct, in that python is not handling the redirection per se, the browser is. this is what's happening under ...
276,292
<p>How can I continuously capture images from a webcam?</p> <p>I want to experiment with object recognition (by maybe using java media framework). </p> <p>I was thinking of creating two threads</p> <p>one thread:</p> <ul> <li>Node 1: capture live image</li> <li>Node 2: save image as "1.jpg"</li> <li>Node 3: wait 5 ...
[ { "answer_id": 276775, "author": "goldenmean", "author_id": 2759376, "author_profile": "https://Stackoverflow.com/users/2759376", "pm_score": 0, "selected": false, "text": "<p>I believe the web-cam application software which comes along with the web-cam, or you native windows webcam soft...
2008/11/09
[ "https://Stackoverflow.com/questions/276292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35962/" ]
How can I continuously capture images from a webcam? I want to experiment with object recognition (by maybe using java media framework). I was thinking of creating two threads one thread: * Node 1: capture live image * Node 2: save image as "1.jpg" * Node 3: wait 5 seconds * Node 4: repeat... other thread: * Nod...
This JavaCV implementation works fine. Code: ``` import org.bytedeco.javacv.*; import org.bytedeco.opencv.opencv_core.IplImage; import java.io.File; import static org.bytedeco.opencv.global.opencv_core.cvFlip; import static org.bytedeco.opencv.helper.opencv_imgcodecs.cvSaveImage; public class Test implements Runna...
276,319
<p>Is there a way to create a Zip archive that contains multiple files, when the files are currently in memory? The files I want to save are really just text only and are stored in a string class in my application. But I would like to save multiple files in a single self-contained archive. They can all be in the roo...
[ { "answer_id": 276330, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": false, "text": "<p>Yes, you can use SharpZipLib to do this - when you need to supply a stream to write to, use a <code>MemoryStream</cod...
2008/11/09
[ "https://Stackoverflow.com/questions/276319", "https://Stackoverflow.com", "https://Stackoverflow.com/users/194/" ]
Is there a way to create a Zip archive that contains multiple files, when the files are currently in memory? The files I want to save are really just text only and are stored in a string class in my application. But I would like to save multiple files in a single self-contained archive. They can all be in the root of t...
Use `ZipEntry` and `PutNextEntry()` for this. The following shows how to do it for a file, but for an in-memory object just use a MemoryStream ``` FileStream fZip = File.Create(compressedOutputFile); ZipOutputStream zipOStream = new ZipOutputStream(fZip); foreach (FileInfo fi in allfiles) { ZipEntry entry = new Zi...
276,324
<p>I'm trying to create a horizontal navigation bar in css with 5 evenly spaced links. The html hopefully will remain like this:</p> <pre><code>&lt;div id="footer"&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="one.html"&gt;One&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="two.html"&gt;Two&lt;/a&gt;&lt;/li&gt; ...
[ { "answer_id": 276333, "author": "mercutio", "author_id": 1951, "author_profile": "https://Stackoverflow.com/users/1951", "pm_score": 4, "selected": false, "text": "<p>If you use this:</p>\n\n<pre><code>div#footer li{\n width:160px;\n display:block;\n float: left;\n text-align:center...
2008/11/09
[ "https://Stackoverflow.com/questions/276324", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to create a horizontal navigation bar in css with 5 evenly spaced links. The html hopefully will remain like this: ``` <div id="footer"> <ul> <li><a href="one.html">One</a></li> <li><a href="two.html">Two</a></li> <li><a href="three.html">Three</a></li> <li><a href="four....
I've had this happen to me. Unfortunately it is caused by the browser taking the line breaks between the list items and rendering them as spaces. To fix, change your HTML to: ``` <div id="footer"> <ul> <li><a href="one.html">One</a></li><li><a href="two.html">Two</a></li><li><a href="three.html">Three</a></li><l...
276,336
<p>This is what I am working with to get back to the web dev world</p> <p>ASP.Net with VS2008</p> <p>Subsonic as Data Access Layer</p> <p>SqlServer DB</p> <p>Home Project description: I have a student registration system. I have a web page which should display the student records. </p> <p>At present I have a grid...
[ { "answer_id": 276369, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 1, "selected": false, "text": "<p>I use LINQ-to-SQL, not Subsonic, so YMMV, but my approach to filtering has been to supply an OnSelecting handler to ...
2008/11/09
[ "https://Stackoverflow.com/questions/276336", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
This is what I am working with to get back to the web dev world ASP.Net with VS2008 Subsonic as Data Access Layer SqlServer DB Home Project description: I have a student registration system. I have a web page which should display the student records. At present I have a gridview control which shows the records T...
I use LINQ-to-SQL, not Subsonic, so YMMV, but my approach to filtering has been to supply an OnSelecting handler to the data source. In LINQ-to-SQL, I'm able to replace the result with a reference to a DataContext method that returns a the result of applying a table-valued function. You might want to investigate someth...
276,345
<p>I'm trying to do the following in my Django template:</p> <pre><code> {% for embed in embeds %} {% embed2 = embed.replace("&amp;lt;", "&lt;") %} {{embed2}}&lt;br /&gt; {% endfor %} </code></pre> <p>However, I always get an invalid block or some syntax error when I do anything like that...
[ { "answer_id": 276372, "author": "Hannes Ovrén", "author_id": 13565, "author_profile": "https://Stackoverflow.com/users/13565", "pm_score": 3, "selected": false, "text": "<p>I am quite sure that Django templates does not support that.\nFor your replace operation I would look into differe...
2008/11/09
[ "https://Stackoverflow.com/questions/276345", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23695/" ]
I'm trying to do the following in my Django template: ``` {% for embed in embeds %} {% embed2 = embed.replace("&lt;", "<") %} {{embed2}}<br /> {% endfor %} ``` However, I always get an invalid block or some syntax error when I do anything like that (by that I mean {% %} code inside a lo...
Instead of using a slice assignment to grow a list `embed_list[len(embed_list):] = [foo]` you should probably just do `embed_list.append(foo)` But really you should try unescaping html with a library function rather than doing it yourself. That NoneType error sounds like embed.replace is None at some point, which ...
276,355
<p>I could really do with updating a user's session variables from within my HTTPModule, but from what I can see, it isn't possible.</p> <p><em>UPDATE:</em> My code is currently running inside the <code>OnBeginRequest ()</code> event handler.</p> <p><em>UPDATE:</em> Following advice received so far, I tried adding th...
[ { "answer_id": 276364, "author": "mdb", "author_id": 8562, "author_profile": "https://Stackoverflow.com/users/8562", "pm_score": 5, "selected": false, "text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/system.web.httpcontext.session.aspx\" rel=\"noreferrer\">HttpContext.Curren...
2008/11/09
[ "https://Stackoverflow.com/questions/276355", "https://Stackoverflow.com", "https://Stackoverflow.com/users/475/" ]
I could really do with updating a user's session variables from within my HTTPModule, but from what I can see, it isn't possible. *UPDATE:* My code is currently running inside the `OnBeginRequest ()` event handler. *UPDATE:* Following advice received so far, I tried adding this to the `Init ()` routine in my HTTPModu...
Found this over on the [ASP.NET forums](http://forums.asp.net/p/1098574/1665773.aspx): ``` using System; using System.Web; using System.Web.Security; using System.Web.SessionState; using System.Diagnostics; // This code demonstrates how to make session state available in HttpModule, // regardless of requested resourc...
276,360
<p>Optimization of PHP code via runtime benchmarking is straight forward. Keep track of $start and $end times via microtime() around a code block - I am not looking for an answer that involves microtime() usage.</p> <p>What I would like to do is measure the time it takes PHP to get prepared to run it's code - code-pa...
[ { "answer_id": 276366, "author": "mercutio", "author_id": 1951, "author_profile": "https://Stackoverflow.com/users/1951", "pm_score": 2, "selected": false, "text": "<p>One method could be timing the execution of the script from the command line.</p>\n\n<p>In Linux for example:</p>\n\n<pr...
2008/11/09
[ "https://Stackoverflow.com/questions/276360", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12694/" ]
Optimization of PHP code via runtime benchmarking is straight forward. Keep track of $start and $end times via microtime() around a code block - I am not looking for an answer that involves microtime() usage. What I would like to do is measure the time it takes PHP to get prepared to run it's code - code-parse/op-code...
Yes. There is. ``` <?php return; rest of the code ?> ``` or ``` <?php whole code; $%^parse erorr!@! ?> ``` and then compare time of running empty script ``` time php empty.php ``` with time it takes to run (or fail) regular script with the additions I've mentioned above: ``` time php test.php ``` I've used ...
276,362
<p>I'm working on a project for OSX where the user can pick a collection of documents (from any application) which I need to generate PDF's from. The standard Macintosh Print dialog has a PDF button which has a number of PDF-related commands including "Save as PDF...". However, I need to generate the PDF file without ...
[ { "answer_id": 277015, "author": "Timour", "author_id": 21105, "author_profile": "https://Stackoverflow.com/users/21105", "pm_score": 4, "selected": true, "text": "<p>I think you could use applescript to open a document and then use <a href=\"https://developer.apple.com/library/content/...
2008/11/09
[ "https://Stackoverflow.com/questions/276362", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35958/" ]
I'm working on a project for OSX where the user can pick a collection of documents (from any application) which I need to generate PDF's from. The standard Macintosh Print dialog has a PDF button which has a number of PDF-related commands including "Save as PDF...". However, I need to generate the PDF file without requ...
I think you could use applescript to open a document and then use [applescript UI scripting](https://developer.apple.com/library/content/documentation/LanguagesUtilities/Conceptual/MacAutomationScriptingGuide/AutomatetheUserInterface.html) to invoke print menu. For example : ``` tell application "System Events" ...
276,382
<p>In my app users need to be able to enter numeric values with decimal places. The iPhone doesn't provides a keyboard that's specific for this purpose - only a number pad and a keyboard with numbers and symbols.</p> <p>Is there an easy way to use the latter and prevent any non-numeric input from being entered without...
[ { "answer_id": 276437, "author": "Martin v. Löwis", "author_id": 33006, "author_profile": "https://Stackoverflow.com/users/33006", "pm_score": 2, "selected": false, "text": "<p>Depending on the specific application, providing a slider that the user can select a position from might be a b...
2008/11/09
[ "https://Stackoverflow.com/questions/276382", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1043/" ]
In my app users need to be able to enter numeric values with decimal places. The iPhone doesn't provides a keyboard that's specific for this purpose - only a number pad and a keyboard with numbers and symbols. Is there an easy way to use the latter and prevent any non-numeric input from being entered without having to...
A more elegant solution happens to also be the simplest. *You don't need a decimal separator key* Why? Because you can simply infer it from the user's input. For instance, in the US locale when you what to enter in $1.23, you start by entering the numbers 1-2-3 (in that order). In the system, as each character is ent...
276,383
<p>I have a Dictionary that when I add multiple values to it, the items that were entered before take the values of the item added. I am using the .Net 3.5 Here is the code:</p> <pre><code>public static Dictionary&lt;string, Neighborhoods&gt; Families() { if (File.Exists(calculatePath() + "Family.txt")){} ...
[ { "answer_id": 276411, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 2, "selected": false, "text": "<p>From the looks of it, you want to parse a file, and load it into a Dictionary collection.</p>\n\n<p>A couple critiques......
2008/11/09
[ "https://Stackoverflow.com/questions/276383", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35984/" ]
I have a Dictionary that when I add multiple values to it, the items that were entered before take the values of the item added. I am using the .Net 3.5 Here is the code: ``` public static Dictionary<string, Neighborhoods> Families() { if (File.Exists(calculatePath() + "Family.txt")){} else {File.C...
With the sample data you've given and the code you've given, it works okay using a `Neighborhoods` class like this: ``` public class Neighborhoods { public string Name { get; set; } public string Neighbourhood_Input1 { get; set; } public string University_Input1 { get; set; } public string Downtown_Inp...
276,443
<p>I'm developing a PHP website that uses url routing. I'd like the site to be directory independent, so that it could be moved from <a href="http://site.example.com/" rel="noreferrer">http://site.example.com/</a> to <a href="http://example.com/site/" rel="noreferrer">http://example.com/site/</a> without having to chan...
[ { "answer_id": 276444, "author": "Tom Haigh", "author_id": 22224, "author_profile": "https://Stackoverflow.com/users/22224", "pm_score": 4, "selected": true, "text": "<p>You could put in the head</p>\n\n<pre><code>&lt;base href=\"&lt;?php echo url::base(); ?&gt;\" /&gt; \n</code></pre>\n...
2008/11/09
[ "https://Stackoverflow.com/questions/276443", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35951/" ]
I'm developing a PHP website that uses url routing. I'd like the site to be directory independent, so that it could be moved from <http://site.example.com/> to <http://example.com/site/> without having to change every path in the HTML. The problem comes up when I'm linking to files which are not subject to routing, lik...
You could put in the head ``` <base href="<?php echo url::base(); ?>" /> ``` This will mean the browser will request any non-absolute URLs relative to that path. However I am not sure how this would affect URLs embedded in CSS files etc. This does not affect paths defined in CSS files. (thanks mooware)
276,479
<p>I saw a potential answer here but that was for YYYY-MM-DD: <a href="http://paulschreiber.com/blog/2007/03/02/javascript-date-validation/" rel="noreferrer">JavaScript date validation</a></p> <p>I modified the code code above for MM-DD-YYYY like so but I still can't get it to work:</p> <pre><code>String.prototype.is...
[ { "answer_id": 276488, "author": "Kevin Gorski", "author_id": 35806, "author_profile": "https://Stackoverflow.com/users/35806", "pm_score": 1, "selected": false, "text": "<p>You can simplify it somewhat by changing the first two lines of the function to this:</p>\n\n<pre><code>var matche...
2008/11/09
[ "https://Stackoverflow.com/questions/276479", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3401/" ]
I saw a potential answer here but that was for YYYY-MM-DD: [JavaScript date validation](http://paulschreiber.com/blog/2007/03/02/javascript-date-validation/) I modified the code code above for MM-DD-YYYY like so but I still can't get it to work: ``` String.prototype.isValidDate = function() { var IsoDateRe = ne...
``` function isValidDate(date) { var matches = /^(\d{1,2})[-\/](\d{1,2})[-\/](\d{4})$/.exec(date); if (matches == null) return false; var d = matches[2]; var m = matches[1] - 1; var y = matches[3]; var composedDate = new Date(y, m, d); return composedDate.getDate() == d && compos...
276,489
<p>We'll soon be embarking on the development of a new mobile application. This particular app will be used for heavy searching of text based fields. Any suggestions from the group at large for what sort of database engine is best suited to allowing these types of searches on a mobile platform?</p> <p>Specifics includ...
[ { "answer_id": 276541, "author": "Wayne Bloss", "author_id": 16387, "author_profile": "https://Stackoverflow.com/users/16387", "pm_score": 2, "selected": false, "text": "<p>You could try Lucene.Net. I'm not sure how well it's suited to mobile devices, but it is billed as a \"high-perform...
2008/11/09
[ "https://Stackoverflow.com/questions/276489", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26853/" ]
We'll soon be embarking on the development of a new mobile application. This particular app will be used for heavy searching of text based fields. Any suggestions from the group at large for what sort of database engine is best suited to allowing these types of searches on a mobile platform? Specifics include Windows ...
Just recently I had the same issue. Here is what I did: I created a class to hold just an id and the text for each object (in my case I called it a sku (item number) and a description). This creates a smaller object that uses less memory since it is only used for searching. I'll still grab the full-blown objects from ...
276,499
<p>I have a custom UILabel subclass for displaying currency values. I only want the user to be able to enter digits and let the view format those digits into a currency value -- like a cash register. This makes UITextField an inappropriate choice for this kind of input.</p> <p>I've already overridden hitTest: so that ...
[ { "answer_id": 276541, "author": "Wayne Bloss", "author_id": 16387, "author_profile": "https://Stackoverflow.com/users/16387", "pm_score": 2, "selected": false, "text": "<p>You could try Lucene.Net. I'm not sure how well it's suited to mobile devices, but it is billed as a \"high-perform...
2008/11/09
[ "https://Stackoverflow.com/questions/276499", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35999/" ]
I have a custom UILabel subclass for displaying currency values. I only want the user to be able to enter digits and let the view format those digits into a currency value -- like a cash register. This makes UITextField an inappropriate choice for this kind of input. I've already overridden hitTest: so that the UILabe...
Just recently I had the same issue. Here is what I did: I created a class to hold just an id and the text for each object (in my case I called it a sku (item number) and a description). This creates a smaller object that uses less memory since it is only used for searching. I'll still grab the full-blown objects from ...
276,512
<p>I have seen some very weird <code>for</code> loops when reading other people's code. I have been trying to search for a full syntax explanation for the <code>for</code> loop in C but it is very hard because the word "for" appears in unrelated sentences making the search almost impossible to Google effectively.</p> ...
[ { "answer_id": 276518, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 3, "selected": false, "text": "<p>The comma simply separates two expressions and is valid anywhere in C where a normal expression is allowed. These ...
2008/11/09
[ "https://Stackoverflow.com/questions/276512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26004/" ]
I have seen some very weird `for` loops when reading other people's code. I have been trying to search for a full syntax explanation for the `for` loop in C but it is very hard because the word "for" appears in unrelated sentences making the search almost impossible to Google effectively. This question came to my mind...
The comma is not exclusive of for loops; it is the comma operator. ``` x = (a, b); ``` will do first a, then b, then set x to the value of b. The for syntax is: ``` for (init; condition; increment) ... ``` Which is somewhat (ignoring `continue` and `break` for now) equivalent to: ``` init; while (condition)...
276,516
<p>I need to build a function which parses the domain from a URL.</p> <p>So, with</p> <pre><code>http://google.com/dhasjkdas/sadsdds/sdda/sdads.html </code></pre> <p>or</p> <pre><code>http://www.google.com/dhasjkdas/sadsdds/sdda/sdads.html </code></pre> <p>it should return <code>google.com</code></p> <p>with</p> <pre><...
[ { "answer_id": 276525, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 10, "selected": true, "text": "<p>Check out <a href=\"http://php.net/parse_url\" rel=\"noreferrer\"><code>parse_url()</code></a>:</p>\n\n<pre><code>$url = 'ht...
2008/11/09
[ "https://Stackoverflow.com/questions/276516", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26823/" ]
I need to build a function which parses the domain from a URL. So, with ``` http://google.com/dhasjkdas/sadsdds/sdda/sdads.html ``` or ``` http://www.google.com/dhasjkdas/sadsdds/sdda/sdads.html ``` it should return `google.com` with ``` http://google.co.uk/dhasjkdas/sadsdds/sdda/sdads.html ``` it should ret...
Check out [`parse_url()`](http://php.net/parse_url): ``` $url = 'http://google.com/dhasjkdas/sadsdds/sdda/sdads.html'; $parse = parse_url($url); echo $parse['host']; // prints 'google.com' ``` `parse_url` doesn't handle really badly mangled urls very well, but is fine if you generally expect decent urls.
276,524
<p>In rpc.h, the GUID structure is declared as follows:</p> <pre><code>typedef struct _GUID { DWORD Data1; WORD Data2; WORD Data3; BYTE Data[8]; } GUID; </code></pre> <p>I understand Data1, Data2, and Data3. They define the first, second, and third sets of hex digits when writing out a GUID (XXX...
[ { "answer_id": 276528, "author": "PW.", "author_id": 927, "author_profile": "https://Stackoverflow.com/users/927", "pm_score": 2, "selected": false, "text": "<p><a href=\"http://en.wikipedia.org/wiki/Globally_Unique_Identifier\" rel=\"nofollow noreferrer\">http://en.wikipedia.org/wiki/Gl...
2008/11/09
[ "https://Stackoverflow.com/questions/276524", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14972/" ]
In rpc.h, the GUID structure is declared as follows: ``` typedef struct _GUID { DWORD Data1; WORD Data2; WORD Data3; BYTE Data[8]; } GUID; ``` I understand Data1, Data2, and Data3. They define the first, second, and third sets of hex digits when writing out a GUID (XXXXXXXX-XXXX-XXXX-XXXX-XXXXXX...
It's because a GUID is a special case of a [UUID](http://en.wikipedia.org/wiki/UUID). For information on what all the fields mean, you can look at [RFC 4122](http://www.ietf.org/rfc/rfc4122.txt).
276,531
<p>If I have the LINQ objects:</p> <pre><code>public class SampleDataContext : DataContext { public Table&lt;Customer&gt; Customers { get { return this.GetTable&lt;Customer&gt;(); } } public SampleDataContext( string connectionString ) : base( connectionString ) { } } [Table( Name="dbo.tblCustomers" )] public...
[ { "answer_id": 276536, "author": "Wayne Bloss", "author_id": 16387, "author_profile": "https://Stackoverflow.com/users/16387", "pm_score": 2, "selected": false, "text": "<p>The simplest thing to do is to pass the DataContext into your method.</p>\n\n<p>However, you may also consider chan...
2008/11/09
[ "https://Stackoverflow.com/questions/276531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20382/" ]
If I have the LINQ objects: ``` public class SampleDataContext : DataContext { public Table<Customer> Customers { get { return this.GetTable<Customer>(); } } public SampleDataContext( string connectionString ) : base( connectionString ) { } } [Table( Name="dbo.tblCustomers" )] public class Customer { priv...
Kevin - I feel your pain... when you are building business logic around your business objects, there are times when you simply *have* to have access to the DataContext to which an object belongs, since not knowing the DataContext menas having to put your code in places that reduce the maintainability of your code. I w...
276,546
<p>Let's say you have a text file like this one: <a href="http://www.gutenberg.org/files/17921/17921-8.txt" rel="noreferrer">http://www.gutenberg.org/files/17921/17921-8.txt</a></p> <p>Does anyone has a good algorithm, or open-source code, to extract words from a text file? How to get all the words, while avoiding spe...
[ { "answer_id": 276554, "author": "GurdeepS", "author_id": 32484, "author_profile": "https://Stackoverflow.com/users/32484", "pm_score": 0, "selected": false, "text": "<p>You could try regex, using a pattern you've made, and run a count the number of times that pattern has been found.</p>...
2008/11/09
[ "https://Stackoverflow.com/questions/276546", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25645/" ]
Let's say you have a text file like this one: <http://www.gutenberg.org/files/17921/17921-8.txt> Does anyone has a good algorithm, or open-source code, to extract words from a text file? How to get all the words, while avoiding special characters, and keeping things like "it's", etc... I'm working in Java. Thanks
This sounds like the right job for regular expressions. Here is some Java code to give you an idea, in case you don't know how to start: ``` String input = "Input text, with words, punctuation, etc. Well, it's rather short."; Pattern p = Pattern.compile("[\\w']+"); Matcher m = p.matcher(input); while ( m.find() ) { ...
276,555
<p>I'm looking to implement something in Java along the lines of:</p> <pre><code>class Foo{ private int lorem; // private int ipsum; public setAttribute(String attr, int val){ //sets attribute based on name } public static void main(String [] args){ Foo f = new Foo(); f.setAttribute("lorem",1); f....
[ { "answer_id": 276561, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 3, "selected": false, "text": "<p>In general, you want to use Reflection. Here is a good introduction to the <a href=\"http://web.archive.org/web/200812...
2008/11/09
[ "https://Stackoverflow.com/questions/276555", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25985/" ]
I'm looking to implement something in Java along the lines of: ``` class Foo{ private int lorem; // private int ipsum; public setAttribute(String attr, int val){ //sets attribute based on name } public static void main(String [] args){ Foo f = new Foo(); f.setAttribute("lorem",1); f.setAttribute("...
Here's how you might implement `setAttribute` using reflection (I've renamed the function; there are different reflection functions for different field types): ``` public void setIntField(String fieldName, int value) throws NoSuchFieldException, IllegalAccessException { Field field = getClass().getDeclared...
276,575
<p>I am trying to migrate my .net remoting code to wcf but I'm finding it difficult. Can someone help me migrate this simple Remoting based program below to use WCF? The program implements a simple publisher/subscriber pattern where we have a single TemperatureProviderProgram that publishers to many TemperatureSubcrib...
[ { "answer_id": 277405, "author": "Alexandre Brisebois", "author_id": 18619, "author_profile": "https://Stackoverflow.com/users/18619", "pm_score": 1, "selected": false, "text": "<p>You will need to modify your logic a bit. If you want to migrate this app to <code>WCF</code>. You will nee...
2008/11/09
[ "https://Stackoverflow.com/questions/276575", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am trying to migrate my .net remoting code to wcf but I'm finding it difficult. Can someone help me migrate this simple Remoting based program below to use WCF? The program implements a simple publisher/subscriber pattern where we have a single TemperatureProviderProgram that publishers to many TemperatureSubcriberPr...
You will need to modify your logic a bit. If you want to migrate this app to `WCF`. You will need to have clients pull data from the service at regular intervals. You will also need a Windows service or application to host the `WCF` like the console you are using in the previous code.
276,585
<p>In vs2008, is it possible to write an extension methods which would apply to any enumeration.</p> <p>I know you can write extension methods against a specific enumeration, but I want to be able to every enumeration using a single extension method. Is this possible?</p>
[ { "answer_id": 276589, "author": "Greg Beech", "author_id": 13552, "author_profile": "https://Stackoverflow.com/users/13552", "pm_score": 7, "selected": true, "text": "<p>Yes, just code against the base <code>Enum</code> type, e.g.</p>\n\n<pre><code>public static void Something(this Enum...
2008/11/09
[ "https://Stackoverflow.com/questions/276585", "https://Stackoverflow.com", "https://Stackoverflow.com/users/100/" ]
In vs2008, is it possible to write an extension methods which would apply to any enumeration. I know you can write extension methods against a specific enumeration, but I want to be able to every enumeration using a single extension method. Is this possible?
Yes, just code against the base `Enum` type, e.g. ``` public static void Something(this Enum e) { // code here } ``` The down-side is you'll probably end up doing some quite nasty stuff like finding the real base type using [`Enum.GetUnderlyingType`](http://msdn.microsoft.com/en-us/library/system.enum.getunderly...
276,602
<p>In php I need to get the contents of a url (source) search for a string "maybe baby love you" and if it does not contain this then do x.</p>
[ { "answer_id": 276611, "author": "okoman", "author_id": 35903, "author_profile": "https://Stackoverflow.com/users/35903", "pm_score": 4, "selected": true, "text": "<p>Just read the contents of the page as you would read a file. PHP does the connection stuff for you. Then just look for th...
2008/11/09
[ "https://Stackoverflow.com/questions/276602", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26823/" ]
In php I need to get the contents of a url (source) search for a string "maybe baby love you" and if it does not contain this then do x.
Just read the contents of the page as you would read a file. PHP does the connection stuff for you. Then just look for the string via regex or simple string comparison. ``` $url = 'http://my.url.com/'; $data = file_get_contents( $url ); if ( strpos( 'maybe baby love you', $data ) === false ) { // do something }...
276,644
<p>A voice recorder doesn't need uncompressed Linear PCM audio. Compressed <code>AMR</code> would do fine. The iPhone framework built for recording audio is simple enough, but the only examples I've found for setting up the audio format (which come from Apple) use LinearPCM. I've tried various other combinations of ...
[ { "answer_id": 276794, "author": "goldenmean", "author_id": 2759376, "author_profile": "https://Stackoverflow.com/users/2759376", "pm_score": 2, "selected": false, "text": "<p>I guess AMR codec format is not supported my iPhone voice recorder app.</p>\n\n<p>May be one can try integrating...
2008/11/09
[ "https://Stackoverflow.com/questions/276644", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36007/" ]
A voice recorder doesn't need uncompressed Linear PCM audio. Compressed `AMR` would do fine. The iPhone framework built for recording audio is simple enough, but the only examples I've found for setting up the audio format (which come from Apple) use LinearPCM. I've tried various other combinations of values, but can't...
AMR codec is NOT supported for encoding/recording on the iPhone, albeit it is supported for playback: this is the reason the kAudioFormatAMR constant exists. [Official api](http://developer.apple.com/library/ios/#qa/qa1615/_index.html) says that supported encoding formats are: * **ALAC** (Apple Lossless) ~> kAudioFor...
276,654
<p>I have an initialization class that preloads content into a variable (probably a list or array). There will only be one instance of this initialization class but there will be many classes that need to access the preloaded content.</p> <p>The problem is not many of them are related and none of them extend my initi...
[ { "answer_id": 276659, "author": "okoman", "author_id": 35903, "author_profile": "https://Stackoverflow.com/users/35903", "pm_score": 0, "selected": false, "text": "<p>To avoid static/global scope you could use some kind of Registry class. This means you have one class which you initiali...
2008/11/09
[ "https://Stackoverflow.com/questions/276654", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have an initialization class that preloads content into a variable (probably a list or array). There will only be one instance of this initialization class but there will be many classes that need to access the preloaded content. The problem is not many of them are related and none of them extend my initialization c...
what you are doing is known as [singleton](http://en.wikipedia.org/wiki/Singleton_pattern). here are some previous discussions on this: * [How to implement a singleton in C#](https://stackoverflow.com/questions/246710/how-to-implement-a-singleton-in-c) * [What’s a good threadsafe singleton generic template pattern in ...
276,656
<p>So let's say I'm using Python 2.5's built-in default sqlite3 and I have a Django model class with the following code:</p> <pre><code>class SomeEntity(models.Model): some_field = models.CharField(max_length=50, db_index=True, unique=True) </code></pre> <p>I've got the admin interface setup and everything appear...
[ { "answer_id": 276708, "author": "Doug Currie", "author_id": 33252, "author_profile": "https://Stackoverflow.com/users/33252", "pm_score": 2, "selected": false, "text": "<p>Perhaps you can create and use a custom model field; it would be a subclass of CharField but providing a <a href=\"...
2008/11/09
[ "https://Stackoverflow.com/questions/276656", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29123/" ]
So let's say I'm using Python 2.5's built-in default sqlite3 and I have a Django model class with the following code: ``` class SomeEntity(models.Model): some_field = models.CharField(max_length=50, db_index=True, unique=True) ``` I've got the admin interface setup and everything appears to be working fine excep...
Yes this can easily be done by adding a unique index to the table with the following command: CREATE UNIQUE INDEX uidxName ON mytable (myfield COLLATE NOCASE) If you need case insensitivity for nonASCII letters, you will need to register your own COLLATION with commands similar to the following: The following exampl...
276,660
<p>I need to warn users about unsaved changes before they leave a page (a pretty common problem).</p> <pre><code>window.onbeforeunload = handler </code></pre> <p>This works but it raises a default dialog with an irritating standard message that wraps my own text. I need to either completely replace the standard message...
[ { "answer_id": 276739, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 9, "selected": true, "text": "<p>You can't modify the default dialogue for <code>onbeforeunload</code>, so your best bet may be to work with it.</p>\n\n<pre><...
2008/11/09
[ "https://Stackoverflow.com/questions/276660", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27805/" ]
I need to warn users about unsaved changes before they leave a page (a pretty common problem). ``` window.onbeforeunload = handler ``` This works but it raises a default dialog with an irritating standard message that wraps my own text. I need to either completely replace the standard message, so my text is clear, o...
You can't modify the default dialogue for `onbeforeunload`, so your best bet may be to work with it. ``` window.onbeforeunload = function() { return 'You have unsaved changes!'; } ``` [Here's a reference](http://msdn.microsoft.com/en-us/library/ms536907(VS.85).aspx) to this from Microsoft: > > When a string is...
276,677
<p>I'm a self-taught developer and my experience is all in small applications that I've developed.</p> <p>I'm currently working on an application that I've made public, and I've realized that I need to start doing good unit testing to catch regressions and generally make sure everything works.</p> <p>I've read up on ...
[ { "answer_id": 276681, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<p><a href=\"http://www.asp.net/learn/mvc-videos/\" rel=\"nofollow noreferrer\">http://www.asp.net/learn/mvc-videos/</a></p>\n...
2008/11/09
[ "https://Stackoverflow.com/questions/276677", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5982/" ]
I'm a self-taught developer and my experience is all in small applications that I've developed. I'm currently working on an application that I've made public, and I've realized that I need to start doing good unit testing to catch regressions and generally make sure everything works. I've read up on a [previous quest...
You don't specify which [flavor of VS2008](http://msdn.microsoft.com/en-us/subscriptions/subscriptionschart.aspx) you are using. If it is Pro or above, then MSTest is bundled, but a lot of people have issues with it - it isn't always very intuitive, and it takes far too much setup to do simple things like coverage / fi...
276,678
<p>C#: What is the proper way to change the font style (underline) from a Label at runtime?</p> <p>So far I understand that if you want to change font related properties at runtime from a label, mainly all font properties, you would have to use,</p> <pre><code> lblName.Font = new Font(... etc. etc. </code></pre> <p>...
[ { "answer_id": 276686, "author": "wonderchook", "author_id": 32113, "author_profile": "https://Stackoverflow.com/users/32113", "pm_score": 0, "selected": false, "text": "<p>How about (I'm using .Net Framework 2.0) Okay so this works for a Web Application. In a forms application it is r...
2008/11/09
[ "https://Stackoverflow.com/questions/276678", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
C#: What is the proper way to change the font style (underline) from a Label at runtime? So far I understand that if you want to change font related properties at runtime from a label, mainly all font properties, you would have to use, ``` lblName.Font = new Font(... etc. etc. ``` Is there a shortcut to the above ...
The way you did it: ``` this.Font = new Font(this.Font, FontStyle.Underline); ``` is correct. The reason is that Font is a sealed and immutable type (by design). When introduced in .NET 1 this seemed a bit strange but with today's emphasis on functional programming, concurrency and immutability this style is seen a ...
276,693
<p>What is the best way to change the height and width of an ASP.NET control from a client-side Javascript function?</p> <p>Thanks, Jeff</p>
[ { "answer_id": 276699, "author": "CubanX", "author_id": 27555, "author_profile": "https://Stackoverflow.com/users/27555", "pm_score": 1, "selected": false, "text": "<p>You can use the controls .ClientID and some javascript and change it that way.</p>\n\n<p>You can do it through CSS heigh...
2008/11/09
[ "https://Stackoverflow.com/questions/276693", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12172/" ]
What is the best way to change the height and width of an ASP.NET control from a client-side Javascript function? Thanks, Jeff
Because of the name mangling introduced by ASP.NET, I use the function at the bottom to find ASP controls. Once you have the control, you can set the height/width as needed. ``` example usage: <input type='button' value='Expand' onclick='setSize("myDiv", 500, 500);' /> ... function setSize(ctlName, height, width ) ...
276,706
<p>I'm someone who writes code just for fun and haven't really delved into it in either an academic or professional setting, so stuff like these bitwise operators really escapes me.</p> <p>I was reading an article about JavaScript, which apparently supports bitwise operations. I keep seeing this operation mentioned in...
[ { "answer_id": 276711, "author": "Jeff Hillman", "author_id": 3950, "author_profile": "https://Stackoverflow.com/users/3950", "pm_score": 4, "selected": false, "text": "<p>These are the bitwise operators, all supported in JavaScript:</p>\n\n<ul>\n<li><p><code>op1 &amp; op2</code> -- The ...
2008/11/09
[ "https://Stackoverflow.com/questions/276706", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36032/" ]
I'm someone who writes code just for fun and haven't really delved into it in either an academic or professional setting, so stuff like these bitwise operators really escapes me. I was reading an article about JavaScript, which apparently supports bitwise operations. I keep seeing this operation mentioned in places, a...
Since nobody has broached the subject of why these are useful: I use bitwise operations a lot when working with flags. For example, if you want to pass a series of flags to an operation (say, `File.Open()`, with Read mode and Write mode both enabled), you could pass them as a single value. This is accomplished by assi...
276,709
<p>It's easy to wrap optional memcached caching around your existing database queries. For example:</p> <p>Old (DB-only):</p> <pre><code>function getX x = get from db return x end </code></pre> <p>New (DB with memcache):</p> <pre><code>function getX x = get from memcache if found return x ...
[ { "answer_id": 276831, "author": "Cem Catikkas", "author_id": 3087, "author_profile": "https://Stackoverflow.com/users/3087", "pm_score": 1, "selected": false, "text": "<p>Well, I guess that's something you'll have to live with. Memcahced will work the best if you don't really do stuff i...
2008/11/10
[ "https://Stackoverflow.com/questions/276709", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
It's easy to wrap optional memcached caching around your existing database queries. For example: Old (DB-only): ``` function getX x = get from db return x end ``` New (DB with memcache): ``` function getX x = get from memcache if found return x endif x = get from db set x in memc...
Read about the [Identity Map](http://martinfowler.com/eaaCatalog/identityMap.html) pattern. This is a way to make sure you only keep one copy of a given row in your application space. Whether you store it in memcached or just plain objects, this is a way to handle what you want. I would guess that Identity Map is best ...
276,732
<p>I have a CSS like this</p> <pre><code>ul { list-style-image:url(images/bulletArrow.gif); } ul li { background: url(images/hr.gif) no-repeat left bottom; padding: 5px 0 7px 0; } </code></pre> <p>But the bullet image doesn't align properly in IE (it's fine in Firefox). I already have a background image ...
[ { "answer_id": 276820, "author": "Paige Ruten", "author_id": 813, "author_profile": "https://Stackoverflow.com/users/813", "pm_score": 5, "selected": false, "text": "<p>There is a good explanation and solution of this here: <a href=\"http://css.maxdesign.com.au/listutorial/master.htm\" r...
2008/11/10
[ "https://Stackoverflow.com/questions/276732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36036/" ]
I have a CSS like this ``` ul { list-style-image:url(images/bulletArrow.gif); } ul li { background: url(images/hr.gif) no-repeat left bottom; padding: 5px 0 7px 0; } ``` But the bullet image doesn't align properly in IE (it's fine in Firefox). I already have a background image for li, so I can't use the...
Thank you both of you. The problem is that I already use background for a line-separator. But I'll change it to border then I'll use background for the bullet image.
276,737
<p>I have one large access database that I need to normalize into five tables and a lookup table. I understand the theory behind normalization and have already sketched out the look of the tables but I am lost on how to transform my table to get the database normalized. The table analyzers doesn't offer the the breakdo...
[ { "answer_id": 276741, "author": "Fionnuala", "author_id": 2548, "author_profile": "https://Stackoverflow.com/users/2548", "pm_score": 0, "selected": false, "text": "<p>Can queries, particularly Union queries, offer a solution? Where are you seeing a problem?</p>\n" }, { "answer_...
2008/11/10
[ "https://Stackoverflow.com/questions/276737", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have one large access database that I need to normalize into five tables and a lookup table. I understand the theory behind normalization and have already sketched out the look of the tables but I am lost on how to transform my table to get the database normalized. The table analyzers doesn't offer the the breakdown ...
If you have a single table, add an Autonumber field to it. Then create your other tables, and use the Autonumber value from the original single table as the foreign key to join them back to the original data. If you had tblPerson: ``` tblPerson LastName, FirstName, WorkPhone, HomePhone ``` and you wanted to br...
276,740
<p>I want to retrieve a list of the files that has been added or deleted from our Subversion repository over, for example, the last month.</p> <p>I'd prefer to have the file names, and not just a count.</p> <p>Is this possible from the Subversion command line, or would I need to use a script to trawl the log?</p>
[ { "answer_id": 276755, "author": "Lasse V. Karlsen", "author_id": 267, "author_profile": "https://Stackoverflow.com/users/267", "pm_score": 4, "selected": true, "text": "<p>I don't think you can do it with just the command-line tools, but outputting it with an XML format and doing some g...
2008/11/10
[ "https://Stackoverflow.com/questions/276740", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6340/" ]
I want to retrieve a list of the files that has been added or deleted from our Subversion repository over, for example, the last month. I'd prefer to have the file names, and not just a count. Is this possible from the Subversion command line, or would I need to use a script to trawl the log?
I don't think you can do it with just the command-line tools, but outputting it with an XML format and doing some grepping or filtering would probably give you what you want. Try this for a start: ``` svn log -v --xml | grep 'action="[A|D]"' ```
276,766
<p>I need help with this route map</p> <pre><code>routes.MapRoute("Blog_Archive", "Blog/Archive/{year}/{month}/{day}", new { controller = "Blog", action = "archive", year = "", month = "", ...
[ { "answer_id": 276772, "author": "Michael Stum", "author_id": 91, "author_profile": "https://Stackoverflow.com/users/91", "pm_score": 5, "selected": true, "text": "<p>Do you have any other Route for Blog/Archive/{something}?</p>\n\n<p>Use the <a href=\"http://haacked.com/archive/2008/03/...
2008/11/10
[ "https://Stackoverflow.com/questions/276766", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31296/" ]
I need help with this route map ``` routes.MapRoute("Blog_Archive", "Blog/Archive/{year}/{month}/{day}", new { controller = "Blog", action = "archive", year = "", month = "", ...
Do you have any other Route for Blog/Archive/{something}? Use the [Routing Debugger](http://haacked.com/archive/2008/03/13/url-routing-debugger.aspx) to see which route actually gets hit, most likely it's not hitting that route.
276,769
<p>I'm trying to expose this function to Python using SWIG:</p> <pre><code>std::vector&lt;int&gt; get_match_stats(); </code></pre> <p>And I want SWIG to generate wrapping code for Python so I can see it as a list of integers.</p> <p>Adding this to the .i file:</p> <pre> %include "typemaps.i" %include "std_vector.i"...
[ { "answer_id": 277687, "author": "Mr Fooz", "author_id": 25050, "author_profile": "https://Stackoverflow.com/users/25050", "pm_score": 5, "selected": true, "text": "<pre><code>%template(IntVector) vector&lt;int&gt;;\n</code></pre>\n" }, { "answer_id": 368961, "author": "Ferga...
2008/11/10
[ "https://Stackoverflow.com/questions/276769", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30626/" ]
I'm trying to expose this function to Python using SWIG: ``` std::vector<int> get_match_stats(); ``` And I want SWIG to generate wrapping code for Python so I can see it as a list of integers. Adding this to the .i file: ``` %include "typemaps.i" %include "std_vector.i" namespace std { %template(IntVector) vec...
``` %template(IntVector) vector<int>; ```
276,780
<p>My mission is to create a little app where you can upload a picture, and the app will turn it into ASCII art. I'm sure these exist already but I want to prove that I can do it myself.</p> <p>This would involve taking an image, making it greyscale and then matching each pixel with a character depending on how dark t...
[ { "answer_id": 276877, "author": "Austin Platt", "author_id": 7206, "author_profile": "https://Stackoverflow.com/users/7206", "pm_score": 1, "selected": false, "text": "<p>You don't have to convert it to grayscale... the result would be the same if you just calculated how close a pixel i...
2008/11/10
[ "https://Stackoverflow.com/questions/276780", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2128/" ]
My mission is to create a little app where you can upload a picture, and the app will turn it into ASCII art. I'm sure these exist already but I want to prove that I can do it myself. This would involve taking an image, making it greyscale and then matching each pixel with a character depending on how dark the picture...
A common formula to convert RGB to greyscale is: ``` Gray scale intensity = 0.30R + 0.59G + 0.11B ```
276,790
<pre><code>(define (repeated f n) if (= n 0) f ((compose repeated f) (lambda (x) (- n 1)))) </code></pre> <p>I wrote this function, but how would I express this more clearly, using simple recursion with repeated?</p> <p>I'm sorry, I forgot to define my compose function.</p> <pre><code>(define (compose f g) ...
[ { "answer_id": 276885, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 0, "selected": false, "text": "<p>What <em>is</em> your function trying to do, just out of curiosity? Is it to run <code>f</code>, <code>n</code> times? If...
2008/11/10
[ "https://Stackoverflow.com/questions/276790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
``` (define (repeated f n) if (= n 0) f ((compose repeated f) (lambda (x) (- n 1)))) ``` I wrote this function, but how would I express this more clearly, using simple recursion with repeated? I'm sorry, I forgot to define my compose function. ``` (define (compose f g) (lambda (x) (f (g x)))) ``` And the...
I'm assuming that (repeated f 3) should return a function g(x)=f(f(f(x))). If that's not what you want, please clarify. Anyways, that definition of repeated can be written as follows: ``` (define (repeated f n) (lambda (x) (if (= n 0) x ((repeated f (- n 1)) (f x))))) (define (square x) (* x ...
276,808
<p>I have a 2-dimensional array of objects and I basically want to databind each one to a cell in a WPF grid. Currently I have this working but I am doing most of it procedurally. I create the correct number of row and column definitions, then I loop through the cells and create the controls and set up the correct bi...
[ { "answer_id": 276868, "author": "Jobi Joy", "author_id": 8091, "author_profile": "https://Stackoverflow.com/users/8091", "pm_score": 7, "selected": true, "text": "<p>The purpose of the Grid is not for real databinding, it is just a panel. I am listing down the easiest way to accomplish ...
2008/11/10
[ "https://Stackoverflow.com/questions/276808", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1509/" ]
I have a 2-dimensional array of objects and I basically want to databind each one to a cell in a WPF grid. Currently I have this working but I am doing most of it procedurally. I create the correct number of row and column definitions, then I loop through the cells and create the controls and set up the correct binding...
The purpose of the Grid is not for real databinding, it is just a panel. I am listing down the easiest way to accomplish the visualization of a two dimensional list ``` <Window.Resources> <DataTemplate x:Key="DataTemplate_Level2"> <Button Content="{Binding}" Height="40" Width="50" Margin="4,4,4,4"/> ...
276,827
<p>I wrote this function that's supposed to do StringPadRight("Hello", 10, "0") -> "Hello00000".</p> <pre><code>char *StringPadRight(char *string, int padded_len, char *pad) { int len = (int) strlen(string); if (len &gt;= padded_len) { return string; } int i; for (i = 0; i &lt; padded_len -...
[ { "answer_id": 276835, "author": "Eugene Yokota", "author_id": 3827, "author_profile": "https://Stackoverflow.com/users/3827", "pm_score": 1, "selected": false, "text": "<p>The argument you passed \"Hello\" is on the constant data area. Unless you've allocated enough memory to char * str...
2008/11/10
[ "https://Stackoverflow.com/questions/276827", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I wrote this function that's supposed to do StringPadRight("Hello", 10, "0") -> "Hello00000". ``` char *StringPadRight(char *string, int padded_len, char *pad) { int len = (int) strlen(string); if (len >= padded_len) { return string; } int i; for (i = 0; i < padded_len - len; i++) { ...
It might be helpful to know that printf does padding for you, using %-10s as the format string will pad the input right in a field 10 characters long ``` printf("|%-10s|", "Hello"); ``` will output ``` |Hello | ``` In this case the - symbol means "Left align", the 10 means "Ten characters in field" and the s ...
276,843
<p>Is there a way short of writing a seperate batch file or adding a system call to pause or getch or a breakpoint right before the end of the main function to keep a command window open after a command line application has finished running?</p> <p>Put differently, is there a way in the project properties to run anoth...
[ { "answer_id": 276849, "author": "Tom Leys", "author_id": 11440, "author_profile": "https://Stackoverflow.com/users/11440", "pm_score": 0, "selected": false, "text": "<p>In C++</p>\n\n<pre><code>#include &lt;conio.h&gt;\n\n// .. Your code\n\nint main()\n{\n // More of your code\n\n // ...
2008/11/10
[ "https://Stackoverflow.com/questions/276843", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34799/" ]
Is there a way short of writing a seperate batch file or adding a system call to pause or getch or a breakpoint right before the end of the main function to keep a command window open after a command line application has finished running? Put differently, is there a way in the project properties to run another command...
As you may know, at least in the C# project system, pressing Ctrl-F5 will add a "press any key to continue" to the end. But this doesn't run under the debugger, so I endorse the prior answer that said 'put a breakpoint at the end of main'.
276,856
<p>I have a lot of assignments where I have to continually update a Makefile as I add more subsequently numbered C programs. Is there a way to do this with a loop which iterates over the values 1.1, 1.2, 1.3, etc.?</p> <pre><code>all: 1.1 1.2 1.3 1.4 1.5 1.6 1.7. 1.8 1.9 1.1: 1.1.o gcc -o 1.1 $(FLAGS) 1.1.o 1.1....
[ { "answer_id": 276860, "author": "Adam Liss", "author_id": 29157, "author_profile": "https://Stackoverflow.com/users/29157", "pm_score": 0, "selected": false, "text": "<p>Yes; you can use shell commands in a Makefile, and make itself may offer the looping you need. There are oodles of g...
2008/11/10
[ "https://Stackoverflow.com/questions/276856", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18091/" ]
I have a lot of assignments where I have to continually update a Makefile as I add more subsequently numbered C programs. Is there a way to do this with a loop which iterates over the values 1.1, 1.2, 1.3, etc.? ``` all: 1.1 1.2 1.3 1.4 1.5 1.6 1.7. 1.8 1.9 1.1: 1.1.o gcc -o 1.1 $(FLAGS) 1.1.o 1.1.o: 1.1.c gc...
You want a [suffix rule](http://owen.sj.ca.us/rkowen/howto/slides/make/slides/makesuff.html), not a loop.
276,861
<p>I would like to dynamically hide a button in one of my views depending on a certain condition.</p> <p>I tried adding some code to the view controller's <code>-viewWillAppear</code> method, to make the button hidden before displaying the actual view, but I still don't know how to do that.</p> <p>I have a reference ...
[ { "answer_id": 276890, "author": "Ben Gottlieb", "author_id": 6694, "author_profile": "https://Stackoverflow.com/users/6694", "pm_score": -1, "selected": false, "text": "<p>Just set the button's hidden property to true:</p>\n\n<pre><code>myButton.hidden = YES;\n</code></pre>\n" }, { ...
2008/11/10
[ "https://Stackoverflow.com/questions/276861", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35478/" ]
I would like to dynamically hide a button in one of my views depending on a certain condition. I tried adding some code to the view controller's `-viewWillAppear` method, to make the button hidden before displaying the actual view, but I still don't know how to do that. I have a reference to the button through an IBO...
If you're trying to hide a UIBarButtonItem, you'll actually have to modify the contents of the parent bar. If it's a UIToolBar, you'll need to set the bar's items array to an array that doesn't include your item. ``` NSMutableArray *items = [[myToolbar.items mutableCopy] autorelease]; [items removeObject: myButton...
276,867
<p>In this <a href="https://stackoverflow.com/questions/275545/does-aspnet-mvc-framework-support-asynchronous-page-execution">question &amp; answer</a>, I found one way to make ASP.NET MVC support asynchronous processing. However, I cannot make it work.</p> <p>Basically, the idea is to create a new implementation of I...
[ { "answer_id": 278831, "author": "MrJavaGuy", "author_id": 7138, "author_profile": "https://Stackoverflow.com/users/7138", "pm_score": 0, "selected": false, "text": "<p>I have tried to do this in the past, I manage to either get the view to render and then all the async tasks would finis...
2008/11/10
[ "https://Stackoverflow.com/questions/276867", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26349/" ]
In this [question & answer](https://stackoverflow.com/questions/275545/does-aspnet-mvc-framework-support-asynchronous-page-execution), I found one way to make ASP.NET MVC support asynchronous processing. However, I cannot make it work. Basically, the idea is to create a new implementation of IRouteHandler which has on...
After hours of hassle with the code, I found out the issue. In my Visual Studio 2008, when I press Ctrl+F5, the Application Development Server is launched and IE is popped up to access "<http://localhost:3573/>". In this case, the sync API ***ProcessRequest*** is invoked. The stack trace is like this. > > > > > > ...
276,891
<p>I'm trying to figure out how to drop/discard a request, I'm basically trying to implement a blocked list of IPs in my app to block spammers and I don't want to return any response (just ignore the request), is this possible in ASP.NET?</p> <p>Edit: Some of the answers suggest that I could add them in the firewall, ...
[ { "answer_id": 276894, "author": "John Boker", "author_id": 2847, "author_profile": "https://Stackoverflow.com/users/2847", "pm_score": 2, "selected": false, "text": "<p>Maybe you could use </p>\n\n<pre><code>Response.Clear();\nResponse.End();\n</code></pre>\n" }, { "answer_id": ...
2008/11/10
[ "https://Stackoverflow.com/questions/276891", "https://Stackoverflow.com", "https://Stackoverflow.com/users/676066/" ]
I'm trying to figure out how to drop/discard a request, I'm basically trying to implement a blocked list of IPs in my app to block spammers and I don't want to return any response (just ignore the request), is this possible in ASP.NET? Edit: Some of the answers suggest that I could add them in the firewall, while this...
Maybe you could use ``` Response.Clear(); Response.End(); ```
276,927
<p>Using <code>MySQL</code>, I can do something like:</p> <pre><code>SELECT hobbies FROM peoples_hobbies WHERE person_id = 5; </code></pre> <p><strong>My Output:</strong></p> <pre><code>shopping fishing coding </code></pre> <p>but instead I just want 1 row, 1 col:</p> <p><strong>Expected Output:</strong></p> <pre...
[ { "answer_id": 276949, "author": "che", "author_id": 7806, "author_profile": "https://Stackoverflow.com/users/7806", "pm_score": 12, "selected": true, "text": "<p>You can use <a href=\"https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_group-concat\" rel=\"noreferr...
2008/11/10
[ "https://Stackoverflow.com/questions/276927", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14966/" ]
Using `MySQL`, I can do something like: ``` SELECT hobbies FROM peoples_hobbies WHERE person_id = 5; ``` **My Output:** ``` shopping fishing coding ``` but instead I just want 1 row, 1 col: **Expected Output:** ``` shopping, fishing, coding ``` The reason is that I'm selecting multiple values from multiple ta...
You can use [`GROUP_CONCAT`](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_group-concat): ``` SELECT person_id, GROUP_CONCAT(hobbies SEPARATOR ', ') FROM peoples_hobbies GROUP BY person_id; ``` As Ludwig stated in [his comment,](https://stackoverflow.com/questions/276927/can-i-concaten...
276,965
<p>I have noticed that our VMWare VMs often have the incorrect time on them. No matter how many times I reset the time they keep on desyncing.</p> <p>Has anyone else noticed this? What do other people do to keep their VM time in sync?</p> <p><strong>Edit:</strong> These are CLI linux VMs btw..</p>
[ { "answer_id": 276981, "author": "Tom Leys", "author_id": 11440, "author_profile": "https://Stackoverflow.com/users/11440", "pm_score": 1, "selected": false, "text": "<p>The CPU speed varies due to power saving. I originally noticed this because VMware gave me a helpful tip on my laptop,...
2008/11/10
[ "https://Stackoverflow.com/questions/276965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1666/" ]
I have noticed that our VMWare VMs often have the incorrect time on them. No matter how many times I reset the time they keep on desyncing. Has anyone else noticed this? What do other people do to keep their VM time in sync? **Edit:** These are CLI linux VMs btw..
If your host time is correct, you can set the following .vmx configuration file option to enable periodic synchronization: ``` tools.syncTime = true ``` By default, this synchronizes the time every minute. To change the periodic rate, set the following option to the desired synch time in seconds: ``` tools.syncTime...
276,986
<p>When the program runs, there is a series of ListView forms. We populated one of them with items (as strings) and we check whether the state of selection has changed. Once it's changed, we grab the text of the selected item using FocusedItem.Text. The first time works just fine but when another selection is made, the...
[ { "answer_id": 277179, "author": "chakrit", "author_id": 3055, "author_profile": "https://Stackoverflow.com/users/3055", "pm_score": 0, "selected": false, "text": "<p>I have run a test program and see no instance where FocusedItem could be nulls.</p>\n\n<p>Could you post some code?</p>\n...
2008/11/10
[ "https://Stackoverflow.com/questions/276986", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
When the program runs, there is a series of ListView forms. We populated one of them with items (as strings) and we check whether the state of selection has changed. Once it's changed, we grab the text of the selected item using FocusedItem.Text. The first time works just fine but when another selection is made, the se...
Put the following condition around in the `OnSelectedIndexHandler`: ``` if(listViewObject.SelectedItems!=null&& listViewObject.SelectedItems.Count>0) { //....your code here } ```
277,007
<p>I need to load a bunch of words (about 70,000) from a text file, add it to a hashtable (using soundex as a key) and sort the values. While doing all these I want to show a progress bar using JProgressBar. Articles such as <a href="http://java.sun.com/docs/books/tutorial/uiswing/components/progress.html" rel="norefer...
[ { "answer_id": 277048, "author": "Zach Scrivena", "author_id": 20029, "author_profile": "https://Stackoverflow.com/users/20029", "pm_score": 3, "selected": false, "text": "<p>I would read the text file in a loop on a dedicated work thread, not the event-dispatch thread (EDT). If I know t...
2008/11/10
[ "https://Stackoverflow.com/questions/277007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35307/" ]
I need to load a bunch of words (about 70,000) from a text file, add it to a hashtable (using soundex as a key) and sort the values. While doing all these I want to show a progress bar using JProgressBar. Articles such as [this](http://java.sun.com/docs/books/tutorial/uiswing/components/progress.html) and [this](http:/...
I would read the text file in a loop on a dedicated work thread, not the event-dispatch thread (EDT). If I know the total number of words to be read, then I can compute the percentage completed at each iteration of the loop and update the progress bar accordingly. **Sample Code** The following code puts the progress ...
277,018
<p>I have a class storing the name of a WS method to call and the type and value of the only parameter that service receives (it will be a collection of parameters but lets keep it simple for the example):</p> <pre><code>public class MethodCall { public string Method { get; set; } public Type ParType { get; set; }...
[ { "answer_id": 277023, "author": "Bill the Lizard", "author_id": 1288, "author_profile": "https://Stackoverflow.com/users/1288", "pm_score": 9, "selected": true, "text": "<p>The <code>readonly</code> keyword is used to declare a member variable a constant, but allows the value to be calc...
2008/11/10
[ "https://Stackoverflow.com/questions/277018", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a class storing the name of a WS method to call and the type and value of the only parameter that service receives (it will be a collection of parameters but lets keep it simple for the example): ``` public class MethodCall { public string Method { get; set; } public Type ParType { get; set; } public stri...
The `readonly` keyword is used to declare a member variable a constant, but allows the value to be calculated at runtime. This differs from a constant declared with the `const` modifier, which must have its value set at compile time. Using `readonly` you can set the value of the field either in the declaration, or in t...
277,029
<p>Let's say I've got a setup that look something like</p> <pre><code>phd/code/ phd/figures/ phd/thesis/ </code></pre> <p>For historical reasons, these all have their own git repositories. But I'd like to combine them into a single one to simplify things a little. For example, right now I might make two sets of chang...
[ { "answer_id": 277068, "author": "Patrick_O", "author_id": 11084, "author_profile": "https://Stackoverflow.com/users/11084", "pm_score": 2, "selected": false, "text": "<p>The sequence you suggested</p>\n\n<pre><code>git init\ngit add *\ngit commit -a -m \"import everything\"\n</code></pr...
2008/11/10
[ "https://Stackoverflow.com/questions/277029", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4161/" ]
Let's say I've got a setup that look something like ``` phd/code/ phd/figures/ phd/thesis/ ``` For historical reasons, these all have their own git repositories. But I'd like to combine them into a single one to simplify things a little. For example, right now I might make two sets of changes and have to do somethin...
Here's a solution I gave [here](https://stackoverflow.com/questions/614229/can-i-move-the-git-directory-for-a-repo-to-its-parent-directory/614254): 1. First do a complete backup of your phd directory: I don't want to be held responsible for your losing years of hard work! ;-) ``` $ cp -r phd phd-backup ``` 2. Move t...
277,055
<p>There are a couple of different ways to remove <code>HTML tags</code> from an <code>NSString</code> in <code>Cocoa</code>.</p> <p><a href="http://cocoa.karelia.com/Foundation_Categories/NSString/_Flatten__a_string_.m" rel="noreferrer">One way</a> is to render the string into an <code>NSAttributedString</code> and t...
[ { "answer_id": 277083, "author": "Ben Gottlieb", "author_id": 6694, "author_profile": "https://Stackoverflow.com/users/6694", "pm_score": 2, "selected": false, "text": "<p>I would imagine the safest way would just be to parse for &lt;>s, no? Loop through the entire string, and copy anyth...
2008/11/10
[ "https://Stackoverflow.com/questions/277055", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28106/" ]
There are a couple of different ways to remove `HTML tags` from an `NSString` in `Cocoa`. [One way](http://cocoa.karelia.com/Foundation_Categories/NSString/_Flatten__a_string_.m) is to render the string into an `NSAttributedString` and then grab the rendered text. [Another way](http://sugarmaplesoftware.com/25/strip-...
A quick and "dirty" (removes everything between < and >) solution, works with iOS >= 3.2: ``` -(NSString *) stringByStrippingHTML { NSRange r; NSString *s = [[self copy] autorelease]; while ((r = [s rangeOfString:@"<[^>]+>" options:NSRegularExpressionSearch]).location != NSNotFound) s = [s stringByReplacing...
277,077
<p>I'm a Git newbie. I recently moved a Rails project from Subversion to Git. I followed the tutorial here: <a href="http://www.simplisticcomplexity.com/2008/03/05/cleanly-migrate-your-subversion-repository-to-a-git-repository/" rel="noreferrer">http://www.simplisticcomplexity.com/2008/03/05/cleanly-migrate-your-subv...
[ { "answer_id": 277098, "author": "Aristotle Pagaltzis", "author_id": 9410, "author_profile": "https://Stackoverflow.com/users/9410", "pm_score": 3, "selected": false, "text": "<blockquote>\n <p>I thought my laptop was the origin…</p>\n</blockquote>\n\n<p>That’s kind of nonsensical: <cod...
2008/11/10
[ "https://Stackoverflow.com/questions/277077", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8252/" ]
I'm a Git newbie. I recently moved a Rails project from Subversion to Git. I followed the tutorial here: <http://www.simplisticcomplexity.com/2008/03/05/cleanly-migrate-your-subversion-repository-to-a-git-repository/> I am also using unfuddle.com to store my code. I make changes on my Mac laptop on the train to/from w...
> > `1.` Find out where Git thinks 'origin/master' is using [`git-remote`](http://schacon.github.com/git/git-remote.html#_commands) > > > ``` git remote show origin ``` ..which will return something like.. ``` * remote origin URL: me@remote.example.com:~/something.git Remote branch merged with 'git pull' wh...
277,085
<p>I'm trying to get the name of the executable of a window that is outside my C# 2.0 application. My app currently gets a window handle (hWnd) using the GetForegroundWindow() call from "user32.dll".</p> <p>From the digging that I've been able to do, I think I want to use the GetModuleFileNameEx() function (from PSAPI...
[ { "answer_id": 277095, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 4, "selected": true, "text": "<p>You can call <a href=\"http://msdn.microsoft.com/en-us/library/ms633522(VS.85).aspx\" rel=\"nofollow noreferrer\">GetWindowT...
2008/11/10
[ "https://Stackoverflow.com/questions/277085", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21244/" ]
I'm trying to get the name of the executable of a window that is outside my C# 2.0 application. My app currently gets a window handle (hWnd) using the GetForegroundWindow() call from "user32.dll". From the digging that I've been able to do, I think I want to use the GetModuleFileNameEx() function (from PSAPI) to obtai...
You can call [GetWindowThreadProcessId](http://msdn.microsoft.com/en-us/library/ms633522(VS.85).aspx) and that will return you the process associated with the window. From that, you can call [OpenProcess](http://msdn.microsoft.com/en-us/library/ms684320.aspx) to open the process and get the handle to the process.
277,092
<p>How can I refer a custom function in xml? Suppose that I have a function written in Java and want it to refer by the xml tag, how is this possible?</p> <p>Current senario: I am using XACML2.0 which contains xml tags and I want to refer some function in Java that will talk to the backend data, I'm unable to refer a...
[ { "answer_id": 352783, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "<p>You should read up on Reflection in Java.</p>\n\n<p>The following example would invoke the method </p>\n\n<p>myObjectThatCo...
2008/11/10
[ "https://Stackoverflow.com/questions/277092", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How can I refer a custom function in xml? Suppose that I have a function written in Java and want it to refer by the xml tag, how is this possible? Current senario: I am using XACML2.0 which contains xml tags and I want to refer some function in Java that will talk to the backend data, I'm unable to refer a function i...
You should read up on Reflection in Java. The following example would invoke the method myObjectThatContainsMethod#methodNameAsString(Integer arg1, Integer arg2) ``` Integer[] params = {new Integer(123),new Integer(567)}; Class cl=Class.forName("stringParsedFromYourXML"); Class[] par=new Class[2]; par[0]=Integer...
277,102
<p>I'm working on a System Preferences Pane. It opens fine on some computers, but on other Macs (all running 10.5.5), the preference pane refuses to load and simply hangs, spitting the following into the console:</p> <pre><code>11/9/08 8:38:50 PM [0x0-0x31031].com.apple.systempreferences[369] Sun Nov 9 20:38:50 Macint...
[ { "answer_id": 352783, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "<p>You should read up on Reflection in Java.</p>\n\n<p>The following example would invoke the method </p>\n\n<p>myObjectThatCo...
2008/11/10
[ "https://Stackoverflow.com/questions/277102", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4103/" ]
I'm working on a System Preferences Pane. It opens fine on some computers, but on other Macs (all running 10.5.5), the preference pane refuses to load and simply hangs, spitting the following into the console: ``` 11/9/08 8:38:50 PM [0x0-0x31031].com.apple.systempreferences[369] Sun Nov 9 20:38:50 Macintosh.local Syst...
You should read up on Reflection in Java. The following example would invoke the method myObjectThatContainsMethod#methodNameAsString(Integer arg1, Integer arg2) ``` Integer[] params = {new Integer(123),new Integer(567)}; Class cl=Class.forName("stringParsedFromYourXML"); Class[] par=new Class[2]; par[0]=Integer...
277,149
<p>I have an ASP.NET MVC project and I have a single action that accepts GET, POST, and DELETE requests. Each type of request is filtered via attributes on my controllers <code>Action</code> methods.</p> <pre><code>[ActionName(Constants.AdministrationGraphDashboardAction), AcceptVerbs(HttpVerbs.Post)] public ActionRe...
[ { "answer_id": 277218, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 5, "selected": true, "text": "<p>i don't believe this is possible. the method attribute of form elements in HTML4 &amp; XHTML 1.0 will only accept GET or POS...
2008/11/10
[ "https://Stackoverflow.com/questions/277149", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3957/" ]
I have an ASP.NET MVC project and I have a single action that accepts GET, POST, and DELETE requests. Each type of request is filtered via attributes on my controllers `Action` methods. ``` [ActionName(Constants.AdministrationGraphDashboardAction), AcceptVerbs(HttpVerbs.Post)] public ActionResult GraphAdd([ModelBinder...
i don't believe this is possible. the method attribute of form elements in HTML4 & XHTML 1.0 will only accept GET or POST. in addition, standard configs of most webservers will deny DELETE and PUT requests. assuming you have configured your webserver to allow methods like PUT / DELETE (such as WebDav does), you could t...
277,150
<p>How do I define an Extension Method for <code>IEnumerable&lt;T&gt;</code> which returns <code>IEnumerable&lt;T&gt;</code>? The goal is to make the Extension Method available for all <code>IEnumerable</code> and <code>IEnumerable&lt;T&gt;</code> where <code>T</code> can be an anonymous type.</p>
[ { "answer_id": 277172, "author": "Nathan W", "author_id": 6335, "author_profile": "https://Stackoverflow.com/users/6335", "pm_score": 0, "selected": false, "text": "<p>This post may help you to get started:<a href=\"https://stackoverflow.com/questions/68750/how-do-you-write-a-c-extension...
2008/11/10
[ "https://Stackoverflow.com/questions/277150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21586/" ]
How do I define an Extension Method for `IEnumerable<T>` which returns `IEnumerable<T>`? The goal is to make the Extension Method available for all `IEnumerable` and `IEnumerable<T>` where `T` can be an anonymous type.
The easiest way to write any iterator is with an iterator block, for example: ``` static IEnumerable<T> Where<T>(this IEnumerable<T> data, Func<T, bool> predicate) { foreach(T value in data) { if(predicate(value)) yield return value; } } ``` The key here is the "`yield return`", which turns the m...
277,187
<p>I am using BeautifulSoup in Python to parse some HTML. One of the problems I am dealing with is that I have situations where the colspans are different across header rows. (Header rows are the rows that need to be combined to get the column headings in my jargon) That is one column may span a number of columns abo...
[ { "answer_id": 277280, "author": "unmounted", "author_id": 11596, "author_profile": "https://Stackoverflow.com/users/11596", "pm_score": 1, "selected": false, "text": "<p>Maybe look at the zip function for parts of the problem:</p>\n\n<pre><code>&gt;&gt;&gt; execfile('so_ques.py')\n[[' '...
2008/11/10
[ "https://Stackoverflow.com/questions/277187", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30105/" ]
I am using BeautifulSoup in Python to parse some HTML. One of the problems I am dealing with is that I have situations where the colspans are different across header rows. (Header rows are the rows that need to be combined to get the column headings in my jargon) That is one column may span a number of columns above or...
You've actually got a lot going on in this example. 1. You've "over-processed" the Beautiful Soup Tag objects to make lists. Leave them as Tags. 2. All of these kinds of merge algorithms are hard. It helps to treat the two things being merged symmetrically. Here's a version that should work directly with the Beautifu...
277,197
<p>The site I'm working on is using a Databound asp:Menu control. When sending 1 menu item it renders HTML that is absolutely correct in Firefox (and IE), but really messed up code in Safari and Chrome. Below is the code that was sent to each browser. I've tested it a few browsers, and they are all pretty similarly ...
[ { "answer_id": 277231, "author": "stephenbayer", "author_id": 18893, "author_profile": "https://Stackoverflow.com/users/18893", "pm_score": 5, "selected": true, "text": "<p>I found this solution from a comment on <a href=\"http://weblogs.asp.net/dannychen/archive/2005/11/21/using-device-...
2008/11/10
[ "https://Stackoverflow.com/questions/277197", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18893/" ]
The site I'm working on is using a Databound asp:Menu control. When sending 1 menu item it renders HTML that is absolutely correct in Firefox (and IE), but really messed up code in Safari and Chrome. Below is the code that was sent to each browser. I've tested it a few browsers, and they are all pretty similarly render...
I found this solution from a comment on [weblogs.asp.net](http://weblogs.asp.net/dannychen/archive/2005/11/21/using-device-filters-and-making-menu-work-with-safari.aspx). It might be a hack, but it does work. This cross browser compatibility struggle is getting upsetting. ``` if (Request.UserAgent.IndexOf("AppleWeb...
277,207
<p>I am a bit confused why this code compiles. I leave out the "necessary" <code>#include &lt;OpenGL/gl.h&gt;</code> and still the program can compile. How is this possible when my program is calling functions from the GL library, without including them.</p> <pre><code>int main(int argc, char** argv) { glClearC...
[ { "answer_id": 277233, "author": "Jason Coco", "author_id": 34218, "author_profile": "https://Stackoverflow.com/users/34218", "pm_score": 3, "selected": false, "text": "<p>glClearColor isn't a macro so you don't <em>need</em> the headers to define it. If you add warnings:</p>\n\n<pre><co...
2008/11/10
[ "https://Stackoverflow.com/questions/277207", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28486/" ]
I am a bit confused why this code compiles. I leave out the "necessary" `#include <OpenGL/gl.h>` and still the program can compile. How is this possible when my program is calling functions from the GL library, without including them. ``` int main(int argc, char** argv) { glClearColor(1.0,1.0,1.0,1.0); return...
In C (prior to C99), you don't have to declare functions in order to use them. The compiler will assume the function takes the promoted parameter types you pass to it, and assume the function returns an `int`. This, however can be quite problematic, and behavior is undefined if the function doesn't. Let's look at this:...