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
544,088
<p>I have a line of code along the lines of:</p> <pre><code>print $somehash{$var}{fh} "foo"; </code></pre> <p>The hash contains the filehandle a few levels down. The error is:</p> <pre><code>String found where operator expected at test.pl line 10, near "} "foo"" </code></pre> <p>I can fix it by doing this:</p> <pr...
[ { "answer_id": 544117, "author": "j w", "author_id": 65819, "author_profile": "https://Stackoverflow.com/users/65819", "pm_score": 6, "selected": true, "text": "<p>see <a href=\"http://perldoc.perl.org/functions/print.html\" rel=\"nofollow noreferrer\">http://perldoc.perl.org/functions/p...
2009/02/12
[ "https://Stackoverflow.com/questions/544088", "https://Stackoverflow.com", "https://Stackoverflow.com/users/91385/" ]
I have a line of code along the lines of: ``` print $somehash{$var}{fh} "foo"; ``` The hash contains the filehandle a few levels down. The error is: ``` String found where operator expected at test.pl line 10, near "} "foo"" ``` I can fix it by doing this: ``` my $fh = $somehash{$var}{fh}; print $fh "foo"; ``` ...
see <http://perldoc.perl.org/functions/print.html> > > Note that if you're storing > FILEHANDLEs in an array, **or if you're > using any other expression more > complex than a scalar variable to > retrieve it**, you will have to use a > block returning the filehandle value > instead: ... > > > So, in your c...
544,094
<p>I have two tables: 'movies' and 'users'. There's an n:m relationship between those, describing what movies a user has seen. This is described with a table 'seen' Now i want to find out for a given user, all the movies he has not seen. My current solution is like this:</p> <pre><code>SELECT * FROM movies WHERE movi...
[ { "answer_id": 544118, "author": "dwc", "author_id": 57301, "author_profile": "https://Stackoverflow.com/users/57301", "pm_score": 2, "selected": false, "text": "<p>Not only does your query work, it's the right approach to the problem as stated. Perhaps you can find a different way to ap...
2009/02/12
[ "https://Stackoverflow.com/questions/544094", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65502/" ]
I have two tables: 'movies' and 'users'. There's an n:m relationship between those, describing what movies a user has seen. This is described with a table 'seen' Now i want to find out for a given user, all the movies he has not seen. My current solution is like this: ``` SELECT * FROM movies WHERE movies.id NOT IN (...
Here's a typical way to do this query without using the subquery method you showed. This may satisfy @Godeke's request to see a join-based solution. ``` SELECT * FROM movies m LEFT OUTER JOIN seen s ON (m.id = s.movie_id AND s.user_id = 123) WHERE s.movie_id IS NULL; ``` However, in most brands of database this s...
544,134
<p>How can you search all the Stored Procedures for a Pattern and then open the stored procedures to be edited?</p> <p>Is there anything built inside of SQL Server 2005? </p> <p>Or are there any 3rd party addins that will do this searching?</p> <p>I am also using Red Gate's SQL Prompt but I have not noticed that opt...
[ { "answer_id": 544191, "author": "Rob Boek", "author_id": 27179, "author_profile": "https://Stackoverflow.com/users/27179", "pm_score": 1, "selected": false, "text": "<p>Unfortunately, there is no feature in SQL Server 2005 other than querying, to find stored procedures based on their co...
2009/02/13
[ "https://Stackoverflow.com/questions/544134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4964/" ]
How can you search all the Stored Procedures for a Pattern and then open the stored procedures to be edited? Is there anything built inside of SQL Server 2005? Or are there any 3rd party addins that will do this searching? I am also using Red Gate's SQL Prompt but I have not noticed that option. Currently I am usi...
There is a open source stored procedure called sp\_grep that allows for you to find database objects based on the DDL/code of their makup. I use this procedure all the time to find objects that meet certain criteria. This is very useful in Database refactoring. To programmatically open and modify SQL objects you can u...
544,141
<p>I want to write a function like so,</p> <pre><code> public System.Windows.Input.Key ResolveKey(char charToResolve) { // Code goes here, that resolves the charToResolve // in to the Key enumerated value // (For example with '.' as the character for Key.OemPeriod) ...
[ { "answer_id": 544227, "author": "Joacim Andersson", "author_id": 25203, "author_profile": "https://Stackoverflow.com/users/25203", "pm_score": 3, "selected": false, "text": "<p>Try using the ConvertFrom method of the System.Windows.Input.KeyConverter class.</p>\n" }, { "answer_i...
2009/02/13
[ "https://Stackoverflow.com/questions/544141", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1747/" ]
I want to write a function like so, ``` public System.Windows.Input.Key ResolveKey(char charToResolve) { // Code goes here, that resolves the charToResolve // in to the Key enumerated value // (For example with '.' as the character for Key.OemPeriod) } ``` ...
``` [DllImport("user32.dll")] static extern short VkKeyScan(char ch); static public Key ResolveKey(char charToResolve) { return KeyInterop.KeyFromVirtualKey(VkKeyScan(charToResolve)); } ```
544,153
<p>I am working on transforming a xml file from old version to new version. Here is the basic template which i am using:</p> <pre><code>&lt;xsl:template match="*"&gt; &lt;xsl:element name="{name(.)}" namespace="{namespace-uri(.)}"&gt; &lt;xsl:copy-of select="@*"&gt;&lt;/xsl:copy-of&gt; &lt;xsl:apply-te...
[ { "answer_id": 544630, "author": "Dimitre Novatchev", "author_id": 36305, "author_profile": "https://Stackoverflow.com/users/36305", "pm_score": 2, "selected": false, "text": "<blockquote>\n <p>However, i found out if input looks\n like:</p>\n\n<pre><code>&lt;dataset&gt;\n &lt;title&g...
2009/02/13
[ "https://Stackoverflow.com/questions/544153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am working on transforming a xml file from old version to new version. Here is the basic template which i am using: ``` <xsl:template match="*"> <xsl:element name="{name(.)}" namespace="{namespace-uri(.)}"> <xsl:copy-of select="@*"></xsl:copy-of> <xsl:apply-templates></xsl:apply-templates> </xsl:...
> > However, i found out if input looks > like: > > > > ``` > <dataset> > <title>My tile</title> > </dataset> > > ``` > > the new text template will be called > > > **Yes, this is exactly what the provided code should be doing** -- I will explain this in a moment. > > If input looks like: > > > > ``` ...
544,182
<p>On the View: </p> <pre><code>&lt;% =Html.BeginForm("About", "Home", FormMethod.Post, new {enctype="multipart/form-data "})%&gt; &lt;input type="file" name="postedFile" /&gt; &lt;input type="submit" name="upload" value="Upload" /&gt; &lt;% Html.EndForm(); %&gt; </code></pre> <p>In the Controller, there's someth...
[ { "answer_id": 544264, "author": "Ben Robbins", "author_id": 1880, "author_profile": "https://Stackoverflow.com/users/1880", "pm_score": 3, "selected": false, "text": "<p>This doesn't answer why your parameter is null, but you can dig into the request directly. This might not be the most...
2009/02/13
[ "https://Stackoverflow.com/questions/544182", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
On the View: ``` <% =Html.BeginForm("About", "Home", FormMethod.Post, new {enctype="multipart/form-data "})%> <input type="file" name="postedFile" /> <input type="submit" name="upload" value="Upload" /> <% Html.EndForm(); %> ``` In the Controller, there's something like this: ``` [AcceptVerbs(HttpVerbs.Post)] ...
Use HttpPostedFileBase (not HttpPostedFile) and also name the parameter exactly as in the form. eg. if you have ``` <input type="file" id="file1" name="file1" /> ``` you have to have the method head: ``` public ActionResult About(HttpPostedFileBase file1) ```
544,186
<p>This is seriously killing me. I'm trying to convert a Unix timestamp (1236268800, which equates to Thu, 05 Mar 2009 16:00:00 GMT) to a Date object in Flex.</p> <pre><code>var timestamp:Number = 1236268800; trace(new Date(timestamp)); Output: Wed Jan 14 23:24:28 GMT-0800 1970 </code></pre> <p>Also tried this:</p> ...
[ { "answer_id": 544211, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 5, "selected": true, "text": "<p>you have to convert to milliseconds, multiply that by 1000</p>\n" }, { "answer_id": 544219, "author": "Chetan S"...
2009/02/13
[ "https://Stackoverflow.com/questions/544186", "https://Stackoverflow.com", "https://Stackoverflow.com/users/574/" ]
This is seriously killing me. I'm trying to convert a Unix timestamp (1236268800, which equates to Thu, 05 Mar 2009 16:00:00 GMT) to a Date object in Flex. ``` var timestamp:Number = 1236268800; trace(new Date(timestamp)); Output: Wed Jan 14 23:24:28 GMT-0800 1970 ``` Also tried this: ``` var timestamp:Number = 12...
you have to convert to milliseconds, multiply that by 1000
544,187
<p>I'm new to javascript, my problem is effectively: I have a php page that produces a single form with multiple process blocks or sections, each with a group of checkboxes</p> <p>eg</p> <pre><code>&lt;form action='./this.php' method='POST'&gt; One&lt;br&gt; &lt;input type='checkbox' name='one[part1]'&gt;a&lt;br&gt; ...
[ { "answer_id": 544196, "author": "achinda99", "author_id": 60824, "author_profile": "https://Stackoverflow.com/users/60824", "pm_score": 1, "selected": true, "text": "<p>You need one javascript onClickAll function that takes a parameter of the group name. You can then loop through each ...
2009/02/13
[ "https://Stackoverflow.com/questions/544187", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62202/" ]
I'm new to javascript, my problem is effectively: I have a php page that produces a single form with multiple process blocks or sections, each with a group of checkboxes eg ``` <form action='./this.php' method='POST'> One<br> <input type='checkbox' name='one[part1]'>a<br> <input type='checkbox' name='one[part2]'>b<br...
You need one javascript onClickAll function that takes a parameter of the group name. You can then loop through each checkbox returned by getElementsByName and mark them checked/unchecked. On the postback, you will get an array of values for the checkboxes with the group name used. By looping through, you know which wa...
544,204
<p>I am messing around with the Indy 10 supplied with Delphi 2009 and am having trouble with getting all the data from the IOHandler when OnExecute fires...</p> <pre><code>procedure TFormMain.IdTCPServerExecute(AContext: TIdContext); var RxBufStr: UTF8String; RxBufSize: Integer; begin if AContext.Connection.IOH...
[ { "answer_id": 544473, "author": "Remy Lebeau", "author_id": 65863, "author_profile": "https://Stackoverflow.com/users/65863", "pm_score": 5, "selected": true, "text": "<p>You should not be using Readable() like that. Try the following instead:</p>\n\n<pre><code>procedure TFormMain.IdTC...
2009/02/13
[ "https://Stackoverflow.com/questions/544204", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44574/" ]
I am messing around with the Indy 10 supplied with Delphi 2009 and am having trouble with getting all the data from the IOHandler when OnExecute fires... ``` procedure TFormMain.IdTCPServerExecute(AContext: TIdContext); var RxBufStr: UTF8String; RxBufSize: Integer; begin if AContext.Connection.IOHandler.Readabl...
You should not be using Readable() like that. Try the following instead: ``` procedure TFormMain.IdTCPServerExecute(AContext: TIdContext); var RxBuf: TIdBytes; begin RxBuf := nil; with AContext.Connection.IOHandler do begin CheckForDataOnSource(10); if not InputBufferIsEmpty then begin InputB...
544,206
<p>I have a std::list of Points (that simply store an x, y). Each one of these points represents a polygon, which I later draw.</p> <pre><code>class Point { public: int x, y; Point(int x1, int y1) { x = x1; y = y1; } }; std::list &lt;Point&gt; currentPolygon; </code></pre> <p>I woul...
[ { "answer_id": 544218, "author": "Jeffrey", "author_id": 3259, "author_profile": "https://Stackoverflow.com/users/3259", "pm_score": 3, "selected": false, "text": "<p>It sure is. But what you probably want - for expandability purposes later - create a second class - \"polygon\", that ho...
2009/02/13
[ "https://Stackoverflow.com/questions/544206", "https://Stackoverflow.com", "https://Stackoverflow.com/users/64878/" ]
I have a std::list of Points (that simply store an x, y). Each one of these points represents a polygon, which I later draw. ``` class Point { public: int x, y; Point(int x1, int y1) { x = x1; y = y1; } }; std::list <Point> currentPolygon; ``` I would like to have a list of these po...
You could use this: ``` std::list< std::list<Point> > polygons; ``` To make things easier, use typedefs. ``` class Point { public: int x, y; Point(int x1, int y1) { x = x1; y = y1; } }; typedef std::list<Point> PolygonType; typedef std::list<PolygonType> PolygonsType; ```
544,207
<p>I've been puzzling over something which ought to be very easy indeed, but after a fruitless three hours I've not yet solved it:</p> <p>A friend asked me to fix the template of <a href="http://www.hootingyard.org/" rel="noreferrer">his WordPress website</a> so that the horizontal navigation menu-bar is centered hori...
[ { "answer_id": 544229, "author": "MK_Dev", "author_id": 39843, "author_profile": "https://Stackoverflow.com/users/39843", "pm_score": -1, "selected": false, "text": "<p>Since it's positioned absolute, you can give it a left attribute:</p>\n\n<blockquote>\n <p>.menu { left: 125px; }</p>\...
2009/02/13
[ "https://Stackoverflow.com/questions/544207", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46411/" ]
I've been puzzling over something which ought to be very easy indeed, but after a fruitless three hours I've not yet solved it: A friend asked me to fix the template of [his WordPress website](http://www.hootingyard.org/) so that the horizontal navigation menu-bar is centered horizontally on the page. He wants it to f...
To center a row of blocks, you should use inline-block: ``` ul.menu { display: block; text-align:center; } ul.menu li { display: inline-block; } ``` IE doesn't understand inline-block, but if you set it inline just for IE, it'll still behave as an inline-block: ``` <!--[if lt IE 8]> ul.menu li { display: inline } <...
544,209
<p>I've looped over the <code>Request.ServerVariables</code> collection in ASP.NET, but it's not as comprehensive as <code>phpinfo()</code>.</p> <p>How can I print all that information, including server software, drivers, etc, for ASP.NET?</p>
[ { "answer_id": 544213, "author": "MK_Dev", "author_id": 39843, "author_profile": "https://Stackoverflow.com/users/39843", "pm_score": 0, "selected": false, "text": "<p>Quick google result:</p>\n\n<p><a href=\"http://forums.asp.net/p/901862/2087653.aspx\" rel=\"nofollow noreferrer\">http:...
2009/02/13
[ "https://Stackoverflow.com/questions/544209", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52529/" ]
I've looped over the `Request.ServerVariables` collection in ASP.NET, but it's not as comprehensive as `phpinfo()`. How can I print all that information, including server software, drivers, etc, for ASP.NET?
An empty page with this header should do the trick: ``` <%@ Page Trace="true" Language="C#" ContentType="text/html" ResponseEncoding="utf-8" %> ```
544,215
<p>I'm using Spring for an HTML form. One of the fields is an <code>enum</code> and thus I'd like a HTML drop-down list (<code>&lt;option&gt;</code> tag). My enum's name is different than the <code>toString()</code> value. For example:</p> <pre><code>public enum Size { SMALL("Small"), LARGE("Large"), VERY_LARGE("V...
[ { "answer_id": 544899, "author": "Jeff Olson", "author_id": 56708, "author_profile": "https://Stackoverflow.com/users/56708", "pm_score": 2, "selected": false, "text": "<p>Why not add a public getDisplayName() method to your enum?</p>\n" }, { "answer_id": 6944736, "author": "...
2009/02/13
[ "https://Stackoverflow.com/questions/544215", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24396/" ]
I'm using Spring for an HTML form. One of the fields is an `enum` and thus I'd like a HTML drop-down list (`<option>` tag). My enum's name is different than the `toString()` value. For example: ``` public enum Size { SMALL("Small"), LARGE("Large"), VERY_LARGE("Very large"); private final String displayName; ...
I know this is few years old and must be solved by now, but thought I'd add the solution for future comers. Just remove the [itemLabel="beanProperty"] part. It will use the toString to print the values.
544,241
<p>My project requires users to create some basic math functions, I need to store these in a ms sql databse to use on datasets in my business logic.</p> <p>The functions will be similar to: when (value1 between 20 and 40) then value2 = value 2 * 37.8 </p> <p>What is the best schema to store something like this ?...
[ { "answer_id": 544866, "author": "Noah", "author_id": 12113, "author_profile": "https://Stackoverflow.com/users/12113", "pm_score": 0, "selected": false, "text": "<p>Store them as user defined functions</p>\n\n<p>Nice article on them <a href=\"http://www.sqlteam.com/article/user-defined-...
2009/02/13
[ "https://Stackoverflow.com/questions/544241", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50970/" ]
My project requires users to create some basic math functions, I need to store these in a ms sql databse to use on datasets in my business logic. The functions will be similar to: when (value1 between 20 and 40) then value2 = value 2 \* 37.8 What is the best schema to store something like this ? And what is the m...
This is a tough one. Basically you want to create a parser. I believe that you would need to have two tables : first table would have a functionID ,orderID , operatorID The second table would have 1 to many relationship between operatorID and operands. FunctionID would be unique identifier for the function. orderID...
544,249
<p>I am using Jon Skeet's very clever <a href="http://msmvps.com/blogs/jon_skeet/archive/2007/07/27/smart-enumerations.aspx" rel="nofollow noreferrer">SmartEnumerable</a>. I recommend checking it out if you haven't already seen it.</p> <p>The class is defined :</p> <pre><code>public class SmartEnumerable&lt;T&gt; : I...
[ { "answer_id": 544257, "author": "JaredPar", "author_id": 23283, "author_profile": "https://Stackoverflow.com/users/23283", "pm_score": 3, "selected": false, "text": "<p>Try this code</p>\n\n<pre><code>public static class SmartEnumerable {\n public static SmartEnumerable&lt;T&gt; Create...
2009/02/13
[ "https://Stackoverflow.com/questions/544249", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16940/" ]
I am using Jon Skeet's very clever [SmartEnumerable](http://msmvps.com/blogs/jon_skeet/archive/2007/07/27/smart-enumerations.aspx). I recommend checking it out if you haven't already seen it. The class is defined : ``` public class SmartEnumerable<T> : IEnumerable<SmartEnumerable<T>.Entry> ``` The constructor is : ...
Try this code ``` public static class SmartEnumerable { public static SmartEnumerable<T> Create<T>(IEnumerable<T> source) { return new SmartEnumerable<T>(source); } } void Example() { IEnumerable<string> myCats = GetMyCats(); var se = SmartEnumerable.Create(myCats); } ``` Your code is failing because C#...
544,253
<p>We use a batch file to generate code, and it automatically checks out the generated files from Team Foundation Server (TFS) so that it can regenerate them. The majority of these files are not modified, but the generator does not know this ahead of time.</p> <p>The "tfs undo" command undoes the checkout, but prompts...
[ { "answer_id": 544259, "author": "achinda99", "author_id": 60824, "author_profile": "https://Stackoverflow.com/users/60824", "pm_score": -1, "selected": false, "text": "<p>As far as I understood, in TFS if you checkout a team project, the whole project is checked out and you do not have ...
2009/02/13
[ "https://Stackoverflow.com/questions/544253", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10784/" ]
We use a batch file to generate code, and it automatically checks out the generated files from Team Foundation Server (TFS) so that it can regenerate them. The majority of these files are not modified, but the generator does not know this ahead of time. The "tfs undo" command undoes the checkout, but prompts if some h...
Take a look on Undo Unchanged command of the [Team Foundation Server Power Tools August 2011](http://visualstudiogallery.msdn.microsoft.com/c255a1e4-04ba-4f68-8f4e-cd473d6b971f) ``` c:\myProject> tfpt uu . /noget /recursive ``` *Thanks Matt Florence for link update.* *Thanks Ray Vega for [actual syntax](https://sta...
544,276
<p>I'm trying to set up a simple rewrite rule to convert a url such as:</p> <pre><code> index.php?page=login </code></pre> <p>to something like</p> <pre><code> page/login </code></pre> <p>However, I keep getting 404 errors.</p> <p>Can anyone suggest why the following might not be working?</p> <p>.htaccess:</p> <...
[ { "answer_id": 544297, "author": "gnud", "author_id": 27204, "author_profile": "https://Stackoverflow.com/users/27204", "pm_score": 1, "selected": false, "text": "<p>Make sure you use RewriteBase.</p>\n\n<p>These are the rules I normally use.\nThey say that any request that is not a file...
2009/02/13
[ "https://Stackoverflow.com/questions/544276", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to set up a simple rewrite rule to convert a url such as: ``` index.php?page=login ``` to something like ``` page/login ``` However, I keep getting 404 errors. Can anyone suggest why the following might not be working? .htaccess: ``` RewriteEngine on RewriteRule ^page/([^/\.]+)/?$ index.php?page=...
I think you may have it bacwards. Do you want the user to type in this? ``` http://site.com/page/login ``` ? That's the more logical situation. If so, do this: ``` RewriteEngine On RewriteBase / RewriteRule ^/page/login$ /index.php?page=login [L] ``` Or, more generally: ``` RewriteRule ^/page/(\w+)$ /index.php?...
544,284
<p>It's time to implement sorting on my blog-like web application. In addition to browsing by creation date, I want users to be able to sort by the number of replies, too.</p> <p>Given that I have two tables blog_posts and replies, and that replies has a field called blog_post_id (a foreign key for the blog_post it's...
[ { "answer_id": 544293, "author": "Ian P", "author_id": 10853, "author_profile": "https://Stackoverflow.com/users/10853", "pm_score": 1, "selected": false, "text": "<p>I don't have a copy of MySQL locally that I can mess around with, but you could do something like this:</p>\n\n<pre><code...
2009/02/13
[ "https://Stackoverflow.com/questions/544284", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45553/" ]
It's time to implement sorting on my blog-like web application. In addition to browsing by creation date, I want users to be able to sort by the number of replies, too. Given that I have two tables blog\_posts and replies, and that replies has a field called blog\_post\_id (a foreign key for the blog\_post it's a repl...
This should do the trick: ``` SELECT blog_posts.*, count(replies.blog_post_id) as blog_replies FROM blog_posts LEFT JOIN replies ON replies.blog_post_id = blog_posts.id GROUP BY blog_posts.id ORDER BY blog_replies DESC ``` You could tack on a LIMIT and OFFSET clause at the end to get the paging working.
544,292
<p>Is there a way to do a disk-based binary search for a particular key in a text file in Javascript? The text file is too big to be loaded into memory, but sorted by the key values. In particular I am looking for a way to mimic Perl's <a href="http://perldoc.perl.org/Search/Dict.html" rel="nofollow noreferrer">Search:...
[ { "answer_id": 544293, "author": "Ian P", "author_id": 10853, "author_profile": "https://Stackoverflow.com/users/10853", "pm_score": 1, "selected": false, "text": "<p>I don't have a copy of MySQL locally that I can mess around with, but you could do something like this:</p>\n\n<pre><code...
2009/02/13
[ "https://Stackoverflow.com/questions/544292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5734/" ]
Is there a way to do a disk-based binary search for a particular key in a text file in Javascript? The text file is too big to be loaded into memory, but sorted by the key values. In particular I am looking for a way to mimic Perl's [Search::Dict](http://perldoc.perl.org/Search/Dict.html) functionality in Javascript. ...
This should do the trick: ``` SELECT blog_posts.*, count(replies.blog_post_id) as blog_replies FROM blog_posts LEFT JOIN replies ON replies.blog_post_id = blog_posts.id GROUP BY blog_posts.id ORDER BY blog_replies DESC ``` You could tack on a LIMIT and OFFSET clause at the end to get the paging working.
544,310
<p>I'm trying to look at the best way of changing the value of an element in XML.</p> <pre><code>&lt;MyXmlType&gt; &lt;MyXmlElement&gt;Value&lt;/MyXmlElement&gt; &lt;/MyXmlType&gt; </code></pre> <p>What is the easiest and/or best way to change "Value" in C#?</p> <p>I've looked at XMLDocument and it will cause a l...
[ { "answer_id": 544316, "author": "Rex M", "author_id": 67, "author_profile": "https://Stackoverflow.com/users/67", "pm_score": 2, "selected": false, "text": "<p>You could use an XmlReader to read into a class that pumps the data back out through an XmlWriter and scan for the element betw...
2009/02/13
[ "https://Stackoverflow.com/questions/544310", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53771/" ]
I'm trying to look at the best way of changing the value of an element in XML. ``` <MyXmlType> <MyXmlElement>Value</MyXmlElement> </MyXmlType> ``` What is the easiest and/or best way to change "Value" in C#? I've looked at XMLDocument and it will cause a load of the whole XML document to memory. Could you do it ...
You could use the System.Xml.Linq namespace stuff for the easiest to read code. This will load the full file into memory. ``` XDocument xdoc = XDocument.Load("file.xml"); var element = xdoc.Elements("MyXmlElement").Single(); element.Value = "foo"; xdoc.Save("file.xml"); ```
544,314
<p>I have a NSString value of @"78000". How do I get this in currency format, i.e. $78,000 with it remaining an NSString.</p>
[ { "answer_id": 544370, "author": "Andrew Grant", "author_id": 1043, "author_profile": "https://Stackoverflow.com/users/1043", "pm_score": 5, "selected": true, "text": "<p>You need to use a number formatter. Note this is also how you would display dates/times etc in the correct format for...
2009/02/13
[ "https://Stackoverflow.com/questions/544314", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7280/" ]
I have a NSString value of @"78000". How do I get this in currency format, i.e. $78,000 with it remaining an NSString.
You need to use a number formatter. Note this is also how you would display dates/times etc in the correct format for the users locale ``` // alloc formatter NSNumberFormatter *currencyStyle = [[NSNumberFormatter alloc] init]; // set options. [currencyStyle setFormatterBehavior:NSNumberFormatterBehavior10_4]; [curre...
544,329
<p>I am trying to find a way to query rows of data by using a "multivalue" pipe delimited column in another table as a WHERE clause. SQL SERVER 2005 </p> <p>This is my best description of the problem:</p> <p>Imagine a pipe delimited column set to a variable like @LIST = 'Bob|Mary|Joe'</p> <p>then I am trying to f...
[ { "answer_id": 544373, "author": "dwc", "author_id": 57301, "author_profile": "https://Stackoverflow.com/users/57301", "pm_score": 0, "selected": false, "text": "<p>Check out the PATINDEX() function. It's a bit limited, but it should do what you're looking for.</p>\n" }, { "answe...
2009/02/13
[ "https://Stackoverflow.com/questions/544329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35615/" ]
I am trying to find a way to query rows of data by using a "multivalue" pipe delimited column in another table as a WHERE clause. SQL SERVER 2005 This is my best description of the problem: Imagine a pipe delimited column set to a variable like @LIST = 'Bob|Mary|Joe' then I am trying to find a match like this ```...
You can use a split udf and join it to your main query. see this [link](http://www.sqlmag.com/Article/ArticleID/21071/sql_server_21071.html) for the code and an example. Your query would end up looking like this. This is untested but hopefully this points you in the right direction. ``` Select A.* from Users A JOIN db...
544,336
<p>I have a an attribute who's value may be one or more text strings all delimited by a comma. I wish to transform using XSL the attribute value(s) into their own element;</p> <p>e.g</p> <pre><code>&lt;post title='Hello World" tags="Test,Hello,World /&gt; </code></pre> <p>In which I would like it transformed to;</p...
[ { "answer_id": 544760, "author": "Dimitre Novatchev", "author_id": 36305, "author_profile": "https://Stackoverflow.com/users/36305", "pm_score": 4, "selected": true, "text": "<p>There are several ways to do this.</p>\n\n<p><strong>I. Using a recursively-called named template in XSLT 1.0\...
2009/02/13
[ "https://Stackoverflow.com/questions/544336", "https://Stackoverflow.com", "https://Stackoverflow.com/users/234160/" ]
I have a an attribute who's value may be one or more text strings all delimited by a comma. I wish to transform using XSL the attribute value(s) into their own element; e.g ``` <post title='Hello World" tags="Test,Hello,World /> ``` In which I would like it transformed to; ``` <post> <title>Hello World</title> <t...
There are several ways to do this. **I. Using a recursively-called named template in XSLT 1.0 This transformation**: ``` <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output omit-xml-declaration="yes" indent="yes"/> <xsl:template match="/*"> <xsl:copy> <xsl:...
544,354
<p>I'm not much of a VB programmer but something like this should be simple enough... I'm really stumped here though.</p> <p>I have a web app that does a lot of work with emails and PDFs. I'm adding a few new functions to it and have run into two very basic "Type Mismatch" errors and haven't been able to solve them.</...
[ { "answer_id": 544392, "author": "JeffK", "author_id": 5420, "author_profile": "https://Stackoverflow.com/users/5420", "pm_score": 0, "selected": false, "text": "<p>This <strong><em>exact code</em></strong> works elsewhere? Are you sure you're passing the arguments to the inArray() func...
2009/02/13
[ "https://Stackoverflow.com/questions/544354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm not much of a VB programmer but something like this should be simple enough... I'm really stumped here though. I have a web app that does a lot of work with emails and PDFs. I'm adding a few new functions to it and have run into two very basic "Type Mismatch" errors and haven't been able to solve them. The first ...
There is no built in function called InArray() in vbscript. Do you have the function included?
544,369
<p>I have a site that has been up for some time. I had a blog on a subdomain for some time. I have decided to do away with the main site and just support the blog subdomain.</p> <p>I have a redirect setup for this, but it carries all the extra parameters through to the blog which results in a file not found page app...
[ { "answer_id": 544621, "author": "Mark Hurd", "author_id": 65714, "author_profile": "https://Stackoverflow.com/users/65714", "pm_score": 1, "selected": false, "text": "<pre><code>RewriteEngine On\nOptions +FollowSymlinks\nRewriteCond %{HTTP_HOST} ^(www\\.)?foo\\.org$ [NC]\nRewriteRule ^ ...
2009/02/13
[ "https://Stackoverflow.com/questions/544369", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65810/" ]
I have a site that has been up for some time. I had a blog on a subdomain for some time. I have decided to do away with the main site and just support the blog subdomain. I have a redirect setup for this, but it carries all the extra parameters through to the blog which results in a file not found page appearing. I ju...
You have to specify the query in the replacement to override the original: ``` RewriteCond %{HTTP_HOST} !^blog\.example\.org$ [NC] RewriteRule ^ http://blog.example.org/index.php? [R=301,L] ```
544,378
<h2>Employee table</h2> <p>Employee_ID int<br> Employee_Name varchar(50)</p> <h2>Sales table:</h2> <p>Sales_ID int<br> Employee_ID int<br> Sale_Amount money</p> <h2>Standard SQL select</h2> <p>Select<br> *<br> From Employee emp<br> left outer join<br> Sales s<br> on<br> s.Em...
[ { "answer_id": 544453, "author": "Michael La Voie", "author_id": 65843, "author_profile": "https://Stackoverflow.com/users/65843", "pm_score": 2, "selected": false, "text": "<p>You need to perform a left join by using the &quot;Into&quot; and &quot;DefaultIfEmpty()&quot; keywords:</p>\n<...
2009/02/13
[ "https://Stackoverflow.com/questions/544378", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53234/" ]
Employee table -------------- Employee\_ID int Employee\_Name varchar(50) Sales table: ------------ Sales\_ID int Employee\_ID int Sale\_Amount money Standard SQL select ------------------- Select \* From Employee emp left outer join Sales s on s.Employee\_ID = emp.Employee\_ID S...
You need to perform a left join by using the "Into" and "DefaultIfEmpty()" keywords: ``` Dim query = From emp In entities.Employee _ Join sal In entities.Sales On emp.Employee_ID Equals sal.Employee_ID Into LeftJoinSal _ From ljs In LeftJoinSal.DefaultIfEmpty() _ Select _ emp, _ ...
544,397
<p>I'm trying to concat "(" + mouseX + ", " + mouseY ")". However, mouseX and mouseY are ints, so I tried using a stringstream as follows:</p> <pre><code>std::stringstream pos; pos &lt;&lt; "(" &lt;&lt; mouseX &lt;&lt; ", " &lt;&lt; mouseY &lt;&lt; ")"; _glutBitmapString(GLUT_BITMAP_HELVETICA_12, pos.str()); </code>...
[ { "answer_id": 544410, "author": "Andrew Grant", "author_id": 1043, "author_profile": "https://Stackoverflow.com/users/1043", "pm_score": 2, "selected": false, "text": "<p>Try </p>\n\n<pre><code>_glutBitmapString(GLUT_BITMAP_HELVETICA_12, pos.str().c_str());\n</code></pre>\n" }, { ...
2009/02/13
[ "https://Stackoverflow.com/questions/544397", "https://Stackoverflow.com", "https://Stackoverflow.com/users/64878/" ]
I'm trying to concat "(" + mouseX + ", " + mouseY ")". However, mouseX and mouseY are ints, so I tried using a stringstream as follows: ``` std::stringstream pos; pos << "(" << mouseX << ", " << mouseY << ")"; _glutBitmapString(GLUT_BITMAP_HELVETICA_12, pos.str()); ``` And it doesn't seem to work. I get the follow...
`glutBitmapString()` expects a `char*` and you're sending it a string. use .c\_str() on the string like so: ``` _glutBitmapString(GLUT_BITMAP_HELVETICA_12, pos.str().c_str()); ```
544,398
<p>I'm trying to use a windows forms datagrid (.NET 1.1) to update the elements of a two dimensional array. Using the microsoft documentation, I've been able to get the datagrid to display the array properly.</p> <p>EDIT: The MS instructions I followed are at <a href="http://support.microsoft.com/kb/315786" rel="nofol...
[ { "answer_id": 544410, "author": "Andrew Grant", "author_id": 1043, "author_profile": "https://Stackoverflow.com/users/1043", "pm_score": 2, "selected": false, "text": "<p>Try </p>\n\n<pre><code>_glutBitmapString(GLUT_BITMAP_HELVETICA_12, pos.str().c_str());\n</code></pre>\n" }, { ...
2009/02/13
[ "https://Stackoverflow.com/questions/544398", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4777/" ]
I'm trying to use a windows forms datagrid (.NET 1.1) to update the elements of a two dimensional array. Using the microsoft documentation, I've been able to get the datagrid to display the array properly. EDIT: The MS instructions I followed are at <http://support.microsoft.com/kb/315786>. ``` class myrow { priva...
`glutBitmapString()` expects a `char*` and you're sending it a string. use .c\_str() on the string like so: ``` _glutBitmapString(GLUT_BITMAP_HELVETICA_12, pos.str().c_str()); ```
544,411
<p>I have a C# console app (.NET 2.0 framework) that does an HTTP post using the following code:</p> <pre><code>StringBuilder postData = new StringBuilder(100); postData.Append("post.php?"); postData.Append("Key1="); postData.Append(val1); postData.Append("&amp;Key2="); postData.Append(val2); byte[] dataArray = Encod...
[ { "answer_id": 544436, "author": "EnocNRoll - AnandaGopal Pardue", "author_id": 54289, "author_profile": "https://Stackoverflow.com/users/54289", "pm_score": 0, "selected": false, "text": "<p>I believe the problem has something to do with the way your headers are set up for the WebReques...
2009/02/13
[ "https://Stackoverflow.com/questions/544411", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4555/" ]
I have a C# console app (.NET 2.0 framework) that does an HTTP post using the following code: ``` StringBuilder postData = new StringBuilder(100); postData.Append("post.php?"); postData.Append("Key1="); postData.Append(val1); postData.Append("&Key2="); postData.Append(val2); byte[] dataArray = Encoding.UTF8.GetBytes(...
If you are indeed supposed to use the `POST` HTTP method, you have a couple things wrong. First, this line: ``` postData.Append("post.php?"); ``` is incorrect. You want to post *to* `post.php`, you don't want post the value "post.php?" to the page. Just remove this line entirely. This piece: ``` ... WebRequest.Cre...
544,417
<p>What's the easiest/best way to find and remove empty (zero-byte) files using only tools native to Mac OS X?</p>
[ { "answer_id": 544427, "author": "dwc", "author_id": 57301, "author_profile": "https://Stackoverflow.com/users/57301", "pm_score": 1, "selected": false, "text": "<pre><code>find /path/to/stuff -empty\n</code></pre>\n\n<p>If that's the list of files you're looking for then make the comman...
2009/02/13
[ "https://Stackoverflow.com/questions/544417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/214303/" ]
What's the easiest/best way to find and remove empty (zero-byte) files using only tools native to Mac OS X?
Easy enough: ``` find . -type f -size 0 -exec rm -f '{}' + ``` --- To ignore any file having xattr content (assuming the MacOS `find` implementation): ``` find . -type f -size 0 '!' -xattr -exec rm -f '{}' + ``` That said, note that many xattrs are not particularly useful (for example, `com.apple.quarantine` exi...
544,433
<p>I've got a string, a signature, and a public key, and I want to verify the signature on the string. The key looks like this:</p> <pre><code>-----BEGIN PUBLIC KEY----- MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDfG4IuFO2h/LdDNmonwGNw5srW nUEWzoBrPRF1NM8LqpOMD45FAPtZ1NmPtHGo0BAS1UsyJEGXx0NPJ8Gw1z+huLrl XnAVX5B4ec6cJfKKmpL...
[ { "answer_id": 544487, "author": "David Z", "author_id": 56541, "author_profile": "https://Stackoverflow.com/users/56541", "pm_score": 0, "selected": false, "text": "<p>Maybe this isn't the answer you're looking for, but if all you need is to turn the key into bits, it looks like it's Ba...
2009/02/13
[ "https://Stackoverflow.com/questions/544433", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65385/" ]
I've got a string, a signature, and a public key, and I want to verify the signature on the string. The key looks like this: ``` -----BEGIN PUBLIC KEY----- MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDfG4IuFO2h/LdDNmonwGNw5srW nUEWzoBrPRF1NM8LqpOMD45FAPtZ1NmPtHGo0BAS1UsyJEGXx0NPJ8Gw1z+huLrl XnAVX5B4ec6cJfKKmpL/l94WhP2v8F3OG...
The data between the markers is the base64 encoding of the ASN.1 DER-encoding of a PKCS#8 PublicKeyInfo containing an PKCS#1 RSAPublicKey. That is a lot of standards, and you will be best served with using a crypto-library to decode it (such as M2Crypto as [suggested by joeforker](https://stackoverflow.com/questions/5...
544,449
<p>In the following c# code, how do I get rid of the objects when it's no longer useful? Does it get taken care of automatically, or do I need to do something?</p> <pre><code>public void Test() { object MyObject = new object(); ... code ... } </code></pre>
[ { "answer_id": 544454, "author": "Matt", "author_id": 53139, "author_profile": "https://Stackoverflow.com/users/53139", "pm_score": 4, "selected": false, "text": "<p>Automatically. When MyObject goes out of scope (at the end of Test), it's flagged for garbage collection. At some point in...
2009/02/13
[ "https://Stackoverflow.com/questions/544449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62055/" ]
In the following c# code, how do I get rid of the objects when it's no longer useful? Does it get taken care of automatically, or do I need to do something? ``` public void Test() { object MyObject = new object(); ... code ... } ```
The short answer is: unless it has unmanaged resources (file handles etc) you don't need to worry. The long answer is a bit more involved. When .NET decides it wants to free up some memory, it runs the *garbage collector*. This looks for all the objects which are still in use, and marks them as such. Any local variab...
544,462
<p>I am having small problem in making a global variable works. I am using Visual Studio 2008 and standard C++. </p> <p>I have two projects, one is a static library and second one is a test program which uses this library. I have a global variable in global.h like </p> <pre><code>#ifndef GLOBAL_H #define GLOBAL_H #i...
[ { "answer_id": 544483, "author": "Mark Ransom", "author_id": 5987, "author_profile": "https://Stackoverflow.com/users/5987", "pm_score": 3, "selected": false, "text": "<p>With the \"extern\" keyword, you're telling the compiler that the actual variable exists somewhere else. You should ...
2009/02/13
[ "https://Stackoverflow.com/questions/544462", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50419/" ]
I am having small problem in making a global variable works. I am using Visual Studio 2008 and standard C++. I have two projects, one is a static library and second one is a test program which uses this library. I have a global variable in global.h like ``` #ifndef GLOBAL_H #define GLOBAL_H #include <string> exte...
Don't use global variables. Just don't. Much better, if you HAVE to have globally accessible data, is to use a global function which will return globalWord, like this: ``` std::string globalWord() { static std::string word("Hi Mom"); return word; } ``` This saves you from initialization order issues (read Ef...
544,472
<p>I'm a big fan of TDD and use it for the vast majority of my development these days. One situation I run into somewhat frequently, though, and have never found what I thought was a "good" answer for, is something like the following (contrived) example.</p> <p>Suppose I have an interface, like this (writing in Java,...
[ { "answer_id": 544495, "author": "DavidN", "author_id": 33662, "author_profile": "https://Stackoverflow.com/users/33662", "pm_score": 3, "selected": true, "text": "<p>You write interface tests to exercise the interface, and you write more detailed tests for the actual implementations. <a...
2009/02/13
[ "https://Stackoverflow.com/questions/544472", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52734/" ]
I'm a big fan of TDD and use it for the vast majority of my development these days. One situation I run into somewhat frequently, though, and have never found what I thought was a "good" answer for, is something like the following (contrived) example. Suppose I have an interface, like this (writing in Java, but really...
You write interface tests to exercise the interface, and you write more detailed tests for the actual implementations. [Interface-based design](https://rads.stackoverflow.com/amzn/click/com/0976694050) talks a bit about the fact that your unit tests should form a kind of "contract" specification for that interface. May...
544,477
<p>Lets say I have the following table in MS SQL 2000</p> <pre><code>Id | description | quantity | ------------------------------- 1 my desc 3 2 desc 2 2 </code></pre> <p>I need to display multiple rows based on the quantity, so I need the following output:</p> <pre><code>Id | description | ...
[ { "answer_id": 544500, "author": "Sean Bright", "author_id": 21926, "author_profile": "https://Stackoverflow.com/users/21926", "pm_score": 1, "selected": false, "text": "<pre><code>DECLARE @Id INT\nDECLARE @Description VARCHAR(32)\nDECLARE @Quantity INT\nDECLARE @Results TABLE (Id INT, [...
2009/02/13
[ "https://Stackoverflow.com/questions/544477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51775/" ]
Lets say I have the following table in MS SQL 2000 ``` Id | description | quantity | ------------------------------- 1 my desc 3 2 desc 2 2 ``` I need to display multiple rows based on the quantity, so I need the following output: ``` Id | description | quantity | --------------------------...
This works just fine, no need for any cursors on this one. It may be possible to fangle something out without a number table as well. *Note* if going for this kind of solution I would keep a number table around and not recreate it every time I ran the query. ``` create table #splitme (Id int, description varchar(25...
544,514
<p>have a weird situation. I'm using Glassfish server for my Enterprise application. In that application i'm using JSF, Richfaces, Quartz, Jasper Reports, and Commons Email. When I build and deploy application to my dev. computer, dev and test servers, everything works fine. But when I deploy app to Production server w...
[ { "answer_id": 544521, "author": "Jared", "author_id": 44757, "author_profile": "https://Stackoverflow.com/users/44757", "pm_score": 4, "selected": true, "text": "<p>A <code>java.lang.NoSuchMethodException</code> always indicates that the class file on the runtime classpath is not the sa...
2009/02/13
[ "https://Stackoverflow.com/questions/544514", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51230/" ]
have a weird situation. I'm using Glassfish server for my Enterprise application. In that application i'm using JSF, Richfaces, Quartz, Jasper Reports, and Commons Email. When I build and deploy application to my dev. computer, dev and test servers, everything works fine. But when I deploy app to Production server with...
A `java.lang.NoSuchMethodException` always indicates that the class file on the runtime classpath is not the same version as the class file that was on the compile-time classpath (if the method had been missing during compilation, the compile would have failed.) Specifically, the offending method in this case is: `jav...
544,519
<p>Is there any way to open the command prompt and change directory in the command prompt and run the batch file in the same command prompt using java.</p> <p>I know how to open the command prompt using java. Thanks,</p>
[ { "answer_id": 544534, "author": "Lawrence Dol", "author_id": 8946, "author_profile": "https://Stackoverflow.com/users/8946", "pm_score": 3, "selected": false, "text": "<p>You can encode the CD and the batch file in the value for cmd.exe /K. From the doco (cmd /?):</p>\n\n<blockquote>\n...
2009/02/13
[ "https://Stackoverflow.com/questions/544519", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48094/" ]
Is there any way to open the command prompt and change directory in the command prompt and run the batch file in the same command prompt using java. I know how to open the command prompt using java. Thanks,
You can encode the CD and the batch file in the value for cmd.exe /K. From the doco (cmd /?): > > Note that multiple commands separated by the command separator '&&' > are accepted for string if surrounded by quotes. > > > For Example: ``` cmd /C "CD C:\ && Dir" cmd /C "CD C:\Windows && Dir" cmd /C "CD C:\Windo...
544,542
<p>I am trying to plot a bunch of data points (many thousands) in Python using <a href="http://matplotlib.sourceforge.net/index.html" rel="noreferrer">matplotlib</a> so I need each marker to be very small and precise. How do I get the smallest most simple marker possible? I use this command to plot my data:</p> <pre...
[ { "answer_id": 544610, "author": "Matt", "author_id": 49135, "author_profile": "https://Stackoverflow.com/users/49135", "pm_score": 2, "selected": false, "text": "<p>If you haven't, you should try saving in a rasterizing engine -- save it to a PNG file and see if that fixes it. If you n...
2009/02/13
[ "https://Stackoverflow.com/questions/544542", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30181/" ]
I am trying to plot a bunch of data points (many thousands) in Python using [matplotlib](http://matplotlib.sourceforge.net/index.html) so I need each marker to be very small and precise. How do I get the smallest most simple marker possible? I use this command to plot my data: ``` matplotlib.pyplot( x , y ,'.',marker...
For nice-looking vectorized output, don't use the `'.'` marker style. Use e.g. `'o'` (circle) or `'s'` (square) (see `help(plot)` for the options) and set the `markersize` keyword argument to something suitably small, e.g.: ``` plot(x, y, 'ko', markersize=2) savefig('foo.ps') ``` That `'.'` (point) produces less nic...
544,580
<p>I have a regular expression to match 2 different number formats: <i>\=(?[0-9]+)\?|\+(?[0-9]+)\?</i></p> <p>This should return 9876543 as its Value for <i>;1234567890123456?+1234567890123456789012345123=9876543?</i><br> and <i>;1234567890123456?+9876543?</i> What I would like is to be able to return another value a...
[ { "answer_id": 544606, "author": "Bennett McElwee", "author_id": 61754, "author_profile": "https://Stackoverflow.com/users/61754", "pm_score": 2, "selected": false, "text": "<p>No, you can't match text that isn't there. The match can only return a substring of the target.</p>\n\n<p>You e...
2009/02/13
[ "https://Stackoverflow.com/questions/544580", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31027/" ]
I have a regular expression to match 2 different number formats: *\=(?[0-9]+)\?|\+(?[0-9]+)\?* This should return 9876543 as its Value for *;1234567890123456?+1234567890123456789012345123=9876543?* and *;1234567890123456?+9876543?* What I would like is to be able to return another value along with the matched 'Val...
Another option, which is not quite the solution you wanted, but saves you using two separate regexes, is to use named groups, if your implementation supports it. Here is some C#: ``` var regex = new Regex(@"\=(?<Long>[0-9]+)\?|\+(?<Short>[0-9]+)\?"); string test1 = ";1234567890123456?+1234567890123456789012345123=987...
544,581
<p>Is there a way to set a limit on the size of a JasperReport? We just looked at a WebSphere 6.1 Heapdump and someone tried to create a report and it was 1.5GB of memory in the heap. And it brought our Websphere server to its knees. Thanks, T</p>
[ { "answer_id": 545652, "author": "McDowell", "author_id": 304, "author_profile": "https://Stackoverflow.com/users/304", "pm_score": 2, "selected": false, "text": "<p>I'm not familiar with JasperReports, but you could <a href=\"http://jasperreports.sourceforge.net/api/net/sf/jasperreports...
2009/02/13
[ "https://Stackoverflow.com/questions/544581", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Is there a way to set a limit on the size of a JasperReport? We just looked at a WebSphere 6.1 Heapdump and someone tried to create a report and it was 1.5GB of memory in the heap. And it brought our Websphere server to its knees. Thanks, T
I'm not familiar with JasperReports, but you could [wrap your I/O streams](http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/JasperCompileManager.html#compileReportToStream(java.io.InputStream,%20java.io.OutputStream)) to ensure that the amount of data read/written does not exceed a defined limit. [...
544,590
<p>How do I use a custom .tff font file I have with my current windows.forms application? I read some where that I use it as an embedded resource, but how do I set it the System.Drawing.Font type?</p>
[ { "answer_id": 544619, "author": "Thomas", "author_id": 14637, "author_profile": "https://Stackoverflow.com/users/14637", "pm_score": 2, "selected": false, "text": "<p>Use the <a href=\"http://msdn.microsoft.com/en-us/library/dd183327(VS.85).aspx\" rel=\"nofollow noreferrer\">AddFontReso...
2009/02/13
[ "https://Stackoverflow.com/questions/544590", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65875/" ]
How do I use a custom .tff font file I have with my current windows.forms application? I read some where that I use it as an embedded resource, but how do I set it the System.Drawing.Font type?
This article: [How to embed a true type font](https://web.archive.org/web/20141224204810/http://bobpowell.net/embedfonts.aspx) shows how to do what you ask in .NET. **How to embed a True Type font** > > Some applications, for reasons of esthetics or a required visual > style, will embed certain uncommon fonts so tha...
544,592
<p>In MS-SQL 2005 when i exec </p> <p><strong>select * from sys.sysusers</strong> </p> <p>in <strong>master</strong> database , guest user <strong>hasdbaccess</strong> = 1 .</p> <p>how to set hasdbaccess = 0 ?</p>
[ { "answer_id": 544594, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 1, "selected": true, "text": "<p>I suppose it's not as simple as:</p>\n\n<pre><code>update sys.sysusers\n set hasdbaccess = 0\n where user = 'gue...
2009/02/13
[ "https://Stackoverflow.com/questions/544592", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
In MS-SQL 2005 when i exec **select \* from sys.sysusers** in **master** database , guest user **hasdbaccess** = 1 . how to set hasdbaccess = 0 ?
I suppose it's not as simple as: ``` update sys.sysusers set hasdbaccess = 0 where user = 'guest' ``` or something similar? No, life is never that easy :-) You would normally use `deny` or `revoke` to remove such permissions but be aware that guest is not considered a regular user. For some reason, `GUEST` ...
544,595
<p>I have been working to automate some deployment processes using just Nant for the time being. Once the Nant script scripts are fairly stable and proven, I'll be looking to incorporate CruiseControl.net or similar product.</p> <p>With that being said, I ran into a snag today. </p> <p>I have a Nant script that wil...
[ { "answer_id": 544594, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 1, "selected": true, "text": "<p>I suppose it's not as simple as:</p>\n\n<pre><code>update sys.sysusers\n set hasdbaccess = 0\n where user = 'gue...
2009/02/13
[ "https://Stackoverflow.com/questions/544595", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28540/" ]
I have been working to automate some deployment processes using just Nant for the time being. Once the Nant script scripts are fairly stable and proven, I'll be looking to incorporate CruiseControl.net or similar product. With that being said, I ran into a snag today. I have a Nant script that will copy files from a...
I suppose it's not as simple as: ``` update sys.sysusers set hasdbaccess = 0 where user = 'guest' ``` or something similar? No, life is never that easy :-) You would normally use `deny` or `revoke` to remove such permissions but be aware that guest is not considered a regular user. For some reason, `GUEST` ...
544,626
<p>Why didn't the designers of SQL require a keyword (e.g. "<strong>All</strong>") for any <strong>Update</strong> or <strong>Delete</strong> statements that don't have a <strong>Where</strong> clause? Was it just an oversight on their part? They would have saved so much grief (not to mention jobs!) if they had done ...
[ { "answer_id": 544633, "author": "vdsf", "author_id": 358120, "author_profile": "https://Stackoverflow.com/users/358120", "pm_score": 1, "selected": false, "text": "<p>For the same reason you can have a malloc without matching free in C : it's your responsibility.</p>\n" }, { "an...
2009/02/13
[ "https://Stackoverflow.com/questions/544626", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16012/" ]
Why didn't the designers of SQL require a keyword (e.g. "**All**") for any **Update** or **Delete** statements that don't have a **Where** clause? Was it just an oversight on their part? They would have saved so much grief (not to mention jobs!) if they had done that!
After making this mistake I've religiously gotten into the habit of typing ``` BEGIN TRANSACTION; -- Select Blah -- Some Sql here that changes Blah -- Select Blah ROLLBACK TRANSACTION; ``` then running it, making sure the rows affected count looks sane, staring at the Sql some more, then replacing `ROLLBACK` wi...
544,636
<p>I need to rotate a picture box 180 degrees when a condition in my if statement is met. Is this possible?</p>
[ { "answer_id": 544665, "author": "Thomas", "author_id": 14637, "author_profile": "https://Stackoverflow.com/users/14637", "pm_score": 4, "selected": true, "text": "<p>I'll assume that you want to rotate the image inside, because rotating the box itself doesn't make much sense (and is imp...
2009/02/13
[ "https://Stackoverflow.com/questions/544636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39035/" ]
I need to rotate a picture box 180 degrees when a condition in my if statement is met. Is this possible?
I'll assume that you want to rotate the image inside, because rotating the box itself doesn't make much sense (and is impossible anyway). Try this: ``` myPictureBox.Image.RotateFlip(RotateFlipType.Rotate180FlipNone); ```
544,673
<p>SELECT <code>item_name</code> from items WHERE <code>item_id</code> = $var;</p> <p>I tried:</p> <p>$var = 001 || 002 || 003 || 004;</p> <p>$var = 001 OR 002 OR 003 OR 004;</p> <p>$var = 001 or 002 or 003 or 004;</p> <p>But all do not work. </p> <p>Thanks, i try that, but the output only 1 result => 1.</p> <p>...
[ { "answer_id": 544676, "author": "Sean Bright", "author_id": 21926, "author_profile": "https://Stackoverflow.com/users/21926", "pm_score": 4, "selected": true, "text": "<pre><code>SELECT item_name from items WHERE item_id IN (1, 2, 3, 4)\n</code></pre>\n\n<p>And if <code>item_id</code> i...
2009/02/13
[ "https://Stackoverflow.com/questions/544673", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65379/" ]
SELECT `item_name` from items WHERE `item_id` = $var; I tried: $var = 001 || 002 || 003 || 004; $var = 001 OR 002 OR 003 OR 004; $var = 001 or 002 or 003 or 004; But all do not work. Thanks, i try that, but the output only 1 result => 1. What I want is to output all, i.e. 1, 2 , 3 and 4.. Means, I want to selec...
``` SELECT item_name from items WHERE item_id IN (1, 2, 3, 4) ``` And if `item_id` is a `VARCHAR` for some reason: ``` SELECT item_name from items WHERE item_id IN ('001', '002', '003', '004') ```
544,687
<p>I want to kill a process programmatically in vista/windows 7 (I'm not sure if there's significant problems in the implementation of the UAC between the two to make a difference). </p> <p>Right now, my code looks like:</p> <pre><code> if(killProcess){ System.Diagnostics.Process[] process = System.Diagnostic...
[ { "answer_id": 544728, "author": "Andrew Ensley", "author_id": 20801, "author_profile": "https://Stackoverflow.com/users/20801", "pm_score": 4, "selected": true, "text": "<p>You are correct in that it's because you don't have administrative priveleges. You can solve this by installing a...
2009/02/13
[ "https://Stackoverflow.com/questions/544687", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21981/" ]
I want to kill a process programmatically in vista/windows 7 (I'm not sure if there's significant problems in the implementation of the UAC between the two to make a difference). Right now, my code looks like: ``` if(killProcess){ System.Diagnostics.Process[] process = System.Diagnostics.Process.GetProcesses...
You are correct in that it's because you don't have administrative priveleges. You can solve this by installing a service under the local system user and running a custom command against it as needed. In your windows form app: ``` private enum SimpleServiceCustomCommands { KillProcess = 128 }; ServiceControllerPermi...
544,709
<p>I have a PolygonList and a Polygon type, which are std::lists of Points or lists of lists of points.</p> <pre><code>class Point { public: int x, y; Point(int x1, int y1) { x = x1; y = y1; } }; typedef std::list&lt;Point&gt; Polygon; typedef std::list&lt;P...
[ { "answer_id": 544727, "author": "shoosh", "author_id": 9611, "author_profile": "https://Stackoverflow.com/users/9611", "pm_score": 3, "selected": false, "text": "<p>like this:</p>\n\n<pre><code> Polygon &amp;currentPolygon = polygonList.front();\n currentPolygon.push_front(somePoint);\n...
2009/02/13
[ "https://Stackoverflow.com/questions/544709", "https://Stackoverflow.com", "https://Stackoverflow.com/users/64878/" ]
I have a PolygonList and a Polygon type, which are std::lists of Points or lists of lists of points. ``` class Point { public: int x, y; Point(int x1, int y1) { x = x1; y = y1; } }; typedef std::list<Point> Polygon; typedef std::list<Polygon> PolygonList; /...
like this: ``` Polygon &currentPolygon = polygonList.front(); currentPolygon.push_front(somePoint); ``` the & sign before the name means this is a reference.
544,725
<p>I'm developing an Eclipse plugin and am going to start presenting it in conferences and other venues, so people will install it.</p> <p>One limitation of the plugin is that because of the amount of information it has to maintain to work, it needs more heap space than what is allocated to Eclipse by default. Eclipse...
[ { "answer_id": 544727, "author": "shoosh", "author_id": 9611, "author_profile": "https://Stackoverflow.com/users/9611", "pm_score": 3, "selected": false, "text": "<p>like this:</p>\n\n<pre><code> Polygon &amp;currentPolygon = polygonList.front();\n currentPolygon.push_front(somePoint);\n...
2009/02/13
[ "https://Stackoverflow.com/questions/544725", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23072/" ]
I'm developing an Eclipse plugin and am going to start presenting it in conferences and other venues, so people will install it. One limitation of the plugin is that because of the amount of information it has to maintain to work, it needs more heap space than what is allocated to Eclipse by default. Eclipse runs with...
like this: ``` Polygon &currentPolygon = polygonList.front(); currentPolygon.push_front(somePoint); ``` the & sign before the name means this is a reference.
544,740
<p>I am to make a cut and a replace method on JTextArea. I have the code for copy and paste, and I reckon I could just use that, in addition to just deleting the marked text in the JTA.</p> <p>How would the code for a code for cut and replace methods look like?</p> <p>The code for copy looks like this:</p> <pre><cod...
[ { "answer_id": 544753, "author": "Adeel Ansari", "author_id": 42769, "author_profile": "https://Stackoverflow.com/users/42769", "pm_score": 2, "selected": false, "text": "<p>It would mixture of both methods, without <em>clipBoard</em> concatenation, I suppose.</p>\n\n<pre><code>public vo...
2009/02/13
[ "https://Stackoverflow.com/questions/544740", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37161/" ]
I am to make a cut and a replace method on JTextArea. I have the code for copy and paste, and I reckon I could just use that, in addition to just deleting the marked text in the JTA. How would the code for a code for cut and replace methods look like? The code for copy looks like this: ``` public void copy(){ in...
It would mixture of both methods, without *clipBoard* concatenation, I suppose. ``` public void cut(){ int start=ta.getSelectionStart(); int end=ta.getSelectionEnd(); String startText=ta.getText().substring(0, start); String endText=ta.getText().substring(end, ta.getText.length()); ta.setText(startText+endTe...
544,749
<p>I've got page to edit some html code from db, to do that I use openwysiwig <a href="http://www.openwebware.com/wysiwyg/demo.shtml" rel="nofollow noreferrer">http://www.openwebware.com/wysiwyg/demo.shtml</a> which hosts over textarea, functions implemented in editor to insert images and hyperlinks aren't quite suitab...
[ { "answer_id": 544753, "author": "Adeel Ansari", "author_id": 42769, "author_profile": "https://Stackoverflow.com/users/42769", "pm_score": 2, "selected": false, "text": "<p>It would mixture of both methods, without <em>clipBoard</em> concatenation, I suppose.</p>\n\n<pre><code>public vo...
2009/02/13
[ "https://Stackoverflow.com/questions/544749", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24824/" ]
I've got page to edit some html code from db, to do that I use openwysiwig <http://www.openwebware.com/wysiwyg/demo.shtml> which hosts over textarea, functions implemented in editor to insert images and hyperlinks aren't quite suitable for me, so I need to find some piece of code which help me to change/insert text to ...
It would mixture of both methods, without *clipBoard* concatenation, I suppose. ``` public void cut(){ int start=ta.getSelectionStart(); int end=ta.getSelectionEnd(); String startText=ta.getText().substring(0, start); String endText=ta.getText().substring(end, ta.getText.length()); ta.setText(startText+endTe...
544,750
<p>I want to display four (4) items'name from these id: Can I do like this?</p> <pre><code>SELECT item_name from items WHERE item_id IN ('001', '012', '103', '500') </code></pre> <p>or</p> <pre><code>SELECT item_name from items WHERE item_id = '001' or item_id = '012' or item_id = '103' or item_id = '500' </code></p...
[ { "answer_id": 544757, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 2, "selected": false, "text": "<p>Yes, both those should work fine. What's the actual problem you're seeing?</p>\n\n<p>If, as you say, only one record ...
2009/02/13
[ "https://Stackoverflow.com/questions/544750", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65379/" ]
I want to display four (4) items'name from these id: Can I do like this? ``` SELECT item_name from items WHERE item_id IN ('001', '012', '103', '500') ``` or ``` SELECT item_name from items WHERE item_id = '001' or item_id = '012' or item_id = '103' or item_id = '500' ``` **IN RESPONSE TO ALL ANSWERS** Well, mos...
You can do either one, but the IN query is much more efficient for this purpose for any large queries. I did some simple testing long ago that revealed it's about 10 times faster to use the IN construct for this. If you're asking if the syntax is correct then yes, it looks fine, other than missing semi-colons to comple...
544,774
<p>I just started using Git and I want to know if this is the right way of using it. I started a Rails app with:</p> <pre><code>rails newapp </code></pre> <p>Then I did:</p> <pre><code>cd newapp git init git add . git commit -a </code></pre> <p>So is it "right" to init my git inside my working directory?</p>
[ { "answer_id": 544783, "author": "Alex Wayne", "author_id": 62076, "author_profile": "https://Stackoverflow.com/users/62076", "pm_score": 0, "selected": false, "text": "<p>Yep. Looks good to me. </p>\n" }, { "answer_id": 544790, "author": "Thomas", "author_id": 14637, ...
2009/02/13
[ "https://Stackoverflow.com/questions/544774", "https://Stackoverflow.com", "https://Stackoverflow.com/users/58521/" ]
I just started using Git and I want to know if this is the right way of using it. I started a Rails app with: ``` rails newapp ``` Then I did: ``` cd newapp git init git add . git commit -a ``` So is it "right" to init my git inside my working directory?
Yes. You can place a git repository *anywhere* - including the invisible .git directory created by another git repository. I have a friend who has git track all his system config files in case he makes a mistake. When working on a project, you want to init your repository in the root directory of the project. To elab...
544,786
<p>I want to write a batch script that should read a text file line by line and search for a keyword.</p> <p>If the keyword is found it should return value 0 else it should return 1. Like this it should keep on incrementing the value until the end of the file. The output should go to a file.</p> <p>The sample log is ...
[ { "answer_id": 544796, "author": "Antti Huima", "author_id": 64376, "author_profile": "https://Stackoverflow.com/users/64376", "pm_score": 2, "selected": false, "text": "<p>On Unix</p>\n\n<pre><code>fgrep 'keyword' log.txt | wc -l\n</code></pre>\n" }, { "answer_id": 544805, "...
2009/02/13
[ "https://Stackoverflow.com/questions/544786", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65891/" ]
I want to write a batch script that should read a text file line by line and search for a keyword. If the keyword is found it should return value 0 else it should return 1. Like this it should keep on incrementing the value until the end of the file. The output should go to a file. The sample log is as follows, ``` ...
On Unix ``` fgrep 'keyword' log.txt | wc -l ```
544,791
<p>I have been working on an application in Django. To begin with, for simplicity, I had been using sqlite3 for the database.</p> <p>However, once I moved to PostgreSQL, I've run into a bit of a problem: the primary key does not reset once I clear out a table.</p> <p>This app is a game that is played over a long ti...
[ { "answer_id": 544830, "author": "superUntitled", "author_id": 54259, "author_profile": "https://Stackoverflow.com/users/54259", "pm_score": 0, "selected": false, "text": "<p>You need to truncate the table.\nSee <a href=\"http://www.postgresql.org/docs/8.1/static/sql-truncate.html\" rel=...
2009/02/13
[ "https://Stackoverflow.com/questions/544791", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12983/" ]
I have been working on an application in Django. To begin with, for simplicity, I had been using sqlite3 for the database. However, once I moved to PostgreSQL, I've run into a bit of a problem: the primary key does not reset once I clear out a table. This app is a game that is played over a long time period (weeks). ...
In your app directory try this: ``` python manage.py help sqlsequencereset ``` Pipe it into psql like this to actually run the reset: ``` python manage.py sqlsequencereset myapp1 myapp2 | psql ``` Edit: here's an example of the output from this command on one of my tables: ``` BEGIN; SELECT setval('"project_row_...
544,812
<p>I am using TinyScheme (actually Script-Fu in GIMP), and cannot find a good way to open a file and append a line of text to it.</p> <p>I am trying to log some info to the file for debugging, and transcript-on doesn't seem to be implemented...</p> <p>Right now I am scraping along by reading the entire file (one char...
[ { "answer_id": 544851, "author": "Charlie Martin", "author_id": 35092, "author_profile": "https://Stackoverflow.com/users/35092", "pm_score": 2, "selected": false, "text": "<p>It's going to be something like</p>\n<pre><code>(open-file &quot;myfile&quot; (file-options append))\n</code></p...
2009/02/13
[ "https://Stackoverflow.com/questions/544812", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am using TinyScheme (actually Script-Fu in GIMP), and cannot find a good way to open a file and append a line of text to it. I am trying to log some info to the file for debugging, and transcript-on doesn't seem to be implemented... Right now I am scraping along by reading the entire file (one character at a time!)...
It's going to be something like ``` (open-file "myfile" (file-options append)) ``` You want to look up the `file-options` function. ### Update Here's the [guile version](http://www.delorie.com/gnu/docs/guile/guile_317.html): ``` (open-file "myfilename.dat" "a") ```
544,823
<p>I am trying to send a php script some content to be stored in a database via ajax. I am using the jQuery framework. I would like to use a link on a page to send the information. I am having trouble writing the function that will send and receive the information, everything that I have tried is asymptotic.</p> <p><s...
[ { "answer_id": 544841, "author": "Scott Evernden", "author_id": 11397, "author_profile": "https://Stackoverflow.com/users/11397", "pm_score": 0, "selected": false, "text": "<p>did you really mean to declare your ajax success return function as </p>\n\n<pre><code>function(html)\n</code></...
2009/02/13
[ "https://Stackoverflow.com/questions/544823", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54259/" ]
I am trying to send a php script some content to be stored in a database via ajax. I am using the jQuery framework. I would like to use a link on a page to send the information. I am having trouble writing the function that will send and receive the information, everything that I have tried is asymptotic. **EDIT** Th...
The load() function in jQuery is really cool for this sort of thing. Here's an example. Basically, you have an outer div as a container. You call a script/service which returns html. You have a div in that html with an id that you will refer to later in the ajax call. The replacement div replaces the inner html of the...
544,825
<p>i want to know how to drop a constraint only if it exists. is there any single line statement present in mysql server which will allow me to do this.</p> <p>i have tried the following command but unable to get the desire output</p> <pre><code>alter table airlines drop foreign key if exits FK_airlines; </code></pr...
[ { "answer_id": 545028, "author": "gahooa", "author_id": 64004, "author_profile": "https://Stackoverflow.com/users/64004", "pm_score": 1, "selected": false, "text": "<p>I do not believe this is possible in a single line, unless you are <strong>willing</strong> to detect the error and move...
2009/02/13
[ "https://Stackoverflow.com/questions/544825", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
i want to know how to drop a constraint only if it exists. is there any single line statement present in mysql server which will allow me to do this. i have tried the following command but unable to get the desire output ``` alter table airlines drop foreign key if exits FK_airlines; ``` any help to this really he...
I do not believe this is possible in a single line, unless you are **willing** to detect the error and move on (not a bad thing). The INFORMATION\_SCHEMA database contains the info you need to tell if the foreign key exists, so you could implement it in a 2 step process. <http://dev.mysql.com/doc/refman/5.1/en/table-...
544,842
<p>Instead of using</p> <pre><code>std::vector&lt;Object&gt; ObjectArray; </code></pre> <p>I would like it to be</p> <pre><code>MyArray&lt;Object&gt; ObjectArray; </code></pre> <p>with all the std::vector methods preserved. (like push_back(), reserve(), ...etc)</p> <p>However, using</p> <pre><code>typedef std::ve...
[ { "answer_id": 544847, "author": "Thomas", "author_id": 14637, "author_profile": "https://Stackoverflow.com/users/14637", "pm_score": 5, "selected": true, "text": "<p>What you would really want is a templated typedef. Unfortunately those are not supported in the current version of C++, b...
2009/02/13
[ "https://Stackoverflow.com/questions/544842", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52415/" ]
Instead of using ``` std::vector<Object> ObjectArray; ``` I would like it to be ``` MyArray<Object> ObjectArray; ``` with all the std::vector methods preserved. (like push\_back(), reserve(), ...etc) However, using ``` typedef std::vector MyArray; ``` won't work. Should I use template instead? How?
What you would really want is a templated typedef. Unfortunately those are not supported in the current version of C++, but they will be added in C++0x. For now, here's a possible workaround: ``` template<class T> struct My { typedef std::vector<T> Array; }; My<Object>::Array ObjectArray ``` Whether or not tha...
544,845
<p>Last question for tonight, I promise. These pointers are giving me a serious headache.</p> <p>I have a std::list<code>&lt;Point</code>> called Polygon and a std::list of Polygons defined like:</p> <pre><code>typedef std::list&lt;Point&gt; Polygon; typedef std::list&lt;Polygon&gt; PolygonList; // List of all ou...
[ { "answer_id": 544858, "author": "shoosh", "author_id": 9611, "author_profile": "https://Stackoverflow.com/users/9611", "pm_score": 2, "selected": false, "text": "<p>You can't assign to a reference.<br>\nThis is a main difference between references in C++ and references in C# and the lik...
2009/02/13
[ "https://Stackoverflow.com/questions/544845", "https://Stackoverflow.com", "https://Stackoverflow.com/users/64878/" ]
Last question for tonight, I promise. These pointers are giving me a serious headache. I have a std::list`<Point`> called Polygon and a std::list of Polygons defined like: ``` typedef std::list<Point> Polygon; typedef std::list<Polygon> PolygonList; // List of all our polygons PolygonList polygonList; ``` I cr...
Other answers have pointed out what caused the error. As a general advice I would suggest not using references except in function arguments. The semantics are confusing, also for someone that will try to read your code. Try rewriting to something like this (I didn't test the code): ``` void deleteNearestPoint(int x, i...
544,865
<p>I have a template and need to create several xml files. The file contains one variable -this- to replace several times, save it as that name -this-.xml and then repeat for each of the values in my text or excel list or from a database - How would I best go about doing this?</p>
[ { "answer_id": 544904, "author": "marc_s", "author_id": 13302, "author_profile": "https://Stackoverflow.com/users/13302", "pm_score": 0, "selected": false, "text": "<p>Are you looking at doing this in code, or using a template-driven generator?</p>\n\n<p>Several choices:</p>\n\n<ul>\n<li...
2009/02/13
[ "https://Stackoverflow.com/questions/544865", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a template and need to create several xml files. The file contains one variable -this- to replace several times, save it as that name -this-.xml and then repeat for each of the values in my text or excel list or from a database - How would I best go about doing this?
Old school unix way (bash shell syntax): ``` for var in $(cat replacelist.txt); do sed "s/-this-/$var/g" < template.xml >$var.xml; done ```
544,884
<p>I am implementing Code Generation for WindowsForm control at Design-Time, using a Custom CodeDomSerializer. </p> <p>Here is what I have. </p> <ul> <li>A user control i.e. MyControl written in C#. </li> <li>MyControl has a property MyControlProperty of type ObjectXXX that is accessible publicly.(like myControl.MyCo...
[ { "answer_id": 544894, "author": "MrTelly", "author_id": 56092, "author_profile": "https://Stackoverflow.com/users/56092", "pm_score": 0, "selected": false, "text": "<p>Not sure if this will help, but have you looked at <a href=\"http://www.mygenerationsoftware.com/portal/default.aspx\" ...
2009/02/13
[ "https://Stackoverflow.com/questions/544884", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65912/" ]
I am implementing Code Generation for WindowsForm control at Design-Time, using a Custom CodeDomSerializer. Here is what I have. * A user control i.e. MyControl written in C#. * MyControl has a property MyControlProperty of type ObjectXXX that is accessible publicly.(like myControl.MyControlProperty). * The type Ob...
Thanks for the quick reply. I found the solution. What i need was generating code containing property access and generating code for of .NET types. To generate code that accesses a property, one should use CodePropertyReferenceExpression. This solves my problem with Line2. To generate code that contains a Type, one...
544,901
<p>I'm using mootools to toggle the display (and existence) of two DOM elements in one of my forms. Then, I am using javascript to validate the form to make sure that all of the required fields were filled in. The problem is that the the browser seems to be caching the elements. For example, I have html like this:</...
[ { "answer_id": 544912, "author": "Steven Oxley", "author_id": 3831, "author_profile": "https://Stackoverflow.com/users/3831", "pm_score": 1, "selected": false, "text": "<p>Well, I can answer the second part of my question now: how to fix it. If you are using mootools, then use the dolla...
2009/02/13
[ "https://Stackoverflow.com/questions/544901", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3831/" ]
I'm using mootools to toggle the display (and existence) of two DOM elements in one of my forms. Then, I am using javascript to validate the form to make sure that all of the required fields were filled in. The problem is that the the browser seems to be caching the elements. For example, I have html like this: ``` <i...
Evaluating an element by name (form.elementName) when non-existent returns undefined. Evaluating the property value of an object ($('elementId')) returns null. Undefined and null are treated differently.
544,906
<p>I am trying to get the current Windows theme name in C# but it has turned out to be a little tougher than expected. I have a code sample from MSDN:</p> <pre><code>public void Test() { StringBuilder themeFileName = new StringBuilder(0x200); GetCurrentThemeName(themeFileName, themeFileName.Capacity, null, 0,...
[ { "answer_id": 544970, "author": "Xn0vv3r", "author_id": 42475, "author_profile": "https://Stackoverflow.com/users/42475", "pm_score": 3, "selected": true, "text": "<p><a href=\"http://www.codeproject.com/KB/miscctrl/uxtheme.aspx\" rel=\"nofollow noreferrer\">That article on CodeProject<...
2009/02/13
[ "https://Stackoverflow.com/questions/544906", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1053/" ]
I am trying to get the current Windows theme name in C# but it has turned out to be a little tougher than expected. I have a code sample from MSDN: ``` public void Test() { StringBuilder themeFileName = new StringBuilder(0x200); GetCurrentThemeName(themeFileName, themeFileName.Capacity, null, 0, null, 0); ...
[That article on CodeProject](http://www.codeproject.com/KB/miscctrl/uxtheme.aspx) describes how to get "the current visual style information" (search for that string in the article). It contains sample code how to do that.
544,907
<p>How do I remove the red boxes from my hyperlinked table of contents created by using the hyperref package in LaTeX.</p>
[ { "answer_id": 544950, "author": "alamodey", "author_id": 58521, "author_profile": "https://Stackoverflow.com/users/58521", "pm_score": 5, "selected": false, "text": "<pre><code>\\usepackage{hyperref}\n\\hypersetup{\n colorlinks,\n citecolor=black,\n filecolor=black,\n linkco...
2009/02/13
[ "https://Stackoverflow.com/questions/544907", "https://Stackoverflow.com", "https://Stackoverflow.com/users/58521/" ]
How do I remove the red boxes from my hyperlinked table of contents created by using the hyperref package in LaTeX.
To remove the borders: ``` \hypersetup{% pdfborder = {0 0 0} } ``` The `colorlinks` option will turn on the link colors and also remove the borders. (This is why alamodey set all the link colors to black.)
544,908
<p>I'm running in to a lot of inconsistencies with regards to what will compile and execute correctly in a Visual Web Developer 2008 Express environment and what fails on my web server.</p> <p>In particular, I've got an aspx and aspx.cs codebehind, plus a number of additional .cs files in my Web Developer project. It...
[ { "answer_id": 544930, "author": "Canavar", "author_id": 55351, "author_profile": "https://Stackoverflow.com/users/55351", "pm_score": 3, "selected": true, "text": "<p>It seems like you have a deployment problem.</p>\n\n<p>Just <strong>publish</strong> (in build menu there is a publish i...
2009/02/13
[ "https://Stackoverflow.com/questions/544908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56998/" ]
I'm running in to a lot of inconsistencies with regards to what will compile and execute correctly in a Visual Web Developer 2008 Express environment and what fails on my web server. In particular, I've got an aspx and aspx.cs codebehind, plus a number of additional .cs files in my Web Developer project. It builds fin...
It seems like you have a deployment problem. Just **publish** (in build menu there is a publish item) your web application/site to a folder and then move the files in that folder to your server. I think you have old assembly files and new classes in your directory. hope this helps
544,921
<p>I am trying to determine the best way to handle getting rid of newlines when reading in newline delimited files in Python.</p> <p>What I've come up with is the following code, include throwaway code to test.</p> <pre><code>import os def getfile(filename,results): f = open(filename) filecontents = f.readlines(...
[ { "answer_id": 544932, "author": "Curt Hagenlocher", "author_id": 533, "author_profile": "https://Stackoverflow.com/users/533", "pm_score": 9, "selected": true, "text": "<pre><code>lines = open(filename).read().splitlines()\n</code></pre>\n" }, { "answer_id": 544935, "author"...
2009/02/13
[ "https://Stackoverflow.com/questions/544921", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2519/" ]
I am trying to determine the best way to handle getting rid of newlines when reading in newline delimited files in Python. What I've come up with is the following code, include throwaway code to test. ``` import os def getfile(filename,results): f = open(filename) filecontents = f.readlines() for line in fi...
``` lines = open(filename).read().splitlines() ```
544,923
<p>I know this question has been asked before, but there was no clear answer. </p> <p>How do I change the printer tray programmatically?</p> <p>I am trying to use python to batch print some PDFs. I need to print different pages from different trays. The printer is a Ricoh 2232C. Is there a way to do it through an...
[ { "answer_id": 544963, "author": "Noah", "author_id": 12113, "author_profile": "https://Stackoverflow.com/users/12113", "pm_score": 1, "selected": false, "text": "<p>There is no easy way to do this, since you indicate you want to choose specific pages from the pdf and print them to speci...
2009/02/13
[ "https://Stackoverflow.com/questions/544923", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41713/" ]
I know this question has been asked before, but there was no clear answer. How do I change the printer tray programmatically? I am trying to use python to batch print some PDFs. I need to print different pages from different trays. The printer is a Ricoh 2232C. Is there a way to do it through and Acrobat Reader comm...
Ok, I figured this out. The answer is: 1. you need a local printer (if you need to print to a network printer, download the drivers and add it as a local printer) 2. use win32print to get and set default printer 3. also using win32print, use the following code: ``` import win32print PRINTER_DEFAULTS = {...
544,924
<p>Using <code>SocketChannel sc =(SocketChannel)key.channel();</code>, we can fetch data from port into buffer.<br> In order to receive the data continuously from port without the loss of data, how the code should be ?</p> <p>Here is my code</p> <pre><code>import java.io.*; import java.net.*; import java.nio.*; impor...
[ { "answer_id": 545002, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 0, "selected": false, "text": "<p>You can find some leads in this <a href=\"http://www.koders.com/java/fid3CD88A21886023A09357484BC6E96F4246D5FC06.aspx?s=Sock...
2009/02/13
[ "https://Stackoverflow.com/questions/544924", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Using `SocketChannel sc =(SocketChannel)key.channel();`, we can fetch data from port into buffer. In order to receive the data continuously from port without the loss of data, how the code should be ? Here is my code ``` import java.io.*; import java.net.*; import java.nio.*; import java.nio.channels.*; import jav...
The maximum size you can read is effectively limited by the amount of memory you have. However you don't need to read super large blocks for efficiency. You should find that 1 MB is more than enough. In fact you may find that blocks of 4KB are large enough to get maximum bandwidth for a 1 Gb connection.
544,928
<p>I want to read <code>sizeof(int)</code> bytes from a <code>char*</code> array.</p> <p>a) In what scenario's do we need to worry if endianness needs to be checked?</p> <p>b) How would you read the first 4 bytes either taking endianness into consideration or not.</p> <p><strong>EDIT :</strong> The <code>sizeof(int...
[ { "answer_id": 544947, "author": "Steve Rowe", "author_id": 40744, "author_profile": "https://Stackoverflow.com/users/40744", "pm_score": 1, "selected": false, "text": "<p>You shouldn't need to worry about endianess unless you are reading the bytes from a source created on a different ma...
2009/02/13
[ "https://Stackoverflow.com/questions/544928", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43756/" ]
I want to read `sizeof(int)` bytes from a `char*` array. a) In what scenario's do we need to worry if endianness needs to be checked? b) How would you read the first 4 bytes either taking endianness into consideration or not. **EDIT :** The `sizeof(int)` bytes that I have read needs to be compared with an integer va...
Do you mean something like that?: ``` char* a; int i; memcpy(&i, a, sizeof(i)); ``` You only have to worry about endianess if the source of the data is from a different platform, like a device.
544,936
<p>So if you have a html List Box, also called a multiple select, and you want to generate a comma delimited string that lists all the values in that List Box you can you can do that with the following example. The list_to_string() js function is the only important thing here. You can play with this page at <a href="h...
[ { "answer_id": 545037, "author": "shiftins", "author_id": 8162, "author_profile": "https://Stackoverflow.com/users/8162", "pm_score": 1, "selected": false, "text": "<p>You could use array.join(','); to create a comma separated list from an array.</p>\n\n<p>Something like this, only bette...
2009/02/13
[ "https://Stackoverflow.com/questions/544936", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56069/" ]
So if you have a html List Box, also called a multiple select, and you want to generate a comma delimited string that lists all the values in that List Box you can you can do that with the following example. The list\_to\_string() js function is the only important thing here. You can play with this page at <http://josh...
String concatenation is very slow on IE, use an array instead: ``` function listBoxToString(listBox,all) { if (typeof listBox === "string") { listBox = document.getElementById(listBox); } if (!(listBox || listBox.options)) { throw Error("No options"); } var options=[],opt; for (...
544,974
<p>I want to search a sentence (word combination of) in some table or view of DB. I dont want to use Fultext search property of DB. Is there any alternative efficient way? </p>
[ { "answer_id": 544981, "author": "Learning", "author_id": 18275, "author_profile": "https://Stackoverflow.com/users/18275", "pm_score": 2, "selected": false, "text": "<p>None as efficient as Fulltext search.</p>\n\n<p>Basically it boils down to <em>where</em> with <em>like</em> derivativ...
2009/02/13
[ "https://Stackoverflow.com/questions/544974", "https://Stackoverflow.com", "https://Stackoverflow.com/users/63305/" ]
I want to search a sentence (word combination of) in some table or view of DB. I dont want to use Fultext search property of DB. Is there any alternative efficient way?
Without the use of an index, a database has to perform a "full table scan". This is rather like you looking through a book one page at a time to find what you need. That being said, computers are a lot faster than humans. It really depends on how much load your system has. Using MySQL we successfully implemented a se...
544,986
<p>I need to get the bit rate of a mp3 file which is being streamed as a netstream object in flash action scripting. I am using Flash Media Server 3.2.</p> <p>I need the bitrate to calculate the duration of the mp3 file using the formula: Duration = file size in bytes / bitrate</p>
[ { "answer_id": 544981, "author": "Learning", "author_id": 18275, "author_profile": "https://Stackoverflow.com/users/18275", "pm_score": 2, "selected": false, "text": "<p>None as efficient as Fulltext search.</p>\n\n<p>Basically it boils down to <em>where</em> with <em>like</em> derivativ...
2009/02/13
[ "https://Stackoverflow.com/questions/544986", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53270/" ]
I need to get the bit rate of a mp3 file which is being streamed as a netstream object in flash action scripting. I am using Flash Media Server 3.2. I need the bitrate to calculate the duration of the mp3 file using the formula: Duration = file size in bytes / bitrate
Without the use of an index, a database has to perform a "full table scan". This is rather like you looking through a book one page at a time to find what you need. That being said, computers are a lot faster than humans. It really depends on how much load your system has. Using MySQL we successfully implemented a se...
544,991
<p>I ended up with something like the following code in a project I'm working on. I thought it was really odd that I was allowed to do it, but now I'm starting wonder what is most likely an architectural gaff on my part led me to this.</p> <p>My questions to you are:</p> <ul> <li>What exactly is this called?</li> <li...
[ { "answer_id": 545025, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 2, "selected": false, "text": "<p>Each type has an <a href=\"http://msdn.microsoft.com/en-us/library/system.reflection.interfacemapping.aspx\" rel=\"no...
2009/02/13
[ "https://Stackoverflow.com/questions/544991", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1894/" ]
I ended up with something like the following code in a project I'm working on. I thought it was really odd that I was allowed to do it, but now I'm starting wonder what is most likely an architectural gaff on my part led me to this. My questions to you are: * What exactly is this called? * What are some real world us...
There is absolutely nothing wrong with this code (provided it isn't confusing for your users), and it isn't a pattern with any name that I'm familiar with. `CanDoThisAndThat` implements two interfaces, so clients can use it in either way. .NET allows interfaces to be implemented this way -- known as *explicit interfac...
544,993
<p>In jQuery when you do this:</p> <pre><code>$(function() { alert("DOM is loaded, but images not necessarily all loaded"); }); </code></pre> <p>It waits for the DOM to load and executes your code. If all the images are not loaded then it still executes the code. This is obviously what we want if we're initializin...
[ { "answer_id": 545005, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 11, "selected": true, "text": "<p>With jQuery, you use <code>$(document).ready()</code> to execute something when the <em>DOM</em> is loaded and <code>...
2009/02/13
[ "https://Stackoverflow.com/questions/544993", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16940/" ]
In jQuery when you do this: ``` $(function() { alert("DOM is loaded, but images not necessarily all loaded"); }); ``` It waits for the DOM to load and executes your code. If all the images are not loaded then it still executes the code. This is obviously what we want if we're initializing any DOM stuff such as sh...
With jQuery, you use `$(document).ready()` to execute something when the *DOM* is loaded and `$(window).on("load", handler)` to execute something when all other things are loaded as well, such as the images. The difference can be seen in the following complete HTML file, provided you have a lot of `jollyrogerNN` JPEG ...
545,014
<p>I have a C# Excel Add-in project "MyExcelAddIn" that has a public method Foo() to do something complex. For testing purposes, the add-in also defines a toolbar button which is wired to Foo() so I can test this and verify that clicking the button calls Foo() and does what I want it to do. This is fine.</p> <p>Now I ...
[ { "answer_id": 545084, "author": "Jakob Christensen", "author_id": 64161, "author_profile": "https://Stackoverflow.com/users/64161", "pm_score": 0, "selected": false, "text": "<p>I assume that your method Foo somehow interacts with Excel. Otherwise you can just add a reference to the as...
2009/02/13
[ "https://Stackoverflow.com/questions/545014", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11163/" ]
I have a C# Excel Add-in project "MyExcelAddIn" that has a public method Foo() to do something complex. For testing purposes, the add-in also defines a toolbar button which is wired to Foo() so I can test this and verify that clicking the button calls Foo() and does what I want it to do. This is fine. Now I want to ca...
I'm using the SendMessage Win32 API to do this. My C# Add-in creates a "NativeWindow" with a uniqe window title that the WinForm app can locate.
545,018
<pre><code>sscanf(input_str, "%5s", buf); //reads at max 5 characters from input_str to buf </code></pre> <p>But I need to use something like %MACRO_SIZEs instead of %5s</p> <p>A trivial solution is to create a format string for the same</p> <pre><code>char fmt_str[100] = ""; snprintf(fmt_str, 100, "%%%ds", MACR...
[ { "answer_id": 545027, "author": "Stefan", "author_id": 48003, "author_profile": "https://Stackoverflow.com/users/48003", "pm_score": 4, "selected": true, "text": "<p>if your MACRO_SIZE is const at compile time, you can try this:</p>\n\n<pre><code>#define MACRO_SIZE \"5\"\nsnprintf(fmt_s...
2009/02/13
[ "https://Stackoverflow.com/questions/545018", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29405/" ]
``` sscanf(input_str, "%5s", buf); //reads at max 5 characters from input_str to buf ``` But I need to use something like %MACRO\_SIZEs instead of %5s A trivial solution is to create a format string for the same ``` char fmt_str[100] = ""; snprintf(fmt_str, 100, "%%%ds", MACRO_SIZE); sscanf(input_str, fmt_str, ...
if your MACRO\_SIZE is const at compile time, you can try this: ``` #define MACRO_SIZE "5" snprintf(fmt_str, 100, "%" MACRO_SIZE "s", buf); ```
545,024
<p>I have a user control that conatins HTML, like this:</p> <pre><code>&lt;table id="tblProgramInfo" runat="server" cellpadding="0" cellspacing="0" class="ProgramInfo"&gt; &lt;tr&gt; &lt;td&gt; &lt;table cellpadding="0" cellspacing="0" width="100%" class="tblProgram" abc="def"&gt; &lt;tr&gt; ...
[ { "answer_id": 545031, "author": "Rog", "author_id": 65338, "author_profile": "https://Stackoverflow.com/users/65338", "pm_score": 1, "selected": false, "text": "<pre><code>$(this).find('.tblProgram').css({ borderColor:\"cdd6e8\" });\n</code></pre>\n" }, { "answer_id": 545057, ...
2009/02/13
[ "https://Stackoverflow.com/questions/545024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2572740/" ]
I have a user control that conatins HTML, like this: ``` <table id="tblProgramInfo" runat="server" cellpadding="0" cellspacing="0" class="ProgramInfo"> <tr> <td> <table cellpadding="0" cellspacing="0" width="100%" class="tblProgram" abc="def"> <tr> <td> Some ...
Look into the jQuery hover() method: <http://docs.jquery.com/Events/hover> It provides a cleaner abstraction for mouseover/-out
545,062
<p>I was reading another answer. And it made me wonder, when do does one need to explicitly call Dispose if I am using <code>using</code> statements? </p> <p>EDIT: </p> <p>Just to vindicate myself from being a total know-nothing, the reason I asked was because someone on another thread said something implying there...
[ { "answer_id": 545066, "author": "Svish", "author_id": 39321, "author_profile": "https://Stackoverflow.com/users/39321", "pm_score": 5, "selected": true, "text": "<p>You don't. The <code>using</code> statement does it for you.</p>\n\n<hr>\n\n<p>According to <a href=\"http://msdn.microsof...
2009/02/13
[ "https://Stackoverflow.com/questions/545062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47630/" ]
I was reading another answer. And it made me wonder, when do does one need to explicitly call Dispose if I am using `using` statements? EDIT: Just to vindicate myself from being a total know-nothing, the reason I asked was because someone on another thread said something implying there was a good reason to have to ...
You don't. The `using` statement does it for you. --- According to [MSDN](http://msdn.microsoft.com/en-us/library/yh598w02.aspx), this code example: ``` using (Font font1 = new Font("Arial", 10.0f)) { byte charset = font1.GdiCharSet; } ``` is expanded, when compiled, to the following code (note the extra curl...
545,076
<p>I have an ASP.NET MVC View that works great on IE7, but looks really crappy when I try to view it with IE6. With IE6, the white area of the page (the ContentPlaceHolder part) is bunched over to the right and does weird things like move around when I resize the window. I have looked in the .aspx, Site.Master, and S...
[ { "answer_id": 545096, "author": "superUntitled", "author_id": 54259, "author_profile": "https://Stackoverflow.com/users/54259", "pm_score": 1, "selected": false, "text": "<p>Having a width of 90% on your page wrap may not be the best idea. Setting a pixel value (say 800px) will eliminat...
2009/02/13
[ "https://Stackoverflow.com/questions/545076", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14101/" ]
I have an ASP.NET MVC View that works great on IE7, but looks really crappy when I try to view it with IE6. With IE6, the white area of the page (the ContentPlaceHolder part) is bunched over to the right and does weird things like move around when I resize the window. I have looked in the .aspx, Site.Master, and Site.c...
Having a width of 90% on your page wrap may not be the best idea. Setting a pixel value (say 800px) will eliminate some of the issues you may be having with jumping content. Also, you should modify div#title and div#logindisplay ``` #title { width: 600px; float:left; } #logindisplay { font-size:1.1em; ...
545,077
<p>I want to convert a link to a definite text by using regular expression.While binding datagrid,i have a function which convert (look: the text) to link.My Function is here.</p> <pre><code>Private Function Convertlook(ByVal str As String) As String Dim look As String Dim pattern As String = "\(look:...
[ { "answer_id": 545160, "author": "soulmerge", "author_id": 44562, "author_profile": "https://Stackoverflow.com/users/44562", "pm_score": 2, "selected": true, "text": "<p>Looks like the regex can be reduced to 'anything between the angle brackets'</p>\n\n<pre><code>Dim regex As New Regex(...
2009/02/13
[ "https://Stackoverflow.com/questions/545077", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to convert a link to a definite text by using regular expression.While binding datagrid,i have a function which convert (look: the text) to link.My Function is here. ``` Private Function Convertlook(ByVal str As String) As String Dim look As String Dim pattern As String = "\(look: ([a-z0-9$&.öı...
Looks like the regex can be reduced to 'anything between the angle brackets' ``` Dim regex As New Regex(".*>(.*)</font.*", RegexOptions.IgnoreCase) str = regex.Replace(str, "(look: $1)") ```
545,082
<p>I'm building a small program that acts as an XMPP client and I am using the <a href="http://www.igniterealtime.org/projects/smack/index.jsp" rel="noreferrer">Smack</a> library. Now, the server I am connecting to requires SSL (in Pidgin I have to check "Force old (port 5223) SSL"). I'm having trouble getting Smack to...
[ { "answer_id": 1359613, "author": "deeringc", "author_id": 100791, "author_profile": "https://Stackoverflow.com/users/100791", "pm_score": 2, "selected": false, "text": "<p>Yes, it's quite easy to achieve. Take a look at the <a href=\"http://www.igniterealtime.org/builds/smack/docs/lates...
2009/02/13
[ "https://Stackoverflow.com/questions/545082", "https://Stackoverflow.com", "https://Stackoverflow.com/users/988/" ]
I'm building a small program that acts as an XMPP client and I am using the [Smack](http://www.igniterealtime.org/projects/smack/index.jsp) library. Now, the server I am connecting to requires SSL (in Pidgin I have to check "Force old (port 5223) SSL"). I'm having trouble getting Smack to connect to this server. Is it ...
Take a look at this thread. <http://www.igniterealtime.org/community/thread/37678> Essentially, you need to add these two lines to your code: ``` connConfig.setSecurityMode(ConnectionConfiguration.SecurityMode.enabled); connConfig.setSocketFactory(new DummySSLSocketFactory()); ``` where connConfig is your Connecti...
545,091
<p>I'm using <code>+[NSUserDefaults standardUserDefaults]</code> to store application settings. This consists of roughly a dozen string values. Is it possible to delete these values permanently instead of just setting them to a default value?</p>
[ { "answer_id": 545099, "author": "sbooth", "author_id": 31520, "author_profile": "https://Stackoverflow.com/users/31520", "pm_score": 7, "selected": false, "text": "<p>Did you try using -<code>removeObjectForKey</code>?</p>\n\n<pre><code> [[NSUserDefaults standardUserDefaults] removeObje...
2009/02/13
[ "https://Stackoverflow.com/questions/545091", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51630/" ]
I'm using `+[NSUserDefaults standardUserDefaults]` to store application settings. This consists of roughly a dozen string values. Is it possible to delete these values permanently instead of just setting them to a default value?
You can remove the application's persistent domain like this: ``` NSString *appDomain = [[NSBundle mainBundle] bundleIdentifier]; [[NSUserDefaults standardUserDefaults] removePersistentDomainForName:appDomain]; ``` In Swift 3 and later: ``` if let bundleID = Bundle.main.bundleIdentifier { UserDefaults.standard....
545,093
<p>At school we have been using a bootstrap program to run stand-alone programs without an operating system. I have been studying this program and when protected mode is enabled there is a far jump executed by directly assembling the opcode and operands as data within the program. This was for the GNU assembler:</p> <...
[ { "answer_id": 545115, "author": "Diego Sevilla", "author_id": 62365, "author_profile": "https://Stackoverflow.com/users/62365", "pm_score": 5, "selected": true, "text": "<p>The 0x66 indicates that the JMP (0xEA) refers to six bytes. The default is refering to 64K (16 bits) in real mode ...
2009/02/13
[ "https://Stackoverflow.com/questions/545093", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65928/" ]
At school we have been using a bootstrap program to run stand-alone programs without an operating system. I have been studying this program and when protected mode is enabled there is a far jump executed by directly assembling the opcode and operands as data within the program. This was for the GNU assembler: ``` ...
The 0x66 indicates that the JMP (0xEA) refers to six bytes. The default is refering to 64K (16 bits) in real mode or to 32 bits in protected mode (if I recall well). Having it increased, it also includes the segment descriptor, the index of the segment either in the GDT or the LDT, which means, that this code is making...
545,124
<p>I am new to AS3. When learning AS3, I get the below code from an Adobe example and trying to run it gives an error like</p> <pre><code> "1037: Packages cannot be nested." </code></pre> <p>What does this mean?</p> <p>Please tell me how to execute? or any problem in this code?</p> <pre><code>package { import f...
[ { "answer_id": 545147, "author": "Richard Szalay", "author_id": 3603, "author_profile": "https://Stackoverflow.com/users/3603", "pm_score": 3, "selected": true, "text": "<p>Your code should compile, provided that it is in the root source folder (\"src\" in flex builder). Are you sure tha...
2009/02/13
[ "https://Stackoverflow.com/questions/545124", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54128/" ]
I am new to AS3. When learning AS3, I get the below code from an Adobe example and trying to run it gives an error like ``` "1037: Packages cannot be nested." ``` What does this mean? Please tell me how to execute? or any problem in this code? ``` package { import flash.display.Sprite; import flash.text.T...
Your code should compile, provided that it is in the root source folder ("src" in flex builder). Are you sure that's the entire file? The error means that you have nested a package {} statement inside another package {} statement.
545,127
<p>Does anyone know how to set the path for DirectoryInfo when I want to map to a folder named images on webRoot. /images</p> <p>Any help much appreciated, Thanks</p>
[ { "answer_id": 545133, "author": "Sessiz Saat", "author_id": 63305, "author_profile": "https://Stackoverflow.com/users/63305", "pm_score": 2, "selected": false, "text": "<pre><code>String virtualPath= \"~\\\\images\";\nString RealPath=Server.MapPath(virtualPath); //it must be done at we...
2009/02/13
[ "https://Stackoverflow.com/questions/545127", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17510/" ]
Does anyone know how to set the path for DirectoryInfo when I want to map to a folder named images on webRoot. /images Any help much appreciated, Thanks
If you have a path relative to your web-app, you'll need to map it with the MapPath(...) method. In the Page class: ``` string fullyQualifiedFilename = Server.MapPath(relativeFilename); ``` or outside of the page class: ``` string fullyQualifiedFilename = HttpContext.Current.Server.MapPath(relativeFilename); ```
545,146
<p>i want to pass a variable from a viewcontroller to another the way i do is at the first viewcontroller header file i declared a variable</p> <p>1.h:</p> <p><strong>NSString *string;</strong></p> <p>and at the second viewcontroller i have import the 1.h in my 2.m file,the way i call the variable is </p> <p>2.m:<...
[ { "answer_id": 545273, "author": "Andrew Grant", "author_id": 1043, "author_profile": "https://Stackoverflow.com/users/1043", "pm_score": 0, "selected": false, "text": "<p>Although it is possible to directly access members variables like that (using the -> operator) it is not recommended...
2009/02/13
[ "https://Stackoverflow.com/questions/545146", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
i want to pass a variable from a viewcontroller to another the way i do is at the first viewcontroller header file i declared a variable 1.h: **NSString \*string;** and at the second viewcontroller i have import the 1.h in my 2.m file,the way i call the variable is 2.m: **NSString \*string2 = 1.string** however...
Just defining and declaring the two strings is not enough. That makes sure that each class has a variable called string or string2 - but when your program is running, it is actual objects that must refer to specific instances of string1 (or string2). It's like designing a house with a letterbox - the letterbox is ther...
545,164
<p>I am using PHP and mysql.</p> <p>Scenario:</p> <p>The registration form only required 2 fields. Email and password, and then, first user registered from England, second user from China, etc..</p> <p>Is there any way to set timezone automatically for different countries of users in PHP? I checked php.net, but no l...
[ { "answer_id": 545185, "author": "soulmerge", "author_id": 44562, "author_profile": "https://Stackoverflow.com/users/44562", "pm_score": 1, "selected": false, "text": "<p>No, that's not possible through php, since the browser doesn't always send that information. Last time we solved that...
2009/02/13
[ "https://Stackoverflow.com/questions/545164", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65379/" ]
I am using PHP and mysql. Scenario: The registration form only required 2 fields. Email and password, and then, first user registered from England, second user from China, etc.. Is there any way to set timezone automatically for different countries of users in PHP? I checked php.net, but no lucks..
You could attempt to infer their [country from their IP](http://www.maxmind.com/app/geolitecountry), and derive their timezone from that. Alternatively, add something like this to the form and get Javascript to tell you the time zone offset used by the browser... ``` <script language="JavaScript"> <!-- var d= n...
545,171
<p>I am trying to develop an online exam app with JSP. So I want to link to the results page with the same parameters of the current page (exam page) when a certain period of time runs out. I want to know how to add a timer and how to link to another page when the time is out. Thanks.</p>
[ { "answer_id": 545218, "author": "Per Stilling", "author_id": 65584, "author_profile": "https://Stackoverflow.com/users/65584", "pm_score": 2, "selected": false, "text": "<p>You need to use Javascript to achieve this. There you'll need to create a JS segment looking something like this:<...
2009/02/13
[ "https://Stackoverflow.com/questions/545171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am trying to develop an online exam app with JSP. So I want to link to the results page with the same parameters of the current page (exam page) when a certain period of time runs out. I want to know how to add a timer and how to link to another page when the time is out. Thanks.
You need to use Javascript to achieve this. There you'll need to create a JS segment looking something like this: ``` <script type="text/javascript"> var myTimer = window.setTimeout(timer, 3000); function timer() { window.location.href = "new_page.htm" } </script> ``` That script is meant for going into t...
545,173
<p>I'm trying to send faxes with a .NET (C#) program using Crystal Reports and Unimessage Pro (or any other fax program).</p> <p>My problem is that Unimessage Pro (and other fax programs) uses printer fonts for the fax commands. Since .NET doesn't support printer fonts the fax commands in the report are converted to C...
[ { "answer_id": 546451, "author": "Douglas Anderson", "author_id": 5678, "author_profile": "https://Stackoverflow.com/users/5678", "pm_score": 0, "selected": false, "text": "<p>When you say uses printer fonts, I'm assuming that you need to send some PCL (or similar) commands such as:</p>\...
2009/02/13
[ "https://Stackoverflow.com/questions/545173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65941/" ]
I'm trying to send faxes with a .NET (C#) program using Crystal Reports and Unimessage Pro (or any other fax program). My problem is that Unimessage Pro (and other fax programs) uses printer fonts for the fax commands. Since .NET doesn't support printer fonts the fax commands in the report are converted to Courier New...
I got this answer from WordCraft (company behind Unimessage Pro) > > 1. Create a file named WilCapAX.INI in the main Windows folder, e.g. > C:\Windows\WilCapAX.INI The file > should contain the following: > [WilCapAX] > Commands=C:\Commands.DAT Where "C:\Commands.DAT" is the name of > a text file you are going t...
545,177
<p>I want to use a Java file <code>SaveProp</code> which is written in a package <code>user</code>. The class file has been placed in <code>WEBINF/classes</code>. Below are the two lines which cause the issue.</p> <pre><code>jsp:useBean id="user" class="user.SaveProp" scope="session" jsp:setProperty name="user" prope...
[ { "answer_id": 545265, "author": "kgiannakakis", "author_id": 24054, "author_profile": "https://Stackoverflow.com/users/24054", "pm_score": 5, "selected": true, "text": "<p>You should put the file under WEBINF/classes/user</p>\n" }, { "answer_id": 1764211, "author": "tiktock"...
2009/02/13
[ "https://Stackoverflow.com/questions/545177", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62835/" ]
I want to use a Java file `SaveProp` which is written in a package `user`. The class file has been placed in `WEBINF/classes`. Below are the two lines which cause the issue. ``` jsp:useBean id="user" class="user.SaveProp" scope="session" jsp:setProperty name="user" property="*" ``` It throws: ``` The value for the...
You should put the file under WEBINF/classes/user
545,181
<p>I want to catch exceptions in javascript if an insertion query is not done.</p> <p>I have written the code below:</p> <pre><code>var adoConn = new ActiveXObject("ADODB.Connection"); var adoRS = new ActiveXObject("ADODB.Recordset"); var rec = new ActiveXObject("ADODB.Record"); adoConn.Open="DRIVER={MySQL ODBC 3.51 ...
[ { "answer_id": 545192, "author": "KooiInc", "author_id": 58186, "author_profile": "https://Stackoverflow.com/users/58186", "pm_score": 1, "selected": false, "text": "<pre><code>try {\n adoConn.Execute(\"insert into session (SessionId,Timestamp) values ('\"\n + Sess...
2009/02/13
[ "https://Stackoverflow.com/questions/545181", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to catch exceptions in javascript if an insertion query is not done. I have written the code below: ``` var adoConn = new ActiveXObject("ADODB.Connection"); var adoRS = new ActiveXObject("ADODB.Recordset"); var rec = new ActiveXObject("ADODB.Record"); adoConn.Open="DRIVER={MySQL ODBC 3.51 Driver};SERVER=172.25...
To be complete, here's the full structure ``` try { // your code that can throw exception goes here } catch(e) { //do stuff with the exception } finally { //regardless if it worked or not, do stuff here (cleanup?) } ```
545,194
<p>I have a problematic situation with some quite advanced unit tests (using PowerMock for mocking and JUnit 4.5). Without going into too much detail, the first test case of a test class will always succeed, but any following test cases in the same test class fails. However, if I select to only run test case 5 out of 1...
[ { "answer_id": 545224, "author": "Itay Maman", "author_id": 27198, "author_profile": "https://Stackoverflow.com/users/27198", "pm_score": 3, "selected": false, "text": "<p>It seems that your test cases are dependent, that is: the execution of case-X affects the execution of case-Y. Such ...
2009/02/13
[ "https://Stackoverflow.com/questions/545194", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22012/" ]
I have a problematic situation with some quite advanced unit tests (using PowerMock for mocking and JUnit 4.5). Without going into too much detail, the first test case of a test class will always succeed, but any following test cases in the same test class fails. However, if I select to only run test case 5 out of 10, ...
Your problem is not that JUnit runs all the tests at once, you problem is that you don't see *why* a test fails. Solutions: 1. Add more asserts to the tests to make sure that every variable actually contains what you think 2. Download an IDE from the Internet and use the built-in debugger to look at the various variab...
545,197
<p>I published an orchestration in Biztalk as a webservice. Does anyone know how I can use XML serialization or something to load XML from a file and "convert" it to the messagetype the webservice expects? How do people usually use this webservices? I try to avoid using untyped messages since I use both XML and flatf...
[ { "answer_id": 545224, "author": "Itay Maman", "author_id": 27198, "author_profile": "https://Stackoverflow.com/users/27198", "pm_score": 3, "selected": false, "text": "<p>It seems that your test cases are dependent, that is: the execution of case-X affects the execution of case-Y. Such ...
2009/02/13
[ "https://Stackoverflow.com/questions/545197", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I published an orchestration in Biztalk as a webservice. Does anyone know how I can use XML serialization or something to load XML from a file and "convert" it to the messagetype the webservice expects? How do people usually use this webservices? I try to avoid using untyped messages since I use both XML and flatfile, ...
Your problem is not that JUnit runs all the tests at once, you problem is that you don't see *why* a test fails. Solutions: 1. Add more asserts to the tests to make sure that every variable actually contains what you think 2. Download an IDE from the Internet and use the built-in debugger to look at the various variab...
545,253
<p>Let me start off by saying that I'm pretty new to flex and action script. Anyways, I'm trying to create a custom event to take a selected employee and populate a form. The event is being dispatched (the dispatchEvent(event) is returning true) but the breakpoints set inside of the handler are never being hit.</p> <...
[ { "answer_id": 545378, "author": "Rytmis", "author_id": 266, "author_profile": "https://Stackoverflow.com/users/266", "pm_score": 1, "selected": false, "text": "<p>You're dispatching the event from the class in the lower code sample (DataGrid, I guess), but the event is defined in the Em...
2009/02/13
[ "https://Stackoverflow.com/questions/545253", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59452/" ]
Let me start off by saying that I'm pretty new to flex and action script. Anyways, I'm trying to create a custom event to take a selected employee and populate a form. The event is being dispatched (the dispatchEvent(event) is returning true) but the breakpoints set inside of the handler are never being hit. Here is s...
There are a few things conspiring to cause trouble here. :) First, this declaration in your custom component: ``` <mx:Metadata> [Event(name="selectEmployeeEvent", type="events.EmployeeEvent")] <mx:Metadata> ``` ... announces to the compiler that your custom component *dispatches* this particular event, but you...
545,259
<p>I am using Pivotal CRM and I do not find easy ways to code unit test for its ASRs for this software. Do you have any experience programming test for this software? </p> <p>Edit: I have thought a simple but not perfect way of testing. But I am willing to give the Bounty to anybody who gives the minimun insight. </p...
[ { "answer_id": 565021, "author": "borjab", "author_id": 16206, "author_profile": "https://Stackoverflow.com/users/16206", "pm_score": 0, "selected": false, "text": "<p>The only possible answer I find is to move the logic to other clases than would be called by the ASR. This way you can u...
2009/02/13
[ "https://Stackoverflow.com/questions/545259", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16206/" ]
I am using Pivotal CRM and I do not find easy ways to code unit test for its ASRs for this software. Do you have any experience programming test for this software? Edit: I have thought a simple but not perfect way of testing. But I am willing to give the Bounty to anybody who gives the minimun insight.
Great question. I would inject stubs or mocks on the implemented methods to set up the test. So if I implement the IRFormScript interface like below. I could use a stub that implements the IRForm interface to setup expectations on the form object that gets injected into my methods. Some of these arguments are just stri...
545,270
<p>Is there any difference at all between this:</p> <pre><code>dataContext.People.Select(ø =&gt; new { Name = ø.Name, }); </code></pre> <p>and this:</p> <pre><code>dataContext.People.Select(ø =&gt; new { ø.Name, }); </code></pre> <p>?</p>
[ { "answer_id": 545284, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 4, "selected": true, "text": "<p>They are identical; if no name is specified (and the right-hand-side is a simple member-access) then the name of th...
2009/02/13
[ "https://Stackoverflow.com/questions/545270", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39321/" ]
Is there any difference at all between this: ``` dataContext.People.Select(ø => new { Name = ø.Name, }); ``` and this: ``` dataContext.People.Select(ø => new { ø.Name, }); ``` ?
They are identical; if no name is specified (and the right-hand-side is a simple member-access) then the name of the existing member is assumed. The name is only necessary to: * change the name to something *else* (for example `Name = grp.Key`) * to give a name to a non-member-access expression (for example `Count = g...
545,281
<p>I've been using FxCop for a while, almost all of the rules it suggests make sense, but when it comes to naming controls it throws a wobbly.</p> <p>I tend to name things like this:</p> <pre><code>btnSavePerson lblForename txtPostcode ddlEthnicity </code></pre> <p>and so on.</p> <p>Now, I only use prefixes for con...
[ { "answer_id": 545300, "author": "AnthonyWJones", "author_id": 17516, "author_profile": "https://Stackoverflow.com/users/17516", "pm_score": 0, "selected": false, "text": "<p>I don't use hungarian prefixes, I don't see them being of more value than they would be on variable names or publ...
2009/02/13
[ "https://Stackoverflow.com/questions/545281", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48886/" ]
I've been using FxCop for a while, almost all of the rules it suggests make sense, but when it comes to naming controls it throws a wobbly. I tend to name things like this: ``` btnSavePerson lblForename txtPostcode ddlEthnicity ``` and so on. Now, I only use prefixes for controls, I found that identifying them was...
I actually name controls the same way you do. I find it's provides for a faster way to identify a control from a code behind. If you really don't want to stick with this convention including some sort of prefix may be helpful, especially on big forms. For instance, if you are registering a user, taking their CC info, a...
545,282
<p>For objects which compose another object as part of their implementation, what's the best way to write the unit test so only the principle object gets tested? Trivial example:</p> <pre><code>class myObj { public function doSomethingWhichIsLogged() { // ... $logger = new logger('/tmp/log.tx...
[ { "answer_id": 545669, "author": "troelskn", "author_id": 18180, "author_profile": "https://Stackoverflow.com/users/18180", "pm_score": 3, "selected": true, "text": "<p>As you seem to be aware already, Concrete Class Dependencies makes testing hard (or outright impossible). You need to d...
2009/02/13
[ "https://Stackoverflow.com/questions/545282", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25517/" ]
For objects which compose another object as part of their implementation, what's the best way to write the unit test so only the principle object gets tested? Trivial example: ``` class myObj { public function doSomethingWhichIsLogged() { // ... $logger = new logger('/tmp/log.txt'); $l...
As you seem to be aware already, Concrete Class Dependencies makes testing hard (or outright impossible). You need to decouple that dependency. A simple change, that doesn't break the existing API, is to default to the current behaviour, but provide a hook to override it. There are a number of ways that this could be i...
545,318
<p>I am using jQuery to call PHP files via the $.get method</p> <pre><code>function fetchDepartment(company_id) { $.get("ajax/fetchDepartment.php?sec=departments&amp;company_id="+company_id, function(data){ $("#department_id").html(data); }); } </code></pre> <p>What I am thinking is can I secure the f...
[ { "answer_id": 545363, "author": "Aram Verstegen", "author_id": 64234, "author_profile": "https://Stackoverflow.com/users/64234", "pm_score": 0, "selected": false, "text": "<p>Pretty much the only way you can obscure the URL for a certain piece of information from the user is by not load...
2009/02/13
[ "https://Stackoverflow.com/questions/545318", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22459/" ]
I am using jQuery to call PHP files via the $.get method ``` function fetchDepartment(company_id) { $.get("ajax/fetchDepartment.php?sec=departments&company_id="+company_id, function(data){ $("#department_id").html(data); }); } ``` What I am thinking is can I secure the filename even further? Current...
**Encoded requests** You could make the request details effectively invisible to the casual miscreant by encoding almost all of the URL and then decoding the request details server-side. The request details would include the action you wish to perform plus the parameters relevant to that action. All requests would...