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
354,097
<p>When I add a # in insert mode on an empty line in Vim while editing python files, vim moves the # to the beginning of the line, but I would like the # to be inserted at the tab level where I entered it.</p> <p>For example, when writing this in vim</p> <pre><code>for i in range(10): # </code></pre> <p>the # do...
[ { "answer_id": 354271, "author": "m0j0", "author_id": 31319, "author_profile": "https://Stackoverflow.com/users/31319", "pm_score": 1, "selected": false, "text": "<p>My Vim configuration doesn't do that. You might try the python.vim script available from this link: <a href=\"http://www...
2008/12/09
[ "https://Stackoverflow.com/questions/354097", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3045/" ]
When I add a # in insert mode on an empty line in Vim while editing python files, vim moves the # to the beginning of the line, but I would like the # to be inserted at the tab level where I entered it. For example, when writing this in vim ``` for i in range(10): # ``` the # does not stay there where I entered...
I found an answer here <http://vim.wikia.com/wiki/Restoring_indent_after_typing_hash> It seems that the vim smartindent option is the cause of the problem. The referenced page above describes work-a-rounds but after reading the help in smartindent in vim itself (:help smartindent), I decided to try cindent instead of ...
354,136
<p>How do I create the default for a generic in VB? in C# I can call:</p> <pre><code>T variable = default(T); </code></pre> <ol> <li>How do I do this in VB?</li> <li>If this just returns null (C#) or nothing (vb) then what happens to value types?</li> <li>Is there a way to specify for a custom type what the default v...
[ { "answer_id": 354142, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 6, "selected": true, "text": "<h2>Question 1:</h2>\n\n<pre><code>Dim variable As T\n' or '\nDim variable As T = Nothing\n' or '\nDim variable As New...
2008/12/09
[ "https://Stackoverflow.com/questions/354136", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17744/" ]
How do I create the default for a generic in VB? in C# I can call: ``` T variable = default(T); ``` 1. How do I do this in VB? 2. If this just returns null (C#) or nothing (vb) then what happens to value types? 3. Is there a way to specify for a custom type what the default value is? For instance what if I want the ...
Question 1: ----------- ``` Dim variable As T ' or ' Dim variable As T = Nothing ' or ' Dim variable As New T() ``` Notice that the latter only works if you specify the `Structure` constraint for the generic type (for reference types, `New T()` in VB does something else than `default(T)` in C#). Question 2: -------...
354,167
<p>In its enthusiasm to <a href="http://www.postgresql.org/docs/current/interactive/textsearch-intro.html" rel="nofollow noreferrer">stemm tokens into lexemes</a>, PostgreSQL Full Text Search engine also reduce proper nouns. For instance:</p> <pre><code>essais=&gt; select to_tsquery('english', 'bortzmeyer'); to_tsquer...
[ { "answer_id": 354256, "author": "Jasper Bekkers", "author_id": 31486, "author_profile": "https://Stackoverflow.com/users/31486", "pm_score": 3, "selected": true, "text": "<p>The point of stemming algorithms is <em>not</em> to reduce every word to its proper stem; the goal is to reduce w...
2008/12/09
[ "https://Stackoverflow.com/questions/354167", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15625/" ]
In its enthusiasm to [stemm tokens into lexemes](http://www.postgresql.org/docs/current/interactive/textsearch-intro.html), PostgreSQL Full Text Search engine also reduce proper nouns. For instance: ``` essais=> select to_tsquery('english', 'bortzmeyer'); to_tsquery ------------ 'bortzmey' essais=> select to_tsquery...
The point of stemming algorithms is *not* to reduce every word to its proper stem; the goal is to reduce words that are alike to a common stemmed form. The goal is generally not to get a word that can be presented to the user: even if 'balling' and 'ball' would both produce 'kjebnkkekaa' the algorithm is correct becaus...
354,171
<p>I am pretty new to both Struts and Spring. I need to know how to access a Spring Service in a Struts ActionForm. Even a pointer in the right direction would be appreciated.</p>
[ { "answer_id": 354205, "author": "krosenvold", "author_id": 23691, "author_profile": "https://Stackoverflow.com/users/23691", "pm_score": 1, "selected": false, "text": "<p>Normally you add the spring contextloader listener to your web xml.</p>\n\n<pre><code>&lt;listener&gt;\n &lt;listene...
2008/12/09
[ "https://Stackoverflow.com/questions/354171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am pretty new to both Struts and Spring. I need to know how to access a Spring Service in a Struts ActionForm. Even a pointer in the right direction would be appreciated.
From a struts 1 ActionForm class you'll be needing: ``` WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext).getBean("yourService"); ```
354,182
<p>Given Microsoft FORTRAN 5.1 and Microsoft C/C++ 14.0, along with the linker that comes with that version of FORTRAN (that must be used for other dependencies) how do I create a C function and call it from the FORTRAN application? </p>
[ { "answer_id": 354631, "author": "Die in Sente", "author_id": 40756, "author_profile": "https://Stackoverflow.com/users/40756", "pm_score": 2, "selected": false, "text": "<p>There's an article on MSDN with sample code here: <a href=\"http://msdn.microsoft.com/en-us/library/aa279034(VS.6...
2008/12/09
[ "https://Stackoverflow.com/questions/354182", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5070/" ]
Given Microsoft FORTRAN 5.1 and Microsoft C/C++ 14.0, along with the linker that comes with that version of FORTRAN (that must be used for other dependencies) how do I create a C function and call it from the FORTRAN application?
You have two choices. 1) I can show with example FORTRAN ``` program ftest use iso_c_bindings implicit none interface function saythis(a) ! should be subroutine if saythis returns void import :: c_ptr type(c_ptr), value :: a end function saythis end interface character(len=80), target :: str type(c_ptr) cstr ...
354,188
<p>Unlike many of the ASP.NET documentation and examples, I'm doing a gridview list on one page, and it links to a 2nd page to do the edit/update view, sending the ID for the record in the GET string.</p> <p>On my edit/update view, I'm using an ASP:DetailsView for viewing, editing and inserting records. All of this w...
[ { "answer_id": 355319, "author": "Dhaust", "author_id": 242, "author_profile": "https://Stackoverflow.com/users/242", "pm_score": 3, "selected": true, "text": "<p>I could have misunderstood your question but.... </p>\n\n<p>I don't believe you can 'link to the insert view', but what y...
2008/12/09
[ "https://Stackoverflow.com/questions/354188", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22452/" ]
Unlike many of the ASP.NET documentation and examples, I'm doing a gridview list on one page, and it links to a 2nd page to do the edit/update view, sending the ID for the record in the GET string. On my edit/update view, I'm using an ASP:DetailsView for viewing, editing and inserting records. All of this works fine. ...
I could have misunderstood your question but.... I don't believe you can 'link to the insert view', but what you can do is programmatically change the mode of the DetailsView once the page has loaded. Remember to check that the passed in ID has a value first. For example: ``` If Not idValue Is Nothing Then ...
354,194
<p>After upgrading a few gems via terminal on my mac, I have created a new rails project backed up by a mysql database. Upon starting the app, the regular welcome aboard page appears. </p> <p>Here's the problem - I tried clicking the link entitled "About your application's environment", I receive the following output ...
[ { "answer_id": 354197, "author": "bradheintz", "author_id": 40093, "author_profile": "https://Stackoverflow.com/users/40093", "pm_score": 3, "selected": false, "text": "<p>The issue is that the MySQL gem builds native extensions and needs system-specific information about where to find c...
2008/12/09
[ "https://Stackoverflow.com/questions/354194", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2294/" ]
After upgrading a few gems via terminal on my mac, I have created a new rails project backed up by a mysql database. Upon starting the app, the regular welcome aboard page appears. Here's the problem - I tried clicking the link entitled "About your application's environment", I receive the following output in my brow...
The issue is that the MySQL gem builds native extensions and needs system-specific information about where to find certain libraries. You have to provide this on the command line. Check out [this page](http://forums.mysql.com/read.php?116,204740,204740 "Mysql Gem Install Instructions") - the important bit (that worked...
354,195
<p>I'm finding that hitting the "Refresh" button on my browser will temporarily screw up the ViewState for controls inside an UpdatePanel.</p> <p>Here's my situation : I made a custom WebControl that stores values in the ViewState. I put this control inside an UpdatePanel. When I hit the "refresh" button on my brows...
[ { "answer_id": 354608, "author": "BlackMael", "author_id": 19377, "author_profile": "https://Stackoverflow.com/users/19377", "pm_score": 1, "selected": false, "text": "<p>Try the following...</p>\n\n<pre><code> protected override void LoadViewState(object savedState)\n {\n i...
2008/12/09
[ "https://Stackoverflow.com/questions/354195", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44701/" ]
I'm finding that hitting the "Refresh" button on my browser will temporarily screw up the ViewState for controls inside an UpdatePanel. Here's my situation : I made a custom WebControl that stores values in the ViewState. I put this control inside an UpdatePanel. When I hit the "refresh" button on my browser, it will ...
I just re-read your question and realised I missed something... **You are hitting the *browsers* refresh button!** Is this a problem? **YES!** What happens when you hit the refresh button on the browser? It refreshes the current page. If there was a postback, it will resend the post data. The AJAX callback may upd...
354,221
<p>What is the most efficient algorithm for grouping identical items together in an array, given the following:</p> <ol> <li>Almost all items are duplicated several times.</li> <li>The items are not necessarily integers or anything else that's similarly simple. The range of the keys is not even well-defined, let alon...
[ { "answer_id": 354227, "author": "Bill the Lizard", "author_id": 1288, "author_profile": "https://Stackoverflow.com/users/1288", "pm_score": 4, "selected": true, "text": "<p>I think you could just hash the objects, since real order doesn't matter, only grouping. Identical objects will e...
2008/12/09
[ "https://Stackoverflow.com/questions/354221", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23903/" ]
What is the most efficient algorithm for grouping identical items together in an array, given the following: 1. Almost all items are duplicated several times. 2. The items are not necessarily integers or anything else that's similarly simple. The range of the keys is not even well-defined, let alone small. In fact, th...
I think you could just hash the objects, since real order doesn't matter, only grouping. Identical objects will end up grouped in the same bucket. This is assuming that every type you're interested in has its own hash function, or you can define your own and overload it (taking each type as a parameter to a different h...
354,224
<p>Using Firebird, I want to combine the results of two queries using UNION ALL, then sort the resulting output on a given column.</p> <pre><code>(select C1, C2, C3 from T1) union all (select C1, C2, C3 from T2) order by C3 </code></pre> <p>The parentheses came from valid syntax for other databases, and are needed to ...
[ { "answer_id": 354225, "author": "Chris", "author_id": 8415, "author_profile": "https://Stackoverflow.com/users/8415", "pm_score": 1, "selected": false, "text": "<p>Perform the UNION ALL in a view (without the ORDER BY clause), then select from the view using ORDER BY.</p>\n" }, { ...
2008/12/09
[ "https://Stackoverflow.com/questions/354224", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8415/" ]
Using Firebird, I want to combine the results of two queries using UNION ALL, then sort the resulting output on a given column. ``` (select C1, C2, C3 from T1) union all (select C1, C2, C3 from T2) order by C3 ``` The parentheses came from valid syntax for other databases, and are needed to make sure the arguments ...
``` SELECT C1, C2, C3 FROM ( select C1, C2, C3 from T1 union all select C1, C2, C3 from T2 ) order by C3 ```
354,226
<p>I want to be able to run my SqlDataProvider against an oracle stored procedure. I can use Microsoft's Oracle Provider but that wouldn't allow me to call a stored procedure. has anyone been able to get this to work? I particularly want to be able to use declarative data binding. I have been able to programatically cr...
[ { "answer_id": 366442, "author": "user46119", "author_id": 46119, "author_profile": "https://Stackoverflow.com/users/46119", "pm_score": 2, "selected": false, "text": "<p>SqlDataProvider, SqlConnection and other classes prefixed Sql from the System.Data namespaces almost universally refe...
2008/12/09
[ "https://Stackoverflow.com/questions/354226", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4491/" ]
I want to be able to run my SqlDataProvider against an oracle stored procedure. I can use Microsoft's Oracle Provider but that wouldn't allow me to call a stored procedure. has anyone been able to get this to work? I particularly want to be able to use declarative data binding. I have been able to programatically creat...
SqlDataProvider, SqlConnection and other classes prefixed Sql from the System.Data namespaces almost universally refer to SQL-Server specific implementations. It is, however, possible to invoke a Stored Procedure using the System.Data.oracleClient library Microsoft have released. Please ensure that when constructing t...
354,231
<p>I'd like to use your wisdom for picking up the right solution for a data-warehouse system. Here are some details to better understand the problem:</p> <p>Data is organized in a star schema structure with one BIG fact and ~15 dimensions. <br /> 20B fact rows per month <br /> 10 dimensions with hundred rows (somew...
[ { "answer_id": 354352, "author": "ConcernedOfTunbridgeWells", "author_id": 15401, "author_profile": "https://Stackoverflow.com/users/15401", "pm_score": 6, "selected": false, "text": "<p>I cannot stress this enough: <em>Get something that plays nicely with off-the-shelf reporting tools.<...
2008/12/09
[ "https://Stackoverflow.com/questions/354231", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'd like to use your wisdom for picking up the right solution for a data-warehouse system. Here are some details to better understand the problem: Data is organized in a star schema structure with one BIG fact and ~15 dimensions. 20B fact rows per month 10 dimensions with hundred rows (somewhat hierarchy) 5 dimens...
I cannot stress this enough: *Get something that plays nicely with off-the-shelf reporting tools.* 20 Billion rows per month puts you in VLDB territory, so you need partitioning. The low cardinality dimensions would also suggest that bitmap indexes would be a performance win. * Forget the cloud systems ([Hive](http:/...
354,263
<p>Is there a CPAN module that can read a string like this:</p> <pre><code>"[[&lt;asdf&gt;, &lt;foo&gt;], (abc, def, ghi), ({'jkl'})]" </code></pre> <p>...and parse it into some sort of tree structure that's easy to walk and pretty-print?</p>
[ { "answer_id": 354294, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 1, "selected": false, "text": "<p><a href=\"http://search.cpan.org/perldoc?Parse::RecDescent\" rel=\"nofollow noreferrer\">Damian Conway's Parse::Rec...
2008/12/09
[ "https://Stackoverflow.com/questions/354263", "https://Stackoverflow.com", "https://Stackoverflow.com/users/91385/" ]
Is there a CPAN module that can read a string like this: ``` "[[<asdf>, <foo>], (abc, def, ghi), ({'jkl'})]" ``` ...and parse it into some sort of tree structure that's easy to walk and pretty-print?
I think that you could build on top of [Text::Balanced](http://search.cpan.org/dist/Text-Balanced/), which will do a lot of the heavy lifting for you. You'll still need to build a tree structure, though.
354,264
<p>So regular expressions seem to match on the longest possible match. For instance:</p> <pre><code>public static void main(String[] args) { String s = "ClarkRalphKentGuyGreenGardnerClarkSupermanKent"; Pattern p = Pattern.compile("Clark.*Kent", Pattern.CASE_INSENSITIVE); Matcher myMatcher = p.matcher(s); ...
[ { "answer_id": 354289, "author": "Gareth Davis", "author_id": 31480, "author_profile": "https://Stackoverflow.com/users/31480", "pm_score": 4, "selected": true, "text": "<p>greedy vs reluctant is your friend here.</p>\n\n<p>try: <code>Clark.+?Kent</code></p>\n" }, { "answer_id": ...
2008/12/09
[ "https://Stackoverflow.com/questions/354264", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34410/" ]
So regular expressions seem to match on the longest possible match. For instance: ``` public static void main(String[] args) { String s = "ClarkRalphKentGuyGreenGardnerClarkSupermanKent"; Pattern p = Pattern.compile("Clark.*Kent", Pattern.CASE_INSENSITIVE); Matcher myMatcher = p.matcher(s); int i = 1; ...
greedy vs reluctant is your friend here. try: `Clark.+?Kent`
354,288
<p>I'm having a problem using CSS's <code>display:inline</code> property with the <code>list-style-image:</code> property on <code>&lt;li&gt;</code> tags. Basically, I want to output the following:</p> <pre><code>* Link 1 * Link 2 </code></pre> <p>where <code>*</code> represents an image.</p> <p>I'm doing this with...
[ { "answer_id": 354297, "author": "annakata", "author_id": 13018, "author_profile": "https://Stackoverflow.com/users/13018", "pm_score": 6, "selected": true, "text": "<p>Try using <code>float: left</code> (or <code>right</code>) instead of <code>display: inline</code>. Inline display repl...
2008/12/09
[ "https://Stackoverflow.com/questions/354288", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28804/" ]
I'm having a problem using CSS's `display:inline` property with the `list-style-image:` property on `<li>` tags. Basically, I want to output the following: ``` * Link 1 * Link 2 ``` where `*` represents an image. I'm doing this with the following bit of HTML: ``` <ol class="widgets"> <li class="l1">Link 1</li...
Try using `float: left` (or `right`) instead of `display: inline`. Inline display replaces list-item display, which is what adds the bullet points.
354,309
<p>I am trying to do some simple formatting stuff with 'sed' in linux, and i need to use a regex to trim a string after the 15th character, and append a '...' to the end. Something like this:</p> <pre><code>before: this is a long string that needs to be shortened after: this is a long ... </code></pre> <p>Can anyone ...
[ { "answer_id": 354318, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 5, "selected": true, "text": "<p>The following works for me:</p>\n\n<pre><code>echo \"This is a test with more than 15 characters\" | sed \"s/\\(.\\...
2008/12/09
[ "https://Stackoverflow.com/questions/354309", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18811/" ]
I am trying to do some simple formatting stuff with 'sed' in linux, and i need to use a regex to trim a string after the 15th character, and append a '...' to the end. Something like this: ``` before: this is a long string that needs to be shortened after: this is a long ... ``` Can anyone please show me how i could...
The following works for me: ``` echo "This is a test with more than 15 characters" | sed "s/\(.\{15\}\).\+$/\1…/" ``` What happens here is that we match any character ( `.`) 15 times (`{15}`). We capture the text so matched inside parentheses. The following part (`.+$`) matches all the rest, until the end of the lin...
354,312
<p>When you run <code>git branch -r</code> why the blazes does it list <code>origin/HEAD</code>? For example, there's a remote repo on GitHub, say, with two branches: master and awesome-feature. If I do <code>git clone</code> to grab it and then go into my new directory and list the branches, I see this:</p> <pre><cod...
[ { "answer_id": 354617, "author": "Dustin", "author_id": 39975, "author_profile": "https://Stackoverflow.com/users/39975", "pm_score": -1, "selected": false, "text": "<p>My guess is that someone pushed a branch and called it HEAD:</p>\n\n<pre><code>git push origin HEAD\n</code></pre>\n" ...
2008/12/09
[ "https://Stackoverflow.com/questions/354312", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9619/" ]
When you run `git branch -r` why the blazes does it list `origin/HEAD`? For example, there's a remote repo on GitHub, say, with two branches: master and awesome-feature. If I do `git clone` to grab it and then go into my new directory and list the branches, I see this: ``` $ git branch -r origin/HEAD origin/master ori...
**@robinst** is correct. In git, you can select which branch is checked out by default (i.e. when you clone). By default, `origin/HEAD` will point at that. On GitHub, [You can change this](https://github.com/blog/421-pick-your-default-branch) in the Admin settings for your GitHub repo. You can also do it from the com...
354,313
<p>How can I force the input's onchange script to run <em>before</em> the RangeValidator's script? </p> <p>I want to prevent a failed validation when the user enters a dollar sign or comma.</p> <pre><code>function cleanUp(str) { re = /^\$|,/g; return str.replace(re, ""); // remove "$" and "," } &lt;input ty...
[ { "answer_id": 354375, "author": "Victor", "author_id": 42518, "author_profile": "https://Stackoverflow.com/users/42518", "pm_score": 0, "selected": false, "text": "<p>There is a way to do this by registering the script; however why not use a Regular Expression Validator to make sure the...
2008/12/09
[ "https://Stackoverflow.com/questions/354313", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23566/" ]
How can I force the input's onchange script to run *before* the RangeValidator's script? I want to prevent a failed validation when the user enters a dollar sign or comma. ``` function cleanUp(str) { re = /^\$|,/g; return str.replace(re, ""); // remove "$" and "," } <input type="text" id="salary" runat="ser...
Have you tried using a CustomerValidator control and combined the functionality of the JS cleanup methods and the RangeValidator method.
354,329
<p>I'm trying to set an invalid value to -1.. But I don't like magic numbers.. Anyone know where to find a set of common constants. I'm working in VS6 (ish). </p> <p>I'm trying to read a file from across a network, and I need a bad value for the total file size,so I know if I got valid info on it.. 0 is a valid size s...
[ { "answer_id": 354343, "author": "Steven A. Lowe", "author_id": 9345, "author_profile": "https://Stackoverflow.com/users/9345", "pm_score": 3, "selected": true, "text": "<pre><code>#define BAD_VALUE -1\n</code></pre>\n\n<p>EDIT: the original question had no context. The revised question ...
2008/12/09
[ "https://Stackoverflow.com/questions/354329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31325/" ]
I'm trying to set an invalid value to -1.. But I don't like magic numbers.. Anyone know where to find a set of common constants. I'm working in VS6 (ish). I'm trying to read a file from across a network, and I need a bad value for the total file size,so I know if I got valid info on it.. 0 is a valid size so I can't ...
``` #define BAD_VALUE -1 ``` EDIT: the original question had no context. The revised question indicates you want an invalid file size and are thus looking for the win32 constants. Look at [windows.h](http://en.wikipedia.org/wiki/Windows.h) i think the constant you seek may be in [windows.h](http://en.wikipedia.org/wi...
354,330
<p>I'm concerned that this might be working on an NP-Complete problem. I'm hoping someone can give me an answer as to whether it is or not. And I'm looking for more of an answer than just yes or no. I'd like to know why. If you can say,"This is basically this problem 'x' which is/is not NP-Complete. (wikipedia link)"</...
[ { "answer_id": 354335, "author": "Steven A. Lowe", "author_id": 9345, "author_profile": "https://Stackoverflow.com/users/9345", "pm_score": 2, "selected": false, "text": "<p>not NP-complete, solved with a well-known solution - <a href=\"http://en.wikipedia.org/wiki/Dijkstra&#39;s_algorit...
2008/12/09
[ "https://Stackoverflow.com/questions/354330", "https://Stackoverflow.com", "https://Stackoverflow.com/users/685/" ]
I'm concerned that this might be working on an NP-Complete problem. I'm hoping someone can give me an answer as to whether it is or not. And I'm looking for more of an answer than just yes or no. I'd like to know why. If you can say,"This is basically this problem 'x' which is/is not NP-Complete. (wikipedia link)" (No...
See <http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm> , your one stop shop for all graph related problems. I believe your problem is in fact solvable in quadratic time.
354,349
<p>Is it possible to change the auto-increment offset on a pre-existing table with JavaDB? </p> <p>I'm having a problem where inserting new records usually (but not always) fails with an error complaining about using an existing key (my auto-increment column). To populate this database, I took a dump from another da...
[ { "answer_id": 354517, "author": "Tim Frey", "author_id": 1471, "author_profile": "https://Stackoverflow.com/users/1471", "pm_score": 1, "selected": true, "text": "<p>I don't know how to directly change the offset, but I managed to fix this by:</p>\n\n<ol>\n<li>Changing the increment amo...
2008/12/09
[ "https://Stackoverflow.com/questions/354349", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1471/" ]
Is it possible to change the auto-increment offset on a pre-existing table with JavaDB? I'm having a problem where inserting new records usually (but not always) fails with an error complaining about using an existing key (my auto-increment column). To populate this database, I took a dump from another database (MySQ...
I don't know how to directly change the offset, but I managed to fix this by: 1. Changing the increment amount by X (1 million in my case). 2. Inserting a dummy record. 3. Reducing the increment amount back down to 1. 4. Deleting the dummy record. I used this SQL statement to change the increment amount: ``` ALTER T...
354,354
<p>I'm using StructureMap in my project and when the application finishes running I need to call the Dispose() method on all of the Singleton instances inside the ObjectFactory that implement IDisposable.</p> <p>I cannot find anyway to do it via the StructureMap API.</p> <p>Another thought I had was to get a referenc...
[ { "answer_id": 354517, "author": "Tim Frey", "author_id": 1471, "author_profile": "https://Stackoverflow.com/users/1471", "pm_score": 1, "selected": true, "text": "<p>I don't know how to directly change the offset, but I managed to fix this by:</p>\n\n<ol>\n<li>Changing the increment amo...
2008/12/09
[ "https://Stackoverflow.com/questions/354354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8739/" ]
I'm using StructureMap in my project and when the application finishes running I need to call the Dispose() method on all of the Singleton instances inside the ObjectFactory that implement IDisposable. I cannot find anyway to do it via the StructureMap API. Another thought I had was to get a reference to every instan...
I don't know how to directly change the offset, but I managed to fix this by: 1. Changing the increment amount by X (1 million in my case). 2. Inserting a dummy record. 3. Reducing the increment amount back down to 1. 4. Deleting the dummy record. I used this SQL statement to change the increment amount: ``` ALTER T...
354,369
<p>In C# how do I still show the headers of a gridview, even with the data source is empty. </p> <p>I am not auto generating the columns as they are all predefined. </p> <p>Currently what I am doing is the following.</p> <p>Get a DataTable back from a stored procedure, then set the DataSource of the gridview, and th...
[ { "answer_id": 354391, "author": "Joshua Hudson", "author_id": 6232, "author_profile": "https://Stackoverflow.com/users/6232", "pm_score": 5, "selected": false, "text": "<p>After posting this I did come up with a way that works. However, I don't feel it is the best way to handle this. An...
2008/12/09
[ "https://Stackoverflow.com/questions/354369", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6232/" ]
In C# how do I still show the headers of a gridview, even with the data source is empty. I am not auto generating the columns as they are all predefined. Currently what I am doing is the following. Get a DataTable back from a stored procedure, then set the DataSource of the gridview, and then call DataBind(). Thi...
ASP.Net 4.0 added the boolean `ShowHeaderWhenEmpty` property. <http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.showheaderwhenempty.aspx> --- ``` <asp:GridView runat="server" ID="GridView1" ShowHeaderWhenEmpty="true" AutoGenerateColumns="false"> <Columns> <asp:BoundField HeaderT...
354,385
<p>I would like to create a view similar to the "Now Playing" page on the iPhone and have 3 lines of text in the Navigation bar.</p> <p>The only way I could find to do this was:</p> <pre><code>UINavigationBar *bar = [self.navigationController navigationBar]; label = [[UILabel alloc] initWithFrame:CGRectMake(60, 2,...
[ { "answer_id": 354434, "author": "Heat Miser", "author_id": 3484, "author_profile": "https://Stackoverflow.com/users/3484", "pm_score": 2, "selected": false, "text": "<p>You could try creating a UIViewController with your labels positioned correctly, and then instantiate it, like UIViewC...
2008/12/09
[ "https://Stackoverflow.com/questions/354385", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I would like to create a view similar to the "Now Playing" page on the iPhone and have 3 lines of text in the Navigation bar. The only way I could find to do this was: ``` UINavigationBar *bar = [self.navigationController navigationBar]; label = [[UILabel alloc] initWithFrame:CGRectMake(60, 2, 200, 14)]; label.tag...
You could try creating a UIViewController with your labels positioned correctly, and then instantiate it, like UIViewControllerSubclass \*sub = [[UIViewControllerSubclass alloc] init]; Within the UIViewController subclass, you would have to build up your view in the loadView delegate method and attach each label's vie...
354,386
<p>I have a Windows Mobile application using the compact framework (NETCF) that I would like to respond to someone pressing the send key and have the phone dial the number selected in my application. Is there a way using the compact framework to trap the send key? I have looked at several articles on capturing keys,...
[ { "answer_id": 354432, "author": "Quibblesome", "author_id": 1143, "author_profile": "https://Stackoverflow.com/users/1143", "pm_score": 2, "selected": false, "text": "<p>You can catch all keys in teh worlds (apart from CTRL+ALT+DEL on desktop) via a keyhook:</p>\n\n<p><a href=\"http://w...
2008/12/09
[ "https://Stackoverflow.com/questions/354386", "https://Stackoverflow.com", "https://Stackoverflow.com/users/791/" ]
I have a Windows Mobile application using the compact framework (NETCF) that I would like to respond to someone pressing the send key and have the phone dial the number selected in my application. Is there a way using the compact framework to trap the send key? I have looked at several articles on capturing keys, but I...
I can confirm that using SHCMBM\_OVERRIDEKEY works on both PPC and SP devices. I have tested it on WM5 PPC, WM5 SP, WM6 PPC, WM6 SP. I have not tried WM6.1 or WM6.5 yet but I kind-of assume that they work since WM6 works. Also you may need to support DTMF during the call as well? Since I was writing a LAP dll I follo...
354,393
<p>** Dup: <a href="https://stackoverflow.com/questions/226002/whats-the-difference-between-x-x-vs-x">What&#39;s the difference between X = X++; vs X++;?</a> **</p> <p>So, even though I know you would never actually do this in code, I'm still curious:</p> <pre><code>public static void main(String[] args) { int in...
[ { "answer_id": 354398, "author": "Jimmy", "author_id": 4435, "author_profile": "https://Stackoverflow.com/users/4435", "pm_score": 3, "selected": true, "text": "<p>this is a duplicate question. </p>\n\n<p><b>EDIT:</b> I can't seem to find the original :P oh well</p>\n\n<p>a = a++ uses th...
2008/12/09
[ "https://Stackoverflow.com/questions/354393", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1666/" ]
\*\* Dup: [What's the difference between X = X++; vs X++;?](https://stackoverflow.com/questions/226002/whats-the-difference-between-x-x-vs-x) \*\* So, even though I know you would never actually do this in code, I'm still curious: ``` public static void main(String[] args) { int index = 0; System.out.println(...
this is a duplicate question. **EDIT:** I can't seem to find the original :P oh well a = a++ uses the postincrement, which your compiler interprets as: ``` a = function() { var old_value = a; a++; return old_value; } ``` **EDIT 2:** [What's the difference between X = X++; vs X++;?](https://stackoverflow....
354,408
<p>It seems like when you have a WinForms .NET application, and a ComboBox (set to the "DropDown" style), and that ComboBox has multiple items in it that are identical, weird things happen. Specifically, the index of the selected item can change <em>without</em> firing the SelectedIndexChanged event. </p> <p>Of course...
[ { "answer_id": 355012, "author": "Eric Rosenberger", "author_id": 41624, "author_profile": "https://Stackoverflow.com/users/41624", "pm_score": 5, "selected": true, "text": "<p>The .NET Framework does not actually keep track of the selected index of the combo box's drop down list; this i...
2008/12/09
[ "https://Stackoverflow.com/questions/354408", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5956/" ]
It seems like when you have a WinForms .NET application, and a ComboBox (set to the "DropDown" style), and that ComboBox has multiple items in it that are identical, weird things happen. Specifically, the index of the selected item can change *without* firing the SelectedIndexChanged event. Of course, this causes mas...
The .NET Framework does not actually keep track of the selected index of the combo box's drop down list; this is handled internally by the Windows API. As a consequence of this, .NET is reliant on the Windows API to notify it when the selected index changes by means of a notification message sent to the combo box's win...
354,414
<p>Can anybody help me to build an XSD file to validate XMLs like these:</p> <pre><code>[test] [a/] [b/] [a/] [b/] [/test] [test] [a/] [a/] [b/] [/test] </code></pre> <p>Basically, I can have any number of <code>&lt;a&gt;</code> and/or <code>&lt;b&gt;</code> nodes without any other rule (can't use <code>&lt;xs:seque...
[ { "answer_id": 354461, "author": "George Stocker", "author_id": 16587, "author_profile": "https://Stackoverflow.com/users/16587", "pm_score": 0, "selected": false, "text": "<p>If you paste the sample XML, we can help you better. However, <a href=\"https://stackoverflow.com/questions/2882...
2008/12/09
[ "https://Stackoverflow.com/questions/354414", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44769/" ]
Can anybody help me to build an XSD file to validate XMLs like these: ``` [test] [a/] [b/] [a/] [b/] [/test] [test] [a/] [a/] [b/] [/test] ``` Basically, I can have any number of `<a>` and/or `<b>` nodes without any other rule (can't use `<xs:sequence>`).
It isn't going to very fast if you have a lot of **a** or **b** nodes but this validates against what you've described. ``` <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="test"> <xs:complexType> <xs:sequence> <xs:choice maxOccurs="unbounded"> <xs:element name="a...
354,415
<p>I'm using VS2008 Team Suite, ASP.NET MVC Beta, with TestDriven.Net installed. When I created my project from the template, it created a "Tests" project as well and put some controller tests for the AccountController in a folder inside this project. I've added other controllers and associated tests. Howerver, when ...
[ { "answer_id": 354461, "author": "George Stocker", "author_id": 16587, "author_profile": "https://Stackoverflow.com/users/16587", "pm_score": 0, "selected": false, "text": "<p>If you paste the sample XML, we can help you better. However, <a href=\"https://stackoverflow.com/questions/2882...
2008/12/09
[ "https://Stackoverflow.com/questions/354415", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12950/" ]
I'm using VS2008 Team Suite, ASP.NET MVC Beta, with TestDriven.Net installed. When I created my project from the template, it created a "Tests" project as well and put some controller tests for the AccountController in a folder inside this project. I've added other controllers and associated tests. Howerver, when I rig...
It isn't going to very fast if you have a lot of **a** or **b** nodes but this validates against what you've described. ``` <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="test"> <xs:complexType> <xs:sequence> <xs:choice maxOccurs="unbounded"> <xs:element name="a...
354,419
<p>I'm migrating to Nhibernate 2.0 GA but have some trouble with setting cache expirations in memcached provider.</p> <p>I see in the NHibernate.Caches.MemCache sources that there is a property for expiration and a default value for 300 seconds. </p> <p>There are also properties for cache regions but the config secti...
[ { "answer_id": 363072, "author": "kͩeͣmͮpͥ ͩ", "author_id": 26479, "author_profile": "https://Stackoverflow.com/users/26479", "pm_score": 0, "selected": false, "text": "<p>As far as I understand, the cache expiry time is provider specific as some cache providers don't support this. \nAls...
2008/12/09
[ "https://Stackoverflow.com/questions/354419", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43853/" ]
I'm migrating to Nhibernate 2.0 GA but have some trouble with setting cache expirations in memcached provider. I see in the NHibernate.Caches.MemCache sources that there is a property for expiration and a default value for 300 seconds. There are also properties for cache regions but the config section handler does n...
Use expiration. ``` <property name="expiration" >YOUR_INTERVAL_IN_SECONDS</property> ``` After that, when you run app with logging you can see: ``` NHibernate.Caches.MemCache.MemCacheClient: 20:57:55,762 DEBUG MemCacheClient:0 - using expiration of YOUR_INTERVAL_IN_SECONDS seconds ```
354,421
<p>I'm wondering where I find the source to show how the operator ** is implemented in Python. Can someone point me in the right direction? </p>
[ { "answer_id": 354433, "author": "Zoomulator", "author_id": 44563, "author_profile": "https://Stackoverflow.com/users/44563", "pm_score": 0, "selected": false, "text": "<p>It's the power to operator</p>\n\n<p><a href=\"http://www.python.org/doc/2.5.2/ref/power.html\" rel=\"nofollow noref...
2008/12/09
[ "https://Stackoverflow.com/questions/354421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41718/" ]
I'm wondering where I find the source to show how the operator \*\* is implemented in Python. Can someone point me in the right direction?
The python grammar definition (from which the parser is generated using [pgen](http://www.python.org/dev/peps/pep-0269/)), look for 'power': [Gramar/Gramar](http://svn.python.org/view/python/trunk/Grammar/Grammar?rev=65872&view=markup) The python ast, look for 'ast\_for\_power': [Python/ast.c](http://svn.python.org/vi...
354,442
<p>Before I write my own I will ask all y'all.</p> <p>I'm looking for a C++ class that is almost exactly like a STL vector but stores data into an array on the stack. Some kind of STL allocator class would work also, but I am trying to avoid any kind of heap, even static allocated per-thread heaps (although one of th...
[ { "answer_id": 354455, "author": "Mark Ransom", "author_id": 5987, "author_profile": "https://Stackoverflow.com/users/5987", "pm_score": 3, "selected": false, "text": "<p>You can use your own allocator for std::vector and have it allocate chunks of your stack-based storage, similar to yo...
2008/12/09
[ "https://Stackoverflow.com/questions/354442", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13422/" ]
Before I write my own I will ask all y'all. I'm looking for a C++ class that is almost exactly like a STL vector but stores data into an array on the stack. Some kind of STL allocator class would work also, but I am trying to avoid any kind of heap, even static allocated per-thread heaps (although one of those is my s...
You don't have to write a completely new container class. You can stick with your STL containers, but change the second parameter of for example `std::vector` to give it your custom allocator which allocates from a stack-buffer. The chromium authors wrote an allocator just for this: <https://chromium.googlesource.com/...
354,445
<p>Is there an easy method to restore a minimized form to its previous state, either Normal or Maximized? I'm expecting the same functionality as clicking the taskbar (or right-clicking and choosing restore).</p> <p>So far, I have this, but if the form was previously maximized, it still comes back as a normal window....
[ { "answer_id": 354493, "author": "jeffm", "author_id": 1544, "author_profile": "https://Stackoverflow.com/users/1544", "pm_score": 3, "selected": false, "text": "<p>You could simulate clicking on the taskbar button like this:</p>\n\n<pre><code>SendMessage(docView.Handle, WM_SYSCOMMAND, S...
2008/12/09
[ "https://Stackoverflow.com/questions/354445", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44770/" ]
Is there an easy method to restore a minimized form to its previous state, either Normal or Maximized? I'm expecting the same functionality as clicking the taskbar (or right-clicking and choosing restore). So far, I have this, but if the form was previously maximized, it still comes back as a normal window. ``` if (d...
I use the following extension method: ``` using System.Runtime.InteropServices; namespace System.Windows.Forms { public static class Extensions { [DllImport( "user32.dll" )] private static extern int ShowWindow( IntPtr hWnd, uint Msg ); private const uint SW_RESTORE = 0x09; p...
354,472
<p>I just saw this question:</p> <p><a href="https://stackoverflow.com/questions/353968/understanding-nets-securityaction-parameter-for-permissions">Understanding .NET’s “SecurityAction” parameter for permissions</a></p> <p>And I have a question. With the following code:</p> <pre><code>private void button1_Click(obj...
[ { "answer_id": 354500, "author": "Mitchel Sellers", "author_id": 13279, "author_profile": "https://Stackoverflow.com/users/13279", "pm_score": 0, "selected": false, "text": "<p>Upon first look, I would guess that the permission object is still in scope, as it is defined inside the method...
2008/12/09
[ "https://Stackoverflow.com/questions/354472", "https://Stackoverflow.com", "https://Stackoverflow.com/users/267/" ]
I just saw this question: [Understanding .NET’s “SecurityAction” parameter for permissions](https://stackoverflow.com/questions/353968/understanding-nets-securityaction-parameter-for-permissions) And I have a question. With the following code: ``` private void button1_Click(object sender, EventArgs e) { Layer1()...
Calling .Deny() on a CodeAccessPermission will cause the .NET Security runtime to set the deny flag on the security object for the current stack frame for that permission. So even if you call GC.Collect() after calling .Deny(), it doesn't really matter, the permission will stay in effect. The permission object is just...
354,473
<p>What's the best way to load HTML markup for a custom jQuery UI widget?</p> <p>So far, I've seen elements simply created using strings (i.e. <code>$(...).wrap('&lt;div&gt;&lt;/div&gt;')</code>) which is fine for something simple. However, this makes it extremely difficult to modify later for more complex elements.</...
[ { "answer_id": 354537, "author": "Andreas Grech", "author_id": 44084, "author_profile": "https://Stackoverflow.com/users/44084", "pm_score": 4, "selected": true, "text": "<p>Something which is quite neat to do is this:</p>\n\n<pre><code>var newDiv = $(\"&lt;div&gt;&lt;/div&gt;\"); //Crea...
2008/12/09
[ "https://Stackoverflow.com/questions/354473", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5291/" ]
What's the best way to load HTML markup for a custom jQuery UI widget? So far, I've seen elements simply created using strings (i.e. `$(...).wrap('<div></div>')`) which is fine for something simple. However, this makes it extremely difficult to modify later for more complex elements. This seems like a fairly common p...
Something which is quite neat to do is this: ``` var newDiv = $("<div></div>"); //Create a new element and save a reference newDiv.attr("id","someid").appendTo("body"); ``` That way, you are creating an element, and storing its reference in a variable, for later use.
354,476
<p>I need to achieve the following when opening an HTML in Excel <code>(Response.contentType="application/vnd.ms-excel")</code> :</p> <ul> <li>force Excel to consider content of td cells as numbers</li> <li>make the above so that any subsequent user-entered formulas work on these cells (when the spreadsheet is opened)...
[ { "answer_id": 354570, "author": "BlackMael", "author_id": 19377, "author_profile": "https://Stackoverflow.com/users/19377", "pm_score": 3, "selected": false, "text": "<p>The best trick is to mock up an Excel spreadsheet with all the colors/(conditional) formats/formulas you require.</p>...
2008/12/09
[ "https://Stackoverflow.com/questions/354476", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I need to achieve the following when opening an HTML in Excel `(Response.contentType="application/vnd.ms-excel")` : * force Excel to consider content of td cells as numbers * make the above so that any subsequent user-entered formulas work on these cells (when the spreadsheet is opened) So far I was successful with a...
If you add a CSS Class to your page: ``` .num { mso-number-format:General; } .date { mso-number-format:"Short Date"; } ``` And slap those classes on your TD's, does it work? ``` <td class="num">34</td> <td class="num">17.0</td> <td class="date">12/17/2008</td> <!-- if you are playing with dates too --> ``` **...
354,477
<p>What's the best way, using C# or other .NET language, to determine if a file path string is on the local machine or a remote server?</p> <p>It's possible to determine if a path string is UNC using the following:</p> <pre><code>new Uri(path).IsUnc </code></pre> <p>That works great for paths that start with C:\ or ...
[ { "answer_id": 354558, "author": "tbetts42", "author_id": 44770, "author_profile": "https://Stackoverflow.com/users/44770", "pm_score": 0, "selected": false, "text": "<p>I don't know of a single method to check that. However, you can compare the Uri's <code>Host</code> property to eithe...
2008/12/09
[ "https://Stackoverflow.com/questions/354477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10039/" ]
What's the best way, using C# or other .NET language, to determine if a file path string is on the local machine or a remote server? It's possible to determine if a path string is UNC using the following: ``` new Uri(path).IsUnc ``` That works great for paths that start with C:\ or other drive letter, but what abou...
Don't know if there's a more efficient way of doing this, but it seems to work for me: ``` IPAddress[] host; IPAddress[] local; bool isLocal = false; host = Dns.GetHostAddresses(uri.Host); local = Dns.GetHostAddresses(Dns.GetHostName()); foreach (IPAddress hostAddress in host) { i...
354,490
<p>As per <a href="http://www.gnu.org/software/emacs/manual/html_node/emacs/File-Names.html" rel="noreferrer">the Emacs docs</a>, every time you open a file, Emacs changes <code>default-directory</code> to the directory containing that file. </p> <p>Then, if the cursor is in that buffer and you (for example) start SL...
[ { "answer_id": 354654, "author": "link0ff", "author_id": 23952, "author_profile": "https://Stackoverflow.com/users/23952", "pm_score": 5, "selected": true, "text": "<p>You could try using something like this:</p>\n\n<pre><code>(add-hook 'find-file-hook\n (lambda ()\n ...
2008/12/09
[ "https://Stackoverflow.com/questions/354490", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23070/" ]
As per [the Emacs docs](http://www.gnu.org/software/emacs/manual/html_node/emacs/File-Names.html), every time you open a file, Emacs changes `default-directory` to the directory containing that file. Then, if the cursor is in that buffer and you (for example) start SLIME, it uses `default-directory` as the current wo...
You could try using something like this: ``` (add-hook 'find-file-hook (lambda () (setq default-directory command-line-default-directory))) ```
354,503
<p>I'm working on an application that makes asynchronous calls to the WebService.</p> <p>I added a proxy class to make asynchronous calls. The code compiles and runs properly, however whenever I try to double-click the proxy class in solution explorer (Visual Studio 2008) I am presented with a page</p> <p>To prevent ...
[ { "answer_id": 631732, "author": "Gian Marco", "author_id": 66629, "author_profile": "https://Stackoverflow.com/users/66629", "pm_score": 5, "selected": true, "text": "<p>Same problem here..<br>\nJust decorate your proxy class with the following attribute</p>\n\n<p>[System.ComponentModel...
2008/12/09
[ "https://Stackoverflow.com/questions/354503", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26447/" ]
I'm working on an application that makes asynchronous calls to the WebService. I added a proxy class to make asynchronous calls. The code compiles and runs properly, however whenever I try to double-click the proxy class in solution explorer (Visual Studio 2008) I am presented with a page To prevent possible data los...
Same problem here.. Just decorate your proxy class with the following attribute [System.ComponentModel.DesignerCategoryAttribute("code")] to get rid of the useless design mode.
354,526
<p>I have two files with slight differences. A normal <code>diff</code> will show me the differences between the files. With <code>-c</code> or <code>-u</code> I can add an amount of context to each hunk. What options can I pass to <code>diff</code> to see every unchanged line alongside the changes, and get the diff...
[ { "answer_id": 354552, "author": "madlep", "author_id": 14160, "author_profile": "https://Stackoverflow.com/users/14160", "pm_score": 6, "selected": true, "text": "<p>Use the \"-y\" option for full side by side output</p>\n\n<p>diff -y file1 file2</p>\n\n<p>Will give you output something...
2008/12/09
[ "https://Stackoverflow.com/questions/354526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4937/" ]
I have two files with slight differences. A normal `diff` will show me the differences between the files. With `-c` or `-u` I can add an amount of context to each hunk. What options can I pass to `diff` to see every unchanged line alongside the changes, and get the diff as a single, large hunk?
Use the "-y" option for full side by side output diff -y file1 file2 Will give you output something like ``` * Lorem ipsum dolor sit amet, consectetuer adipiscing elit. * Lorem ipsum dolor sit amet, consectetuer adipiscing elit. * Praesent fringilla facilisis pede. * Praesent fringilla...
354,547
<p>When I'm running a simple Ruby script, what's the easiest way to dump an object's fields to the console? </p> <p>I'm looking for something similar to PHP's <code>print_r()</code> that will work with arrays as well.</p>
[ { "answer_id": 354578, "author": "Christian Lescuyer", "author_id": 341, "author_profile": "https://Stackoverflow.com/users/341", "pm_score": 10, "selected": true, "text": "<p>Possibly:</p>\n\n<pre><code>puts variable.inspect\n</code></pre>\n" }, { "answer_id": 354624, "autho...
2008/12/09
[ "https://Stackoverflow.com/questions/354547", "https://Stackoverflow.com", "https://Stackoverflow.com/users/270/" ]
When I'm running a simple Ruby script, what's the easiest way to dump an object's fields to the console? I'm looking for something similar to PHP's `print_r()` that will work with arrays as well.
Possibly: ``` puts variable.inspect ```
354,556
<p>I often want to trigger a certain function just once, but I need to trigger it from within another function that gets repeatedly called. For instance, taking a snapshot of something for later use. I usually do it by setting a global boolean.</p> <p>I'm wondering whether the way I do it is actually best way? </p> <...
[ { "answer_id": 354566, "author": "JoshBerke", "author_id": 26160, "author_profile": "https://Stackoverflow.com/users/26160", "pm_score": 0, "selected": false, "text": "<p>I see nothing wrong with your approach here. Keep in mind there isn't always the \"Right\" thing...there are definetl...
2008/12/09
[ "https://Stackoverflow.com/questions/354556", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10875/" ]
I often want to trigger a certain function just once, but I need to trigger it from within another function that gets repeatedly called. For instance, taking a snapshot of something for later use. I usually do it by setting a global boolean. I'm wondering whether the way I do it is actually best way? I seem to recal...
When you call a function it should do what you expect it to do with the arguments you give it. If you call a function twice in exactly the same way you should expect that function to give you the same results or do the same thing. It is probably better to move this call-once dependency to the logic that calls your fun...
354,559
<p>I'm having some trouble running a groovy servlet (groovlet) in tomcat that imports a library class. When I don't import anything the groovlet works correctly, but if I do import something that I expect to be on the classpath (I can import the same class successfully in a regular servlet), I see the following error:<...
[ { "answer_id": 584443, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "<p>I'm using Groovy plugin for Eclipse. Exporting Groovlets in a war file does also work.</p>\n\n<p>When I do export my Groovl...
2008/12/09
[ "https://Stackoverflow.com/questions/354559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29995/" ]
I'm having some trouble running a groovy servlet (groovlet) in tomcat that imports a library class. When I don't import anything the groovlet works correctly, but if I do import something that I expect to be on the classpath (I can import the same class successfully in a regular servlet), I see the following error: ``...
I'm using Groovy plugin for Eclipse. Exporting Groovlets in a war file does also work. When I do export my Groovlet-based application, this helpful plugin puts .groovy files in the /WEB-INF/classes directory (in the classpath). And it works when I deploy the war file in my Tomcat Server. Hope that this helps. Regard...
354,568
<p>In C#, I'm creating an XML file from a DataTable using dataTable.WriteXml(filePath), and get the following:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;ExperienceProfiles&gt; &lt;ExperienceProfile&gt; &lt;Col1&gt;blah&lt;/Col1&gt; &lt;Col2&gt;4ed397bf-a4d5-4ace-9d44-8c1a5cdb0f34&lt;/C...
[ { "answer_id": 354602, "author": "Strelok", "author_id": 2788, "author_profile": "https://Stackoverflow.com/users/2788", "pm_score": 0, "selected": false, "text": "<blockquote>\n <p>Short answer: you can't, using the\n WriteXml method of a DataTable.</p>\n \n <p>Long answer (which is...
2008/12/09
[ "https://Stackoverflow.com/questions/354568", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33185/" ]
In C#, I'm creating an XML file from a DataTable using dataTable.WriteXml(filePath), and get the following: ``` <?xml version="1.0" encoding="utf-8" ?> <ExperienceProfiles> <ExperienceProfile> <Col1>blah</Col1> <Col2>4ed397bf-a4d5-4ace-9d44-8c1a5cdb0f34</Col2> </ExperienceProfile> </ExperienceProfiles> ``...
What you want is some way to tell the DataSet the expected format of your data. You're in luck, the DataSet supports just this feature. You will need to create an XML schema for your data and load it into the DataSet before you write out the XML. In the schema define Col1 and Col2 as attributes of the ExperienceProfil...
354,587
<p><strong>Update</strong> - for those of a facetious frame of mind, you can assume that Aggregate still produces the normal result whatever function is passed to it, including in the case being optimized.</p> <p>I wrote this program to build a long string of integers from 0 to 19999 separate by commas.</p> <pre><code>...
[ { "answer_id": 354594, "author": "Lasse V. Karlsen", "author_id": 267, "author_profile": "https://Stackoverflow.com/users/267", "pm_score": 2, "selected": false, "text": "<p>Well, that would depend entirely on what code is in the MageAggregateGoFaster namespace now wouldn't it?</p>\n\n<p...
2008/12/09
[ "https://Stackoverflow.com/questions/354587", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27423/" ]
**Update** - for those of a facetious frame of mind, you can assume that Aggregate still produces the normal result whatever function is passed to it, including in the case being optimized. I wrote this program to build a long string of integers from 0 to 19999 separate by commas. ``` using System; using System.Linq;...
You are 'overriding' System.Linq.Aggregate with your own extension method in namespace MakeAggregateGoFaster. Perhaps specialised on `IEnumerable<string>` and making use of a StringBuilder? Maybe taking an `Expression<Func<string, string, string>>` instead of a `Func<string, string, string>` so it can analyse the e...
354,599
<p>Looking to get a list of all the files (commit comments would be nice too) of a user in cvs. </p>
[ { "answer_id": 354611, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 5, "selected": true, "text": "<pre><code>cvs log -t -wJellyJoe\n</code></pre>\n" }, { "answer_id": 354618, "author": "Alex B", "autho...
2008/12/09
[ "https://Stackoverflow.com/questions/354599", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Looking to get a list of all the files (commit comments would be nice too) of a user in cvs.
``` cvs log -t -wJellyJoe ```
354,650
<p>I need to keep an NSPathControl updated with the currently selected path in an NSBrowser, but I'm having trouble figuring out a way of getting notifications when the path has changed from the NSBrowser. The ideal way to do this would just to be to observe the path key path in the NSBrowser, but that gives a KVO can ...
[ { "answer_id": 354682, "author": "Marc Charbonneau", "author_id": 35136, "author_profile": "https://Stackoverflow.com/users/35136", "pm_score": 0, "selected": false, "text": "<p>I just checked in IB, and it looks like NSBrowser has a selection index paths binding (an array of NSIndexPath...
2008/12/09
[ "https://Stackoverflow.com/questions/354650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1512/" ]
I need to keep an NSPathControl updated with the currently selected path in an NSBrowser, but I'm having trouble figuring out a way of getting notifications when the path has changed from the NSBrowser. The ideal way to do this would just to be to observe the path key path in the NSBrowser, but that gives a KVO can onl...
Courtesy of Rob Keniger over at [Cocoa Dev](http://cocoadev.com/forums/comments.php?DiscussionID=600&page=1#Item_1): > > Have you looked at the SimpleBrowser > example in /Developer/Examples? It > shows how to get the current selection > when it is changed by the user, > basically by just setting up the > action of t...
354,651
<p>I have a couple of mdb files with the exact table structure. I have to change the primary key of the main table from autonumber to number in all of them, which means I have to:</p> <ol> <li>Drop the all the relationships the main table has</li> <li>Change the main table</li> <li>Create the relationships again,... ...
[ { "answer_id": 354954, "author": "Patrick Cuff", "author_id": 7903, "author_profile": "https://Stackoverflow.com/users/7903", "pm_score": 5, "selected": true, "text": "<p>Not a complete solution, but this may get you going...</p>\n\n<p>The following function will print out the metadata f...
2008/12/09
[ "https://Stackoverflow.com/questions/354651", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15884/" ]
I have a couple of mdb files with the exact table structure. I have to change the primary key of the main table from autonumber to number in all of them, which means I have to: 1. Drop the all the relationships the main table has 2. Change the main table 3. Create the relationships again,... for all the tables. Is th...
Not a complete solution, but this may get you going... The following function will print out the metadata for all relationships. Change this to save to a file in whatever format you prefer (CSV, tab delimited, XML, etc.): ``` Function PrintRelationships() For Each rel In CurrentDb.Relations With rel ...
354,653
<p>What is the best way to close a browser window of an AJAX ASP.NET application after the server-side has been executed.</p> <p>I found this <a href="https://stackoverflow.com/questions/250450/aspnet-ajax-close-window-after-ajax-call">solution</a>, but it seems a little complex for what I want to accomplish. Or is t...
[ { "answer_id": 354658, "author": "Strelok", "author_id": 2788, "author_profile": "https://Stackoverflow.com/users/2788", "pm_score": -1, "selected": false, "text": "<p>That's pretty much it. You can just use <code>ScriptManager.RegisterStartupScript(...)</code></p>\n" }, { "answe...
2008/12/09
[ "https://Stackoverflow.com/questions/354653", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26327/" ]
What is the best way to close a browser window of an AJAX ASP.NET application after the server-side has been executed. I found this [solution](https://stackoverflow.com/questions/250450/aspnet-ajax-close-window-after-ajax-call), but it seems a little complex for what I want to accomplish. Or is this the best way to ac...
No, there is no way to close a browser window without the user's consent. You can log them out of their application, but you can't forcibly close the browser window.
354,657
<p><a href="http://api.rubyonrails.com/classes/ActiveSupport/CoreExtensions/Time/Conversions.html" rel="noreferrer">Rails' ActiveSupport module extends the builtin ruby Time class with a number of methods.</a></p> <p>Notably, there is the <code>to_formatted_s</code> method, which lets you write <code>Time.now.to_forma...
[ { "answer_id": 1474238, "author": "Tyler Rick", "author_id": 47185, "author_profile": "https://Stackoverflow.com/users/47185", "pm_score": 6, "selected": false, "text": "<p>It looks like ActiveSupport does provide the parsing methods you are looking for (and I was looking for too), after...
2008/12/09
[ "https://Stackoverflow.com/questions/354657", "https://Stackoverflow.com", "https://Stackoverflow.com/users/234/" ]
[Rails' ActiveSupport module extends the builtin ruby Time class with a number of methods.](http://api.rubyonrails.com/classes/ActiveSupport/CoreExtensions/Time/Conversions.html) Notably, there is the `to_formatted_s` method, which lets you write `Time.now.to_formatted_s(:db)` to get a string in Database format, rathe...
It looks like ActiveSupport does provide the parsing methods you are looking for (and I was looking for too), after all! — at least if the string you are trying to parse is a standard, ISO-8601-formatted (`:db` format) date. If the date you're trying to parse is already in your local time zone, it's really easy! ``` ...
354,664
<p>This pretty much has me defeated.</p> <p>On XP and earlier versions of Windows you could customise Open With filetypes to include java - jar "myjar.jar", but on Vista this functionality seems to have been removed. I can of course create a .bat file to launch my application, but is it possible to make Vista execute ...
[ { "answer_id": 354670, "author": "berlindev", "author_id": 44276, "author_profile": "https://Stackoverflow.com/users/44276", "pm_score": 2, "selected": false, "text": "<p>Use the software JarFix >= 1.1.0 .\nThere is Vista support included and it \"recovers\" the .jar association!</p>\n\n...
2008/12/09
[ "https://Stackoverflow.com/questions/354664", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1293123/" ]
This pretty much has me defeated. On XP and earlier versions of Windows you could customise Open With filetypes to include java - jar "myjar.jar", but on Vista this functionality seems to have been removed. I can of course create a .bat file to launch my application, but is it possible to make Vista execute a .jar as ...
You can do it from the command line with 2 utilities. The first one, ASSOC, is used to create a file association. To verify if there is one defined for JAR type : ``` >assoc .jar .jar=jarfile ``` If not found then create it with : ``` >assoc .jar=jarfile ``` The next step is to define the association. This is do...
354,666
<p>I want to add options to a dropdownbox on my aspx page from the c# code behind during load. I don't know how to get a reference to the control. I have some c# code that is triggered when the user changes the dropdownbox. In that I get a reference to the dropdown with:</p> <pre><code>DropDownBox ddb = (DropDownBox...
[ { "answer_id": 354684, "author": "jcollum", "author_id": 30946, "author_profile": "https://Stackoverflow.com/users/30946", "pm_score": 0, "selected": false, "text": "<p>PreRender is toward the end of the page lifecycle. Are you sure you want to be making changes there? Sounds like you sh...
2008/12/09
[ "https://Stackoverflow.com/questions/354666", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5234/" ]
I want to add options to a dropdownbox on my aspx page from the c# code behind during load. I don't know how to get a reference to the control. I have some c# code that is triggered when the user changes the dropdownbox. In that I get a reference to the dropdown with: ``` DropDownBox ddb = (DropDownBox)info.Toolbar.To...
If you want the selected item of the dropdown to be automatically selected from viewstate on postbacks you will need to have all the items in the dropdown by the time Page\_PreLoad fires. To do this you will want to put your code in Page\_Init, at this point the controls are created but viewstate has not yet been injec...
354,669
<p>I have the following attributes in my DB.</p> <blockquote> <p>statistic id, devicename, value, timestamp.</p> </blockquote> <p>For a given statistic, I want to find the 2 most recent timestamps and corresopnding values for a every unique device.</p> <p>I am trying stuff like </p> <p>Trial 1)</p> <pre><code>se...
[ { "answer_id": 354696, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 2, "selected": false, "text": "<p>This is how I solve this type of problem:</p>\n\n<pre><code>SELECT x.statistic, x.devicename, x.value, x.timestamp\...
2008/12/09
[ "https://Stackoverflow.com/questions/354669", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have the following attributes in my DB. > > statistic id, devicename, value, timestamp. > > > For a given statistic, I want to find the 2 most recent timestamps and corresopnding values for a every unique device. I am trying stuff like Trial 1) ``` select statistic, devicename, value, timestamp from X_STATS...
This is how I solve this type of problem: ``` SELECT x.statistic, x.devicename, x.value, x.timestamp FROM X_STATSVALUE AS x LEFT OUTER JOIN X_STATSVALUE AS x2 ON (x.statistic = x2.statistic AND x.devicename = x2.devicename AND x.timestamp < x2.timestamp) GROUP BY x.statistic, x.devicename HAVING COUNT(...
354,680
<p>I have balls bouncing around and each time they collide their speed vector is reduced by the Coefficient of Restitution.</p> <p>Right now my balls CoR for my balls is .80 . So after many bounces my balls have "stopped" rolling because their speed has becoming some ridiculously small number. </p> <p>In what stage ...
[ { "answer_id": 354702, "author": "grepsedawk", "author_id": 14388, "author_profile": "https://Stackoverflow.com/users/14388", "pm_score": 0, "selected": false, "text": "<p>IMO your epsilon approach is fine. I would just experiment to see what looks or feels natural to the animation in th...
2008/12/10
[ "https://Stackoverflow.com/questions/354680", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2635/" ]
I have balls bouncing around and each time they collide their speed vector is reduced by the Coefficient of Restitution. Right now my balls CoR for my balls is .80 . So after many bounces my balls have "stopped" rolling because their speed has becoming some ridiculously small number. In what stage is it appropriate ...
A reasonable value for epsilon is going to depend on the constraints of your system. If you are representing the ball graphically, then your epsilon might correspond to, say, a velocity of .1 pixels a second (ensuring that your notion of stopping matches the user's experience of the screen objects stopping). If you're ...
354,685
<p>I recognize that there's an obvious pattern in the output to this, I just want to know why lispbox's REPL aborts when I try to run anything > 52. Also, any suggestions on improving the code are more than welcome. ^-^</p> <pre><code>(defun count-reduced-fractions (n d sum) (setf g (gcd n d)) (if (equal 1 d) ...
[ { "answer_id": 354693, "author": "nobody", "author_id": 19405, "author_profile": "https://Stackoverflow.com/users/19405", "pm_score": 0, "selected": false, "text": "<p>Probably a Stack Overflow (heh).</p>\n" }, { "answer_id": 354694, "author": "Kyle Cronin", "author_id": ...
2008/12/10
[ "https://Stackoverflow.com/questions/354685", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I recognize that there's an obvious pattern in the output to this, I just want to know why lispbox's REPL aborts when I try to run anything > 52. Also, any suggestions on improving the code are more than welcome. ^-^ ``` (defun count-reduced-fractions (n d sum) (setf g (gcd n d)) (if (equal 1 d) (return-from...
This behaviour hints at a missing tail call optimization, so that your recursion blows the stack. A possible reason is that you have declaimed debugging optimization. By the way, you don't need to make an explicit call to `return-from`. Since `sum` is a self-evaluating symbol, you can change this line ``` (return-fro...
354,689
<p>I am trying to write a simple AI for a "Get four" game. The basic game principles are done, so I can throw in coins of different color, and they stack on each other and fill a 2D Array and so on and so forth. until now this is what the method looks like:</p> <pre><code>public int insert(int x, int color) //0 = emp...
[ { "answer_id": 354731, "author": "Uri", "author_id": 23072, "author_profile": "https://Stackoverflow.com/users/23072", "pm_score": 2, "selected": false, "text": "<p>I'm guessing that this is a homework assignment, and that you mean you want to write the evaluation function and don't know...
2008/12/10
[ "https://Stackoverflow.com/questions/354689", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am trying to write a simple AI for a "Get four" game. The basic game principles are done, so I can throw in coins of different color, and they stack on each other and fill a 2D Array and so on and so forth. until now this is what the method looks like: ``` public int insert(int x, int color) //0 = empty, 1=player1 ...
I'm guessing that this is a homework assignment, and that you mean you want to write the evaluation function and don't know what tricks to use? The game is called "Connect 4" in English, so you can google for "connect 4 evaluation function". You can find enough people discussion heuristics. Please don't copy an actu...
354,691
<p>What I am trying to do is so simple but I am having a hard time making it work. I saw some posts along the same lines but I still have questions.</p> <p>I have a MenuItem object called mnuA. All I want is set the icon property programatically in C#. I have tried the following</p> <p>a) <code>mnuA.Icon = new Bitmap...
[ { "answer_id": 354754, "author": "w4g3n3r", "author_id": 36745, "author_profile": "https://Stackoverflow.com/users/36745", "pm_score": 4, "selected": true, "text": "<p>Try this:</p>\n\n<pre><code>Image img = new Image();\nimg.Source = new BitmapImage(new Uri(@\"c:\\icons\\A.png\"));\nmnu...
2008/12/10
[ "https://Stackoverflow.com/questions/354691", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28029/" ]
What I am trying to do is so simple but I am having a hard time making it work. I saw some posts along the same lines but I still have questions. I have a MenuItem object called mnuA. All I want is set the icon property programatically in C#. I have tried the following a) `mnuA.Icon = new BitmapImage{UriSource = new ...
Try this: ``` Image img = new Image(); img.Source = new BitmapImage(new Uri(@"c:\icons\A.png")); mnuA.Icon = img; ```
354,695
<p>I need to use one logical PGM based multicast address in application while enable such application "seamlessly" running across several different geo-locations (i.e. think US/Europe/Australia).</p> <p>Application is quite throughput (several million biz. messages a day) and latency demanding whith a lot of small but...
[ { "answer_id": 354754, "author": "w4g3n3r", "author_id": 36745, "author_profile": "https://Stackoverflow.com/users/36745", "pm_score": 4, "selected": true, "text": "<p>Try this:</p>\n\n<pre><code>Image img = new Image();\nimg.Source = new BitmapImage(new Uri(@\"c:\\icons\\A.png\"));\nmnu...
2008/12/10
[ "https://Stackoverflow.com/questions/354695", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30777/" ]
I need to use one logical PGM based multicast address in application while enable such application "seamlessly" running across several different geo-locations (i.e. think US/Europe/Australia). Application is quite throughput (several million biz. messages a day) and latency demanding whith a lot of small but very freq...
Try this: ``` Image img = new Image(); img.Source = new BitmapImage(new Uri(@"c:\icons\A.png")); mnuA.Icon = img; ```
354,703
<p>I am trying to process files one at a time that are stored over a network. Reading the files is fast due to buffering is not the issue. The problem I have is just listing the directories in a folder. I have at least 10k files per folder over many folders.</p> <p>Performance is super slow since File.list() return...
[ { "answer_id": 354721, "author": "grepsedawk", "author_id": 14388, "author_profile": "https://Stackoverflow.com/users/14388", "pm_score": 2, "selected": false, "text": "<p>A non-portable solution would be to make native calls to the operating system and stream the results.</p>\n<p><stron...
2008/12/10
[ "https://Stackoverflow.com/questions/354703", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21838/" ]
I am trying to process files one at a time that are stored over a network. Reading the files is fast due to buffering is not the issue. The problem I have is just listing the directories in a folder. I have at least 10k files per folder over many folders. Performance is super slow since File.list() returns an array in...
Although it's not pretty, I solved this kind of problem once by piping the output of dir/ls to a file before starting my app, and passing in the filename. If you needed to do it within the app, you could just use system.exec(), but it would create some nastiness. You asked. The first form is going to be blazingly fas...
354,718
<p>How do you detect which form input has focus using JavaScript or jQuery?</p> <p>From within a function I want to be able to determine which form input has focus. I'd like to be able to do this in straight JavaScript and/or jQuery.</p>
[ { "answer_id": 354770, "author": "Marc Novakowski", "author_id": 27020, "author_profile": "https://Stackoverflow.com/users/27020", "pm_score": 2, "selected": false, "text": "<p>If all you want to do is change the CSS for a particular form field when it gets focus, you could use the CSS \...
2008/12/10
[ "https://Stackoverflow.com/questions/354718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25991/" ]
How do you detect which form input has focus using JavaScript or jQuery? From within a function I want to be able to determine which form input has focus. I'd like to be able to do this in straight JavaScript and/or jQuery.
I am not sure if this is the most efficient way, but you could try: ``` var selectedInput = null; $(function() { $('input, textarea, select').focus(function() { selectedInput = this; }).blur(function(){ selectedInput = null; }); }); ```
354,723
<p><strong>Problem:</strong> a table of coordinate lat/lngs. Two rows can potentially have the same coordinate. We want a query that returns a set of rows with unique coordinates (within the returned set). Note that <code>distinct</code> is not usable because I need to return the id column which is, by definition, dist...
[ { "answer_id": 354735, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 0, "selected": false, "text": "<p>Where did you get the idea that DISTINCT only works on one column? Anyway, you could also use a GROUP BY clause.</...
2008/12/10
[ "https://Stackoverflow.com/questions/354723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2942/" ]
**Problem:** a table of coordinate lat/lngs. Two rows can potentially have the same coordinate. We want a query that returns a set of rows with unique coordinates (within the returned set). Note that `distinct` is not usable because I need to return the id column which is, by definition, distinct. This sort of works (`...
You might be able to use a CTE for this with the ROW\_NUMBER function across lat and long and then use rand() against that. Something like: ``` WITH cte AS ( SELECT intID, ROW_NUMBER() OVER ( PARTITION BY geoLat, geoLng ORDER BY NEWID() ) AS r...
354,724
<p>Currently I use this reg ex:</p> <pre><code>"\bI([ ]{1,2})([a-zA-Z]|\d){2,13}\b" </code></pre> <p>It was just brought to my attention that the text that I use this against could contain a "<code>\</code>" (backslash). How do I add this to the expression?</p>
[ { "answer_id": 354730, "author": "user44511", "author_id": 44511, "author_profile": "https://Stackoverflow.com/users/44511", "pm_score": 3, "selected": true, "text": "<p>Add <code>|\\\\</code> inside the group, after the <code>\\d</code> for instance.</p>\n" }, { "answer_id": 354...
2008/12/10
[ "https://Stackoverflow.com/questions/354724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38349/" ]
Currently I use this reg ex: ``` "\bI([ ]{1,2})([a-zA-Z]|\d){2,13}\b" ``` It was just brought to my attention that the text that I use this against could contain a "`\`" (backslash). How do I add this to the expression?
Add `|\\` inside the group, after the `\d` for instance.
354,727
<p>Using the WCF web programming model one can specify an operation contract like so:</p> <pre><code>[OperationContract] [WebGet(ResponseFormat = WebMessageFormat.Xml, UriTemplate = "SomeRequest?qs1={qs1}&amp;qs2={qs2}")] XElement SomeRequest1(string qs1, string qs2); </code></pre> <p>Now if we had to make a contract...
[ { "answer_id": 354823, "author": "joshperry", "author_id": 30587, "author_profile": "https://Stackoverflow.com/users/30587", "pm_score": 6, "selected": true, "text": "<p>I've implemented a simple custom QueryStringConverter so that you can make qs1 an string[] then have the query string ...
2008/12/10
[ "https://Stackoverflow.com/questions/354727", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19219/" ]
Using the WCF web programming model one can specify an operation contract like so: ``` [OperationContract] [WebGet(ResponseFormat = WebMessageFormat.Xml, UriTemplate = "SomeRequest?qs1={qs1}&qs2={qs2}")] XElement SomeRequest1(string qs1, string qs2); ``` Now if we had to make a contract that accepts an array of para...
I've implemented a simple custom QueryStringConverter so that you can make qs1 an string[] then have the query string variable be comma delimited (e.g. <http://server/service/SomeRequest?qs1=val1,val2,val3,val4>) ``` [OperationContract] [WebGet(ResponseFormat = WebMessageFormat.Xml, UriTemplate = "SomeRequest?...
354,738
<p>I am making a small <strong>C#</strong> application and would like to extract a <strong>tag cloud</strong> from a simple plain text. Is there a function that could do that for me?</p>
[ { "answer_id": 354759, "author": "Nathan W", "author_id": 6335, "author_profile": "https://Stackoverflow.com/users/6335", "pm_score": 0, "selected": false, "text": "<p>I'm not sure if this is exactly what your looking for but it may help you get started:</p>\n\n<p>LINQ that counts word f...
2008/12/10
[ "https://Stackoverflow.com/questions/354738", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19159/" ]
I am making a small **C#** application and would like to extract a **tag cloud** from a simple plain text. Is there a function that could do that for me?
Building a tag cloud is, as I see it, a two part process: First, you need to split and count your tokens. Depending on how the document is structured, as well as the language it is written in, this could be as easy as counting the space-separated words. However, this is a very naive approach, as words like the, of, a,...
354,739
<p>I have noticed a common technique is to place a generic container <em>div</em> in the root of the <em>body</em> tag:</p> <pre><code>&lt;html&gt; &lt;head&gt; ... &lt;/head&gt; &lt;body&gt; &lt;div id=&quot;container&quot;&gt; ... &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Is ...
[ { "answer_id": 354747, "author": "Mitchel Sellers", "author_id": 13279, "author_profile": "https://Stackoverflow.com/users/13279", "pm_score": 4, "selected": false, "text": "<p>This method allows you to have more flexibility of styling your entire content. Effectively creating two conta...
2008/12/10
[ "https://Stackoverflow.com/questions/354739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44810/" ]
I have noticed a common technique is to place a generic container *div* in the root of the *body* tag: ``` <html> <head> ... </head> <body> <div id="container"> ... </div> </body> </html> ``` Is there a valid reason for doing this? Why can't the CSS just reference the *body* tag?
The container div, and sometimes content div, are almost always used to allow for more sophisticated CSS styling. The body tag is special in some ways. Browsers don't treat it like a normal div; its position and dimensions are tied to the browser window. But a container div is just a div and you can style it with marg...
354,745
<p>How can i make my Java Swing GUI Components [Right To Left] for Arabic language from NetBeans Desktop Application?</p>
[ { "answer_id": 354771, "author": "Uri", "author_id": 23072, "author_profile": "https://Stackoverflow.com/users/23072", "pm_score": 1, "selected": false, "text": "<p>You could use alignment, but that would not handle the complexities if you have English letters or numbers embedded within ...
2008/12/10
[ "https://Stackoverflow.com/questions/354745", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How can i make my Java Swing GUI Components [Right To Left] for Arabic language from NetBeans Desktop Application?
Don't you just have to use: ``` Component.setComponentOrientation( ComponentOrientation.RIGHT_TO_LEFT ) ``` I believe that the swing components all already have support for RTL, don't they? Not sure how/where you'd do that in regards to netbeans, though.
354,755
<p>I'm working on a blog application in Django. Naturally, I have models set up such that there are Posts and Comments, and a particular Post may have many Comments; thus, Post is a ForeignKey in the Comments model.</p> <p>Given a Post object, is there an easy way (ideally, through a method call) to find out how many ...
[ { "answer_id": 354765, "author": "Daniel Naab", "author_id": 32638, "author_profile": "https://Stackoverflow.com/users/32638", "pm_score": 4, "selected": true, "text": "<pre><code>Comments.objects.filter(post=post).count()\n</code></pre>\n\n<p>or:</p>\n\n<pre><code>post.comment_set.count...
2008/12/10
[ "https://Stackoverflow.com/questions/354755", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28804/" ]
I'm working on a blog application in Django. Naturally, I have models set up such that there are Posts and Comments, and a particular Post may have many Comments; thus, Post is a ForeignKey in the Comments model. Given a Post object, is there an easy way (ideally, through a method call) to find out how many Comments b...
``` Comments.objects.filter(post=post).count() ``` or: ``` post.comment_set.count() ```
354,796
<p>I am writing Eclipse plugins, and frequently have a situation where a running Job needs to pause for a short while, run something asynchronously on the UI thread, and resume.</p> <p>So my code usually looks something like:</p> <pre class="lang-java prettyprint-override"><code>Display display = Display.getDefault...
[ { "answer_id": 355039, "author": "SCdF", "author_id": 1666, "author_profile": "https://Stackoverflow.com/users/1666", "pm_score": 0, "selected": false, "text": "<p>Well, if it's sync you can just have a value holder of some kind external to the <code>run()</code> method.</p>\n\n<p>The cl...
2008/12/10
[ "https://Stackoverflow.com/questions/354796", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23072/" ]
I am writing Eclipse plugins, and frequently have a situation where a running Job needs to pause for a short while, run something asynchronously on the UI thread, and resume. So my code usually looks something like: ```java Display display = Display.getDefault(); display.syncExec(new Runnable() { public void run(...
You probably shouldn't be assuming that the async `Runnable` will have finished by the time the `asyncExec` call returns. In which case, you're looking at pushing the result out into listeners/callbacks (possibly Command pattern), or if you do want to have the result available at a later in the same method, using som...
354,799
<p>I'm working on a website with a em-based layout (so it can stretch and compress gracefully when users increase or decrease font size). This site has a header that should be displayed across all pages. I have a "header" div in all pages, and the site-wide css file includes the code:</p> <pre><code>#header { wi...
[ { "answer_id": 355039, "author": "SCdF", "author_id": 1666, "author_profile": "https://Stackoverflow.com/users/1666", "pm_score": 0, "selected": false, "text": "<p>Well, if it's sync you can just have a value holder of some kind external to the <code>run()</code> method.</p>\n\n<p>The cl...
2008/12/10
[ "https://Stackoverflow.com/questions/354799", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1615/" ]
I'm working on a website with a em-based layout (so it can stretch and compress gracefully when users increase or decrease font size). This site has a header that should be displayed across all pages. I have a "header" div in all pages, and the site-wide css file includes the code: ``` #header { width: 50em; h...
You probably shouldn't be assuming that the async `Runnable` will have finished by the time the `asyncExec` call returns. In which case, you're looking at pushing the result out into listeners/callbacks (possibly Command pattern), or if you do want to have the result available at a later in the same method, using som...
354,811
<p>I have a ToggleButtonBar with a DataProvider setup like this:</p> <pre><code> &lt;mx:ToggleButtonBar itemClick="clickHandler(event);" selectedIndex="0"&gt; &lt;mx:dataProvider&gt; &lt;mx:String&gt;{resourceManager.getString('dashboard','daily')}&lt;/mx:String&gt; &lt;mx:String&gt;{resourceMana...
[ { "answer_id": 355822, "author": "Alexandru", "author_id": 44226, "author_profile": "https://Stackoverflow.com/users/44226", "pm_score": 1, "selected": false, "text": "<p>Maybe if you make a getter bindable to a custom event for ex: \"langChange\"</p>\n\n<pre><code>[Bindable(\"langChange...
2008/12/10
[ "https://Stackoverflow.com/questions/354811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16534/" ]
I have a ToggleButtonBar with a DataProvider setup like this: ``` <mx:ToggleButtonBar itemClick="clickHandler(event);" selectedIndex="0"> <mx:dataProvider> <mx:String>{resourceManager.getString('dashboard','daily')}</mx:String> <mx:String>{resourceManager.getString('dashboard','monthly')}</mx:St...
I would abstract out the data for your data provider into a bindable variable, then just reset the data provider when you change locals. ``` <mx:Script> <![CDATA[ [Bindable] myArray:Array = new Array( [resourceManager.getString('dashboard','daily')] , [resourceManager.getS...
354,835
<p>If I just want to know if a domain name is reserved; is it sufficient to use this command and see if any domain name servers turn up, in which case it's reserved?</p> <pre><code>host -t NS example.com </code></pre> <p>It's a lot faster than visiting <a href="http://www.internic.net/whois.html" rel="nofollow norefe...
[ { "answer_id": 354839, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 1, "selected": false, "text": "<p>NS records are not necessarily required for registered domains. The whois service is your most reliable option.</p>\n\...
2008/12/10
[ "https://Stackoverflow.com/questions/354835", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
If I just want to know if a domain name is reserved; is it sufficient to use this command and see if any domain name servers turn up, in which case it's reserved? ``` host -t NS example.com ``` It's a lot faster than visiting <http://www.internic.net/whois.html> and typing example.com to get much more detailed resul...
Various TLDs have differing requirements for whether name servers are provisioned or not. For example ".de" does require that name servers are up and running and correctly configured before they'll allow the domain registration to proceed. The technical standards for DNS don't require it though, in fact there's nothin...
354,837
<p>Why one would use one of the following packages instead of the other?</p> <ul> <li>Java Logging</li> <li>Commons Logging</li> <li>Log4j</li> <li>SLF4j</li> <li>Logback</li> </ul>
[ { "answer_id": 354868, "author": "Stephen", "author_id": 37193, "author_profile": "https://Stackoverflow.com/users/37193", "pm_score": 7, "selected": true, "text": "<p>In chronological order of api apperance (as far as I know):</p>\n\n<ul>\n<li>Log4j because most everybody uses it (in my...
2008/12/10
[ "https://Stackoverflow.com/questions/354837", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39057/" ]
Why one would use one of the following packages instead of the other? * Java Logging * Commons Logging * Log4j * SLF4j * Logback
In chronological order of api apperance (as far as I know): * Log4j because most everybody uses it (in my experience) * Commons Logging because open source projects use it (so they can integrate with whatever logging framework is used in the integrated solution); especially valid if you're an API/Framework/OSS and you...
354,838
<p>I want to convert user-submitted date format (mm/dd/yyyy) to a MySQL date format (YYYY-mm-dd). Submission is via a simple PHP form direc tto MySQL database. </p>
[ { "answer_id": 354844, "author": "Paolo Bergantino", "author_id": 16417, "author_profile": "https://Stackoverflow.com/users/16417", "pm_score": 3, "selected": false, "text": "<pre><code>$mysql_date = date('Y-m-d H:i:s', strtotime($user_date));\n</code></pre>\n" }, { "answer_id": ...
2008/12/10
[ "https://Stackoverflow.com/questions/354838", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to convert user-submitted date format (mm/dd/yyyy) to a MySQL date format (YYYY-mm-dd). Submission is via a simple PHP form direc tto MySQL database.
``` $mysql_date = date('Y-m-d H:i:s', strtotime($user_date)); ```
354,840
<p>I'm developing an application with Adobe Flex and AIR, and I've been banging my head against the wall trying to figure out how to solve a scrolling issue.</p> <p>The basic structure of my main application window (simplified greatly) is this:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;mx:Window...
[ { "answer_id": 355881, "author": "benjismith", "author_id": 22979, "author_profile": "https://Stackoverflow.com/users/22979", "pm_score": 2, "selected": true, "text": "<p>Found a solution.</p>\n\n<p>Looks like the only way to prevent the VBox from aggressively extending its vertical spac...
2008/12/10
[ "https://Stackoverflow.com/questions/354840", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22979/" ]
I'm developing an application with Adobe Flex and AIR, and I've been banging my head against the wall trying to figure out how to solve a scrolling issue. The basic structure of my main application window (simplified greatly) is this: ``` <?xml version="1.0" encoding="utf-8"?> <mx:WindowedApplication xmlns:mx="http:/...
Found a solution. Looks like the only way to prevent the VBox from aggressively extending its vertical space (and forcing its parents to grow scrollbars) is to wrap the VBox in a Canvas. There's a handy little component [here](http://dusbabek.net/?p=50), called ScrollableVBox, which performs the workaround while taki...
354,842
<p>I would like to create my ObjectDataProvider in my C# code behind rather than my XAML.</p> <p>I was wondering how to change this XAML into equivalent C#. The XAML was generated by Microsoft Expression Blend 2, so the d: namespace can be ignored safely.</p> <pre><code>&lt;ObjectDataProvider x:Key="FooSourceDS" Obje...
[ { "answer_id": 355881, "author": "benjismith", "author_id": 22979, "author_profile": "https://Stackoverflow.com/users/22979", "pm_score": 2, "selected": true, "text": "<p>Found a solution.</p>\n\n<p>Looks like the only way to prevent the VBox from aggressively extending its vertical spac...
2008/12/10
[ "https://Stackoverflow.com/questions/354842", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36234/" ]
I would like to create my ObjectDataProvider in my C# code behind rather than my XAML. I was wondering how to change this XAML into equivalent C#. The XAML was generated by Microsoft Expression Blend 2, so the d: namespace can be ignored safely. ``` <ObjectDataProvider x:Key="FooSourceDS" ObjectType="{x:Type myNS:Foo...
Found a solution. Looks like the only way to prevent the VBox from aggressively extending its vertical space (and forcing its parents to grow scrollbars) is to wrap the VBox in a Canvas. There's a handy little component [here](http://dusbabek.net/?p=50), called ScrollableVBox, which performs the workaround while taki...
354,853
<p>Regex to Find Second Char is Alpha up to 5 Alpha Followed by 1 numeral.</p> <p>Thanks</p>
[ { "answer_id": 354865, "author": "UnkwnTech", "author_id": 115, "author_profile": "https://Stackoverflow.com/users/115", "pm_score": 0, "selected": false, "text": "<pre><code>.\\w{1,5}\\d\n</code></pre>\n\n<p>any character followed by between 1 and 5 letters then 1 number</p>\n" }, {...
2008/12/10
[ "https://Stackoverflow.com/questions/354853", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38349/" ]
Regex to Find Second Char is Alpha up to 5 Alpha Followed by 1 numeral. Thanks
I was not successful in implementing any of the solutions above, probably my poor explanation of need. I did solve it in code not using Regex. Thanks to everyone who took the time to help. For those that thought this was homework, it was not. Here is some sample data. Need this I INDY2 ' INDY VECTOR DP FOR FILING '...
354,869
<p>I want to create a C# program to provision Windows Mobile devices. I have found MSDN documentation on a function called <a href="http://msdn.microsoft.com/en-us/library/ms852998.aspx" rel="nofollow noreferrer">DMProcessConfigXML</a>, but no instructions on how to use this function.</p> <p>How can I use this functio...
[ { "answer_id": 355376, "author": "kgiannakakis", "author_id": 24054, "author_profile": "https://Stackoverflow.com/users/24054", "pm_score": 1, "selected": false, "text": "<p>I looked at the MSDN and indeed very little information is available. I did some google searching and I found this...
2008/12/10
[ "https://Stackoverflow.com/questions/354869", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37481/" ]
I want to create a C# program to provision Windows Mobile devices. I have found MSDN documentation on a function called [DMProcessConfigXML](http://msdn.microsoft.com/en-us/library/ms852998.aspx), but no instructions on how to use this function. How can I use this function in my Windows Mobile app? I suspect it has so...
From managed code, you can call ConfigurationManager.ProcessConfiguration found in the Microsoft.WindowsMobile.Configuration namespace. [msdn](http://msdn.microsoft.com/en-us/library/microsoft.windowsmobile.configuration.configurationmanager.processconfiguration.aspx) Here is sample code: ``` XmlDocument configDoc = ...
354,870
<p>Is there a command in oracle 9i that displays the foreign keys of a table and also the table that those foreign keys reference?</p> <p>I was searching, did not find anything but i found an equivalent command that works with MySql which is SHOW CREATE TABLE </p> <p>Is there an equivalent command for this within ora...
[ { "answer_id": 354944, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 1, "selected": false, "text": "<p>This may do what you want, it uses Oracle system views. I don't have an Oracle instance handy to test it, however....
2008/12/10
[ "https://Stackoverflow.com/questions/354870", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31274/" ]
Is there a command in oracle 9i that displays the foreign keys of a table and also the table that those foreign keys reference? I was searching, did not find anything but i found an equivalent command that works with MySql which is SHOW CREATE TABLE Is there an equivalent command for this within oracle's SQL? I app...
You could start by listing all of the constraints for the table along with any referenced constraint on other tables: ``` SELECT acc.table_name ,acc.column_name ,acc.constraint_name ,ac.r_constraint_name AS referenced_constraint FROM all_cons_columns acc INNER JOIN all_constraints ac ON (acc.constrain...
354,875
<p>I have been working on a Java project for a class for a while now. It is an implementation of a linked list (here called <code>AddressList</code>, containing simple nodes called <code>ListNode</code>). The catch is that everything would have to be done with recursive algorithms. I was able to do everything fine sans...
[ { "answer_id": 354906, "author": "Ari Ronen", "author_id": 34957, "author_profile": "https://Stackoverflow.com/users/34957", "pm_score": 5, "selected": false, "text": "<p>I was asked this question at an interview and was annoyed that I fumbled with it since I was a little nervous.</p>\n\...
2008/12/10
[ "https://Stackoverflow.com/questions/354875", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41200/" ]
I have been working on a Java project for a class for a while now. It is an implementation of a linked list (here called `AddressList`, containing simple nodes called `ListNode`). The catch is that everything would have to be done with recursive algorithms. I was able to do everything fine sans one method: `public Addr...
There's code in one reply that spells it out, but you might find it easier to start from the bottom up, by asking and answering tiny questions (this is the approach in The Little Lisper): 1. What is the reverse of null (the empty list)? null. 2. What is the reverse of a one element list? the element. 3. What is the re...
354,883
<p>The canonical way to return multiple values in languages that support it is often <a href="https://stackoverflow.com/questions/38508/whats-the-best-way-to-return-multiple-values-from-a-function-in-python">tupling</a>.</p> <h3>Option: Using a tuple</h3> <p>Consider this trivial example:</p> <pre><code>def f(x): y0 ...
[ { "answer_id": 354892, "author": "UnkwnTech", "author_id": 115, "author_profile": "https://Stackoverflow.com/users/115", "pm_score": 5, "selected": false, "text": "<p>I prefer:</p>\n\n<pre><code>def g(x):\n y0 = x + 1\n y1 = x * 3\n y2 = y0 ** y3\n return {'y0':y0, 'y1':y1 ,'y2':y2 }...
2008/12/10
[ "https://Stackoverflow.com/questions/354883", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37984/" ]
The canonical way to return multiple values in languages that support it is often [tupling](https://stackoverflow.com/questions/38508/whats-the-best-way-to-return-multiple-values-from-a-function-in-python). ### Option: Using a tuple Consider this trivial example: ``` def f(x): y0 = x + 1 y1 = x * 3 y2 = y0 ** ...
[Named tuples](http://docs.python.org/library/collections.html#namedtuple-factory-function-for-tuples-with-named-fields) were added in 2.6 for this purpose. Also see [os.stat](http://docs.python.org/library/os.html#os.stat) for a similar builtin example. ``` >>> import collections >>> Point = collections.namedtuple('P...
354,888
<p>This is very interesting to me... This image displays perfectly well in Safari, but not at all in Firefox! Here's the relevant code:</p> <pre><code>&lt;div id="ad"&gt; &lt;p&gt;Advertisment&lt;/p&gt; &lt;img src="/ADS/fakead1.gif" /&gt; &lt;/div&gt; </code></pre> <p>With CSS:</p> <pre><code>#ad{color: #6...
[ { "answer_id": 354893, "author": "stalepretzel", "author_id": 1615, "author_profile": "https://Stackoverflow.com/users/1615", "pm_score": 4, "selected": true, "text": "<p>Wow, I'm not so smart...</p>\n\n<p>AdBlock Plus is smarter that I would have thought! I'll need to change the div na...
2008/12/10
[ "https://Stackoverflow.com/questions/354888", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1615/" ]
This is very interesting to me... This image displays perfectly well in Safari, but not at all in Firefox! Here's the relevant code: ``` <div id="ad"> <p>Advertisment</p> <img src="/ADS/fakead1.gif" /> </div> ``` With CSS: ``` #ad{color: #666;} #ad p{ font-size: .5em; text-align: center; padding...
Wow, I'm not so smart... AdBlock Plus is smarter that I would have thought! I'll need to change the div name to something less obvious than "ad" (!) I should have known. A word to the wise: if you want your ad to get through, name the div in klingon.
354,900
<p>So I'm teaching myself Ruby on Rails, with a PHP background. I've written a sloppy, proof-of-concept PHP application called "<a href="http://rezich.com/storybored" rel="nofollow noreferrer">2NDP.</a>" I want to re-create this in Ruby on Rails (but more basic, more clean, and with a better interface), so I can learn ...
[ { "answer_id": 355437, "author": "Hates_", "author_id": 3410, "author_profile": "https://Stackoverflow.com/users/3410", "pm_score": 3, "selected": true, "text": "<p>Rather then having four seperate columns, a separate joining table might be more appropriate. For example:</p>\n\n<p>Pages ...
2008/12/10
[ "https://Stackoverflow.com/questions/354900", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34795/" ]
So I'm teaching myself Ruby on Rails, with a PHP background. I've written a sloppy, proof-of-concept PHP application called "[2NDP.](http://rezich.com/storybored)" I want to re-create this in Ruby on Rails (but more basic, more clean, and with a better interface), so I can learn some of the basics. 2NDP is a website w...
Rather then having four seperate columns, a separate joining table might be more appropriate. For example: Pages -> LinkedPages -> Pages Then you can create a [has\_many through](http://wiki.rubyonrails.org/rails/pages/Beginner+Howto+on+has_many+:through) relationship. ``` class Pages < ActiveRecord::Base has_many...
354,902
<p>How do you open a path in explorer by code in c++. I googled and couldn't find any thing but systems commands to do this, however, i dont want it to block or show the console window.</p>
[ { "answer_id": 354916, "author": "berlindev", "author_id": 44276, "author_profile": "https://Stackoverflow.com/users/44276", "pm_score": 2, "selected": false, "text": "<p>This does not show the command window, just opens the directory.</p>\n\n<pre><code>\nsystem(\"explorer C:\\\\\");\n</...
2008/12/10
[ "https://Stackoverflow.com/questions/354902", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23339/" ]
How do you open a path in explorer by code in c++. I googled and couldn't find any thing but systems commands to do this, however, i dont want it to block or show the console window.
You probably are looking for the [`ShellExecute()`](http://msdn.microsoft.com/en-us/library/bb762153(VS.85).aspx) function in `shellapi.h`. It is called with an "action verb", a path, and optional parameters. In your case this will want either "open" or "explore" as follows: ``` ShellExecuteA(NULL, "open", "C:\\", NUL...
354,936
<p>I get a 2032 stream error from Flash in response to POST requests that return "201 Created" in IE (Firefox works fine). Since Flash doesn't provide access to the HTTP status I can't tell that it has actually succeeded. The request is being made with HTTPService.</p> <p>Any suggestions? Has anyone else seen this?...
[ { "answer_id": 355320, "author": "grapefrukt", "author_id": 914, "author_profile": "https://Stackoverflow.com/users/914", "pm_score": 1, "selected": false, "text": "<p>Try using a debug proxy to take a peek at the traffic, I like <a href=\"http://www.charlesproxy.com/\" rel=\"nofollow no...
2008/12/10
[ "https://Stackoverflow.com/questions/354936", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15899/" ]
I get a 2032 stream error from Flash in response to POST requests that return "201 Created" in IE (Firefox works fine). Since Flash doesn't provide access to the HTTP status I can't tell that it has actually succeeded. The request is being made with HTTPService. Any suggestions? Has anyone else seen this? Thanks, Ale...
I found a way around this on my Flex on Rails application. I was seeing the same problem in IE - my development.log in Rails gave a 201 message, but this caused a fault coming back to Flex. I found a reference in a new book called *Flex On Rails* by Tony Hillerson and Daniel Wanja, on p. 31. It involves catching the 20...
354,942
<p>If I have two objects, one being the list of items, and the other having a property storing the selected item of the other list, is it possible to update the selected item through binding in WPF?</p> <p>Lets say I have these two data structures:</p> <pre><code>public class MyDataList { public ObservableCollect...
[ { "answer_id": 355007, "author": "Jobi Joy", "author_id": 8091, "author_profile": "https://Stackoverflow.com/users/8091", "pm_score": 1, "selected": false, "text": "<p>Make this two properties inside a single class(Just to simplify the solution) and make the code ready for property chang...
2008/12/10
[ "https://Stackoverflow.com/questions/354942", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3820/" ]
If I have two objects, one being the list of items, and the other having a property storing the selected item of the other list, is it possible to update the selected item through binding in WPF? Lets say I have these two data structures: ``` public class MyDataList { public ObservableCollection<Guid> Data { get;...
I believe you should be able to do this (make sure to declare the local namespace): ``` <Window.Resources> <local:MyDataStructure x:Key="mds1" /> </Window.Resources> <ListBox ItemsSource="{Binding Data}" SelectedValue="{Binding Source={StaticResource mds1} Path=ChosenItem}"/> ```
354,945
<p>What would be the most effective way to grab the schema + table name in this scenario:</p> <p>SELECT [t0].[Id], [t0].[CODE] AS [arg0], [t0].[DESC] AS [arg1] FROM [SchemaName].[TableName] AS [t0] WHERE ([t0].[Id] &lt;> @p0)</p> <p>The outcome needs to be: "SchemaName.TableName" ....</p> <p>I'm using C#.</p> <p>Th...
[ { "answer_id": 355007, "author": "Jobi Joy", "author_id": 8091, "author_profile": "https://Stackoverflow.com/users/8091", "pm_score": 1, "selected": false, "text": "<p>Make this two properties inside a single class(Just to simplify the solution) and make the code ready for property chang...
2008/12/10
[ "https://Stackoverflow.com/questions/354945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
What would be the most effective way to grab the schema + table name in this scenario: SELECT [t0].[Id], [t0].[CODE] AS [arg0], [t0].[DESC] AS [arg1] FROM [SchemaName].[TableName] AS [t0] WHERE ([t0].[Id] <> @p0) The outcome needs to be: "SchemaName.TableName" .... I'm using C#. Thanks!
I believe you should be able to do this (make sure to declare the local namespace): ``` <Window.Resources> <local:MyDataStructure x:Key="mds1" /> </Window.Resources> <ListBox ItemsSource="{Binding Data}" SelectedValue="{Binding Source={StaticResource mds1} Path=ChosenItem}"/> ```
354,967
<p>For example, I could write either of these:</p> <pre><code>class example &lt;T&gt; { ... public void insert (T data) { ... } } </code></pre> <p>or</p> <pre><code>class example { ... public void insert (Object o) { ... } } </code></pre> <p>Is there a signficant di...
[ { "answer_id": 354973, "author": "Lawrence Dol", "author_id": 8946, "author_profile": "https://Stackoverflow.com/users/8946", "pm_score": 3, "selected": false, "text": "<p>The only reason to write the latter is if you must target an earlier JVM. Generics are implemented by type-erasure,...
2008/12/10
[ "https://Stackoverflow.com/questions/354967", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
For example, I could write either of these: ``` class example <T> { ... public void insert (T data) { ... } } ``` or ``` class example { ... public void insert (Object o) { ... } } ``` Is there a signficant difference between the 2 in terms of performance? With ge...
The only reason to write the latter is if you must target an earlier JVM. Generics are implemented by type-erasure, so they have no runtime impact - only added compile time checking which will improve your code. Of course if you need a collection which holds any old object, or a mix of several which don't have a commo...
354,981
<p>I'm porting a process which creates a MASSIVE <code>CROSS JOIN</code> of two tables. The resulting table contains 15m records (looks like the process makes a 30m cross join with a 2600 row table and a 12000 row table and then does some grouping which must split it in half). The rows are relatively narrow - just 6 ...
[ { "answer_id": 355132, "author": "shahkalpesh", "author_id": 23574, "author_profile": "https://Stackoverflow.com/users/23574", "pm_score": 1, "selected": false, "text": "<p>Break down the query to make it a plain simple cross join.</p>\n\n<pre>\n<code>\n SELECT CC.COST_CTR_NUM, GL.ACC...
2008/12/10
[ "https://Stackoverflow.com/questions/354981", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18255/" ]
I'm porting a process which creates a MASSIVE `CROSS JOIN` of two tables. The resulting table contains 15m records (looks like the process makes a 30m cross join with a 2600 row table and a 12000 row table and then does some grouping which must split it in half). The rows are relatively narrow - just 6 columns. It's be...
Examining that query shows only one column used from one table, and only two columns used from the other table. Due to the very low numbers of columns used, this query can be easily enhanced with covering indexes: ``` CREATE INDEX COSTCENTCoverCross ON COSTCENT(COST_CTR_NUM) CREATE INDEX JOINGLACCoverCross ON JOINGLAC...
354,993
<p>I have following table structure:</p> <pre><code>Table: Plant PlantID: Primary Key PlantName: String Table: Party PartyID: Primary Key PartyName: String PlantID: link to Plant table Table: Customer PartyID: Primary Key, link to Party CustomerCode: String </code></pre> <p>I'd like to have Customer entity ...
[ { "answer_id": 355968, "author": "YeahStu", "author_id": 1300, "author_profile": "https://Stackoverflow.com/users/1300", "pm_score": 3, "selected": true, "text": "<p>You can get these fields by using the reference path on the Entity Object. </p>\n\n<p>To get the PartyName, use this synta...
2008/12/10
[ "https://Stackoverflow.com/questions/354993", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44838/" ]
I have following table structure: ``` Table: Plant PlantID: Primary Key PlantName: String Table: Party PartyID: Primary Key PartyName: String PlantID: link to Plant table Table: Customer PartyID: Primary Key, link to Party CustomerCode: String ``` I'd like to have Customer entity object with following fiel...
You can get these fields by using the reference path on the Entity Object. To get the PartyName, use this syntax: `Customer.Party.PartyName` To get the PlantName, use this syntax: `Customer.Party.Plant.PlantName`
355,019
<p>I have an object in C# on which I need to execute a method on a regular basis. I would like this method to be executed only when other people are using my object, as soon as people stop using my object I would like this background operation to stop. </p> <p>So here is a simple example is this (which is broken): </p...
[ { "answer_id": 355028, "author": "Andrew Kennan", "author_id": 22506, "author_profile": "https://Stackoverflow.com/users/22506", "pm_score": 2, "selected": false, "text": "<p>I think the IDisposable solution is the correct one. </p>\n\n<p>If the users of your class don't follow the guide...
2008/12/10
[ "https://Stackoverflow.com/questions/355019", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17174/" ]
I have an object in C# on which I need to execute a method on a regular basis. I would like this method to be executed only when other people are using my object, as soon as people stop using my object I would like this background operation to stop. So here is a simple example is this (which is broken): ``` class F...
Here is my proposed solution to this problem: ``` class Fish : IDisposable { class Swimmer { Thread t; WeakReference fishRef; public ManualResetEvent terminate = new ManualResetEvent(false); public Swimmer(Fish3 fish) { this.fishRef = new WeakReference(fi...
355,020
<p>I have a Double which could have a value from around 0.000001 to 1,000,000,000.000</p> <p>I wish to format this number as a string but conditionally depending on its size. So if it's very small I want to format it with something like:</p> <pre><code>String.Format("{0:.000000000}", number); </code></pre> <p>if it'...
[ { "answer_id": 355024, "author": "Andrew Kennan", "author_id": 22506, "author_profile": "https://Stackoverflow.com/users/22506", "pm_score": 2, "selected": false, "text": "<p>Use the # character for optional positions in the string:</p>\n\n<pre><code>string.Format(\"{0:#,###,##0.000}\", ...
2008/12/10
[ "https://Stackoverflow.com/questions/355020", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1463/" ]
I have a Double which could have a value from around 0.000001 to 1,000,000,000.000 I wish to format this number as a string but conditionally depending on its size. So if it's very small I want to format it with something like: ``` String.Format("{0:.000000000}", number); ``` if it's not that small, say 0.001 then ...
Use Math.Log10 of the absolute value of the double to figure out how many 0's you need either left (if positive) or right (if negative) of the decimal place. Choose the format string based on this value. You'll need handle zero values separately. ``` string s; double epislon = 0.0000001; // or however near zero you wa...
355,030
<p>I'd like to use POSIX semaphores to manage atomic get and put from a file representing a queue. I want the flexibility of having something named in the filesystem, so that completely unrelated processes can share a queue. I think this plan rules out pthreads. The named posix semaphores are great for putting somet...
[ { "answer_id": 355368, "author": "Chris", "author_id": 15578, "author_profile": "https://Stackoverflow.com/users/15578", "pm_score": -1, "selected": false, "text": "<p>You are looking for: pthread_cond_wait, pthread_cond_signal, I think.<br>\nThat's if you are using posix threads, then t...
2008/12/10
[ "https://Stackoverflow.com/questions/355030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41661/" ]
I'd like to use POSIX semaphores to manage atomic get and put from a file representing a queue. I want the flexibility of having something named in the filesystem, so that completely unrelated processes can share a queue. I think this plan rules out pthreads. The named posix semaphores are great for putting something i...
Since there are no other answers I will follow up with what I've learned: * Pthreads will not work with my application because I have processes without a common ancestor which need to share an atomic queue. * Posix semaphores *are* subject to the wakeup-waiting race, but because unlike classic condition variables **th...
355,031
<p>Is that possible? I mean, can both ends of the many to many relationship point to the same table?</p>
[ { "answer_id": 355035, "author": "Uri", "author_id": 23072, "author_profile": "https://Stackoverflow.com/users/23072", "pm_score": 0, "selected": false, "text": "<p>If you are using hibernate-annotations, there is a @ManyToMany, not sure about the XML equivalent. It should appear in the ...
2008/12/10
[ "https://Stackoverflow.com/questions/355031", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38807/" ]
Is that possible? I mean, can both ends of the many to many relationship point to the same table?
I'm not sure how you'd do it without enormous, horrible redundancy. The standard way to handle a many-to-many relationship between two tables is via a third table that contains two primary key values, one for the first table, one for the second table, with a unique constraint (read 'index') on the combination of all th...
355,032
<p>I am trying to creating an optional association between a couple of tables. I have one table called Invoice. The Invoice table has a FK reference to the Customer table through the CustomerId field. The Invoice table also has a not enforced FK reference to the Project able through the ProjectId field.</p> <p>Is t...
[ { "answer_id": 355035, "author": "Uri", "author_id": 23072, "author_profile": "https://Stackoverflow.com/users/23072", "pm_score": 0, "selected": false, "text": "<p>If you are using hibernate-annotations, there is a @ManyToMany, not sure about the XML equivalent. It should appear in the ...
2008/12/10
[ "https://Stackoverflow.com/questions/355032", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1768/" ]
I am trying to creating an optional association between a couple of tables. I have one table called Invoice. The Invoice table has a FK reference to the Customer table through the CustomerId field. The Invoice table also has a not enforced FK reference to the Project able through the ProjectId field. Is there anyway t...
I'm not sure how you'd do it without enormous, horrible redundancy. The standard way to handle a many-to-many relationship between two tables is via a third table that contains two primary key values, one for the first table, one for the second table, with a unique constraint (read 'index') on the combination of all th...
355,038
<p>I see in richfaces that there is a single slider, wondering if anyone has created a dual slider like in Scriptaculous for it.</p> <p>Is there any concerns in mixing JSF, Richfaces and Scriptaculous in an application?</p>
[ { "answer_id": 357398, "author": "McDowell", "author_id": 304, "author_profile": "https://Stackoverflow.com/users/304", "pm_score": 3, "selected": true, "text": "<p>I can't answer your question with precision, but here's what I know.</p>\n\n<blockquote>\n <p>Is there any concerns in mix...
2008/12/10
[ "https://Stackoverflow.com/questions/355038", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8981/" ]
I see in richfaces that there is a single slider, wondering if anyone has created a dual slider like in Scriptaculous for it. Is there any concerns in mixing JSF, Richfaces and Scriptaculous in an application?
I can't answer your question with precision, but here's what I know. > > Is there any concerns in mixing JSF, > Richfaces and Scriptaculous in an > application? > > > Yes. About 50% of the problems people have with JSF are because they try to treat it like a another taglib library rather than a UI framework lik...
355,043
<p>I am trying to pass a dataString to to an ajax call using JQuery. In the call, I construct the get parameters and then send them to the php page on the receiving end. The trouble is that the data string has ampersands in them and the HTML strict validator is chocking on it.</p> <p>Here is the code:</p> <pre><cod...
[ { "answer_id": 355047, "author": "Marc Novakowski", "author_id": 27020, "author_profile": "https://Stackoverflow.com/users/27020", "pm_score": 6, "selected": true, "text": "<p>Try putting your javascript inside a CDATA block like this:</p>\n\n<pre><code>&lt;script type=\"text/javascript\...
2008/12/10
[ "https://Stackoverflow.com/questions/355043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4082/" ]
I am trying to pass a dataString to to an ajax call using JQuery. In the call, I construct the get parameters and then send them to the php page on the receiving end. The trouble is that the data string has ampersands in them and the HTML strict validator is chocking on it. Here is the code: ``` $(document).ready(fun...
Try putting your javascript inside a CDATA block like this: ``` <script type="text/javascript"> <![CDATA[ // content of your Javascript goes here ]]> </script> ``` which should make it pass validation. To be extra safe you can add Javascript comments around the CDATA tags to hide them from older browsers who don't ...
355,051
<p>I have a prefix trie. What is the recommended schema for representing this structure in a relational database? I need substring matching to remain efficient.</p>
[ { "answer_id": 355064, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 5, "selected": true, "text": "<p>How about the <a href=\"http://www.dbazine.com/oracle/or-articles/tropashko4\" rel=\"noreferrer\">Materialized Path<...
2008/12/10
[ "https://Stackoverflow.com/questions/355051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a prefix trie. What is the recommended schema for representing this structure in a relational database? I need substring matching to remain efficient.
How about the [Materialized Path](http://www.dbazine.com/oracle/or-articles/tropashko4) design? ``` CREATE TABLE trie ( path VARCHAR(<maxdepth>) PRIMARY KEY, ...other attributes of a tree node... ); ``` To store a word like "stackoverflow": ``` INSERT INTO trie (path) VALUES ('s'), ('st'), ('sta'), ('stac'), ...
355,062
<p>If I have a string with a valid math expression such as:</p> <pre><code>String s = "1 + 2 * 7"; </code></pre> <p>Is there a built in library/function in .NET that will parse and evaluate that expression for me and return the result? In this case 15.</p>
[ { "answer_id": 392347, "author": "Guy", "author_id": 1463, "author_profile": "https://Stackoverflow.com/users/1463", "pm_score": 5, "selected": false, "text": "<p>For anybody developing in C# on Silverlight here's a pretty neat trick that I've just discovered that allows evaluation of an...
2008/12/10
[ "https://Stackoverflow.com/questions/355062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1463/" ]
If I have a string with a valid math expression such as: ``` String s = "1 + 2 * 7"; ``` Is there a built in library/function in .NET that will parse and evaluate that expression for me and return the result? In this case 15.
You could add a reference to Microsoft Script Control Library (COM) and use code like this to evaluate an expression. (Also works for JScript.) ``` Dim sc As New MSScriptControl.ScriptControl() sc.Language = "VBScript" Dim expression As String = "1 + 2 * 7" Dim result As Double = sc.Eval(expression) ``` **Edit** - C...
355,073
<p>I have a simple vb6 editor type application which has a richtextbox as the editor page. It allows users to key in stuff and the store it into a file which will keep all the text in RTF stored as CDATA in xml.</p> <p>When you load back the file, it will read it off the xml and load back the rtf. We allow for unicode...
[ { "answer_id": 392347, "author": "Guy", "author_id": 1463, "author_profile": "https://Stackoverflow.com/users/1463", "pm_score": 5, "selected": false, "text": "<p>For anybody developing in C# on Silverlight here's a pretty neat trick that I've just discovered that allows evaluation of an...
2008/12/10
[ "https://Stackoverflow.com/questions/355073", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38124/" ]
I have a simple vb6 editor type application which has a richtextbox as the editor page. It allows users to key in stuff and the store it into a file which will keep all the text in RTF stored as CDATA in xml. When you load back the file, it will read it off the xml and load back the rtf. We allow for unicode editing, ...
You could add a reference to Microsoft Script Control Library (COM) and use code like this to evaluate an expression. (Also works for JScript.) ``` Dim sc As New MSScriptControl.ScriptControl() sc.Language = "VBScript" Dim expression As String = "1 + 2 * 7" Dim result As Double = sc.Eval(expression) ``` **Edit** - C...
355,083
<p>I wanna add server controls by using javascript. The main purpose of why I want is to add controls without any postback and get them in code-behind.</p>
[ { "answer_id": 355088, "author": "Strelok", "author_id": 2788, "author_profile": "https://Stackoverflow.com/users/2788", "pm_score": 0, "selected": false, "text": "<p>That is not generally possible. You must add server side controls <em>on the server</em>.</p>\n\n<p>If you want to avoid ...
2008/12/10
[ "https://Stackoverflow.com/questions/355083", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44852/" ]
I wanna add server controls by using javascript. The main purpose of why I want is to add controls without any postback and get them in code-behind.
You can check the Request.Form collection for all form values (client side controls) on the server. Each control will need to have a unique ID to access it in the request.Form collection. For example, if you had the following control ``` <input type="text" id="testBox" value="blah" /> ``` On the server you would ac...