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
256,046
<p>Is it generally better to run functions on the webserver, or in the database?</p> <p>Example:</p> <pre><code>INSERT INTO example (hash) VALUE (MD5('hello')) </code></pre> <p>or</p> <pre><code>INSERT INTO example (hash) VALUE ('5d41402abc4b2a76b9719d911017c592') </code></pre> <p>Ok so that's a really trivial exa...
[ { "answer_id": 256054, "author": "dkretz", "author_id": 31641, "author_profile": "https://Stackoverflow.com/users/31641", "pm_score": 5, "selected": true, "text": "<p>I try to think of the database as the place to persist stuff only, and put all abstraction code elsewhere. Database expre...
2008/11/01
[ "https://Stackoverflow.com/questions/256046", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33322/" ]
Is it generally better to run functions on the webserver, or in the database? Example: ``` INSERT INTO example (hash) VALUE (MD5('hello')) ``` or ``` INSERT INTO example (hash) VALUE ('5d41402abc4b2a76b9719d911017c592') ``` Ok so that's a really trivial example, but for scalability when a site grows to multiple ...
I try to think of the database as the place to persist stuff only, and put all abstraction code elsewhere. Database expressions are complex enough already without adding functions to them. Also, the query optimizer will trip over any expressions with functions if you should ever end up wanting to do something like "SE...
256,073
<p>I'm not sure why I'm getting this error, but shouldn't this code compile, since I'm already checking to see if queue is getting initialized? </p> <pre><code>public static void Main(String[] args) { Byte maxSize; Queue queue; if(args.Length != 0) { if(Byte.TryParse(args[0], out maxSize)) ...
[ { "answer_id": 256075, "author": "Brian", "author_id": 19299, "author_profile": "https://Stackoverflow.com/users/19299", "pm_score": 3, "selected": false, "text": "<p>The compiler doesn't know that Environment.Exit() does not return. Why not just \"return\" from Main()?</p>\n" }, { ...
2008/11/01
[ "https://Stackoverflow.com/questions/256073", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33324/" ]
I'm not sure why I'm getting this error, but shouldn't this code compile, since I'm already checking to see if queue is getting initialized? ``` public static void Main(String[] args) { Byte maxSize; Queue queue; if(args.Length != 0) { if(Byte.TryParse(args[0], out maxSize)) queue...
The compiler doesn't know that the Environment.Exit() is going to terminate the program; it just sees you executing a static method on a class. Just initialize `queue` to null when you declare it. ``` Queue queue = null; ```
256,093
<p>I'm trying to use class names to change the color of a link after it has been selected, so that It will remain the new color, but only until another link is selected, and then it will change back.</p> <p>I'm using this code that was posted by Martin Kool in <a href="https://stackoverflow.com/questions/206689/changi...
[ { "answer_id": 256107, "author": "lacker", "author_id": 2652, "author_profile": "https://Stackoverflow.com/users/2652", "pm_score": 0, "selected": false, "text": "<p>Is there an error or is there just nothing happening? A good first step if you are a javascript beginner is to use a tool ...
2008/11/01
[ "https://Stackoverflow.com/questions/256093", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to use class names to change the color of a link after it has been selected, so that It will remain the new color, but only until another link is selected, and then it will change back. I'm using this code that was posted by Martin Kool in [this](https://stackoverflow.com/questions/206689/changing-the-bg-co...
You're looping through the siblings. If the links are in separate `<td>`'s then they're no longer siblings. You can loop through all the links like this: ``` document.onclick = function(evt) { var el = window.event? event.srcElement : evt.target; if (el && el.className == 'unselected') { var links...
256,109
<p>I've almost completely installed Boost, but I have a problem with how to set my path to Boost in <em>Tools->options->projects->VC++ Directories</em>.</p> <p>I've written the path to include files and libraries (my folder contains two subfolders, <code>lib</code> and <code>include</code>), but when I try to use Boos...
[ { "answer_id": 256114, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 5, "selected": true, "text": "<p>Use the <a href=\"http://www.boostpro.com/download/\" rel=\"nofollow noreferrer\">Boost Installer</a> by the Boost ...
2008/11/01
[ "https://Stackoverflow.com/questions/256109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28298/" ]
I've almost completely installed Boost, but I have a problem with how to set my path to Boost in *Tools->options->projects->VC++ Directories*. I've written the path to include files and libraries (my folder contains two subfolders, `lib` and `include`), but when I try to use Boost with `#include boost/regex.hpp`, I go...
Use the [Boost Installer](http://www.boostpro.com/download/) by the Boost consulting group.
256,142
<p>When I try to commit the first revision to my git repository (git commit) from Cygwin, I'm getting an error in gvim which says "Unable to open swap file for "foo\.git\COMMIT_EDITMSG" [New Directory]. I think it might be some sort of permission problem, but I've tried removing the read-only flag from the folder, as w...
[ { "answer_id": 256168, "author": "Ken Gentle", "author_id": 8709, "author_profile": "https://Stackoverflow.com/users/8709", "pm_score": 2, "selected": false, "text": "<blockquote>\n <p>Unable to open swap file for \"foo\\.git\\COMMIT_EDITMSG\" [New Directory].</p>\n</blockquote>\n\n<p>L...
2008/11/01
[ "https://Stackoverflow.com/questions/256142", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32539/" ]
When I try to commit the first revision to my git repository (git commit) from Cygwin, I'm getting an error in gvim which says "Unable to open swap file for "foo\.git\COMMIT\_EDITMSG" [New Directory]. I think it might be some sort of permission problem, but I've tried removing the read-only flag from the folder, as wel...
> > Unable to open swap file for "foo\.git\COMMIT\_EDITMSG" [New Directory]. > > > Looks like the `git commit` is passing the file path as a Windows path, not a POSIX path. note the `\` in the message. `gvim` is going to try to open `foo.gitCOMMIT\_EDITMSG", which doesn't exist. I don't use `git`, but I imagine ...
256,148
<p>This is going to sound like a silly question, but I'm still learning C, so please bear with me. :)</p> <p>I'm working on chapter 6 of K&amp;R (structs), and thus far through the book have seen great success. I decided to work with structs pretty heavily, and therefore did a lot of work early in the chapter with the...
[ { "answer_id": 256153, "author": "Brian R. Bondy", "author_id": 3153, "author_profile": "https://Stackoverflow.com/users/3153", "pm_score": 5, "selected": true, "text": "<p><strong>I think what you want to do is this:</strong></p>\n\n<pre><code>void canonRect(struct rect *r) {\n struc...
2008/11/01
[ "https://Stackoverflow.com/questions/256148", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14048/" ]
This is going to sound like a silly question, but I'm still learning C, so please bear with me. :) I'm working on chapter 6 of K&R (structs), and thus far through the book have seen great success. I decided to work with structs pretty heavily, and therefore did a lot of work early in the chapter with the point and rec...
**I think what you want to do is this:** ``` void canonRect(struct rect *r) { struct rect temp; temp.lowerLeft.x = min(r->lowerLeft.x, r->upperRight.x); temp.lowerLeft.y = min(r->lowerLeft.y, r->upperRight.y); temp.upperRight.x = max(r->lowerLeft.x, r->upperRight.x); temp.upperRight.y = max(r->lowe...
256,195
<p>I'm using jQuery to wire up some mouseover effects on elements that are inside an UpdatePanel. The events are bound in <code>$(document).ready</code> . For example:</p> <pre><code>$(function() { $('div._Foo').bind("mouseover", function(e) { // Do something exciting }); }); </code></pre> <p>...
[ { "answer_id": 256211, "author": "Eran Galperin", "author_id": 10585, "author_profile": "https://Stackoverflow.com/users/10585", "pm_score": 3, "selected": false, "text": "<p>I would use one of the following approaches:</p>\n\n<ol>\n<li><p>Encapsulate the event binding in a function and ...
2008/11/01
[ "https://Stackoverflow.com/questions/256195", "https://Stackoverflow.com", "https://Stackoverflow.com/users/239663/" ]
I'm using jQuery to wire up some mouseover effects on elements that are inside an UpdatePanel. The events are bound in `$(document).ready` . For example: ``` $(function() { $('div._Foo').bind("mouseover", function(e) { // Do something exciting }); }); ``` Of course, this works fine the first ...
An UpdatePanel completely replaces the contents of the update panel on an update. This means that those events you subscribed to are no longer subscribed because there are new elements in that update panel. What I've done to work around this is re-subscribe to the events I need after every update. I use `$(document).r...
256,204
<p>I use the <code>:e</code> and <code>:w</code> commands to edit and to write a file. I am not sure if there is "close" command to close the current file without leaving Vim?</p> <p>I know that the <code>:q</code> command can be used to close a file, but if it is the last file, Vim is closed as well; Actually on Mac ...
[ { "answer_id": 256206, "author": "Rytmis", "author_id": 266, "author_profile": "https://Stackoverflow.com/users/266", "pm_score": 3, "selected": false, "text": "<p>If you've saved the last file already, then <code>:enew</code> is your friend (<code>:enew!</code> if you don't want to save...
2008/11/01
[ "https://Stackoverflow.com/questions/256204", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62776/" ]
I use the `:e` and `:w` commands to edit and to write a file. I am not sure if there is "close" command to close the current file without leaving Vim? I know that the `:q` command can be used to close a file, but if it is the last file, Vim is closed as well; Actually on Mac OS MacVim does quit. Only the Vim window is...
This deletes the buffer (which translates to close the file) ``` :bd ```
256,218
<p>Let's say I have a <code>char* str = "0123456789"</code> and I want to cut the first and the last three letters and print just the middle, what is the simplest, and safest, way of doing it?</p> <p>Now the trick: The portion to cut and the portion to print are of variable size, so I could have a very long char*, or ...
[ { "answer_id": 256223, "author": "Robert Gamble", "author_id": 25222, "author_profile": "https://Stackoverflow.com/users/25222", "pm_score": 7, "selected": true, "text": "<p>You can use <code>printf()</code>, and a special format string:</p>\n\n<pre><code>char *str = \"0123456789\";\npri...
2008/11/01
[ "https://Stackoverflow.com/questions/256218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21648/" ]
Let's say I have a `char* str = "0123456789"` and I want to cut the first and the last three letters and print just the middle, what is the simplest, and safest, way of doing it? Now the trick: The portion to cut and the portion to print are of variable size, so I could have a very long char\*, or a very small one.
You can use `printf()`, and a special format string: ``` char *str = "0123456789"; printf("%.6s\n", str + 1); ``` The precision in the `%s` conversion specifier specifies the maximum number of characters to print. You can use a variable to specify the precision at runtime as well: ``` int length = 6; char *str = "0...
256,222
<p>I was wondering about the best practices for indicating invalid argument combinations in Python. I've come across a few situations where you have a function like so:</p> <pre><code>def import_to_orm(name, save=False, recurse=False): """ :param name: Name of some external entity to import. :param save: S...
[ { "answer_id": 256235, "author": "Eli Courtwright", "author_id": 1694, "author_profile": "https://Stackoverflow.com/users/1694", "pm_score": 4, "selected": false, "text": "<p>I've mostly just seen the builtin <code>ValueError</code> used in this situation.</p>\n" }, { "answer_id"...
2008/11/01
[ "https://Stackoverflow.com/questions/256222", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3594/" ]
I was wondering about the best practices for indicating invalid argument combinations in Python. I've come across a few situations where you have a function like so: ``` def import_to_orm(name, save=False, recurse=False): """ :param name: Name of some external entity to import. :param save: Save the ORM ob...
I would just raise [ValueError](https://docs.python.org/3/library/exceptions.html#ValueError), unless you need a more specific exception.. ``` def import_to_orm(name, save=False, recurse=False): if recurse and not save: raise ValueError("save must be True if recurse is True") ``` There's really no point ...
256,228
<p>I'm trying to read data from a photocell resistor and my Arduino Decimila and then graph it in real-time with Processing.</p> <p>Should be painfully simple; but its growing into a little bit of a nightmare for me.</p> <p>code I'm running on my Arduino:</p> <pre class="lang-java prettyprint-override"><code>int p...
[ { "answer_id": 256397, "author": "Josh Sandlin", "author_id": 13293, "author_profile": "https://Stackoverflow.com/users/13293", "pm_score": 2, "selected": false, "text": "<p>After a closer look at the resources at hand, I realized that the problem had already been solved for me by the fo...
2008/11/01
[ "https://Stackoverflow.com/questions/256228", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13293/" ]
I'm trying to read data from a photocell resistor and my Arduino Decimila and then graph it in real-time with Processing. Should be painfully simple; but its growing into a little bit of a nightmare for me. code I'm running on my Arduino: ```java int photoPin; void setup(){ photoPin = 0; Serial.begin( 9600 ); ...
You could transmit that data with the Plotly Arduino API, which along with the documentation and setup is available [here](http://plot.ly/api/arduino). Basic idea: you can continuously stream data from your Arduino, or transmit a single chunk. Then, if you want to embed it into a site, you'll want to grab the URL and...
256,234
<p>(If anything here needs clarification/ more detail please let me know.)</p> <p>I have an application (C#, 2.* framework) that interfaces with a third-party webservice using SOAP. I used thinktecture's WSCF add-in against a supplied WSDL to create the client-side implementation. For reasons beyond my control the SO...
[ { "answer_id": 256246, "author": "Chris Shaffer", "author_id": 6744, "author_profile": "https://Stackoverflow.com/users/6744", "pm_score": 0, "selected": false, "text": "<p>The <a href=\"http://msdn.microsoft.com/en-us/library/system.web.services.protocols.soapextension(VS.85).aspx\" rel...
2008/11/01
[ "https://Stackoverflow.com/questions/256234", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30901/" ]
(If anything here needs clarification/ more detail please let me know.) I have an application (C#, 2.\* framework) that interfaces with a third-party webservice using SOAP. I used thinktecture's WSCF add-in against a supplied WSDL to create the client-side implementation. For reasons beyond my control the SOAP message...
You can utilize SoapExtension from existing WSE2.0 framework to intercept the responses from the server. ``` public class MyClientSOAPExtension : SoapExtension { Stream oldStream; Stream newStream; // Save the Stream representing the SOAP request or SOAP response into // a local memory buffer. ...
256,264
<p>The symptom of the problem looks like "[0m[27m[24m[J[34;1" which on a terminal translates into the color blue.</p> <p>-A </p>
[ { "answer_id": 256393, "author": "cefstat", "author_id": 19155, "author_profile": "https://Stackoverflow.com/users/19155", "pm_score": 0, "selected": false, "text": "<p>The following should work in your .bash_profile or .bashrc</p>\n\n<pre><code>case $TERM in\nxterm-color)\nexport PS1='\...
2008/11/01
[ "https://Stackoverflow.com/questions/256264", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30636/" ]
The symptom of the problem looks like "[0m[27m[24m[J[34;1" which on a terminal translates into the color blue. -A
The solution that is currently giving me some success is to redefine the shell function as an ansi term: ``` ;; shell-mode (defun sh () (interactive) (ansi-term "/bin/zsh")) ```
256,267
<p>I have a windows service connecting to a SqlServer database on the local box. This works fine most all the time. At a large customer, however, the database connectivity gets corrupted for some rare and unknown reason. When this happens, calls to DbDataAdapter.Fill return a DataSet with a different number of colum...
[ { "answer_id": 256393, "author": "cefstat", "author_id": 19155, "author_profile": "https://Stackoverflow.com/users/19155", "pm_score": 0, "selected": false, "text": "<p>The following should work in your .bash_profile or .bashrc</p>\n\n<pre><code>case $TERM in\nxterm-color)\nexport PS1='\...
2008/11/01
[ "https://Stackoverflow.com/questions/256267", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18313/" ]
I have a windows service connecting to a SqlServer database on the local box. This works fine most all the time. At a large customer, however, the database connectivity gets corrupted for some rare and unknown reason. When this happens, calls to DbDataAdapter.Fill return a DataSet with a different number of columns tha...
The solution that is currently giving me some success is to redefine the shell function as an ansi term: ``` ;; shell-mode (defun sh () (interactive) (ansi-term "/bin/zsh")) ```
256,277
<p>"C Interfaces and Implementations" shows some interesting usage patterns for data structures, but I am sure there are others out there.</p> <p><a href="https://rads.stackoverflow.com/amzn/click/com/0201498413" rel="nofollow noreferrer" rel="nofollow noreferrer">http://www.amazon.com/Interfaces-Implementations-Tech...
[ { "answer_id": 256292, "author": "Doug Currie", "author_id": 33252, "author_profile": "https://Stackoverflow.com/users/33252", "pm_score": 1, "selected": false, "text": "<p><a href=\"http://www.hwaci.com/sw/mkhdr/\" rel=\"nofollow noreferrer\">Makeheaders</a> is an interesting approach: ...
2008/11/01
[ "https://Stackoverflow.com/questions/256277", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30636/" ]
"C Interfaces and Implementations" shows some interesting usage patterns for data structures, but I am sure there are others out there. [http://www.amazon.com/Interfaces-Implementations-Techniques-Addison-Wesley-Professional/dp/0201498413](https://rads.stackoverflow.com/amzn/click/com/0201498413)
Look at the Goddard Space Flight Center (NASA) C coding standard (at this [URL](http://software.gsfc.nasa.gov/assetsbytype.cfm?TypeAsset=Standard)). It has some good and interesting guidelines. One specific guideline, which I've adopted for my own code, is that headers should be self-contained. That is, you should be ...
256,282
<p>On <a href="http://andrew.hedges.name/blog/" rel="nofollow noreferrer">my blog</a>, I display in the right nav the 10 most popular articles in terms of page hits. Here's how I get that:</p> <pre><code>SELECT * FROM entries WHERE is_published = 1 ORDER BY hits DESC, created DESC LIMIT 10 </code></pre> <p>What I wou...
[ { "answer_id": 256302, "author": "Stephen Walcher", "author_id": 25375, "author_profile": "https://Stackoverflow.com/users/25375", "pm_score": 4, "selected": true, "text": "<p>I'm not entirely sure you can by using the table structure you suggest in your query. The only way I can think o...
2008/11/01
[ "https://Stackoverflow.com/questions/256282", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11577/" ]
On [my blog](http://andrew.hedges.name/blog/), I display in the right nav the 10 most popular articles in terms of page hits. Here's how I get that: ``` SELECT * FROM entries WHERE is_published = 1 ORDER BY hits DESC, created DESC LIMIT 10 ``` What I would like to do is show the top 10 in terms of page hits *per day...
I'm not entirely sure you can by using the table structure you suggest in your query. The only way I can think of is to get the top 10 by way of highest *average* hits per day. By doing that, your query becomes: ``` SELECT *, AVG(hits / DATEDIFF(NOW(), created)) as avg_hits FROM entries WHERE is_published = 1 GROUP BY...
256,291
<p>What tools do you know, other than those in Visual Studio, to analyze performance bottlenecks in a Windows CE/Mobile application? I'm looking for something like AQTime for CE/Mobile, to profile C/C++ applications compiled to native code.</p>
[ { "answer_id": 256310, "author": "Maxam", "author_id": 15310, "author_profile": "https://Stackoverflow.com/users/15310", "pm_score": 0, "selected": false, "text": "<p>If you're doing .NET CF development, check out the <a href=\"http://www.microsoft.com/downloads/details.aspx?FamilyID=c81...
2008/11/02
[ "https://Stackoverflow.com/questions/256291", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8999/" ]
What tools do you know, other than those in Visual Studio, to analyze performance bottlenecks in a Windows CE/Mobile application? I'm looking for something like AQTime for CE/Mobile, to profile C/C++ applications compiled to native code.
I haven't found any such tools for WindowsMobile for native development. The closest I've found is the EnTrek toolset (CodeSnitch / ProcMan), but they aren't really profiling tools. <http://www.entrek.com/products.htm> What we did do is build own own profiling support into our own products using the Vistual Studio "/...
256,297
<p>In C++ I'd like to do something like:</p> <pre><code>int n = get_int_from_user(); char* matrix = new char[n][n]; matrix[0][0] = 'c'; //... matrix[n][n] = 'a'; delete [][] matrix; </code></pre> <p>but of course this doesn't work. What is the best way to do something similar? I've seen some solutions to this bu...
[ { "answer_id": 256303, "author": "Bernard", "author_id": 61, "author_profile": "https://Stackoverflow.com/users/61", "pm_score": 2, "selected": false, "text": "<p>For a true two dimensional array:</p>\n\n<pre><code>int n = get_int_from_user();\n\nchar** matrix = new char*[n];\nfor (int i...
2008/11/02
[ "https://Stackoverflow.com/questions/256297", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30529/" ]
In C++ I'd like to do something like: ``` int n = get_int_from_user(); char* matrix = new char[n][n]; matrix[0][0] = 'c'; //... matrix[n][n] = 'a'; delete [][] matrix; ``` but of course this doesn't work. What is the best way to do something similar? I've seen some solutions to this but they seem pretty messy.
**The manual dynamic way:** Let's say you want an array of width\*height, the most efficient way is to just use a single dimensional array: ``` char *matrix = new char[width*height]; ``` To delete it: ``` delete[] matrix; ``` To access it: ``` char getArrayValue(char *matrix, int row, int col) { return matri...
256,306
<p>I have a class that defines a CallRate type. I need to add the ability to create multiple instances of my class by reading the data from a file.</p> <p>I added a static method to my class CallRate that returns a <code>List&lt;CallRate&gt;</code>. Is it ok for a class to generate new instances of itself by calling o...
[ { "answer_id": 256308, "author": "Ray Lu", "author_id": 11413, "author_profile": "https://Stackoverflow.com/users/11413", "pm_score": 5, "selected": true, "text": "<p>It is perfectly fine to get object(s) of its own from the static method.</p>\n\n<p>e.g.</p>\n\n<p>One of the dot net libr...
2008/11/02
[ "https://Stackoverflow.com/questions/256306", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10178/" ]
I have a class that defines a CallRate type. I need to add the ability to create multiple instances of my class by reading the data from a file. I added a static method to my class CallRate that returns a `List<CallRate>`. Is it ok for a class to generate new instances of itself by calling one of its own constructors?...
It is perfectly fine to get object(s) of its own from the static method. e.g. One of the dot net libraries does the same thing as you did, ``` XmlReadrer reader = XmlReader.Create(filepathString); ```
256,325
<p>For my Django app I have Events, Ratings, and Users. Ratings are related to Events and Users through a foreign keys. When displaying a list of Events I want to filter the ratings of the Event by a user_id so I know if an event has been rated by the user. </p> <p>If I do:</p> <pre><code>event_list = Event.objects....
[ { "answer_id": 256342, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 1, "selected": false, "text": "<p>To make best use of Django, you have to avoid trying to do joins.</p>\n\n<p>A \"left outer join\" is actually a list of ...
2008/11/02
[ "https://Stackoverflow.com/questions/256325", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5112/" ]
For my Django app I have Events, Ratings, and Users. Ratings are related to Events and Users through a foreign keys. When displaying a list of Events I want to filter the ratings of the Event by a user\_id so I know if an event has been rated by the user. If I do: ``` event_list = Event.objects.filter(rating__user=r...
The `filter` method is for filtering which objects are returned based on the specified criteria, so it's not what you want here. One option is to do a second query to retrieve all ratings for given `Event` objects for the current `User`. Models: ``` import collections from django.db import models class RatingManage...
256,345
<p>Could you write a function that takes one argument (a positive integer) and</p> <ul> <li>divides it by two if it's even, or</li> <li>multiplies it by three and adds one if it's odd</li> </ul> <p>and then returns the resulting number.</p> <p>And then a separate function that takes one argument (a positive integer)...
[ { "answer_id": 256352, "author": "Kyle Cronin", "author_id": 658, "author_profile": "https://Stackoverflow.com/users/658", "pm_score": 0, "selected": false, "text": "<p>A function that performs one iteration:</p>\n\n<pre><code>(define (collatz x)\n (if (even? x)\n (/ x 2)\n (+...
2008/11/02
[ "https://Stackoverflow.com/questions/256345", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30622/" ]
Could you write a function that takes one argument (a positive integer) and * divides it by two if it's even, or * multiplies it by three and adds one if it's odd and then returns the resulting number. And then a separate function that takes one argument (a positive integer) and repeatedly passes it to the previous ...
i believe this is a great unsolved question of number theory. There is a hypothesis that every number when it goes through this operation enough times will reduce to one. However i don't really think scheme is the right tool for this, plus since a lot of people have decided that this is homework and not a legit questi...
256,349
<p>I'm trying to find some info on the best and most common RESTful url actions.</p> <p>for example, what url do you use for displaying the details of an item, for editing the item, updating, etc.</p> <pre><code>/question/show/&lt;whatever&gt; /question/edit/&lt;whatever&gt; /question/update/&lt;whatever&gt; (this is...
[ { "answer_id": 256355, "author": "Allain Lalonde", "author_id": 2443, "author_profile": "https://Stackoverflow.com/users/2443", "pm_score": 4, "selected": false, "text": "<p>Assuming <code>/questions/10</code> is a valid question then the method is used to interact with it.</p>\n\n<p>POS...
2008/11/02
[ "https://Stackoverflow.com/questions/256349", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30674/" ]
I'm trying to find some info on the best and most common RESTful url actions. for example, what url do you use for displaying the details of an item, for editing the item, updating, etc. ``` /question/show/<whatever> /question/edit/<whatever> /question/update/<whatever> (this is the post back url) /question/list (l...
**Use URLs to specify your objects, not your actions:** Note what you first mentioned is not RESTful: ``` /questions/show/<whatever> ``` Instead, you should use your URLs to specify your objects: ``` /questions/<question> ``` Then you perform one of the below operations on that resource. --- **GET:** Used to...
256,370
<p>Today, everytime I try to open any <strong>.Net application</strong> I get:</p> <pre><code>CLR error: 80004005 The program will now terminate. </code></pre> <p>Any suggestions?</p>
[ { "answer_id": 256373, "author": "Jeff Donnici", "author_id": 821, "author_profile": "https://Stackoverflow.com/users/821", "pm_score": 5, "selected": true, "text": "<p>I'd start with <a href=\"http://msdn.microsoft.com/en-us/netframework/aa569263.aspx\" rel=\"noreferrer\">downloading</a...
2008/11/02
[ "https://Stackoverflow.com/questions/256370", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14484/" ]
Today, everytime I try to open any **.Net application** I get: ``` CLR error: 80004005 The program will now terminate. ``` Any suggestions?
I'd start with [downloading](http://msdn.microsoft.com/en-us/netframework/aa569263.aspx) and re-installing the .NET framework.
256,387
<p>When using copy-on-write semantics to share memory among processes, how can you test if a memory page is writable or if it is marked as read-only? Can this be done by calling a specific assembler code, or reading a certain spot in memory, or through the OS's API?</p>
[ { "answer_id": 256402, "author": "Jim Nelson", "author_id": 32168, "author_profile": "https://Stackoverflow.com/users/32168", "pm_score": 1, "selected": false, "text": "<p>If you're using Win32, there are the calls IsBadReadPtr and IsBadWritePtr. However, their use is discouraged:</p>\n...
2008/11/02
[ "https://Stackoverflow.com/questions/256387", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33364/" ]
When using copy-on-write semantics to share memory among processes, how can you test if a memory page is writable or if it is marked as read-only? Can this be done by calling a specific assembler code, or reading a certain spot in memory, or through the OS's API?
On Linux you can examine /proc/*pid*/maps: ``` $ cat /proc/self/maps 002b3000-002cc000 r-xp 00000000 68:01 143009 /lib/ld-2.5.so 002cc000-002cd000 r-xp 00018000 68:01 143009 /lib/ld-2.5.so 002cd000-002ce000 rwxp 00019000 68:01 143009 /lib/ld-2.5.so 002d0000-00407000 r-xp 00000000 68:01 143010 /lib/libc-2.5.so...
256,460
<p>Is there anything similar to an <code>indexOf</code> function in the NSString objects?</p>
[ { "answer_id": 256464, "author": "Airsource Ltd", "author_id": 18017, "author_profile": "https://Stackoverflow.com/users/18017", "pm_score": 8, "selected": true, "text": "<p>Use <code>-[NSString rangeOfString:]</code>:</p>\n\n<pre><code>- (NSRange)rangeOfString:(NSString *)aString;\n</co...
2008/11/02
[ "https://Stackoverflow.com/questions/256460", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12388/" ]
Is there anything similar to an `indexOf` function in the NSString objects?
Use `-[NSString rangeOfString:]`: ``` - (NSRange)rangeOfString:(NSString *)aString; ``` > > Finds and returns the range of the first occurrence of a given string within the receiver. > > >
256,500
<p>I am unlucky to be in charge of maintaining some old Yahoo! Store built using their RTML-based platform.</p> <p>Recently I've noticed that HTML code generated by some RTML functions is sprinkled all over with "padding images" (or whatever is the conventional name for those 1x1 pixel images used to enforce layout). ...
[ { "answer_id": 256588, "author": "tsilb", "author_id": 11112, "author_profile": "https://Stackoverflow.com/users/11112", "pm_score": 1, "selected": false, "text": "<p>Well you're right on RTML being relatively untraveled :)</p>\n\n<p>Do you have a way to add your own attributes to these ...
2008/11/02
[ "https://Stackoverflow.com/questions/256500", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31415/" ]
I am unlucky to be in charge of maintaining some old Yahoo! Store built using their RTML-based platform. Recently I've noticed that HTML code generated by some RTML functions is sprinkled all over with "padding images" (or whatever is the conventional name for those 1x1 pixel images used to enforce layout). I have not...
Nice try from the other posters, but there is a very simple RTML command that will do it. . . ``` TEXT PAT-SUBST s GRAB MULTI HEAD BODY TEXT @var-with-alt-tag-equals-pad-in-it frompat "alt=\"pad\"" ...
256,507
<p>I'm a Lisp beginner. I'm trying to memoize a recursive function for calculating the number of terms in a <a href="http://en.wikipedia.org/wiki/Collatz_conjecture" rel="noreferrer">Collatz sequence</a> (for problem 14 in <a href="http://projecteuler.net/index.php?section=problems&amp;id=14" rel="noreferrer">Project E...
[ { "answer_id": 256552, "author": "Javier", "author_id": 11649, "author_profile": "https://Stackoverflow.com/users/11649", "pm_score": 2, "selected": false, "text": "<p>something like this:</p>\n\n<pre><code>(setf collatz-steps (memoize lambda (n)\n (if (= 1 n) 0\n (if (evenp n) \n ...
2008/11/02
[ "https://Stackoverflow.com/questions/256507", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8127/" ]
I'm a Lisp beginner. I'm trying to memoize a recursive function for calculating the number of terms in a [Collatz sequence](http://en.wikipedia.org/wiki/Collatz_conjecture) (for problem 14 in [Project Euler](http://projecteuler.net/index.php?section=problems&id=14)). My code as of yet is: ``` (defun collatz-steps (n) ...
I assume you're using Common-Lisp, which has separate namespaces for variable and function names. In order to memoize the function named by a symbol, you need to change its function binding, through the accessor `fdefinition': ``` (setf (fdefinition 'collatz-steps) (memoize #'collatz-steps)) (defun p14 () (let ((mx...
256,529
<p>I am building a WPF application. Inside that application I am using the XmlReader class to parse several local XML files. The code I have written <strong>works perfectly</strong> during debugging, but fails once I publish the application and install it.</p> <p>I have the XML documents as CONTENT in build action, an...
[ { "answer_id": 256576, "author": "Jeremy Wiebe", "author_id": 11807, "author_profile": "https://Stackoverflow.com/users/11807", "pm_score": 1, "selected": false, "text": "<p>Can you describe \"but fails once I publish the application and install it\" ?</p>\n\n<p>It would be helpful if yo...
2008/11/02
[ "https://Stackoverflow.com/questions/256529", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30408/" ]
I am building a WPF application. Inside that application I am using the XmlReader class to parse several local XML files. The code I have written **works perfectly** during debugging, but fails once I publish the application and install it. I have the XML documents as CONTENT in build action, and I have them set to CO...
By your publish description I assume you are using clickonce to install the application. Clickonce has different default behavior for xml files - it assumes they are data files and places them in a different install location from your other files. Please double check that your xml files really are being installed whe...
256,546
<p>Anyone know if there is already a validator for "type" strings?</p> <p>I want to make sure that the type attributes in my custom config are one of the following:</p> <pre> type="TopNamespace.SubNameSpace.ContainingClass, MyAssembly" type="TopNamespace.SubNameSpace.ContainingClass, MyAssembly, Version=1.3.0.0, Cult...
[ { "answer_id": 256764, "author": "Scott Cowan", "author_id": 253, "author_profile": "https://Stackoverflow.com/users/253", "pm_score": 0, "selected": false, "text": "<p>You'll get an error with resharper's Global Error Analysis if it can't find the namespace or class, but that's not alwa...
2008/11/02
[ "https://Stackoverflow.com/questions/256546", "https://Stackoverflow.com", "https://Stackoverflow.com/users/91911/" ]
Anyone know if there is already a validator for "type" strings? I want to make sure that the type attributes in my custom config are one of the following: ``` type="TopNamespace.SubNameSpace.ContainingClass, MyAssembly" type="TopNamespace.SubNameSpace.ContainingClass, MyAssembly, Version=1.3.0.0, Culture=neutral, Pu...
I'm not sure what you mean by "custom config", but if you're still working within .NET's configuration framework (e.g., developing a custom [configurationSection](http://msdn.microsoft.com/en-us/library/system.configuration.configurationsection.aspx)/[configurationElement](http://msdn.microsoft.com/en-us/library/system...
256,554
<p>In particular, I'm editing the AutoCompletion.plist file for CSSEdit (if that even matters).</p> <p>My question is, are there any characters withing the STRING elements that need to be escaped? spaces? quotes?</p> <p>EDIT: Just to be clear, I'm not using CSSEdit to edit the file - rather the file is part of the CS...
[ { "answer_id": 256585, "author": "Louis Gerbarg", "author_id": 30506, "author_profile": "https://Stackoverflow.com/users/30506", "pm_score": 0, "selected": false, "text": "<p>There are 3 types of plists, and the escaping rules depend on type you are working with. The most common form are...
2008/11/02
[ "https://Stackoverflow.com/questions/256554", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17252/" ]
In particular, I'm editing the AutoCompletion.plist file for CSSEdit (if that even matters). My question is, are there any characters withing the STRING elements that need to be escaped? spaces? quotes? EDIT: Just to be clear, I'm not using CSSEdit to edit the file - rather the file is part of the CSSEdit package. I'...
If you're editing an XML plist using a text editor of some sort, you'll need to escape characters just like in any XML. The basic characters to watch out for are: < (less than), escaped as &lt; > (greater than), escaped as &gt; & (ampersand), escaped as &amp; ' (apostrophe), escaped as &apos; " (quote mark), escap...
256,557
<p>One of the things that seems to be necessary with use of STL is a way to specify local functions. Many of the functions that I would normally provide cannot be created using STL function object creation tools ( eg bind ), I have to hand roll my function object.</p> <p>Since the C++ standard forbids local types to b...
[ { "answer_id": 256567, "author": "hazzen", "author_id": 5066, "author_profile": "https://Stackoverflow.com/users/5066", "pm_score": 2, "selected": false, "text": "<p>The standard way is a \"functor\" - basically, a <code>struct</code> that supplies an <code>operator()</code></p>\n\n<p>Fo...
2008/11/02
[ "https://Stackoverflow.com/questions/256557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29178/" ]
One of the things that seems to be necessary with use of STL is a way to specify local functions. Many of the functions that I would normally provide cannot be created using STL function object creation tools ( eg bind ), I have to hand roll my function object. Since the C++ standard forbids local types to be used as ...
Boost.Bind, Boost.Function, and Boost.Lambda are your friends.
256,564
<p>I'm a Python novice, trying to use pyCurl. The project I am working on is creating a Python wrapper for the twitpic.com API (<a href="http://twitpic.com/api.do" rel="nofollow noreferrer">http://twitpic.com/api.do</a>). For reference purposes, check out the code (<a href="http://pastebin.com/f4c498b6e" rel="nofollow ...
[ { "answer_id": 256610, "author": "gimel", "author_id": 6491, "author_profile": "https://Stackoverflow.com/users/6491", "pm_score": 3, "selected": true, "text": "<p><a href=\"http://pycurl.sourceforge.net/doc/curlobject.html\" rel=\"nofollow noreferrer\">The pycurl doc</a> explicitly says...
2008/11/02
[ "https://Stackoverflow.com/questions/256564", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33383/" ]
I'm a Python novice, trying to use pyCurl. The project I am working on is creating a Python wrapper for the twitpic.com API (<http://twitpic.com/api.do>). For reference purposes, check out the code (<http://pastebin.com/f4c498b6e>) and the error I'm getting (<http://pastebin.com/mff11d31>). Pay special attention to li...
[The pycurl doc](http://pycurl.sourceforge.net/doc/curlobject.html) explicitly says: > > perform() -> None > > > So the expected result is what you observe. looking at an example from the pycurl site: ``` import sys import pycurl class Test: def __init__(self): self.contents = '' def body_callbac...
256,566
<p>I'm trying to create a function in C# which will allow me to, when called, return a reference to a given class type. The only types of functions like this that I have seen are in UnrealScript and even then the functionality is hard coded into its compiler. I'm wondering if I can do this in C#. Here's what I mean ...
[ { "answer_id": 256586, "author": "Martin v. Löwis", "author_id": 33006, "author_profile": "https://Stackoverflow.com/users/33006", "pm_score": 0, "selected": false, "text": "<p>You can use the class System.Type to represent classes. To get references to type objects, you either use typeo...
2008/11/02
[ "https://Stackoverflow.com/questions/256566", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to create a function in C# which will allow me to, when called, return a reference to a given class type. The only types of functions like this that I have seen are in UnrealScript and even then the functionality is hard coded into its compiler. I'm wondering if I can do this in C#. Here's what I mean (code ...
Rather than use a generic *class*, use a generic *method*: ``` public T Spawn<T>() where T : new() { return new T(); } ``` Having said that, I assume you want to do more than just blindly create an instance, otherwise you could just call `new MyClass()` yourself.
256,625
<p>I have seen samples of closure from - <a href="https://stackoverflow.com/questions/36636/what-is-a-closure">What is a &#39;Closure&#39;?</a></p> <p>Can anyone provide simple example of when to use closure?<br></p> <p><b>Specifically, scenarios in which closure makes sense?</b><Br></p> <p>Lets assume that the lang...
[ { "answer_id": 256630, "author": "Rich", "author_id": 22003, "author_profile": "https://Stackoverflow.com/users/22003", "pm_score": 4, "selected": false, "text": "<p>Typically, if one doesn't have closures, one must define a class to carry with it the equivalent of the closure's environm...
2008/11/02
[ "https://Stackoverflow.com/questions/256625", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23574/" ]
I have seen samples of closure from - [What is a 'Closure'?](https://stackoverflow.com/questions/36636/what-is-a-closure) Can anyone provide simple example of when to use closure? **Specifically, scenarios in which closure makes sense?** Lets assume that the language doesn't have closure support, how would one s...
Closures are simply great tools. When to use them? Any time you like... As has already been said, the alternative is to write a class; for example, pre C# 2.0, creating a parameterised thread was a real struggle. With C# 2.0 you don't even need the `ParameterizedThreadStart' you just do: ``` string name = // blah int ...
256,628
<p>I'm trying to set up a loop where an animation runs a certain number of times, and a function is run before each iteration of the animation. The timing ends up being off, though -- it runs the callback n times, then runs the animation n times. For example:</p> <pre><code>for (var i=0;i&lt;3;i++) { console.log(i)...
[ { "answer_id": 256645, "author": "MDCore", "author_id": 1896, "author_profile": "https://Stackoverflow.com/users/1896", "pm_score": 2, "selected": false, "text": "<p>The animation is asynchronous. So the loops runs through pretty quickly, starting off three animations and outputting 1, 2...
2008/11/02
[ "https://Stackoverflow.com/questions/256628", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33391/" ]
I'm trying to set up a loop where an animation runs a certain number of times, and a function is run before each iteration of the animation. The timing ends up being off, though -- it runs the callback n times, then runs the animation n times. For example: ``` for (var i=0;i<3;i++) { console.log(i); $('#blerg').an...
The animation is asynchronous. So the loops runs through pretty quickly, starting off three animations and outputting 1, 2 and 3. After a while the animations complete and output animated x 3. That would explain your output. How about some recursion? ``` do_animation(max_runs, total_runs) { log(); if (total_ru...
256,634
<p>I have a problem. I am coding using VS2008. I am calling webservices from my JavaScript Page. An example</p> <pre><code>Services.ChangeDropDownLists.GetNowPlayingMoviesByLocationSVC( blah, OnSuccessMoviesByRegion, OnError, OnTimeOut ); </code></pre> <p>after execution, it goes to the function <cod...
[ { "answer_id": 256632, "author": "Martin v. Löwis", "author_id": 33006, "author_profile": "https://Stackoverflow.com/users/33006", "pm_score": 4, "selected": true, "text": "<p>I would write it in <a href=\"http://www.antlr.org/\" rel=\"noreferrer\">ANTLR</a>. Write the grammar, let ANTLR...
2008/11/02
[ "https://Stackoverflow.com/questions/256634", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17447/" ]
I have a problem. I am coding using VS2008. I am calling webservices from my JavaScript Page. An example ``` Services.ChangeDropDownLists.GetNowPlayingMoviesByLocationSVC( blah, OnSuccessMoviesByRegion, OnError, OnTimeOut ); ``` after execution, it goes to the function `OnSuccessMoviesByRegion`. ...
I would write it in [ANTLR](http://www.antlr.org/). Write the grammar, let ANTLR generate a C# parser. You can ANTLR ask for a parse tree, and possibly the interpreter can already operate on the parse tree. Perhaps you'll have to convert the parse tree to some more abstract internal representation (although ANTLR alrea...
256,647
<p>I want to see how long a function takes to run. What's the easiest way to do this in PLT-Scheme? Ideally I'd want to be able to do something like this:</p> <pre><code>&gt; (define (loopy times) (if (zero? times) 0 (loopy (sub1 times)))) &gt; (loopy 5000000) 0 ;(after about a seco...
[ { "answer_id": 256652, "author": "Claudiu", "author_id": 15055, "author_profile": "https://Stackoverflow.com/users/15055", "pm_score": 2, "selected": false, "text": "<p>Found it...</p>\n\n<p>From the <a href=\"http://download.plt-scheme.org/doc/301/html/mzscheme/mzscheme-Z-H-15.html#node...
2008/11/02
[ "https://Stackoverflow.com/questions/256647", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15055/" ]
I want to see how long a function takes to run. What's the easiest way to do this in PLT-Scheme? Ideally I'd want to be able to do something like this: ``` > (define (loopy times) (if (zero? times) 0 (loopy (sub1 times)))) > (loopy 5000000) 0 ;(after about a second) > (timed (loopy ...
The standard name for timing the execution of expressions in most Scheme implementations is "time". Here is an example from within DrRacket. > > (define (loopy times) > (if (zero? times) > 0 > (loopy (sub1 times)))) > > > (time (loopy 5000000)) > cpu time: 1526 real time: 1657 gc time: 0 > 0 > > > If you ...
256,700
<p>What is a view in Oracle?</p>
[ { "answer_id": 256703, "author": "splattne", "author_id": 6461, "author_profile": "https://Stackoverflow.com/users/6461", "pm_score": 7, "selected": false, "text": "<p>A <strong>View in Oracle</strong> and in other database systems is simply the representation of a SQL statement that is ...
2008/11/02
[ "https://Stackoverflow.com/questions/256700", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
What is a view in Oracle?
A **View in Oracle** and in other database systems is simply the representation of a SQL statement that is stored in memory so that it can easily be re-used. For example, if we frequently issue the following query ``` SELECT customerid, customername FROM customers WHERE countryid='US'; ``` To create a view use the *...
256,702
<p>I have used something like the following to compose policies for my application:</p> <p>The policy classes look like this:</p> <pre><code>struct Policy { static void init(); static void cleanup(); //... }; template &lt;class CarT, class CdrT&gt; struct Cons { static void init() { CarT::init(); Cdr...
[ { "answer_id": 256860, "author": "tabdamage", "author_id": 28022, "author_profile": "https://Stackoverflow.com/users/28022", "pm_score": 1, "selected": false, "text": "<p>I think your problem is rather runtime invocation than metafunctions, because you want to call the init functions on ...
2008/11/02
[ "https://Stackoverflow.com/questions/256702", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28888/" ]
I have used something like the following to compose policies for my application: The policy classes look like this: ``` struct Policy { static void init(); static void cleanup(); //... }; template <class CarT, class CdrT> struct Cons { static void init() { CarT::init(); CdrT::init(); } static voi...
Since no one answered the question satisfactorily, I spent sometime digging into the boost::mpl source. Man, it's not pretty with layers of macros and hundreds of lines of specialization classes. I now have more appreciation for the authors of the boost libraries to make meta programming easier and more portable for us...
256,719
<p>In most versions of windows, you can get to the menu by pressing the F10 key, thus avoiding having to use the mouse. This behaviour does not appear to be present in Windows Mobile 5.0, but is desirable as the device I am using will be more keyboard than touch screen driven. </p> <p>Is there a way of programmatica...
[ { "answer_id": 256777, "author": "SmacL", "author_id": 22564, "author_profile": "https://Stackoverflow.com/users/22564", "pm_score": 2, "selected": true, "text": "<p>After a number of attempts, the following appears to work;</p>\n\n<pre><code>void CMyFrame::OnFocusMenu()\n{\n PostMessag...
2008/11/02
[ "https://Stackoverflow.com/questions/256719", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22564/" ]
In most versions of windows, you can get to the menu by pressing the F10 key, thus avoiding having to use the mouse. This behaviour does not appear to be present in Windows Mobile 5.0, but is desirable as the device I am using will be more keyboard than touch screen driven. Is there a way of programmatically activati...
After a number of attempts, the following appears to work; ``` void CMyFrame::OnFocusMenu() { PostMessage(WM_SYSCOMMAND,SC_KEYMENU,0); } ``` FWIW, none of the following did, where m\_wndCommandBar is the CCeCommandBar toolbar containing the menu; ``` ::SetActiveWindow(m_wndCommandBar.m_hWnd); m_wndCommandBar.Post...
256,723
<p>We are using Subversion. We would like to </p> <pre><code>1. search across all commit messages ? 2. monitor the commits on certain important files ? 3. identify files that are never/rarely used ? 4. identify files that are most frequently changed ? 5. identify files that most developers have accessed ? 6....
[ { "answer_id": 256727, "author": "Adam Liss", "author_id": 29157, "author_profile": "https://Stackoverflow.com/users/29157", "pm_score": 1, "selected": false, "text": "<p>What platform are you using? On linux, a quick shell script using <code>sed</code> should do the trick.</p>\n" }, ...
2008/11/02
[ "https://Stackoverflow.com/questions/256723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27474/" ]
We are using Subversion. We would like to ``` 1. search across all commit messages ? 2. monitor the commits on certain important files ? 3. identify files that are never/rarely used ? 4. identify files that are most frequently changed ? 5. identify files that most developers have accessed ? 6. identify files...
Another tool worth looking at is [ViewVC](http://www.viewvc.org/). The latest version has the option to maintain a commit database. This allows you to search across all commit messages and to see a list of changes to either a file or a files in a directory filtered by user, time or regular expression. It also supports ...
256,724
<p>In C++, is it safe to extend scope via a reference?</p> <p>In code, what I mean is: </p> <pre><code>MyCLass&amp; function badIdea() { MyClass obj1; ... return obj1; } </code></pre>
[ { "answer_id": 256741, "author": "peterchen", "author_id": 31317, "author_profile": "https://Stackoverflow.com/users/31317", "pm_score": 1, "selected": false, "text": "<p>Please clarify what you do mean.</p>\n\n<p>Assuming you intend to do this:</p>\n\n<pre><code>int * p = NULL;\n{\n in...
2008/11/02
[ "https://Stackoverflow.com/questions/256724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3153/" ]
In C++, is it safe to extend scope via a reference? In code, what I mean is: ``` MyCLass& function badIdea() { MyClass obj1; ... return obj1; } ```
It is NOT safe to extend the scope via reference. Objects in C++ are not reference counted when obj1 goes out of scope it will be deleted, refering to the result of badIdea() will only get you into trouble
256,728
<pre><code>function AddTheatres() { Services.AdminWebServices.AddTheatresSVC(oTheatres, OnSuccessTheatres, OnError, OnTimeOut); } function OnSuccessTheatres(result1) { Services.AdminWebServices.AddTicketPricesSVC(oTicketPrices, OnSuccessTicketPrices, OnError, OnTimeOut); //working } function OnSuccessTicketPrices...
[ { "answer_id": 256733, "author": "splattne", "author_id": 6461, "author_profile": "https://Stackoverflow.com/users/6461", "pm_score": 2, "selected": true, "text": "<p>Did you implement the OnError and OnTimeout handlers? Maybe there is a server error?</p>\n" }, { "answer_id": 256...
2008/11/02
[ "https://Stackoverflow.com/questions/256728", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17447/" ]
``` function AddTheatres() { Services.AdminWebServices.AddTheatresSVC(oTheatres, OnSuccessTheatres, OnError, OnTimeOut); } function OnSuccessTheatres(result1) { Services.AdminWebServices.AddTicketPricesSVC(oTicketPrices, OnSuccessTicketPrices, OnError, OnTimeOut); //working } function OnSuccessTicketPrices(result...
Did you implement the OnError and OnTimeout handlers? Maybe there is a server error?
256,729
<p>I have a regular expression to match a persons name.</p> <p>So far I have ^([a-zA-Z\'\s]+)$ but id like to add a check to allow for a maximum of 4 spaces. How do I amend it to do this?</p> <p><strong>Edit:</strong> what i meant was 4 spaces anywhere in the string</p>
[ { "answer_id": 256735, "author": "Kent Fredric", "author_id": 15614, "author_profile": "https://Stackoverflow.com/users/15614", "pm_score": 4, "selected": true, "text": "<h2> Screw the regex. </h2>\n\n<p>Using a regex here seems to be creating a problem for a solution instead of just sol...
2008/11/02
[ "https://Stackoverflow.com/questions/256729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17211/" ]
I have a regular expression to match a persons name. So far I have ^([a-zA-Z\'\s]+)$ but id like to add a check to allow for a maximum of 4 spaces. How do I amend it to do this? **Edit:** what i meant was 4 spaces anywhere in the string
Screw the regex. ----------------- Using a regex here seems to be creating a problem for a solution instead of just solving a problem. This task should be 'easy' for even a novice programmer, and the novel idea of regex has polluted our minds!. ``` 1: Get Input 2: Trim White Space 3: If this makes sence, trim ...
256,754
<p>The situation is somewhat like-</p> <pre><code>var someVar = some_other_function(); someObj.addEventListener("click", function(){ some_function(someVar); }, false); </code></pre> <p>The problem is that the value of <code>someVar</code> is not visible inside the listener function of the <code>addEventListener</...
[ { "answer_id": 256763, "author": "Sergey Ilinsky", "author_id": 23815, "author_profile": "https://Stackoverflow.com/users/23815", "pm_score": 9, "selected": true, "text": "<p>There is absolutely nothing wrong with the code you've written. Both <code>some_function</code> and <code>someVar...
2008/11/02
[ "https://Stackoverflow.com/questions/256754", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30252/" ]
The situation is somewhat like- ``` var someVar = some_other_function(); someObj.addEventListener("click", function(){ some_function(someVar); }, false); ``` The problem is that the value of `someVar` is not visible inside the listener function of the `addEventListener`, where it is probably being treated as a n...
There is absolutely nothing wrong with the code you've written. Both `some_function` and `someVar` should be accessible, in case they were available in the context where anonymous ``` function() { some_function(someVar); } ``` was created. Check if the alert gives you the value you've been looking for, be sure i...
256,804
<p>Is there a way to execute SQL custom functions with Enterpise Library? I've tried Database.ExecuteScalar() but for some reason it returns null.</p> <p>This is my function:</p> <pre><code>Database db = DatabaseFactory.CreateDatabase("ConnectionString"); DbCommand cmd = db.GetStoredProcCommand("FunctionName"); db.Ad...
[ { "answer_id": 256851, "author": "cstick", "author_id": 2735, "author_profile": "https://Stackoverflow.com/users/2735", "pm_score": 4, "selected": true, "text": "<p>You have to create a select statement which selects the result from the function and execute that.</p>\n\n<p>\"SELECT * FRO...
2008/11/02
[ "https://Stackoverflow.com/questions/256804", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14533/" ]
Is there a way to execute SQL custom functions with Enterpise Library? I've tried Database.ExecuteScalar() but for some reason it returns null. This is my function: ``` Database db = DatabaseFactory.CreateDatabase("ConnectionString"); DbCommand cmd = db.GetStoredProcCommand("FunctionName"); db.AddInParameter(cmd, "Va...
You have to create a select statement which selects the result from the function and execute that. "SELECT \* FROM FunctionName(@Value1, @Value2)" Or you can wrap your function call in a procedure and call the procedure, I prefer this.
256,807
<p>Is there any way to check if a given index of an array exists? I am trying to set numerical index but something like 1, 5, 6,10. And so I want to see if these indexes already exist and if they do just increase another counter.</p> <p>I normally work with php but I am trying to do this in c++, so basically I am tryi...
[ { "answer_id": 256814, "author": "mdec", "author_id": 15534, "author_profile": "https://Stackoverflow.com/users/15534", "pm_score": 2, "selected": false, "text": "<p>My personal vote is for using a vector. They will resize dynamically, and as long as you don't do something stupid (like t...
2008/11/02
[ "https://Stackoverflow.com/questions/256807", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8715/" ]
Is there any way to check if a given index of an array exists? I am trying to set numerical index but something like 1, 5, 6,10. And so I want to see if these indexes already exist and if they do just increase another counter. I normally work with php but I am trying to do this in c++, so basically I am trying to ask ...
In C++, the size of an array is fixed when it is declared, and while you can access off the end of the declared array size, this is very dangerous and the source of hard-to-track-down bugs: ``` int i[10]; i[10] = 2; // Legal but very dangerous! Writing on memory you don't know about ``` It seems that you want array-...
256,811
<p>How do you create non scrolling div that looks like the MS Office 2007 ribbon on a web page without two sets of scroll bars. One for the window and one for the div.</p>
[ { "answer_id": 256830, "author": "belugabob", "author_id": 13397, "author_profile": "https://Stackoverflow.com/users/13397", "pm_score": 3, "selected": false, "text": "<p>Use a fixed position <code>&lt;div&gt;</code> element, that has 100% width and a high <code>z-index</code>.</p>\n\n<p...
2008/11/02
[ "https://Stackoverflow.com/questions/256811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How do you create non scrolling div that looks like the MS Office 2007 ribbon on a web page without two sets of scroll bars. One for the window and one for the div.
Try this: ``` <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Fixed Header/Full Page Content</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"...
256,822
<p>In RoR,how to validate a Chinese or a Japanese word for a posting form with utf8 code.</p> <p>In GBK code, it uses [\u4e00-\u9fa5]+ to validate Chinese words. In Php, it uses /^[\x{4e00}-\x{9fa5}]+$/u for utf-8 pages.</p>
[ { "answer_id": 256855, "author": "Rômulo Ceccon", "author_id": 23193, "author_profile": "https://Stackoverflow.com/users/23193", "pm_score": 3, "selected": false, "text": "<p>Ruby 1.8 has poor support for UTF-8 strings. You need to write the bytes individually in the regular expression, ...
2008/11/02
[ "https://Stackoverflow.com/questions/256822", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20191/" ]
In RoR,how to validate a Chinese or a Japanese word for a posting form with utf8 code. In GBK code, it uses [\u4e00-\u9fa5]+ to validate Chinese words. In Php, it uses /^[\x{4e00}-\x{9fa5}]+$/u for utf-8 pages.
Ruby 1.8 has poor support for UTF-8 strings. You need to write the bytes individually in the regular expression, rather then the full code: ``` >> "acentuação".scan(/\xC3\xA7/) => ["ç"] ``` To match the range you specified the expression will become a bit complicated: ``` /([\x4E-\x9E][\x00-\xFF])|(\x9F[\x00-\x...
256,823
<p>The scenario is trying to adjust font size to get a nice graphic arrangement, or trying to decide where to break a caption/subtitle. a) In XL VBA is there a way to find out whether a text on a textbox, or caption on a label, still fits the control? b) Is there a way to know where was the text/caption broken on multi...
[ { "answer_id": 256885, "author": "dbb", "author_id": 25675, "author_profile": "https://Stackoverflow.com/users/25675", "pm_score": 0, "selected": false, "text": "<p>I'm sure there is no way to do this with the ordinary Excel controls on the Forms toolbar, not least because (as I understa...
2008/11/02
[ "https://Stackoverflow.com/questions/256823", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11567/" ]
The scenario is trying to adjust font size to get a nice graphic arrangement, or trying to decide where to break a caption/subtitle. a) In XL VBA is there a way to find out whether a text on a textbox, or caption on a label, still fits the control? b) Is there a way to know where was the text/caption broken on multilin...
I gave this a rest, gave it enough back-of-head time (which produces far better results than "burp a non-answer ASAP, for credits"), and... ``` Function TextWidth(aText As String, Optional aFont As NewFont) As Single Dim theFont As New NewFont Dim notSeenTBox As Control On Error Resume Next 'trap for aFon...
256,832
<p>I'm used to work with Java where large amounts of examples are available. For various reasons I had to switch to C# and trying to do the following in SharpDevelop:</p> <pre><code>// Form has a menu containing a combobox added via SharpDevelop's GUI // --- Variables languages = new string[2]; languages[0] = "Englis...
[ { "answer_id": 256840, "author": "Alan", "author_id": 31223, "author_profile": "https://Stackoverflow.com/users/31223", "pm_score": 0, "selected": false, "text": "<p>This line</p>\n\n<pre><code>mnuActionLanguage.ComboBox.DisplayMember = \"Lang.Language\";\n</code></pre>\n\n<p>is wrong. C...
2008/11/02
[ "https://Stackoverflow.com/questions/256832", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33429/" ]
I'm used to work with Java where large amounts of examples are available. For various reasons I had to switch to C# and trying to do the following in SharpDevelop: ``` // Form has a menu containing a combobox added via SharpDevelop's GUI // --- Variables languages = new string[2]; languages[0] = "English"; languages[...
You need to set the binding context of the ToolStripComboBox.ComboBox. Here is a slightly modified version of the code that I have just recreated using Visual Studio. The menu item combo box is called toolStripComboBox1 in my case. Note the last line of code to set the binding context. I noticed that if the combo is ...
256,859
<p>What, if any, is the performance difference between the following two loops?</p> <pre><code>for (Object o: objectArrayList) { o.DoSomething(); } </code></pre> <p>and </p> <pre><code>for (int i=0; i&lt;objectArrayList.size(); i++) { objectArrayList.get(i).DoSomething(); } </code></pre>
[ { "answer_id": 256861, "author": "Vijay Dev", "author_id": 27474, "author_profile": "https://Stackoverflow.com/users/27474", "pm_score": 9, "selected": true, "text": "<p>From Item 46 in <a href=\"https://rads.stackoverflow.com/amzn/click/com/0321356683\" rel=\"noreferrer\" rel=\"nofollow...
2008/11/02
[ "https://Stackoverflow.com/questions/256859", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26567/" ]
What, if any, is the performance difference between the following two loops? ``` for (Object o: objectArrayList) { o.DoSomething(); } ``` and ``` for (int i=0; i<objectArrayList.size(); i++) { objectArrayList.get(i).DoSomething(); } ```
From Item 46 in [Effective Java](https://rads.stackoverflow.com/amzn/click/com/0321356683) by Joshua Bloch : > > The for-each loop, introduced in > release 1.5, gets rid of the clutter > and the opportunity for error by > hiding the iterator or index variable > completely. The resulting idiom > applies equally t...
256,892
<p>How do i backup a SQL database using PHP.</p> <p>Is there a vendor agnostic way to do this that conforms to ANSI SQL?</p> <p>If not maybe you can list how to do it for each of the database vendors?</p>
[ { "answer_id": 256907, "author": "vog", "author_id": 19163, "author_profile": "https://Stackoverflow.com/users/19163", "pm_score": 4, "selected": true, "text": "<p>Every database system comes with some program for dumping its contents.</p>\n\n<ul>\n<li>PostgreSQL: <a href=\"http://www.po...
2008/11/02
[ "https://Stackoverflow.com/questions/256892", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13227/" ]
How do i backup a SQL database using PHP. Is there a vendor agnostic way to do this that conforms to ANSI SQL? If not maybe you can list how to do it for each of the database vendors?
Every database system comes with some program for dumping its contents. * PostgreSQL: [`pg_dump`](http://www.postgresql.org/docs/8.0/interactive/backup.html) * MySQL: [`mysqldump`](http://dev.mysql.com/doc/refman/5.0/en/mysqldump.html) * ... You can simply call that program from PHP using [`system()`](http://php.net/...
256,915
<p>I'm building small web shop with asp.net mvc and Structuremap ioc/di. My Basket class uses session object for persistence, and I want use SM to create my basket object through IBasket interface. My basket implementation need HttpSessionStateBase (session state wrapper from mvc) in constructor, which is available ins...
[ { "answer_id": 257496, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 3, "selected": true, "text": "<p>If you absolutely have to have your StoreBasketService use the session, I'd be tempted to define an interface and wra...
2008/11/02
[ "https://Stackoverflow.com/questions/256915", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1407/" ]
I'm building small web shop with asp.net mvc and Structuremap ioc/di. My Basket class uses session object for persistence, and I want use SM to create my basket object through IBasket interface. My basket implementation need HttpSessionStateBase (session state wrapper from mvc) in constructor, which is available inside...
If you absolutely have to have your StoreBasketService use the session, I'd be tempted to define an interface and wrapper around HttpSessionState instead of using HttpSessionStateBase so that you can register it with StructureMap as well.The wrapper would get the session state from the current context. Register the wra...
256,938
<p>I am writing a footer div that displays info from the database. The footer has a different background color than the rest of the page, and will have a height that depends on how much content the database throws to it. When I generate the content with php and call for a border around the footer div, the content app...
[ { "answer_id": 256944, "author": "scunliffe", "author_id": 6144, "author_profile": "https://Stackoverflow.com/users/6144", "pm_score": 4, "selected": true, "text": "<p>Check your footer CSS... if you have overflow set to anything but auto/scroll, then the DIV won't grow.</p>\n\n<p>If not...
2008/11/02
[ "https://Stackoverflow.com/questions/256938", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1149/" ]
I am writing a footer div that displays info from the database. The footer has a different background color than the rest of the page, and will have a height that depends on how much content the database throws to it. When I generate the content with php and call for a border around the footer div, the content appears ...
Check your footer CSS... if you have overflow set to anything but auto/scroll, then the DIV won't grow. If not try using something other than DL/DT since DT's are inline elements, they won't push your div to fit content.\* e.g. just try using a DIV instead, if the footer grows, you have your answer. (note: I revised...
256,978
<p>Is there a way to persist an enum to the DB using NHibernate? That is have a table of both the code and the name of each value in the enum.</p> <p>I want to keep the enum without an entity, but still have a foreign key (the int representation of the enum) from all other referencing entities to the enum's table.</p>...
[ { "answer_id": 257073, "author": "Paco", "author_id": 13376, "author_profile": "https://Stackoverflow.com/users/13376", "pm_score": 3, "selected": false, "text": "<p>An easy but not so beautiful solution:</p>\n\n<p>Create an integer field with and set the mapping in the mapping file to t...
2008/11/02
[ "https://Stackoverflow.com/questions/256978", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19956/" ]
Is there a way to persist an enum to the DB using NHibernate? That is have a table of both the code and the name of each value in the enum. I want to keep the enum without an entity, but still have a foreign key (the int representation of the enum) from all other referencing entities to the enum's table.
Why are you guys over complicating this? It is really simple. The mapping looks like this: ``` <property name="OrganizationType"></property> ``` The model property looks like this: ``` public virtual OrganizationTypes OrganizationType { get; set; } ``` The Enum looks like this: ``` public enum OrganizationTypes...
257,005
<p>I want to do this using the <code>Math.Round</code> function</p>
[ { "answer_id": 257011, "author": "John Boker", "author_id": 2847, "author_profile": "https://Stackoverflow.com/users/2847", "pm_score": 7, "selected": false, "text": "<p>Try this:</p>\n\n<pre><code>twoDec = Math.Round(val, 2)\n</code></pre>\n" }, { "answer_id": 257017, "autho...
2008/11/02
[ "https://Stackoverflow.com/questions/257005", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to do this using the `Math.Round` function
Here's some examples: ``` decimal a = 1.994444M; Math.Round(a, 2); //returns 1.99 decimal b = 1.995555M; Math.Round(b, 2); //returns 2.00 ``` You might also want to look at bankers rounding / round-to-even with the following overload: ``` Math.Round(a, 2, MidpointRounding.ToEven); ``` There's more information ...
257,030
<p>Writing something like this using the <a href="http://loki-lib.sourceforge.net/" rel="nofollow noreferrer">loki library</a>,</p> <pre><code>typedef Functor&lt;void&gt; BitButtonPushHandler; </code></pre> <p>throws a compiler error, but this works</p> <pre><code>typedef Functor&lt;void,TYPELIST_1(Matrix3D*)&gt; Pe...
[ { "answer_id": 257064, "author": "user23167", "author_id": 23167, "author_profile": "https://Stackoverflow.com/users/23167", "pm_score": 3, "selected": true, "text": "<p>Looking at the source code, the Functor template definition is as follows:</p>\n\n<pre><code>template &lt;typename R =...
2008/11/02
[ "https://Stackoverflow.com/questions/257030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/209/" ]
Writing something like this using the [loki library](http://loki-lib.sourceforge.net/), ``` typedef Functor<void> BitButtonPushHandler; ``` throws a compiler error, but this works ``` typedef Functor<void,TYPELIST_1(Matrix3D*)> Perspective; ``` > > Functor.h:530: error: '((Loki::FunctorHandler, int>\*)this)->Lok...
Looking at the source code, the Functor template definition is as follows: ``` template <typename R = void, class TList = NullType, template<class, class> class ThreadingModel = LOKI_DEFAULT_THREADING_NO_OBJ_LEVEL> class Functor{...}; ``` As commented below, there are no template typedefs allowed, so all...
257,047
<p>Where would i go to look for algorithms that take a 2d grid of values that are either 0 or 1 as input and then identifies all possible non-overlapping rectangles in it?</p> <p>In a more practical explanation: I am drawing a grid that is represented by a number of squares, and i wish to find a way to combine as many...
[ { "answer_id": 257069, "author": "Martin Beckett", "author_id": 10897, "author_profile": "https://Stackoverflow.com/users/10897", "pm_score": 0, "selected": false, "text": "<p>So you are looking for the rectangular boundary of the 'ON' squares?<br>\nDo you want the inner or outer bound?<...
2008/11/02
[ "https://Stackoverflow.com/questions/257047", "https://Stackoverflow.com", "https://Stackoverflow.com/users/145119/" ]
Where would i go to look for algorithms that take a 2d grid of values that are either 0 or 1 as input and then identifies all possible non-overlapping rectangles in it? In a more practical explanation: I am drawing a grid that is represented by a number of squares, and i wish to find a way to combine as many adjacent ...
I've done something similar for a quick-and-dirty voxel visualization of 3d boxes with OpenGL. I started from the top left box and stored the empty/filled flag. Then I tried to expand the rectangle to the right until I hit a box with a different flag. I did the same in the down direction. Draw the rectangle, if it i...
257,065
<p>The reason I am asking this is that I had accidentally done a <code>git commit -a</code> that included a file I did not yet want to commit. My solution was to do the following:</p> <pre><code>git reset --soft HEAD^ git reset -- file/with/changes_not_to_committed git commit -C HEAD@{1} </code></pre> <p>Here, I’ve r...
[ { "answer_id": 257105, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 2, "selected": false, "text": "<p>It looks like you can do something like this using <a href=\"http://kernel.org/pub/software/scm/git-core/docs/git-upda...
2008/11/02
[ "https://Stackoverflow.com/questions/257065", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9410/" ]
The reason I am asking this is that I had accidentally done a `git commit -a` that included a file I did not yet want to commit. My solution was to do the following: ``` git reset --soft HEAD^ git reset -- file/with/changes_not_to_committed git commit -C HEAD@{1} ``` Here, I’ve rewound the branch by one commit while...
Right. When you want to move revisions from HEAD or another revision to the index, you use 'git reset REVISION -- file' - then, you'd use 'git commit --amend' to revise the commit. As it happens I'm currently working on a review aimed towards making it more obvious how files can be moved from A to B like that. Of cour...
257,078
<p>I understand that using the "===" compares type, so running the following code results in "not equal" because it's comparing a number type to a string type.</p> <pre><code>var a = 20; var b = "20"; if (a === b) { alert("They are equal"); } else { alert("They are not equal"); } </code></pre> ...
[ { "answer_id": 257083, "author": "andy.gurin", "author_id": 22388, "author_profile": "https://Stackoverflow.com/users/22388", "pm_score": 5, "selected": true, "text": "<p>The <code>==</code> operator compares only the values of the variables. If the types are different, a conversion is o...
2008/11/02
[ "https://Stackoverflow.com/questions/257078", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I understand that using the "===" compares type, so running the following code results in "not equal" because it's comparing a number type to a string type. ``` var a = 20; var b = "20"; if (a === b) { alert("They are equal"); } else { alert("They are not equal"); } ``` But I dont understand ...
The `==` operator compares only the values of the variables. If the types are different, a conversion is operated. So the number 20 is converted to the string "20" and the result is compared. The `===` operator compares not only the values, but also the types, so no cast is operated. In this case `"20" !== 20`
257,085
<p>I have a JavaScript snippet that runs very well on Firefox and Safari, but refuses to run on IE:</p> <pre><code>var drop= function(id) { if(document.getElementById("select1").value == "Ficha de pediatria"){ top.location.href = "print.jsp?id="+id+"&amp;type=2"; } else if(document.getElementById("select1...
[ { "answer_id": 257095, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 4, "selected": true, "text": "<p>[EDIT] Sorry. I introduced an error with my first post by not carefully looking at how you are constructing your ur...
2008/11/02
[ "https://Stackoverflow.com/questions/257085", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26004/" ]
I have a JavaScript snippet that runs very well on Firefox and Safari, but refuses to run on IE: ``` var drop= function(id) { if(document.getElementById("select1").value == "Ficha de pediatria"){ top.location.href = "print.jsp?id="+id+"&type=2"; } else if(document.getElementById("select1").value == "Ficha...
[EDIT] Sorry. I introduced an error with my first post by not carefully looking at how you are constructing your url. I shouldn't have removed the `id` parameter. I've updated the code and it should work now. Try this instead: ``` function drop(ctl,id) { var value = ctl.options[ctl.selectedIndex].value; if(val...
257,091
<p>How do I clear the cin buffer in C++?</p>
[ { "answer_id": 257092, "author": "Gunnar Steinn", "author_id": 33468, "author_profile": "https://Stackoverflow.com/users/33468", "pm_score": 1, "selected": false, "text": "<p>The following should work:</p>\n\n<pre><code>cin.flush();\n</code></pre>\n\n<p>On some systems it's not available...
2008/11/02
[ "https://Stackoverflow.com/questions/257091", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How do I clear the cin buffer in C++?
Possibly: ``` std::cin.ignore(INT_MAX); ``` This would read in and ignore everything until `EOF`. (you can also supply a second argument which is the character to read until (ex: `'\n'` to ignore a single line). Also: You probably want to do a: `std::cin.clear();` before this too to reset the stream state.
257,093
<p>Given the following table, how does one calculate the hourly mode, or value with the highest frequency by hour?</p> <pre><code>CREATE TABLE Values ( ValueID int NOT NULL, Value int NOT NULL, LogTime datetime NOT NULL ) </code></pre> <p>So far, I've come up with the following query.</p> <pre><code>SELE...
[ { "answer_id": 257181, "author": "gbn", "author_id": 27535, "author_profile": "https://Stackoverflow.com/users/27535", "pm_score": 1, "selected": false, "text": "<p>Nest the aggregates...</p>\n\n<pre><code>SELECT\n MAX(Frequency) AS [Mode],\n [Year],[Month],[Day],[Hour]\nFROM\n ...
2008/11/02
[ "https://Stackoverflow.com/questions/257093", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Given the following table, how does one calculate the hourly mode, or value with the highest frequency by hour? ``` CREATE TABLE Values ( ValueID int NOT NULL, Value int NOT NULL, LogTime datetime NOT NULL ) ``` So far, I've come up with the following query. ``` SELECT count(*) AS Frequency, DatePart(y...
The following query may look odd... but it works and it gives you what you want. This query will give you the value that had the highest frequency in a particular "hour" (slice of time). I am *NOT* dividing into Year, Month, Day, etc... only hour (as you requested) even though you had those other fields in your exampl...
257,102
<p>In other words, can <code>fn()</code> know that it is being used as <code>$var = fn();</code> rather than as <code>fn();</code>?</p> <p>A use case would be to <code>echo</code> the return value in the latter case but to <code>return</code> it in the former.</p> <p>Can this be done without passing a parameter to th...
[ { "answer_id": 257113, "author": "andy.gurin", "author_id": 22388, "author_profile": "https://Stackoverflow.com/users/22388", "pm_score": 0, "selected": false, "text": "<p>No, there is no way to find it out. The unique thing you could do, is to grab the call stack (<a href=\"http://it2.p...
2008/11/02
[ "https://Stackoverflow.com/questions/257102", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17964/" ]
In other words, can `fn()` know that it is being used as `$var = fn();` rather than as `fn();`? A use case would be to `echo` the return value in the latter case but to `return` it in the former. Can this be done without passing a parameter to the function to declare which way it is being used?
Many PHP functions do this by passing a boolean value called $return which returns the value if $return is true, or prints the value if $return is false. A couple of examples are [print\_r()](http://php.net/print_r) and [highlight\_file()](http://php.net/highlight_file). So your function would look like this: ``` fun...
257,120
<p>I'm using TNMHTTP in Delphi to retrieve the code from a webpage. The code is relatively simple:</p> <pre><code>NMHTTP1 := TNMHTTP.Create(Self); NMHTTP1.InputFileMode := FALSE; NMHTTP1.OutputFileMode := FALSE; NMHTTP1.ReportLevel := Status_Basic; NMHTTP1.TimeOut := 3000; URL := 'http://www....'; NMHTTP1.Get(URL); ...
[ { "answer_id": 257123, "author": "Dave Ward", "author_id": 60, "author_profile": "https://Stackoverflow.com/users/60", "pm_score": 0, "selected": false, "text": "<p>The performance difference is negligible.</p>\n" }, { "answer_id": 257222, "author": "Timothy Khouri", "aut...
2008/11/02
[ "https://Stackoverflow.com/questions/257120", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30176/" ]
I'm using TNMHTTP in Delphi to retrieve the code from a webpage. The code is relatively simple: ``` NMHTTP1 := TNMHTTP.Create(Self); NMHTTP1.InputFileMode := FALSE; NMHTTP1.OutputFileMode := FALSE; NMHTTP1.ReportLevel := Status_Basic; NMHTTP1.TimeOut := 3000; URL := 'http://www....'; NMHTTP1.Get(URL); S := NMHTTP1.B...
The wireup isn't done at compile-time. It's done at runtime. As described in this article: <http://odetocode.com/Blogs/scott/archive/2006/02/16/2914.aspx> There IS a performance penalty because of the calls to CreateDelegate which must be made every time a page has been created. The performance hit is probably neglig...
257,152
<p>If I have two things which are hex, can I someone how append their binary together to get a value?</p> <p>In C++, say I have</p> <pre><code>unsigned char t = 0xc2; // 11000010 unsigned char q = 0xa3; // 10100011 </code></pre> <p>What I want is somehow, <code>1100001010100011</code>, is this possible using bit-w...
[ { "answer_id": 257158, "author": "Tigraine", "author_id": 21699, "author_profile": "https://Stackoverflow.com/users/21699", "pm_score": -1, "selected": false, "text": "<p>There is no append in binary/hex because you are dealing with Numbers (can you append 1 and 2 and not confuse the res...
2008/11/02
[ "https://Stackoverflow.com/questions/257152", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33481/" ]
If I have two things which are hex, can I someone how append their binary together to get a value? In C++, say I have ``` unsigned char t = 0xc2; // 11000010 unsigned char q = 0xa3; // 10100011 ``` What I want is somehow, `1100001010100011`, is this possible using bit-wise operators? I want to extract the binary...
Yes it's possible. Just use the left-bitshift operator, shifting to the left by 8, using at least a 16-bit integer. Then binary OR the 2nd value to the integer. ``` unsigned char t = 0xc2; // 11000010 unsigned char q = 0xa3; // 10100011 unsigned short s = (((unsigned short)t)<<8) | q; //// 11000010 10100011 ``` A...
257,157
<p>I am attempting to build a simple method that creates an XML file from a database in ruby on rails. I feel like my code is right but I am not seeing all of the users in the XML.<br> I am a complete newbie to RoR.</p> <p>Here's my code:</p> <pre><code>def create_file @users = User.find(:all) file = File.ne...
[ { "answer_id": 257180, "author": "Rômulo Ceccon", "author_id": 23193, "author_profile": "https://Stackoverflow.com/users/23193", "pm_score": 3, "selected": true, "text": "<p>There's a bug in your code. In each iteration you create an element with <a href=\"http://ruby-doc.org/stdlib/libd...
2008/11/02
[ "https://Stackoverflow.com/questions/257157", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33344/" ]
I am attempting to build a simple method that creates an XML file from a database in ruby on rails. I feel like my code is right but I am not seeing all of the users in the XML. I am a complete newbie to RoR. Here's my code: ``` def create_file @users = User.find(:all) file = File.new('dir.xml','w') doc...
There's a bug in your code. In each iteration you create an element with [`add_element`](http://ruby-doc.org/stdlib/libdoc/rexml/rdoc/classes/REXML/Element.html#M003015) and then try to access that element with [`Elements#[]`](http://ruby-doc.org/stdlib/libdoc/rexml/rdoc/classes/REXML/Elements.html#M002900). But when y...
257,190
<p>Here is a simple scenario with table characters:</p> <pre><code>CharacterName GameTime Gold Live Foo 10 100 3 Foo 20 100 2 Foo 30 95 2 </code></pre> <p>How do I get this output for the query <code>SELECT Gold, Live FROM characters WHERE name = 'Foo' ORDER BY GameTime</code>:</p> <pre><code>Gold Live 100 3 0 -1 ...
[ { "answer_id": 257213, "author": "Eoin Campbell", "author_id": 30155, "author_profile": "https://Stackoverflow.com/users/30155", "pm_score": 2, "selected": false, "text": "<p>Do you have an ID on your Table.</p>\n\n<pre><code>GameID CharacterName GameTime Gold Live\n------...
2008/11/02
[ "https://Stackoverflow.com/questions/257190", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15345/" ]
Here is a simple scenario with table characters: ``` CharacterName GameTime Gold Live Foo 10 100 3 Foo 20 100 2 Foo 30 95 2 ``` How do I get this output for the query `SELECT Gold, Live FROM characters WHERE name = 'Foo' ORDER BY GameTime`: ``` Gold Live 100 3 0 -1 -5 0 ``` using MySQL stored procedure (or quer...
One possible solution using a temporary table: ``` CREATE TABLE characters_by_gametime ( id INTEGER AUTO_INCREMENT PRIMARY KEY, gold INTEGER, live INTEGER); INSERT INTO characters_by_gametime (gold, live) SELECT gold, live FROM characters ORDER BY game_time; SELECT c1.id, c1.gold - IFNULL(c2.gold, 0) AS go...
257,220
<h2>solution structure [Plain Winforms + VS 2008 Express Edition]</h2> <ul> <li>CoffeeMakerInterface (NS CoffeeMaker)</li> <li>CoffeeMakerSoftware (NS CoffeeMakerSoftware)</li> <li>TestCoffeeMaker (NS TestCoffeeMaker)</li> </ul> <p>CoffeeMakerSoftware proj references CoffeeMakerInterface. TestCoffeeMaker proj referen...
[ { "answer_id": 257336, "author": "x0n", "author_id": 6920, "author_profile": "https://Stackoverflow.com/users/6920", "pm_score": 0, "selected": false, "text": "<p>A few things to check:</p>\n\n<ul>\n<li>Ensure \"copy local\" is TRUE for all project references</li>\n<li>If any are set to ...
2008/11/02
[ "https://Stackoverflow.com/questions/257220", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1695/" ]
solution structure [Plain Winforms + VS 2008 Express Edition] ------------------------------------------------------------- * CoffeeMakerInterface (NS CoffeeMaker) * CoffeeMakerSoftware (NS CoffeeMakerSoftware) * TestCoffeeMaker (NS TestCoffeeMaker) CoffeeMakerSoftware proj references CoffeeMakerInterface. TestCoffee...
I broke my 'Don't code when you're tired' dictum. I zipped it up, went to sleep and looked at it today.. found the issue by looking at the output window. *(FWIW everything was CopyLocal=True and nothing in GAC. This is Bob Martin's OOD problem from the Agile PPnP book.. coming up with good names was particularly hard)*...
257,229
<p>I am writing a quick application myself - first project, however I am trying to find the VBA code for writing the result of an input string to a named cell in Excel.</p> <p>For example, a input box asks the question "Which job number would you like to add to the list?"... the user would then enter a reference numbe...
[ { "answer_id": 257247, "author": "Bill the Lizard", "author_id": 1288, "author_profile": "https://Stackoverflow.com/users/1288", "pm_score": 5, "selected": true, "text": "<p>You can use the Range object in VBA to set the value of a named cell, just like any other cell.</p>\n\n<pre><code>...
2008/11/02
[ "https://Stackoverflow.com/questions/257229", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22284/" ]
I am writing a quick application myself - first project, however I am trying to find the VBA code for writing the result of an input string to a named cell in Excel. For example, a input box asks the question "Which job number would you like to add to the list?"... the user would then enter a reference number such as ...
You can use the Range object in VBA to set the value of a named cell, just like any other cell. ``` Range("C1").Value = Inputbox("Which job number would you like to add to the list?) ``` Where "C1" is the name of the cell you want to update. My Excel VBA is a little bit old and crusty, so there may be a better way ...
257,250
<p>I'm relatively new to jQuery, but so far what I've seen I like. What I want is for a div (or any element) to be across the top of the page as if "position: fixed" worked in every browser.</p> <p>I do not want something complicated. I do not want giant CSS hacks. I would prefer if just using jQuery (version 1.2.6) i...
[ { "answer_id": 257972, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 7, "selected": true, "text": "<p>Using this HTML:</p>\n\n<pre><code>&lt;div id=\"myElement\" style=\"position: absolute\"&gt;This stays at the top&lt;/div&gt...
2008/11/02
[ "https://Stackoverflow.com/questions/257250", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11917/" ]
I'm relatively new to jQuery, but so far what I've seen I like. What I want is for a div (or any element) to be across the top of the page as if "position: fixed" worked in every browser. I do not want something complicated. I do not want giant CSS hacks. I would prefer if just using jQuery (version 1.2.6) is good eno...
Using this HTML: ``` <div id="myElement" style="position: absolute">This stays at the top</div> ``` This is the javascript you want to use. It attaches an event to the window's scroll and moves the element down as far as you've scrolled. ``` $(window).scroll(function() { $('#myElement').css('top', $(this).scrol...
257,251
<p>I swear I've seen someone do this, but I can't find it in the various lists of shortcuts.</p> <p>Given:</p> <pre><code>String s = "A very long ............................ String"; </code></pre> <p>Is there an Eclipse shortcut to turn it into:</p> <pre><code>String s = "A very long ............................ "...
[ { "answer_id": 257252, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 5, "selected": true, "text": "<p>Yup - just hit return when your cursor is in the middle of the string.</p>\n\n<p>Admittedly that puts the + at the end...
2008/11/02
[ "https://Stackoverflow.com/questions/257251", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18995/" ]
I swear I've seen someone do this, but I can't find it in the various lists of shortcuts. Given: ``` String s = "A very long ............................ String"; ``` Is there an Eclipse shortcut to turn it into: ``` String s = "A very long ............................ " + "String"; ```
Yup - just hit return when your cursor is in the middle of the string. Admittedly that puts the + at the end of the first line instead of the start of the second, which is irritating if your style guide demands the latter, but if you're not fussy it's great :)
257,255
<p>I'm looking for a really generic way to "fill out" a form based on a parameter string using javascript.</p> <p>for example, if i have this form:</p> <pre><code>&lt;form id="someform"&gt; &lt;select name="option1"&gt; &lt;option value="1"&gt;1&lt;/option&gt; &lt;option value="2"&gt;2&lt;/option&gt; &lt;...
[ { "answer_id": 257287, "author": "Shadow2531", "author_id": 1697, "author_profile": "https://Stackoverflow.com/users/1697", "pm_score": 1, "selected": false, "text": "<p>You said you're already going through the elements and setting the values. However, maybe this is cleaner that what yo...
2008/11/02
[ "https://Stackoverflow.com/questions/257255", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12983/" ]
I'm looking for a really generic way to "fill out" a form based on a parameter string using javascript. for example, if i have this form: ``` <form id="someform"> <select name="option1"> <option value="1">1</option> <option value="2">2</option> </select> <select name="option2"> <option value="1">1</...
If you're using Prototype, this is easy. First, you can use the [toQueryParams](http://prototypejs.org/api/string/toQueryParams) method on the String object to get a Javascript object with name/value pairs for each parameter. Second, you can use the Form.Elements.setValue method (doesn't seem to be documented) to tran...
257,259
<pre><code>void addNewNode (struct node *head, int n) { struct node* temp = (struct node*) malloc(sizeof(struct node)); temp -&gt; data = n; temp -&gt; link = head; head = temp; } </code></pre> <p>The code give above is the popularly wrong version of a function for adding a new node at the head of a li...
[ { "answer_id": 257264, "author": "Michael Burr", "author_id": 12711, "author_profile": "https://Stackoverflow.com/users/12711", "pm_score": 5, "selected": true, "text": "<p>The flaw is that you're relying on the caller to perform the last step of updating the head pointer to the list.</p...
2008/11/02
[ "https://Stackoverflow.com/questions/257259", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6561/" ]
``` void addNewNode (struct node *head, int n) { struct node* temp = (struct node*) malloc(sizeof(struct node)); temp -> data = n; temp -> link = head; head = temp; } ``` The code give above is the popularly wrong version of a function for adding a new node at the head of a linked list. Generally the ...
The flaw is that you're relying on the caller to perform the last step of updating the head pointer to the list. If the caller neglects to do this, the compiler will not complain, and for all intents and purposes the list will appear to not have changed (and you'll have leaked the memory for a node).
257,286
<p>in C++ I have two chars holding hex values e.g.:</p> <pre><code>char t = 0x4; char q = 0x4; </code></pre> <p>How would i compare if the two values held in the char are the same?? I tried</p> <pre><code>if (t == q) // should give me true </code></pre> <p>but no, any help, thanks!</p>
[ { "answer_id": 257291, "author": "BobS", "author_id": 33481, "author_profile": "https://Stackoverflow.com/users/33481", "pm_score": -1, "selected": false, "text": "<p>Ah, I found the solution:</p>\n\n<pre><code>if (t &amp; q)\n</code></pre>\n" }, { "answer_id": 257304, "autho...
2008/11/02
[ "https://Stackoverflow.com/questions/257286", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33481/" ]
in C++ I have two chars holding hex values e.g.: ``` char t = 0x4; char q = 0x4; ``` How would i compare if the two values held in the char are the same?? I tried ``` if (t == q) // should give me true ``` but no, any help, thanks!
A char is just an 8-bit integer. It doesn't matter if you initialized it with hex or decimal literal, in either case the value of the char will be the same afterwards. So: ``` char t = 0x4; char q = 0x4; if(t == q) { //They are the same } ``` It is equivalent to: ``` char t = 4; char q = 4; if(t == q) { //They...
257,288
<p>Is it possible to write a template that changes behavior depending on if a certain member function is defined on a class?</p> <p>Here's a simple example of what I would want to write:</p> <pre><code>template&lt;class T&gt; std::string optionalToString(T* obj) { if (FUNCTION_EXISTS(T-&gt;toString)) retu...
[ { "answer_id": 257315, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 5, "selected": false, "text": "<p>This is what type traits are there for. Unfortunately, they have to be defined manually. In your case, imagine the...
2008/11/02
[ "https://Stackoverflow.com/questions/257288", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21482/" ]
Is it possible to write a template that changes behavior depending on if a certain member function is defined on a class? Here's a simple example of what I would want to write: ``` template<class T> std::string optionalToString(T* obj) { if (FUNCTION_EXISTS(T->toString)) return obj->toString(); else ...
Yes, with SFINAE you can check if a given class does provide a certain method. Here's the working code: ``` #include <iostream> struct Hello { int helloworld() { return 0; } }; struct Generic {}; // SFINAE test template <typename T> class has_helloworld { typedef char one; struct two { char x[2]; };...
257,324
<p>I need to add 30 minutes to values in a Oracle date column. I do this in my SELECT statement by specifying </p> <p><code>to_char(date_and_time + (.000694 * 31)</code></p> <p>which works fine most of the time. But not when the time is on the AM/PM border. For example, adding 30 minutes to <code>12:30</code> [whi...
[ { "answer_id": 257337, "author": "Camilo Díaz Repka", "author_id": 861, "author_profile": "https://Stackoverflow.com/users/861", "pm_score": 1, "selected": false, "text": "<p>Be sure that Oracle understands that the starting time is PM, and to specify the HH24 format mask for the final o...
2008/11/02
[ "https://Stackoverflow.com/questions/257324", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3401/" ]
I need to add 30 minutes to values in a Oracle date column. I do this in my SELECT statement by specifying `to_char(date_and_time + (.000694 * 31)` which works fine most of the time. But not when the time is on the AM/PM border. For example, adding 30 minutes to `12:30` [which is PM] returns `1:00` which is AM. The ...
All of the other answers are basically right but I don't think anyone's directly answered your original question. Assuming that "date\_and\_time" in your example is a column with type DATE or TIMESTAMP, I think you just need to change this: ``` to_char(date_and_time + (.000694 * 31)) ``` to this: ``` to_char(date_...
257,339
<p>I've never done it myself, and I've never subscribed to a feed, but it seems that I'm going to have to create one, so I'm wondering. The only way that seems apparent to me is that when the system is updated with a new item (blog post, news item, whatever), a new element should be written to the rss file. Or alternat...
[ { "answer_id": 257354, "author": "Drew Olson", "author_id": 9434, "author_profile": "https://Stackoverflow.com/users/9434", "pm_score": 2, "selected": false, "text": "<p>I'd say the answer is having an RSS feed be nothing more than another view of your data. This means that your rss feed...
2008/11/02
[ "https://Stackoverflow.com/questions/257339", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12765/" ]
I've never done it myself, and I've never subscribed to a feed, but it seems that I'm going to have to create one, so I'm wondering. The only way that seems apparent to me is that when the system is updated with a new item (blog post, news item, whatever), a new element should be written to the rss file. Or alternative...
For PHP I use feedcreator <http://feedcreator.org/> ``` <?php define ('CONFIG_SYSTEM_URL','http://www.domain.tld/'); require_once('feedcreator/feedcreator.class.php'); $feedformat='RSS2.0'; header('Content-type: application/xml'); $rss = new UniversalFeedCreator(); $rss->useCached(); $rss->title = "Item List"; $rs...
257,343
<p>If I have a range of say <code>000080-0007FF</code> and I want to see if a char containing hex is within that range, how can I do it?</p> <p>Example</p> <pre><code>char t = 0xd790; if (t is within range of 000080-0007FF) // true </code></pre>
[ { "answer_id": 257346, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 3, "selected": false, "text": "<pre><code>wchar_t t = 0xd790;\n\nif (t &gt;= 0x80 &amp;&amp; t &lt;= 0x7ff) ...\n</code></pre>\n\n<p>In C++, characters ...
2008/11/02
[ "https://Stackoverflow.com/questions/257343", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33481/" ]
If I have a range of say `000080-0007FF` and I want to see if a char containing hex is within that range, how can I do it? Example ``` char t = 0xd790; if (t is within range of 000080-0007FF) // true ```
``` wchar_t t = 0xd790; if (t >= 0x80 && t <= 0x7ff) ... ``` In C++, characters are interchangeable with integers and you can compare their values directly. Note that I used `wchar_t`, because the `char` data type can only hold values up to 0xFF.
257,350
<p>I need to create a form with, half linear view (textboxes and dropdownlists in separate line) and the other half, non linear view i.e. the textboxes will appear next to each other, like first name and last name will be next to each other. </p> <p>I am aware how to acomplish the linear view with CSS. I am using</p> ...
[ { "answer_id": 257370, "author": "Jake", "author_id": 24730, "author_profile": "https://Stackoverflow.com/users/24730", "pm_score": 2, "selected": true, "text": "<p>if you also float:left, set a width and display:inline the other input fields, the should appear on the same line</p>\n" ...
2008/11/02
[ "https://Stackoverflow.com/questions/257350", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23667/" ]
I need to create a form with, half linear view (textboxes and dropdownlists in separate line) and the other half, non linear view i.e. the textboxes will appear next to each other, like first name and last name will be next to each other. I am aware how to acomplish the linear view with CSS. I am using ``` fieldset ...
if you also float:left, set a width and display:inline the other input fields, the should appear on the same line
257,391
<p>I have a const char arr[] parameter that I am trying to iterate over,</p> <pre><code>char *ptr; for (ptr= arr; *ptr!= '\0'; ptr++) /* some code*/ </code></pre> <p>I get an error: assignment discards qualifiers from pointer target type</p> <p>Are const char [] handled differently than non-const?</p>
[ { "answer_id": 257394, "author": "JaredPar", "author_id": 23283, "author_profile": "https://Stackoverflow.com/users/23283", "pm_score": 5, "selected": true, "text": "<p>Switch the declaration of *ptr to be.</p>\n\n<pre><code>const char* ptr;\n</code></pre>\n\n<p>The problem is you are es...
2008/11/02
[ "https://Stackoverflow.com/questions/257391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9628/" ]
I have a const char arr[] parameter that I am trying to iterate over, ``` char *ptr; for (ptr= arr; *ptr!= '\0'; ptr++) /* some code*/ ``` I get an error: assignment discards qualifiers from pointer target type Are const char [] handled differently than non-const?
Switch the declaration of \*ptr to be. ``` const char* ptr; ``` The problem is you are essentially assigning a const char\* to a char\*. This is a violation of const since you're going from a const to a non-const.
257,396
<p>I'm having some trouble understanding how command parameter binding works.</p> <p>When I create an instance of the widget class before the call to InitializeComponent it seems to work fine. Modifications to the parameter(Widget) in the ExecuteCommand function will be "applied" to _widget. This is the behavior I e...
[ { "answer_id": 257508, "author": "Todd White", "author_id": 30833, "author_profile": "https://Stackoverflow.com/users/30833", "pm_score": 2, "selected": false, "text": "<p>InitializeCompenent processes the xaml associated with the file. It is at this point in time that the CommandParamet...
2008/11/02
[ "https://Stackoverflow.com/questions/257396", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22522/" ]
I'm having some trouble understanding how command parameter binding works. When I create an instance of the widget class before the call to InitializeComponent it seems to work fine. Modifications to the parameter(Widget) in the ExecuteCommand function will be "applied" to \_widget. This is the behavior I expected. ...
InitializeCompenent processes the xaml associated with the file. It is at this point in time that the CommandParameter binding is first processed. If you initialize your field before InitializeCompenent then your property will not be null. If you create it after then it is null. If you want to create the widget after ...
257,409
<p>I am writing a scraper that downloads all the image files from a HTML page and saves them to a specific folder. All the images are part of the HTML page.</p>
[ { "answer_id": 257412, "author": "user20955", "author_id": 20955, "author_profile": "https://Stackoverflow.com/users/20955", "pm_score": 3, "selected": false, "text": "<p>You have to download the page and parse html document, find your image with regex and download it.. You can use urlli...
2008/11/02
[ "https://Stackoverflow.com/questions/257409", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2220518/" ]
I am writing a scraper that downloads all the image files from a HTML page and saves them to a specific folder. All the images are part of the HTML page.
Here is some code to download all the images from the supplied URL, and save them in the specified output folder. You can modify it to your own needs. ``` """ dumpimages.py Downloads all the images on the supplied URL, and saves them to the specified output file ("/test/" by default) Usage: python dumpima...
257,418
<p>I've been seeing that expression for over 10 years now. I've been trying to think what it's good for. Since I see it mostly in #defines, I assume it's good for inner scope variable declaration and for using breaks (instead of gotos.)</p> <p>Is it good for anything else? Do you use it?</p>
[ { "answer_id": 257421, "author": "Jere.Jones", "author_id": 19476, "author_profile": "https://Stackoverflow.com/users/19476", "pm_score": 7, "selected": false, "text": "<p>It is a way to simplify error checking and avoid deep nested if's. For example:</p>\n\n<pre><code>do {\n // do som...
2008/11/02
[ "https://Stackoverflow.com/questions/257418", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31515/" ]
I've been seeing that expression for over 10 years now. I've been trying to think what it's good for. Since I see it mostly in #defines, I assume it's good for inner scope variable declaration and for using breaks (instead of gotos.) Is it good for anything else? Do you use it?
It's the only construct in C that you can use to `#define` a multistatement operation, put a semicolon after, and still use within an `if` statement. An example might help: ``` #define FOO(x) foo(x); bar(x) if (condition) FOO(x); else // syntax error here ...; ``` Even using braces doesn't help: ``` #defin...
257,462
<p>So I have this c# application that needs to ping my web server thats running linux/php stack.<br> I am having problems with the c# way of base 64 encoding bytes.</p> <p>my c# code is like:</p> <pre><code>byte[] encbuff = System.Text.Encoding.UTF8.GetBytes("the string"); String enc = Convert.ToBase64String(encbuff)...
[ { "answer_id": 257470, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 1, "selected": false, "text": "<p>Convert.ToBase64String doesn't seem to add anything extra as far as I can see. For instance:</p>\n\n<pre><code>byte[]...
2008/11/02
[ "https://Stackoverflow.com/questions/257462", "https://Stackoverflow.com", "https://Stackoverflow.com/users/146637/" ]
So I have this c# application that needs to ping my web server thats running linux/php stack. I am having problems with the c# way of base 64 encoding bytes. my c# code is like: ``` byte[] encbuff = System.Text.Encoding.UTF8.GetBytes("the string"); String enc = Convert.ToBase64String(encbuff); ``` and php side: ...
You should probably URL Encode your Base64 string on the C# side before you send it. And URL Decode it on the php side prior to base64 decoding it. C# side ``` byte[] encbuff = System.Text.Encoding.UTF8.GetBytes("the string"); string enc = Convert.ToBase64String(encbuff); string urlenc = Server.UrlEncode(enc); ``` ...
257,505
<p>Within an unordered list:</p> <pre><code>&lt;li&gt;&lt;span&gt;&lt;/span&gt; The lazy dog.&lt;/li&gt; &lt;li&gt;&lt;span&gt;AND&lt;/span&gt; The lazy cat.&lt;/li&gt; &lt;li&gt;&lt;span&gt;OR&lt;/span&gt; The active goldfish.&lt;/li&gt; </code></pre> <p>Adding a class or style attribute is permitted but padding the...
[ { "answer_id": 257524, "author": "Stephen Caldwell", "author_id": 33437, "author_profile": "https://Stackoverflow.com/users/33437", "pm_score": 10, "selected": true, "text": "<p><div class=\"snippet\" data-lang=\"js\" data-hide=\"false\" data-console=\"true\" data-babel=\"false\">\r\n<di...
2008/11/02
[ "https://Stackoverflow.com/questions/257505", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1293/" ]
Within an unordered list: ``` <li><span></span> The lazy dog.</li> <li><span>AND</span> The lazy cat.</li> <li><span>OR</span> The active goldfish.</li> ``` Adding a class or style attribute is permitted but padding the text and adding or changing tags is not allowed. The page is rendering with Courier New. Goal i...
```css ul { list-style-type: none; padding-left: 0px; } ul li span { float: left; width: 40px; } ``` ```html <ul> <li><span></span> The lazy dog.</li> <li><span>AND</span> The lazy cat.</li> <li><span>OR</span> The active goldfish.</li> </ul> ``` Like Eoin said, you need to put a non-breakin...
257,507
<p>I understand how the implementation of dynamic binding works and also the difference between static and dynamic binding, I am just having trouble wrapping my brain around the definition of dynamic binding. Basically other than it is a run-time binding type.</p>
[ { "answer_id": 257565, "author": "kings90", "author_id": 33269, "author_profile": "https://Stackoverflow.com/users/33269", "pm_score": 1, "selected": false, "text": "<p>I understand it being evident in polymorphism. Typically when creating multiple classes that derive from a base class....
2008/11/02
[ "https://Stackoverflow.com/questions/257507", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29299/" ]
I understand how the implementation of dynamic binding works and also the difference between static and dynamic binding, I am just having trouble wrapping my brain around the definition of dynamic binding. Basically other than it is a run-time binding type.
Basically, dynamic binding means that the address for a function call is not hard-coded into the code segment of your program when it's translated into assembly language, and is instead obtained from elsewhere, i.e. stack variables, array lookups, etc. At a higher level, if you have a line of code: ``` foo(bar) //Cal...
257,514
<p>I need to find out the pixel position of one element in a list that's been displayed using a <code>ListView</code>. It seems like I should get one of the <strong>TextView's</strong> and then use <code>getTop()</code>, but I can't figure out how to get a child view of a <code>ListView</code>.</p> <p><strong>Update:<...
[ { "answer_id": 257541, "author": "Feet", "author_id": 18340, "author_profile": "https://Stackoverflow.com/users/18340", "pm_score": 3, "selected": false, "text": "<p>A quick search of the docs for the ListView class has turned up getChildCount() and getChildAt() methods inherited from Vi...
2008/11/02
[ "https://Stackoverflow.com/questions/257514", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2652/" ]
I need to find out the pixel position of one element in a list that's been displayed using a `ListView`. It seems like I should get one of the **TextView's** and then use `getTop()`, but I can't figure out how to get a child view of a `ListView`. **Update:** The children of the `ViewGroup` do not correspond 1-to-1 wit...
See: [Android ListView: get data index of visible item](https://stackoverflow.com/questions/2001760/android-listview-get-data-index-of-visible-item/2002413#2002413) and combine with part of Feet's answer above, can give you something like: ``` int wantedPosition = 10; // Whatever position you're looking for int firstP...
257,519
<p>I'm completely new at C# and NUnit.</p> <p>In Boost.Test there is a family of <code>BOOST_*_THROW</code> macros. In Python's test module there is <code>TestCase.assertRaises</code> method.</p> <p>As far as I understand it, in C# with NUnit (2.4.8) the only method of doing exception test is to use <code>ExpectedExc...
[ { "answer_id": 257523, "author": "Cristian Libardo", "author_id": 16526, "author_profile": "https://Stackoverflow.com/users/16526", "pm_score": 3, "selected": false, "text": "<p>If you can use NUnit 2.5 there's some nice <a href=\"http://nunit.com/blogs/?p=63\" rel=\"noreferrer\">helpers...
2008/11/02
[ "https://Stackoverflow.com/questions/257519", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26141/" ]
I'm completely new at C# and NUnit. In Boost.Test there is a family of `BOOST_*_THROW` macros. In Python's test module there is `TestCase.assertRaises` method. As far as I understand it, in C# with NUnit (2.4.8) the only method of doing exception test is to use `ExpectedExceptionAttribute`. Why should I prefer `Expe...
I'm surprised I haven't seen this pattern mentioned yet. David Arno's is very similar, but I prefer the simplicity of this: ``` try { obj.SetValueAt(-1, "foo"); Assert.Fail("Expected exception"); } catch (IndexOutOfRangeException) { // Expected } Assert.IsTrue(obj.IsValid()); ```
257,550
<p>I have put together a script which is very much like the flickr photostream feature. Two thumbnails next to each other, and when you click the next or prev links the next (or previous) two images slide in. Cool!</p> <p>Currently when the page loads it loads the two images. The first time nxt / prv is used then the ...
[ { "answer_id": 257594, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 5, "selected": true, "text": "<p>To preload an image from Javascript, you don't need to do anything that sounds like AJAX or JSON. All you need is this:...
2008/11/02
[ "https://Stackoverflow.com/questions/257550", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28241/" ]
I have put together a script which is very much like the flickr photostream feature. Two thumbnails next to each other, and when you click the next or prev links the next (or previous) two images slide in. Cool! Currently when the page loads it loads the two images. The first time nxt / prv is used then the next two i...
To preload an image from Javascript, you don't need to do anything that sounds like AJAX or JSON. All you need is this: ``` var img = new Image(); img.src = "http://example.com/new/image.jpg"; ``` The browser will quite happily load the image in the background, even though it's not displayed anywhere. Then, when you...
257,563
<p>hey, I'm very new to all this so please excuse stupidity :)</p> <pre><code>import os import MySQLdb import time db = MySQLdb.connect(host="localhost", user="root", passwd="********", db="workspace") cursor = db.cursor() tailoutputfile = os.popen('tail -f syslog.log') while 1: x = tailoutputfile.readline()...
[ { "answer_id": 257570, "author": "Harley Holcombe", "author_id": 1057, "author_profile": "https://Stackoverflow.com/users/1057", "pm_score": 2, "selected": false, "text": "<pre><code> cursor.execute(\"INSERT INTO releases (date, cat, name) values (timestring, y[4], y[7]\")\n</code></pre>...
2008/11/02
[ "https://Stackoverflow.com/questions/257563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33512/" ]
hey, I'm very new to all this so please excuse stupidity :) ``` import os import MySQLdb import time db = MySQLdb.connect(host="localhost", user="root", passwd="********", db="workspace") cursor = db.cursor() tailoutputfile = os.popen('tail -f syslog.log') while 1: x = tailoutputfile.readline() if ...
As pointed out, you're failing to copy the Python variable values into the query, only their names, which mean nothing to MySQL. However the direct string concatenation option: ``` cursor.execute("INSERT INTO releases (date, cat, name) VALUES ('%s', '%s', '%s')" % (timestring, y[4], y[7])) ``` is dangerous and shou...
257,566
<p>I am attempting to use a Stream Result to return an image from a struts2 application. I seem to be having problem with configuring the action. Here is the configuration:</p> <pre><code> &lt;result name="success" type="stream"&gt; &lt;param name="contentType"&gt;image/jpeg&lt;/param&gt; &l...
[ { "answer_id": 257646, "author": "Vincent Ramdhanie", "author_id": 27439, "author_profile": "https://Stackoverflow.com/users/27439", "pm_score": 4, "selected": true, "text": "<p>I found <a href=\"http://www.nabble.com/Struts-2-File-upload-to-store-the-filedata-td14168069.html\" rel=\"nof...
2008/11/02
[ "https://Stackoverflow.com/questions/257566", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27439/" ]
I am attempting to use a Stream Result to return an image from a struts2 application. I seem to be having problem with configuring the action. Here is the configuration: ``` <result name="success" type="stream"> <param name="contentType">image/jpeg</param> <param name="inputName">inputStrea...
I found [this](http://www.nabble.com/Struts-2-File-upload-to-store-the-filedata-td14168069.html) which explained that the `InputStream` has to be created by me. It makes sense that I create an `InputStream` from the file that I want the user to download and then pass the Stream to the result. I guess that's my answer.
257,577
<p>Im thinking of updating my practices, and looking for a little help and advice!</p> <p>I do a lot of work on sites that run joomla, oscommerce, drupal etc and so I have created a lot of custom components/plugins and hacks etc. Currently each site has its own folder on my xampp setup. What I would like to do is hav...
[ { "answer_id": 257617, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 3, "selected": true, "text": "<p>Yes, SVN would be a great tool for this purpose. Store your code (eg: a custom Joomla component) in source control. Wherever...
2008/11/02
[ "https://Stackoverflow.com/questions/257577", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28241/" ]
Im thinking of updating my practices, and looking for a little help and advice! I do a lot of work on sites that run joomla, oscommerce, drupal etc and so I have created a lot of custom components/plugins and hacks etc. Currently each site has its own folder on my xampp setup. What I would like to do is have a default...
Yes, SVN would be a great tool for this purpose. Store your code (eg: a custom Joomla component) in source control. Wherever you want to use that component, just do a `checkout` or `export` of that particular folder into your live site. Here's one way you could structure your repository: ``` unfuddle.com/myRepo/trunk/...
257,583
<p>I need to schedule several different pages on several different sites to be run at certain times, usually once a night. Is there any software out there to do this? it would be nice if it called the page and then recorded the response and whether the called page was successful run or not. I was using Helm on a dif...
[ { "answer_id": 257595, "author": "Mark Allen", "author_id": 5948, "author_profile": "https://Stackoverflow.com/users/5948", "pm_score": 2, "selected": false, "text": "<p>How about <a href=\"http://www.google.com/search?hl=en&amp;rls=com.microsoft%3Aen-us&amp;q=wget+windows\" rel=\"nofoll...
2008/11/02
[ "https://Stackoverflow.com/questions/257583", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34548/" ]
I need to schedule several different pages on several different sites to be run at certain times, usually once a night. Is there any software out there to do this? it would be nice if it called the page and then recorded the response and whether the called page was successful run or not. I was using Helm on a different...
We use standard scheduled tasks that call a bat file that calls a VBS file. I know it is not the most elegant solution ever, but it consistently works. BAT: ``` webrun.vbs http://website.com/page.aspx ``` VBS: ``` dim URL, oArgs Set oArgs = WScript.Arguments if oArgs.Count = 0 then msgbox("Error: M...
257,587
<p>How can I bring my WPF application to the front of the desktop? So far I've tried:</p> <pre><code>SwitchToThisWindow(new WindowInteropHelper(Application.Current.MainWindow).Handle, true); SetWindowPos(new WindowInteropHelper(Application.Current.MainWindow).Handle, IntPtr.Zero, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);...
[ { "answer_id": 257741, "author": "Factor Mystic", "author_id": 1569, "author_profile": "https://Stackoverflow.com/users/1569", "pm_score": 3, "selected": true, "text": "<p>Well I figured out a work around. I'm making the call from a keyboard hook used to implement a hotkey. The call work...
2008/11/02
[ "https://Stackoverflow.com/questions/257587", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1569/" ]
How can I bring my WPF application to the front of the desktop? So far I've tried: ``` SwitchToThisWindow(new WindowInteropHelper(Application.Current.MainWindow).Handle, true); SetWindowPos(new WindowInteropHelper(Application.Current.MainWindow).Handle, IntPtr.Zero, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); SetForegroun...
Well I figured out a work around. I'm making the call from a keyboard hook used to implement a hotkey. The call works as expected if I put it into a BackgroundWorker with a pause. It's a kludge, but I have no idea why it wasn't working originally. ``` void hotkey_execute() { IntPtr handle = new WindowInteropHelper...
257,605
<p>I'm currently working on a small project with OCaml; a simple mathematical expression simplifier. I'm supposed to find certain patterns inside an expression, and simplify them so the number of parenthesis inside the expression decreases. So far I've been able to implement most rules except two, for which I've decide...
[ { "answer_id": 257627, "author": "vog", "author_id": 19163, "author_profile": "https://Stackoverflow.com/users/19163", "pm_score": 7, "selected": true, "text": "<p><strong>Quick Solution</strong></p>\n<p>You just need to add parentheses, or <code>begin</code>/<code>end</code>, around the...
2008/11/02
[ "https://Stackoverflow.com/questions/257605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9506/" ]
I'm currently working on a small project with OCaml; a simple mathematical expression simplifier. I'm supposed to find certain patterns inside an expression, and simplify them so the number of parenthesis inside the expression decreases. So far I've been able to implement most rules except two, for which I've decided t...
**Quick Solution** You just need to add parentheses, or `begin`/`end`, around the inner match: ```ml let rec filter exp = match exp with | Var v -> Var v | Sum (e1, e2) -> Sum (e1, e2) | Prod (e1, e2) -> Prod (e1, e2) | Diff (e1, e2) -> (match e2 with | Sum (e3, e4) -> fil...
257,616
<p>This is the <code>PATH</code> variable without sudo:</p> <pre><code>$ echo 'echo $PATH' | sh /opt/local/ruby/bin:/usr/bin:/bin </code></pre> <p>This is the <code>PATH</code> variable with sudo:</p> <pre><code>$ echo 'echo $PATH' | sudo sh /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bi...
[ { "answer_id": 257644, "author": "Kent Fredric", "author_id": 15614, "author_profile": "https://Stackoverflow.com/users/15614", "pm_score": 5, "selected": false, "text": "<p><code>PATH</code> is an environment variable, and as such is by default reset by sudo.</p>\n\n<p>You need special ...
2008/11/03
[ "https://Stackoverflow.com/questions/257616", "https://Stackoverflow.com", "https://Stackoverflow.com/users/136/" ]
This is the `PATH` variable without sudo: ``` $ echo 'echo $PATH' | sh /opt/local/ruby/bin:/usr/bin:/bin ``` This is the `PATH` variable with sudo: ``` $ echo 'echo $PATH' | sudo sh /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin ``` As far as I can tell, `sudo` is supposed to leave `...
This is ~~an annoying function~~ *a feature* of sudo on many distributions. To work around this "problem" on ubuntu I do the following in my ~/.bashrc ``` alias sudo='sudo env PATH=$PATH' ``` Note the above will work for commands that don't reset the $PATH themselves. However `su' resets it's $PATH so you must use ...
257,645
<p>For a random event generator I'm writing I need a simple algorithm to generate random ranges. </p> <p>So, for example:</p> <p>I may say I want 10 random intervals, between 1/1 and 1/7, with no overlap, in the states (1,2,3) where state 1 events add up to 1 day, state 2 events add up to 2 days and state 3 events ad...
[ { "answer_id": 257651, "author": "Brent Rockwood", "author_id": 31253, "author_profile": "https://Stackoverflow.com/users/31253", "pm_score": 1, "selected": false, "text": "<p>First use DateTime.Subtract to determine how many minutes/seconds/whatever between your min and max dates. Then...
2008/11/03
[ "https://Stackoverflow.com/questions/257645", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17174/" ]
For a random event generator I'm writing I need a simple algorithm to generate random ranges. So, for example: I may say I want 10 random intervals, between 1/1 and 1/7, with no overlap, in the states (1,2,3) where state 1 events add up to 1 day, state 2 events add up to 2 days and state 3 events add up to the rest....
Here is my current implementation that seems to work ok and accounts for all time. This would be so much cleaner if I didn't have to target .net 1.1 ``` public class Interval { public Interval(int state) { this.State = state; this.Duration = -1; this.Date = DateTime.MinValue; } ...
257,653
<p>Having a problem trying to create a function, as part of a BizTalk helper class that returns a value of type (Microsoft.XLANGs.BaseTypes.XLANGMessage). The function code is as follows:</p> <pre><code>public XLANGMessage UpdateXML (XLANGMessage inputFile) { XmlDocument xDoc = new XmlDocument(); XLANGMessage ou...
[ { "answer_id": 257702, "author": "David Hall", "author_id": 2660, "author_profile": "https://Stackoverflow.com/users/2660", "pm_score": 3, "selected": true, "text": "<p>In the code you have provided, change the line:</p>\n\n<pre><code>XLANGMessage outputFile;\n</code></pre>\n\n<p>to:</p>...
2008/11/03
[ "https://Stackoverflow.com/questions/257653", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3810/" ]
Having a problem trying to create a function, as part of a BizTalk helper class that returns a value of type (Microsoft.XLANGs.BaseTypes.XLANGMessage). The function code is as follows: ``` public XLANGMessage UpdateXML (XLANGMessage inputFile) { XmlDocument xDoc = new XmlDocument(); XLANGMessage outputFile; x...
In the code you have provided, change the line: ``` XLANGMessage outputFile; ``` to: ``` XLANGMessage outputFile = null; ``` and change the `TypeOf` to `typeof` You might want to take a look at these two blog articles [here](http://vijaymodi.wordpress.com/2008/07/19/biztalk-pass-an-xlang-message-or-an-xlang-mess...