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
343,518
<p>Inside a windows batch file I'd like to figure out what the fully qualified path name of this batch file is.</p> <p>I have tried <code>%0</code> but this does only gave me the typed command (e.g. just the file name without path or extension).</p>
[ { "answer_id": 343531, "author": "benlumley", "author_id": 39161, "author_profile": "https://Stackoverflow.com/users/39161", "pm_score": 3, "selected": false, "text": "<p><code>%CD%</code> gives the current directory.</p>\n\n<p><code>%~dp0</code> will give you the directory the script is...
2008/12/05
[ "https://Stackoverflow.com/questions/343518", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25782/" ]
Inside a windows batch file I'd like to figure out what the fully qualified path name of this batch file is. I have tried `%0` but this does only gave me the typed command (e.g. just the file name without path or extension).
``` echo %~f0 ``` works for me. see `for /?` from `cmd` and read about variable substitution.
343,521
<p>Using TeamCity, I'm trying to get a (TestAutomationFX) test that requires an STA thread to run .</p> <p>It works via a custom app.config that configures NUnit 2.4.x (8) (as referred to by Gishu, thanks, described at <a href="http://madcoderspeak.blogspot.com/2008/12/getting-nunit-to-go-all-sta.html" rel="nofollow n...
[ { "answer_id": 343532, "author": "Gishu", "author_id": 1695, "author_profile": "https://Stackoverflow.com/users/1695", "pm_score": 0, "selected": false, "text": "<p>Can you see if this helps? Setting STA via the .config file approach... as in pre NUnit 2.5</p>\n\n<p><a href=\"http://madc...
2008/12/05
[ "https://Stackoverflow.com/questions/343521", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11635/" ]
Using TeamCity, I'm trying to get a (TestAutomationFX) test that requires an STA thread to run . It works via a custom app.config that configures NUnit 2.4.x (8) (as referred to by Gishu, thanks, described at <http://madcoderspeak.blogspot.com/2008/12/getting-nunit-to-go-all-sta.html>) It works via: ``` /// <summary...
TeamCity 4.0.1 contains NUnit 2.5.0 beta 2. I believe that should work for that case.
343,528
<p>I'm looking for a <em>SimpleGrepSedPerlOrPythonOneLiner</em> that outputs all quotations in a text.</p> <hr> <p>Example 1:</p> <pre><code>echo “HAL,” noted Frank, “said that everything was going extremely well.” | SimpleGrepSedPerlOrPythonOneLiner </code></pre> <p>stdout:</p> <pre><code>"HAL," "said that everyt...
[ { "answer_id": 343555, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 2, "selected": false, "text": "<pre><code>grep -o \"\\\"[^\\\"]*\\\"\"\n</code></pre>\n\n<p>This greps for <code>\"</code> + anything except a quote, any nu...
2008/12/05
[ "https://Stackoverflow.com/questions/343528", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4085/" ]
I'm looking for a *SimpleGrepSedPerlOrPythonOneLiner* that outputs all quotations in a text. --- Example 1: ``` echo “HAL,” noted Frank, “said that everything was going extremely well.” | SimpleGrepSedPerlOrPythonOneLiner ``` stdout: ``` "HAL," "said that everything was going extremely well.” ``` --- Example 2...
I like this: ``` perl -ne 'print "$_\n" foreach /"((?>[^"\\]|\\+[^"]|\\(?:\\\\)*")*)"/g;' ``` It's a little verbose, but it handles escaped quotes and backtracking a lot better than the simplest implementation. What it's saying is: ``` my $re = qr{ " # Begin it with literal quote ( (?> ...
343,533
<p>I am trying to build a function grapher,</p> <p>The user enters xmin, xmax, ymin, ymax, function. I got the x, y for all points.</p> <p>Now i want to translate this initial referential to a Canvas starting at 0,0 up to 250,250.</p> <p>Is there a short way or should i just check </p> <pre><code>if x &lt; 0 new ...
[ { "answer_id": 343694, "author": "avp", "author_id": 20514, "author_profile": "https://Stackoverflow.com/users/20514", "pm_score": 0, "selected": false, "text": "<ol>\n<li>You can estimate the derivative (if you have one). </li>\n<li>You can use bidirectional (dichotomic) approach: esti...
2008/12/05
[ "https://Stackoverflow.com/questions/343533", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32032/" ]
I am trying to build a function grapher, The user enters xmin, xmax, ymin, ymax, function. I got the x, y for all points. Now i want to translate this initial referential to a Canvas starting at 0,0 up to 250,250. Is there a short way or should i just check ``` if x < 0 new x = (x - xmin) * (250 / (xmax - xmin))...
Instead of iterating over x in the original coordinates, iterate over the canvas and then transform back to the original coordinates: ``` for (int xcanvas = 0; xcanvas <= 250; i++) { double x = ((xmax - xmin) * xcanvas / 250.0) + xmin; double y = f(x); int ycanvas = 250 * (y - ymin) / (ymax - ymin) + .5; ...
343,553
<p>I am not a Delphi programmer, but I I got an old Delphi 7 application that I need to fix and it is using ADO.</p> <p>The database table (MS Accesss) contains +100,000 rows and when I set the ADOTable.Active=true it starts to load the entire table into RAM and that takes a lot of memory and time.</p> <p>How can I p...
[ { "answer_id": 343619, "author": "Lars Truijens", "author_id": 1242, "author_profile": "https://Stackoverflow.com/users/1242", "pm_score": 3, "selected": false, "text": "<p>You could use TADOQuery to limit the result set with a sql query. Or you could use TADOTable and set the <a href=\"...
2008/12/05
[ "https://Stackoverflow.com/questions/343553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38165/" ]
I am not a Delphi programmer, but I I got an old Delphi 7 application that I need to fix and it is using ADO. The database table (MS Accesss) contains +100,000 rows and when I set the ADOTable.Active=true it starts to load the entire table into RAM and that takes a lot of memory and time. How can I prevent ADO to loa...
You could use TADOQuery to limit the result set with a sql query. Or you could use TADOTable and set the [CursorLocation](http://docs.codegear.com/docs/radstudio/radstudio2007/RS2007_helpupdates/HUpdate4/EN/html/delphivclwin32/ADODB_TCustomADODataSet_CursorLocation.html) to a Server side cursor to prevent the client lo...
343,557
<p>Is there a way to distinguish if a script was invoked from the command line or by the web server? </p> <p>(<strong>See <a href="https://stackoverflow.com/questions/173851/what-is-the-canonical-way-to-determine-commandline-vs-http-execution-of-a-php-s">What is the canonical way to determine commandline vs. http exec...
[ { "answer_id": 343569, "author": "Nuramon", "author_id": 43583, "author_profile": "https://Stackoverflow.com/users/43583", "pm_score": 8, "selected": true, "text": "<p><strike>If called from command line, the server variable HTTP_USER_AGENT is not set. I use this constant to define, whet...
2008/12/05
[ "https://Stackoverflow.com/questions/343557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19746/" ]
Is there a way to distinguish if a script was invoked from the command line or by the web server? (**See [What is the canonical way to determine commandline vs. http execution of a PHP script?](https://stackoverflow.com/questions/173851/what-is-the-canonical-way-to-determine-commandline-vs-http-execution-of-a-php-s) ...
If called from command line, the server variable HTTP\_USER\_AGENT is not set. I use this constant to define, whether the script is called from command line or not: ``` define("CLI", !isset($_SERVER['HTTP_USER_AGENT'])); ``` **UPDATE:** Since this answer is still marked as the 'correct' one, I'd like to revise my st...
343,561
<p>I want to achieve going to the parent element then to the prev element get the atrribute id of the element which has class: classname.</p> <pre><code>&lt;div&gt; &lt;span&gt;&lt;span id="190" class="classname"&gt;blabla&lt;/span&gt;&lt;/span&gt; &lt;span&gt;&lt;a href="#" class="button"&gt;blabla&lt;/a&gt;&lt;/sp...
[ { "answer_id": 343582, "author": "Garry Shutler", "author_id": 6369, "author_profile": "https://Stackoverflow.com/users/6369", "pm_score": 0, "selected": false, "text": "<p>I would use <code>find</code> as you have suggested.</p>\n" }, { "answer_id": 343601, "author": "tvanfo...
2008/12/05
[ "https://Stackoverflow.com/questions/343561", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to achieve going to the parent element then to the prev element get the atrribute id of the element which has class: classname. ``` <div> <span><span id="190" class="classname">blabla</span></span> <span><a href="#" class="button">blabla</a></span> </div> ``` Pseudo code: ``` $('.button').click(function()...
For your example: ``` $(this).parent().prev().children( '.classname' ).attr( 'id' ); ```
343,562
<p>I need some SQL to update a record in a database if it exists and insert it when it does not, looking around there looks to be several solutions for this, but I don't know what are the correct/ accepted ways to do this.</p> <p>I would ideally like it to work on both Firebird 2 and MySQL 5 as the update will need to...
[ { "answer_id": 343579, "author": "xahtep", "author_id": 42184, "author_profile": "https://Stackoverflow.com/users/42184", "pm_score": 1, "selected": false, "text": "<p>For MySQL, try the <code>REPLACE</code> command: <a href=\"http://dev.mysql.com/doc/refman/5.0/en/replace.html\" rel=\"n...
2008/12/05
[ "https://Stackoverflow.com/questions/343562", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2098/" ]
I need some SQL to update a record in a database if it exists and insert it when it does not, looking around there looks to be several solutions for this, but I don't know what are the correct/ accepted ways to do this. I would ideally like it to work on both Firebird 2 and MySQL 5 as the update will need to be ran ag...
You should either use something like this: ``` BEGIN TRANSACTION IF EXISTS (SELECT * FROM the_table WHERE pk = 'whatever') UPDATE the_table SET data = 'stuff' WHERE pk = 'whatever' ELSE INSERT INTO the_table (pk, data) VALUES ('whatever', 'stuff') COMMIT ``` Or this, but send them separately and ignore any e...
343,584
<p>How do I get whole and fractional parts from double in JSP/Java ? If the value is 3.25 then I want to get <code>fractional =.25</code>, <code>whole = 3</code></p> <p>How can we do this in Java?</p>
[ { "answer_id": 343598, "author": "Rasmus Faber", "author_id": 5542, "author_profile": "https://Stackoverflow.com/users/5542", "pm_score": 3, "selected": false, "text": "<p>The original question asked for the exponent and mantissa, rather than the fractional and whole part.</p>\n\n<p>To g...
2008/12/05
[ "https://Stackoverflow.com/questions/343584", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28557/" ]
How do I get whole and fractional parts from double in JSP/Java ? If the value is 3.25 then I want to get `fractional =.25`, `whole = 3` How can we do this in Java?
<http://www.java2s.com/Code/Java/Data-Type/Obtainingtheintegerandfractionalparts.htm> ``` double num; long iPart; double fPart; // Get user input num = 2.3d; iPart = (long) num; fPart = num - iPart; System.out.println("Integer part = " + iPart); System.out.println("Fractional part = " + fPart); ``` Outputs: ``` In...
343,588
<p>If I pass a ClientID to a javascript function as a parameter without including the single quotes around it, it gets passed as a reference to the control itself which can then be used without first calling getElementByID.</p> <p>I can't find this behaviour documented anywhere, is this a browser specific thing or a ....
[ { "answer_id": 343599, "author": "Gunnar Steinn", "author_id": 33468, "author_profile": "https://Stackoverflow.com/users/33468", "pm_score": 0, "selected": false, "text": "<p>If you pass it with single quotes and use getElementByID it should work in all browsers, that's the \"normal\" wa...
2008/12/05
[ "https://Stackoverflow.com/questions/343588", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1127460/" ]
If I pass a ClientID to a javascript function as a parameter without including the single quotes around it, it gets passed as a reference to the control itself which can then be used without first calling getElementByID. I can't find this behaviour documented anywhere, is this a browser specific thing or a .net thing ...
Add quotes around your ID value when you generate the JS code e.g: string.Format("showvalue(**'**{0}**'**)", TextBox1.ClientID) Without quotes, showValue gets an instance of the global variable with your ClientID name that usually is the DOM element your control rendered.
343,605
<p>I'm interested in hearing what technique(s) you're using to validate the internal state of an object during an operation that, from it's own point of view, only can fail because of bad internal state or invariant breach.</p> <p>My primary focus is on C++, since in C# the official and prevalent way is to throw an ex...
[ { "answer_id": 343628, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 3, "selected": false, "text": "<p>You can use a technique called NVI (<em>Non-Virtual-Interface</em>) together with the <code>template met...
2008/12/05
[ "https://Stackoverflow.com/questions/343605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6345/" ]
I'm interested in hearing what technique(s) you're using to validate the internal state of an object during an operation that, from it's own point of view, only can fail because of bad internal state or invariant breach. My primary focus is on C++, since in C# the official and prevalent way is to throw an exception, a...
The question is best considered in combination with how you test your software. It's important that hitting a broken invariant during testing is filed as a high severity bug, just as a crash would be. Builds for testing during development can be made to stop dead and output diagnostics. It can be appropriate to add d...
343,609
<p>I have two or three i18n files in my struts application. I am able to switch between these by setting the <code>Global.LOCALE_KEY</code> variable in the session.</p> <p>Is there a way to set a default locale for the application (probably in the struts-config.xml file, I guess) ? Is the session the only place to set...
[ { "answer_id": 343641, "author": "JeeBee", "author_id": 17832, "author_profile": "https://Stackoverflow.com/users/17832", "pm_score": 2, "selected": false, "text": "<p>In your web.xml you can define a context-param:</p>\n\n<pre><code>&lt;context-param&gt;\n &lt;param-name&gt;LOCALE&lt...
2008/12/05
[ "https://Stackoverflow.com/questions/343609", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15649/" ]
I have two or three i18n files in my struts application. I am able to switch between these by setting the `Global.LOCALE_KEY` variable in the session. Is there a way to set a default locale for the application (probably in the struts-config.xml file, I guess) ? Is the session the only place to set the locale ? Sure, ...
In your web.xml you can define a context-param: ``` <context-param> <param-name>LOCALE</param-name> <param-value>en-GB</param-value> </context-param> ``` Then up front in your webapp: ``` java.util.Enumeration<String> setout = servletContext.getInitParameterNames(); while (setout.hasMoreElements()) { St...
343,622
<p>I would like to be able to submit a form in an <strong>HTML source (string)</strong>. In other words I need at least the ability to generate POST parameters <strong>from a string containing HTML source of the form</strong>. This is needed in unit tests for a Django project. I would like a solution that possibly;</p>...
[ { "answer_id": 343639, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 2, "selected": false, "text": "<p>Since the Django test framework does this, I'm not sure what you're asking.</p>\n\n<p>Do you want to test a Django app t...
2008/12/05
[ "https://Stackoverflow.com/questions/343622", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42188/" ]
I would like to be able to submit a form in an **HTML source (string)**. In other words I need at least the ability to generate POST parameters **from a string containing HTML source of the form**. This is needed in unit tests for a Django project. I would like a solution that possibly; * Uses only standard Python lib...
You should re-read the [documentation about Django's testing framework](http://docs.djangoproject.com/en/dev/topics/testing/), specifically the part about testing views (and forms) with [the test client](http://docs.djangoproject.com/en/dev/topics/testing/#module-django.test.client). The test client acts as a simple w...
343,638
<p>I'm looking for some information on Routing in MVC with C#. I'm currently very aware of the basics of routing in MVC, but what i'm looking for is somewhat difficult to find. </p> <p>Effectively, what I want to find is a way of defining a single route that takes a single parameter.</p> <p>The common examples I have...
[ { "answer_id": 343681, "author": "Eduardo Molteni", "author_id": 2385, "author_profile": "https://Stackoverflow.com/users/2385", "pm_score": 1, "selected": true, "text": "<p>You can construct the routes as you like</p>\n\n<pre><code>routes.MapRoute(\n \"Default\",\n \"{controller}....
2008/12/05
[ "https://Stackoverflow.com/questions/343638", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20749/" ]
I'm looking for some information on Routing in MVC with C#. I'm currently very aware of the basics of routing in MVC, but what i'm looking for is somewhat difficult to find. Effectively, what I want to find is a way of defining a single route that takes a single parameter. The common examples I have found online is ...
You can construct the routes as you like ``` routes.MapRoute( "Default", "{controller}.mvc/{action}/{param1}/{param2}/{param3}" new { controller = "Default", action="Index", param1="", param2="", param3=""}); ``` Also, [look at this post](http://chriscavanagh.wordpress.com/2008/03/11/aspnet-routing-goodb...
343,642
<p>Where I work, people don't like to write specs. (Boy, does anyone?) So they don't do it, unless forced by their bosses. If they are forced to write them, they make them as short as possible. (By the way, <em>they</em> also includes <em>me</em>.)</p> <p>This results in specifications like</p> <ul> <li>This software...
[ { "answer_id": 343681, "author": "Eduardo Molteni", "author_id": 2385, "author_profile": "https://Stackoverflow.com/users/2385", "pm_score": 1, "selected": true, "text": "<p>You can construct the routes as you like</p>\n\n<pre><code>routes.MapRoute(\n \"Default\",\n \"{controller}....
2008/12/05
[ "https://Stackoverflow.com/questions/343642", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22114/" ]
Where I work, people don't like to write specs. (Boy, does anyone?) So they don't do it, unless forced by their bosses. If they are forced to write them, they make them as short as possible. (By the way, *they* also includes *me*.) This results in specifications like * This software logs the time between event A and ...
You can construct the routes as you like ``` routes.MapRoute( "Default", "{controller}.mvc/{action}/{param1}/{param2}/{param3}" new { controller = "Default", action="Index", param1="", param2="", param3=""}); ``` Also, [look at this post](http://chriscavanagh.wordpress.com/2008/03/11/aspnet-routing-goodb...
343,646
<p>How can I ignore directories or folders in Git using msysgit on Windows?</p>
[ { "answer_id": 343734, "author": "stew", "author_id": 43613, "author_profile": "https://Stackoverflow.com/users/43613", "pm_score": 12, "selected": true, "text": "<p>Create a file named <code>.gitignore</code> in your project's directory. Ignore directories by entering the directory name...
2008/12/05
[ "https://Stackoverflow.com/questions/343646", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43603/" ]
How can I ignore directories or folders in Git using msysgit on Windows?
Create a file named `.gitignore` in your project's directory. Ignore directories by entering the directory name into the file (with a slash appended): ``` dir_to_ignore/ ``` More information is [here](http://git-scm.com/docs/gitignore).
343,652
<p>I have been working on Flex for last couple of months and as this was the first time I had to actually do Flex I ended up underestimating the project tasks which resulted in a delay. So how does one estimate the project timings when working on a new technology?</p>
[ { "answer_id": 343661, "author": "Nailer", "author_id": 37346, "author_profile": "https://Stackoverflow.com/users/37346", "pm_score": 3, "selected": false, "text": "<p>I would give myself a set period of time to experiment with and learn the new technology before promising to deliver any...
2008/12/05
[ "https://Stackoverflow.com/questions/343652", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20301/" ]
I have been working on Flex for last couple of months and as this was the first time I had to actually do Flex I ended up underestimating the project tasks which resulted in a delay. So how does one estimate the project timings when working on a new technology?
I also recommend looking at this thread: [Does anyone work with Function Points?](https://stackoverflow.com/questions/118023/does-anyone-work-with-function-points) Function Points are an "industry standard" (whatever that means) for estimating how long it takes to do something. For a most part they try to map out what...
343,654
<p>I am looking to refactor a c# method into a c function in an attempt to gain some speed, and then call the c dll in c# to allow my program to use the functionality.</p> <p>Currently the c# method takes a list of integers and returns a list of lists of integers. The method calculated the power set of the integers s...
[ { "answer_id": 343668, "author": "Smokey Bacon Esq.", "author_id": 43595, "author_profile": "https://Stackoverflow.com/users/43595", "pm_score": 1, "selected": false, "text": "<p>Does it have to be C, or is C++ an option too? If C++, you can just its own <code>list</code> type from the S...
2008/12/05
[ "https://Stackoverflow.com/questions/343654", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21197/" ]
I am looking to refactor a c# method into a c function in an attempt to gain some speed, and then call the c dll in c# to allow my program to use the functionality. Currently the c# method takes a list of integers and returns a list of lists of integers. The method calculated the power set of the integers so an input ...
This returns one set of a powerset at a time. It is based on python code [here](http://groups.google.com/group/comp.lang.python/browse_thread/thread/d9211cd6c65e1d3a/). It works for powersets of over 32 elements. If you need fewer than 32, you can change long to int. It is pretty fast -- faster than my previous algorit...
343,656
<p>I'm trying to fix a broken SSP on a MOSS 2007 site. The problem I am running into manifests itself as follows...</p> <p>In the SSP "Search Settings" page I get this message:</p> <p><i>The search service is currently offline. Visit the Services on Server page in SharePoint Central Administration to verify whether t...
[ { "answer_id": 344346, "author": "Sam", "author_id": 37379, "author_profile": "https://Stackoverflow.com/users/37379", "pm_score": 1, "selected": false, "text": "<p>Maybe you can make sense of this - I'm new to sharepoint, so it makes little sense to me:\n\"Service Shared, after looking ...
2008/12/05
[ "https://Stackoverflow.com/questions/343656", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15394/" ]
I'm trying to fix a broken SSP on a MOSS 2007 site. The problem I am running into manifests itself as follows... In the SSP "Search Settings" page I get this message: *The search service is currently offline. Visit the Services on Server page in SharePoint Central Administration to verify whether the service is enabl...
So it seems that the problem was a corrupted Shared Service Provider ( no idea how it came about, but there you go ) and the only working solution I could find was to delete it and start again. I suspect there may have been a more elegant fix by changing something in the database somewhere, but I don't know the Sharep...
343,667
<p>I want to determine whether two different child nodes within an XML document are equal or not. Two nodes should be considered equal if they have the same set of attributes and child notes and all child notes are equal, too (i.e. the whole sub tree should be equal).</p> <p>The input document might be very large (up ...
[ { "answer_id": 343703, "author": "PW.", "author_id": 927, "author_profile": "https://Stackoverflow.com/users/927", "pm_score": 0, "selected": false, "text": "<p>not a direct answer to your question, but closely related to what you are trying to acheive: have a look at <a href=\"http://ms...
2008/12/05
[ "https://Stackoverflow.com/questions/343667", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40347/" ]
I want to determine whether two different child nodes within an XML document are equal or not. Two nodes should be considered equal if they have the same set of attributes and child notes and all child notes are equal, too (i.e. the whole sub tree should be equal). The input document might be very large (up to 60MB, m...
I'd recommend against rolling your own hash creation function and instead rely on the in-built `XNodeEqualityComparer`'s `GetHashCode` method. This guarantees to take account of attributes and descendant nodes when creating the result and could save you some time too. Your code would look like the following: ``` XNod...
343,669
<p>Got a quick question. Does anyone know how to let JAXB (marshall) render boolean fields as 1 and 0 instead of printing out "true" and "false"?</p>
[ { "answer_id": 343693, "author": "Dennis C", "author_id": 40214, "author_profile": "https://Stackoverflow.com/users/40214", "pm_score": 0, "selected": false, "text": "<p>You can write a pair of parser/writers and define the property mapping in binding JAXB XML.</p>\n" }, { "answe...
2008/12/05
[ "https://Stackoverflow.com/questions/343669", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20298/" ]
Got a quick question. Does anyone know how to let JAXB (marshall) render boolean fields as 1 and 0 instead of printing out "true" and "false"?
The adapter class: ``` import javax.xml.bind.annotation.adapters.XmlAdapter; public class BooleanAdapter extends XmlAdapter<Integer, Boolean> { @Override public Boolean unmarshal( Integer s ) { return s == null ? null : s == 1; } @Override public Integer marshal( Boolean c ) { ...
343,711
<p>I'm SSHing into a remote server on the command line, and trying to copy a directory onto my local machine with the <code>scp</code> command. However, the remote server returns this "usage" message:</p> <pre><code>[Stewart:console/ebooks/discostat] jmm% scp -p ./styles/ usage: scp [-1246BCEpqrv] [-c cipher] [-F ssh_...
[ { "answer_id": 343720, "author": "Gareth", "author_id": 31582, "author_profile": "https://Stackoverflow.com/users/31582", "pm_score": 4, "selected": false, "text": "<p>No, you still need to <code>scp [from] [to]</code> whichever way you're copying</p>\n\n<p>The difference is, you need to...
2008/12/05
[ "https://Stackoverflow.com/questions/343711", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm SSHing into a remote server on the command line, and trying to copy a directory onto my local machine with the `scp` command. However, the remote server returns this "usage" message: ``` [Stewart:console/ebooks/discostat] jmm% scp -p ./styles/ usage: scp [-1246BCEpqrv] [-c cipher] [-F ssh_config] [-i identity_file...
You need to `scp` something somewhere. You have `scp ./styles/`, so you're saying secure copy `./styles/`, but not where to copy it to. Generally, if you want to download, it will go: ``` # download: remote -> local scp user@remote_host:remote_file local_file ``` where `local_file` might actually be a directory to...
343,717
<p>I raised a request over at Microsoft Connect regarding the formatting of dates ("<a href="http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=327261" rel="nofollow noreferrer">DateTime Formatting should caluclate the correct suffix for the day</a>"). Basically I wanted to have a formattin...
[ { "answer_id": 343722, "author": "Joe", "author_id": 13087, "author_profile": "https://Stackoverflow.com/users/13087", "pm_score": 3, "selected": false, "text": "<p>Completely agree that it's reasonable. There's nothing to prevent you from implementing the formatting you want yourself i...
2008/12/05
[ "https://Stackoverflow.com/questions/343717", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20553/" ]
I raised a request over at Microsoft Connect regarding the formatting of dates ("[DateTime Formatting should caluclate the correct suffix for the day](http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=327261)"). Basically I wanted to have a formatting string code for adding the suffix to t...
1: It's their framework, anything they choose to do is by definition reasonable. They're not under any obligation to provide anything they don't feel like. 2: Features that can't be internationalized are basically useless. If they added it for english only, all they'd achieve is that the rest of the world would demand...
343,728
<p>Apache XMLBeans can be used to generate Java classes and interfaces from XML Schema Definition files (XSD). It also generates Enums based on StringEnumAbstractBase and StringEnumAbstractBase.Table to represent domain values. They are handy for entering only valid values. However, I want to get all those values to ge...
[ { "answer_id": 344064, "author": "Nick Holt", "author_id": 41423, "author_profile": "https://Stackoverflow.com/users/41423", "pm_score": 3, "selected": true, "text": "<p>This worked for me:</p>\n\n<pre><code>for (int i = 1; i &lt;= MyEnum.Enum.table.lastInt(); i++) \n{\n System.out.prin...
2008/12/05
[ "https://Stackoverflow.com/questions/343728", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24165/" ]
Apache XMLBeans can be used to generate Java classes and interfaces from XML Schema Definition files (XSD). It also generates Enums based on StringEnumAbstractBase and StringEnumAbstractBase.Table to represent domain values. They are handy for entering only valid values. However, I want to get all those values to gener...
This worked for me: ``` for (int i = 1; i <= MyEnum.Enum.table.lastInt(); i++) { System.out.println(MyEnum.Enum.forInt(i)); } ```
343,732
<p>In our app, we currently live with the legacy of a decision to store all engineering data in our database in SI.</p> <p>I worry that we may run the risk of not having sufficient precision and accuracy in our database or in .NET numeric types. I am also worried that we may see artifacts of floating-point maths (alth...
[ { "answer_id": 343742, "author": "Lasse V. Karlsen", "author_id": 267, "author_profile": "https://Stackoverflow.com/users/267", "pm_score": 0, "selected": false, "text": "<p>Well, it depends on how exact you want to be. Remember than when talking about engineering, it isn't enough to jus...
2008/12/05
[ "https://Stackoverflow.com/questions/343732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5351/" ]
In our app, we currently live with the legacy of a decision to store all engineering data in our database in SI. I worry that we may run the risk of not having sufficient precision and accuracy in our database or in .NET numeric types. I am also worried that we may see artifacts of floating-point maths (although that ...
Keep *significant figures* in mind -- the accuracy of the measurement. If the PSI is known to only whole pounds, then after conversion to Pa there are 15 decimals, there is still only one significant figure. Precision is different from accuracy, and performing floating point operations on engineering units need to tak...
343,744
<p>Is it possible to close parent window in Firefox 2.0 using JavaScript. I have a parent page which opens another window, i need to close the parent window after say 10 seconds. I have tried Firefox tweaks "dom.allow_scripts_to_close_windows", tried delay but nothing seems to work.</p> <p>Any help will be really appr...
[ { "answer_id": 343759, "author": "Gareth", "author_id": 31582, "author_profile": "https://Stackoverflow.com/users/31582", "pm_score": 2, "selected": false, "text": "<p>Generally, you can't close a window which you didn't open yourself using javascript.</p>\n" }, { "answer_id": 34...
2008/12/05
[ "https://Stackoverflow.com/questions/343744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21195/" ]
Is it possible to close parent window in Firefox 2.0 using JavaScript. I have a parent page which opens another window, i need to close the parent window after say 10 seconds. I have tried Firefox tweaks "dom.allow\_scripts\_to\_close\_windows", tried delay but nothing seems to work. Any help will be really appreciate...
Scissored from [quirksmode](http://www.quirksmode.org/js/croswin.html) (EDIT: added a bit of context, as suggested by Diodeus): Theoretically ``` opener.close() ``` should be the code from the popup: close the window that has opened this popup. However, in some browsers it is not allowed to automatically close win...
343,753
<p>I have a mysql database which as one of the fields contains a html description. This description is not in my control, and is obtained and inserted automatically. An example of one of these descriptions is here:</p> <p><a href="http://www.nomorepasting.com/getpaste.php?pasteid=22492" rel="nofollow noreferrer">http:...
[ { "answer_id": 343778, "author": "OIS", "author_id": 36175, "author_profile": "https://Stackoverflow.com/users/36175", "pm_score": 2, "selected": false, "text": "<p>Reminds me a little of <a href=\"https://stackoverflow.com/questions/340478/phpcode-generating-broken-javascript-and-html-c...
2008/12/05
[ "https://Stackoverflow.com/questions/343753", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1246613/" ]
I have a mysql database which as one of the fields contains a html description. This description is not in my control, and is obtained and inserted automatically. An example of one of these descriptions is here: <http://www.nomorepasting.com/getpaste.php?pasteid=22492> The data is originally exported from an access d...
The CSV file is a bit of a mess. It appears that the fields are separated by tabs and not enclosed by anything. This may be OK for simple data but when you start putting HTML in you are going to have problems - looking at [one of your other question](https://stackoverflow.com/questions/340478/phpcode-generating-broken-...
343,790
<p>I am trying to play the Asterisk system sound from a C# program with</p> <pre><code>System.Media.SystemSounds.Asterisk.Play(); </code></pre> <p>but no sound plays. My system does have a sound set up for Asterisk and other programs (not written by me) cause various system sounds to play.</p> <p>Can anyone suggest...
[ { "answer_id": 344130, "author": "ng5000", "author_id": 36860, "author_profile": "https://Stackoverflow.com/users/36860", "pm_score": 1, "selected": false, "text": "<p>Sorry if this is overstating the obvious...</p>\n\n<ol>\n<li>Are you sure this line of code is being executed?</li>\n<li...
2008/12/05
[ "https://Stackoverflow.com/questions/343790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1535/" ]
I am trying to play the Asterisk system sound from a C# program with ``` System.Media.SystemSounds.Asterisk.Play(); ``` but no sound plays. My system does have a sound set up for Asterisk and other programs (not written by me) cause various system sounds to play. Can anyone suggest any possible reasons for this?
I had ignored this problem until today. Some googling revealed that this is quite a common problem and totally unrelated to the .NET Play calls. What happens is that while you can play/preview the sounds from the Control Panel Sounds and Audio Devices applet they do not play when programs trigger the sounds. It seems ...
343,811
<p>I'm trying to click on a link using jquery. There only appears to be a click event that replicates "onclick" (i.e user input). Is it possible to use jquery to actually click a link?</p>
[ { "answer_id": 343831, "author": "kamal.gs", "author_id": 43605, "author_profile": "https://Stackoverflow.com/users/43605", "pm_score": 2, "selected": false, "text": "<p>$(-some object-).trigger('click') should do the trick. </p>\n" }, { "answer_id": 343839, "author": "brabs...
2008/12/05
[ "https://Stackoverflow.com/questions/343811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43626/" ]
I'm trying to click on a link using jquery. There only appears to be a click event that replicates "onclick" (i.e user input). Is it possible to use jquery to actually click a link?
From your answer: ``` $("a[0]") ``` is not a valid selector. to get the first a on the page use: ``` $("a:first") ``` or ``` $("a").eq(0). ``` So for the selector in your answer: ``` $("table[1]/tr[1]/td[1]/a").trigger('click'); ``` write ``` $("table").eq(1).children("tr").eq(1).children('td').eq(...
343,836
<p>When I try to execute the following code in IE:</p> <pre><code> &lt;script type="text/javascript"&gt; google.load("jquery", 1); google.load("jqueryui", "1.5.3"); $(document).ready(function() { $("#main-dialog").draggable(); }); &lt;/script&gt; &lt;d...
[ { "answer_id": 343885, "author": "Nico", "author_id": 22970, "author_profile": "https://Stackoverflow.com/users/22970", "pm_score": 0, "selected": false, "text": "<p>I depends on what you want to do.<br>\nYou can also use the MOSS search engine to search for documents.</p>\n\n<p><a href=...
2008/12/05
[ "https://Stackoverflow.com/questions/343836", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
When I try to execute the following code in IE: ``` <script type="text/javascript"> google.load("jquery", 1); google.load("jqueryui", "1.5.3"); $(document).ready(function() { $("#main-dialog").draggable(); }); </script> <div id="main-dialog"> This ...
Essentially, yes, you need to at least be able to read and understand CAML. However you can probably get out of writing it. I've used these tools: U2U CAML Query Builder by U2U - [download](http://www.u2u.be/res/Tools/CamlQueryBuilder.aspx) and [online](http://www.u2u.be/res/Tools/SharePointCamlQueryBuilder.aspx) Yet...
343,841
<p>How to configure Tomcat 5.5 to authenticate against Win2003 Activedirectory(LDAP)</p> <p>What changes are needed to default tomcat configuration, at least server.xml needs to be changed somehow to have IP of Win2003 server?</p>
[ { "answer_id": 344339, "author": "Igal Serban", "author_id": 25737, "author_profile": "https://Stackoverflow.com/users/25737", "pm_score": 0, "selected": false, "text": "<p><a href=\"http://wiki.openi.org/index.php/Configuring_Tomcat_With_Active_Directory\" rel=\"nofollow noreferrer\">Co...
2008/12/05
[ "https://Stackoverflow.com/questions/343841", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20979/" ]
How to configure Tomcat 5.5 to authenticate against Win2003 Activedirectory(LDAP) What changes are needed to default tomcat configuration, at least server.xml needs to be changed somehow to have IP of Win2003 server?
I don't know if "automatic" login with IE is possible. But you can use a "classic" login form (Java EE style) and let Tomcat perform the login against Active Directory using a JNDI Realm. change the default realm in your server.xml or set the realm in your application's context.xml like this: ``` <Realm ...
343,852
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/295579/fastest-way-to-determine-if-an-integers-square-root-is-an-integer">Fastest way to determine if an integer&#39;s square root is an integer</a> </p> </blockquote> <p>What's a way to see if a number is a <a...
[ { "answer_id": 343862, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 8, "selected": true, "text": "\n\n<pre class=\"lang-cs prettyprint-override\"><code>bool IsPerfectSquare(long input)\n{\n long closestRoot = (long) ...
2008/12/05
[ "https://Stackoverflow.com/questions/343852", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29/" ]
> > **Possible Duplicate:** > > [Fastest way to determine if an integer's square root is an integer](https://stackoverflow.com/questions/295579/fastest-way-to-determine-if-an-integers-square-root-is-an-integer) > > > What's a way to see if a number is a [perfect square](http://en.wikipedia.org/wiki/Square_numb...
```cs bool IsPerfectSquare(long input) { long closestRoot = (long) Math.Sqrt(input); return input == closestRoot * closestRoot; } ``` This may get away from *some* of the problems of just checking "is the square root an integer" but possibly not all. You potentially need to get a little bit funkier: ```cs bo...
343,865
<p>I have a bunch of files with coordinates in UTM form. For each coordinate I have easting, northing and zone. I need to convert this to LatLng for use with Google Map API to show the information in a map.</p> <p>I have found some online calculators that does this, but no actual code or libraries. <a href="http://tra...
[ { "answer_id": 343961, "author": "kender", "author_id": 4172, "author_profile": "https://Stackoverflow.com/users/4172", "pm_score": 3, "selected": false, "text": "<p>What I found is the following site: <a href=\"http://home.hiwaay.net/~taylorc/toolbox/geography/geoutm.html\" rel=\"nofoll...
2008/12/05
[ "https://Stackoverflow.com/questions/343865", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3355/" ]
I have a bunch of files with coordinates in UTM form. For each coordinate I have easting, northing and zone. I need to convert this to LatLng for use with Google Map API to show the information in a map. I have found some online calculators that does this, but no actual code or libraries. <http://trac.osgeo.org/proj4j...
I ended up finding java code from IBM that solved it: <http://www.ibm.com/developerworks/java/library/j-coordconvert/index.html> Just for reference, here is my python implementation of the method I needed: ``` import math def utmToLatLng(zone, easting, northing, northernHemisphere=True): if not northernHemispher...
343,866
<p>More and more applications need different representations of similar objects, e.g., when crossing the wire with web services or when mapping to the database. When you are working with a domain model you probably need one kind of objects in your business layer/domain model (small, lots of behaviour) and another when ...
[ { "answer_id": 343961, "author": "kender", "author_id": 4172, "author_profile": "https://Stackoverflow.com/users/4172", "pm_score": 3, "selected": false, "text": "<p>What I found is the following site: <a href=\"http://home.hiwaay.net/~taylorc/toolbox/geography/geoutm.html\" rel=\"nofoll...
2008/12/05
[ "https://Stackoverflow.com/questions/343866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
More and more applications need different representations of similar objects, e.g., when crossing the wire with web services or when mapping to the database. When you are working with a domain model you probably need one kind of objects in your business layer/domain model (small, lots of behaviour) and another when cro...
I ended up finding java code from IBM that solved it: <http://www.ibm.com/developerworks/java/library/j-coordconvert/index.html> Just for reference, here is my python implementation of the method I needed: ``` import math def utmToLatLng(zone, easting, northing, northernHemisphere=True): if not northernHemispher...
343,878
<p>Currently I'm doing something like this in markup </p> <pre><code>&lt;input type="text" ONKEYPRESS="InputNumeric(event);" id="txtNumber" /&gt; </code></pre> <p>But I want to use the jQuery bind method instead for all the obvious reasons.</p> <pre><code>jQuery(function($) { $("#txtNumber").bind("keyup", InputN...
[ { "answer_id": 343913, "author": "matthewk", "author_id": 42905, "author_profile": "https://Stackoverflow.com/users/42905", "pm_score": 3, "selected": true, "text": "<pre><code>jQuery(function($)\n{\n $(\"#txtNumber\").bind(\"keyup\", function(event) {InputNumeric(event);});\n});\n</c...
2008/12/05
[ "https://Stackoverflow.com/questions/343878", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2701/" ]
Currently I'm doing something like this in markup ``` <input type="text" ONKEYPRESS="InputNumeric(event);" id="txtNumber" /> ``` But I want to use the jQuery bind method instead for all the obvious reasons. ``` jQuery(function($) { $("#txtNumber").bind("keyup", InputNumeric(event)); }); ``` But when I try th...
``` jQuery(function($) { $("#txtNumber").bind("keyup", function(event) {InputNumeric(event);}); }); ```
343,899
<p>I have read lots of information about page caching and partial page caching in a MVC application. However, I would like to know how you would cache data.</p> <p>In my scenario I will be using LINQ to Entities (entity framework). On the first call to GetNames (or whatever the method is) I want to grab the data from ...
[ { "answer_id": 343935, "author": "terjetyl", "author_id": 29519, "author_profile": "https://Stackoverflow.com/users/29519", "pm_score": 7, "selected": true, "text": "<p>Reference the <code>System.Web</code> dll in your model and use <code>System.Web.Caching.Cache</code></p>\n<pre><code> ...
2008/12/05
[ "https://Stackoverflow.com/questions/343899", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42434/" ]
I have read lots of information about page caching and partial page caching in a MVC application. However, I would like to know how you would cache data. In my scenario I will be using LINQ to Entities (entity framework). On the first call to GetNames (or whatever the method is) I want to grab the data from the databa...
Reference the `System.Web` dll in your model and use `System.Web.Caching.Cache` ``` public string[] GetNames() { string[] names = Cache["names"] as string[]; if(names == null) //not in cache { names = DB.GetNames(); Cache["names"] = names; } return names; } ``...
343,900
<p>I have a table with playerhandles, like this:</p> <pre><code>1 - [N] Laka 2 - [N] James 3 - nor | Brian 4 - nor | John 5 - Player 2 6 - Spectator 7 - [N] Joe </code></pre> <p>From there I wanna select all players where the first n-chars match, but I don't know the pattern, only that it's the first n-chars. In the...
[ { "answer_id": 343982, "author": "Kieveli", "author_id": 15852, "author_profile": "https://Stackoverflow.com/users/15852", "pm_score": 3, "selected": true, "text": "<p>You could add an exists clause.</p>\n\n<pre><code>select name from players p1 where exists (\n select 1 from players p2...
2008/12/05
[ "https://Stackoverflow.com/questions/343900", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33232/" ]
I have a table with playerhandles, like this: ``` 1 - [N] Laka 2 - [N] James 3 - nor | Brian 4 - nor | John 5 - Player 2 6 - Spectator 7 - [N] Joe ``` From there I wanna select all players where the first n-chars match, but I don't know the pattern, only that it's the first n-chars. In the above example I wan't it ...
You could add an exists clause. ``` select name from players p1 where exists ( select 1 from players p2 where p2.name like CONCAT( SUBSTRING(p1.name, 1, 3), '%') and p1.name <> p2.name ) ``` This will give you: 1 - [N] Laka 2 - [N] James 3 - nor | Brian 4 - nor | John 7 - [N] Joe Add an '...
343,902
<p>I have a table in a ORACLE 10g database with a column "<code>kzCode NUMBER(1)</code>".</p> <p>If I try to map this with Hibernate annotations in JBOSS Server WebApp like this:</p> <pre><code>@Column(nullable=false) private Integer kzCode; </code></pre> <p>I got an error: </p> <pre><code>org.hibernate.HibernateEx...
[ { "answer_id": 343922, "author": "Paul Croarkin", "author_id": 18995, "author_profile": "https://Stackoverflow.com/users/18995", "pm_score": 0, "selected": false, "text": "<pre><code>@Column(nullable=false)\nprivate Boolean kzCode;\n</code></pre>\n\n<p>or if you really want it to be a nu...
2008/12/05
[ "https://Stackoverflow.com/questions/343902", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a table in a ORACLE 10g database with a column "`kzCode NUMBER(1)`". If I try to map this with Hibernate annotations in JBOSS Server WebApp like this: ``` @Column(nullable=false) private Integer kzCode; ``` I got an error: ``` org.hibernate.HibernateException: Wrong column type: kzCode, expected: integer ...
ok, got it! I had a wrong dialect property in persistence.xml file. Now all works fine..
343,921
<p>I am writing a batch script which I wish to open a file and then change the second line of it. I want to find the string "cat" and replace it with a value that I have SET i.e. %var% . I only want this to happen on the second line (or for the first 3 times). How would you go about doing this?</p>
[ { "answer_id": 343942, "author": "Vincent Van Den Berghe", "author_id": 39259, "author_profile": "https://Stackoverflow.com/users/39259", "pm_score": 0, "selected": false, "text": "<p>First of all, using a batch file to achieve this, is messy (IMHO). You will have to use an external tool...
2008/12/05
[ "https://Stackoverflow.com/questions/343921", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am writing a batch script which I wish to open a file and then change the second line of it. I want to find the string "cat" and replace it with a value that I have SET i.e. %var% . I only want this to happen on the second line (or for the first 3 times). How would you go about doing this?
I just solve it myself. It will lookup var on line two only. ``` @echo OFF SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION SET filename=%1 set LINENO=0 for /F "delims=" %%l in (%filename%) do ( SET /A LINENO=!LINENO!+1 IF "!LINENO!"=="2" ( call echo %%l ) ELSE ( echo %%l ) ) ``` But I prefer using cscript (vb...
343,946
<p>I want to change the font I am using in a CEikLabel on S60 device</p> <p>I believe I can do the following</p> <pre><code>const CFont* aPlainFont = LatinPlain12(); aLabel-&gt;SetFont(aPlainFont); </code></pre> <p>where LatinPlain12 is one from this list..</p> <pre><code>Albi12 Alp13 Alpi13 Albi13 alp17 Alb17b alb...
[ { "answer_id": 344021, "author": "ayaz", "author_id": 23191, "author_profile": "https://Stackoverflow.com/users/23191", "pm_score": 1, "selected": false, "text": "<p>You may use the <a href=\"http://www.newlc.com/FontViewer.html\" rel=\"nofollow noreferrer\">FontViewer</a> application to...
2008/12/05
[ "https://Stackoverflow.com/questions/343946", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33604/" ]
I want to change the font I am using in a CEikLabel on S60 device I believe I can do the following ``` const CFont* aPlainFont = LatinPlain12(); aLabel->SetFont(aPlainFont); ``` where LatinPlain12 is one from this list.. ``` Albi12 Alp13 Alpi13 Albi13 alp17 Alb17b albi17b alpi17 Aco13 Aco21 Acalc21 LatinBold12 Lat...
Programatically, you can determine if a font is proportional using: ``` const CFont* myFont; // Initialize your font // .... TBool isProportional = (myFont->FontSpecInTwips().iTypeface.Attributes() & TTypeFace::EProportional); ``` BTW you might be better off enumerating the fonts on the device and/or using the logi...
343,991
<p>I use VS6 and ATL with CServiceModule to implement a custom windows service. In case of a fatal error service should shut itself down. Since CServiceModule is available via _Module variable in all files I thought of something like this to cause CServiceModule::Run to stop pumping messages and shut itself down</p> <...
[ { "answer_id": 344074, "author": "Lars Truijens", "author_id": 1242, "author_profile": "https://Stackoverflow.com/users/1242", "pm_score": 0, "selected": false, "text": "<p>I do not know much about Office, but I guess you should use COM/ActiveX. Then you also get your IDispatch. See <a h...
2008/12/05
[ "https://Stackoverflow.com/questions/343991", "https://Stackoverflow.com", "https://Stackoverflow.com/users/501/" ]
I use VS6 and ATL with CServiceModule to implement a custom windows service. In case of a fatal error service should shut itself down. Since CServiceModule is available via \_Module variable in all files I thought of something like this to cause CServiceModule::Run to stop pumping messages and shut itself down ``` Pos...
What you describe is called writing a COM addin. You need to create an automation DLL and implement the [`IDTExtensibility2`](http://msdn.microsoft.com/en-us/library/aa155640(office.10).aspx#comaddins_idtextens2) interface. You will then receive the Excel `Application` interface as a parameter to the `OnConnection` met...
343,995
<p>I'm rewriting a PHP web site in ASP.NET MVC. I'd like to maintain the same user base but the passwords are hashed using the PHP crypt() function. I need the same function in .Net so that I can hash a password on login and check it against the hashed password in the user database.</p> <p>crypt in this case is using ...
[ { "answer_id": 344023, "author": "MrKurt", "author_id": 35296, "author_profile": "https://Stackoverflow.com/users/35296", "pm_score": 2, "selected": false, "text": "<p>There are a few .NET methods for md5 hashing, <code>System.Web.Security.FormsAuthentication.HashPasswordForStoringInConf...
2008/12/05
[ "https://Stackoverflow.com/questions/343995", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43649/" ]
I'm rewriting a PHP web site in ASP.NET MVC. I'd like to maintain the same user base but the passwords are hashed using the PHP crypt() function. I need the same function in .Net so that I can hash a password on login and check it against the hashed password in the user database. crypt in this case is using the CRYPT\...
The only solution I found was to call a trivial PHP script that simply performs a hash of the input string and returns it :-(
344,012
<p><strong>UPDATE:</strong> Obviously, you'd want to do this using templates or a base class rather than macros. Unfortunately for various reasons I can't use templates, or a base class.</p> <hr/> <p>At the moment I am using a macro to define a bunch of fields and methods on various classes, like this:</p> <pre><cod...
[ { "answer_id": 344029, "author": "Jonathan Leffler", "author_id": 15168, "author_profile": "https://Stackoverflow.com/users/15168", "pm_score": 4, "selected": true, "text": "<p>This cries out for a template.</p>\n\n<pre><code>class Example&lt;class T&gt;\n{\n ...class definition...\n}...
2008/12/05
[ "https://Stackoverflow.com/questions/344012", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25457/" ]
**UPDATE:** Obviously, you'd want to do this using templates or a base class rather than macros. Unfortunately for various reasons I can't use templates, or a base class. --- At the moment I am using a macro to define a bunch of fields and methods on various classes, like this: ``` class Example { // Use FIELDS_AN...
This cries out for a template. ``` class Example<class T> { ...class definition... }; ``` The direct answer to the last part of your question - "given that I'm not in a macro definition any more, how do I get pasting and stringizing operators to work" - is "You can't". Those operators only work in macros, so you...
344,018
<p>I have an ASP.NET application which tracks statistics by creating and writing to custom performance counters. Occasionally, I see in the error logs that indicate that the counters have failed to open because they had already been used in the current process. I presume this is due to my .NET appdomain having been r...
[ { "answer_id": 687946, "author": "eglasius", "author_id": 66372, "author_profile": "https://Stackoverflow.com/users/66372", "pm_score": 0, "selected": false, "text": "<p>I am no expert with custom counters, but based on the info you provided, I think it is worth a shot considering the po...
2008/12/05
[ "https://Stackoverflow.com/questions/344018", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7450/" ]
I have an ASP.NET application which tracks statistics by creating and writing to custom performance counters. Occasionally, I see in the error logs that indicate that the counters have failed to open because they had already been used in the current process. I presume this is due to my .NET appdomain having been reset ...
IIRC, IIS will not make sure that your first AppDomain is closed before it starts the second, particularly when you are recyclying it manually or automatically. I believe that when a recycle is initiated, the second AppDomain is instantiated first, and once that succeeds, new incoming requests are directed towards it, ...
344,034
<p>I've got a file filled with records like this:</p> <pre><code>NCNSCF1124557200811UPPY19871230 </code></pre> <p>The codes are all fixed-length, and some of them link to other flat files (sort of like a relational database). What's the best way of querying this data using LINQ?</p> <p>This is what I came up with i...
[ { "answer_id": 344048, "author": "James Curran", "author_id": 12725, "author_profile": "https://Stackoverflow.com/users/12725", "pm_score": 0, "selected": false, "text": "<p>I don't think there's a better way out of the box.</p>\n\n<p>One could define a Flat-File Linq Provider which coul...
2008/12/05
[ "https://Stackoverflow.com/questions/344034", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9825/" ]
I've got a file filled with records like this: ``` NCNSCF1124557200811UPPY19871230 ``` The codes are all fixed-length, and some of them link to other flat files (sort of like a relational database). What's the best way of querying this data using LINQ? This is what I came up with intuitively, but I was wondering if...
For one thing I wouldn't read it all into memory to start with. It's very easy to write a LineReader class which iterates over a file a line at a time. I've got a version in [MiscUtil](http://pobox.com/~skeet/csharp/miscutil) which you can use. Unless you only want to read the results once, however, you might want to ...
344,047
<p>I want to get at the item that is being data bound, during the ItemDataBound event of an asp:repeater.</p> <p>I tried the following (which was an unaccepted answer in a <a href="https://stackoverflow.com/questions/284420/datagridview-bindinghow-to-color-line-depending-of-the-object-binded#284470">stackoverflow ques...
[ { "answer_id": 344073, "author": "Programmin Tool", "author_id": 21691, "author_profile": "https://Stackoverflow.com/users/21691", "pm_score": 5, "selected": true, "text": "<p>Right off the bat I would have to guess you need this:</p>\n\n<pre><code>if (e.Item.ItemType == ListItemType.Ite...
2008/12/05
[ "https://Stackoverflow.com/questions/344047", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12597/" ]
I want to get at the item that is being data bound, during the ItemDataBound event of an asp:repeater. I tried the following (which was an unaccepted answer in a [stackoverflow question](https://stackoverflow.com/questions/284420/datagridview-bindinghow-to-color-line-depending-of-the-object-binded#284470)): ``` prote...
Right off the bat I would have to guess you need this: ``` if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { //Put stuff here } ``` After all, the item itself could be representing a header or footer row.
344,056
<p>According to <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.process.startinfo(VS.80).aspx" rel="nofollow noreferrer">MSDN</a>:</p> <blockquote> <p>If you did not use the <code>Start</code> method to start a process, the <code>StartInfo</code> property does not reflect the parameters used to star...
[ { "answer_id": 344071, "author": "leppie", "author_id": 15541, "author_profile": "https://Stackoverflow.com/users/15541", "pm_score": 2, "selected": false, "text": "<p>You are getting a different Process instance back from GetProcessesByName that falls into the latter case of the stateme...
2008/12/05
[ "https://Stackoverflow.com/questions/344056", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12842/" ]
According to [MSDN](http://msdn.microsoft.com/en-us/library/system.diagnostics.process.startinfo(VS.80).aspx): > > If you did not use the `Start` method to start a process, the `StartInfo` property does not reflect the parameters used to start the process. For example, if you use `GetProcesses` to get an array of pro...
You are still doing a GetProcess, thus it continues to work the same. The fact that you started it doesn't make a difference. Process.Start(...) returns the process that you started. I expect that if you check the StartInfo property on that, it will be populated.
344,068
<p>I have a table like so:</p> <pre><code>keyA keyB data </code></pre> <p>keyA and keyB together are unique, are the primary key of my table and make up a clustered index.</p> <p>There are 5 possible values of keyB but an unlimited number of possible values of keyA,. keyB generally increments.</p> <p>For example, t...
[ { "answer_id": 344088, "author": "Davide Vosti", "author_id": 1812, "author_profile": "https://Stackoverflow.com/users/1812", "pm_score": 0, "selected": false, "text": "<p>The best thing you can do is to try both solutions and measure the execution time.</p>\n\n<p>In my experience, index...
2008/12/05
[ "https://Stackoverflow.com/questions/344068", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34632/" ]
I have a table like so: ``` keyA keyB data ``` keyA and keyB together are unique, are the primary key of my table and make up a clustered index. There are 5 possible values of keyB but an unlimited number of possible values of keyA,. keyB generally increments. For example, the following data can be ordered in 2 wa...
You should order your composite clustered index with the most selective column first. This means the column with the most distinct values compared to total row count. "B\*TREE Indexes improve the performance of queries that select a small percentage of rows from a table." <http://www.akadia.com/services/ora_index_sele...
344,072
<p>I have a table with a large amount of information, how do i select just the last months worth? (ie just the last 31 cells in the column?)</p> <p>The data is in the form</p> <pre><code>date1 numbers date2 numbers . . . . . . daten numbers </code></pre> <p>where...
[ { "answer_id": 344123, "author": "CestLaGalere", "author_id": 6684, "author_profile": "https://Stackoverflow.com/users/6684", "pm_score": 1, "selected": false, "text": "<p>use</p>\n\n<pre><code>LastRow = Sheet.Cells.SpecialCells(Excel.XlCellType.xlCellTypeLastCell).Row\n</code></pre>\n\n...
2008/12/05
[ "https://Stackoverflow.com/questions/344072", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a table with a large amount of information, how do i select just the last months worth? (ie just the last 31 cells in the column?) The data is in the form ``` date1 numbers date2 numbers . . . . . . daten numbers ``` where date1 is dd/mm/ccyy cheers
Ideally there would be a column that has the date in it. Then you could do an advanced filter to filter on the date range that you require. Selecting the last 31 days will not always select just one month. It may select up to 3 days from the previous month as well. --- ``` Public Sub selectLastMonth() Dim ws As Wor...
344,078
<p>I've been evaluating ActiveMQ as a candidate message broker. I've written some test code to try and get an understanding of ActiveMQ's performance limitations. </p> <p>I can produce a failure state in the broker by sending messages as fast as possible like this:</p> <pre><code>try { while(true) { byte...
[ { "answer_id": 344097, "author": "Chris Kimpton", "author_id": 48310, "author_profile": "https://Stackoverflow.com/users/48310", "pm_score": 0, "selected": false, "text": "<p>Not sure about ActiveMQ config, but other JMS providers have various configuration options - so you maybe able to...
2008/12/05
[ "https://Stackoverflow.com/questions/344078", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5814/" ]
I've been evaluating ActiveMQ as a candidate message broker. I've written some test code to try and get an understanding of ActiveMQ's performance limitations. I can produce a failure state in the broker by sending messages as fast as possible like this: ``` try { while(true) { byte[] payload = new byte[...
You are testing the ['slow consumer' and producer flowcontrol](http://activemq.apache.org/producer-flow-control.html) issue all message brokers have to deal with. Do you wanna fail producers, block them or spool to disk? Basically the out of the box default in ActiveMQ is to block producers. But you can [configure me...
344,092
<p>I work for a large website. Our marketing department asks us to add ever more web ad tracking pixels to our pages. I have no problem with tracking the effectiveness of ad campaigns, but the servers serving those pixels can be unreliable. I'm sure most of you have seen web pages that refuse to finish loading because ...
[ { "answer_id": 344118, "author": "Stevo", "author_id": 1937, "author_profile": "https://Stackoverflow.com/users/1937", "pm_score": 4, "selected": true, "text": "<p>jQuery and other JavaScript frameworks can help handle the problem by using a method such as the\" document ready\" function...
2008/12/05
[ "https://Stackoverflow.com/questions/344092", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43670/" ]
I work for a large website. Our marketing department asks us to add ever more web ad tracking pixels to our pages. I have no problem with tracking the effectiveness of ad campaigns, but the servers serving those pixels can be unreliable. I'm sure most of you have seen web pages that refuse to finish loading because a p...
jQuery and other JavaScript frameworks can help handle the problem by using a method such as the" document ready" function, which fire when the document is ready and don't need to wait for all the images. I'll quote direct from the jQuery tutorial: > > The first thing that most Javascript programmers end up doing is...
344,095
<p>Is that possible to have a single PHP SOAP server which will handle requests to several classes (services)?</p> <p>If yes, could you please show an example implementation?</p> <p>If not, could you please describe why?</p>
[ { "answer_id": 344192, "author": "Keith Palmer Jr.", "author_id": 26133, "author_profile": "https://Stackoverflow.com/users/26133", "pm_score": 3, "selected": true, "text": "<p>Could you wrap the other services in a single class? Completely untested, it was just a thought... </p>\n\n<pre...
2008/12/05
[ "https://Stackoverflow.com/questions/344095", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43668/" ]
Is that possible to have a single PHP SOAP server which will handle requests to several classes (services)? If yes, could you please show an example implementation? If not, could you please describe why?
Could you wrap the other services in a single class? Completely untested, it was just a thought... ``` class MySoapService { public function __construct() { $this->_service1 = new Service1(); $this->_service2 = new Service2(); } // You could probably use __call() here and intercept any calls, /...
344,098
<p>Consider the following table:</p> <pre><code>mysql&gt; select * from phone_numbers; +-------------+------+-----------+ | number | type | person_id | +-------------+------+-----------+ | 17182225465 | home | 1 | | 19172225465 | cell | 1 | | 12129876543 | home | 2 | | 13049876543 | cell |...
[ { "answer_id": 344121, "author": "Powerlord", "author_id": 15880, "author_profile": "https://Stackoverflow.com/users/15880", "pm_score": -1, "selected": false, "text": "<p>I don't know if this will fix things or not, but...</p>\n\n<p>The statements starting with \"and\" should be part of...
2008/12/05
[ "https://Stackoverflow.com/questions/344098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1094969/" ]
Consider the following table: ``` mysql> select * from phone_numbers; +-------------+------+-----------+ | number | type | person_id | +-------------+------+-----------+ | 17182225465 | home | 1 | | 19172225465 | cell | 1 | | 12129876543 | home | 2 | | 13049876543 | cell | 2 | | 15...
In the second SQL, the condition h.type = 'home' is part of the outer join conditions, and is not a filter on the results. For all records where h.type='cell', the condition h.type = 'home' is FALSE and so no "matching" c row is found - so c.number is null, which is your only filtering (WHERE) condition. In pseudo-cod...
344,101
<p>Wish to simultaneously call a function multiple times. I wish to use threads to call a function which will utilize the machines capability to the fullest. This is a 8 core machine, and my requirement is to use the machine cpu from 10% to 100% or more. </p> <p>My requirement is to use the boost class. Is there any ...
[ { "answer_id": 344160, "author": "Patrick", "author_id": 38892, "author_profile": "https://Stackoverflow.com/users/38892", "pm_score": 2, "selected": false, "text": "<p>If your interest is in using your processor effeciently then you might want to consider intels thread building blocks <...
2008/12/05
[ "https://Stackoverflow.com/questions/344101", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35416/" ]
Wish to simultaneously call a function multiple times. I wish to use threads to call a function which will utilize the machines capability to the fullest. This is a 8 core machine, and my requirement is to use the machine cpu from 10% to 100% or more. My requirement is to use the boost class. Is there any way I can a...
I suggest that you read up on the documentation for the functions you use. From your comment in James Hopkin's answer, it seems like you don't know what boost::bind does, but simply copy-pasted the code. boost::bind takes a function (call it f), and optionally a number of parameters, and returns a function which, when...
344,104
<p>I was wondering which was better:</p> <pre><code>$lookup = array( "a" =&gt; 1, "b" =&gt; 2, "c" =&gt; 3 ); return $lookup[$key]; </code></pre> <p>or</p> <pre><code>if ( $key == "a" ) return 1 else if ( $key == "b" ) return 2 else if ( $key == "c" ) return 3 </code></pre> <p>or maybe just a nice switch...</p> <p...
[ { "answer_id": 344116, "author": "joegtp", "author_id": 39431, "author_profile": "https://Stackoverflow.com/users/39431", "pm_score": 2, "selected": false, "text": "<p>There will be a tipping point you will just have to test to find it. My guess is with 3 items you are better off with if...
2008/12/05
[ "https://Stackoverflow.com/questions/344104", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24525/" ]
I was wondering which was better: ``` $lookup = array( "a" => 1, "b" => 2, "c" => 3 ); return $lookup[$key]; ``` or ``` if ( $key == "a" ) return 1 else if ( $key == "b" ) return 2 else if ( $key == "c" ) return 3 ``` or maybe just a nice switch... ``` switch($key){ case "a": return 1; case "b": return 2; case "...
For anything with measurable performance (not only 3 entries) lookup is fastest way. That's what hash tables are for.
344,117
<p>Is there any way to get a String[] with the roles a user has in the JSP or Servlet?</p> <p>I know about request.isUserInRole("role1") but I also want to know all the roles of the user.</p> <p>I searched the servlet source and it seems this is not possible, but this seems odd to me.</p> <p>So... any ideas?</p>
[ { "answer_id": 344153, "author": "Steve McLeod", "author_id": 2959, "author_profile": "https://Stackoverflow.com/users/2959", "pm_score": 4, "selected": false, "text": "<p>The answer is messy.</p>\n\n<p>First you need to find out what type request.getUserPrincipal() returns in your webap...
2008/12/05
[ "https://Stackoverflow.com/questions/344117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43671/" ]
Is there any way to get a String[] with the roles a user has in the JSP or Servlet? I know about request.isUserInRole("role1") but I also want to know all the roles of the user. I searched the servlet source and it seems this is not possible, but this seems odd to me. So... any ideas?
Read in all the possible roles, or hardcode a list. Then iterate over it running the isUserInRole and build a list of roles the user is in and then convert the list to an array. ``` String[] allRoles = {"1","2","3"}; HttpServletRequest request = ... (or from method argument) List userRoles = new ArrayList(allRoles.len...
344,128
<p>I'm pulling back a Date and a Time from a database. They are stored in separate fields, but I would like to combine them into a java.util.Date object that reflects the date/time appropriately.</p> <p>Here is my original approach, but it is flawed. I always end up with a Date/Time that is 6 hours off what it should ...
[ { "answer_id": 344165, "author": "Paul Tomblin", "author_id": 3333, "author_profile": "https://Stackoverflow.com/users/3333", "pm_score": 4, "selected": true, "text": "<p>I would put both the Date and the Time into Calendar objects, and then use the various Calendar methods to extract th...
2008/12/05
[ "https://Stackoverflow.com/questions/344128", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1310/" ]
I'm pulling back a Date and a Time from a database. They are stored in separate fields, but I would like to combine them into a java.util.Date object that reflects the date/time appropriately. Here is my original approach, but it is flawed. I always end up with a Date/Time that is 6 hours off what it should be. I thin...
I would put both the Date and the Time into Calendar objects, and then use the various Calendar methods to extract the time values from the second object and put them into the first. ``` Calendar dCal = Calendar.getInstance(); dCal.setTime(date); Calendar tCal = Calendar.getInstance(); tCal.setTime(time); dC...
344,161
<p>Using WMI VB scripting, I would like to create/attach multiple child processes to a parent process, such as the explorer process.</p> <p>When an app is started by clicking on it, it becomes a child process of the explorer process. The same is true for all apps that are loaded when Windows starts up.</p> <p>If you ...
[ { "answer_id": 18647191, "author": "josh poley", "author_id": 858968, "author_profile": "https://Stackoverflow.com/users/858968", "pm_score": 1, "selected": false, "text": "<p>A window's process keeps track of the Process ID of who created it, this is how the relationships are being mana...
2008/12/05
[ "https://Stackoverflow.com/questions/344161", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43244/" ]
Using WMI VB scripting, I would like to create/attach multiple child processes to a parent process, such as the explorer process. When an app is started by clicking on it, it becomes a child process of the explorer process. The same is true for all apps that are loaded when Windows starts up. If you kill the explorer...
A window's process keeps track of the Process ID of who created it, this is how the relationships are being managed. To get what you want, you either have to change the parent PID stored in the child process, or inject code into the process you want to be the parent and have it create the new child process. Neither of ...
344,162
<p>I have a bunch of old classic ASP pages, many of which show database data in tables. None of the pages have any sorting functionality built in: you are at the mercy of whatever ORDER BY clause the original developer saw fit to use.</p> <p>I'm working on a quick fix to tack on sorting via client-side javascript. I...
[ { "answer_id": 344176, "author": "Josh", "author_id": 2204759, "author_profile": "https://Stackoverflow.com/users/2204759", "pm_score": 0, "selected": false, "text": "<p>Don't set the style object itself, set the background color property of the style object that is a property of the ele...
2008/12/05
[ "https://Stackoverflow.com/questions/344162", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3043/" ]
I have a bunch of old classic ASP pages, many of which show database data in tables. None of the pages have any sorting functionality built in: you are at the mercy of whatever ORDER BY clause the original developer saw fit to use. I'm working on a quick fix to tack on sorting via client-side javascript. I have a scri...
You can try grabbing the `cssText` and `className`. ``` var css1 = table.rows[1].style.cssText; var css2 = table.rows[2].style.cssText; var class1 = table.rows[1].className; var class2 = table.rows[2].className; // sort // loop if (i%2==0) { table.rows[i].style.cssText = css1; table.rows[i].class...
344,168
<p>I have a page that allows users to enter a lot of information about them (metadata) they can then click on a icon which opens a modal window containing a googlemap which allows them to add locations, and a title for that location.</p> <p>Using mootools I can pass the value of a form field back to the original form,...
[ { "answer_id": 344408, "author": "Elocution Safari", "author_id": 43670, "author_profile": "https://Stackoverflow.com/users/43670", "pm_score": 3, "selected": true, "text": "<p>I would suggest that you use an object to maintain all of the location data while the user is making their sele...
2008/12/05
[ "https://Stackoverflow.com/questions/344168", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28241/" ]
I have a page that allows users to enter a lot of information about them (metadata) they can then click on a icon which opens a modal window containing a googlemap which allows them to add locations, and a title for that location. Using mootools I can pass the value of a form field back to the original form, using onc...
I would suggest that you use an object to maintain all of the location data while the user is making their selections. When, when the form is submitted, serialize that data into a hidden field as a JSON object. So, when the user clicks in the map window, you record the info in the object, in addition to the table. The...
344,171
<p>As we know that, with compute function of datatable we can get sum of columns. But I want to get sum of a row of datatable. I will explain with a example:</p> <p>I have a datatable like image below: With compute function we can get the sum of each column (product). Such as for product1, 2 + 12 + 50 + 13= 77.</p> ...
[ { "answer_id": 344215, "author": "Galwegian", "author_id": 3201, "author_profile": "https://Stackoverflow.com/users/3201", "pm_score": 2, "selected": false, "text": "<p>From <a href=\"http://msdn.microsoft.com/en-us/library/system.data.datatable.compute.aspx\" rel=\"nofollow noreferrer\"...
2008/12/05
[ "https://Stackoverflow.com/questions/344171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/439507/" ]
As we know that, with compute function of datatable we can get sum of columns. But I want to get sum of a row of datatable. I will explain with a example: I have a datatable like image below: With compute function we can get the sum of each column (product). Such as for product1, 2 + 12 + 50 + 13= 77. I want to get ...
**LINQ to the rescue:** ``` DataTable dt = WhateverCreatesDataTable(); DataRow dr = dt.Rows[0]; int sum = dt.Columns.Cast<DataColumn>().Sum(dc=>(int)dr[dc]); ``` For those still dragging their knuckles in the stone ages (aka pre-.Net 3.5 and LINQ): ``` DataTable dt = WhateverCreatesDataTable(); DataRow dr = dt.Rows...
344,199
<p>I know how to do a regular php mysql search and display the results. However, because of the nature of what I'm trying to accomplish I need to be able to sort by relevancy. Let me explain this better:</p> <p>Normal Query "apple iphone applications" will search the database using %apple iphone application%, but if t...
[ { "answer_id": 344213, "author": "Filip Ekberg", "author_id": 39106, "author_profile": "https://Stackoverflow.com/users/39106", "pm_score": 3, "selected": false, "text": "<p>A quick google gave me <a href=\"http://www.mysqlperformanceblog.com/?s=select%20match%20against%20as%20relevance\...
2008/12/05
[ "https://Stackoverflow.com/questions/344199", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26823/" ]
I know how to do a regular php mysql search and display the results. However, because of the nature of what I'm trying to accomplish I need to be able to sort by relevancy. Let me explain this better: Normal Query "apple iphone applications" will search the database using %apple iphone application%, but if there aren'...
take a look at the [MySQL FULLTEXT search functions](http://dev.mysql.com/doc/refman/5.1/en/fulltext-search.html), These should automatically return results by relevancy, and give you much more control over your searches The only potential issue with using fulltext indexes is that they aren't supported by InnoDB tabl...
344,203
<p>What is the maximum number of threads that can be created by a process under Linux?</p> <p>How (if possible) can this value be modified?</p>
[ { "answer_id": 344264, "author": "Vincent Van Den Berghe", "author_id": 39259, "author_profile": "https://Stackoverflow.com/users/39259", "pm_score": 4, "selected": false, "text": "<p>To retrieve it:</p>\n<pre><code>cat /proc/sys/kernel/threads-max\n</code></pre>\n<p>To set it:</p>\n<pre...
2008/12/05
[ "https://Stackoverflow.com/questions/344203", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
What is the maximum number of threads that can be created by a process under Linux? How (if possible) can this value be modified?
Linux doesn't have a separate threads per process limit, just a limit on the total number of processes on the system (threads are essentially just processes with a shared address space on Linux) which you can view like this: ``` cat /proc/sys/kernel/threads-max ``` The default is the number of memory pages/4. You ca...
344,212
<p>Ok I need to change the value of a hidden field in a gridview and here is what I have so far:</p> <pre><code>for(var i = 0; i &lt; gv_Proofs.rows.length; i++) { var tbl_Cell = gv_Proofs.rows[i].cells[0]; var sdiFound = false; for(var x = 0; x &lt; tbl_Cell.childNodes.length; x++) { if(tbl_C...
[ { "answer_id": 344259, "author": "annakata", "author_id": 13018, "author_profile": "https://Stackoverflow.com/users/13018", "pm_score": 0, "selected": false, "text": "<p><strong>Edit: classic case of check before you post. <a href=\"http://www.beansoftware.com/ASP.NET-Tutorials/GridView-...
2008/12/05
[ "https://Stackoverflow.com/questions/344212", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2486/" ]
Ok I need to change the value of a hidden field in a gridview and here is what I have so far: ``` for(var i = 0; i < gv_Proofs.rows.length; i++) { var tbl_Cell = gv_Proofs.rows[i].cells[0]; var sdiFound = false; for(var x = 0; x < tbl_Cell.childNodes.length; x++) { if(tbl_Cell.childNodes[x].id...
I got it working. The above loop was working just right but apparently my value of sdi was not always getting set right, and therefore the value I was checking was always set to false. So the above worked perfectly in my case if anyone ever has this issue again.
344,236
<p>I have yet another managed C++ KeyValuePair question where I know what to do in C#, but am having a hard time translating to managed C++. Here is the code that does what I want to do in C#:</p> <pre><code>KeyValuePair&lt;String, String&gt; KVP = new KeyValuePair&lt;string, string&gt;("this", "that"); </code></pre> ...
[ { "answer_id": 344331, "author": "Excel Kobayashi", "author_id": 42911, "author_profile": "https://Stackoverflow.com/users/42911", "pm_score": 3, "selected": true, "text": "<p>This should do it:</p>\n\n<p><code>KeyValuePair&lt; String ^, String ^> k(gcnew String(\"Foo\"), gcnew String(\"...
2008/12/05
[ "https://Stackoverflow.com/questions/344236", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2831/" ]
I have yet another managed C++ KeyValuePair question where I know what to do in C#, but am having a hard time translating to managed C++. Here is the code that does what I want to do in C#: ``` KeyValuePair<String, String> KVP = new KeyValuePair<string, string>("this", "that"); ``` I've reflected it into MC++ and ge...
This should do it: `KeyValuePair< String ^, String ^> k(gcnew String("Foo"), gcnew String("Bar"));` KeyValuePair is an immutable type, so you have to pass everything to the constructor, which looks the same as in C#, except you write it like this if the object is on the stack.
344,263
<p>I want to pass the params collection from the controller to the model to parse filtering and sorting conditions. Does having a method in the model that takes the params from the controller break MVC?</p>
[ { "answer_id": 344414, "author": "Jamie", "author_id": 24559, "author_profile": "https://Stackoverflow.com/users/24559", "pm_score": 0, "selected": false, "text": "<p>I don't believe it does, but then again I am not a rails veteran by any means. Typically, the params hash is used in the ...
2008/12/05
[ "https://Stackoverflow.com/questions/344263", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to pass the params collection from the controller to the model to parse filtering and sorting conditions. Does having a method in the model that takes the params from the controller break MVC?
It depends. You are passing a hash of data to the model and saying "make sense of this". ``` class Model < ActiveRecord::Base def update_from_params(params) .... end end class ModelsController < ActionController::Base def update ... @model.update_from_params(params) end end ``` This is OK. But y...
344,315
<p>I am trying to test a class that manages data access in the database (you know, CRUD, essentially). The DB library we're using happens to have an API wherein you first get the table object by a static call:</p> <pre><code>function getFoo($id) { $MyTableRepresentation = DB_DataObject::factory("mytable"); $MyTabl...
[ { "answer_id": 344452, "author": "Ciaran McNulty", "author_id": 34024, "author_profile": "https://Stackoverflow.com/users/34024", "pm_score": 1, "selected": false, "text": "<p>This is a good example of a dependency in your code - the design has made it impossible to inject in a Mock rath...
2008/12/05
[ "https://Stackoverflow.com/questions/344315", "https://Stackoverflow.com", "https://Stackoverflow.com/users/577/" ]
I am trying to test a class that manages data access in the database (you know, CRUD, essentially). The DB library we're using happens to have an API wherein you first get the table object by a static call: ``` function getFoo($id) { $MyTableRepresentation = DB_DataObject::factory("mytable"); $MyTableRepresentatio...
I agree with both of you that it would be better not to use a static call. However, I guess I forgot to mention that DB\_DataObject is a third party library, and the static call is *their* best practice for their code usage, not ours. There are other ways to use their objects that involve constructing the returned obje...
344,317
<p>On a Unix system, where does gcc look for header files?</p> <p>I spent a little time this morning looking for some system header files, so I thought this would be good information to have here.</p>
[ { "answer_id": 344321, "author": "Bill the Lizard", "author_id": 1288, "author_profile": "https://Stackoverflow.com/users/1288", "pm_score": 4, "selected": false, "text": "<p>The <a href=\"http://gcc.gnu.org/onlinedocs/gcc-4.3.2/cpp/\" rel=\"nofollow noreferrer\">CPP Section</a> of the <...
2008/12/05
[ "https://Stackoverflow.com/questions/344317", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1288/" ]
On a Unix system, where does gcc look for header files? I spent a little time this morning looking for some system header files, so I thought this would be good information to have here.
``` `gcc -print-prog-name=cc1plus` -v ``` This command asks gcc which **C++** preprocessor it is using, and then asks that preprocessor where it looks for includes. You will get a reliable answer for your specific setup. Likewise, for the **C** preprocessor: ``` `gcc -print-prog-name=cpp` -v ```
344,320
<p>I'm tyring to convert a MSVC project from VS 2005 to VS 2008. It contains a IDL file that outputs a header and stubs used for RPC. The VS 2005 project uses MIDL.exe version 6.00.0366. The VS 2008 project uses MIDL.exe version 7.00.0500.</p> <p>Here's the problem: MIDL v6 outputs the following prototype for me to ...
[ { "answer_id": 344515, "author": "Charles", "author_id": 24898, "author_profile": "https://Stackoverflow.com/users/24898", "pm_score": 2, "selected": true, "text": "<p>Looks like I can answer my own question...</p>\n\n<p>MIDL v6 appears to automatically default the handle type to auto_ha...
2008/12/05
[ "https://Stackoverflow.com/questions/344320", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24898/" ]
I'm tyring to convert a MSVC project from VS 2005 to VS 2008. It contains a IDL file that outputs a header and stubs used for RPC. The VS 2005 project uses MIDL.exe version 6.00.0366. The VS 2008 project uses MIDL.exe version 7.00.0500. Here's the problem: MIDL v6 outputs the following prototype for me to implement in...
Looks like I can answer my own question... MIDL v6 appears to automatically default the handle type to auto\_handle for the server prototypes. MIDL v7 does not, so the solution is to use a Server.acl file with the auto\_handle setting in it. This outputs a Server.h file with function prototypes that is the same betwee...
344,327
<p>I am doing some simple sanity validation on various types. The current test I'm working on is checking to make sure their properties are populated. In this case, populated is defined as not null, having a length greater than zero (if a string), or not equal to 0 (if an integer).</p> <p>The "tricky" part of this tes...
[ { "answer_id": 344340, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": true, "text": "<p>Make a HashSet \"exactNames\" with PropertyOne, PropertyTwo etc, and then a List \"partialNames\" with ValueOne, Value...
2008/12/05
[ "https://Stackoverflow.com/questions/344327", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43699/" ]
I am doing some simple sanity validation on various types. The current test I'm working on is checking to make sure their properties are populated. In this case, populated is defined as not null, having a length greater than zero (if a string), or not equal to 0 (if an integer). The "tricky" part of this test is that ...
Make a HashSet "exactNames" with PropertyOne, PropertyTwo etc, and then a List "partialNames" with ValueOne, ValueTwo etc. Then: ``` var matchingProperties = pi.Where(exactNames.Contains(pi.Name) || partialNames.Any(name => pi.Name.Contains(name)); foreach (PropertyInfo property in matchingP...
344,343
<p>I'm looking for digital low pass filter code/library/class for a .net windows forms project, preferably written in c, c++ or c#. I probably need to set the number of poles, coefficients, windowing, that sort of thing. I can't use any of the gpl'd code that's available, and don't know what else is out there. Any sugg...
[ { "answer_id": 344362, "author": "Keith Sirmons", "author_id": 1048, "author_profile": "https://Stackoverflow.com/users/1048", "pm_score": 5, "selected": true, "text": "<p>Here is a Butterworth Low Pass filter I wrote for a recent project. </p>\n\n<p>It has some magic numbers as constan...
2008/12/05
[ "https://Stackoverflow.com/questions/344343", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28343/" ]
I'm looking for digital low pass filter code/library/class for a .net windows forms project, preferably written in c, c++ or c#. I probably need to set the number of poles, coefficients, windowing, that sort of thing. I can't use any of the gpl'd code that's available, and don't know what else is out there. Any suggest...
Here is a Butterworth Low Pass filter I wrote for a recent project. It has some magic numbers as constants that was given to me. If you can figure out how to create the magic numbers with your poles, coefficients, etc, then this might be helpful. ``` using System; using System.Collections.Generic; using System.Text;...
344,350
<p>There is a column in a database that is of type INT (Sql server).</p> <p>This int value is used at a bit flag, so I will be AND'ing and OR'ing on it.</p> <p>I have to pass a parameter into my sproc, and that parameter will represent a specific flag item.</p> <p><b>I would normally use an enumeration and pass the ...
[ { "answer_id": 344385, "author": "Victor", "author_id": 42518, "author_profile": "https://Stackoverflow.com/users/42518", "pm_score": 0, "selected": false, "text": "<p>Why not use the old 0 and 1 for the flag? It is widely accepted as a bit switch already and there would be no confusion ...
2008/12/05
[ "https://Stackoverflow.com/questions/344350", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39677/" ]
There is a column in a database that is of type INT (Sql server). This int value is used at a bit flag, so I will be AND'ing and OR'ing on it. I have to pass a parameter into my sproc, and that parameter will represent a specific flag item. **I would normally use an enumeration and pass the int representation to the...
You could use a string, and a CASE construct: ``` CREATE PROCEDURE BitBang(@Flag AS VARCHAR(50), @Id AS INT) AS BEGIN DECLARE @Bit INT SET @BIT = CASE @Flag WHEN 'approved' THEN 16 WHEN 'noapproved' THEN 16 WHEN 'fooflag' THEN 8 WHEN 'nofooflag' THEN 8 END IF @Bit IS NOT NULL BEGIN ...
344,363
<p>I have a base class that has a private static member:</p> <pre><code>class Base { private static Base m_instance = new Base(); public static Base Instance { get { return m_instance; } } } </code></pre> <p>And I want to derive multiple classes from this:</p> <pre><code>class DerivedA : Base...
[ { "answer_id": 344376, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 3, "selected": false, "text": "<p>Static methods does not support polymorphism, therefore, such a thing is not possible.</p>\n\n<p>Fundamentally, the Instanc...
2008/12/05
[ "https://Stackoverflow.com/questions/344363", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18202/" ]
I have a base class that has a private static member: ``` class Base { private static Base m_instance = new Base(); public static Base Instance { get { return m_instance; } } } ``` And I want to derive multiple classes from this: ``` class DerivedA : Base {} class DerivedB : Base {} class De...
There's one really icky way of doing this: ``` class Base { // Put common stuff in here... } class Base<T> : Base where T : Base<T>, new() { private static T m_instance = new T(); public static T Instance { get { return m_instance; } } } class DerivedA : Base<DerivedA> {} class DerivedB : Base<DerivedB...
344,372
<p>just now the dba let me connect to the database using Sql Server Management Studio, this is how i noticed that the default database for the tfs setup and service users is master, is this ok?, is this why I'm having this error?, Let me post part of the log and the properties of the Setup user to confirm that the use...
[ { "answer_id": 344376, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 3, "selected": false, "text": "<p>Static methods does not support polymorphism, therefore, such a thing is not possible.</p>\n\n<p>Fundamentally, the Instanc...
2008/12/05
[ "https://Stackoverflow.com/questions/344372", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15058/" ]
just now the dba let me connect to the database using Sql Server Management Studio, this is how i noticed that the default database for the tfs setup and service users is master, is this ok?, is this why I'm having this error?, Let me post part of the log and the properties of the Setup user to confirm that the users a...
There's one really icky way of doing this: ``` class Base { // Put common stuff in here... } class Base<T> : Base where T : Base<T>, new() { private static T m_instance = new T(); public static T Instance { get { return m_instance; } } } class DerivedA : Base<DerivedA> {} class DerivedB : Base<DerivedB...
344,380
<p>In <code>java.util.Calendar</code>, January is defined as month 0, not month 1. Is there any specific reason to that ?</p> <p>I have seen many people getting confused about that...</p>
[ { "answer_id": 344387, "author": "TheSmurf", "author_id": 1975282, "author_profile": "https://Stackoverflow.com/users/1975282", "pm_score": 4, "selected": false, "text": "<p>I'd say laziness. Arrays start at 0 (everyone knows that); the months of the year are an array, which leads me to ...
2008/12/05
[ "https://Stackoverflow.com/questions/344380", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11618/" ]
In `java.util.Calendar`, January is defined as month 0, not month 1. Is there any specific reason to that ? I have seen many people getting confused about that...
It's just part of the horrendous mess which is the Java date/time API. Listing what's wrong with it would take a very long time (and I'm sure I don't know half of the problems). Admittedly working with dates and times is tricky, but aaargh anyway. Do yourself a favour and use [Joda Time](http://joda-time.sourceforge.n...
344,419
<p>In HTML, I can find a file starting from the <strong>web server's</strong> root folder by beginning the filepath with &quot;/&quot;. Like:</p> <pre><code>/images/some_image.jpg </code></pre> <p>I can put that path in any file in any subdirectory, and it will point to the right image.</p> <p>With PHP, I tried somethi...
[ { "answer_id": 344445, "author": "Rob Prouse", "author_id": 30827, "author_profile": "https://Stackoverflow.com/users/30827", "pm_score": 7, "selected": true, "text": "<p>What I do is put a config.php file in my root directory. This file is included by all PHP files in my project. In tha...
2008/12/05
[ "https://Stackoverflow.com/questions/344419", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4376/" ]
In HTML, I can find a file starting from the **web server's** root folder by beginning the filepath with "/". Like: ``` /images/some_image.jpg ``` I can put that path in any file in any subdirectory, and it will point to the right image. With PHP, I tried something similar: ``` include("/includes/header.php"); ``...
What I do is put a config.php file in my root directory. This file is included by all PHP files in my project. In that config.php file, I then do the following; ``` define( 'ROOT_DIR', dirname(__FILE__) ); ``` Then in all files, I know what the root of my project is and can do stuff like this ``` require_once( ROOT...
344,428
<p>How do I access 'a' below?</p> <pre><code>var test = function () { return { 'a' : 1, 'b' : this.a + 1 //doesn't work }; }; </code></pre>
[ { "answer_id": 344453, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 3, "selected": false, "text": "<p>You can't do it this way. When you are in the process of constructing an object (that's what you actually do using the ...
2008/12/05
[ "https://Stackoverflow.com/questions/344428", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How do I access 'a' below? ``` var test = function () { return { 'a' : 1, 'b' : this.a + 1 //doesn't work }; }; ```
You can't do it this way. When you are in the process of constructing an object (that's what you actually do using the curly braces), there is no way to access it's properties before it is constructed. ``` var test = function () { var o = {}; o['a'] = 1; o['b'] = o['a'] + 1; return o; }; ```
344,440
<p>I have a general exception handler, Application_error in my global.asax where I'm trying to isolate all the uncaught exceptions on all my many pages. I don't want to use Page_error to catch exception because it's inefficient to call that on so many pages. So where in the exception can I find what page actually cause...
[ { "answer_id": 344463, "author": "jlew", "author_id": 7450, "author_profile": "https://Stackoverflow.com/users/7450", "pm_score": 6, "selected": true, "text": "<pre><code>HttpContext con = HttpContext.Current;\ncon.Request.Url.ToString()\n</code></pre>\n" }, { "answer_id": 347569...
2008/12/05
[ "https://Stackoverflow.com/questions/344440", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8456/" ]
I have a general exception handler, Application\_error in my global.asax where I'm trying to isolate all the uncaught exceptions on all my many pages. I don't want to use Page\_error to catch exception because it's inefficient to call that on so many pages. So where in the exception can I find what page actually caused...
``` HttpContext con = HttpContext.Current; con.Request.Url.ToString() ```
344,451
<p>I'm using jQuery in conjunction with the <a href="http://malsup.com/jquery/form/" rel="nofollow noreferrer">form plugin</a> and I'd like to intercept the form data before submission and make changes. </p> <p>The form plugin has a property called beforeSubmit that should do this, but I seem to be having trouble gett...
[ { "answer_id": 344918, "author": "Ariel", "author_id": 24654, "author_profile": "https://Stackoverflow.com/users/24654", "pm_score": 3, "selected": true, "text": "<p>I ran the following code through firebug and it appears to work as advertised, but the formData variable in the beforeSubm...
2008/12/05
[ "https://Stackoverflow.com/questions/344451", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1249/" ]
I'm using jQuery in conjunction with the [form plugin](http://malsup.com/jquery/form/) and I'd like to intercept the form data before submission and make changes. The form plugin has a property called beforeSubmit that should do this, but I seem to be having trouble getting the function I specify to run. Here's the ...
I ran the following code through firebug and it appears to work as advertised, but the formData variable in the beforeSubmit callback is empty because you didn't set the name attribute on the text boxes. ``` <script type="text/javascript"> $(document).ready(function() { var options = { beforeSubmit: showDa...
344,460
<p>I am trying to put the stuff within parentheses into the value of a src attribute in an img tag:</p> <pre><code>while(&lt;TOCFILE&gt;) { $toc_line = $_; $toc_line =~ s/&lt;inlineFig.*?(\.\.\/pics\/ch09_inline99_*?\.jpg)*?&lt;\/inlineFig&gt;/&lt;img src="${1}" alt="" \/\&gt;/g; $new_toc_file .= $toc_line...
[ { "answer_id": 344577, "author": "bart", "author_id": 19966, "author_profile": "https://Stackoverflow.com/users/19966", "pm_score": 4, "selected": false, "text": "<p>There's an error in your regex so that phrase will never match anything:</p>\n\n<pre><code>inline99_*?\\.jpg\n ^^^ ...
2008/12/05
[ "https://Stackoverflow.com/questions/344460", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am trying to put the stuff within parentheses into the value of a src attribute in an img tag: ``` while(<TOCFILE>) { $toc_line = $_; $toc_line =~ s/<inlineFig.*?(\.\.\/pics\/ch09_inline99_*?\.jpg)*?<\/inlineFig>/<img src="${1}" alt="" \/\>/g; $new_toc_file .= $toc_line; } ``` So I expected to see tags...
There's an error in your regex so that phrase will never match anything: ``` inline99_*?\.jpg ^^^ ``` I think you forgot `\d` in front of the star, judging by the example data you are trying to match. You're not even asking that it'll match, as you put a `*?` after the captured group. So, it just doesn't m...
344,478
<p>Can LINQ to SQL query using <strong>NOT IN</strong>? </p> <p>e.g., SELECT au_lname, state FROM authors WHERE state NOT IN ('CA', 'IN', 'MD')</p>
[ { "answer_id": 344498, "author": "Galwegian", "author_id": 3201, "author_profile": "https://Stackoverflow.com/users/3201", "pm_score": 3, "selected": false, "text": "<p>here's an example:</p>\n\n<pre><code>NorthwindDataContext dc = new NorthwindDataContext();\ndc.Log = Console.Out;\nvar ...
2008/12/05
[ "https://Stackoverflow.com/questions/344478", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1316/" ]
Can LINQ to SQL query using **NOT IN**? e.g., SELECT au\_lname, state FROM authors WHERE state NOT IN ('CA', 'IN', 'MD')
``` List<string> states = new List<string> { "CA", "IN", "MD" }; var q = from a in authors where !states.Contains(a.state) select new { a.au_lname, a.state }; ``` or ``` var q = authors.Where( a => !states.Contains( a.state ) ) .Select( a => new { a.au_lname, a.st...
344,479
<p>Is it possible to get the expiry <code>DateTime</code> of an <code>HttpRuntime.Cache</code> object?</p> <p>If so, what would be the best approach?</p>
[ { "answer_id": 350374, "author": "Tom Jelen", "author_id": 28399, "author_profile": "https://Stackoverflow.com/users/28399", "pm_score": 6, "selected": true, "text": "<p>I just went through the System.Web.Caching.Cache in reflector. It seems like everything that involves the expiry date ...
2008/12/05
[ "https://Stackoverflow.com/questions/344479", "https://Stackoverflow.com", "https://Stackoverflow.com/users/343/" ]
Is it possible to get the expiry `DateTime` of an `HttpRuntime.Cache` object? If so, what would be the best approach?
I just went through the System.Web.Caching.Cache in reflector. It seems like everything that involves the expiry date is marked as internal. The only place i found public access to it, was through the Cache.Add and Cache.Insert methods. So it looks like you are out of luck, unless you want to go through reflection, wh...
344,503
<pre><code>class MyBase { protected object PropertyOfBase { get; set; } } class MyType : MyBase { void MyMethod(MyBase parameter) { // I am looking for: object p = parameter.PropertyOfBase; // error CS1540: Cannot access protected member 'MyBase.PropertyOfBase' via a qualifier of type 'MyB...
[ { "answer_id": 344555, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 5, "selected": true, "text": "<p>No, you can't do this.</p>\n\n<p>You're only allowed to access protected members of objects of the accessing type (or ...
2008/12/05
[ "https://Stackoverflow.com/questions/344503", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31505/" ]
``` class MyBase { protected object PropertyOfBase { get; set; } } class MyType : MyBase { void MyMethod(MyBase parameter) { // I am looking for: object p = parameter.PropertyOfBase; // error CS1540: Cannot access protected member 'MyBase.PropertyOfBase' via a qualifier of type 'MyBase'; t...
No, you can't do this. You're only allowed to access protected members of objects of the accessing type (or derived from it). Here, we don't know whether the parameter is of type MyType or SomeOtherCompletelyDifferentType. EDIT: The relevant bit of the C# 3.0 spec is section 3.5.3: > > When a protected instance mem...
344,509
<p>Trying to get this example working from <a href="http://www.munna.shatkotha.com/blog/post/2008/10/26/Light-box-effect-with-WPF.aspx" rel="nofollow noreferrer">http://www.munna.shatkotha.com/blog/post/2008/10/26/Light-box-effect-with-WPF.aspx</a></p> <p>However, I can't seem to get the namespace or syntax right for ...
[ { "answer_id": 344610, "author": "John Z", "author_id": 43430, "author_profile": "https://Stackoverflow.com/users/43430", "pm_score": 2, "selected": false, "text": "<p>Looks like the person who wrote the blog forgot to define their custom delegate called Process (a bit of an odd name for...
2008/12/05
[ "https://Stackoverflow.com/questions/344509", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22451/" ]
Trying to get this example working from <http://www.munna.shatkotha.com/blog/post/2008/10/26/Light-box-effect-with-WPF.aspx> However, I can't seem to get the namespace or syntax right for "Process" below. ``` <Border x:Name="panelDialog" Visibility="Collapsed"> <Grid> <Border Background="Black" Opacity="0.49"></Borde...
Typos here: Process and ShowWaitScreenHandler needs to be changed to ShowWaitScreenUIHandler. DispatcherPriority needs a using. Right click on DispatcherPriority and select Resolve.
344,519
<p>I am trying to filter an IEnumerable object of the duplicate values, so I would like to get the distinct values from it, for example, lets say that it holds days:</p> <p>monday tuesday wednesday wednesday</p> <p>I would like to filter it and return:</p> <p>monday tuesday wednesday</p> <p>What is the most effici...
[ { "answer_id": 344536, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 3, "selected": true, "text": "<pre><code>Dictionary&lt;object, object&gt; list = new Dictionary&lt;object, object&gt;();\nforeach (object o in enumerable)\n ...
2008/12/05
[ "https://Stackoverflow.com/questions/344519", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7952/" ]
I am trying to filter an IEnumerable object of the duplicate values, so I would like to get the distinct values from it, for example, lets say that it holds days: monday tuesday wednesday wednesday I would like to filter it and return: monday tuesday wednesday What is the most efficient way to do this in .net 2.0?
``` Dictionary<object, object> list = new Dictionary<object, object>(); foreach (object o in enumerable) if (!list.ContainsKey(o)) { // Do the actual work. list[o] = null; } ``` Dictionary will use a hash table to hold keys therefore lookup is efficient. Sorting will be O(n log(n)) at bes...
344,533
<p>I'm struggling to understand Dependency Properties in Silverlight 2. Does anybody have a good explanation or link that clearly explains the DependencyObject and/or DependencyProperty?</p>
[ { "answer_id": 344536, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 3, "selected": true, "text": "<pre><code>Dictionary&lt;object, object&gt; list = new Dictionary&lt;object, object&gt;();\nforeach (object o in enumerable)\n ...
2008/12/05
[ "https://Stackoverflow.com/questions/344533", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1463/" ]
I'm struggling to understand Dependency Properties in Silverlight 2. Does anybody have a good explanation or link that clearly explains the DependencyObject and/or DependencyProperty?
``` Dictionary<object, object> list = new Dictionary<object, object>(); foreach (object o in enumerable) if (!list.ContainsKey(o)) { // Do the actual work. list[o] = null; } ``` Dictionary will use a hash table to hold keys therefore lookup is efficient. Sorting will be O(n log(n)) at bes...
344,557
<p>Why is garbage collection required for tail call optimization? Is it because if you allocate memory in a function which you then want to do a tail call on, there'd be no way to do the tail call and regain that memory? (So the stack would have to be saved so that, after the tail call, the memory could be reclaimed.)<...
[ { "answer_id": 344596, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 3, "selected": false, "text": "<p>Where did you hear that?</p>\n\n<p>Even C compilers without any kind of garbage collector are able to optimize tail recursi...
2008/12/05
[ "https://Stackoverflow.com/questions/344557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15055/" ]
Why is garbage collection required for tail call optimization? Is it because if you allocate memory in a function which you then want to do a tail call on, there'd be no way to do the tail call and regain that memory? (So the stack would have to be saved so that, after the tail call, the memory could be reclaimed.)
Like most myths, there may be a grain of truth to this one. While GC isn't *required* for tail call optimization, it certainly *helps* in a few cases. Let's say you have something like this in C++: ``` int foo(int arg) { // Base case. vector<double> bar(10); // Populate bar, do other stuff. return fo...
344,580
<p>I am trying to do a file upload from gwt-ext without bringing up the dialog box. To do this, I created a FormPanel and added the appropriate fields to it. Then did a form.submit(). This doesn't seem to work. Any idea why? The code is shown below.</p> <pre><code>final FormPanel uploadForm = new FormPanel(); uploadFo...
[ { "answer_id": 344576, "author": "Cade Roux", "author_id": 18255, "author_profile": "https://Stackoverflow.com/users/18255", "pm_score": 0, "selected": false, "text": "<p>When you are saying manage a data warehouse, what kind of tasks are you talking about?</p>\n\n<p>Much of the manageme...
2008/12/05
[ "https://Stackoverflow.com/questions/344580", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42551/" ]
I am trying to do a file upload from gwt-ext without bringing up the dialog box. To do this, I created a FormPanel and added the appropriate fields to it. Then did a form.submit(). This doesn't seem to work. Any idea why? The code is shown below. ``` final FormPanel uploadForm = new FormPanel(); uploadForm.setVisible(...
If you write your management functionality as PowerShell cmdlets, then you can surface that functionality either by letting people run cmdlets directly, or by wrapping them in a GUI. Going with PowerShell probably gives you the most long-term flexibility, and as MS implements more PowerShell cmdlets, it means that mana...
344,630
<p>I have an enumeration value marked with the following attribute. The second parameter instructs the compiler to error whenever the value is used. I want this behavior for anyone that implements my library, but I need to use this enumeration value within my library. How do I tell the compiler to ignore the Obsolet...
[ { "answer_id": 344635, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": true, "text": "<p>Private a separate constant somewhere like this:</p>\n\n<pre><code>private const Choices BackwardsCompatibleThree = (C...
2008/12/05
[ "https://Stackoverflow.com/questions/344630", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28736/" ]
I have an enumeration value marked with the following attribute. The second parameter instructs the compiler to error whenever the value is used. I want this behavior for anyone that implements my library, but I need to use this enumeration value within my library. How do I tell the compiler to ignore the Obsolete erro...
Private a separate constant somewhere like this: ``` private const Choices BackwardsCompatibleThree = (Choices) 3; ``` Note that anyone else will be able to do the same thing.
344,665
<p>I have a table like this:</p> <pre><code> Column | Type | Modifiers ---------+------+----------- country | text | food_id | int | eaten | date | </code></pre> <p>And for each country, I want to get the food that is eaten most often. The best I can think of (I'm using postgres) is:</p> <pre><code>CREAT...
[ { "answer_id": 344713, "author": "John MacIntyre", "author_id": 29043, "author_profile": "https://Stackoverflow.com/users/29043", "pm_score": 2, "selected": false, "text": "<p>Try something like this</p>\n\n<pre><code>select country, food_id, count(*) cnt \ninto #tempTbl \nfrom mytable \...
2008/12/05
[ "https://Stackoverflow.com/questions/344665", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34382/" ]
I have a table like this: ``` Column | Type | Modifiers ---------+------+----------- country | text | food_id | int | eaten | date | ``` And for each country, I want to get the food that is eaten most often. The best I can think of (I'm using postgres) is: ``` CREATE TEMP TABLE counts AS SELECT coun...
It is now even simpler: PostgreSQL 9.4 introduced the `mode()` function: ``` select mode() within group (order by food_id) from munch group by country ``` returns (like user2247323's example): ``` country | mode -------------- GB | 3 US | 1 ``` See documentation here: <https://wiki.postgresql.org/wiki/A...
344,672
<p>What is the algorithm for storing the pixels in a spiral in JS?</p>
[ { "answer_id": 344820, "author": "Mike Burton", "author_id": 22225, "author_profile": "https://Stackoverflow.com/users/22225", "pm_score": 2, "selected": false, "text": "<p>There are a couple of problems with this question. The first is that you're not really being specific about what y...
2008/12/05
[ "https://Stackoverflow.com/questions/344672", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18149/" ]
What is the algorithm for storing the pixels in a spiral in JS?
<http://www.mathematische-basteleien.de/spiral.htm> ``` var Spiral = function(a) { this.initialize(a); } Spiral.prototype = { _a: 0.5, constructor: Spiral, initialize: function( a ) { if (a != null) this._a = a; }, /* specify the increment in radians */ points: function( rotation...
344,697
<p>I have a site with the following robots.txt in the root:</p> <pre><code>User-agent: * Disabled: / User-agent: Googlebot Disabled: / User-agent: Googlebot-Image Disallow: / </code></pre> <p>And pages within this site are getting scanned by Googlebots all day long. Is there something wrong with my file or with G...
[ { "answer_id": 344700, "author": "Sean Carpenter", "author_id": 729, "author_profile": "https://Stackoverflow.com/users/729", "pm_score": 6, "selected": true, "text": "<p>It should be <code>Disallow:</code>, not <code>Disabled:</code>.</p>\n" }, { "answer_id": 344701, "author...
2008/12/05
[ "https://Stackoverflow.com/questions/344697", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29493/" ]
I have a site with the following robots.txt in the root: ``` User-agent: * Disabled: / User-agent: Googlebot Disabled: / User-agent: Googlebot-Image Disallow: / ``` And pages within this site are getting scanned by Googlebots all day long. Is there something wrong with my file or with Google?
It should be `Disallow:`, not `Disabled:`.
344,715
<p>I'm writing some code that id like to be able to work with any window, such as a window created through the windows API, MFC, wxWidgets, etc.</p> <p>The problem is that for some things I need to use the same thread that created the window, which in many cases is just sat in a message loop.</p> <p>My first thought ...
[ { "answer_id": 344738, "author": "John Z", "author_id": 43430, "author_profile": "https://Stackoverflow.com/users/43430", "pm_score": 3, "selected": true, "text": "<p>If you are in the same process as the window you can hook its messages by subclassing it. Check out <a href=\"http://msd...
2008/12/05
[ "https://Stackoverflow.com/questions/344715", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6266/" ]
I'm writing some code that id like to be able to work with any window, such as a window created through the windows API, MFC, wxWidgets, etc. The problem is that for some things I need to use the same thread that created the window, which in many cases is just sat in a message loop. My first thought was to post a cal...
If you are in the same process as the window you can hook its messages by subclassing it. Check out <http://msdn.microsoft.com/en-us/library/ms633570(VS.85).aspx> The key API is SetWindowLong. ``` // Subclass the edit control. wpOrigEditProc = (WNDPROC) SetWindowLong(hwndEdit, GWL_WNDPROC, (LONG)EditSubclassProc); ...
344,737
<p>I have a XML Structure that looks like this.</p> <pre><code>&lt;sales&gt; &lt;item name="Games" sku="MIC28306200" iCat="28" sTime="11/26/2008 8:41:12 AM" price="1.00" desc="Item Name" /&gt; &lt;item name="Games" sku="MIC28307100" iCat="28" sTime="11/26/2008 8:42:12 AM" price="1.00" desc=...
[ { "answer_id": 344764, "author": "jlew", "author_id": 7450, "author_profile": "https://Stackoverflow.com/users/7450", "pm_score": 3, "selected": true, "text": "<p>There's an overload of XPathExpression.Addsort which takes an IComparer interface. If you implement the comparison yourself ...
2008/12/05
[ "https://Stackoverflow.com/questions/344737", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30408/" ]
I have a XML Structure that looks like this. ``` <sales> <item name="Games" sku="MIC28306200" iCat="28" sTime="11/26/2008 8:41:12 AM" price="1.00" desc="Item Name" /> <item name="Games" sku="MIC28307100" iCat="28" sTime="11/26/2008 8:42:12 AM" price="1.00" desc="Item Name" /> ... </sales> ...
There's an overload of XPathExpression.Addsort which takes an IComparer interface. If you implement the comparison yourself as IComparer, you could use this mechanism. ``` class Program { static void Main(string[] args) { XPathDocument saleResults = new XPathDocument( @...
344,741
<p>I am looking to create an expression tree by parsing xml using C#. The xml would be like the following:</p> <pre><code>&lt;Expression&gt; &lt;If&gt; &lt;Condition&gt; &lt;GreaterThan&gt; &lt;X&gt; &lt;Y&gt; &lt;/GreaterThan&gt; &lt;/Condition&gt; &lt;Expression /&gt; &lt;If&gt; &lt;Else&gt...
[ { "answer_id": 344768, "author": "Will Dean", "author_id": 987, "author_profile": "https://Stackoverflow.com/users/987", "pm_score": 0, "selected": false, "text": "<p>I'd start by looking at the DLR, which has a published expression tree mechanism.</p>\n" }, { "answer_id": 344811...
2008/12/05
[ "https://Stackoverflow.com/questions/344741", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21586/" ]
I am looking to create an expression tree by parsing xml using C#. The xml would be like the following: ``` <Expression> <If> <Condition> <GreaterThan> <X> <Y> </GreaterThan> </Condition> <Expression /> <If> <Else> <Expression /> </Else> <Expression> ``` or another example... ``` <Expres...
``` using System.Linq.Expressions; //in System.Core.dll Expression BuildExpr(XmlNode xmlNode) { switch(xmlNode.Name) { case "Add": { return Expression.Add( BuildExpr(xmlNode.ChildNodes[0]) ,BuildExpr(xmlNode.ChilNodes[1])); } /* ... */ } } ```
344,744
<p>The DB load on my site is getting really high so it is time for me to cache common queries that are being called 1000s of times an hour where the results are not changing. So for instance on my city model I do the following: </p> <pre><code>def self.fetch(id) Rails.cache.fetch("city_#{id}") { City.find(id) } ...
[ { "answer_id": 344844, "author": "Bill", "author_id": 36285, "author_profile": "https://Stackoverflow.com/users/36285", "pm_score": -1, "selected": false, "text": "<p>Check out <a href=\"http://github.com/netshade/cached_model/tree/master\" rel=\"nofollow noreferrer\">cached_model</a></p...
2008/12/05
[ "https://Stackoverflow.com/questions/344744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43744/" ]
The DB load on my site is getting really high so it is time for me to cache common queries that are being called 1000s of times an hour where the results are not changing. So for instance on my city model I do the following: ``` def self.fetch(id) Rails.cache.fetch("city_#{id}") { City.find(id) } end def a...
With respect to the caching, a couple of minor points: It's worth using slash for separation of object type and id, which is rails convention. Even better, ActiveRecord models provide the cacke\_key instance method which will provide a unique identifier of table name and id, "cities/13" etc. One minor correction to y...
344,748
<p>I'm trying to do something like </p> <pre><code>URL clientks = com.messaging.SubscriptionManager.class.getResource( "client.ks" ); String path = clientks.toURI().getPath(); System.setProperty( "javax.net.ssl.keyStore", path); </code></pre> <p>Where client.ks is a file stored in com/messaging in the jar file that I...
[ { "answer_id": 344782, "author": "Jason Day", "author_id": 737, "author_profile": "https://Stackoverflow.com/users/737", "pm_score": 3, "selected": false, "text": "<p>You can get an <code>InputStream</code> to a resource in a jar file, but not a <code>File</code>. If the \"thing\" that ...
2008/12/05
[ "https://Stackoverflow.com/questions/344748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7949/" ]
I'm trying to do something like ``` URL clientks = com.messaging.SubscriptionManager.class.getResource( "client.ks" ); String path = clientks.toURI().getPath(); System.setProperty( "javax.net.ssl.keyStore", path); ``` Where client.ks is a file stored in com/messaging in the jar file that I'm running. The thing tha...
Still working on implementation, but I believe it is possible to load the keystore from the jar via InputStream and explicitly set the TrustStore programatically (vs setting the System properties). See the article: [Setting multiple truststore on the same JVM](https://stackoverflow.com/questions/7591281/setting-multipl...
344,777
<p>I'm trying to add two folders to my eclipse project's classpath, let's say Folder A and Folder B. B is inside A. Whenever I add A to the classpath</p> <pre><code>&lt;classpathentry kind="lib" path="/A"/&gt; </code></pre> <p>it works just fine, but I need to be able to access the files in B as well. Whenever I t...
[ { "answer_id": 344796, "author": "Uri", "author_id": 23072, "author_profile": "https://Stackoverflow.com/users/23072", "pm_score": 4, "selected": true, "text": "<p>I don't think you can (or should be) allowed to do that, and it's not really an Eclipse issue AFAIK</p>\n\n<p>Any individual...
2008/12/05
[ "https://Stackoverflow.com/questions/344777", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1459442/" ]
I'm trying to add two folders to my eclipse project's classpath, let's say Folder A and Folder B. B is inside A. Whenever I add A to the classpath ``` <classpathentry kind="lib" path="/A"/> ``` it works just fine, but I need to be able to access the files in B as well. Whenever I try to add ``` <classpathentry kind...
I don't think you can (or should be) allowed to do that, and it's not really an Eclipse issue AFAIK Any individual classpath is a root under which the JVM starts looking for classes using the standard package notation So let's say that your program has a class X in the default package, and a b.X class in the b packag...
344,784
<p>I have some library code which is used from my application and is also used by a .NET custom action in a Visual Studio installer project. The library code in turn uses the Enterprise Library logging block to do its logging. How can I get configuration information to the Enterprise Library in the context of my cust...
[ { "answer_id": 362029, "author": "w4g3n3r", "author_id": 36745, "author_profile": "https://Stackoverflow.com/users/36745", "pm_score": 0, "selected": false, "text": "<p>Not sure if this helps, but you can write to the msi log from within a custom action. (Sample VBScript below:)</p>\n\n<...
2008/12/05
[ "https://Stackoverflow.com/questions/344784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7450/" ]
I have some library code which is used from my application and is also used by a .NET custom action in a Visual Studio installer project. The library code in turn uses the Enterprise Library logging block to do its logging. How can I get configuration information to the Enterprise Library in the context of my custom ac...
There is no way to use the standard app.config way because that app.config is the msiexec.config you would need to edit prior to executing your MSI. My recommendation would be to have your own configuration loading method which reads from a custom XML or values in the MSI.
344,789
<p>I want to install PEAR on PHP 5, so I can use Spreadsheet_Excel_Writer.</p> <p>I don`t know how to install it on my ISP nor my personal MacBook.</p> <p>Thoughts for both?</p>
[ { "answer_id": 344830, "author": "jlleblanc", "author_id": 586, "author_profile": "https://Stackoverflow.com/users/586", "pm_score": 2, "selected": false, "text": "<p>From the command line, do this:</p>\n\n<pre><code>pear install Spreadsheet_Excel_Writer\n</code></pre>\n\n<p>You can also...
2008/12/05
[ "https://Stackoverflow.com/questions/344789", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to install PEAR on PHP 5, so I can use Spreadsheet\_Excel\_Writer. I don`t know how to install it on my ISP nor my personal MacBook. Thoughts for both?
From the command line, do this: ``` pear install Spreadsheet_Excel_Writer ``` You can also download the package directly here without using PEAR: <http://download.pear.php.net/package/Spreadsheet_Excel_Writer-0.9.1.tgz>. It's pretty easy to use if you have the script located anywhere within your include path.