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
461,439
<p>I have a list of values like this</p> <pre><code>1000, 20400 22200, 24444 </code></pre> <p>The ranges don't overlap.</p> <p>What I want to do is have a c# function that can store (loaded values from db then cache it locally) a relatively large list of these values then have a method for finding if a supplied valu...
[ { "answer_id": 461465, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 5, "selected": true, "text": "<p>You've specified values, but then talked about ranges.</p>\n\n<p>For just values, I'd use a <code>HashSet&lt;int&gt;</...
2009/01/20
[ "https://Stackoverflow.com/questions/461439", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42434/" ]
I have a list of values like this ``` 1000, 20400 22200, 24444 ``` The ranges don't overlap. What I want to do is have a c# function that can store (loaded values from db then cache it locally) a relatively large list of these values then have a method for finding if a supplied value is in any of the ranges? Does ...
You've specified values, but then talked about ranges. For just values, I'd use a `HashSet<int>`. For ranges it gets more complicated... Let us know if that's actually what you're after and I'll think about it more. If they *are* ranges, do you have any extra information about them? Do you know if they'll overlap or n...
461,443
<p>I have a window "Operation" in XAML that uses a user control "Status" defined in the same project. When I build the solution, it returns ok, but when I open the design view for the Window, visual studio says "Could not create an instance of type 'Status'. The XAML for the Window "Operation" is below:</p> <pre><cod...
[ { "answer_id": 461472, "author": "Megacan", "author_id": 54947, "author_profile": "https://Stackoverflow.com/users/54947", "pm_score": 1, "selected": false, "text": "<p>I don't know exactly whats the solution, but that happens to me too from time to time. I end up deleting declaration of...
2009/01/20
[ "https://Stackoverflow.com/questions/461443", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21668/" ]
I have a window "Operation" in XAML that uses a user control "Status" defined in the same project. When I build the solution, it returns ok, but when I open the design view for the Window, visual studio says "Could not create an instance of type 'Status'. The XAML for the Window "Operation" is below: ``` <Window x:Cla...
I was consistently having this problem with one control in my project and wound up resolving it by changing all of my images to `DynamicResource` rather than `StaticResource`. The really strange thing is that the designer worked just fine for the control itself and showed the images as expected. It was only when I use...
461,507
<p>How can I use BOOST_FOREACH efficiently (number-of-character/readability-wise) with a boost::ptr_map? </p> <p>Kristo demonstrated in his <a href="https://stackoverflow.com/questions/461507/how-to-use-boostforeach-with-a-boostptrmap#461908">answer</a> that it is possible to use BOOST_FOREACH with a ptr_map, but it ...
[ { "answer_id": 461628, "author": "Ferruccio", "author_id": 4086, "author_profile": "https://Stackoverflow.com/users/4086", "pm_score": 0, "selected": false, "text": "<p>It should compile without the reference:</p>\n\n<pre><code>BOOST_FOREACH (IntTpair p, mymap)\n</code></pre>\n\n<p>I thi...
2009/01/20
[ "https://Stackoverflow.com/questions/461507", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52986/" ]
How can I use BOOST\_FOREACH efficiently (number-of-character/readability-wise) with a boost::ptr\_map? Kristo demonstrated in his [answer](https://stackoverflow.com/questions/461507/how-to-use-boostforeach-with-a-boostptrmap#461908) that it is possible to use BOOST\_FOREACH with a ptr\_map, but it does not really sa...
As STL style containers, the pointer containers have a `value_type` typedef that you can use: ``` #include <boost/ptr_container/ptr_map.hpp> #include <boost/foreach.hpp> int main() { typedef boost::ptr_map<int, int> int_map; int_map mymap; BOOST_FOREACH(int_map::value_type p, mymap) { } } ``` I...
461,527
<p>I installed VisualSVN on a server that I am using to "stage" web applications that I write - at the present time these applications are Classic ASP/VBScript. My development workstation that I write code on has TortoiseSVN installed, and I can connect to the repository folder I created - I'm using the following stru...
[ { "answer_id": 461607, "author": "Chris K", "author_id": 51789, "author_profile": "https://Stackoverflow.com/users/51789", "pm_score": 2, "selected": false, "text": "<p>I can see you've done your homework, your repository layout is set up by the book. I'm not sure what VisualSVN does in...
2009/01/20
[ "https://Stackoverflow.com/questions/461527", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40667/" ]
I installed VisualSVN on a server that I am using to "stage" web applications that I write - at the present time these applications are Classic ASP/VBScript. My development workstation that I write code on has TortoiseSVN installed, and I can connect to the repository folder I created - I'm using the following structur...
First, I would concur with the other comments, your repository format is by the book with branches, tags, and the trunk. I would also recommend splitting the repository per project as mentioned. I've been involved in projects that have one shared repository and with split repositories, and the split repositories work b...
461,535
<p>I have an text that consists of information enclosed by a certain pattern. The only thing I know is the pattern: "${template.start}" and ${template.end} To keep it simple I will substitute ${template.start} and ${template.end} with "a" in the example.</p> <p>So one entry in the text would be:</p> <pre><code>aINFO...
[ { "answer_id": 461548, "author": "cletus", "author_id": 18393, "author_profile": "https://Stackoverflow.com/users/18393", "pm_score": 4, "selected": true, "text": "<p>Simply use non-greedy expressions, namely:</p>\n\n<pre><code>a(.*?)a\n</code></pre>\n" }, { "answer_id": 461563, ...
2009/01/20
[ "https://Stackoverflow.com/questions/461535", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have an text that consists of information enclosed by a certain pattern. The only thing I know is the pattern: "${template.start}" and ${template.end} To keep it simple I will substitute ${template.start} and ${template.end} with "a" in the example. So one entry in the text would be: ``` aINFORMATIONHEREa ``` I ...
Simply use non-greedy expressions, namely: ``` a(.*?)a ```
461,537
<p>Is there a quick and dirty way of using a query passed as follows:</p> <p>domain.com/mypage.aspx/product/toycar/ </p> <p>I've done it before in PHP, but this needs to be done in page (in this instance).</p> <p>-- I only have access to the aspx page and code behind, and have to work in asp.net 2 <em>(i wish i was ...
[ { "answer_id": 461576, "author": "stusmith", "author_id": 6604, "author_profile": "https://Stackoverflow.com/users/6604", "pm_score": 1, "selected": false, "text": "<p>You might want to look into the ASP.NET System.Web.Routing namespace, which was added in .NET 3.5 SP1 I believe:</p>\n\n...
2009/01/20
[ "https://Stackoverflow.com/questions/461537", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52912/" ]
Is there a quick and dirty way of using a query passed as follows: domain.com/mypage.aspx/product/toycar/ I've done it before in PHP, but this needs to be done in page (in this instance). -- I only have access to the aspx page and code behind, and have to work in asp.net 2 *(i wish i was using 3.5)*
quick and dirty: ``` public class ModuleRewriter : IHttpModule { public void Init(HttpApplication application) { application.BeginRequest += (new EventHandler(this.Application_BeginRequest)); } private void Application_BeginRequest(Object source, EventArgs e) { // The url will look...
461,555
<p>i have a field in table opt named confirm of type tinyint. i want to insert value(1) by this statement but it is not working can any one help??</p> <pre><code>$connect= mysql_connect("localhost","root") or die ("Sorry, Can not connect to database"); mysql_select_db("login") or die (mysql_error()); $user=$_POST['s...
[ { "answer_id": 461559, "author": "Bombe", "author_id": 43582, "author_profile": "https://Stackoverflow.com/users/43582", "pm_score": 3, "selected": false, "text": "<p>You are not executing the query.</p>\n" }, { "answer_id": 461572, "author": "Allain Lalonde", "author_id"...
2009/01/20
[ "https://Stackoverflow.com/questions/461555", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
i have a field in table opt named confirm of type tinyint. i want to insert value(1) by this statement but it is not working can any one help?? ``` $connect= mysql_connect("localhost","root") or die ("Sorry, Can not connect to database"); mysql_select_db("login") or die (mysql_error()); $user=$_POST['staff']; echo $...
You are not executing the query.
461,581
<p>I'm setting up a continuous integration server (Hudson) to build a Java project and run the relevant unit/integration tests. Most of these tests access a database and the test data is kept in a DbUnit XML file.</p> <p>I'm looking for a way to automatically keep the test database schema up-to-date. Currently the SQL...
[ { "answer_id": 461643, "author": "Aaron Digulla", "author_id": 34088, "author_profile": "https://Stackoverflow.com/users/34088", "pm_score": 2, "selected": false, "text": "<p>What I do in my tests:</p>\n\n<ul>\n<li>I keep a DB version somewhere</li>\n<li>In the first test, I tear down th...
2009/01/20
[ "https://Stackoverflow.com/questions/461581", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648/" ]
I'm setting up a continuous integration server (Hudson) to build a Java project and run the relevant unit/integration tests. Most of these tests access a database and the test data is kept in a DbUnit XML file. I'm looking for a way to automatically keep the test database schema up-to-date. Currently the SQL script fo...
What I do in my tests: * I keep a DB version somewhere * In the first test, I tear down the whole DB and build it from scratch * I run each schema update in an individual test * I run the "update DB" module as an individual test (must not do anything because all changes have been applied already). Optionally, I tear d...
461,584
<p>I am running into quite an annoying issue while trying to deserialise a specific XML document using XmlSerializer.Deserialize() method. </p> <p>Basically, I have a strongly typed XSD with an element of type double. When trying to deserialise the element for a specific XML document, I get the usual "System.FormatExc...
[ { "answer_id": 461621, "author": "Jeff Yates", "author_id": 23234, "author_profile": "https://Stackoverflow.com/users/23234", "pm_score": 0, "selected": false, "text": "<p>You could edit the schema to specify that the AverageSpeed value is not nullable. This requires that whatever produc...
2009/01/20
[ "https://Stackoverflow.com/questions/461584", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57125/" ]
I am running into quite an annoying issue while trying to deserialise a specific XML document using XmlSerializer.Deserialize() method. Basically, I have a strongly typed XSD with an element of type double. When trying to deserialise the element for a specific XML document, I get the usual "System.FormatException: In...
You can specify the default value like ``` [XmlElement] [System.ComponentModel.DefaultValueAttribute(0.0)] public double AverageSpeed { ... } ``` /edit: ok, strange beaviour here. Whatever I set as value in the Attribute it's always the fields value: ``` private double averageSpeed = 2.0; ``` But ...
461,595
<p>I have some code that will be accessed from two threads:</p> <pre><code> class Timer{ public: void Start(){ start_ = clock_->GetCurrentTime(); running_ = true; } void Read(){ if(running_){ time_duration remaining = clock_->GetCurrentTime() - start_; Actions(remaining) ...
[ { "answer_id": 461616, "author": "Frederik Gheysels", "author_id": 55774, "author_profile": "https://Stackoverflow.com/users/55774", "pm_score": 0, "selected": false, "text": "<p>I'm not sure whether I understand your question, but I think you want to prevent that Read is being executed ...
2009/01/20
[ "https://Stackoverflow.com/questions/461595", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17949/" ]
I have some code that will be accessed from two threads: ``` class Timer{ public: void Start(){ start_ = clock_->GetCurrentTime(); running_ = true; } void Read(){ if(running_){ time_duration remaining = clock_->GetCurrentTime() - start_; Actions(remaining) } } p...
Why not get rid of the "running" flag and use whether the "start" variable is empty as the condition? You don't specify a language but some sort of volatile marker for "start" would be a good idea too. This also assumes that "start" can be written atomically. For example: ``` class Timer{ public: void Start(){ ...
461,605
<p>Original Question:</p> <p>We have an odd error with WebResource.axd url generation. (It does not seem to be related to the fairly common "WebRsource.axd Padding is invalid and cannot be removed" issue).</p> <p>We have an ASP.NET web page that, when created, adds a script reference to WebResource.axd.</p> <p>In t...
[ { "answer_id": 511722, "author": "John Boker", "author_id": 2847, "author_profile": "https://Stackoverflow.com/users/2847", "pm_score": 3, "selected": false, "text": "<p>according to this post: </p>\n\n<p><a href=\"http://bytes.com/topic/asp-net/answers/861764-invalid-viewstate-system-st...
2009/01/20
[ "https://Stackoverflow.com/questions/461605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57120/" ]
Original Question: We have an odd error with WebResource.axd url generation. (It does not seem to be related to the fairly common "WebRsource.axd Padding is invalid and cannot be removed" issue). We have an ASP.NET web page that, when created, adds a script reference to WebResource.axd. In this case, we're seeing th...
This was eventually fixed by Microsoft: <http://blogs.msdn.com/b/ieinternals/archive/2010/04/01/ie8-lookahead-downloader-fixed.aspx>
461,619
<p>I saw <a href="https://stackoverflow.com/questions/461539/do-theoretical-computer-science-topics-such-as-regular-vs-non-regular-languages">this question</a>, and was curious as to what the <strong>pumping lemma</strong> was (<a href="http://en.wikipedia.org/wiki/Pumping_lemma" rel="noreferrer">Wikipedia</a> didn't h...
[ { "answer_id": 461647, "author": "Welbog", "author_id": 52443, "author_profile": "https://Stackoverflow.com/users/52443", "pm_score": 2, "selected": false, "text": "<p>Basically, you have a definition of a language (like XML), which is a way to tell whether a given string of characters (...
2009/01/20
[ "https://Stackoverflow.com/questions/461619", "https://Stackoverflow.com", "https://Stackoverflow.com/users/292/" ]
I saw [this question](https://stackoverflow.com/questions/461539/do-theoretical-computer-science-topics-such-as-regular-vs-non-regular-languages), and was curious as to what the **pumping lemma** was ([Wikipedia](http://en.wikipedia.org/wiki/Pumping_lemma) didn't help much). I understand that it's basically a theoret...
The pumping lemma is a simple proof to show that a language is not regular, meaning that a Finite State Machine cannot be built for it. The canonical example is the language `(a^n)(b^n)`. This is the simple language which is just any number of `a`s, followed by the same number of `b`s. So the strings ``` ab aabb aaabb...
461,631
<p>I have a seemingly simple problem though i am unable to get my head around it.</p> <p>Let's say i have the following string: 'abcabcabcabc' and i want to get the last occurrence of 'ab'. Is there a way i can do this <em>without</em> looping through all the other 'ab's from the beginning of the string?</p> <p>I rea...
[ { "answer_id": 461642, "author": "chills42", "author_id": 23855, "author_profile": "https://Stackoverflow.com/users/23855", "pm_score": 1, "selected": false, "text": "<pre><code>Pattern p = Pattern.compile(\"ab.*?$\");\nMatcher m = p.matcher(\"abcabcabcabc\");\nboolean b = m.matches();\n...
2009/01/20
[ "https://Stackoverflow.com/questions/461631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/58798/" ]
I have a seemingly simple problem though i am unable to get my head around it. Let's say i have the following string: 'abcabcabcabc' and i want to get the last occurrence of 'ab'. Is there a way i can do this *without* looping through all the other 'ab's from the beginning of the string? I read about anchoring the en...
Firstly, thanks for all the answers. Here is what i tried and this worked for me: ``` Pattern pattern = Pattern.compile("(ab)(?!.*ab)"); Matcher matcher = pattern.matcher("abcabcabcd"); if(matcher.find()) { System.out.println(matcher.start() + ", " + matcher.end()); } ``` This displays the following: ``` 6, 8 `...
461,641
<p>I'm trying to find a simple MySQL statement for the following two problems:</p> <p>I have 4 tables: Employees, Customers, Orders, Products (Each entry in Orders contains a date, a reference one product, a quantity and a reference to a customer, and a reference to an Employee).</p> <p>Now I'm trying to get all cust...
[ { "answer_id": 461686, "author": "Allain Lalonde", "author_id": 2443, "author_profile": "https://Stackoverflow.com/users/2443", "pm_score": 3, "selected": true, "text": "<p>For the first part (assuming quite a bit about the schema):</p>\n\n<pre><code>SELECT Customers.ID\nFROM Customers \...
2009/01/20
[ "https://Stackoverflow.com/questions/461641", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43960/" ]
I'm trying to find a simple MySQL statement for the following two problems: I have 4 tables: Employees, Customers, Orders, Products (Each entry in Orders contains a date, a reference one product, a quantity and a reference to a customer, and a reference to an Employee). Now I'm trying to get all customers where the v...
For the first part (assuming quite a bit about the schema): ``` SELECT Customers.ID FROM Customers LEFT JOIN orders AS o1 ON o1.CustomerID=Customers.ID AND YEAR(o1.DATE) = 1995 LEFT JOIN products AS p1 ON p1.id = o1.productID LEFT JOIN orders AS o2 ON o2.CustomerID=Customers.ID AND YEAR(o2.DATE) = 1996 ...
461,644
<p>I have a base class for many tests that has some helper methods they all need.</p> <p>It does not by itself have any tests on it, but JUnit (in eclipse) is invoking the test runner on it and complaining that there are no methods to test.</p> <p>How can I make it ignore this class?</p> <p>I know I could add a <cod...
[ { "answer_id": 461693, "author": "guerda", "author_id": 32043, "author_profile": "https://Stackoverflow.com/users/32043", "pm_score": 8, "selected": true, "text": "<p>Use to <code>@Ignore</code> annotation. It also works on classes.\nSee this one:</p>\n\n<pre><code>@Ignore public class I...
2009/01/20
[ "https://Stackoverflow.com/questions/461644", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2443/" ]
I have a base class for many tests that has some helper methods they all need. It does not by itself have any tests on it, but JUnit (in eclipse) is invoking the test runner on it and complaining that there are no methods to test. How can I make it ignore this class? I know I could add a `dummyTest` method that woul...
Use to `@Ignore` annotation. It also works on classes. See this one: ``` @Ignore public class IgnoreMe { @Test public void test1() { ... } @Test public void test2() { ... } } ``` > > Also, you can annotate a class > containing test methods with @Ignor...
461,645
<p>I know I can "SELECT 5 AS foo" and get the resultset:</p> <blockquote> <p><strong>foo</strong></p> <p>5</p> <p>(1 row)</p> </blockquote> <p>...is there any way to "SELECT 5,6,7 AS foo" and get the resultset:</p> <blockquote> <p><strong>foo</strong></p> <p>5</p> <p>6</p> <p>7</p> ...
[ { "answer_id": 461669, "author": "SQLMenace", "author_id": 740, "author_profile": "https://Stackoverflow.com/users/740", "pm_score": 4, "selected": true, "text": "<p>this is easy with a number table, here is an example</p>\n\n<pre><code>select number as foo\n from master..spt_values\nwhe...
2009/01/20
[ "https://Stackoverflow.com/questions/461645", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1335/" ]
I know I can "SELECT 5 AS foo" and get the resultset: > > **foo** > > > 5 > > > (1 row) > > > ...is there any way to "SELECT 5,6,7 AS foo" and get the resultset: > > **foo** > > > 5 > > > 6 > > > 7 > > > (3 rows) > > > ...I'm well aware that this is not typical DB usage, and any conceivable usag...
this is easy with a number table, here is an example ``` select number as foo from master..spt_values where type = 'p' and number between 5 and 7 ``` or if you want to use in ``` select number as foo from master..spt_values where type = 'p' and number in(5,6,7) ```
461,646
<p>I'd like to convert an external XML document without any XSD schema associated with it into a fluent .NET object.</p> <p>I have a simple XML file like:</p> <pre><code>&lt;application&gt; &lt;parameters&gt; &lt;param&gt;&lt;/param&gt; &lt;param&gt;&lt;/param&gt; &lt;/parameters&gt; &lt;g...
[ { "answer_id": 461664, "author": "Andrew Hare", "author_id": 34211, "author_profile": "https://Stackoverflow.com/users/34211", "pm_score": 1, "selected": false, "text": "<p>I would look at <a href=\"http://msdn.microsoft.com/en-us/library/x6c1kb0s(VS.71).aspx\" rel=\"nofollow noreferrer\...
2009/01/20
[ "https://Stackoverflow.com/questions/461646", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1929/" ]
I'd like to convert an external XML document without any XSD schema associated with it into a fluent .NET object. I have a simple XML file like: ``` <application> <parameters> <param></param> <param></param> </parameters> <generation /> <entities> <entity ID="1"> <P...
Arguably, the best way to do this these days is with Linq to XML. It is a whole lot easier than messing with XSDs and convoluted class definitions. ``` XDocument doc = XDocument.Load("file.xml"); var val = doc .Descendants("entity") .Where(p => p.Attribute("ID").Value == "1") .Descendants("PropTest") ....
461,649
<p>In my Flex3 app I have some floating windows which contain variable amounts of text. The windows are meant to be user-resizable. Currently, while I can resize the windows OK, I can't get the text in a TextArea in the window to re-flow when the window is resized. I've come across blog postings that there's a size bug...
[ { "answer_id": 461664, "author": "Andrew Hare", "author_id": 34211, "author_profile": "https://Stackoverflow.com/users/34211", "pm_score": 1, "selected": false, "text": "<p>I would look at <a href=\"http://msdn.microsoft.com/en-us/library/x6c1kb0s(VS.71).aspx\" rel=\"nofollow noreferrer\...
2009/01/20
[ "https://Stackoverflow.com/questions/461649", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6716/" ]
In my Flex3 app I have some floating windows which contain variable amounts of text. The windows are meant to be user-resizable. Currently, while I can resize the windows OK, I can't get the text in a TextArea in the window to re-flow when the window is resized. I've come across blog postings that there's a size bug in...
Arguably, the best way to do this these days is with Linq to XML. It is a whole lot easier than messing with XSDs and convoluted class definitions. ``` XDocument doc = XDocument.Load("file.xml"); var val = doc .Descendants("entity") .Where(p => p.Attribute("ID").Value == "1") .Descendants("PropTest") ....
461,655
<p>I am observing some behavior for which I am finding it tough to reason.</p> <p>I have a piece of code as follows:</p> <pre><code>int timer_temp_var; if ((timer_temp_var/1000.0) &gt; 5.0) { //Do something } </code></pre> <p>This piece leads to link error. </p> <pre><code>&gt; &gt; dld: warning: Undefined sym...
[ { "answer_id": 461731, "author": "qrdl", "author_id": 28494, "author_profile": "https://Stackoverflow.com/users/28494", "pm_score": 2, "selected": false, "text": "<p>Seems your compiler replaces \">\" operator with call to <code>_d_fle()</code> function, so you need to link some library ...
2009/01/20
[ "https://Stackoverflow.com/questions/461655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44111/" ]
I am observing some behavior for which I am finding it tough to reason. I have a piece of code as follows: ``` int timer_temp_var; if ((timer_temp_var/1000.0) > 5.0) { //Do something } ``` This piece leads to link error. ``` > > dld: warning: Undefined symbol _d_fle" > dld: no output written make[1]: *** > [...
Seems your compiler replaces ">" operator with call to `_d_fle()` function, so you need to link some library to your executable. Surprisingly "<" works although it should be replaced with `d_fgt()` function that most likely to be located in the same lib. Changing from `100.0` to `100` makes left operand of ">" intege...
461,685
<p>I am receiving a large list of current account numbers daily, and storing them in a database. My task is to find added and released accounts from each file. Right now, I have 4 SQL tables, (AccountsCurrent, AccountsNew, AccountsAdded, AccountsRemoved). When I receive a file, I am adding it entirely to AccountsNew. T...
[ { "answer_id": 461712, "author": "duffymo", "author_id": 37213, "author_profile": "https://Stackoverflow.com/users/37213", "pm_score": 1, "selected": false, "text": "<p>Sounds like a history/audit process that might be better done using triggers. Have a separate history table that captu...
2009/01/20
[ "https://Stackoverflow.com/questions/461685", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53007/" ]
I am receiving a large list of current account numbers daily, and storing them in a database. My task is to find added and released accounts from each file. Right now, I have 4 SQL tables, (AccountsCurrent, AccountsNew, AccountsAdded, AccountsRemoved). When I receive a file, I am adding it entirely to AccountsNew. Then...
To be honest, I think that I'd follow something like your approach. One thing is that you could remove the truncate, do a rename of the "new" to "current" and re-create "new".
461,711
<p>Whatever I try to compile in Cygwin I get the following output:</p> <pre> checking for mingw32 environment... no checking for EMX OS/2 environment... no checking how to run the C preprocessor... gcc -E checking for gcc... gcc checking whether the C compiler (gcc ) works... no configure: error: installation or con...
[ { "answer_id": 461746, "author": "Jay", "author_id": 20840, "author_profile": "https://Stackoverflow.com/users/20840", "pm_score": 2, "selected": false, "text": "<p>The '-llib' seems a bit unusual to me, but I'm far from an expert. Just out of curiosity is autoconf installed? I had some ...
2009/01/20
[ "https://Stackoverflow.com/questions/461711", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46411/" ]
Whatever I try to compile in Cygwin I get the following output: ``` checking for mingw32 environment... no checking for EMX OS/2 environment... no checking how to run the C preprocessor... gcc -E checking for gcc... gcc checking whether the C compiler (gcc ) works... no configure: error: installation or configurati...
Your Configure is wrong. Usually `autoreconf -f` helps. If not you need to check the failing rule and fix it.
461,714
<p>Is there a way to have a statement across multiple lines without the underscore character?</p> <p>It is really annoying in multi-line strings such as SQL statements, and especially <a href="http://en.wikipedia.org/wiki/Language_Integrated_Query" rel="noreferrer">LINQ</a> queries.</p> <p>Beside from the ugliness an...
[ { "answer_id": 461723, "author": "Nathan Koop", "author_id": 18821, "author_profile": "https://Stackoverflow.com/users/18821", "pm_score": 2, "selected": false, "text": "<p>I will say no. </p>\n\n<p>But the only proof that I have is personal experience and the fact that documentation on ...
2009/01/20
[ "https://Stackoverflow.com/questions/461714", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26/" ]
Is there a way to have a statement across multiple lines without the underscore character? It is really annoying in multi-line strings such as SQL statements, and especially [LINQ](http://en.wikipedia.org/wiki/Language_Integrated_Query) queries. Beside from the ugliness and difficulty when changing a line (nothing li...
No, you have to use the underscore, but I believe that VB.NET 10 will allow multiple lines w/o the underscore, only requiring if it can't figure out where the end should be.
461,717
<p>We have a RichTextBox WPF control and since we control the layout, we simply cannot allow any rich content... </p> <p>Therefor, we need to strip all data except text from the clipboard. For example, if someone is trying to copy/paste lets say text from a table directly from Microsoft Word, the RichTextBox also take...
[ { "answer_id": 461745, "author": "Sebastian", "author_id": 56440, "author_profile": "https://Stackoverflow.com/users/56440", "pm_score": -1, "selected": false, "text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/aa970910.aspx\" rel=\"nofollow noreferrer\">http://msdn.microsoft....
2009/01/20
[ "https://Stackoverflow.com/questions/461717", "https://Stackoverflow.com", "https://Stackoverflow.com/users/900/" ]
We have a RichTextBox WPF control and since we control the layout, we simply cannot allow any rich content... Therefor, we need to strip all data except text from the clipboard. For example, if someone is trying to copy/paste lets say text from a table directly from Microsoft Word, the RichTextBox also takes into acc...
It's simply not possible. In the end we used a toggle button where you could toggle to a textbox, paste it in there, and toggle back to our control. Nasty, but it works.
461,730
<p>I have come across a quirky "feature" in Visual Studio and I was interested in seeing if anyone else had noticed this. Or if it is specific to myself.</p> <p>I have some methods that perform SQL queries on a database and then return an OracleDataReader</p> <pre><code>method() { OracleCommand cmd = new command(quer...
[ { "answer_id": 461745, "author": "Sebastian", "author_id": 56440, "author_profile": "https://Stackoverflow.com/users/56440", "pm_score": -1, "selected": false, "text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/aa970910.aspx\" rel=\"nofollow noreferrer\">http://msdn.microsoft....
2009/01/20
[ "https://Stackoverflow.com/questions/461730", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47026/" ]
I have come across a quirky "feature" in Visual Studio and I was interested in seeing if anyone else had noticed this. Or if it is specific to myself. I have some methods that perform SQL queries on a database and then return an OracleDataReader ``` method() { OracleCommand cmd = new command(query, connection); Oracl...
It's simply not possible. In the end we used a toggle button where you could toggle to a textbox, paste it in there, and toggle back to our control. Nasty, but it works.
461,739
<p>I'm in the process of learning F# and am enjoying it so far. Almost all of the examples online use the lightweight syntax (#light); however, also give a comment about it being on for said example in most cases.</p> <p>Is it better to learn F# using #light enabled or disabled? I'm planning on eventually learning i...
[ { "answer_id": 461929, "author": "Tomas Petricek", "author_id": 33518, "author_profile": "https://Stackoverflow.com/users/33518", "pm_score": 6, "selected": true, "text": "<p>I'd definitely prefer learning F# with the #light syntax. The non-light version is sometimes useful for understan...
2009/01/20
[ "https://Stackoverflow.com/questions/461739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28540/" ]
I'm in the process of learning F# and am enjoying it so far. Almost all of the examples online use the lightweight syntax (#light); however, also give a comment about it being on for said example in most cases. Is it better to learn F# using #light enabled or disabled? I'm planning on eventually learning it w/o it tur...
I'd definitely prefer learning F# with the #light syntax. The non-light version is sometimes useful for understanding some tricks about the F# syntax, but the #light syntax gives you much pleasant experience. For example - using #light ``` let add a b c = let ab = a + b printfn "%d" ab c - ab ``` Using non-l...
461,742
<p>I'm looking for a function that will convert a standard IPv4 address into an Integer. Bonus points available for a function that will do the opposite.</p> <p>Solution should be in C#.</p>
[ { "answer_id": 461770, "author": "Barry Kelly", "author_id": 3712, "author_profile": "https://Stackoverflow.com/users/3712", "pm_score": 7, "selected": false, "text": "<p>32-bit unsigned integers <strong>are</strong> IPv4 addresses. Meanwhile, the <code>IPAddress.Address</code> property,...
2009/01/20
[ "https://Stackoverflow.com/questions/461742", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383/" ]
I'm looking for a function that will convert a standard IPv4 address into an Integer. Bonus points available for a function that will do the opposite. Solution should be in C#.
32-bit unsigned integers **are** IPv4 addresses. Meanwhile, the `IPAddress.Address` property, while deprecated, is an Int64 that returns the unsigned 32-bit value of the IPv4 address (the catch is, it's in network byte order, so you need to swap it around). For example, my local google.com is at `64.233.187.99`. That'...
461,748
<p>My TabItems before attempting to apply a left margin of 10 look like:</p> <p><img src="https://farm4.static.flickr.com/3487/3213045582_6830246427.jpg?v=0" alt="alt text"></p> <p>After attempting to apply the left margin of 10 to the blue tab, the blue tab gets cut off like:</p> <p><img src="https://farm4.static.f...
[ { "answer_id": 462279, "author": "Bryan Anderson", "author_id": 21186, "author_profile": "https://Stackoverflow.com/users/21186", "pm_score": -1, "selected": false, "text": "<p>My guess is you have a Width set on the blue tab. When you add a margin part of the width is taken up by the ma...
2009/01/20
[ "https://Stackoverflow.com/questions/461748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51746/" ]
My TabItems before attempting to apply a left margin of 10 look like: ![alt text](https://farm4.static.flickr.com/3487/3213045582_6830246427.jpg?v=0) After attempting to apply the left margin of 10 to the blue tab, the blue tab gets cut off like: ![alt text](https://farm4.static.flickr.com/3512/3213045546_20400f1226...
There are a few ways to go about this but easiest thing to do is to simply customize the TabItem.Header content like so: ``` <TabControl Margin="29,29,25,23" Name="tabControl1"> <TabItem Name="tabItem1"> <TabItem.Header> <TextBlock Margin="20,0,20,0">tabItem1</TextBlock> ...
461,756
<p>I've an old website, navigation in an frame at left, pages at right.</p> <p>I want when an page is url'd directly the nav (left frame) shows also.</p> <p>Until now I was an js working, but I don't know from when it are not working, now returns this message:</p> <p><em>Forbidden You don't have permission to access...
[ { "answer_id": 461856, "author": "Maiku Mori", "author_id": 54091, "author_profile": "https://Stackoverflow.com/users/54091", "pm_score": 1, "selected": false, "text": "<p>I just checked the website and it seems to be working now. My guess is that there was no file located at <a href=\"h...
2009/01/20
[ "https://Stackoverflow.com/questions/461756", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I've an old website, navigation in an frame at left, pages at right. I want when an page is url'd directly the nav (left frame) shows also. Until now I was an js working, but I don't know from when it are not working, now returns this message: *Forbidden You don't have permission to access /master.html on this serve...
Sorry for delay. Looks like the problem is in this little peace of javascript: ``` passpage = document.URL if (top.location == self.location) top.location.href="master.html?" + passpage ``` It should be: ``` passpage = window.location.pathname; if (top.location == self.location) { top.location.href="master...
461,761
<p>In JSF is it possible to have a datatable displays records as follows?</p> <pre><code> [Name ][Last Name][Age] 1. John Doe 20 Extra info on record 1 2. John Smith 20 Extra info on record 2 </code></pre> <p>Thank you</p>
[ { "answer_id": 461792, "author": "Romain Linsolas", "author_id": 26457, "author_profile": "https://Stackoverflow.com/users/26457", "pm_score": 1, "selected": false, "text": "<p>Third libraries, such as RichFaces, allow you to do that with the principle of subTable.\nYou can check this <a...
2009/01/20
[ "https://Stackoverflow.com/questions/461761", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32812/" ]
In JSF is it possible to have a datatable displays records as follows? ``` [Name ][Last Name][Age] 1. John Doe 20 Extra info on record 1 2. John Smith 20 Extra info on record 2 ``` Thank you
I'm sure there are a number of ways you could do this. If you don't mind nesting tables, you can use the *panelGrid* tag and CSS. View: ``` <f:view> <h:dataTable value="#{peopleBean.people}" var="row"> <h:column id="column1"> <f:facet name="header"> <h:panelGrid columns="3" co...
461,773
<p>What is the easiest way to programatically convert a compressed wav file (MPEG codec for example, but could be any installed codec) to an uncompressed wav file (16 bit PCM)?</p> <p>I've heard that using direct show and writing the code in native C++ would do it, but I've not had much experience with direct show. </...
[ { "answer_id": 461828, "author": "Stu Mackellar", "author_id": 28591, "author_profile": "https://Stackoverflow.com/users/28591", "pm_score": 2, "selected": false, "text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/dd375454(VS.85).aspx\" rel=\"nofollow noreferrer\">DirectShow</...
2009/01/20
[ "https://Stackoverflow.com/questions/461773", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1078/" ]
What is the easiest way to programatically convert a compressed wav file (MPEG codec for example, but could be any installed codec) to an uncompressed wav file (16 bit PCM)? I've heard that using direct show and writing the code in native C++ would do it, but I've not had much experience with direct show. Is there a...
You can decompress WAV files in C# using any ACM codec installed on your PC using [NAudio](http://www.codeplex.com/naudio). Here's some sample code: ``` using (WaveFileReader reader = new WaveFileReader(inputFileName)) { using (WaveStream convertedStream = WaveFormatConversionStream.CreatePcmStream(reader...
461,774
<p>I want to reuse some code licensed under a BSD license but I don't know how to make it clear what I wrote, what I have reused and what I have modified.</p> <p>Say the project I want to reuse code from has the following directory structure:</p> <pre><code>project/ |-- LICENSE.txt |-- module1/ | |-- file1.c | |-...
[ { "answer_id": 461887, "author": "Jeff Yates", "author_id": 23234, "author_profile": "https://Stackoverflow.com/users/23234", "pm_score": 1, "selected": false, "text": "<p>I like to have the license referenced inside a comment in the source code - it is easier that way as people are more...
2009/01/20
[ "https://Stackoverflow.com/questions/461774", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50765/" ]
I want to reuse some code licensed under a BSD license but I don't know how to make it clear what I wrote, what I have reused and what I have modified. Say the project I want to reuse code from has the following directory structure: ``` project/ |-- LICENSE.txt |-- module1/ | |-- file1.c | |-- file2.c | `-- fil...
Copy `LICENSE.txt` in your `module1` dir, and mention in your docs (README, LICENSE, etc.) that you use this part of the project. BSD style license is very liberal: as long as you give due credit and respect its requirements (this usually involves providing the unmodified license and copyright notices), you can do what...
461,782
<p>How do I get rid of the page breaks in an SSRS report, making the report display in a single page?</p>
[ { "answer_id": 461854, "author": "Dustin Brooks", "author_id": 54617, "author_profile": "https://Stackoverflow.com/users/54617", "pm_score": 4, "selected": false, "text": "<p>Make sure you do not have one of the properties set to true on one of your report items for <strong>PageBreakAtEn...
2009/01/20
[ "https://Stackoverflow.com/questions/461782", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How do I get rid of the page breaks in an SSRS report, making the report display in a single page?
Open the report's .rdl file in a text editor and locate the `<Page></Page>` section. In that section, insert the following: ``` <InteractiveHeight>0in</InteractiveHeight> <InteractiveWidth>8.5in</InteractiveWidth> ``` In SSRS, an interactive height of 0 means the report has an infinite length and therefore, it will ...
461,784
<p>im trying to getting auto complete working and i can do so fine when i just create an array in my mxml and then just initialize an arrayCollection at the top of the file in the initialize keyword.</p> <p>However i want to populate the arraycollection from a webservice but i cant seem to get it;</p> <p>im my applic...
[ { "answer_id": 461881, "author": "kenneth", "author_id": 53363, "author_profile": "https://Stackoverflow.com/users/53363", "pm_score": 2, "selected": true, "text": "<p>first off, Array is not Bindable so changing the variable data1 will have no knock on effect.</p>\n\n<p>The arrayCollect...
2009/01/20
[ "https://Stackoverflow.com/questions/461784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24481/" ]
im trying to getting auto complete working and i can do so fine when i just create an array in my mxml and then just initialize an arrayCollection at the top of the file in the initialize keyword. However i want to populate the arraycollection from a webservice but i cant seem to get it; im my application tag i have ...
first off, Array is not Bindable so changing the variable data1 will have no knock on effect. The arrayCollection is bindable. So presumming that the result (e.result) is actually an array (you should check this when debugging) then you could do the following ``` [Bindable] priavte var ac : ArrayCollection; ``` th...
461,788
<p>I have a problem reading and loading items of a collection which belongs to another collection in VB 2005. Those are all nodes of XML file. For example:</p> <p>Toto is a node in XML file, an item of collection Tocollect and also a child-node of Tocollect, Tocollect is an item of Collect and a child-node of it. </p>...
[ { "answer_id": 461881, "author": "kenneth", "author_id": 53363, "author_profile": "https://Stackoverflow.com/users/53363", "pm_score": 2, "selected": true, "text": "<p>first off, Array is not Bindable so changing the variable data1 will have no knock on effect.</p>\n\n<p>The arrayCollect...
2009/01/20
[ "https://Stackoverflow.com/questions/461788", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a problem reading and loading items of a collection which belongs to another collection in VB 2005. Those are all nodes of XML file. For example: Toto is a node in XML file, an item of collection Tocollect and also a child-node of Tocollect, Tocollect is an item of Collect and a child-node of it. When writing...
first off, Array is not Bindable so changing the variable data1 will have no knock on effect. The arrayCollection is bindable. So presumming that the result (e.result) is actually an array (you should check this when debugging) then you could do the following ``` [Bindable] priavte var ac : ArrayCollection; ``` th...
461,790
<p>I am trying to write a rails application which lets you go to a certain page, say /person/:id. On this page it shows a set of available resources. I want each resource to have a button next to it, which reserves that resource to that person (by creating a new instance of an Allocation model.) As an extension, I'd li...
[ { "answer_id": 463346, "author": "Chuck", "author_id": 50742, "author_profile": "https://Stackoverflow.com/users/50742", "pm_score": 1, "selected": false, "text": "<p>Make each row in the list a form and put the info about the item in question there. Of course, you'll need to submit and ...
2009/01/20
[ "https://Stackoverflow.com/questions/461790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am trying to write a rails application which lets you go to a certain page, say /person/:id. On this page it shows a set of available resources. I want each resource to have a button next to it, which reserves that resource to that person (by creating a new instance of an Allocation model.) As an extension, I'd like ...
im using jQuery, and this is what i did : ``` <script type="text/javascript"> $(document).ready(function() { $('#bulk_print').click(function(){ var target = '<%= bulk_print_prepaid_vouchers_path(:format => :pdf) %>'; $('#prepaidvoucher_bulk_print').attr('action', target); ...
461,800
<p>I have some strings that have been encrypted using the <a href="http://php.net/crypt" rel="nofollow noreferrer">PHP function <code>crypt()</code></a>.</p> <p>The outputs look something like this:</p> <pre><code>$1$Vf/.4.1.$CgCo33ebiHVuFhpwS.kMI0 $1$84..vD4.$Ps1PdaLWRoaiWDKCfjLyV1 $1$or1.RY4.$v3xo04v1yfB7JxDj1sC/J/...
[ { "answer_id": 461845, "author": "Ray Booysen", "author_id": 42124, "author_profile": "https://Stackoverflow.com/users/42124", "pm_score": 0, "selected": false, "text": "<p>From the documentation, this depends on the system. You can force the algorithm used by setting the salt parameter...
2009/01/20
[ "https://Stackoverflow.com/questions/461800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/55402/" ]
I have some strings that have been encrypted using the [PHP function `crypt()`](http://php.net/crypt). The outputs look something like this: ``` $1$Vf/.4.1.$CgCo33ebiHVuFhpwS.kMI0 $1$84..vD4.$Ps1PdaLWRoaiWDKCfjLyV1 $1$or1.RY4.$v3xo04v1yfB7JxDj1sC/J/ ``` While I believe crypt() is using the MD5 algorithm, the output...
OK, so maybe this answer is a year late, but I'll give it a shot. In your own answer, you note that `crypt()` is using the FreeBSD MD5, which also does some interesting transformations on the salt before running the hash, so the result of what I'm about to give you will never quite match up with the results of a call t...
461,826
<p>I am really thankful for everyone who would read this and try to help me, the following is the code I am trying to write for a server class for a socket-programming project for college:</p> <pre><code>import java.io.*; import java.net.*; import java.io.File; class Server{ public static void main (String[]args)...
[ { "answer_id": 461867, "author": "Richard Walton", "author_id": 15075, "author_profile": "https://Stackoverflow.com/users/15075", "pm_score": 0, "selected": false, "text": "<p>I'd be lying if I said I fully understand what your code is doing - But if you are getting null data when you ar...
2009/01/20
[ "https://Stackoverflow.com/questions/461826", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am really thankful for everyone who would read this and try to help me, the following is the code I am trying to write for a server class for a socket-programming project for college: ``` import java.io.*; import java.net.*; import java.io.File; class Server{ public static void main (String[]args)throws IOExcep...
In general, when there is a NullPointerException either: * You have not instantiated your object * Your object has been destroyed (closed) and therefore does not exist * You have an invalid cast * Your code has overwritten your object pointer You would need to examine your stack dump to see which of these is true. F...
461,840
<p>I was wondering how to avoid using Windows clipboard, when you want to "replicate" multiple sections of a Word document (using VBA in macros)</p> <p>Why to avoid? Because we're using Word on a server, in a multiuser environment (I know that it is officially frowned upon)</p> <p>Otherwise, this would be easily acco...
[ { "answer_id": 462758, "author": "John Mo", "author_id": 38988, "author_profile": "https://Stackoverflow.com/users/38988", "pm_score": -1, "selected": false, "text": "<p>Use the Text property of the Selection object to put the data into a string variable rather than onto the clipboard:</...
2009/01/20
[ "https://Stackoverflow.com/questions/461840", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57033/" ]
I was wondering how to avoid using Windows clipboard, when you want to "replicate" multiple sections of a Word document (using VBA in macros) Why to avoid? Because we're using Word on a server, in a multiuser environment (I know that it is officially frowned upon) Otherwise, this would be easily accomplished with Sel...
I finally resolved to copy word by word. FormattedText seemed to work fairly well, until the last word (some special (evidently) characters), where suddenly the cell that I just filled with copied content would go blank. When I increased the number of cells, other run-time errors would pop up, like Your table got corru...
461,842
<p>Every time I use Setup &amp; Deployment to create a new Web Setup, and run it (after edit all the nice things in the properties), the output is always a copy of the Web Site project...</p> <p>How can I output a PreCompile version of the WebSite project?</p> <p>What I did was, publish the Web Site (so I get the pre...
[ { "answer_id": 471049, "author": "Sergiu Damian", "author_id": 41345, "author_profile": "https://Stackoverflow.com/users/41345", "pm_score": 4, "selected": true, "text": "<p>I see you tried the standard Web Setup project from VS.\nScott Gu's blog post takes you to this page: </p>\n\n<p><...
2009/01/20
[ "https://Stackoverflow.com/questions/461842", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28004/" ]
Every time I use Setup & Deployment to create a new Web Setup, and run it (after edit all the nice things in the properties), the output is always a copy of the Web Site project... How can I output a PreCompile version of the WebSite project? What I did was, publish the Web Site (so I get the precompiled version), ad...
I see you tried the standard Web Setup project from VS. Scott Gu's blog post takes you to this page: [Visual Studio 2008 Web Deployment Projects](http://www.microsoft.com/downloads/details.aspx?FamilyID=0aa30ae8-c73b-4bdd-bb1b-fe697256c459&DisplayLang=en) which is a plugin for Visual Studio that activates an additio...
461,850
<p>I'm trying to use the MusiSync font to embed a sharp and flat symbol in a line of text. In order to keep these symbols from being tiny I have to make their point size twice the size of the rest of the text. Unfortunately, this messes up the line height in Internet Explorer and I cannot find a way to control it. You ...
[ { "answer_id": 462147, "author": "Diodeus - James MacFarlane", "author_id": 12579, "author_profile": "https://Stackoverflow.com/users/12579", "pm_score": 2, "selected": true, "text": "<p>I opened up Photoshop and used the font you link to. There is a huge amount of white-space above each...
2009/01/20
[ "https://Stackoverflow.com/questions/461850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4320/" ]
I'm trying to use the MusiSync font to embed a sharp and flat symbol in a line of text. In order to keep these symbols from being tiny I have to make their point size twice the size of the rest of the text. Unfortunately, this messes up the line height in Internet Explorer and I cannot find a way to control it. You can...
I opened up Photoshop and used the font you link to. There is a huge amount of white-space above each glyph in the font itself. The font is poorly designed. If you set your style to this, you'll see the issue: ``` .style2 { font-family: MusiSync; font-size: 24pt; border:1px solid #000000; } ``` The prob...
461,853
<p>Here's the scenario:</p> <p>We have users login on a secure connection. Could an unathorized user capture packets sent from the users machine to the server and then resend them? Would this allow them to login?</p> <p>This is a homegrown login system running on coldfusion.</p>
[ { "answer_id": 462147, "author": "Diodeus - James MacFarlane", "author_id": 12579, "author_profile": "https://Stackoverflow.com/users/12579", "pm_score": 2, "selected": true, "text": "<p>I opened up Photoshop and used the font you link to. There is a huge amount of white-space above each...
2009/01/20
[ "https://Stackoverflow.com/questions/461853", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38613/" ]
Here's the scenario: We have users login on a secure connection. Could an unathorized user capture packets sent from the users machine to the server and then resend them? Would this allow them to login? This is a homegrown login system running on coldfusion.
I opened up Photoshop and used the font you link to. There is a huge amount of white-space above each glyph in the font itself. The font is poorly designed. If you set your style to this, you'll see the issue: ``` .style2 { font-family: MusiSync; font-size: 24pt; border:1px solid #000000; } ``` The prob...
461,865
<p>I often find I want to write code something like this in C#, but I am uncomfortable with the identifier names:</p> <pre><code>public class Car { private Engine engine; public Engine Engine { get { return engine; } set { engine = value; ...
[ { "answer_id": 461878, "author": "Garry Shutler", "author_id": 6369, "author_profile": "https://Stackoverflow.com/users/6369", "pm_score": 5, "selected": true, "text": "<p>In this case, I would name them exactly as they are in the example.</p>\n\n<p>This is because the naming is clear as...
2009/01/20
[ "https://Stackoverflow.com/questions/461865", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2283/" ]
I often find I want to write code something like this in C#, but I am uncomfortable with the identifier names: ``` public class Car { private Engine engine; public Engine Engine { get { return engine; } set { engine = value; } } ...
In this case, I would name them exactly as they are in the example. This is because the naming is clear as to what data each element holds and/or will be used for. The only thing I would change for C#3 is to use an auto-property which would remove the local variable.
461,869
<p>How can a I guarantee that no pop-up dialogs will appear when I automate Microsoft Excel through OLE? I'm using a Perl module (Win32::OLE). I can avoid most dialog pop-ups using the following code:</p> <pre><code>use Win32::OLE; use Win32::OLE::Variant; use Win32::OLE::Const; my $excel_symbols = Win32::OLE::Const-...
[ { "answer_id": 462076, "author": "moonshadow", "author_id": 11834, "author_profile": "https://Stackoverflow.com/users/11834", "pm_score": 2, "selected": false, "text": "<p>You could consider using <a href=\"http://search.cpan.org/dist/Spreadsheet-ParseExcel/lib/Spreadsheet/ParseExcel.pm\...
2009/01/20
[ "https://Stackoverflow.com/questions/461869", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7045/" ]
How can a I guarantee that no pop-up dialogs will appear when I automate Microsoft Excel through OLE? I'm using a Perl module (Win32::OLE). I can avoid most dialog pop-ups using the following code: ``` use Win32::OLE; use Win32::OLE::Variant; use Win32::OLE::Const; my $excel_symbols = Win32::OLE::Const->Load('Microso...
I revisited this issue and found a solution. Copy the file before processing to a temporary location. Then save the file before closing it in Excel: ``` File::Copy::copy('c:\some_excel_file.xls', 'c:\temp\SFO3jfd.xls'); my $book = $excel->Workbooks->Open('c:\temp\SFO3jfd.xls', { 'UpdateLinks' => $excel_symbols->{'x...
461,886
<p>We are currently trying to implement a web application which is using the Java EE authentication mechanism with a FORM-based login, inside the Websphere 6.1 web container. If the authentication is successful, we have everything working; the LDAP membership groups are being retrieved, the group to role mapping is be...
[ { "answer_id": 463286, "author": "Olaf Kock", "author_id": 13447, "author_profile": "https://Stackoverflow.com/users/13447", "pm_score": 0, "selected": false, "text": "<p>This is ancient knowledge - I believe to have done such a thing with tomcat. There was, as far as I can remember, no ...
2009/01/20
[ "https://Stackoverflow.com/questions/461886", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57153/" ]
We are currently trying to implement a web application which is using the Java EE authentication mechanism with a FORM-based login, inside the Websphere 6.1 web container. If the authentication is successful, we have everything working; the LDAP membership groups are being retrieved, the group to role mapping is being ...
I use Struts so it will do forwarding for you. If you don't have a framework (why not?) you'll will have to do it manually. The Java EE spec covers the j\_security\_check servlet. The login page POSTs j\_username and j\_password to the j\_security\_check servlet. Your app will be configured to error to an unauthorize...
461,893
<p>I'd like to write a generic <em>method</em> that creates a new instances of a specified Type. I tried</p> <pre><code>protected T CreateNew&lt;T&gt;() where T : new() { return new T(); } </code></pre> <p>This works, but only if I specified the type at compile time, just like</p> <pre><code>var x = CreateNe...
[ { "answer_id": 461902, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": false, "text": "<p>The point of generics is to provide a mechanism whereby code can be reused for different types when the type is known...
2009/01/20
[ "https://Stackoverflow.com/questions/461893", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44107/" ]
I'd like to write a generic *method* that creates a new instances of a specified Type. I tried ``` protected T CreateNew<T>() where T : new() { return new T(); } ``` This works, but only if I specified the type at compile time, just like ``` var x = CreateNew<Point>(); ``` The point is, that I need to do ...
You can do it using a lambda: ``` Function<ISomeInterface> creationDelegate; if (selection == 1) creationDelegate = () => CreateNew<SomeClass>; else creationDelegate = () => CreateNew<SomeClass2>; ISomeInterface inter = creationDelegate(); // ... ISomeInterface inter2 = creationDelegate(); ``` I can't see t...
461,896
<p>This is a poll of sorts about common concurrency problems in Java. An example might be the classic deadlock or race condition or perhaps EDT threading bugs in Swing. I'm interested both in a breadth of possible issues but also in what issues are most common. So, please leave one specific answer of a Java concurre...
[ { "answer_id": 461910, "author": "Alex Miller", "author_id": 7671, "author_profile": "https://Stackoverflow.com/users/7671", "pm_score": 6, "selected": false, "text": "<p>One classic problem is changing the object you're synchronizing on while synchronizing on it:</p>\n\n<pre><code>synch...
2009/01/20
[ "https://Stackoverflow.com/questions/461896", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7671/" ]
This is a poll of sorts about common concurrency problems in Java. An example might be the classic deadlock or race condition or perhaps EDT threading bugs in Swing. I'm interested both in a breadth of possible issues but also in what issues are most common. So, please leave one specific answer of a Java concurrency bu...
The most common concurrency problem I've seen, is not realizing that a field written by one thread is *not guaranteed* to be seen by a different thread. A common application of this: ``` class MyThread extends Thread { private boolean stop = false; public void run() { while(!stop) { doSomeWork(); } ...
461,898
<p>I have some business objects which use:</p> <pre><code>Web.Configuration.WebConfigurationManager.AppSettings.Item("SomeSetting") </code></pre> <p>Now that I'm breaking those objects into their own library, it feels dirty to take a dependency on System.Web when nothing else in the library has anything to do with we...
[ { "answer_id": 461950, "author": "abatishchev", "author_id": 41956, "author_profile": "https://Stackoverflow.com/users/41956", "pm_score": 0, "selected": false, "text": "<p>Why don't use Web.config? I saw in MSDN mention that it's properly analogue of app.config for web applications.</p>...
2009/01/20
[ "https://Stackoverflow.com/questions/461898", "https://Stackoverflow.com", "https://Stackoverflow.com/users/337/" ]
I have some business objects which use: ``` Web.Configuration.WebConfigurationManager.AppSettings.Item("SomeSetting") ``` Now that I'm breaking those objects into their own library, it feels dirty to take a dependency on System.Web when nothing else in the library has anything to do with web. What is the proper wa...
Put it in web.config and call ConfigurationManager.AppSettings["KEY"] No need for system.web in your libraries.
461,911
<p>Can the elements of the Master Page be accessed from the Content Page?</p> <p>Lets say I have MasterPage1 and ContentPage1 that inherits from the MasterPage1, and the MasterPage1 has a button: Button1.</p> <p>Can I change the property of that button from the content page, for example to make Button1 invisible, ina...
[ { "answer_id": 461941, "author": "mbillard", "author_id": 810, "author_profile": "https://Stackoverflow.com/users/810", "pm_score": 4, "selected": true, "text": "<p>You have to put a reference to the MasterPage in your page/user control markup.</p>\n\n<pre><code>&lt;%@ Reference VirtualP...
2009/01/20
[ "https://Stackoverflow.com/questions/461911", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3241/" ]
Can the elements of the Master Page be accessed from the Content Page? Lets say I have MasterPage1 and ContentPage1 that inherits from the MasterPage1, and the MasterPage1 has a button: Button1. Can I change the property of that button from the content page, for example to make Button1 invisible, inactive etc? How ca...
You have to put a reference to the MasterPage in your page/user control markup. ``` <%@ Reference VirtualPath="..." %> ``` Then in the code-behind, you just cast the Page.MasterPage to your MasterPage and access its properties. ``` MyMasterPage myMasterPage = (MyMasterPage)Page.Master; ```
461,912
<p>I have two divs and two separate links that triggers slideDown and slideUp for the divs.</p> <p>When one of the divs are slided down and I click the other one, I hide the first div (slidingUp) and then open the other div (slidingDown) but, at the moment it's like while one div is sliding down, the other, also in th...
[ { "answer_id": 461916, "author": "Bryan A", "author_id": 29707, "author_profile": "https://Stackoverflow.com/users/29707", "pm_score": 0, "selected": false, "text": "<p>Most jquery functions have a callback parameter, you can just pass a function into that.</p>\n" }, { "answer_id...
2009/01/20
[ "https://Stackoverflow.com/questions/461912", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49742/" ]
I have two divs and two separate links that triggers slideDown and slideUp for the divs. When one of the divs are slided down and I click the other one, I hide the first div (slidingUp) and then open the other div (slidingDown) but, at the moment it's like while one div is sliding down, the other, also in the same tim...
``` $('#Div1').slideDown('fast', function(){ $('#Div2').slideUp('fast'); }); ``` Edit: Have you checked out the accordion plugin (if that's what you're trying to do)?
461,918
<p>I am thinking is that a good idea to define exception with template. Defining different types of exception is a super verbose task. You have to inherit exception, there is nothing changed, just inherit. Like this..</p> <pre><code>class FooException : public BaseException { public: ... }; class BarException : p...
[ { "answer_id": 462242, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 3, "selected": true, "text": "<p>It's definitely possible and works fine, but i would avoid it. It obscures diagnostics. GCC will display ...
2009/01/20
[ "https://Stackoverflow.com/questions/461918", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25077/" ]
I am thinking is that a good idea to define exception with template. Defining different types of exception is a super verbose task. You have to inherit exception, there is nothing changed, just inherit. Like this.. ``` class FooException : public BaseException { public: ... }; class BarException : public BaseExce...
It's definitely possible and works fine, but i would avoid it. It obscures diagnostics. GCC will display the name of the exception type, with the usual template stuff included. I would take the few minutes to define the new exception class, personally. It's not like you would do it all the time.
461,923
<p>I have an swc which needs to operate slightly differently depending on whether it is being hosted by AIR or not. I've seen two suggestions on the internet:</p> <ul> <li>Test Application.application for WindowedApplication.</li> <li>Test Security.sandboxType for Security.APPLICATION.</li> </ul> <p>However, these do...
[ { "answer_id": 461968, "author": "cliff.meyers", "author_id": 41754, "author_profile": "https://Stackoverflow.com/users/41754", "pm_score": 1, "selected": false, "text": "<p>I would try flash.utils.getDefinitionByName() which will allow you to pass one of the AIR API classes as a String....
2009/01/20
[ "https://Stackoverflow.com/questions/461923", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6448/" ]
I have an swc which needs to operate slightly differently depending on whether it is being hosted by AIR or not. I've seen two suggestions on the internet: * Test Application.application for WindowedApplication. * Test Security.sandboxType for Security.APPLICATION. However, these don't seem to work in my .swc as the ...
You can use the [flash.system.Capabilities](http://livedocs.adobe.com/flex/3/langref/index.html?flash/system/Capabilities.html&package-frame.html) object to find out if you running under AIR. ``` var isAir : Boolean = (Capabilities.playerType == "Desktop"); var isFlashPlayer : Boolean = (Capabilities.playerType == "St...
461,939
<p>what i want to do is select the appropriate class to instantiate based on parenthesis passed in. Currently what i have are two classes (ClassA and ClassB) and to call these im using 2 methods depending on the parenthesis. What i would like to achieve is to use just one method to instantiate either ClassA or ClassB...
[ { "answer_id": 461958, "author": "Tamas Czinege", "author_id": 8954, "author_profile": "https://Stackoverflow.com/users/8954", "pm_score": 4, "selected": false, "text": "<p>What you need is a factory method in a base class:</p>\n\n<pre><code>enum ClassType { ClassA, ClassB }\n\nclass Cla...
2009/01/20
[ "https://Stackoverflow.com/questions/461939", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26098/" ]
what i want to do is select the appropriate class to instantiate based on parenthesis passed in. Currently what i have are two classes (ClassA and ClassB) and to call these im using 2 methods depending on the parenthesis. What i would like to achieve is to use just one method to instantiate either ClassA or ClassB bas...
What you need is a factory method in a base class: ``` enum ClassType { ClassA, ClassB } class ClassBase { public static ClassBase Create(ClassType classType) { switch (classType) { case ClassType.ClassA: return new ClassA(); case ClassType.ClassB: return new ClassB(); ...
461,957
<p>I have a .Net Compact app running on Windows Mobile, and I want to be able to connect to a webservice running on the 'host' machine (i.e. the desktop the PDA is plugged into) when connected via ActiveSync, but I don't know the ip address of the host. How can I find the ip of the desktop PC progromatically on the PDA...
[ { "answer_id": 462009, "author": "ctacke", "author_id": 13154, "author_profile": "https://Stackoverflow.com/users/13154", "pm_score": 2, "selected": false, "text": "<p>Getting the address is no different than when you're connected to any other network adapter (typically ActiveSync is run...
2009/01/20
[ "https://Stackoverflow.com/questions/461957", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1367/" ]
I have a .Net Compact app running on Windows Mobile, and I want to be able to connect to a webservice running on the 'host' machine (i.e. the desktop the PDA is plugged into) when connected via ActiveSync, but I don't know the ip address of the host. How can I find the ip of the desktop PC progromatically on the PDA?
I've found a KB article [How To Retrieve the IP Address of the Remote PPP Peer](http://kbalertz.com/183988/Retrieve-Address-Remote.aspx), which uses the host "PPP\_Peer". So I tried: ``` Dns.GetHostEntry("PPP_Peer").AddressList[0] ``` And that does give me what I'm looking for (169.254.2.2 on the PC I'm using at the...
461,970
<p>I have a colleague who needs to convert text from a PL/SQL method into XML compliant text, as he is constructing a excel spreadsheet by updating a text template.</p> <p>Is there a method in PL/SQL to convert/encode text to XML compliant text?</p>
[ { "answer_id": 462097, "author": "hamishmcn", "author_id": 3590, "author_profile": "https://Stackoverflow.com/users/3590", "pm_score": 2, "selected": false, "text": "<p>Later versions of oracle have a built in <a href=\"http://www.orafaq.com/wiki/DBMS_XMLGEN\" rel=\"nofollow noreferrer\"...
2009/01/20
[ "https://Stackoverflow.com/questions/461970", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13911/" ]
I have a colleague who needs to convert text from a PL/SQL method into XML compliant text, as he is constructing a excel spreadsheet by updating a text template. Is there a method in PL/SQL to convert/encode text to XML compliant text?
Well, if you just want to convert XML characters, you'll want to do something like... ``` outgoing_text := DBMS_XMLGEN.CONVERT(incoming_text) ``` Where `outgoing_text` and `incoming_text` are both VARCHAR2 or CLOB. You can specify a second argument, but it defaults to `DBMS_XMLGEN.ENTITY_ENCODE`... it can also de...
461,978
<p>Consider the following lua code snippet :</p> <pre><code>local time = os.time() for _= 1, 10 do time = time + 1 print('Seeding with ' .. time) math.randomseed(time) for i = 1, 5 do print('\t' .. math.random(100)) end end </code></pre> <p>On a Linux machine, the result is, as expected, r...
[ { "answer_id": 462340, "author": "Gerald", "author_id": 19404, "author_profile": "https://Stackoverflow.com/users/19404", "pm_score": 2, "selected": false, "text": "<p>It's generally a bad idea to call srand multiple times with seeds that are numerically close (and especially bad to do s...
2009/01/20
[ "https://Stackoverflow.com/questions/461978", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56761/" ]
Consider the following lua code snippet : ``` local time = os.time() for _= 1, 10 do time = time + 1 print('Seeding with ' .. time) math.randomseed(time) for i = 1, 5 do print('\t' .. math.random(100)) end end ``` On a Linux machine, the result is, as expected, random numbers. But it seem...
Lua's random used to use C's `rand(3)` and `srand(3)` functions ([see here](http://www.lua.org/source/5.1/lmathlib.c.html#math_random)). UPDATE: newer Lua versions [use random(3) where available](http://www.lua.org/source/5.3/lmathlib.c.html#l_rand). Both the C90 standard and POSIX suggest an cross-platform implementa...
461,983
<p>I'm trying this but its giving me a type-mismatch. Is there another way to do this? I'm assuming rSource is not coming from the active sheet.</p> <p>Also, I only need values.</p> <p>Edit: The rSource is expected to have rows and columns. It will also be a single continuous area.</p> <p>Edit: Once this operation i...
[ { "answer_id": 462044, "author": "CABecker", "author_id": 32790, "author_profile": "https://Stackoverflow.com/users/32790", "pm_score": 0, "selected": false, "text": "<p>Is this a continuous area? Is it bounded by empty cells? If so you should be able to use the currentregion property ...
2009/01/20
[ "https://Stackoverflow.com/questions/461983", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1946/" ]
I'm trying this but its giving me a type-mismatch. Is there another way to do this? I'm assuming rSource is not coming from the active sheet. Also, I only need values. Edit: The rSource is expected to have rows and columns. It will also be a single continuous area. Edit: Once this operation is complete I should be a...
I believe your function is fine. I created a teststub: ``` Function Check() Dim x As Range Dim c As Range Set c = Range("A1", "A2") Set x = CopyRange(c) End Function ``` With the cells A1 set to 2 and A2 set to 3. On stepping into this, and evaluating the x variable using: ?x.Range("A1") (I got Type ...
461,985
<p>Just wondering if there is a better way to write the following PL/SQL piece of code in ORACLE ?</p> <pre><code>IF(p_c_courtesies_cd is not null OR p_c_language_cd is not null OR v_c_name is not null OR v_c_firstname is not null OR v_c_function is not null OR p_c_phone is not null OR p_c_mobile is not null OR p_c_...
[ { "answer_id": 462006, "author": "Otávio Décio", "author_id": 48684, "author_profile": "https://Stackoverflow.com/users/48684", "pm_score": 4, "selected": true, "text": "<pre><code>If coalesce( expr1, expr2, ... expr_n ) is not null then do something end if;\n</code></pre>\n\n<p><a href=...
2009/01/20
[ "https://Stackoverflow.com/questions/461985", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41766/" ]
Just wondering if there is a better way to write the following PL/SQL piece of code in ORACLE ? ``` IF(p_c_courtesies_cd is not null OR p_c_language_cd is not null OR v_c_name is not null OR v_c_firstname is not null OR v_c_function is not null OR p_c_phone is not null OR p_c_mobile is not null OR p_c_fax is not nul...
``` If coalesce( expr1, expr2, ... expr_n ) is not null then do something end if; ``` [See here.](http://www.techonthenet.com/oracle/functions/coalesce.php) (Thanks Tony for the correction)
462,027
<p>For all trinary numbers with length 36 (including those starting with 0's), how many have exactly equal counts of 1's and 2's, or exactly one more 1 than 2?</p> <p>For example:</p> <ul> <li>00 - yes</li> <li>01 - yes</li> <li>02 - no</li> <li>10 - yes</li> <li>11 - no</li> <li>12 - yes</li> <li>20 - no</li> <li>21...
[ { "answer_id": 462092, "author": "Paul Brinkley", "author_id": 18160, "author_profile": "https://Stackoverflow.com/users/18160", "pm_score": 1, "selected": false, "text": "<p>The process seems straightforward enough as a combinatorial exercise. For every N in [1..18], find all the diffe...
2009/01/20
[ "https://Stackoverflow.com/questions/462027", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16266/" ]
For all trinary numbers with length 36 (including those starting with 0's), how many have exactly equal counts of 1's and 2's, or exactly one more 1 than 2? For example: * 00 - yes * 01 - yes * 02 - no * 10 - yes * 11 - no * 12 - yes * 20 - no * 21 - yes * 22 - no So for all trinary numbers of length 2, 5 out of 9 p...
A friend of mine gave me the following answer, and he knows more math than I do. I have marked this as 'community' because it is not my work. You would need to know the number of ways for every (most?) combination, not just equal 1s/2s. EG you can put together +18 and -18 to get an equal number of 1s and 2s ``` 18 0/...
462,038
<p>Has anyone had any success with getting data via Xml-rpc using Python or Perl...?</p> <p>I'm using the continuum.py library:</p> <pre><code>#!/usr/bin/env python from continuum import * c = Continuum( "http://localhost:8080/continuum/xmlrpc" ) </code></pre> <p>or:</p> <pre><code>#!/usr/bin/perl use Frontier::...
[ { "answer_id": 462092, "author": "Paul Brinkley", "author_id": 18160, "author_profile": "https://Stackoverflow.com/users/18160", "pm_score": 1, "selected": false, "text": "<p>The process seems straightforward enough as a combinatorial exercise. For every N in [1..18], find all the diffe...
2009/01/20
[ "https://Stackoverflow.com/questions/462038", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57160/" ]
Has anyone had any success with getting data via Xml-rpc using Python or Perl...? I'm using the continuum.py library: ``` #!/usr/bin/env python from continuum import * c = Continuum( "http://localhost:8080/continuum/xmlrpc" ) ``` or: ``` #!/usr/bin/perl use Frontier::Client; my $url = "http://dev.server.com:80...
A friend of mine gave me the following answer, and he knows more math than I do. I have marked this as 'community' because it is not my work. You would need to know the number of ways for every (most?) combination, not just equal 1s/2s. EG you can put together +18 and -18 to get an equal number of 1s and 2s ``` 18 0/...
462,062
<p>I'm creating a simple project for iPhone, using Xcode and Interface Builder. While I understand what a delegate is, I have a problem with using it.</p> <p>I have an UITextField in my interface. It displays keyboard when user taps on it, but I need to program manually how to hide keyboard. It can be done using deleg...
[ { "answer_id": 462214, "author": "Marc Charbonneau", "author_id": 35136, "author_profile": "https://Stackoverflow.com/users/35136", "pm_score": 0, "selected": false, "text": "<p>You can put delegate methods in any class, including one built just for that purpose. The reason Apple (and ot...
2009/01/20
[ "https://Stackoverflow.com/questions/462062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57157/" ]
I'm creating a simple project for iPhone, using Xcode and Interface Builder. While I understand what a delegate is, I have a problem with using it. I have an UITextField in my interface. It displays keyboard when user taps on it, but I need to program manually how to hide keyboard. It can be done using delegates. So i...
Your Control1Delegate object is getting destroyed soon after it is created. All top-level Nib objects must be retained if you want to keep them alive. Refer to the [Resource Programming Guide: The Nib Object Life Cycle](https://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/LoadingResources/CocoaNibs...
462,071
<p>I have a view that is joining two tables and ordering by the first table. Except that the order isn't correct. It misses an occasional record, and then at the end, most of those records exist in order, and then at that end, the rest of the records exist in order. So it has records such as </p> <pre><code>1 (mos...
[ { "answer_id": 462091, "author": "Brent Ozar", "author_id": 26837, "author_profile": "https://Stackoverflow.com/users/26837", "pm_score": 1, "selected": false, "text": "<p>Most likely the two SQL Servers are slightly different versions. There's a known hotfix for this:</p>\n\n<p><a href...
2009/01/20
[ "https://Stackoverflow.com/questions/462071", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22523/" ]
I have a view that is joining two tables and ordering by the first table. Except that the order isn't correct. It misses an occasional record, and then at the end, most of those records exist in order, and then at that end, the rest of the records exist in order. So it has records such as ``` 1 (most of the records ...
Read [Create a sorted view in SQL Server 2005 and SQL Server 2008](http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/create-a-sorted-view-in-sql-server-2005--2008) there is a hotfix and you HAVE to run in 2000 compatibility mode for it to work. Why not just do the order by when selecting from the view?
462,077
<p>I have the following interface:</p> <pre><code>public interface Result&lt;T extends Serializable&gt; extends Serializable{ T getResult(); } </code></pre> <p>With that interface, I can not define a variable of type</p> <pre><code>Result&lt;List&lt;Integer&gt;&gt; </code></pre> <p>because List is not serializa...
[ { "answer_id": 462116, "author": "Matthew Brubaker", "author_id": 21311, "author_profile": "https://Stackoverflow.com/users/21311", "pm_score": -1, "selected": false, "text": "<p>Initial thought. If you are planning on using serialization for any kind of long term data storage, don't. ...
2009/01/20
[ "https://Stackoverflow.com/questions/462077", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54318/" ]
I have the following interface: ``` public interface Result<T extends Serializable> extends Serializable{ T getResult(); } ``` With that interface, I can not define a variable of type ``` Result<List<Integer>> ``` because List is not serializable. However, if I change the interface to this: ``` public inter...
You need to declare your variable type as `Result<? extends List<Integer>>`. The type checking knows that `List` isn't `serializable`, but a subtype of `List` can be `serializable`. Here is some sample code. The interface implementation was just done with anonymous inner classes. You can see that the `getResult` will...
462,082
<p>I have two Apache servers running PHP. One accepts forward-slashes in the query string and passes it along to PHP in the expected way, for example:</p> <pre> http://server/index.php?url=http://foo.bar </pre> <p>works and in PHP this expression is true:</p> <pre><code>$_REQUEST['url'] == "http://foo.bar" </code><...
[ { "answer_id": 462291, "author": "UberDragon", "author_id": 56854, "author_profile": "https://Stackoverflow.com/users/56854", "pm_score": -1, "selected": false, "text": "<p>This sounds like another case of default magic_quotes_gpc. On the server causing problems check the php.ini and ma...
2009/01/20
[ "https://Stackoverflow.com/questions/462082", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4926/" ]
I have two Apache servers running PHP. One accepts forward-slashes in the query string and passes it along to PHP in the expected way, for example: ``` http://server/index.php?url=http://foo.bar ``` works and in PHP this expression is true: ``` $_REQUEST['url'] == "http://foo.bar" ``` However, in the *other* Apa...
`http://server/index.php?url=http://foo.bar` is not a valid url. You have to encode the slashes. I think browsers do this automagically, so maybe you were testing with different browsers? Or perhaps it's the [AllowEncodedSlashes](http://httpd.apache.org/docs/2.2/mod/core.html#allowencodedslashes) setting?
462,084
<p>I'm doing a peer review and I've found people using window.location.search to check what paremetes have been sent to a given (search) page.</p> <p>Is it safe to do so? I was thinking that we could probably print the parameters in the HTML output inside a script block and verify the printed variables instead of quer...
[ { "answer_id": 462093, "author": "Christoph", "author_id": 48015, "author_profile": "https://Stackoverflow.com/users/48015", "pm_score": 4, "selected": false, "text": "<p>If javascript is enabled, <code>window.location.search</code> is safe to use.</p>\n\n<p>And just as some useless piec...
2009/01/20
[ "https://Stackoverflow.com/questions/462084", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43490/" ]
I'm doing a peer review and I've found people using window.location.search to check what paremetes have been sent to a given (search) page. Is it safe to do so? I was thinking that we could probably print the parameters in the HTML output inside a script block and verify the printed variables instead of querying windo...
One thing to note about this approach. `window.location` is set statically on page load and will not detect changes that the user has made to the address bar after that time. This should not be a concern but it is important to know. Save the following code as an html file and fire it up in a browser: ``` <!DOCTYPE ht...
462,088
<p>We have a projector application (.exe) compiled from AS3. How can we start another (external) executable from the projector?</p> <p>This is the code...it does nothing visible.</p> <pre><code>//Play ACQ Demo Acq.addEventListener(MouseEvent.CLICK, clickAcq); function clickAcq(event:MouseEvent):void { ...
[ { "answer_id": 462115, "author": "Simon Groenewolt", "author_id": 31884, "author_profile": "https://Stackoverflow.com/users/31884", "pm_score": 4, "selected": true, "text": "<p>The documentation says the program you want to execute should be in an 'fscommand' folder that is next to the p...
2009/01/20
[ "https://Stackoverflow.com/questions/462088", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1490/" ]
We have a projector application (.exe) compiled from AS3. How can we start another (external) executable from the projector? This is the code...it does nothing visible. ``` //Play ACQ Demo Acq.addEventListener(MouseEvent.CLICK, clickAcq); function clickAcq(event:MouseEvent):void { flash.system.fscomma...
The documentation says the program you want to execute should be in an 'fscommand' folder that is next to the projector exe. (You can put a bat file there to start other programs) <http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/system/package.html> Edit: If you want more advanced options you...
462,094
<p>As an example:</p> <pre><code>public class Foo { private Foo() {} } public class Bar extends Foo { private Bar() {} static public doSomething() { } } </code></pre> <p>That's a compilation error right there. A class needs to, at least, implicitly call its superclass's default constructor, which in...
[ { "answer_id": 462102, "author": "Richard Walton", "author_id": 15075, "author_profile": "https://Stackoverflow.com/users/15075", "pm_score": 4, "selected": true, "text": "<p>You can't. You need to make Foo's constructor package private at the very least (Though I'd probably just make i...
2009/01/20
[ "https://Stackoverflow.com/questions/462094", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8683/" ]
As an example: ``` public class Foo { private Foo() {} } public class Bar extends Foo { private Bar() {} static public doSomething() { } } ``` That's a compilation error right there. A class needs to, at least, implicitly call its superclass's default constructor, which in this case is isn't visibl...
You can't. You need to make Foo's constructor package private at the very least (Though I'd probably just make it protected. (Edit - Comments in this post make a good point)
462,100
<p>I think this question is rather easy for you shell scripting monsters.</p> <p>I am looking for the most elegant and shortest way to create symbolic links to shared libraries for Unix by means of a bash shell script.</p> <p>What I need is starting out with a list of shared library files such as "libmythings.so.1.1,...
[ { "answer_id": 462140, "author": "Kent Fredric", "author_id": 15614, "author_profile": "https://Stackoverflow.com/users/15614", "pm_score": 4, "selected": false, "text": "<p>I believe <code>ldconfig</code> is the standard tool that does this. </p>\n\n<p>I recall somewhere it can generate...
2009/01/20
[ "https://Stackoverflow.com/questions/462100", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34880/" ]
I think this question is rather easy for you shell scripting monsters. I am looking for the most elegant and shortest way to create symbolic links to shared libraries for Unix by means of a bash shell script. What I need is starting out with a list of shared library files such as "libmythings.so.1.1, libotherthings.s...
``` for baselib in "$@" do shortlib=$baselib while extn=$(echo $shortlib | sed 's/\.[0-9][0-9]*$//') [ -n "$extn" ] do shortlib=$(basename $shortlib $extn) ln -s $baselib $shortlib done done ``` I've cheated - all the links go to the base library (libmythings.so.1.1); ...
462,165
<p>I get this message when compiling C++ on gcc 4.3</p> <pre><code>error: ‘NULL’ was not declared in this scope </code></pre> <p>It appears and disappears and I don't know why. Why?</p> <p>Thanks.</p>
[ { "answer_id": 462199, "author": "David Thornley", "author_id": 14148, "author_profile": "https://Stackoverflow.com/users/14148", "pm_score": 3, "selected": false, "text": "<p><code>NULL</code> isn't a keyword; it's a macro substitution for 0, and comes in <code>stddef.h</code> or <code>...
2009/01/20
[ "https://Stackoverflow.com/questions/462165", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48461/" ]
I get this message when compiling C++ on gcc 4.3 ``` error: ‘NULL’ was not declared in this scope ``` It appears and disappears and I don't know why. Why? Thanks.
`NULL` is not a keyword. It's an identifier defined in some standard headers. You can include ``` #include <cstddef> ``` To have it in scope, including some other basics, like `std::size_t`.
462,167
<p>I'm making a call:</p> <pre><code>myResult = MakeMyCall(inputParams, out messages); </code></pre> <p>but I don't actually care about the messages. If it was an input parameter I didn't care about I'd just pass in a null. If it was the return I didn't care about I'd just leave it off. </p> <p>Is there a way to ...
[ { "answer_id": 462183, "author": "Andrew Hare", "author_id": 34211, "author_profile": "https://Stackoverflow.com/users/34211", "pm_score": 5, "selected": false, "text": "<p>Unfortunately you are required to pass something because the method is required to set it. So you cannot send <cod...
2009/01/20
[ "https://Stackoverflow.com/questions/462167", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26874/" ]
I'm making a call: ``` myResult = MakeMyCall(inputParams, out messages); ``` but I don't actually care about the messages. If it was an input parameter I didn't care about I'd just pass in a null. If it was the return I didn't care about I'd just leave it off. Is there a way to do something similar with an out, or...
Starting with C# 7.0, it is possible to avoid predeclaring out parameters as well as ignoring them. ``` public void PrintCoordinates(Point p) { p.GetCoordinates(out int x, out int y); WriteLine($"({x}, {y})"); } public void PrintXCoordinate(Point p) { p.GetCoordinates(out int x, out _); // I only care abo...
462,171
<p>I'm having an issue with Delphi 2007 when trying to consume a web service I've set up in Java using JAX-WS. The web service can be consumed fine from another Java program and from a C# / ASP.NET 2.0 website. However, when I try to access the same service using the WSDL Importer in Delphi 2007 (17-DEc-2007 patch), th...
[ { "answer_id": 462515, "author": "Cesar Romero", "author_id": 36875, "author_profile": "https://Stackoverflow.com/users/36875", "pm_score": 1, "selected": false, "text": "<p>Not the solution for your problem, but I had been in trouble recently with the same environment. \nI had to change...
2009/01/20
[ "https://Stackoverflow.com/questions/462171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22687/" ]
I'm having an issue with Delphi 2007 when trying to consume a web service I've set up in Java using JAX-WS. The web service can be consumed fine from another Java program and from a C# / ASP.NET 2.0 website. However, when I try to access the same service using the WSDL Importer in Delphi 2007 (17-DEc-2007 patch), the J...
HA HA IT LIVES!!! Basically I had to take out the recommended ``` InvRegistry.RegisterInvokeOptions(TypeInfo(ActivityService), ioDocument); ``` and force it to use Sec. 5 encoding. Namespaces are generated as required and parameters are passed to the Java web service. Right, need beer, lots of beer :)
462,180
<p>I could be totally wrong here, but as I understand it, C++ doesn't really have a native "pointer to member function" type. I know you can do tricks with Boost and mem_fun etc. But why did the designers of C++ decide not to have a 64-bit pointer containing a pointer to the function and a pointer to the object, for e...
[ { "answer_id": 462190, "author": "Zach Hirsch", "author_id": 50773, "author_profile": "https://Stackoverflow.com/users/50773", "pm_score": 2, "selected": false, "text": "<p><a href=\"http://www.parashift.com/c++-faq-lite/pointers-to-members.html\" rel=\"nofollow noreferrer\">It does.</a>...
2009/01/20
[ "https://Stackoverflow.com/questions/462180", "https://Stackoverflow.com", "https://Stackoverflow.com/users/55934/" ]
I could be totally wrong here, but as I understand it, C++ doesn't really have a native "pointer to member function" type. I know you can do tricks with Boost and mem\_fun etc. But why did the designers of C++ decide not to have a 64-bit pointer containing a pointer to the function and a pointer to the object, for exam...
@RocketMagnet - This is in response to your [other question](https://stackoverflow.com/questions/462491/again-why-doesnt-c-have-a-pointer-to-member-function-type), the one which was labeled a duplicate. I'm answering *that* question, not this one. In general, C++ pointer to member functions can't portably be cast acro...
462,198
<p>From what I have gathered, I want to force a class to use particular private fields (and methods) I need an abstract class because an interface only declares public/static/final fields and methods. Correct??</p> <p>I just started my first big java project and want to make sure I'm not going to hurt myself later :)<...
[ { "answer_id": 462218, "author": "Fabian Steeg", "author_id": 18154, "author_profile": "https://Stackoverflow.com/users/18154", "pm_score": 1, "selected": false, "text": "<p>This is correct. But it is not necessarily an either-or decision, you can combine the advantages of interfaces and...
2009/01/20
[ "https://Stackoverflow.com/questions/462198", "https://Stackoverflow.com", "https://Stackoverflow.com/users/55310/" ]
From what I have gathered, I want to force a class to use particular private fields (and methods) I need an abstract class because an interface only declares public/static/final fields and methods. Correct?? I just started my first big java project and want to make sure I'm not going to hurt myself later :)
It's fairly common to provide both, so that you end up with: ``` public interface Sendable { public void sendMe(); } ``` and ``` public abstract class AbstractSender implements Sendable { public abstract void send(); public void sendMe() { send(this.toString()); } } ``` That way, anyone w...
462,223
<p>I'm not sure if there is a way to do this in Velocity or not:</p> <p>I have a User POJO which a property named Status, which looks like an enum (but it is not, since I am stuck on Java 1.4), the definition looks something like this:</p> <pre><code>public class User { // default status to User private Sta...
[ { "answer_id": 462292, "author": "matt b", "author_id": 4249, "author_profile": "https://Stackoverflow.com/users/4249", "pm_score": 4, "selected": true, "text": "<p>I figured out a workaround that allows me to add each <code>User.Status</code> object to the Velocity context, which avoids...
2009/01/20
[ "https://Stackoverflow.com/questions/462223", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4249/" ]
I'm not sure if there is a way to do this in Velocity or not: I have a User POJO which a property named Status, which looks like an enum (but it is not, since I am stuck on Java 1.4), the definition looks something like this: ``` public class User { // default status to User private Status status = Status.U...
I figured out a workaround that allows me to add each `User.Status` object to the Velocity context, which avoids any sort of references to constants or magic numbers in the template. On the controller/Java side: ``` // put the statuses directly into the model Map statusMap = new HashMap(); statusMap.put("user", User....
462,270
<p>In .Net (C# or VB: don't care), given a file path string, FileInfo struct, or FileSystemInfo struct for a real existing file, how can I determine the icon(s) used by the shell (explorer) for that file?</p> <p>I'm not currently planning to use this for anything, but I became curious about how to do it when looking a...
[ { "answer_id": 462301, "author": "Stefan", "author_id": 19307, "author_profile": "https://Stackoverflow.com/users/19307", "pm_score": 7, "selected": true, "text": "<pre><code>Imports System.Drawing\nModule Module1\n\n Sub Main() \n Dim filePath As String = \"C:\\myfile.exe\...
2009/01/20
[ "https://Stackoverflow.com/questions/462270", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3043/" ]
In .Net (C# or VB: don't care), given a file path string, FileInfo struct, or FileSystemInfo struct for a real existing file, how can I determine the icon(s) used by the shell (explorer) for that file? I'm not currently planning to use this for anything, but I became curious about how to do it when looking at [this qu...
``` Imports System.Drawing Module Module1 Sub Main() Dim filePath As String = "C:\myfile.exe" Dim TheIcon As Icon = IconFromFilePath(filePath) If TheIcon IsNot Nothing Then ''#Save it to disk, or do whatever you want with it. Using stream As New System....
462,281
<p>The legacy database I've inherited contains the following tables:</p> <pre><code>Teams ( TeamId INT PRIMARY KEY, Name VARCHAR(30) ) Players ( PlayerId INT PRIMARY KEY, Team VARCHAR(30) ) </code></pre> <p>The foreign key in the players table refers to the team name, rather than teamId.</p> <p>I've attempted ...
[ { "answer_id": 462481, "author": "CalvinR", "author_id": 55990, "author_profile": "https://Stackoverflow.com/users/55990", "pm_score": 2, "selected": false, "text": "<p>Now I'm not 100% sure if this will work but have you tried a many-to-one mapping relationship? </p>\n\n<p>Maybe somethi...
2009/01/20
[ "https://Stackoverflow.com/questions/462281", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21940/" ]
The legacy database I've inherited contains the following tables: ``` Teams ( TeamId INT PRIMARY KEY, Name VARCHAR(30) ) Players ( PlayerId INT PRIMARY KEY, Team VARCHAR(30) ) ``` The foreign key in the players table refers to the team name, rather than teamId. I've attempted to map from Team to Players using...
Now I'm not 100% sure if this will work but have you tried a many-to-one mapping relationship? Maybe something like this: ``` <many-to-one name="Players" class="DataTransfer.Player, DataTransfer" column="Name" property-ref="Team" /> ``` I believe that should work, according to the NHibernate manual pr...
462,296
<p>I'm having a problem with an ATL Service that exports a COM object. It works running as a local service, but when running as a Windows Service, I can't connect. The service starts correctly and runs, but my client (code below) always fails with the error "Failed to start service".</p> <p>So we're looking at the sam...
[ { "answer_id": 462412, "author": "lsalamon", "author_id": 47733, "author_profile": "https://Stackoverflow.com/users/47733", "pm_score": 1, "selected": false, "text": "<p>Do you select option \"Add common header files for: ATL\" in app MyClient ?\nThis one work fine in my test.</p>\n\n<p>...
2009/01/20
[ "https://Stackoverflow.com/questions/462296", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57185/" ]
I'm having a problem with an ATL Service that exports a COM object. It works running as a local service, but when running as a Windows Service, I can't connect. The service starts correctly and runs, but my client (code below) always fails with the error "Failed to start service". So we're looking at the same thing, I...
Do you select option "Add common header files for: ATL" in app MyClient ? This one work fine in my test. Put service running at your user account (default is system account) for access at debugging IDE. Good lock.
462,297
<p>There's a good discussion of Generics and what they really do behind the scenes over at <a href="https://stackoverflow.com/questions/31693/differences-in-generics">this question</a>, so we all know that <code>Vector&lt;int[]&gt;</code> is a vector of integer arrays, and <code>HashTable&lt;String, Person&gt;</code> i...
[ { "answer_id": 462305, "author": "raupach", "author_id": 132162, "author_profile": "https://Stackoverflow.com/users/132162", "pm_score": 5, "selected": false, "text": "<p>From the Java Documentation:</p>\n\n<p>[...]\nMore surprisingly, class Class has been generified. Class literals now ...
2009/01/20
[ "https://Stackoverflow.com/questions/462297", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36093/" ]
There's a good discussion of Generics and what they really do behind the scenes over at [this question](https://stackoverflow.com/questions/31693/differences-in-generics), so we all know that `Vector<int[]>` is a vector of integer arrays, and `HashTable<String, Person>` is a table of whose keys are strings and values `...
Using the generified version of class Class allows you, among other things, to write things like ``` Class<? extends Collection> someCollectionClass = someMethod(); ``` and then you can be sure that the Class object you receive extends `Collection`, and an instance of this class will be (at least) a Collection.
462,312
<p>I am attempting to execute a Stored Procedure within another stored procedure. The catch is that the stored procedure name is dynamically built within the first procedure. Here is an example of what I am trying to do ...</p> <pre><code>CREATE PROCEDURE SPINSVALUE_12345 @guid uniqueidentifier AS DECLARE @ret...
[ { "answer_id": 462361, "author": "SQLMenace", "author_id": 740, "author_profile": "https://Stackoverflow.com/users/740", "pm_score": 3, "selected": true, "text": "<p>does the proc have a return value or an output value?\nhere is an example</p>\n\n<pre><code>create proc prBlatest\nas\nret...
2009/01/20
[ "https://Stackoverflow.com/questions/462312", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am attempting to execute a Stored Procedure within another stored procedure. The catch is that the stored procedure name is dynamically built within the first procedure. Here is an example of what I am trying to do ... ``` CREATE PROCEDURE SPINSVALUE_12345 @guid uniqueidentifier AS DECLARE @returnValue bit ...
does the proc have a return value or an output value? here is an example ``` create proc prBlatest as return 5 go DECLARE @chvTableName VARCHAR(100), @intTableCount INT, @chvSQL NVARCHAR(100) SELECT @chvTableName = 'prBlatest' SELECT @chvSQL = N'exec @intTableCount = ' + @chvTableName EXEC sp_executesql @chvSQL, N'...
462,313
<p>I have an ASP.NET website (in C#) that takes in user data and then attempts to create a windows scheduled task. Of course, this works great on the DEV machine, but fails to run on the server. I'm trying to figure out what permission(s) are required on the ASPNET user (or anonymous web user) to create tasks.</p> <...
[ { "answer_id": 462331, "author": "Frederik Gheysels", "author_id": 55774, "author_profile": "https://Stackoverflow.com/users/55774", "pm_score": 0, "selected": false, "text": "<p>Are you writing something to the eventlog ?\nIt is possible that your component (which is hosted in IIS i pre...
2009/01/20
[ "https://Stackoverflow.com/questions/462313", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30440/" ]
I have an ASP.NET website (in C#) that takes in user data and then attempts to create a windows scheduled task. Of course, this works great on the DEV machine, but fails to run on the server. I'm trying to figure out what permission(s) are required on the ASPNET user (or anonymous web user) to create tasks. The error ...
I have been able to solve my particular problem, though not completely. I have still not identified the exact rights needed to create and run scheduled tasks, but the following seems to work: 1. Add the `<identity impersonate="true" />` to the Web.config 2. Add the IUSR user (which is the user the app will run as usin...
462,345
<p>I declare a variable for a 64 bit counter as :</p> <pre><code>long long call_count; </code></pre> <p>What is the format specifier that I should use in print statements?</p> <p>I tried, <code>%l</code>, <code>%ld</code>, <code>%ll</code>. None seems to be correct.</p> <p>I use Diab C compiler for compiling my app...
[ { "answer_id": 462358, "author": "Christoph", "author_id": 48015, "author_profile": "https://Stackoverflow.com/users/48015", "pm_score": 4, "selected": false, "text": "<p>It's <code>\"%lli\"</code> (or equivalently <code>\"%lld\"</code>)</p>\n" }, { "answer_id": 462359, "auth...
2009/01/20
[ "https://Stackoverflow.com/questions/462345", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44111/" ]
I declare a variable for a 64 bit counter as : ``` long long call_count; ``` What is the format specifier that I should use in print statements? I tried, `%l`, `%ld`, `%ll`. None seems to be correct. I use Diab C compiler for compiling my application code to run on pSOS operating system.
According to C99, it should be "%lld" (see, for example,[here](http://www.nullstone.com/download/releasenotes-ns-c.htm)). If Diab C isn't C99, then you'd have to look at the compiler docs, which I can't seem to find online with a quick Googling.
462,348
<p>I've got a JSP page with a piece of Javascript validation code which limits to a certain amount of characters on submit. I'm using a <code>&lt;textarea&gt;</code> so I can't simply use a length attribute like in a <code>&lt;input type="text"&gt;</code>.</p> <p>I use <code>document.getElementById("text").value.lengt...
[ { "answer_id": 462370, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 4, "selected": false, "text": "<p>Do you particularly care which line-endings are used? Why not just make the Java convert \"\\r\\n\" to \"\\n\"? (Note...
2009/01/20
[ "https://Stackoverflow.com/questions/462348", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54380/" ]
I've got a JSP page with a piece of Javascript validation code which limits to a certain amount of characters on submit. I'm using a `<textarea>` so I can't simply use a length attribute like in a `<input type="text">`. I use `document.getElementById("text").value.length` to get the string length. I'm running Firefox ...
This isn't really a JavaScript (or Java) problem - both layers report an accurate length for the string they are dealing with. The problem in your case is that the string gets transformed during the HTTP transmission. If you absolutely must ensure that the string doesn't exceed a certain length, you can mimic this tra...
462,381
<p>How could I restart or shutdown Windows using the .NET framework?</p>
[ { "answer_id": 462400, "author": "abatishchev", "author_id": 41956, "author_profile": "https://Stackoverflow.com/users/41956", "pm_score": 3, "selected": false, "text": "<p>The best way I saw:</p>\n\n<pre><code>System.Diagnostics.Process.Start(\"cmd.exe /c shutdown\", \"-rf\");\n</code><...
2009/01/20
[ "https://Stackoverflow.com/questions/462381", "https://Stackoverflow.com", "https://Stackoverflow.com/users/55623/" ]
How could I restart or shutdown Windows using the .NET framework?
The following code will execute the shutdown command from the shell: ``` // using System.Diagnostics; class Shutdown { /// <summary> /// Windows restart /// </summary> public static void Restart() { StartShutDown("-f -r -t 5"); } /// <summary> /// Log off. /// </summary> ...
462,390
<p>I have a Window with my user control and I would like to make usercontrol width equals window width. How to do that?</p> <p>The user control is a horizontal menu and contains a grid with three columns:</p> <pre><code>&lt;ColumnDefinition Name="LeftSideMenu" Width="433"/&gt; &lt;ColumnDefinition Name="Middle" Width...
[ { "answer_id": 462472, "author": "Andy", "author_id": 3857, "author_profile": "https://Stackoverflow.com/users/3857", "pm_score": 1, "selected": false, "text": "<p>What container are you adding the UserControl to? Generally when you add controls to a Grid, they will stretch to fill the a...
2009/01/20
[ "https://Stackoverflow.com/questions/462390", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21668/" ]
I have a Window with my user control and I would like to make usercontrol width equals window width. How to do that? The user control is a horizontal menu and contains a grid with three columns: ``` <ColumnDefinition Name="LeftSideMenu" Width="433"/> <ColumnDefinition Name="Middle" Width="*"/> <ColumnDefinition Name=...
You need to make sure your usercontrol hasn't set it's width in the usercontrol's xaml file. Just delete the Width="..." from it and you're good to go! **EDIT:** This is the code I tested it with: *SOUserAnswerTest.xaml:* ``` <UserControl x:Class="WpfApplication1.SOAnswerTest" xmlns="http://schemas.microsoft.com...
462,401
<p>If you want to move your development process from Test-Driven Development to <a href="http://en.wikipedia.org/wiki/Behavior_Driven_Development" rel="nofollow noreferrer">Behavior-Driven Development</a> what path would you take or recommend?</p> <p>What are the possible challenges that you might face? Moving the de...
[ { "answer_id": 462524, "author": "Allain Lalonde", "author_id": 2443, "author_profile": "https://Stackoverflow.com/users/2443", "pm_score": 2, "selected": false, "text": "<p>As far as I understand... BDD is a new way of looking at TDD. It's more a mental shift than a new technology.</p>...
2009/01/20
[ "https://Stackoverflow.com/questions/462401", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34644/" ]
If you want to move your development process from Test-Driven Development to [Behavior-Driven Development](http://en.wikipedia.org/wiki/Behavior_Driven_Development) what path would you take or recommend? What are the possible challenges that you might face? Moving the development process will be a huge task itself as ...
When I started to look at BDD I investigated all the frameworks out there (for .net) and ended up using none of them. Main reason is I feel like the community hasn't settled on a syntax and best practises yet so instead I continued to use NUnit with a base class based on a [blog post](http://flux88.com/blog/the-transit...
462,427
<p>is_numeric, intval, ctype__digit.. can you rely on them?</p> <p>or do i have to use regex?</p> <pre> function isNum($str) {<br> return (preg_match("/^[0-9]+$/", $str)); <br>} </pre> <p>what do you guys think? am i stupid?</p>
[ { "answer_id": 462450, "author": "Josh", "author_id": 11702, "author_profile": "https://Stackoverflow.com/users/11702", "pm_score": 0, "selected": false, "text": "<p>I am not an expert on PHP, but have you considered writing a data driven unit test to gain a concrete understanding of tho...
2009/01/20
[ "https://Stackoverflow.com/questions/462427", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
is\_numeric, intval, ctype\_\_digit.. can you rely on them? or do i have to use regex? ``` function isNum($str) { return (preg_match("/^[0-9]+$/", $str)); } ``` what do you guys think? am i stupid?
is\_numeric, intval, and ctype\_digit all do very different things. [is\_numeric](http://ca3.php.net/manual/en/function.is-numeric.php) will tell you if the contents of the variable are numeric (i.e. true if it is a floating point or integer value). [intval](http://ca.php.net/manual/en/function.intval.php) attempts t...
462,439
<p>What is the best way to sniff network packets using Python?</p> <p>I've heard from several places that the best module for this is a module called Scapy, unfortunately, it makes python.exe crash on my system. I would assume that it's just a problem with how I installed it, except that many other people have told me...
[ { "answer_id": 462447, "author": "nosklo", "author_id": 17160, "author_profile": "https://Stackoverflow.com/users/17160", "pm_score": 3, "selected": false, "text": "<p>Use <a href=\"http://sourceforge.net/projects/pylibpcap/\" rel=\"noreferrer\">python-libpcap</a>.</p>\n\n<pre><code>impo...
2009/01/20
[ "https://Stackoverflow.com/questions/462439", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
What is the best way to sniff network packets using Python? I've heard from several places that the best module for this is a module called Scapy, unfortunately, it makes python.exe crash on my system. I would assume that it's just a problem with how I installed it, except that many other people have told me that it d...
Using [pypcap](http://code.google.com/p/pypcap/): ``` import dpkt, pcap pc = pcap.pcap() # construct pcap object pc.setfilter('icmp') # filter out unwanted packets for timestamp, packet in pc: print dpkt.ethernet.Ethernet(packet) ``` output sample: ``` Ethernet(src='\x00\x03G\xb2M\xe4', dst='\x00\x03G\x06h\...
462,440
<p>I plan to use XML/XSLT in my iPhone application. </p> <p>What version of XSLT is currently supported on the iPhone? Can I use XSLT 2.0 or just 1.0 ?</p>
[ { "answer_id": 462542, "author": "Gordon Wilson", "author_id": 23071, "author_profile": "https://Stackoverflow.com/users/23071", "pm_score": 3, "selected": false, "text": "<p>I'm afraid the xslt situation is rather grim. The <code>NSXMLDocument</code> class would be the way to do this b...
2009/01/20
[ "https://Stackoverflow.com/questions/462440", "https://Stackoverflow.com", "https://Stackoverflow.com/users/437523/" ]
I plan to use XML/XSLT in my iPhone application. What version of XSLT is currently supported on the iPhone? Can I use XSLT 2.0 or just 1.0 ?
Using `libxslt` on the iPhone OS is actually quite easy: 1. [Download the source-code of libxslt](http://xmlsoft.org/XSLT/downloads.html) and extract it. 2. Add the "libxslt" dir to **Header search paths** in your build settings. Also, add the path to the libxml-headers there (usually `/Developer/Platforms/iPhoneOS.pl...
462,471
<p><a href="https://stackoverflow.com/users/18747/tony-andrews">Tony Andrews</a> in another <a href="https://stackoverflow.com/questions/461985/better-way-to-structure-a-pl-sql-if-then-statement">question</a> gave an example of:</p> <pre><code>IF p_c_courtesies_cd || p_c_language_cd || v_c_name || v_c_firs...
[ { "answer_id": 462511, "author": "nezroy", "author_id": 49968, "author_profile": "https://Stackoverflow.com/users/49968", "pm_score": 1, "selected": false, "text": "<p>Well COALESCE is explicitly defined by the SQL-92 standard to return the first non-NULL value in the list; so by definit...
2009/01/20
[ "https://Stackoverflow.com/questions/462471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8670/" ]
[Tony Andrews](https://stackoverflow.com/users/18747/tony-andrews) in another [question](https://stackoverflow.com/questions/461985/better-way-to-structure-a-pl-sql-if-then-statement) gave an example of: ``` IF p_c_courtesies_cd || p_c_language_cd || v_c_name || v_c_firstname || v_c_function || p_c...
No, Oracle's treatment of nulls is idiosyncratic, different from everyone else's, and inconsistent with the ANSI standards. In Oracle's defence however, it probably settled on and was committed to this treatment long before there was an ANSI standard to be consistent with! It all starts from the fact that Oracle store...
462,500
<p>I read in the manual of Numpy that there is function <code>det(M)</code> that can calculate the determinant. However, I can't find the <code>det()</code> method in Numpy.</p> <p>By the way, I use Python 2.5. There should be no compatibility problems with Numpy.</p>
[ { "answer_id": 462514, "author": "xyz", "author_id": 43158, "author_profile": "https://Stackoverflow.com/users/43158", "pm_score": 6, "selected": false, "text": "<p>You can use <a href=\"http://docs.scipy.org/doc/numpy/reference/generated/numpy.linalg.det.html\" rel=\"noreferrer\"><code>...
2009/01/20
[ "https://Stackoverflow.com/questions/462500", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I read in the manual of Numpy that there is function `det(M)` that can calculate the determinant. However, I can't find the `det()` method in Numpy. By the way, I use Python 2.5. There should be no compatibility problems with Numpy.
You can use [`numpy.linalg.det`](http://docs.scipy.org/doc/numpy/reference/generated/numpy.linalg.det.html) to compute the determinant of an array: ``` In [1]: import numpy In [2]: M = [[1, 2], [3, 4]] In [3]: print numpy.linalg.det(M) Out[3]: -2.0000000000000004 ```
462,532
<p>I would like my website to create search-engine-optimized links for dynamic content (instead of locating data via the querystring). So: <pre>mysite/SomeModifiableNname.aspx</pre> instead of </p> <p><pre>mysite/DynamicContent.aspx?entryID=2345</pre>.</p> <p>Aside from a smart 404 handler that redirects requests, o...
[ { "answer_id": 462535, "author": "Larsenal", "author_id": 337, "author_profile": "https://Stackoverflow.com/users/337", "pm_score": 2, "selected": false, "text": "<p>You can use a <strong>HttpHandler</strong>, as seen <a href=\"http://codebetter.com/blogs/jeffrey.palermo/archive/2005/08/...
2009/01/20
[ "https://Stackoverflow.com/questions/462532", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39972/" ]
I would like my website to create search-engine-optimized links for dynamic content (instead of locating data via the querystring). So: ``` mysite/SomeModifiableNname.aspx ``` instead of ``` mysite/DynamicContent.aspx?entryID=2345 ``` . Aside from a smart 404 handler that redirects requests, or a custom mime-type...
Thanks for everyone's thoughts. With the information provided, I came across what I think is the solution I need: In the Global.asax (or via an HttpModule), listen to the BeginRequest event and apply Context.Rewrite path there: ``` void Application_BeginRequest(object sender, EventArgs e) { string fullOrigionalpa...
462,534
<p>I am querying data from views that are subject to change. I need to know if the column exists before I do a <code>crs.get******()</code>.</p> <p>I have found that I can query the <em>metadata</em> like this to see if a column exist before I request the data from it:</p> <pre><code>ResultSetMetaData meta = crs.getMet...
[ { "answer_id": 462556, "author": "OscarRyz", "author_id": 20654, "author_profile": "https://Stackoverflow.com/users/20654", "pm_score": 1, "selected": false, "text": "<p>Which Database?</p>\n\n<p>I think in Oracle there are tables where the columns are listed.</p>\n\n<p>I don't remember ...
2009/01/20
[ "https://Stackoverflow.com/questions/462534", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13491/" ]
I am querying data from views that are subject to change. I need to know if the column exists before I do a `crs.get******()`. I have found that I can query the *metadata* like this to see if a column exist before I request the data from it: ``` ResultSetMetaData meta = crs.getMetaData(); int numCol = meta.getColumnC...
There's not a simpler way with the general JDBC API (at least not that I know of, or can find...I've got exactly the same code in my home-grown toolset.) Your code isn't complete: ``` ResultSetMetaData meta = crs.getMetaData(); int numCol = meta.getColumnCount(); for (int i = 1; i < numCol + 1; i++) { if (meta.g...
462,537
<p>Title pretty much sums it up.</p> <p>The external style sheet has the following code:</p> <pre class="lang-css prettyprint-override"><code>td.EvenRow a { display: none !important; } </code></pre> <p>I have tried using:</p> <pre><code>element.style.display = "inline"; </code></pre> <p>and</p> <pre><code>eleme...
[ { "answer_id": 462603, "author": "James", "author_id": 21677, "author_profile": "https://Stackoverflow.com/users/21677", "pm_score": 7, "selected": true, "text": "<p>I believe the only way to do this it to add the style as a new CSS declaration with the '!important' suffix. The easiest w...
2009/01/20
[ "https://Stackoverflow.com/questions/462537", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44816/" ]
Title pretty much sums it up. The external style sheet has the following code: ```css td.EvenRow a { display: none !important; } ``` I have tried using: ``` element.style.display = "inline"; ``` and ``` element.style.display = "inline !important"; ``` but neither works. Is it possible to override an !import...
I believe the only way to do this it to add the style as a new CSS declaration with the '!important' suffix. The easiest way to do this is to append a new <style> element to the head of document: ``` function addNewStyle(newStyle) { var styleElement = document.getElementById('styles_js'); if (!styleElement) { ...
462,563
<p>(This is no homework and no work issue. It's just my personal interest/occupation and completly fictional. But I am interested in a good algorithm or data structure.)</p> <p>Let's assume, that I would run a dating site. And my <strong><em>special feature</em></strong> would be that the singles were <strong>matched ...
[ { "answer_id": 462598, "author": "Quassnoi", "author_id": 55159, "author_profile": "https://Stackoverflow.com/users/55159", "pm_score": 0, "selected": false, "text": "<pre><code>CREATE TABLE data (user INTEGER, movie INTEGER, rate INTEGER);\n\nSELECT other.user, AVG(ABS(d1.rate - d2.rat...
2009/01/20
[ "https://Stackoverflow.com/questions/462563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32726/" ]
(This is no homework and no work issue. It's just my personal interest/occupation and completly fictional. But I am interested in a good algorithm or data structure.) Let's assume, that I would run a dating site. And my ***special feature*** would be that the singles were **matched by movie taste**. (Why not?) In tha...
Sounds a lot like the [Netflix Prize](http://www.netflixprize.com/index) challenge, more specifically the first half of the most popular approach. The possible implementations of what you are trying to do are numerous and varied. None of them are exceptionally efficient, and the L1 metric is not a particularly good opt...
462,564
<p>I know that I can add a <strong>HintPath</strong> to an external DLLs to help Visual Studio/TFS find the dll when it builds.</p> <p>What I was wondering is... is it possible to add multiple <strong>HintPath</strong>?</p> <p>For example... developers have their DLLs for one place and we do a GetLatest of those DLLs...
[ { "answer_id": 462650, "author": "Maxime Rouiller", "author_id": 24975, "author_profile": "https://Stackoverflow.com/users/24975", "pm_score": 5, "selected": true, "text": "<p>This answer is no longer valid. As <a href=\"https://stackoverflow.com/questions/462564/hintpath-on-a-added-refe...
2009/01/20
[ "https://Stackoverflow.com/questions/462564", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24975/" ]
I know that I can add a **HintPath** to an external DLLs to help Visual Studio/TFS find the dll when it builds. What I was wondering is... is it possible to add multiple **HintPath**? For example... developers have their DLLs for one place and we do a GetLatest of those DLLs at a different place on the server hence t...
This answer is no longer valid. As [Sardaukar's comment](https://stackoverflow.com/questions/462564/hintpath-on-a-added-reference-in-visual-studio/462650#comment16281588_462650) says, **Visual Studio always blindly uses the last HintPath**. [Alex's answer](https://stackoverflow.com/a/13417794/105971) supports this. --...
462,565
<p>I have two tables 1) Product 2) Categories</p> <p>Product table has a field called "CategoryID" and the Category table has a field called "CategoryName", ID, DateCreated, and a few others.</p> <p>I want to use LINQ to SQL to query all the Product rows as well as JUST the Category.CategoryName. This query will be u...
[ { "answer_id": 462876, "author": "Zhaph - Ben Duguid", "author_id": 33051, "author_profile": "https://Stackoverflow.com/users/33051", "pm_score": 1, "selected": false, "text": "<p>I think you're pretty much on the right track, but I wouldn't really worry about the intermediery class:</p>...
2009/01/20
[ "https://Stackoverflow.com/questions/462565", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56302/" ]
I have two tables 1) Product 2) Categories Product table has a field called "CategoryID" and the Category table has a field called "CategoryName", ID, DateCreated, and a few others. I want to use LINQ to SQL to query all the Product rows as well as JUST the Category.CategoryName. This query will be used in a datasour...
I think you're pretty much on the right track, but I wouldn't really worry about the intermediery class: ``` var products = from p in db.Products join c in db.Categories on p.CategoryID = c.ID select new { p.ProdName, ProdId = p.ID, p.CategoryID, CategoryName = c.CategoryName } ``...
462,569
<p>I'm implementing a table with a fixed header using this kind of setup:</p> <pre><code>&lt;div style="padding-right:18px"&gt;&lt;!-- to account for the scrollbar on the other div --&gt; &lt;table id="head"&gt; &lt;tr&gt; &lt;th&gt;Col 1&lt;/th&gt; &lt;th&gt;Col 2&lt;/th&gt; &lt;/tr&gt; &lt;...
[ { "answer_id": 462601, "author": "roborourke", "author_id": 42147, "author_profile": "https://Stackoverflow.com/users/42147", "pm_score": 1, "selected": false, "text": "<p>Have you tried setting the widths in CSS or do you need to implement column resizing and all that jazz? I'm not sure...
2009/01/20
[ "https://Stackoverflow.com/questions/462569", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24197/" ]
I'm implementing a table with a fixed header using this kind of setup: ``` <div style="padding-right:18px"><!-- to account for the scrollbar on the other div --> <table id="head"> <tr> <th>Col 1</th> <th>Col 2</th> </tr> </table> </div> <div style="height:400px; overflow-y:scroll"> <table i...
offsetWidth gets the width of the element, padding and borders. setting the width using the element style, you are only setting the width of the element so each column will be off by the sum of all the horizontal borders and paddings of preceding columns try this ``` dojo.addOnLoad(function(){ var $bodyRow = doj...
462,580
<p>Looking for an implementation for C++ of a function like .NET's String.Format. Obviously there is printf and it's varieties, but I'm looking for something that is positional as in:</p> <blockquote> <p>String.Format("Hi there {0}. You are {1} years old. How does it feel to be {1}?", name, age);</p> </blockq...
[ { "answer_id": 462584, "author": "Eddie Parker", "author_id": 56349, "author_profile": "https://Stackoverflow.com/users/56349", "pm_score": 5, "selected": false, "text": "<p>Look at the <a href=\"http://www.boost.org/doc/libs/1_37_0/libs/format/index.html\" rel=\"nofollow noreferrer\">bo...
2009/01/20
[ "https://Stackoverflow.com/questions/462580", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7442/" ]
Looking for an implementation for C++ of a function like .NET's String.Format. Obviously there is printf and it's varieties, but I'm looking for something that is positional as in: > > String.Format("Hi there {0}. You are > {1} years old. How does it feel to be > {1}?", name, age); > > > This is needed because ...
Lots of good recommendations above that would work in most situations. In my case, I ultimately wanted to load strings from a resource, AND keep the string resources as close to .NET String.Format as I could, so I rolled my own. After looking at some of the implementations above for ideas, the resulting implementation ...
462,585
<p>I'm trying to display an address right aligned in the footer of my page like this:</p> <pre> 1234 south east Main St. Nowhere, ID 45445 (555) 555-5555 </pre> <p>in my markup I have this:</p> <pre> &lt;address&gt; 1234 south east Main St. Nowhere, Id 45445 (555) 555-5555 &lt;/address&gt; </pre...
[ { "answer_id": 462602, "author": "Sulaiman", "author_id": 55750, "author_profile": "https://Stackoverflow.com/users/55750", "pm_score": 5, "selected": true, "text": "<p>hey try to use this use this </p>\n\n<pre><code>.address\n{\nwhite-space:pre;\ntext-align:right;\n}\n</code></pre>\n" ...
2009/01/20
[ "https://Stackoverflow.com/questions/462585", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17744/" ]
I'm trying to display an address right aligned in the footer of my page like this: ``` 1234 south east Main St. Nowhere, ID 45445 (555) 555-5555 ``` in my markup I have this: ``` <address> 1234 south east Main St. Nowhere, Id 45445 (555) 555-5555 </address> ``` How can I get this to layout ...
hey try to use this use this ``` .address { white-space:pre; text-align:right; } ```
462,590
<p>We have a flash file that in every other browser displays at its correct size (which is something like 1600px) however, in safari it appears tiny. We have also noticed that sometimes when the flash file is not cached it appears at normal size, then after a soft refresh the flash goes tiny again.</p> <p>We are usin...
[ { "answer_id": 462602, "author": "Sulaiman", "author_id": 55750, "author_profile": "https://Stackoverflow.com/users/55750", "pm_score": 5, "selected": true, "text": "<p>hey try to use this use this </p>\n\n<pre><code>.address\n{\nwhite-space:pre;\ntext-align:right;\n}\n</code></pre>\n" ...
2009/01/20
[ "https://Stackoverflow.com/questions/462590", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
We have a flash file that in every other browser displays at its correct size (which is something like 1600px) however, in safari it appears tiny. We have also noticed that sometimes when the flash file is not cached it appears at normal size, then after a soft refresh the flash goes tiny again. We are using mootools ...
hey try to use this use this ``` .address { white-space:pre; text-align:right; } ```
462,609
<p>I have to check a number if it satisfies the following criteria:</p> <ul> <li>in binary, all one-bits must be successive.</li> <li>the number must have at least one bit set. </li> <li>the successive one-bits may start at the MSB or end at the LSB, so it's perfectly valid if the number is made up of a single one-bit...
[ { "answer_id": 462633, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 2, "selected": false, "text": "<pre><code>bool isOK(uint val) {\n while (val != 0 &amp;&amp; (val &amp; 1u) == 0) val &gt;&gt;= 1;\n if (val == 0) return...
2009/01/20
[ "https://Stackoverflow.com/questions/462609", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15955/" ]
I have to check a number if it satisfies the following criteria: * in binary, all one-bits must be successive. * the number must have at least one bit set. * the successive one-bits may start at the MSB or end at the LSB, so it's perfectly valid if the number is made up of a single one-bit stream followed by a zero-bi...
This should do what you want. ``` if(i == 0) return false; while(i % 2 == 0) { i = i / 2; } return (i & (i + 1)) == 0; ```