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
137,336
<p>PHP, as we all know is very loosely typed. The language does not require you to specify any kind of type for function parameters or class variables. This can be a powerful feature.</p> <p>Sometimes though, it can make debugging your script a painful experience. For example, passing one kind of object into a method ...
[ { "answer_id": 137342, "author": "Eran Galperin", "author_id": 10585, "author_profile": "https://Stackoverflow.com/users/10585", "pm_score": 5, "selected": true, "text": "<p>Actually for classes you can provide type hinting in PHP (5+).</p>\n\n<pre><code> &lt;?php\n class UsesBaseClass\n...
2008/09/26
[ "https://Stackoverflow.com/questions/137336", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8123/" ]
PHP, as we all know is very loosely typed. The language does not require you to specify any kind of type for function parameters or class variables. This can be a powerful feature. Sometimes though, it can make debugging your script a painful experience. For example, passing one kind of object into a method that expec...
Actually for classes you can provide type hinting in PHP (5+). ``` <?php class UsesBaseClass { function SetObject(InterfaceObject $obj) { } } ?> ``` This will also work correctly with inheritance as you would expect it to. As an aside, don't put the word 'object' in your class names...
137,359
<p>I produce a report as an CSV file. When I try to open the file in Excel, it makes an assumption about the data type based on the contents of the cell, and reformats it accordingly.</p> <p>For example, if the CSV file contains</p> <pre><code>...,005,... </code></pre> <p>Then Excel shows it as 5. Is there a way to ...
[ { "answer_id": 137368, "author": "Ólafur Waage", "author_id": 22459, "author_profile": "https://Stackoverflow.com/users/22459", "pm_score": 2, "selected": false, "text": "<p>You can simply format your range as Text.</p>\n\n<p>Also <a href=\"http://peltiertech.com/Excel/NumberFormats.html...
2008/09/26
[ "https://Stackoverflow.com/questions/137359", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10557/" ]
I produce a report as an CSV file. When I try to open the file in Excel, it makes an assumption about the data type based on the contents of the cell, and reformats it accordingly. For example, if the CSV file contains ``` ...,005,... ``` Then Excel shows it as 5. Is there a way to override this and display 005? I...
There isn’t an easy way to control the formatting Excel applies when opening a .csv file. However listed below are three approaches that might help. My preference is the first option. **Option 1 – Change the data in the file** You could change the data in the .csv file as follows ...,**=”005”**,... This will be disp...
137,375
<p>I'm teaching/helping a student to program.</p> <p>I remember the following process always helped me when I started; It looks pretty intuitive and I wonder if someone else have had a similar approach.</p> <ol> <li>Read the problem and understand it ( of course ) .</li> <li>Identify possible "functions" and variable...
[ { "answer_id": 137383, "author": "J.J.", "author_id": 21204, "author_profile": "https://Stackoverflow.com/users/21204", "pm_score": 3, "selected": true, "text": "<p>I did something similar. </p>\n\n<ul>\n<li>Figure out the rules/logic. </li>\n<li>Figure out the math. </li>\n<li>Then try ...
2008/09/26
[ "https://Stackoverflow.com/questions/137375", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20654/" ]
I'm teaching/helping a student to program. I remember the following process always helped me when I started; It looks pretty intuitive and I wonder if someone else have had a similar approach. 1. Read the problem and understand it ( of course ) . 2. Identify possible "functions" and variables. 3. Write how would I do...
I did something similar. * Figure out the rules/logic. * Figure out the math. * Then try and code it. After doing that for a couple of months it just gets internalized. You don't realize your doing it until you come up against a complex problem that requires you to break it down.
137,387
<p>I'm converting an old app that records folder sizes on a daily basis. The legacy app uses the Scripting.FileSystemObject library:</p> <pre><code>Set fso = CreateObject("Scripting.FileSystemObject") Set folderObject = fso.GetFolder(folder) size = folderObject.Size </code></pre> <p>There isn't an equivalent mechanis...
[ { "answer_id": 137393, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 2, "selected": false, "text": "<p>Sadly, yes...who knows why.</p>\n\n<pre><code>public static long DirSize(DirectoryInfo d) \n{ \n long Size = 0; ...
2008/09/26
[ "https://Stackoverflow.com/questions/137387", "https://Stackoverflow.com", "https://Stackoverflow.com/users/419/" ]
I'm converting an old app that records folder sizes on a daily basis. The legacy app uses the Scripting.FileSystemObject library: ``` Set fso = CreateObject("Scripting.FileSystemObject") Set folderObject = fso.GetFolder(folder) size = folderObject.Size ``` There isn't an equivalent mechanism on the System.IO.Directo...
I think that you already know the answer; you will need to add up all of the files in the directory (as well as its child directories.) I don't know of any built in function for this, but hey, I don't know everything (not even close).
137,392
<p>I'm sick of remembering all the passwords for different logins. Lately I found the interesting tool <a href="http://www.xs4all.nl/~jlpoutre/BoT/Javascript/PasswordComposer/" rel="nofollow noreferrer">password composer</a> which lets you generate passwords base on the <strong>hostname</strong> and a secret <strong>ma...
[ { "answer_id": 137421, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 2, "selected": false, "text": "<p>Why don't you just use the exact same algorithm as the password composer?</p>\n\n<ul>\n<li>Pick a master password...
2008/09/26
[ "https://Stackoverflow.com/questions/137392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/720/" ]
I'm sick of remembering all the passwords for different logins. Lately I found the interesting tool [password composer](http://www.xs4all.nl/~jlpoutre/BoT/Javascript/PasswordComposer/) which lets you generate passwords base on the **hostname** and a secret **master password**. But I don't want to use a website or insta...
Why don't you just use the exact same algorithm as the password composer? * Pick a master password * Take the application/machine name for which you want a password * Concatenate the two (or shuffle) * Apply a code you can do in your head, like [Caesar's cipher](http://en.wikipedia.org/wiki/Caesar%27s_cipher) * Take t...
137,398
<p>I have a SQL query (MS Access) and I need to add two columns, either of which may be null. For instance:</p> <pre><code>SELECT Column1, Column2, Column3+Column4 AS [Added Values] FROM Table </code></pre> <p>where Column3 or Column4 may be null. In this case, I want null to be considered zero (so <code>4 + null = 4...
[ { "answer_id": 137410, "author": "Michael Haren", "author_id": 29, "author_profile": "https://Stackoverflow.com/users/29", "pm_score": 5, "selected": true, "text": "<p>Since ISNULL in Access is a boolean function (one parameter), use it like this:</p>\n\n<pre><code>SELECT Column1, Column...
2008/09/26
[ "https://Stackoverflow.com/questions/137398", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14902/" ]
I have a SQL query (MS Access) and I need to add two columns, either of which may be null. For instance: ``` SELECT Column1, Column2, Column3+Column4 AS [Added Values] FROM Table ``` where Column3 or Column4 may be null. In this case, I want null to be considered zero (so `4 + null = 4, null + null = 0`). Any sugge...
Since ISNULL in Access is a boolean function (one parameter), use it like this: ``` SELECT Column1, Column2, IIF(ISNULL(Column3),0,Column3) + IIF(ISNULL(Column4),0,Column4) AS [Added Values] FROM Table ```
137,399
<p>Occasionally I come accross a unit test that doesn't Assert anything. The particular example I came across this morning was testing that a log file got written to when a condition was met. The assumption was that if no error was thrown the test passed.</p> <p>I personally don't have a problem with this, however it ...
[ { "answer_id": 137409, "author": "chessguy", "author_id": 1908025, "author_profile": "https://Stackoverflow.com/users/1908025", "pm_score": 2, "selected": false, "text": "<p>In some sense, you are making an implicit assertion - that the code doesn't throw an exception. Of course it would...
2008/09/26
[ "https://Stackoverflow.com/questions/137399", "https://Stackoverflow.com", "https://Stackoverflow.com/users/493/" ]
Occasionally I come accross a unit test that doesn't Assert anything. The particular example I came across this morning was testing that a log file got written to when a condition was met. The assumption was that if no error was thrown the test passed. I personally don't have a problem with this, however it seems to b...
This would be the official way to do it: ``` // Act Exception ex = Record.Exception(() => someCode()); // Assert Assert.Null(ex); ```
137,400
<p>Looking at the processmodel element in the Web.Config there are two attributes.</p> <pre><code>maxWorkerThreads="25" maxIoThreads="25" </code></pre> <p>What is the difference between worker threads and I/O threads?</p>
[ { "answer_id": 137431, "author": "chadmyers", "author_id": 10862, "author_profile": "https://Stackoverflow.com/users/10862", "pm_score": 6, "selected": true, "text": "<p>Fundamentally not a lot, it's all about how ASP.NET and IIS allocate I/O wait objects and manage the contention and la...
2008/09/26
[ "https://Stackoverflow.com/questions/137400", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19490/" ]
Looking at the processmodel element in the Web.Config there are two attributes. ``` maxWorkerThreads="25" maxIoThreads="25" ``` What is the difference between worker threads and I/O threads?
Fundamentally not a lot, it's all about how ASP.NET and IIS allocate I/O wait objects and manage the contention and latency of communicating over the network and transferring data. I/O threads are set aside as such because they will be doing I/O (as the name implies) and may have to wait for "long" periods of time (hu...
137,448
<p>Take the following snippet:</p> <pre><code>List&lt;int&gt; distances = new List&lt;int&gt;(); </code></pre> <p>Was the redundancy intended by the language designers? If so, why?</p>
[ { "answer_id": 137455, "author": "Nescio", "author_id": 14484, "author_profile": "https://Stackoverflow.com/users/14484", "pm_score": 4, "selected": false, "text": "<p>You could always say: <br></p>\n\n<pre><code> var distances = new List&lt;int&gt;();\n</code></pre>\n" }, { "ans...
2008/09/26
[ "https://Stackoverflow.com/questions/137448", "https://Stackoverflow.com", "https://Stackoverflow.com/users/781/" ]
Take the following snippet: ``` List<int> distances = new List<int>(); ``` Was the redundancy intended by the language designers? If so, why?
The reason the code appears to be redundant is because, to a novice programmer, it appears to be defining the same thing twice. But this is not what the code is doing. It is defining two separate things that just happen to be of the same type. It is defining the following: 1. A variable named distances of type `List<i...
137,449
<p>I have a draggable div element with a hover style. This works fine, but the div contains some form elements (label, input). The problem is that when the mouse is over these child elements the hover is disabled.</p> <pre><code>&lt;div class="app_setting"&gt; &lt;label"&gt;Name&lt;/label&gt; &lt;input type="text"...
[ { "answer_id": 137466, "author": "garrow", "author_id": 21095, "author_profile": "https://Stackoverflow.com/users/21095", "pm_score": 6, "selected": true, "text": "<pre><code>.app_setting *:hover { cursor:move }\n</code></pre>\n" }, { "answer_id": 137496, "author": "seanb", ...
2008/09/26
[ "https://Stackoverflow.com/questions/137449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14971/" ]
I have a draggable div element with a hover style. This works fine, but the div contains some form elements (label, input). The problem is that when the mouse is over these child elements the hover is disabled. ``` <div class="app_setting"> <label">Name</label> <input type="text" name="name"/> </div> .app_setting...
``` .app_setting *:hover { cursor:move } ```
137,452
<p>I hate case sensitivity in databases, but I'm developing for a client who uses it. How can I turn on this option on my SQL Server, so I can be sure I've gotten the case right in all my queries?</p>
[ { "answer_id": 137460, "author": "John Hoven", "author_id": 1907, "author_profile": "https://Stackoverflow.com/users/1907", "pm_score": 0, "selected": false, "text": "<p>You'll have to change the database collation. You'll also need to alter the table and column level collation. I bele...
2008/09/26
[ "https://Stackoverflow.com/questions/137452", "https://Stackoverflow.com", "https://Stackoverflow.com/users/672/" ]
I hate case sensitivity in databases, but I'm developing for a client who uses it. How can I turn on this option on my SQL Server, so I can be sure I've gotten the case right in all my queries?
How about: ``` ALTER DATABASE database_name COLLATE collation_name ``` See BOL for a [list of collation options](http://msdn.microsoft.com/en-us/library/ms144250(SQL.90).aspx) and pick the case-sensitive one that best fits your needs (i.e. the one your client is using). Obviously, it's probably a good idea to mak...
137,487
<p>I am told that good developers can spot/utilize the difference between <code>Null</code> and <code>False</code> and <code>0</code> and all the other good "nothing" entities.<br> What <em>is</em> the difference, specifically in PHP? Does it have something to do with <code>===</code>?</p>
[ { "answer_id": 137500, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 1, "selected": false, "text": "<p>The differences between these values always come down to detailed language-specific rules. What you learn for PHP isn'...
2008/09/26
[ "https://Stackoverflow.com/questions/137487", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1615/" ]
I am told that good developers can spot/utilize the difference between `Null` and `False` and `0` and all the other good "nothing" entities. What *is* the difference, specifically in PHP? Does it have something to do with `===`?
It's language specific, but in PHP : ------------------------------------ **`Null`** means "**nothing**". The var has not been initialized. **`False`** means "**not true in a boolean context**". Used to explicitly show you are dealing with logical issues. **`0`** is an **`int`**. Nothing to do with the rest above, u...
137,497
<p>In Oracle, is there an easy way to fully unwrap a view? eg: If I have a view which is made up of selects on more views, is there some way to unwrap it to just select directly on real tables?</p>
[ { "answer_id": 137750, "author": "Mark Stock", "author_id": 19737, "author_profile": "https://Stackoverflow.com/users/19737", "pm_score": 2, "selected": false, "text": "<ol>\n<li><p>Get the query text of your view.</p>\n\n<pre><code>SELECT text FROM dba_views\nWHERE owner = 'the-owner' A...
2008/09/26
[ "https://Stackoverflow.com/questions/137497", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3839/" ]
In Oracle, is there an easy way to fully unwrap a view? eg: If I have a view which is made up of selects on more views, is there some way to unwrap it to just select directly on real tables?
1. Get the query text of your view. ``` SELECT text FROM dba_views WHERE owner = 'the-owner' AND view_name = 'the-view-name'; ``` 2. Parse. Search for view names within the query text. 3. Get the query text for each view name found. (see item 1.) 4. Replace each view name in the query with the related query text. 5. ...
137,521
<p>My Invoice model has an address_id attribute, and I don't want this address_id to change FOREVER. So I don't want this to happen outside the class:</p> <pre><code>invoice.address_id = 1 invoice.address = some_address </code></pre> <p>Rails automatically adds this address_id attribute to the model from the invoice ...
[ { "answer_id": 137538, "author": "ryw", "author_id": 2477, "author_profile": "https://Stackoverflow.com/users/2477", "pm_score": 2, "selected": false, "text": "<p>Not as pretty as a one liner, but code below should work (and you could always do some metaprogramming to write an 'immutable...
2008/09/26
[ "https://Stackoverflow.com/questions/137521", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11082/" ]
My Invoice model has an address\_id attribute, and I don't want this address\_id to change FOREVER. So I don't want this to happen outside the class: ``` invoice.address_id = 1 invoice.address = some_address ``` Rails automatically adds this address\_id attribute to the model from the invoice table, so how can I dec...
You want [`attr_readonly`](http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M001317).
137,530
<p>Ok, this is a curly one. I'm working on some Delphi code that I didn't write, and I'm encountering a very strange problem. One of my stored procedures' parameters is coming through as <code>null</code>, even though it's definitely being sent <code>1</code>.</p> <p>The Delphi code uses a TADOQuery to execute the sto...
[ { "answer_id": 137694, "author": "Steven A. Lowe", "author_id": 9345, "author_profile": "https://Stackoverflow.com/users/9345", "pm_score": 0, "selected": false, "text": "<p>caveat: i don't know delphi, but this issue rings a faint bell and so i'm interested in it</p>\n\n<p>do you get th...
2008/09/26
[ "https://Stackoverflow.com/questions/137530", "https://Stackoverflow.com", "https://Stackoverflow.com/users/369/" ]
Ok, this is a curly one. I'm working on some Delphi code that I didn't write, and I'm encountering a very strange problem. One of my stored procedures' parameters is coming through as `null`, even though it's definitely being sent `1`. The Delphi code uses a TADOQuery to execute the stored procedure (anonymized): ```...
Ok, progress is made.. sort of. @Robsoft was correct, setting the parameter direction to `pdInput` fixed the issue. I traced into the VCL code, and it came down to `TParameters.InternalRefresh.RefreshFromOleDB`. This function is being called when I set the SQL.Text. Here's the (abridged) code: ``` function TParamete...
137,580
<p>I know how to do a HEAD request with httplib, but I have to use mechanize for this site. </p> <p>Essentially, what I need to do is grab a value from the header (filename) without actually downloading the file.</p> <p>Any suggestions how I could accomplish this?</p>
[ { "answer_id": 137624, "author": "Michał Kwiatkowski", "author_id": 21998, "author_profile": "https://Stackoverflow.com/users/21998", "pm_score": 4, "selected": true, "text": "<p>Mechanize itself only sends GETs and POSTs, but you can easily extend the Request class to send HEAD. Example...
2008/09/26
[ "https://Stackoverflow.com/questions/137580", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18866/" ]
I know how to do a HEAD request with httplib, but I have to use mechanize for this site. Essentially, what I need to do is grab a value from the header (filename) without actually downloading the file. Any suggestions how I could accomplish this?
Mechanize itself only sends GETs and POSTs, but you can easily extend the Request class to send HEAD. Example: ``` import mechanize class HeadRequest(mechanize.Request): def get_method(self): return "HEAD" request = HeadRequest("http://www.example.com/") response = mechanize.urlopen(request) print respo...
137,621
<p>I can't find a reference to it but I remember reading that it wasn't a good idea to call virtual (polymorphic) methods within a destructor or the Dispose() method of IDisposable.</p> <p>Is this true and if so can someone explain why?</p>
[ { "answer_id": 137636, "author": "Jon Limjap", "author_id": 372, "author_profile": "https://Stackoverflow.com/users/372", "pm_score": 1, "selected": false, "text": "<p>Virtual methods are discouraged in both constructors and destructors. </p>\n\n<p>The reason is more practical than anyth...
2008/09/26
[ "https://Stackoverflow.com/questions/137621", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21429/" ]
I can't find a reference to it but I remember reading that it wasn't a good idea to call virtual (polymorphic) methods within a destructor or the Dispose() method of IDisposable. Is this true and if so can someone explain why?
Calling virtual methods from a finalizer/`Dispose` is unsafe, for the same reasons [it is unsafe to do in a constructor](https://stackoverflow.com/questions/119506/virtual-member-call-in-a-constructor). It is impossible to be sure that the derived class has not already cleaned-up some state that the virtual method requ...
137,629
<p>How do you render primitives as wireframes in OpenGL?</p>
[ { "answer_id": 137644, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 6, "selected": false, "text": "<p>From <a href=\"https://web.archive.org/web/20090119194513/http://cone3d.gamedev.net/cgi-bin/index.pl?page=tutorials...
2008/09/26
[ "https://Stackoverflow.com/questions/137629", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How do you render primitives as wireframes in OpenGL?
``` glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); ``` to switch on, ``` glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); ``` to go back to normal. Note that things like texture-mapping and lighting will still be applied to the wireframe lines if they're enabled, which can look weird.
137,630
<p>I was wondering if there was a way to use "find_by_sql" within a named_scope. I'd like to treat custom sql as named_scope so I can chain it to my existing named_scopes. It would also be good for optimizing a sql snippet I use frequently.</p>
[ { "answer_id": 137643, "author": "macarthy", "author_id": 17232, "author_profile": "https://Stackoverflow.com/users/17232", "pm_score": 0, "selected": false, "text": "<p>sure why not </p>\n\n<p>:named_scope :conditions => [ your sql ]</p>\n" }, { "answer_id": 180440, "author"...
2008/09/26
[ "https://Stackoverflow.com/questions/137630", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1227001/" ]
I was wondering if there was a way to use "find\_by\_sql" within a named\_scope. I'd like to treat custom sql as named\_scope so I can chain it to my existing named\_scopes. It would also be good for optimizing a sql snippet I use frequently.
While you can put any SQL you like in the conditions of a named scope, if you then call `find_by_sql` then the 'scopes' get thrown away. Given: ``` class Item # Anything you can put in an sql WHERE you can put here named_scope :mine, :conditions=>'user_id = 12345 and IS_A_NINJA() = 1' end ``` This works (it jus...
137,660
<p>In a J2EE application (like one running in WebSphere), when I use <code>System.out.println()</code>, my text goes to standard out, which is mapped to a file by the WebSphere admin console.</p> <p>In an ASP.NET application (like one running in IIS), where does the output of <code>Console.WriteLine()</code> go? The ...
[ { "answer_id": 137704, "author": "Leon Tayson", "author_id": 18413, "author_profile": "https://Stackoverflow.com/users/18413", "pm_score": -1, "selected": false, "text": "<p>In an ASP.NET application, I think it goes to the Output or Console window which is visible during debugging.</p>\...
2008/09/26
[ "https://Stackoverflow.com/questions/137660", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22514/" ]
In a J2EE application (like one running in WebSphere), when I use `System.out.println()`, my text goes to standard out, which is mapped to a file by the WebSphere admin console. In an ASP.NET application (like one running in IIS), where does the output of `Console.WriteLine()` go? The IIS process must have a stdin, st...
If you look at the `Console` class in [.NET Reflector](http://en.wikipedia.org/wiki/.NET_Reflector), you'll find that if a process doesn't have an associated console, `Console.Out` and `Console.Error` are backed by `Stream.Null` (wrapped inside a `TextWriter`), which is a dummy implementation of `Stream` that basically...
137,661
<p>In C#, I can do this:</p> <pre><code>class Program { static void Main(string[] args) { List&lt;Animal&gt; animals = new List&lt;Animal&gt;(); animals.Add(new Dog()); animals.Add(new Cat()); foreach (Animal a in animals) { Console.WriteLine(a.MakeNoise())...
[ { "answer_id": 137675, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 5, "selected": true, "text": "<p>edit: added more code for your updated question</p>\n\n<p>disclaimer: I haven't used Ruby in a year or so, and don't...
2008/09/26
[ "https://Stackoverflow.com/questions/137661", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1965/" ]
In C#, I can do this: ``` class Program { static void Main(string[] args) { List<Animal> animals = new List<Animal>(); animals.Add(new Dog()); animals.Add(new Cat()); foreach (Animal a in animals) { Console.WriteLine(a.MakeNoise()); a.Sleep(); ...
edit: added more code for your updated question disclaimer: I haven't used Ruby in a year or so, and don't have it installed on this machine, so the syntax might be entirely wrong. But the concepts are correct. --- The exact same way, with classes and overridden methods: ``` class Animal def MakeNoise r...
137,679
<p>I setup phpMyID on one of my machines, and I'm trying to get apache to redirect to HTTPS only when a password is being submitted. I am doing this as my original setup of redirecting all openid traffic didn't work stackoverflow doesn't like my self signed certificate. This is the new rule I've written, but its not ...
[ { "answer_id": 137692, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 3, "selected": true, "text": "<p>You need to use a Cond to test for both port (http or httpd) and query string:</p>\n\n<pre><code>RewriteCond %{SER...
2008/09/26
[ "https://Stackoverflow.com/questions/137679", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9940/" ]
I setup phpMyID on one of my machines, and I'm trying to get apache to redirect to HTTPS only when a password is being submitted. I am doing this as my original setup of redirecting all openid traffic didn't work stackoverflow doesn't like my self signed certificate. This is the new rule I've written, but its not worki...
You need to use a Cond to test for both port (http or httpd) and query string: ``` RewriteCond %{SERVER_PORT} 80 RewriteCond %{QUERY_STRING} (.+) RewriteRule /openid/index.php https://%{SERVER_NAME}/openid/index.php?%1 ``` if on .htaccess you must use instead ``` RewriteCond %{SERVER_PORT} 80 RewriteCond %{QUERY_ST...
137,730
<p>How to post a username, password and multiple binary files from a single html form and process it using php? I'm not allowed to use ajax.</p>
[ { "answer_id": 137751, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 1, "selected": false, "text": "<p>You should use the <code>$_FILES</code> superglobal and <code>move_uploaded_file()</code> function to see which f...
2008/09/26
[ "https://Stackoverflow.com/questions/137730", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3740/" ]
How to post a username, password and multiple binary files from a single html form and process it using php? I'm not allowed to use ajax.
first off check out these pages on PHP.net 1. [file upload info](http://us3.php.net/features.file-upload) 2. [`move_uploaded_file`](http://us3.php.net/manual/en/function.move-uploaded-file.php) But to get you started here's a couple stub files. **uploadForm.html** ``` <html> <body> <form action="processStuff.ph...
137,753
<p>I'm looking for the most ideal data structure (for performance and ease of use) from which values can be retrieved by string key or index. Dictionary doesn't work because you can't really retrieve by index. Any ideas?</p>
[ { "answer_id": 137762, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 0, "selected": false, "text": "<p>Hash based collections (Dictionary, Hashtable, HashSet) are out because you won't have an index, since you want an index,...
2008/09/26
[ "https://Stackoverflow.com/questions/137753", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4541/" ]
I'm looking for the most ideal data structure (for performance and ease of use) from which values can be retrieved by string key or index. Dictionary doesn't work because you can't really retrieve by index. Any ideas?
You want the [OrderedDictionary](http://msdn.microsoft.com/en-us/library/system.collections.specialized.ordereddictionary.aspx) class. You will need to include the System.Collections.Specialized namespace: ``` OrderedDictionary od = new OrderedDictionary(); od.Add("abc", 1); od.Add("def", 2); od.Add...
137,773
<p>In our product we ship some linux binaries that dynamically link to system libraries like "libpam". On some customer systems we get the following error on stderr when the program runs:</p> <pre><code>./authpam: /lib/libpam.so.0: no version information available (required by authpam) </code></pre> <p>The applicati...
[ { "answer_id": 137810, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 1, "selected": false, "text": "<p>Have you seen <a href=\"http://answers.google.com/answers/threadview/id/786136.html\" rel=\"nofollow noreferrer\"...
2008/09/26
[ "https://Stackoverflow.com/questions/137773", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
In our product we ship some linux binaries that dynamically link to system libraries like "libpam". On some customer systems we get the following error on stderr when the program runs: ``` ./authpam: /lib/libpam.so.0: no version information available (required by authpam) ``` The application runs fine and executes c...
The "no version information available" means that the library version number is lower on the shared object. For example, if your major.minor.patch number is 7.15.5 on the machine where you build the binary, and the major.minor.patch number is 7.12.1 on the installation machine, ld will print the warning. You can fix t...
137,775
<p>I've wanted this for fluent interfaces. See, for example <a href="http://channel9.msdn.com/forums/Coffeehouse/257556-C-Extension-Properties/" rel="nofollow noreferrer">this</a> Channel9 discussion. Would probably <a href="http://ayende.com/Blog/archive/2007/12/02/Why-C-doesnt-have-extension-properties.aspx" rel="nof...
[ { "answer_id": 137787, "author": "Ben Hoffstein", "author_id": 4482, "author_profile": "https://Stackoverflow.com/users/4482", "pm_score": 5, "selected": false, "text": "<p>Since properties are just syntactic sugar for methods, I don't see why C# should have extension methods without ext...
2008/09/26
[ "https://Stackoverflow.com/questions/137775", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22528/" ]
I've wanted this for fluent interfaces. See, for example [this](http://channel9.msdn.com/forums/Coffeehouse/257556-C-Extension-Properties/) Channel9 discussion. Would probably [require](http://ayende.com/Blog/archive/2007/12/02/Why-C-doesnt-have-extension-properties.aspx) also adding indexed properties. What are your ...
In my book the #1 most substantial reason for extension properties is implementing fluent interface patterns around unowned code. I built a wrapper around the NHibernate session to make it more intitutive to work with so I can do logic similar to ``` public bool IsInTransaction { get { return _session.Is().Not.Nul...
137,783
<p>Given a function which produces a random integer in the range 1 to 5, write a function which produces a random integer in the range 1 to 7.</p>
[ { "answer_id": 137807, "author": "Will Hartung", "author_id": 13663, "author_profile": "https://Stackoverflow.com/users/13663", "pm_score": 4, "selected": false, "text": "<p>Are homework problems allowed here?</p>\n\n<p>This function does crude \"base 5\" math to generate a number betwee...
2008/09/26
[ "https://Stackoverflow.com/questions/137783", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22535/" ]
Given a function which produces a random integer in the range 1 to 5, write a function which produces a random integer in the range 1 to 7.
There is no (exactly correct) solution which will run in a constant amount of time, since 1/7 is an infinite decimal in base 5. One simple solution would be to use rejection sampling, e.g.: ``` int i; do { i = 5 * (rand5() - 1) + rand5(); // i is now uniformly random between 1 and 25 } while(i > 21); // i is now u...
137,784
<p>I have a report in SSRS 2005 that's based on a query that's similar to this one: </p> <pre><code>SELECT * FROM MyTable (NOLOCK) WHERE col1 = 'ABC' AND col2 LIKE '%XYZ%' </code></pre> <p>I need to be able to dynamically include the AND part of the WHERE clause in the query based on whether the user has checked a c...
[ { "answer_id": 137856, "author": "Jason Stevenson", "author_id": 13368, "author_profile": "https://Stackoverflow.com/users/13368", "pm_score": 1, "selected": false, "text": "<p>Perhaps this would work for you:</p>\n\n<pre><code>if @checked = 1\n select * from mytable (nolock) where co...
2008/09/26
[ "https://Stackoverflow.com/questions/137784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11507/" ]
I have a report in SSRS 2005 that's based on a query that's similar to this one: ``` SELECT * FROM MyTable (NOLOCK) WHERE col1 = 'ABC' AND col2 LIKE '%XYZ%' ``` I need to be able to dynamically include the AND part of the WHERE clause in the query based on whether the user has checked a checkbox. Basically, this i...
Charles almost had the correct answer. It should be: ``` SELECT * FROM MyTable (NOLOCK) WHERE col1 = 'ABC' AND (@checked = 0 OR col2 LIKE '%XYZ%') ``` This is a classic "pattern" in SQL for conditional predicates. If `@checked = 0`, then it will return all rows matching the remainder of the predicate (`col1 = '...
137,803
<p>Does anyone happen to remember the function name used to generate sequential row number built-in SQL Server 2000.</p>
[ { "answer_id": 137818, "author": "FryHard", "author_id": 231, "author_profile": "https://Stackoverflow.com/users/231", "pm_score": 5, "selected": true, "text": "<p>If you are making use of GUIDs this should be nice and easy, if you are looking for an integer ID, you will have to wait for...
2008/09/26
[ "https://Stackoverflow.com/questions/137803", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15396/" ]
Does anyone happen to remember the function name used to generate sequential row number built-in SQL Server 2000.
If you are making use of GUIDs this should be nice and easy, if you are looking for an integer ID, you will have to wait for another answer. ``` SELECT newId() AS ColId, Col1, Col2, Col3 FROM table1 ``` The newId() will generate a new GUID for you that you can use as your automatically generated id column.
137,837
<p>Does your software handle newline characters from other systems?</p> <pre><code>Linux/BSD linefeed ^J 10 x0A Windows/IBM return linefeed ^M^J 13 10 x0D x0A old Macs return ^M 13 x0D others? </code></pre> <p>For reasons of insanity, I am going with using the Linux version ...
[ { "answer_id": 137841, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 0, "selected": false, "text": "<p>I suspect you will find that most modern Windows programs (with the notable exception of Notepad) handle newline-only ...
2008/09/26
[ "https://Stackoverflow.com/questions/137837", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19737/" ]
Does your software handle newline characters from other systems? ``` Linux/BSD linefeed ^J 10 x0A Windows/IBM return linefeed ^M^J 13 10 x0D x0A old Macs return ^M 13 x0D others? ``` For reasons of insanity, I am going with using the Linux version of the newline character i...
As they say, be strict in what you write and liberal in what you read. Your application should be able to work properly reading both line endings. If you want to use linefeeds, and potentially upset Windows users, that's fine. But save for Notepad, most programs I play with seem to be happy with both methods. (And I...
137,872
<p>I am using the JQuery form plugin (<a href="http://malsup.com/jquery/form/" rel="noreferrer">http://malsup.com/jquery/form/</a>) to handle the ajax submission of a form. I also have JQuery.Validate (<a href="http://docs.jquery.com/Plugins/Validation" rel="noreferrer">http://docs.jquery.com/Plugins/Validation</a>) pl...
[ { "answer_id": 137881, "author": "billjamesdev", "author_id": 13824, "author_profile": "https://Stackoverflow.com/users/13824", "pm_score": 1, "selected": false, "text": "<p>Just as a first pass, I'm wondering why the line</p>\n\n<pre><code>$(\"form\").validate({\n</code></pre>\n\n<p>doe...
2008/09/26
[ "https://Stackoverflow.com/questions/137872", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4884/" ]
I am using the JQuery form plugin (<http://malsup.com/jquery/form/>) to handle the ajax submission of a form. I also have JQuery.Validate (<http://docs.jquery.com/Plugins/Validation>) plugged in for my client side validation. What I am seeing is that the validation fails when I expect it to however it does not stop th...
You need to add a callback function for use with the beforeSubmit event when initializing the ajaxForm(): ``` var options = { beforeSubmit: function() { return $('#searchForm').validate().form(); }, target: '#detailsView' }; ``` Now it knows to check the result of the validati...
137,911
<p>I want to add the link tags to redirect my web-site to my OpenID provider. These tags should go in the head element. What's the best way to add them in Plone?</p> <p>I understand that filling the head_slot is a way to do it, but that can only happen when you are adding a template to the page and that template is be...
[ { "answer_id": 139950, "author": "Nikki9696", "author_id": 456669, "author_profile": "https://Stackoverflow.com/users/456669", "pm_score": -1, "selected": false, "text": "<p>Plone documentation on supporting OpenID can be found here.</p>\n\n<p><a href=\"http://plone.org/documentation/how...
2008/09/26
[ "https://Stackoverflow.com/questions/137911", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6068/" ]
I want to add the link tags to redirect my web-site to my OpenID provider. These tags should go in the head element. What's the best way to add them in Plone? I understand that filling the head\_slot is a way to do it, but that can only happen when you are adding a template to the page and that template is being rende...
I couldn't understand how to fill a slot without a product or anything. I understand that you can fill a slot from a template, but if Plone is not picking up that template, then the *filling code* would never be run. I ended up modifying main\_template and putting my code directly in the . This is bad because different...
137,935
<p>In Vim editor I opted <code>]I</code> on a function (in C++ code). This presented a list, which says <em>'Press ENTER or type command to continue'</em>.</p> <p>Now to jump to an occurrence say 6, I type <code>6</code> - but this is not working.</p> <p>What commands can I type in such a case, and how do I jump to ...
[ { "answer_id": 137942, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 3, "selected": true, "text": "<p>It should present you a list like:</p>\n\n<pre><code>1: 345 my_func (int var)\n2: 4523 my_func (int var)\n3: 1003...
2008/09/26
[ "https://Stackoverflow.com/questions/137935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14803/" ]
In Vim editor I opted `]I` on a function (in C++ code). This presented a list, which says *'Press ENTER or type command to continue'*. Now to jump to an occurrence say 6, I type `6` - but this is not working. What commands can I type in such a case, and how do I jump to Nth occurrence from this list? **Update:** A...
It should present you a list like: ``` 1: 345 my_func (int var) 2: 4523 my_func (int var) 3: 10032 my_func (3); ``` The second column is line numbers. Type :345 to jump to line 345.
137,951
<p>I have an ASP.NET Datagrid with several text boxes and drop down boxes inside it. I want to read all the values in the grid using a JavaScript function. How do i go about it?</p>
[ { "answer_id": 137993, "author": "Rodrick Chapman", "author_id": 3927, "author_profile": "https://Stackoverflow.com/users/3927", "pm_score": 2, "selected": false, "text": "<p>Easily done with jQuery. I don't recall what kind of markup the Datagrid creates but basically something like thi...
2008/09/26
[ "https://Stackoverflow.com/questions/137951", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have an ASP.NET Datagrid with several text boxes and drop down boxes inside it. I want to read all the values in the grid using a JavaScript function. How do i go about it?
And here's an example using Microsoft AJAX framework: ``` var txts = $get('client_id_of_datagrid').getElementsByTagName('input'); var ddls = $get('client_id_of_datagrid').getElementsByTagName('select'); for(var i=0;i<txts.length;i++){ if(txts[i].type==='text'){ /* do stuff */ } } for(var i=0;i<ddls.length;i+...
137,952
<p>I decide to learn more about vim and its syntax highlighting. Using examples for others, I am creating my own syntax file for Markdown. I have seen <a href="http://www.vim.org/scripts/script.php?script_id=1242" rel="noreferrer">mkd.vim</a> and it has this problem too. My issue is between list items and code block hi...
[ { "answer_id": 138186, "author": "hcs42", "author_id": 17916, "author_profile": "https://Stackoverflow.com/users/17916", "pm_score": 4, "selected": true, "text": "<p>Just make sure that the definition of mkdListItem is after the definition of mkdCodeBlock, like this:</p>\n\n<pre><code>sy...
2008/09/26
[ "https://Stackoverflow.com/questions/137952", "https://Stackoverflow.com", "https://Stackoverflow.com/users/873/" ]
I decide to learn more about vim and its syntax highlighting. Using examples for others, I am creating my own syntax file for Markdown. I have seen [mkd.vim](http://www.vim.org/scripts/script.php?script_id=1242) and it has this problem too. My issue is between list items and code block highlighting. Code Block [defini...
Just make sure that the definition of mkdListItem is after the definition of mkdCodeBlock, like this: ``` syn match mkdCodeBlock /\(\s\{4,}\|\t\{1,}\).*\n/ contained nextgroup=mkdCodeBlock hi link mkdCodeBlock comment syn region mkdListItem start=/\s*[-*+]\s\+/ matchgroup=pdcListText end=".*" contained nextgrou...
137,998
<p>I'm a newbie to pgsql. I have few questionss on it:</p> <p>1) I know it is possible to access columns by <code>&lt;schema&gt;.&lt;table_name&gt;</code>, but when I try to access columns like <code>&lt;db_name&gt;.&lt;schema&gt;.&lt;table_name&gt;</code> it throwing error like</p> <pre><code>Cross-database referenc...
[ { "answer_id": 138022, "author": "Michael Ratanapintha", "author_id": 1879, "author_profile": "https://Stackoverflow.com/users/1879", "pm_score": 0, "selected": false, "text": "<p>1: A workaround is to open a connection to the other database, and (if using psql(1)) set that as your curre...
2008/09/26
[ "https://Stackoverflow.com/questions/137998", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22554/" ]
I'm a newbie to pgsql. I have few questionss on it: 1) I know it is possible to access columns by `<schema>.<table_name>`, but when I try to access columns like `<db_name>.<schema>.<table_name>` it throwing error like ``` Cross-database references are not implemented ``` How do I implement it? 2) We have 10+ table...
1. Cross Database exists in PostGreSQL for years now. You must prefix the name of the database by the database name (and, of course, have the right to query on it). You'll come with something like this: SELECT alias\_1.col1, alias\_2.col3 FROM table\_1 as alias\_1, database\_b.table\_2 as alias\_2 WHERE ... If your d...
138,000
<p>When I try to send an HTTP GET request through XMLHttpRequest it works on non-secure HTTP.</p> <p>But when sent over HTTPS, different browsers gave different results:</p> <p>On Firefox 3.0.2: - The GET request doesn't reach the web server.</p> <p>On IE 7: - The GET request reached the web server.</p> <p>Does thi...
[ { "answer_id": 138011, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 0, "selected": false, "text": "<p>By any chance, are you requesting a non-HTTPS URL in an HTTPS page? Do any messages appear in the error log/console...
2008/09/26
[ "https://Stackoverflow.com/questions/138000", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16139/" ]
When I try to send an HTTP GET request through XMLHttpRequest it works on non-secure HTTP. But when sent over HTTPS, different browsers gave different results: On Firefox 3.0.2: - The GET request doesn't reach the web server. On IE 7: - The GET request reached the web server. Does this have something to do with Fir...
Try placing your closure after the open: ``` // send HTTP GET request try { xmlHttp.open("GET", "/[relative path to request]", true); } catch (e) { alert('Error sending HTTP GET request!'); return false; } // we won't be handling any HTTP response xmlHttp.onreadystatechange=function() { // do nothing.....
138,029
<p>After a bind a method to an event of a Tkinter element is there a way to get the method back?</p> <pre><code>&gt;&gt;&gt; root = Tkinter.Tk() &gt;&gt;&gt; frame = Tkinter.Frame(root, width=100, height=100) &gt;&gt;&gt; frame.bind('&lt;Button-1&gt;', lambda e: pprint('Click')) # function needed &gt;&gt;&gt; frame.pa...
[ { "answer_id": 138039, "author": "Dan Lenski", "author_id": 20789, "author_profile": "https://Stackoverflow.com/users/20789", "pm_score": 0, "selected": false, "text": "<p>Doesn't appear to be... why not just save it yourself if you're going to need it, or use a non-anonymous function?</...
2008/09/26
[ "https://Stackoverflow.com/questions/138029", "https://Stackoverflow.com", "https://Stackoverflow.com/users/680/" ]
After a bind a method to an event of a Tkinter element is there a way to get the method back? ``` >>> root = Tkinter.Tk() >>> frame = Tkinter.Frame(root, width=100, height=100) >>> frame.bind('<Button-1>', lambda e: pprint('Click')) # function needed >>> frame.pack() >>> bound_event_method = frame.??? ```
The associated call to do that for the tk C API would be [Get\_GetCommandInfo](http://linux.about.com/library/cmd/blcmdl3_Tcl_GetCommandInfo.htm) which > > places information about the command > in the Tcl\_CmdInfo structure pointed > to by infoPtr > > > However this function is not used anywhere in [\_tkinter....
138,040
<p>I have to create a dialog based application, instead of old CFormView type of design. But CDialog produces fixed-size dialogs. How can I create dialog based applications with resizable dialogs?</p>
[ { "answer_id": 138052, "author": "user22044", "author_id": 22044, "author_profile": "https://Stackoverflow.com/users/22044", "pm_score": 2, "selected": false, "text": "<p>There is no easy way to do this. Basically, you will need to dynamically layout controls when the window size is chan...
2008/09/26
[ "https://Stackoverflow.com/questions/138040", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have to create a dialog based application, instead of old CFormView type of design. But CDialog produces fixed-size dialogs. How can I create dialog based applications with resizable dialogs?
In the RC resource file if the dialog has this style similar to this it will be fixed size: ``` IDD_DIALOG_DIALOG DIALOGEX 0, 0, 320, 201 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU ``` If the dialog has this style it will be sizeable: ``` IDD_DIALOG_DIALOG DIALOGEX 0, 0, 320, 201 STYLE WS_POPUP | WS_V...
138,043
<p>I want to create a new net.tcp://localhost:x/Service endpoint for a WCF service call, with a dynamically assigned new open TCP port.</p> <p>I know that TcpClient will assign a new client side port when I open a connection to a given server.</p> <p>Is there a simple way to find the next open TCP port in .NET?</p> ...
[ { "answer_id": 138044, "author": "Jerub", "author_id": 14648, "author_profile": "https://Stackoverflow.com/users/14648", "pm_score": 5, "selected": false, "text": "<p>Use a port number of 0. The TCP stack will allocate the next free one.</p>\n" }, { "answer_id": 138220, "auth...
2008/09/26
[ "https://Stackoverflow.com/questions/138043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4829/" ]
I want to create a new net.tcp://localhost:x/Service endpoint for a WCF service call, with a dynamically assigned new open TCP port. I know that TcpClient will assign a new client side port when I open a connection to a given server. Is there a simple way to find the next open TCP port in .NET? I need the actual num...
Here is what I was looking for: ``` static int FreeTcpPort() { TcpListener l = new TcpListener(IPAddress.Loopback, 0); l.Start(); int port = ((IPEndPoint)l.LocalEndpoint).Port; l.Stop(); return port; } ```
138,045
<p>Is there something like <a href="http://effbot.org/zone/python-getattr.htm" rel="noreferrer">Python's getattr()</a> in C#? I would like to create a window by reading a list which contains the names of controls to put on the window.</p>
[ { "answer_id": 138053, "author": "Eric Schoonover", "author_id": 3957, "author_profile": "https://Stackoverflow.com/users/3957", "pm_score": 3, "selected": false, "text": "<p>Use reflection for this.</p>\n\n<p><a href=\"http://msdn.microsoft.com/en-us/library/system.type.getproperty.aspx...
2008/09/26
[ "https://Stackoverflow.com/questions/138045", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22562/" ]
Is there something like [Python's getattr()](http://effbot.org/zone/python-getattr.htm) in C#? I would like to create a window by reading a list which contains the names of controls to put on the window.
There is also [Type.InvokeMember](http://msdn.microsoft.com/en-us/library/66btctbe.aspx). ``` public static class ReflectionExt { public static object GetAttr(this object obj, string name) { Type type = obj.GetType(); BindingFlags flags = BindingFlags.Instance | ...
138,056
<p>In other words, a block of code like this:</p> <pre><code>(setq initial-major-mode (lambda () (text-mode) (font-lock-mode) )) </code></pre> <p>... would come out looking like something like this:</p> <p><img src="https://i.stack.imgur.com/kiaIG.gif" alt="alt text"></p> <p>If something like this alr...
[ { "answer_id": 138357, "author": "dsm", "author_id": 7780, "author_profile": "https://Stackoverflow.com/users/7780", "pm_score": 5, "selected": true, "text": "<p>I think you are looking for something like <a href=\"http://www.foldr.org/~michaelw/emacs/mwe-color-box.el\" rel=\"noreferrer\...
2008/09/26
[ "https://Stackoverflow.com/questions/138056", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7598/" ]
In other words, a block of code like this: ``` (setq initial-major-mode (lambda () (text-mode) (font-lock-mode) )) ``` ... would come out looking like something like this: ![alt text](https://i.stack.imgur.com/kiaIG.gif) If something like this already exists, what is it? And if it doesn't exist, how ...
I think you are looking for something like [mwe-color-box.el](http://www.foldr.org/~michaelw/emacs/mwe-color-box.el)
138,071
<p>The questions says everything, take this example code: </p> <pre><code>&lt;ul id="css-id"&gt; &lt;li&gt; &lt;something:CustomControl ID="SomeThingElse" runat="server" /&gt; &lt;something:OtherCustomControl runat="server" /&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p>Now if an error gets thrown som...
[ { "answer_id": 138082, "author": "Drejc", "author_id": 6482, "author_profile": "https://Stackoverflow.com/users/6482", "pm_score": 4, "selected": true, "text": "<p>You can catch all exception not handled elswhere in the Global.asax page / class. \nLook at:</p>\n\n<pre><code>protected voi...
2008/09/26
[ "https://Stackoverflow.com/questions/138071", "https://Stackoverflow.com", "https://Stackoverflow.com/users/452521/" ]
The questions says everything, take this example code: ``` <ul id="css-id"> <li> <something:CustomControl ID="SomeThingElse" runat="server" /> <something:OtherCustomControl runat="server" /> </li> </ul> ``` Now if an error gets thrown somewhere inside these controlls (that are located in a master pa...
You can catch all exception not handled elswhere in the Global.asax page / class. Look at: ``` protected void Application_Error(Object sender, EventArgs e) ``` method.
138,073
<p><strong>Scenario:</strong> C# apps uses SQL2000. It excecute 3 stored procs within a try catch in the app. In the catch the error is suppressed. Due to some legalities, the c# code cannot be changed and implemented. </p> <p><strong>Q:</strong> How do I trap the actual SQL error in the stored proc into a log file or...
[ { "answer_id": 138111, "author": "Matt Lacey", "author_id": 1755, "author_profile": "https://Stackoverflow.com/users/1755", "pm_score": 2, "selected": false, "text": "<p>Haven't got an example to hand, but look at using</p>\n\n<pre><code>RAISERROR ... WITH LOG\n</code></pre>\n\n<p>see: <...
2008/09/26
[ "https://Stackoverflow.com/questions/138073", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
**Scenario:** C# apps uses SQL2000. It excecute 3 stored procs within a try catch in the app. In the catch the error is suppressed. Due to some legalities, the c# code cannot be changed and implemented. **Q:** How do I trap the actual SQL error in the stored proc into a log file or other table? @@Error returns an err...
`@@ERROR` is reset to 0 when you check it. Why? Because it reflects the status of the last statement executed. ``` IF @@ERROR <> 0 ... ``` is a statement, and that statement succeeds, causing `@@ERROR` to be set to 0. The proper way to examine and operate on `@@ERROR` values is as follows: ``` DECLARE @ErrorCode I...
138,096
<p>I have a Window where I have put a Frame. I would like to add a Page to the Frame when I click a button that is also on the Window but not in the Frame. There are several buttons in the Window and each click on a button should load a different Page in the Frame.</p> <p>Since I'm a total newbie on this WPF stuff it'...
[ { "answer_id": 138315, "author": "Joachim Kerschbaumer", "author_id": 20227, "author_profile": "https://Stackoverflow.com/users/20227", "pm_score": 5, "selected": true, "text": "<p>the Frame class exposes a method named \"Navigate\" that takes the content you want to show in your frame a...
2008/09/26
[ "https://Stackoverflow.com/questions/138096", "https://Stackoverflow.com", "https://Stackoverflow.com/users/143/" ]
I have a Window where I have put a Frame. I would like to add a Page to the Frame when I click a button that is also on the Window but not in the Frame. There are several buttons in the Window and each click on a button should load a different Page in the Frame. Since I'm a total newbie on this WPF stuff it's quite po...
the Frame class exposes a method named "Navigate" that takes the content you want to show in your frame as parameter. try calling ``` myFrame.Navigate(myPageObject); ``` this should work
138,097
<p>I need to find the PID of the current running process on a Linux platform (it can be a system dependent solution). Java does not support getting the process ID, and JRuby currently has a bug with the Ruby method, Process.pid.</p> <p>Is there another way to obtain the PID?</p>
[ { "answer_id": 138098, "author": "Mike Stone", "author_id": 122, "author_profile": "https://Stackoverflow.com/users/122", "pm_score": 6, "selected": true, "text": "<p>If you have <a href=\"http://en.wikipedia.org/wiki/Procfs\" rel=\"nofollow noreferrer\">procfs</a> installed, you can fin...
2008/09/26
[ "https://Stackoverflow.com/questions/138097", "https://Stackoverflow.com", "https://Stackoverflow.com/users/122/" ]
I need to find the PID of the current running process on a Linux platform (it can be a system dependent solution). Java does not support getting the process ID, and JRuby currently has a bug with the Ruby method, Process.pid. Is there another way to obtain the PID?
If you have [procfs](http://en.wikipedia.org/wiki/Procfs) installed, you can find the process id via the /proc/self symlink, which points to a directory whose name is the pid (there are also files here with other pertinent information, including the PID, but the directory is all you need in this case). Thus, with Java...
138,099
<p>GWT's serializer has limited <code>java.io.Serializable</code> support, but for security reasons there is a whitelist of types it supports. The documentation I've found, for example <a href="http://www.gwtproject.org/doc/latest/FAQ_Server.html#Does_the_GWT_RPC_system_support_the_use_of_java.io.Serializable" rel="no...
[ { "answer_id": 138965, "author": "pfranza", "author_id": 22221, "author_profile": "https://Stackoverflow.com/users/22221", "pm_score": 3, "selected": false, "text": "<p>The whitelist is generated by the GWT compiler and contains all the entries that are designated by the IsSerializable m...
2008/09/26
[ "https://Stackoverflow.com/questions/138099", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3562/" ]
GWT's serializer has limited `java.io.Serializable` support, but for security reasons there is a whitelist of types it supports. The documentation I've found, for example [this FAQ entry](http://www.gwtproject.org/doc/latest/FAQ_Server.html#Does_the_GWT_RPC_system_support_the_use_of_java.io.Serializable) says that any ...
Any specific types that you include in your service interface and any types that they reference will be automatically whitelisted, as long as they implement java.io.Serializable, eg: ``` public String getStringForDates(ArrayList<java.util.Date> dates); ``` Will result in ArrayList and Date both being included on the...
138,117
<p>how to send rich text message in system.net.mail need code for send a mail as html</p>
[ { "answer_id": 138128, "author": "Vincent McNabb", "author_id": 16299, "author_profile": "https://Stackoverflow.com/users/16299", "pm_score": 2, "selected": false, "text": "<pre><code>System.Net.Mail.MailMessage mm = new System.Net.Mail.MailMessage();\nmm.Body = \"&lt;html&gt;...&lt;/htm...
2008/09/26
[ "https://Stackoverflow.com/questions/138117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
how to send rich text message in system.net.mail need code for send a mail as html
``` //create the mail message MailMessage mail = new MailMessage(); //set the addresses mail.From = new MailAddress("me@mycompany.com"); mail.To.Add("you@yourcompany.com"); //set the content mail.Subject = "This is an email"; mail.Body = "<b>This is bold</b> <font color=#336699>This is blue</font>"; mail.IsBo...
138,122
<p>I'd like to be able to create a large (say 20,000 x 20,000) pixel bitmap in a C++ MFC application, using a CDC derived class to write to the bitmap. I've tried using memory DCs as described in the MSDN docs, but these appear to be restricted to sizes compatible with the current display driver.</p> <p>I'm currently...
[ { "answer_id": 138126, "author": "Rob", "author_id": 9236, "author_profile": "https://Stackoverflow.com/users/9236", "pm_score": 1, "selected": false, "text": "<p>This is unusual as I often created a DC based on the screen that will be used for a bitmap image that is much larger than the...
2008/09/26
[ "https://Stackoverflow.com/questions/138122", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22564/" ]
I'd like to be able to create a large (say 20,000 x 20,000) pixel bitmap in a C++ MFC application, using a CDC derived class to write to the bitmap. I've tried using memory DCs as described in the MSDN docs, but these appear to be restricted to sizes compatible with the current display driver. I'm currently using a bi...
CDC and CBitmap appears to only support device dependant bitmaps, you might have more luck creating your bitmap with [::CreateDIBSection](http://msdn.microsoft.com/en-us/library/ms532292(VS.85).aspx), then attaching a CBitmap to that. The raw GDI interfaces are a little hoary, unfortunately. You probably won't have mu...
138,132
<p><strong>Here's the situation</strong>: I'm trying my hand at some MySpace page customisations. If you've <a href="https://stackoverflow.com/questions/116610/myspace-dom">ever tried</a> [stackoverflow], I'm sure you understand how frustrating it can be.<br> Basically it can be all customised via CSS, within a certain...
[ { "answer_id": 138145, "author": "skaffman", "author_id": 21234, "author_profile": "https://Stackoverflow.com/users/21234", "pm_score": 1, "selected": false, "text": "<p>Have you tried the various values for the \"overflow\" css property? I think that may do what you need in some permut...
2008/09/26
[ "https://Stackoverflow.com/questions/138132", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6340/" ]
**Here's the situation**: I'm trying my hand at some MySpace page customisations. If you've [ever tried](https://stackoverflow.com/questions/116610/myspace-dom) [stackoverflow], I'm sure you understand how frustrating it can be. Basically it can be all customised via CSS, within a certain set of rules (e.g. the '#' ...
Have you tried the various values for the "overflow" css property? I think that may do what you need in some permutation.
138,133
<p>Is there a standard framework (maybe part of Enterprise Library... or .NET itself) that allows you to do common parameter validation in method attributes?</p>
[ { "answer_id": 138152, "author": "Fredrik Kalseth", "author_id": 1710, "author_profile": "https://Stackoverflow.com/users/1710", "pm_score": 1, "selected": false, "text": "<p><a href=\"http://www.codeplex.com/aspnet/Wiki/View.aspx?title=Dynamic%20Data&amp;referringTitle=Home\" rel=\"nofo...
2008/09/26
[ "https://Stackoverflow.com/questions/138133", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3957/" ]
Is there a standard framework (maybe part of Enterprise Library... or .NET itself) that allows you to do common parameter validation in method attributes?
[Microsoft Code Contracts](http://msdn.microsoft.com/en-us/devlabs/dd491992.aspx), which are part of .NET Framework since 4.0 CTP and are available for earlier .NET Framework versions as a stand-alone package, allow to specify coding assumptions. This includes specifying pre-conditions which can verify parameters. An ...
138,144
<p>What essential things (functions, aliases, start up scripts) do you have in your profile?</p>
[ { "answer_id": 138224, "author": "Ed Guiness", "author_id": 4200, "author_profile": "https://Stackoverflow.com/users/4200", "pm_score": 2, "selected": false, "text": "<pre><code>############################################################################## \n# Get an XPath Navigator obje...
2008/09/26
[ "https://Stackoverflow.com/questions/138144", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20911/" ]
What essential things (functions, aliases, start up scripts) do you have in your profile?
I often find myself needing needing some basic agregates to count/sum some things., I've defined these functions and use them often, they work really nicely at the end of a pipeline : ``` # # useful agregate # function count { BEGIN { $x = 0 } PROCESS { $x += 1 } END { $x } } function product { BEGIN ...
138,162
<p>I want to setup my local development machine so that any requests for <code>*.local</code> are redirected to <code>localhost</code>. The idea is that as I develop multiple sites, I can just add vhosts to Apache called <code>site1.local</code>, <code>site2.local</code> etc, and have them all resolve to <code>localhos...
[ { "answer_id": 138181, "author": "Biri", "author_id": 968, "author_profile": "https://Stackoverflow.com/users/968", "pm_score": 5, "selected": false, "text": "<p>I don't think that it is possible.</p>\n\n<p>You anyway have to modify the apache virtualroot entries every time you add a new...
2008/09/26
[ "https://Stackoverflow.com/questions/138162", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20851/" ]
I want to setup my local development machine so that any requests for `*.local` are redirected to `localhost`. The idea is that as I develop multiple sites, I can just add vhosts to Apache called `site1.local`, `site2.local` etc, and have them all resolve to `localhost`, while Apache serves a different site accordingly...
Acrylic DNS Proxy (free, open source) does the job. It creates a proxy DNS server (on your own computer) with its own hosts file. The hosts file accepts wildcards. **Download from the offical website** <http://mayakron.altervista.org/support/browse.php?path=Acrylic&name=Home> Configuring Acrylic DNS Proxy ----------...
138,194
<p>In the Flex framework a custom preloader can be used while the site is loading.</p> <p>In the <a href="http://livedocs.adobe.com/flex/3/html/help.html?content=app_container_4.html" rel="nofollow noreferrer">Adobe docs</a> it specifies that '<strong>the progress bar [preloader] is displayed if less than half of the ...
[ { "answer_id": 138247, "author": "Simon Buchan", "author_id": 20135, "author_profile": "https://Stackoverflow.com/users/20135", "pm_score": 1, "selected": false, "text": "<p>This is in mx.preloaders::DownloadProgressBar.as, line 1205 in the <code>showDisplayForDownloading</code> function...
2008/09/26
[ "https://Stackoverflow.com/questions/138194", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16940/" ]
In the Flex framework a custom preloader can be used while the site is loading. In the [Adobe docs](http://livedocs.adobe.com/flex/3/html/help.html?content=app_container_4.html) it specifies that '**the progress bar [preloader] is displayed if less than half of the application is downloaded after 700 milliseconds of d...
You should just extend the DownloadProgressBar, try the following code. i've used this before and I've found jesse warden site [click here](http://jessewarden.com/2007/07/making-a-cooler-preloader-in-flex-part-1-of-3.html) usful for info on this (where I found out about it and this is a cut down version of his code) `...
138,203
<p>Is it possible for a stand alone executable to generate a report and output it as PDF (or one of the other export options available from the report viewer) without displaying the ReportViewer control? </p> <p>The report definition should be embedded in the executable and should not use the Reporting Services web se...
[ { "answer_id": 138222, "author": "Biri", "author_id": 968, "author_profile": "https://Stackoverflow.com/users/968", "pm_score": 2, "selected": false, "text": "<p>You don't have to show the control itself.</p>\n\n<pre><code>ReportViewer rv = new ReportViewer();\nrv.LocalReport.ReportPath ...
2008/09/26
[ "https://Stackoverflow.com/questions/138203", "https://Stackoverflow.com", "https://Stackoverflow.com/users/966/" ]
Is it possible for a stand alone executable to generate a report and output it as PDF (or one of the other export options available from the report viewer) without displaying the ReportViewer control? The report definition should be embedded in the executable and should not use the Reporting Services web service.
Actually you don't need a ReportViewer at all, you can directly instantiate and use a LocalReport: ``` LocalReport report = new LocalReport(); report.ReportPath = "templatepath"; // or use file from resource with report.ReportEmbeddedResource // add parameters, datasource, etc. Warning[] warnings; string[] streamids...
138,245
<p>currently I'm dealing with a video processing software in which the picture data (8bit signed and unsigned) is stored in arrays of 16-aligned integers allocated as</p> <pre><code>__declspec(align(16)) int *pData = (__declspec(align(16)) int *)_mm_malloc(width*height*sizeof(int),16); </code></pre> <p>Generally, wou...
[ { "answer_id": 138297, "author": "akiva", "author_id": 65724, "author_profile": "https://Stackoverflow.com/users/65724", "pm_score": -1, "selected": false, "text": "<p>on the contrary, packing and unpacking is CPU commands expensive.</p>\n\n<p>if you want to make a lot of a random pixel ...
2008/09/26
[ "https://Stackoverflow.com/questions/138245", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
currently I'm dealing with a video processing software in which the picture data (8bit signed and unsigned) is stored in arrays of 16-aligned integers allocated as ``` __declspec(align(16)) int *pData = (__declspec(align(16)) int *)_mm_malloc(width*height*sizeof(int),16); ``` Generally, wouldn't it enable faster rea...
If you're planning to use SSE, storing the data in its native size (8-bit) is almost certainly a better choice, since loads of operations can be done without unpacking, and even if you need to unpack for pmaddwd or other similar instructions, its still faster because you have to load less data. Even in scalar code, lo...
138,250
<p>If I open an image with <code>open("image.jpg")</code>, how can I get the RGB values of a pixel assuming I have the coordinates of the pixel?</p> <p>Then, how can I do the reverse of this? Starting with a blank graphic, 'write' a pixel with a certain RGB value?</p> <p>I would prefer if I didn't have to download an...
[ { "answer_id": 138254, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 2, "selected": false, "text": "<p>Image manipulation is a complex topic, and it's best if you <em>do</em> use a library. I can recommend <a href=\"http:...
2008/09/26
[ "https://Stackoverflow.com/questions/138250", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2592/" ]
If I open an image with `open("image.jpg")`, how can I get the RGB values of a pixel assuming I have the coordinates of the pixel? Then, how can I do the reverse of this? Starting with a blank graphic, 'write' a pixel with a certain RGB value? I would prefer if I didn't have to download any additional libraries.
It's probably best to use the [Python Image Library](http://www.pythonware.com/products/pil/) to do this which I'm afraid is a separate download. The easiest way to do what you want is via the [load() method on the Image object](http://effbot.org/imagingbook/image.htm) which returns a pixel access object which you can...
138,251
<p>I am trying to access a Windows Media Player library from ASP.NET.</p> <p>The following code:</p> <p>WMPLib.WindowsMediaPlayer mplayer = new WMPLib.WindowsMediaPlayer();</p> <p>WMPLib.IWMPStringCollection list = mplayer.mediaCollection.getAttributeStringCollection("artist", "audio");</p> <p>Returns an non-empty ...
[ { "answer_id": 140939, "author": "Dylan Beattie", "author_id": 5017, "author_profile": "https://Stackoverflow.com/users/5017", "pm_score": 1, "selected": false, "text": "<p>Have you tried configuration via web.config in ASP.NET? When you're running in the VS2005 debugger, you're (probabl...
2008/09/26
[ "https://Stackoverflow.com/questions/138251", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22590/" ]
I am trying to access a Windows Media Player library from ASP.NET. The following code: WMPLib.WindowsMediaPlayer mplayer = new WMPLib.WindowsMediaPlayer(); WMPLib.IWMPStringCollection list = mplayer.mediaCollection.getAttributeStringCollection("artist", "audio"); Returns an non-empty list when run using the VS2005 ...
Have you tried configuration via web.config in ASP.NET? When you're running in the VS2005 debugger, you're (probably) running code as yourself, but when under IIS you'll be running it as IUSR\_*machinename* or another low-permission system account. Try adding something like this to your web.config file: ``` <system.w...
138,261
<p>I am having a table Table1 with columns id1, id2, id3 all the columns are nullable</p> <p>I may enter null or value to all columns in rows.</p> <p>My question is I need to select the rows whose all the column values should not be null.</p> <p>Thanks</p> <hr> <p>There are totally around 300 columns in the table....
[ { "answer_id": 138274, "author": "Georgi", "author_id": 13209, "author_profile": "https://Stackoverflow.com/users/13209", "pm_score": 2, "selected": false, "text": "<p>The answer to use a \"function\" to test the null-values is correct. The syntax depends on the database. If ISNULL() doe...
2008/09/26
[ "https://Stackoverflow.com/questions/138261", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22162/" ]
I am having a table Table1 with columns id1, id2, id3 all the columns are nullable I may enter null or value to all columns in rows. My question is I need to select the rows whose all the column values should not be null. Thanks --- There are totally around 300 columns in the table. I can't do the `is null` proper...
You need to do this: ``` SELECT * FROM yourtable WHERE column1 IS NOT NULL AND column2 IS NOT NULL AND column3 IS NOT NULL AND .... ```
138,302
<p>When using SQLBulkCopy on a table with a GUID primary key and default newsequentialid()</p> <p>e.g</p> <pre><code>CREATE TABLE [dbo].[MyTable]( [MyPrimaryKey] [uniqueidentifier] NOT NULL CONSTRAINT [MyConstraint] DEFAULT (newsequentialid()), [Status] [int] NULL, [Priority] [int] NULL, CONSTRAINT [PK_MyTable] PRI...
[ { "answer_id": 139804, "author": "NotMe", "author_id": 2424, "author_profile": "https://Stackoverflow.com/users/2424", "pm_score": 0, "selected": false, "text": "<p>You're only options are to remove the MyPrimaryKey field from the data that is being loaded or to modify the table structur...
2008/09/26
[ "https://Stackoverflow.com/questions/138302", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
When using SQLBulkCopy on a table with a GUID primary key and default newsequentialid() e.g ``` CREATE TABLE [dbo].[MyTable]( [MyPrimaryKey] [uniqueidentifier] NOT NULL CONSTRAINT [MyConstraint] DEFAULT (newsequentialid()), [Status] [int] NULL, [Priority] [int] NULL, CONSTRAINT [PK_MyTable] PRIMARY KEY NONCLUSTERED...
You need to set up the column mappings. First call ``` sqlCopy.ColumnMappings.Clear(); ``` Then call ``` sqlBulkCopy.ColumnMappings.Add("Status", "Status"); sqlBulkCopy.ColumnMappings.Add("Priority", "Priority"); ``` This means the bulk copy will stop trying to insert into MyPrimaryKey column and will only insert...
138,309
<p>I have made a SVG image, or more like mini application, for viewing graphs of data. I want to include this in a HTML page, and call methods on the SVG image.</p> <p>Example:</p> <pre><code>&lt;object id="img" data="image.svg" width="500" height="300"/&gt; &lt;script&gt;document.getElementById("img").addData([1,23,...
[ { "answer_id": 138358, "author": "Staale", "author_id": 3355, "author_profile": "https://Stackoverflow.com/users/3355", "pm_score": 5, "selected": true, "text": "<p>Solution:</p>\n\n<p>in svg:</p>\n\n<pre><code>&lt;script&gt;document.method = function() {}&lt;/script&gt;\n</code></pre>\n...
2008/09/26
[ "https://Stackoverflow.com/questions/138309", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3355/" ]
I have made a SVG image, or more like mini application, for viewing graphs of data. I want to include this in a HTML page, and call methods on the SVG image. Example: ``` <object id="img" data="image.svg" width="500" height="300"/> <script>document.getElementById("img").addData([1,23,4]);</script> ``` Is it at all ...
Solution: in svg: ``` <script>document.method = function() {}</script> ``` in html (using prototype to add event listeners): ``` <script>$("img").observe("load", function() {$("img").contentDocument.method()}); ``` You need to listen to the load event on the image. Once the image is loaded, you can use the `elem...
138,311
<p>The CSRF prevention built in to Rails is causing some problems for some automated load testing we are doing, and I want to turn it off for the duration of the process. How do I do this?</p>
[ { "answer_id": 138372, "author": "Patrick McKenzie", "author_id": 15046, "author_profile": "https://Stackoverflow.com/users/15046", "pm_score": 6, "selected": true, "text": "<p>I love simple questions with clear answers.</p>\n\n<pre><code>#I go in application.rb\nself.allow_forgery_prote...
2008/09/26
[ "https://Stackoverflow.com/questions/138311", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7473/" ]
The CSRF prevention built in to Rails is causing some problems for some automated load testing we are doing, and I want to turn it off for the duration of the process. How do I do this?
I love simple questions with clear answers. ``` #I go in application.rb self.allow_forgery_protection = false ``` If you want to do this for testing only you can move that into one of the environment files (obviously, you'll be touching `Application` then rather than `self`). You could also write something like: ``...
138,313
<p>I would like to create a page where all images which reside on my website are listed with title and alternative representation.</p> <p>I already wrote me a little program to find and load all HTML files, but now I am stuck at how to extract <code>src</code>, <code>title</code> and <code>alt</code> from this HTML:</...
[ { "answer_id": 138614, "author": "Stefan Gehrig", "author_id": 11354, "author_profile": "https://Stackoverflow.com/users/11354", "pm_score": 6, "selected": false, "text": "<p>Just to give a small example of using PHP's XML functionality for the task:</p>\n\n<pre><code>$doc=new DOMDocumen...
2008/09/26
[ "https://Stackoverflow.com/questions/138313", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7021/" ]
I would like to create a page where all images which reside on my website are listed with title and alternative representation. I already wrote me a little program to find and load all HTML files, but now I am stuck at how to extract `src`, `title` and `alt` from this HTML: ``` <img **src**="/image/fluffybunny.jpg" *...
EDIT : now that I know better ----------------------------- Using regexp to solve this kind of problem is [a bad idea](https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454) and will likely lead in unmaintainable and unreliable code. Better use an [HTML pars...
138,318
<p>here is my directory structure.</p> <p>/user/a /user/b /user/b</p> <p>inside folder a,b,c there is a file person.java (it is the Same file, just a one line modification.</p> <p>now, on my shell, im on my /user/ directory and i try to do </p> <pre><code> javac */person.java </code></pre> <p>the shell returns t...
[ { "answer_id": 138329, "author": "Horst Gutmann", "author_id": 22312, "author_profile": "https://Stackoverflow.com/users/22312", "pm_score": 4, "selected": true, "text": "<p>I think the problem here might be, that javac tries to compile everything in one go, which naturally results in du...
2008/09/26
[ "https://Stackoverflow.com/questions/138318", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17085/" ]
here is my directory structure. /user/a /user/b /user/b inside folder a,b,c there is a file person.java (it is the Same file, just a one line modification. now, on my shell, im on my /user/ directory and i try to do ``` javac */person.java ``` the shell returns the following error, person.java:14: duplicate ...
I think the problem here might be, that javac tries to compile everything in one go, which naturally results in duplicated class definitions. A simple way to resolve this would be `find . -name '*.java' -exec javac {} \;` **Edit:** Or to be more precise `find . -name 'person.java' -maxdepth 2 -exec javac {} \;`
138,321
<p>I unpacked a zip-file delivery into a clearcase view. Now I want to add the complete file tree to the repository. The GUI only provides an "Add to source control ..." for individual files/directories. Do you know how to recursively add the whole tree?</p> <p>(I'm on a Windows system, but have Cygwin installed.)</p>...
[ { "answer_id": 138325, "author": "prakash", "author_id": 123, "author_profile": "https://Stackoverflow.com/users/123", "pm_score": 2, "selected": false, "text": "<p>You have to use the commandline. The Context menu in Explorer doesnt do this recursively!</p>\n\n<pre><code>clearfsimport –...
2008/09/26
[ "https://Stackoverflow.com/questions/138321", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20668/" ]
I unpacked a zip-file delivery into a clearcase view. Now I want to add the complete file tree to the repository. The GUI only provides an "Add to source control ..." for individual files/directories. Do you know how to recursively add the whole tree? (I'm on a Windows system, but have Cygwin installed.)
I would rather go with the clearfsimport script, better equipped to import multiple times the same set of files, and automatically: * add new files, * make new version of existing files previously imported (but modified in the source set of files re-imported) * remove files already imported but no longer present in th...
138,353
<p>In wxPython, if I create a list of radio buttons and place the list initially, is it possible to change the contents in that list later?</p> <p>For example, I have a panel that uses a boxSizer to place the widgets initially. One of those widgets is a list of radio buttons (I have also tried a normal radiobox). I wo...
[ { "answer_id": 138479, "author": "Eli Bendersky", "author_id": 8206, "author_profile": "https://Stackoverflow.com/users/8206", "pm_score": 0, "selected": false, "text": "<p>Two possible solutions</p>\n\n<ol>\n<li>Rebuild the sizer with the radio widgets each time you have to make a chang...
2008/09/26
[ "https://Stackoverflow.com/questions/138353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18676/" ]
In wxPython, if I create a list of radio buttons and place the list initially, is it possible to change the contents in that list later? For example, I have a panel that uses a boxSizer to place the widgets initially. One of those widgets is a list of radio buttons (I have also tried a normal radiobox). I would like t...
To make new list elements appear in correct places, you have to re-layout the grid after adding new elements to it. For example, to add a few new items, you could call: ``` def addNewSkills(self, newSkillList): '''newSkillList is a list of skill names you want to add''' for skillName in newSkillList: n...
138,355
<p>I have a third party .NET Assembly and a large Java application. I need to call mothods provided by the .NET class library from the Java application. The assembly is not COM-enabled. I have searched the net and so far i have the following:</p> <p>C# code (cslib.cs):</p> <pre><code>using System; namespace CSLib { ...
[ { "answer_id": 138359, "author": "cruizer", "author_id": 6441, "author_profile": "https://Stackoverflow.com/users/6441", "pm_score": 2, "selected": false, "text": "<p>Have you looked at ikvm.NET, which allows calls between .NET and Java code?</p>\n" }, { "answer_id": 138763, ...
2008/09/26
[ "https://Stackoverflow.com/questions/138355", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22602/" ]
I have a third party .NET Assembly and a large Java application. I need to call mothods provided by the .NET class library from the Java application. The assembly is not COM-enabled. I have searched the net and so far i have the following: C# code (cslib.cs): ``` using System; namespace CSLib { public class CSCl...
OK, the mystery is solved. The JVM crash is caused by unhandled System.IO.FileNotFoundException. The exception is thrown because the .NET assembly is searched in the folder where the calling exe file resides. 1. The mscorlib.dll is in the Global Assembly Cache, so it works. 2. The CPP application exe is in the same...
138,371
<p>What are (if any)the implied assumptions or restrictions and the differences of designing like:</p> <p>A) this:</p> <pre><code>class SampleClass1 { IWorker workerA; IWorker workerB; void setWorkerA(IWorker w); void setWorkerB(IWorker w); WorkResult doWork(); } </code></pre> <p>B) versus this:...
[ { "answer_id": 138376, "author": "Richard Walton", "author_id": 15075, "author_profile": "https://Stackoverflow.com/users/15075", "pm_score": 0, "selected": false, "text": "<p>Another Option:</p>\n\n<p>IWorker class:</p>\n\n<p>static WorkResult doWork(Iworker a, Iworker b);</p>\n" }, ...
2008/09/26
[ "https://Stackoverflow.com/questions/138371", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11906/" ]
What are (if any)the implied assumptions or restrictions and the differences of designing like: A) this: ``` class SampleClass1 { IWorker workerA; IWorker workerB; void setWorkerA(IWorker w); void setWorkerB(IWorker w); WorkResult doWork(); } ``` B) versus this: ``` class SampleClass2 { Wo...
In option (A) you are creating what is known as a Function Object or Functor, this is a design pattern that is [well documented](http://en.wikipedia.org/wiki/Function_object). The two main advantages are: * The workers can be set by in one place and then the object used elsewhere * The object can retain state betwee...
138,374
<p>I'm attempting to do an AJAX call (via JQuery) that will initiate a fairly long process. I'd like the script to simply send a response indicating that the process has started, but JQuery won't return the response until the PHP script is done running.</p> <p>I've tried this with a "close" header (below), and also wi...
[ { "answer_id": 138409, "author": "paan", "author_id": 2976, "author_profile": "https://Stackoverflow.com/users/2976", "pm_score": 1, "selected": false, "text": "<p>You could try to do multithreading.</p>\n\n<p>you could whip up a script that makes a system call ( using <a href=\"http://m...
2008/09/26
[ "https://Stackoverflow.com/questions/138374", "https://Stackoverflow.com", "https://Stackoverflow.com/users/82944/" ]
I'm attempting to do an AJAX call (via JQuery) that will initiate a fairly long process. I'd like the script to simply send a response indicating that the process has started, but JQuery won't return the response until the PHP script is done running. I've tried this with a "close" header (below), and also with output ...
The following PHP manual page (incl. user-notes) suggests multiple instructions on how to close the TCP connection to the browser without ending the PHP script: * [Connection handling *Docs*](http://php.net/features.connection-handling) Supposedly it requires a bit more than sending a close header. --- OP then conf...
138,379
<p>What happens if I use <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb762181%28v=vs.85%29.aspx" rel="nofollow noreferrer">SHGetFolderPath</a> api call in a 32 bit system with CSIDL_PROGRAM_FILESx86 folder id instead of the CSIDL_PROGRAM_FILES id?</p> <p>Theoretically CSIDL_PROGRAM_FILESx86 should...
[ { "answer_id": 138473, "author": "Magnus Johansson", "author_id": 3584, "author_profile": "https://Stackoverflow.com/users/3584", "pm_score": 4, "selected": true, "text": "<p>The different scenarios are described in <a href=\"http://msdn.microsoft.com/en-us/library/bb762584(VS.85).aspx\"...
2008/09/26
[ "https://Stackoverflow.com/questions/138379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14587/" ]
What happens if I use [SHGetFolderPath](http://msdn.microsoft.com/en-us/library/windows/desktop/bb762181%28v=vs.85%29.aspx) api call in a 32 bit system with CSIDL\_PROGRAM\_FILESx86 folder id instead of the CSIDL\_PROGRAM\_FILES id? Theoretically CSIDL\_PROGRAM\_FILESx86 should map to `C:\program files (x86)` in a 64 ...
The different scenarios are described in [this article on MSDN](http://msdn.microsoft.com/en-us/library/bb762584(VS.85).aspx). Scroll down to remarks, "FOLDERID\_ProgramFiles" ``` The interpretation of certain KNOWNFOLDERID values depends on whether the folder is part of a 32-bit or 64-bit application and whether tha...
138,383
<p>Sometimes coloring a logfile or other gives a good overview when looking for <em>stuff</em> and <em>behaviors</em></p> <p>I just saw that grep have a coloring feature</p> <pre><code>grep -C 99999 --color &lt;regexp&gt; &lt;filename&gt; </code></pre> <p>What other methods are there?</p>
[ { "answer_id": 138390, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 5, "selected": true, "text": "<p>For searching source code, I use <a href=\"http://petdance.com/ack/\" rel=\"noreferrer\">ack</a>. It's got a lot of opt...
2008/09/26
[ "https://Stackoverflow.com/questions/138383", "https://Stackoverflow.com", "https://Stackoverflow.com/users/842/" ]
Sometimes coloring a logfile or other gives a good overview when looking for *stuff* and *behaviors* I just saw that grep have a coloring feature ``` grep -C 99999 --color <regexp> <filename> ``` What other methods are there?
For searching source code, I use [ack](http://petdance.com/ack/). It's got a lot of options that make sense for searching code (such as automatically ignoring SCM directories).
138,412
<p>I can't get my GridView to enable a user to sort a column of data when I'm using a custom SqlDataSource.</p> <p>I have a GridView in which the code in the ASP reference to it in the HTML is minimal:</p> <pre><code>&lt;asp:GridView id="grid" runat="server" AutoGenerateColumns="False" AllowSorting="True"&gt; &lt;/as...
[ { "answer_id": 138467, "author": "Biri", "author_id": 968, "author_profile": "https://Stackoverflow.com/users/968", "pm_score": 0, "selected": false, "text": "<p>I'm not sure about this one, but if you use a standard SqlDataSource and you click on a field to sort according to that field,...
2008/09/26
[ "https://Stackoverflow.com/questions/138412", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22185/" ]
I can't get my GridView to enable a user to sort a column of data when I'm using a custom SqlDataSource. I have a GridView in which the code in the ASP reference to it in the HTML is minimal: ``` <asp:GridView id="grid" runat="server" AutoGenerateColumns="False" AllowSorting="True"> </asp:GridView> ``` In the code-...
First you need to add an event: ``` <asp:GridView AllowSorting="True" OnSorting="gvName_Sorting" ... ``` Then that event looks like: ``` protected void gvName_Sorting( object sender, GridViewSortEventArgs e ) { ... //rebind gridview } ``` You basically have to get your data again. You're right that it l...
138,419
<p>While porting an application from SQL 2005 to SQL Server Compact Edition, I found that I need to port this command:</p> <pre><code>SELECT TOP 1 Id FROM tblJob WHERE Holder_Id IS NULL </code></pre> <p>But SQL Server Compact Edition doesn't support the <code>TOP</code> keyword. How can I port this command?</p>
[ { "answer_id": 138436, "author": "Jesper Blad Jensen", "author_id": 11559, "author_profile": "https://Stackoverflow.com/users/11559", "pm_score": 0, "selected": false, "text": "<p>Looks like it can't be done in compact. You have to read all the jobs, or make a SqlReader, and just read th...
2008/09/26
[ "https://Stackoverflow.com/questions/138419", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15136/" ]
While porting an application from SQL 2005 to SQL Server Compact Edition, I found that I need to port this command: ``` SELECT TOP 1 Id FROM tblJob WHERE Holder_Id IS NULL ``` But SQL Server Compact Edition doesn't support the `TOP` keyword. How can I port this command?
``` SELECT TOP(1) Id FROM tblJob WHERE Holder_Id IS NULL ``` Need the brackets as far as I know. reference: <http://technet.microsoft.com/en-us/library/bb686896.aspx> addition: likewise, only for version 3.5 onwards
138,422
<p>I have a HTML report, which needs to be printed landscape because of the many columns. It there a way to do this, without the user having to change the document settings?</p> <p>And what are the options amongst browsers.</p>
[ { "answer_id": 138456, "author": "yann.kmm", "author_id": 15780, "author_profile": "https://Stackoverflow.com/users/15780", "pm_score": 3, "selected": false, "text": "<p>You can also use the non-standard IE-only css attribute <a href=\"http://www.eskimo.com/~bloo/indexdot/css/properties/...
2008/09/26
[ "https://Stackoverflow.com/questions/138422", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56/" ]
I have a HTML report, which needs to be printed landscape because of the many columns. It there a way to do this, without the user having to change the document settings? And what are the options amongst browsers.
In your CSS you can set the @page property as shown below. ``` @media print{@page {size: landscape}} ``` The @page is part of [CSS 2.1 specification](http://www.w3.org/TR/CSS21/page.html#page-box) however this `size` is not as highlighted by the answer to the question [Is @Page { size:landscape} obsolete?](https://...
138,449
<p>Here's the problem:</p> <p>In C# I'm getting information from a legacy ACCESS database. .NET converts the content of the database (in the case of this problem a string) to Unicode before handing the content to me.</p> <p>How do I convert this Unicode string back to it's ASCII equivalent?</p> <p><hr> <strong>Edit<...
[ { "answer_id": 138462, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 0, "selected": false, "text": "<p>Hmm … I'm not sure which character you mean. The caret (“^”, CIRCUMFLEX ACCENT) has the same code in ASCII and Uni...
2008/09/26
[ "https://Stackoverflow.com/questions/138449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1830/" ]
Here's the problem: In C# I'm getting information from a legacy ACCESS database. .NET converts the content of the database (in the case of this problem a string) to Unicode before handing the content to me. How do I convert this Unicode string back to it's ASCII equivalent? --- **Edit** Unicode char 710 is indee...
Okay, let's elaborate. Both [csgero](https://stackoverflow.com/questions/138449/how-to-convert-a-unicode-character-to-its-extended-ascii-equivalent#138579) and [bzlm](https://stackoverflow.com/questions/138449/how-to-convert-a-unicode-character-to-its-extended-ascii-equivalent#138583) pointed in the right direction. B...
138,477
<p>Is it possible to send my own developed exceptions over Soap to a client using http.sys??</p>
[ { "answer_id": 303158, "author": "Zach", "author_id": 8720, "author_profile": "https://Stackoverflow.com/users/8720", "pm_score": 0, "selected": false, "text": "<p>Yes, you can throw your own exceptions. Any uncaught exception that does not derive from SoapException will be bottled up by...
2008/09/26
[ "https://Stackoverflow.com/questions/138477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Is it possible to send my own developed exceptions over Soap to a client using http.sys??
To the best of my knowledge unfortunately the answer is no. You cannot build your own custom exceptions on the server side and expect to use them on the client side through WSE. I can't give much technical background as to why (as in why this is not allowed by WSE), but I am sure about my answer because I tested this o...
138,493
<p>How does one handle a <code>DateTime</code> with a <code>NOT NULL</code>?</p> <p>I want to do something like this:</p> <pre><code>SELECT * FROM someTable WHERE thisDateTime IS NOT NULL </code></pre> <p>But how?</p>
[ { "answer_id": 138495, "author": "Johnno Nolan", "author_id": 1116, "author_profile": "https://Stackoverflow.com/users/1116", "pm_score": 6, "selected": true, "text": "<p>erm it does work? I've just tested it?</p>\n\n<pre><code>/****** Object: Table [dbo].[DateTest] Script Date: 09/2...
2008/09/26
[ "https://Stackoverflow.com/questions/138493", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14777/" ]
How does one handle a `DateTime` with a `NOT NULL`? I want to do something like this: ``` SELECT * FROM someTable WHERE thisDateTime IS NOT NULL ``` But how?
erm it does work? I've just tested it? ``` /****** Object: Table [dbo].[DateTest] Script Date: 09/26/2008 10:44:21 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[DateTest]( [Date1] [datetime] NULL, [Date2] [datetime] NOT NULL ) ON [PRIMARY] GO Insert into DateTest (Date1,Date...
138,496
<p>How would you go about producing reports by user selected date ranges in a rails app? What are the best date range pickers? </p> <p>edit in response to patrick : I am looking for a bit of both widget and active record advice but what I am really curious about is how to restfully display a date ranged list based on...
[ { "answer_id": 138810, "author": "Patrick McKenzie", "author_id": 15046, "author_profile": "https://Stackoverflow.com/users/15046", "pm_score": 6, "selected": true, "text": "<p>Are we asking an interface question here (i.e. you want a widget) or an ActiveRecord question?</p>\n\n<h1>Date ...
2008/09/26
[ "https://Stackoverflow.com/questions/138496", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6805/" ]
How would you go about producing reports by user selected date ranges in a rails app? What are the best date range pickers? edit in response to patrick : I am looking for a bit of both widget and active record advice but what I am really curious about is how to restfully display a date ranged list based on user selec...
Are we asking an interface question here (i.e. you want a widget) or an ActiveRecord question? Date Picking Widgets ==================== 1) **Default Rails Solution**: See `date_select` documentation [here](http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html). 2) **Use a plugin** : Why write code? ...
138,497
<p>How can I iterate over each file in a directory using a <code>for</code> loop?</p> <p>And how could I tell if a certain entry is a directory or if it's just a file?</p>
[ { "answer_id": 138513, "author": "Axeman", "author_id": 22108, "author_profile": "https://Stackoverflow.com/users/22108", "pm_score": 3, "selected": false, "text": "<pre><code>for %1 in (*.*) do echo %1\n</code></pre>\n\n<p>Try \"HELP FOR\" in cmd for a full guide</p>\n\n<p>This is the g...
2008/09/26
[ "https://Stackoverflow.com/questions/138497", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11234/" ]
How can I iterate over each file in a directory using a `for` loop? And how could I tell if a certain entry is a directory or if it's just a file?
This lists all the files (and only the files) in the current directory and its subdirectories recursively: ``` for /r %i in (*) do echo %i ``` Also if you run that command in a batch file you need to double the % signs. ``` for /r %%i in (*) do echo %%i ``` (thanks @agnul)
138,501
<p>I have mixed data i nvarchar column (words and numbers). Which is fastest way to sort data in this column in Numeric Order.</p> <p>Result example:</p> <ul> <li>1</li> <li>2</li> <li>3</li> <li>...</li> <li>10</li> <li>11</li> <li>...</li> <li>aaaa</li> <li>aaab</li> <li>b</li> <li>ba</li> <li>ba</li> <li>...</li> ...
[ { "answer_id": 138507, "author": "Dan", "author_id": 17121, "author_profile": "https://Stackoverflow.com/users/17121", "pm_score": -1, "selected": false, "text": "<p>Cast it. </p>\n\n<pre><code>SELECT * FROM foo ORDER BY CAST(somecolumn AS int);\n</code></pre>\n\n<p>Been a while since I'...
2008/09/26
[ "https://Stackoverflow.com/questions/138501", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17465/" ]
I have mixed data i nvarchar column (words and numbers). Which is fastest way to sort data in this column in Numeric Order. Result example: * 1 * 2 * 3 * ... * 10 * 11 * ... * aaaa * aaab * b * ba * ba * ...
Use this: ``` ORDER BY CASE WHEN ISNUMERIC(column) = 1 THEN 0 ELSE 1 END, CASE WHEN ISNUMERIC(column) = 1 THEN CAST(column AS INT) ELSE 0 END, column ``` This works as expected. --- **Note**: You say *fastest way*. This sql was fast for me to produce, but the execution plan shows a table-scan, followed...
138,508
<p>My understanding of the MVC is as follows (incase it's horribly wrong, I am afterall new to it)</p> <ol> <li>Models are the things that interface with the database</li> <li>Views are the design/layout of the page</li> <li>Controllers are where everything starts and are essentially the page logic</li> </ol> <p>I'm ...
[ { "answer_id": 138527, "author": "Alexander Morland", "author_id": 4013, "author_profile": "https://Stackoverflow.com/users/4013", "pm_score": 1, "selected": false, "text": "<p>In <a href=\"http://cakephp.org\" rel=\"nofollow noreferrer\">CakePHP</a> there are 3 more \"parts\" : </p>\n\n...
2008/09/26
[ "https://Stackoverflow.com/questions/138508", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1384652/" ]
My understanding of the MVC is as follows (incase it's horribly wrong, I am afterall new to it) 1. Models are the things that interface with the database 2. Views are the design/layout of the page 3. Controllers are where everything starts and are essentially the page logic I'm using [CodeIgniter](http://codeigniter....
Model is the wrong word to use when discussing what to do with products: each product is a **value object (VO)** (or data transfer objet/DTO, whatever fits in your mouth better). Value objects generally have the same fields that a table contains. In your case ProductVO should have the fields that are in Products table....
138,511
<p>I know there's some <code>JAVA_OPTS</code> to set to remotely debug a Java program.</p> <p>What are they and what do they mean ?</p>
[ { "answer_id": 138518, "author": "Hans Sjunnesson", "author_id": 8683, "author_profile": "https://Stackoverflow.com/users/8683", "pm_score": 10, "selected": true, "text": "<p>I have <a href=\"http://www.eclipsezone.com/eclipse/forums/t53459.html\" rel=\"noreferrer\">this article</a> book...
2008/09/26
[ "https://Stackoverflow.com/questions/138511", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3122/" ]
I know there's some `JAVA_OPTS` to set to remotely debug a Java program. What are they and what do they mean ?
I have [this article](http://www.eclipsezone.com/eclipse/forums/t53459.html) bookmarked on setting this up for Java 5 and below. Basically [run it with](http://download.oracle.com/otn_hosted_doc/jdeveloper/904preview/jdk14doc/docs/tooldocs/windows/jdb.html): ``` -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=...
138,514
<p>I have a ASP.NET 2.0 webpage with 2 UserControls (.ascx). Each UserControl contains a bunch of validators. Placing a ValidationSummary on the page will display all validation errors, of both UserControl's. Placing a ValidationSummary in each UserControl will display all the errors of both controls twice. </p> <p>Wh...
[ { "answer_id": 138557, "author": "Jonathan Carter", "author_id": 6412, "author_profile": "https://Stackoverflow.com/users/6412", "pm_score": 2, "selected": false, "text": "<p>The control that is causing your form submission (i.e. a Button control) has to be a part of the same validation ...
2008/09/26
[ "https://Stackoverflow.com/questions/138514", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6399/" ]
I have a ASP.NET 2.0 webpage with 2 UserControls (.ascx). Each UserControl contains a bunch of validators. Placing a ValidationSummary on the page will display all validation errors, of both UserControl's. Placing a ValidationSummary in each UserControl will display all the errors of both controls twice. What I want ...
If you use ValidationGroups, the validation only occurs if the control causing the postback is assign to the same ValidationGroup. If you want to use a single control to postback you can still do this but you would need to explicitly call the Page.Validate method. ``` Page.Validate(MyValidationGroup1); Page.Validate(...
138,533
<p>I have a swing gui with a tabbed pane in the north. Several key events are added to its input map:</p> <pre><code>InputMap paneInputMap = pane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); paneInputMap.put( KeyStroke.getKeyStroke( KeyEvent.VK_E, KeyEvent.CTRL_MASK ), "finish"); paneInputMap.put( KeySt...
[ { "answer_id": 138668, "author": "Daniel Hiller", "author_id": 16193, "author_profile": "https://Stackoverflow.com/users/16193", "pm_score": 0, "selected": false, "text": "<p>May be the OS retargets the <kbd>F1</kbd> key? Install a key listener and see what events are handled.</p>\n\n<p>...
2008/09/26
[ "https://Stackoverflow.com/questions/138533", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18633/" ]
I have a swing gui with a tabbed pane in the north. Several key events are added to its input map: ``` InputMap paneInputMap = pane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); paneInputMap.put( KeyStroke.getKeyStroke( KeyEvent.VK_E, KeyEvent.CTRL_MASK ), "finish"); paneInputMap.put( KeyStroke.getKeyStr...
So that this gets an answer, here's the solution copied from your edit in the question. ;-) > > The ToolTipManager registeres the Key > `Ctrl`+`F1` to display the tooltip text if > the key combination is pressed. So if > a button with a tooltip is focused, > `Ctrl`+`F1` is handled by the > ToolTipManager. Otherw...
138,550
<p>I didn't find an explicit answer to this question in the WiX Documentation (or Google, for that matter). Of course I could just write the appropriate registry keys in HKCR, but it makes me feel dirty and I'd expect this to be a standard task which should have a nice default solution.</p> <p>For bonus points, I'd li...
[ { "answer_id": 139151, "author": "Edward Wilde", "author_id": 5182, "author_profile": "https://Stackoverflow.com/users/5182", "pm_score": 3, "selected": false, "text": "<p>\"If your application handles its own file data type, you will need to register a file association for it. Put a Pro...
2008/09/26
[ "https://Stackoverflow.com/questions/138550", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20363/" ]
I didn't find an explicit answer to this question in the WiX Documentation (or Google, for that matter). Of course I could just write the appropriate registry keys in HKCR, but it makes me feel dirty and I'd expect this to be a standard task which should have a nice default solution. For bonus points, I'd like to know...
After some additional research, I found a partial answer to this question in the [WiX Tutorial](http://www.tramontana.co.hu/wix/lesson1.php#1.7). It shows an advertised solution and does not work with WiX 3.0, but given that information, I figured it out. Add a ProgId element to the component containing your executable...
138,552
<p>I need to replace character (say) <strong>x</strong> with character (say) <strong>P</strong> in a string, but only if it is contained in a quoted substring. An example makes it clearer:</p> <pre><code>axbx'cxdxe'fxgh'ixj'k -&gt; axbx'cPdPe'fxgh'iPj'k </code></pre> <p>Let's assume, for the sake of simplicity, that...
[ { "answer_id": 138594, "author": "Remo.D", "author_id": 16827, "author_profile": "https://Stackoverflow.com/users/16827", "pm_score": 1, "selected": false, "text": "<p>Not with plain regexp. Regular expressions have no \"memory\" so they cannot distinguish between being \"inside\" or \"o...
2008/09/26
[ "https://Stackoverflow.com/questions/138552", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11545/" ]
I need to replace character (say) **x** with character (say) **P** in a string, but only if it is contained in a quoted substring. An example makes it clearer: ``` axbx'cxdxe'fxgh'ixj'k -> axbx'cPdPe'fxgh'iPj'k ``` Let's assume, for the sake of simplicity, that quotes always come in pairs. The obvious way is to j...
I was able to do this with Python: ``` >>> import re >>> re.sub(r"x(?=[^']*'([^']|'[^']*')*$)", "P", "axbx'cxdxe'fxgh'ixj'k") "axbx'cPdPe'fxgh'iPj'k" ``` What this does is use the non-capturing match (?=...) to check that the character x is within a quoted string. It looks for some nonquote characters up to the next...
138,555
<p>I need to convert HTML documents into valid XML, preferably XHTML. What's the best way to do this? Does anybody know a toolkit/library/sample/...whatever that helps me to get that task done?</p> <p>To be a bit more clear here, my application has to do the conversion automatically at runtime. I don't look for a tool...
[ { "answer_id": 138561, "author": "prakash", "author_id": 123, "author_profile": "https://Stackoverflow.com/users/123", "pm_score": 6, "selected": true, "text": "<p><a href=\"http://www.ibm.com/developerworks/library/tiptidy.html\" rel=\"nofollow noreferrer\"><strong>Convert from HTML to ...
2008/09/26
[ "https://Stackoverflow.com/questions/138555", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6777/" ]
I need to convert HTML documents into valid XML, preferably XHTML. What's the best way to do this? Does anybody know a toolkit/library/sample/...whatever that helps me to get that task done? To be a bit more clear here, my application has to do the conversion automatically at runtime. I don't look for a tool that help...
[**Convert from HTML to XML with HTML Tidy**](http://www.ibm.com/developerworks/library/tiptidy.html) [**Downloadable Binaries**](http://tidy.sourceforge.net/#binaries) JRoppert, For your need, i guess you might want to look at the [Sources](http://sourceforge.net/cvs/?group_id=27659) ``` c:\temp>tidy -help tidy [op...
138,565
<p>For a new project that I'm doing in PHP I've created an SQLMethods class to connect to the database and perform queries. Tonight was the first night that I actually got to test it (I wrote it a week or so ago and forgot about it) and an unexpected error occured: When it was calling my ExecuteQuery() function, it wou...
[ { "answer_id": 138590, "author": "cruizer", "author_id": 6441, "author_profile": "https://Stackoverflow.com/users/6441", "pm_score": 4, "selected": true, "text": "<p>you should declare $SQLConnection in your class, and you should refer to it as </p>\n\n<pre><code> $this-&gt;SQLConnection...
2008/09/26
[ "https://Stackoverflow.com/questions/138565", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14877/" ]
For a new project that I'm doing in PHP I've created an SQLMethods class to connect to the database and perform queries. Tonight was the first night that I actually got to test it (I wrote it a week or so ago and forgot about it) and an unexpected error occured: When it was calling my ExecuteQuery() function, it wouldn...
you should declare $SQLConnection in your class, and you should refer to it as ``` $this->SQLConnection ``` and not simply $SQLConnection.
138,576
<p>I'm trying to use the tree command in a windows commandline to generate a text file listing the contents of a directory but when I pipe the output the unicode characters get stuffed up.</p> <p>Here is the command I am using:</p> <pre><code>tree /f /a &gt; output.txt </code></pre> <p>The results in the console win...
[ { "answer_id": 138736, "author": "bzlm", "author_id": 7724, "author_profile": "https://Stackoverflow.com/users/7724", "pm_score": 4, "selected": false, "text": "<p>If you output as non-Unicode (which you apparently do), you have to view the text file you create using the same encoding th...
2008/09/26
[ "https://Stackoverflow.com/questions/138576", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48281/" ]
I'm trying to use the tree command in a windows commandline to generate a text file listing the contents of a directory but when I pipe the output the unicode characters get stuffed up. Here is the command I am using: ``` tree /f /a > output.txt ``` The results in the console window are fine: ``` \---Erika szobáj...
Have someone already tried this: ``` tree /f /a |clip ``` Open notepad, ctrl + V, save in notepad as output.txt with unicode support?
138,600
<p>What is the right way of initializing a static map? Do we need a static function that will initialize it? </p>
[ { "answer_id": 138612, "author": "Ferruccio", "author_id": 4086, "author_profile": "https://Stackoverflow.com/users/4086", "pm_score": 9, "selected": false, "text": "<p>Using C++11:</p>\n\n<pre><code>#include &lt;map&gt;\nusing namespace std;\n\nmap&lt;int, char&gt; m = {{1, 'a'}, {3, 'b...
2008/09/26
[ "https://Stackoverflow.com/questions/138600", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15163/" ]
What is the right way of initializing a static map? Do we need a static function that will initialize it?
Using C++11: ``` #include <map> using namespace std; map<int, char> m = {{1, 'a'}, {3, 'b'}, {5, 'c'}, {7, 'd'}}; ``` Using [Boost.Assign](http://www.boost.org/doc/libs/1_36_0/libs/assign/doc/index.html): ``` #include <map> #include "boost/assign.hpp" using namespace std; using namespace boost::assign; map<int, c...
138,607
<p>I have a very simple bit of script that changes the status of an item in a MySql database - it works fine in IE7, but if I try it in Firefox, it looks like it's worked, but hasn't... Which is extremely odd.</p> <p>The code is very simple - first I get the details of the record I'm looking for:</p> <pre><code>&lt;c...
[ { "answer_id": 138659, "author": "Re0sless", "author_id": 2098, "author_profile": "https://Stackoverflow.com/users/2098", "pm_score": 2, "selected": false, "text": "<p>Are you 100% certain that the database record does not change? You could get this affect if firefox calls you script twi...
2008/09/26
[ "https://Stackoverflow.com/questions/138607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22113/" ]
I have a very simple bit of script that changes the status of an item in a MySql database - it works fine in IE7, but if I try it in Firefox, it looks like it's worked, but hasn't... Which is extremely odd. The code is very simple - first I get the details of the record I'm looking for: ``` <cfscript> // Get the Prod...
I found the cause of the problem... Firebug. I haven't the slightest idea what Firebug thinks it's doing, if I remove the 'cflocation' tag from the script (the one that takes the user back to the summary page), then it works fine. But if I keep it in, Firebug seems to run the function again before forwarding the brows...
138,616
<p>I need to enumerate all running applications. In particular, all top windows. And for every window I need to add my custom item to the system menu of that window.</p> <p>How can I accomplish that in C++?</p> <p><strong>Update.</strong></p> <p>I would be more than happy to have a solution for Windows, MacOS, and U...
[ { "answer_id": 138657, "author": "Chris", "author_id": 2134, "author_profile": "https://Stackoverflow.com/users/2134", "pm_score": 1, "selected": false, "text": "<p>Once you have another window's top level handle, you may be able to call <a href=\"http://msdn.microsoft.com/en-us/library/...
2008/09/26
[ "https://Stackoverflow.com/questions/138616", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22623/" ]
I need to enumerate all running applications. In particular, all top windows. And for every window I need to add my custom item to the system menu of that window. How can I accomplish that in C++? **Update.** I would be more than happy to have a solution for Windows, MacOS, and Ubuntu (though, I'm not sure if MacOS ...
For Windows, another way to get the top-level windows (besides EnumWindows, which uses a callback) is to get the first child of the desktop and then retrieve all its siblings: ``` HWND wnd = GetWindow(GetDesktopWindow(), GW_CHILD); while (wnd) { // handle 'wnd' here // ... wnd = GetNextWindow(wnd, GW_HWNDN...
138,617
<p>Is there a way to create an html link using h:outputLink, other JSF tag or code to create a non faces request (HTTP GET) with request parameters?</p> <p>For example I have the following navigation-rule</p> <pre><code>&lt;navigation-rule&gt; &lt;navigation-case&gt; &lt;from-outcome&gt;showMessage&lt;/fr...
[ { "answer_id": 139620, "author": "hubbardr", "author_id": 22457, "author_profile": "https://Stackoverflow.com/users/22457", "pm_score": 0, "selected": false, "text": "<p>Have you considered a form?</p>\n\n<pre><code>&lt;h:form&gt;\n &lt;h:commandLink value=\"Click to see the message\"...
2008/09/26
[ "https://Stackoverflow.com/questions/138617", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19331/" ]
Is there a way to create an html link using h:outputLink, other JSF tag or code to create a non faces request (HTTP GET) with request parameters? For example I have the following navigation-rule ``` <navigation-rule> <navigation-case> <from-outcome>showMessage</from-outcome> <to-view-id>/showMessa...
This is an interesting idea. I'd be curious to know how it pans out in practice. **Getting the navigation rules** Navigation is handled by the [NavigationHandler](http://java.sun.com/javaee/javaserverfaces/1.1_01/docs/api/javax/faces/application/NavigationHandler.html). Getting hold of the NavigationHandler isn't dif...
138,638
<p>Can I expose a class from another .net namespace as a class in my namespace? I use a class - antlr.collections.AST - as the return type for a function belonging to a class in my namespace; as a result, the user has to have</p> <pre><code>using antlr.collections; using myNamespace; </code></pre> <p>at the top of t...
[ { "answer_id": 138642, "author": "Agnel Kurian", "author_id": 45603, "author_profile": "https://Stackoverflow.com/users/45603", "pm_score": 2, "selected": false, "text": "<p>How about deriving a class using the same name in the new namespace? I meant:</p>\n\n<pre><code>namespace MyForms ...
2008/09/26
[ "https://Stackoverflow.com/questions/138638", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15371/" ]
Can I expose a class from another .net namespace as a class in my namespace? I use a class - antlr.collections.AST - as the return type for a function belonging to a class in my namespace; as a result, the user has to have ``` using antlr.collections; using myNamespace; ``` at the top of their files in order to use ...
Bear in mind that the consumers of your code won't actually *need* to have using statements. Those are there to make their lives easier, so they don't have to type antlr.collections.Foo and antlr.collections.Bar all over their source. The bigger "impact" (if indeed there really is a severe one) is that the consumer of...
138,680
<p>is it possible to extend vim functionality via custom extension (preferably, written in Python)?</p> <p>What I need ideally is custom command when in command mode. E.g.</p> <p>ESC</p> <p>:do_this</p> <p>:do_that</p>
[ { "answer_id": 138709, "author": "Paolo Tedesco", "author_id": 15622, "author_profile": "https://Stackoverflow.com/users/15622", "pm_score": 5, "selected": true, "text": "<p>vim supports scripting in python (and in perl as well, I think).</p>\n\n<p>You just have to make sure that the vim...
2008/09/26
[ "https://Stackoverflow.com/questions/138680", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22623/" ]
is it possible to extend vim functionality via custom extension (preferably, written in Python)? What I need ideally is custom command when in command mode. E.g. ESC :do\_this :do\_that
vim supports scripting in python (and in perl as well, I think). You just have to make sure that the vim distribution you are using has been compiled with python support. If you are using a Linux system, you can download the source and then compile it with ``` ./configure --enable-pythoninterp make sudo make instal...
138,747
<p>A client of mine uses Oracle 9i's utl_smtp to send mails out notifications to managers when their employees have made travel requests and they woul like quite a few changes made to the mailouts done. </p> <p>We're having a lot of problems getting utl_smtp to talk to any smtp server on our network. We've even tried ...
[ { "answer_id": 139021, "author": "Dan Maharry", "author_id": 2756, "author_profile": "https://Stackoverflow.com/users/2756", "pm_score": 1, "selected": false, "text": "<p>Yes, we can telnet to the server.</p>\n\n<pre><code>-- ****** Object: Stored Procedure TRAVELADMIN_DEV.HTML_EMAIL Scr...
2008/09/26
[ "https://Stackoverflow.com/questions/138747", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2756/" ]
A client of mine uses Oracle 9i's utl\_smtp to send mails out notifications to managers when their employees have made travel requests and they woul like quite a few changes made to the mailouts done. We're having a lot of problems getting utl\_smtp to talk to any smtp server on our network. We've even tried installi...
Looks like the HELO is the problem. Please can we check with a simple testcase... ``` set serveroutput on declare lConnection UTL_SMTP.CONNECTION; begin lConnection := UTL_SMTP.OPEN_CONNECTION(your_smtp_server); DBMS_OUTPUT.PUT_LINE('Opened ok'); UTL_SMTP.HELO(lConnection, your_client_machine...
138,785
<p>I'm trying to learn RegEx in Ruby, based on what I'm reading in "<em>The Rails Way</em>". But, even this simple example has me stumped. I can't tell if it is a typo or not:</p> <pre><code>text.gsub(/\s/, "-").gsub([^\W-], '').downcase </code></pre> <p>It seems to me that this would replace all spaces with <code>-<...
[ { "answer_id": 138800, "author": "Khoth", "author_id": 20686, "author_profile": "https://Stackoverflow.com/users/20686", "pm_score": 2, "selected": false, "text": "<p>You forgot the slashes. It should be <code>/[^\\W-]/</code></p>\n" }, { "answer_id": 138809, "author": "Vinko...
2008/09/26
[ "https://Stackoverflow.com/questions/138785", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9450/" ]
I'm trying to learn RegEx in Ruby, based on what I'm reading in "*The Rails Way*". But, even this simple example has me stumped. I can't tell if it is a typo or not: ``` text.gsub(/\s/, "-").gsub([^\W-], '').downcase ``` It seems to me that this would replace all spaces with `-`, then anywhere a string starts with a...
``` >> text = "I love spaces" => "I love spaces" >> text.gsub(/\s/, "-").gsub(/[^\W-]/, '').downcase => "--" ``` Missing // Although this makes a little more sense :-) ``` >> text.gsub(/\s/, "-").gsub(/([^\W-])/, '\1').downcase => "i-love-spaces" ``` And this is probably what is meant ``` >> text.gsub(/\s/, "-")...
138,819
<p>If I am iterating over each file using :</p> <pre><code>@echo off FOR %%f IN (*\*.\**) DO ( echo %%f ) </code></pre> <p>how could I print the extension of each file? I tried assigning %%f to a temporary variable, and then using the code : <code>echo "%t:~-3%"</code> to print but with no success.</p>
[ { "answer_id": 138847, "author": "Sam Holloway", "author_id": 1377325, "author_profile": "https://Stackoverflow.com/users/1377325", "pm_score": 6, "selected": true, "text": "<p>The FOR command has several built-in switches that allow you to modify file names. Try the following:</p>\n\n<p...
2008/09/26
[ "https://Stackoverflow.com/questions/138819", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11234/" ]
If I am iterating over each file using : ``` @echo off FOR %%f IN (*\*.\**) DO ( echo %%f ) ``` how could I print the extension of each file? I tried assigning %%f to a temporary variable, and then using the code : `echo "%t:~-3%"` to print but with no success.
The FOR command has several built-in switches that allow you to modify file names. Try the following: ``` @echo off for %%i in (*.*) do echo "%%~xi" ``` For further details, use `help for` to get a complete list of the modifiers - there are quite a few!
138,839
<p>Currently I use .Net <code>WebBrowser.Document.Images()</code> to do this. It requires the <code>Webrowser</code> to load the document. It's messy and takes up resources. </p> <p>According to <a href="https://stackoverflow.com/questions/138313/how-to-extract-img-src-title-and-alt-from-html-using-php">this question<...
[ { "answer_id": 138863, "author": "Khoth", "author_id": 20686, "author_profile": "https://Stackoverflow.com/users/20686", "pm_score": -1, "selected": false, "text": "<p>If it's valid xhtml, you could do this:</p>\n\n<pre><code>XmlDocument doc = new XmlDocument();\ndoc.LoadXml(html);\nXmlN...
2008/09/26
[ "https://Stackoverflow.com/questions/138839", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5648/" ]
Currently I use .Net `WebBrowser.Document.Images()` to do this. It requires the `Webrowser` to load the document. It's messy and takes up resources. According to [this question](https://stackoverflow.com/questions/138313/how-to-extract-img-src-title-and-alt-from-html-using-php) XPath is better than a regex at this. ...
If your input string is valid XHTML you can treat is as xml, load it into an xmldocument, and do XPath magic :) But it's not always the case. Otherwise you can try this function, that will return all image links from HtmlSource : ``` public List<Uri> FetchLinksFromSource(string htmlSource) { List<Uri> links = new...
138,880
<p>Our web site (running Rails) freezes IE6 nearly every time. The same code, deployed on a different server, does not freeze IE6. Where and how should we start tracking this down?</p>
[ { "answer_id": 138891, "author": "Liam", "author_id": 18333, "author_profile": "https://Stackoverflow.com/users/18333", "pm_score": 0, "selected": false, "text": "<p>Use Firefox with Firebug to compare the HTTP Headers in the Request and Response from both servers.</p>\n" }, { "a...
2008/09/26
[ "https://Stackoverflow.com/questions/138880", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18666/" ]
Our web site (running Rails) freezes IE6 nearly every time. The same code, deployed on a different server, does not freeze IE6. Where and how should we start tracking this down?
You need to determine the difference between them, so I'd start out with the following: ``` curl -D first.headers -o first.body http://first.example.com curl -D second.headers -o second.body http://second.example.com diff -u first.headers second.headers diff -u first.body second.body ```