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
555,924
<p>When given an example of refactoring, I'm tired of seeing a <strong>Data Access Layer</strong> with string literals for connection strings being replaced by <em>IConnectionStringProvider</em>.</p> <p>eg:</p> <pre><code>public DataSet GetCustomers() { string connectionString = "SQLClient;Blah;Blah"; using(...
[ { "answer_id": 555934, "author": "Henrik Paul", "author_id": 2238, "author_profile": "https://Stackoverflow.com/users/2238", "pm_score": 1, "selected": false, "text": "<p>I remember reading of OOP with examples of a <code>Car</code> or <code>Bicycle</code> extending a <code>Vehicle</code...
2009/02/17
[ "https://Stackoverflow.com/questions/555924", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1894/" ]
When given an example of refactoring, I'm tired of seeing a **Data Access Layer** with string literals for connection strings being replaced by *IConnectionStringProvider*. eg: ``` public DataSet GetCustomers() { string connectionString = "SQLClient;Blah;Blah"; using(SqlConnection conn = new SqlConnection(co...
As someone who does a lot of phone screens, I am tired of hearing about Shape being the base class for Square and Circle. We need some more independent thought when it comes to discussing class hierarchies and interfaces.
555,928
<p>Is it valid html to have the following:</p> <pre><code>&lt;form action="a"&gt; &lt;input.../&gt; &lt;form action="b"&gt; &lt;input.../&gt; &lt;input.../&gt; &lt;input.../&gt; &lt;/form&gt; &lt;input.../&gt; &lt;/form&gt; </code></pre> <p>So when you submit "b" you only get t...
[ { "answer_id": 555945, "author": "David Grant", "author_id": 40581, "author_profile": "https://Stackoverflow.com/users/40581", "pm_score": 3, "selected": false, "text": "<p>No, the HTML specification states that no <code>FORM</code> element should contain another <code>FORM</code> elemen...
2009/02/17
[ "https://Stackoverflow.com/questions/555928", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Is it valid html to have the following: ``` <form action="a"> <input.../> <form action="b"> <input.../> <input.../> <input.../> </form> <input.../> </form> ``` So when you submit "b" you only get the fields within the inner form. When you submit "a" you get all fields minus th...
A. **It is not valid HTML nor XHTML** In the official W3C XHTML specification, Section B. "Element Prohibitions", states that: > > "form must not contain other form elements." > > > <http://www.w3.org/TR/xhtml1/#prohibitions> As for the older [HTML 3.2 spec](http://www.w3.org/MarkUp/html3/forms.html), the secti...
555,929
<p>Is there a way to find how much memory is used for a particular object? For example a List. Taking everything into account, like string interning and whatever is done by compiler/runtime environment/whatever.</p>
[ { "answer_id": 555938, "author": "Vyas Bharghava", "author_id": 28413, "author_profile": "https://Stackoverflow.com/users/28413", "pm_score": 1, "selected": false, "text": "<p>Have you tried CLR Profiler 2.0?</p>\n" }, { "answer_id": 555955, "author": "Jon Skeet", "author...
2009/02/17
[ "https://Stackoverflow.com/questions/555929", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39321/" ]
Is there a way to find how much memory is used for a particular object? For example a List. Taking everything into account, like string interning and whatever is done by compiler/runtime environment/whatever.
You'd really have to define *exactly* what you meant by "how much memory is used for a particular object". For instance, you could mean "if this object were garbage collected, how much would be freed" - or you could mean "how much memory does this object and everything it touches take up." Your point about string inte...
555,965
<pre><code>function DeleteData(ID) { var ctrlId=ID.id; var divcontents=document.getElementById(ctrlId).innerHTML; var tabid=ctrlId.replace(/div/,'tab'); var tabcontents=document.getElementById(tabid).innerHTML; alert(document.getElementById(tabid).innerHTML); document.getElementById(tabid).innerHTML="&lt;TBody&g...
[ { "answer_id": 556020, "author": "Canavar", "author_id": 55351, "author_profile": "https://Stackoverflow.com/users/55351", "pm_score": 5, "selected": true, "text": "<p>You can't set value to a table's innerHTML, you should access to child cells or rows and change them like that : </p>\n\...
2009/02/17
[ "https://Stackoverflow.com/questions/555965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
``` function DeleteData(ID) { var ctrlId=ID.id; var divcontents=document.getElementById(ctrlId).innerHTML; var tabid=ctrlId.replace(/div/,'tab'); var tabcontents=document.getElementById(tabid).innerHTML; alert(document.getElementById(tabid).innerHTML); document.getElementById(tabid).innerHTML="<TBody><tr><td></t...
You can't set value to a table's innerHTML, you should access to child cells or rows and change them like that : ``` document.getElementById(tabid).rows[0].cells.innerHTML = 'blah blah'; ``` For more info/example : [Table, TableHeader, TableRow, TableData Objects](http://www.w3schools.com/JS/js_examples_3.asp)
555,975
<p>I have an array:</p> <pre><code>$array = array("apple", "banana", "cap", "dog", etc..) up to 80 values. </code></pre> <p>and a string variable:</p> <pre><code>$str = "abc"; </code></pre> <p>If I want to check whether this string (<code>$str</code>) exists in the array or not, I use the <code>preg_match</code> fu...
[ { "answer_id": 555987, "author": "Sam McAfee", "author_id": 577, "author_profile": "https://Stackoverflow.com/users/577", "pm_score": 6, "selected": true, "text": "<pre class=\"lang-php prettyprint-override\"><code> bool in_array ( mixed $needle , array $haystack [, bool $strict ] )\...
2009/02/17
[ "https://Stackoverflow.com/questions/555975", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65379/" ]
I have an array: ``` $array = array("apple", "banana", "cap", "dog", etc..) up to 80 values. ``` and a string variable: ``` $str = "abc"; ``` If I want to check whether this string (`$str`) exists in the array or not, I use the `preg_match` function, which is like this: ``` $isExists = preg_match("/$str/", $arra...
```php bool in_array ( mixed $needle , array $haystack [, bool $strict ] ) ``` <http://php.net/manual/en/function.in-array.php>
556,044
<p>I need to create a group of <code>DropDownList</code>s to show and allow change of a property group for an item.</p> <p>I have the following code on my ASP page.</p> <pre><code>&lt;asp:Repeater runat="server" ID="repeaterProperties"&gt; &lt;ItemTemplate&gt; &lt;p&gt;&lt;asp:DropDownList runat="server" ...
[ { "answer_id": 556272, "author": "Bryan", "author_id": 22033, "author_profile": "https://Stackoverflow.com/users/22033", "pm_score": 3, "selected": true, "text": "<p>Maybe I'm misunderstanding something about your question... but it seems like this is exactly what OnItemDataBound is for....
2009/02/17
[ "https://Stackoverflow.com/questions/556044", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57898/" ]
I need to create a group of `DropDownList`s to show and allow change of a property group for an item. I have the following code on my ASP page. ``` <asp:Repeater runat="server" ID="repeaterProperties"> <ItemTemplate> <p><asp:DropDownList runat="server" ID="ddProperty" OnInit="ddProperty_OnInit" /><p> ...
Maybe I'm misunderstanding something about your question... but it seems like this is exactly what OnItemDataBound is for. :) Use FindControl to get a reference to your DropDownList in the event handler. Also check to make sure the item is not the header/footer. The example from MSDN does both these things: <http://...
556,063
<p>I'm learning about timestamps. I can find lots of infomation about extracting data from current timestamps but little about querying a database timestamp. For example, I'd like to perform the following (the syntax is not correct, but should hopefully illustrate my question)</p> <pre><code>SELECT * FROM database whe...
[ { "answer_id": 556070, "author": "Aron Rotteveel", "author_id": 11568, "author_profile": "https://Stackoverflow.com/users/11568", "pm_score": 2, "selected": false, "text": "<p><strong>You can use the MySQL function <a href=\"http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions....
2009/02/17
[ "https://Stackoverflow.com/questions/556063", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm learning about timestamps. I can find lots of infomation about extracting data from current timestamps but little about querying a database timestamp. For example, I'd like to perform the following (the syntax is not correct, but should hopefully illustrate my question) ``` SELECT * FROM database where timestamp D...
**You can use the MySQL function [`FROM_UNIXTIME()`](http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_from-unixtime).** ``` SELECT * FROM database WHERE DAY(FROM_UNIXTIME(timestamp)) = 12 AND MONTH(FROM_UNIXTIME(timestamp)) = 1 SELECT * FROM database WHERE MONTH(FROM_UNIXTIME(timestam...
556,072
<p>I have to update a field in a table. I'm using following queries. Help me, which one is right?</p> <pre><code>update table1 set col1=&lt;value&gt;,col2=&lt;value&gt;.... from table1 t,table2 s where t.id=s.num and s.code='abc'; </code></pre> <p>or</p> <pre><code>update table1 set col1=&lt;value&gt;,col2=&lt;val...
[ { "answer_id": 556134, "author": "Tony Andrews", "author_id": 18747, "author_profile": "https://Stackoverflow.com/users/18747", "pm_score": 3, "selected": false, "text": "<p>Neither is correct. It's not clear from your fragment what you are trying to do, but the syntax to update one tab...
2009/02/17
[ "https://Stackoverflow.com/questions/556072", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have to update a field in a table. I'm using following queries. Help me, which one is right? ``` update table1 set col1=<value>,col2=<value>.... from table1 t,table2 s where t.id=s.num and s.code='abc'; ``` or ``` update table1 set col1=<value>,col2=<value>.... where table1.id=table2.num and table2.code='abc'...
Neither is correct. It's not clear from your fragment what you are trying to do, but the syntax to update one table with values from another would be more like: ``` update table1 set (col1, col2) = ( select col1, col2 from table2 where table2.num = table1.id and table2.code = 'abc' ) where table1.id in (se...
556,083
<p>I'm working on a website for a client, in PHP/MySQL. They are a publisher, and the site needs to show whether the book you are looking at is in stock with their distributor.</p> <p>The stock file is a CSV file on the distributor's FTP. This file is updated at a certain time every evening. So far I've written a scri...
[ { "answer_id": 556119, "author": "Andrew Vit", "author_id": 61439, "author_profile": "https://Stackoverflow.com/users/61439", "pm_score": 4, "selected": true, "text": "<p>The conventional way to automate repeating tasks is to use <strong>cron</strong>. You can edit your cron configuratio...
2009/02/17
[ "https://Stackoverflow.com/questions/556083", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49376/" ]
I'm working on a website for a client, in PHP/MySQL. They are a publisher, and the site needs to show whether the book you are looking at is in stock with their distributor. The stock file is a CSV file on the distributor's FTP. This file is updated at a certain time every evening. So far I've written a script in PHP ...
The conventional way to automate repeating tasks is to use **cron**. You can edit your cron configuration from the command line using `crontab -e`. The file follows the following format: ``` # .---------------- minute (0 - 59) # | .------------- hour (0 - 23) # | | .---------- day of month (1 - 31) # | | | .---...
556,095
<p>I am attempting to build a .PLY parser to load 3d models stored as .ply files into a half edge data structure mesh. </p> <p>Sorry for the huge question, I'm very verbose and I wanted to make sure I laid out all the details. Because of this, I'll restate my ultimate goals immediately, just so users can see can get a...
[ { "answer_id": 556161, "author": "Paul-Jan", "author_id": 16725, "author_profile": "https://Stackoverflow.com/users/16725", "pm_score": 0, "selected": false, "text": "<p>Are you storing indices or references in the edge? If you use incides, wouldn't a trivial hash function like</p>\n\n<p...
2009/02/17
[ "https://Stackoverflow.com/questions/556095", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33583/" ]
I am attempting to build a .PLY parser to load 3d models stored as .ply files into a half edge data structure mesh. Sorry for the huge question, I'm very verbose and I wanted to make sure I laid out all the details. Because of this, I'll restate my ultimate goals immediately, just so users can see can get an idea of ...
> > I'm very verbose > > > You might want to to something about that. A trivial way to has an edge is by the indexes of its two vertices. To make it unique take the smaller index first and the larger index second. Something like this: ``` uint hash(const Vertex& v1, const Vertex& v2) { int i1 = v1.index; ...
556,105
<p>I'm using Fmod in a project I'm working on in Visual C++ 2008. If I include </p> <pre><code>../fmodapi375win/api/lib/fmodvc.lib </code></pre> <p>in Project->Linker->Input, it works fine, but for some reason if I use</p> <pre><code>#pragma comment(lib,"../fmodapi375win/api/lib/fmodvc.lib") </code></pre> <p>instea...
[ { "answer_id": 556124, "author": "Jacek Ławrynowicz", "author_id": 43399, "author_profile": "https://Stackoverflow.com/users/43399", "pm_score": 1, "selected": false, "text": "<p>Libs could be linked in another order, so symbols are resolved differently.</p>\n" }, { "answer_id": ...
2009/02/17
[ "https://Stackoverflow.com/questions/556105", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34799/" ]
I'm using Fmod in a project I'm working on in Visual C++ 2008. If I include ``` ../fmodapi375win/api/lib/fmodvc.lib ``` in Project->Linker->Input, it works fine, but for some reason if I use ``` #pragma comment(lib,"../fmodapi375win/api/lib/fmodvc.lib") ``` instead it works the same as if that line wasn't there:...
I don't think you are supposed to provide the .lib in the pragma comment, but, I think the real problem is that you are calling the comment by path. Add the path to your lib search paths, and then just use a ``` #pragma comment(lib,"fmodvc") ``` You are SUPPOSED to be able to use a path in this comment, but are you...
556,108
<p>I'm looking for a Java library for circle recognition in a supplied bitmap. My Java knowledge is too basic to implement eg. Hough transform efficiently (Java newbie).</p> <p>Thanks!</p>
[ { "answer_id": 556124, "author": "Jacek Ławrynowicz", "author_id": 43399, "author_profile": "https://Stackoverflow.com/users/43399", "pm_score": 1, "selected": false, "text": "<p>Libs could be linked in another order, so symbols are resolved differently.</p>\n" }, { "answer_id": ...
2009/02/17
[ "https://Stackoverflow.com/questions/556108", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5731/" ]
I'm looking for a Java library for circle recognition in a supplied bitmap. My Java knowledge is too basic to implement eg. Hough transform efficiently (Java newbie). Thanks!
I don't think you are supposed to provide the .lib in the pragma comment, but, I think the real problem is that you are calling the comment by path. Add the path to your lib search paths, and then just use a ``` #pragma comment(lib,"fmodvc") ``` You are SUPPOSED to be able to use a path in this comment, but are you...
556,133
<p>This is a .NET question for C# (or possibly VB.net), but I am trying to figure out what's the difference between the following declarations:</p> <pre><code>string hello = "hello"; </code></pre> <p>vs. </p> <pre><code>string hello_alias = @"hello"; </code></pre> <p>Printing out on the console makes no difference,...
[ { "answer_id": 556141, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 8, "selected": false, "text": "<p>It's a <em>verbatim string literal</em>. It means that escaping isn't applied. For instance:</p>\n\n<pre><code>string...
2009/02/17
[ "https://Stackoverflow.com/questions/556133", "https://Stackoverflow.com", "https://Stackoverflow.com/users/67283/" ]
This is a .NET question for C# (or possibly VB.net), but I am trying to figure out what's the difference between the following declarations: ``` string hello = "hello"; ``` vs. ``` string hello_alias = @"hello"; ``` Printing out on the console makes no difference, the length properties are the same.
It marks the string as a [verbatim string literal](http://csharpindepth.com/Articles/General/Strings.aspx) - anything in the string that would normally be interpreted as an [escape sequence](http://en.wikipedia.org/wiki/Escape_sequence) is ignored. So `"C:\\Users\\Rich"` is the same as `@"C:\Users\Rich"` There is one...
556,147
<p>I want to embed fonts in my WinForms application so that I don't have to worry about them being installed on the machine. I've searched a bit on the MSDN site and found a few hints about using native Windows API calls, for instance Michael Caplan's (sp?) tutorial linked to by Scott Hanselman. Now, do I really have t...
[ { "answer_id": 557225, "author": "Richard", "author_id": 67392, "author_profile": "https://Stackoverflow.com/users/67392", "pm_score": 2, "selected": false, "text": "<blockquote>\n <p>Can't I just use the resource part of my app?</p>\n</blockquote>\n\n<p>Yes, but need to be native resou...
2009/02/17
[ "https://Stackoverflow.com/questions/556147", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9077/" ]
I want to embed fonts in my WinForms application so that I don't have to worry about them being installed on the machine. I've searched a bit on the MSDN site and found a few hints about using native Windows API calls, for instance Michael Caplan's (sp?) tutorial linked to by Scott Hanselman. Now, do I really have to g...
This is what worked for me in VS 2013, without having to use an unsafe block. **Embed the resource** 1. Double-click Resources.resx, and in the toolbar for the designer click Add Resource/Add Existing File and select your .ttf file 2. In your solution explorer, right-click your .ttf file (now in a Resources folder) a...
556,153
<p>I created a horizontal menu using a HTML lists and CSS. Everything works as it should except when you hover over the links. You see, I created a bold hover state for the links, and now the menu links shift because of the bold size difference.</p> <p>I encounter the same problem as <a href="http://www.sitepoint.com/...
[ { "answer_id": 556175, "author": "Andrew Vit", "author_id": 61439, "author_profile": "https://Stackoverflow.com/users/61439", "pm_score": 5, "selected": false, "text": "<p>If you cannot set the width, then that means the width will change as the text gets bold. There is no way to avoid t...
2009/02/17
[ "https://Stackoverflow.com/questions/556153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/64873/" ]
I created a horizontal menu using a HTML lists and CSS. Everything works as it should except when you hover over the links. You see, I created a bold hover state for the links, and now the menu links shift because of the bold size difference. I encounter the same problem as [this SitePoint post](http://www.sitepoint.c...
**Pre-set the width** by using an invisible pseudo-element which has the same content and styling as the parent hover style. Use a data attribute, like `title`, as the source for content. ```css li { display: inline-block; font-size: 0; } li a { display:inline-block; text-align:center; font: norma...
556,155
<p>I have a class that dispatches a Success and a Failure event and I need to maintain a statistic on the average number of failure/total number of events in the last X seconds from that class. </p> <p>I was thinking something along the lines of using a circular linked list and append a success or failure node for eac...
[ { "answer_id": 556168, "author": "tliff", "author_id": 65502, "author_profile": "https://Stackoverflow.com/users/65502", "pm_score": 1, "selected": false, "text": "<p>keep you events in a <a href=\"http://en.wikipedia.org/wiki/Queue_%28data_structure%29\" rel=\"nofollow noreferrer\">Queu...
2009/02/17
[ "https://Stackoverflow.com/questions/556155", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3263/" ]
I have a class that dispatches a Success and a Failure event and I need to maintain a statistic on the average number of failure/total number of events in the last X seconds from that class. I was thinking something along the lines of using a circular linked list and append a success or failure node for each event. T...
You should use a sampling frequency (a-la MRTG). Say you only need one second precision and to maintain the average for the past minute, you will have a fixed table of 60 entries referring to the past 60 seconds (including the present one). And also maintain the current global entry. Each entry consists of an average ...
556,194
<p>I need to run a bash script as root (passwordless sudo or su not viable) and since you cannot setuid a script in Linux, I thought about calling it from an executable and making <em>it</em> setuid:</p> <pre><code>$ cat wrapper.c int main(void) { system("/bin/bash ./should_run_as_root.sh"); } $ gcc -o wrapper...
[ { "answer_id": 556198, "author": "Tom Alsberg", "author_id": 66034, "author_profile": "https://Stackoverflow.com/users/66034", "pm_score": 7, "selected": true, "text": "<p>Since the <code>suid</code> bit on executables only changes the effective UID (EUID) the executable will run as, and...
2009/02/17
[ "https://Stackoverflow.com/questions/556194", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I need to run a bash script as root (passwordless sudo or su not viable) and since you cannot setuid a script in Linux, I thought about calling it from an executable and making *it* setuid: ``` $ cat wrapper.c int main(void) { system("/bin/bash ./should_run_as_root.sh"); } $ gcc -o wrapper wrapper.c $ sudo cho...
Since the `suid` bit on executables only changes the effective UID (EUID) the executable will run as, and not the real UID (RUID) which `getuid()` returns, and in addition to the restriction on `suid` interpreted scripts (any executable beginning with "`#!`"), some shells like `bash` as an extra safety measure will set...
556,203
<p>I am trying to inherit a non-static class by a static class.</p> <pre><code>public class foo { } public static class bar : foo { } </code></pre> <p>And I get:</p> <blockquote> <p>Static class cannot derive from type. Static classes must derive from object.</p> </blockquote> <p><strong>How can I derive it ...
[ { "answer_id": 556206, "author": "Svish", "author_id": 39321, "author_profile": "https://Stackoverflow.com/users/39321", "pm_score": 0, "selected": false, "text": "<p>Doesn't all classes (static included) already derive from object? As in, by default?</p>\n\n<p>Also, like it says, \"Stat...
2009/02/17
[ "https://Stackoverflow.com/questions/556203", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61976/" ]
I am trying to inherit a non-static class by a static class. ``` public class foo { } public static class bar : foo { } ``` And I get: > > Static class cannot derive from type. > Static classes must derive from > object. > > > **How can I derive it from object?** The code is in C#.
There's no value in deriving static classes. The reasons to use inheritance are: * Polymorphism * Code reuse You can't get polymorphism with static classes, obviously, because there is no instance to dynamically dispatch on (in other words, it's not like you can pass a Bar to a function expecting a Foo, since you don...
556,205
<p>I want to process my image point by point, but I don't know how to obtain the color of the point from the image. And how to move the pointer point by point?</p>
[ { "answer_id": 556347, "author": "philsquared", "author_id": 32136, "author_profile": "https://Stackoverflow.com/users/32136", "pm_score": 2, "selected": false, "text": "<p>You can't do it directly from the UIImage, but you can render the image into a bitmap context, with a memory buffer...
2009/02/17
[ "https://Stackoverflow.com/questions/556205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to process my image point by point, but I don't know how to obtain the color of the point from the image. And how to move the pointer point by point?
You can't do it directly from the UIImage, but you can render the image into a bitmap context, with a memory buffer you supply, then test the memory directly. That sounds more complex than it really is, but may still be more complex than you wanted to hear. If you have Erica Sadun's iPhone Developer's Cookbook there's...
556,207
<p>which of the following code is more appropriate situation where multiple threads access the function</p> <pre><code>public ArrayList CallMe1() { ArrayList al = new ArrayList(); lock(al.SyncRoot) { al.Add("33"); al.Add("45"); return al; } ...
[ { "answer_id": 556214, "author": "Sesh", "author_id": 38212, "author_profile": "https://Stackoverflow.com/users/38212", "pm_score": -1, "selected": false, "text": "<p>the problem with .net <strong>lock</strong> is that in case of a deadlock it is not going to throw any exception or anyth...
2009/02/17
[ "https://Stackoverflow.com/questions/556207", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
which of the following code is more appropriate situation where multiple threads access the function ``` public ArrayList CallMe1() { ArrayList al = new ArrayList(); lock(al.SyncRoot) { al.Add("33"); al.Add("45"); return al; } } public...
There's no shared state in this case, so synchronisation is unnecessary. However, assuming the arraylist **was** shared state, the following applies: They're both the same ([lock implements Monitor internally](http://msdn.microsoft.com/en-us/library/c5kehkcz(VS.80).aspx)). Mostly. Your second version needs to relea...
556,238
<p>I have a com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException in my code (using Hibernate and Spring) and I can't figure why. My entities are Corpus and Semspace and there's a many-to-one relation from Semspace to Corpus as defined in my hibernate mapping configuration :</p> <pre><code>&lt;class nam...
[ { "answer_id": 556273, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 1, "selected": false, "text": "<p>Seems simple enough. The first line of your exception clearly states that the violation is from the column <code>idCo...
2009/02/17
[ "https://Stackoverflow.com/questions/556238", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26859/" ]
I have a com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException in my code (using Hibernate and Spring) and I can't figure why. My entities are Corpus and Semspace and there's a many-to-one relation from Semspace to Corpus as defined in my hibernate mapping configuration : ``` <class name="xxx.entities.S...
I get confused w/ the association mappings all the time. Review the association needed and the hibernate mapping config used to create the assiocation. <http://docs.jboss.org/hibernate/core/3.5/reference/en/html/associations.html> is a great recipe book of associations.
556,240
<p>i am using URL rewriting in my asp.net application using regx</p> <p>virtual URL is</p> <pre><code>/ProductDatabaseCMS/(?&lt;category&gt;\w*)/Product/(?&lt;product&gt;\w*)\.aspx </code></pre> <p>original URL is</p> <pre><code>/ProductDatabaseCMS/Product.aspx?PROD_ID=${product} </code></pre> <p>application path ...
[ { "answer_id": 556287, "author": "Gumbo", "author_id": 53114, "author_profile": "https://Stackoverflow.com/users/53114", "pm_score": 2, "selected": true, "text": "<p>If you use a relative URI to reference the external stylesheet, you have to consider this: Relative URIs are always resolv...
2009/02/17
[ "https://Stackoverflow.com/questions/556240", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
i am using URL rewriting in my asp.net application using regx virtual URL is ``` /ProductDatabaseCMS/(?<category>\w*)/Product/(?<product>\w*)\.aspx ``` original URL is ``` /ProductDatabaseCMS/Product.aspx?PROD_ID=${product} ``` application path is `~/ProductDatabaseCMS` my application has master page that uses ...
If you use a relative URI to reference the external stylesheet, you have to consider this: Relative URIs are always resolved from a base URI which is the URI of the current resource if not declared otherwise. So if you request `/foo/bar` and there is a relative URI reference `css/baz.css` in the HTML document, it woul...
556,241
<p>In CSS, when setting a style on a div (for example) is there any benefit in including the 'div' other than to give it more precision for matching. Is it faster for the browser to render perhaps?</p> <p>ie Is:</p> <pre><code>div.something { font-size: 1em; } </code></pre> <p>better than</p> <pre><code>.something ...
[ { "answer_id": 556246, "author": "TomHastjarjanto", "author_id": 53170, "author_profile": "https://Stackoverflow.com/users/53170", "pm_score": 0, "selected": false, "text": "<p>Well if you like to have other tags with the same classname have another appearence then it might be a good ide...
2009/02/17
[ "https://Stackoverflow.com/questions/556241", "https://Stackoverflow.com", "https://Stackoverflow.com/users/67304/" ]
In CSS, when setting a style on a div (for example) is there any benefit in including the 'div' other than to give it more precision for matching. Is it faster for the browser to render perhaps? ie Is: ``` div.something { font-size: 1em; } ``` better than ``` .something { font-size: 1em; } ``` for any other reas...
Besides the different semantics of both selectors, read this: [Speed of CSS](https://stackoverflow.com/questions/536091/speed-of-css/536124)
556,242
<p>I am actually having 100's of SP in my database. I have to find a set of 10 SP's in that which have a particular comment inside them. Is there any search query for this. </p>
[ { "answer_id": 556278, "author": "Rich Andrews", "author_id": 37381, "author_profile": "https://Stackoverflow.com/users/37381", "pm_score": 3, "selected": true, "text": "<p>Found <a href=\"http://www.knowdotnet.com/articles/storedprocfinds.html\" rel=\"nofollow noreferrer\">this</a> arti...
2009/02/17
[ "https://Stackoverflow.com/questions/556242", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20951/" ]
I am actually having 100's of SP in my database. I have to find a set of 10 SP's in that which have a particular comment inside them. Is there any search query for this.
Found [this](http://www.knowdotnet.com/articles/storedprocfinds.html) article which does exactly what your after if your using SQL Server I'll certainly be keeping a copy of this code for my own use :) Also, It doesn't just work for comments but it appears to work for all text in an SP. **Edit** I've included a cop...
556,255
<p>I heard you should never throw a string because there is a lack of information and you'll catch exceptions you dont expect to catch. What are good practice for throwing exceptions? do you inherit a base exception class? Do you have many exceptions or few? do you do MyExceptionClass&amp; or const MyExceptionClass&am...
[ { "answer_id": 556270, "author": "RvdK", "author_id": 47351, "author_profile": "https://Stackoverflow.com/users/47351", "pm_score": 2, "selected": false, "text": "<p>Use the standard exceptions! If you have a specific error, try to avoid it with return value. If you <strong>have</strong>...
2009/02/17
[ "https://Stackoverflow.com/questions/556255", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I heard you should never throw a string because there is a lack of information and you'll catch exceptions you dont expect to catch. What are good practice for throwing exceptions? do you inherit a base exception class? Do you have many exceptions or few? do you do MyExceptionClass& or const MyExceptionClass& ? etc. Al...
In my opinion, a function should throw an exception if it can't keep its "promise", if it has to break its "contract". The function's signature (name and parameters) determine its contract. Given these two member functions: ``` const Apple* FindApple(const wchar_t* name) const; const Apple& GetApple(const wchar_t* na...
556,262
<p>My aim is to create nested resources via one REST request. The REST requests is represented via a XML document. That works fine for single resources but I could not manage it for nested ones. OK I'll give you a little example next.</p> <p>First create a new rails project</p> <pre><code>rails forrest </code></pre> ...
[ { "answer_id": 556798, "author": "jlc", "author_id": 62620, "author_profile": "https://Stackoverflow.com/users/62620", "pm_score": 1, "selected": false, "text": "<p>The default controller will have a line like </p>\n\n<pre><code>@tree = Tree.new(params[:tree])\n</code></pre>\n\n<p>which ...
2009/02/17
[ "https://Stackoverflow.com/questions/556262", "https://Stackoverflow.com", "https://Stackoverflow.com/users/76172/" ]
My aim is to create nested resources via one REST request. The REST requests is represented via a XML document. That works fine for single resources but I could not manage it for nested ones. OK I'll give you a little example next. First create a new rails project ``` rails forrest ``` Next we generate the scaffold...
One way you can accomplish this is to override the bird\_nests= method on your tree model. ``` def bird_nests=(attrs_array) attrs_array.each do |attrs| bird_nests.build(attrs) end end ``` The only issue here is that you lose the default behavior of the setter, which may or may not be an issue in your app. I...
556,269
<p>I'm trying to unpickle an object stored as a blob in a MySQL database. I've manually generated and stored the pickled object in the database, but when I try to unpickle the object, I get the following rather cryptic exception:</p> <p>ImportError: No module named copy_reg</p> <p>Any ideas as to why this happens?</p...
[ { "answer_id": 556295, "author": "Stephen Edmonds", "author_id": 17349, "author_profile": "https://Stackoverflow.com/users/17349", "pm_score": 6, "selected": true, "text": "<p>It seems this might be caused by my method of exporting the pickled object.</p>\n\n<p><a href=\"http://www.archi...
2009/02/17
[ "https://Stackoverflow.com/questions/556269", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17349/" ]
I'm trying to unpickle an object stored as a blob in a MySQL database. I've manually generated and stored the pickled object in the database, but when I try to unpickle the object, I get the following rather cryptic exception: ImportError: No module named copy\_reg Any ideas as to why this happens? **Method of Repro...
It seems this might be caused by my method of exporting the pickled object. [This bug report](http://www.archivum.info/python-bugs-list@python.org/2007-04/msg00222.html "Bug report of similiar nature") seens to suggest that my issue can be resolved by exporting to a file writen in binary mode. I'm going to give this a...
556,277
<p>Can anyone suggest a way of stripping tab characters ( "\t"s ) from a string? CString or std::string.</p> <p>So that "1E10&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" for example becomes "1E10".</p>
[ { "answer_id": 556285, "author": "sharptooth", "author_id": 57428, "author_profile": "https://Stackoverflow.com/users/57428", "pm_score": 2, "selected": false, "text": "<p>Scan the string and remove all the found occurences.</p>\n" }, { "answer_id": 556293, "author": "drby", ...
2009/02/17
[ "https://Stackoverflow.com/questions/556277", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6795/" ]
Can anyone suggest a way of stripping tab characters ( "\t"s ) from a string? CString or std::string. So that "1E10      " for example becomes "1E10".
[hackingwords' answer](https://stackoverflow.com/questions/556277/trim-remove-a-tab-t-from-a-string/556293#556293) gets you halfway there. But [`std::remove()`](http://en.cppreference.com/w/cpp/algorithm/remove) from `<algorithm>` doesn't actually make the string any shorter -- it just returns an iterator saying "the n...
556,283
<p>I'm running a VBScript that may run under x64 Windows. I need to read a registry key from the 32-bit part of the registry. For that I use path <code>HKLM\Software\Wow6432Node\xyz</code> instead of <code>HKLM\Software\xyz</code>. How can I check if the script is executed under x64?</p>
[ { "answer_id": 557980, "author": "Grant Wagner", "author_id": 9254, "author_profile": "https://Stackoverflow.com/users/9254", "pm_score": 3, "selected": true, "text": "<p>I'm not sure you need to check if the script is executing under x64.</p>\n\n<p>Try to read from <code>HKLM\\Software\...
2009/02/17
[ "https://Stackoverflow.com/questions/556283", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23740/" ]
I'm running a VBScript that may run under x64 Windows. I need to read a registry key from the 32-bit part of the registry. For that I use path `HKLM\Software\Wow6432Node\xyz` instead of `HKLM\Software\xyz`. How can I check if the script is executed under x64?
I'm not sure you need to check if the script is executing under x64. Try to read from `HKLM\Software\Wow6432Node\xyz`, if that fails, try to read from `HKLM\Software\xyz`, if that fails, your registry key doesn't exist, take whatever action is appropriate. Of course, if your design is more complicated (for example, y...
556,288
<p>In my forms, I want to make HTML labels bold in general, but not bold when they are labelling radio buttons and checkboxes.</p> <p>How can I do that in a CSS that can be imported and works by default, without requiring local overrides of the styling?</p> <p>Example Radio Label (should not be bold)</p> <pre><code>...
[ { "answer_id": 556298, "author": "Rich Adams", "author_id": 10018, "author_profile": "https://Stackoverflow.com/users/10018", "pm_score": 0, "selected": false, "text": "<p>You could add a class to the labels for radio buttons, and then style them differently.</p>\n\n<pre><code>&lt;label ...
2009/02/17
[ "https://Stackoverflow.com/questions/556288", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2362/" ]
In my forms, I want to make HTML labels bold in general, but not bold when they are labelling radio buttons and checkboxes. How can I do that in a CSS that can be imported and works by default, without requiring local overrides of the styling? Example Radio Label (should not be bold) ``` <label for="banana"> <input ...
You can't do that without giving the right labels a class or by using Javascript. With jQuery selectors you could do that: ``` $("label:not(:has(radio))").addClass("boldmenow"); ... .boldmenow { font-weight: bold; } ```
556,300
<p>I have a database where each row has an id, a URL, and an XML. The IDs are unique, but URLs column can have duplicates. I need all the URLs, without duplicates, and for each URL I need the id and XML.</p> <p>If I ask only for the URL and the Id, I use the following query:</p> <pre><code>select URL, max(ID) as ID f...
[ { "answer_id": 556304, "author": "Robert", "author_id": 27412, "author_profile": "https://Stackoverflow.com/users/27412", "pm_score": 0, "selected": false, "text": "<p>Your no performing an aggregate function on the column XML, you must include it in your group by. </p>\n\n<p>Remember ...
2009/02/17
[ "https://Stackoverflow.com/questions/556300", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59241/" ]
I have a database where each row has an id, a URL, and an XML. The IDs are unique, but URLs column can have duplicates. I need all the URLs, without duplicates, and for each URL I need the id and XML. If I ask only for the URL and the Id, I use the following query: ``` select URL, max(ID) as ID from T1 group by URL ...
``` select id, url, xml from table1 where id in ( select min(id) from table1 group by url) ``` would give you rows with duplicate urls removed (and only the first instance of duplicate urls included)
556,310
<p>Can I call <code>HttpContext.Current</code> from within a static class and Method?</p> <p>I want to store a value on a per-user basis but want to be able to access it in a static manner.</p> <p>e.g. Will this work?</p> <pre><code>public static class StaticClass { public static string SomeThing { ...
[ { "answer_id": 556319, "author": "AnthonyWJones", "author_id": 17516, "author_profile": "https://Stackoverflow.com/users/17516", "pm_score": 5, "selected": true, "text": "<p>Yes thats one way in which it is helpful, of course the thread on which it is called must currently be processing ...
2009/02/17
[ "https://Stackoverflow.com/questions/556310", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1741868/" ]
Can I call `HttpContext.Current` from within a static class and Method? I want to store a value on a per-user basis but want to be able to access it in a static manner. e.g. Will this work? ``` public static class StaticClass { public static string SomeThing { get { return HttpContext.Current.Items[...
Yes thats one way in which it is helpful, of course the thread on which it is called must currently be processing a request to make it useful.
556,316
<p>I'm learning tcl (expect) and now I came to an interesting issue. I need a command to move/rename a bunch of files with extension .status. I tried these:</p> <pre><code>spawn /bin/mv *.status some_dir exec /bin/mv *.status some_dir </code></pre> <p>Of course, that did not work. I googled a bit and found something ...
[ { "answer_id": 556735, "author": "Randy Proctor", "author_id": 22131, "author_profile": "https://Stackoverflow.com/users/22131", "pm_score": 2, "selected": true, "text": "<pre>\n$ ls -1\n1.status\n2.status\nrename.tclsh*\nsome_dir/\ntwo words.status\n\n$ cat rename.tclsh\n#!/usr/local/bi...
2009/02/17
[ "https://Stackoverflow.com/questions/556316", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14690/" ]
I'm learning tcl (expect) and now I came to an interesting issue. I need a command to move/rename a bunch of files with extension .status. I tried these: ``` spawn /bin/mv *.status some_dir exec /bin/mv *.status some_dir ``` Of course, that did not work. I googled a bit and found something about glob, but it doesn't...
``` $ ls -1 1.status 2.status rename.tclsh* some_dir/ two words.status $ cat rename.tclsh #!/usr/local/bin/tclsh eval exec /bin/mv [glob *.status] some_dir $ ./rename.tclsh $ ls -1 rename.tclsh* some_dir/ $ ls -1 some_dir/ 1.status 2.status two words.status ```
556,322
<p>I was wondering why ad's still use the document.write approach to inserting the add into the page </p> <pre><code>&lt;script language="javascript" type="text/javascript"&gt; document.write("&lt;script type='text/javascript' src='http://addomain/someadd.js'&gt;&lt;\/sc" + "ript&gt;"); &lt;/script&gt; </code></pr...
[ { "answer_id": 556432, "author": "annakata", "author_id": 13018, "author_profile": "https://Stackoverflow.com/users/13018", "pm_score": 2, "selected": false, "text": "<p>I stand corrected, doc.write created scripts <em>are</em> blocking - worse than I though heh :) - but as an adblock av...
2009/02/17
[ "https://Stackoverflow.com/questions/556322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34671/" ]
I was wondering why ad's still use the document.write approach to inserting the add into the page ``` <script language="javascript" type="text/javascript"> document.write("<script type='text/javascript' src='http://addomain/someadd.js'><\/sc" + "ript>"); </script> ``` Why is it that I can't just put ``` <scri...
A traditional script tag will block the page while it is loading and executing. A script loaded with document.write will work asynchronously. That's why you see this on ads or analytics, as such scripts don't influence the page content directly.
556,342
<p>I wrote a twitter application in Python. Following is the code I used for a module where I find if x is following y. This code can be obviously improved upon. A pythonic way to do that?</p> <pre><code>import urllib2 import sys import re import base64 from urlparse import urlparse import simplejson def is_follows(f...
[ { "answer_id": 556352, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 2, "selected": false, "text": "<p>Three things:</p>\n\n<ul>\n<li>Fix the indentation (but then I guess this was not done on purpose).</li>\n<li>Use ...
2009/02/17
[ "https://Stackoverflow.com/questions/556342", "https://Stackoverflow.com", "https://Stackoverflow.com/users/55562/" ]
I wrote a twitter application in Python. Following is the code I used for a module where I find if x is following y. This code can be obviously improved upon. A pythonic way to do that? ``` import urllib2 import sys import re import base64 from urlparse import urlparse import simplejson def is_follows(follower, follo...
From your code it looks like you are trying to do a Basic HTTP Authentication. Is this right? Then you shouldn't create the HTTP headers by hand. Instead use the urllib2.HTTPBasicAuthHandler. An example from the [docs](http://docs.python.org/library/urllib2.html): ``` import urllib2 # Create an OpenerDirector with sup...
556,350
<p>just having a problem here. i'm doing the UI of a web-based app using jquery, css. there's a shopping a cart, and i want to store the selected items in the session, i used jquery.session plugin. e.g. <code>var $.session("var1","item1");</code></p> <p>What i want is to dynamically store items into dynamically named ...
[ { "answer_id": 556379, "author": "Svante Svenson", "author_id": 19707, "author_profile": "https://Stackoverflow.com/users/19707", "pm_score": 0, "selected": false, "text": "<p>Since the session function takes strings as parameters, just create these strings dynamically.</p>\n" }, { ...
2009/02/17
[ "https://Stackoverflow.com/questions/556350", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46270/" ]
just having a problem here. i'm doing the UI of a web-based app using jquery, css. there's a shopping a cart, and i want to store the selected items in the session, i used jquery.session plugin. e.g. `var $.session("var1","item1");` What i want is to dynamically store items into dynamically named variables. how could ...
One way that you could do that is to create a function that stores the 'session' variables. The session would have two parameters, the variable name and its value. For example: ``` function setSession(name, value) { $.session(name, value); } ``` Whenever you need to set the jQuery session variable, just call ...
556,397
<p>I have 2 tables like which I would like to query to form a new table.</p> <p>table 1</p> <pre><code> number type serial index 1000001 613 3 1 1000001 613 3 1 1000001 613 3 1 1000001 613 3 1 1000001 613 4 1 1000001 613 3 1 </code></pre...
[ { "answer_id": 557330, "author": "BIBD", "author_id": 685, "author_profile": "https://Stackoverflow.com/users/685", "pm_score": 2, "selected": true, "text": "<p>I don't think it's possible to do what you are asking. You would have to be able to distinguish each row uniquely to guarantee ...
2009/02/17
[ "https://Stackoverflow.com/questions/556397", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31132/" ]
I have 2 tables like which I would like to query to form a new table. table 1 ``` number type serial index 1000001 613 3 1 1000001 613 3 1 1000001 613 3 1 1000001 613 3 1 1000001 613 4 1 1000001 613 3 1 ``` table 2 ``` number typ...
I don't think it's possible to do what you are asking. You would have to be able to distinguish each row uniquely to guarantee a 1-to-1 result (this is normally the job of your index column or ID column). You might be able to jerry-rig something with rownum, however, if the tables are identically ordered, then perhaps...
556,405
<pre><code>$ time foo real 0m0.003s user 0m0.000s sys 0m0.004s $ </code></pre> <p>What do <code>real</code>, <code>user</code> and <code>sys</code> mean in the output of time? Which one is meaningful when benchmarking my app?</p>
[ { "answer_id": 556411, "author": "ConcernedOfTunbridgeWells", "author_id": 15401, "author_profile": "https://Stackoverflow.com/users/15401", "pm_score": 12, "selected": true, "text": "<p><strong>Real, User and Sys process time statistics</strong></p>\n\n<p>One of these things is not like...
2009/02/17
[ "https://Stackoverflow.com/questions/556405", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
``` $ time foo real 0m0.003s user 0m0.000s sys 0m0.004s $ ``` What do `real`, `user` and `sys` mean in the output of time? Which one is meaningful when benchmarking my app?
**Real, User and Sys process time statistics** One of these things is not like the other. Real refers to actual elapsed time; User and Sys refer to CPU time used *only by the process.* * **Real** is wall clock time - time from start to finish of the call. This is all elapsed time including time slices used by other p...
556,406
<p>I'm using Google Ajax API and they suggest I use <code>google.setOnLoadCallback()</code> to do various things related to their API but I'm using also jQuery's <code>$(document).ready()</code> to do other JS things, not related to Google API.</p> <p>Is it safe to mix these two approaches in one document? I did not n...
[ { "answer_id": 556423, "author": "cletus", "author_id": 18393, "author_profile": "https://Stackoverflow.com/users/18393", "pm_score": 7, "selected": true, "text": "<p>You pretty much have to do this:</p>\n\n<pre><code>google.setOnLoadCallback(function() {\n $(function() {\n // init m...
2009/02/17
[ "https://Stackoverflow.com/questions/556406", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12138/" ]
I'm using Google Ajax API and they suggest I use `google.setOnLoadCallback()` to do various things related to their API but I'm using also jQuery's `$(document).ready()` to do other JS things, not related to Google API. Is it safe to mix these two approaches in one document? I did not notice any problems yet but I sup...
You pretty much have to do this: ``` google.setOnLoadCallback(function() { $(function() { // init my stuff }); }); ``` You can't do `$(document).ready()` without `$` (the jQuery object) being available, so that needs to go inside the callback. And you can't be sure the document is ready inside the callback, ...
556,408
<p>I want to create an XML string in Flex 3 in a similar way to you might approach it in Java. I only want a small piece of XML in the format</p> <pre><code>&lt;slide thumb="http://www.thumbs.com/thumb.jpg" type="static" blah="bleh" /&gt; </code></pre> <p>The only type of code I can find for doing this seems ridiculo...
[ { "answer_id": 556446, "author": "grapefrukt", "author_id": 914, "author_profile": "https://Stackoverflow.com/users/914", "pm_score": 5, "selected": true, "text": "<p>Stay away from XMLNode if you're using as3, it's a legacy class, the new XML and XMLList classes are the ones that suppor...
2009/02/17
[ "https://Stackoverflow.com/questions/556408", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33604/" ]
I want to create an XML string in Flex 3 in a similar way to you might approach it in Java. I only want a small piece of XML in the format ``` <slide thumb="http://www.thumbs.com/thumb.jpg" type="static" blah="bleh" /> ``` The only type of code I can find for doing this seems ridiculous.... ``` private function cre...
Stay away from XMLNode if you're using as3, it's a legacy class, the new XML and XMLList classes are the ones that support the excellent E4X. Using those it's as easy as this: ``` var myXML:XML = <slide />; myXML.@thumb="http://www.thumbs.com/thumb.jpg"; myXML.@type="static"; myXML.@blah="bleh"; trace("myXML", myXML.t...
556,425
<p>Can you explain to me:</p> <ul> <li>What is a Predicate Delegate?</li> <li>Where should we use predicates?</li> <li>Any best practices when using predicates?</li> </ul> <p>Descriptive source code will be appreciated.</p>
[ { "answer_id": 556430, "author": "Adam Carr", "author_id": 1405, "author_profile": "https://Stackoverflow.com/users/1405", "pm_score": 4, "selected": false, "text": "<p>Just a delegate that returns a boolean. It is used a lot in filtering lists but can be used wherever you'd like.</p>\n...
2009/02/17
[ "https://Stackoverflow.com/questions/556425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/55351/" ]
Can you explain to me: * What is a Predicate Delegate? * Where should we use predicates? * Any best practices when using predicates? Descriptive source code will be appreciated.
A predicate is a function that returns `true` or `false`. A predicate delegate is a reference to a predicate. So basically a predicate delegate is a reference to a function that returns `true` or `false`. Predicates are very useful for filtering a list of values - here is an example. ``` using System; using System.C...
556,441
<p>Is there any way to take a StreamWriter and output the file (in this case a .txt file) to the user with the option to open/save without actually writing the file to disk? If it is not saved it will basically go away.</p> <p>I am looking for the same functionality of</p> <pre><code>HttpContext.Current.Response.Tra...
[ { "answer_id": 556454, "author": "Spence", "author_id": 53771, "author_profile": "https://Stackoverflow.com/users/53771", "pm_score": 4, "selected": true, "text": "<p>Try a <code>System.IO.MemoryStream</code></p>\n\n<pre><code>System.IO.MemoryStream ms = new System.IO.MemoryStream();\nSy...
2009/02/17
[ "https://Stackoverflow.com/questions/556441", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14777/" ]
Is there any way to take a StreamWriter and output the file (in this case a .txt file) to the user with the option to open/save without actually writing the file to disk? If it is not saved it will basically go away. I am looking for the same functionality of ``` HttpContext.Current.Response.TransmitFile(file); ``` ...
Try a `System.IO.MemoryStream` ``` System.IO.MemoryStream ms = new System.IO.MemoryStream(); System.IO.StreamWriter sw = new System.IO.StreamWriter(ms); sw.Write("hello"); ```
556,448
<p>The "onsubmit" statement is not called:</p> <pre><code>&lt;form action="index.php" method="post" onsubmit="return validateSearchKeyword()"&gt; &lt;input class="text_search" id="text_search" name="text_search" type="text" value="search" onfocus="if (this.value=='search') this.value = ''" onBlur="if (this.val...
[ { "answer_id": 556460, "author": "David Grant", "author_id": 40581, "author_profile": "https://Stackoverflow.com/users/40581", "pm_score": 2, "selected": false, "text": "<p>You're missing a submit button, which may result in users not being able to submit the form in some browsers.</p>\n...
2009/02/17
[ "https://Stackoverflow.com/questions/556448", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2019426/" ]
The "onsubmit" statement is not called: ``` <form action="index.php" method="post" onsubmit="return validateSearchKeyword()"> <input class="text_search" id="text_search" name="text_search" type="text" value="search" onfocus="if (this.value=='search') this.value = ''" onBlur="if (this.value=='') this.value = 's...
You're missing a submit button, which may result in users not being able to submit the form in some browsers. Furthermore, it would be helpful if you could post your validation function, so we can check if there problem is there, e.g. does it return a boolean? What are you results if you use the following: ``` <form...
556,483
<p>Is there an API to clear anonymous cookie?</p>
[ { "answer_id": 556631, "author": "HectorMac", "author_id": 1400, "author_profile": "https://Stackoverflow.com/users/1400", "pm_score": -1, "selected": false, "text": "<p>I'm not sure if this is what you are asking, but you can clear all cookies sent to browser as follows:</p>\n\n<pre><co...
2009/02/17
[ "https://Stackoverflow.com/questions/556483", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40789/" ]
Is there an API to clear anonymous cookie?
Yes! ``` System.Web.Security.AnonymousIdentificationModule.ClearAnonymousIdentifier() ``` See this [useful article](http://odetocode.com/articles/440.aspx) : (Migrating Anonymous User Settings) Also [Best way to Migrate Anonymous Profile](https://stackoverflow.com/questions/1660999/best-way-to-migrate-anonymous-pr...
556,494
<p>I had no luck with <a href="https://stackoverflow.com/questions/553331/detecting-unusable-pooled-sqlconnections">this question</a> so I've produced this simple-as-possible-test-case to demonstrate the problem.</p> <p>In the code below, is it possible to detect that the connection is unusable before trying to use it...
[ { "answer_id": 556559, "author": "Anton Gogolev", "author_id": 60188, "author_profile": "https://Stackoverflow.com/users/60188", "pm_score": -1, "selected": false, "text": "<p>Try moving <code>sp_unsetapprole</code> (is it really the name of the sproc? Probably, <code>sp_dropapprole</cod...
2009/02/17
[ "https://Stackoverflow.com/questions/556494", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4200/" ]
I had no luck with [this question](https://stackoverflow.com/questions/553331/detecting-unusable-pooled-sqlconnections) so I've produced this simple-as-possible-test-case to demonstrate the problem. In the code below, is it possible to detect that the connection is unusable before trying to use it? ``` SqlConnect...
In short, it doesn't look like you can in any simple way. My first thought was to run this SQL: ``` SELECT CASE WHEN USER = 'MyAppRole' THEN 1 ELSE 0 END ``` This works if you use SQL Server Management Studio, but fails when you run it from C# code. The trouble is the error you are getting is not occuring when the ...
556,509
<p>Imagine the following sql query:</p> <pre><code>UPDATE MYTABLE SET COL2 = (SELECT COL2 + 1 FROM (SELECT MAX(COL2) FROM MYTABLE) AS X) WHERE ID IN (1,2,3,4,5) </code></pre> <p>Assume that before the update is executed MAX(COL2) is 1.</p> <p>My intention is that for the update where ID=1 COL2 is updated to 'max(COL...
[ { "answer_id": 556516, "author": "lc.", "author_id": 44853, "author_profile": "https://Stackoverflow.com/users/44853", "pm_score": -1, "selected": false, "text": "<p><strike>It should be re-evaluating it at each insert; presumably the max of COL2 is not changing. Are you sure you don't w...
2009/02/17
[ "https://Stackoverflow.com/questions/556509", "https://Stackoverflow.com", "https://Stackoverflow.com/users/60956/" ]
Imagine the following sql query: ``` UPDATE MYTABLE SET COL2 = (SELECT COL2 + 1 FROM (SELECT MAX(COL2) FROM MYTABLE) AS X) WHERE ID IN (1,2,3,4,5) ``` Assume that before the update is executed MAX(COL2) is 1. My intention is that for the update where ID=1 COL2 is updated to 'max(COL2) + 1' (i.e. 2), and that for su...
``` UPDATE mytable, ( SELECT @loop := MAX(col1) FROM mytable ) o SET col1 = (@loop := @loop + 1) ``` What you encountered here is called `query stability`. No query can see the changes made by itself, or the following query: ``` UPDATE mytable SET col1 = col2 + 1 WHERE col1 > col2 ``` would never end.
556,512
<p>Im using Flex 3 and the WebService component. I started getting the following fault</p> <pre><code> HTTP request error </code></pre> <p>when making a call to service method. This error only showed up and i cant figure out whats causing it</p> <pre><code> &lt;mx:WebService useProxy="false" id= "myService"&...
[ { "answer_id": 556532, "author": "dirkgently", "author_id": 66692, "author_profile": "https://Stackoverflow.com/users/66692", "pm_score": 2, "selected": false, "text": "<p>Add the following to <code>faultHandler()</code>:</p>\n\n<pre><code>trace(event.fault.faultString, \"Error\");\nif (...
2009/02/17
[ "https://Stackoverflow.com/questions/556512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24481/" ]
Im using Flex 3 and the WebService component. I started getting the following fault ``` HTTP request error ``` when making a call to service method. This error only showed up and i cant figure out whats causing it ``` <mx:WebService useProxy="false" id= "myService"> <mx:operation name="getName" r...
Most SOAP and RPC frameworks will set the HTTP status code of an error response to `500`. The Flash Player is not able to process the contents of an HTTP response whose status code is 500, so it can be difficult to work with. Unfortunately, there is no way to work around this problem in the player, so the most common a...
556,523
<p>I'm trying to create dynamic balls by using a <code>for</code> loop. For some reason I get two objects (trace show 2 balls and their DIFFERENT properties), but on the stage I can see just a last one created.</p> <p>This is my code:</p> <pre><code>var randomBall_mc:ball=new ball(); for (i=1; i&lt;3; i++) { ...
[ { "answer_id": 556648, "author": "Theo.T", "author_id": 64223, "author_profile": "https://Stackoverflow.com/users/64223", "pm_score": 1, "selected": false, "text": "<p>It seems like you're instantiating the ball only once before the loop instead of doing it for each iteration.</p>\n" }...
2009/02/17
[ "https://Stackoverflow.com/questions/556523", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65472/" ]
I'm trying to create dynamic balls by using a `for` loop. For some reason I get two objects (trace show 2 balls and their DIFFERENT properties), but on the stage I can see just a last one created. This is my code: ``` var randomBall_mc:ball=new ball(); for (i=1; i<3; i++) { addChild(randomBall_mc); random...
**var randomBall\_mc:ball=new ball();** should be inside the for loop in order to create more than ONE "ball" ``` for (i=1; i<3; i++) { var randomBall_mc:ball=new ball();** addChild(randomBall_mc); randomBall_mc.name="randomBall"+i; randomBall_mc.x=150*i; randomBall_mc.y=175; randomBall_mc.height=20*i; randomBall_mc.w...
556,525
<p>I need to create TCP/IP headers manually for my application. For that i used Raw socket. My system os is win xp (SP3).</p> <p>My code compiles fine :) but it throws a run time error:</p> <pre> <code>Initialising Winsock...Initialised successfully. Creating Raw TCP Socket...Raw TCP Socket Created successfully. Se...
[ { "answer_id": 556589, "author": "ng5000", "author_id": 36860, "author_profile": "https://Stackoverflow.com/users/36860", "pm_score": 2, "selected": false, "text": "<p>not an answer, but hopefully a start...</p>\n\n<p>From <a href=\"http://msdn.microsoft.com/en-us/library/ms740668(VS.85)...
2009/02/17
[ "https://Stackoverflow.com/questions/556525", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61892/" ]
I need to create TCP/IP headers manually for my application. For that i used Raw socket. My system os is win xp (SP3). My code compiles fine :) but it throws a run time error: ``` Initialising Winsock...Initialised successfully. Creating Raw TCP Socket...Raw TCP Socket Created successfully. Setting the socket in RAW...
I suggest using [WinPcap](http://www.winpcap.org/) for this purpose. Even when you figure out how to do this properly with the win32 API it is going to be horribly slow. I've used WinPcap successfully to inject packets to a Gigabit ethernet port as fast as the hardware can handle.
556,526
<p>I want to create a class file dynamically. Here it goes... With the given ResultSet, extracting the metadata I want to build a class file dynamically with getter and setter methods for all the columns that exist in ResultSet. Also I should be able to use this class file generated where ever I want in my later use. C...
[ { "answer_id": 556530, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 2, "selected": false, "text": "<p>You might want to look at <a href=\"http://jakarta.apache.org/bcel/\" rel=\"nofollow noreferrer\">BCEL</a>, although ...
2009/02/17
[ "https://Stackoverflow.com/questions/556526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61369/" ]
I want to create a class file dynamically. Here it goes... With the given ResultSet, extracting the metadata I want to build a class file dynamically with getter and setter methods for all the columns that exist in ResultSet. Also I should be able to use this class file generated where ever I want in my later use. Can ...
Perhaps [Apache Beanutils](http://commons.apache.org/beanutils/) might suit your requirements? See the section on [Dynabeans](http://commons.apache.org/beanutils/apidocs/org/apache/commons/beanutils/package-summary.html#dynamic) In particular: > > 3.3 ResultSetDynaClass (Wraps ResultSet in DynaBeans) > > > A very...
556,552
<pre><code>declare begin for i in (select * from emp) loop if i.sal=1300 then update emp set sal=13000; end if; end loop; end; </code></pre> <p>This code is updating all the records with salary 13000. <br>Instead i want to update records having salary 1300 to the value 13000. <br>Can you tell...
[ { "answer_id": 556556, "author": "Andrzej Doyle", "author_id": 45664, "author_profile": "https://Stackoverflow.com/users/45664", "pm_score": 3, "selected": false, "text": "<p>You need to put a constraint on your update statement.</p>\n\n<p>What you have at the moment will loop through th...
2009/02/17
[ "https://Stackoverflow.com/questions/556552", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59649/" ]
``` declare begin for i in (select * from emp) loop if i.sal=1300 then update emp set sal=13000; end if; end loop; end; ``` This code is updating all the records with salary 13000. Instead i want to update records having salary 1300 to the value 13000. Can you tell where I made a mista...
Whenever you can do the update with one single statement, you should do that instead of using a loop. You'll get a very huge performance gain that way; or, the other way round, updates in a loop cost you a lot of performance. If you really really have to use a loop, of course you need a where condition to make sure yo...
556,572
<p>This is my first web API project, so I hope the solution to this isn't blindingly obvious. </p> <pre><code>// Contstruct the http request NSString *urlString = [NSString stringWithFormat:@"http://%@:%@@twitter.com/statuses/user_timeline/%@.xml?count=5", username, password, friend]; NSURL *url = [NSURL URLWithString...
[ { "answer_id": 556591, "author": "dirkgently", "author_id": 66692, "author_profile": "https://Stackoverflow.com/users/66692", "pm_score": 2, "selected": true, "text": "<p>Add a Basic Authentication header field where you specify the username/password. Most libraries have a setCredentials...
2009/02/17
[ "https://Stackoverflow.com/questions/556572", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28422/" ]
This is my first web API project, so I hope the solution to this isn't blindingly obvious. ``` // Contstruct the http request NSString *urlString = [NSString stringWithFormat:@"http://%@:%@@twitter.com/statuses/user_timeline/%@.xml?count=5", username, password, friend]; NSURL *url = [NSURL URLWithString:urlString]; N...
Add a Basic Authentication header field where you specify the username/password. Most libraries have a setCredentials() method though.
556,580
<p>I have a question, and I'm going to tag this <em>subjective</em> since that's what I think it evolves into, more of a discussion. I'm hoping for some good ideas or some thought-provokers. I apologize for the long-winded question but you need to know the context.</p> <p>The question is basically:</p> <ul> <li>How d...
[ { "answer_id": 556705, "author": "Chris Ballard", "author_id": 18782, "author_profile": "https://Stackoverflow.com/users/18782", "pm_score": 2, "selected": false, "text": "<p>One option might be to go with a factory pattern, so that the objects created directly by the IoC container never...
2009/02/17
[ "https://Stackoverflow.com/questions/556580", "https://Stackoverflow.com", "https://Stackoverflow.com/users/267/" ]
I have a question, and I'm going to tag this *subjective* since that's what I think it evolves into, more of a discussion. I'm hoping for some good ideas or some thought-provokers. I apologize for the long-winded question but you need to know the context. The question is basically: * How do you deal with concrete typ...
(Disclaimer: I'm answering this based on java stuff. Although I program C# I haven't proxied anything in C# but I know it's possible. Sorry about the java terminology) You could let the IoC framework inspect the object being constructed to see if it supports IDisposable. If not, you could use a dynamic proxy to wrap ...
556,590
<p>Setting the DBIC_TRACE environment variable to true:</p> <pre><code>BEGIN { $ENV{DBIC_TRACE} = 1 } </code></pre> <p>generates very helpful output, especially showing the SQL query that is being executed, but the SQL query is all on one line.</p> <p>Is there a way to push it through some kinda "sql tidy" routine t...
[ { "answer_id": 556620, "author": "Leon Timmermans", "author_id": 4727, "author_profile": "https://Stackoverflow.com/users/4727", "pm_score": 4, "selected": false, "text": "<p>From the documentation of DBIx::Class::Storage</p>\n\n<blockquote>\n <p>If DBIC_TRACE is set then trace informat...
2009/02/17
[ "https://Stackoverflow.com/questions/556590", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22682/" ]
Setting the DBIC\_TRACE environment variable to true: ``` BEGIN { $ENV{DBIC_TRACE} = 1 } ``` generates very helpful output, especially showing the SQL query that is being executed, but the SQL query is all on one line. Is there a way to push it through some kinda "sql tidy" routine to format it better, perhaps brea...
[As of DBIx::Class 0.08124 it's built in.](http://blog.afoolishmanifesto.com/archives/1444) Just set `$ENV{DBIC_TRACE_PROFILE}` to `console` or `console_monochrome`.
556,592
<p>I am just starting out on Silverlight using version 2.0. I wanted to show a few data grids on the page and got this going OK by dropping each into a grid cell. I then thought I would try adding a grid splitter using the following markup:</p> <pre><code>&lt;UserControl xmlns:basics="clr-namespace:System.Windows.Cont...
[ { "answer_id": 556777, "author": "Jarrett Meyer", "author_id": 5834, "author_profile": "https://Stackoverflow.com/users/5834", "pm_score": 4, "selected": true, "text": "<p>You don't need the middle column for the gridsplitter. The Gridsplitter will bind to the right edge of column 0 if y...
2009/02/17
[ "https://Stackoverflow.com/questions/556592", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44938/" ]
I am just starting out on Silverlight using version 2.0. I wanted to show a few data grids on the page and got this going OK by dropping each into a grid cell. I then thought I would try adding a grid splitter using the following markup: ``` <UserControl xmlns:basics="clr-namespace:System.Windows.Controls;assembly=Sys...
You don't need the middle column for the gridsplitter. The Gridsplitter will bind to the right edge of column 0 if you put the splitter in column 0. You can add a small margin to the grids in the left-hand side so that you don't lose the last 5 pixels. ``` <Grid x:Name="LayoutRoot" Background="White"> <Grid.Column...
556,601
<p>What is the equation of a helix <strong>parametrized by arc length</strong> (i.e. a function of arc length) between any two points in space? Is there any function for this ? How do i implement the same using matlab or mathematica ?</p>
[ { "answer_id": 556636, "author": "Mitch Wheat", "author_id": 16076, "author_profile": "https://Stackoverflow.com/users/16076", "pm_score": 2, "selected": false, "text": "<p>To find the arc length parameterization of the helix defined by </p>\n\n<pre><code> r(t) = cos t i + sin t j +...
2009/02/17
[ "https://Stackoverflow.com/questions/556601", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
What is the equation of a helix **parametrized by arc length** (i.e. a function of arc length) between any two points in space? Is there any function for this ? How do i implement the same using matlab or mathematica ?
To find the arc length parameterization of the helix defined by ``` r(t) = cos t i + sin t j + t k ``` Arc Length = s = Integral(a,b){sqrt((dx/dt)^2 + (dy/dt)^2 + (dz/dt)^2) dt} First find the arc length function ``` s(t) = Integral(0,t) { sqrt((sin u)^2 + (cos u)^2 + 1) du } = Integral(0,t) ...
556,607
<p>I have a project that need to sends notification for employees by local email. I use SmtpClient class to send email but didn't work! here is the code: </p> <pre><code> MailMessage message = new MailMessage(); message.From = new MailAddress("localmail1@company.com"); message.To.Add(new MailAddress("loca...
[ { "answer_id": 556611, "author": "Garry Shutler", "author_id": 6369, "author_profile": "https://Stackoverflow.com/users/6369", "pm_score": 1, "selected": false, "text": "<p>Assuming that you have the server and any required credentials correct (double check these) I would try increasing ...
2009/02/17
[ "https://Stackoverflow.com/questions/556607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36446/" ]
I have a project that need to sends notification for employees by local email. I use SmtpClient class to send email but didn't work! here is the code: ``` MailMessage message = new MailMessage(); message.From = new MailAddress("localmail1@company.com"); message.To.Add(new MailAddress("localmail2@company....
Use the fully qualified name for your server, for example, exchangeDNS.example.com. If that doesn't work, try the IP address. You may want to manually telnet to port 25 on the Exchange server, just to see if it is possible. Also, check whether your server requires an authenticated or encrypted connection. If so, you'll...
556,612
<p>I am using the Microsoft Ajax Template DataView to bind values to a template. I can do this and it works as you'd expect:</p> <pre><code>&lt;h3&gt;{{ID}}&lt;/h3&gt; &lt;p&gt;{{Address}}&lt;/p&gt; </code></pre> <p>However I am trying to build an action link that has the ID in it.</p> <pre><code>&lt;h2&gt;&lt;%= Ht...
[ { "answer_id": 556611, "author": "Garry Shutler", "author_id": 6369, "author_profile": "https://Stackoverflow.com/users/6369", "pm_score": 1, "selected": false, "text": "<p>Assuming that you have the server and any required credentials correct (double check these) I would try increasing ...
2009/02/17
[ "https://Stackoverflow.com/questions/556612", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33054/" ]
I am using the Microsoft Ajax Template DataView to bind values to a template. I can do this and it works as you'd expect: ``` <h3>{{ID}}</h3> <p>{{Address}}</p> ``` However I am trying to build an action link that has the ID in it. ``` <h2><%= Html.ActionLink(Html.AttributeEncode("{{Name}}"), "Index", "Restaurant",...
Use the fully qualified name for your server, for example, exchangeDNS.example.com. If that doesn't work, try the IP address. You may want to manually telnet to port 25 on the Exchange server, just to see if it is possible. Also, check whether your server requires an authenticated or encrypted connection. If so, you'll...
556,616
<p>I'm facing a deadlock, my code structure is similar to this:</p> <pre><code>private delegate void UpdateControlDelegate(string value); public void UpdateControl(string value) { if (txtAddress.InvokeRequired) { txtAddress.Invoke(new UpdateControlDelegate(UpdateControl), value); } else { ...
[ { "answer_id": 556622, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": true, "text": "<p>The problem is almost certainly that you're acquiring the lock within a background thread, then calling <code>Control....
2009/02/17
[ "https://Stackoverflow.com/questions/556616", "https://Stackoverflow.com", "https://Stackoverflow.com/users/66887/" ]
I'm facing a deadlock, my code structure is similar to this: ``` private delegate void UpdateControlDelegate(string value); public void UpdateControl(string value) { if (txtAddress.InvokeRequired) { txtAddress.Invoke(new UpdateControlDelegate(UpdateControl), value); } else { txtAdd...
The problem is almost certainly that you're acquiring the lock within a background thread, then calling `Control.Invoke`, and invoking a delegate (on the UI thread) which tries to acquire the same lock. It can't do that, because the other thread holds the lock - and will keep holding the lock while it waits for the UI ...
556,625
<p>As the topic says I'm very new to c++, but I have some experience with java. To start learning c++ I had the (not very original) idea of making a simple command line calculator. What I'm trying to do is store the numbers and operators in a binary tree.</p> <pre><code>#include &lt;iostream&gt; using namespace std; ...
[ { "answer_id": 556640, "author": "Lennart Koopmann", "author_id": 66445, "author_profile": "https://Stackoverflow.com/users/66445", "pm_score": 0, "selected": false, "text": "<p>There are very different conventions for C++. Google some. There is no \"official\" convention. ;)</p>\n\n<p>T...
2009/02/17
[ "https://Stackoverflow.com/questions/556625", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
As the topic says I'm very new to c++, but I have some experience with java. To start learning c++ I had the (not very original) idea of making a simple command line calculator. What I'm trying to do is store the numbers and operators in a binary tree. ``` #include <iostream> using namespace std; class Node { bool ...
First, i recommend you a good book too. There are very good SO threads about C++ books, like [The definitive C++ book guide and List](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list). In the following, you find i tell you how to solve some problems, but i don't delve into details, becaus...
556,655
<p>I have a case in which I have to read an input file in the C'tor, but sometimes this file doesn't exist. This object is usually held statically, so its C'tor is called while loading the dll. I can't catch the exception I throw if the file doesn't exist because it's too early, and my executable crashes in an ugly way...
[ { "answer_id": 556666, "author": "sharptooth", "author_id": 57428, "author_profile": "https://Stackoverflow.com/users/57428", "pm_score": 1, "selected": false, "text": "<p>Redesign the object in such a way that it opens the file later - for example when the data from the file is requeste...
2009/02/17
[ "https://Stackoverflow.com/questions/556655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46418/" ]
I have a case in which I have to read an input file in the C'tor, but sometimes this file doesn't exist. This object is usually held statically, so its C'tor is called while loading the dll. I can't catch the exception I throw if the file doesn't exist because it's too early, and my executable crashes in an ugly way. I...
I assume the static object has the file scope (it is outside any function/class definition). You may consider moving it to an accessor function and accessing it only via that function, like this: ``` class Object; Object& getObject() { static Object object; return object; } ``` The static instance of *Object...
556,673
<p>I need to make a rather complex query, and I need help bad. Below is an example I made.</p> <p>Basically, I need a query that will return one row for each <strong>case_id</strong> where the type is <strong>support</strong>, status <strong>start</strong>, and date meaning the very first one created (so that in the e...
[ { "answer_id": 556710, "author": "Rockcoder", "author_id": 5290, "author_profile": "https://Stackoverflow.com/users/5290", "pm_score": 2, "selected": false, "text": "<p>Maybe something like:</p>\n\n<pre><code>select Case_ID, Name, MIN(date), Status, Type \nfrom table\nwhere type = 'Suppo...
2009/02/17
[ "https://Stackoverflow.com/questions/556673", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I need to make a rather complex query, and I need help bad. Below is an example I made. Basically, I need a query that will return one row for each **case\_id** where the type is **support**, status **start**, and date meaning the very first one created (so that in the example below, only the 2/1/2009 John's case gets...
In SQL Server 2005 and beyond I would use Common Table Expressions (CTE). This offers lots of possibilities like so: ``` With ResultTable (RowNumber ,ID ,Case_ID ,Name ,Date ,Status ,Type) AS ( SELECT Row_Number()...
556,674
<p>Does anyone know if VB6 IDE has the ability to run pre-build events prior to making and compiling the code (this is for creating a .vb file from a template file for subversion revision numbers to be compiled into the code using SubWCRev.exe).</p> <p>Thanks</p>
[ { "answer_id": 556745, "author": "RS Conley", "author_id": 7890, "author_profile": "https://Stackoverflow.com/users/7890", "pm_score": 4, "selected": true, "text": "<p>There is no method to do this from the IDE. My company built a utility (in VB6) to do our automated build process includ...
2009/02/17
[ "https://Stackoverflow.com/questions/556674", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51604/" ]
Does anyone know if VB6 IDE has the ability to run pre-build events prior to making and compiling the code (this is for creating a .vb file from a template file for subversion revision numbers to be compiled into the code using SubWCRev.exe). Thanks
There is no method to do this from the IDE. My company built a utility (in VB6) to do our automated build process including steps like you mention (updating version numbers, etc). The essential trick is that you can run VB6.exe from the command line to compile projects. To see a list of all the option just goto the V...
556,683
<p>I have a customized exception class. say class CustomExcep{};</p> <p>My Application is a middleware made of C++. It is a webservice which is used for the communication between Java based web Front-end and the DCE Backend.</p> <p>whenever the DCE Backend is not running or down due to some core dumps, the applicatio...
[ { "answer_id": 556695, "author": "Douglas Leeder", "author_id": 3978, "author_profile": "https://Stackoverflow.com/users/3978", "pm_score": 0, "selected": false, "text": "<p>When you catch the exception you need to <code>delete</code> it.</p>\n" }, { "answer_id": 556701, "aut...
2009/02/17
[ "https://Stackoverflow.com/questions/556683", "https://Stackoverflow.com", "https://Stackoverflow.com/users/67355/" ]
I have a customized exception class. say class CustomExcep{}; My Application is a middleware made of C++. It is a webservice which is used for the communication between Java based web Front-end and the DCE Backend. whenever the DCE Backend is not running or down due to some core dumps, the application throws the Cust...
Pre allocate the exception using the static keyword. ``` static const CustomExcep e; throw e; ``` Microsoft's VC++ implementation of the "new"-operator uses this technique. By using the static keyword only one exception will be created throughout the applications lifetime, and then reused in every call. That way you...
556,698
<p>I am attempting to write a 'User Control' in WinForms .NET (not ASP.NET). The control is relatively simple. It will contain a label, a button, and a DataGridView.</p> <p>However, the control needs to be able to instantiate itself, i.e. when the user clicks the button (of the parent control) at least 1 nested (chi...
[ { "answer_id": 556695, "author": "Douglas Leeder", "author_id": 3978, "author_profile": "https://Stackoverflow.com/users/3978", "pm_score": 0, "selected": false, "text": "<p>When you catch the exception you need to <code>delete</code> it.</p>\n" }, { "answer_id": 556701, "aut...
2009/02/17
[ "https://Stackoverflow.com/questions/556698", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52212/" ]
I am attempting to write a 'User Control' in WinForms .NET (not ASP.NET). The control is relatively simple. It will contain a label, a button, and a DataGridView. However, the control needs to be able to instantiate itself, i.e. when the user clicks the button (of the parent control) at least 1 nested (children) contr...
Pre allocate the exception using the static keyword. ``` static const CustomExcep e; throw e; ``` Microsoft's VC++ implementation of the "new"-operator uses this technique. By using the static keyword only one exception will be created throughout the applications lifetime, and then reused in every call. That way you...
556,703
<p>We have a requirement to have our ASP.NET MVC websites be automatically closed down by a remote notification (change in database value). Where would be the best place to implement this?</p> <ul> <li>Base Controller Class</li> <li>Global.asax</li> <li>Custom attribute</li> <li>Other</li> </ul> <p><strong>Update</st...
[ { "answer_id": 556713, "author": "Garry Shutler", "author_id": 6369, "author_profile": "https://Stackoverflow.com/users/6369", "pm_score": 3, "selected": false, "text": "<p>I would go with Global.asax Application_BeginRequest if you have to do it programmatically.</p>\n\n<p>You could Res...
2009/02/17
[ "https://Stackoverflow.com/questions/556703", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38911/" ]
We have a requirement to have our ASP.NET MVC websites be automatically closed down by a remote notification (change in database value). Where would be the best place to implement this? * Base Controller Class * Global.asax * Custom attribute * Other **Update** Lots of suggestions to use app\_offline but this scenar...
I'm going to answer this myself as I did it a different way but thanks to everyone for their responses. What I ended up doing is overriding OnActionExecuting() in my BaseController class (which all my controllers derived from). In this method I check the database (using a 1 minute cache) and if the website is closed...
556,714
<p>I'm currently trying to understand how the stack works, so I've decided teach myself some <a href="http://en.wikipedia.org/wiki/Assembly_language" rel="noreferrer">assembly language</a>, I'm using this book:</p> <p><a href="http://savannah.nongnu.org/projects/pgubook/" rel="noreferrer">http://savannah.nongnu.org/pr...
[ { "answer_id": 556728, "author": "Gal Goldman", "author_id": 46418, "author_profile": "https://Stackoverflow.com/users/46418", "pm_score": 1, "selected": false, "text": "<p>The stack already exists, so you can assume that when writing your code.\nThe stack contains the return addresses o...
2009/02/17
[ "https://Stackoverflow.com/questions/556714", "https://Stackoverflow.com", "https://Stackoverflow.com/users/67357/" ]
I'm currently trying to understand how the stack works, so I've decided teach myself some [assembly language](http://en.wikipedia.org/wiki/Assembly_language), I'm using this book: <http://savannah.nongnu.org/projects/pgubook/> I'm using [Gas](http://en.wikipedia.org/wiki/GNU_Assembler) and doing my development on [L...
I think primarily you're getting confused between a `program's stack` and `any old stack`. **A Stack** Is an abstract data structure which consists of information in a Last In First Out system. You put arbitrary objects onto the stack and then you take them off again, much like an in/out tray, the top item is always ...
556,730
<p>I need to load (de-serialize) a pre-computed list of integers from a file in a Python script (into a Python list). The list is large (upto millions of items), and I can choose the format I store it in, as long as loading is fastest.</p> <p>Which is the fastest method, and why?</p> <ol> <li>Using <code>import</code...
[ { "answer_id": 556843, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 2, "selected": false, "text": "<p>\"how can one benchmark such things reliably?\" </p>\n\n<p>I don't get the question.</p>\n\n<p>You write a bunch of lit...
2009/02/17
[ "https://Stackoverflow.com/questions/556730", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8206/" ]
I need to load (de-serialize) a pre-computed list of integers from a file in a Python script (into a Python list). The list is large (upto millions of items), and I can choose the format I store it in, as long as loading is fastest. Which is the fastest method, and why? 1. Using `import` on a .py file that just conta...
I would guess [cPickle](http://docs.python.org/library/pickle.html#module-cPickle) will be fastest if you really need the thing in a list. If you can use an [array](http://docs.python.org/library/array.html), which is a built-in sequence type, I timed this at a quarter of a second for 1 million integers: ``` from arr...
556,747
<p>I have a UIViewController that allows me to view and edit information of a class.</p> <p>It is only allocated once but it's number of rows,sections and data is passed to it depending on the value the user selected. </p> <p>For example. Here it is editing a name &amp; type property (Header view of table is too big....
[ { "answer_id": 558404, "author": "Mark Bessey", "author_id": 17826, "author_profile": "https://Stackoverflow.com/users/17826", "pm_score": 2, "selected": false, "text": "<p>Hard to tell without looking at all the code, but is it possible that you're not recycling your tableview cells pro...
2009/02/17
[ "https://Stackoverflow.com/questions/556747", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51420/" ]
I have a UIViewController that allows me to view and edit information of a class. It is only allocated once but it's number of rows,sections and data is passed to it depending on the value the user selected. For example. Here it is editing a name & type property (Header view of table is too big.. I did this so you w...
Hard to tell without looking at all the code, but is it possible that you're not recycling your tableview cells properly? You have to assign a different reuseIdentifier for each cell that's rendered differently. If a header cell is getting reused as a detail cell (or vice-versa) that'll cause some oddities in rendering...
556,767
<p>I'm looking for a javascript that can limit the number of lines (by line I mean some text ended by user pressing enter on the keyboard) the user is able to enter in textarea. I've found some solutions but they simply don't work or behave really weird. The best solution would be a jquery plugin that can do the work -...
[ { "answer_id": 556792, "author": "alphadogg", "author_id": 59494, "author_profile": "https://Stackoverflow.com/users/59494", "pm_score": 2, "selected": false, "text": "<p>The number of visible/display lines for a given block of text would vary with different browsers, fonts used, etc. Yo...
2009/02/17
[ "https://Stackoverflow.com/questions/556767", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49048/" ]
I'm looking for a javascript that can limit the number of lines (by line I mean some text ended by user pressing enter on the keyboard) the user is able to enter in textarea. I've found some solutions but they simply don't work or behave really weird. The best solution would be a jquery plugin that can do the work - so...
This *might* help (probably be best using jQuery, onDomReady and unobtrusively adding the keydown event to the textarea) but tested in IE7 and FF3: ``` <html> <head><title>Test</title></head> <body> <script type="text/javascript"> var keynum, lines = 1; function limitLines(obj, e) { // IE ...
556,771
<p>From <a href="http://msdn.microsoft.com/en-us/library/441722ys(VS.80).aspx" rel="noreferrer">msdn</a> I get this:</p> <pre><code>#pragma warning disable warning-list #pragma warning restore warning-list </code></pre> <p>In the examples, both <code>disable</code> and <code>restore</code> are used. Is it necessary t...
[ { "answer_id": 556783, "author": "John Leidegren", "author_id": 58961, "author_profile": "https://Stackoverflow.com/users/58961", "pm_score": 2, "selected": false, "text": "<p>No, you'll find that the compiler will automatically restore any disabled warning once it's finished parsing a s...
2009/02/17
[ "https://Stackoverflow.com/questions/556771", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39321/" ]
From [msdn](http://msdn.microsoft.com/en-us/library/441722ys(VS.80).aspx) I get this: ``` #pragma warning disable warning-list #pragma warning restore warning-list ``` In the examples, both `disable` and `restore` are used. Is it necessary to `restore` if I want it disabled for a whole file? Like, if I do not resto...
If you do not restore the disabling is active for the remainder of the file. Interestingly this behaviour is **not** defined in the [language specification](http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-334.pdf). (see section 9.5.8) However the 9.5.1 section on Conditional compilation symbols does ...
556,775
<p>In wcf, what is the difference between applying the <code>DataMember</code> attribute on a property </p> <pre><code>private int m_SomeValue; [DataMember] public int SomeValue { get {...} set {...} } </code></pre> <p>instead of a member variable </p> <pre><code>[DataMember] private int m_SomeValue; pub...
[ { "answer_id": 556794, "author": "Jarrett Meyer", "author_id": 5834, "author_profile": "https://Stackoverflow.com/users/5834", "pm_score": 2, "selected": false, "text": "<p>In theory, and as long as you keep <code>m_SomeValue</code> always equal to <code>SomeValue</code> (like a simple g...
2009/02/17
[ "https://Stackoverflow.com/questions/556775", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65060/" ]
In wcf, what is the difference between applying the `DataMember` attribute on a property ``` private int m_SomeValue; [DataMember] public int SomeValue { get {...} set {...} } ``` instead of a member variable ``` [DataMember] private int m_SomeValue; public int SomeValue { get {...} set {...} } ```...
In general, you should favor applying the DataMember attribute on the property, rather than on the private field. The only reason to apply the attribute to the field instead is if the property were read-only (i.e. it has no setter).
556,787
<p>I have a weird problem with the CalandarExtender on my web project. When someone click on the little calandar icon IE6 crash! I think i properly implemented it </p> <pre><code>&lt;%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %&gt; &lt;asp:TextBox ID="txtDat...
[ { "answer_id": 628984, "author": "Chris", "author_id": 59198, "author_profile": "https://Stackoverflow.com/users/59198", "pm_score": 1, "selected": false, "text": "<p>If you're willing to step outside the world of what asp.net gives you, you have lots of options such as this:</p>\n\n<p><...
2009/02/17
[ "https://Stackoverflow.com/questions/556787", "https://Stackoverflow.com", "https://Stackoverflow.com/users/60561/" ]
I have a weird problem with the CalandarExtender on my web project. When someone click on the little calandar icon IE6 crash! I think i properly implemented it ``` <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <asp:TextBox ID="txtDateDebut" runat="server" ...
Two things to try: 1) If you're running this inside of an `UpdatePanel`, make sure your UpdatePanel has an ID set on it. 2) If you have set `EnableEventValidation="false"`, try turning it back `on`. I know those sound weird, but #2 fixed a crash in IE6 in a very complicated web application that I work on...
556,789
<p>Having an HTML page with a simple table and js code to do show / hide on it: </p> <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;title&gt;title&lt;/title&gt; &lt;script type="text/javascript"&gt; function showErrorSteps() { var el = document.getElemen...
[ { "answer_id": 556810, "author": "cletus", "author_id": 18393, "author_profile": "https://Stackoverflow.com/users/18393", "pm_score": 4, "selected": true, "text": "<p>Tables shouldn't be set to <code>display: block</code>. Table rows and cells shouldn't either. They have different disp...
2009/02/17
[ "https://Stackoverflow.com/questions/556789", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21634/" ]
Having an HTML page with a simple table and js code to do show / hide on it: ``` <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>title</title> <script type="text/javascript"> function showErrorSteps() { var el = document.getElementById("t1"); if(el.style.display=="n...
Tables shouldn't be set to `display: block`. Table rows and cells shouldn't either. They have different display values. My advice? Don't do it this way. Use a class: ``` .hidden { display: none; } ``` and dynamically add it and remove it from the table to avoid problems of setting the right display type on an elem...
556,801
<p>My primary computer for programming is the same computer I use for gaming etc. So to increase speed while gaming I turned off services like Apache, MySQL, Subversion etc. from starting at boot as I use it about 50/50 for gaming/programming.</p> <p>This is fine most of the time but it's a bit of a nuisance to start ...
[ { "answer_id": 556808, "author": "kemiller2002", "author_id": 1942, "author_profile": "https://Stackoverflow.com/users/1942", "pm_score": 4, "selected": true, "text": "<p>Well you can write a batch file like</p>\n\n<pre><code>net start \"Service Name\"\n</code></pre>\n\n<p>There should b...
2009/02/17
[ "https://Stackoverflow.com/questions/556801", "https://Stackoverflow.com", "https://Stackoverflow.com/users/67366/" ]
My primary computer for programming is the same computer I use for gaming etc. So to increase speed while gaming I turned off services like Apache, MySQL, Subversion etc. from starting at boot as I use it about 50/50 for gaming/programming. This is fine most of the time but it's a bit of a nuisance to start them all s...
Well you can write a batch file like ``` net start "Service Name" ``` There should be a way to dependency link the services together also, so when one starts all the others will too. I'll see if I can find the switch to do that. EDIT: I haven't tried this, but this should tell you where to find in the registry to...
556,814
<p>I have a UITableView with an Index on the side; I want to add a UISearchBar to it, but the index overlaps with the "x" to clear the search. I've noticed in the Contacts application, the textfield within the UISearchBar is resized to accommodate this, but I can't work out how to do this in my own app.</p> <p>I hav...
[ { "answer_id": 556935, "author": "Can Berk Güder", "author_id": 2119, "author_profile": "https://Stackoverflow.com/users/2119", "pm_score": 1, "selected": false, "text": "<p>The text field used in UISearchBar is a subclass of UITextField called UISearchBarTextField.</p>\n\n<p>AFAIK, ther...
2009/02/17
[ "https://Stackoverflow.com/questions/556814", "https://Stackoverflow.com", "https://Stackoverflow.com/users/67369/" ]
I have a UITableView with an Index on the side; I want to add a UISearchBar to it, but the index overlaps with the "x" to clear the search. I've noticed in the Contacts application, the textfield within the UISearchBar is resized to accommodate this, but I can't work out how to do this in my own app. I have tried the ...
it's much easier than all these suggestions. In interface builder, instead of putting the Search Bar as the header of your Table View, you can put a View instead. Then, put a Navigation Bar inside this View. Grab the left resizing handle of the Navigation Bar and pull it to the right until the N B is only 25 pixels wid...
556,818
<p>Is there any difference between typing:</p> <pre><code>&lt;?php echo $_SERVER[REQUEST_URI] ?&gt; </code></pre> <p>or</p> <pre><code>&lt;?php echo $_SERVER['REQUEST_URI'] ?&gt; </code></pre> <p>or</p> <pre><code>&lt;?php echo $_SERVER[&quot;REQUEST_URI&quot;] ?&gt; </code></pre> <p>?</p> <p>They all work... I use the...
[ { "answer_id": 556833, "author": "Gumbo", "author_id": 53114, "author_profile": "https://Stackoverflow.com/users/53114", "pm_score": 5, "selected": true, "text": "<p><strong>Without quotes PHP interprets the <code>REQUEST_URI</code> as a constant</strong> but corrects your typo error if ...
2009/02/17
[ "https://Stackoverflow.com/questions/556818", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Is there any difference between typing: ``` <?php echo $_SERVER[REQUEST_URI] ?> ``` or ``` <?php echo $_SERVER['REQUEST_URI'] ?> ``` or ``` <?php echo $_SERVER["REQUEST_URI"] ?> ``` ? They all work... I use the first one. Maybe one is faster than the other?
**Without quotes PHP interprets the `REQUEST_URI` as a constant** but corrects your typo error if there is no such constant and interprets it as string. When [`error_reporting`](http://docs.php.net/manual/en/errorfunc.configuration.php#ini.error-reporting) includes [`E_NOTICE`](http://docs.php.net/manual/en/errorfunc....
556,820
<p>I have a shell script that saves the output of a command that is executed to a CSV file. It reads the command it has to execute from a shell script which is in this format:</p> <pre><code>ffmpeg -i /home/test/videos/avi/418kb.avi /home/test/videos/done/418kb.flv ffmpeg -i /home/test/videos/avi/1253kb.avi /home/test...
[ { "answer_id": 556881, "author": "Johannes Weiss", "author_id": 55925, "author_profile": "https://Stackoverflow.com/users/55925", "pm_score": 3, "selected": true, "text": "<p>I think that should do the same and seems to be correct:</p>\n\n<pre><code>#!/bin/bash\n\nCSVFILE=/tmp/file.csv\n...
2009/02/17
[ "https://Stackoverflow.com/questions/556820", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51649/" ]
I have a shell script that saves the output of a command that is executed to a CSV file. It reads the command it has to execute from a shell script which is in this format: ``` ffmpeg -i /home/test/videos/avi/418kb.avi /home/test/videos/done/418kb.flv ffmpeg -i /home/test/videos/avi/1253kb.avi /home/test/videos/done/1...
I think that should do the same and seems to be correct: ``` #!/bin/bash CSVFILE=/tmp/file.csv cat "$@" | while read line; do echo "Executing '$line'" START=$(date +%s) eval $line &> /dev/null END=$(date +%s) let DIFF=$END-$START echo "$line, $START, $END, $DIFF" >> "$CSVFILE" echo "It t...
556,827
<p>On windows, I'm trying to acquire the file name using the %~f1 parameter. </p> <p>I'm doing this from a new voice (command) which I've added to the contextual menu. </p> <p>In the windows registry, the voice simply calls a batch script which prints the file name, by this way:</p> <pre><code>`C:\script.bat %~f1` ...
[ { "answer_id": 556880, "author": "Antonio Haley", "author_id": 390, "author_profile": "https://Stackoverflow.com/users/390", "pm_score": 0, "selected": false, "text": "<p>Try enclosing the entire variable in %'s.</p>\n\n<p><code>C:\\script.bat %~f1%</code></p>\n" }, { "answer_id"...
2009/02/17
[ "https://Stackoverflow.com/questions/556827", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39339/" ]
On windows, I'm trying to acquire the file name using the %~f1 parameter. I'm doing this from a new voice (command) which I've added to the contextual menu. In the windows registry, the voice simply calls a batch script which prints the file name, by this way: ``` `C:\script.bat %~f1` ``` but I get this output:...
When the context menu item it triggered, it is done so by Explorer (not cmd.exe) and Explorer does not implement %~f1. Hence you get the current result. What you need is to modify your script so it receives the whole filename (you would probably put only 'C:\script.bat %1' or 'C:\script.bat' in the registry) and updat...
556,835
<p>Hey, I'm trying to figure out how to display the ▼ character properly in a .NET winform application.</p> <p>I am creating a custom control, and for the button, I want this character to appear. I am able to set the text to this character, but it appears as a blank square. </p> <p>Any ideas on what I need to do t...
[ { "answer_id": 556844, "author": "SecretDeveloper", "author_id": 2720, "author_profile": "https://Stackoverflow.com/users/2720", "pm_score": 0, "selected": false, "text": "<p>Can you post the code you are currently using ?</p>\n\n<p>You can print out characters using the chr(int) functio...
2009/02/17
[ "https://Stackoverflow.com/questions/556835", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62923/" ]
Hey, I'm trying to figure out how to display the ▼ character properly in a .NET winform application. I am creating a custom control, and for the button, I want this character to appear. I am able to set the text to this character, but it appears as a blank square. Any ideas on what I need to do to make this characte...
There can often be issues (both with source control systes and diff tools) if you embed more complex unicode characters in source files. It is often better to do it via an explicit escape sequence and keep the source file in a simpler encoding. ``` btnCalendarToggle.Text = "\u25BC"; ``` If this works it is likely t...
556,838
<p>I want to do the following:<br> Define a map between a string and any kind of object (may be a list, integer - anything).<br> The keys to the map can be as follow (the values are, again, not important):<br> "AAA/123" ==> 1<br> "AAA/<em>" ==> 2<br> "BBB/</em>" ==> 3<br> "CCC/*" ==> 4<br> "CCC/123" ==> 5<br> Now, the ...
[ { "answer_id": 557408, "author": "Guy", "author_id": 24409, "author_profile": "https://Stackoverflow.com/users/24409", "pm_score": 3, "selected": true, "text": "<p>Here's a variant of litb answer (which was somehow deleted from the answers list) which might work given the '*' is removed:...
2009/02/17
[ "https://Stackoverflow.com/questions/556838", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24409/" ]
I want to do the following: Define a map between a string and any kind of object (may be a list, integer - anything). The keys to the map can be as follow (the values are, again, not important): "AAA/123" ==> 1 "AAA/*" ==> 2 "BBB/*" ==> 3 "CCC/\*" ==> 4 "CCC/123" ==> 5 Now, the trick is I want t...
Here's a variant of litb answer (which was somehow deleted from the answers list) which might work given the '\*' is removed: ``` template<typename Map> typename Map::const_iterator find_prefix(Map const& map, typename Map::key_type const& key) { typename Map::const_iterator it = map.upper_bound(key); while (...
556,865
<p>I am working with Visual Studio 2008 editor. Is there a way to take a piece of text for example, highlight it and use shortcuts to quickly add markup?<br> For example, lets say I have a text, I went to: <code>the store</code> and I want to bold it, I have to type <code>&lt;b&gt;the store&lt;/b&gt;</code>. Is there ...
[ { "answer_id": 556941, "author": "Mike Chaliy", "author_id": 38975, "author_profile": "https://Stackoverflow.com/users/38975", "pm_score": 3, "selected": true, "text": "<p>With HTML Editor just press <kbd>Ctrl</kbd>+<kbd>B</kbd>...</p>\n\n<p>With regular text editor VS does not provide s...
2009/02/17
[ "https://Stackoverflow.com/questions/556865", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33690/" ]
I am working with Visual Studio 2008 editor. Is there a way to take a piece of text for example, highlight it and use shortcuts to quickly add markup? For example, lets say I have a text, I went to: `the store` and I want to bold it, I have to type `<b>the store</b>`. Is there a quicker and easier way to do this?
With HTML Editor just press `Ctrl`+`B`... With regular text editor VS does not provide something build-in, but you can add custom macros. Something like the following will do job for you. ``` Sub MakeSelectionBold() DTE.ActiveDocument.Selection.Text = "<b>" + DTE.ActiveDocument.Selection.Text + "</b>" End Sub ``...
556,875
<p>What is the best way to use more than 1 font color with <code>textField.htmlText</code>?</p> <p>I already use code like:</p> <pre><code>textField.htmlText = "blaa blaa" + "&lt; u &gt;"+w+"&lt; /u &gt;"+"blaa blaa" </code></pre> <p>How can I make that to define a specific color as well?</p>
[ { "answer_id": 556915, "author": "Jeff Winkworth", "author_id": 1306, "author_profile": "https://Stackoverflow.com/users/1306", "pm_score": 2, "selected": false, "text": "<p>Use <a href=\"http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/text/StyleSheet.html\" rel=\"nofollo...
2009/02/17
[ "https://Stackoverflow.com/questions/556875", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20979/" ]
What is the best way to use more than 1 font color with `textField.htmlText`? I already use code like: ``` textField.htmlText = "blaa blaa" + "< u >"+w+"< /u >"+"blaa blaa" ``` How can I make that to define a specific color as well?
FONT Tag is easier
556,876
<p>If I have a makefile that calls another makefile, how to I get the master makefile to correctly check if the dependencies of the subordinate makefile have changed?</p> <p>For example, if I have the rule</p> <pre><code>server: @cd $(SERVERDIR) &amp;&amp; $(MAKE) </code></pre> <p>That invokes make in the subdi...
[ { "answer_id": 557154, "author": "Quassnoi", "author_id": 55159, "author_profile": "https://Stackoverflow.com/users/55159", "pm_score": 1, "selected": false, "text": "<p>Your target name matches the name of one of the files or directories in your main <code>Makefile</code> directory.</p>...
2009/02/17
[ "https://Stackoverflow.com/questions/556876", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4924/" ]
If I have a makefile that calls another makefile, how to I get the master makefile to correctly check if the dependencies of the subordinate makefile have changed? For example, if I have the rule ``` server: @cd $(SERVERDIR) && $(MAKE) ``` That invokes make in the subdirectory in which I build an executable "s...
It looks like you want to use a phony target ``` .PHONY: server server: @cd $(SERVERDIR) && $(MAKE) ``` There's a detailed description of the Phony target [here](http://www.gnu.org/software/make/manual/make.html#index-g_t_002ePHONY-216), but the short description is you're telling the makefile that there will n...
556,911
<p>This is a challenge for the css gurus out there. I want to show 2 links on my page, on the same "line", one on the left, one on the right.</p> <p>The code below works perfectly well in terms of visual presentation, but I'm aware that tables to format a page are not the done thing. Can anyone tell me what the "app...
[ { "answer_id": 556931, "author": "Lennart Koopmann", "author_id": 66445, "author_profile": "https://Stackoverflow.com/users/66445", "pm_score": 1, "selected": false, "text": "<pre><code>&lt;div style=\"width: 95%\"&gt;\n &lt;div style=\"float: left;\"&gt;Link 1&lt;/div&gt;\n &lt;div st...
2009/02/17
[ "https://Stackoverflow.com/questions/556911", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52494/" ]
This is a challenge for the css gurus out there. I want to show 2 links on my page, on the same "line", one on the left, one on the right. The code below works perfectly well in terms of visual presentation, but I'm aware that tables to format a page are not the done thing. Can anyone tell me what the "approved" marku...
You can avoid the heavy markup by leveraging the fact that both links are oneliners. With this markup: ``` <div id="navigation"></div> <a id="view" href="...">View this page</a> <a id="back" href="...">Back to List of Pages</a> <form></form> ``` And this simple css: ``` #view { float: right; } ``` No cl...
556,923
<p>How can I do the following in Git?</p> <p>My current branch is branch1 and I have made some local changes. However, I now realize that I actually meant to be applying these changes to branch2. Is there a way to apply/merge these changes so that they become local changes on branch2 without committing them on branch1...
[ { "answer_id": 556938, "author": "claf", "author_id": 61838, "author_profile": "https://Stackoverflow.com/users/61838", "pm_score": 2, "selected": false, "text": "<p>If it were about committed changes, you should have a look at git-rebase, but as pointed out in comment by VonC, as you're...
2009/02/17
[ "https://Stackoverflow.com/questions/556923", "https://Stackoverflow.com", "https://Stackoverflow.com/users/67378/" ]
How can I do the following in Git? My current branch is branch1 and I have made some local changes. However, I now realize that I actually meant to be applying these changes to branch2. Is there a way to apply/merge these changes so that they become local changes on branch2 without committing them on branch1?
Since your files are not yet committed in `branch1`: ``` git stash git checkout branch2 git stash pop ``` or ``` git stash git checkout branch2 git stash list # to check the various stash made in different branch git stash apply x # to select the right one ``` Above is the longer more explicit version of...
556,960
<p>I wonder how to debug the following error:</p> <pre><code>Debug Assertion failure Program: tomtoprog.exe File: dbgheap.c Line: 1044 Expression:_CrtIsValidHeapPointer(pUserData) ... </code></pre> <p>I'm quiet new to windows development with VC++ 6 ... is there a valgrind or something like that? The tomtoprog code...
[ { "answer_id": 556954, "author": "Mitch Wheat", "author_id": 16076, "author_profile": "https://Stackoverflow.com/users/16076", "pm_score": 4, "selected": true, "text": "<p>You can achieve this using <a href=\"http://msdn.microsoft.com/en-us/library/ms379564.aspx\" rel=\"nofollow noreferr...
2009/02/17
[ "https://Stackoverflow.com/questions/556960", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40260/" ]
I wonder how to debug the following error: ``` Debug Assertion failure Program: tomtoprog.exe File: dbgheap.c Line: 1044 Expression:_CrtIsValidHeapPointer(pUserData) ... ``` I'm quiet new to windows development with VC++ 6 ... is there a valgrind or something like that? The tomtoprog code is not written by me and ...
You can achieve this using [Generics](http://msdn.microsoft.com/en-us/library/ms379564.aspx) in .NET 2.0 onwards. This [post](http://blogs.msdn.com/kcwalina/archive/2005/09/23/Collections.aspx) describes the various generic collections available in .NET 2.0
556,967
<p>Today I needed to parse some data out from an xlsx file (Office open XML Spreadsheet). I could have just opened the files in openoffice and exported to csv. However I will need to reimport data from this spreadsheet later, and I wanted to eliminate the manual operation.</p> <p>I searched on the net for xlsx parser,...
[ { "answer_id": 556993, "author": "ryeguy", "author_id": 49018, "author_profile": "https://Stackoverflow.com/users/49018", "pm_score": 3, "selected": false, "text": "<p>You should post it <a href=\"http://code.activestate.com/recipes/langs/python/\" rel=\"nofollow noreferrer\">here</a>. T...
2009/02/17
[ "https://Stackoverflow.com/questions/556967", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3355/" ]
Today I needed to parse some data out from an xlsx file (Office open XML Spreadsheet). I could have just opened the files in openoffice and exported to csv. However I will need to reimport data from this spreadsheet later, and I wanted to eliminate the manual operation. I searched on the net for xlsx parser, and all I...
[GitHub](http://github.com/) would also be a great place to post this. Especially as that would allow others to quickly fork their own copies and make any improvements or modifications they need. These changes would then also be available to anyone else who wants them.
556,979
<p>I don't know what I'm doing wrong. I'm using IceFaces and I have simple managed bean:</p> <pre><code>public class TestingController { private String name; public String submit() { setName("newName"); return null; } public void setName(String name) { this.name = name; }...
[ { "answer_id": 558452, "author": "Drew", "author_id": 67521, "author_profile": "https://Stackoverflow.com/users/67521", "pm_score": 1, "selected": false, "text": "<p>Worked for me. After clicking submit, the input box became \"newName\" regardless of what was in the box previously.</p>\n...
2009/02/17
[ "https://Stackoverflow.com/questions/556979", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51598/" ]
I don't know what I'm doing wrong. I'm using IceFaces and I have simple managed bean: ``` public class TestingController { private String name; public String submit() { setName("newName"); return null; } public void setName(String name) { this.name = name; } public S...
Worked for me. After clicking submit, the input box became "newName" regardless of what was in the box previously. test.jspx ``` <?xml version="1.0" encoding="UTF-8"?> <!-- Document : test Created on : Feb 17, 2009, 2:35:12 PM Author : drew --> <jsp:root xmlns:h="http://java.sun.com/jsf/html" xm...
556,997
<p>I need to be able to create guids on the fly. Is there a way to do that in MFC? I see how to do it in .net, but we haven't gone there yet. If not, do you have pointers to some code I can use?</p>
[ { "answer_id": 557019, "author": "Edouard A.", "author_id": 41363, "author_profile": "https://Stackoverflow.com/users/41363", "pm_score": 3, "selected": false, "text": "<p>Use the function UuidCreate to generate GUIDs :</p>\n\n<pre><code>UUID generated;\n\nif (::UuidCreate(&amp;generated...
2009/02/17
[ "https://Stackoverflow.com/questions/556997", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6701/" ]
I need to be able to create guids on the fly. Is there a way to do that in MFC? I see how to do it in .net, but we haven't gone there yet. If not, do you have pointers to some code I can use?
``` GUID guid; HRESULT hr = CoCreateGuid(&guid); // Convert the GUID to a string _TUCHAR * guidStr; UuidToString(&guid, &guidStr); ``` The application is responsible for calling `RpcStringFree` to deallocate the memory allocated for the string returned in the StringUuid parameter.
557,007
<p>I would like to insert line comments in my code, programmatically. I am visiting a method declaration and I want to insert a line comment (or more) above it, using the AST of the method. Could anyone please give me a code example of how to do that? I have been searching for a long time and no success yet.</p>
[ { "answer_id": 557039, "author": "jgallant", "author_id": 62923, "author_profile": "https://Stackoverflow.com/users/62923", "pm_score": 0, "selected": false, "text": "<p>The only way I can think of, to insert code programmatically, is to open a Filestream and write to the text file at a ...
2009/02/17
[ "https://Stackoverflow.com/questions/557007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23486/" ]
I would like to insert line comments in my code, programmatically. I am visiting a method declaration and I want to insert a line comment (or more) above it, using the AST of the method. Could anyone please give me a code example of how to do that? I have been searching for a long time and no success yet.
I believe you can insert comments programatically using the Eclipse AST API. It seems that you are using that API already so it would be even better if you stick to the same API. You have a lot of code examples [here](http://www.ibm.com/developerworks/opensource/library/os-ast/) and one of them is the code for insertin...
557,011
<p>This may sound really stupid. but I've got a strange problem with the D programming language. When I try to create a new array like this:</p> <pre><code>import std.stdio; void main() { char[] variable = "value"; writefln(variable); } </code></pre> <p>The DMD compiler always gives me this error:</p> <bloc...
[ { "answer_id": 557033, "author": "ryeguy", "author_id": 49018, "author_profile": "https://Stackoverflow.com/users/49018", "pm_score": 4, "selected": true, "text": "<p>I was searching around the arrays section of the guide, this may help:</p>\n\n<p><em><a href=\"http://digitalmars.com/d/2...
2009/02/17
[ "https://Stackoverflow.com/questions/557011", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32756/" ]
This may sound really stupid. but I've got a strange problem with the D programming language. When I try to create a new array like this: ``` import std.stdio; void main() { char[] variable = "value"; writefln(variable); } ``` The DMD compiler always gives me this error: > > test.d(5): Error: cannot impli...
I was searching around the arrays section of the guide, this may help: *[A string is an array of characters. String literals are just an easy way to write character arrays. String literals are immutable (read only).](http://digitalmars.com/d/2.0/arrays.html#strings)* ``` char[] str1 = "abc"; // error,...
557,028
<p>I am using a Canvas itemRenderer for a container I use to display images. See pseudo code below.</p> <pre><code>image = new Image(); image.source = data.@thumb; this.addChild(image); this.addEventListener(MouseEvent.MOUSE_OVER, enlarge(image)); this.addEventListener(MouseEvent.MOUSE_OUT, shrink(image)); </code></p...
[ { "answer_id": 557139, "author": "Josh Tynjala", "author_id": 10768, "author_profile": "https://Stackoverflow.com/users/10768", "pm_score": 5, "selected": true, "text": "<p>You should use <a href=\"http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/display/InteractiveObject.html#event:r...
2009/02/17
[ "https://Stackoverflow.com/questions/557028", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33604/" ]
I am using a Canvas itemRenderer for a container I use to display images. See pseudo code below. ``` image = new Image(); image.source = data.@thumb; this.addChild(image); this.addEventListener(MouseEvent.MOUSE_OVER, enlarge(image)); this.addEventListener(MouseEvent.MOUSE_OUT, shrink(image)); ``` When I mouse over ...
You should use [`MouseEvent.ROLL_OVER`](http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/display/InteractiveObject.html#event:rollOver) and [`MouseEvent.ROLL_OUT`](http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/display/InteractiveObject.html#event:rollOut) events instead. From the Flash CS4 documentation: > ...
557,030
<p>I am stuck with a problem which seems stupid but I cannot find out the solution... With XLST, I need to sum a list of values calculated by a template. So I stored these values in a tree structure (a list of "Number" elements contained in a root element "Numbers"). But whatever I try to do with this self-made list, i...
[ { "answer_id": 557139, "author": "Josh Tynjala", "author_id": 10768, "author_profile": "https://Stackoverflow.com/users/10768", "pm_score": 5, "selected": true, "text": "<p>You should use <a href=\"http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/display/InteractiveObject.html#event:r...
2009/02/17
[ "https://Stackoverflow.com/questions/557030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/67395/" ]
I am stuck with a problem which seems stupid but I cannot find out the solution... With XLST, I need to sum a list of values calculated by a template. So I stored these values in a tree structure (a list of "Number" elements contained in a root element "Numbers"). But whatever I try to do with this self-made list, it w...
You should use [`MouseEvent.ROLL_OVER`](http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/display/InteractiveObject.html#event:rollOver) and [`MouseEvent.ROLL_OUT`](http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/display/InteractiveObject.html#event:rollOut) events instead. From the Flash CS4 documentation: > ...
557,052
<p>I'm developing some lower end code in my system that uses multiple child classes of the php exception class. Essentially I have the exceptions broken up to a few categories. What I'm wanting to do is two things. </p> <ol> <li>I need all exceptions that are fired in the application to be handled in a single place...
[ { "answer_id": 557109, "author": "Crescent Fresh", "author_id": 45433, "author_profile": "https://Stackoverflow.com/users/45433", "pm_score": 6, "selected": true, "text": "<ol>\n<li>Run your web requests through a <a href=\"https://stackoverflow.com/questions/20277102/proper-separation-d...
2009/02/17
[ "https://Stackoverflow.com/questions/557052", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62551/" ]
I'm developing some lower end code in my system that uses multiple child classes of the php exception class. Essentially I have the exceptions broken up to a few categories. What I'm wanting to do is two things. 1. I need all exceptions that are fired in the application to be handled in a single place. 2. I need to b...
1. Run your web requests through a [Front Controller script](https://stackoverflow.com/questions/20277102/proper-separation-difference-between-index-php-and-front-controller/20299496#20299496) 2. call [`set_exception_handler`](http://www.php.net/set_error_handler) early in execution (don't forget to account for `error_...
557,069
<p>I have some python code that receives a message every so often containing a timestamp and an edge transition, either low-to-high, or high-to-low. I'd like to graph each transition on a stripchart for a quick and dirty visualization of the digital waveform with the minimal amount of effort.</p> <p>Can you recommend ...
[ { "answer_id": 557091, "author": "ubiyubix", "author_id": 19701, "author_profile": "https://Stackoverflow.com/users/19701", "pm_score": 2, "selected": false, "text": "<p>I haven't use it myself, but perhaps <a href=\"http://linil.wordpress.com/2008/06/14/cairoplot-plotting-graphics-using...
2009/02/17
[ "https://Stackoverflow.com/questions/557069", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7161/" ]
I have some python code that receives a message every so often containing a timestamp and an edge transition, either low-to-high, or high-to-low. I'd like to graph each transition on a stripchart for a quick and dirty visualization of the digital waveform with the minimal amount of effort. Can you recommend any method...
I haven't use it myself, but perhaps [Cairo Plot](http://linil.wordpress.com/2008/06/14/cairoplot-plotting-graphics-using-python-and-cairo/) is worth taking a look at.
557,073
<p>I am trying to create a instance of a user web control from the code behind of another user web control. </p> <p>using ASP.NET;</p> <pre><code> placeholder1.Controls.Clear(); module_userWebControl_ascx slModule = (module_userWebControl_ascx)LoadControl("~/module/module_userWebControl.ascx"); ...
[ { "answer_id": 557096, "author": "Sergio", "author_id": 32037, "author_profile": "https://Stackoverflow.com/users/32037", "pm_score": 2, "selected": true, "text": "<p>I looks like the page you are placing that code does not belong to the same namespace of the usercontrol.</p>\n\n<p>try: ...
2009/02/17
[ "https://Stackoverflow.com/questions/557073", "https://Stackoverflow.com", "https://Stackoverflow.com/users/64779/" ]
I am trying to create a instance of a user web control from the code behind of another user web control. using ASP.NET; ``` placeholder1.Controls.Clear(); module_userWebControl_ascx slModule = (module_userWebControl_ascx)LoadControl("~/module/module_userWebControl.ascx"); placeholder1.Contro...
I looks like the page you are placing that code does not belong to the same namespace of the usercontrol. try: ``` (usercontrolNamespace.module_userWebControl_ascx)LoadControl("~/module/module_userWebControl.ascx"); ```
557,081
<p>I have a static library that may get linked into either a <code>.exe</code> or a <code>.dll</code>. At runtime I want one of my library functions to get the <code>HMODULE</code> for whatever thing the static library code has been linked into.</p> <p>I currently use the following trick (inspired from <a href="http:/...
[ { "answer_id": 557529, "author": "Rob K", "author_id": 53089, "author_profile": "https://Stackoverflow.com/users/53089", "pm_score": 2, "selected": false, "text": "<p>I'd look at <code>GetModuleHandleEx()</code> using the flag <code>GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS</code>. It looks...
2009/02/17
[ "https://Stackoverflow.com/questions/557081", "https://Stackoverflow.com", "https://Stackoverflow.com/users/755/" ]
I have a static library that may get linked into either a `.exe` or a `.dll`. At runtime I want one of my library functions to get the `HMODULE` for whatever thing the static library code has been linked into. I currently use the following trick (inspired from [this forum](http://www.ureader.com/message/1095160.aspx))...
``` HMODULE GetCurrentModule() { // NB: XP+ solution! HMODULE hModule = NULL; GetModuleHandleEx( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCTSTR)GetCurrentModule, &hModule); return hModule; } ```
557,112
<p>In our API, we use byte[] to send over data across the network. Everything worked fine, until the day our "foreign" clients decided to pass/receive Unicode characters.</p> <p>As far as I know, Unicode characters occupy 2 bytes, however, we only allocate 1 byte in the byte array for them. </p> <p>Here is how we ...
[ { "answer_id": 557133, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 4, "selected": true, "text": "<p>You should use <a href=\"http://msdn.microsoft.com/en-us/library/system.text.encoding.getstring.aspx\" rel=\"nofollow ...
2009/02/17
[ "https://Stackoverflow.com/questions/557112", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
In our API, we use byte[] to send over data across the network. Everything worked fine, until the day our "foreign" clients decided to pass/receive Unicode characters. As far as I know, Unicode characters occupy 2 bytes, however, we only allocate 1 byte in the byte array for them. Here is how we read the character f...
You should use [`Encoding.GetString`](http://msdn.microsoft.com/en-us/library/system.text.encoding.getstring.aspx), using the most appropriate encoding. I don't quite understand your situation fully, but the `Encoding` class is almost certain to be the way to handle it. Who is in control of the data here? Your code, ...
557,117
<p>I have three models that can all have a Review and each review must belong to a User. I am using polymorphic associations :as => :reviewable but I am not sure where I should put the logic for creating a review for each model. I would assume that the CRUD for each review should be handled by the reviews_controller (o...
[ { "answer_id": 563489, "author": "Sarah Mei", "author_id": 66801, "author_profile": "https://Stackoverflow.com/users/66801", "pm_score": 0, "selected": false, "text": "<p>Since it's an update to the model, it's easier to go through the model's controller. Plus then there is no mistaking ...
2009/02/17
[ "https://Stackoverflow.com/questions/557117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47579/" ]
I have three models that can all have a Review and each review must belong to a User. I am using polymorphic associations :as => :reviewable but I am not sure where I should put the logic for creating a review for each model. I would assume that the CRUD for each review should be handled by the reviews\_controller (or ...
The problem with handling the object within the reviewable objects' controllers is that you'll find you wind up repeating a lot of the same code in each of the controllers. Moreover, where do you put the code? Either you wind up with some seriously heavy action methods (by piggy backing on your 7 existing actions) or y...