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
348,964
<p>Can someone share a simple example of using the <code>foreach</code> keyword with custom objects?</p>
[ { "answer_id": 348977, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 7, "selected": true, "text": "<p>Given the tags, I assume you mean in .NET - and I'll choose to talk about C#, as that's what I know about.</p>\n\n<p>T...
2008/12/08
[ "https://Stackoverflow.com/questions/348964", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42070/" ]
Can someone share a simple example of using the `foreach` keyword with custom objects?
Given the tags, I assume you mean in .NET - and I'll choose to talk about C#, as that's what I know about. The `foreach` statement (usually) uses `IEnumerable` and `IEnumerator` or their generic cousins. A statement of the form: ``` foreach (Foo element in source) { // Body } ``` where `source` implements `IEnu...
348,978
<p>One CSS rule I have learned is that you should use the relative "em" font-size unit instead of the absolute "pt". The general idea is to set the font-size in your body tag to e.g. "94%" and then set all other elements with an "em" size like this. The reasoning is:</p> <ul> <li>you can then change the relative size...
[ { "answer_id": 348982, "author": "Dirk Vollmar", "author_id": 40347, "author_profile": "https://Stackoverflow.com/users/40347", "pm_score": 1, "selected": false, "text": "<p>See also <a href=\"http://www.killersites.com/mvnforum/mvnforum/viewthread?thread=4084\" rel=\"nofollow noreferrer...
2008/12/08
[ "https://Stackoverflow.com/questions/348978", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4639/" ]
One CSS rule I have learned is that you should use the relative "em" font-size unit instead of the absolute "pt". The general idea is to set the font-size in your body tag to e.g. "94%" and then set all other elements with an "em" size like this. The reasoning is: * you can then change the relative size of all the fon...
Depending on the country where you live, you might actually end up breaking the law using pt instead of em, depending on how hard your legislature want to enforce rules. Here in the UK, there is a disability discrimination act, which has been used to target companies where their websites have been rendered in a fixed f...
348,985
<p>I user sun jdk 1.5 ThreadPoolExecutor( 24, 24,60,TimeUnit.SECONDS, new LinkedBlockingQueue()). soemtime I use jdb tool to find the status of all threads in thread pool are " waiting in a monitor", the code is : </p> <pre><code> String key = getKey(dt.getPrefix(), id); synchronized (key.intern()) { ----...
[ { "answer_id": 348994, "author": "Bombe", "author_id": 43582, "author_profile": "https://Stackoverflow.com/users/43582", "pm_score": 2, "selected": false, "text": "<p>Quite. The problem is that key.intern() isn’t really that unique because it’s returning a string from a pool. String.inte...
2008/12/08
[ "https://Stackoverflow.com/questions/348985", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44230/" ]
I user sun jdk 1.5 ThreadPoolExecutor( 24, 24,60,TimeUnit.SECONDS, new LinkedBlockingQueue()). soemtime I use jdb tool to find the status of all threads in thread pool are " waiting in a monitor", the code is : ``` String key = getKey(dt.getPrefix(), id); synchronized (key.intern()) { -----> ``` Is the...
I posted a related question to this once that you might want to take a look at: [Problem with synchronizing on String objects?](https://stackoverflow.com/questions/133988/problem-with-synchronizing-on-string-objects) What I learned was: using intern'ed Strings for synchronization is a **bad** practice.
349,018
<p>Is there any way I can use AS400 style library/file style naming over JDBC with jt400? I want to be able to run queries like:</p> <pre><code>SELECT * FROM MYLIBRARY/MYFILE </code></pre> <p>Thanks</p>
[ { "answer_id": 349272, "author": "LenW", "author_id": 41292, "author_profile": "https://Stackoverflow.com/users/41292", "pm_score": -1, "selected": false, "text": "<p>There is a way to do this on the 400 with STRSQL but not as far as I know with JDBC </p>\n" }, { "answer_id": 350...
2008/12/08
[ "https://Stackoverflow.com/questions/349018", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29574/" ]
Is there any way I can use AS400 style library/file style naming over JDBC with jt400? I want to be able to run queries like: ``` SELECT * FROM MYLIBRARY/MYFILE ``` Thanks
Set the jdbc naming property to "system". <http://javadoc.midrange.com/jtopen_6_3/com/ibm/as400/access/doc-files/JDBCProperties.html>
349,023
<p>The code below is the code i am using. It works fine in thunderbird but not in mac mail client (and i assume anything made by microsoft. I currently do not have access to this to test it in). Much as i am aware of the idiosyncrasies of the various mail clients, I am flummoxed by this! It's fairly self explanatory bu...
[ { "answer_id": 349039, "author": "Paul Dixon", "author_id": 6521, "author_profile": "https://Stackoverflow.com/users/6521", "pm_score": 0, "selected": false, "text": "<p>You're not using output buffering correctly - see man page for <a href=\"http://php.net/ob_end_clean\" rel=\"nofollow ...
2008/12/08
[ "https://Stackoverflow.com/questions/349023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31677/" ]
The code below is the code i am using. It works fine in thunderbird but not in mac mail client (and i assume anything made by microsoft. I currently do not have access to this to test it in). Much as i am aware of the idiosyncrasies of the various mail clients, I am flummoxed by this! It's fairly self explanatory but i...
Rather than try and roll your own mailer, try e.g. [PHPMailer](http://phpmailer.codeworxtech.com/). It has very good support for multipart/alternative. It's much easier to integrate this than to roll your own solution. I've been there - after working endlessly around strange MIME problems, I've dropped my hand-made mai...
349,025
<p>Is a string literal in C++ created in static memory and destroyed only when the program exits?</p>
[ { "answer_id": 349030, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 7, "selected": true, "text": "<p>Where it's created is an implementation decision by the compiler writer, really. Most likely, string literals will be ...
2008/12/08
[ "https://Stackoverflow.com/questions/349025", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22076/" ]
Is a string literal in C++ created in static memory and destroyed only when the program exits?
Where it's created is an implementation decision by the compiler writer, really. Most likely, string literals will be stored in read-only segments of memory since they never change. In the old compiler days, you used to have static data like these literals, and global but changeable data. These were stored in the TEXT...
349,047
<p>Connection Code:</p> <pre><code>set conx = Server.CreateObject("ADODB.connection") conx.Open Application("connectionString") set cmdx = server.CreateObject("ADODB.command") cmdx.ActiveConnection = conx cmdx.CommandText = "dbo.sproc" cmdx.CommandType = &amp;H0004 set rsx = Server.CreateObject("ADODB.Recordset") rs...
[ { "answer_id": 349160, "author": "xoxo", "author_id": 36243, "author_profile": "https://Stackoverflow.com/users/36243", "pm_score": -1, "selected": false, "text": "<p>Sounds like a permissions problem in the database!</p>\n" }, { "answer_id": 352419, "author": "AnthonyWJones"...
2008/12/08
[ "https://Stackoverflow.com/questions/349047", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39643/" ]
Connection Code: ``` set conx = Server.CreateObject("ADODB.connection") conx.Open Application("connectionString") set cmdx = server.CreateObject("ADODB.command") cmdx.ActiveConnection = conx cmdx.CommandText = "dbo.sproc" cmdx.CommandType = &H0004 set rsx = Server.CreateObject("ADODB.Recordset") rsx.open cmdx resar...
Just a punt here, but the way OLEDB drivers handle Row count informationals differs from ODBC. I very much suspect that if you add SET NOCOUNT ON at the top of the Stored Procedure the problem will go away.
349,050
<p>I'm in the midst of writing a 3d engine and I've come across the LookAt algorithm described in the DirectX documentation:</p> <pre><code>zaxis = normal(At - Eye) xaxis = normal(cross(Up, zaxis)) yaxis = cross(zaxis, xaxis) xaxis.x yaxis.x zaxis.x 0 xaxis.y yaxis.y ...
[ { "answer_id": 349065, "author": "Eugene Yokota", "author_id": 3827, "author_profile": "https://Stackoverflow.com/users/3827", "pm_score": 2, "selected": false, "text": "<p>Dot product simply projects a point to an axis to get the x-, y-, or z-component of the eye. You are moving the cam...
2008/12/08
[ "https://Stackoverflow.com/questions/349050", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3719/" ]
I'm in the midst of writing a 3d engine and I've come across the LookAt algorithm described in the DirectX documentation: ``` zaxis = normal(At - Eye) xaxis = normal(cross(Up, zaxis)) yaxis = cross(zaxis, xaxis) xaxis.x yaxis.x zaxis.x 0 xaxis.y yaxis.y zaxis.y ...
I build a look-at matrix by creating a 3x3 rotation matrix as you have done here and then expanding it to a 4x4 with zeros and the single 1 in the bottom right corner. Then I build a 4x4 translation matrix using the negative eye point coordinates (no dot products), and multiply the two matrices together. My guess is th...
349,055
<p>T have used checkbox column in gridview. On click of a linkbutton, it should be checked that checkboxes in gridview are checked or not. If none check box is checked then it should display alert("Check at leat one check box"). </p>
[ { "answer_id": 349134, "author": "xoxo", "author_id": 36243, "author_profile": "https://Stackoverflow.com/users/36243", "pm_score": 0, "selected": false, "text": "<p>I havnt used the checkbox in grid view but would you not do a for loop around the columns in gridview and check the state?...
2008/12/08
[ "https://Stackoverflow.com/questions/349055", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43886/" ]
T have used checkbox column in gridview. On click of a linkbutton, it should be checked that checkboxes in gridview are checked or not. If none check box is checked then it should display alert("Check at leat one check box").
I found the answer. and its working... function checkBoxselectedornot() { ``` var frm=document.forms['aspnetForm']; var flag=false; for(var i=0;i<document.forms[0].length;i++) { if(document.forms[0].elements[i].id.indexOf('chkDownloadSelectedEvent')!=-1) { ...
349,060
<p>Now I know about the "normal" CSS list styles (roman, latin, etc) and certainly in years past they were somewhat inflexible in not allowing things like:</p> <p>(a)</p> <p>or </p> <p>a)</p> <p>only</p> <p>a.</p> <p>Now I believe that you can get an effect like the above with the :before and :after pseudo-elemen...
[ { "answer_id": 349089, "author": "Eugene Yokota", "author_id": 3827, "author_profile": "https://Stackoverflow.com/users/3827", "pm_score": 4, "selected": true, "text": "<p>See <a href=\"http://www.w3.org/TR/CSS2/generate.html\" rel=\"noreferrer\">Generated content, automatic numbering, a...
2008/12/08
[ "https://Stackoverflow.com/questions/349060", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18393/" ]
Now I know about the "normal" CSS list styles (roman, latin, etc) and certainly in years past they were somewhat inflexible in not allowing things like: (a) or a) only a. Now I believe that you can get an effect like the above with the :before and :after pseudo-elements. Is that correct? And whats the browser co...
See [Generated content, automatic numbering, and lists](http://www.w3.org/TR/CSS2/generate.html). > > This example shows a way to number > chapters and sections with "Chapter > 1", "1.1", "1.2", etc. > > > ``` H1:before { content: "Chapter " counter(chapter) ". "; counter-increment: chapter; /* Add 1 t...
349,062
<p>Is it possible to overload the null-coalescing operator for a class in C#? </p> <p>Say for example I want to return a default value if an instance is null and return the instance if it's not. The code would look like something like this:</p> <pre><code> return instance ?? new MyClass("Default"); </code></pre>...
[ { "answer_id": 349072, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 3, "selected": false, "text": "<p>Simple answer: No</p>\n\n<p>C# design principles do not allow operator overloading that change semantics of the language. T...
2008/12/08
[ "https://Stackoverflow.com/questions/349062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/936/" ]
Is it possible to overload the null-coalescing operator for a class in C#? Say for example I want to return a default value if an instance is null and return the instance if it's not. The code would look like something like this: ``` return instance ?? new MyClass("Default"); ``` But what if I would like to u...
Good question! It's not listed one way or another in the [list of overloadable and non-overloadable operators](http://msdn.microsoft.com/en-us/library/8edha89s.aspx) and nothing's mentioned on [the operator's page](http://msdn.microsoft.com/en-us/library/ms173224.aspx). So I tried the following: ``` public class Test...
349,067
<p>There's this Excel file I want users to be able to download from my server. There must be an easy way to initiate the download of the file after a click on the "Download" button... but I have no clue how to make that happen.</p> <p>I have this so far: (VBscript and ASP)</p> <pre><code>&lt;head&gt; &lt;script type...
[ { "answer_id": 349077, "author": "Kablam", "author_id": 42389, "author_profile": "https://Stackoverflow.com/users/42389", "pm_score": 5, "selected": true, "text": "<p>you're not going to believe this.\nFound it...</p>\n\n<pre><code>function exportmasterfile()\n{ var url='../documenten/...
2008/12/08
[ "https://Stackoverflow.com/questions/349067", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42389/" ]
There's this Excel file I want users to be able to download from my server. There must be an easy way to initiate the download of the file after a click on the "Download" button... but I have no clue how to make that happen. I have this so far: (VBscript and ASP) ``` <head> <script type="text/javascript" src="overzic...
you're not going to believe this. Found it... ``` function exportmasterfile() { var url='../documenten/Master-File.xls'; window.open(url,'Download'); } ``` Sorry guys!
349,075
<p>Hey. I have a problem with the highlighter in ComboBox. Recently I had to gray out certain items in a ComboBox and I did that by manually (programitically) drawing strings in the <strong>ComboBox</strong>. In a .NET combobox under the <strong>DrawMode.NORMAL</strong>, the lighlighter will automatically come when you...
[ { "answer_id": 350006, "author": "Eric Rosenberger", "author_id": 41624, "author_profile": "https://Stackoverflow.com/users/41624", "pm_score": 3, "selected": false, "text": "<p>By default the text in a ComboBox is drawn in one of two colors:</p>\n\n<pre><code>SystemColors.WindowText\n</...
2008/12/08
[ "https://Stackoverflow.com/questions/349075", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Hey. I have a problem with the highlighter in ComboBox. Recently I had to gray out certain items in a ComboBox and I did that by manually (programitically) drawing strings in the **ComboBox**. In a .NET combobox under the **DrawMode.NORMAL**, the lighlighter will automatically come when you click the arrow and the back...
By default the text in a ComboBox is drawn in one of two colors: ``` SystemColors.WindowText ``` for non-highlighted items, or ``` SystemColors.HighlightText ``` for highlighted items. These colors are not fixed, but can be configured by the user (e.g., through Control Panel). In a typical Windows color scheme, ...
349,087
<p>I have used checkbox column in gridview. I want to check status of that checkboxes. On click of a button it should be checked that if any checkbox is checked or not. If none checkbox is checked then it should display alert message that check checkbox first.</p>
[ { "answer_id": 349100, "author": "I.devries", "author_id": 6388, "author_profile": "https://Stackoverflow.com/users/6388", "pm_score": 2, "selected": false, "text": "<pre><code>if(document.getElementById('checkBoxId').checked) {\n //checked\n} else {\n //not checked\n}\n</code></pr...
2008/12/08
[ "https://Stackoverflow.com/questions/349087", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43886/" ]
I have used checkbox column in gridview. I want to check status of that checkboxes. On click of a button it should be checked that if any checkbox is checked or not. If none checkbox is checked then it should display alert message that check checkbox first.
Hey, I found answer. It is as follows: ``` function checkBoxselectedornot() { var frm=document.forms['aspnetForm']; var flag=false; for(var i=0;i<document.forms[0].length;i++) { if(document.forms[0].elements[i].id.indexOf('chkDownloadSelectedEvent')!=-1) { ...
349,092
<p>I need to have one column as the primary key and another to auto increment an order number field. Is this possible?</p> <p>EDIT: I think I'll just use a composite number as the order number. Thanks anyways.</p>
[ { "answer_id": 349110, "author": "Mladen Prajdic", "author_id": 31345, "author_profile": "https://Stackoverflow.com/users/31345", "pm_score": 0, "selected": false, "text": "<p>in sql server it's not possible to have more than one column as identity.</p>\n" }, { "answer_id": 34911...
2008/12/08
[ "https://Stackoverflow.com/questions/349092", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23230/" ]
I need to have one column as the primary key and another to auto increment an order number field. Is this possible? EDIT: I think I'll just use a composite number as the order number. Thanks anyways.
``` CREATE TABLE [dbo].[Foo]( [FooId] [int] IDENTITY(1,1) NOT NULL, [BarId] [int] IDENTITY(1,1) NOT NULL ) ``` returns ``` Msg 2744, Level 16, State 2, Line 1 Multiple identity columns specified for table 'Foo'. Only one identity column per table is allowed. ``` So, no, you can't have two identity columns....
349,108
<p>What is the correct way of retrieving maximum values of all columns in a table with a single query? Thanks.</p> <p>Clarification: the same query should work on any table, i.e. the column names are not to be hard-coded into it.</p>
[ { "answer_id": 349115, "author": "gnud", "author_id": 27204, "author_profile": "https://Stackoverflow.com/users/27204", "pm_score": 3, "selected": false, "text": "<pre><code>SELECT max(col1) as max_col1, max(col2) as max_col2 FROM `table`;\n</code></pre>\n" }, { "answer_id": 3491...
2008/12/08
[ "https://Stackoverflow.com/questions/349108", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27122/" ]
What is the correct way of retrieving maximum values of all columns in a table with a single query? Thanks. Clarification: the same query should work on any table, i.e. the column names are not to be hard-coded into it.
You're going to have to do it in two steps - one to retrieve the structure of the table, followed by a second step to retrieve the max values for each In php: ``` $table = "aTableName"; $columnsResult = mysql_query("SHOW COLUMNS FROM $table"); $maxValsSelect = ""; while ($aColumn = mysql_fetch_assoc($columnsResult))...
349,119
<p>I have implemented tracing based on System.Diagnostics. </p> <p>I am also using a System.Diagnostics.TextWriterTraceListener, and hooked the whole trace up to a MOSS 2007 Web Application. </p> <p>The trace for some reason is trying to (a) create the log file, and/or (b) write to the log file using <strong>the user...
[ { "answer_id": 349317, "author": "Michael L", "author_id": 41291, "author_profile": "https://Stackoverflow.com/users/41291", "pm_score": 0, "selected": false, "text": "<p>Please don't tell me this is necessary - <a href=\"http://www.15seconds.com/Issue/040511.htm?voteresult=5\" rel=\"nof...
2008/12/08
[ "https://Stackoverflow.com/questions/349119", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41291/" ]
I have implemented tracing based on System.Diagnostics. I am also using a System.Diagnostics.TextWriterTraceListener, and hooked the whole trace up to a MOSS 2007 Web Application. The trace for some reason is trying to (a) create the log file, and/or (b) write to the log file using **the user that is currently brow...
Obviously MOSS is configured to use windows authentication (kerberos) and imersonation. If you don't need to impersonate the current user logged into moss, turn off impersonation (its in web.config). You'll find that the log files will be created and written by the user under which your moss installation's application ...
349,175
<p>I need to convert a list (or a dict) into a comma-separated list for passing to another language.</p> <p>Is there a nicer way of doing this than:</p> <pre><code> result = '' args = ['a', 'b', 'c', 'd'] i = 0 for arg in args: if i != 0: result += arg else: result += arg + ', ' i += 1 ...
[ { "answer_id": 349182, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 4, "selected": false, "text": "<p><code>', '.join(args)</code> will do the trick.</p>\n" }, { "answer_id": 349197, "author": "James Hopkin", ...
2008/12/08
[ "https://Stackoverflow.com/questions/349175", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18909/" ]
I need to convert a list (or a dict) into a comma-separated list for passing to another language. Is there a nicer way of doing this than: ``` result = '' args = ['a', 'b', 'c', 'd'] i = 0 for arg in args: if i != 0: result += arg else: result += arg + ', ' i += 1 result = 'function (...
``` 'function(%s)' % ', '.join(args) ``` produces ``` 'function(a, b, c, d)' ```
349,192
<p>In a multi-threaded program running on a multi-cpu machine do I need to access shared state ( _data in the example code below) using volatile read/writes to ensure correctness.</p> <p>In other words, can heap objects be cached on the cpu?</p> <p>Using the example below and assuming multi-threads will access the Ge...
[ { "answer_id": 349239, "author": "Eugene Yokota", "author_id": 3827, "author_profile": "https://Stackoverflow.com/users/3827", "pm_score": 2, "selected": false, "text": "<p>I don't think volatile can be a replacement of locking if you start calling methods on it. You are guaranteeing tha...
2008/12/08
[ "https://Stackoverflow.com/questions/349192", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
In a multi-threaded program running on a multi-cpu machine do I need to access shared state ( \_data in the example code below) using volatile read/writes to ensure correctness. In other words, can heap objects be cached on the cpu? Using the example below and assuming multi-threads will access the GetValue and Add m...
The [MSDN docs](http://msdn.microsoft.com/en-us/library/xfhwa508.aspx) for `Dictionary<TKey, TValue>` say that it's safe for multiple *readers* but they don't give the "one writer, multiple readers" guarantee that some other classes do. In short, I wouldn't do this. You say you're avoiding locking because you need the...
349,204
<p>I've written a simple control which basically displays a few words with an image next to it.</p> <p>I want the containing items to strech when the parent form is resized and as you can see from my commented out code, I don't want to use a loop as it flickers.</p> <p>Any idea on how to get the items to grow and shr...
[ { "answer_id": 349219, "author": "xoxo", "author_id": 36243, "author_profile": "https://Stackoverflow.com/users/36243", "pm_score": 0, "selected": false, "text": "<p>Anchor right and bottom on the form and maybe dock them.</p>\n" }, { "answer_id": 349244, "author": "Treb", ...
2008/12/08
[ "https://Stackoverflow.com/questions/349204", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17211/" ]
I've written a simple control which basically displays a few words with an image next to it. I want the containing items to strech when the parent form is resized and as you can see from my commented out code, I don't want to use a loop as it flickers. Any idea on how to get the items to grow and shrink with the form...
Avoid triggering a redraw every time you resize a child control by embedding your `foreach` in `SuspendLayout()` and `ResumeLayout()`: ``` this.SuspendLayout(); foreach (FlowLayoutPanel item in _listItems) { item.Width = this.Width - 10; } this.ResumeLayout(); ```
349,206
<p>I'm trying to find the actual class of a django-model object, when using model-inheritance.</p> <p>Some code to describe the problem:</p> <pre><code>class Base(models.model): def basemethod(self): ... class Child_1(Base): pass class Child_2(Base): pass </code></pre> <p>If I create various ob...
[ { "answer_id": 349235, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": -1, "selected": false, "text": "<p>It feels brittle because it is. (This is a reprint of an answer in a different context. <a href=\"https://stackoverfl...
2008/12/08
[ "https://Stackoverflow.com/questions/349206", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6093/" ]
I'm trying to find the actual class of a django-model object, when using model-inheritance. Some code to describe the problem: ``` class Base(models.model): def basemethod(self): ... class Child_1(Base): pass class Child_2(Base): pass ``` If I create various objects of the two Child classes an...
Django implements model inheritance with a OneToOneField between the parent model's table and the child model's table. When you do `Base.object.all()`, Django is querying just the Base table, and so has no way of knowing what the child table is. Therefore, unfortunately, it's not possible to go directly to the child mo...
349,238
<p>I had a realtivley simple ajax application, which I have broken up to be more modular. The code is at the link below, and what I have mainly done is add the GetRecordSet function and allowed fetchcompelte to take a variable for which layer to put data in. It should work fine in thery. When I put alert()s in, the cod...
[ { "answer_id": 349235, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": -1, "selected": false, "text": "<p>It feels brittle because it is. (This is a reprint of an answer in a different context. <a href=\"https://stackoverfl...
2008/12/08
[ "https://Stackoverflow.com/questions/349238", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1246613/" ]
I had a realtivley simple ajax application, which I have broken up to be more modular. The code is at the link below, and what I have mainly done is add the GetRecordSet function and allowed fetchcompelte to take a variable for which layer to put data in. It should work fine in thery. When I put alert()s in, the code s...
Django implements model inheritance with a OneToOneField between the parent model's table and the child model's table. When you do `Base.object.all()`, Django is querying just the Base table, and so has no way of knowing what the child table is. Therefore, unfortunately, it's not possible to go directly to the child mo...
349,257
<p>Is there a way to detect the true border, padding and margin of elements from Javascript code? If you look at the following code:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;style&gt; &lt;!-- .some_class { padding-left: 2px; border: 2px solid green; } ...
[ { "answer_id": 349395, "author": "I.devries", "author_id": 6388, "author_profile": "https://Stackoverflow.com/users/6388", "pm_score": 4, "selected": true, "text": "<p>It's possible, but of course, every browser has its own implementation. Luckily, PPK has done all the hard work for us:<...
2008/12/08
[ "https://Stackoverflow.com/questions/349257", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11384/" ]
Is there a way to detect the true border, padding and margin of elements from Javascript code? If you look at the following code: ``` <html> <head> <style> <!-- .some_class { padding-left: 2px; border: 2px solid green; } --> </style> ...
It's possible, but of course, every browser has its own implementation. Luckily, PPK has done all the hard work for us: <http://www.quirksmode.org/dom/getstyles.html>
349,260
<p>I used a query a few weeks ago in MySQL that described a table and suggested possible improvements to its structure. For example, if I have an int field but only the numbers 1-3 in that field, it will suggest set(1,2,3) as the type.</p> <p>I think I was using phpMyAdmin but I've been through all the functions I can...
[ { "answer_id": 349273, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 6, "selected": true, "text": "<p>This is what phpMyAdmin gives me:</p>\n\n<pre><code>SELECT *\nFROM `table_name`\nPROCEDURE ANALYSE ( ) \n</code></pre>\n" ...
2008/12/08
[ "https://Stackoverflow.com/questions/349260", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37947/" ]
I used a query a few weeks ago in MySQL that described a table and suggested possible improvements to its structure. For example, if I have an int field but only the numbers 1-3 in that field, it will suggest set(1,2,3) as the type. I think I was using phpMyAdmin but I've been through all the functions I can find - An...
This is what phpMyAdmin gives me: ``` SELECT * FROM `table_name` PROCEDURE ANALYSE ( ) ```
349,286
<p>I am using ASP.NET membership for the authentication of my web app. This worked great for me. I now have to implement password expiration.</p> <p>If the password has expired the user should be redirected to <code>ChangePassword</code> screen and should not be allowed access to any other part of the application with...
[ { "answer_id": 349687, "author": "csgero", "author_id": 21764, "author_profile": "https://Stackoverflow.com/users/21764", "pm_score": 4, "selected": false, "text": "<p>You could add an event handler for the HttpApplication.PostAuthenticateRequest event in global.asax and handle the redir...
2008/12/08
[ "https://Stackoverflow.com/questions/349286", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44272/" ]
I am using ASP.NET membership for the authentication of my web app. This worked great for me. I now have to implement password expiration. If the password has expired the user should be redirected to `ChangePassword` screen and should not be allowed access to any other part of the application without changing the pass...
Further to [csgero's answer](https://stackoverflow.com/questions/349286/asp-net-membership-password-expiration/349687#349687), I found that you don't need to explicitly add an event handler for this event in ASP.Net 2.0 (3.5). You can simply create the following method in `global.asax` and it gets wired up for you: `...
349,291
<p>How do I convert a datetime field in Grails to just date, with out capturing the time? I need to do this for comparison with system date. </p> <pre><code>class Trip { String name String city Date startDate Date endDate String purpose String notes static constraints = { name(ma...
[ { "answer_id": 349421, "author": "Samiksha", "author_id": 29515, "author_profile": "https://Stackoverflow.com/users/29515", "pm_score": 1, "selected": false, "text": "<p>Try using 'java.sql.Date' not 'java.util.Date' as a type of your Date property along with</p>\n\n<p><strong>formatDate...
2008/12/08
[ "https://Stackoverflow.com/questions/349291", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11193/" ]
How do I convert a datetime field in Grails to just date, with out capturing the time? I need to do this for comparison with system date. ``` class Trip { String name String city Date startDate Date endDate String purpose String notes static constraints = { name(maxLength: 50, bl...
There's [unfortunately] not an "out-of-the box" method for performing this operation in `Grails|Groovy|Java`. Somebody **always** throws in [Joda-Time](http://joda-time.sourceforge.net/) any time a `java.util.Date` or `java.util.Calendar` question is raised, but including yet another library is not always an option. ...
349,322
<p>I've been handing a design for a webpage which I'm trying to implement correctly. This design contains navigation elements which are partially or entirely duplicated all over the page - in particular, links to the main 3 categories for navigation are present on the page no less than 4 times.</p> <p>I'm no web desi...
[ { "answer_id": 349335, "author": "Germstorm", "author_id": 18631, "author_profile": "https://Stackoverflow.com/users/18631", "pm_score": 1, "selected": false, "text": "<p>IMHO it is not possible.\nMy solution would be adding a small PHP or other engine that automatically renders the menu...
2008/12/08
[ "https://Stackoverflow.com/questions/349322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12744/" ]
I've been handing a design for a webpage which I'm trying to implement correctly. This design contains navigation elements which are partially or entirely duplicated all over the page - in particular, links to the main 3 categories for navigation are present on the page no less than 4 times. I'm no web design expert, ...
Sort of Possible, But Still Not Sure You Would Want To ------------------------------------------------------ **And poses some serious challenges which varies depending on the context.** One problem is that your stated goal is to reduce html clutter and redundancy. However, to have a link, you still need to have an a...
349,326
<p>I am currently working on converting an existing web application to support an additional language (namely Welsh). My proposed approach is to extract all displayed text into property files and then access the text using JSTL fmt tags.</p> <p>My question is: how should these property files be structured? I know they...
[ { "answer_id": 349337, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": true, "text": "<blockquote>\n <p>Is this approach in line with industry standards? This is the first multilingual application for my current ...
2008/12/08
[ "https://Stackoverflow.com/questions/349326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25464/" ]
I am currently working on converting an existing web application to support an additional language (namely Welsh). My proposed approach is to extract all displayed text into property files and then access the text using JSTL fmt tags. My question is: how should these property files be structured? I know they need to b...
> > Is this approach in line with industry standards? This is the first multilingual application for my current company, so it is likely to be used as a blueprint for all others. > > > Yes, I think it is. I believe Maven creates the following directory structure: ``` src +- main | |- java | |- reso...
349,348
<p>I have the following JavaScript code: <a href="http://www.nomorepasting.com/getpaste.php?pasteid=22561" rel="nofollow noreferrer">Link</a></p> <p>In which the function makewindows does not seem to be working.</p> <p>It does actual create a window, however the html either contains what is quotes, or if I change it ...
[ { "answer_id": 349353, "author": "Pawka", "author_id": 33599, "author_profile": "https://Stackoverflow.com/users/33599", "pm_score": 0, "selected": false, "text": "<p>$row2[\"ARTICLE_DESC\"] is PHP variable.</p>\n" }, { "answer_id": 349363, "author": "Irmantas", "author_i...
2008/12/08
[ "https://Stackoverflow.com/questions/349348", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1246613/" ]
I have the following JavaScript code: [Link](http://www.nomorepasting.com/getpaste.php?pasteid=22561) In which the function makewindows does not seem to be working. It does actual create a window, however the html either contains what is quotes, or if I change it to ``` child1.document.write(json_encode($row2["ARTIC...
> > $row2["ARTICLE\_DESC"] is PHP variable. > > > It is indeed a php variable, but **it is not being rendered as php because it is not enclosed in `<?php ?>` tags** So, the correct way to do it is: ``` child1.document.write(<?php echo json_encode($row2["ARTICLE_DESC"]); ?>); ``` That way, the php, being a ser...
349,369
<p>I want to send some strings in a list in a POST call. eg:</p> <pre><code> www.example.com/?post_data = A list of strings </code></pre> <p>The python code receives the data as a single string (Instead of a list of strings). How do I post it as a list of strings?</p>
[ { "answer_id": 349384, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 4, "selected": true, "text": "<p>There's no such thing as a \"list of strings\" in a URL (or in practically anything in HTTP - if you specify multiple ...
2008/12/08
[ "https://Stackoverflow.com/questions/349369", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2220518/" ]
I want to send some strings in a list in a POST call. eg: ``` www.example.com/?post_data = A list of strings ``` The python code receives the data as a single string (Instead of a list of strings). How do I post it as a list of strings?
There's no such thing as a "list of strings" in a URL (or in practically anything in HTTP - if you specify multiple values for the same header, they come out as a single delimited value in most web app frameworks IME). It's just a single string. I suggest you delimit the strings in some way (e.g. comma-separated) and t...
349,375
<p>When it comes to putting the <strong>submit and reset buttons</strong> on your forms, <strong>what order do you use?</strong></p> <pre><code>[SUBMIT] [RESET] </code></pre> <p>or</p> <pre><code>[RESET] [SUBMIT] </code></pre> <p>This issue has come up countless times at work...</p> <p>So, in your opinion, which i...
[ { "answer_id": 349390, "author": "Tuminoid", "author_id": 40657, "author_profile": "https://Stackoverflow.com/users/40657", "pm_score": 0, "selected": false, "text": "<p>It depends which platform background the user has, since dialogs and message boxes typically present buttons in a layo...
2008/12/08
[ "https://Stackoverflow.com/questions/349375", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44084/" ]
When it comes to putting the **submit and reset buttons** on your forms, **what order do you use?** ``` [SUBMIT] [RESET] ``` or ``` [RESET] [SUBMIT] ``` This issue has come up countless times at work... So, in your opinion, which is the most usable for online users? I personally favor the latter, but some peopl...
In addition to the suggestions given already, I would like to add that the submit button should be an actual button where as reset or cancel just a link making it different from the submit button hence highlighting the fact that they are functionally different and keeping it simple. Last thing you want is to make your ...
349,410
<p>I have a registry value which is stored as a binary value (REG_BINARY) holding information about a filepath. The value is read out into an byte array. But how can I transform it into a readable string?</p> <p>I have read about system.text.encoding.ASCII.GetString(value) but this does not work. As far as I got to kn...
[ { "answer_id": 349428, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": true, "text": "<p>Well, it's not <em>arbitrary</em> binary data - it's text data in <em>some</em> kind of encoding. You need to find out...
2008/12/08
[ "https://Stackoverflow.com/questions/349410", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25428/" ]
I have a registry value which is stored as a binary value (REG\_BINARY) holding information about a filepath. The value is read out into an byte array. But how can I transform it into a readable string? I have read about system.text.encoding.ASCII.GetString(value) but this does not work. As far as I got to know the re...
Well, it's not *arbitrary* binary data - it's text data in *some* kind of encoding. You need to find out what the encoding is. I wouldn't be surprised if `Encoding.Unicode.GetString(value)` worked - but if that doesn't, please post a sample (in hex) and I'll see what I can do. What does the documentation of whatever's...
349,442
<p>I have a class with two methods defined in it.</p> <pre><code>public class Routines { public static method1() { /* set of statements */ } public static method2() { /* another set of statements.*/ } } </code></pre> <p>Now I need to call method1() from method2()</p> <p>Which one th...
[ { "answer_id": 349484, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 1, "selected": false, "text": "<p>Well, it qualifies as a question, but obviously the results are going to be the same either way so it's just a matter...
2008/12/08
[ "https://Stackoverflow.com/questions/349442", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40614/" ]
I have a class with two methods defined in it. ``` public class Routines { public static method1() { /* set of statements */ } public static method2() { /* another set of statements.*/ } } ``` Now I need to call method1() from method2() Which one the following approaches is better?...
While I agree with the existing answers that this is primarily a style issue, it is enough of a style issue that both Eclipse and IntelliJ's code critics will flag "non-static references to static methods" in code that does not use the `Classname.method()` style. I made it a habit to emphasize *intent* by using the cl...
349,459
<p>Say I have a table called "xml" that stores XML files in a single column "data". How would I write a MySQL query that run an XPath and return only rows matching that XPath?</p>
[ { "answer_id": 350180, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 4, "selected": true, "text": "<pre><code>SELECT * FROM xml\nWHERE EXTRACTVALUE(data, '&lt;xpath-expr&gt;') != '';\n</code></pre>\n\n<p>You should not...
2008/12/08
[ "https://Stackoverflow.com/questions/349459", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11236/" ]
Say I have a table called "xml" that stores XML files in a single column "data". How would I write a MySQL query that run an XPath and return only rows matching that XPath?
``` SELECT * FROM xml WHERE EXTRACTVALUE(data, '<xpath-expr>') != ''; ``` You should note, however, that there are limitations to MySQL's support of XPath. * `EXTRACTVALUE()` returns only CDATA. * Not all XPath constructions are supported. Details under the heading "XPath limitations" on the doc [page](http://dev.my...
349,460
<p>I have this code:</p> <pre><code>SELECT idcallhistory3, callid, starttime, answertime, endtime, duration, is_answ, is_fail, is_compl, is_fromoutside, mediatype, from_no, to_no, callerid, dialednumber, lastcallerid, lastdialednumber, group_no, line_no FROM "public".callhistory3 ...
[ { "answer_id": 349473, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 1, "selected": false, "text": "<p>The typical way of doing this is something like:</p>\n\n<pre><code>WHERE (? IS NULL OR starttime &gt;= ?)\n</code></p...
2008/12/08
[ "https://Stackoverflow.com/questions/349460", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have this code: ``` SELECT idcallhistory3, callid, starttime, answertime, endtime, duration, is_answ, is_fail, is_compl, is_fromoutside, mediatype, from_no, to_no, callerid, dialednumber, lastcallerid, lastdialednumber, group_no, line_no FROM "public".callhistory3 WHERE (sta...
``` WHERE (@start is null OR starttime >= @start) AND (@end is null OR endtime <= @end) AND (@fromOutside is null OR is_fromoutside = @fromOutside) AND (@fromNo is null OR from_no = @fromNo) AND (@toNo is null OR to_no = @toNo) ``` Pass nulls for all parameters (dang sql nulls; thanks GC).
349,520
<p>Is there any built-in utility or helper to parse <code>HttpContext.Current.User.Identity.Name</code>, e.g. <code>domain\user</code> to get separately domain name if exists and user?</p> <p>Or is there any other class to do so?</p> <p>I understand that it's very easy to call <code>String.Split("\")</code> but just ...
[ { "answer_id": 349552, "author": "Aen Sidhe", "author_id": 27337, "author_profile": "https://Stackoverflow.com/users/27337", "pm_score": 1, "selected": false, "text": "<p>I don't think so, because System.Security.Principal.WindowsIdentity doesn't contain such members.</p>\n" }, { ...
2008/12/08
[ "https://Stackoverflow.com/questions/349520", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41956/" ]
Is there any built-in utility or helper to parse `HttpContext.Current.User.Identity.Name`, e.g. `domain\user` to get separately domain name if exists and user? Or is there any other class to do so? I understand that it's very easy to call `String.Split("\")` but just interesting
This is better (*easier to use, no opportunity of `NullReferenceExcpetion` and conforms MS coding guidelines about treating empty and null string equally*): ``` public static class Extensions { public static string GetDomain(this IIdentity identity) { string s = identity.Name; int stop = s.Inde...
349,524
<p>In my SQL Server backend for my app, I want to create history tables for a bunch of my key tables, which will track a history of changes to the rows.</p> <p>My entire application uses Stored Procedures, there is no embedded SQL. The only connection to the database to modify these tables will be through the applicat...
[ { "answer_id": 349535, "author": "ConcernedOfTunbridgeWells", "author_id": 15401, "author_profile": "https://Stackoverflow.com/users/15401", "pm_score": 2, "selected": false, "text": "<p>Use triggers for this. This means that any changes, regardless of source, will be reflected in the h...
2008/12/08
[ "https://Stackoverflow.com/questions/349524", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24126/" ]
In my SQL Server backend for my app, I want to create history tables for a bunch of my key tables, which will track a history of changes to the rows. My entire application uses Stored Procedures, there is no embedded SQL. The only connection to the database to modify these tables will be through the application and th...
Triggers. We wrote a GUI (internally called *Red Matrix Reloaded*) to allow easy creation/management of audit logging triggers. Here's some DDL of the stuff used: --- The AuditLog table ------------------ ``` CREATE TABLE [AuditLog] ( [AuditLogID] [int] IDENTITY (1, 1) NOT NULL , [ChangeDate] [datetime] N...
349,536
<p>I've got a potentially rather large list of objects I'd like to bind to a ListBox in WPF. However, I'd like to have the List load itself incrementally. How can I bind a ListBox to an IEnumerable that loads itself on-demand in such a way that the listbox only tries to enumerate as much as it needs for the display?...
[ { "answer_id": 349553, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 0, "selected": false, "text": "<p>With winform, \"virtual mode\" - but AFAIK, this isn't the same in WPF.\nYou could see <a href=\"http://social.msd...
2008/12/08
[ "https://Stackoverflow.com/questions/349536", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3279/" ]
I've got a potentially rather large list of objects I'd like to bind to a ListBox in WPF. However, I'd like to have the List load itself incrementally. How can I bind a ListBox to an IEnumerable that loads itself on-demand in such a way that the listbox only tries to enumerate as much as it needs for the display?
WPF ListBox's use a [VirtualizingStackPanel](http://msdn.microsoft.com/en-us/library/system.windows.controls.virtualizingstackpanel.aspx) as the layout control for its items. You can set the VirtualizingStackPanel to only load items as needed with the following XAML: ``` <ListBox VirtualizingStackPanel.IsVirtuali...
349,559
<p>I have a database with two main tables <code>notes</code> and <code>labels</code>. They have a many-to-many relationship (similar to how stackoverflow.com has questions with labels). What I am wondering is how can I search for a note using multiple labels using SQL? </p> <p>For example if I have a note "test" wi...
[ { "answer_id": 349570, "author": "Kev", "author_id": 16777, "author_profile": "https://Stackoverflow.com/users/16777", "pm_score": 1, "selected": false, "text": "<pre><code>select * from notes a\ninner join notes_labels mm on (mm.note = a.id and mm.labeltext in ('one', 'two') )\n</code><...
2008/12/08
[ "https://Stackoverflow.com/questions/349559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5004/" ]
I have a database with two main tables `notes` and `labels`. They have a many-to-many relationship (similar to how stackoverflow.com has questions with labels). What I am wondering is how can I search for a note using multiple labels using SQL? For example if I have a note "test" with three labels "one", "two", and "...
To obtain the details of notes that have **both** labels 'One' and 'Two': ``` select * from notes where note_id in ( select note_id from labels where label = 'One' intersect select note_id from labels where label = 'Two' ) ```
349,576
<p>On Linux, how can I (programmatically) retrieve the following counters <em>on a per-interface basis</em>:</p> <ul> <li>Sent/received ethernet frames,</li> <li>Sent/received IPv4 packets,</li> <li>Sent/received IPv6 packets.</li> </ul>
[ { "answer_id": 349607, "author": "dsm", "author_id": 7780, "author_profile": "https://Stackoverflow.com/users/7780", "pm_score": 0, "selected": false, "text": "<p><a href=\"http://www.wireshark.org/\" rel=\"nofollow noreferrer\">Wireshark</a> (used to be Ethereal) can help you with that....
2008/12/08
[ "https://Stackoverflow.com/questions/349576", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21435/" ]
On Linux, how can I (programmatically) retrieve the following counters *on a per-interface basis*: * Sent/received ethernet frames, * Sent/received IPv4 packets, * Sent/received IPv6 packets.
You should be able to do this using `iptables` rules and packet counters, e.g. ``` # input and output must be accounted for separately # ipv4, eth0 iptables -I INPUT -i eth0 iptables -I OUTPUT -o eth0 # ipv6, eth0 ip6tables -I INPUT -i eth0 ip6tables -I OUTPUT -o eth0 ``` And to view the stats, parse the output of t...
349,597
<p>Is anyone aware of a good resource <strong><em>online</em></strong> for detailed information on the use of ole excel objects(embeded workbooks, worksheets, etc...) in VB6? I'm maintaining an application that makes heavy use of these conrols and I'm having a lot of trouble getting them to work properly for the user's...
[ { "answer_id": 367503, "author": "Mark Nold", "author_id": 4134, "author_profile": "https://Stackoverflow.com/users/4134", "pm_score": 1, "selected": false, "text": "<p>Any book on Excel VBA should help as you can copy and paste code from VBA to VB6. I would start there. </p>\n\n<p>Also ...
2008/12/08
[ "https://Stackoverflow.com/questions/349597", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10007/" ]
Is anyone aware of a good resource ***online*** for detailed information on the use of ole excel objects(embeded workbooks, worksheets, etc...) in VB6? I'm maintaining an application that makes heavy use of these conrols and I'm having a lot of trouble getting them to work properly for the user's of this program. The s...
I'm not sure this is helpful for *embedding* Excel, but assuming that the Excel engine is at the core of the embedded controls, you can look [here](http://msdn.microsoft.com/en-us/library/aa272310(office.11).aspx) for an alphabetized reference of the objects available for Excel 2003. And [here](http://msdn.microsoft.c...
349,603
<p>I wanted to start with the use of Remoting under C# in a testdriven way, but I got stuck.</p> <p>One thing I found on the topic is this <a href="http://www.codeproject.com/KB/architecture/TddRemoting.aspx" rel="nofollow noreferrer">article by Marc Clifton</a>, but he seems to have the server running by starting it ...
[ { "answer_id": 359236, "author": "GrGr", "author_id": 32679, "author_profile": "https://Stackoverflow.com/users/32679", "pm_score": 0, "selected": false, "text": "<p>I found a nice way to do exactly what I wanted to do, just using WCF instead of Remoting.</p>\n\n<p>I ported the source co...
2008/12/08
[ "https://Stackoverflow.com/questions/349603", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32679/" ]
I wanted to start with the use of Remoting under C# in a testdriven way, but I got stuck. One thing I found on the topic is this [article by Marc Clifton](http://www.codeproject.com/KB/architecture/TddRemoting.aspx), but he seems to have the server running by starting it manually from the console. I try to have the s...
I don't really have a solution to your problem but my advice would be, not to write unit-tests in this manner. See this [post](http://www.artima.com/weblogs/viewpost.jsp?thread=126923). What code do you really want to test here. I'm pretty sure Microsoft has done a good deal of testing the Remoting feature that ships w...
349,612
<pre><code>$(document).ready(function() { $("span.link").mouseover(function(e){ $(this.children).css("display","inline"); }); }); </code></pre> <p>I'm not a javascript expert, but I've cobbled together a few functions using jQuery. </p> <p>In this case, the stylesheet hides some cont...
[ { "answer_id": 349627, "author": "Andreas Grech", "author_id": 44084, "author_profile": "https://Stackoverflow.com/users/44084", "pm_score": 4, "selected": true, "text": "<p>Try it like this:</p>\n\n<pre><code>$(function() {\n $(\"span.link\").mouseover(function(e){\n $(this).c...
2008/12/08
[ "https://Stackoverflow.com/questions/349612", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10461/" ]
``` $(document).ready(function() { $("span.link").mouseover(function(e){ $(this.children).css("display","inline"); }); }); ``` I'm not a javascript expert, but I've cobbled together a few functions using jQuery. In this case, the stylesheet hides some controls. When the user mouses...
Try it like this: ``` $(function() { $("span.link").mouseover(function(e){ $(this).children().css("display","inline"); }); }); ```
349,613
<p>Hopefully an easy question, but I'd quite like a technical answer to this!</p> <p>What's the difference between:</p> <pre><code>i = 4 </code></pre> <p>and</p> <pre><code>Set i = 4 </code></pre> <p>in VBA? I know that the latter will throw an error, but I don't fully understand why.</p>
[ { "answer_id": 349622, "author": "LeppyR64", "author_id": 16592, "author_profile": "https://Stackoverflow.com/users/16592", "pm_score": 3, "selected": false, "text": "<p>Set is used for setting object references, as opposed to assigning a value.</p>\n" }, { "answer_id": 349624, ...
2008/12/08
[ "https://Stackoverflow.com/questions/349613", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4019/" ]
Hopefully an easy question, but I'd quite like a technical answer to this! What's the difference between: ``` i = 4 ``` and ``` Set i = 4 ``` in VBA? I know that the latter will throw an error, but I don't fully understand why.
`set` is used to assign a reference to an object. The C equivalent would be ``` int i; int* ref_i; i = 4; // Assigning a value (in VBA: i = 4) ref_i = &i; //assigning a reference (in VBA: set ref_i = i) ```
349,652
<p>I'm getting a strange effect in Jena 2.5.5 (on Linux) where I am playing around with the inference API. The following code is a stripped down version. I am creating an initially empty Model and a generic rule reasoner. I add a reflexivity rule for a certain statement. I attach the reasoner to the model to get an Inf...
[ { "answer_id": 350894, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>It's likely that model.toString() has side-effects. I have not looked at the JENA source, so I can't be sure, though.</p>\n...
2008/12/08
[ "https://Stackoverflow.com/questions/349652", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm getting a strange effect in Jena 2.5.5 (on Linux) where I am playing around with the inference API. The following code is a stripped down version. I am creating an initially empty Model and a generic rule reasoner. I add a reflexivity rule for a certain statement. I attach the reasoner to the model to get an InfMod...
Had a quick look at the relevant source and it appears that you have two options: * If you want to make changes to the base *model* and then be sure that they propagate to the *infModel*, then you have to call *infModel.rebind()* after having made the changes and before you "ask" the *infModel* anything. * You can use...
349,653
<p>The following doesn't work, because it doesn't wait until the process is finished:</p> <pre><code>import subprocess p = subprocess.Popen('start /WAIT /B MOZILL~1.LNK', shell=True) p.wait() </code></pre> <p>Any idea how to run a shortcut and wait that the subprocess returns ?</p> <p><strong>Edit:</strong> original...
[ { "answer_id": 349697, "author": "JimB", "author_id": 32880, "author_profile": "https://Stackoverflow.com/users/32880", "pm_score": 3, "selected": true, "text": "<p>You will need to invoke a shell to get the subprocess option to work:</p>\n\n<pre><code>p = subprocess.Popen('start /B MOZI...
2008/12/08
[ "https://Stackoverflow.com/questions/349653", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28165/" ]
The following doesn't work, because it doesn't wait until the process is finished: ``` import subprocess p = subprocess.Popen('start /WAIT /B MOZILL~1.LNK', shell=True) p.wait() ``` Any idea how to run a shortcut and wait that the subprocess returns ? **Edit:** originally I was trying this without the **shell** opt...
You will need to invoke a shell to get the subprocess option to work: ``` p = subprocess.Popen('start /B MOZILL~1.LNK', shell=True) p.wait() ``` This however will still exit immediately (see @R. Bemrose). If `p.pid` contains the correct pid (I'm not sure on windows), then you could use [`os.waitpid()`](http://docs....
349,655
<p>I've created a database in Visual Studio 2008 in an App_Data folder of a MVC Web Application project. This results in an mdf file for the database that can be explored in the Server Explorer tab. You can create a SQL script for changes you do to the database.</p> <p>So I'm wondering how you run these sql change scr...
[ { "answer_id": 349670, "author": "Neil Barnwell", "author_id": 26414, "author_profile": "https://Stackoverflow.com/users/26414", "pm_score": 3, "selected": true, "text": "<p>The syntax is:</p>\n\n<pre><code>CREATE DATABASE [databaseName]\n</code></pre>\n\n<p>This will create a database o...
2008/12/08
[ "https://Stackoverflow.com/questions/349655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3713/" ]
I've created a database in Visual Studio 2008 in an App\_Data folder of a MVC Web Application project. This results in an mdf file for the database that can be explored in the Server Explorer tab. You can create a SQL script for changes you do to the database. So I'm wondering how you run these sql change scripts to a...
The syntax is: ``` CREATE DATABASE [databaseName] ``` This will create a database on the SQL Server you are connected do, creating files with the standard names in the standard location. There are additional options ([described on MSDN](http://msdn.microsoft.com/en-us/library/aa258257.aspx)) that will help you to pl...
349,659
<h1>Duplicate from : <a href="https://stackoverflow.com/questions/16432/c-string-output-format-or-concat">String output: format or concat in C#?</a></h1> <p>Especially in C# world using String.Format for everything is really common, normally as VB.NET developer unless I have to* I don't String.Format, </p> <p>I prefe...
[ { "answer_id": 349674, "author": "Lasse V. Karlsen", "author_id": 267, "author_profile": "https://Stackoverflow.com/users/267", "pm_score": 0, "selected": false, "text": "<p>Personally I find that String.Format is easier to read, the string is presented as one consecutive text. It depend...
2008/12/08
[ "https://Stackoverflow.com/questions/349659", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40322/" ]
Duplicate from : [String output: format or concat in C#?](https://stackoverflow.com/questions/16432/c-string-output-format-or-concat) ===================================================================================================================================== Especially in C# world using String.Format for ever...
If you're ever going to localize your application (and it's often hard to rule that out at the start), then String.Format is to be much preferred, for two reasons: 1. You have only one string literal to translate 2. You can change the order of the values, which may make more sense in another language.
349,702
<p>I'm trying to learn bash string handling. How do I create a bash script which is equivalent to this Java code snippet?</p> <pre><code>String symbols = "abcdefg12345_"; for (char i : symbols.toCharArray()) { for (char j : symbols.toCharArray()) { System.out.println(new StringBuffer().append(i).append(j))...
[ { "answer_id": 349712, "author": "unwind", "author_id": 28169, "author_profile": "https://Stackoverflow.com/users/28169", "pm_score": 4, "selected": true, "text": "<p>That is so simple, Bash does it in the input parser. No code required. Try:</p>\n\n<pre><code>echo {a,b,c,d,e,f,g,1,2,3,4...
2008/12/08
[ "https://Stackoverflow.com/questions/349702", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to learn bash string handling. How do I create a bash script which is equivalent to this Java code snippet? ``` String symbols = "abcdefg12345_"; for (char i : symbols.toCharArray()) { for (char j : symbols.toCharArray()) { System.out.println(new StringBuffer().append(i).append(j)); } } ```...
That is so simple, Bash does it in the input parser. No code required. Try: ``` echo {a,b,c,d,e,f,g,1,2,3,4,5,_}{a,b,c,d,e,f,g,1,2,3,4,5,_} ``` You might need a second pass to split it into lines, though. Or, you could of course use a couple of nested loops like in your example: ``` LIST="a b c d e f 1 2 3 4 5 _";...
349,705
<p>As in the subject, how can one get the total width of an element, including its border and padding, using jQuery? I've got the jQuery dimensions plugin, and running <code>.width()</code> on my <code>760px-wide</code>, <code>10px padding</code> DIV returns <code>760</code>.</p> <p>Perhaps I'm doing something wrong,...
[ { "answer_id": 349719, "author": "Andreas Grech", "author_id": 44084, "author_profile": "https://Stackoverflow.com/users/44084", "pm_score": 9, "selected": true, "text": "<p><strong>[Update]</strong></p>\n\n<p>The original answer was written prior to jQuery 1.3, and the functions that ex...
2008/12/08
[ "https://Stackoverflow.com/questions/349705", "https://Stackoverflow.com", "https://Stackoverflow.com/users/192/" ]
As in the subject, how can one get the total width of an element, including its border and padding, using jQuery? I've got the jQuery dimensions plugin, and running `.width()` on my `760px-wide`, `10px padding` DIV returns `760`. Perhaps I'm doing something wrong, but if my element manifests itself as `780 pixels wide...
**[Update]** The original answer was written prior to jQuery 1.3, and the functions that existed at the time where not adequate by themselves to calculate the whole width. Now, as [J-P](https://stackoverflow.com/questions/349705/total-width-of-element-including-padding-and-border-in-jquery/673622#673622) correctly st...
349,724
<p>A recent <a href="https://stackoverflow.com/questions/349659/stringformat-or-not">question came up</a> about using String.Format(). Part of my answer included a suggestion to use StringBuilder.AppendLine(string.Format(...)). Jon Skeet suggested this was a bad example and proposed using a combination of AppendLine a...
[ { "answer_id": 349736, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 7, "selected": true, "text": "<p>I view <code>AppendFormat</code> followed by <code>AppendLine</code> as not only more readable, but also more performa...
2008/12/08
[ "https://Stackoverflow.com/questions/349724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26414/" ]
A recent [question came up](https://stackoverflow.com/questions/349659/stringformat-or-not) about using String.Format(). Part of my answer included a suggestion to use StringBuilder.AppendLine(string.Format(...)). Jon Skeet suggested this was a bad example and proposed using a combination of AppendLine and AppendFormat...
I view `AppendFormat` followed by `AppendLine` as not only more readable, but also more performant than calling `AppendLine(string.Format(...))`. The latter creates a whole new string and then appends it wholesale into the existing builder. I'm not going to go as far as saying "Why bother using StringBuilder then?" bu...
349,729
<p>I am using <a href="http://msdn.microsoft.com/en-us/library/system.net.networkinformation.networkinterface.getallnetworkinterfaces.aspx" rel="nofollow noreferrer">NetworkInterface.GetAllNetworkInterfaces()</a> to get all the interfaces on a PC. However, this appears to only return "active" interfaces. How can I find...
[ { "answer_id": 349766, "author": "Paul Nearney", "author_id": 24071, "author_profile": "https://Stackoverflow.com/users/24071", "pm_score": 1, "selected": false, "text": "<p>This example using WMI may get you most of the way (Sorry about the C# by the way!):</p>\n\n<pre><code>using Syste...
2008/12/08
[ "https://Stackoverflow.com/questions/349729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15393/" ]
I am using [NetworkInterface.GetAllNetworkInterfaces()](http://msdn.microsoft.com/en-us/library/system.net.networkinformation.networkinterface.getallnetworkinterfaces.aspx) to get all the interfaces on a PC. However, this appears to only return "active" interfaces. How can I find "inactive" network interfaces, such as ...
``` RasDialer dialer = new RasDialer(); ReadOnlyCollection<RasConnection> connections = dialer.GetActiveConnections(); foreach (RasConnection connection in connections) { // Do what you want to with the connections. } ``` That will retrieve all connected dial up entries (including VPN connections) that are in us...
349,742
<p>I frequently make use of <code>Request.QueryString[]</code> variables.</p> <p>In my <code>Page_load</code> I often do things like:</p> <pre><code> int id = -1; if (Request.QueryString["id"] != null) { try { id = int.Parse(Request.QueryString["id"]); ...
[ { "answer_id": 349748, "author": "VVS", "author_id": 21038, "author_profile": "https://Stackoverflow.com/users/21038", "pm_score": 5, "selected": false, "text": "<p>Use int.TryParse instead to get rid of the try-catch block:</p>\n\n<pre><code>if (!int.TryParse(Request.QueryString[\"id\"]...
2008/12/08
[ "https://Stackoverflow.com/questions/349742", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31765/" ]
I frequently make use of `Request.QueryString[]` variables. In my `Page_load` I often do things like: ``` int id = -1; if (Request.QueryString["id"] != null) { try { id = int.Parse(Request.QueryString["id"]); } catch { ...
Below is an extension method that will allow you to write code like this: ``` int id = request.QueryString.GetValue<int>("id"); DateTime date = request.QueryString.GetValue<DateTime>("date"); ``` It makes use of `TypeDescriptor` to perform the conversion. Based on your needs, you could add an overload which takes a ...
349,743
<p>My homepage (or welcome page) will consist of data from two models (lets call them authors and posts). I am new to rails and not sure what is the best way to accomplish this.</p> <p>Should I create a new controller called welcome which gathers data from the authors and posts and then display them in the welcome ind...
[ { "answer_id": 349798, "author": "Mike Woodhouse", "author_id": 1060, "author_profile": "https://Stackoverflow.com/users/1060", "pm_score": 3, "selected": false, "text": "<p>Create a new controller named as appropriately as you can. SummaryController? StartController? DailyFrontPageContr...
2008/12/08
[ "https://Stackoverflow.com/questions/349743", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50718/" ]
My homepage (or welcome page) will consist of data from two models (lets call them authors and posts). I am new to rails and not sure what is the best way to accomplish this. Should I create a new controller called welcome which gathers data from the authors and posts and then display them in the welcome index view? O...
The question is, is your home page just a landing page or will it be a group of pages? If it's just a landing page, you don't expect your users to hang around there for long except to go elsewhere. If it's a group of pages, or similar to an existing group, you can add an action to the controller it's most like. What I...
349,769
<p>Is it possible to return an XElement from a webservice (in C#/asp.net)?</p> <p>Try a simple web service that returns an XElement:</p> <pre><code>[WebMethod] public XElement DoItXElement() { XElement xe = new XElement("hello", new XElement("message", "Hello World") ); return xe; } </code></pre> <p>T...
[ { "answer_id": 349882, "author": "Agies", "author_id": 333860, "author_profile": "https://Stackoverflow.com/users/333860", "pm_score": 3, "selected": false, "text": "<p>There appears to be an issue with how an XElement is serialized, check <a href=\"http://www.developersdex.com/csharp/me...
2008/12/08
[ "https://Stackoverflow.com/questions/349769", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3099/" ]
Is it possible to return an XElement from a webservice (in C#/asp.net)? Try a simple web service that returns an XElement: ``` [WebMethod] public XElement DoItXElement() { XElement xe = new XElement("hello", new XElement("message", "Hello World") ); return xe; } ``` This compiles fine but if you try ...
There appears to be an issue with how an XElement is serialized, check [here](http://www.developersdex.com/csharp/message.asp?p=1111&r=6149937)... You can try outing the XElement as a string or as the article suggests you could just use a class wrapper and place your XElement inside. If the point is to output the data...
349,802
<p>Is it possible for me to create and destroy a TXMLDocument by myself in Borland C++ Builder? I've tried but borland keeps telling me that TXMLDocument is (and must be) an IDE managed component. </p> <p>Also, the only reason that I want to do this is that TXMLDocument sort of crashes: I get the TXMLDocument and 'Get...
[ { "answer_id": 349857, "author": "Roddy", "author_id": 1737, "author_profile": "https://Stackoverflow.com/users/1737", "pm_score": 3, "selected": true, "text": "<p>You need to do something like this instead:</p>\n\n<pre><code>_di_IXMLDocument Doc = NewXMLDocument(); \n</code></pre>\n\n<p...
2008/12/08
[ "https://Stackoverflow.com/questions/349802", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2079/" ]
Is it possible for me to create and destroy a TXMLDocument by myself in Borland C++ Builder? I've tried but borland keeps telling me that TXMLDocument is (and must be) an IDE managed component. Also, the only reason that I want to do this is that TXMLDocument sort of crashes: I get the TXMLDocument and 'Gets' a workb...
You need to do something like this instead: ``` _di_IXMLDocument Doc = NewXMLDocument(); ``` I can't remember the gory details of why, but that should point you in the right direction. There's more info on the Codegear website [here](http://dn.codegear.com/article/29241).
349,811
<p>How to arrange a Makefile to compile a kernel module with multiple .c files?</p> <p>Here is my current Makefile. It was auto generated by <a href="http://www.kdevelop.org/" rel="noreferrer">KDevelop</a></p> <pre><code>TARGET = nlb-driver OBJS = nlb-driver.o MDIR = drivers/misc EXTRA_CFLAGS = -DEXPORT_SYMTAB CURRE...
[ { "answer_id": 349820, "author": "unwind", "author_id": 28169, "author_profile": "https://Stackoverflow.com/users/28169", "pm_score": 2, "selected": false, "text": "<p>I would assume that just listing more object files in the second line would do the trick.</p>\n" }, { "answer_id...
2008/12/08
[ "https://Stackoverflow.com/questions/349811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1100/" ]
How to arrange a Makefile to compile a kernel module with multiple .c files? Here is my current Makefile. It was auto generated by [KDevelop](http://www.kdevelop.org/) ``` TARGET = nlb-driver OBJS = nlb-driver.o MDIR = drivers/misc EXTRA_CFLAGS = -DEXPORT_SYMTAB CURRENT = $(shell uname -r) KDIR = /lib/modules/$(CURR...
In my case the project consists of 6 files: * `monter_main.c`, `monter_main.h` * `monter_cdev.c`, `monter_cdev.h` * `monter_pci.c`, `monter_pci.h` `monter_main.c` is the main file of my module. Remember that you shouldn't have a file with the same name as the module you're trying to build (e.g. `monter.c` and `mon...
349,822
<p>When using the following function (compare 2 user's group membership), I get results that do not make sense.</p> <pre><code>function Compare-ADUserGroups &lt;br&gt; { #requires -pssnapin Quest.ActiveRoles.ADManagement param ( [string] $FirstUser = $(Throw "logonname required."), [string] $Sec...
[ { "answer_id": 350460, "author": "Don Jones", "author_id": 40405, "author_profile": "https://Stackoverflow.com/users/40405", "pm_score": 1, "selected": false, "text": "<p>There's <em>something</em> in them which is throwing off the comparison. You'll see something similar if you run...</...
2008/12/08
[ "https://Stackoverflow.com/questions/349822", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
When using the following function (compare 2 user's group membership), I get results that do not make sense. ``` function Compare-ADUserGroups <br> { #requires -pssnapin Quest.ActiveRoles.ADManagement param ( [string] $FirstUser = $(Throw "logonname required."), [string] $SecondUser = $(Throw "l...
There's *something* in them which is throwing off the comparison. You'll see something similar if you run... get-process | export-clixml c\procs.xml Diff (get-process) (import-clixml c:\procs.xml) Because SOME properties of those objects - things like VM and PM, for example, change in the brief interval between the t...
349,824
<p>I am attempting to programmatically monitor the size of a SQL Server database, so that my admin section of my web app can report it, and I can use that to execute some cleanup SPs, to clear log files, etc.</p> <p>I use the following code to calculate the size of the tables, per SO recommendation:</p> <pre><code>CR...
[ { "answer_id": 349939, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": true, "text": "<p>The difference, in my opinion, is due to the fact that the size you see in the \"Properties\" page is calculated by querying...
2008/12/08
[ "https://Stackoverflow.com/questions/349824", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24126/" ]
I am attempting to programmatically monitor the size of a SQL Server database, so that my admin section of my web app can report it, and I can use that to execute some cleanup SPs, to clear log files, etc. I use the following code to calculate the size of the tables, per SO recommendation: ``` CREATE TABLE #t (name S...
The difference, in my opinion, is due to the fact that the size you see in the "Properties" page is calculated by querying the table .sys.database\_files, which counts the number of 8KB pages allocated by each database file. To obtain the same result, simply run the following query (SQL Server 2005): ``` SELECT SU...
349,842
<p>I want to do some functional testing on a (restful) webservice. The testsuite contains a bunch of test cases, each of which performs a couple of HTTP requests on the webservice.</p> <p>Naturally, the webservice has to run or the tests will fail. :-)</p> <p>Starting the webservice takes a couple of minutes (it does...
[ { "answer_id": 349863, "author": "sblundy", "author_id": 4893, "author_profile": "https://Stackoverflow.com/users/4893", "pm_score": 1, "selected": false, "text": "<p>jUnit can't do that sort of thing -- though TestNG does have <code>@BeforeSuite</code> and <code>@AfterSuite</code> annot...
2008/12/08
[ "https://Stackoverflow.com/questions/349842", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to do some functional testing on a (restful) webservice. The testsuite contains a bunch of test cases, each of which performs a couple of HTTP requests on the webservice. Naturally, the webservice has to run or the tests will fail. :-) Starting the webservice takes a couple of minutes (it does some heavy data ...
The answer is now to create a `@ClassRule` within your suite. The rule will be invoked before or after (depending on how you implement it) each test class is run. There are a few different base classes you can extend/implement. What is nice about class rules is that if you do not implement them as anonymous classes the...
349,845
<p>Environment: Rails 2.2.2, Oracle 10g</p> <p>Most of the columns declared "date" in my ActiveRecord models are exactly that: dates: they don't care about time at all.</p> <p>So with a model declared thus:#</p> <pre><code>class MyDateOnlyModel &lt; ActiveRecord::Migration def self.up create_table :my_date_onl...
[ { "answer_id": 349863, "author": "sblundy", "author_id": 4893, "author_profile": "https://Stackoverflow.com/users/4893", "pm_score": 1, "selected": false, "text": "<p>jUnit can't do that sort of thing -- though TestNG does have <code>@BeforeSuite</code> and <code>@AfterSuite</code> annot...
2008/12/08
[ "https://Stackoverflow.com/questions/349845", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1060/" ]
Environment: Rails 2.2.2, Oracle 10g Most of the columns declared "date" in my ActiveRecord models are exactly that: dates: they don't care about time at all. So with a model declared thus:# ``` class MyDateOnlyModel < ActiveRecord::Migration def self.up create_table :my_date_only_model do |t| t.date :ef...
The answer is now to create a `@ClassRule` within your suite. The rule will be invoked before or after (depending on how you implement it) each test class is run. There are a few different base classes you can extend/implement. What is nice about class rules is that if you do not implement them as anonymous classes the...
349,852
<p>I'm extracting an interface that I would like to retain the original name. The actual class will get a "Impl" suffix, in accordance with our naming conventions. I want to know how to best reflect that in subversion so that the history "AppPropertiesImpl.java" covers its life as "AppProperties.java". As for the new "...
[ { "answer_id": 349863, "author": "sblundy", "author_id": 4893, "author_profile": "https://Stackoverflow.com/users/4893", "pm_score": 1, "selected": false, "text": "<p>jUnit can't do that sort of thing -- though TestNG does have <code>@BeforeSuite</code> and <code>@AfterSuite</code> annot...
2008/12/08
[ "https://Stackoverflow.com/questions/349852", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4893/" ]
I'm extracting an interface that I would like to retain the original name. The actual class will get a "Impl" suffix, in accordance with our naming conventions. I want to know how to best reflect that in subversion so that the history "AppPropertiesImpl.java" covers its life as "AppProperties.java". As for the new "App...
The answer is now to create a `@ClassRule` within your suite. The rule will be invoked before or after (depending on how you implement it) each test class is run. There are a few different base classes you can extend/implement. What is nice about class rules is that if you do not implement them as anonymous classes the...
349,858
<p>I'm trying to get a UIDatePicker with a UIButton to show up in a UIActionSheet. Unfortunately it gets cropped off and the entire Date Picker is not visible. I have not even attempted to add the UIButton yet. Can anyone suggest on getting the entire view to fit properly? I'm not sure how to add the proper dimensions ...
[ { "answer_id": 353779, "author": "thbonk", "author_id": 44123, "author_profile": "https://Stackoverflow.com/users/44123", "pm_score": 6, "selected": true, "text": "<p>You can use something like this (adjust the coordinates):</p>\n\n<pre><code> UIActionSheet *menu = [[UIActionSheet all...
2008/12/08
[ "https://Stackoverflow.com/questions/349858", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40882/" ]
I'm trying to get a UIDatePicker with a UIButton to show up in a UIActionSheet. Unfortunately it gets cropped off and the entire Date Picker is not visible. I have not even attempted to add the UIButton yet. Can anyone suggest on getting the entire view to fit properly? I'm not sure how to add the proper dimensions as ...
You can use something like this (adjust the coordinates): ``` UIActionSheet *menu = [[UIActionSheet alloc] initWithTitle:@"Date Picker" delegate:self cancelButtonTitle:@"Cancel" destructi...
349,861
<p>I have a script that animates a small DIV popping up on the page. It all works fine in IE, and in FF if I remove the DOCTYPE, but when the DOCTYPE is XHTML/Transitional, in Firefox, the width does not change. </p> <pre><code>this.container.style.visibility = "visible"; alert("this.container.style.width before = " +...
[ { "answer_id": 349900, "author": "scunliffe", "author_id": 6144, "author_profile": "https://Stackoverflow.com/users/6144", "pm_score": 5, "selected": true, "text": "<p>Have you tried setting:</p>\n\n<pre><code>this.container.style.visibility = \"visible\";\nalert(\"this.container.style.w...
2008/12/08
[ "https://Stackoverflow.com/questions/349861", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8349/" ]
I have a script that animates a small DIV popping up on the page. It all works fine in IE, and in FF if I remove the DOCTYPE, but when the DOCTYPE is XHTML/Transitional, in Firefox, the width does not change. ``` this.container.style.visibility = "visible"; alert("this.container.style.width before = " + this.containe...
Have you tried setting: ``` this.container.style.visibility = "visible"; alert("this.container.style.width before = " + this.container.style.width); this.container.style.width = this.width + 'px'; alert("this.container.style.width after = " + this.container.style.width); this.container.style.height = this.height + 'px...
349,864
<p>If you visit <a href="http://www.maplesoft.com/company/news/index.aspx" rel="nofollow noreferrer">this page</a> in Internet explorer, and choose a value from the "Current Media Releases" dropdown on the top right, eventually IE will try to redirect you to an ugly url containing this string:</p> <p>__EVENTTARGET=sel...
[ { "answer_id": 349891, "author": "spaetzel", "author_id": 28943, "author_profile": "https://Stackoverflow.com/users/28943", "pm_score": 0, "selected": false, "text": "<p>The problem only occurs in IE. It works fine in Firefox, and obviously Chrome as well.</p>\n" }, { "answer_id"...
2008/12/08
[ "https://Stackoverflow.com/questions/349864", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28943/" ]
If you visit [this page](http://www.maplesoft.com/company/news/index.aspx) in Internet explorer, and choose a value from the "Current Media Releases" dropdown on the top right, eventually IE will try to redirect you to an ugly url containing this string: \_\_EVENTTARGET=selArchives&\_\_EVENTARGUMENT=&\_\_LASTFOCUS=&\_...
First off, your page has javascript errors. Please fix them. Second, you only see the ugly url when you select a date and click the go button. But you've got the dropdown set to auto postback. Ditch the button; you don't need it. There's something screwy with the button in your codebehind. And the dropdown, as well, ...
349,875
<p>Is it possible to display the text in a TextBlock vertically so that all letters are stacked upon each other (not rotated with LayoutTransform)?</p>
[ { "answer_id": 349954, "author": "Micah", "author_id": 17744, "author_profile": "https://Stackoverflow.com/users/17744", "pm_score": 4, "selected": false, "text": "<p>I don't think there is a straighforward of doing this withought changing the way the system inherently laysout text. The ...
2008/12/08
[ "https://Stackoverflow.com/questions/349875", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11499/" ]
Is it possible to display the text in a TextBlock vertically so that all letters are stacked upon each other (not rotated with LayoutTransform)?
Nobody has yet mentioned the obvious and trivial way to stack the letters of an arbitrary string vertically (without rotating them) using pure XAML: ```xml <ItemsControl ItemsSource="Text goes here, or you could use a binding to a string" /> ``` This simply lays out the text vertically by recognizing the fact that...
349,878
<p>OK since I am in a holding pattern on this issue perhaps someone has seen these symptoms and can provide some sage advice. (Note: I have learned only enough Active Directory information to build this feature and I only have read access to the Active Directory.)</p> <p>I updated the company intranet to allow the au...
[ { "answer_id": 349954, "author": "Micah", "author_id": 17744, "author_profile": "https://Stackoverflow.com/users/17744", "pm_score": 4, "selected": false, "text": "<p>I don't think there is a straighforward of doing this withought changing the way the system inherently laysout text. The ...
2008/12/08
[ "https://Stackoverflow.com/questions/349878", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30934/" ]
OK since I am in a holding pattern on this issue perhaps someone has seen these symptoms and can provide some sage advice. (Note: I have learned only enough Active Directory information to build this feature and I only have read access to the Active Directory.) I updated the company intranet to allow the automatic ent...
Nobody has yet mentioned the obvious and trivial way to stack the letters of an arbitrary string vertically (without rotating them) using pure XAML: ```xml <ItemsControl ItemsSource="Text goes here, or you could use a binding to a string" /> ``` This simply lays out the text vertically by recognizing the fact that...
349,884
<p>I need to simple way to allow an end user to restart tomcat from a web page served from apache on the same box.</p> <p>We're trying to make it easy for our QC department to deploy a new version of our webapp to apache. We're using samba, but we need an easy way for them to stop / start the tomcat server before/afte...
[ { "answer_id": 349895, "author": "Skip Head", "author_id": 23271, "author_profile": "https://Stackoverflow.com/users/23271", "pm_score": 0, "selected": false, "text": "<p>I would use a CGI script. Set it up to run as root and call '/etc/init.d/tomcat restart' (or however you restart tom...
2008/12/08
[ "https://Stackoverflow.com/questions/349884", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1310/" ]
I need to simple way to allow an end user to restart tomcat from a web page served from apache on the same box. We're trying to make it easy for our QC department to deploy a new version of our webapp to apache. We're using samba, but we need an easy way for them to stop / start the tomcat server before/after the depl...
Like Skip said, but don't run the CGI as root. Instead, have the CGI call sudo. You can give your web server permission to run `/etc/init.d/tomcat restart` only in the sudoers file. I've actually done this at work; the relevant part of the CGI looks like this: ``` #!/usr/bin/perl use CGI; use IPC::Run3; my $CGI = new...
349,886
<p>So I have an Oracle instance, and I know it's running on this system, I've su'd to the oracle user, and I'm trying to connect using "/ as sysdba". However, when I do connect, it says the instance is idle. I know the database is up and opened, because my application's talking to it. My paths (ORACLE_HOME, etc.) mi...
[ { "answer_id": 349901, "author": "Igor Zelaya", "author_id": 22769, "author_profile": "https://Stackoverflow.com/users/22769", "pm_score": 3, "selected": false, "text": "<p>that means that the database instance is not mounted nor open. Execute the <em>startup</em> command and see if any...
2008/12/08
[ "https://Stackoverflow.com/questions/349886", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
So I have an Oracle instance, and I know it's running on this system, I've su'd to the oracle user, and I'm trying to connect using "/ as sysdba". However, when I do connect, it says the instance is idle. I know the database is up and opened, because my application's talking to it. My paths (ORACLE\_HOME, etc.) might b...
make sure you have your ORACLE\_HOME setup exactly the same as when the server was started, I've seen this problem with oracle 9.2.0.5.0 on solaris, ``` ORACLE_HOME=/opt/oracle ORACLE_HOME=/opt/oracle/ ``` is two different things, and will result in issues connecting locally.
349,889
<p>I just wrote the following C++ function to programmatically determine how much RAM a system has installed. It works, but it seems to me that there should be a simpler way to do this. Am I missing something?</p> <pre><code>getRAM() { FILE* stream = popen(&quot;head -n1 /proc/meminfo&quot;, &quot;r&quot;); st...
[ { "answer_id": 349970, "author": "Bombe", "author_id": 43582, "author_profile": "https://Stackoverflow.com/users/43582", "pm_score": 1, "selected": false, "text": "<p>Even <code>top</code> (from <code>procps</code>) parses <code>/proc/meminfo</code>. See <a href=\"http://procps.cvs.sourc...
2008/12/08
[ "https://Stackoverflow.com/questions/349889", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1288/" ]
I just wrote the following C++ function to programmatically determine how much RAM a system has installed. It works, but it seems to me that there should be a simpler way to do this. Am I missing something? ``` getRAM() { FILE* stream = popen("head -n1 /proc/meminfo", "r"); std::ostringstream output; int b...
On Linux, you can use the function `sysinfo` which sets values in the following struct: ``` #include <sys/sysinfo.h> int sysinfo(struct sysinfo *info); struct sysinfo { long uptime; /* Seconds since boot */ unsigned long loads[3]; /* 1, 5, and 15 minute load averages */ uns...
349,892
<p>I have a logging table which has three columns. One column is a unique identifier, One Column is called "Name" and the other is "Status".<br> Values in the Name column can repeat so that you might see Name "Joe" in multiple rows. Name "Joe" might have a row with a status "open", another row with a status "closed",...
[ { "answer_id": 349903, "author": "matt b", "author_id": 4249, "author_profile": "https://Stackoverflow.com/users/4249", "pm_score": 3, "selected": true, "text": "<p>I would create a second table named something like \"Status_Precedence\", with rows like:</p>\n\n<pre><code>Status | Order...
2008/12/08
[ "https://Stackoverflow.com/questions/349892", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13954/" ]
I have a logging table which has three columns. One column is a unique identifier, One Column is called "Name" and the other is "Status". Values in the Name column can repeat so that you might see Name "Joe" in multiple rows. Name "Joe" might have a row with a status "open", another row with a status "closed", anoth...
I would create a second table named something like "Status\_Precedence", with rows like: ``` Status | Order --------------- Closed | 1 Hold | 2 Waiting | 3 Open | 4 ``` In your query of the other table, do a join to this table (on `Status_Precedence.Status`) and then you can `ORDER BY Status_Precedence.O...
349,896
<p>I'm trying to make a function that has a list of lists, it multiplies the sum of the inner list with the outer list. So far i can sum a list, i've made a function sumlist([1..n],X) that will return X = (result). But i cannot get another function to usefully work with that function, i've tried both is and = to no ava...
[ { "answer_id": 351501, "author": "mweerden", "author_id": 4285, "author_profile": "https://Stackoverflow.com/users/4285", "pm_score": 1, "selected": false, "text": "<p>The part \"it multiplies the sum of the inner list with the outer list\" isn't really clear, but I believe you mean that...
2008/12/08
[ "https://Stackoverflow.com/questions/349896", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42789/" ]
I'm trying to make a function that has a list of lists, it multiplies the sum of the inner list with the outer list. So far i can sum a list, i've made a function sumlist([1..n],X) that will return X = (result). But i cannot get another function to usefully work with that function, i've tried both is and = to no avail.
Is this what you mean? ``` prodsumlist([], 1). prodsumlist([Head | Tail], Result) :- sumlist(Head, Sum_Of_Head), prodsumlist(Tail, ProdSum_Of_Tail), Result is Sum_Of_Head * ProdSum_Of_Tail. ``` where `sumlist/2` is a SWI-Prolog built-in. Usage example: ``` ?- prodsumlist([[1, 2], [3], [-4]], Result). ...
349,904
<p>Recently I used a class that inherits from a collection instead of having the collection instantiated within the class, is this acceptable or does it create unseen problems further down the road? Examples below for the sake of clarity:</p> <pre><code>public class Cars : List&lt;aCar&gt; </code></pre> <p>instead of...
[ { "answer_id": 349928, "author": "Michael Borgwardt", "author_id": 16883, "author_profile": "https://Stackoverflow.com/users/16883", "pm_score": 4, "selected": true, "text": "<p>The problem with this is that your Cars class will still have the interface it inherits from List, which may a...
2008/12/08
[ "https://Stackoverflow.com/questions/349904", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4098/" ]
Recently I used a class that inherits from a collection instead of having the collection instantiated within the class, is this acceptable or does it create unseen problems further down the road? Examples below for the sake of clarity: ``` public class Cars : List<aCar> ``` instead of something like: ``` public cla...
The problem with this is that your Cars class will still have the interface it inherits from List, which may allow operations you don't want.
349,927
<p>According to <em>Cocoa Programming for Mac OS X, 3rd Edition</em>, on page 245 (chapter 17), you will usually create views in Interface Builder. However, it is possible to create them in code, a la:</p> <pre><code>NSView *superview = [window contentView]; NSRect frame = NSMakeRect(10, 10, 200, 100); NSButton *but...
[ { "answer_id": 350104, "author": "Ben Gottlieb", "author_id": 6694, "author_profile": "https://Stackoverflow.com/users/6694", "pm_score": 6, "selected": true, "text": "<p>You can wire them up using a simple assignment. To continue your code from above:</p>\n\n<pre><code>[button setTarget...
2008/12/08
[ "https://Stackoverflow.com/questions/349927", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14048/" ]
According to *Cocoa Programming for Mac OS X, 3rd Edition*, on page 245 (chapter 17), you will usually create views in Interface Builder. However, it is possible to create them in code, a la: ``` NSView *superview = [window contentView]; NSRect frame = NSMakeRect(10, 10, 200, 100); NSButton *button = [[NSButton allo...
You can wire them up using a simple assignment. To continue your code from above: ``` [button setTarget: self]; [button setAction: @selector(myButtonWasHit:)]; ```
349,931
<p>Please tell me how do I print a bit, like <code>printf("%d",bit);</code>.</p>
[ { "answer_id": 349937, "author": "Herms", "author_id": 1409, "author_profile": "https://Stackoverflow.com/users/1409", "pm_score": 4, "selected": false, "text": "<p>If bit is just an int that contains the value you want in the least significant bit, then:</p>\n\n<pre><code>printf(\"%d\",...
2008/12/08
[ "https://Stackoverflow.com/questions/349931", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Please tell me how do I print a bit, like `printf("%d",bit);`.
If bit is just an int that contains the value you want in the least significant bit, then: ``` printf("%d", bit & 0x1); ``` should do it. The & is doing a binary-AND with a number with only the first significant bit set, so you're removing all the rest of the bits in the integer.
349,933
<p>I have a user table like this</p> <pre><code>user_id | community_id | registration_date -------------------------------------------- 1 | 1 | 2008-01-01 2 | 1 | 2008-05-01 3 | 2 | 2008-01-28 4 | 2 | 2008-07-22 5 | 3 | 2008-01-11 </c...
[ { "answer_id": 350001, "author": "Adam Bellaire", "author_id": 21632, "author_profile": "https://Stackoverflow.com/users/21632", "pm_score": 2, "selected": false, "text": "<p>With an inner select:</p>\n\n<pre><code>select \n registration_date, community_id \nfrom \n user outer \nwhere ...
2008/12/08
[ "https://Stackoverflow.com/questions/349933", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648/" ]
I have a user table like this ``` user_id | community_id | registration_date -------------------------------------------- 1 | 1 | 2008-01-01 2 | 1 | 2008-05-01 3 | 2 | 2008-01-28 4 | 2 | 2008-07-22 5 | 3 | 2008-01-11 ``` For each co...
With an inner select: ``` select registration_date, community_id from user outer where user_id IN ( select user_id from user inner where inner.community_id = outer.community_id order by registration_date limit 2,1 ) order by registration_date ``` Selec...
349,938
<p>Is there a programmatic way to extract equations (and possibly images) from an MS Word document? I've googled all over, but have yet to find anything that I can sink my teeth into and work from. If possible, I'd like to be able to do this with VB.NET or C#, but I can pick up enough of any language to hack out a DL...
[ { "answer_id": 349964, "author": "RobS", "author_id": 41338, "author_profile": "https://Stackoverflow.com/users/41338", "pm_score": 0, "selected": false, "text": "<p>Try looking at the <a href=\"http://kebrt.webz.cz/programs/word-to-latex/\" rel=\"nofollow noreferrer\">Word-to-latex</a> ...
2008/12/08
[ "https://Stackoverflow.com/questions/349938", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4252/" ]
Is there a programmatic way to extract equations (and possibly images) from an MS Word document? I've googled all over, but have yet to find anything that I can sink my teeth into and work from. If possible, I'd like to be able to do this with VB.NET or C#, but I can pick up enough of any language to hack out a DLL. Th...
I don't know if any of this will help, but the object model in Word 2000/2003 has an `InlineShapes` collection as part of the `Document` object which represents embedded images and possibly similar objects like equations. Some VBA code to copy the first item onto the clipboard, which might help you extract them: ``` ...
349,948
<p>I had a class with some common error handling code, and I wanted to pass in the method and arguments to call, but I couldn't quite come up with the syntax. What I want to do is roughly this:</p> <pre><code>private void InvokeHelper(Delegate method, params object[] args) { bool retry = false; do { try ...
[ { "answer_id": 350043, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": true, "text": "<p>First off, your signature is </p>\n\n<pre><code>private void InvokeHelper(Delegate method, params object[] args)\n</code></p...
2008/12/08
[ "https://Stackoverflow.com/questions/349948", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9323/" ]
I had a class with some common error handling code, and I wanted to pass in the method and arguments to call, but I couldn't quite come up with the syntax. What I want to do is roughly this: ``` private void InvokeHelper(Delegate method, params object[] args) { bool retry = false; do { try { metho...
First off, your signature is ``` private void InvokeHelper(Delegate method, params object[] args) ``` Yet you're making the mistake that you have to group your args into an array to call this method: ``` InvokeHelper(foo.MethodA, new object[] { a, b, c}); ``` The `parms` keyword tells the compiler to do this for...
349,953
<p>I am converting a linux script from <a href="http://www.perlmonks.org/index.pl?node_id=217166" rel="nofollow noreferrer">http://www.perlmonks.org/index.pl?node_id=217166</a> specifically this:</p> <pre><code>#!/usr/bin/perl -w use strict; use Getopt::Std; use File::Find; @ARGV &gt; 0 and getopts('a:', \my %opt) or...
[ { "answer_id": 349992, "author": "Powerlord", "author_id": 15880, "author_profile": "https://Stackoverflow.com/users/15880", "pm_score": 3, "selected": false, "text": "<p>Just a few notes:</p>\n\n<ol>\n<li>You don't need to flip the / to an \\. Perl understands that / is a directory sep...
2008/12/08
[ "https://Stackoverflow.com/questions/349953", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38211/" ]
I am converting a linux script from <http://www.perlmonks.org/index.pl?node_id=217166> specifically this: ``` #!/usr/bin/perl -w use strict; use Getopt::Std; use File::Find; @ARGV > 0 and getopts('a:', \my %opt) or die << "USAGE"; # Deletes any old files from the directory tree(s) given and # removes empty directorie...
From this [documentation](http://perl.active-venture.com/lib/File/Find.html) > > postprocess > > > The value should be a code reference. **It is invoked just before > leaving the currently processed > directory**. It is called in void > context with no arguments. The name of > the current directory is in > $Fi...
349,957
<p>I'm having an issue with an ObservableCollection getting new items but not reflecting those changes in a ListView. I have enough quirks in the way I'm implementing this that I'm having a hard time determining what the problem is.</p> <p>My ObservableCollection is implemented thusly:</p> <pre><code>public class Me...
[ { "answer_id": 352879, "author": "Sailing Judo", "author_id": 42620, "author_profile": "https://Stackoverflow.com/users/42620", "pm_score": 3, "selected": true, "text": "<p>I resolved this issue.</p>\n\n<p>Neither the static property or the context of the incoming data had anything to do...
2008/12/08
[ "https://Stackoverflow.com/questions/349957", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42620/" ]
I'm having an issue with an ObservableCollection getting new items but not reflecting those changes in a ListView. I have enough quirks in the way I'm implementing this that I'm having a hard time determining what the problem is. My ObservableCollection is implemented thusly: ``` public class MessageList : Observable...
I resolved this issue. Neither the static property or the context of the incoming data had anything to do with the issue (which seems obvious in hindsight). The XAML which was generated from Expression Blend was not up to the task for some reason. All I did to get this to work was assign the ItemSource to the collect...
349,980
<p>I need to format an integer representation of bytes into something friendly, and I'm hoping that there's a utility function in Ruby or in Rails that will do that formatting for me (to perpetuate my laziness, of course.)</p> <p>I'm looking for something that would look like:</p> <pre><code>format_bytes(1024) -&...
[ { "answer_id": 350083, "author": "mwilliams", "author_id": 23909, "author_profile": "https://Stackoverflow.com/users/23909", "pm_score": 6, "selected": true, "text": "<p><a href=\"http://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html\" rel=\"noreferrer\">Number to human...
2008/12/08
[ "https://Stackoverflow.com/questions/349980", "https://Stackoverflow.com", "https://Stackoverflow.com/users/650/" ]
I need to format an integer representation of bytes into something friendly, and I'm hoping that there's a utility function in Ruby or in Rails that will do that formatting for me (to perpetuate my laziness, of course.) I'm looking for something that would look like: ``` format_bytes(1024) -> "1 KB" format_bytes(...
[Number to human size](http://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html) is what you're looking for. ``` require 'action_view' include ActionView::Helpers::NumberHelper number_to_human_size(123) # => 123 Bytes number_to_human_size(1234) ...
349,997
<pre><code>$pee = preg_replace( '|&lt;p&gt;|', "$1&lt;p&gt;", $pee ); </code></pre> <p>This regular expression is from the Wordpress source code (formatting.php, wpautop function); I'm not sure what it does, can anyone help?</p> <p>Actually I'm trying to port this function to Python...if anyone knows of an existing p...
[ { "answer_id": 350026, "author": "Powerlord", "author_id": 15880, "author_profile": "https://Stackoverflow.com/users/15880", "pm_score": 2, "selected": false, "text": "<p>...?</p>\n\n<p>Actually, it looks like this takes the first <code>&lt;p&gt;</code> tag and prepends the previous regu...
2008/12/08
[ "https://Stackoverflow.com/questions/349997", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18494/" ]
``` $pee = preg_replace( '|<p>|', "$1<p>", $pee ); ``` This regular expression is from the Wordpress source code (formatting.php, wpautop function); I'm not sure what it does, can anyone help? Actually I'm trying to port this function to Python...if anyone knows of an existing port already, that would be much better...
wordpress really calls a variable "pee" ? I'm not sure what the $1 stands for (there are no braces in the first parameter?), so I don't think it actually does anything, but i could be wrong.
350,018
<p>What is the best way to combine both hashes into %hash1? I always know that %hash2 and %hash1 always have unique keys. I would also prefer a single line of code if possible. </p> <pre><code>$hash1{'1'} = 'red'; $hash1{'2'} = 'blue'; $hash2{'3'} = 'green'; $hash2{'4'} = 'yellow'; </code></pre>
[ { "answer_id": 350038, "author": "dreftymac", "author_id": 42223, "author_profile": "https://Stackoverflow.com/users/42223", "pm_score": 9, "selected": true, "text": "<h2>Quick Answer (TL;DR)</h2>\n<pre>\n\n %hash1 = (%hash1, %hash2)\n\n ## or else ...\n\n @hash1{keys %hash2} = ...
2008/12/08
[ "https://Stackoverflow.com/questions/350018", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2356/" ]
What is the best way to combine both hashes into %hash1? I always know that %hash2 and %hash1 always have unique keys. I would also prefer a single line of code if possible. ``` $hash1{'1'} = 'red'; $hash1{'2'} = 'blue'; $hash2{'3'} = 'green'; $hash2{'4'} = 'yellow'; ```
Quick Answer (TL;DR) -------------------- ``` %hash1 = (%hash1, %hash2) ## or else ... @hash1{keys %hash2} = values %hash2; ## or with references ... $hash_ref1 = { %$hash_ref1, %$hash_ref2 }; ``` Overview -------- * **Context:** Perl 5.x * **Problem:** The user wishes to merge two hashes1 ...
350,027
<p>I'm trying to set a WPF image's source in code. The image is embedded as a resource in the project. By looking at examples I've come up with the below code. For some reason it doesn't work - the image does not show up. </p> <p>By debugging I can see that the stream contains the image data. So what's wrong?</p> <pr...
[ { "answer_id": 350059, "author": "Arcturus", "author_id": 900, "author_profile": "https://Stackoverflow.com/users/900", "pm_score": 3, "selected": false, "text": "<p>Put the frame in a VisualBrush:</p>\n\n<pre><code>VisualBrush brush = new VisualBrush { TileMode = TileMode.None };\n\nbru...
2008/12/08
[ "https://Stackoverflow.com/questions/350027", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22621/" ]
I'm trying to set a WPF image's source in code. The image is embedded as a resource in the project. By looking at examples I've come up with the below code. For some reason it doesn't work - the image does not show up. By debugging I can see that the stream contains the image data. So what's wrong? ``` Assembly asm ...
After having the same problem as you and doing some reading, I discovered the solution - [Pack URIs](http://msdn.microsoft.com/en-us/library/aa970069.aspx). I did the following in code: ``` Image finalImage = new Image(); finalImage.Width = 80; ... BitmapImage logo = new BitmapImage(); logo.BeginInit(); logo.UriSourc...
350,047
<p>I would like to run a job through cron that will be executed every second Tuesday at given time of day. For every Tuesday is easy:</p> <pre><code>0 6 * * Tue </code></pre> <p>But how to make it on "every second Tuesday" (or if you prefer - every second week)? I would not like to implement any logic in the script i...
[ { "answer_id": 350061, "author": "xahtep", "author_id": 42184, "author_profile": "https://Stackoverflow.com/users/42184", "pm_score": 7, "selected": true, "text": "<p>How about this, it does keep it in the <code>crontab</code> even if it isn't exactly defined in the first five fields:</p...
2008/12/08
[ "https://Stackoverflow.com/questions/350047", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42201/" ]
I would like to run a job through cron that will be executed every second Tuesday at given time of day. For every Tuesday is easy: ``` 0 6 * * Tue ``` But how to make it on "every second Tuesday" (or if you prefer - every second week)? I would not like to implement any logic in the script it self, but keep the defin...
How about this, it does keep it in the `crontab` even if it isn't exactly defined in the first five fields: ``` 0 6 * * Tue expr `date +\%W` \% 2 > /dev/null || /scripts/fortnightly.sh ```
350,081
<p>In the application I'm working on porting to the web, we currently dynamically access different tables at runtime from run to run, based on a "template" string that is specified. I would like to move the burden of doing that back to the database now that we are moving to SQL server, so I don't have to mess with a dy...
[ { "answer_id": 350106, "author": "NotMe", "author_id": 2424, "author_profile": "https://Stackoverflow.com/users/2424", "pm_score": 2, "selected": false, "text": "<p>The only way to do this is with the exec command. </p>\n\n<p>Also, you have to move it out to a stored proc instead of a f...
2008/12/08
[ "https://Stackoverflow.com/questions/350081", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26140/" ]
In the application I'm working on porting to the web, we currently dynamically access different tables at runtime from run to run, based on a "template" string that is specified. I would like to move the burden of doing that back to the database now that we are moving to SQL server, so I don't have to mess with a dynam...
``` CREATE PROCEDURE TemplateSelector ( @template varchar(40), @code varchar(80) ) AS EXEC('SELECT * FROM ' + @template + ' WHERE ProductionCode = ' + @code) ``` This works, though it's not a UDF.
350,095
<p>Is there a way to programmatically, through a batch file (or powershell script), put all folders in <code>c:\Program Files</code> into the system variable <code>PATH</code>? I'm dependent on the command line and really want to just start a program from the command line.</p> <p>Yes, I'm jealous of Linux shells.</p>
[ { "answer_id": 350121, "author": "Greg Hurlman", "author_id": 35, "author_profile": "https://Stackoverflow.com/users/35", "pm_score": 3, "selected": false, "text": "<p>Passing in \"C:\\Program Files\" as a parameter into this batch file:</p>\n\n<pre><code>@echo off\n\nFOR /D %%G IN (%1\\...
2008/12/08
[ "https://Stackoverflow.com/questions/350095", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Is there a way to programmatically, through a batch file (or powershell script), put all folders in `c:\Program Files` into the system variable `PATH`? I'm dependent on the command line and really want to just start a program from the command line. Yes, I'm jealous of Linux shells.
Passing in "C:\Program Files" as a parameter into this batch file: ``` @echo off FOR /D %%G IN (%1\*) DO PATH "%%G";%path% ```
350,120
<p>Does someone knows if it's possible to dynamically create a call chain and invoke it?</p> <p>Lets say I have two classes A &amp; B:</p> <pre><code>public class A public function Func() as B return new B() end function end class public class B public function Name() as string return "a str...
[ { "answer_id": 350178, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": true, "text": "<p>Are you using .NET 3.5? If so, it should be relatively straightforward to build an expression tree to represent this. ...
2008/12/08
[ "https://Stackoverflow.com/questions/350120", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11361/" ]
Does someone knows if it's possible to dynamically create a call chain and invoke it? Lets say I have two classes A & B: ``` public class A public function Func() as B return new B() end function end class public class B public function Name() as string return "a string"; end function end...
Are you using .NET 3.5? If so, it should be relatively straightforward to build an expression tree to represent this. I don't have enough expression-tree-fu to easily write the relevant tree without VS open, but if you confirm that it's an option, I'll get to work in notepad (from my Eee... hence the lack of VS). EDIT...
350,124
<p>I'm looking to write an automated monitor script to programmatically retrieve information from another user's Exchange 2003 inbox. I have working C++ code to log into MAPI and connect to my own inbox. I can also use the Control Panel->Mail applet to configure another user's mailbox into my profile, and my code can...
[ { "answer_id": 350356, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>Have you looked into ConfigureMsgService? I believe that works with Exchange MAPI, or are you saying you tried that and it...
2008/12/08
[ "https://Stackoverflow.com/questions/350124", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3347/" ]
I'm looking to write an automated monitor script to programmatically retrieve information from another user's Exchange 2003 inbox. I have working C++ code to log into MAPI and connect to my own inbox. I can also use the Control Panel->Mail applet to configure another user's mailbox into my profile, and my code can acce...
I see... I'm not sure how to do that explicitly; that's usually a side effect of calling `CreateStoreEntryID` with the wrong flags. What's you're looking to do is probably: 1. Get an `IID_IExchangeManageStore` from your default message store 2. Call `CreateStoreEntryID` 3. Then open that store by the entry ID ``` LPE...
350,126
<p>I am trying to write a textbox that will search on 5 DB columns and will return every result of a given search, ex. "Red" would return: red ball, Red Williams, etc. Any examples or similar things people have tried. My example code for the search.</p> <p>Thanks.</p> <pre><code> ItemMasterDataContext db = new...
[ { "answer_id": 350189, "author": "James Curran", "author_id": 12725, "author_profile": "https://Stackoverflow.com/users/12725", "pm_score": 1, "selected": false, "text": "<p>\"q\" in your example will be an <code>IQueryable&lt;ITMST&gt;</code>. I don't think the Datasource property of W...
2008/12/08
[ "https://Stackoverflow.com/questions/350126", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37126/" ]
I am trying to write a textbox that will search on 5 DB columns and will return every result of a given search, ex. "Red" would return: red ball, Red Williams, etc. Any examples or similar things people have tried. My example code for the search. Thanks. ``` ItemMasterDataContext db = new ItemMasterDataContext();...
You can do something like this (syntax may be off ) ``` using(var db = new ItemMasterDataContext()) { var s = txtSearch.Text.Trim(); var result = from p in db.ITMSTs select p; if( result.Any(p=>p.IMITD1.Contains(s)) lv.DataSource = result.Where(p=>p.IMITD1.Contains(s)) else if ( result.Any(p=...
350,129
<p>How do I check to see if a particular value has already been assigned to Smarty and if not assign a (default) value?</p> <p>Answer:</p> <pre><code>if ($this-&gt;cismarty-&gt;get_template_vars('test') === null) { $this-&gt;cismarty-&gt;assign('test', 'Default value'); } </code></pre>
[ { "answer_id": 350162, "author": "Andy", "author_id": 26693, "author_profile": "https://Stackoverflow.com/users/26693", "pm_score": 5, "selected": true, "text": "<p><strong>Smarty 2</strong> </p>\n\n<pre><code>if ($smarty-&gt;get_template_vars('foo') === null) \n{\n $smarty-&gt;assign(...
2008/12/08
[ "https://Stackoverflow.com/questions/350129", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3238/" ]
How do I check to see if a particular value has already been assigned to Smarty and if not assign a (default) value? Answer: ``` if ($this->cismarty->get_template_vars('test') === null) { $this->cismarty->assign('test', 'Default value'); } ```
**Smarty 2** ``` if ($smarty->get_template_vars('foo') === null) { $smarty->assign('foo', 'some value'); } ``` **Smarty 3** ``` if ($smarty->getTemplateVars('foo') === null) { $smarty->assign('foo', 'some value'); } ``` Note that for **Smarty 3**, you will have to use `$smarty->getTemplateVars` instead.
350,140
<p>So I'm basically a beginner when it comes to Vim, nonetheless I do know the basic things (open files, edit, move around, basic grep, .vimrc, etc)</p> <p>I would submit this link first</p> <p><a href="http://weblog.jamisbuck.org/2008/11/17/vim-follow-up" rel="nofollow noreferrer">http://weblog.jamisbuck.org/2008/11...
[ { "answer_id": 350159, "author": "mat", "author_id": 42083, "author_profile": "https://Stackoverflow.com/users/42083", "pm_score": 4, "selected": true, "text": "<p>I'd say <code>:help leader</code> will give you what you need, is an anti-slash by default.</p>\n\n<p>Thus, <code>map &lt;l...
2008/12/08
[ "https://Stackoverflow.com/questions/350140", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44346/" ]
So I'm basically a beginner when it comes to Vim, nonetheless I do know the basic things (open files, edit, move around, basic grep, .vimrc, etc) I would submit this link first <http://weblog.jamisbuck.org/2008/11/17/vim-follow-up> If you scroll down to where it says "NERD\_\_\_tree", it explains what it is and give...
I'd say `:help leader` will give you what you need, is an anti-slash by default. Thus, `map <leader>d` will be launched when you do `\d`.
350,141
<p>In Unix/Linux, how do you find out what group a given user is in via command line?</p>
[ { "answer_id": 350144, "author": "Bombe", "author_id": 43582, "author_profile": "https://Stackoverflow.com/users/43582", "pm_score": 10, "selected": true, "text": "<pre><code>groups\n</code></pre>\n\n<p>or</p>\n\n<pre><code>groups user\n</code></pre>\n" }, { "answer_id": 350145, ...
2008/12/08
[ "https://Stackoverflow.com/questions/350141", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5885/" ]
In Unix/Linux, how do you find out what group a given user is in via command line?
``` groups ``` or ``` groups user ```
350,150
<p>I am trying to run some Perl CGI scripts under IIS. I get the following message :</p> <pre> <code> CGI Error The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are: perl: warning: Setting locale failed. perl: warning: Please check that your locale se...
[ { "answer_id": 350165, "author": "Leon Timmermans", "author_id": 4727, "author_profile": "https://Stackoverflow.com/users/4727", "pm_score": 0, "selected": false, "text": "<p>It seems your Perl application is sending it's errors to the browser, and an error happens before a header is sen...
2008/12/08
[ "https://Stackoverflow.com/questions/350150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35273/" ]
I am trying to run some Perl CGI scripts under IIS. I get the following message : ``` CGI Error The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are: perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LC_...
The LANG and LC\_ALL environment variables are set for your shell, but they aren't set for IIS. I'm not an IIS person, but the docs say that IIS is a service and you have to set those ahead of time then reboot. Alternatively, you can set these variables as soon your script starts to compile (and before you load your l...
350,202
<p>The following VBA code works great in Excel 2003, but results in a <em>Stack Overflow Error</em> in Excel 2007. The code is required to either unlock or lock certain cells based on a drop-down menu selection. I need to be able to run the code in both Excel 2003 and 2007. Please help.</p> <pre><code>Private Sub Wor...
[ { "answer_id": 350246, "author": "Joe", "author_id": 13087, "author_profile": "https://Stackoverflow.com/users/13087", "pm_score": 2, "selected": false, "text": "<p>The stack overflow almost certainly comes from recursion. Not sure why you aren't getting a stack overflow in Excel 2003 -...
2008/12/08
[ "https://Stackoverflow.com/questions/350202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
The following VBA code works great in Excel 2003, but results in a *Stack Overflow Error* in Excel 2007. The code is required to either unlock or lock certain cells based on a drop-down menu selection. I need to be able to run the code in both Excel 2003 and 2007. Please help. ``` Private Sub Worksheet_Change(ByVal Ta...
The stack overflow almost certainly comes from recursion. Not sure why you aren't getting a stack overflow in Excel 2003 - perhaps an error is being raised before the stack overflows. You can protect against infinite recursion something like the following: ``` Private m_bInChange As Boolean Private Sub Worksheet_Ch...
350,207
<p>I have an ASP.NET page that uses a menu based on <code>asp:LinkButton</code> control in a Master page. When a user selects a menu item, an <code>onclick</code> handler calls a method in my C# code. The method it calls just does a <code>Server.Transfer()</code> to a new page. From what I have read, this is not sup...
[ { "answer_id": 350216, "author": "JoshBerke", "author_id": 26160, "author_profile": "https://Stackoverflow.com/users/26160", "pm_score": 0, "selected": false, "text": "<p>Try <code>Server.Execute(\"Help.aspx\")</code> instead. You can preserve the form if you need by using </p>\n\n<pre><...
2008/12/08
[ "https://Stackoverflow.com/questions/350207", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16148/" ]
I have an ASP.NET page that uses a menu based on `asp:LinkButton` control in a Master page. When a user selects a menu item, an `onclick` handler calls a method in my C# code. The method it calls just does a `Server.Transfer()` to a new page. From what I have read, this is not supposed to change the URL displayed in th...
You can use iframes to make sure that URL of browser doesn't change. In Page\_Load you can change src attribute of iframe to help.aspx
350,214
<p>I have a ListBox whose ItemSource is an ObjectDataProvider that is an instance of an ObservableCollection. The ObservableCollection is a collection of ObservableCollections. The ItemTemplate of the ListBox is a DataTemplate that creates a ListBox for each item of the listbox. To illustrate this better I'm trying to ...
[ { "answer_id": 351392, "author": "Donnelle", "author_id": 28074, "author_profile": "https://Stackoverflow.com/users/28074", "pm_score": 3, "selected": true, "text": "<p>With Card like the following:</p>\n\n<pre><code> public class Card\n{\n\n private string _name;\n\n public Card(s...
2008/12/08
[ "https://Stackoverflow.com/questions/350214", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42858/" ]
I have a ListBox whose ItemSource is an ObjectDataProvider that is an instance of an ObservableCollection. The ObservableCollection is a collection of ObservableCollections. The ItemTemplate of the ListBox is a DataTemplate that creates a ListBox for each item of the listbox. To illustrate this better I'm trying to rec...
With Card like the following: ``` public class Card { private string _name; public Card(string name) { _name = name; } public string Name { get { return _name; } set { _name = value; } } } ``` and Book like the following: ``` public class Book { private re...
350,227
<p>I've encountered a very strange bug in VBA and wondered if anyone could shed some light?</p> <p>I'm calling a worksheet function like this: </p> <pre><code>Dim lMyRow As Long lMyRow = WorksheetFunction.Match(vItemID, rngMyRange.Columns(1), 0) </code></pre> <p>This is intended to get the row of the item I pass in...
[ { "answer_id": 350351, "author": "Dirk Vollmar", "author_id": 40347, "author_profile": "https://Stackoverflow.com/users/40347", "pm_score": 0, "selected": false, "text": "<p>I cannot reproduce the problem with Excel 2007.</p>\n\n<p>This was the code I used:</p>\n\n<pre><code>Sub test()\n...
2008/12/08
[ "https://Stackoverflow.com/questions/350227", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4019/" ]
I've encountered a very strange bug in VBA and wondered if anyone could shed some light? I'm calling a worksheet function like this: ``` Dim lMyRow As Long lMyRow = WorksheetFunction.Match(vItemID, rngMyRange.Columns(1), 0) ``` This is intended to get the row of the item I pass in. Under certain circumstances (alt...
The only difference between the immediate window and normal code run is the scope. Code in the immediate window runs in the current application scope. If nothing is currently running this means a global scope. The code when put in a VBA function is restricted to the function scope. So my guess is that one of your vari...
350,240
<p>I am doing some float manipulation and end up with the following numbers:</p> <pre><code>-0.5 -0.4 -0.3000000000000000004 -0.2000000000000000004 -0.1000000000000000003 1.10E-16 0.1 0.2 0.30000000000000000004 0.4 0.5 </code></pre> <p>The algorithm is the following:</p> <pre><code>var inc:Number = nextMultiple(min,...
[ { "answer_id": 350252, "author": "brian d foy", "author_id": 2766176, "author_profile": "https://Stackoverflow.com/users/2766176", "pm_score": 2, "selected": false, "text": "<p>The limited floating point precision of binary numbers is your problem, as you recognize. One way around this i...
2008/12/08
[ "https://Stackoverflow.com/questions/350240", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32032/" ]
I am doing some float manipulation and end up with the following numbers: ``` -0.5 -0.4 -0.3000000000000000004 -0.2000000000000000004 -0.1000000000000000003 1.10E-16 0.1 0.2 0.30000000000000000004 0.4 0.5 ``` The algorithm is the following: ``` var inc:Number = nextMultiple(min, stepSize); trace(String(inc)); priv...
A language agnostic solution would be to store your numbers as an integer number of steps, given that you know your step size, instead of as floats. A non-language agnostic solution would be to find out what your language's implementation of [printf](http://www.cplusplus.com/reference/clibrary/cstdio/printf.html) is. ...
350,250
<p>I need a RegEx pattern for extracting all the properties of an image tag.</p> <p>As we all know, there are lots of malformed HTML out there, so the pattern has to cover those possibilities.</p> <p>I was looking at this solution <a href="https://stackoverflow.com/questions/138313/how-to-extract-img-src-title-and-al...
[ { "answer_id": 350270, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 3, "selected": false, "text": "<blockquote>\n <p>As we all know, there are lots of malformed HTML out there, so the pattern has to cover those possibili...
2008/12/08
[ "https://Stackoverflow.com/questions/350250", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41385/" ]
I need a RegEx pattern for extracting all the properties of an image tag. As we all know, there are lots of malformed HTML out there, so the pattern has to cover those possibilities. I was looking at this solution [https://stackoverflow.com/questions/138313/how-to-extract-img-src-title-and-alt-from-html-using-php](ht...
> > As we all know, there are lots of malformed HTML out there, so the pattern has to cover those possibilities. > > > It won't. Use a HTML parser if you have to parse "evil" (from an unknown source) HTML.