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
372,934
<p>By "fixed vector" I mean a static list of values, like 1 through 24.</p> <p>The current query looks like this (simplified)</p> <pre><code>SELECT Period, Profit FROM Projections </code></pre> <p>But the data is "sparse" &#8212; so there's not a row for every period.</p> <p>What query will give me a row for peiods...
[ { "answer_id": 372953, "author": "Joachim Sauer", "author_id": 40342, "author_profile": "https://Stackoverflow.com/users/40342", "pm_score": 3, "selected": false, "text": "<p>There are just too many ways to get this wrong, that I wouldn't rely if anyone told me \"no, this will be safe, b...
2008/12/16
[ "https://Stackoverflow.com/questions/372934", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4525/" ]
By "fixed vector" I mean a static list of values, like 1 through 24. The current query looks like this (simplified) ``` SELECT Period, Profit FROM Projections ``` But the data is "sparse" — so there's not a row for every period. What query will give me a row for peiods 1-24 every time, with zeros (or NULLs) where ...
Any time you allow a user to enter data into a query string like this you are vulnerable to SQL injection and it should be avoided like the plague! You should be very careful how you allow your searchStrings[] array to be populated. You should always append variable data to your query using parameter objects: ``` + f...
372,955
<p>If I'm rendering a regular view in asp.net mvc the only domain object properties that show up in my page the ones I specifically write out. For example:</p> <pre><code>&lt;div&gt;&lt;%= Customer.FirstName %&gt;&lt;/div&gt; </code></pre> <p>However, if I serialize a domain object for json it will include every prop...
[ { "answer_id": 372977, "author": "Craig Stuntz", "author_id": 7714, "author_profile": "https://Stackoverflow.com/users/7714", "pm_score": 5, "selected": true, "text": "<p>I use anonymous types for this:</p>\n\n<pre><code>var customer = from c in serviceLayer.GetCustomers()\n ...
2008/12/16
[ "https://Stackoverflow.com/questions/372955", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31624/" ]
If I'm rendering a regular view in asp.net mvc the only domain object properties that show up in my page the ones I specifically write out. For example: ``` <div><%= Customer.FirstName %></div> ``` However, if I serialize a domain object for json it will include every property. Example: ``` public JsonResult Custom...
I use anonymous types for this: ``` var customer = from c in serviceLayer.GetCustomers() where c.Id == id.Value select new { FirstName = c.FirstName }; ``` This is not just a good idea. Rather, it's protection against the exception that you will get when calling Json() if your object gr...
372,961
<p>I have a SQL statement similar to this:</p> <pre><code>SELECT COUNT(*) AS foo, SUM(foo) AS foo_sum FROM bar </code></pre> <p>But MySQL doesn't allow this because foo is an alias. Does anyone have an idea of how this could be accomplished in SQL?</p>
[ { "answer_id": 372987, "author": "Harper Shelby", "author_id": 21196, "author_profile": "https://Stackoverflow.com/users/21196", "pm_score": 1, "selected": false, "text": "<pre><code>SELECT SUM(foo) as foo_sum\nFROM \n(\n SELECT COUNT(*) AS foo\n FROM bar\n GROUP BY baz\n)\n</co...
2008/12/16
[ "https://Stackoverflow.com/questions/372961", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46540/" ]
I have a SQL statement similar to this: ``` SELECT COUNT(*) AS foo, SUM(foo) AS foo_sum FROM bar ``` But MySQL doesn't allow this because foo is an alias. Does anyone have an idea of how this could be accomplished in SQL?
No, you can't use an alias in the select-list or a WHERE clause. You can only use the alias in a GROUP BY, HAVING, or ORDER BY. You can also use aliases defined in a subquery: ``` SELECT foo, SUM(foo) AS foo_sum FROM ( SELECT COUNT(*) AS foo FROM bar ); ```
372,974
<p>I want to programmatically invoke an event handler for a control. For example:</p> <pre><code>DateTimePicker dtpLastConsummated; </code></pre> <p>I want to trigger the TextChanged event handler for the <code>dtpLastConsummated</code>, how can i do it?</p> <p>In other languages I would call something akin to:</p> ...
[ { "answer_id": 372995, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 3, "selected": false, "text": "<p>Button in Windows Forms is a special case, because it has a <a href=\"http://msdn.microsoft.com/en-us/library/system....
2008/12/16
[ "https://Stackoverflow.com/questions/372974", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12597/" ]
I want to programmatically invoke an event handler for a control. For example: ``` DateTimePicker dtpLastConsummated; ``` I want to trigger the TextChanged event handler for the `dtpLastConsummated`, how can i do it? In other languages I would call something akin to: ``` dtpLastConsummated.TextChanged(this, new Ev...
3 suggestions to fire the TextChanged Event: Manually change the text: ``` string s = dateTimePicker1.Text; dateTimePicker1.Text = String.Empty; dateTimePicker1.Text = s; ``` or Inherit from DateTimePicker and create a new method that exposes / calls DateTimePicker's protected OnTextChang...
372,982
<p>I have from the backend a time on the format 00:12:54 and I display it to the screen. But, I would like to have this time to continue to go down. I have though to create a variable in javascript that will old the time and with <code>setTimeout</code> to loop to display with document.getElementById the new value. I t...
[ { "answer_id": 372986, "author": "Patrick Desjardins", "author_id": 13913, "author_profile": "https://Stackoverflow.com/users/13913", "pm_score": 2, "selected": false, "text": "<p>Do you know jQuery Framework? It's a Javascript framework that have a lot of utilities methods and functions...
2008/12/16
[ "https://Stackoverflow.com/questions/372982", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46829/" ]
I have from the backend a time on the format 00:12:54 and I display it to the screen. But, I would like to have this time to continue to go down. I have though to create a variable in javascript that will old the time and with `setTimeout` to loop to display with document.getElementById the new value. I think it can be...
General algorithm: 1. Read time from server. 2. Read the current time. 3. Call a function. 4. In your function, read the current time, get the delta from the initial time you read in step 2. 5. Subtract the delta from the initial time you read from the server in step 1 and display the remainder. 6. The function should...
372,988
<p>I'm new to database indexing, if I have 2 columns in a table that are good choices for indexing like for example,</p> <pre><code>[Posts]( [PostID] [int] IDENTITY(1,1) NOT NULL, [UserName] [nvarchar](64) NOT NULL, [ApplicationType] [smallint] NOT NULL, ... ) </code></pre> <p>in this case PostID woul...
[ { "answer_id": 373021, "author": "Scott Ivey", "author_id": 36297, "author_profile": "https://Stackoverflow.com/users/36297", "pm_score": 2, "selected": false, "text": "<p>The answer to this question really depends on how you are going to be searching on the table. If your searches will...
2008/12/16
[ "https://Stackoverflow.com/questions/372988", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32240/" ]
I'm new to database indexing, if I have 2 columns in a table that are good choices for indexing like for example, ``` [Posts]( [PostID] [int] IDENTITY(1,1) NOT NULL, [UserName] [nvarchar](64) NOT NULL, [ApplicationType] [smallint] NOT NULL, ... ) ``` in this case PostID would be the PRIMARY KEY CLUST...
Keep in mind the telephone-book rule for compound indexes: the phone book is effectively indexed by last-name, first-name. It's a compound index. If you search for people named "Smith, John" then it's helpful that the first-name is part of the index. Once you find the entries with last-name "Smith" then you can find ...
373,002
<p>I'm trying to find a markdown interpreter class/module that I can use in a rakefile.</p> <p>So far I've found <a href="http://maruku.rubyforge.org/" rel="noreferrer">maruku</a>, but I'm a bit wary of beta releases.</p> <p>Has anyone had any issues with maruku? Or, do you know of a better alternative?</p>
[ { "answer_id": 373013, "author": "Gordon Wilson", "author_id": 23071, "author_profile": "https://Stackoverflow.com/users/23071", "pm_score": 1, "selected": false, "text": "<p>I believe <a href=\"http://www.deveiate.org/projects/BlueCloth/\" rel=\"nofollow noreferrer\">BlueCloth</a> is th...
2008/12/16
[ "https://Stackoverflow.com/questions/373002", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15031/" ]
I'm trying to find a markdown interpreter class/module that I can use in a rakefile. So far I've found [maruku](http://maruku.rubyforge.org/), but I'm a bit wary of beta releases. Has anyone had any issues with maruku? Or, do you know of a better alternative?
I use Maruku to process 100,000 - 200,000 documents per day. Mostly forum posts but I also use it on large documents like wiki pages. Maruku is much faster than BlueCloth and it doesn't choke on large documents. It's all Ruby and although the code isn't especially easy to extend and augment, it is doable. We have a few...
373,020
<p>Is there a way to find the application name of the current active window at a given time on Mac OS X using Python?</p>
[ { "answer_id": 373210, "author": "Peter Hosey", "author_id": 30461, "author_profile": "https://Stackoverflow.com/users/30461", "pm_score": 3, "selected": false, "text": "<p>First off, do you want the window or the application name? This isn't Windows—an application process on Mac OS X ca...
2008/12/16
[ "https://Stackoverflow.com/questions/373020", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40195/" ]
Is there a way to find the application name of the current active window at a given time on Mac OS X using Python?
This should work: ``` #!/usr/bin/python from AppKit import NSWorkspace activeAppName = NSWorkspace.sharedWorkspace().activeApplication()['NSApplicationName'] print activeAppName ``` Only works on Leopard, or on Tiger if you have PyObjC installed and happen to point at the right python binary in line one (not the ca...
373,022
<p>I'm trying to retrive a dataset to a Gridview, but I just don't get any row in my Gridview. What am I doing wrong?</p> <p>the page code</p> <pre><code>Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load CType(Master, AreaTrabalho).AlteraTitulo = "Projectos" Using o...
[ { "answer_id": 373210, "author": "Peter Hosey", "author_id": 30461, "author_profile": "https://Stackoverflow.com/users/30461", "pm_score": 3, "selected": false, "text": "<p>First off, do you want the window or the application name? This isn't Windows—an application process on Mac OS X ca...
2008/12/16
[ "https://Stackoverflow.com/questions/373022", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2019426/" ]
I'm trying to retrive a dataset to a Gridview, but I just don't get any row in my Gridview. What am I doing wrong? the page code ``` Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load CType(Master, AreaTrabalho).AlteraTitulo = "Projectos" Using oSQL As New clsSQL(Sys...
This should work: ``` #!/usr/bin/python from AppKit import NSWorkspace activeAppName = NSWorkspace.sharedWorkspace().activeApplication()['NSApplicationName'] print activeAppName ``` Only works on Leopard, or on Tiger if you have PyObjC installed and happen to point at the right python binary in line one (not the ca...
373,027
<p>I'm getting this error in a PHP (Drupal) application:</p> <pre><code>(104)Connection reset by peer: FastCGI: comm with server "/opt/php-5.2.5/bin/php-cgi" aborted: read failed </code></pre> <p>It is often followed by this error:</p> <pre><code>FastCGI: incomplete headers (0 bytes) received from server "/opt/php-...
[ { "answer_id": 373163, "author": "Leandro Ardissone", "author_id": 42565, "author_profile": "https://Stackoverflow.com/users/42565", "pm_score": 1, "selected": false, "text": "<p>What's the character set you're using?\nI've read that some people is having issues if their app is using a d...
2008/12/16
[ "https://Stackoverflow.com/questions/373027", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32137/" ]
I'm getting this error in a PHP (Drupal) application: ``` (104)Connection reset by peer: FastCGI: comm with server "/opt/php-5.2.5/bin/php-cgi" aborted: read failed ``` It is often followed by this error: ``` FastCGI: incomplete headers (0 bytes) received from server "/opt/php-5.2.5/bin/php-cgi" ``` The basic Apa...
In this particular issue, it was related to an odd bug in my code... it seems certain kinds of errors cause FastCGI to fail so badly that it doesn't forward on the underlying PHP code error. Sorry I don't have more detail for those of you visiting from Google.
373,057
<p>I'm performing a bulk insert with an ADO.NET 2.0 SqlBulkCopy object from a C# method into a MS SQL 2005 database, using a database user with limited permissions. When I try to run the operation, I get the error message:</p> <blockquote> <p>Bulk copy failed. User does not have ALTER TABLE permission on table ...
[ { "answer_id": 373963, "author": "gbn", "author_id": 27535, "author_profile": "https://Stackoverflow.com/users/27535", "pm_score": 2, "selected": false, "text": "<p>Possibilities only, I'm sorry</p>\n\n<p>SQL documentation for <a href=\"http://msdn.microsoft.com/en-us/library/ms188365(SQ...
2008/12/16
[ "https://Stackoverflow.com/questions/373057", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41457/" ]
I'm performing a bulk insert with an ADO.NET 2.0 SqlBulkCopy object from a C# method into a MS SQL 2005 database, using a database user with limited permissions. When I try to run the operation, I get the error message: > > Bulk copy failed. User does not have > ALTER TABLE permission on table > 'theTable'. ALTER >...
Solved it! Looks like I need a refresher on flags enums. I was bitwise ANDing the enum values when I should have been ORing them. ``` SqlBulkCopyOptions.FireTriggers & SqlBulkCopyOptions.CheckConstraints ``` evaluates to zero (which is equivalent to SqlBulkCopyOptions.Default.) ``` SqlBulkCopyOptions.FireTriggers |...
373,067
<p>I'm creating a simple API that creates typed classes based on JSON data that has a mandatory 'type' field defined in it. It uses this string to define a new type, add the fields in the JSON object, instantiate it, and then populate the fields on the instance.</p> <p>What I want to be able to do is allow for these ...
[ { "answer_id": 373076, "author": "Can Berk Güder", "author_id": 2119, "author_profile": "https://Stackoverflow.com/users/2119", "pm_score": 0, "selected": false, "text": "<p>You can use <code>dir()</code>:</p>\n\n<pre><code>Python 2.5.2 (r252:60911, Oct 5 2008, 19:29:17)\n[GCC 4.3.2] on...
2008/12/16
[ "https://Stackoverflow.com/questions/373067", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm creating a simple API that creates typed classes based on JSON data that has a mandatory 'type' field defined in it. It uses this string to define a new type, add the fields in the JSON object, instantiate it, and then populate the fields on the instance. What I want to be able to do is allow for these types to be...
You can use `dir()` to get a list of all the names of all objects in the current environment, and you can use `globals()` to a get a dictionary mapping those names to their values. Thus, to get just the list of objects which are classes, you can do: ``` import types listOfClasses = [cls for cls in globals().values() i...
373,089
<p>What is the purpose of this Rails config setting...</p> <pre><code>config.action_controller.consider_all_requests_local = true </code></pre> <p>It's set to true by default in <code>config/environments/development.rb</code>.</p> <p>Thanks,</p> <p>Ethan</p>
[ { "answer_id": 373135, "author": "Gordon Wilson", "author_id": 23071, "author_profile": "https://Stackoverflow.com/users/23071", "pm_score": 8, "selected": true, "text": "<p>Non-local requests result in user-friendly error pages. Local requests, assumed to come from developers, see a mo...
2008/12/16
[ "https://Stackoverflow.com/questions/373089", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42595/" ]
What is the purpose of this Rails config setting... ``` config.action_controller.consider_all_requests_local = true ``` It's set to true by default in `config/environments/development.rb`. Thanks, Ethan
Non-local requests result in user-friendly error pages. Local requests, assumed to come from developers, see a more useful error message that includes line numbers and a backtrace. `consider_all_requests_local` allows your app to display these developer-friendly messages even when the machine making the request is remo...
373,106
<p>I have a site that will ultimately support 4 languages and 2 countries (US &amp; Canada, English and Spanish)</p> <p>I'm wondering what's the best way to set up the directory structure?</p> <p>Right now, I have a root site called site.com: </p> <p>This will take you to a page where you choose your country and lan...
[ { "answer_id": 373145, "author": "Stefan", "author_id": 19307, "author_profile": "https://Stackoverflow.com/users/19307", "pm_score": 1, "selected": false, "text": "<p>Why not having one site and check the client setting (request.servervariables / HTTP_ACCEPT_LANGUAGE) for what preferred...
2008/12/16
[ "https://Stackoverflow.com/questions/373106", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26931/" ]
I have a site that will ultimately support 4 languages and 2 countries (US & Canada, English and Spanish) I'm wondering what's the best way to set up the directory structure? Right now, I have a root site called site.com: This will take you to a page where you choose your country and language. Ideally, I want to h...
Well, they want the Url to be different for each site. Essentially it is actually one site (for maintenance reasons) and we're using globalization to determine which connection string to use (different databases, identical structures in each one) Each time we publish I'll publish to four locations. Identical app. G...
373,126
<p>I am trying to so something like <a href="https://stackoverflow.com/questions/48475/database-design-for-tagging">Database Design for Tagging</a>, except each of my tags are grouped into categories.</p> <p>For example, let's say I have a database about vehicles. Let's say we actually don't know very much about vehi...
[ { "answer_id": 373160, "author": "Carlos Nunes-Ueno", "author_id": 21979, "author_profile": "https://Stackoverflow.com/users/21979", "pm_score": 0, "selected": false, "text": "<p>I think your solution is to simply add a manufacturer column to your vehicles table. It's an attribute that ...
2008/12/16
[ "https://Stackoverflow.com/questions/373126", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21838/" ]
I am trying to so something like [Database Design for Tagging](https://stackoverflow.com/questions/48475/database-design-for-tagging), except each of my tags are grouped into categories. For example, let's say I have a database about vehicles. Let's say we actually don't know very much about vehicles, so we can't spec...
This is yet another variation on the [Entity-Attribute-Value](http://en.wikipedia.org/wiki/Entity-attribute-value_model) design. A more recognizable EAV table looks like the following: ``` CREATE TABLE vehicleEAV ( vid INTEGER, attr_name VARCHAR(20), attr_value VARCHAR(100), PRIMARY KEY (vid, attr_nam...
373,134
<p>I have just installed darcs 2.1.2.2. When I type darcs help, sth less-like shows up. When I dismiss it with q it goes away but I don't get prompt and can't execute any commands. C-c doesn't work either. I am using bash on gentoo.</p>
[ { "answer_id": 411496, "author": "Steve Baker", "author_id": 13566, "author_profile": "https://Stackoverflow.com/users/13566", "pm_score": 3, "selected": true, "text": "<p>I have no idea what darcs is, but when bash fails to return to the prompt that some command as part of a pipeline is...
2008/12/16
[ "https://Stackoverflow.com/questions/373134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5978/" ]
I have just installed darcs 2.1.2.2. When I type darcs help, sth less-like shows up. When I dismiss it with q it goes away but I don't get prompt and can't execute any commands. C-c doesn't work either. I am using bash on gentoo.
I have no idea what darcs is, but when bash fails to return to the prompt that some command as part of a pipeline is still running. For instance if you ran: ``` cmd | less ``` And exited less, but cmd did not die from a broken pipe, then cmd would continue to run and bash would continue to wait until it exited. It a...
373,142
<p>What techniques can be used to speed up C++ compilation times?</p> <p>This question came up in some comments to Stack Overflow question <em><a href="https://stackoverflow.com/questions/372862">C++ programming style</a></em>, and I'm interested to hear what ideas there are.</p> <p>I've seen a related question, <em>...
[ { "answer_id": 373147, "author": "Vilx-", "author_id": 41360, "author_profile": "https://Stackoverflow.com/users/41360", "pm_score": 2, "selected": false, "text": "<p>I had an idea about <a href=\"https://stackoverflow.com/questions/354254/ramdrive-for-compiling-is-there-such-a-thing\">u...
2008/12/16
[ "https://Stackoverflow.com/questions/373142", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11898/" ]
What techniques can be used to speed up C++ compilation times? This question came up in some comments to Stack Overflow question *[C++ programming style](https://stackoverflow.com/questions/372862)*, and I'm interested to hear what ideas there are. I've seen a related question, *[Why does C++ compilation take so long...
Language techniques ------------------- ### Pimpl Idiom Take a look at the *[Pimpl idiom](https://en.wikipedia.org/wiki/Opaque_pointer)* [here](http://www.gotw.ca/gotw/028.htm), and [here](http://www.gotw.ca/gotw/024.htm), also known as an [opaque pointer](http://en.wikipedia.org/wiki/Opaque_pointer) or handle classe...
373,149
<p>I am trying to encode/decode MIME headers in Ruby.</p>
[ { "answer_id": 374045, "author": "Keltia", "author_id": 16143, "author_profile": "https://Stackoverflow.com/users/16143", "pm_score": 3, "selected": true, "text": "<p>Ruby has Base64 methods in core, just do</p>\n\n<pre><code>require \"base64\"\n</code></pre>\n\n<p>and use <code>Base64.d...
2008/12/16
[ "https://Stackoverflow.com/questions/373149", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39529/" ]
I am trying to encode/decode MIME headers in Ruby.
Ruby has Base64 methods in core, just do ``` require "base64" ``` and use `Base64.decode64` and `Base64.encode64`. For quoted-printable, you could use the following code [here](http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/133587).
373,153
<p>When you're using a factory pattern, how do you inject dependencies into constructors at runtime?</p> <p>I'm building Foos with different formats - boolean, array, freetext, matrix, etc. That format list will grow as we find different uses for Foo. Here's my basic core domain:</p> <pre><code>public interface IFo...
[ { "answer_id": 373797, "author": "Andrew Kennan", "author_id": 22506, "author_profile": "https://Stackoverflow.com/users/22506", "pm_score": 3, "selected": true, "text": "<p>Maybe you can do something along these lines where your abstract FooFormat becomes IFooFormat and a generic FooFor...
2008/12/16
[ "https://Stackoverflow.com/questions/373153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33157/" ]
When you're using a factory pattern, how do you inject dependencies into constructors at runtime? I'm building Foos with different formats - boolean, array, freetext, matrix, etc. That format list will grow as we find different uses for Foo. Here's my basic core domain: ``` public interface IFoo { FooFormat Forma...
Maybe you can do something along these lines where your abstract FooFormat becomes IFooFormat and a generic FooFormat provides an Init method that gets passed the parameter. Then a single overload of Build lets you pass in the parameter. ``` public interface IFooFormat { } public class FooFormat<TValue> : IFooFormat...
373,156
<p>I'm scared that one day, I'm going to put a space or miss out something in the command I currently use:</p> <pre><code>rm -rf ./* </code></pre> <p>Is there a safer way of emptying the current directory's contents?</p>
[ { "answer_id": 373164, "author": "Chris Kloberdanz", "author_id": 28714, "author_profile": "https://Stackoverflow.com/users/28714", "pm_score": 0, "selected": false, "text": "<p>You could always turn on <code>-i</code> which would prompt you on every file, but that would be really time c...
2008/12/16
[ "https://Stackoverflow.com/questions/373156", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3410/" ]
I'm scared that one day, I'm going to put a space or miss out something in the command I currently use: ``` rm -rf ./* ``` Is there a safer way of emptying the current directory's contents?
The safest way is to sit on your hands before pressing Enter. That aside, you could create an alias like this one (for Bash) ``` alias rm="pwd;read;rm" ``` That will show you your directory, wait for an enter press and then remove what you specified with the proper flags. You can cancel by pressing ^C instead of E...
373,157
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/321113/how-can-i-pre-set-arguments-in-javascript-function-call-partial-function-appli">How can I pre-set arguments in JavaScript function call? (Partial Function Application)</a> </p> </blockquote> <p>I need to...
[ { "answer_id": 373216, "author": "Jason Bunting", "author_id": 1790, "author_profile": "https://Stackoverflow.com/users/1790", "pm_score": 7, "selected": true, "text": "<p>What you are after is called <strong>partial function application</strong>. </p>\n\n<p>Don't be fooled by those that...
2008/12/16
[ "https://Stackoverflow.com/questions/373157", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44084/" ]
> > **Possible Duplicate:** > > [How can I pre-set arguments in JavaScript function call? (Partial Function Application)](https://stackoverflow.com/questions/321113/how-can-i-pre-set-arguments-in-javascript-function-call-partial-function-appli) > > > I need to able to **pass a reference to a function with a gi...
What you are after is called **partial function application**. Don't be fooled by those that don't understand the subtle difference between that and currying, they *are* different. Partial function application can be used to implement, but *is not* currying. Here is a quote from [**a blog post on the difference**](h...
373,182
<p>I bet I've got elementary question, but I couldn't solve it for two nights. I've got 1 "ul" element and I just want it to move any amount of pixels every e.g. 2 sec to the left. I want him to move like this step by step and then come back to the original position and start moving again. I've been stucked, my script...
[ { "answer_id": 373201, "author": "hhafez", "author_id": 42303, "author_profile": "https://Stackoverflow.com/users/42303", "pm_score": 0, "selected": false, "text": "<p>Is the problem you can't go back from where you started?</p>\n\n<p>Why not just add a new for loop in move</p>\n\n<pre><...
2008/12/16
[ "https://Stackoverflow.com/questions/373182", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46866/" ]
I bet I've got elementary question, but I couldn't solve it for two nights. I've got 1 "ul" element and I just want it to move any amount of pixels every e.g. 2 sec to the left. I want him to move like this step by step and then come back to the original position and start moving again. I've been stucked, my script on...
Do you mean something like this? ``` window.onload = function moveUl() { var eUl = document.getElementById('change'); var eLi = eUl.getElementsByTagName('li'); var delta = 0; function move() { for(i=0;i< eLi.length;i++) eUl.style.marginLeft = (-300*i+delta)+'px'; delta...
373,186
<p>I see that I can declare a function with (say)</p> <pre><code>public double Function(double parameter) </code></pre> <p>but what if I do want to take the derivative of that function?</p>
[ { "answer_id": 373199, "author": "Chris Brandsma", "author_id": 9443, "author_profile": "https://Stackoverflow.com/users/9443", "pm_score": 1, "selected": false, "text": "<p>Are you thinking of Lambda Expressions?</p>\n\n<p>Basically you can pass a function into a function.</p>\n\n<p>So ...
2008/12/16
[ "https://Stackoverflow.com/questions/373186", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46827/" ]
I see that I can declare a function with (say) ``` public double Function(double parameter) ``` but what if I do want to take the derivative of that function?
You can't calculate the exact derivative of a function using a computer program (unless you're doing symbolic math... but that's another, way more complicated, topic). There are several approaches to computing a *numerical* derivative of a function. The simplest is the centered three-point method: * Take a small numb...
373,194
<p>I've come up with:</p> <pre><code>re.findall("([a-fA-F\d]*)", data) </code></pre> <p>but it's not very fool proof, is there a better way to grab all MD5-hash codes?</p>
[ { "answer_id": 373206, "author": "Corey", "author_id": 1595, "author_profile": "https://Stackoverflow.com/users/1595", "pm_score": 2, "selected": false, "text": "<p>How about \"([a-fA-F\\d]{32})\" which requires it to be 32 characters long?</p>\n" }, { "answer_id": 373207, "a...
2008/12/16
[ "https://Stackoverflow.com/questions/373194", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32933/" ]
I've come up with: ``` re.findall("([a-fA-F\d]*)", data) ``` but it's not very fool proof, is there a better way to grab all MD5-hash codes?
Well, since md5 is just a string of 32 hex digits, about all you could add to your expression is a check for "32 digits", perhaps something like this? ``` re.findall(r"([a-fA-F\d]{32})", data) ```
373,212
<p>I've created a <em>very</em> simple app, which presents an easygui entrybox() and continues to loop this indefinitely as it receives user input.</p> <p>I can quit the program using the Cancel button as this returns None, but I would also like to be able to use the standard 'close' button to quit the program. (ie. t...
[ { "answer_id": 373267, "author": "Angel", "author_id": 23285, "author_profile": "https://Stackoverflow.com/users/23285", "pm_score": 0, "selected": false, "text": "<p>I don't know right now, but have you tried something like this?:</p>\n\n<pre><code>root.protocol('WM_DELETE_WINDOW', sel...
2008/12/16
[ "https://Stackoverflow.com/questions/373212", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44817/" ]
I've created a *very* simple app, which presents an easygui entrybox() and continues to loop this indefinitely as it receives user input. I can quit the program using the Cancel button as this returns None, but I would also like to be able to use the standard 'close' button to quit the program. (ie. top right of a Win...
It would require altering the easygui module, yes. I will get it modified! \*\* I have sent in a e-mail to the EasyGUI creator explaning this [12:12 PM, January 23/09] \*\* I just want to say that the possibility of this change happening - if at all, which I doubt - is very tiny. You see, EasyGUI is intended to be a ...
373,219
<p>I have a silverlight control which has a reference to a silverlight enabled wcf service.</p> <p>When I add a reference to the service in my silverlight control, it adds the following to my clientconfig file:</p> <pre><code>&lt;configuration&gt; &lt;system.serviceModel&gt; &lt;bindings&gt; &...
[ { "answer_id": 373280, "author": "Strelok", "author_id": 2788, "author_profile": "https://Stackoverflow.com/users/2788", "pm_score": 3, "selected": true, "text": "<p>You can't use relative URIs in client endpoint configuration. What you can do is just add another constructor to your prox...
2008/12/16
[ "https://Stackoverflow.com/questions/373219", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9266/" ]
I have a silverlight control which has a reference to a silverlight enabled wcf service. When I add a reference to the service in my silverlight control, it adds the following to my clientconfig file: ``` <configuration> <system.serviceModel> <bindings> <basicHttpBinding> <bind...
You can't use relative URIs in client endpoint configuration. What you can do is just add another constructor to your proxy class that will take some sort of URL parameter that you can perhaps get from another config value or use one of the Dns class methods.
373,229
<p>I think im asking for the right type of report from Quickreport.</p> <p>What we have is a simple table, </p> <pre><code>gauge,site,value </code></pre> <p>Gauge and site are the keyfields, (there could be anynumber of Gauge-Site Pairs) normally there is only at most, about 10 sites.</p> <p>and we are looking to ...
[ { "answer_id": 373443, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": true, "text": "<p>It's called a cross tabulation. Google for \"crosstab\", \"crosstab report\", \"crosstab object\".</p>\n" }, { "answ...
2008/12/17
[ "https://Stackoverflow.com/questions/373229", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11016/" ]
I think im asking for the right type of report from Quickreport. What we have is a simple table, ``` gauge,site,value ``` Gauge and site are the keyfields, (there could be anynumber of Gauge-Site Pairs) normally there is only at most, about 10 sites. and we are looking to get a reports that looks like this ``` ...
It's called a cross tabulation. Google for "crosstab", "crosstab report", "crosstab object".
373,230
<p>How do I check to see if a column exists in a <code>SqlDataReader</code> object? In my data access layer, I have create a method that builds the same object for multiple stored procedures calls. One of the stored procedures has an additional column that is not used by the other stored procedures. I want to modifi...
[ { "answer_id": 373250, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 5, "selected": false, "text": "<p>I think your best bet is to call <a href=\"http://msdn.microsoft.com/en-us/library/system.data.idatarecord.getordinal...
2008/12/17
[ "https://Stackoverflow.com/questions/373230", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26327/" ]
How do I check to see if a column exists in a `SqlDataReader` object? In my data access layer, I have create a method that builds the same object for multiple stored procedures calls. One of the stored procedures has an additional column that is not used by the other stored procedures. I want to modified the method to ...
``` public static class DataRecordExtensions { public static bool HasColumn(this IDataRecord dr, string columnName) { for (int i=0; i < dr.FieldCount; i++) { if (dr.GetName(i).Equals(columnName, StringComparison.InvariantCultureIgnoreCase)) return true; } ...
373,233
<p>Why does adding an "||" OR between 2 "!=" not work for me? </p> <p>When 'name' is "test" or "test2" my if statement doesn't work if I've used 2 "!=" but if I use just one it does, please tell me why.</p> <pre><code>if (col.Name != "test" || col.Name != "test2") { MessageBox.Show("No" + col.Name.ToString()); //T...
[ { "answer_id": 373240, "author": "Dan Vinton", "author_id": 21849, "author_profile": "https://Stackoverflow.com/users/21849", "pm_score": 4, "selected": false, "text": "<p>try this:</p>\n\n<pre><code>col.Name != \"test\" &amp;&amp; col.Name != \"test2\"\n</code></pre>\n\n<p>think about i...
2008/12/17
[ "https://Stackoverflow.com/questions/373233", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Why does adding an "||" OR between 2 "!=" not work for me? When 'name' is "test" or "test2" my if statement doesn't work if I've used 2 "!=" but if I use just one it does, please tell me why. ``` if (col.Name != "test" || col.Name != "test2") { MessageBox.Show("No" + col.Name.ToString()); //This shows "No test" a...
try this: ``` col.Name != "test" && col.Name != "test2" ``` think about it... "if the number is not 1, or the number is not 2" will always be true, since no number is both 1 *and* 2 to makes both halves false. Now extend this to strings.
373,234
<p>How can I grab my local changelist and send it to someone else in Perforce? More specifically, I would like to send unsubmitted changes from a local pending changelist to another user's pending changelist.</p>
[ { "answer_id": 373434, "author": "Ana Betts", "author_id": 5728, "author_profile": "https://Stackoverflow.com/users/5728", "pm_score": 5, "selected": true, "text": "<pre><code>set P4DIFF=C:\\cygwin\\bin\\diff.exe\np4 diff -du -c 12345 &gt; patch-to-head.diff\n\n# On Other machine\npatch ...
2008/12/17
[ "https://Stackoverflow.com/questions/373234", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46869/" ]
How can I grab my local changelist and send it to someone else in Perforce? More specifically, I would like to send unsubmitted changes from a local pending changelist to another user's pending changelist.
``` set P4DIFF=C:\cygwin\bin\diff.exe p4 diff -du -c 12345 > patch-to-head.diff # On Other machine patch -p1 < patch-to-head.diff ``` I may be wrong on the env var there, and you might have to do some fixups on the diff file, but the general idea is that you generate a GNU Unified Diff, that you can send to people t...
373,243
<p>I use ls to obtain my filename which has white space so it looks something like: </p> <p><code>my file with whitespace.tar.bz2</code></p> <p>I want to pipe this to tar similar to:</p> <pre><code>ls | grep mysearchstring | tar xvjf </code></pre> <p>How can I insert double quotes before piping it to tar?</p>
[ { "answer_id": 373296, "author": "Zan Lynx", "author_id": 13422, "author_profile": "https://Stackoverflow.com/users/13422", "pm_score": 3, "selected": false, "text": "<p>A good tool for this is find and xargs. For example, you might use:</p>\n\n<pre><code>find . -name '*.tar.bz2' -print...
2008/12/17
[ "https://Stackoverflow.com/questions/373243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23120/" ]
I use ls to obtain my filename which has white space so it looks something like: `my file with whitespace.tar.bz2` I want to pipe this to tar similar to: ``` ls | grep mysearchstring | tar xvjf ``` How can I insert double quotes before piping it to tar?
A good tool for this is find and xargs. For example, you might use: ``` find . -name '*.tar.bz2' -print0 | xargs -0 -n1 tar xjf ``` As pixelbeat suggested you can also use the shell like this: ``` for archive in *.tar.bz2; do tar xvjf "$archive"; done ```
373,252
<p>Recently saw someone commending another user on their use of sizeof var instead of sizeof(type). I always thought that was just a style choice. Is there any significant difference? As an example, the lines with f and ff were considered better than the lines with g and gg:</p> <pre><code> typedef struct _foo {} foo;...
[ { "answer_id": 373256, "author": "Steve Fallows", "author_id": 18882, "author_profile": "https://Stackoverflow.com/users/18882", "pm_score": 7, "selected": true, "text": "<p>If the type of the variable is changed, the sizeof will not require changing if the variable is the argument, rath...
2008/12/17
[ "https://Stackoverflow.com/questions/373252", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44065/" ]
Recently saw someone commending another user on their use of sizeof var instead of sizeof(type). I always thought that was just a style choice. Is there any significant difference? As an example, the lines with f and ff were considered better than the lines with g and gg: ``` typedef struct _foo {} foo; foo *f = ma...
If the type of the variable is changed, the sizeof will not require changing if the variable is the argument, rather than the type. Regarding @icepack's comment: the possibility or likelihood of change for type vs. variable name is not the issue. Imagine the variable name is used as the the argument to sizeof and then...
373,253
<p>Given an array like {"one two", "three four five"}, how'd you calculate the total number of words contained in it using LINQ?</p>
[ { "answer_id": 373260, "author": "Christian C. Salvadó", "author_id": 5445, "author_profile": "https://Stackoverflow.com/users/5445", "pm_score": 3, "selected": false, "text": "<p>You can do it with SelectMany:</p>\n\n<pre><code>var stringArray = new[] {\"one two\", \"three four five\"};...
2008/12/17
[ "https://Stackoverflow.com/questions/373253", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1670/" ]
Given an array like {"one two", "three four five"}, how'd you calculate the total number of words contained in it using LINQ?
Or if you want to use the C# language extensions: ``` var words = (from line in new[] { "one two", "three four five" } from word in line.Split(' ', StringSplitOptions.RemoveEmptyEntries) select word).Count(); ```
373,257
<p>I have many sites that use the same root category of the Main Site. Each product that is added is added to the site it was added to (wow.) and also the Main Site. However, I would like categories on a per site basis to only appear if there are products on that site.</p> <p>If I have:</p> <pre><code>Category1 Categ...
[ { "answer_id": 380762, "author": "Till", "author_id": 2859, "author_profile": "https://Stackoverflow.com/users/2859", "pm_score": 2, "selected": true, "text": "<p>Well, what you can do is, create your own helper with a collection (through a model), and then filter the collection based on...
2008/12/17
[ "https://Stackoverflow.com/questions/373257", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have many sites that use the same root category of the Main Site. Each product that is added is added to the site it was added to (wow.) and also the Main Site. However, I would like categories on a per site basis to only appear if there are products on that site. If I have: ``` Category1 Category2 Category3 ``` ...
Well, what you can do is, create your own helper with a collection (through a model), and then filter the collection based on product count. Only a rough draft, but I've posted some code in another magento related question: [Magento products by categories](https://stackoverflow.com/questions/272818/magento-products-by...
373,258
<p>Let's in fact generalize to a <code>c</code>-confidence interval. Let the common rate parameter be <code>a</code>. (Note that the mean of an exponential distribution with rate parameter <code>a</code> is <code>1/a</code>.)</p> <p>First find the cdf of the sum of <code>n</code> such i.i.d. random variables. Use t...
[ { "answer_id": 373470, "author": "John D. Cook", "author_id": 25188, "author_profile": "https://Stackoverflow.com/users/25188", "pm_score": 1, "selected": false, "text": "<p>Hint: the sum of independent exponential random variables is a gamma random variable.</p>\n" }, { "answer_...
2008/12/17
[ "https://Stackoverflow.com/questions/373258", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4234/" ]
Let's in fact generalize to a `c`-confidence interval. Let the common rate parameter be `a`. (Note that the mean of an exponential distribution with rate parameter `a` is `1/a`.) First find the cdf of the sum of `n` such i.i.d. random variables. Use that to compute a `c`-confidence interval on the sum. Note that the m...
As John D. Cook hinted, the sum of i.i.d. exponential random variables has a gamma distribution. Here's the cdf of the sum of n exponential random variables with rate parameter a (expressed in Mathematica): ``` F[x_] := 1 - GammaRegularized[n, a*x]; ``` <http://mathworld.wolfram.com/RegularizedGammaFunction.html>...
373,262
<p>How can the XOR operation (on two 32 bit ints) be implemented using only basic arithmetic operations? Do you have to do it bitwise after dividing by each power of 2 in turn, or is there a shortcut? I don't care about execution speed so much as about the simplest, shortest code.</p> <p><strong>Edit:</strong> This is...
[ { "answer_id": 373290, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 4, "selected": true, "text": "<p>I'm sorry i only know the straight forward one in head:</p>\n\n<pre><code>uint32_t mod_op(uint32_t a, uin...
2008/12/17
[ "https://Stackoverflow.com/questions/373262", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16883/" ]
How can the XOR operation (on two 32 bit ints) be implemented using only basic arithmetic operations? Do you have to do it bitwise after dividing by each power of 2 in turn, or is there a shortcut? I don't care about execution speed so much as about the simplest, shortest code. **Edit:** This is not homework, but a ri...
I'm sorry i only know the straight forward one in head: ``` uint32_t mod_op(uint32_t a, uint32_t b) { uint32_t int_div = a / b; return a - (b * int_div); } uint32_t xor_op(uint32_t a, uint32_t b) { uint32_t n = 1u; uint32_t result = 0u; while(a != 0 || b != 0) { // or just: result += n * m...
373,287
<p>Is it possible to send messages from a PHP script to the console in Eclipse? Has anyone attempted this already? I'm not very familiar with how the console works, so I'm not sure if there is a standardized method for communicating with it.</p>
[ { "answer_id": 374991, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>All output from an Eclipse external tool launch goes to the console by default, so if you execute a PHP script using an ext...
2008/12/17
[ "https://Stackoverflow.com/questions/373287", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5291/" ]
Is it possible to send messages from a PHP script to the console in Eclipse? Has anyone attempted this already? I'm not very familiar with how the console works, so I'm not sure if there is a standardized method for communicating with it.
If you look at... Main Menu -> Run -> External Tools -> Open External Tools Dialog. In there I have set up PHP Codesniffer with the following... * Name : Code Sniffer * Location : /usr/bin/phpcs * Working Directory : ${workspace\_loc} * Arguments : --standard=${resource\_loc} That runs the codesniffer as an externa...
373,295
<p>Has anyone came across where they have to deal with .truststore file? and knowing how to import .cer into .truststore file? </p> <p>I am not sure if I have to use Java Keytool or Linux command (such as openssl command).</p> <p>Thanks</p>
[ { "answer_id": 373307, "author": "Strelok", "author_id": 2788, "author_profile": "https://Stackoverflow.com/users/2788", "pm_score": 9, "selected": true, "text": "<pre><code># Copy the certificate into the directory Java_home\\Jre\\Lib\\Security\n# Change your directory to Java_home\\Jre...
2008/12/17
[ "https://Stackoverflow.com/questions/373295", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44534/" ]
Has anyone came across where they have to deal with .truststore file? and knowing how to import .cer into .truststore file? I am not sure if I have to use Java Keytool or Linux command (such as openssl command). Thanks
``` # Copy the certificate into the directory Java_home\Jre\Lib\Security # Change your directory to Java_home\Jre\Lib\Security> # Import the certificate to a trust store. keytool -import -alias ca -file somecert.cer -keystore cacerts -storepass changeit [Return] Trust this certificate: [Yes] ``` changeit is the def...
373,297
<p>I have Windows Server 2008 installed on a Sony laptop and the brightness control doesn't work. I'd like to write a program to allow me to change it.</p> <p>Currently what I have to do is open the Power control panel, click advanced settings, and fight through so many UAC boxes that anybody watching me must think I'...
[ { "answer_id": 373306, "author": "DaEagle", "author_id": 43024, "author_profile": "https://Stackoverflow.com/users/43024", "pm_score": 2, "selected": false, "text": "<p>This is vista only:</p>\n\n<p><a href=\"http://msdn.microsoft.com/en-us/library/ms775232.aspx\" rel=\"nofollow noreferr...
2008/12/17
[ "https://Stackoverflow.com/questions/373297", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16940/" ]
I have Windows Server 2008 installed on a Sony laptop and the brightness control doesn't work. I'd like to write a program to allow me to change it. Currently what I have to do is open the Power control panel, click advanced settings, and fight through so many UAC boxes that anybody watching me must think I'm complete...
I looked up [John Rudy](https://stackoverflow.com/questions/373297/what-api-call-would-i-use-to-change-brightness-of-laptop-net/373308#373308)'s link to [WmiSetBrightness](http://msdn.microsoft.com/en-us/library/aa394549.aspx) in MSDN and came up with this: ``` ManagementClass mclass = new ManagementClass("WmiMonitorB...
373,305
<p>I am trying to develop a slideshow with a pause between slides. So I'm trying to use the setTimeout statement as shown below. This is written to swap 2.jpg for 1.jpg with a pause of 10 seconds on clicking the button. But it does now work. Can anyone help me. Thanks.</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;scri...
[ { "answer_id": 373320, "author": "OJ.", "author_id": 611, "author_profile": "https://Stackoverflow.com/users/611", "pm_score": 2, "selected": false, "text": "<p>Your swap function requires a parameter, so it won't work with setTimeout.</p>\n" }, { "answer_id": 373340, "author...
2008/12/17
[ "https://Stackoverflow.com/questions/373305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39973/" ]
I am trying to develop a slideshow with a pause between slides. So I'm trying to use the setTimeout statement as shown below. This is written to swap 2.jpg for 1.jpg with a pause of 10 seconds on clicking the button. But it does now work. Can anyone help me. Thanks. ``` <html> <head> <script type="text/javascript"> va...
There are a couple of things wrong here. First, its passing code to be eval'ed in the first parameter of [setTimeout](https://developer.mozilla.org/en/DOM/window.setTimeout) is not recommended. Better pass a callback instead: ``` setTimeout(function() { swap(); },10000); //Or setTimeout(swap,10000); //Passing the a...
373,312
<p>A lot of developers say only throw exceptions in truly exceptional circumstances. One of these would be if an external hard drive I want to write to is not switched on (therefore not a connected/registered drive). However, there are some situations which are difficult to work out whether they are truly exceptional o...
[ { "answer_id": 373326, "author": "xtophyr", "author_id": 41764, "author_profile": "https://Stackoverflow.com/users/41764", "pm_score": 2, "selected": true, "text": "<p>Generally, it works like this:</p>\n\n<p>If you can handle the situation without any interruptions, do so. (File doesn'...
2008/12/17
[ "https://Stackoverflow.com/questions/373312", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32484/" ]
A lot of developers say only throw exceptions in truly exceptional circumstances. One of these would be if an external hard drive I want to write to is not switched on (therefore not a connected/registered drive). However, there are some situations which are difficult to work out whether they are truly exceptional or n...
Generally, it works like this: If you can handle the situation without any interruptions, do so. (File doesn't exist, but its input isn't essential to continuing operation [preferences, optional configuration, etc]) If you need user intervention, ask them. (File doesn't exist, but you need it to continue operating) ...
373,324
<p>I seem to recall that there is an HTML tag that escapes absolutely everything inside it except the matching closing tag. Kind of like <a href="http://www.htmlref.com/reference/AppA/tag_plaintext.htm" rel="noreferrer"><code>&lt;plaintext&gt;</code></a> but not fundamentally broken.</p>
[ { "answer_id": 373337, "author": "EndangeredMassa", "author_id": 106, "author_profile": "https://Stackoverflow.com/users/106", "pm_score": 5, "selected": true, "text": "<p>&lt;xmp&gt; is the tag you are looking for:</p>\n\n<pre><code>&lt;xmp&gt;some stuff &lt;tags&gt;&lt;/tags&gt; too&lt...
2008/12/17
[ "https://Stackoverflow.com/questions/373324", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1343/" ]
I seem to recall that there is an HTML tag that escapes absolutely everything inside it except the matching closing tag. Kind of like [`<plaintext>`](http://www.htmlref.com/reference/AppA/tag_plaintext.htm) but not fundamentally broken.
<xmp> is the tag you are looking for: ``` <xmp>some stuff <tags></tags> too</xmp> ``` But, since it's depricated, the best you can get is <pre>.
373,335
<p>I'm looking for a library in Python which will provide <code>at</code> and <code>cron</code> like functionality.</p> <p>I'd quite like have a pure Python solution, rather than relying on tools installed on the box; this way I run on machines with no cron.</p> <p>For those unfamiliar with <code>cron</code>: you can...
[ { "answer_id": 373348, "author": "Davide", "author_id": 25891, "author_profile": "https://Stackoverflow.com/users/25891", "pm_score": 1, "selected": false, "text": "<p>I don't know if something like that already exists. It would be easy to write your own with time, datetime and/or calend...
2008/12/17
[ "https://Stackoverflow.com/questions/373335", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4737/" ]
I'm looking for a library in Python which will provide `at` and `cron` like functionality. I'd quite like have a pure Python solution, rather than relying on tools installed on the box; this way I run on machines with no cron. For those unfamiliar with `cron`: you can schedule tasks based upon an expression like: `...
If you're looking for something lightweight checkout [schedule](https://github.com/dbader/schedule): ``` import schedule import time def job(): print("I'm working...") schedule.every(10).minutes.do(job) schedule.every().hour.do(job) schedule.every().day.at("10:30").do(job) while 1: schedule.run_pending() ...
373,342
<p>I have a line of Fortran code, which includes some text. I'm changing the text, which makes the code line too long for Fortran, so I split it over two lines using 'a'. </p> <p>Was:</p> <pre><code> IF (MYVAR .EQ. 1) THEN WRITE(iott,'(A) (A)') 'ABC=', SOMEVAR </code></pre> <p>Changed to:</p> <pre><code> IF (...
[ { "answer_id": 373405, "author": "Michael Burr", "author_id": 12711, "author_profile": "https://Stackoverflow.com/users/12711", "pm_score": 0, "selected": false, "text": "<p>It's been too long for me to remember the old column requirements of FORTRAN (and they may not even be as strict a...
2008/12/17
[ "https://Stackoverflow.com/questions/373342", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a line of Fortran code, which includes some text. I'm changing the text, which makes the code line too long for Fortran, so I split it over two lines using 'a'. Was: ``` IF (MYVAR .EQ. 1) THEN WRITE(iott,'(A) (A)') 'ABC=', SOMEVAR ``` Changed to: ``` IF (MYVAR .EQ. 1) THEN WRITE(iott,'(A) (A)')...
If you're worried about exceeding a 72 column limit, then I assume you're using Fortran 77. The syntax for Fortran 77 requires that you start with column 7, except for continued lines, which need a continuation character in column 6. I use the following method to tell me how many lines are continued for one statement (...
373,350
<p>I'm looking to generate a simple standalone Java client which will make calls to a SOAP web service, given a wsdl. When I say simple and standalone I mean that once I'm done I want to be able to do something like</p> <pre><code>import my.generated.nonsense; public static void main(String[] args) { Client clie...
[ { "answer_id": 373432, "author": "neesh", "author_id": 43864, "author_profile": "https://Stackoverflow.com/users/43864", "pm_score": 3, "selected": false, "text": "<p>I would recommend <a href=\"http://www.soapui.org/\" rel=\"nofollow noreferrer\">SOAP UI</a> for what you need to do. You...
2008/12/17
[ "https://Stackoverflow.com/questions/373350", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm looking to generate a simple standalone Java client which will make calls to a SOAP web service, given a wsdl. When I say simple and standalone I mean that once I'm done I want to be able to do something like ``` import my.generated.nonsense; public static void main(String[] args) { Client client = new Client...
I would recommend [SOAP UI](http://www.soapui.org/) for what you need to do. You do not need to write any code - you can call the web service from the soap UI client. If you need to automate making soap calls you can use the maven plugin as part of your build/deploy process. More info about the maven plugin here: <ht...
373,362
<p>I know there are several ways to deploy a .net windows client application:</p> <p>There's <a href="http://msdn.microsoft.com/en-us/library/aa367449(VS.85).aspx" rel="nofollow noreferrer">Windows Installer</a>, <a href="http://msdn.microsoft.com/en-us/library/t71a733d(VS.80).aspx" rel="nofollow noreferrer">Click Onc...
[ { "answer_id": 373399, "author": "JB King", "author_id": 8745, "author_profile": "https://Stackoverflow.com/users/8745", "pm_score": 3, "selected": true, "text": "<p>I could see doing what you suggest within a corporate intranet environment, where the custom application can talk to a cus...
2008/12/17
[ "https://Stackoverflow.com/questions/373362", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18552/" ]
I know there are several ways to deploy a .net windows client application: There's [Windows Installer](http://msdn.microsoft.com/en-us/library/aa367449(VS.85).aspx), [Click Once](http://msdn.microsoft.com/en-us/library/t71a733d(VS.80).aspx), a simple download & run, and loading the windows forms / WCF application in I...
I could see doing what you suggest within a corporate intranet environment, where the custom application can talk to a custom server and each understands the other well. Granted there would be possible connectivity and synchronization issues, but those could get worked on over time to some extent. I have done this in o...
373,365
<p>I want to write out a text file.</p> <p>Instead of the default UTF-8, I want to write it encoded as ISO-8859-1 which is code page 28591. I have no idea how to do this...</p> <p>I'm writing out my file with the following very simple code:</p> <pre><code>using (StreamWriter sw = File.CreateText(myfilename)) { s...
[ { "answer_id": 373368, "author": "Steven Behnke", "author_id": 42588, "author_profile": "https://Stackoverflow.com/users/42588", "pm_score": -1, "selected": false, "text": "<p>Change the Encoding of the stream writer. It's a property.</p>\n\n<p><a href=\"http://msdn.microsoft.com/en-us/...
2008/12/17
[ "https://Stackoverflow.com/questions/373365", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44004/" ]
I want to write out a text file. Instead of the default UTF-8, I want to write it encoded as ISO-8859-1 which is code page 28591. I have no idea how to do this... I'm writing out my file with the following very simple code: ``` using (StreamWriter sw = File.CreateText(myfilename)) { sw.WriteLine("my text..."); ...
``` using System.IO; using System.Text; using (StreamWriter sw = new StreamWriter(File.Open(myfilename, FileMode.Create), Encoding.WhateverYouWant)) { sw.WriteLine("my text..."); } ``` An alternate way of getting your encoding: ``` using System.IO; using System.Text; using (var sw = new StreamWriter(...
373,366
<p>I'm having an issue setting up one of my projects in TeamCity (v4.0), specifically when it comes to using Object Initializers.</p> <p>The project builds fine normally, however it would seem that TeamCity transforms the build file into something it likes (some MSBuild mutation) and when it comes to compiling the cod...
[ { "answer_id": 373422, "author": "Mike Two", "author_id": 23659, "author_profile": "https://Stackoverflow.com/users/23659", "pm_score": 3, "selected": true, "text": "<p>Are you using the sln2005 build runner? That will use the 2.0 csc. Check your build configuration and change it to the ...
2008/12/17
[ "https://Stackoverflow.com/questions/373366", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18434/" ]
I'm having an issue setting up one of my projects in TeamCity (v4.0), specifically when it comes to using Object Initializers. The project builds fine normally, however it would seem that TeamCity transforms the build file into something it likes (some MSBuild mutation) and when it comes to compiling the code for a pa...
Are you using the sln2005 build runner? That will use the 2.0 csc. Check your build configuration and change it to the sln2008 runner ( see <http://www.jetbrains.net/confluence/display/TCD4/3.Build+Runners> ). That should use the 3.5 compiler. If you are using the MSBuild runner <http://www.jetbrains.net/confluence/di...
373,370
<p>The best I can come up with for now is this monstrosity:</p> <pre><code>&gt;&gt;&gt; datetime.utcnow() \ ... .replace(tzinfo=pytz.UTC) \ ... .astimezone(pytz.timezone("Australia/Melbourne")) \ ... .replace(hour=0,minute=0,second=0,microsecond=0) \ ... .astimezone(pytz.UTC) \ ... .replace(tzinfo=None) date...
[ { "answer_id": 373379, "author": "Ignacio Vazquez-Abrams", "author_id": 20862, "author_profile": "https://Stackoverflow.com/users/20862", "pm_score": 0, "selected": false, "text": "<p>Setting the TZ environment variable modifies what timezone Python's date and time functions work with.</...
2008/12/17
[ "https://Stackoverflow.com/questions/373370", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3715/" ]
The best I can come up with for now is this monstrosity: ``` >>> datetime.utcnow() \ ... .replace(tzinfo=pytz.UTC) \ ... .astimezone(pytz.timezone("Australia/Melbourne")) \ ... .replace(hour=0,minute=0,second=0,microsecond=0) \ ... .astimezone(pytz.UTC) \ ... .replace(tzinfo=None) datetime.datetime(2008, 12,...
I think you can shave off a few method calls if you do it like this: ``` >>> from datetime import datetime >>> datetime.now(pytz.timezone("Australia/Melbourne")) \ .replace(hour=0, minute=0, second=0, microsecond=0) \ .astimezone(pytz.utc) ``` BUT… there is a bigger problem than aesthetics in...
373,388
<p>I'll soon be working on a large c# project and would like to build in multi-language support from the start. I've had a play around and can get it working using a separate resource file for each language, then use a resource manager to load up the strings.</p> <p>Are there any other good approaches that I could loo...
[ { "answer_id": 373412, "author": "BenAlabaster", "author_id": 40650, "author_profile": "https://Stackoverflow.com/users/40650", "pm_score": 5, "selected": false, "text": "<p>I've seen projects implemented using a number of different approaches, each have their merits and drawbacks.</p>\n...
2008/12/17
[ "https://Stackoverflow.com/questions/373388", "https://Stackoverflow.com", "https://Stackoverflow.com/users/74652/" ]
I'll soon be working on a large c# project and would like to build in multi-language support from the start. I've had a play around and can get it working using a separate resource file for each language, then use a resource manager to load up the strings. Are there any other good approaches that I could look into?
Use a separate project with Resources ===================================== I can tell this from out experience, having a current solution with 12 **24** projects that includes API, MVC, Project Libraries (Core functionalities), WPF, UWP and Xamarin. It is worth reading this long post as I think it is the best way to ...
373,395
<p>I am a Java programmer and need to work on a Flex/ActionScript project right now. I got an example of using ITreeDataDesriptor from Flex 3 Cookbook, but there is one line of actionscript code that's hard for me to understand. I appreciate if someone could explain this a little further. </p> <pre><code>public functi...
[ { "answer_id": 373423, "author": "Luke", "author_id": 21406, "author_profile": "https://Stackoverflow.com/users/21406", "pm_score": 1, "selected": false, "text": "<p>I think in Java you would call that a map or an associative array. In Javascript and Actionscript you can say this to crea...
2008/12/17
[ "https://Stackoverflow.com/questions/373395", "https://Stackoverflow.com", "https://Stackoverflow.com/users/455772/" ]
I am a Java programmer and need to work on a Flex/ActionScript project right now. I got an example of using ITreeDataDesriptor from Flex 3 Cookbook, but there is one line of actionscript code that's hard for me to understand. I appreciate if someone could explain this a little further. ``` public function getData(nod...
The following return expression (modified from the question) ... ``` return {children:{label:node.name, body:node.address}} ``` ... is functionally equivalent to this code ... ``` var obj:Object = new Object(); obj.children = new Object(); obj.children.label = node.name; obj.children.body = node.address; return obj...
373,449
<p>I have a Delphi 2009 program that handles a lot of data and needs to be as fast as possible and not use too much memory.</p> <p>What <strong>small simple</strong> changes have you made to your Delphi code that had the biggest impact on the performance of your program by noticeably reducing execution time or memory ...
[ { "answer_id": 373463, "author": "Argalatyr", "author_id": 18484, "author_profile": "https://Stackoverflow.com/users/18484", "pm_score": 2, "selected": false, "text": "<p>Separating the program logic from user interface, refactoring, then optimizing the most-used, most resource-intensive...
2008/12/17
[ "https://Stackoverflow.com/questions/373449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30176/" ]
I have a Delphi 2009 program that handles a lot of data and needs to be as fast as possible and not use too much memory. What **small simple** changes have you made to your Delphi code that had the biggest impact on the performance of your program by noticeably reducing execution time or memory use? --- Thanks every...
The biggest improvement came when I started using AsyncCalls to convert single-threaded applications that used to freeze up the UI, into (sort of) multi-threaded apps. Although AsyncCalls can do a lot more, I've found it useful for this very simple purpose. Let's say you have a subroutine blocked like this: Disable Bu...
373,454
<p>The code</p> <pre><code>&lt;%=Html.CheckBox("SendEmail") %&gt; </code></pre> <p>evaluates to two HTML elements when it's rendered</p> <pre><code>&lt;input id="SendEmail" name="SendEmail" type="checkbox" value="true" /&gt; &lt;input name="SendEmail" type="hidden" value="false" /&gt; </code></pre> <p>Is this by ...
[ { "answer_id": 373473, "author": "Graviton", "author_id": 3834, "author_profile": "https://Stackoverflow.com/users/3834", "pm_score": 2, "selected": true, "text": "<p>I think I found <a href=\"http://forums.asp.net/p/1314753/2603373.aspx\" rel=\"nofollow noreferrer\">something on the web...
2008/12/17
[ "https://Stackoverflow.com/questions/373454", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3834/" ]
The code ``` <%=Html.CheckBox("SendEmail") %> ``` evaluates to two HTML elements when it's rendered ``` <input id="SendEmail" name="SendEmail" type="checkbox" value="true" /> <input name="SendEmail" type="hidden" value="false" /> ``` Is this by a bug? Or by design? If it's by design, why?
I think I found [something on the web](http://forums.asp.net/p/1314753/2603373.aspx) that is directly related to my question.
373,459
<p>I'd like to split a string using one or more separator characters.</p> <p>E.g. "a b.c", split on " " and "." would give the list ["a", "b", "c"].</p> <p>At the moment, I can't see anything in the standard library to do this, and my own attempts are a bit clumsy. E.g.</p> <pre><code>def my_split(string, split_char...
[ { "answer_id": 373474, "author": "Ignacio Vazquez-Abrams", "author_id": 20862, "author_profile": "https://Stackoverflow.com/users/20862", "pm_score": 6, "selected": true, "text": "<pre><code>&gt;&gt;&gt; import re\n&gt;&gt;&gt; re.split('[ .]', 'a b.c')\n['a', 'b', 'c']\n</code></pre>\n"...
2008/12/17
[ "https://Stackoverflow.com/questions/373459", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29903/" ]
I'd like to split a string using one or more separator characters. E.g. "a b.c", split on " " and "." would give the list ["a", "b", "c"]. At the moment, I can't see anything in the standard library to do this, and my own attempts are a bit clumsy. E.g. ``` def my_split(string, split_chars): if isinstance(string...
``` >>> import re >>> re.split('[ .]', 'a b.c') ['a', 'b', 'c'] ```
373,462
<p>I'm trying to do a simple erase and keep getting errors.</p> <p>Here is the snippet of code for my erase:</p> <pre><code>std::list&lt;Mine*&gt;::iterator iterMines = mines.begin(); for(int i = oldSizeOfMines; i &gt;0 ; i--, iterMines++) { if(player-&gt;distanceFrom(*iterMines) &lt; radiusOfOnScreen) { ...
[ { "answer_id": 373502, "author": "grepsedawk", "author_id": 14388, "author_profile": "https://Stackoverflow.com/users/14388", "pm_score": 3, "selected": true, "text": "<p>The problem is you are trying to use the iterator of mines as an iterator in the onScreen list. This will not work. <...
2008/12/17
[ "https://Stackoverflow.com/questions/373462", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39189/" ]
I'm trying to do a simple erase and keep getting errors. Here is the snippet of code for my erase: ``` std::list<Mine*>::iterator iterMines = mines.begin(); for(int i = oldSizeOfMines; i >0 ; i--, iterMines++) { if(player->distanceFrom(*iterMines) < radiusOfOnScreen) { onScreen.push_back(*iterMines); ...
The problem is you are trying to use the iterator of mines as an iterator in the onScreen list. This will not work. Did you mean to call mines.erase(iterMines) instead of onScreen.erase(iterMines)?
373,490
<p>We are building a query to count the number of events per hour, per day. Most days there are hours that do not have any activity and therefore where the query is run the count of activities per hour show up but there are gaps and the query excludes these. We still want to show the hours that do not have activity and...
[ { "answer_id": 373509, "author": "Dave Markle", "author_id": 24995, "author_profile": "https://Stackoverflow.com/users/24995", "pm_score": 2, "selected": false, "text": "<p>You are going to somehow need a table of days and hours, and then you will have to do an outer join between that ta...
2008/12/17
[ "https://Stackoverflow.com/questions/373490", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
We are building a query to count the number of events per hour, per day. Most days there are hours that do not have any activity and therefore where the query is run the count of activities per hour show up but there are gaps and the query excludes these. We still want to show the hours that do not have activity and di...
You are going to somehow need a table of days and hours, and then you will have to do an outer join between that table and your query. Here's how I would do it. Note that this solution will only work in SQL Server 2005 and 2008. If you don't have those platforms, you'll have to actually create a table of times in your ...
373,518
<p>Using the Java URL class, I can connect to an external <code>HTTPS</code> server (such as our production site), but using a local URL I get following exception. </p> <pre><code>"SunCertPathBuilderException: unable to find valid certification path to requested target". </code></pre> <p>How do I get a valid certifi...
[ { "answer_id": 373526, "author": "Charlie Martin", "author_id": 35092, "author_profile": "https://Stackoverflow.com/users/35092", "pm_score": 0, "selected": false, "text": "<p>The problem it's complaining about is that when you create an SSL connection, the server must present a valid ce...
2008/12/17
[ "https://Stackoverflow.com/questions/373518", "https://Stackoverflow.com", "https://Stackoverflow.com/users/943/" ]
Using the Java URL class, I can connect to an external `HTTPS` server (such as our production site), but using a local URL I get following exception. ``` "SunCertPathBuilderException: unable to find valid certification path to requested target". ``` How do I get a valid certification path? EDIT: I'm not using this...
Here was my solution that incorporates some of the ideas in this thread and peiced together with code from around the net. All I do call this function and it sets the default Trust Manager and HostName Verifier for HttpsURLConnection. This might be undesirable for some because it will effect all HttpsURLConnections but...
373,520
<p>I have a program in Perl I'm working on where I would need multiple keys, and a way of giving each key multiple values and follow that by being able to both read them in and write them out to an external file depending on if the key matches what the person enters into standard input. I've looked across several sites...
[ { "answer_id": 373539, "author": "David Norman", "author_id": 34502, "author_profile": "https://Stackoverflow.com/users/34502", "pm_score": 2, "selected": false, "text": "<p>Check out the module <a href=\"http://search.cpan.org/dist/XML-Simple/lib/XML/Simple.pm\" rel=\"nofollow noreferre...
2008/12/17
[ "https://Stackoverflow.com/questions/373520", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a program in Perl I'm working on where I would need multiple keys, and a way of giving each key multiple values and follow that by being able to both read them in and write them out to an external file depending on if the key matches what the person enters into standard input. I've looked across several sites an...
Check out [Data::Dumper](http://search.cpan.org/~ilyam/Data-Dumper-2.121/). For instance, this microscopic script: ``` #!/bin/perl -w use strict; use Data::Dumper; my(%hash); $hash{key1} = [ 1, "b", "c" ]; $hash{key2} = [ 4.56, "g", "2008-12-16 19:10 -08:00" ]; print Dumper(\%hash); ``` produces this output, whi...
373,541
<p>I need to do a LINQ2DataSet query that does a join on more than one field (as</p> <pre><code>var result = from x in entity join y in entity2 on x.field1 = y.field1 and x.field2 = y.field2 </code></pre> <p>I have yet found a suitable solution (I can add the extra constraints to a where clause, b...
[ { "answer_id": 373550, "author": "KristoferA", "author_id": 11241, "author_profile": "https://Stackoverflow.com/users/11241", "pm_score": 7, "selected": false, "text": "<pre><code>var result = from x in entity\n join y in entity2 on new { x.field1, x.field2 } equals new { y.field1, y.f...
2008/12/17
[ "https://Stackoverflow.com/questions/373541", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5302/" ]
I need to do a LINQ2DataSet query that does a join on more than one field (as ``` var result = from x in entity join y in entity2 on x.field1 = y.field1 and x.field2 = y.field2 ``` I have yet found a suitable solution (I can add the extra constraints to a where clause, but this is far from a suit...
The solution with the anonymous type should work fine. LINQ *can* only represent equijoins (with join clauses, anyway), and indeed that's what you've said you want to express anyway based on your original query. If you don't like the version with the anonymous type for some specific reason, you should explain that rea...
373,589
<p>I'm playing with the new geography column in SQL Server 2008 and the STGeomFromText function. Here is my code (works with AdventureWorks2008)</p> <pre><code>DECLARE @region geography; set @region = geography::STGeomFromText('POLYGON(( -80.0 50.0, -90.0 50.0, -90.0 25.0, -80.0 25.0, -80.0 50...
[ { "answer_id": 374475, "author": "Mladen Prajdic", "author_id": 31345, "author_profile": "https://Stackoverflow.com/users/31345", "pm_score": 4, "selected": false, "text": "<p><a href=\"http://en.wikipedia.org/wiki/SRID\" rel=\"noreferrer\">SRID = Spatial Reference IDentifier</a></p>\n\n...
2008/12/17
[ "https://Stackoverflow.com/questions/373589", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9443/" ]
I'm playing with the new geography column in SQL Server 2008 and the STGeomFromText function. Here is my code (works with AdventureWorks2008) ``` DECLARE @region geography; set @region = geography::STGeomFromText('POLYGON(( -80.0 50.0, -90.0 50.0, -90.0 25.0, -80.0 25.0, -80.0 50.0))', 4326); ...
So I ended up talking with an ex-military guy yesterday who was a radar/mapping specialist. Basically, he knew exactly what that number (4326) was, where it came from, and why it is there. It is an industry standard for computing geography. The problem is that the earth is not a perfect sphere (it bulges in the middl...
373,599
<p>I am using a route like this one:</p> <pre><code>routes.MapRoute("Invoice-New-NewCustomer", "Invoice/New/Customer/New/{*name}", new { controller = "Customer", action = "NewInvoice" }, new { name = @"[^\.]*" }); </code></pre> <p>There is an action which handles this route:</p> <pre><code>public ActionR...
[ { "answer_id": 373640, "author": "EndangeredMassa", "author_id": 106, "author_profile": "https://Stackoverflow.com/users/106", "pm_score": 2, "selected": false, "text": "<p>URL Encoding! Change the link so that it encodes special characters.</p>\n\n<pre><code>Server.URLencode(strURL)\n</...
2008/12/17
[ "https://Stackoverflow.com/questions/373599", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1195872/" ]
I am using a route like this one: ``` routes.MapRoute("Invoice-New-NewCustomer", "Invoice/New/Customer/New/{*name}", new { controller = "Customer", action = "NewInvoice" }, new { name = @"[^\.]*" }); ``` There is an action which handles this route: ``` public ActionResult NewInvoice(string name) { A...
Ok, I confirmed that this is *now* a known issue in ASP.NET Routing, unfortunately. The problem is that deep in the bowels of routing, we use Uri.EscapeString when escaping routing parameters for the Uri. However, that method does not escape the "#" character. Note that the # character (aka Octothorpe) is technically ...
373,605
<p>How do I load a dropdown list in asp.net and c#?</p>
[ { "answer_id": 373608, "author": "keithwarren7", "author_id": 40714, "author_profile": "https://Stackoverflow.com/users/40714", "pm_score": 1, "selected": false, "text": "<p>wow...rather quick to the point there...</p>\n\n<p><code>DropDownLists</code> have an items collection, you call t...
2008/12/17
[ "https://Stackoverflow.com/questions/373605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How do I load a dropdown list in asp.net and c#?
You can also do it declaratively: ``` <asp:DropDownList runat="server" ID="yourDDL"> <asp:ListItem Text="Add something" Value="theValue" /> </asp:DropDownList> ``` You can also data bind them: ``` yourDDL.DataSource = YourIEnumberableObject; yourDDL.DataBind(); ``` Edit: As mentioned in the comments, you can ...
373,623
<p>This database will store a list of children. But the problem is, they will have their weight measured once a day. How can I store the changes so I can easily query their actual weight and the weight variation over one day, one week and one month?</p>
[ { "answer_id": 373633, "author": "warren", "author_id": 4418, "author_profile": "https://Stackoverflow.com/users/4418", "pm_score": 4, "selected": true, "text": "<p>I'd think something like the following:</p>\n\n<pre><code>table kid\n int pkey(id)\n text name\n\ntable weight\n d...
2008/12/17
[ "https://Stackoverflow.com/questions/373623", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46921/" ]
This database will store a list of children. But the problem is, they will have their weight measured once a day. How can I store the changes so I can easily query their actual weight and the weight variation over one day, one week and one month?
I'd think something like the following: ``` table kid int pkey(id) text name table weight date when int kidid fkey(kid.id) int weight int pkey(id) ```
373,639
<p>I'm trying to run an interactive command through paramiko. The cmd execution tries to prompt for a password but I do not know how to supply the password through paramiko's exec_command and the execution hangs. Is there a way to send values to the terminal if a cmd execution expects input interactively?</p> <pre><...
[ { "answer_id": 373742, "author": "monkut", "author_id": 24718, "author_profile": "https://Stackoverflow.com/users/24718", "pm_score": 2, "selected": false, "text": "<p>I'm not familiar with paramiko, but this may work: </p>\n\n<pre><code>ssh_stdin.write('input value')\nssh_stdin.flush()\...
2008/12/17
[ "https://Stackoverflow.com/questions/373639", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46920/" ]
I'm trying to run an interactive command through paramiko. The cmd execution tries to prompt for a password but I do not know how to supply the password through paramiko's exec\_command and the execution hangs. Is there a way to send values to the terminal if a cmd execution expects input interactively? ``` ssh = para...
The full paramiko distribution ships with a lot of good [demos](https://github.com/paramiko/paramiko/tree/master/demos). In the demos subdirectory, `demo.py` and `interactive.py` have full interactive TTY examples which would probably be overkill for your situation. In your example above `ssh_stdin` acts like a stand...
373,643
<p>I'm trying to center a page and then make it <code>100%</code> in height. I have a div called "content" as the parent element of all elements in the HTML page. What do I need to do next? I'd like to stay away from any CSS-hacks. This is currently working in IE7, but not in Firefox 3.</p> <p><strong>EDIT:</strong> I...
[ { "answer_id": 373652, "author": "AJ.", "author_id": 46890, "author_profile": "https://Stackoverflow.com/users/46890", "pm_score": -1, "selected": false, "text": "<p>For centering the page, I typically just put the content div in the center tag, because margin-left/right:auto really does...
2008/12/17
[ "https://Stackoverflow.com/questions/373643", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36590/" ]
I'm trying to center a page and then make it `100%` in height. I have a div called "content" as the parent element of all elements in the HTML page. What do I need to do next? I'd like to stay away from any CSS-hacks. This is currently working in IE7, but not in Firefox 3. **EDIT:** I added height: `100%`; to `#conten...
To center content, put it inside of an element that has a fixed width (important!) and has `margin: auto;` There is no cross-browser was to make your div have 100% height unless you use javascript. If you are desperate for this functionality and are willing to use javascript, you can dynamically set the height of your...
373,656
<p>If I have a clone of a git repository as a cached copy on a remote server for capistrano/vlad style deployment, is it better to do A) </p> <pre><code>git archive --format=tar origin/master | (cd #{destination} &amp;&amp; tar xf -) </code></pre> <p>or B)</p> <pre><code>cp -R cached-copy #{destination} &amp;&amp; r...
[ { "answer_id": 373694, "author": "Otto", "author_id": 9594, "author_profile": "https://Stackoverflow.com/users/9594", "pm_score": 2, "selected": false, "text": "<p><strong>A)</strong></p>\n\n<p>You save the network overhead of transferring the .git directory which could possibly be quite...
2008/12/17
[ "https://Stackoverflow.com/questions/373656", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5830/" ]
If I have a clone of a git repository as a cached copy on a remote server for capistrano/vlad style deployment, is it better to do A) ``` git archive --format=tar origin/master | (cd #{destination} && tar xf -) ``` or B) ``` cp -R cached-copy #{destination} && rm -Rf #{destination}/.git ``` To clarify, the repos...
I'd say actually ``` rsync -avP /local/repo/* server:/remote/repo ``` This works as long as it's OK to **skip all the dot files** in the repo, not only `.git`. If you want to skip *only* `.git` then you'll need the `-f` option and the man page. I love [rsync](http://samba.anu.edu.au/rsync/). Works great and most ti...
373,671
<p>So I have some XML in the following format:</p> <pre><code>&lt;somenode&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;title/&gt; &lt;/head&gt; &lt;body&gt; &lt;p&gt;P one&lt;/p&gt; &lt;p&gt;Another p&lt;/p&gt; &lt;/body...
[ { "answer_id": 373669, "author": "ewakened", "author_id": 38354, "author_profile": "https://Stackoverflow.com/users/38354", "pm_score": 2, "selected": false, "text": "<p>Yes, but only for your fonts and JavaScripts.</p>\n\n<p>I have noticed some of the default fonts are smaller on Safari...
2008/12/17
[ "https://Stackoverflow.com/questions/373671", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46927/" ]
So I have some XML in the following format: ``` <somenode> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title/> </head> <body> <p>P one</p> <p>Another p</p> </body> </html> </somenode> ``` Nestled in there is some html, which I didn't...
I've noticed Safari handles Asian characters better than Chrome. Also Chrome and Safari rely on the same Webkit for rendering pages, but their Javascript engines are totally different, so if you use Javascript in your pages you need to check both.
373,680
<p>Given a grammar and the attached action code, are there any standard solution for deducing what type each production needs to result in (and consequently, what type the invoking production should expect to get from it)?</p> <p>I'm thinking of an OO program and action code that employs something like c#'s <code>var<...
[ { "answer_id": 373723, "author": "Norman Ramsey", "author_id": 41661, "author_profile": "https://Stackoverflow.com/users/41661", "pm_score": 2, "selected": false, "text": "<p>If you are writing code in a functional language it is easy; standard Hindley-Milner type inference works great. ...
2008/12/17
[ "https://Stackoverflow.com/questions/373680", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1343/" ]
Given a grammar and the attached action code, are there any standard solution for deducing what type each production needs to result in (and consequently, what type the invoking production should expect to get from it)? I'm thinking of an OO program and action code that employs something like c#'s `var` syntax (but I'...
If you are writing code in a functional language it is easy; standard Hindley-Milner type inference works great. **Do not do this**. In my EBNF parser generator (never released but source code available on request), which supports Icon, c, and Standard ML, I actually **implemented the idea** you are asking about for th...
373,687
<p>I am creating an application in .NET that will serve as a second UI for my already-deployed Django app. For some operations users need to authenticate themselves (as Django users). I used a super-simple way to do this (without encrypting credentials for simplicity):-</p> <p>Step 1. I created a django view that acce...
[ { "answer_id": 373727, "author": "Strelok", "author_id": 2788, "author_profile": "https://Stackoverflow.com/users/2788", "pm_score": 3, "selected": true, "text": "<p>Looks ok to me. I recommend using Wireshark to see what your restclient is sending in the headers and and see what your ap...
2008/12/17
[ "https://Stackoverflow.com/questions/373687", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46928/" ]
I am creating an application in .NET that will serve as a second UI for my already-deployed Django app. For some operations users need to authenticate themselves (as Django users). I used a super-simple way to do this (without encrypting credentials for simplicity):- Step 1. I created a django view that accepted the u...
Looks ok to me. I recommend using Wireshark to see what your restclient is sending in the headers and and see what your app sending in the headers.
373,725
<p>I'm using Apache.</p> <p>I'm auto gzipping my HTML &amp; CSS files on the fly using the following directive in my .htaccess file.</p> <pre><code># Enable ETag FileETag MTime Size # Set expiration header ExpiresActive on ExpiresDefault "access plus 1 year" ExpiresByType image/gif A2592000 ExpiresByType image/png ...
[ { "answer_id": 373737, "author": "Jim Puls", "author_id": 6010, "author_profile": "https://Stackoverflow.com/users/6010", "pm_score": 2, "selected": false, "text": "<p>Have you declared the text/javascript MIME type in Apache? If your server configuration points to, say, a <code>mime.typ...
2008/12/17
[ "https://Stackoverflow.com/questions/373725", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm using Apache. I'm auto gzipping my HTML & CSS files on the fly using the following directive in my .htaccess file. ``` # Enable ETag FileETag MTime Size # Set expiration header ExpiresActive on ExpiresDefault "access plus 1 year" ExpiresByType image/gif A2592000 ExpiresByType image/png A2592000 ExpiresByType ima...
I figured it out, looks like I need it to be: ``` AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml application/x-javascript text/javascript application/javascript ``` To get javascript to compress/gzip
373,731
<p>An example of what I'm talking about:</p> <pre><code>class Person &lt; ActiveRecord::Base def name=(name) super(name.capitalize) end def name super().downcase # not sure why you'd do this; this is just an example end end </code></pre> <p>This seems to work, but I was just read the section on overr...
[ { "answer_id": 379576, "author": "Aaron Longwell", "author_id": 32137, "author_profile": "https://Stackoverflow.com/users/32137", "pm_score": 8, "selected": false, "text": "<p>Echoing Gareth's comments... your code will not work as written. It should be rewritten this way:</p>\n\n<pre><c...
2008/12/17
[ "https://Stackoverflow.com/questions/373731", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
An example of what I'm talking about: ``` class Person < ActiveRecord::Base def name=(name) super(name.capitalize) end def name super().downcase # not sure why you'd do this; this is just an example end end ``` This seems to work, but I was just read the section on overriding attribute methods in th...
Echoing Gareth's comments... your code will not work as written. It should be rewritten this way: ``` def name=(name) write_attribute(:name, name.capitalize) end def name read_attribute(:name).downcase # No test for nil? end ```
373,761
<p>I'm using php and I have the following code to convert an absolute path to a url.</p> <pre><code>function make_url($path, $secure = false){ return (!$secure ? 'http://' : 'https://').str_replace($_SERVER['DOCUMENT_ROOT'], $_SERVER['HTTP_HOST'], $path); } </code></pre> <p>My question is basically, is there a be...
[ { "answer_id": 373972, "author": "Craig Francis", "author_id": 6632, "author_profile": "https://Stackoverflow.com/users/6632", "pm_score": 2, "selected": false, "text": "<p>I don't think security is going to be effected, simply because this is a url, being printed to a browser... the wor...
2008/12/17
[ "https://Stackoverflow.com/questions/373761", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46264/" ]
I'm using php and I have the following code to convert an absolute path to a url. ``` function make_url($path, $secure = false){ return (!$secure ? 'http://' : 'https://').str_replace($_SERVER['DOCUMENT_ROOT'], $_SERVER['HTTP_HOST'], $path); } ``` My question is basically, is there a better way to do this in ter...
The [HTTP\_HOST variable is not a reliable or secure value](http://shiflett.org/blog/2006/mar/server-name-versus-http-host) as it is also being sent by the client. So be sure to validate its value before using it.
373,762
<p>Simply put:</p> <p>foo.h:</p> <pre><code>#include "bar.h" class foo { private: bar it; void DoIt(); } </code></pre> <p>bar.h:</p> <pre><code>class bar { public: void Test(); } </code></pre> <p>foo.cpp:</p> <pre><code>void foo::DoIt() { it.Test(); } </code></pre> <p>This will result in a:</p> ...
[ { "answer_id": 373764, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>I'm dumb! I did define Test() in the class definition but did not actually have an existing Test() function :( </p>\n\n<p>S...
2008/12/17
[ "https://Stackoverflow.com/questions/373762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Simply put: foo.h: ``` #include "bar.h" class foo { private: bar it; void DoIt(); } ``` bar.h: ``` class bar { public: void Test(); } ``` foo.cpp: ``` void foo::DoIt() { it.Test(); } ``` This will result in a: > > error LNK2001: unresolved external symbol > > > Why?
You have not written the code for `bar::Test()` method.
373,774
<p>How do I use grep to perform a search which, when a match is found, will print the file name as well as the first n characters in that file? Note that <code>n</code> is a parameter that can be specified and it is irrelevant whether the first n characters actually contains the matching string.</p>
[ { "answer_id": 373780, "author": "Diomidis Spinellis", "author_id": 20520, "author_profile": "https://Stackoverflow.com/users/20520", "pm_score": 2, "selected": false, "text": "<p>You need to pipe the output of grep to sed to accomplish what you want. Here is an example:</p>\n\n<pre><co...
2008/12/17
[ "https://Stackoverflow.com/questions/373774", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23120/" ]
How do I use grep to perform a search which, when a match is found, will print the file name as well as the first n characters in that file? Note that `n` is a parameter that can be specified and it is irrelevant whether the first n characters actually contains the matching string.
``` grep -l pattern *.txt | while read line; do echo -n "$line: "; head -c $n "$line"; echo; done ``` Change `-c` to `-n` if you want to see the first `n` lines instead of bytes.
373,776
<p>Windows, Firefox or Google Chrome all monitor usage statistics and analyze the crash reports are sent to them. I am thinking of implementing the same feature into my application. </p> <p>Of course it's easy to litter an application with a lot of logging statement, but this is the approach that I want to avoid becau...
[ { "answer_id": 374057, "author": "ng5000", "author_id": 36860, "author_profile": "https://Stackoverflow.com/users/36860", "pm_score": 1, "selected": false, "text": "<p>In \"Debugging .Net 2.0 Applications\" John Robbins (of Wintellect) writes extensively about how to generate and debug c...
2008/12/17
[ "https://Stackoverflow.com/questions/373776", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3834/" ]
Windows, Firefox or Google Chrome all monitor usage statistics and analyze the crash reports are sent to them. I am thinking of implementing the same feature into my application. Of course it's easy to litter an application with a lot of logging statement, but this is the approach that I want to avoid because I don't...
In "Debugging .Net 2.0 Applications" John Robbins (of Wintellect) writes extensively about how to generate and debug crash reports (acutally windbg/SOS mini dumps). His Superassert class contains code to generate these. Be warned though - there is a lot of effort required to set this up properly: symbol servers, source...
373,778
<p>This seems to be an absurdly simple question but Google and Stack Overflow searches yield nothing. How can I disable horizontal scrolling in a WPF <a href="https://learn.microsoft.com/en-gb/dotnet/api/system.windows.controls.listbox" rel="noreferrer">ListBox</a> when items take up more horizontal space than is avail...
[ { "answer_id": 373781, "author": "Jason Anderson", "author_id": 5142, "author_profile": "https://Stackoverflow.com/users/5142", "pm_score": 9, "selected": true, "text": "<p>In XAML:</p>\n\n<pre><code>&lt;ListBox ScrollViewer.HorizontalScrollBarVisibility=\"Disabled\" /&gt;\n</code></pre>...
2008/12/17
[ "https://Stackoverflow.com/questions/373778", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13877/" ]
This seems to be an absurdly simple question but Google and Stack Overflow searches yield nothing. How can I disable horizontal scrolling in a WPF [ListBox](https://learn.microsoft.com/en-gb/dotnet/api/system.windows.controls.listbox) when items take up more horizontal space than is available in the box?
In XAML: ``` <ListBox ScrollViewer.HorizontalScrollBarVisibility="Disabled" /> ``` In C#: ``` myListBox.SetValue( ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Disabled); ```
373,791
<p>What is the proper way to implement the status bar and navigation bar that go on top of an UIView?</p> <p><a href="http://img.skitch.com/20081217-t78sdixk37hqgdh1ia2fgec4st.png" rel="nofollow noreferrer">alt text http://img.skitch.com/20081217-t78sdixk37hqgdh1ia2fgec4st.png</a></p>
[ { "answer_id": 374981, "author": "August", "author_id": 30966, "author_profile": "https://Stackoverflow.com/users/30966", "pm_score": 5, "selected": false, "text": "<p>In the screenshot above, there's a translucent status bar and a translucent navigation bar.</p>\n\n<p>The status bar is ...
2008/12/17
[ "https://Stackoverflow.com/questions/373791", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30883/" ]
What is the proper way to implement the status bar and navigation bar that go on top of an UIView? [alt text http://img.skitch.com/20081217-t78sdixk37hqgdh1ia2fgec4st.png](http://img.skitch.com/20081217-t78sdixk37hqgdh1ia2fgec4st.png)
Just set “wants fullscreen layout” in your view controller. That solves the problem for me. ``` self.wantsFullScreenLayout = YES; ```
373,810
<p>I'm sure I once found a shell command which could print the common lines from two or more files. What is its name?</p> <p>It was much simpler than <a href="https://linux.die.net/man/1/diff" rel="noreferrer"><code>diff</code></a>.</p>
[ { "answer_id": 373819, "author": "Jonathan Leffler", "author_id": 15168, "author_profile": "https://Stackoverflow.com/users/15168", "pm_score": 9, "selected": true, "text": "<p>The command you are seeking is <a href=\"http://pubs.opengroup.org/onlinepubs/9699919799/utilities/comm.html\" ...
2008/12/17
[ "https://Stackoverflow.com/questions/373810", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28835/" ]
I'm sure I once found a shell command which could print the common lines from two or more files. What is its name? It was much simpler than [`diff`](https://linux.die.net/man/1/diff).
The command you are seeking is [`comm`](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/comm.html). eg:- ``` comm -12 1.sorted.txt 2.sorted.txt ``` Here: **-1** : suppress column 1 (lines unique to 1.sorted.txt) **-2** : suppress column 2 (lines unique to 2.sorted.txt)
373,832
<p>I am fairly new to programming and while doing a lot of reading this concept of a lambda keeps coming up but I'm having a hard time putting my finger on what it actually is and how implementing it will make my programming life so much better. So first, what is a lambda and second how might it be implemented?</p> <...
[ { "answer_id": 373835, "author": "Eugene Yokota", "author_id": 3827, "author_profile": "https://Stackoverflow.com/users/3827", "pm_score": 2, "selected": false, "text": "<p>Lambda is <a href=\"http://en.wikipedia.org/wiki/Lambda_calculus\" rel=\"nofollow noreferrer\">lambda calculus</a>,...
2008/12/17
[ "https://Stackoverflow.com/questions/373832", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4082/" ]
I am fairly new to programming and while doing a lot of reading this concept of a lambda keeps coming up but I'm having a hard time putting my finger on what it actually is and how implementing it will make my programming life so much better. So first, what is a lambda and second how might it be implemented? Thanks to...
Lambda are hard to catch, but once you have pictured them, you cannot understand why you didn't get it before. Lamdba are anonymous functions ------------------------------ Lambda are ordinary functions, **the only difference is that you don't give them a name.** To understand that, you must know first that when you...
373,872
<p><strong>First of all i am doing a Windows application. Not a web application.</strong></p> <p>Now i am doing on application to send SMS (Short message) from System to Mobile.</p> <p>Here, i am using a http URL to push the message having parameters To (number) and Msg (test message).</p> <p>after forming the URL, ...
[ { "answer_id": 373874, "author": "Eugene Yokota", "author_id": 3827, "author_profile": "https://Stackoverflow.com/users/3827", "pm_score": 0, "selected": false, "text": "<p>Here's a code from Microsoft's <a href=\"http://msdn.microsoft.com/en-us/library/system.net.webclient.aspx\" rel=\"...
2008/12/17
[ "https://Stackoverflow.com/questions/373872", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
**First of all i am doing a Windows application. Not a web application.** Now i am doing on application to send SMS (Short message) from System to Mobile. Here, i am using a http URL to push the message having parameters To (number) and Msg (test message). after forming the URL, like <http://333.33.33.33:3333/csms...
Using .NET , see [WebClient Class](http://msdn.microsoft.com/en-us/library/system.net.webclient(VS.80).aspx) - Provides common methods for sending data to and receiving data from a resource identified by a URI. Seen here a few times, e.g. [fastest c# code to download a web page](https://stackoverflow.com/questions/26...
373,881
<p>I always forget to write subject in email, so I want make the subject field compulsory. Can you help me please?</p>
[ { "answer_id": 373921, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 2, "selected": false, "text": "<pre><code>Private Sub Application_ItemSend(ByVal Item As Object, ByRef Cancel As Boolean)\n\n If Item.Subject = \"\" The...
2008/12/17
[ "https://Stackoverflow.com/questions/373881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I always forget to write subject in email, so I want make the subject field compulsory. Can you help me please?
``` Private Sub Application_ItemSend(ByVal Item As Object, ByRef Cancel As Boolean) If Item.Subject = "" Then Item.Subject = InputBox("Please do not always forget the subject!") End If If Item.Subject = "" Then MsgBox "Won't send this without a subject." Cancel = True End If End Sub ```
373,888
<p>When I use (in MS Access 2003 SP3): </p> <pre><code>SELECT * INTO NewTable FROM SomeQuery; </code></pre> <p>MEMO fields are converted to TEXT fields (which are limited to 255 characters), so longer texts are cut.</p> <p>The output of the query itself is fine and not truncated; the text is cut only in the new tabl...
[ { "answer_id": 373896, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 2, "selected": false, "text": "<p>You have here the <a href=\"http://allenbrowne.com/ser-63.html\" rel=\"nofollow noreferrer\">current workarounds</a> for avo...
2008/12/17
[ "https://Stackoverflow.com/questions/373888", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46967/" ]
When I use (in MS Access 2003 SP3): ``` SELECT * INTO NewTable FROM SomeQuery; ``` MEMO fields are converted to TEXT fields (which are limited to 255 characters), so longer texts are cut. The output of the query itself is fine and not truncated; the text is cut only in the new table that is created. An update: I ...
You have here the [current workarounds](http://allenbrowne.com/ser-63.html) for avoiding any Truncation of Memo fields. In your case, that may be the result of the query's Properties Sheet including a "`set Unique`" Values to Yes (which forces comparison of Memo fields, triggering the truncation), or the Format proper...
373,895
<p>Can someone please walk me through the process of loading a class or package in JSP with Tomcat?</p> <p>I think it might just be a Tomcat setup issue :S my JSP file runs fine without importing or using dbpool or dbpooljar. I've tried many suggestions to other peoples similar issues without any luck. Any help would ...
[ { "answer_id": 374448, "author": "Olaf Kock", "author_id": 13447, "author_profile": "https://Stackoverflow.com/users/13447", "pm_score": 1, "selected": false, "text": "<p>You've typed </p>\n\n<p>[%@ page import=\"java.sql.*,java.util.List,java.util.ArrayList,<strong>DBPool</strong>\" %]<...
2008/12/17
[ "https://Stackoverflow.com/questions/373895", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46953/" ]
Can someone please walk me through the process of loading a class or package in JSP with Tomcat? I think it might just be a Tomcat setup issue :S my JSP file runs fine without importing or using dbpool or dbpooljar. I've tried many suggestions to other peoples similar issues without any luck. Any help would be aprecia...
You've typed [%@ page import="java.sql.\*,java.util.List,java.util.ArrayList,**DBPool**" %] but ``` package dbpooljar; public class DBPool { ... ``` Therefor, it should be [%@ page import="java.sql.\*,java.util.List,java.util.ArrayList,**dbpooljar.DBPool**" %] plus your java file should be located in a directo...
373,925
<p>I need a solution to export a dataset to an excel file without any asp code (HttpResonpsne...) but i did not find a good example to do this...</p> <p>Best thanks in advance</p>
[ { "answer_id": 373954, "author": "lc.", "author_id": 44853, "author_profile": "https://Stackoverflow.com/users/44853", "pm_score": 6, "selected": true, "text": "<p>I've created a class that exports a <code>DataGridView</code> or <code>DataTable</code> to an Excel file. You can probably c...
2008/12/17
[ "https://Stackoverflow.com/questions/373925", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46973/" ]
I need a solution to export a dataset to an excel file without any asp code (HttpResonpsne...) but i did not find a good example to do this... Best thanks in advance
I've created a class that exports a `DataGridView` or `DataTable` to an Excel file. You can probably change it a bit to make it use your `DataSet` instead (iterating through the `DataTables` in it). It also does some basic formatting which you could also extend. To use it, simply call ExcelExport, and specify a filena...
374,007
<p>Everything was going well. Nightly builds ran for more than a month with no problems. However, suddenly when invoking the feature builder from Eclipse the execution ends right away with the message.</p> <p>ERRORLEVEL 13</p> <p>As far as I know I haven't changed anything, as this computer is normally not touched....
[ { "answer_id": 374050, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 2, "selected": false, "text": "<p>It should mean \"<strong><em>ant</em></strong> <strong>build failed</strong>\", meaning the headless ant script fails at som...
2008/12/17
[ "https://Stackoverflow.com/questions/374007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2309/" ]
Everything was going well. Nightly builds ran for more than a month with no problems. However, suddenly when invoking the feature builder from Eclipse the execution ends right away with the message. ERRORLEVEL 13 As far as I know I haven't changed anything, as this computer is normally not touched. (It is only used f...
After reading what the error code means thanks to the answer from VonC I understood where to look. The problem was a lot more obscure that it seems. I looked into the configuration folder for Eclipse (logs are either written there or in the .metadata folder when something goes wrong), and I found a huge log file. Insi...
374,009
<p>Setup is SQL2005 SP2 with Reporting Services installed local on Win2003 64bit. When users browse report manager on <a href="http://server/reports" rel="nofollow noreferrer">http://server/reports</a> they get login dialog for every request, but only if they use IE7. In FireFox all works.</p> <p>The site is in "local...
[ { "answer_id": 374050, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 2, "selected": false, "text": "<p>It should mean \"<strong><em>ant</em></strong> <strong>build failed</strong>\", meaning the headless ant script fails at som...
2008/12/17
[ "https://Stackoverflow.com/questions/374009", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24595/" ]
Setup is SQL2005 SP2 with Reporting Services installed local on Win2003 64bit. When users browse report manager on <http://server/reports> they get login dialog for every request, but only if they use IE7. In FireFox all works. The site is in "local intranet" zone on IE. It seems like it is a NTLM, I've tested reinst...
After reading what the error code means thanks to the answer from VonC I understood where to look. The problem was a lot more obscure that it seems. I looked into the configuration folder for Eclipse (logs are either written there or in the .metadata folder when something goes wrong), and I found a huge log file. Insi...
374,014
<p>Is there any reason for the use of 'T' in generics? Is it some kind of abbreviation? As far as I know, everything works. For example </p> <pre><code>public G Say&lt;G&gt;(){ ... } </code></pre> <p>or even</p> <pre><code>public Hello Say&lt;Hello&gt;(){ ... } </code></pre>
[ { "answer_id": 374020, "author": "yesraaj", "author_id": 22076, "author_profile": "https://Stackoverflow.com/users/22076", "pm_score": 3, "selected": false, "text": "<p>T for Type,\nas like you said everything works fine.But putting T in that place remind you that is of generic type.</p>...
2008/12/17
[ "https://Stackoverflow.com/questions/374014", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31722/" ]
Is there any reason for the use of 'T' in generics? Is it some kind of abbreviation? As far as I know, everything works. For example ``` public G Say<G>(){ ... } ``` or even ``` public Hello Say<Hello>(){ ... } ```
T is for **T**ype. But it's really just a tradition and there is nothing to prevent you from using other names. For example, generic dictionaries use `<TKey, TValue>`. There is also a [Microsoft guideline](http://msdn.microsoft.com/lv-lv/library/ms229040(en-us).aspx) that recommends using the letter **T** if you have ...
374,024
<p>We have a web application project (not a web site), until the day we have added batch="false" to web.config web development server was compiling all the web application instead of the page that was requested.</p> <pre><code>&lt;compilation debug="true" batch="false"&gt; &lt;assemblies&gt; ... &l...
[ { "answer_id": 374020, "author": "yesraaj", "author_id": 22076, "author_profile": "https://Stackoverflow.com/users/22076", "pm_score": 3, "selected": false, "text": "<p>T for Type,\nas like you said everything works fine.But putting T in that place remind you that is of generic type.</p>...
2008/12/17
[ "https://Stackoverflow.com/questions/374024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35012/" ]
We have a web application project (not a web site), until the day we have added batch="false" to web.config web development server was compiling all the web application instead of the page that was requested. ``` <compilation debug="true" batch="false"> <assemblies> ... </assemblies> </compilation>...
T is for **T**ype. But it's really just a tradition and there is nothing to prevent you from using other names. For example, generic dictionaries use `<TKey, TValue>`. There is also a [Microsoft guideline](http://msdn.microsoft.com/lv-lv/library/ms229040(en-us).aspx) that recommends using the letter **T** if you have ...
374,025
<p>I have two branches : X and Y. I want to replace a Y's subdirectory (y1) by its equivalent from X (x1).</p> <p>For the time being, I do the following : copy x1 to Y, remove y1, rename (move) x1 to y1 :</p> <pre><code>a) svn copy https://path/to/branches/X/x1 https://path/to/branches/Y/ b) svn delete https://path/t...
[ { "answer_id": 374053, "author": "Martin v. Löwis", "author_id": 33006, "author_profile": "https://Stackoverflow.com/users/33006", "pm_score": 3, "selected": true, "text": "<p>If you really want to replace the directory, you can do that with two operations:</p>\n\n<pre><code>svn delete h...
2008/12/17
[ "https://Stackoverflow.com/questions/374025", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20986/" ]
I have two branches : X and Y. I want to replace a Y's subdirectory (y1) by its equivalent from X (x1). For the time being, I do the following : copy x1 to Y, remove y1, rename (move) x1 to y1 : ``` a) svn copy https://path/to/branches/X/x1 https://path/to/branches/Y/ b) svn delete https://path/to/branches/Y/y1 c) sv...
If you really want to replace the directory, you can do that with two operations: ``` svn delete https://path/to/branches/Y/y1 svn copy https://path/to/branches/X/x1 https://path/to/branches/Y/y1 ``` If Y/y1 is really already an older copy of X/y1, you shouldn't replace it all the time, but instead merge all changes...
374,032
<p>How can I use Doxygen to create the HTML documentation as a single, very long file? I want something like the RTF output, but as HTML.</p> <p>The reason: I need my API published as a single, printable, document. Something that can be loaded into Word, converted to PDF, etc.</p>
[ { "answer_id": 374073, "author": "ChrisN", "author_id": 3853, "author_profile": "https://Stackoverflow.com/users/3853", "pm_score": 2, "selected": false, "text": "<p>I don't think there's an option that will produce the output as a single HTML file, but the RTF output may be suitable if ...
2008/12/17
[ "https://Stackoverflow.com/questions/374032", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38557/" ]
How can I use Doxygen to create the HTML documentation as a single, very long file? I want something like the RTF output, but as HTML. The reason: I need my API published as a single, printable, document. Something that can be loaded into Word, converted to PDF, etc.
I think you can use [HTMLDOC](https://www.msweet.org/htmldoc/index.html) to convert the generated html files to a single html file. (I did not try it myself) The [manual](https://www.msweet.org/htmldoc/htmldoc.html) includes the following example to generate a html from two source html files: ``` htmldoc --book -f ou...
374,040
<p>When I disable input elements the text is taking the font color: <code>#000000</code> in Firefox. This is not happening in IE. Please check the below page in IE and Firefox. Let me know how to give it a gray look as in IE.<br /> <a href="http://shivanand.in/tmp/test.html" rel="nofollow noreferrer">test</a></p>
[ { "answer_id": 374078, "author": "ng.mangine", "author_id": 37784, "author_profile": "https://Stackoverflow.com/users/37784", "pm_score": 4, "selected": true, "text": "<p>Different browsers style disabled elements differently. Here is how you can control the style of disabled elements i...
2008/12/17
[ "https://Stackoverflow.com/questions/374040", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34642/" ]
When I disable input elements the text is taking the font color: `#000000` in Firefox. This is not happening in IE. Please check the below page in IE and Firefox. Let me know how to give it a gray look as in IE. [test](http://shivanand.in/tmp/test.html)
Different browsers style disabled elements differently. Here is how you can control the style of disabled elements in Firefox. ``` [disabled] { color:#ff0000; background-color:#00ff00; } ```
374,041
<p>I am familiar with inserting text nodes after or before a given reference node. But, I would like to know how to insert a tag between text in a given node. For example, </p> <pre><code>Before insertion: &lt;p&gt;Lorem dolor&lt;/p&gt; After insertion: &lt;p&gt;Lorem &lt;span&gt;ipsum&lt;/span&gt; dolor&lt;/p&gt; </c...
[ { "answer_id": 374048, "author": "Vilx-", "author_id": 41360, "author_profile": "https://Stackoverflow.com/users/41360", "pm_score": 1, "selected": false, "text": "<p>You could check a nodes <code>innerHTML</code> property and modify that. Alternatively you might look at <code>childNodes...
2008/12/17
[ "https://Stackoverflow.com/questions/374041", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am familiar with inserting text nodes after or before a given reference node. But, I would like to know how to insert a tag between text in a given node. For example, ``` Before insertion: <p>Lorem dolor</p> After insertion: <p>Lorem <span>ipsum</span> dolor</p> ``` The span node must be inserted after N characte...
You need to get the text into a variable then remove it from the DOM. Split it, then insert the first part, then your span node then the second part. ``` var p = document.getElementById('myParagraph'); var text = p.childNodes[0]; // Split the text var len = 5 var text1 = text.nodeValue.substr(0, len); var text2 = tex...
374,046
<p>Sample</p> <pre><code>void func(void* data) { CResource* resource = (CResource*)data; delete resource; // ~CResource never called. resource = NULL; } </code></pre> <p>Kindly help me to figure out this.</p>
[ { "answer_id": 374060, "author": "yesraaj", "author_id": 22076, "author_profile": "https://Stackoverflow.com/users/22076", "pm_score": 0, "selected": false, "text": "<p>Destructor is called.Give us the full code.</p>\n" }, { "answer_id": 374066, "author": "Suma", "author_...
2008/12/17
[ "https://Stackoverflow.com/questions/374046", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Sample ``` void func(void* data) { CResource* resource = (CResource*)data; delete resource; // ~CResource never called. resource = NULL; } ``` Kindly help me to figure out this.
*Summarized possible reasons why CResource destructor may be not called, extracted from other answers:* Incomplete type --------------- One possible cause is you have the CResource type only declared, not defined: ``` class CResource; void func(void* data) { CResource* resource = (CResource*)data; delete resource...
374,061
<p>I build JQuery/JS/PHP/mySQL app with DB records management and need to provide reliable &amp; complete feedback to the user on AJAX calls, modifying back end DB records. The problem IMHO is <code>$.ajax</code> <code>success:</code> and <code>error:</code> functions indicate just AJAX transport layer success and not ...
[ { "answer_id": 374069, "author": "Rik Heywood", "author_id": 4012, "author_profile": "https://Stackoverflow.com/users/4012", "pm_score": 2, "selected": false, "text": "<p>If you respond to the request with some json data instead of just some new html to insert into the DOM, you can place...
2008/12/17
[ "https://Stackoverflow.com/questions/374061", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I build JQuery/JS/PHP/mySQL app with DB records management and need to provide reliable & complete feedback to the user on AJAX calls, modifying back end DB records. The problem IMHO is `$.ajax` `success:` and `error:` functions indicate just AJAX transport layer success and not the whole process. What if DB modificati...
If you respond to the request with some json data instead of just some new html to insert into the DOM, you can place whatever kinds of error codes and messages you like with the data. For example, if your response was something like... ``` { errorstate: 0, errormsg: "All systems are go", displaytext: "st...
374,079
<p>I have the following table and data in SQL Server 2005:</p> <pre><code>create table LogEntries ( ID int identity, LogEntry varchar(100) ) insert into LogEntries values ('beans') insert into LogEntries values ('beans') insert into LogEntries values ('beans') insert into LogEntries values ('cabbage') insert into...
[ { "answer_id": 374096, "author": "The Archetypal Paul", "author_id": 21755, "author_profile": "https://Stackoverflow.com/users/21755", "pm_score": 1, "selected": false, "text": "<p>SQL not exactly my strong point but won't</p>\n\n<pre><code>SELECT LogEntry, COUNT(1) AS Counter FROM LogEn...
2008/12/17
[ "https://Stackoverflow.com/questions/374079", "https://Stackoverflow.com", "https://Stackoverflow.com/users/571/" ]
I have the following table and data in SQL Server 2005: ``` create table LogEntries ( ID int identity, LogEntry varchar(100) ) insert into LogEntries values ('beans') insert into LogEntries values ('beans') insert into LogEntries values ('beans') insert into LogEntries values ('cabbage') insert into LogEntries va...
This is a set-based solution for the problem. The performance will probably suck, but it works :) ``` CREATE TABLE #LogEntries ( ID INT IDENTITY, LogEntry VARCHAR(100) ) INSERT INTO #LogEntries VALUES ('beans') INSERT INTO #LogEntries VALUES ('beans') INSERT INTO #LogEntries VALUES ('beans') INSERT INTO #LogEntri...
374,085
<p>I've got HTML code that roughly looks like this:</p> <pre><code>&lt;li id="someid-11"&gt; &lt;img src="..." alt="alt" /&gt; &lt;h2&gt;&lt;a href="somelink"&gt; sometext &lt;/a&gt; &lt;span&gt;&lt;a class="editcontent" href="?action=editme"&gt;Edit&lt;/a&gt;&lt;/span&gt; &lt;/h2&gt; &lt;div id="11" class="conte...
[ { "answer_id": 374110, "author": "benlumley", "author_id": 39161, "author_profile": "https://Stackoverflow.com/users/39161", "pm_score": 1, "selected": false, "text": "<p>You can probably use xpath to get from the A to the DIV in one go?</p>\n\n<p>Edit: Apparently xpath selectors are no ...
2008/12/17
[ "https://Stackoverflow.com/questions/374085", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1011/" ]
I've got HTML code that roughly looks like this: ``` <li id="someid-11"> <img src="..." alt="alt" /> <h2><a href="somelink"> sometext </a> <span><a class="editcontent" href="?action=editme">Edit</a></span> </h2> <div id="11" class="content"> <!-- // content goes here --> <div class="bottom_of_entry"> </div> </...
I recommended the Sprintstar Solution. but if you don't like it, use this: ``` $("a.editcontent").click(function(){ $(this).parents("h2").next(".content").trigger("edit"); }); ``` If you have more that one "h2": ``` $("a.editcontent").click(function(){ $(this).parents("h2:first").next(".content").trigger("e...
374,086
<p>Aloha</p> <p>I received a nice wsdl with xs: documentation tags like:</p> <pre><code>&lt;xs:complexType name="Supplier"&gt; &lt;xs:annotation&gt; &lt;xs:documentation&gt; The supplier of the product &lt;/xs:documentation&gt; &lt;/xs:annotation&gt; </code></pre> <p>Is there any way to generate <c...
[ { "answer_id": 374110, "author": "benlumley", "author_id": 39161, "author_profile": "https://Stackoverflow.com/users/39161", "pm_score": 1, "selected": false, "text": "<p>You can probably use xpath to get from the A to the DIV in one go?</p>\n\n<p>Edit: Apparently xpath selectors are no ...
2008/12/17
[ "https://Stackoverflow.com/questions/374086", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6399/" ]
Aloha I received a nice wsdl with xs: documentation tags like: ``` <xs:complexType name="Supplier"> <xs:annotation> <xs:documentation> The supplier of the product </xs:documentation> </xs:annotation> ``` Is there any way to generate `///<summary>` tags from this? I'm using visual studio 2008
I recommended the Sprintstar Solution. but if you don't like it, use this: ``` $("a.editcontent").click(function(){ $(this).parents("h2").next(".content").trigger("edit"); }); ``` If you have more that one "h2": ``` $("a.editcontent").click(function(){ $(this).parents("h2:first").next(".content").trigger("e...
374,099
<p>I have to pass some parameter from an action to another action,for example to keep trace of an event. </p> <p>What is the best way to do that? </p> <p>I would not use session parameters. Thanks</p>
[ { "answer_id": 374119, "author": "krosenvold", "author_id": 23691, "author_profile": "https://Stackoverflow.com/users/23691", "pm_score": 5, "selected": true, "text": "<p>Assuming you are serverside within one action and wishing to invoke another action with some parameters.</p>\n\n<p>Yo...
2008/12/17
[ "https://Stackoverflow.com/questions/374099", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39339/" ]
I have to pass some parameter from an action to another action,for example to keep trace of an event. What is the best way to do that? I would not use session parameters. Thanks
Assuming you are serverside within one action and wishing to invoke another action with some parameters. You can use the s:action tag to invoke another action, possibly with additional/other parameters than the original action: ``` <s:action name="myAction" ignoreContextParams="true" executeResult="true"> ...
374,109
<p><a href="http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/7ab67d24-6afa-4be6-855e-e260845a47e2/" rel="noreferrer">Tell me it ain't so</a>.</p> <p>I have a typical windows/file explorer like setup.</p> <ul> <li>Left Side I have a TreeView all data bound showing nodes in a hierachy</li> <li>Right Side I have...
[ { "answer_id": 374380, "author": "Gishu", "author_id": 1695, "author_profile": "https://Stackoverflow.com/users/1695", "pm_score": 0, "selected": false, "text": "<p>My solution to this turned out to be pretty tiny.. don't know if it is equivalent to IsSynchronizedWithCurrentItem. ListVie...
2008/12/17
[ "https://Stackoverflow.com/questions/374109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1695/" ]
[Tell me it ain't so](http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/7ab67d24-6afa-4be6-855e-e260845a47e2/). I have a typical windows/file explorer like setup. * Left Side I have a TreeView all data bound showing nodes in a hierachy * Right Side I have a ListView showing Node.Properties ListView has a IsSy...
A really simple solution is to bind your "details" UI elements to the SelectedValue property of the TreeView. For example, if your TreeView looked like this: ``` <TreeView Name="CategoryName" ItemsSource="{Binding Source={StaticResource A_Collection}, Path=RootItems}" /> ``` Then you could bind details UI elements (...
374,134
<p>I'm having troubles with a regexp. I'm looking through a set of XML files, and trying to detect some text inside specific nodes that contain a line break.</p> <p>Here is some sample data:</p> <pre><code>&lt;item name='GenMsgText'&gt;&lt;text&gt;The signature will be discarded.&lt;/text&gt;&lt;/item&gt; &lt;item n...
[ { "answer_id": 374144, "author": "bezmax", "author_id": 43677, "author_profile": "https://Stackoverflow.com/users/43677", "pm_score": 0, "selected": false, "text": "<p>I'm not sure, but think this should work:</p>\n\n<pre><code>&lt;item name='GenMsgText'&gt;(&lt;textlist&gt;)?&lt;text&gt...
2008/12/17
[ "https://Stackoverflow.com/questions/374134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29568/" ]
I'm having troubles with a regexp. I'm looking through a set of XML files, and trying to detect some text inside specific nodes that contain a line break. Here is some sample data: ``` <item name='GenMsgText'><text>The signature will be discarded.</text></item> <item name='GenMsgText'><text>The signature will be dis...
Regex is not the right tool for this task, it simply can't handle nested structures very well. If you have a DOM API your disposal, this XPath would find the right nodes: If you are looking for `<break/>` elements, as your example suggests: ``` //item[@name='GenMsgText']/text[break] ``` For "real" line breaks, bein...