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
218,531
<p>I have a situation where I want to create a signature of a data structure:</p> <pre><code>my $signature = ds_to_sig( { foo =&gt; 'bar', baz =&gt; 'bundy', boing =&gt; undef, number =&gt; 1_234_567, } ); </code></pre> <p>The aim should be that if the data structure changes then so should the sig...
[ { "answer_id": 218549, "author": "Rik", "author_id": 5409, "author_profile": "https://Stackoverflow.com/users/5409", "pm_score": 0, "selected": false, "text": "<p>I think the word you're looking for is <a href=\"http://en.wikipedia.org/wiki/Hash_function\" rel=\"nofollow noreferrer\">\"h...
2008/10/20
[ "https://Stackoverflow.com/questions/218531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5349/" ]
I have a situation where I want to create a signature of a data structure: ``` my $signature = ds_to_sig( { foo => 'bar', baz => 'bundy', boing => undef, number => 1_234_567, } ); ``` The aim should be that if the data structure changes then so should the signature. Is there an established way t...
The best way to do this is to use a deep-structure serialization system like [Storable](http://search.cpan.org/~ams/Storable-2.18/Storable.pm). Two structures with the same data will produce the same blob of Storable output, so they can be compared. ``` #!/usr/bin/perl use strict; use warnings; use Storable ('freez...
218,535
<p>I have a database full of small HTML documents and I need to programmatically insert several into, say, a PDF document with <em>iText</em> or a Word document with <em>Aspose.Words</em>. I need to preserve any formatting within the HTML documents (within reason, honouring &lt;b&gt; tags is a must, CSS like &lt;span s...
[ { "answer_id": 218705, "author": "Diodeus - James MacFarlane", "author_id": 12579, "author_profile": "https://Stackoverflow.com/users/12579", "pm_score": 0, "selected": false, "text": "<p>Adobe Acrobat Pro allows you to grab sites via HTTP and does an excellent job of preserving the styl...
2008/10/20
[ "https://Stackoverflow.com/questions/218535", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29620/" ]
I have a database full of small HTML documents and I need to programmatically insert several into, say, a PDF document with *iText* or a Word document with *Aspose.Words*. I need to preserve any formatting within the HTML documents (within reason, honouring <b> tags is a must, CSS like <span style="blah"> is a nice-to-...
[HTMLparser](http://htmlparser.sourceforge.net/) is a good HTML parser. I have used this to parse HTML on one of my projects. You can write your own filters to parse the HTML for what you want, so the `<br>` tag shouldn't be difficult to parse out Yo can parse out CSS usin the [CssSelectorNodeFilter](http://htmlpa...
218,578
<p>I get the warning "childNodes is null or not an object' with different line numbers, depending on which version of the library I reference (I've tried about three different versions of 1.2.6). Consequently, I get jack for jQuery intellisense.</p> <p>I can hack this to get it to work, but I'd rather not as I don't ...
[ { "answer_id": 218678, "author": "Herb Caudill", "author_id": 239663, "author_profile": "https://Stackoverflow.com/users/239663", "pm_score": 2, "selected": true, "text": "<p>Have you tried adding a reference to the documentation-only file available here?\n<a href=\"http://blogs.ipona.co...
2008/10/20
[ "https://Stackoverflow.com/questions/218578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I get the warning "childNodes is null or not an object' with different line numbers, depending on which version of the library I reference (I've tried about three different versions of 1.2.6). Consequently, I get jack for jQuery intellisense. I can hack this to get it to work, but I'd rather not as I don't understand ...
Have you tried adding a reference to the documentation-only file available here? [jQuery IntelliSense in Visual Studio 2008](http://blogs.ipona.com/james/archive/2008/02/15/JQuery-IntelliSense-in-Visual-Studio-2008.aspx)
218,604
<p>For example, if I have a network spec like 172.20.10.0/24, "24" is the bitcount. What's the best way to convert that to a netmask like 0xffffff00 ?</p>
[ { "answer_id": 218620, "author": "Eric Hogue", "author_id": 4137, "author_profile": "https://Stackoverflow.com/users/4137", "pm_score": 2, "selected": false, "text": "<p>This is not a programming question, but in linux you can use whatmask. </p>\n\n<pre><code>whatmask 72.20.10.0/24\n</co...
2008/10/20
[ "https://Stackoverflow.com/questions/218604", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19655/" ]
For example, if I have a network spec like 172.20.10.0/24, "24" is the bitcount. What's the best way to convert that to a netmask like 0xffffff00 ?
Why waste time with subtraction or ternary statements? ``` int suffix = 24; int mask = 0xffffffff ^ 0xffffffff >> suffix; ``` If you know your integer is exactly 32 bits long then you only need to type 0xffffffff once. ``` int32_t mask = ~(0xffffffff >> suffix); ``` Both compile to the exact same assembly code.
218,608
<p>I need to do a few very simple URL manipulations in Java. Like get the value for a parameter in the query, or update it, ... I was expecting to find a simple utility class doing that in the commons-lang package, but no. I know it is a simple problem, but if there is something already written, why do it again ? Do yo...
[ { "answer_id": 218674, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 4, "selected": true, "text": "<p>I think what you want is called a query string parser instead of an url manipulator and here's one: <a href=\"http...
2008/10/20
[ "https://Stackoverflow.com/questions/218608", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23704/" ]
I need to do a few very simple URL manipulations in Java. Like get the value for a parameter in the query, or update it, ... I was expecting to find a simple utility class doing that in the commons-lang package, but no. I know it is a simple problem, but if there is something already written, why do it again ? Do you k...
I think what you want is called a query string parser instead of an url manipulator and here's one: <http://ostermiller.org/utils/CGIParser.java.html>
218,616
<p>Given the Python function:</p> <pre><code>def a_method(arg1, arg2): pass </code></pre> <p>How can I extract the number and names of the arguments. I.e., given that I have a reference to <code>func</code>, I want the <code>func.[something]</code> to return <code>("arg1", "arg2")</code>.</p> <p>The usage scenar...
[ { "answer_id": 218625, "author": "Jouni K. Seppänen", "author_id": 26575, "author_profile": "https://Stackoverflow.com/users/26575", "pm_score": 7, "selected": false, "text": "<p>In CPython, the number of arguments is</p>\n\n<pre><code>a_method.func_code.co_argcount\n</code></pre>\n\n<p>...
2008/10/20
[ "https://Stackoverflow.com/questions/218616", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3355/" ]
Given the Python function: ``` def a_method(arg1, arg2): pass ``` How can I extract the number and names of the arguments. I.e., given that I have a reference to `func`, I want the `func.[something]` to return `("arg1", "arg2")`. The usage scenario for this is that I have a decorator, and I wish to use the meth...
Take a look at the [`inspect`](http://docs.python.org/library/inspect.html) module - this will do the inspection of the various code object properties for you. ``` >>> inspect.getfullargspec(a_method) (['arg1', 'arg2'], None, None, None) ``` The other results are the name of the \*args and \*\*kwargs variables, and ...
218,638
<p>Using the ClearCase find command, how do I find all files in a directory that do not have the name pom.xml? </p> <p>I'd like to pass other selection options to the ClearCase find command so I'd prefer not to execute another command.</p> <p>I am using a RedHat linux version of ClearCase. I have tried "cleartool f...
[ { "answer_id": 218976, "author": "Dmitry Khalatov", "author_id": 18174, "author_profile": "https://Stackoverflow.com/users/18174", "pm_score": 2, "selected": false, "text": "<p>ClearCase wildcards doesn't have inversion (AFAIR) but you can use grep for this - </p>\n\n<pre><code>cleartool...
2008/10/20
[ "https://Stackoverflow.com/questions/218638", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4476/" ]
Using the ClearCase find command, how do I find all files in a directory that do not have the name pom.xml? I'd like to pass other selection options to the ClearCase find command so I'd prefer not to execute another command. I am using a RedHat linux version of ClearCase. I have tried "cleartool find ! -name pom.xml...
You seem to forget the ***-exec*** option of the cleartool find command. It actually does allow you to execute other commands than cleartool ones, including system ones (like a sh or DOS script). I know you would "prefer not to execute another command", but if that other system script is part of the exec option of ...
218,663
<p>I work for a custom cabinetry manufacturer and we write our own pricing program for our product. I have a form that has a pop-up box so the user can select which side the hinge will be on for ambiguous doors on that cabinet. I've got that to work so far, but when they copy an item and paste it at the bottom I don'...
[ { "answer_id": 218783, "author": "Fionnuala", "author_id": 2548, "author_profile": "https://Stackoverflow.com/users/2548", "pm_score": 2, "selected": false, "text": "<p>Perhaps something on the lines of this would suit.</p>\n\n<pre><code>Option Compare Database\nPublic gvarPasted As Bool...
2008/10/20
[ "https://Stackoverflow.com/questions/218663", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4549/" ]
I work for a custom cabinetry manufacturer and we write our own pricing program for our product. I have a form that has a pop-up box so the user can select which side the hinge will be on for ambiguous doors on that cabinet. I've got that to work so far, but when they copy an item and paste it at the bottom I don't wan...
You can customize the menu, for example if you add code like so to a standard module: ``` Public gvarPasted As Boolean Function AssignVar() gvarPasted = True DoCmd.RunCommand acCmdPaste End Function ``` You can set the Action property of Paste on the menu to this function using the customize option of the t...
218,681
<p>The following code snippet illustrates a memory leak when opening XPS files. If you run it and watch the task manager, it will grow and not release memory until the app exits.</p> <p>'****** Console application BEGINS.</p> <pre><code>Module Main Const DefaultTestFilePath As String = "D:\Test.xps" Const De...
[ { "answer_id": 218776, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 0, "selected": false, "text": "<p>I can't give you any authoritative advice, but I did have a few thoughts:</p>\n\n<ul>\n<li>If you want to watch you...
2008/10/20
[ "https://Stackoverflow.com/questions/218681", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26221/" ]
The following code snippet illustrates a memory leak when opening XPS files. If you run it and watch the task manager, it will grow and not release memory until the app exits. '\*\*\*\*\*\* Console application BEGINS. ``` Module Main Const DefaultTestFilePath As String = "D:\Test.xps" Const DefaultLoopRuns A...
Well, I found it. It IS a bug in the framework and to work around it you add a call to UpdateLayout. Using statement can be changed to the following to provide a fix; ``` Using XPSItem As New Windows.Xps.Packaging.XpsDocument(PathToTestXps, System.IO.FileAccess.Read) Dim FixedDocSequence As Windows...
218,691
<p>Is there a way to temporary swap Flex's main application to another then switch back. Scenario : Main app started, display login box - then go on with main app. Login box is an application as well. </p> <p>Application.application is a read only property, that attempt failed.</p>
[ { "answer_id": 219404, "author": "mmattax", "author_id": 1638, "author_profile": "https://Stackoverflow.com/users/1638", "pm_score": 1, "selected": false, "text": "<p>Is there a reason why you cannot make the login box a component and then perhaps use a ViewStack to control the viewable ...
2008/10/20
[ "https://Stackoverflow.com/questions/218691", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Is there a way to temporary swap Flex's main application to another then switch back. Scenario : Main app started, display login box - then go on with main app. Login box is an application as well. Application.application is a read only property, that attempt failed.
I've had great success with a modular application whereby the main application basically consists of a module loader, that initially loads a logon module. Once the logon module has done it's stuff (in my case validated inputs, called the logon service and retrieved a token), it dispatches an event (imaginatively calle...
218,696
<p>Is there a generic way to clone objects in VBA? So that i could copy x to y instead of copying just the pointer?</p> <pre><code> Dim x As New Class1 Dim y As Class1 x.Color = 1 x.Height = 1 Set y = x y.Color = 2 Debug.Print "x.Color=" &amp; x.Color &amp; ", x.Height=" &amp; x.Height </code></pre> <...
[ { "answer_id": 219123, "author": "Mike Woodhouse", "author_id": 1060, "author_profile": "https://Stackoverflow.com/users/1060", "pm_score": 2, "selected": false, "text": "<p>I don't think there's anything built in, although it would be nice.</p>\n\n<p>I think there should at least be a w...
2008/10/20
[ "https://Stackoverflow.com/questions/218696", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4134/" ]
Is there a generic way to clone objects in VBA? So that i could copy x to y instead of copying just the pointer? ``` Dim x As New Class1 Dim y As Class1 x.Color = 1 x.Height = 1 Set y = x y.Color = 2 Debug.Print "x.Color=" & x.Color & ", x.Height=" & x.Height ``` By generic i mean something like `Se...
OK, here's the beginning of something that illustrates it: Create a class, call it, oh, "Class1": ``` Option Explicit Public prop1 As Long Private DontCloneThis As Variant Public Property Get PrivateThing() PrivateThing = DontCloneThis End Property Public Property Let PrivateThing(value) DontCloneThis = va...
218,733
<p>I have a <code>GridView</code> control in an Asp.net application, that has a <code>&lt;asp:buttonField&gt;</code> of <code>type="image"</code> and <code>CommandName="Delete"</code>.</p> <p>Is there any way to execute a piece of javascript before reaching the <code>OnRowDelete</code> event?</p> <p>I want just a sim...
[ { "answer_id": 218785, "author": "steve_c", "author_id": 769, "author_profile": "https://Stackoverflow.com/users/769", "pm_score": 6, "selected": true, "text": "<p>I would use a TemplateField instead, and populate the ItemTemplate with a regular asp:Button or asp:ImageButton, depending o...
2008/10/20
[ "https://Stackoverflow.com/questions/218733", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7595/" ]
I have a `GridView` control in an Asp.net application, that has a `<asp:buttonField>` of `type="image"` and `CommandName="Delete"`. Is there any way to execute a piece of javascript before reaching the `OnRowDelete` event? I want just a simple confirm before deleting the row. Thanks! **EDIT**: Please Note that `<as...
I would use a TemplateField instead, and populate the ItemTemplate with a regular asp:Button or asp:ImageButton, depending one what is needed. You can then execute the same logic that the RowCommand event was going to do when it intercepted the Delete command. On either of those buttons I would then use the OnClientCl...
218,760
<p>Although elements like <code>&lt;div&gt;</code>s normally grow to fit their contents, using the <code>float</code> property can cause a startling problem for CSS newbies: <strong>If floated elements have non-floated parent elements, the parent will collapse.</strong></p> <p>For example:</p> <p><div class="snippet" d...
[ { "answer_id": 218799, "author": "Bobby Jack", "author_id": 5058, "author_profile": "https://Stackoverflow.com/users/5058", "pm_score": 6, "selected": false, "text": "<p>I usually use the <code>overflow: auto</code> trick; although that's not, strictly speaking, the intended use for over...
2008/10/20
[ "https://Stackoverflow.com/questions/218760", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4376/" ]
Although elements like `<div>`s normally grow to fit their contents, using the `float` property can cause a startling problem for CSS newbies: **If floated elements have non-floated parent elements, the parent will collapse.** For example: ```html <div> <div style="float: left;">Div 1</div> <div style="float: lef...
Solution 1: ----------- The most reliable and unobtrusive method appears to be this: Demo: <http://jsfiddle.net/SO_AMK/wXaEH/> **HTML**: ``` <div class="clearfix"> <div style="float: left;">Div 1</div> <div style="float: left;">Div 2</div> </div>​ ``` **CSS**: ``` .clearfix::after { content: " "; ...
218,777
<p>Is it right to use a private constant in the following situation:</p> <p>Say I have a game with a lives variable and a startingLives variable. At the start of the game I set the lives variable to equal the startingLives variable. This is how I would normally do it:</p> <pre><code>private var lives:int = 0; private...
[ { "answer_id": 218782, "author": "ine", "author_id": 4965, "author_profile": "https://Stackoverflow.com/users/4965", "pm_score": 3, "selected": true, "text": "<p>Put it in a constant named <code>DEFAULT_STARTING_LIVES</code>, but also have a variable named startingLives. For now, set sta...
2008/10/20
[ "https://Stackoverflow.com/questions/218777", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11911/" ]
Is it right to use a private constant in the following situation: Say I have a game with a lives variable and a startingLives variable. At the start of the game I set the lives variable to equal the startingLives variable. This is how I would normally do it: ``` private var lives:int = 0; private var startingLives:in...
Put it in a constant named `DEFAULT_STARTING_LIVES`, but also have a variable named startingLives. For now, set startingLives = `DEFAULT_STARTING_LIVES`. Later, you can set startingLives based on a value from a configuration file. If the file has not been created or is not found, you have a back up. (thanks to Plinth ...
218,781
<p>Been having a "heated debate" with a colleague about his practice of wrapping most of his functions in a try/catch but the catch has JUST a "throw" in it e.g.</p> <pre><code>Private sub foo() try 'Do something' catch throw 'And nothing else!' End Try End Sub </code></pre> <p>My thought ...
[ { "answer_id": 218791, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 5, "selected": true, "text": "<p>The reason you have a lone throw inside a catch rather than throwing a new exception is because this causes the orig...
2008/10/20
[ "https://Stackoverflow.com/questions/218781", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20151/" ]
Been having a "heated debate" with a colleague about his practice of wrapping most of his functions in a try/catch but the catch has JUST a "throw" in it e.g. ``` Private sub foo() try 'Do something' catch throw 'And nothing else!' End Try End Sub ``` My thought was to not even bother (as...
The reason you have a lone throw inside a catch rather than throwing a new exception is because this causes the original stack trace/exception data to be preserved. And one reason you might do this is because you can now set a break-point there for debugging.
218,786
<p>I keep on hearing about concurrent programing every where. Can you guys throw some light on what it's and how c++ new standards facilitate doing the same?</p>
[ { "answer_id": 218797, "author": "Paul Nathan", "author_id": 26227, "author_profile": "https://Stackoverflow.com/users/26227", "pm_score": 3, "selected": false, "text": "<p>Concurrency is having multiple threads of execution for a given process. As of today, C++ does not directly support...
2008/10/20
[ "https://Stackoverflow.com/questions/218786", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22076/" ]
I keep on hearing about concurrent programing every where. Can you guys throw some light on what it's and how c++ new standards facilitate doing the same?
Concurrency is about your code doing multiple things at the same time. This is typically done with explicit "threads", but there are other possibilities. For example, if you use OpenMP directives in your code then a compiler that supports OpenMP will automatically generate threads for you. Thread is short for "thread ...
218,794
<p>I have a form that uses jQuery to submit an ajax post and it serializes the form that is sent up. The code looks like this:</p> <pre><code>var form = $("form"); var action = form.attr("action"); var serializedForm = form.serialize(); $.post(action, serializedForm, function(data) { ... }); </code></pre> <p>The pr...
[ { "answer_id": 219013, "author": "micahwittman", "author_id": 11181, "author_profile": "https://Stackoverflow.com/users/11181", "pm_score": 3, "selected": false, "text": "<p>Trim all <strong>&lt;input&gt;</strong> and <strong>&lt;textarea&gt;&lt;/textarea&gt;</strong> element values in t...
2008/10/20
[ "https://Stackoverflow.com/questions/218794", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24841/" ]
I have a form that uses jQuery to submit an ajax post and it serializes the form that is sent up. The code looks like this: ``` var form = $("form"); var action = form.attr("action"); var serializedForm = form.serialize(); $.post(action, serializedForm, function(data) { ... }); ``` The problem here is that if a fi...
You could try looping through the object and triming everything. ``` //Serialize form as array var serializedForm = form.serializeArray(); //trim values for(var i =0, len = serializedForm.length;i<len;i++){ serializedForm[i] = $.trim(serializedForm[i]); } //turn it into a string if you wish serializedForm = $.param(...
218,798
<p>The output of my JSON call can either be an Array or a Hash. How do I distinguish between these two?</p>
[ { "answer_id": 218833, "author": "Borgar", "author_id": 27388, "author_profile": "https://Stackoverflow.com/users/27388", "pm_score": 5, "selected": false, "text": "<p>Is object: </p>\n\n<pre><code>function isObject ( obj ) {\n return obj &amp;&amp; (typeof obj === \"object\");\n}\n</...
2008/10/20
[ "https://Stackoverflow.com/questions/218798", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29653/" ]
The output of my JSON call can either be an Array or a Hash. How do I distinguish between these two?
**Modern browsers support the `Array.isArray(obj)` method.** [See MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray) for documentation and a polyfill. = *original answer from 2008* = you can use the constuctor property of your output: ``` if(output.constructor == A...
218,806
<p>I am wondering how the JBoss ExceptionSorter classes are able to check for database errors.</p> <p>The application (the EJB or persistence framework) is holding the reference to the database Connection, so SQLExceptions are caught by the application. How is JBoss able to see the contents of the exception?</p> <p>D...
[ { "answer_id": 360041, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>JBoss uses a connection pool for its datasources (org.jboss.resource.adapter.jdbc.local.LocalTxDataSource). The ExceptionSo...
2008/10/20
[ "https://Stackoverflow.com/questions/218806", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25688/" ]
I am wondering how the JBoss ExceptionSorter classes are able to check for database errors. The application (the EJB or persistence framework) is holding the reference to the database Connection, so SQLExceptions are caught by the application. How is JBoss able to see the contents of the exception? Does JBoss wrap th...
If you have ever run a debugger against code running inside JBoss, while that that has an open database connection, you will notice that the connection is actually a JBoss-specific class that wraps the real database connection. In some cases, you can see this wrapper as a line in the stack trace when an exception is t...
218,808
<p>I've got a <code>DateTime?</code> that I'm trying to insert into a field using a <code>DbParameter</code>. I'm creating the parameter like so:</p> <pre><code>DbParameter datePrm = updateStmt.CreateParameter(); datePrm.ParameterName = "@change_date"; </code></pre> <p>And then I want to put the value of the <code>Da...
[ { "answer_id": 218843, "author": "dnolan", "author_id": 29086, "author_profile": "https://Stackoverflow.com/users/29086", "pm_score": 3, "selected": false, "text": "<p>It would work if you used</p>\n\n<pre><code>datePrm.Value = nullableDate.HasValue ? (object)nullableDate.Value : DBNull....
2008/10/20
[ "https://Stackoverflow.com/questions/218808", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6408/" ]
I've got a `DateTime?` that I'm trying to insert into a field using a `DbParameter`. I'm creating the parameter like so: ``` DbParameter datePrm = updateStmt.CreateParameter(); datePrm.ParameterName = "@change_date"; ``` And then I want to put the value of the `DateTime?` into the `dataPrm.Value` while accounting fo...
Ah ha! I found an even more efficient solution than @Trebz's! ``` datePrm.Value = nullableDate ?? (object)DBNull.Value; ```
218,825
<p>I have three Java <code>JCheckboxes</code> in a column, arranged by setting the layout of the container <code>JPanel</code> to <code>GridLayout(3, 1, 1, 1)</code>. When I run the program, there is too much vertical space between the JCheckBoxes; it looks like more than 1 pixel. Since I've already set the vertical ...
[ { "answer_id": 219198, "author": "Alex B", "author_id": 6180, "author_profile": "https://Stackoverflow.com/users/6180", "pm_score": 2, "selected": false, "text": "<p>I explored using <code>GridLayout</code>, <code>BorderLayout</code>, and <code>GridBagLayout</code> and I believe that any...
2008/10/20
[ "https://Stackoverflow.com/questions/218825", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have three Java `JCheckboxes` in a column, arranged by setting the layout of the container `JPanel` to `GridLayout(3, 1, 1, 1)`. When I run the program, there is too much vertical space between the JCheckBoxes; it looks like more than 1 pixel. Since I've already set the vertical space between the JCheckboxes in the l...
I explored using `GridLayout`, `BorderLayout`, and `GridBagLayout` and I believe that any extra vertical space that is present in your application is due to the sizing of the JCheckBox component, not related to the layout manager. All of the examples below have no space between components in the layout manager. **Gri...
218,848
<p>I need to give users the ability to optionally add metadata to documents. Another way to state this is the fact that users need to add at least 5 categories to a document.</p> <p>Basically what I want to do is dynamically add metadata (or categories) to a document on an ad hoc basis. Here are the options that I hav...
[ { "answer_id": 218872, "author": "Adam Davis", "author_id": 2915, "author_profile": "https://Stackoverflow.com/users/2915", "pm_score": 3, "selected": false, "text": "<p>Each document has a unique DocumentID.</p>\n\n<p>Just add another table that has three columns:</p>\n\n<pre>DocumentID...
2008/10/20
[ "https://Stackoverflow.com/questions/218848", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29441/" ]
I need to give users the ability to optionally add metadata to documents. Another way to state this is the fact that users need to add at least 5 categories to a document. Basically what I want to do is dynamically add metadata (or categories) to a document on an ad hoc basis. Here are the options that I have thought ...
Each document has a unique DocumentID. Just add another table that has three columns: ``` DocumentID MetaName MetaData ``` Then they can add as many pieces of metadata to a given document. If all their documents use the same metanames then it's trivial to search the metadata. -Adam
218,857
<p>I have a class that contains a bunch of properties. It is a mistake by a programmer if they call ToString() on an object of that type. Take this example code:</p> <pre><code>using System; public class Foo { public int ID = 123; public string Name = "SomeName"; private string ToString() { return null; ...
[ { "answer_id": 218868, "author": "Sander", "author_id": 2928, "author_profile": "https://Stackoverflow.com/users/2928", "pm_score": 4, "selected": false, "text": "<p>The Obsolete attribute allows you to do this.</p>\n\n<pre><code>[Obsolete(\"Use the XYZ properties instead of .ToString() ...
2008/10/20
[ "https://Stackoverflow.com/questions/218857", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a class that contains a bunch of properties. It is a mistake by a programmer if they call ToString() on an object of that type. Take this example code: ``` using System; public class Foo { public int ID = 123; public string Name = "SomeName"; private string ToString() { return null; } } public cl...
**I cannot stress enough how bad an idea this design is.** `ToString()` is part of the object contract in .Net. If you don't want to implement it then don't override it, and just let it return the type info. What harm could that possible cause? I don't mean to be so negative, but I am absolutely floored that someone...
218,866
<p>I have data from MySQL showing all organisations a customer got, with all details of employess in each organisation. I want to list each organisation name only once i.e. in a single cell ( row span) and all employees in that organisation against this name like:</p> <pre><code>Org1 Emp1 Name, Emp1 Phone, Emp1 Ad...
[ { "answer_id": 218900, "author": "Veynom", "author_id": 11670, "author_profile": "https://Stackoverflow.com/users/11670", "pm_score": 3, "selected": true, "text": "<p>Classic.</p>\n\n<p>Workaround: only display the name if different than the previous one. You can even not bother about th...
2008/10/20
[ "https://Stackoverflow.com/questions/218866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29656/" ]
I have data from MySQL showing all organisations a customer got, with all details of employess in each organisation. I want to list each organisation name only once i.e. in a single cell ( row span) and all employees in that organisation against this name like: ``` Org1 Emp1 Name, Emp1 Phone, Emp1 Address ...
Classic. Workaround: only display the name if different than the previous one. You can even not bother about the rowspan (you keep an empty cell). ``` $currentOrg = ''; while ($row = mysql_fetch_object($query)) { if ($row->org != $currentOrg) { echo "$row->org". } $currentorg = $row->org; } ``` Not t...
218,888
<p>I have 3 classes that are essentially the same but don't implement an interface because they all come from different web services. </p> <p>e.g.</p> <ul> <li>Service1.Object1</li> <li>Service2.Object1</li> <li>Service3.Object1</li> </ul> <p>They all have the same properties and I am writing some code to map them t...
[ { "answer_id": 218930, "author": "Scott Dorman", "author_id": 1559, "author_profile": "https://Stackoverflow.com/users/1559", "pm_score": 1, "selected": false, "text": "<p>Constraining to a list of classes in an \"OR\" fashion like you want to do isn't possible in C#. (In fact, I'm not e...
2008/10/20
[ "https://Stackoverflow.com/questions/218888", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4950/" ]
I have 3 classes that are essentially the same but don't implement an interface because they all come from different web services. e.g. * Service1.Object1 * Service2.Object1 * Service3.Object1 They all have the same properties and I am writing some code to map them to each other using an intermediary object which i...
Assuming the generated classes are partial, you can create an interface and then add another partial source file to make your generated classes implement the interface. Then you can constrain by interface as normal. No changes to the actual generated code required :)
218,904
<p>I am using TortoiseSVN for my Subversion repository held on a USB drive. When I move from one PC to another, is there a way to automatically identify that files are out of date (without using the Check for Modifications menu). It would be nice just to be able to see that the folder on my hard drive did not match tha...
[ { "answer_id": 218913, "author": "Veynom", "author_id": 11670, "author_profile": "https://Stackoverflow.com/users/11670", "pm_score": 1, "selected": false, "text": "<p>Create a batch file which automatically update your local working copy when the USB key is connected.</p>\n" }, { ...
2008/10/20
[ "https://Stackoverflow.com/questions/218904", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21862/" ]
I am using TortoiseSVN for my Subversion repository held on a USB drive. When I move from one PC to another, is there a way to automatically identify that files are out of date (without using the Check for Modifications menu). It would be nice just to be able to see that the folder on my hard drive did not match that o...
Try creating a file called ["autorun.inf"](http://dailycupoftech.com/usb-drive-autoruninf-tweaking/) in the root directory of your USB key. Then fill it with the following lines: ``` [autorun] open=CheckForMods.bat ``` Then create a `CheckForMods.bat` batch file in the root directory that does an `svn status -u`.
218,908
<p>Is there a best way to turn an integer into its month name in .net?</p> <p>Obviously I can spin up a datetime to string it and parse the month name out of there. That just seems like a gigantic waste of time.</p>
[ { "answer_id": 218927, "author": "leppie", "author_id": 15541, "author_profile": "https://Stackoverflow.com/users/15541", "pm_score": 4, "selected": false, "text": "<p>Why not just use <code>somedatetime.ToString(\"MMMM\")</code>?</p>\n" }, { "answer_id": 218947, "author": "T...
2008/10/20
[ "https://Stackoverflow.com/questions/218908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1220/" ]
Is there a best way to turn an integer into its month name in .net? Obviously I can spin up a datetime to string it and parse the month name out of there. That just seems like a gigantic waste of time.
Try GetMonthName from DateTimeFormatInfo <http://msdn.microsoft.com/en-us/library/system.globalization.datetimeformatinfo.getmonthname.aspx> You can do it by: ``` CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(1); ```
218,909
<p><strong>EDIT:</strong> See <a href="https://stackoverflow.com/questions/218909/returning-a-pdf-file-from-a-java-bean-to-a-jsp#221252">my working code</a> in the answers below.</p> <hr> <p><strong>In brief:</strong> I have a JSP file which calls a method in a Java Bean. This method creates a PDF file and in theory,...
[ { "answer_id": 218942, "author": "matt b", "author_id": 4249, "author_profile": "https://Stackoverflow.com/users/4249", "pm_score": 2, "selected": false, "text": "<p>Just a guess, but have you checked the MIME type that your JSP page is returning?</p>\n\n<p>edit: if I actually read the c...
2008/10/20
[ "https://Stackoverflow.com/questions/218909", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21709/" ]
**EDIT:** See [my working code](https://stackoverflow.com/questions/218909/returning-a-pdf-file-from-a-java-bean-to-a-jsp#221252) in the answers below. --- **In brief:** I have a JSP file which calls a method in a Java Bean. This method creates a PDF file and in theory, returns it to the JSP so that the user can down...
The way I have implemented this type of feature in the past is to make a servlet write the contents of the PDF file out to the response as a stream. I don't have the source code with me any longer (and it's been at least a year since I did any servlet/jsp work), but here is what you might want to try: In a servlet, ge...
218,912
<p>Is there a command like <code>cat</code> in linux which can return a specified quantity of characters from a file?</p> <p>e.g., I have a text file like:</p> <pre><code>Hello world this is the second line this is the third line </code></pre> <p>And I want something that would return the first 5 characters, which w...
[ { "answer_id": 218928, "author": "gimel", "author_id": 6491, "author_profile": "https://Stackoverflow.com/users/6491", "pm_score": 4, "selected": false, "text": "<p><a href=\"http://linux.die.net/man/1/head\" rel=\"noreferrer\">head</a>:</p>\n\n<h2>Name</h2>\n\n<p>head - output the first...
2008/10/20
[ "https://Stackoverflow.com/questions/218912", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2011/" ]
Is there a command like `cat` in linux which can return a specified quantity of characters from a file? e.g., I have a text file like: ``` Hello world this is the second line this is the third line ``` And I want something that would return the first 5 characters, which would be "hello". thanks
`head` works too: ``` head -c 100 file # returns the first 100 bytes in the file ``` ..will extract the first 100 bytes and return them. What's nice about using `head` for this is that the syntax for `tail` matches: ``` tail -c 100 file # returns the last 100 bytes in the file ``` You can combine these to get...
218,935
<p>I'm pretty sure one would do this using the os.plock(op) function, but I have no idea how. Also, if there's a better way, I'd be grateful to find out. Code snippets are very welcome. </p>
[ { "answer_id": 218943, "author": "Dan Lenski", "author_id": 20789, "author_profile": "https://Stackoverflow.com/users/20789", "pm_score": 3, "selected": false, "text": "<p>This is pretty much Python-independent! It's a classic example of Unix interprocess communication. One good option...
2008/10/20
[ "https://Stackoverflow.com/questions/218935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm pretty sure one would do this using the os.plock(op) function, but I have no idea how. Also, if there's a better way, I'd be grateful to find out. Code snippets are very welcome.
[Subprocess](http://docs.python.org/library/subprocess) replaces os.popen, os.system, os.spawn, popen2 and commands. A [simple example for piping](http://docs.python.org/library/subprocess#replacing-shell-pipe-line) would be: ``` p1 = Popen(["dmesg"], stdout=PIPE) p2 = Popen(["grep", "hda"], stdin=p1.stdout, stdout=PI...
218,969
<p>I have a problem perplexing me to no end. When I run the following query against an access database:</p> <pre><code>SELECT * FROM PreferredSpacer INNER JOIN SpacerThickness ON PreferredSpacer.SpacerTypeID = SpacerThickness.SpacerTypeID ORDER BY PreferredSpacer.UnitTypeID DESC </code></pre> <p>(UnitTypeID field i...
[ { "answer_id": 218995, "author": "Zebra North", "author_id": 17440, "author_profile": "https://Stackoverflow.com/users/17440", "pm_score": 0, "selected": false, "text": "<p>Does SpacerThickness have a UnitTypeID column? If so, the \"*\" in the select may mean that it's sorting on Prefer...
2008/10/20
[ "https://Stackoverflow.com/questions/218969", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17784/" ]
I have a problem perplexing me to no end. When I run the following query against an access database: ``` SELECT * FROM PreferredSpacer INNER JOIN SpacerThickness ON PreferredSpacer.SpacerTypeID = SpacerThickness.SpacerTypeID ORDER BY PreferredSpacer.UnitTypeID DESC ``` (UnitTypeID field is a text type) The results...
I figured it out. The tool our customer was using to generate the access DB in question was incorrectly turning varchar fields in SQL to memo fields in access (instead of text, as our tools do), and the memo field does not sort correctly. It seems odd to me that Access will just silently go along with it however, and n...
218,987
<p>I want to use Sharepoint with python (C-Python)</p> <p>Has anyone tried this before ?</p>
[ { "answer_id": 219175, "author": "Rob Windsor", "author_id": 28785, "author_profile": "https://Stackoverflow.com/users/28785", "pm_score": 2, "selected": false, "text": "<p>SharePoint exposes several web services which you can use to query and update data.</p>\n\n<p>I'm not sure what web...
2008/10/20
[ "https://Stackoverflow.com/questions/218987", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22176/" ]
I want to use Sharepoint with python (C-Python) Has anyone tried this before ?
I suspect that since this question was answered the SUDS library has been updated to take care of the required authentication itself. After jumping through various hoops, I found this to do the trick: ``` from suds import WebFault from suds.client import * from suds.transport.https import WindowsHttpAuthenticated us...
219,009
<p>If I view the HTML generated by one of my Jasper reports in IE7 I see the following: </p> <pre><code>&lt;BR /&gt;&lt;BR /&gt; &lt;A name="JR_PAGE_ANCHOR_0_1"&gt; &lt;TABLE style="WIDTH: 1000px" cellSpacing="0" cellPadding="0" bgColor="#ffffff" border="0"&gt; &lt;-- table body omitted --&gt; &lt;/TABLE&gt; </code></...
[ { "answer_id": 219119, "author": "PhiLho", "author_id": 15459, "author_profile": "https://Stackoverflow.com/users/15459", "pm_score": 1, "selected": false, "text": "<p>That's odd code, the <code>&lt;br /&gt;</code> tags are XHTML-style, while the unclosed <code>a</code> tags are good old...
2008/10/20
[ "https://Stackoverflow.com/questions/219009", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648/" ]
If I view the HTML generated by one of my Jasper reports in IE7 I see the following: ``` <BR /><BR /> <A name="JR_PAGE_ANCHOR_0_1"> <TABLE style="WIDTH: 1000px" cellSpacing="0" cellPadding="0" bgColor="#ffffff" border="0"> <-- table body omitted --> </TABLE> ``` The two BR tags are added via the JRHtmlExporterParam...
I took Phil's advice and dove into the Jasper source code. I've fixed the problem and submitted it to the project. Details of the cause and resolution are available [here](http://jasperforge.org/tracker/index.php?func=detail&aid=3180&group_id=102&atid=611&action=edit).
219,046
<p>I'm trying to construct a query that will include a column indicating whether or not a user has downloaded a document. I have a table called HasDownloaded with the following columns: id, documentID, memberID. Finding out whether a user has downloaded a <em>specific</em> document is easy; but I need to generate a que...
[ { "answer_id": 219053, "author": "matt b", "author_id": 4249, "author_profile": "https://Stackoverflow.com/users/4249", "pm_score": 6, "selected": true, "text": "<p>Move the condition in the WHERE clause to the join condition.</p>\n\n<pre><code>SELECT Documents.name, HasDownloaded.id FRO...
2008/10/20
[ "https://Stackoverflow.com/questions/219046", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4965/" ]
I'm trying to construct a query that will include a column indicating whether or not a user has downloaded a document. I have a table called HasDownloaded with the following columns: id, documentID, memberID. Finding out whether a user has downloaded a *specific* document is easy; but I need to generate a query where t...
Move the condition in the WHERE clause to the join condition. ``` SELECT Documents.name, HasDownloaded.id FROM Documents LEFT JOIN HasDownloaded ON HasDownloaded.documentID = Documents.id AND HasDownloaded.memberID = @memberID ``` This is necessary whenever you want to refer to a left join-ed table in what would...
219,055
<p>I'm trying to get some code working that a previous developer has written. Yep, he now left the company. :-(</p> <p>I have a JSON RPC call being made from the JS code. The JS all runs fine and the callback method gets an object back (not an error object).</p> <p>But the method on the Java class never gets hit. The...
[ { "answer_id": 219095, "author": "matt b", "author_id": 4249, "author_profile": "https://Stackoverflow.com/users/4249", "pm_score": 1, "selected": false, "text": "<p>I'm guessing that you need to update the <code>smd()</code> method to actually call <code>updateRowValueForField()</code> ...
2008/10/20
[ "https://Stackoverflow.com/questions/219055", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26778/" ]
I'm trying to get some code working that a previous developer has written. Yep, he now left the company. :-( I have a JSON RPC call being made from the JS code. The JS all runs fine and the callback method gets an object back (not an error object). But the method on the Java class never gets hit. The smd method does ...
You forgot to include the javascript code. From the example: ``` <s:url id="smdUrl" namespace="/nodecorate" action="SMDAction" /> <script type="text/javascript"> //load dojo RPC dojo.require("dojo.rpc.*"); //create service object(proxy) using SMD (generated by the json result) var service = new dojo.r...
219,109
<p>Obviously I could create a <code>Calendar</code> object with the date and use <code>get(DAY)</code> on it, but knowing Groovy, I would guess there is an easier, quicker way I just don't know about?</p> <p><strong>Answer</strong></p> <pre><code>(date1..date2).size() == 1 // true if two dates are on same calendar da...
[ { "answer_id": 219133, "author": "Ruben", "author_id": 26919, "author_profile": "https://Stackoverflow.com/users/26919", "pm_score": 4, "selected": true, "text": "<p>Quickly opened the Groovy In Action book and found the following sample that should help:</p>\n\n<pre><code>def today = ne...
2008/10/20
[ "https://Stackoverflow.com/questions/219109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6583/" ]
Obviously I could create a `Calendar` object with the date and use `get(DAY)` on it, but knowing Groovy, I would guess there is an easier, quicker way I just don't know about? **Answer** ``` (date1..date2).size() == 1 // true if two dates are on same calendar day ```
Quickly opened the Groovy In Action book and found the following sample that should help: ``` def today = new Date() def yesterday = today-1 assert (yesterday..today).size() == 2 ```
219,110
<p>I have a <a href="http://en.wikipedia.org/wiki/Bluehost" rel="noreferrer">Bluehost</a> account where I can run Python scripts as CGI. I guess it's the simplest CGI, because to run I have to define the following in <code>.htaccess</code>:</p> <pre><code>Options +ExecCGI AddType text/html py AddHandler cgi-script .py...
[ { "answer_id": 219124, "author": "Florian Bösch", "author_id": 19435, "author_profile": "https://Stackoverflow.com/users/19435", "pm_score": 5, "selected": false, "text": "<p>You can <a href=\"http://www.python.org/dev/peps/pep-0333/#the-server-gateway-side\" rel=\"noreferrer\">run WSGI ...
2008/10/20
[ "https://Stackoverflow.com/questions/219110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8206/" ]
I have a [Bluehost](http://en.wikipedia.org/wiki/Bluehost) account where I can run Python scripts as CGI. I guess it's the simplest CGI, because to run I have to define the following in `.htaccess`: ``` Options +ExecCGI AddType text/html py AddHandler cgi-script .py ``` Now, whenever I look up web programming with P...
**How WSGI, CGI, and the frameworks are all connected?** Apache listens on port 80. It gets an HTTP request. It parses the request to find a way to respond. Apache has a LOT of choices for responding. One way to respond is to use CGI to run a script. Another way to respond is to simply serve a file. In the case of C...
219,135
<p>I have been reading carefully through the mediawiki documentation but I have not been able to find out how to create new groups. </p> <p>When I look at Special:Userrights, I see only 3 groups : Bots, Sysops, Bureaycrats</p> <p>I would like to create my own custom groups, so I can use some extensions like the <a h...
[ { "answer_id": 219213, "author": "jeph perro", "author_id": 28351, "author_profile": "https://Stackoverflow.com/users/28351", "pm_score": 1, "selected": false, "text": "<p>I beleive I have found the answer, I just need to add the UserGroup and the permission to the wgGroupPermissions arr...
2008/10/20
[ "https://Stackoverflow.com/questions/219135", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28351/" ]
I have been reading carefully through the mediawiki documentation but I have not been able to find out how to create new groups. When I look at Special:Userrights, I see only 3 groups : Bots, Sysops, Bureaycrats I would like to create my own custom groups, so I can use some extensions like the <http://www.mediawiki...
You can add permissions for new groups to your LocalSettings.php file and they will automatically appear in the Special:UserRights page. For example, I wanted to disallow editing by regular users but create a "Trusted" group that was allowed to edit. The following code creates a "Trusted" group that is equal to the "u...
219,138
<p>I need to run a Linux CLI command and get its stdout output from C.</p> <p>I can use pipe() to create a pipe, then fork/exec, redirecting child's stdout descriptor into the pipe before calling exec(), and reading from the pipe in parent. Plus I'll need to wait on the child.</p> <p>Is there a simple call to do fork...
[ { "answer_id": 219150, "author": "dmckee --- ex-moderator kitten", "author_id": 2509, "author_profile": "https://Stackoverflow.com/users/2509", "pm_score": 1, "selected": false, "text": "<p>Use <code>popen()</code> and <code>pclose()</code>.</p>\n\n<hr>\n\n<p><code>popen()</code> does no...
2008/10/20
[ "https://Stackoverflow.com/questions/219138", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23420/" ]
I need to run a Linux CLI command and get its stdout output from C. I can use pipe() to create a pipe, then fork/exec, redirecting child's stdout descriptor into the pipe before calling exec(), and reading from the pipe in parent. Plus I'll need to wait on the child. Is there a simple call to do fork + redirect + exe...
Is this it? ``` NAME popen, pclose - process I/O SYNOPSIS #include <stdio.h> FILE *popen(const char *command, const char *type); int pclose(FILE *stream); DESCRIPTION The popen() function opens a process by creating a pipe, forking, and invoking the shell. Since a pipe is ...
219,139
<p>I'm trying to use stl algorithm for_each without proliferating templates throughout my code. std::for_each wants to instantiate MyFunctor class by value, but it can't since its abstract. I've created a functor adapter class which passes a pointer around and then derefernces it when appropriate.</p> <p>My Question: ...
[ { "answer_id": 219199, "author": "xtofl", "author_id": 6610, "author_profile": "https://Stackoverflow.com/users/6610", "pm_score": 3, "selected": false, "text": "<p>You could use the function adapters (and their shims) from <code>functional</code>.</p>\n\n<pre><code>#include &lt;function...
2008/10/20
[ "https://Stackoverflow.com/questions/219139", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1575281/" ]
I'm trying to use stl algorithm for\_each without proliferating templates throughout my code. std::for\_each wants to instantiate MyFunctor class by value, but it can't since its abstract. I've created a functor adapter class which passes a pointer around and then derefernces it when appropriate. My Question: Does t...
tr1::ref may help you here --- it's meant to be a reference wrapper so that you can pass normal objects by reference to bind or function objects (even abstract ones) by reference to standard algorithms. ``` // requires TR1 support from your compiler / standard library implementation #include <functional> void applyTo...
219,151
<p>I want to create a WCF-service hosted in IIS6 and disable anonymous authentication in IIS. And don't use SSL.</p> <p>So only way I have is to use basicHttpBinging with <code>TransportCredentialOnly</code>, itsn't it?</p> <p>I create a virtual directory, set Windows Integrated Auth and uncheck "Enable Anonymous Acc...
[ { "answer_id": 219270, "author": "Sixto Saez", "author_id": 9711, "author_profile": "https://Stackoverflow.com/users/9711", "pm_score": 3, "selected": false, "text": "<p>The MEX endpoint may still be the problem (see this <a href=\"http://ahmed0192.spaces.live.com/blog/cns!FD6F44C91F5D2A...
2008/10/20
[ "https://Stackoverflow.com/questions/219151", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27703/" ]
I want to create a WCF-service hosted in IIS6 and disable anonymous authentication in IIS. And don't use SSL. So only way I have is to use basicHttpBinging with `TransportCredentialOnly`, itsn't it? I create a virtual directory, set Windows Integrated Auth and uncheck "Enable Anonymous Access". Here's my web.config:...
The MEX endpoint may still be the problem (see this [post](http://ahmed0192.spaces.live.com/blog/cns!FD6F44C91F5D2AD9!160.entry)). Try disabling MEX like this: ``` <services> <!-- Note: the service name must match the configuration name for the service implementation. --> <service name="MyNamespace.MyServiceTy...
219,219
<p>Is it possible to to change a <code>&lt;span&gt;</code> tag (or <code>&lt;div&gt;</code>) to preformat its contents like a <code>&lt;pre&gt;</code> tag would using only CSS?</p>
[ { "answer_id": 219230, "author": "Diodeus - James MacFarlane", "author_id": 12579, "author_profile": "https://Stackoverflow.com/users/12579", "pm_score": 9, "selected": true, "text": "<p>Look at the <a href=\"https://www.w3.org/TR/CSS21/sample.html\" rel=\"noreferrer\">W3C CSS2.1 Default...
2008/10/20
[ "https://Stackoverflow.com/questions/219219", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1432/" ]
Is it possible to to change a `<span>` tag (or `<div>`) to preformat its contents like a `<pre>` tag would using only CSS?
Look at the [W3C CSS2.1 Default Style Sheet](https://www.w3.org/TR/CSS21/sample.html) or the [CSS2.2 Working Draft](https://www.w3.org/TR/CSS22/sample.html). Copy all the settings for PRE and put them into your own class. ```css pre { display: block; unicode-bidi: embed; font-family: monospace; white-s...
219,226
<p>Recently I have been studying recursion; how to write it, analyze it, etc. I have thought for a while that recurrence and recursion were the same thing, but some problems on recent homework assignments and quizzes have me thinking there are slight differences, that 'recurrence' is the way to describe a recursive pro...
[ { "answer_id": 219238, "author": "David Koelle", "author_id": 2197, "author_profile": "https://Stackoverflow.com/users/2197", "pm_score": 1, "selected": false, "text": "<p>Your method, written in code using a recursive function, would look like this:</p>\n\n<pre><code>function r(int n) \...
2008/10/20
[ "https://Stackoverflow.com/questions/219226", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23323/" ]
Recently I have been studying recursion; how to write it, analyze it, etc. I have thought for a while that recurrence and recursion were the same thing, but some problems on recent homework assignments and quizzes have me thinking there are slight differences, that 'recurrence' is the way to describe a recursive progra...
A few years ago, Mohamad Akra and Louay Bazzi proved a result that generalizes the Master method -- it's almost always better. You really shouldn't be using the Master Theorem anymore... See, for example, this writeup: <http://courses.csail.mit.edu/6.046/spring04/handouts/akrabazzi.pdf> Basically, get your recurrence...
219,243
<pre><code>function Submit_click() { if (!bValidateFields()) return; } function bValidateFields() { /// &lt;summary&gt;Validation rules&lt;/summary&gt; /// &lt;returns&gt;Boolean&lt;/returns&gt; ... } </code></pre> <p>So, when I type the call to my bValidateFields() function intellisence in Visual Studio doesn'...
[ { "answer_id": 219279, "author": "SaaS Developer", "author_id": 7215, "author_profile": "https://Stackoverflow.com/users/7215", "pm_score": 0, "selected": false, "text": "<p>Did you try adding the <code>/// &lt;reference&gt;</code> comment at the top of the external library? I've run in...
2008/10/20
[ "https://Stackoverflow.com/questions/219243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28098/" ]
``` function Submit_click() { if (!bValidateFields()) return; } function bValidateFields() { /// <summary>Validation rules</summary> /// <returns>Boolean</returns> ... } ``` So, when I type the call to my bValidateFields() function intellisence in Visual Studio doesn't show my comments. But according to [this]...
I recall an issue where having turned off the Navigation Bar in VS stopped a lot of the JS intellisense from working properly. If you have it turned off, try turning the Navigation Bar on again and see if it helps. Edit: You may also have to do Ctrl+Shift+J to force the IDE to update the intellisense. Edit2: As @blub...
219,245
<p>I'm looking for a way to transform a genuine string into it's hexadecimal value in SQL. I'm looking something that is Informix-friendly but I would obviously prefer something database-neutral </p> <p>Here is the select I am using now:</p> <pre><code>SELECT SomeStringColumn from SomeTable </code></pre> <p>Here is ...
[ { "answer_id": 219310, "author": "stephenbayer", "author_id": 18893, "author_profile": "https://Stackoverflow.com/users/18893", "pm_score": 4, "selected": false, "text": "<p>Can you use Cast and the fn_varbintohexstr?</p>\n\n<pre><code>SELECT master.dbo.fn_varbintohexstr(CAST(SomeStringC...
2008/10/20
[ "https://Stackoverflow.com/questions/219245", "https://Stackoverflow.com", "https://Stackoverflow.com/users/244/" ]
I'm looking for a way to transform a genuine string into it's hexadecimal value in SQL. I'm looking something that is Informix-friendly but I would obviously prefer something database-neutral Here is the select I am using now: ``` SELECT SomeStringColumn from SomeTable ``` Here is the select I would like to use: ...
Can you use Cast and the fn\_varbintohexstr? ``` SELECT master.dbo.fn_varbintohexstr(CAST(SomeStringColumn AS varbinary)) FROM SomeTable ``` I'm not sure if you have that function in your database system, it is in MS-SQL. I just tried it in my SQL server MMC on one of my tables: ``` SELECT master.dbo.fn_varbi...
219,285
<p>Nowadays, we have tons of Javascript libraries per page in addition to the Javascript files we write ourselves. How do you manage them all? How do you minify them in an organized way? </p>
[ { "answer_id": 219309, "author": "keparo", "author_id": 19468, "author_profile": "https://Stackoverflow.com/users/19468", "pm_score": 2, "selected": false, "text": "<p>First of all, <a href=\"http://developer.yahoo.com/yui/compressor/\" rel=\"nofollow noreferrer\"><strong>YUI Compressor<...
2008/10/20
[ "https://Stackoverflow.com/questions/219285", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10352/" ]
Nowadays, we have tons of Javascript libraries per page in addition to the Javascript files we write ourselves. How do you manage them all? How do you minify them in an organized way?
**Organization** All of my scripts are maintained in a directory structure that I follow whenever I work on a site. The directory structure normally goes something like this: ``` +--root |--javascript |--lib |--prototype.js |--scriptaculous |--scriptaculous.js |--eff...
219,323
<p>Here is a stripped down version of what I use to authenticate users, it works fine on my PHP v5.0.2/MySQL 4.0.21 server, but fails on my PHP v5.1.6/MySQL v5.0.45 server.</p> <p>In the code below, should I be aware of anything that might not be supported by the newer version of PHP &amp; MySQL? Global variables have...
[ { "answer_id": 219341, "author": "changelog", "author_id": 5646, "author_profile": "https://Stackoverflow.com/users/5646", "pm_score": 3, "selected": true, "text": "<p>I'm guessing it might be because of <code>$HTTP_POST_VARS</code>. Try replacing that with <code>$_POST</code>. If it sti...
2008/10/20
[ "https://Stackoverflow.com/questions/219323", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26130/" ]
Here is a stripped down version of what I use to authenticate users, it works fine on my PHP v5.0.2/MySQL 4.0.21 server, but fails on my PHP v5.1.6/MySQL v5.0.45 server. In the code below, should I be aware of anything that might not be supported by the newer version of PHP & MySQL? Global variables have been enabled....
I'm guessing it might be because of `$HTTP_POST_VARS`. Try replacing that with `$_POST`. If it still doesn't work, try putting the following snippet right after `<?php`: ``` // Enable displaying errors error_reporting(E_ALL); ini_set('display_errors', '1'); ```
219,338
<p>I'm using JQuery's jquery.corner.js to create rounded corners on some td tags, and they look fine in IE EXCEPT </p> <ol> <li>if you open a new tab and then come back to the page</li> <li>if you go to another tab, click a link, then come back to the page</li> <li>if you hover over a javascript-executing div / menu (...
[ { "answer_id": 219358, "author": "RichH", "author_id": 16779, "author_profile": "https://Stackoverflow.com/users/16779", "pm_score": 2, "selected": false, "text": "<p>I've had nothing but trouble with rounded corners Javascript libraries (especially with IE6 and 7)</p>\n\n<p>In the end I...
2008/10/20
[ "https://Stackoverflow.com/questions/219338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1943/" ]
I'm using JQuery's jquery.corner.js to create rounded corners on some td tags, and they look fine in IE EXCEPT 1. if you open a new tab and then come back to the page 2. if you go to another tab, click a link, then come back to the page 3. if you hover over a javascript-executing div / menu (I think). The rounded co...
In IE I had better results with the *[DD\_Roundies](http://www.filamentgroup.com/lab/achieving_rounded_corners_in_internet_explorer_for_jquery_ui_with_dd_roundi/)* library. Only works in IE though. For Firefox you need to add -moz-border-radius styles.
219,360
<p>I've got a unfinished project that a developer just didn't finish and didn't leave any documentation about the installation process. I've downloaded the production directory to my windows machine (running InstantRails 2), I created the databases as required in the <code>database.yml</code> and I tried to run the <co...
[ { "answer_id": 219383, "author": "Chris Bunch", "author_id": 422, "author_profile": "https://Stackoverflow.com/users/422", "pm_score": 1, "selected": false, "text": "<p>I'd say your problem is in the <code>uninitialized constant Admin</code> part of your migration issue. Have you tried f...
2008/10/20
[ "https://Stackoverflow.com/questions/219360", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18642/" ]
I've got a unfinished project that a developer just didn't finish and didn't leave any documentation about the installation process. I've downloaded the production directory to my windows machine (running InstantRails 2), I created the databases as required in the `database.yml` and I tried to run the `rake:db:migrate ...
Sometimes Rails will throw this error if there's a syntax error where Admin is defined. Try looking for admin.rb and make sure that it parses. Also, you may want to try running the migrations one at a time (`rake db:migrate VERSION=1`, etc.) to see if that helps you track down which migration causes the error, or if ...
219,368
<p>I got a little problem I can't figure out. I have a server side MarshalByRefObject that I'm trying to wrap a transparent proxy around on the client side. Here's the setup:</p> <pre><code>public class ClientProgram { public static void Main( string[] args ) { ITest test = (ITest)Activator.GetObject( type...
[ { "answer_id": 219442, "author": "bh213", "author_id": 28912, "author_profile": "https://Stackoverflow.com/users/28912", "pm_score": 0, "selected": false, "text": "<p>I did that a while ago and forgot exact procedure, but try using RemotingServices.GetRealProxy to get proxy from <em>test...
2008/10/20
[ "https://Stackoverflow.com/questions/219368", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I got a little problem I can't figure out. I have a server side MarshalByRefObject that I'm trying to wrap a transparent proxy around on the client side. Here's the setup: ``` public class ClientProgram { public static void Main( string[] args ) { ITest test = (ITest)Activator.GetObject( typeof( ITest ), "...
Got it. your comment put me on the right track. The key is to unwrap the proxy and call invoke on it. THANK YOU!!!!! ``` public class ClientProgram { public static void Main( string[] args ) { ITest test = (ITest)Activator.GetObject( typeof( ITest ), "http://127.0.0.1:8765/Test.rem" ); ...
219,369
<p>I want to display some WPF elements near to the selected item of a ListView. How can I obtain the coordinates (screen or relative) of the selected ListViewItem? </p> <pre><code>&lt;ListView x:Name="TechSchoolListView" ClipToBounds="False" Width="Auto" Height="Auto" HorizontalContentAlignment="Stre...
[ { "answer_id": 219448, "author": "Franci Penov", "author_id": 17028, "author_profile": "https://Stackoverflow.com/users/17028", "pm_score": 3, "selected": true, "text": "<p>You should use <a href=\"http://msdn.microsoft.com/en-us/library/aa346420.aspx\" rel=\"nofollow noreferrer\">Contai...
2008/10/20
[ "https://Stackoverflow.com/questions/219369", "https://Stackoverflow.com", "https://Stackoverflow.com/users/205962/" ]
I want to display some WPF elements near to the selected item of a ListView. How can I obtain the coordinates (screen or relative) of the selected ListViewItem? ``` <ListView x:Name="TechSchoolListView" ClipToBounds="False" Width="Auto" Height="Auto" HorizontalContentAlignment="Stretch" Vertica...
You should use [ContainerFromElement](http://msdn.microsoft.com/en-us/library/aa346420.aspx) to get the item's container, which is a visual and from there you can get the coordinates. You can't express this in XAML, however. You need to do it in code, on one of the ListView events, raised when the selected item is chan...
219,396
<p>I'm writing a mobile content adaptation plugin for a bespoke CMS in PHP. The CMS contains <code>&lt;img/&gt;</code> links to images with absolute URLs which are all 400 pixels wide and vary in height.</p> <p>I'd like to parse the HTML (which is stored in MySQL) and re-scale each image to a new width - this will var...
[ { "answer_id": 219407, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 2, "selected": false, "text": "<p>what about doing something a bit different. basically off load the caching/resizing to an on demand model. so say your appli...
2008/10/20
[ "https://Stackoverflow.com/questions/219396", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm writing a mobile content adaptation plugin for a bespoke CMS in PHP. The CMS contains `<img/>` links to images with absolute URLs which are all 400 pixels wide and vary in height. I'd like to parse the HTML (which is stored in MySQL) and re-scale each image to a new width - this will vary according to the device. ...
what about doing something a bit different. basically off load the caching/resizing to an on demand model. so say your application is being run on device A, which requires 200x200 images. you'd change the image links to: ``` <img src="/images/image.php?height=200&width=200&source=filename.jpg" /> ``` image.php could...
219,402
<p>I want to find a linux command that can return a part of the string. In most programming languages, it's the <code>substr()</code> function. Does bash have any command that can be used for this purpose. I want to be able to do something like this... <code>substr "abcdefg" 2 3</code> - prints <code>cde</code>.</p> <...
[ { "answer_id": 219409, "author": "dmckee --- ex-moderator kitten", "author_id": 2509, "author_profile": "https://Stackoverflow.com/users/2509", "pm_score": 7, "selected": false, "text": "<p>From the bash manpage:</p>\n\n<pre><code>${parameter:offset}\n${parameter:offset:length}\n ...
2008/10/20
[ "https://Stackoverflow.com/questions/219402", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15595/" ]
I want to find a linux command that can return a part of the string. In most programming languages, it's the `substr()` function. Does bash have any command that can be used for this purpose. I want to be able to do something like this... `substr "abcdefg" 2 3` - prints `cde`. --- Subsequent similar question: * [Ext...
If you are looking for a shell utility to do something like that, you can use the `cut` command. To take your example, try: ``` echo "abcdefg" | cut -c3-5 ``` which yields ``` cde ``` Where `-cN-M` tells the cut command to return columns `N` to `M`, inclusive.
219,420
<p>Working through some programming interview challenges I found online, I had to write an algorithm to reverse a const char * and return a pointer to a new char *. I think I have it, but to make it work properly I had to do some wonky stuff - basically having to account for the null-terminating character myself. Someh...
[ { "answer_id": 219432, "author": "nsayer", "author_id": 13757, "author_profile": "https://Stackoverflow.com/users/13757", "pm_score": 4, "selected": false, "text": "<p>I had this question once. That's the first answer that comes to mind, but the follow-up is, \"now do it without allocati...
2008/10/20
[ "https://Stackoverflow.com/questions/219420", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Working through some programming interview challenges I found online, I had to write an algorithm to reverse a const char \* and return a pointer to a new char \*. I think I have it, but to make it work properly I had to do some wonky stuff - basically having to account for the null-terminating character myself. Someho...
I had this question once. That's the first answer that comes to mind, but the follow-up is, "now do it without allocating any memory." ``` int length = strlen(string); for(int i = 0; i < length/2; i++) { char c = string[i]; string[i] = string[length - i]; string[length - i] = c; } ``` EDIT: Some folks have exp...
219,434
<p>What query can return the names of all the stored procedures in a SQL Server database</p> <p>If the query could exclude system stored procedures, that would be even more helpful.</p>
[ { "answer_id": 219440, "author": "Bob Probst", "author_id": 12424, "author_profile": "https://Stackoverflow.com/users/12424", "pm_score": 1, "selected": false, "text": "<pre><code>select * \n from dbo.sysobjects\n where xtype = 'P'\n and status &gt; 0\n</code></pre>\n" }, { "...
2008/10/20
[ "https://Stackoverflow.com/questions/219434", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
What query can return the names of all the stored procedures in a SQL Server database If the query could exclude system stored procedures, that would be even more helpful.
As Mike stated, the best way is to use `information_schema`. As long as you're not in the master database, system stored procedures won't be returned. ``` SELECT * FROM DatabaseName.INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_TYPE = 'PROCEDURE' ``` If for some reason you had non-system stored procedures in the mas...
219,475
<p>I'm working with a client that needs to generate millions of the alphanumeric codes used in magazine scratch-off cards, bottlecap prizes, and so on. They have to be short enough to print on a cap, they want to make sure that ambiguous characters like 1 and I, 0 and O, etc. are not included, and they have to be expli...
[ { "answer_id": 219524, "author": "Paul Dixon", "author_id": 6521, "author_profile": "https://Stackoverflow.com/users/6521", "pm_score": 3, "selected": false, "text": "<p>Let's suppose you can use a character set of, say, 40 symbols of unambiguous upper,lower and numeric characters.</p>\n...
2008/10/20
[ "https://Stackoverflow.com/questions/219475", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19411/" ]
I'm working with a client that needs to generate millions of the alphanumeric codes used in magazine scratch-off cards, bottlecap prizes, and so on. They have to be short enough to print on a cap, they want to make sure that ambiguous characters like 1 and I, 0 and O, etc. are not included, and they have to be explicit...
If you need about 10 million unique keys (for example), the best approach is to pick a key-space that's exponentially bigger, and start randomly generating. Read about the [Birthday Paradox](http://en.wikipedia.org/wiki/Birthday_paradox) -- it's the main thing you should be worried about. If you want 2^n unique and sec...
219,482
<p>If anyone has experience using Oracle text (<code>CTXSYS.CONTEXT</code>), I'm wondering how to handle user input when the user wants to search for names that may contain an apostrophe.</p> <p>Escaping the ' seems to work in some cases, but not for 's at the end of the word - s is in the list of stop words, and so s...
[ { "answer_id": 220417, "author": "yogman", "author_id": 24349, "author_profile": "https://Stackoverflow.com/users/24349", "pm_score": -1, "selected": false, "text": "<p>Forget about sanitizing. Why? Refer to <a href=\"http://en.wikipedia.org/wiki/SQL_injection\" rel=\"nofollow noreferrer...
2008/10/20
[ "https://Stackoverflow.com/questions/219482", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4782/" ]
If anyone has experience using Oracle text (`CTXSYS.CONTEXT`), I'm wondering how to handle user input when the user wants to search for names that may contain an apostrophe. Escaping the ' seems to work in some cases, but not for 's at the end of the word - s is in the list of stop words, and so seems to get removed. ...
Escape all special characters with backslashes. Curly braces won't work with substring searches as they define complete tokens. Eg %{ello}% won't match the token 'Hello' Escaped space characters will be included in the search token, so the search string '%stay\ near\ me%' will be treated as a literal string "stay nea...
219,519
<p>What I'm looking for is a basic equivalent of JavaScript's <code>Array::join()</code> whereby you pass in a separator character and uses that in its return string of all the subscripts. I could certainly write my own function using a <code>StringBuilder</code> or whatnot, but there <em>must</em> be something built ...
[ { "answer_id": 219521, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 3, "selected": true, "text": "<p>If the array contains strings, you can just use <a href=\"http://msdn.microsoft.com/en-us/library/57a79xd0.aspx\" re...
2008/10/20
[ "https://Stackoverflow.com/questions/219519", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9642/" ]
What I'm looking for is a basic equivalent of JavaScript's `Array::join()` whereby you pass in a separator character and uses that in its return string of all the subscripts. I could certainly write my own function using a `StringBuilder` or whatnot, but there *must* be something built into the .NET BCL. EDIT: Array o...
If the array contains strings, you can just use [`String.Join()`](http://msdn.microsoft.com/en-us/library/57a79xd0.aspx). If the array does not contain strings, you'll need something a little more complicated so you can handle the cast or conversion process for each item it contains. **Update:** Using @JaredPar's code...
219,547
<p>I have a python script that is a http-server: <a href="http://paste2.org/p/89701" rel="nofollow noreferrer">http://paste2.org/p/89701</a>, when benchmarking it against ApacheBench (ab) with a concurrency level (-c switch) that is lower then or equal to the value i specified in the socket.listen()-call in the sourcec...
[ { "answer_id": 219642, "author": "extraneon", "author_id": 24582, "author_profile": "https://Stackoverflow.com/users/24582", "pm_score": 0, "selected": false, "text": "<p>I found <a href=\"http://www.mail-archive.com/dev@tomcat.apache.org/msg22589.html\" rel=\"nofollow noreferrer\">this ...
2008/10/20
[ "https://Stackoverflow.com/questions/219547", "https://Stackoverflow.com", "https://Stackoverflow.com/users/452521/" ]
I have a python script that is a http-server: <http://paste2.org/p/89701>, when benchmarking it against ApacheBench (ab) with a concurrency level (-c switch) that is lower then or equal to the value i specified in the socket.listen()-call in the sourcecode everything works fine, but as soon as put the concurrency level...
I cannot confirm your results, and your server is coded fishy. I whipped up my own server and do not have this problem either. Let's move the discussion to a simpler level: ``` import thread, socket, Queue connections = Queue.Queue() num_threads = 10 backlog = 10 def request(): while 1: conn = connection...
219,559
<p>I have a table of data, and I allow people to add meta data to that table.</p> <p>I give them an interface that allows them to treat it as though they're adding extra columns to the table their data is stored in, but I'm actually storing the data in another table.</p> <pre><code>Data Table DataID Data Meta ...
[ { "answer_id": 219578, "author": "Bill the Lizard", "author_id": 1288, "author_profile": "https://Stackoverflow.com/users/1288", "pm_score": 1, "selected": false, "text": "<pre><code>SELECT DataTable.Data AS Data, MetaTable.MetaData AS Date, MetaTable.MetaName AS Name\nFROM DataTable, Me...
2008/10/20
[ "https://Stackoverflow.com/questions/219559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2915/" ]
I have a table of data, and I allow people to add meta data to that table. I give them an interface that allows them to treat it as though they're adding extra columns to the table their data is stored in, but I'm actually storing the data in another table. ``` Data Table DataID Data Meta Table DataID Me...
You want to pivot each of your name-value pair rows in the MyTable... Try this sql: ``` DECLARE @Data TABLE ( DataID INT IDENTITY(1,1) PRIMARY KEY, Data VARCHAR(MAX) ) DECLARE @Meta TABLE ( DataID INT , MetaName VARCHAR(MAX), MetaData VARCHAR(MAX) ) INSERT INTO @Data ...
219,570
<p>I was asked for a comprehensive breakdown on space used within a specific database. I know I can use <em>sys.dm_db_partition_stats</em> in SQL Server 2005 to figure out how much space each <em>table</em> in a database is using, but is there any way to determine the individual and total size of the <em>stored proced...
[ { "answer_id": 219605, "author": "Dave_H", "author_id": 17109, "author_profile": "https://Stackoverflow.com/users/17109", "pm_score": 2, "selected": false, "text": "<p>A slightly better way than counting the characters, is to use information schema.routines. You could sum the length of ...
2008/10/20
[ "https://Stackoverflow.com/questions/219570", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21398/" ]
I was asked for a comprehensive breakdown on space used within a specific database. I know I can use *sys.dm\_db\_partition\_stats* in SQL Server 2005 to figure out how much space each *table* in a database is using, but is there any way to determine the individual and total size of the *stored procedures* in a databa...
``` ;WITH ROUTINES AS ( -- CANNOT use INFORMATION_SCHEMA.ROUTINES because of 4000 character limit SELECT o.type_desc AS ROUTINE_TYPE ,o.[name] AS ROUTINE_NAME ,m.definition AS ROUTINE_DEFINITION FROM sys.sql_modules AS m INNER JOIN sys.objects AS o ON m.object_id = o.obje...
219,574
<p>One thing I've run into a few times is a service class (like a JBoss service) that has gotten overly large due to helper inner classes. I've yet to find a good way to break the class out. These helpers are usually threads. Here's an example:</p> <pre><code>/** Asset service keeps track of the metadata about assets ...
[ { "answer_id": 219644, "author": "OscarRyz", "author_id": 20654, "author_profile": "https://Stackoverflow.com/users/20654", "pm_score": 0, "selected": false, "text": "<p>Yeap. Probably you need to re-refactor those helpers and not move them all as they are. Some things belong to the serv...
2008/10/20
[ "https://Stackoverflow.com/questions/219574", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29734/" ]
One thing I've run into a few times is a service class (like a JBoss service) that has gotten overly large due to helper inner classes. I've yet to find a good way to break the class out. These helpers are usually threads. Here's an example: ``` /** Asset service keeps track of the metadata about assets that live on o...
On bytecode level inner classes are just plain Java classes. Since the Java bytecode verifier does not allow access to private members, it generates synthetic accessor methods for each private field which you use. Also, in order to link the inner class with its enclosing instance, the compiler adds synthetic pointer to...
219,581
<p>I'm looking to add a tooltip to each row in a bound datagrid in vb.net winforms. How can this be done?</p>
[ { "answer_id": 219771, "author": "Ricardo Villamil", "author_id": 19314, "author_profile": "https://Stackoverflow.com/users/19314", "pm_score": 2, "selected": true, "text": "<p>I haven't tried this myself but I would give it a shot:</p>\n\n<pre><code>System.Windows.Forms.ToolTip formTool...
2008/10/20
[ "https://Stackoverflow.com/questions/219581", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3259/" ]
I'm looking to add a tooltip to each row in a bound datagrid in vb.net winforms. How can this be done?
I haven't tried this myself but I would give it a shot: ``` System.Windows.Forms.ToolTip formToolTip = new System.Windows.Forms.ToolTip(); formToolTip .SetToolTip(item, "Row Tooltip"); ``` Where `item` corresponds to the cell you're setting the tool tip for.
219,590
<p>What is the best way to localize a collection (IEnumerable)? From the BL I retrieve a collection of entities which still need to localized, I figured I write a method which extends the IEnumerable and returns the localized list. </p> <p>How can i get the code underneath working? Any ideas? Maybe better options? ...
[ { "answer_id": 219611, "author": "Darren Kopp", "author_id": 77, "author_profile": "https://Stackoverflow.com/users/77", "pm_score": 2, "selected": false, "text": "<p>have you tried something where you <a href=\"http://msdn.microsoft.com/en-us/library/9k7k7cf0.aspx\" rel=\"nofollow noref...
2008/10/20
[ "https://Stackoverflow.com/questions/219590", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27857/" ]
What is the best way to localize a collection (IEnumerable)? From the BL I retrieve a collection of entities which still need to localized, I figured I write a method which extends the IEnumerable and returns the localized list. How can i get the code underneath working? Any ideas? Maybe better options? ``` public ...
have you tried something where you [yield](http://msdn.microsoft.com/en-us/library/9k7k7cf0.aspx) the item? ``` public static IEnumerable<string> Localize(this IEnumerable<string> items, CultureInfo culture) { foreach (string item in items) { yield return ResourceHelper.GetString(item,culture); } }...
219,594
<p>I'm wondering what the best way is to have a "if all else fails catch it".</p> <p>I mean, you're handling as much exceptions as possible in your application, but still there are bound to be bugs, so I need to have something that catches all unhandled exceptions so I can collect information and store them in a datab...
[ { "answer_id": 219607, "author": "ine", "author_id": 4965, "author_profile": "https://Stackoverflow.com/users/4965", "pm_score": 4, "selected": false, "text": "<p>In ASP.NET, you use the <code>Application_Error</code> function in the <code>Global.asax</code> file.</p>\n\n<p>In WinForms, ...
2008/10/20
[ "https://Stackoverflow.com/questions/219594", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28149/" ]
I'm wondering what the best way is to have a "if all else fails catch it". I mean, you're handling as much exceptions as possible in your application, but still there are bound to be bugs, so I need to have something that catches all unhandled exceptions so I can collect information and store them in a database or sub...
I have just played with AppDomain's UnhandledException behavior, (this is the last stage the unhandled exception is registered at) Yes, after processing the event handlers your application will be terminated and the nasty "... program stopped working dialog" shown. :) You *still* can avoid that. Check out: ``` clas...
219,598
<p>I’m writing a test that expects to receive an event from an object that it is calling. Specifically, I am calling out to an object that connects to an AIX machine via SSH (using the open source Granados project), then disconnecting, and I want to make sure I receive the OnConnectionClosed event that is being raised ...
[ { "answer_id": 219922, "author": "jezell", "author_id": 27453, "author_profile": "https://Stackoverflow.com/users/27453", "pm_score": 2, "selected": false, "text": "<p>Use the WaitHandle classes in the System.Threading namespace. Either, AutoResetEvent or ManualResetEvent. The difference...
2008/10/20
[ "https://Stackoverflow.com/questions/219598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I’m writing a test that expects to receive an event from an object that it is calling. Specifically, I am calling out to an object that connects to an AIX machine via SSH (using the open source Granados project), then disconnecting, and I want to make sure I receive the OnConnectionClosed event that is being raised dur...
Use the WaitHandle classes in the System.Threading namespace. Either, AutoResetEvent or ManualResetEvent. The difference between the two is that AutoResetEvent lets one thread proceed each time it is set, while ManualResetEvent releases all waiting threads on set. The reason your example doesn't work has to do with co...
219,604
<p>How would you convert a parapraph to hex notation, and then back again into its original string form?</p> <p>(C#)</p> <p>A side note: would putting the string into hex format shrink it the most w/o getting into hardcore shrinking algo's?</p>
[ { "answer_id": 219619, "author": "Corey Goldberg", "author_id": 16148, "author_profile": "https://Stackoverflow.com/users/16148", "pm_score": 1, "selected": false, "text": "<pre><code>public string ConvertToHex(string asciiString)\n{\n string hex = \"\";\n foreach (char c in asciiS...
2008/10/20
[ "https://Stackoverflow.com/questions/219604", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How would you convert a parapraph to hex notation, and then back again into its original string form? (C#) A side note: would putting the string into hex format shrink it the most w/o getting into hardcore shrinking algo's?
What exactly do you mean by "hex notation"? That usually refers to encoding binary data, not text. You'd need to encode the text somehow (e.g. using UTF-8) and then encode the binary data as text by converting each byte to a pair of characters. ``` using System; using System.Text; public class Hex { static void M...
219,637
<p>The code is,</p> <pre><code>set VAR=before if "%VAR%" == "before" ( set VAR=after; echo %VAR% ) </code></pre> <p>What will the preceding Windows .bat file code segment display? Why? (i.e. why doesn't it behave as you might first think)?</p>
[ { "answer_id": 219658, "author": "Sean Sexton", "author_id": 22357, "author_profile": "https://Stackoverflow.com/users/22357", "pm_score": 3, "selected": true, "text": "<p>Obviously, you'd think the output would be \"after\", given that we reset the env variable inside the loop. </p>\n\...
2008/10/20
[ "https://Stackoverflow.com/questions/219637", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22357/" ]
The code is, ``` set VAR=before if "%VAR%" == "before" ( set VAR=after; echo %VAR% ) ``` What will the preceding Windows .bat file code segment display? Why? (i.e. why doesn't it behave as you might first think)?
Obviously, you'd think the output would be "after", given that we reset the env variable inside the loop. But the output will actually be "before". The reason is that variable substitution is done in .bat files by the interpreter when a command is read, rather than when it's executed. So, for the compound statement, ...
219,668
<p>I'm looking for best practices to integrate log4net to SharePoint for web request, feature activation and all timer stuff. </p> <p>I have several subprojects in my farm, and I would like to have only one Log4Net.config file.</p> <p><strong>[Edit]</strong><br> Not only I need to configure log4net for the web appli...
[ { "answer_id": 219702, "author": "Nat", "author_id": 13813, "author_profile": "https://Stackoverflow.com/users/13813", "pm_score": 0, "selected": false, "text": "<p>You could release the config file as part of the solution package(s) to the 12 hive (use <a href=\"http://www.codeplex.com/...
2008/10/20
[ "https://Stackoverflow.com/questions/219668", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22970/" ]
I'm looking for best practices to integrate log4net to SharePoint for web request, feature activation and all timer stuff. I have several subprojects in my farm, and I would like to have only one Log4Net.config file. **[Edit]** Not only I need to configure log4net for the web application, which is easy to do (I u...
I implemented this recently and came up with a solution that worked for me. Deploy your log4net config file to the 12 hive and the log4net dll into the GAC using a globally scoped solution. Then in your application code explicitly initialize log4net from the location of your global file. This allows you to log feature...
219,716
<p>A cross join performs a cartesian product on the tuples of the two sets.</p> <pre><code>SELECT * FROM Table1 CROSS JOIN Table2 </code></pre> <p>Which circumstances render such an SQL operation particularly useful?</p>
[ { "answer_id": 219738, "author": "Randy", "author_id": 9361, "author_profile": "https://Stackoverflow.com/users/9361", "pm_score": 4, "selected": false, "text": "<p>You're typically not going to want a full Cartesian product for most database queries. The whole power of relational datab...
2008/10/20
[ "https://Stackoverflow.com/questions/219716", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27765/" ]
A cross join performs a cartesian product on the tuples of the two sets. ``` SELECT * FROM Table1 CROSS JOIN Table2 ``` Which circumstances render such an SQL operation particularly useful?
If you have a "grid" that you want to populate completely, like size and color information for a particular article of clothing: ``` select size, color from sizes CROSS JOIN colors ``` Maybe you want a table that contains a row for every minute in the day, and you want to use it to verify that a procedu...
219,719
<p>SQL databases seem to be the cornerstone of most software. However, it seems optimized for textual data. In fact when doing any queries involving numerical data, integers specifically, it seems inefficient that the numbers are getting converted to text and then back to native formats both ways between the applicatio...
[ { "answer_id": 219750, "author": "Lou Franco", "author_id": 3937, "author_profile": "https://Stackoverflow.com/users/3937", "pm_score": 1, "selected": false, "text": "<p>Numerical data in a database is not stored as text. I guess it depends on the database, but it certainly doesn't have...
2008/10/20
[ "https://Stackoverflow.com/questions/219719", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1892/" ]
SQL databases seem to be the cornerstone of most software. However, it seems optimized for textual data. In fact when doing any queries involving numerical data, integers specifically, it seems inefficient that the numbers are getting converted to text and then back to native formats both ways between the application a...
Don't suppose. Measure. Format conversion is not likely to be a measurable cost for database work, unless you are misusing the database as an arithmetic engine. The IO cost for LOBs, especially for CLOBS with character conversion, can become significant; the remedy here, once you know that the simplest thing that mig...
219,770
<p>In Visual Studio, I often use objects only for RAII purposes. For example:</p> <pre><code>ScopeGuard close_guard = MakeGuard( &amp;close_file, file ); </code></pre> <p>The whole purpose of <em>close_guard</em> is to make sure that the file will be close on function exit, it is not used anywhere else. However, Vi...
[ { "answer_id": 219786, "author": "Robert Deml", "author_id": 9516, "author_profile": "https://Stackoverflow.com/users/9516", "pm_score": 0, "selected": false, "text": "<p>Try adding 'volatile' to the ScopeGuard declaration.</p>\n" }, { "answer_id": 219791, "author": "Jorge Fe...
2008/10/20
[ "https://Stackoverflow.com/questions/219770", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9936/" ]
In Visual Studio, I often use objects only for RAII purposes. For example: ``` ScopeGuard close_guard = MakeGuard( &close_file, file ); ``` The whole purpose of *close\_guard* is to make sure that the file will be close on function exit, it is not used anywhere else. However, Visual Studio gives me a warning that a ...
**Method 1:** Use the `#pragma warning` directive. `#pragma warning` allows selective modification of the behavior of compiler warning messages. ``` #pragma warning( push ) #pragma warning( disable : 4705 ) // replace 4705 with warning number ScopeGuard close_guard = MakeGuard( &close_file, file ); #pragma warning(...
219,776
<p>I wanna get the Timedate value from another page using request.querystring and then use it an query to compare and pull up the matching datas. The function for the query in linq is:</p> <pre><code> protected void User_Querytime() { DataClasses2DataContext dc1 = new DataClasses2DataContext(); String D...
[ { "answer_id": 219805, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 2, "selected": true, "text": "<p>Do you mean Convert.ToDateTime? This returns DateTime (not bool).\nDo you mean DateTime.TryParse? Simply use any of...
2008/10/20
[ "https://Stackoverflow.com/questions/219776", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I wanna get the Timedate value from another page using request.querystring and then use it an query to compare and pull up the matching datas. The function for the query in linq is: ``` protected void User_Querytime() { DataClasses2DataContext dc1 = new DataClasses2DataContext(); String Data = Request....
Do you mean Convert.ToDateTime? This returns DateTime (not bool). Do you mean DateTime.TryParse? Simply use any of: ``` DateTime when = DateTime.Parse(data); DateTime when = DateTime.ParseExact(data); DateTime when = Convert.ToDateTime(data); ``` Then use "when" in the query. I'm not sure the purpose of ordering by ...
219,783
<p>I can't seems to change the default color of the required field validator. In the source it is:</p> <pre><code>&lt;span class="required"&gt;*&lt;/span&gt; &lt;asp:RequiredFieldValidator ID="valReq_txtTracks" runat="server" ControlToValidate="txtTracks" Display="Dynamic" /&gt; </code></pre> <p>Here's what ...
[ { "answer_id": 219793, "author": "bob", "author_id": 23805, "author_profile": "https://Stackoverflow.com/users/23805", "pm_score": 1, "selected": false, "text": "<p>I read somewhere to use the !important tag in your css class to override the inline css...</p>\n" }, { "answer_id":...
2008/10/20
[ "https://Stackoverflow.com/questions/219783", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12252/" ]
I can't seems to change the default color of the required field validator. In the source it is: ``` <span class="required">*</span> <asp:RequiredFieldValidator ID="valReq_txtTracks" runat="server" ControlToValidate="txtTracks" Display="Dynamic" /> ``` Here's what I have in my .skin file: ``` <asp:RequiredFi...
There is a [RequiredFieldValidator.ForeColor](http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.basevalidator.forecolor.aspx) property you can set to control the color. Note that if you want to set the color in CSS, then you need to set ForeColor="" to clear it on the control.
219,788
<p>I have a large (700kb) Flex .swf file representing the main file of a site. </p> <p>For performance testing I wanted to try and move it off to Amazon S3 hosting (which i have already done with certain videos and large files). </p> <p>I went ahead and did that, and updated the html page to reference the remote .swf...
[ { "answer_id": 220518, "author": "fenomas", "author_id": 10651, "author_profile": "https://Stackoverflow.com/users/10651", "pm_score": 0, "selected": false, "text": "<p>You could try specifying the <code>base</code> parameter of your SWF's embed/object tags. In theory it defines the base...
2008/10/20
[ "https://Stackoverflow.com/questions/219788", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24727/" ]
I have a large (700kb) Flex .swf file representing the main file of a site. For performance testing I wanted to try and move it off to Amazon S3 hosting (which i have already done with certain videos and large files). I went ahead and did that, and updated the html page to reference the remote .swf. It turns out t...
Append a slash before your urls, this should load relative to the domain instead of the current folder: ``` foo.load('/like/this/image.jpg') ``` This is a bit quick and dirty, feeding a "relative" url via a querystring ([or the base parameter](https://stackoverflow.com/questions/219788/loading-flex-resources-relativ...
219,798
<h2>I'm looking to add some lookup lists in the database, but I want them to be easy localizable (SQL 2005, ADO.NET)</h2> <p>This would include:</p> <ul> <li>Easy Management of multiple languages at the same time</li> <li>Easy Retrieval of values from the database</li> <li>Fallback language (in case the selected lang...
[ { "answer_id": 219871, "author": "Diodeus - James MacFarlane", "author_id": 12579, "author_profile": "https://Stackoverflow.com/users/12579", "pm_score": 2, "selected": false, "text": "<p>If you structure your data like this:</p>\n\n<pre><code>MessageToken DisplayText LangCode\n...
2008/10/20
[ "https://Stackoverflow.com/questions/219798", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23795/" ]
I'm looking to add some lookup lists in the database, but I want them to be easy localizable (SQL 2005, ADO.NET) ---------------------------------------------------------------------------------------------------------------- This would include: * Easy Management of multiple languages at the same time * Easy Retrieva...
If you structure your data like this: ``` MessageToken DisplayText LangCode firewood Fire wood en firewood Bois de chauffage fr ``` When you make your query, just supply the default languageId (if blank) or the supplied languageId. Use a standard list of tokens for the messages. ``` S...
219,800
<p>Here is a snippet of the file <em>/proc/self/smaps</em>:</p> <pre><code>00af8000-00b14000 r-xp 00000000 fd:00 16417 /lib/ld-2.8.so Size: 112 kB Rss: 88 kB Pss: 1 kB Shared_Clean: 88 kB Shared_Dirty: 0 kB Private_Clean: 0 kB Private_Dirt...
[ { "answer_id": 219830, "author": "Adam Davis", "author_id": 2915, "author_profile": "https://Stackoverflow.com/users/2915", "pm_score": 0, "selected": false, "text": "<p>You'll need to extract information from Linux's memory handler to determine how the application's virtual memory map r...
2008/10/20
[ "https://Stackoverflow.com/questions/219800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Here is a snippet of the file */proc/self/smaps*: ``` 00af8000-00b14000 r-xp 00000000 fd:00 16417 /lib/ld-2.8.so Size: 112 kB Rss: 88 kB Pss: 1 kB Shared_Clean: 88 kB Shared_Dirty: 0 kB Private_Clean: 0 kB Private_Dirty: 0 kB Refer...
The format of smaps is: [BOTTOM]-[TOP] [PERM] [FILE OFFSET] b80e9000-b80ea000 rw-p 0001b000 08:05 605294 /lib/ld-2.8.90.so So there the actual content of the file '/lib/ld-2.8.90.so' at file offset 0x0001b000 is mapped at 0xb80e9000 in that program's memory. To extract the line number or C code of the mapped addre...
219,808
<p>I am completely new to LINQ in C#/.NET. I understand that I could use it to convert a DataSet into an Array/List, am I able to go in the opposite direction?</p> <p>I'm using NPlot to generate a graph of captured prices, which are stored in a List, where PriceInformation is a class containing two public doubles and...
[ { "answer_id": 219877, "author": "Amy B", "author_id": 8155, "author_profile": "https://Stackoverflow.com/users/8155", "pm_score": 4, "selected": true, "text": "<p>There's a method called <a href=\"http://msdn.microsoft.com/en-us/library/bb396189.aspx\" rel=\"nofollow noreferrer\">CopyTo...
2008/10/20
[ "https://Stackoverflow.com/questions/219808", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25462/" ]
I am completely new to LINQ in C#/.NET. I understand that I could use it to convert a DataSet into an Array/List, am I able to go in the opposite direction? I'm using NPlot to generate a graph of captured prices, which are stored in a List, where PriceInformation is a class containing two public doubles and a DateTime...
There's a method called [CopyToDataTable](http://msdn.microsoft.com/en-us/library/bb396189.aspx). That method will only help if you already have a IEnumerable(DataRow) Here's how I'd do this: ``` //extension method to convert my type to an object array. public static object[] ToObjectArray(this MyClass theSource) { ...
219,815
<p>I've seen some very good questions on Stack Overflow concerning delegates, events, and the .NET implementation of these two features. One question in particular, "<a href="https://stackoverflow.com/questions/213638/how-do-c-events-work-behind-the-scenes#213651">How do C# Events work behind the scenes?</a>", produce...
[ { "answer_id": 219835, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 4, "selected": true, "text": "<p>I'm not sure that is surprising... compare to the same for properties vs fields (since properties before the same f...
2008/10/20
[ "https://Stackoverflow.com/questions/219815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28350/" ]
I've seen some very good questions on Stack Overflow concerning delegates, events, and the .NET implementation of these two features. One question in particular, "[How do C# Events work behind the scenes?](https://stackoverflow.com/questions/213638/how-do-c-events-work-behind-the-scenes#213651)", produced a great answe...
I'm not sure that is surprising... compare to the same for properties vs fields (since properties before the same function as events: encapsulation via accessors): ``` .field public string Foo // public field .property instance string Bar // public property { .get instance string MyType::get_Bar() .set instanc...
219,827
<p>I am trying to fill a form in a php application from a C# client (Outlook addin). I used Fiddler to see the original request from within the php application and the form is transmitted as a multipart/form. Unfortunately .Net does not come with native support for this type of forms (WebClient has only a method for up...
[ { "answer_id": 220015, "author": "dnolan", "author_id": 29086, "author_profile": "https://Stackoverflow.com/users/29086", "pm_score": 6, "selected": true, "text": "<p>This is cut and pasted from some sample code I wrote, hopefully it should give the basics. It only supports File data and...
2008/10/20
[ "https://Stackoverflow.com/questions/219827", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29876/" ]
I am trying to fill a form in a php application from a C# client (Outlook addin). I used Fiddler to see the original request from within the php application and the form is transmitted as a multipart/form. Unfortunately .Net does not come with native support for this type of forms (WebClient has only a method for uploa...
This is cut and pasted from some sample code I wrote, hopefully it should give the basics. It only supports File data and form-data at the moment. ``` public class PostData { private List<PostDataParam> m_Params; public List<PostDataParam> Params { get { return m_Params; } set { m_Params ...
219,833
<p>I'm collecting metadata using the sys.* views, and according to the documentation, the sys.identity_columns view will return the seed and increment values like so.</p> <pre><code>CREATE TABLE ident_test ( test_id int IDENTITY(1000,10), other int ) SELECT name, seed_value, increment_value FROM sys.identity_co...
[ { "answer_id": 219850, "author": "Cade Roux", "author_id": 18255, "author_profile": "https://Stackoverflow.com/users/18255", "pm_score": 0, "selected": false, "text": "<p>Are you sure you are running this in a database with tables with <code>IDENTITY</code> columns?</p>\n\n<pre><code>SEL...
2008/10/20
[ "https://Stackoverflow.com/questions/219833", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4525/" ]
I'm collecting metadata using the sys.\* views, and according to the documentation, the sys.identity\_columns view will return the seed and increment values like so. ``` CREATE TABLE ident_test ( test_id int IDENTITY(1000,10), other int ) SELECT name, seed_value, increment_value FROM sys.identity_columns WHERE...
Shouldn't you reverse the from and join, like this: ``` SELECT c.name, i.seed_value, i.increment_value from sys.identity_columns i join sys.columns c ON i.object_id = c.object_id AND i.column_id = c.column_id ```
219,851
<p>I want a method of the class: "<code>One</code>" ("<code>AccessibleWithinSameNamespace</code>") to be accessible by the class: "<code>Two</code>", without having "<code>Two</code>" extending "<code>One</code>".</p> <p>Both classes are in the same namespace, so I'm thinking that maybe there's an access-modifier that...
[ { "answer_id": 219858, "author": "Jorge Villuendas Zapatero", "author_id": 27097, "author_profile": "https://Stackoverflow.com/users/27097", "pm_score": 3, "selected": true, "text": "<p>You can use the <a href=\"http://msdn.microsoft.com/en-us/library/7c5ka91b.aspx\" rel=\"nofollow noref...
2008/10/20
[ "https://Stackoverflow.com/questions/219851", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20946/" ]
I want a method of the class: "`One`" ("`AccessibleWithinSameNamespace`") to be accessible by the class: "`Two`", without having "`Two`" extending "`One`". Both classes are in the same namespace, so I'm thinking that maybe there's an access-modifier that emulates the "*protected*" modifyer, but for namespaces. Some c...
You can use the [internal](http://msdn.microsoft.com/en-us/library/7c5ka91b.aspx) modifier if both classes are in the same assembly. With your example: ``` namespace Test { class One { public void AccessibleToAll() { } internal void AccessibleWithinSameNamespace() { ...
219,870
<p>I have a WordPress site (2.6.2) in which I have set the Home page to a static page instead of the normal posts page. The ID of this page is 2, so in the WordPress template I have changed the <code>wp_list_pages</code> to look like this:</p> <pre><code>&lt;?php wp_list_pages('exclude=2&amp;title_li=&amp;depth=1' ); ...
[ { "answer_id": 219911, "author": "Ruben", "author_id": 26919, "author_profile": "https://Stackoverflow.com/users/26919", "pm_score": 2, "selected": false, "text": "<p>You can set a static page as the front page in the Administration > Settings > Reading panel after logging in as the admi...
2008/10/20
[ "https://Stackoverflow.com/questions/219870", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8047/" ]
I have a WordPress site (2.6.2) in which I have set the Home page to a static page instead of the normal posts page. The ID of this page is 2, so in the WordPress template I have changed the `wp_list_pages` to look like this: ``` <?php wp_list_pages('exclude=2&title_li=&depth=1' ); ?> ``` this works fine, but now th...
Setting a static page as the front page doens't highlight the menu link, which is at the heart of the question. So, you could server-side customize (hack) the wp\_list\_pages function, but here's a client-side option if you so choose: Use the jQuery library (conveniently it comes with WP 2.2+), call: ``` wp_enqueue_...
219,873
<p>I've written a IE Toolbar in C# and everything is working fine except that when I open a child Windows Form from my toolbar, the tab key doesn't work on the child form to allow me to move from field to field.</p> <p>The interesting part is that when I open my child form using form.showDialog() instead of form.show...
[ { "answer_id": 220016, "author": "Gerald", "author_id": 19404, "author_profile": "https://Stackoverflow.com/users/19404", "pm_score": 1, "selected": false, "text": "<p>Are you also implementing HasFocusIO? I believe your main toolbar class must also implement HasFocusIO and return true.<...
2008/10/20
[ "https://Stackoverflow.com/questions/219873", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26500/" ]
I've written a IE Toolbar in C# and everything is working fine except that when I open a child Windows Form from my toolbar, the tab key doesn't work on the child form to allow me to move from field to field. The interesting part is that when I open my child form using form.showDialog() instead of form.show() the tabs...
Are you also implementing HasFocusIO? I believe your main toolbar class must also implement HasFocusIO and return true. These types of problems with IE toolbars were the bane of my existence for a while. I think what I eventually ended up doing was creating separate UI threads and making my dialogs modal in those thre...
219,881
<p>Is there a preference or behavior difference between using:</p> <pre><code>if(obj.getClass().isArray()) {} </code></pre> <p>and</p> <pre><code>if(obj instanceof Object[]) {} </code></pre> <p>?</p>
[ { "answer_id": 219891, "author": "Burkhard", "author_id": 12860, "author_profile": "https://Stackoverflow.com/users/12860", "pm_score": 5, "selected": false, "text": "<p>In the latter case, if obj is null you won't get a NullPointerException but a false.</p>\n" }, { "answer_id": ...
2008/10/20
[ "https://Stackoverflow.com/questions/219881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5309/" ]
Is there a preference or behavior difference between using: ``` if(obj.getClass().isArray()) {} ``` and ``` if(obj instanceof Object[]) {} ``` ?
In most cases, you should use the `instanceof` operator to test whether an object is an array. Generally, you test an object's type before downcasting to a particular type which is known at compile time. For example, perhaps you wrote some code that can work with a `Integer[]` or an `int[]`. You'd want to guard your c...
219,904
<p>If I have a property that I want to let inheritors write to, but keep readonly externally, what is the preferred way to implement this? I usually go with something like this:</p> <pre><code>private object m_myProp; public object MyProp { get { return m_myProp; } } protected void SetMyProp(object value) { m_...
[ { "answer_id": 219913, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 6, "selected": true, "text": "<pre><code>private object m_myProp;\npublic object MyProp\n{\n get { return m_myProp; }\n protected set { m_myPr...
2008/10/20
[ "https://Stackoverflow.com/questions/219904", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27414/" ]
If I have a property that I want to let inheritors write to, but keep readonly externally, what is the preferred way to implement this? I usually go with something like this: ``` private object m_myProp; public object MyProp { get { return m_myProp; } } protected void SetMyProp(object value) { m_myProp = value...
``` private object m_myProp; public object MyProp { get { return m_myProp; } protected set { m_myProp = value; } } ``` Or in C# 3.0 ``` public object MyProp {get; protected set;} ```
219,914
<p>I've often used pointers to const objects, like so...</p> <pre><code>const int *p; </code></pre> <p>That simply means that you can't change the integer that <code>p</code> is pointing at through <code>p</code>. But I've also seen reference to const pointers, declared like this...</p> <pre><code>int* const p; </co...
[ { "answer_id": 219932, "author": "James Curran", "author_id": 12725, "author_profile": "https://Stackoverflow.com/users/12725", "pm_score": 2, "selected": false, "text": "<p>Same as a \"const int\" ... if the compiler knows it's not going to change, it can be optimization assumptions bas...
2008/10/20
[ "https://Stackoverflow.com/questions/219914", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12193/" ]
I've often used pointers to const objects, like so... ``` const int *p; ``` That simply means that you can't change the integer that `p` is pointing at through `p`. But I've also seen reference to const pointers, declared like this... ``` int* const p; ``` As I understand it, that means that the pointer variable ...
When you're designing C programs for embedded systems, or special purpose programs that need to refer to the same memory (multi-processor applications sharing memory) then you need constant pointers. For instance, I have a [32 bit MIPs processor](http://flickr.com/photos/adavis/2945502665/) that has a [little LCD](htt...
219,982
<p>e.g,</p> <pre><code>foo1 foo2 foo10 foo100 </code></pre> <p>rather than</p> <pre><code>foo1 foo10 foo100 foo2 </code></pre> <p>Update: not interested in coding the sort myself (although that's interesting in its own right), but having the database to do the sort for me.</p>
[ { "answer_id": 219985, "author": "Mark Harrison", "author_id": 116, "author_profile": "https://Stackoverflow.com/users/116", "pm_score": 4, "selected": true, "text": "<p>You can use functions in your order-by clause. In this case,\nyou can split the non-numeric and numeric portions of t...
2008/10/20
[ "https://Stackoverflow.com/questions/219982", "https://Stackoverflow.com", "https://Stackoverflow.com/users/116/" ]
e.g, ``` foo1 foo2 foo10 foo100 ``` rather than ``` foo1 foo10 foo100 foo2 ``` Update: not interested in coding the sort myself (although that's interesting in its own right), but having the database to do the sort for me.
You can use functions in your order-by clause. In this case, you can split the non-numeric and numeric portions of the field and use them as two of the ordering criteria. ``` select * from t order by to_number(regexp_substr(a,'^[0-9]+')), to_number(regexp_substr(a,'[0-9]+$')), a; ``` You can als...
220,010
<p>Ok, so I know that global variables are considered bad, and the singleton pattern is overused. And I have read in many places that a class should do only one task and contain only those variables that allow it to accomplish that one task. However, while working on my latest project, I actually thought about these r...
[ { "answer_id": 220056, "author": "Jeffrey L Whitledge", "author_id": 10174, "author_profile": "https://Stackoverflow.com/users/10174", "pm_score": 0, "selected": false, "text": "<p>If I am understanding you correctly, it sounds like the lifetime of your dialog objects is too long. Rather...
2008/10/20
[ "https://Stackoverflow.com/questions/220010", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23504/" ]
Ok, so I know that global variables are considered bad, and the singleton pattern is overused. And I have read in many places that a class should do only one task and contain only those variables that allow it to accomplish that one task. However, while working on my latest project, I actually thought about these rules...
I find that storing singletons as public data attributes of the main dialog class of an MFC dialog application works OK for a quick and dirty program. However, as the program becomes larger and more complex, things begin to get untidy. The point where storing singletons in the dialog class needs to be refactored is pr...
220,020
<h2>Caution: This question is over nine years old!</h2> <p>Your best option is to search for newer questions, or to search the answers below looking for your specific version of MVC, as many answers here are obsolete now. </p> <p>If you do find an answer that works for your version, please make sure the answer cont...
[ { "answer_id": 220041, "author": "mmacaulay", "author_id": 22152, "author_profile": "https://Stackoverflow.com/users/22152", "pm_score": 5, "selected": false, "text": "<p>Here's what I've been doing.</p>\n\n<p>View:</p>\n\n<pre>\n<code>\n&lt;input type=\"checkbox\" name=\"applyChanges\" ...
2008/10/20
[ "https://Stackoverflow.com/questions/220020", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Caution: This question is over nine years old! ---------------------------------------------- Your best option is to search for newer questions, or to search the answers below looking for your specific version of MVC, as many answers here are obsolete now. If you do find an answer that works for your version, please...
Html.CheckBox is doing something weird - if you view source on the resulting page, you'll see there's an `<input type="hidden" />` being generated alongside each checkbox, which explains the "true false" values you're seeing for each form element. Try this, which definitely works on ASP.NET MVC Beta because I've just ...
220,021
<p>I am trying to use log4net in an ASP.NET application with Visual Studio 2005. I have declared an instance of the logger like so:</p> <pre><code>Private Shared ReadOnly log As ILog = LogManager.GetLogger("") </code></pre> <p>I am trying to use it in the following manner:</p> <pre><code>If log.IsDebugEnabled Then ...
[ { "answer_id": 220034, "author": "Anson Smith", "author_id": 28685, "author_profile": "https://Stackoverflow.com/users/28685", "pm_score": 6, "selected": true, "text": "<p>Before calling LogManager.GetLogger(\"\")</p>\n\n<p>You have to call log4net.Config.XmlConfigurator.Configure(); \nI...
2008/10/20
[ "https://Stackoverflow.com/questions/220021", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19977/" ]
I am trying to use log4net in an ASP.NET application with Visual Studio 2005. I have declared an instance of the logger like so: ``` Private Shared ReadOnly log As ILog = LogManager.GetLogger("") ``` I am trying to use it in the following manner: ``` If log.IsDebugEnabled Then log.Debug("Integration Services Con...
Before calling LogManager.GetLogger("") You have to call log4net.Config.XmlConfigurator.Configure(); In an ASP.NET app you probably want to put this call in Application\_Start
220,031
<p>Previously, settings for deployments of an ASP.NET application were stored in multiple configuration files under the Web.config config sections using a KEY/VALUE format. We are moving these 'site module options' to the database for a variety of reasons. </p> <p>Here are the two options we are mulling over at the mo...
[ { "answer_id": 223450, "author": "Brad Patton", "author_id": 27989, "author_profile": "https://Stackoverflow.com/users/27989", "pm_score": 1, "selected": false, "text": "<p>If I understand what you are proposing correctly. I would do the first approach. It leverages what you have already...
2008/10/20
[ "https://Stackoverflow.com/questions/220031", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Previously, settings for deployments of an ASP.NET application were stored in multiple configuration files under the Web.config config sections using a KEY/VALUE format. We are moving these 'site module options' to the database for a variety of reasons. Here are the two options we are mulling over at the moment: 1....
If I understand what you are proposing correctly. I would do the first approach. It leverages what you have already built. I would use the hash tables for caching inside of wrapper classes that can provide stongly typed interfaces for the properties. For example: ``` /// <summary> /// The time passwords expire, in da...
220,051
<p>I'm not the best at PHP and would be extremely grateful if somebody could help. Basically I need to parse each line of a datafeed and just get each bit of information between each "|" - then I can add it to a database. I think I can handle getting the information from between the "|"'s by using explode but I need a ...
[ { "answer_id": 220072, "author": "Randy", "author_id": 9361, "author_profile": "https://Stackoverflow.com/users/9361", "pm_score": 3, "selected": true, "text": "<p>You can read a file into an array of lines and do all the splitting with:</p>\n\n<pre><code>$lines = file(\"filename\");\nfo...
2008/10/20
[ "https://Stackoverflow.com/questions/220051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26823/" ]
I'm not the best at PHP and would be extremely grateful if somebody could help. Basically I need to parse each line of a datafeed and just get each bit of information between each "|" - then I can add it to a database. I think I can handle getting the information from between the "|"'s by using explode but I need a bit...
You can read a file into an array of lines and do all the splitting with: ``` $lines = file("filename"); foreach($lines as $line) { $parts = explode("|", $line); // do the database inserts here } ``` If you already have all the text in a variable as you said (e.g., with something like file\_get\_contents() )...
220,097
<p>I'm trying to find out how to read/write to the extended file properties in C# e.g. Comment, Bit Rate, Date Accessed, Category etc that you can see in Windows explorer. Any ideas how to do this? EDIT: I'll mainly be reading/writing to video files (AVI/DIVX/...)</p>
[ { "answer_id": 220141, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 5, "selected": false, "text": "<p>There's <a href=\"http://www.codeproject.com/KB/shell/shellid3tagreader.aspx\" rel=\"noreferrer\">a CodeProject artic...
2008/10/20
[ "https://Stackoverflow.com/questions/220097", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1769/" ]
I'm trying to find out how to read/write to the extended file properties in C# e.g. Comment, Bit Rate, Date Accessed, Category etc that you can see in Windows explorer. Any ideas how to do this? EDIT: I'll mainly be reading/writing to video files (AVI/DIVX/...)
For those of not crazy about VB, here it is in c#: Note, you have to add a reference to *Microsoft Shell Controls and Automation* from the COM tab of the References dialog. ``` public static void Main(string[] args) { List<string> arrHeaders = new List<string>(); Shell32.Shell shell = new Shell32.Shell(); ...
220,100
<p>How do I enable double-buffering of a control using C# (Windows forms)?</p> <p>I have a panel control which I am drawing stuff into and also an owner-drawn tab control. Both suffer from flicker, so how can I enable double-buffering?</p>
[ { "answer_id": 220107, "author": "Gulzar Nazim", "author_id": 4337, "author_profile": "https://Stackoverflow.com/users/4337", "pm_score": 1, "selected": false, "text": "<p>some info here:</p>\n\n<p><a href=\"https://stackoverflow.com/questions/76993/how-to-double-buffer-net-controls-on-a...
2008/10/20
[ "https://Stackoverflow.com/questions/220100", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13227/" ]
How do I enable double-buffering of a control using C# (Windows forms)? I have a panel control which I am drawing stuff into and also an owner-drawn tab control. Both suffer from flicker, so how can I enable double-buffering?
In the constructor of your control, set the DoubleBuffered property, and/or ControlStyle appropriately. For example, I have a simple DoubleBufferedPanel whose constructor is the following: ``` this.DoubleBuffered = true; this.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ...
220,123
<p>I am trying to write a little backup program for friends and family and want it to be as simple to use a possible. I don't want to have to ask the user where to backup their data to, I just want to search for and use the first USB hard drive connected to the computer. Obtaining the unique ID of the hard drive would ...
[ { "answer_id": 220148, "author": "Adam Davis", "author_id": 2915, "author_profile": "https://Stackoverflow.com/users/2915", "pm_score": 0, "selected": false, "text": "<p>A few pieces of information can be gathered without too much trouble:</p>\n\n<ul>\n<li>Use GetDriveType to find the fi...
2008/10/20
[ "https://Stackoverflow.com/questions/220123", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1142/" ]
I am trying to write a little backup program for friends and family and want it to be as simple to use a possible. I don't want to have to ask the user where to backup their data to, I just want to search for and use the first USB hard drive connected to the computer. Obtaining the unique ID of the hard drive would pro...
I spent a little time looking around and found a function called SetupDiEnumDeviceInfo which did provide a solution to know whether a hard drive was removable or not but with that information I still can't (yet) map what I find back to a drive letter! Here's what I have so far (following code creates a dll): ``` #inc...
220,126
<p>Let's say I have the following code:</p> <pre><code>@sites = Site.find(session[:sites]) # will be an array of Site ids @languages = Language.for_sites(@sites) </code></pre> <p>for_sites is a named_scope in the Language model that returns the languages associated with those sites, and languages are associated with ...
[ { "answer_id": 220504, "author": "JasonOng", "author_id": 6048, "author_profile": "https://Stackoverflow.com/users/6048", "pm_score": 0, "selected": false, "text": "<p>Your instance variable @sites is an Array object and not Site so I don't think named_scope can be used. You can open up ...
2008/10/20
[ "https://Stackoverflow.com/questions/220126", "https://Stackoverflow.com", "https://Stackoverflow.com/users/140/" ]
Let's say I have the following code: ``` @sites = Site.find(session[:sites]) # will be an array of Site ids @languages = Language.for_sites(@sites) ``` for\_sites is a named\_scope in the Language model that returns the languages associated with those sites, and languages are associated with sites using has\_many th...
You could extend the array returned by Site.find. ``` class Site def find(*args) result = super result.extend LanguageAggregator if Array === result result end end module LanguageAggregator def languages Language.find(:all, :conditions => [ 'id in (?)', self.collect { |site| site.id } ]) end e...
220,142
<p>I need to output the contents of a text field using MS Query Analyzer. I have tried this:</p> <pre><code>select top 1 text from myTable </code></pre> <p>(where text is a <code>text</code> field)</p> <p>and</p> <pre><code>DECLARE @data VarChar(8000) select top 1 @data = text from myTable PRINT @data </code></pre...
[ { "answer_id": 220232, "author": "Ryan Abbott", "author_id": 27908, "author_profile": "https://Stackoverflow.com/users/27908", "pm_score": 4, "selected": true, "text": "<p>I don't think you can use varchar(MAX) in MSSQL7, so here's something that will give you all the data (note, what I'...
2008/10/20
[ "https://Stackoverflow.com/questions/220142", "https://Stackoverflow.com", "https://Stackoverflow.com/users/80/" ]
I need to output the contents of a text field using MS Query Analyzer. I have tried this: ``` select top 1 text from myTable ``` (where text is a `text` field) and ``` DECLARE @data VarChar(8000) select top 1 @data = text from myTable PRINT @data ``` The first one prints only the first 2000 or so characters and...
I don't think you can use varchar(MAX) in MSSQL7, so here's something that will give you all the data (note, what I'm understanding is you just want to visually see the data, and you aren't going put it in a variable or return it). So, this will print off the entire string so you can visually see what's in the field: ...
220,147
<p>Can someone please let me know how to get the different segments of the three rows that are intersecting in different ways using SQL? The three rows in #t2 represent sets A,B, C - I am looking for A I B, A I C, B I C, A I B I C, A' , B', C' etc., (7 possible segments with 3 rows as in a Venn diagram) where I is the ...
[ { "answer_id": 220284, "author": "Amy B", "author_id": 8155, "author_profile": "https://Stackoverflow.com/users/8155", "pm_score": 0, "selected": false, "text": "<p>How about this?</p>\n\n<pre><code>SELECT key2,\n CASE\n WHEN InA = 1 and InB = 1 and InC = 1 THEN 'ABC'\n WHEN InA = 0 a...
2008/10/20
[ "https://Stackoverflow.com/questions/220147", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26309/" ]
Can someone please let me know how to get the different segments of the three rows that are intersecting in different ways using SQL? The three rows in #t2 represent sets A,B, C - I am looking for A I B, A I C, B I C, A I B I C, A' , B', C' etc., (7 possible segments with 3 rows as in a Venn diagram) where I is the Int...
If I have understood the problem correctly, I think you may have to resort to using a loop to cope with 'n' number of rows ``` DECLARE @Key2 INT DECLARE @Subset VARCHAR(1000) DECLARE @tblResults TABLE ( Key2 INT, Subset VARCHAR(1000) ) SET @Subset = '' SELECT @Key2 = MIN(Key2) FROM #t1 WHILE @Key2 IS NOT NUL...
220,159
<p>I'd like to log the <em>call trace</em> during certain points, like failed assertions, or uncaught exceptions.</p>
[ { "answer_id": 220168, "author": "Max Stewart", "author_id": 18338, "author_profile": "https://Stackoverflow.com/users/18338", "pm_score": 3, "selected": false, "text": "<p><a href=\"https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Exceptions/Tasks/ControllingAp...
2008/10/20
[ "https://Stackoverflow.com/questions/220159", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10184/" ]
I'd like to log the *call trace* during certain points, like failed assertions, or uncaught exceptions.
This code works on any thread: ``` NSLog(@"%@", NSThread.callStackSymbols); ``` > > Returns an array containing the call stack symbols. Each element is an `NSString` object with a value in a format determined by the `backtrace_symbols()` function. > > >