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
514,891
<p>I want to create a bookmarklet that sets the page to be editable, that is, to run this code:</p> <pre><code>javascript:document.body.contentEditable=true; </code></pre> <p>When I made a bookmark of that, I could see that the page becomes editable very briefly and then the whole thing is replaced with the word "tru...
[ { "answer_id": 514895, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 0, "selected": false, "text": "<p>After a bit of random trial and error, I found that this worked:</p>\n\n<pre><code>javascript:(function() { document.body.c...
2009/02/05
[ "https://Stackoverflow.com/questions/514891", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
I want to create a bookmarklet that sets the page to be editable, that is, to run this code: ``` javascript:document.body.contentEditable=true; ``` When I made a bookmark of that, I could see that the page becomes editable very briefly and then the whole thing is replaced with the word "true".
Bookmarklets have to evaluate to void for the browser stay on the same page. Just end it with a void(0): ``` javascript:document.body.contentEditable=true;void(0); ```
514,892
<p>Is it possible to pass parameters with an <code>HTTP</code> get request? If so, how should I then do it? I have found an <code>HTTP</code> post requst (<a href="http://msdn.microsoft.com/en-us/library/debx8sh9.aspx" rel="noreferrer">link</a>). In that example the string <code>postData</code> is sent to a webserver. ...
[ { "answer_id": 514901, "author": "EndangeredMassa", "author_id": 106, "author_profile": "https://Stackoverflow.com/users/106", "pm_score": 7, "selected": true, "text": "<p>In a GET request, you pass parameters as part of the query string.</p>\n\n<pre><code>string url = \"http://somesite....
2009/02/05
[ "https://Stackoverflow.com/questions/514892", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36476/" ]
Is it possible to pass parameters with an `HTTP` get request? If so, how should I then do it? I have found an `HTTP` post requst ([link](http://msdn.microsoft.com/en-us/library/debx8sh9.aspx)). In that example the string `postData` is sent to a webserver. I would like to do the same using *get* instead. Google found th...
In a GET request, you pass parameters as part of the query string. ``` string url = "http://somesite.com?var=12345"; ```
514,908
<p>It's been a while since I programmed in C++, and after coming from python, I feel soooo in a straight jacket, ok I'm not gonna rant.</p> <p>I have a couple of functions that act as "pipes", accepting a list as input, returning another list as output (based on the input), </p> <p>this is in concept, but in practice...
[ { "answer_id": 514917, "author": "Robert Gould", "author_id": 15124, "author_profile": "https://Stackoverflow.com/users/15124", "pm_score": 1, "selected": false, "text": "<p>If you want to be really hardcore, you could use <a href=\"http://www.boost.org/doc/libs/1_37_0/libs/tuple/doc/tup...
2009/02/05
[ "https://Stackoverflow.com/questions/514908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35364/" ]
It's been a while since I programmed in C++, and after coming from python, I feel soooo in a straight jacket, ok I'm not gonna rant. I have a couple of functions that act as "pipes", accepting a list as input, returning another list as output (based on the input), this is in concept, but in practice, I'm using `std:...
The only thing I can see is that your forcing a copy of the list you return. It would be more efficient to do something like: ``` void DoSomething(const std::vector<SomeType>& in, std::vector<SomeType>& out) { ... // no need to return anything, just modify out } ``` Because you pass in the list you want to...
514,916
<p>I have following code and i got the "Unspecified error" when executed.</p> <pre><code>OleDbConnection ExcelConnection = new oleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + pathName + "; Extended Properties=Text;"); ExcelConnection.Open(); </code></pre>
[ { "answer_id": 514933, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 2, "selected": false, "text": "<p>For loading csv, consider <a href=\"http://www.codeproject.com/KB/database/CsvReader.aspx\" rel=\"nofollow norefer...
2009/02/05
[ "https://Stackoverflow.com/questions/514916", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62788/" ]
I have following code and i got the "Unspecified error" when executed. ``` OleDbConnection ExcelConnection = new oleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + pathName + "; Extended Properties=Text;"); ExcelConnection.Open(); ```
For loading csv, consider [CsvReader](http://www.codeproject.com/KB/database/CsvReader.aspx) - fully managed, very fast, and robust. I've used in in numerous projects. More importantly, no messing with OLEDB.
514,926
<p>I should display the bookmarks as hyperlink.so on clicking the bookmark will take me to corresponding web page.Can any one tell me how should i achieve my goal?Thanks.</p> <pre><code>&lt;html&gt; &lt;f:view&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt; ...
[ { "answer_id": 514956, "author": "David Grant", "author_id": 40581, "author_profile": "https://Stackoverflow.com/users/40581", "pm_score": 2, "selected": false, "text": "<p>Take a look at <code>h:outputLink</code>:</p>\n\n<pre><code>&lt;h:outputLink value=\"#{item.sno}\" rendered=\"#{not...
2009/02/05
[ "https://Stackoverflow.com/questions/514926", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40933/" ]
I should display the bookmarks as hyperlink.so on clicking the bookmark will take me to corresponding web page.Can any one tell me how should i achieve my goal?Thanks. ``` <html> <f:view> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> ...
``` <h:outputLink value="#{item.bookmark}" rendered="#{not item.editBookmark}" <h:outputText value = "#{item.bookmark}" ></h:outputText> </h:outputLink> ```
514,943
<p>How do I sort a MySQL table by two columns?</p> <p>What I want are articles sorted by highest ratings first, then most recent date. As an example, this would be a sample output (left # is the rating, then the article title, then the article date)</p> <pre> +================+=============================+===========...
[ { "answer_id": 514947, "author": "mthurlin", "author_id": 39991, "author_profile": "https://Stackoverflow.com/users/39991", "pm_score": 10, "selected": true, "text": "<p>Default sorting is ascending, you need to add the keyword DESC to both your orders:</p>\n\n<pre><code>ORDER BY article...
2009/02/05
[ "https://Stackoverflow.com/questions/514943", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How do I sort a MySQL table by two columns? What I want are articles sorted by highest ratings first, then most recent date. As an example, this would be a sample output (left # is the rating, then the article title, then the article date) ``` +================+=============================+==============+ | article...
Default sorting is ascending, you need to add the keyword DESC to both your orders: ``` ORDER BY article_rating DESC, article_time DESC ```
514,967
<p>I want <a href="http://en.wikipedia.org/wiki/Vim_%28text_editor%29" rel="nofollow noreferrer">Vim</a>'s completion menu to work more like the one in Visual Studio. I want to be able to write the start of a variable (or something which completion is available), hit the omni-completion keys and get the completion menu...
[ { "answer_id": 515358, "author": "f3lix", "author_id": 60617, "author_profile": "https://Stackoverflow.com/users/60617", "pm_score": 4, "selected": true, "text": "<p>The referenced wiki page contained broken mappings. A user (Spiiph) changed the Vim code to something that looked better t...
2009/02/05
[ "https://Stackoverflow.com/questions/514967", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42793/" ]
I want [Vim](http://en.wikipedia.org/wiki/Vim_%28text_editor%29)'s completion menu to work more like the one in Visual Studio. I want to be able to write the start of a variable (or something which completion is available), hit the omni-completion keys and get the completion menu. Now I want the completion menu to high...
The referenced wiki page contained broken mappings. A user (Spiiph) changed the Vim code to something that looked better to him, but was not right. I reversed the changes he made and now the *inoremap* statements should work. To avoid confusion these are IMHO the right commands: ``` inoremap <expr> <c-n> pumvisible(...
514,968
<p>I have an installer-like application that I have to run as elevated on Vista. But from there I have to start a new process as non-elevated. Any hints how to do this with Delphi2007?</p>
[ { "answer_id": 515003, "author": "dmajkic", "author_id": 39233, "author_profile": "https://Stackoverflow.com/users/39233", "pm_score": 2, "selected": false, "text": "<p>This blog post is detailed and useful </p>\n\n<p><a href=\"http://developersoven.blogspot.com/2007/02/leveraging-vistas...
2009/02/05
[ "https://Stackoverflow.com/questions/514968", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62792/" ]
I have an installer-like application that I have to run as elevated on Vista. But from there I have to start a new process as non-elevated. Any hints how to do this with Delphi2007?
I found an [excellent example for C++](http://www.codeproject.com/Messages/3264682/Here-the-cleaned-and-bugfixed-code.aspx) and adapted it for Delphi: ```default unit MediumIL; interface uses Winapi.Windows; function CreateProcessMediumIL(lpApplicationName: PWChar; lpCommandLine: PWChar; lpProcessAttributes: PSec...
514,977
<p>I have following classes.</p> <pre><code>class A { public: void fun(); } class B: public A { } class C: public A { } A * ptr = new C; </code></pre> <p>Is it ok to do something like below? Will i have some problems if introduce some virtual functions in the baseclass?</p> <pre><code>((B *)ptr)-&gt;fun(); <...
[ { "answer_id": 514991, "author": "Steve Rowe", "author_id": 40744, "author_profile": "https://Stackoverflow.com/users/40744", "pm_score": 4, "selected": true, "text": "<p>You can't cast an A* pointing to Class C as a B* because Class C doesn't have any relation with Class B. You'll get ...
2009/02/05
[ "https://Stackoverflow.com/questions/514977", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39615/" ]
I have following classes. ``` class A { public: void fun(); } class B: public A { } class C: public A { } A * ptr = new C; ``` Is it ok to do something like below? Will i have some problems if introduce some virtual functions in the baseclass? ``` ((B *)ptr)->fun(); ``` This may look stupid, but i have a ...
You can't cast an A\* pointing to Class C as a B\* because Class C doesn't have any relation with Class B. You'll get undefined behavior which will probably be the wrong function called and stack corruption. If you intended for class C to derive from class B then you could. However, you wouldn't need to. If class C do...
514,980
<p>I have a simple table in MySql whose raison-d'être is to store logs. The table has an autoincremented sequence and all the other columns has zero referential integrity to other tables. There are no unique keys or indexes on any columns. The column with autoincrement is the primary key.</p> <p>Will concurrent INSERT...
[ { "answer_id": 514998, "author": "Learning", "author_id": 18275, "author_profile": "https://Stackoverflow.com/users/18275", "pm_score": 2, "selected": false, "text": "<p>Yes. For InnoDB , more information <a href=\"http://dev.mysql.com/doc/refman/5.1/en/innodb-auto-increment-handling.htm...
2009/02/05
[ "https://Stackoverflow.com/questions/514980", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24457/" ]
I have a simple table in MySql whose raison-d'être is to store logs. The table has an autoincremented sequence and all the other columns has zero referential integrity to other tables. There are no unique keys or indexes on any columns. The column with autoincrement is the primary key. Will concurrent INSERTs ever int...
From the MySQL manual for the [MyISAM storage engine](http://dev.mysql.com/doc/refman/5.1/en/myisam-storage-engine.html): ``` "MyISAM supports concurrent inserts..." ```
514,981
<p>I am learning templates. Which book is worth buying for doing template programming?</p> <p>I already have <a href="http://en.wikipedia.org/wiki/The_C%2B%2B_Programming_Language" rel="noreferrer">The C++ Programming Language</a> and <a href="http://en.wikipedia.org/wiki/Scott_Meyers#Publications" rel="noreferrer">Ef...
[ { "answer_id": 515001, "author": "Gorpik", "author_id": 25824, "author_profile": "https://Stackoverflow.com/users/25824", "pm_score": 3, "selected": false, "text": "<p>Maybe a bit mind-boggling if you are just learning, but after the books you mention, you may want to read Andrei Alexand...
2009/02/05
[ "https://Stackoverflow.com/questions/514981", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22076/" ]
I am learning templates. Which book is worth buying for doing template programming? I already have [The C++ Programming Language](http://en.wikipedia.org/wiki/The_C%2B%2B_Programming_Language) and [Effective C++](http://en.wikipedia.org/wiki/Scott_Meyers#Publications).
Those two books are pretty good in my opinion and they helped me a lot > > * [*C++ Templates: The Complete Guide* by David Vandevoorde and Nicolai M. > Josuttis](https://rads.stackoverflow.com/amzn/click/com/0201734842) > * [*Modern C++ Design* by Andrei Alexandrescu](https://rads.stackoverflow.com/amzn/click/com/02...
515,028
<p>I am working on a project where the Unity framework is used as the IoC container. My question relates to injecting an optional dependency (in this case a logger) into several classes using property- or setter injection. </p> <p>I do not want to clutter the constructors of all my classes with these optional dependen...
[ { "answer_id": 515048, "author": "Kim Major", "author_id": 32498, "author_profile": "https://Stackoverflow.com/users/32498", "pm_score": 2, "selected": false, "text": "<p>The following walkthrough shows one way of doing it through configuration. You can of course wire it through code as ...
2009/02/05
[ "https://Stackoverflow.com/questions/515028", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6308/" ]
I am working on a project where the Unity framework is used as the IoC container. My question relates to injecting an optional dependency (in this case a logger) into several classes using property- or setter injection. I do not want to clutter the constructors of all my classes with these optional dependencies, but ...
I don't like those attributes also You can do all using the **Configure** method of the unity container: First register the type ``` unityContainer.RegisterType<MyInterface,MyImpl>( new ContainerControlledLifetimeManager()); ``` If you have multiple constructors you'll have to do this so Unity...
515,039
<p>There's the (almost religious) discussion, if you should use LIKE or '=' to compare strings in SQL statements.</p> <ul> <li>Are there reasons to use LIKE?</li> <li>Are there reasons to use '='?</li> <li>Performance? Readability? </li> </ul>
[ { "answer_id": 515044, "author": "Techmaddy", "author_id": 50434, "author_profile": "https://Stackoverflow.com/users/50434", "pm_score": 3, "selected": false, "text": "<p>For pattern matching use LIKE. For exact match =.</p>\n" }, { "answer_id": 515045, "author": "Gishu", ...
2009/02/05
[ "https://Stackoverflow.com/questions/515039", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32043/" ]
There's the (almost religious) discussion, if you should use LIKE or '=' to compare strings in SQL statements. * Are there reasons to use LIKE? * Are there reasons to use '='? * Performance? Readability?
To see the performance difference, try this: ``` SELECT count(*) FROM master..sysobjects as A JOIN tempdb..sysobjects as B on A.name = B.name SELECT count(*) FROM master..sysobjects as A JOIN tempdb..sysobjects as B on A.name LIKE B.name ``` Comparing strings with '=' is much faster.
515,053
<p>I have a website </p> <p>www.somesite1.com which gets all its image content from www.somesite2.com </p> <p>At the moment each time an image is to be displayed we simply use an absolute URL to get it like this </p> <pre><code>&lt;img src="http://www.somesite2.com/images/myimage.jpg" /&gt; </code></pre> <p>So each...
[ { "answer_id": 515067, "author": "Techmaddy", "author_id": 50434, "author_profile": "https://Stackoverflow.com/users/50434", "pm_score": 0, "selected": false, "text": "<p>Keep a separate webserver only for the images, since images are a separate http requests.</p>\n" }, { "answer...
2009/02/05
[ "https://Stackoverflow.com/questions/515053", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51181/" ]
I have a website www.somesite1.com which gets all its image content from www.somesite2.com At the moment each time an image is to be displayed we simply use an absolute URL to get it like this ``` <img src="http://www.somesite2.com/images/myimage.jpg" /> ``` So each time a user goes to www.somesite1.com for con...
The simplest answer is to set an HTTP Expires header with a far future value (say 10 years). This way (in theory) the browser should never request that image again taking huge load off your server if you have a lot of repeat visits. Of course, you'll need to come up with a mechanism for changing the image url when the ...
515,055
<p>I'm having problem showing JQuery UI themes for my CakePHP application. I placed the theme at app/webroot/lib/jquery.ui/ . Now on my layout I imported the theme using : </p> <pre><code>echo $html-&gt;css('/lib/jquery-ui/theme/ui.all'); </code></pre> <p>I'm usingthe DatePicker widget. On my page, I can see that the...
[ { "answer_id": 515067, "author": "Techmaddy", "author_id": 50434, "author_profile": "https://Stackoverflow.com/users/50434", "pm_score": 0, "selected": false, "text": "<p>Keep a separate webserver only for the images, since images are a separate http requests.</p>\n" }, { "answer...
2009/02/05
[ "https://Stackoverflow.com/questions/515055", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40538/" ]
I'm having problem showing JQuery UI themes for my CakePHP application. I placed the theme at app/webroot/lib/jquery.ui/ . Now on my layout I imported the theme using : ``` echo $html->css('/lib/jquery-ui/theme/ui.all'); ``` I'm usingthe DatePicker widget. On my page, I can see that the my textbox was showing the d...
The simplest answer is to set an HTTP Expires header with a far future value (say 10 years). This way (in theory) the browser should never request that image again taking huge load off your server if you have a lot of repeat visits. Of course, you'll need to come up with a mechanism for changing the image url when the ...
515,071
<p>I have a Foo object, and a std::list holding instances of it. My problem is that when I add a new instance to the list, it first calls the ctor but then also the dtor. And then the dtor on another instance (according to the this pointer).</p> <p>A single instance is added to the list but since its dtor (along with ...
[ { "answer_id": 515082, "author": "Ferdinand Beyer", "author_id": 34855, "author_profile": "https://Stackoverflow.com/users/34855", "pm_score": 5, "selected": true, "text": "<p>When you push_back() your Foo object, the object is <strong>copied</strong> to the list's internal data structur...
2009/02/05
[ "https://Stackoverflow.com/questions/515071", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56763/" ]
I have a Foo object, and a std::list holding instances of it. My problem is that when I add a new instance to the list, it first calls the ctor but then also the dtor. And then the dtor on another instance (according to the this pointer). A single instance is added to the list but since its dtor (along with its parent...
When you push\_back() your Foo object, the object is **copied** to the list's internal data structures, therefore the Dtor and the Ctor of another instance are called. All standard STL container types in C++ take their items by value, therefore copying them as needed. For example, whenever a vector needs to grow, it i...
515,085
<p>Let's say that in the HTML with the help of an UpdatePanel I have the "loading" animated gif running while ASP.NET is processing data from a webservice.</p> <p>I'm just wondering if there is a way to implement an Event in the .NET code that can be listen from the HTML code, like:</p> <p>I'm requesting Persons data...
[ { "answer_id": 515121, "author": "uriDium", "author_id": 62544, "author_profile": "https://Stackoverflow.com/users/62544", "pm_score": 0, "selected": false, "text": "<p>Could you not use AJAX to do this. Fire off your query of the webservice on a separate thread. The thread should keep a...
2009/02/05
[ "https://Stackoverflow.com/questions/515085", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28004/" ]
Let's say that in the HTML with the help of an UpdatePanel I have the "loading" animated gif running while ASP.NET is processing data from a webservice. I'm just wondering if there is a way to implement an Event in the .NET code that can be listen from the HTML code, like: I'm requesting Persons data from a WebServic...
Microsoft's AJAX.NET is an upper level controls so it's easy to use but you are a little bit limited. With [Michael Schwarz's AJAX.NET library](http://ajax.schwarz-interactive.de), you can do it in this way : 1. Write a method to do importing information. This method will write a log to session or somewhere else. 2...
515,100
<p>I'm very busy write now debugging some code, so I can't cookup a complete example, but this basically describes my problem </p> <pre><code>class Base{}; class MyX:public Base { ... }; class Derived:Base { ... }; template&lt;class X&gt; class MyClass:Derived { private: MyClass(const MyClass&amp; ) :x() ...
[ { "answer_id": 515117, "author": "Ferdinand Beyer", "author_id": 34855, "author_profile": "https://Stackoverflow.com/users/34855", "pm_score": 0, "selected": false, "text": "<p>I'm afraid you will have to give us a more complete code example. For instance, in constructor MyClass(const X&...
2009/02/05
[ "https://Stackoverflow.com/questions/515100", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15124/" ]
I'm very busy write now debugging some code, so I can't cookup a complete example, but this basically describes my problem ``` class Base{}; class MyX:public Base { ... }; class Derived:Base { ... }; template<class X> class MyClass:Derived { private: MyClass(const MyClass& ) :x() {} public: MyClass(...
``` MyClass<MyX>(x); ``` is parsed as ``` MyClass<MyX> x; ``` But `MyClass<MyX>` does not have a default constructor. Try giving it a name: ``` MyClass<MyX> p(x); ```
515,114
<p>What is the best references/links,cheatsheets for the MDX language? Here are a few starters that I have collected. Please share yours :)</p> <ul> <li><a href="http://www.gumper.com/mdx.html" rel="nofollow noreferrer">http://www.gumper.com/mdx.html</a></li> <li><a href="http://www.sqlserveranalysisservices.com/OLAPP...
[ { "answer_id": 515117, "author": "Ferdinand Beyer", "author_id": 34855, "author_profile": "https://Stackoverflow.com/users/34855", "pm_score": 0, "selected": false, "text": "<p>I'm afraid you will have to give us a more complete code example. For instance, in constructor MyClass(const X&...
2009/02/05
[ "https://Stackoverflow.com/questions/515114", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13995/" ]
What is the best references/links,cheatsheets for the MDX language? Here are a few starters that I have collected. Please share yours :) * <http://www.gumper.com/mdx.html> * <http://www.sqlserveranalysisservices.com/OLAPPapers/InventoryManagement%20in%20AS2005v2.htm> * <http://www.ssas-info.com/ssas-cheat-sheets/72-ch...
``` MyClass<MyX>(x); ``` is parsed as ``` MyClass<MyX> x; ``` But `MyClass<MyX>` does not have a default constructor. Try giving it a name: ``` MyClass<MyX> p(x); ```
515,133
<p>I have written a program with both a Advanced Mode and a Beginner Mode to allow the user to get the hang of my program before it is actually used. The Advanced Mode is almost identical to the Beginner Mode apart from one or two methods needing to be replaced by another, so I have decided to create a general Mode cla...
[ { "answer_id": 515142, "author": "Frederik Gheysels", "author_id": 55774, "author_profile": "https://Stackoverflow.com/users/55774", "pm_score": 4, "selected": true, "text": "<p>Make 'GeneralMode' class, an abstract class, with abstract methods that have to be implemented by the concrete...
2009/02/05
[ "https://Stackoverflow.com/questions/515133", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3609/" ]
I have written a program with both a Advanced Mode and a Beginner Mode to allow the user to get the hang of my program before it is actually used. The Advanced Mode is almost identical to the Beginner Mode apart from one or two methods needing to be replaced by another, so I have decided to create a general Mode class ...
Make 'GeneralMode' class, an abstract class, with abstract methods that have to be implemented by the concrete 'advanced' and 'beginner' classes. The functionality that both modes have in common, can be implemented in the 'GeneralMode' class. Then, in your GUI class, instantiate the correct concrete class, and put it ...
515,141
<p>I have a large application built in ExtJS and am looking for the best way to handle custom events from anywhere in the application. For example I might want to put an anchor tag in some text in the application which will open a custom component in my app. At the moment I listen to clicks on the body and if the targe...
[ { "answer_id": 521665, "author": "Steve -Cutter- Blades", "author_id": 63437, "author_profile": "https://Stackoverflow.com/users/63437", "pm_score": 1, "selected": false, "text": "<p>I personally would not use additional meta in the HTML itself, if it can be helped. I would apply specifi...
2009/02/05
[ "https://Stackoverflow.com/questions/515141", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57083/" ]
I have a large application built in ExtJS and am looking for the best way to handle custom events from anywhere in the application. For example I might want to put an anchor tag in some text in the application which will open a custom component in my app. At the moment I listen to clicks on the body and if the target h...
I personally would not use additional meta in the HTML itself, if it can be helped. I would apply specific IDs to links of specific purpose, and bind a click event to that object. I've also found the DomQuery object (needed to find and reference the anchors) interesting to work with. Since I usually use the JQuery adap...
515,145
<p>Here's the deal:</p> <p>I got two db models, let's say <code>ShoppingCart</code> and <code>Order</code>. Following the DRY principle I'd like to extract some common props/methods into a shared interface <code>ItemContainer</code>.</p> <p>Everything went fine till I came across the <code>_flush()</code> method whic...
[ { "answer_id": 515318, "author": "Van Gale", "author_id": 34258, "author_profile": "https://Stackoverflow.com/users/34258", "pm_score": 3, "selected": true, "text": "<p>First, here are two Django snippets that should be exactly what you're looking for:</p>\n\n<ul>\n<li><a href=\"http://w...
2009/02/05
[ "https://Stackoverflow.com/questions/515145", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53330/" ]
Here's the deal: I got two db models, let's say `ShoppingCart` and `Order`. Following the DRY principle I'd like to extract some common props/methods into a shared interface `ItemContainer`. Everything went fine till I came across the `_flush()` method which mainly performs a delete on a related object set. ``` clas...
First, here are two Django snippets that should be exactly what you're looking for: * [Model inheritance with content type and inheritance-aware manager](http://www.djangosnippets.org/snippets/1034/) * [ParentModel and ChildManager for Model Inheritance](http://www.djangosnippets.org/snippets/1037/) Second, you might...
515,148
<p>If I have</p> <pre><code>List&lt;String&gt; text </code></pre> <p>how can I create a sub-list of all continious elements within a specific range e.g.</p> <pre><code>List&lt;String&gt; subList = /* all elements within text bar the first 2*/ </code></pre> <p>Also are there any other useful List manipulation tips &...
[ { "answer_id": 515154, "author": "Timbo", "author_id": 1810, "author_profile": "https://Stackoverflow.com/users/1810", "pm_score": 3, "selected": false, "text": "<pre><code>subList = text.Skip(2).ToList()\n</code></pre>\n\n<p>Skip(n) returns an IEnumerable&lt;> with all elements except t...
2009/02/05
[ "https://Stackoverflow.com/questions/515148", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1816/" ]
If I have ``` List<String> text ``` how can I create a sub-list of all continious elements within a specific range e.g. ``` List<String> subList = /* all elements within text bar the first 2*/ ``` Also are there any other useful List manipulation tips & tricks that might be useful?
This will work even without LINQ: ``` List<String> subList = text.GetRange(2, text.Count - 2); ``` **Edit:** Fixed a typo.
515,171
<p>I am working on TTCN-3 (Testing and Test Control Notation) scripting language. I wanted to prepare on guideline checker for this code files. <p>For that I want to read lines of TTCN-3 script file( some thing like file.ttcn ) one by one into a buffer. But for me fopen / sopen / open / fgetc / fscanf are not able to ...
[ { "answer_id": 515173, "author": "Chris Young", "author_id": 9417, "author_profile": "https://Stackoverflow.com/users/9417", "pm_score": 2, "selected": false, "text": "<p>Your assumption is wrong about extensions. If fopen is returning NULL, you should output the result of strerror(errno...
2009/02/05
[ "https://Stackoverflow.com/questions/515171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31116/" ]
I am working on TTCN-3 (Testing and Test Control Notation) scripting language. I wanted to prepare on guideline checker for this code files. For that I want to read lines of TTCN-3 script file( some thing like file.ttcn ) one by one into a buffer. But for me fopen / sopen / open / fgetc / fscanf are not able to work p...
Your assumption is wrong about extensions. If fopen is returning NULL, you should output the result of strerror(errno) or use the perror() function to see why it failed. **Edit**: The problem is probably because you have "c:\tc\bin\hi.ttcn". in C, "\t" is interpreted as tab, for example. You could do ``` "c:\\tc\\...
515,176
<p>I have the following code, which is the basis for pagination in a larger application. However, it does not work, as although I should be obtaining the value of pg from the url, pg never goes higher than 2. For some reason, next = pg+1; seems to always see pg as 1, regardless of what is passed on the url. It is a sim...
[ { "answer_id": 515181, "author": "Ben", "author_id": 11522, "author_profile": "https://Stackoverflow.com/users/11522", "pm_score": 1, "selected": false, "text": "<p>Here's your problem:</p>\n\n<pre><code>$last = ceil($rowcount/$page_rows);\n</code></pre>\n\n<p>That's setting $last to be ...
2009/02/05
[ "https://Stackoverflow.com/questions/515176", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1246613/" ]
I have the following code, which is the basis for pagination in a larger application. However, it does not work, as although I should be obtaining the value of pg from the url, pg never goes higher than 2. For some reason, next = pg+1; seems to always see pg as 1, regardless of what is passed on the url. It is a simila...
based on the now revised question: ``` $rowcount = count($rows); ``` will naturally always return 10, as you're limiting the result ``` ... LIMIT 10; ``` But this might help: [SQL CALC FOUND ROWS](http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_found-rows) Example: ``` mysql> SELECT ...
515,184
<p>I have to find the IDs of all the contentPlaceHolders in a MasterPage.</p>
[ { "answer_id": 515181, "author": "Ben", "author_id": 11522, "author_profile": "https://Stackoverflow.com/users/11522", "pm_score": 1, "selected": false, "text": "<p>Here's your problem:</p>\n\n<pre><code>$last = ceil($rowcount/$page_rows);\n</code></pre>\n\n<p>That's setting $last to be ...
2009/02/05
[ "https://Stackoverflow.com/questions/515184", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have to find the IDs of all the contentPlaceHolders in a MasterPage.
based on the now revised question: ``` $rowcount = count($rows); ``` will naturally always return 10, as you're limiting the result ``` ... LIMIT 10; ``` But this might help: [SQL CALC FOUND ROWS](http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_found-rows) Example: ``` mysql> SELECT ...
515,214
<p>I have a tree data structure that is L levels deep each node has <strong>about</strong> N nodes. I want to work-out the total number of nodes in the tree. To do this (I think) I need to know what percentage of the nodes that will have children.</p> <p>What is the correct term for this ratio of leaf nodes to non-lea...
[ { "answer_id": 515226, "author": "Mark Pim", "author_id": 38883, "author_profile": "https://Stackoverflow.com/users/38883", "pm_score": 0, "selected": false, "text": "<p>If you know nothing else but the depth of the tree then your only option for working out the total size is to go throu...
2009/02/05
[ "https://Stackoverflow.com/questions/515214", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18107/" ]
I have a tree data structure that is L levels deep each node has **about** N nodes. I want to work-out the total number of nodes in the tree. To do this (I think) I need to know what percentage of the nodes that will have children. What is the correct term for this ratio of leaf nodes to non-leaf nodes in N? What is ...
Ok, each node has about N subnodes and the tree is L levels deep. ``` With 1 level, the tree has 1 node. With 2 levels, the tree has 1 + N nodes. With 3 levels, the tree has 1 + N + N^2 nodes. With L levels, the tree has 1 + N + N^2 + ... + N^(L-1) nodes. ``` The total number of nodes is (N^L-1) / (N-1). Ok, just a...
515,242
<p>I'm mapping a objectified relationship (the many->many mapping table contains properties), following <a href="http://baley.codebetter.com/blogs/kyle.baley/archive/2008/12/24/many-to-many-relationships-with-data-attached-in-nhibernate.aspx" rel="nofollow noreferrer">this</a> guide.</p> <p>The SQL generated(see excep...
[ { "answer_id": 515263, "author": "Frederik Gheysels", "author_id": 55774, "author_profile": "https://Stackoverflow.com/users/55774", "pm_score": 1, "selected": false, "text": "<p>Are you sure you receive an ADO.NET Exception ?\nCan you execute the generated query against your database ?<...
2009/02/05
[ "https://Stackoverflow.com/questions/515242", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53293/" ]
I'm mapping a objectified relationship (the many->many mapping table contains properties), following [this](http://baley.codebetter.com/blogs/kyle.baley/archive/2008/12/24/many-to-many-relationships-with-data-attached-in-nhibernate.aspx) guide. The SQL generated(see exception) is working and returns what i want(strict...
Then, you should not have a List of Questionnaires in your Question class, but a List of QuestionnaireQuestion objects.
515,256
<p>How would I find the node(s) with the max version from the following document:</p> <pre><code>&lt;GateKeeperFiles&gt; &lt;File&gt; &lt;Name&gt;GateKeeper.exe&lt;/Name&gt; &lt;Major&gt;2&lt;/Major&gt; &lt;Minor&gt;1&lt;/Minor&gt; &lt;Build&gt;1&lt;/Build&gt; &lt;Revision&gt;6&lt;/Revision&gt; ...
[ { "answer_id": 515292, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 1, "selected": false, "text": "<p>If you are using C#, must it be xpath? For example (edited to support multiple files with the same version - post ...
2009/02/05
[ "https://Stackoverflow.com/questions/515256", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How would I find the node(s) with the max version from the following document: ``` <GateKeeperFiles> <File> <Name>GateKeeper.exe</Name> <Major>2</Major> <Minor>1</Minor> <Build>1</Build> <Revision>6</Revision> </File> <File> <Name>GateKeeper.exe</Name> <Major>1</Major> <Minor>1</M...
If you are using C#, must it be xpath? For example (edited to support multiple files with the same version - post mentioned plural): ``` XDocument doc = XDocument.Parse(xml); var nodes = from file in doc.Document .Element("GateKeeperFiles") .Elements("File") ...
515,259
<p>I am trying to set the current line number to a variable in Elisp but keep getting a void-variable error!</p> <p>The code is:</p> <p>(setq x what-line)</p> <p>I'd also like to set the total number of lines in the buffer to a variable as well, but get the same error?!</p>
[ { "answer_id": 515289, "author": "Mike Douglas", "author_id": 26667, "author_profile": "https://Stackoverflow.com/users/26667", "pm_score": 2, "selected": false, "text": "<pre><code>(setq x (what-line))\n</code></pre>\n" }, { "answer_id": 515520, "author": "Jouni K. Seppänen"...
2009/02/05
[ "https://Stackoverflow.com/questions/515259", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62831/" ]
I am trying to set the current line number to a variable in Elisp but keep getting a void-variable error! The code is: (setq x what-line) I'd also like to set the total number of lines in the buffer to a variable as well, but get the same error?!
``` (setq x (line-number-at-pos) y (line-number-at-pos (point-max))) ``` How to find out about this kind of thing? Try `M-x` `find-function` `RET` `what-line` `RET` to see the source code of `what-line`. Reading `simple.el` (the file in which `what-line` is defined) is a good way to get familiar with elementary...
515,269
<p>Recently I've been thinking about securing some of my code. I'm curious how one could make sure an object can never be created directly, but only via some method of a factory class. Let us say I have some "business object" class and I want to make sure any instance of this class will have a valid internal state. In ...
[ { "answer_id": 515283, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 4, "selected": false, "text": "<p>You could make the constructor on your MyBusinessObjectClass class internal, and move it and the factory into their o...
2009/02/05
[ "https://Stackoverflow.com/questions/515269", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62830/" ]
Recently I've been thinking about securing some of my code. I'm curious how one could make sure an object can never be created directly, but only via some method of a factory class. Let us say I have some "business object" class and I want to make sure any instance of this class will have a valid internal state. In ord...
Looks like you just want to run some business logic before creating the object - so why dont you just create a static method inside the "BusinessClass" that does all the dirty "myProperty" checking work, and make the constructor private? ``` public BusinessClass { public string MyProperty { get; private set; } ...
515,273
<p>I want a result to look like this (converting from a solution in Excel to reporting services):</p> <pre><code>Campaigns Success Not Success Total Success % Not sucess % Campaign 1 1 4 5 20% 80% Campaign 2 4 4 8 ...
[ { "answer_id": 515361, "author": "Calanus", "author_id": 445, "author_profile": "https://Stackoverflow.com/users/445", "pm_score": 2, "selected": false, "text": "<p>I think to add new columns you just need to right click and add a new column?</p>\n\n<p>For the <code>\"=Details\"</code> f...
2009/02/05
[ "https://Stackoverflow.com/questions/515273", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want a result to look like this (converting from a solution in Excel to reporting services): ``` Campaigns Success Not Success Total Success % Not sucess % Campaign 1 1 4 5 20% 80% Campaign 2 4 4 8 50% ...
I think to add new columns you just need to right click and add a new column? For the `"=Details"` field of the Success % column, right click and select "expression" to get to the expression editor. Then enter the following expression ``` =(Fields!Success.Value/Fields!Total.Value) * 100 ``` For the Not success colu...
515,275
<p>Is there any way to retrieve the comments from an XML file?</p> <p>I have an XML file, with comments in it, and i have to build an user-interface based on each node in this file, and the associated comments.</p> <p>I can't seem to find a way to get those comments. I was able to get 'some' of them using simpleXML, ...
[ { "answer_id": 515395, "author": "troelskn", "author_id": 18180, "author_profile": "https://Stackoverflow.com/users/18180", "pm_score": 0, "selected": false, "text": "<p>simpleXml is good for quick grabbing of something, but it has limitations. Use The DOM parser instead. Or in this case...
2009/02/05
[ "https://Stackoverflow.com/questions/515275", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11301/" ]
Is there any way to retrieve the comments from an XML file? I have an XML file, with comments in it, and i have to build an user-interface based on each node in this file, and the associated comments. I can't seem to find a way to get those comments. I was able to get 'some' of them using simpleXML, but it didn't wor...
You can use XMLReader to read through all of the nodes and pull out the comments. I've included some sample code to get you started, as it just pulls out the nodes, and doesn't take into account *where* the comment is inside, below or above any xml nodes. ``` $comments = ''; $xml =<<<EOX <xml> <!--data here --> ...
515,284
<p>I have some numbers in a fact table, and have generated a measure which use the SUM aggregator to summarize the numbers. But the problem is that I only want to sum the numbers that are higher than, say 10. I tried using a generic expression in the measure definition, and that works of course, but the problem is that...
[ { "answer_id": 515300, "author": "cjk", "author_id": 52201, "author_profile": "https://Stackoverflow.com/users/52201", "pm_score": 0, "selected": false, "text": "<p>You need to look at:</p>\n\n<ul>\n<li>Continuous Integration</li>\n<li>Running unit tests on check-in of code to check it i...
2009/02/05
[ "https://Stackoverflow.com/questions/515284", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have some numbers in a fact table, and have generated a measure which use the SUM aggregator to summarize the numbers. But the problem is that I only want to sum the numbers that are higher than, say 10. I tried using a generic expression in the measure definition, and that works of course, but the problem is that I ...
Cassy - you obviously have a long way to go before you'll get your source code management entirely in order, but it sounds like you are on your way! Having individual sandboxes will definitely help on things. Next then make sure that the website is ALWAYS just a clean checkout of a particular revision, tag or branch f...
515,305
<p>I'm beginning to fall in love with Extension Methods, but I just don't know how to create an EM only for a determinate Object type.</p> <p>I have for example:</p> <pre><code>public static void AddPhoneNumberToContact(this Contact contact, PhoneType type, String number) { lock (contact) { PhoneRow p...
[ { "answer_id": 515319, "author": "Anton Gogolev", "author_id": 60188, "author_profile": "https://Stackoverflow.com/users/60188", "pm_score": 3, "selected": false, "text": "<p>Make <code>Contact</code> and <code>Person</code> implement common interface - say <code>IContactWithPhoneNumbers...
2009/02/05
[ "https://Stackoverflow.com/questions/515305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28004/" ]
I'm beginning to fall in love with Extension Methods, but I just don't know how to create an EM only for a determinate Object type. I have for example: ``` public static void AddPhoneNumberToContact(this Contact contact, PhoneType type, String number) { lock (contact) { PhoneRow pr = PhoneRow.CreateNe...
How about writing two extension methods: ``` public static void AddPhoneNumber(this Contact contact, PhoneType type); ``` and ``` public static void AddPhoneNumber(this Person person, PhoneType type); ``` Looks cleaner to me. If there's some common code between the two, extract that into a separate method.
515,307
<p>If I implement an interface on a base class will it be inherited by its sub classes, I know the functions/procedures will be, but I am more interested in whether I will be able to cast the subclass to the interface and then back to its original class.</p> <p>What I am hoping I can do is pass objects of different ba...
[ { "answer_id": 515333, "author": "Binary Worrier", "author_id": 18797, "author_profile": "https://Stackoverflow.com/users/18797", "pm_score": 4, "selected": true, "text": "<p>Yes, the interface is inherited by the subclass.</p>\n\n<p>It's perfectly acceptable to cast from subclass to the...
2009/02/05
[ "https://Stackoverflow.com/questions/515307", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2098/" ]
If I implement an interface on a base class will it be inherited by its sub classes, I know the functions/procedures will be, but I am more interested in whether I will be able to cast the subclass to the interface and then back to its original class. What I am hoping I can do is pass objects of different base classes...
Yes, the interface is inherited by the subclass. It's perfectly acceptable to cast from subclass to the interface. However, and apologies if I'm reading your question wrong, but if "and then back to its original class" means . . . You have Interface I, class A and class B. A implements I, and B inherits A, you possi...
515,309
<p>I can understand <code>cmd</code> but not <code>cmd /c</code>. I was trying to invoke a java program from the current for which I use <code>Runtime.getRuntime().exec("cmd /C java helloworld");</code> There arises my doubt.</p>
[ { "answer_id": 515316, "author": "Simon Temlett", "author_id": 35453, "author_profile": "https://Stackoverflow.com/users/35453", "pm_score": 7, "selected": false, "text": "<p><code>/C</code> Carries out the command specified by the string and then terminates.</p>\n\n<p>You can get all th...
2009/02/05
[ "https://Stackoverflow.com/questions/515309", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62835/" ]
I can understand `cmd` but not `cmd /c`. I was trying to invoke a java program from the current for which I use `Runtime.getRuntime().exec("cmd /C java helloworld");` There arises my doubt.
The part you should be interested in is the `/?` part, which should solve most other questions you have with the tool. ``` Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. C:\>cmd /? Starts a new instance of the Windows XP command interpreter CMD [/A | /U] [/Q] [/D] [/E:ON | /E:OFF] [...
515,314
<p>I have a RootViewController and a SubViewController. I traverse the views in either direction. The RootViewController is a UITableView SubClass. Depending upon the row selected I want to change the title of the subview using <code>self.navigationItem.title = [chunks objectAtIndex:1];</code></p> <p>It works when the...
[ { "answer_id": 515421, "author": "Alex Wayne", "author_id": 62076, "author_profile": "https://Stackoverflow.com/users/62076", "pm_score": 1, "selected": true, "text": "<p>I just tried it in an app of mine. When I set the title using</p>\n\n<pre><code>self.navigationItem.title = @\"Foo\"...
2009/02/05
[ "https://Stackoverflow.com/questions/515314", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44878/" ]
I have a RootViewController and a SubViewController. I traverse the views in either direction. The RootViewController is a UITableView SubClass. Depending upon the row selected I want to change the title of the subview using `self.navigationItem.title = [chunks objectAtIndex:1];` It works when the subview is first tim...
I just tried it in an app of mine. When I set the title using ``` self.navigationItem.title = @"Foo" ``` the name in the navigation bar changes instantly. I think you have a bug somewhere else that you code is only getting called the first time you invoke your SubViewController. Stick a break point on that line and ...
515,338
<p>Doing odd/even styling with jQuery is pretty easy:</p> <pre><code>$(function() { $(".oddeven tbody tr:odd").addClass("odd"); $(".oddeven tbody tr:even").addClass("even"); }); </code></pre> <p>Now I came across an interesitng problem today. What if you want to style alternating <strong>groups</strong> of eleme...
[ { "answer_id": 515683, "author": "pawel", "author_id": 4879, "author_profile": "https://Stackoverflow.com/users/4879", "pm_score": 3, "selected": true, "text": "<pre><code>function oddEvenGroupStyle(groupSize) {\n var even = false;\n $('tr').each( \n function(i){ \n ...
2009/02/05
[ "https://Stackoverflow.com/questions/515338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18393/" ]
Doing odd/even styling with jQuery is pretty easy: ``` $(function() { $(".oddeven tbody tr:odd").addClass("odd"); $(".oddeven tbody tr:even").addClass("even"); }); ``` Now I came across an interesitng problem today. What if you want to style alternating **groups** of elements? For example, alternating blocks of ...
``` function oddEvenGroupStyle(groupSize) { var even = false; $('tr').each( function(i){ if(!(i % groupSize)) even = !even; $(this).attr('class', (even ? 'groupEven':'groupOdd') ); }) } ```
515,339
<p>Sample XML:</p> <pre><code> &lt;term&gt; &lt;name&gt;facies&lt;/name&gt; &lt;translation language="en"&gt;facies&lt;/translation&gt; &lt;definition&gt;&lt;num&gt;1.&lt;/num&gt; cara &lt;num&gt;2.&lt;/num&gt; superficie externa, superficie anterior&lt;/definition&gt; &lt;/term&gt; &lt;term&gt; &lt;na...
[ { "answer_id": 515359, "author": "annakata", "author_id": 13018, "author_profile": "https://Stackoverflow.com/users/13018", "pm_score": 2, "selected": false, "text": "<pre><code>Definition and Usage\nThe &lt;xsl:sort&gt; element is used to sort the output.\nNote: &lt;xsl:sort&gt; is alwa...
2009/02/05
[ "https://Stackoverflow.com/questions/515339", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3193/" ]
Sample XML: ``` <term> <name>facies</name> <translation language="en">facies</translation> <definition><num>1.</num> cara <num>2.</num> superficie externa, superficie anterior</definition> </term> <term> <name>factores angiógenos</name> <translation language="en">angiogenic factors</translation> ...
``` Definition and Usage The <xsl:sort> element is used to sort the output. Note: <xsl:sort> is always within <xsl:for-each> or <xsl:apply-templates>. ``` [<xsl:sort>](http://www.w3schools.com/xsl/el_sort.asp)
515,341
<p>Maybe theres another solution to this. I built a web app that requires 5-10 crons to keep it maintained and various intervals. I want to check-in the crontab into version control, so that it can be easily deployed to other servers.</p> <p>I would like to be able to put a line in the /etc/crontab file that would tel...
[ { "answer_id": 515353, "author": "Anders Westrup", "author_id": 36845, "author_profile": "https://Stackoverflow.com/users/36845", "pm_score": 3, "selected": true, "text": "<p>Put your crontab file in /etc/cron.d/ - either as a checked out file or a symlink to the checked out file.</p>\n"...
2009/02/05
[ "https://Stackoverflow.com/questions/515341", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62839/" ]
Maybe theres another solution to this. I built a web app that requires 5-10 crons to keep it maintained and various intervals. I want to check-in the crontab into version control, so that it can be easily deployed to other servers. I would like to be able to put a line in the /etc/crontab file that would tell it to lo...
Put your crontab file in /etc/cron.d/ - either as a checked out file or a symlink to the checked out file.
515,344
<p>I have two columns in Excel, like this:</p> <pre><code> A B 0.5 0.4 0.6 0.59 0.1 0.2 0.3 0.29 </code></pre> <p>I want to count how many of the values in B are less than their corresponding values in A. In this case, the answer is 3.</p> <p>I can do this by adding an extra column, <code>B-A</code> and then d...
[ { "answer_id": 515473, "author": "FM.", "author_id": 53975, "author_profile": "https://Stackoverflow.com/users/53975", "pm_score": 1, "selected": false, "text": "<p>There is a solution, but it still involves 2 extra cells: DCOUNT.</p>\n\n<p>The following is an example(insert into the spe...
2009/02/05
[ "https://Stackoverflow.com/questions/515344", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11522/" ]
I have two columns in Excel, like this: ``` A B 0.5 0.4 0.6 0.59 0.1 0.2 0.3 0.29 ``` I want to count how many of the values in B are less than their corresponding values in A. In this case, the answer is 3. I can do this by adding an extra column, `B-A` and then doing `COUNTIF(RANGE, "<0")`, but I am wonder...
This can be done using Excel array formulas. Try doing something like this: ``` =SUM(IF(A1:A5 > B1:B5, 1, 0)) ``` The very *very* **important** part, is to press `CTRL-SHIFT-ENTER` instead of just `ENTER` when you finished inputting the formula. Otherwise it won't understand you want to treat the data as an array.
515,346
<p>I'm not subclassing the control. Trying to trigger the event via <code>Control.Size = Control.Size</code> fails, since it does not trigger then even unless the new size is actually different.</p>
[ { "answer_id": 515374, "author": "Calanus", "author_id": 445, "author_profile": "https://Stackoverflow.com/users/445", "pm_score": 0, "selected": false, "text": "<p>Just change the size of the control using: Control.Size = new Size(x,y);</p>\n\n<p>Changing the size of the control will is...
2009/02/05
[ "https://Stackoverflow.com/questions/515346", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39590/" ]
I'm not subclassing the control. Trying to trigger the event via `Control.Size = Control.Size` fails, since it does not trigger then even unless the new size is actually different.
If you are subclassing `Control`, you can call `OnResize` directly, or expose it on the API: ``` public void OnResize() { this.OnResize(EventArgs.Empty); } ``` However, you can't do this for arbitrary controls. You could change the `Size` to-and-fro? Alternatively, you could use reflection, but that is hacky:...
515,356
<p>I got to thinking today: what is the best way of getting a distinct (ie no repeats) list of classes used in a document that (preferably) match a pattern (regular expression) pattern or (alternatively) start with a certain character sequence? JQuery can be used for this or just straight Javascript.</p> <p>Now it sh...
[ { "answer_id": 515393, "author": "Natrium", "author_id": 59119, "author_profile": "https://Stackoverflow.com/users/59119", "pm_score": 2, "selected": false, "text": "<p>Can this help you?</p>\n\n<p><a href=\"http://httpcode.com/blogs/PermaLink,guid,77f17d9c-cdc0-4fcb-a392-3cc70ef6ac23.as...
2009/02/05
[ "https://Stackoverflow.com/questions/515356", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18393/" ]
I got to thinking today: what is the best way of getting a distinct (ie no repeats) list of classes used in a document that (preferably) match a pattern (regular expression) pattern or (alternatively) start with a certain character sequence? JQuery can be used for this or just straight Javascript. Now it should obviou...
Using jQuery: ``` var listClasses = function( pattern ){ var allClassesTmp = {}, allClasses = []; var rx = pattern ? (new RegExp(pattern)) : (new RegExp(".*")); $('*[class]').each( function(){ var cn = this.className.split(/\s+/); for(var i=cn.length;--i>-1;){ if(rx.test(cn...
515,360
<p>I have a workflow with a property in it, declared like this:</p> <pre><code>public Person userAccount {get;set;} </code></pre> <p>Person is a class with it's own properties (like Person.Name) and with WF I can bind to the userAccount property fine yet I can't seem to bind to the userAccount.Name.</p> <p>Is it pos...
[ { "answer_id": 524048, "author": "Snehal", "author_id": 39886, "author_profile": "https://Stackoverflow.com/users/39886", "pm_score": 1, "selected": false, "text": "<p>No</p>\n\n<p>i don't think that its possible to driectly bind to Memebers of Variables in Workflow</p>\n\n<p>you will h...
2009/02/05
[ "https://Stackoverflow.com/questions/515360", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53236/" ]
I have a workflow with a property in it, declared like this: ``` public Person userAccount {get;set;} ``` Person is a class with it's own properties (like Person.Name) and with WF I can bind to the userAccount property fine yet I can't seem to bind to the userAccount.Name. Is it possible to do this? If so what do I...
It is possible and so logical just the Visual Studio editor has some issues doing it. Your path property would just need to be a set correctly. Example (taking my scenario from above): `Activity=BusinessProcess, Path=userAccount.Name`
515,372
<p>The subject says it all...</p> <p>I simply want Xcode to make a beep or any other noise once the compilation process is over. </p> <p>How can I do that?</p>
[ { "answer_id": 515442, "author": "Alnitak", "author_id": 6782, "author_profile": "https://Stackoverflow.com/users/6782", "pm_score": 4, "selected": true, "text": "<p>In your Project menu select \"New Build Phase\" and then select \"New Run Script Build Phase\".</p>\n\n<p>You can then add...
2009/02/05
[ "https://Stackoverflow.com/questions/515372", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59301/" ]
The subject says it all... I simply want Xcode to make a beep or any other noise once the compilation process is over. How can I do that?
In your Project menu select "New Build Phase" and then select "New Run Script Build Phase". You can then add shell commands to that script, i.e. ``` /usr/bin/say "Build completed" ```
515,376
<p>I know how to add javascript code to an onclick event of a button eg:</p> "this.disabled=true,this.form.submit();" %> <p>I wonder if I can use rjs in the onclick. I want to use it to render out a partial.</p> <p>Thanks</p>
[ { "answer_id": 515880, "author": "Greg Dan", "author_id": 3315, "author_profile": "https://Stackoverflow.com/users/3315", "pm_score": 2, "selected": false, "text": "<p>Check documentation for <em>remote_form_for</em> and <em>submit_to_remote</em>. Your JS code to disable the form you can...
2009/02/05
[ "https://Stackoverflow.com/questions/515376", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52086/" ]
I know how to add javascript code to an onclick event of a button eg: "this.disabled=true,this.form.submit();" %> I wonder if I can use rjs in the onclick. I want to use it to render out a partial. Thanks
In case that you really need to generate java script from rjs with in submit button. You can add rjs directly to .html.erb file like this ``` <%= submit_tag 'Enter', :onclick => render(:update) { |page| page[:enter].disable }, :id => 'enter' %> ``` but If you just only need to render partial. The an...
515,381
<p>I'm using log4net to log write log message to a rolling log file. </p> <p>Now I would also redirect all trace messages from <code>System.Diagnostics.Trace</code> to that log file. How can I configure that? I tried to find anything about that in the log4net documentation, but without success. Is it possible at all?<...
[ { "answer_id": 515398, "author": "Rune Grimstad", "author_id": 30366, "author_profile": "https://Stackoverflow.com/users/30366", "pm_score": 5, "selected": false, "text": "<p>I don't know if log4net supports this, but you could implement your own trace listener that did this.</p>\n\n<p>T...
2009/02/05
[ "https://Stackoverflow.com/questions/515381", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40347/" ]
I'm using log4net to log write log message to a rolling log file. Now I would also redirect all trace messages from `System.Diagnostics.Trace` to that log file. How can I configure that? I tried to find anything about that in the log4net documentation, but without success. Is it possible at all? The reason I want to...
According to Rune's suggestion I implemented a basic TraceListener which output to log4net: ``` public class Log4netTraceListener : System.Diagnostics.TraceListener { private readonly log4net.ILog _log; public Log4netTraceListener() { _log = log4net.LogManager.GetLogger("System.Diagnostics.Redirec...
515,391
<p>I'm rather miffed / baffled at the moment.</p> <p>I've got a Netbeans project, that compiles fine. I've edited the build.xml file to create a "-post-compile" target, which does an rmic ant task.</p> <p>So now, when I "clean and build" it compiles my main code, then generates the rmic stubs for me.</p> <p>However,...
[ { "answer_id": 519845, "author": "Gerbrand", "author_id": 56280, "author_profile": "https://Stackoverflow.com/users/56280", "pm_score": 1, "selected": false, "text": "<p>Just a wild guess (as I haven't used RMI since a while), since Java 1.5 RMI Stub classes are no longer needed. They're...
2009/02/05
[ "https://Stackoverflow.com/questions/515391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39174/" ]
I'm rather miffed / baffled at the moment. I've got a Netbeans project, that compiles fine. I've edited the build.xml file to create a "-post-compile" target, which does an rmic ant task. So now, when I "clean and build" it compiles my main code, then generates the rmic stubs for me. However, when I chose to 'Run' m...
Just a wild guess (as I haven't used RMI since a while), since Java 1.5 RMI Stub classes are no longer needed. They're automatically generated. This might be the reason netbeans removes them. You can try remove the rmic ant tasks references from you're build.xml.
515,406
<p>Is it possible to join two classes without specified mapping between them (using Criteria API)?</p> <p>I must join two classes and retrieve data from both but I can't mapping them. I know only foreign key <em>SomeID</em> in the first class and primary key <em>ID</em> in second.</p> <p>How to create Criteria to joi...
[ { "answer_id": 515525, "author": "mookid8000", "author_id": 6560, "author_profile": "https://Stackoverflow.com/users/6560", "pm_score": 4, "selected": true, "text": "<p>I don't know the criteria version, but in HQL you can do it like this:</p>\n\n<pre><code>select customer, order from Cu...
2009/02/05
[ "https://Stackoverflow.com/questions/515406", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3644960/" ]
Is it possible to join two classes without specified mapping between them (using Criteria API)? I must join two classes and retrieve data from both but I can't mapping them. I know only foreign key *SomeID* in the first class and primary key *ID* in second. How to create Criteria to join them? Is it possible without ...
I don't know the criteria version, but in HQL you can do it like this: ``` select customer, order from Customer customer, Order order where order.CustomerID = customer.Id and customer.Id = 42 ``` The result set will then be a list of object[] where the customer will be repeated times the number of orders he...
515,428
<p>I have runtime dependencies on some external jars that I would like to "rejar" into a single jar. These external dependencies are stored in an external_jars directory, and I'd like to be able to not have to list them all (i.e., not to need to change my build scripts if my dependencies change). Any thoughts?</p> <p>...
[ { "answer_id": 515438, "author": "Staale", "author_id": 3355, "author_profile": "https://Stackoverflow.com/users/3355", "pm_score": 5, "selected": false, "text": "<p>You could check out jarjar:</p>\n\n<p><a href=\"http://code.google.com/p/jarjar/\" rel=\"noreferrer\">http://code.google.c...
2009/02/05
[ "https://Stackoverflow.com/questions/515428", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25915/" ]
I have runtime dependencies on some external jars that I would like to "rejar" into a single jar. These external dependencies are stored in an external\_jars directory, and I'd like to be able to not have to list them all (i.e., not to need to change my build scripts if my dependencies change). Any thoughts? Google ga...
Just use `zipgroupfileset` with the Ant [Zip task](http://ant.apache.org/manual/Tasks/zip.html) ``` <zip destfile="out.jar"> <zipgroupfileset dir="lib" includes="*.jar"/> </zip> ``` This will flatten all included jar libraries' content.
515,429
<p>I am working on a database that uses the <em>float</em> data type to store values that should only be two decimal positions (dollars and cents).</p> <p>Using float appears to work OK, as long as the person updating the float column does a ROUND. Of course, this does not always happen and then when a SUM is done it i...
[ { "answer_id": 515444, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 2, "selected": false, "text": "<p>You can do triggers, and this is not an unreasonable use of them at all. A pre-insert and pre-update trigger should w...
2009/02/05
[ "https://Stackoverflow.com/questions/515429", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4964/" ]
I am working on a database that uses the *float* data type to store values that should only be two decimal positions (dollars and cents). Using float appears to work OK, as long as the person updating the float column does a ROUND. Of course, this does not always happen and then when a SUM is done it is always off a f...
You can do triggers, and this is not an unreasonable use of them at all. A pre-insert and pre-update trigger should work fine. In addition, you can do a one-shot fix, something like: ``` update tbl set column = round(column * 100) / 100 ``` The syntax may not be perfect, but you should get the idea. But I'm not su...
515,436
<p>Imagine a situation, I have PC with two lan cards, one is connected to internet another is connected to local network, how can I detect IP which is connected to internet with C# ?</p>
[ { "answer_id": 515446, "author": "xyz", "author_id": 82, "author_profile": "https://Stackoverflow.com/users/82", "pm_score": 2, "selected": false, "text": "<p>A hacky way is to fetch and scrape one of the many 'What Is My IP' type websites.</p>\n" }, { "answer_id": 515448, "a...
2009/02/05
[ "https://Stackoverflow.com/questions/515436", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5369/" ]
Imagine a situation, I have PC with two lan cards, one is connected to internet another is connected to local network, how can I detect IP which is connected to internet with C# ?
Try this: ``` static IPAddress getInternetIPAddress() { try { IPAddress[] addresses = Dns.GetHostAddresses(Dns.GetHostName()); IPAddress gateway = IPAddress.Parse(getInternetGateway()); return findMatch(addresses, gateway); } catch (FormatException e) { return null; } } static ...
515,454
<p>I mean, i have one of this controls and text inside one of it's columns. Usually if user changes column size, it's just cutting text. If I'm trying to use template with textblock or textbox and set TextWrapping="Wrap" inside of the template - it's really doesn't change anything. What's the way out?</p> <p>*And yes,...
[ { "answer_id": 522704, "author": "Andy", "author_id": 3857, "author_profile": "https://Stackoverflow.com/users/3857", "pm_score": 3, "selected": true, "text": "<p>The following worked for me:</p>\n\n<pre><code>&lt;ListView ItemsSource=\"{Binding Source={StaticResource MyItems}}\"&gt;\n ...
2009/02/05
[ "https://Stackoverflow.com/questions/515454", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61731/" ]
I mean, i have one of this controls and text inside one of it's columns. Usually if user changes column size, it's just cutting text. If I'm trying to use template with textblock or textbox and set TextWrapping="Wrap" inside of the template - it's really doesn't change anything. What's the way out? \*And yes, I search...
The following worked for me: ``` <ListView ItemsSource="{Binding Source={StaticResource MyItems}}"> <ListView.View> <GridView> <GridViewColumn Width="50" Header="Column 1"> <GridViewColumn.CellTemplate> <DataTemplate x:Name="col1Template"> ...
515,467
<p>I have an automation add-in written in c# that exposes some functions to be used as formulas in Excel.</p> <p>The formulas can be successfully used from an Excel sheet but they do not appear in Excel2007's formula autocomplete lists. </p> <p>i.e. If I want to use the function AddNums(x,y) within an excel sheet the...
[ { "answer_id": 613247, "author": "RedBlueThing", "author_id": 73488, "author_profile": "https://Stackoverflow.com/users/73488", "pm_score": 1, "selected": false, "text": "<p>This from <a href=\"http://support.microsoft.com/kb/285337\" rel=\"nofollow noreferrer\">Microsoft support</a> :</...
2009/02/05
[ "https://Stackoverflow.com/questions/515467", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29059/" ]
I have an automation add-in written in c# that exposes some functions to be used as formulas in Excel. The formulas can be successfully used from an Excel sheet but they do not appear in Excel2007's formula autocomplete lists. i.e. If I want to use the function AddNums(x,y) within an excel sheet then I must know wha...
This from [Microsoft support](http://support.microsoft.com/kb/285337) : > > Automation Add-ins and the Function Wizard > Each Automation Add-in has its own category in the Excel Function Wizard. The category name is the ProgID for the Add-in; you cannot specify a different category name for Automation Add-in functio...
515,476
<p>I have a google suggest like utility on my page. It automatically fills a value in one of input type text box. In IE, after the value is being filled. It doesnt allow mouse to click in between and curor jumps to the end always. Also with the left and right keys,the cursor jumps to the beginning. What's the cause.</p...
[ { "answer_id": 515498, "author": "tehvan", "author_id": 61848, "author_profile": "https://Stackoverflow.com/users/61848", "pm_score": 0, "selected": false, "text": "<p>What does your HTML page looks like? It sounds like javascript is doing something wrong.</p>\n" }, { "answer_id"...
2009/02/05
[ "https://Stackoverflow.com/questions/515476", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50851/" ]
I have a google suggest like utility on my page. It automatically fills a value in one of input type text box. In IE, after the value is being filled. It doesnt allow mouse to click in between and curor jumps to the end always. Also with the left and right keys,the cursor jumps to the beginning. What's the cause. Than...
> > What's the cause. > > > textboxClick() writes to input.value on every click. You write to the value, you lose the cursor position. So write to .value as little as possible, unless you're capable of getting cross-browser cursor handling right, which judging by the quality of the rest of the scripting on this pa...
515,480
<p>I recently set up, for a learning exercise, an Ubuntu desktop PC with KDE 4.2, installed Eclipse and started to look for information on how to develop for KDE. I know there's KDevelop and will probably have a look at that at some time in the future. Right now, however, I don't have the correct headers and libraries ...
[ { "answer_id": 515510, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 2, "selected": false, "text": "<p>You might have some clue as to what include in your <code>.classpath</code> and <code>.project</code> files if you have a lo...
2009/02/05
[ "https://Stackoverflow.com/questions/515480", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1898/" ]
I recently set up, for a learning exercise, an Ubuntu desktop PC with KDE 4.2, installed Eclipse and started to look for information on how to develop for KDE. I know there's KDevelop and will probably have a look at that at some time in the future. Right now, however, I don't have the correct headers and libraries for...
Make sure you have installed the *build-essential* package. For more documentation available from the command line, install glibc-doc, manpages-dev, gcc-\*-doc, libstdc++\*-doc (replace '\*' with suitable version numbers for your system) [Getting Started/Build/KDE4/Kubuntu and Debian](https://techbase.kde.org/Getting_...
515,499
<p>I have started a web application using struts 2. Apache tomcat 6.0 is my web server. It is clear to me that we can validate data using action-validation.xml as my login-validation.xml is – </p> <p><strong><code>&lt;validators&gt; &lt;field name="username"&gt; &lt;field-validator type="requiredstring"&gt; &lt;messag...
[ { "answer_id": 516638, "author": "yalestar", "author_id": 2177, "author_profile": "https://Stackoverflow.com/users/2177", "pm_score": 0, "selected": false, "text": "<p>For the username, there are a couple ways to approach it.</p>\n\n<p>You could use the <a href=\"http://struts.apache.org...
2009/02/05
[ "https://Stackoverflow.com/questions/515499", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have started a web application using struts 2. Apache tomcat 6.0 is my web server. It is clear to me that we can validate data using action-validation.xml as my login-validation.xml is – **`<validators> <field name="username"> <field-validator type="requiredstring"> <message>Login name is required</message> </field...
For your case, i think the regex validor works for your problem: ``` <validators> <field name="username"> <field-validator type="requiredstring"> <message>Login name is required</message> </field-validator> <field-validator type="regex"> <param name="expression"><![CDATA[(.*\*....
515,531
<p>When using gtar to add extra files to an existing archive, the loop terminates prematurely or hangs. It also terminates after creating the initial tar.gz file.</p> <p>However, if I remove the gtar calls from the loop and put print statements in their place instead, the loop executes as expected. Does anyone know wh...
[ { "answer_id": 515538, "author": "Geo", "author_id": 31610, "author_profile": "https://Stackoverflow.com/users/31610", "pm_score": 2, "selected": false, "text": "<pre><code>* exec LIST\n\n* exec PROGRAM LIST\n</code></pre>\n\n<p>The exec function executes a system command and never retur...
2009/02/05
[ "https://Stackoverflow.com/questions/515531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/55119/" ]
When using gtar to add extra files to an existing archive, the loop terminates prematurely or hangs. It also terminates after creating the initial tar.gz file. However, if I remove the gtar calls from the loop and put print statements in their place instead, the loop executes as expected. Does anyone know why this is?...
You want "system", not "exec". Here's a cleaner version: ``` my $tarball = "flex_${yearA}_${monthA}.tar.gz"; if ( -e $tarball ) { print"accessing Flex tar \n"; my $command = "gtar --append --file=$tarball $FILE"; system($command) == 0 or die "Could not ($command): $?"; } else{ print "creating...
515,541
<p>In shell script, how do I iterate through each line in an ASCII file and perform an operation on its value</p> <p>This is the example for an ASCII file which I have</p> <pre> 23 3.4e-09 55.90 5.7e-07 24 12.5 79.90 7.9e-09 25 67.9 78.9 3.4e-09 26 98.8 8...
[ { "answer_id": 515555, "author": "Philip Reynolds", "author_id": 1087, "author_profile": "https://Stackoverflow.com/users/1087", "pm_score": 2, "selected": false, "text": "<p>Using bash on Linux, you can use read. It may depend on the shell and version you want to use.</p>\n\n<p>The \"&l...
2009/02/05
[ "https://Stackoverflow.com/questions/515541", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59695/" ]
In shell script, how do I iterate through each line in an ASCII file and perform an operation on its value This is the example for an ASCII file which I have ``` 23 3.4e-09 55.90 5.7e-07 24 12.5 79.90 7.9e-09 25 67.9 78.9 3.4e-09 26 98.8 89.67 9.7e...
One way (in bash and ksh, at least, may also work in plain sh) is by using something like: ``` while read line do ... done ``` However, this will modify whitespace on each line. If you have a "sufficiently fixed" format on the lines (say each line is ValA ValB ValC), you can modify read line to read vala valb val...
515,553
<p>I want to archive a directory (I don't know whether I can call "I want to tar a directory"). I want to preserve the access permissions at the other end when I un-tar it. I should I tackle this problem in perl.</p> <p>Thanks for the response but why I'm asking for doing it Perl is I want it independent of the platf...
[ { "answer_id": 515569, "author": "zoul", "author_id": 17279, "author_profile": "https://Stackoverflow.com/users/17279", "pm_score": 3, "selected": false, "text": "<p>You might want to look at <a href=\"http://search.cpan.org/~kane/Archive-Tar-1.44/lib/Archive/Tar.pm\" rel=\"nofollow nore...
2009/02/05
[ "https://Stackoverflow.com/questions/515553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2639206/" ]
I want to archive a directory (I don't know whether I can call "I want to tar a directory"). I want to preserve the access permissions at the other end when I un-tar it. I should I tackle this problem in perl. Thanks for the response but why I'm asking for doing it Perl is I want it independent of the platforms. I wan...
Here is a simple example: ``` #!/usr/bin/perl -w use strict; use warnings 'all'; use Archive::Tar; # Create a new tar object: my $tar = Archive::Tar->new(); # Add some files: $tar->add_files( </path/to/files/*.html> ); # */ fix syntax highlighing in stackoverflow.com # Finished: $tar->write( 'file.tar' ); # Now e...
515,557
<p>I am trying to assign absence dates to an academic year, the academic year being 1st August to the 31st July.</p> <p>So what I would want would be:<br> 31/07/2007 = 2006/2007 <br> 02/10/2007 = 2007/2008 <br> 08/01/2008 = 2007/2008 <br></p> <p>Is there an easy way to do this in sql 2000 server.</p>
[ { "answer_id": 515602, "author": "splattne", "author_id": 6461, "author_profile": "https://Stackoverflow.com/users/6461", "pm_score": 1, "selected": false, "text": "<p>Should work this way:</p>\n\n<pre><code>select case \n when month(AbsenceDate) &lt;= 7 then \n ltrim(str(year(...
2009/02/05
[ "https://Stackoverflow.com/questions/515557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16989/" ]
I am trying to assign absence dates to an academic year, the academic year being 1st August to the 31st July. So what I would want would be: 31/07/2007 = 2006/2007 02/10/2007 = 2007/2008 08/01/2008 = 2007/2008 Is there an easy way to do this in sql 2000 server.
A variant with less string handling ``` SELECT AbsenceDate, CASE WHEN MONTH(AbsenceDate) <= 7 THEN CONVERT(VARCHAR(4), YEAR(AbsenceDate) - 1) + '/' + CONVERT(VARCHAR(4), YEAR(AbsenceDate)) ELSE CONVERT(VARCHAR(4), YEAR(AbsenceDate)) + '/' + CONVERT(VARCHAR(4), YEAR(AbsenceDate)...
515,561
<p>I have a combobox in C# and I want to use auto complete suggestions with it, however I want to be able to change the auto complete entries as the user types, because the possible valid entries are far too numerous to populate the <code>AutoCompleteStringCollection</code> at startup.</p> <p>As an example, suppose I'm...
[ { "answer_id": 515573, "author": "Spence", "author_id": 53771, "author_profile": "https://Stackoverflow.com/users/53771", "pm_score": 1, "selected": false, "text": "<p>I think you might want to get out the reflector and look at overriding the autocomplete behaviour in the combobox itself...
2009/02/05
[ "https://Stackoverflow.com/questions/515561", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a combobox in C# and I want to use auto complete suggestions with it, however I want to be able to change the auto complete entries as the user types, because the possible valid entries are far too numerous to populate the `AutoCompleteStringCollection` at startup. As an example, suppose I'm letting the user ty...
I had the same problem, and found an extremely simple workaround. As everybody else here, I couldn't find any means to control de behaviour of the component, so I had to accept it. The natural behaviour is: you can't dynamically populate the list every time the user types into the text box. You have to populate it onc...
515,562
<p>When I use an Iterator of Object I use a <em>while loop</em> (as written in every book learning Java, as <strong>Thinking in Java</strong> of Bruce Eckel):</p> <pre><code>Iterator it=... while(it.hasNext()){ //... } </code></pre> <p>but sometime i saw than instead somebody use the <em>for loop</em>:</p> <pre...
[ { "answer_id": 515588, "author": "tddmonkey", "author_id": 51577, "author_profile": "https://Stackoverflow.com/users/51577", "pm_score": 3, "selected": false, "text": "<p>It's just a style thing and like you I prefer the for loop when using something with an index. If you're using Java ...
2009/02/05
[ "https://Stackoverflow.com/questions/515562", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45745/" ]
When I use an Iterator of Object I use a *while loop* (as written in every book learning Java, as **Thinking in Java** of Bruce Eckel): ``` Iterator it=... while(it.hasNext()){ //... } ``` but sometime i saw than instead somebody use the *for loop*: ``` Iterator it=... for (Iterator it=...; it.hasNext();){ ...
The correct syntax for the for loop is: ``` for (Iterator it = ...; it.hasNext(); ){ //... } ``` (The preceding declaration in your code is superfluous, as well as the extra semicolon in the for loop heading.) Whether you use this syntax or the `while` loop is a matter of taste, both translate to exactly the sa...
515,565
<p>I intend to build a small web site that will poll a third party web service, say every 15 minutes, store the collected data in a db and display the results via web pages. </p> <p>I want the polling to run 24 hours a day with or without anyone visiting the web site.</p> <p>I know I could create a stand alone appli...
[ { "answer_id": 515584, "author": "Spence", "author_id": 53771, "author_profile": "https://Stackoverflow.com/users/53771", "pm_score": 4, "selected": true, "text": "<p>Add a global.asax file to your website project.</p>\n\n<p>This will give you four event handlers, one of which is used wh...
2009/02/05
[ "https://Stackoverflow.com/questions/515565", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5170/" ]
I intend to build a small web site that will poll a third party web service, say every 15 minutes, store the collected data in a db and display the results via web pages. I want the polling to run 24 hours a day with or without anyone visiting the web site. I know I could create a stand alone application that could ...
Add a global.asax file to your website project. This will give you four event handlers, one of which is used when you application loads. You can fire off your thread here. Additionally, I recommend that you set the threads to background so that you can have them dissappear when you close your web app. ``` System.Th...
515,575
<p>I have a more complicated issue (than question 'Java map with values limited by key's type parameter' question) for mapping key and value type in a Map. Here it is:</p> <pre><code>interface AnnotatedFieldValidator&lt;A extends Annotation&gt; { void validate(Field f, A annotation, Object target); Class&lt;A&gt; ...
[ { "answer_id": 515743, "author": "flicken", "author_id": 12880, "author_profile": "https://Stackoverflow.com/users/12880", "pm_score": 1, "selected": false, "text": "<p>You can extract a method to get the validator. All access to the <code>validators</code> Map is through type-checked m...
2009/02/05
[ "https://Stackoverflow.com/questions/515575", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62873/" ]
I have a more complicated issue (than question 'Java map with values limited by key's type parameter' question) for mapping key and value type in a Map. Here it is: ``` interface AnnotatedFieldValidator<A extends Annotation> { void validate(Field f, A annotation, Object target); Class<A> getSupportedAnnotationClas...
Thank you all for your answers, it really helped me come to the following solution. The answer from flicken showed me the way: I have to extract some code into a parameterized method. but instead of extracting `validators.get()` in a method, I can extract the whole validation process. Doing so, I can use programmatic ...
515,578
<p>I have a recurring problem with my Git repositories. I develop in Windows and my production site is under Linux. Several times it has happened that git was showing all files tracked as modified. I thought this was because of a conf issue or conflict between Windows and Linux, but then this morning, when I checked th...
[ { "answer_id": 515636, "author": "Bombe", "author_id": 43582, "author_profile": "https://Stackoverflow.com/users/43582", "pm_score": 3, "selected": false, "text": "<p>Sounds like a line-ending issue. Check <a href=\"http://git-scm.com/docs/git-config\" rel=\"nofollow noreferrer\">man git...
2009/02/05
[ "https://Stackoverflow.com/questions/515578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38995/" ]
I have a recurring problem with my Git repositories. I develop in Windows and my production site is under Linux. Several times it has happened that git was showing all files tracked as modified. I thought this was because of a conf issue or conflict between Windows and Linux, but then this morning, when I checked the L...
Sounds like a line-ending issue. Check [man git-config](http://git-scm.com/docs/git-config) for `core.autocrlf`.
515,591
<p>I have a MySQL table holding lots of records that i want to give the user access to. I don't want to dump the entire table to the page so i need to break it up into 25 records at a time, so i need a page index. You have probably seen these on other pages, they kind of look like this at the base of the page:</p> <p>...
[ { "answer_id": 515635, "author": "Natrium", "author_id": 59119, "author_profile": "https://Stackoverflow.com/users/59119", "pm_score": 0, "selected": false, "text": "<p>How about this jQuery-plugin?\nSo all the work is done on the clientside.</p>\n\n<p><a href=\"http://plugins.jquery.com...
2009/02/05
[ "https://Stackoverflow.com/questions/515591", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13227/" ]
I have a MySQL table holding lots of records that i want to give the user access to. I don't want to dump the entire table to the page so i need to break it up into 25 records at a time, so i need a page index. You have probably seen these on other pages, they kind of look like this at the base of the page: < 1 2 3 4 ...
It's called Pagination: a few examples: 1. [A nice one without SQL](https://stackoverflow.com/questions/207223/php-dynamic-pagination-without-sql) 2. [A long tutorial](http://www.sitepoint.com/article/perfect-php-pagination/) 3. [Another tutorial](http://www.tonymarston.net/php-mysql/pagination.html) 4. [And Another]...
515,608
<p><strong>Updated:</strong> 09/02/2009 - Revised question, provided better examples, added bounty.</p> <hr> <p>Hi,<br> I'm building a PHP application using the data mapper pattern between the database and the entities (domain objects). My question is:</p> <p><em>What is the best way to encapsulate a commonly perfor...
[ { "answer_id": 519384, "author": "Morendil", "author_id": 61168, "author_profile": "https://Stackoverflow.com/users/61168", "pm_score": 0, "selected": false, "text": "<p>I'd probably start by extracting the common task to a helper method somewhere, then waiting to see what the design cal...
2009/02/05
[ "https://Stackoverflow.com/questions/515608", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39428/" ]
**Updated:** 09/02/2009 - Revised question, provided better examples, added bounty. --- Hi, I'm building a PHP application using the data mapper pattern between the database and the entities (domain objects). My question is: *What is the best way to encapsulate a commonly performed task?* For example, one commo...
Using the repository/service pattern, your Repository classes would provide a simple CRUD interface for each of your entities, then the Service classes would be an additional layer that performs additional logic like attaching entity dependencies. The rest of your app then only utilizes the Services. Your example might...
515,612
<p>I am trying to convert an integer number in C into an array containing each of that number's digits</p> <p>i.e. if I have </p> <pre><code>int number = 5400 </code></pre> <p>how can I get to </p> <pre><code>int numberArray[4] </code></pre> <p>where </p> <pre><code>numberArray[0] = 0; numberArray[1] = 0; number...
[ { "answer_id": 515623, "author": "Zach Scrivena", "author_id": 20029, "author_profile": "https://Stackoverflow.com/users/20029", "pm_score": 4, "selected": false, "text": "<p>Hint: Take a look at this earlier question \"<a href=\"https://stackoverflow.com/questions/478968/sum-of-digits-i...
2009/02/05
[ "https://Stackoverflow.com/questions/515612", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59427/" ]
I am trying to convert an integer number in C into an array containing each of that number's digits i.e. if I have ``` int number = 5400 ``` how can I get to ``` int numberArray[4] ``` where ``` numberArray[0] = 0; numberArray[1] = 0; numberArray[2] = 4; numberArray[3] = 5; ``` Any suggestions gratefully r...
This would work for numbers >= 0 ``` #include <math.h> char * convertNumberIntoArray(unsigned int number) { int length = (int)floor(log10((float)number)) + 1; char * arr = new char[length]; int i = 0; do { arr[i] = number % 10; number /= 10; i++; } while (number != 0); ...
515,620
<p>I searched google but couldn't find an answer to this rather simple question. I have a python script that has the hash-bang (#!) on the first line:</p> <pre><code>#!/usr/bin/python </code></pre> <p>However, what if this is run on a computer with python in /bin/python or /usr/local/bin/python, or some other place? ...
[ { "answer_id": 515626, "author": "Philip Reynolds", "author_id": 1087, "author_profile": "https://Stackoverflow.com/users/1087", "pm_score": 5, "selected": true, "text": "<p>Use env.</p>\n\n<pre><code>#!/usr/bin/env python\n</code></pre>\n\n<p>It's not bulletproof, but it covers more cas...
2009/02/05
[ "https://Stackoverflow.com/questions/515620", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3355/" ]
I searched google but couldn't find an answer to this rather simple question. I have a python script that has the hash-bang (#!) on the first line: ``` #!/usr/bin/python ``` However, what if this is run on a computer with python in /bin/python or /usr/local/bin/python, or some other place? There has to be a better w...
Use env. ``` #!/usr/bin/env python ``` It's not bulletproof, but it covers more cases than /usr/bin/python.
515,639
<p>I am trying to set up Ruby on Rails on windows. I am using the Flash Rails distribution that looks pretty good, but there is an issue with sqlite3. I found the threads telling me to install version 1.2.3, which installed fine. I'm using ruby 1.9.0, and every time I try and run a script (e.g. rake db:create) that use...
[ { "answer_id": 515673, "author": "Darin Dimitrov", "author_id": 29407, "author_profile": "https://Stackoverflow.com/users/29407", "pm_score": 2, "selected": false, "text": "<p>Try installing the sqlite3-ruby gem:</p>\n\n<pre><code>gem install sqlite3-ruby\n</code></pre>\n" }, { "...
2009/02/05
[ "https://Stackoverflow.com/questions/515639", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8163/" ]
I am trying to set up Ruby on Rails on windows. I am using the Flash Rails distribution that looks pretty good, but there is an issue with sqlite3. I found the threads telling me to install version 1.2.3, which installed fine. I'm using ruby 1.9.0, and every time I try and run a script (e.g. rake db:create) that uses t...
The problem put simply is that sqlite3-ruby 1.2.3 is not compatible with ruby 1.9. This is caused because ruby 1.9 does not use .dll files for c libraries it uses .so files instead. Additionally, since sqlite3\_api.dll is written against msvcrt-ruby18.dll. This means that it specifically only will support ruby 1.8.\*. ...
515,645
<p>I seem to recall something about avoiding the Immediate If operator (<a href="http://msdn.microsoft.com/en-us/library/ty67wk28(VS.80).aspx" rel="nofollow noreferrer">?:</a>) in C#, but I don't know where I read it and what it was. I think it had to do with the fact that both the true and the false part are executed ...
[ { "answer_id": 515659, "author": "Anton Gogolev", "author_id": 60188, "author_profile": "https://Stackoverflow.com/users/60188", "pm_score": 6, "selected": true, "text": "<p>It's actually called conditional operator and is referred to as \"?:\" in the MSDN. It is basically a shorthand no...
2009/02/05
[ "https://Stackoverflow.com/questions/515645", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57036/" ]
I seem to recall something about avoiding the Immediate If operator ([?:](http://msdn.microsoft.com/en-us/library/ty67wk28(VS.80).aspx)) in C#, but I don't know where I read it and what it was. I think it had to do with the fact that both the true and the false part are executed before deciding on the outcome of the co...
It's actually called conditional operator and is referred to as "?:" in the MSDN. It is basically a shorthand notation for `if-else` except that this is actually expression, not statement. Since it's equivalent for `if` there are no caveats to this operator. What you've read is about is possibly about `Iif` function i...
515,658
<p>I am trying to get a dynamically loaded <code>LinkButton</code> to fire a postback event, which I then handle.</p> <p>I have across <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.linkbutton.command.aspx" rel="nofollow noreferrer"><code>Command</code></a>, <a href="http://msdn.microsoft.co...
[ { "answer_id": 515707, "author": "Canavar", "author_id": 55351, "author_profile": "https://Stackoverflow.com/users/55351", "pm_score": 1, "selected": true, "text": "<p>Here is my trial, and it worked : </p>\n\n<pre><code>protected void Page_Load(object sender, EventArgs e)\n{\n //if (...
2009/02/05
[ "https://Stackoverflow.com/questions/515658", "https://Stackoverflow.com", "https://Stackoverflow.com/users/832/" ]
I am trying to get a dynamically loaded `LinkButton` to fire a postback event, which I then handle. I have across [`Command`](http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.linkbutton.command.aspx), [`CommandName`](http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.linkbutton.commandn...
Here is my trial, and it worked : ``` protected void Page_Load(object sender, EventArgs e) { //if (!IsPostBack) //{ placeHolderAtPage.Controls.Add(CreateEditLink("forCard1")); //} } LinkButton CreateEditLink(string forCard) { LinkButton rtn = new LinkButton(); rtn.ID = "Edit_" + forCard; ...
515,682
<p>I am not able to get xml response data from .aspx page of VS 2005. Following is the function which writes xml response on the client end:</p> <pre><code>protected void GetMailContents(double pdblMessageID) { string lstrMailContents = ""; DataSet lobjDs = new DataSet(); StringBuilder stringBuilder = new ...
[ { "answer_id": 515695, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 1, "selected": false, "text": "<p>First - writing xml through concatenation is really flakey - consider using <code>XmlWriter</code> / <code>XDocume...
2009/02/05
[ "https://Stackoverflow.com/questions/515682", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am not able to get xml response data from .aspx page of VS 2005. Following is the function which writes xml response on the client end: ``` protected void GetMailContents(double pdblMessageID) { string lstrMailContents = ""; DataSet lobjDs = new DataSet(); StringBuilder stringBuilder = new StringBuilder(...
First - writing xml through concatenation is really flakey - consider using `XmlWriter` / `XDocument` / `XmlDocument` instead, which will automatically escape any necessary symbols (`<`, `&`, etc) rather than result in invalid xml. Did you clear the response buffer before writing to it? In reality, it would be a lot s...
515,684
<p>I'm working at an app which would make a POST ajax request to a PHP script on my server. The script would query the database and return a row of records, as an array. (One array for each row, containing elements such as id, title, etc). I then want to use <code>json_encode()</code> to encode this array, and pass it ...
[ { "answer_id": 515696, "author": "Tamas Czinege", "author_id": 8954, "author_profile": "https://Stackoverflow.com/users/8954", "pm_score": 5, "selected": true, "text": "<p>To get JSON with jQuery, just use <a href=\"http://docs.jquery.com/Ajax/jQuery.getJSON\" rel=\"noreferrer\">jQuery.g...
2009/02/05
[ "https://Stackoverflow.com/questions/515684", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49153/" ]
I'm working at an app which would make a POST ajax request to a PHP script on my server. The script would query the database and return a row of records, as an array. (One array for each row, containing elements such as id, title, etc). I then want to use `json_encode()` to encode this array, and pass it back to the ja...
To get JSON with jQuery, just use [jQuery.getJSON()](http://docs.jquery.com/Ajax/jQuery.getJSON). Alternatively, you can use any other AJAX tool and then just eval() the json to get a javascript object. To loop through an array, I usually use [jQuery.each()](http://docs.jquery.com/Utilities/jQuery.each): ``` var reco...
515,690
<p>I'm having a brain-dead moment... I have two tables described by:</p> <pre><code>CREATE TABLE table_a ( id INTEGER PRIMARY KEY AUTO_INCREMENT, name VARCHAR(255) NOT NULL UNIQUE (name)) CREATE TABLE table_b ( id INTEGER PRIMARY KEY AUTO_INCREME...
[ { "answer_id": 515701, "author": "Welbog", "author_id": 52443, "author_profile": "https://Stackoverflow.com/users/52443", "pm_score": 2, "selected": false, "text": "<p>Naively, you can use a NOT EXISTS subquery:</p>\n\n<pre><code>SELECT A.*\nFROM table_a A\nWHERE NOT EXISTS (\n SELECT 1...
2009/02/05
[ "https://Stackoverflow.com/questions/515690", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23167/" ]
I'm having a brain-dead moment... I have two tables described by: ``` CREATE TABLE table_a ( id INTEGER PRIMARY KEY AUTO_INCREMENT, name VARCHAR(255) NOT NULL UNIQUE (name)) CREATE TABLE table_b ( id INTEGER PRIMARY KEY AUTO_INCREMENT, a_key ...
``` SELECT table_a.* FROM table_a LEFT JOIN table_b ON table_a.id = table_b.a_key WHERE table_b.id IS NULL ```
515,693
<p>I'm trying to write a simple raytracer as a hobby project and it's all working fine now, except I can't get soft-shadows to work at all. My idea of soft-shadows is that the lightsource is considered to have a location and a radius. To do a shadow test on this light I take the point where the primary ray hit an objec...
[ { "answer_id": 515716, "author": "Hath", "author_id": 5186, "author_profile": "https://Stackoverflow.com/users/5186", "pm_score": 3, "selected": false, "text": "<p>minor point but is this the best use of the random class..</p>\n\n<pre><code> for(int i = 0; i &lt; _samples; i++)\n {\...
2009/02/05
[ "https://Stackoverflow.com/questions/515693", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61632/" ]
I'm trying to write a simple raytracer as a hobby project and it's all working fine now, except I can't get soft-shadows to work at all. My idea of soft-shadows is that the lightsource is considered to have a location and a radius. To do a shadow test on this light I take the point where the primary ray hit an object i...
Try generating a different "rand" for each component of "loc". As is, your jittered points all lie on a line.
515,726
<p>I created a program that iterates over a bunch of files and invokes for some of them:</p> <pre><code>scp &lt;file&gt; user@host:&lt;remotefile&gt; </code></pre> <p>However, in my case, there may be thousands of small files that need to transferred, and scp is opening a new ssh connection for each of them, which ha...
[ { "answer_id": 515737, "author": "MSalters", "author_id": 15416, "author_profile": "https://Stackoverflow.com/users/15416", "pm_score": 1, "selected": false, "text": "<p>Seems like a job for tar? Pipe its output to ssh, and on the other side pipe the ssh output back to tar.</p>\n" }, ...
2009/02/05
[ "https://Stackoverflow.com/questions/515726", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6918/" ]
I created a program that iterates over a bunch of files and invokes for some of them: ``` scp <file> user@host:<remotefile> ``` However, in my case, there may be thousands of small files that need to transferred, and scp is opening a new ssh connection for each of them, which has quite some overhead. I was wonderin...
This way would work, and for other things, this general approach is more or less right. ``` ( iterate over file list for each matching file echo filename ) | cpio -H newc -o | ssh remotehost cd location \&\& | cpio -H newc -imud ```
515,749
<p>I have implemented a linked list as a self-referencing database table:</p> <pre><code>CREATE TABLE LinkedList( Id bigint NOT NULL, ParentId bigint NULL, SomeData nvarchar(50) NOT NULL) </code></pre> <p>where Id is the primary key, and ParentId is the Id of the previous node on the list. The first node...
[ { "answer_id": 515761, "author": "Quassnoi", "author_id": 55159, "author_profile": "https://Stackoverflow.com/users/55159", "pm_score": 5, "selected": true, "text": "<p>In Oracle:</p>\n\n<pre><code>SELECT Id, ParentId, SomeData\nFROM (\n SELECT ll.*, level AS lvl\n FROM LinkedList ll\n...
2009/02/05
[ "https://Stackoverflow.com/questions/515749", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20959/" ]
I have implemented a linked list as a self-referencing database table: ``` CREATE TABLE LinkedList( Id bigint NOT NULL, ParentId bigint NULL, SomeData nvarchar(50) NOT NULL) ``` where Id is the primary key, and ParentId is the Id of the previous node on the list. The first node has ParentId = NULL. I n...
In Oracle: ``` SELECT Id, ParentId, SomeData FROM ( SELECT ll.*, level AS lvl FROM LinkedList ll START WITH ParentID IS NULL CONNECT BY ParentId = PRIOR Id ) ORDER BY lvl ``` P. S. It's a bad practice to use `NULL` as `ParentID`, as it is not searchable by indices. Insert a surrogate root with id o...
515,763
<pre><code>struct TimerEvent { event Event; timeval TimeOut; static void HandleTimer(int Fd, short Event, void *Arg); }; </code></pre> <p>HandleTimer needs to be static since I'm passing it to C library (libevent).</p> <p>I want to inherit from this class. How can this be done?</p> <p>Thanks.</p>
[ { "answer_id": 515772, "author": "Joao da Silva", "author_id": 46329, "author_profile": "https://Stackoverflow.com/users/46329", "pm_score": 6, "selected": true, "text": "<p>You can easily inherit from that class:</p>\n\n<pre><code>class Derived: public TimerEvent {\n ...\n};\n</code>...
2009/02/05
[ "https://Stackoverflow.com/questions/515763", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48461/" ]
``` struct TimerEvent { event Event; timeval TimeOut; static void HandleTimer(int Fd, short Event, void *Arg); }; ``` HandleTimer needs to be static since I'm passing it to C library (libevent). I want to inherit from this class. How can this be done? Thanks.
You can easily inherit from that class: ``` class Derived: public TimerEvent { ... }; ``` However, you can't override HandleTimer in your subclass and expect this to work: ``` TimerEvent *e = new Derived(); e->HandleTimer(); ``` This is because static methods don't have an entry in the vtable, and can't thus ...
515,785
<p>C++/CLI helpfully generates the <code>IDisposable</code> scaffolding for you when you implement a destructor on a ref class. Also, if you don't implement a destructor, but your class has a member variable which implements <code>IDisposable</code>, then <code>IDisposable</code> is again automatically implemented on y...
[ { "answer_id": 518777, "author": "Rob Walker", "author_id": 3631, "author_profile": "https://Stackoverflow.com/users/3631", "pm_score": 1, "selected": false, "text": "<p>I'm not sure I agree with the ratioanle for avoiding the IDispose implementation -- but why not just store an IWhateve...
2009/02/05
[ "https://Stackoverflow.com/questions/515785", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25457/" ]
C++/CLI helpfully generates the `IDisposable` scaffolding for you when you implement a destructor on a ref class. Also, if you don't implement a destructor, but your class has a member variable which implements `IDisposable`, then `IDisposable` is again automatically implemented on your class. It's pretty helpful and m...
I think the answer is to hold a *handle* to the msclr::com::ptr rather than holding it 'by value' (which is still holding it as a handle 'behind the scenes', except the C++CLI compiler treats it as a value - 'deleting' it (calling Dispose) when the owner object is deleted (Disposed)).
515,787
<p>In .Net 2.0 how can I disallow AutoRedirect when using WebRequest? I found some source code were there where used an AllowAutoRedirect property, but on my WebRequest there is no such property.</p>
[ { "answer_id": 515822, "author": "cgreeno", "author_id": 6088, "author_profile": "https://Stackoverflow.com/users/6088", "pm_score": 4, "selected": true, "text": "<p>You need to cast it to a <code>HttpWebRequest</code></p>\n\n<pre><code>HttpWebRequest WebRequest =\n(HttpWebRequest)System...
2009/02/05
[ "https://Stackoverflow.com/questions/515787", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36476/" ]
In .Net 2.0 how can I disallow AutoRedirect when using WebRequest? I found some source code were there where used an AllowAutoRedirect property, but on my WebRequest there is no such property.
You need to cast it to a `HttpWebRequest` ``` HttpWebRequest WebRequest = (HttpWebRequest)System.Net.WebRequest.Create("http://www.mySite.com"); WebRequest.AllowAutoRedirect = false; ```
515,788
<p>Do I have to explicitly instantiate a function template's type when it comes to reference type deduction. If that is the case, where is the ambiguity? Let's compare following 2 code snippets:</p> <p>1st: <a href="http://codepad.org/2H5QY3sW" rel="nofollow noreferrer">link for the code</a> </p> <pre><code>template ...
[ { "answer_id": 515805, "author": "Fionn", "author_id": 21566, "author_profile": "https://Stackoverflow.com/users/21566", "pm_score": 1, "selected": false, "text": "<p>Second version of the answer, just misinterpreted the question:</p>\n\n<p>The problem with the second version is that the...
2009/02/05
[ "https://Stackoverflow.com/questions/515788", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12652/" ]
Do I have to explicitly instantiate a function template's type when it comes to reference type deduction. If that is the case, where is the ambiguity? Let's compare following 2 code snippets: 1st: [link for the code](http://codepad.org/2H5QY3sW) ``` template <typename T> void foo(T& var, void(*func)(T&)) // T must ...
As highlighted in Fionn's [answer](https://stackoverflow.com/questions/515788/deduction-of-reference-types-in-template-functions/515805#515805), the problem is that the compiler deduces two distinct types for *T*, *int* and *int&*. 18.8.2.4/2 has the following: > > In some cases, the deduction is done using a single ...
515,796
<p>Why I always get WSAETIMEDOUT error in this code :</p> <pre><code>var fUDPBuf: array [1..UdpPacketSize] of byte; {...} UDPSocket := TUDPBlockSocket.Create; UDPSocket.Bind(UDPIP, UDPPort); if UDPSocket.LastError = 0 then Raise EDevFail.Create(Format(SPortFailed, [UDPPort])); while not Terminated do begin BytesR...
[ { "answer_id": 515901, "author": "mj2008", "author_id": 5544, "author_profile": "https://Stackoverflow.com/users/5544", "pm_score": 1, "selected": false, "text": "<p>In the call \"UDPSocket.RecvBufferEx(@fUDPBuf[1], UdpPacketSize, 1000);\" I would presume that the last number is the time...
2009/02/05
[ "https://Stackoverflow.com/questions/515796", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62313/" ]
Why I always get WSAETIMEDOUT error in this code : ``` var fUDPBuf: array [1..UdpPacketSize] of byte; {...} UDPSocket := TUDPBlockSocket.Create; UDPSocket.Bind(UDPIP, UDPPort); if UDPSocket.LastError = 0 then Raise EDevFail.Create(Format(SPortFailed, [UDPPort])); while not Terminated do begin BytesRead := UDPSock...
I solved my problem :) ``` UDPSocket.Bind(UDPIP, UDPPort); ``` must be ``` UDPSocket.Bind('0.0.0.0', UDPPort); ``` And ``` if UDPSocket.LastError = 0 then ``` must be ``` if UDPSocket.LastError <> 0 then ``` For to check IP address where data come from ``` if UDPSocket.GetRemoteSinIP<>UDPIP then .... `...
515,801
<p>I'm trying to capture key presses so that when a given combination is pressed I trigger an event.</p> <p>I've searched around for tips on how to get started and the simplest code snippet I can find is in Python - I grabbed the code below for it from <a href="http://www.daniweb.com/forums/thread112975.html" rel="nof...
[ { "answer_id": 515835, "author": "Ulf", "author_id": 51208, "author_profile": "https://Stackoverflow.com/users/51208", "pm_score": 2, "selected": false, "text": "<p>Tk does not seem to get it if you do not display the window. Try:</p>\n\n<pre><code>import Tkinter as tk\n\ndef key(event):...
2009/02/05
[ "https://Stackoverflow.com/questions/515801", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22185/" ]
I'm trying to capture key presses so that when a given combination is pressed I trigger an event. I've searched around for tips on how to get started and the simplest code snippet I can find is in Python - I grabbed the code below for it from [here](http://www.daniweb.com/forums/thread112975.html). However, when I run...
Well, turns out there is a much simpler answer when using GNOME which doesn't involve any programming at all... <http://www.captain.at/howto-gnome-custom-hotkey-keyboard-shortcut.php> [Archived on Wayback](https://web.archive.org/web/20070802112319/http://www.captain.at/howto-gnome-custom-hotkey-keyboard-shortcut.php...
515,803
<p>The Microsoft C compiler warns when you try to compare two variables, and one is signed, and the other is unsigned. For example:</p> <pre><code>int a; unsigned b; if ( a &lt; b ) { // warning C4018: '&amp;lt;' : signed/unsigned mismatch } </code></pre> <p>Has this warning, in the history of the world, ever c...
[ { "answer_id": 515808, "author": "j_random_hacker", "author_id": 47984, "author_profile": "https://Stackoverflow.com/users/47984", "pm_score": 2, "selected": false, "text": "<p>You <em>should</em> change <code>a</code> and <code>b</code> to both use signed types, or both use unsigned typ...
2009/02/05
[ "https://Stackoverflow.com/questions/515803", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15947/" ]
The Microsoft C compiler warns when you try to compare two variables, and one is signed, and the other is unsigned. For example: ``` int a; unsigned b; if ( a < b ) { // warning C4018: '&lt;' : signed/unsigned mismatch } ``` Has this warning, in the history of the world, ever caught a real bug? Why's it there,...
Oh it has. But the other way around. *Ignoring* that warning caused a huge headache to me one day. I was writing a function that plotted a graph, and mixed signed and unsigned variables. In one place, i compared a negative number to a unsigned one: ``` int32_t t; ... uint32_t ut; ... if(t < ut) { ... } ``` Gue...
515,819
<p>I am implementing a JTextPane-based text editor. Currently, when I have a piece of selected text, pressing the TAB key deletes the selected text. I would like to change this behavior such that TAB will indent the selected text. </p> <p>How to go about it?</p>
[ { "answer_id": 515840, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 4, "selected": true, "text": "<p>Something along the line of:</p>\n\n<pre><code>public void keyPressed ( KeyEvent event ) {\n switch ( event.getKeyCode...
2009/02/05
[ "https://Stackoverflow.com/questions/515819", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27198/" ]
I am implementing a JTextPane-based text editor. Currently, when I have a piece of selected text, pressing the TAB key deletes the selected text. I would like to change this behavior such that TAB will indent the selected text. How to go about it?
Something along the line of: ``` public void keyPressed ( KeyEvent event ) { switch ( event.getKeyCode ()) { case KeyEvent.VK_TAB : insertTabChar ( event.isShiftDown ()); event.consume (); break; case KeyEvent.VK_ENTER : sn...
515,833
<p>I wonder is there any way we can create regions in aspx page as we create it in our cs pages.</p>
[ { "answer_id": 515839, "author": "Chris Van Opstal", "author_id": 7264, "author_profile": "https://Stackoverflow.com/users/7264", "pm_score": 2, "selected": false, "text": "<p>Unfortunately no (at least not in Visual Studio).</p>\n" }, { "answer_id": 515856, "author": "balexa...
2009/02/05
[ "https://Stackoverflow.com/questions/515833", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I wonder is there any way we can create regions in aspx page as we create it in our cs pages.
not as Expandable, but in HTML it is normal to use the comments in order to create blocks of code ``` <!-- Start: Login access form --> ... Code ... <!-- End: Login access form --> ```
515,842
<p>I have a UITextView that i use for typing some text (i have added it with Interface builder)</p> <p>i have made the height 3 font lines high (so in my case the frame height is 47) so i can have 3 lines of text</p> <p>what i want it to do is type until line3 and the go up if i goto line 4 but what it does is whenev...
[ { "answer_id": 528114, "author": "Andy Jacobs", "author_id": 62009, "author_profile": "https://Stackoverflow.com/users/62009", "pm_score": 1, "selected": true, "text": "<p>It looks like the trick is to make the font size bigger</p>\n\n<pre><code>txtView.font = [UIFont systemFontOfSize:14...
2009/02/05
[ "https://Stackoverflow.com/questions/515842", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62009/" ]
I have a UITextView that i use for typing some text (i have added it with Interface builder) i have made the height 3 font lines high (so in my case the frame height is 47) so i can have 3 lines of text what i want it to do is type until line3 and the go up if i goto line 4 but what it does is whenever i type enter i...
It looks like the trick is to make the font size bigger ``` txtView.font = [UIFont systemFontOfSize:14]; ``` when i make my font size 2 points bigger it just types normal instead of going up every line.
515,844
<p>I looked at <a href="http://www.commandlinefu.com/commands/view/58/jaromils-forkbomb-do-not-use" rel="nofollow noreferrer">this page</a> and can't understand how this works.</p> <p>This command "exponentially spawns subprocesses until your box locks up".</p> <p>But why? What I understand less are the colons.</p> ...
[ { "answer_id": 515858, "author": "Johannes Weiss", "author_id": 55925, "author_profile": "https://Stackoverflow.com/users/55925", "pm_score": 7, "selected": true, "text": "<p>That defines a function called <code>:</code> which calls itself twice (Code: <code>: | :</code>). It does that ...
2009/02/05
[ "https://Stackoverflow.com/questions/515844", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41387/" ]
I looked at [this page](http://www.commandlinefu.com/commands/view/58/jaromils-forkbomb-do-not-use) and can't understand how this works. This command "exponentially spawns subprocesses until your box locks up". But why? What I understand less are the colons. `user@host$ :(){ :|:& };:`
That defines a function called `:` which calls itself twice (Code: `: | :`). It does that in the background (`&`). After the `;` the function definition is done and the function `:` gets started. So every instance of : starts two new : and so on... Like a binary tree of processes... Written in plain C that is: ``` f...
515,870
<p>I would like to know how to escape phpdoc comments within a phpdoc comment.</p> <p>For example, how would I have to write this:</p> <pre><code>/** * Some documentation... * * &lt;code&gt; * /** * * Example example phpdoc. * */ * &lt;/code&gt; */ </code></pre> <p>Obviously above example won't work.</p> ...
[ { "answer_id": 1353714, "author": "Léo Léopold Hertz 준영", "author_id": 54964, "author_profile": "https://Stackoverflow.com/users/54964", "pm_score": 0, "selected": false, "text": "<p>You need to use <code>@example</code>.\nAdd the following lines after the tag <code>&lt;/code&gt;</code><...
2009/02/05
[ "https://Stackoverflow.com/questions/515870", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30700/" ]
I would like to know how to escape phpdoc comments within a phpdoc comment. For example, how would I have to write this: ``` /** * Some documentation... * * <code> * /** * * Example example phpdoc. * */ * </code> */ ``` Obviously above example won't work. I tried replacing the asterisk's with &#x2A;, but...
According to [DocBlock Description details](http://manual.phpdoc.org/HTMLframesConverter/default/phpDocumentor/tutorial_phpDocumentor.howto.pkg.html#basics.desc), you can, as of 1.2.0rc1, write {@\*} to write \*/. For example: ``` /** * Simple DocBlock with a code example containing a docblock * * <code> * /** ...
515,876
<p>I know it can be done in Java, as I have used this technique quite extensively in the past. An example in Java would be shown below. (Additional question. What is this technique called? It's hard to find an example of this without a name.)</p> <pre><code>public abstract class Example { public abstract void doStu...
[ { "answer_id": 515886, "author": "Anton Gogolev", "author_id": 60188, "author_profile": "https://Stackoverflow.com/users/60188", "pm_score": 4, "selected": false, "text": "<p>The Java technique is called \"<a href=\"http://java.sun.com/docs/books/tutorial/java/javaOO/innerclasses.html\" ...
2009/02/05
[ "https://Stackoverflow.com/questions/515876", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57898/" ]
I know it can be done in Java, as I have used this technique quite extensively in the past. An example in Java would be shown below. (Additional question. What is this technique called? It's hard to find an example of this without a name.) ``` public abstract class Example { public abstract void doStuff(); } publi...
With lamba expressions and class initializers you can get the same behaviour with a bit of effort. ``` public class Example { public Action DoStuff; public Action<int> DoStuffWithParameter; public Func<int> DoStuffWithReturnValue; } class Program { static void Main(string[] args) { var x = new...
515,887
<p>I have an in-memory "table" that might looks something like this:</p> <pre><code>Favorite# Name Profession --------- ---------- ------------------ 3 Names.Adam Profession.Baker 9 Names.Bob Profession.Teacher 7 Names.Carl Profession.Coder 7 Names.Dave Profession.Min...
[ { "answer_id": 515918, "author": "Nick Berardi", "author_id": 17, "author_profile": "https://Stackoverflow.com/users/17", "pm_score": 4, "selected": true, "text": "<p>Not really however using a dictionary, but if you create a collection of classes like this</p>\n\n<pre><code>class Person...
2009/02/05
[ "https://Stackoverflow.com/questions/515887", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54491/" ]
I have an in-memory "table" that might looks something like this: ``` Favorite# Name Profession --------- ---------- ------------------ 3 Names.Adam Profession.Baker 9 Names.Bob Profession.Teacher 7 Names.Carl Profession.Coder 7 Names.Dave Profession.Miner 5 ...
Not really however using a dictionary, but if you create a collection of classes like this ``` class Person { public int FavoriteNumber; public string Name; public string Profession; } ``` you can use LINQ to search the collections. ``` IList<Person> people = /* my collection */; var selectedPeople = pe...
515,893
<p>I have the following simple mysqli php application, which should work fine. $pk is accepted perfectly and is a valid ARTICLE_NO, and the query works perfectly when executed directly by mysql. I have put output statements after every event and all except tetsing while executes. The while loop is never entered, and I ...
[ { "answer_id": 515926, "author": "Philip Reynolds", "author_id": 1087, "author_profile": "https://Stackoverflow.com/users/1087", "pm_score": 0, "selected": false, "text": "<p>I'm not sure if you've modified that code, but you don't seem to be selecting the database you want to connect to...
2009/02/05
[ "https://Stackoverflow.com/questions/515893", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1246613/" ]
I have the following simple mysqli php application, which should work fine. $pk is accepted perfectly and is a valid ARTICLE\_NO, and the query works perfectly when executed directly by mysql. I have put output statements after every event and all except tetsing while executes. The while loop is never entered, and I am...
Check the value of: ``` $getRecords->num_rows ``` which should help reveal whether the earlier `SELECT` is actually returning any data You may need to also add: ``` $getRecords->store_result() ``` first to ensure that you've the whole query has completed before asking for the number of rows in the result set. A...
515,917
<p>I have an app that allows the user to view, manipulate and manage a collection of Schedule objects. Different parts of the app need access to this data. I've experimented with making the collection a singleton, but I didn't find that very clean.</p> <p>I recently changed to storing the global data in the AppDelegat...
[ { "answer_id": 516006, "author": "nst", "author_id": 55137, "author_profile": "https://Stackoverflow.com/users/55137", "pm_score": 2, "selected": false, "text": "<p>Many people store everything in the AppDelegate and access the data through [[UIApplication sharedApplication] delegate].</...
2009/02/05
[ "https://Stackoverflow.com/questions/515917", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8247/" ]
I have an app that allows the user to view, manipulate and manage a collection of Schedule objects. Different parts of the app need access to this data. I've experimented with making the collection a singleton, but I didn't find that very clean. I recently changed to storing the global data in the AppDelegate class an...
If you've got a central data model that needs to be accessible to multiple controllers, there's nothing wrong with using a singleton to manage the data-- a "sharedManager" is exactly what the scenario demands. This is essentially what Apple does with their address book API for manipulating contacts. They use a C-style ...
515,940
<p>I really like the extension method that TWith2Sugars posted <a href="https://stackoverflow.com/questions/271398/post-your-extension-goodies-for-c-net-codeplexcomextensionoverflow#271423">here</a>. I ran into an odd problem though. When I put this into a shared class library and call the serialization function, I g...
[ { "answer_id": 515953, "author": "Anton Gogolev", "author_id": 60188, "author_profile": "https://Stackoverflow.com/users/60188", "pm_score": 1, "selected": false, "text": "<p>Your understanding is wrong. What this error means is basically as follows: XML serializer cannot operate on clas...
2009/02/05
[ "https://Stackoverflow.com/questions/515940", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2470/" ]
I really like the extension method that TWith2Sugars posted [here](https://stackoverflow.com/questions/271398/post-your-extension-goodies-for-c-net-codeplexcomextensionoverflow#271423). I ran into an odd problem though. When I put this into a shared class library and call the serialization function, I get the following...
Your understanding is wrong. What this error means is basically as follows: XML serializer cannot operate on class hierarchies unless you explicitly tell it what classes are there in the said hierarchy. Just add `XmlInclude` attribute for the type of each derived class to your base class and you're done.
515,951
<p>So, I'm testing all different HTML tags and attributes, freshing things up a bit, and for some reason, accesskey does not appear to be working.</p> <p>The accesskey attribute is used to assign a key to an element. Depending on your OS, pressing Alt+that key (Windows) or Cmd+that key (Mac) will give focus to that el...
[ { "answer_id": 515997, "author": "bobince", "author_id": 18936, "author_profile": "https://Stackoverflow.com/users/18936", "pm_score": 5, "selected": true, "text": "<p>Firefox's accesskey modifier is Shift+Alt.</p>\n" }, { "answer_id": 557875, "author": "John Topley", "au...
2009/02/05
[ "https://Stackoverflow.com/questions/515951", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11795/" ]
So, I'm testing all different HTML tags and attributes, freshing things up a bit, and for some reason, accesskey does not appear to be working. The accesskey attribute is used to assign a key to an element. Depending on your OS, pressing Alt+that key (Windows) or Cmd+that key (Mac) will give focus to that element. He...
Firefox's accesskey modifier is Shift+Alt.
515,985
<p>I have legacy database in which transaction tables are stored by monthly names.</p> <p>eg. </p> <pre><code> Jan08Tran Feb08Tran </code></pre> <p>How can I use NHibernate to work with this tables?</p> <p>Read a bit about entity-name property, SubClass etc. But not able to find concrete solution.</p>
[ { "answer_id": 516021, "author": "Anton Gogolev", "author_id": 60188, "author_profile": "https://Stackoverflow.com/users/60188", "pm_score": 0, "selected": false, "text": "<p>Holy #$%^! =)</p>\n\n<p>I reckon this can be achieved with custom <code>IEntityPersister</code>, but this would b...
2009/02/05
[ "https://Stackoverflow.com/questions/515985", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62889/" ]
I have legacy database in which transaction tables are stored by monthly names. eg. ``` Jan08Tran Feb08Tran ``` How can I use NHibernate to work with this tables? Read a bit about entity-name property, SubClass etc. But not able to find concrete solution.
I had a similar situation where I had to provide an interface between to purchased applications that were in production and being used by tons of different systems. This system had different table names throughout dev, test, and prod (ridiculous...) My solution was to leave a placeholder for the table number in the NHi...
515,993
<p>I have an RCP application that uses a connection to a in-memory database. There is one circumstance that, when shutting down windows, the application is killed without giving it a chance to close the connection to the database.</p> <p>I researched a little and it seems that adding a Shutdown hook is the best way t...
[ { "answer_id": 516000, "author": "Mario Ortegón", "author_id": 2309, "author_profile": "https://Stackoverflow.com/users/2309", "pm_score": 2, "selected": false, "text": "<p>I tried the following code, that I execute from my IApplication implementor start() method, before the RCP applicat...
2009/02/05
[ "https://Stackoverflow.com/questions/515993", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2309/" ]
I have an RCP application that uses a connection to a in-memory database. There is one circumstance that, when shutting down windows, the application is killed without giving it a chance to close the connection to the database. I researched a little and it seems that adding a Shutdown hook is the best way to detect th...
Note: this [blog entry](http://richclientplatform.blogspot.com/2007/09/sigue-sigue-sigterm_12.html) suggests the following implementation for the shutdown hook: > > The shutdown code must be run in the UI thread and should not be run if the workbench is being closed by other means. All dirty editors are automatically...