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 |
|---|---|---|---|---|---|---|
145,291 | <p>Can you have smart behavior for the home key in Emacs? By smart I mean that instead of going to the character number 0, it should go to the first non-blank character, and go to 0 on a second pressing, and back to the first non-blank in a third and so on.
Having smart end would be nice as well.</p>
| [
{
"answer_id": 145359,
"author": "cjm",
"author_id": 8355,
"author_profile": "https://Stackoverflow.com/users/8355",
"pm_score": 7,
"selected": true,
"text": "<pre><code>(defun smart-beginning-of-line ()\n \"Move point to first non-whitespace character or beginning-of-line.\n\nMove poin... | 2008/09/28 | [
"https://Stackoverflow.com/questions/145291",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6068/"
] | Can you have smart behavior for the home key in Emacs? By smart I mean that instead of going to the character number 0, it should go to the first non-blank character, and go to 0 on a second pressing, and back to the first non-blank in a third and so on.
Having smart end would be nice as well. | ```
(defun smart-beginning-of-line ()
"Move point to first non-whitespace character or beginning-of-line.
Move point to the first non-whitespace character on this line.
If point was already at that position, move point to beginning of line."
(interactive "^") ; Use (interactive) in Emacs 22 or older
(let ((oldpo... |
145,335 | <p>I know how to lighten the colors for certain commands, however I'd like to lighten the standard ansi colors across all commands.</p>
| [
{
"answer_id": 145421,
"author": "Hugh Allen",
"author_id": 15069,
"author_profile": "https://Stackoverflow.com/users/15069",
"pm_score": 0,
"selected": false,
"text": "<p>A simple solution would be to turn up your monitor brightness :)</p>\n\n<p>More seriously, see the RESOURCES section... | 2008/09/28 | [
"https://Stackoverflow.com/questions/145335",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3624/"
] | I know how to lighten the colors for certain commands, however I'd like to lighten the standard ansi colors across all commands. | I found instructions for doing it for Xterm and aterm here:
<http://gentoo-wiki.com/TIP_Linux_Colors_in_Aterm/rxvt>
From those I was able to get brighter colors by adding:
```
rxvt*background: #000000
rxvt*foreground: #7f7f7f
rxvt*color0: #000000
rxvt*color1: #9e1828
rxvt*color2: #aece92
rxvt*color3... |
145,337 | <ol>
<li>What is the most efficient way to check if an array is <strong>a flat array
of primitive values</strong> or if it is a <strong>multidimensional array</strong>?</li>
<li>Is there any way to do this without actually looping through an
array and running <code>is_array()</code> on each of its elements?</li>
</ol>
| [
{
"answer_id": 145342,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 3,
"selected": false,
"text": "<p>You could look check <code>is_array()</code> on the first element, under the assumption that if the first element of a... | 2008/09/28 | [
"https://Stackoverflow.com/questions/145337",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5291/"
] | 1. What is the most efficient way to check if an array is **a flat array
of primitive values** or if it is a **multidimensional array**?
2. Is there any way to do this without actually looping through an
array and running `is_array()` on each of its elements? | The short answer is no you can't do it without at least looping implicitly if the 'second dimension' could be anywhere. If it has to be in the first item, you'd just do
```
is_array($arr[0]);
```
But, the most efficient general way I could find is to use a foreach loop on the array, shortcircuiting whenever a hit i... |
145,376 | <p>Would it be possible to write a class that is virtually indistinguishable from an actual PHP array by implementing all the necessary SPL interfaces? Are they missing anything that would be critical?</p>
<p>I'd like to build a more advanced Array object, but I want to make sure I wouldn't break an existing app that ... | [
{
"answer_id": 145428,
"author": "Bob Fanger",
"author_id": 19165,
"author_profile": "https://Stackoverflow.com/users/19165",
"pm_score": 4,
"selected": true,
"text": "<p>The only problems i can think of are the gettype() and the is_array() functions.\nCheck your code for</p>\n\n<pre><co... | 2008/09/28 | [
"https://Stackoverflow.com/questions/145376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5291/"
] | Would it be possible to write a class that is virtually indistinguishable from an actual PHP array by implementing all the necessary SPL interfaces? Are they missing anything that would be critical?
I'd like to build a more advanced Array object, but I want to make sure I wouldn't break an existing app that uses array... | The only problems i can think of are the gettype() and the is\_array() functions.
Check your code for
```
gettype($FakeArray) == 'array'
is_array($FakeArray)
```
Because although you can use the object just like an array, it will still be identified as an object. |
145,480 | <p>Checking the HTML source of a question I see for instance:</p>
<pre><code><a id="comments-link-xxxxx" class="comments-link">add comment</a><noscript>&nbsp;JavaScript is needed to access comments.</noscript>
</code></pre>
<p>And then in the javascript source:</p>
<pre><code>// Setup our... | [
{
"answer_id": 145486,
"author": "gizmo",
"author_id": 9396,
"author_profile": "https://Stackoverflow.com/users/9396",
"pm_score": -1,
"selected": false,
"text": "<p>The only advantage I see is a reduction of the page size, and thus a lower bandwith need.</p>\n\n<p>Edit: As I'm being dow... | 2008/09/28 | [
"https://Stackoverflow.com/questions/145480",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4264/"
] | Checking the HTML source of a question I see for instance:
```
<a id="comments-link-xxxxx" class="comments-link">add comment</a><noscript> JavaScript is needed to access comments.</noscript>
```
And then in the javascript source:
```
// Setup our click events..
$().ready(function() {
$("a[id^='comm... | * You don't have to type the same string over and over again in the HTML (which if nothing else would increase the number of typos to debug)
* You can hand over the HTML/CSS to a designer who need not have any javascript skills
* You have programmatic control over what callbacks are called and when
* It's more elegant ... |
145,552 | <p>I basically want to do this:</p>
<pre><code>grep 'example.com' www_log > example.com.YYYY-MM-DD-H:i:S.log
</code></pre>
<p>...with of course the filename being <b>example.com.2008-09-27-11:21:30.log</b></p>
<p>I'd then put this in crontab to run daily.</p>
| [
{
"answer_id": 145554,
"author": "Michael Ridley",
"author_id": 4838,
"author_profile": "https://Stackoverflow.com/users/4838",
"pm_score": 4,
"selected": true,
"text": "<p>The verbose method:</p>\n\n<pre><code>grep 'example.com' www_log > `date +example.com.%Y-%m-%d-%H:%M:%S.log`\n</... | 2008/09/28 | [
"https://Stackoverflow.com/questions/145552",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I basically want to do this:
```
grep 'example.com' www_log > example.com.YYYY-MM-DD-H:i:S.log
```
...with of course the filename being **example.com.2008-09-27-11:21:30.log**
I'd then put this in crontab to run daily. | The verbose method:
```
grep 'example.com' www_log > `date +example.com.%Y-%m-%d-%H:%M:%S.log`
```
The terse method:
```
grep 'example.com' www_log > `date +example.com.%F-%T.log`
``` |
145,563 | <p>Suppose we have a vector/array in C++ and we wish to count which of these N elements has maximum repetitive occurrences and output the highest count. Which algorithm is best suited for this job.</p>
<p>example:</p>
<pre><code>int a = { 2, 456, 34, 3456, 2, 435, 2, 456, 2}
</code></pre>
<p>the output is 4 because ... | [
{
"answer_id": 145576,
"author": "Franci Penov",
"author_id": 17028,
"author_profile": "https://Stackoverflow.com/users/17028",
"pm_score": 5,
"selected": true,
"text": "<p>Sort the array and then do a quick pass to count each number. The algorithm has O(N*logN) complexity.</p>\n\n<p>Alt... | 2008/09/28 | [
"https://Stackoverflow.com/questions/145563",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8786/"
] | Suppose we have a vector/array in C++ and we wish to count which of these N elements has maximum repetitive occurrences and output the highest count. Which algorithm is best suited for this job.
example:
```
int a = { 2, 456, 34, 3456, 2, 435, 2, 456, 2}
```
the output is 4 because 2 occurs 4 times. That is the max... | Sort the array and then do a quick pass to count each number. The algorithm has O(N\*logN) complexity.
Alternatively, create a hash table, using the number as the key. Store in the hashtable a counter for each element you've keyed. You'll be able to count all elements in one pass; however, the complexity of the algori... |
145,607 | <p>I need an algorithm that can compare two text files and highlight their difference and ( even better!) can compute their difference in a meaningful way (like two similar files should have a similarity score higher than two dissimilar files, with the word "similar" defined in the normal terms). It sounds easy to imp... | [
{
"answer_id": 145609,
"author": "Douglas Leeder",
"author_id": 3978,
"author_profile": "https://Stackoverflow.com/users/3978",
"pm_score": 5,
"selected": false,
"text": "<p>Look at <a href=\"http://docs.python.org/lib/module-difflib.html\" rel=\"noreferrer\">difflib</a>. (Python)</p>\n\... | 2008/09/28 | [
"https://Stackoverflow.com/questions/145607",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3834/"
] | I need an algorithm that can compare two text files and highlight their difference and ( even better!) can compute their difference in a meaningful way (like two similar files should have a similarity score higher than two dissimilar files, with the word "similar" defined in the normal terms). It sounds easy to impleme... | In Python, there is [difflib](https://docs.python.org/3/library/difflib.html), as also others have suggested.
`difflib` offers the [SequenceMatcher](https://docs.python.org/3/library/difflib.html#difflib.SequenceMatcher) class, which can be used to give you a similarity ratio. Example function:
```
def text_compare(t... |
145,617 | <p>The case goes as following:
You have a Boolean property called FullScreenEnabled. You enter some method, and the code within this method is executed iff FullScreenEnabled is true. Which of the 2 approaches below do you use in your everyday programming:</p>
<pre><code> private bool FullScreenEnabled { get; set; }... | [
{
"answer_id": 145622,
"author": "Sören Kuklau",
"author_id": 1600,
"author_profile": "https://Stackoverflow.com/users/1600",
"pm_score": 0,
"selected": false,
"text": "<p>Neither approach was posted. You should read the <a href=\"https://stackoverflow.com/editing-help\">editing help</a>... | 2008/09/28 | [
"https://Stackoverflow.com/questions/145617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/113670/"
] | The case goes as following:
You have a Boolean property called FullScreenEnabled. You enter some method, and the code within this method is executed iff FullScreenEnabled is true. Which of the 2 approaches below do you use in your everyday programming:
```
private bool FullScreenEnabled { get; set; }
// Check ... | ```
private void MyMethod(bool arg){
if(arg)
return;
//do stuff
};
```
(for voting) |
145,701 | <p>Could anyone show me a sample about how to use these two commands in Windbg please? I read the document in debugger.chm, but confused. I did search in Google and MSDN, but not find an easy to learn sample.</p>
| [
{
"answer_id": 145782,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 2,
"selected": false,
"text": "<p>Think in terms of function levels as per the following pseudo-code:</p>\n\n<pre><code> 1 x = 0\n 2 y = 0\n 3 call ... | 2008/09/28 | [
"https://Stackoverflow.com/questions/145701",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Could anyone show me a sample about how to use these two commands in Windbg please? I read the document in debugger.chm, but confused. I did search in Google and MSDN, but not find an easy to learn sample. | Think in terms of function levels as per the following pseudo-code:
```
1 x = 0
2 y = 0
3 call 8
4 x = 5
5 y = 7
6 call 8
7 halt
8 print x
9 print y
10 call 12
11 return
12 print x + y
13 print x * y
14 return
```
The commands are basically "run until an event occurs". The event causes the d... |
145,765 | <p>I've a fairly huge .gdbinit (hence not copied here) in my home directory.</p>
<p>Now if I want to debug code inside Xcode I get this error: </p>
<pre><code>Failed to load debugging library at:
/Developer/Applications/Xcode.app/Contents/PlugIns/GDBMIDebugging.xcplugin/Contents/Resources/PBGDBIntrospectionSupport.A... | [
{
"answer_id": 151368,
"author": "Mike G.",
"author_id": 18901,
"author_profile": "https://Stackoverflow.com/users/18901",
"pm_score": 0,
"selected": false,
"text": "<p>Strange... Looking around my Mac, I see that library just fine, and it looks sane.</p>\n\n<p>Have you tried using dtra... | 2008/09/28 | [
"https://Stackoverflow.com/questions/145765",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18835/"
] | I've a fairly huge .gdbinit (hence not copied here) in my home directory.
Now if I want to debug code inside Xcode I get this error:
```
Failed to load debugging library at:
/Developer/Applications/Xcode.app/Contents/PlugIns/GDBMIDebugging.xcplugin/Contents/Resources/PBGDBIntrospectionSupport.A.dylib
Custom data f... | My "short" answer:
------------------
---
You may have noticed this already, but just in case:
First of all, even when you see that error, (assuming that you click past it and continue), then you should **still be able to use 99% of the debugging features** in Xcode. In other words, that error means that only a very... |
145,770 | <p>There is a webpage loaded in the firefox sidebar and another webpage loaded in the main document. Now, how do I ask access the main document object through the Firefox sidebar? An example to do this through Javascript code in the firefox sidebar document to access the main document would be helpful.</p>
<p>Thanks f... | [
{
"answer_id": 145791,
"author": "ConroyP",
"author_id": 2287,
"author_profile": "https://Stackoverflow.com/users/2287",
"pm_score": 1,
"selected": false,
"text": "<p>Accessing the main window from a sidebar is much trickier than going back the other way.</p>\n\n<p>The DOM tree you'll ne... | 2008/09/28 | [
"https://Stackoverflow.com/questions/145770",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6488/"
] | There is a webpage loaded in the firefox sidebar and another webpage loaded in the main document. Now, how do I ask access the main document object through the Firefox sidebar? An example to do this through Javascript code in the firefox sidebar document to access the main document would be helpful.
Thanks for the ans... | As far as I can tell, you are actually loading a web site in the sidebar (checked the 'Load this bookmark in Sidebar'). If this is the case, AND if the sidebar is opening the main window page. You can use the window.postMessage to communicate between them. But like I said, the sidebar page has to open the main page bec... |
145,803 | <p>I have a little dilemma on how to set up my visual studio builds for multi-targeting.</p>
<p>Background: c# .NET v2.0 with p/invoking into 3rd party 32 bit DLL's, SQL compact v3.5 SP1, with a Setup project.
Right now, the platform target is set to x86 so it can be run on Windows x64.</p>
<p>The 3rd party company ... | [
{
"answer_id": 145820,
"author": "mrpbody",
"author_id": 3849,
"author_profile": "https://Stackoverflow.com/users/3849",
"pm_score": 1,
"selected": false,
"text": "<p>Not sure of the total answer to your question - but thought I would point out a comment in the Additional Information sec... | 2008/09/28 | [
"https://Stackoverflow.com/questions/145803",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3584/"
] | I have a little dilemma on how to set up my visual studio builds for multi-targeting.
Background: c# .NET v2.0 with p/invoking into 3rd party 32 bit DLL's, SQL compact v3.5 SP1, with a Setup project.
Right now, the platform target is set to x86 so it can be run on Windows x64.
The 3rd party company has just released... | Yes, you can target both x86 and x64 with the same code base in the same project. In general, things will Just Work if you create the right solution configurations in VS.NET (although P/Invoke to entirely unmanaged DLLs will most likely require some conditional code): the items that I found to require special attention... |
145,814 | <p>Following techniques from 'Modern C++ Design', I am implementing a persistence library with various compile-time optimisations. I would like the ability to dispatch a function to a templated member variable if that variable derives from a given class:</p>
<pre><code>template<class T, template <class> class... | [
{
"answer_id": 145816,
"author": "David Pierre",
"author_id": 18296,
"author_profile": "https://Stackoverflow.com/users/18296",
"pm_score": 1,
"selected": false,
"text": "<p>Boost traits has something for that : <a href=\"http://www.boost.org/doc/libs/1_36_0/libs/type_traits/doc/html/boo... | 2008/09/28 | [
"https://Stackoverflow.com/questions/145814",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23167/"
] | Following techniques from 'Modern C++ Design', I am implementing a persistence library with various compile-time optimisations. I would like the ability to dispatch a function to a templated member variable if that variable derives from a given class:
```
template<class T, template <class> class Manager = DefaultManag... | Overloading can be useful to implement compile-time dispatching, as proposed by *Alexandrescu* in his book "Modern C++ Design".
You can use a class like this to transform at compile time a boolean or integer into a type:
```
template <bool n>
struct int2type
{ enum { value = n}; };
```
The following source code sho... |
145,838 | <p>What is the advantages/disadvantages of using inline functions in C++? I see that it only increases performance for the code that the compiler outputs, but with today's optimized compilers, fast CPUs, huge memory etc. (not like in the 1980< where memory was scarce and everything had to fit in 100KB of memory) wha... | [
{
"answer_id": 145841,
"author": "Brian R. Bondy",
"author_id": 3153,
"author_profile": "https://Stackoverflow.com/users/3153",
"pm_score": 8,
"selected": true,
"text": "<p>Inline functions are faster because you don't need to push and pop things on/off the stack like parameters and the ... | 2008/09/28 | [
"https://Stackoverflow.com/questions/145838",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22040/"
] | What is the advantages/disadvantages of using inline functions in C++? I see that it only increases performance for the code that the compiler outputs, but with today's optimized compilers, fast CPUs, huge memory etc. (not like in the 1980< where memory was scarce and everything had to fit in 100KB of memory) what adva... | Inline functions are faster because you don't need to push and pop things on/off the stack like parameters and the return address; however, it does make your binary slightly larger.
Does it make a significant difference? Not noticeably enough on modern hardware for most. But it can make a difference, which is enough ... |
145,856 | <p>I have an array of integers:</p>
<pre><code>int[] number = new int[] { 2,3,6,7 };
</code></pre>
<p>What is the easiest way of converting these into a single string where the numbers are separated by a character (like: <code>"2,3,6,7"</code>)?</p>
<p>I'm using C# and .NET 3.5.</p>
| [
{
"answer_id": 145864,
"author": "aku",
"author_id": 1196,
"author_profile": "https://Stackoverflow.com/users/1196",
"pm_score": 8,
"selected": true,
"text": "<pre><code>var ints = new int[] {1, 2, 3, 4, 5};\nvar result = string.Join(",", ints.Select(x => x.ToString()).ToArr... | 2008/09/28 | [
"https://Stackoverflow.com/questions/145856",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/298/"
] | I have an array of integers:
```
int[] number = new int[] { 2,3,6,7 };
```
What is the easiest way of converting these into a single string where the numbers are separated by a character (like: `"2,3,6,7"`)?
I'm using C# and .NET 3.5. | ```
var ints = new int[] {1, 2, 3, 4, 5};
var result = string.Join(",", ints.Select(x => x.ToString()).ToArray());
Console.WriteLine(result); // prints "1,2,3,4,5"
```
As of (at least) .NET 4.5,
```
var result = string.Join(",", ints.Select(x => x.ToString()).ToArray());
```
is equivalent to:
```
var result = str... |
145,900 | <p>I have an install that upgrades a previous version of an app if it exits. I'd like to skip certain actions when the install is upgrade mode. How can I determine if the install is running in upgrade mode vs. first time install mode?</p>
<p>I'm using Wise Installer, but I don't think that matters. I'm assuming that W... | [
{
"answer_id": 145962,
"author": "PhiLho",
"author_id": 15459,
"author_profile": "https://Stackoverflow.com/users/15459",
"pm_score": -1,
"selected": false,
"text": "<p>I am not sure I understood your question.<br>\nIf you are writting the install script yourself, the best way, on Window... | 2008/09/28 | [
"https://Stackoverflow.com/questions/145900",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22984/"
] | I have an install that upgrades a previous version of an app if it exits. I'd like to skip certain actions when the install is upgrade mode. How can I determine if the install is running in upgrade mode vs. first time install mode?
I'm using Wise Installer, but I don't think that matters. I'm assuming that Windows Ins... | Can you elaborate what kind of tools are you using to create this installer?
I use Windows Installer XML([WIX](http://wix.sourceforge.net/)). In WIX you could do something like this:
```
<!-- Property definitions -->
<?define SkuName = "MyCoolApp"?>
<?define ProductName="My Cool Application"?>
<?define Manufa... |
145,922 | <p>I've managed to get a memory 'leak' in a java application I'm developing. When running my JUnit test suite I randomly get out of memory exceptions (java.lang.OutOfMemoryError).</p>
<p>What tools can I use to examine the heap of my java application to see what's using up all my heap so that I can work out what's kee... | [
{
"answer_id": 145925,
"author": "Free Wildebeest",
"author_id": 1849,
"author_profile": "https://Stackoverflow.com/users/1849",
"pm_score": 0,
"selected": false,
"text": "<p>If you're using a system which supports GTK you could try using <a href=\"http://www.khelekore.org/jmp/\" rel=\"n... | 2008/09/28 | [
"https://Stackoverflow.com/questions/145922",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1849/"
] | I've managed to get a memory 'leak' in a java application I'm developing. When running my JUnit test suite I randomly get out of memory exceptions (java.lang.OutOfMemoryError).
What tools can I use to examine the heap of my java application to see what's using up all my heap so that I can work out what's keeping refer... | VisualVM is included in the most recent releases of Java. You can use this to create a heap dump, and look at the objects in it.
Alternatively, you can also create a heapdump commandine using jmap (in your jdk/bin dir):
```
jmap -dump:format=b,file=heap.bin <pid>
```
You can even use this to get a quick histogram o... |
145,969 | <p>I've got a sections table, and an items table.</p>
<p>The problem is each item may be in one or more sections, so a simple 'section_id' for each item won't work, and sql doesn't have a way to store arrays where I can do say "WHERE 5 in section_ids"...</p>
<p>I've considered storing the list of ids as a comma separ... | [
{
"answer_id": 145985,
"author": "albertein",
"author_id": 23020,
"author_profile": "https://Stackoverflow.com/users/23020",
"pm_score": 0,
"selected": false,
"text": "<p>You need a third table itemsPerSection with a primary key composed of both itemid and sectionid, this way you can hav... | 2008/09/28 | [
"https://Stackoverflow.com/questions/145969",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6266/"
] | I've got a sections table, and an items table.
The problem is each item may be in one or more sections, so a simple 'section\_id' for each item won't work, and sql doesn't have a way to store arrays where I can do say "WHERE 5 in section\_ids"...
I've considered storing the list of ids as a comma separated string, th... | You need an intermediate lookup table:
```
CREATE TABLE item_in_section (item_id int, section_id int)
```
(I'm guessing about your key types, use whatever ones are appropriate).
To find items in a section:
```
SELECT item.* from item, item_in_section WHERE item_in_section.item_id = item.item_id AND item_in_section... |
145,972 | <p>I need to setup LookAndFeel Files in JDK 1.6.
I have two files:</p>
<ol>
<li><p>napkinlaf-swingset2.jar</p></li>
<li><p>napkinlaf.jar</p></li>
</ol>
<p>How can I set this up and use it?</p>
<p>I would like a GTK look and feel OR Qt look and feel, Are they available?</p>
| [
{
"answer_id": 145996,
"author": "Tom",
"author_id": 22850,
"author_profile": "https://Stackoverflow.com/users/22850",
"pm_score": 3,
"selected": false,
"text": "<p>This page explains how the work with Look&Feels:\n<a href=\"http://java.sun.com/docs/books/tutorial/uiswing/lookandfeel... | 2008/09/28 | [
"https://Stackoverflow.com/questions/145972",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22634/"
] | I need to setup LookAndFeel Files in JDK 1.6.
I have two files:
1. napkinlaf-swingset2.jar
2. napkinlaf.jar
How can I set this up and use it?
I would like a GTK look and feel OR Qt look and feel, Are they available? | The class name for Naplin is `net.sourceforge.napkinlaf.NapkinLookAndFeel`. So to set it as default on the command line, use:
```
java -Dswing.defaultlaf=net.sourceforge.napkinlaf.NapkinLookAndFeel
```
To install it add `napkinlaf.jar` to the `lib/ext` direction and the lines:
```
swing.installedlafs=napkin
swing.in... |
146,081 | <p>I'm writing an interactive function that I'd like to have remember the last argument the user supplied and use it as the default. </p>
<pre><code>(defun run-rake (param)
(interactive "sTask: ")
(shell-command (format "rake %s" task)))
</code></pre>
<p>The first time the function is invoked I want it to rememb... | [
{
"answer_id": 146139,
"author": "Kyle Burton",
"author_id": 19784,
"author_profile": "https://Stackoverflow.com/users/19784",
"pm_score": 0,
"selected": false,
"text": "<p>I figured out how to do this manually using a defvar (global), but this feels like the kind of thing that should al... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146081",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19784/"
] | I'm writing an interactive function that I'd like to have remember the last argument the user supplied and use it as the default.
```
(defun run-rake (param)
(interactive "sTask: ")
(shell-command (format "rake %s" task)))
```
The first time the function is invoked I want it to remember the argument the user su... | You can see how the `compile` command does this. Bring up the help text for the compile command with `C-h f compile`, move the cursor over the name of the file that contains the function, then hit `RETURN`. This will bring up the source file for `compile`.
Basically, there's a dynamic/global variable `compile-command`... |
146,106 | <p>This question is about organizing the actual CSS directives themselves within a .css file. When developing a new page or set of pages, I usually just add directives by hand to the .css file, trying to refactor when I can. After some time, I have hundreds (or thousands) of lines and it can get difficult to find wha... | [
{
"answer_id": 146115,
"author": "Nick Sergeant",
"author_id": 22468,
"author_profile": "https://Stackoverflow.com/users/22468",
"pm_score": 2,
"selected": false,
"text": "<p>I've tried a bunch of different strategies, and I always come back to this style:</p>\n\n<pre><code>.class {borde... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146106",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21632/"
] | This question is about organizing the actual CSS directives themselves within a .css file. When developing a new page or set of pages, I usually just add directives by hand to the .css file, trying to refactor when I can. After some time, I have hundreds (or thousands) of lines and it can get difficult to find what I n... | Have a look at these three slideshare presentations to start:
* [Beautiful Maintainable CSS](http://www.slideshare.net/lachlanhardy/beautiful-maintainable-css)
* [Maintainable CSS](http://www.slideshare.net/stephenhay/maintainable-css-presentation)
* [Efficient, maintainable, modular CSS](http://www.slideshare.net/max... |
146,134 | <p>I need a robust and simple way to remove illegal path and file characters from a simple string. I've used the below code but it doesn't seem to do anything, what am I missing?</p>
<pre><code>using System;
using System.IO;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] arg... | [
{
"answer_id": 146141,
"author": "user7116",
"author_id": 7116,
"author_profile": "https://Stackoverflow.com/users/7116",
"pm_score": 4,
"selected": false,
"text": "<p>For starters, <a href=\"http://msdn.microsoft.com/en-us/library/system.string.trim.aspx\" rel=\"nofollow noreferrer\">Tr... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146134",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13227/"
] | I need a robust and simple way to remove illegal path and file characters from a simple string. I've used the below code but it doesn't seem to do anything, what am I missing?
```
using System;
using System.IO;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
... | Try something like this instead;
```
string illegal = "\"M\"\\a/ry/ h**ad:>> a\\/:*?\"| li*tt|le|| la\"mb.?";
string invalid = new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars());
foreach (char c in invalid)
{
illegal = illegal.Replace(c.ToString(), "");
}
```
But I have to agre... |
146,140 | <p>I have an OpenGL RGBA texture and I blit another RGBA texture onto it using a framebuffer object. The problem is that if I use the usual blend functions with
<code>glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA),</code>
the resulting blit causes the destination texture alpha to change, making it slightly transpar... | [
{
"answer_id": 146151,
"author": "Jay Conrod",
"author_id": 1891,
"author_profile": "https://Stackoverflow.com/users/1891",
"pm_score": 1,
"selected": false,
"text": "<p>Maybe you could use <a href=\"http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/colormask.html\"... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146140",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have an OpenGL RGBA texture and I blit another RGBA texture onto it using a framebuffer object. The problem is that if I use the usual blend functions with
`glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA),`
the resulting blit causes the destination texture alpha to change, making it slightly transparent for places... | You can set the blend-modes for RGB and alpha to different equations:
```
void glBlendFuncSeparate(
GLenum srcRGB,
GLenum dstRGB,
GLenum srcAlpha,
GLenum dstAlpha);
```
In your case you want to use the following enums:
```
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ZERO, GL_ON... |
146,146 | <p>This is what my browser sent, when logging into some site:</p>
<pre>
POST http://www.some.site/login.php HTTP/1.0
User-Agent: Opera/8.26 (X2000; Linux i686; Z; en)
Host: www.some.site
Accept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1
Accept... | [
{
"answer_id": 146149,
"author": "Adam Bellaire",
"author_id": 21632,
"author_profile": "https://Stackoverflow.com/users/21632",
"pm_score": 0,
"selected": false,
"text": "<p>Yes, your credentials are passed in cleartext, anyone who can hear your network traffic can sniff them.</p>\n"
... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146146",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15453/"
] | This is what my browser sent, when logging into some site:
```
POST http://www.some.site/login.php HTTP/1.0
User-Agent: Opera/8.26 (X2000; Linux i686; Z; en)
Host: www.some.site
Accept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1
Accept-Languag... | Every data sent trought a http connection can be seen by someone in your route to the server (man in the middle attack).
type="password" only hides the character on-screen, and even other programs on your computer can read the data.
The only way to protect the data is to send it trought SSL (HTTPS instead of HTTP) |
146,159 | <p>From time to time I read that Fortran is or can be faster then C for heavy calculations. Is that really true? I must admit that I hardly know Fortran, but the Fortran code I have seen so far did not show that the language has features that C doesn't have.</p>
<p>If it is true, please tell me why. Please don't tell ... | [
{
"answer_id": 146172,
"author": "Kluge",
"author_id": 8752,
"author_profile": "https://Stackoverflow.com/users/8752",
"pm_score": 4,
"selected": false,
"text": "<p>Any speed differences between Fortran and C will be more a function of compiler optimizations and the underlying math libra... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146159",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18687/"
] | From time to time I read that Fortran is or can be faster then C for heavy calculations. Is that really true? I must admit that I hardly know Fortran, but the Fortran code I have seen so far did not show that the language has features that C doesn't have.
If it is true, please tell me why. Please don't tell me what la... | The languages have similar feature-sets. The performance difference comes from the fact that Fortran says aliasing is not allowed, unless an EQUIVALENCE statement is used. Any code that has aliasing is not valid Fortran, but it is up to the programmer and not the compiler to detect these errors. Thus Fortran compilers ... |
146,204 | <p>Are there any dictionary classes in the .NET base class library which allow duplicate keys to be used? The only solution I've found is to create, for example, a class like:</p>
<pre><code>Dictionary<string, List<object>>
</code></pre>
<p>But this is quite irritating to actually use. In Java, I believ... | [
{
"answer_id": 146213,
"author": "MADMap",
"author_id": 17558,
"author_profile": "https://Stackoverflow.com/users/17558",
"pm_score": 4,
"selected": false,
"text": "<p>I think something like <code>List<KeyValuePair<object, object>></code> would do the Job.</p>\n"
},
{
... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146204",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Are there any dictionary classes in the .NET base class library which allow duplicate keys to be used? The only solution I've found is to create, for example, a class like:
```
Dictionary<string, List<object>>
```
But this is quite irritating to actually use. In Java, I believe a MultiMap accomplishes this, but cann... | If you're using .NET 3.5, use the [`Lookup`](http://msdn.microsoft.com/en-us/library/bb460184.aspx) class.
EDIT: You generally create a `Lookup` using [`Enumerable.ToLookup`](http://msdn.microsoft.com/en-us/library/system.linq.enumerable.tolookup.aspx). This does assume that you don't need to change it afterwards - bu... |
146,212 | <p>I have a table of "items", and a table of "itemkeywords".
When a user searches for a keyword, I want to give him one page of results plus the total number of results.</p>
<p>What I'm doing currently is (for a user that searches "a b c": </p>
<pre><code>SELECT DISTINCT {fields I want} FROM itemkeywords JOIN items ... | [
{
"answer_id": 146229,
"author": "ysth",
"author_id": 17389,
"author_profile": "https://Stackoverflow.com/users/17389",
"pm_score": 4,
"selected": true,
"text": "<p>Add SQL_CALC_FOUND_ROWS after the select in your limited select, then do a \"SELECT FOUND_ROWS()\" after the first select i... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146212",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3314/"
] | I have a table of "items", and a table of "itemkeywords".
When a user searches for a keyword, I want to give him one page of results plus the total number of results.
What I'm doing currently is (for a user that searches "a b c":
```
SELECT DISTINCT {fields I want} FROM itemkeywords JOIN items
WHERE (keyword ... | Add SQL\_CALC\_FOUND\_ROWS after the select in your limited select, then do a "SELECT FOUND\_ROWS()" after the first select is finished.
Example:
```
mysql> SELECT SQL_CALC_FOUND_ROWS * FROM tbl_name
-> WHERE id > 100 LIMIT 10;
mysql> SELECT FOUND_ROWS();
``` |
146,269 | <p>I need to change the DataTemplate for items in a ListBox depending on whether the item is selected or not (displaying different/more information when selected).</p>
<p>I don't get a GotFocus/LostFocus event on the top-most element in the DataTemplate (a StackPanel) when clicking the ListBox item in question (only t... | [
{
"answer_id": 146423,
"author": "Micah",
"author_id": 17744,
"author_profile": "https://Stackoverflow.com/users/17744",
"pm_score": 9,
"selected": true,
"text": "<p>The easiest way to do this is to supply a template for the \"ItemContainerStyle\" and NOT the \"ItemTemplate\" property. I... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146269",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23222/"
] | I need to change the DataTemplate for items in a ListBox depending on whether the item is selected or not (displaying different/more information when selected).
I don't get a GotFocus/LostFocus event on the top-most element in the DataTemplate (a StackPanel) when clicking the ListBox item in question (only through tab... | The easiest way to do this is to supply a template for the "ItemContainerStyle" and NOT the "ItemTemplate" property. In the code below I create 2 data templates: one for the "unselected" and one for the "selected" states. I then create a template for the "ItemContainerStyle" which is the actual "ListBoxItem" that conta... |
146,271 | <p><strong>EDIT: This question is more about language engineering than C++ itself. I used C++ as an example to show what I wanted, mostly because I use it daily. I didn't want to know how it works on C++ but open a discussion on how it <em>could</em> be done.</strong></p>
<p>That's not the way it works right now, that... | [
{
"answer_id": 146285,
"author": "user7545",
"author_id": 7545,
"author_profile": "https://Stackoverflow.com/users/7545",
"pm_score": 1,
"selected": false,
"text": "<p>I honestly think that this whole passing by value/passing by reference idea in C++ is misleading. <em>Everything</em> i... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146271",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18623/"
] | **EDIT: This question is more about language engineering than C++ itself. I used C++ as an example to show what I wanted, mostly because I use it daily. I didn't want to know how it works on C++ but open a discussion on how it *could* be done.**
That's not the way it works right now, that's the way I *wish* it could b... | I guess you're missing the point of C++, and C++ semantics. You missed the fact **C++ is correct in passing (almost) everything by value, because it's the way it's done in C. Always**. But not only in C, as I'll show you below...
Parameters Semantics on C
-------------------------
In C, everything is passed by value.... |
146,275 | <p>I have a templated class defined (in part) as</p>
<pre><code>template <class T> MyClass
{
public:
void DoSomething(){}
};
</code></pre>
<p>If I want to call DoSomething from another class, but be able to do this for multiple 'T' types in the same place, I am stuck for an idea as method functions pointers ... | [
{
"answer_id": 146309,
"author": "Evan Teran",
"author_id": 13430,
"author_profile": "https://Stackoverflow.com/users/13430",
"pm_score": 5,
"selected": true,
"text": "<p>Ok, so the functor solution doesn't work as you need. Perhaps you should have your template class inherit from a comm... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146275",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23167/"
] | I have a templated class defined (in part) as
```
template <class T> MyClass
{
public:
void DoSomething(){}
};
```
If I want to call DoSomething from another class, but be able to do this for multiple 'T' types in the same place, I am stuck for an idea as method functions pointers are uniquely constrained to the ... | Ok, so the functor solution doesn't work as you need. Perhaps you should have your template class inherit from a common base "Interface" class. And then you use a vector of those.
Something like this:
```
class Base {
public:
virtual ~Base(){}
virtual void DoSomething() = 0;
}
template <class T> class MyClass :... |
146,291 | <p>I have a problem with <strong>scandir()</strong>: The manpage contains this as prototype:</p>
<pre><code>int scandir(const char *dir, struct dirent ***namelist,
int (*filter)(const struct dirent *),
int (*compar)(const struct dirent **, const struct dirent **));
</code></pre>
<p>Therefore I have this:</p>
<pr... | [
{
"answer_id": 146310,
"author": "jkramer",
"author_id": 12523,
"author_profile": "https://Stackoverflow.com/users/12523",
"pm_score": 1,
"selected": false,
"text": "<p>You're giving it a pointer to an inline function? That doesn't make sense, actually I wonder that it even compiles with... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146291",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18179/"
] | I have a problem with **scandir()**: The manpage contains this as prototype:
```
int scandir(const char *dir, struct dirent ***namelist,
int (*filter)(const struct dirent *),
int (*compar)(const struct dirent **, const struct dirent **));
```
Therefore I have this:
```
static inline int
RubyCompare(const struct... | Actually, there's no such constraint that you can't pass a pointer to an inline function. The inline keyword serves only as a hint to the compiler to inline calls when it can.
The problem is that the manpage for scandir() is a little misleading. The prototype in for the 4th parameter is actually int (\*cmp)(const void... |
146,311 | <p>It says in <a href="http://www.ibm.com/developerworks/java/library/j-jtp04223.html" rel="nofollow noreferrer">this article</a> that: </p>
<blockquote>
<p>Making a class final because it is immutable is a good reason to do so.</p>
</blockquote>
<p>I'm a bit puzzled by this... I understand that immutability is a g... | [
{
"answer_id": 146318,
"author": "cynicalman",
"author_id": 410,
"author_profile": "https://Stackoverflow.com/users/410",
"pm_score": 3,
"selected": false,
"text": "<p>Because if the class is final you can't extend it and make it mutable.</p>\n\n<p>Even if you make the fields final, that... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146311",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2648/"
] | It says in [this article](http://www.ibm.com/developerworks/java/library/j-jtp04223.html) that:
>
> Making a class final because it is immutable is a good reason to do so.
>
>
>
I'm a bit puzzled by this... I understand that immutability is a good thing from the POV of thread-safety and simplicity, but it seems ... | The explanation for this is given in the book 'Effective Java'
Consider `BigDecimal` and `BigInteger` classes in Java .
It was not widely understood that immutable classes had to be effectively final
when `BigInteger` and `BigDecimal` were written, so all of their methods may be
overridden. Unfortunately, this coul... |
146,316 | <p>What number of classes do you think is ideal per one namespace "branch"? At which point would one decide to break one namespace into multiple ones? Let's not discuss the logical grouping of classes (assume they are logically grouped properly), I am, at this point, focused on the maintainable vs. not maintainable num... | [
{
"answer_id": 146323,
"author": "cynicalman",
"author_id": 410,
"author_profile": "https://Stackoverflow.com/users/410",
"pm_score": 3,
"selected": false,
"text": "<p>With modern IDEs and other dev tools, I would say that if all the classes belong in a namespace, then there is no arbitr... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146316",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15497/"
] | What number of classes do you think is ideal per one namespace "branch"? At which point would one decide to break one namespace into multiple ones? Let's not discuss the logical grouping of classes (assume they are logically grouped properly), I am, at this point, focused on the maintainable vs. not maintainable number... | "42? No, it doesn't work..."
Ok, let's put our programming prowess to work and see what is Microsoft's opinion:
```
# IronPython
import System
exported_types = [
(t.Namespace, t.Name)
for t in System.Int32().GetType().Assembly.GetExportedTypes()]
import itertools
get_ns = lambda (ns, typename): ns
sorted_exporte... |
146,354 | <p>I'd like to automatically change my database connection settings on a per-vhost basis, so that I don't have to edit any PHP code as it moves from staging to live and yet access different databases. This is on a single dedicated server.</p>
<p>So I was wondering, can I set a PHP variable or constant in httpd.conf as... | [
{
"answer_id": 146380,
"author": "JW.",
"author_id": 4321,
"author_profile": "https://Stackoverflow.com/users/4321",
"pm_score": 6,
"selected": false,
"text": "<p>Yep...you can do this:</p>\n\n<pre><code>SetEnv DATABASE_NAME testing\n</code></pre>\n\n<p>and then in PHP:</p>\n\n<pre><code... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146354",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/137/"
] | I'd like to automatically change my database connection settings on a per-vhost basis, so that I don't have to edit any PHP code as it moves from staging to live and yet access different databases. This is on a single dedicated server.
So I was wondering, can I set a PHP variable or constant in httpd.conf as part of t... | Did you tried to use the .htaccess file? You could override the php.ini values using it.
Just put the .htaccess file into your htdocs directory:
```
php_value name value
```
Futher information:
* <https://php.net/manual/en/configuration.changes.php>
* <https://php.net/manual/en/ini.php> |
146,358 | <p>I'm using .NET 3.5. I have two string arrays, which may share one or more values:</p>
<pre><code>string[] list1 = new string[] { "apple", "orange", "banana" };
string[] list2 = new string[] { "banana", "pear", "grape" };
</code></pre>
<p>I'd like a way to merge them into one array with no duplicate values:</p>
<... | [
{
"answer_id": 146379,
"author": "petr k.",
"author_id": 15497,
"author_profile": "https://Stackoverflow.com/users/15497",
"pm_score": 1,
"selected": false,
"text": "<p>Probably creating a hashtable with your values as keys (only adding those not already present) and then converting the ... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146358",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5142/"
] | I'm using .NET 3.5. I have two string arrays, which may share one or more values:
```
string[] list1 = new string[] { "apple", "orange", "banana" };
string[] list2 = new string[] { "banana", "pear", "grape" };
```
I'd like a way to merge them into one array with no duplicate values:
```
{ "apple", "orange", "banana... | ```
string[] result = list1.Union(list2).ToArray();
```
from [msdn](http://msdn.microsoft.com/en-us/library/bb341731.aspx): "This method excludes duplicates from the return set. This is different behavior to the Concat(TSource) method, which returns all the elements in the input sequences including duplicates." |
146,359 | <p>I am trying to figure out this:</p>
<pre><code>c = 1
def f(n):
print c + n
def g(n):
c = c + n
f(1) # => 2
g(1) # => UnboundLocalError: local variable 'c' referenced before assignment
</code></pre>
<p>Thanks!</p>
| [
{
"answer_id": 146365,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 7,
"selected": true,
"text": "<p>Within a function, variables that are assigned to are treated as local variables by default. To assign to global variab... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146359",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/462204/"
] | I am trying to figure out this:
```
c = 1
def f(n):
print c + n
def g(n):
c = c + n
f(1) # => 2
g(1) # => UnboundLocalError: local variable 'c' referenced before assignment
```
Thanks! | Within a function, variables that are assigned to are treated as local variables by default. To assign to global variables, use the [`global`](https://docs.python.org/3/reference/simple_stmts.html#the-global-statement) statement:
```
def g(n):
global c
c = c + n
```
This is one of the quirky areas of Python ... |
146,367 | <p>I have an asp.net mvc application with a route similar to:</p>
<pre><code>routes.MapRoute("Blog",
"{controller}/{action}/{year}/{month}/{day}/{friendlyName}",
new { controller = "Blog", action = "Index", id = "", friendlyName="" },
new { controller = @"[^\.]*",
yea... | [
{
"answer_id": 146404,
"author": "Gilligan",
"author_id": 12356,
"author_profile": "https://Stackoverflow.com/users/12356",
"pm_score": 3,
"selected": true,
"text": "<p>I would suggest formatting the Year, Month, and Day as Strings instead. \nThink about this: Will you be doing any math ... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146367",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3085/"
] | I have an asp.net mvc application with a route similar to:
```
routes.MapRoute("Blog",
"{controller}/{action}/{year}/{month}/{day}/{friendlyName}",
new { controller = "Blog", action = "Index", id = "", friendlyName="" },
new { controller = @"[^\.]*",
year = @"\d{4}", ... | I would suggest formatting the Year, Month, and Day as Strings instead.
Think about this: Will you be doing any math on these "integers"? Probably not, so there really is no point for making them integers.
Once you have them as Strings you can force the leading zero format. |
146,385 | <p>I am trying to call a webservice using ssl.
How do i get the relevant server cert so that i can import it into my truststore?
I know about the use of property com.ibm.ssl.enableSignerExchangePrompt from a main method but i would add the server cert to my truststore manually.</p>
<p>I dont want this property set in ... | [
{
"answer_id": 146450,
"author": "Max Stewart",
"author_id": 18338,
"author_profile": "https://Stackoverflow.com/users/18338",
"pm_score": 0,
"selected": false,
"text": "<p>If you browse to the site in your web browser you can look at the security info by hitting the little padlock icon ... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146385",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11612/"
] | I am trying to call a webservice using ssl.
How do i get the relevant server cert so that i can import it into my truststore?
I know about the use of property com.ibm.ssl.enableSignerExchangePrompt from a main method but i would add the server cert to my truststore manually.
I dont want this property set in any of my ... | you can programmatically do this with Java by implementing your own X509TrustManager.
```
public class dummyTrustManager implements X509TrustManager {
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
//do nothing
}
public voi... |
146,387 | <p>I'd like to get <strong>uniform distribution</strong> in range [0.0, 1.0)</p>
<p>If possible, please let the implementation make use of random bytes from <strong>/dev/urandom.</strong></p>
<p>It would also be nice if your solution was <strong>thread-safe</strong>. If you're not sure, please indicate that.</p>
<p>... | [
{
"answer_id": 146410,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<pre><code>#include <stdlib.h>\nprintf(\"%f\\n\", drand48());\n</code></pre>\n\n<h2>/dev/random:</h2>\n\n<pre><code>doub... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146387",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9403/"
] | I'd like to get **uniform distribution** in range [0.0, 1.0)
If possible, please let the implementation make use of random bytes from **/dev/urandom.**
It would also be nice if your solution was **thread-safe**. If you're not sure, please indicate that.
See [some solution](https://stackoverflow.com/questions/146387#... | This seems to be pretty good way:
````
unsigned short int r1, r2, r3;
// let r1, r2 and r3 hold random values
double result = ldexp(r1, -48) + ldexp(r2, -32) + ldexp(r3, -16);
````
This is based on NetBSD's drand48 implementation. |
146,390 | <p>In python you can use a tuple in a formatted print statement and the tuple values are used at the indicated positions in the formatted string. For example:</p>
<pre><code>>>> a = (1,"Hello",7.2)
>>> print "these are the values %d, %s, %f" % a
these are the values 1, Hello, 7.200000
</code></pre>
... | [
{
"answer_id": 146408,
"author": "Tom Hawtin - tackline",
"author_id": 4725,
"author_profile": "https://Stackoverflow.com/users/4725",
"pm_score": 5,
"selected": true,
"text": "<p>printf will have a declaration along the lines of:</p>\n\n<pre><code>public PrintString printf(String format... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146390",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4138/"
] | In python you can use a tuple in a formatted print statement and the tuple values are used at the indicated positions in the formatted string. For example:
```
>>> a = (1,"Hello",7.2)
>>> print "these are the values %d, %s, %f" % a
these are the values 1, Hello, 7.200000
```
Is there some way to use any array or col... | printf will have a declaration along the lines of:
```
public PrintString printf(String format, Object... args);
```
... means much the same as `[]`. The difference is `...` allows the caller to omit explicitly creating an array. So consider:
```
out.printf("%s:%s", a, b);
```
That is the equivalent of:
```
... |
146,435 | <p>I have a file temp.txt, that I want to sort with the <code>sort</code> command in bash.</p>
<p>I want the sorted results to replace the original file.</p>
<p>This doesn't work for example (I get an empty file):</p>
<pre><code>sortx temp.txt > temp.txt
</code></pre>
<p>Can this be done in one line without reso... | [
{
"answer_id": 146441,
"author": "slim",
"author_id": 7512,
"author_profile": "https://Stackoverflow.com/users/7512",
"pm_score": 2,
"selected": false,
"text": "<p>Read up on the non-interactive editor, <a href=\"http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ex.html\" rel=\"n... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146435",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/814/"
] | I have a file temp.txt, that I want to sort with the `sort` command in bash.
I want the sorted results to replace the original file.
This doesn't work for example (I get an empty file):
```
sortx temp.txt > temp.txt
```
Can this be done in one line without resorting to copying to temporary files?
---
EDIT: The `... | ```
sort temp.txt -o temp.txt
``` |
146,439 | <p>Here's the idea, I'd like to make a service? that will look for a certain program starting up and dissallow it unless certain conditions are met. </p>
<p>Let's say I have a game I want to stop myself from playing during the week. So if I start it up on any day other than Friday/Saturday/Sunday, it will intercept a... | [
{
"answer_id": 146444,
"author": "Daren Thomas",
"author_id": 2260,
"author_profile": "https://Stackoverflow.com/users/2260",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not sure if you can catch it starting up, but you could try to look for the program in the list of windows (was ... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146439",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21691/"
] | Here's the idea, I'd like to make a service? that will look for a certain program starting up and dissallow it unless certain conditions are met.
Let's say I have a game I want to stop myself from playing during the week. So if I start it up on any day other than Friday/Saturday/Sunday, it will intercept and cancel. ... | Well, you can definitely determine which programs are running by looking for the process names you want (GetProcessesByName()) and killing them.
```
Process[] processes = Process.GetProcessesByName(processName);
foreach(Process process in processes)
{
process.Kill();
}
```
You could just have a list of them you d... |
146,522 | <p>I’ve got a brand new Django project. I’ve added one minimal view function to <code>views.py</code>, and one URL pattern to <code>urls.py</code>, passing the view by function reference instead of a string:</p>
<pre><code># urls.py
# -------
# coding=utf-8
from django.conf.urls.defaults import *
from myapp import ... | [
{
"answer_id": 146524,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "https://Stackoverflow.com/users/3560",
"pm_score": 5,
"selected": true,
"text": "<p>Got it!! The problem is that some of the imports are of <code>myproject.myapp.views</code>, and some are just of <co... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146522",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20578/"
] | I’ve got a brand new Django project. I’ve added one minimal view function to `views.py`, and one URL pattern to `urls.py`, passing the view by function reference instead of a string:
```
# urls.py
# -------
# coding=utf-8
from django.conf.urls.defaults import *
from myapp import views
urlpatterns = patterns('',
... | Got it!! The problem is that some of the imports are of `myproject.myapp.views`, and some are just of `myapp.views`. This is confusing the Python module system enough that it no longer detects the functions as the same object. This is because your main `settings.py` probably has a line like:
```
ROOT_URLCONF = `myproj... |
146,531 | <p>I have a SQL table with news stories and Unix timestamps. I'd like to only keep the 50 newest stories. How would I write an SQL statement to delete any amount of older stories?</p>
| [
{
"answer_id": 146535,
"author": "Davide Vosti",
"author_id": 1812,
"author_profile": "https://Stackoverflow.com/users/1812",
"pm_score": 3,
"selected": false,
"text": "<p>Blockquote</p>\n\n<pre><code>delete from table where id not in (\n select id from table \n order by id desc \n... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146531",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6305/"
] | I have a SQL table with news stories and Unix timestamps. I'd like to only keep the 50 newest stories. How would I write an SQL statement to delete any amount of older stories? | I ended up using two queries since MySQL5 doesn't yet support LIMIT's in subqueries
```
SELECT unixTime FROM entries ORDER BY unixTime DESC LIMIT 49, 1;
DELETE FROM entries WHERE unixTime < $sqlResult;
``` |
146,557 | <p>I was reading a question about the Python <em>global</em> statement ( <a href="https://stackoverflow.com/questions/146359/python-scope">"Python scope"</a> ) and I was remembering about how often I used this statement when I was a Python beginner (I used <em>global</em> a lot) and how, nowadays, years later, I don't ... | [
{
"answer_id": 146562,
"author": "ironfroggy",
"author_id": 19687,
"author_profile": "https://Stackoverflow.com/users/19687",
"pm_score": 4,
"selected": false,
"text": "<p>I've never had a legit use for the statement in any production code in my 3+ years of professional use of Python and... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146557",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20037/"
] | I was reading a question about the Python *global* statement ( ["Python scope"](https://stackoverflow.com/questions/146359/python-scope) ) and I was remembering about how often I used this statement when I was a Python beginner (I used *global* a lot) and how, nowadays, years later, I don't use it at all, ever. I even ... | I use 'global' in a context such as this:
```
_cached_result = None
def myComputationallyExpensiveFunction():
global _cached_result
if _cached_result:
return _cached_result
# ... figure out result
_cached_result = result
return result
```
I use 'global' because it makes sense and is clea... |
146,575 | <p>I'm writing a program (for Mac OS X, using Objective-C) and I need to create a bunch of .webloc files programmatically.</p>
<p>The .webloc file is simply file which is created after you drag-n-drop an URL from Safari's location bar to some folder.</p>
<p>Generally speaking, I need an approach to create items in a ... | [
{
"answer_id": 146605,
"author": "millenomi",
"author_id": 6061,
"author_profile": "https://Stackoverflow.com/users/6061",
"pm_score": 2,
"selected": false,
"text": "<p>It uses a resource fork-based binary format.</p>\n\n<p>Valid workarounds:</p>\n\n<ul>\n<li>Have the user drag a URL fro... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146575",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20294/"
] | I'm writing a program (for Mac OS X, using Objective-C) and I need to create a bunch of .webloc files programmatically.
The .webloc file is simply file which is created after you drag-n-drop an URL from Safari's location bar to some folder.
Generally speaking, I need an approach to create items in a filesystem which ... | It is little known - but there is also a simple plist based file format for weblocs.
When creating webloc files you *DO NOT NEED* to save them using the resource method the other three posters describe. You can also write a simple plist:
```
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD... |
146,576 | <p>The method signature of a Java <code>main</code>method is:</p>
<pre><code>public static void main(String[] args) {
...
}
</code></pre>
<p><strong>Is there a reason why this method must be static?</strong></p>
| [
{
"answer_id": 146581,
"author": "Logan",
"author_id": 3518,
"author_profile": "https://Stackoverflow.com/users/3518",
"pm_score": 3,
"selected": false,
"text": "<p>It's just a convention, but probably more convenient than the alternative. With a static main, all you need to know to invo... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146576",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2937/"
] | The method signature of a Java `main`method is:
```
public static void main(String[] args) {
...
}
```
**Is there a reason why this method must be static?** | The method is static because otherwise there would be ambiguity: which constructor should be called? Especially if your class looks like this:
```
public class JavaClass{
protected JavaClass(int x){}
public void main(String[] args){
}
}
```
Should the JVM call `new JavaClass(int)`? What should it pass for `x`?... |
146,602 | <p>Has anyone had any recent requirements for programming automated DOS Batch style tasks on a Windows box?</p>
<p>I've got some automation to do and I'd rather not sit and write a pile of .BAT files in Notepad if there is a better way of automating these tasks: mainly moving of files under certain date and time condi... | [
{
"answer_id": 146613,
"author": "Mikael Jansson",
"author_id": 18753,
"author_profile": "https://Stackoverflow.com/users/18753",
"pm_score": 2,
"selected": false,
"text": "<p>Try Python.</p>\n"
},
{
"answer_id": 146617,
"author": "jeffm",
"author_id": 1544,
"author_p... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146602",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22376/"
] | Has anyone had any recent requirements for programming automated DOS Batch style tasks on a Windows box?
I've got some automation to do and I'd rather not sit and write a pile of .BAT files in Notepad if there is a better way of automating these tasks: mainly moving of files under certain date and time conditions, as ... | For simple Windows automation beyond BAT files, [VBScript](http://msdn.microsoft.com/en-us/library/sx7b3k7y(VS.85).aspx) and [Powershell](http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx) might be worth a look. If you're wondering where to start first, VBScript+Windows Task Scheduler would be the first place... |
146,604 | <p>I have a new object with a collection of new objects within it on some property as an IList. I see through sql profiler two insert queries being executed.. one for the parent, which has the new guid id, and one for the child, however, the foreign-key on the child that references the parent, is an empty guid. Here is... | [
{
"answer_id": 146640,
"author": "Elie",
"author_id": 23249,
"author_profile": "https://Stackoverflow.com/users/23249",
"pm_score": 4,
"selected": true,
"text": "<p>You may need to add NOT-NULL=\"true\" to your mapping class:</p>\n\n<pre><code><bag name=\"BackerEntries\" table=\"Backe... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146604",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6350/"
] | I have a new object with a collection of new objects within it on some property as an IList. I see through sql profiler two insert queries being executed.. one for the parent, which has the new guid id, and one for the child, however, the foreign-key on the child that references the parent, is an empty guid. Here is my... | You may need to add NOT-NULL="true" to your mapping class:
```
<bag name="BackerEntries" table="BackerEntry" cascade="all" lazy="false" order-by="Priority">
<key column="BackerId" not-null="true"/>
<one-to-many class="BackerEntry" />
</bag>
```
as well as make sure that you have the reverse of the mapping define... |
146,607 | <p>My goal here is to create a very simple template language. At the moment, I'm working on replacing a variable with a value, like this:</p>
<p>This input:</p>
<blockquote>
The Web
</blockquote>
<p>Should produce this output:</p>
<blockquote>
<p>The Web This Is A Test Variable</p>
</blockquote>
<p>I've got i... | [
{
"answer_id": 146637,
"author": "JesperE",
"author_id": 13051,
"author_profile": "https://Stackoverflow.com/users/13051",
"pm_score": 2,
"selected": false,
"text": "<p>Never create your own programming language. Ever. (I used to have an exception to this rule, but not any more.)</p>\n\n... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146607",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19207/"
] | My goal here is to create a very simple template language. At the moment, I'm working on replacing a variable with a value, like this:
This input:
>
> The Web
>
Should produce this output:
>
> The Web This Is A Test Variable
>
>
>
I've got it working. But looking at my code, I'm running multiple identical ... | The first thing that may improve things is to move the re.compile outside the function. The compilation is cached, but there is a speed hit in checking this to see if its compiled.
Another possibility is to use a single regex as below:
```
MatchedQuotes = re.compile(r"(['\"])(.*)\1", re.LOCALE)
item = MatchedQuotes.s... |
146,622 | <p>I'm in the process of learning Erlang. As an exercise I picked up the <a href="http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes" rel="noreferrer">Sieve of Eratosthenes</a> algorithm of generating prime numbers. Here is my code:</p>
<pre><code>-module(seed2).
-export([get/1]).
get(N) -> WorkList = lists:duplic... | [
{
"answer_id": 146626,
"author": "EvilTeach",
"author_id": 7734,
"author_profile": "https://Stackoverflow.com/users/7734",
"pm_score": 2,
"selected": false,
"text": "<p>I approached the problem by using concurrent processing.</p>\n\n<p><a href=\"http://web.archive.org/web/20080911213200/... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13635/"
] | I'm in the process of learning Erlang. As an exercise I picked up the [Sieve of Eratosthenes](http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes) algorithm of generating prime numbers. Here is my code:
```
-module(seed2).
-export([get/1]).
get(N) -> WorkList = lists:duplicate(N, empty),
get(2, N, WorkList, ... | Here's a simple (but not terribly fast) sieve implementation:
```
-module(primes).
-export([sieve/1]).
-include_lib("eunit/include/eunit.hrl").
sieve([]) ->
[];
sieve([H|T]) ->
List = lists:filter(fun(N) -> N rem H /= 0 end, T),
[H|sieve(List)];
sieve(N) ->
sieve(lists:seq(2,N)).
``` |
146,657 | <p>I have a couple of header files, which boil down to:</p>
<p>tree.h:</p>
<pre><code>#include "element.h"
typedef struct tree_
{
struct *tree_ first_child;
struct *tree_ next_sibling;
int tag;
element *obj;
....
} tree;
</code></pre>
<p>and element.h:</p>
<pre><code>#include "tree.h"
typedef ... | [
{
"answer_id": 146665,
"author": "x0n",
"author_id": 6920,
"author_profile": "https://Stackoverflow.com/users/6920",
"pm_score": 0,
"selected": false,
"text": "<p>These are known as \"once-only headers.\" See <a href=\"http://developer.apple.com/DOCUMENTATION/DeveloperTools/gcc-4.0.1/cpp... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146657",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19214/"
] | I have a couple of header files, which boil down to:
tree.h:
```
#include "element.h"
typedef struct tree_
{
struct *tree_ first_child;
struct *tree_ next_sibling;
int tag;
element *obj;
....
} tree;
```
and element.h:
```
#include "tree.h"
typedef struct element_
{
tree *tree_parent;
... | I think the problem here is not the missing include guard but the fact that the two structures need each other in their definition. So it's a type define hann and egg problem.
The way to solve these in C or C++ is to do forward declarations on the type. If you tell the compiler that element is a structure of some sort... |
146,659 | <p>I know this would be easy with position:fixed, but unfortanately I'm stuck with supporting IE 6. How can I do this? I would rather use CSS to be clean, but if I have to use Javascript, that's not the end of the world. In my current implementation I have a "floating footer" that floats above the main content area ... | [
{
"answer_id": 146689,
"author": "Mattias",
"author_id": 261,
"author_profile": "https://Stackoverflow.com/users/261",
"pm_score": 2,
"selected": false,
"text": "<p>I have done this using CSS expressions in the Past.</p>\n\n<p>Try something like this:</p>\n\n<pre><code>.footer {\n pos... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146659",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2484/"
] | I know this would be easy with position:fixed, but unfortanately I'm stuck with supporting IE 6. How can I do this? I would rather use CSS to be clean, but if I have to use Javascript, that's not the end of the world. In my current implementation I have a "floating footer" that floats above the main content area and is... | This may work for you. It works on IE6 and Firefox 2.0.0.17 for me. Give it a shot. I made the footer's height very tall, just for effect. You would obviously change it to what you need. I hope this works for you.
```
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<he... |
146,668 | <p>In ruby I am parsing a date in the following format: 24092008.
I want to convert each section (year, month, date) into a number.</p>
<p>I have split them up using a regex which produces three Strings which I am passing into the Integer constructor.</p>
<pre><code> date =~ /^([\d]{2})([\d]{2})([\d]{4})/
year = I... | [
{
"answer_id": 146679,
"author": "Atiaxi",
"author_id": 2555346,
"author_profile": "https://Stackoverflow.com/users/2555346",
"pm_score": 5,
"selected": true,
"text": "<p>I'm not familiar with regexes, so forgive me if this answer's off-base. I've been assuming that $3, $2, and $1 are s... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146668",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/151/"
] | In ruby I am parsing a date in the following format: 24092008.
I want to convert each section (year, month, date) into a number.
I have split them up using a regex which produces three Strings which I am passing into the Integer constructor.
```
date =~ /^([\d]{2})([\d]{2})([\d]{4})/
year = Integer($3)
month = ... | I'm not familiar with regexes, so forgive me if this answer's off-base. I've been assuming that $3, $2, and $1 are strings. Here's what I did in IRB to replicate the problem:
```
irb(main):003:0> Integer("04")
=> 4
irb(main):004:0> Integer("09")
ArgumentError: invalid value for Integer: "09"
from (irb):4:in `Integ... |
146,704 | <p>Puzzled by the Lua 5.0 documentation references to things like <code>_LOADED</code>, <code>LUA_PATH</code>, <code>_ALERT</code> and so on (that I could not use in Lua 5.1), I discovered all of those have been removed and the functionality put elsewhere. Am I right in thinking that the only one global variable left i... | [
{
"answer_id": 146679,
"author": "Atiaxi",
"author_id": 2555346,
"author_profile": "https://Stackoverflow.com/users/2555346",
"pm_score": 5,
"selected": true,
"text": "<p>I'm not familiar with regexes, so forgive me if this answer's off-base. I've been assuming that $3, $2, and $1 are s... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146704",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12291/"
] | Puzzled by the Lua 5.0 documentation references to things like `_LOADED`, `LUA_PATH`, `_ALERT` and so on (that I could not use in Lua 5.1), I discovered all of those have been removed and the functionality put elsewhere. Am I right in thinking that the only one global variable left in Lua 5.1 is `_VERSION`? | I'm not familiar with regexes, so forgive me if this answer's off-base. I've been assuming that $3, $2, and $1 are strings. Here's what I did in IRB to replicate the problem:
```
irb(main):003:0> Integer("04")
=> 4
irb(main):004:0> Integer("09")
ArgumentError: invalid value for Integer: "09"
from (irb):4:in `Integ... |
146,732 | <p>Within SQL Server Integration Services (SSIS) there is the ability to setup a connection to a flat file that can hold millions of records and have that data pushed to a SQL DB. Furthermore, this process can be called from a C# app by referencing and using the Microsoft.SqlServer.Dts.Runtime namespace. </p>
<p>Would... | [
{
"answer_id": 146752,
"author": "Michael Brown",
"author_id": 14359,
"author_profile": "https://Stackoverflow.com/users/14359",
"pm_score": 1,
"selected": false,
"text": "<p>SSIS is incredibly fast. In addition, if it's something that needs to occur repeatedly, you can setup an agent to... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146732",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7952/"
] | Within SQL Server Integration Services (SSIS) there is the ability to setup a connection to a flat file that can hold millions of records and have that data pushed to a SQL DB. Furthermore, this process can be called from a C# app by referencing and using the Microsoft.SqlServer.Dts.Runtime namespace.
Would a flat fi... | I can only speak for myself and my experience. I would go with SSIS, since this is one of those cases where you might be re-inventing the wheel unnecessarily. This is a repetitive task that has already been solved by SSIS.
I have about 57 jobs (combination of DTS and SSIS) that I manage on a daily basis. Four of those... |
146,737 | <p>So I'm programming along in a nice, up to date, object oriented fashion. I regularly make use of the various aspects of OOP that PHP implements but I am wondering when might I need to use closures. Any experts out there that can shed some light on when it would be useful to implement closures?</p>
| [
{
"answer_id": 146775,
"author": "Dan Udey",
"author_id": 21450,
"author_profile": "https://Stackoverflow.com/users/21450",
"pm_score": 4,
"selected": false,
"text": "<p>When you will need a function in the future which performs a task that you have decided upon now.</p>\n\n<p>For exampl... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146737",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11252/"
] | So I'm programming along in a nice, up to date, object oriented fashion. I regularly make use of the various aspects of OOP that PHP implements but I am wondering when might I need to use closures. Any experts out there that can shed some light on when it would be useful to implement closures? | PHP will support closures natively in 5.3. A closure is good when you want a local function that's only used for some small, specific purpose. The [RFC for closures](http://wiki.php.net/rfc/closures) gives a good example:
```
function replace_spaces ($text) {
$replacement = function ($matches) {
return str... |
146,743 | <p>I need to store a list of key value pairs of (integer, boolean) in .NET</p>
<p>When I use a dictionary it re-orders them. Is there a built in collection that will handle this.</p>
| [
{
"answer_id": 146751,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 4,
"selected": true,
"text": "<pre><code> List<KeyValuePair<int, bool>> l = \n new List<KeyValuePair<in... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146743",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4998/"
] | I need to store a list of key value pairs of (integer, boolean) in .NET
When I use a dictionary it re-orders them. Is there a built in collection that will handle this. | ```
List<KeyValuePair<int, bool>> l =
new List<KeyValuePair<int, bool>>();
l.Add(new KeyValuePair<int, bool>(1, false));
``` |
146,789 | <p>This question is related to (but perhaps not quite the same as):</p>
<p><a href="https://stackoverflow.com/questions/61451/does-django-have-html-helpers">Does Django have HTML helpers?</a></p>
<p>My problem is this: In Django, I am constantly reproducing the basic formatting for low-level database objects. Here's ... | [
{
"answer_id": 146829,
"author": "jamting",
"author_id": 2639,
"author_profile": "https://Stackoverflow.com/users/2639",
"pm_score": 2,
"selected": false,
"text": "<p>I would use a template tag outputting data using a template html-file a k a <a href=\"http://docs.djangoproject.com/en/de... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19212/"
] | This question is related to (but perhaps not quite the same as):
[Does Django have HTML helpers?](https://stackoverflow.com/questions/61451/does-django-have-html-helpers)
My problem is this: In Django, I am constantly reproducing the basic formatting for low-level database objects. Here's an example:
I have two clas... | Sounds like an [inclusion tag](http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#inclusion-tags) is what you're looking for. You could have a template and tag for each major variation and use the tag's arguments to customise the context for each template as required.
Basic tag definition:
```
@register... |
146,794 | <p>I'm running into an unusual problem in my unit tests. The class I'm testing creates a dependency property dynamically at runtime and the type of that dependency property can vary depending on the circumstances. While writing my unit tests, I need to create the dependency property with different types and that leads ... | [
{
"answer_id": 146830,
"author": "Micah",
"author_id": 17744,
"author_profile": "https://Stackoverflow.com/users/17744",
"pm_score": 1,
"selected": false,
"text": "<p>I don't think you can un-register a dependency property but you can redefine it by overriding the metadata like this:</p>... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146794",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9045/"
] | I'm running into an unusual problem in my unit tests. The class I'm testing creates a dependency property dynamically at runtime and the type of that dependency property can vary depending on the circumstances. While writing my unit tests, I need to create the dependency property with different types and that leads to ... | I had similar issue just yesterday when trying to test my own DependencyProperty creating class. I came across this question, and noticed there was no real solution to unregister dependency properties. So I did some digging using [Red Gate .NET Reflector](http://www.red-gate.com/products/reflector/) to see what I could... |
146,795 | <p>I can't use the <code>Get*Profile</code> functions because I'm using an older version of the Windows CE platform SDK which doesn't have those. It doesn't have to be too general.</p>
<pre><code>[section]
name = some string
</code></pre>
<p>I just need to open the file, check for the existence of "section", and the ... | [
{
"answer_id": 146830,
"author": "Micah",
"author_id": 17744,
"author_profile": "https://Stackoverflow.com/users/17744",
"pm_score": 1,
"selected": false,
"text": "<p>I don't think you can un-register a dependency property but you can redefine it by overriding the metadata like this:</p>... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146795",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3146/"
] | I can't use the `Get*Profile` functions because I'm using an older version of the Windows CE platform SDK which doesn't have those. It doesn't have to be too general.
```
[section]
name = some string
```
I just need to open the file, check for the existence of "section", and the value associated with "name". Standar... | I had similar issue just yesterday when trying to test my own DependencyProperty creating class. I came across this question, and noticed there was no real solution to unregister dependency properties. So I did some digging using [Red Gate .NET Reflector](http://www.red-gate.com/products/reflector/) to see what I could... |
146,801 | <p>I am using virtual machines for development,but each time I need a new VM, I copy the file and create a new server, but I need a new name for the server to add it to our network.</p>
<p>After renaming the server, the Sharepoint sites have many errors and do not run.</p>
| [
{
"answer_id": 146830,
"author": "Micah",
"author_id": 17744,
"author_profile": "https://Stackoverflow.com/users/17744",
"pm_score": 1,
"selected": false,
"text": "<p>I don't think you can un-register a dependency property but you can redefine it by overriding the metadata like this:</p>... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13813/"
] | I am using virtual machines for development,but each time I need a new VM, I copy the file and create a new server, but I need a new name for the server to add it to our network.
After renaming the server, the Sharepoint sites have many errors and do not run. | I had similar issue just yesterday when trying to test my own DependencyProperty creating class. I came across this question, and noticed there was no real solution to unregister dependency properties. So I did some digging using [Red Gate .NET Reflector](http://www.red-gate.com/products/reflector/) to see what I could... |
146,835 | <p>I have a project the requires the use of the exec family. My project consist of making an interactive shell. The shell will implement a few basic commands like cd, ls, echo, etc. I have been researching the use of exec, but have not found a useful site. Any suggested links would help.</p>
<pre><code>int ret;
ret = ... | [
{
"answer_id": 146885,
"author": "Jose Vega",
"author_id": 17162,
"author_profile": "https://Stackoverflow.com/users/17162",
"pm_score": 2,
"selected": false,
"text": "<p>doing<br> </p>\n\n<pre><code>int fd = 1;\ndup(fd);\nclose(fd);\n</code></pre>\n\n<p>gets the output to the screen.</p... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146835",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17162/"
] | I have a project the requires the use of the exec family. My project consist of making an interactive shell. The shell will implement a few basic commands like cd, ls, echo, etc. I have been researching the use of exec, but have not found a useful site. Any suggested links would help.
```
int ret;
ret = execl ("/bin/l... | The code you wrote works for me in a simple test program that does nothing else. Remember, when you call execl, the process retains all of the old file handles. So whatever stdout was when you call execl, it will be the same when the new binary is loaded. If you just want the output to go to the terminal, just make sur... |
146,893 | <p>I am a firm believer in the idea that one of the most important things you get from learning a new language is not how to use a new language, but the knowledge of concepts that you get from it. I am not asking how important or useful you think Assembly is, nor do I care if I never use it in any of my real projects. ... | [
{
"answer_id": 146908,
"author": "itsmatt",
"author_id": 7862,
"author_profile": "https://Stackoverflow.com/users/7862",
"pm_score": 2,
"selected": false,
"text": "<p>Memory, registers, jumps, loops, shifts and the various operations one can perform in assembler. I don't miss the days o... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146893",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23175/"
] | I am a firm believer in the idea that one of the most important things you get from learning a new language is not how to use a new language, but the knowledge of concepts that you get from it. I am not asking how important or useful you think Assembly is, nor do I care if I never use it in any of my real projects.
W... | I think assembly language can teach you lots of little things, as well as a few big concepts.
I'll list a few things I can think of here, but there is no substitute for going and learning and using both x86 and a RISC instruction set.
You probably think that integer operations are fastest. If you want to find an inte... |
146,896 | <p>How can I access <code>UserId</code> in ASP.NET Membership without using <code>Membership.GetUser(username)</code> in ASP.NET Web Application Project?</p>
<p>Can <code>UserId</code> be included in <code>Profile</code> namespace next to <code>UserName</code> (<code>System.Web.Profile.ProfileBase</code>)?</p>
| [
{
"answer_id": 147660,
"author": "Ted",
"author_id": 9344,
"author_profile": "https://Stackoverflow.com/users/9344",
"pm_score": 4,
"selected": false,
"text": "<p>Is your reason for this to save a database call everytime you need the UserId? If so, when I'm using the ASP.NET MembershipPr... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146896",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23280/"
] | How can I access `UserId` in ASP.NET Membership without using `Membership.GetUser(username)` in ASP.NET Web Application Project?
Can `UserId` be included in `Profile` namespace next to `UserName` (`System.Web.Profile.ProfileBase`)? | I decided to write authentication of users users on my own (very simple but it works) and I should done this long time ago.
My original question was about UserId and it is not available from:
```
System.Web.HttpContext.Current.User.Identity.Name
``` |
146,897 | <p>This is a bit of a weird one, and I could well be coding this completely wrong - hence why I've hit the same error twice in two days, in completely different parts of a script. The code I'm using is below:</p>
<pre><code>
public function findAll( $constraints = array() ) {
// Select all records
... | [
{
"answer_id": 146925,
"author": "troelskn",
"author_id": 18180,
"author_profile": "https://Stackoverflow.com/users/18180",
"pm_score": 4,
"selected": true,
"text": "<p>That's because <a href=\"http://docs.php.net/manual/en/pdostatement.bindparam.php\" rel=\"noreferrer\"><code>bindParam<... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146897",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/393028/"
] | This is a bit of a weird one, and I could well be coding this completely wrong - hence why I've hit the same error twice in two days, in completely different parts of a script. The code I'm using is below:
```
public function findAll( $constraints = array() ) {
// Select all records
$SQL = 'SELEC... | That's because [`bindParam`](http://docs.php.net/manual/en/pdostatement.bindparam.php) works by binding to a variable, and you are re-using the variable (`$value`) for multiple values. Try with [`bindValue`](http://docs.php.net/manual/en/pdostatement.bindvalue.php) instead.
Or even better yet; Pass the values as an ar... |
146,914 | <p>Is there any way to see an overview of what kind of queries are spent the most time on every day on MySQL?</p>
| [
{
"answer_id": 146922,
"author": "petr k.",
"author_id": 15497,
"author_profile": "https://Stackoverflow.com/users/15497",
"pm_score": 1,
"selected": false,
"text": "<p>You can always set up query logging as described here:<br>\n<a href=\"http://dev.mysql.com/doc/refman/5.0/en/query-log.... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146914",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8005/"
] | Is there any way to see an overview of what kind of queries are spent the most time on every day on MySQL? | Yes, mysql can create a slow query log. You'll need to start `mysqld` with the `--log-slow-queries` flag:
```
mysqld --log-slow-queries=/path/to/your.log
```
Then you can parse the log using `mysqldumpslow`:
```
mysqldumpslow /path/to/your.log
```
More info is here (<http://dev.mysql.com/doc/refman/5.0/en/slow-qu... |
146,916 | <p>I have the following problem:</p>
<p>I have an HTML textbox (<code><input type="text"></code>) whose contents are modified by a script I cannot touch (it is my page, but i'm using external components).</p>
<p>I want to be notified in my script every time the value of that textbox changes, so I can react to i... | [
{
"answer_id": 146928,
"author": "noah",
"author_id": 12034,
"author_profile": "https://Stackoverflow.com/users/12034",
"pm_score": 4,
"selected": true,
"text": "<p>As you've implied, change (and other events) only fire when the user takes some action. A script modifying things won't fir... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146916",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3314/"
] | I have the following problem:
I have an HTML textbox (`<input type="text">`) whose contents are modified by a script I cannot touch (it is my page, but i'm using external components).
I want to be notified in my script every time the value of that textbox changes, so I can react to it.
I've tried this:
```
txtStart... | As you've implied, change (and other events) only fire when the user takes some action. A script modifying things won't fire any events. Your only solution is to find some hook into the control that you can hook up to your listener.
Here is how I would do it:
```
basicDatePicker.selectDate = basicDatePicker.selectDat... |
146,931 | <p>I am working with a log of events where there are about 60 different "types" of events. Each event shares about 10 properties, and then there are subcategories of events that share various extra properties.</p>
<p>How I work with these events does depend on their type or what categorical interfaces they implement.<... | [
{
"answer_id": 146946,
"author": "petr k.",
"author_id": 15497,
"author_profile": "https://Stackoverflow.com/users/15497",
"pm_score": 1,
"selected": false,
"text": "<p>I would go with the object per event type solution, but I would instead group commonly used combinations of interfaces ... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146931",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2204759/"
] | I am working with a log of events where there are about 60 different "types" of events. Each event shares about 10 properties, and then there are subcategories of events that share various extra properties.
How I work with these events does depend on their type or what categorical interfaces they implement.
But it se... | It depends on if each type of event inherently has different behavior that the event itself can execute.
Do your Event objects need methods that behave differently per type? If so, use inheritance.
If not, use an enum to classify the event type. |
146,943 | <p>This is something simple I came up with for <a href="https://stackoverflow.com/questions/146795/how-to-read-config-file-entries-from-an-ini-file">this question</a>. I'm not entirely happy with it and I saw it as a chance to help improve my use of STL and streams based programming.</p>
<pre><code>std::wifstream file... | [
{
"answer_id": 146998,
"author": "Airsource Ltd",
"author_id": 18017,
"author_profile": "https://Stackoverflow.com/users/18017",
"pm_score": 1,
"selected": false,
"text": "<p>This:</p>\n\n<pre><code>for (size_t i=1; i<line.length(); i++)\n {\n if (line[i]!=L']')\n ... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146943",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3146/"
] | This is something simple I came up with for [this question](https://stackoverflow.com/questions/146795/how-to-read-config-file-entries-from-an-ini-file). I'm not entirely happy with it and I saw it as a chance to help improve my use of STL and streams based programming.
```
std::wifstream file(L"\\Windows\\myini.ini")... | >
> // what if the name = value does not have white space?
>
> // what if the value is enclosed in quotes?
>
>
>
I would use boost::regex to match for every different type of element, something like:
```
boost::smatch matches;
boost::regex name_value("(\S+)\s*=\s*(\S+)");
if(boost::regex_match(line, matches, ... |
146,963 | <p>I'm creating an ORM in PHP, and I've got a class 'ORM' which basically creates an object corresponding to a database table (I'm aiming for similar to/same functionality as an ActiveRecord pattern.) ORM itself extends 'Database', which sets up the database connection. </p>
<p>So, I can call: <code><pre>$c = new Cust... | [
{
"answer_id": 146969,
"author": "petr k.",
"author_id": 15497,
"author_profile": "https://Stackoverflow.com/users/15497",
"pm_score": 1,
"selected": false,
"text": "<p>Yes, place your business logic in a descendant class. This is a very common pattern seen in most Data Access Layers gen... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146963",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/393028/"
] | I'm creating an ORM in PHP, and I've got a class 'ORM' which basically creates an object corresponding to a database table (I'm aiming for similar to/same functionality as an ActiveRecord pattern.) ORM itself extends 'Database', which sets up the database connection.
So, I can call: ````
$c = new Customer();
$c->name... | I agree with the other answers here - put the additional methods into a descendant class. I'd also add an asterisk to that though: each time you extend the class with extra methods, think about what you are trying to achieve with the extension, and think about whether or not it can be generalised and worked back into t... |
146,973 | <p>I'm making an automated script to read a list from a site posting the latest compiled code. That's the part I've already figured out. The next part of the script is to grab that compiled code from a server with an Untrusted Cert.</p>
<p>This is how I'm going about grabbing the file:</p>
<pre><code>$web = new-obj... | [
{
"answer_id": 147006,
"author": "Brad Wilson",
"author_id": 1554,
"author_profile": "https://Stackoverflow.com/users/1554",
"pm_score": 3,
"selected": true,
"text": "<p>You need to write a callback handler for <a href=\"http://msdn.microsoft.com/en-us/library/system.net.servicepointmana... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146973",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm making an automated script to read a list from a site posting the latest compiled code. That's the part I've already figured out. The next part of the script is to grab that compiled code from a server with an Untrusted Cert.
This is how I'm going about grabbing the file:
```
$web = new-object System.Net.WebClien... | You need to write a callback handler for [ServicePointManager.ServerCertificateValidationCallback](http://msdn.microsoft.com/en-us/library/system.net.servicepointmanager.servercertificatevalidationcallback.aspx). |
146,986 | <p>I'm writing some semi-portable code and want to be able to detect when I'm compiling for iPhone. So I want something like <code>#ifdef IPHONE_SDK...</code>. </p>
<p>Presumably Xcode defines something, but I can't see anything under project properties, and Google isn't much help.</p>
| [
{
"answer_id": 147027,
"author": "Airsource Ltd",
"author_id": 18017,
"author_profile": "https://Stackoverflow.com/users/18017",
"pm_score": 8,
"selected": true,
"text": "<p>It's in the SDK docs under \"Compiling source code conditionally\"</p>\n\n<p>The relevant definitions are TARGET_O... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146986",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18017/"
] | I'm writing some semi-portable code and want to be able to detect when I'm compiling for iPhone. So I want something like `#ifdef IPHONE_SDK...`.
Presumably Xcode defines something, but I can't see anything under project properties, and Google isn't much help. | It's in the SDK docs under "Compiling source code conditionally"
The relevant definitions are TARGET\_OS\_IPHONE (and he deprecated TARGET\_IPHONE\_SIMULATOR), which are defined in /usr/include/TargetConditionals.h within the iOS framework. On earlier versions of the toolchain, you had to write:
```
#include "TargetC... |
146,989 | <p>One of my nasty (?) programming habits in C++ and Java is to always precede calls or accesses to members with a <code>this</code>. For example: <code>this.process(this.event)</code>.</p>
<p>A few of my students commented on this, and I'm wondering if I am teaching bad habits. </p>
<p>My rationale is:</p>
<ol>
<li... | [
{
"answer_id": 146995,
"author": "cynicalman",
"author_id": 410,
"author_profile": "https://Stackoverflow.com/users/410",
"pm_score": 6,
"selected": false,
"text": "<p>I think it's less readable, especially in environments where fields are highlighted differently from local variables. T... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146989",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23072/"
] | One of my nasty (?) programming habits in C++ and Java is to always precede calls or accesses to members with a `this`. For example: `this.process(this.event)`.
A few of my students commented on this, and I'm wondering if I am teaching bad habits.
My rationale is:
1. Makes code more readable — Easier to distinguish... | I think it's less readable, especially in environments where fields are highlighted differently from local variables. The only time I want to see "this" is when it is required, for example:
```
this.fieldName = fieldName
```
When assigning the field.
That said, if you need some way to differentiate fields for some ... |
146,994 | <p>I'm looking for a free, preferably open source, http <a href="http://en.wikipedia.org/wiki/Image_server" rel="noreferrer">image processing server</a>. I.e. I would send it a request like this:</p>
<pre><code>http://myimageserver/rotate?url=http%3A%2F%2Fstackoverflow.com%2FContent%2FImg%2Fstackoverflow-logo-250.png&... | [
{
"answer_id": 147012,
"author": "Ferruccio",
"author_id": 4086,
"author_profile": "https://Stackoverflow.com/users/4086",
"pm_score": 2,
"selected": false,
"text": "<p>You can use <a href=\"http://libgd.org\" rel=\"nofollow noreferrer\">LibGD</a> or <a href=\"http://www.imagemagick.org\... | 2008/09/28 | [
"https://Stackoverflow.com/questions/146994",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21239/"
] | I'm looking for a free, preferably open source, http [image processing server](http://en.wikipedia.org/wiki/Image_server). I.e. I would send it a request like this:
```
http://myimageserver/rotate?url=http%3A%2F%2Fstackoverflow.com%2FContent%2FImg%2Fstackoverflow-logo-250.png&angle=90
```
and it would return that im... | The [ImageResizing.Net library](http://imageresizing.net) is both a .NET library and an IIS module. It's an image server or an image library, whichever you prefer.
It's open-source, under an [MIT-style license](http://imageresizing.net/licenses/), and is supported by plugins.
It has excellent performance, and suppor... |
147,040 | <p>Is there a way to have Visual Studio 2008 automatically add heading information to files? For example, "Copyright 2008" or something along those lines. I've been digging through the options, but nothing seems to be jumping out at me.</p>
| [
{
"answer_id": 147043,
"author": "TheSoftwareJedi",
"author_id": 18941,
"author_profile": "https://Stackoverflow.com/users/18941",
"pm_score": 3,
"selected": true,
"text": "<p>I assume you'd like to modify the class file templates. They're in:</p>\n\n<pre><code>%ProgramFiles%\\Microsoft... | 2008/09/29 | [
"https://Stackoverflow.com/questions/147040",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1880/"
] | Is there a way to have Visual Studio 2008 automatically add heading information to files? For example, "Copyright 2008" or something along those lines. I've been digging through the options, but nothing seems to be jumping out at me. | I assume you'd like to modify the class file templates. They're in:
```
%ProgramFiles%\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Code\1033
```
[More specific details here](http://blogs.southworks.net/jpgarcia/2008/09/01/visual-studio-2008-templates-compliant-with-microsoft-stylecop/) |
147,049 | <p>In other words, is it correct to use:</p>
<pre><code>public class CustomerList : System.Collections.Generic.List<Customer>
{
/// supposed to be empty
}
</code></pre>
<p>instead of:</p>
<pre><code>using CustomerList = System.Collections.Generic.List<Customer>
</code></pre>
<p>I'd rather use the fi... | [
{
"answer_id": 147060,
"author": "Ed S.",
"author_id": 1053,
"author_profile": "https://Stackoverflow.com/users/1053",
"pm_score": 4,
"selected": false,
"text": "<p>well, unless you are adding some functionality to the base class there is no point in creating a wrapper object. I would g... | 2008/09/29 | [
"https://Stackoverflow.com/questions/147049",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7839/"
] | In other words, is it correct to use:
```
public class CustomerList : System.Collections.Generic.List<Customer>
{
/// supposed to be empty
}
```
instead of:
```
using CustomerList = System.Collections.Generic.List<Customer>
```
I'd rather use the first approach because I'd just define CustomerList once, and e... | Don't do it. When people read:
```
List<Customer>
```
they immediately understand it. When they read:
```
CustomerList
```
they have to go and figure out what a CustomerList is, and that makes your code harder to read. Unless you are the only one working on your codebase, writing readable code is a good idea. |
147,053 | <p>I'm creating a new mail item, in C# VS-2008 outlook 2007, and attaching a file. The first issue is that I don't see an attachment area under the subject line showing the attachment. If I send the e-mail its properties show that there is an attachment and the e-mail size has grown by the attachment amount. I just ... | [
{
"answer_id": 147188,
"author": "John Dyer",
"author_id": 2862,
"author_profile": "https://Stackoverflow.com/users/2862",
"pm_score": 2,
"selected": false,
"text": "<p>I have found the issue. I change the code to use the following:</p>\n\n<pre><code>attachments.Add(ReleaseForm.ZipFile,... | 2008/09/29 | [
"https://Stackoverflow.com/questions/147053",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2862/"
] | I'm creating a new mail item, in C# VS-2008 outlook 2007, and attaching a file. The first issue is that I don't see an attachment area under the subject line showing the attachment. If I send the e-mail its properties show that there is an attachment and the e-mail size has grown by the attachment amount. I just cannot... | I have found the issue. I change the code to use the following:
```
attachments.Add(ReleaseForm.ZipFile, Outlook.OlAttachmentType.olByValue, Type.Missing, Type.Missing);
```
It appears that the Position and DisplayName parameters control what happens with an olByValue. Using Type.Missing and now I see the attachment... |
147,083 | <p>I have a standard windows server that inherits from the ServiceBase class.</p>
<p>On the OnStart method I want to check for certain conditions before I get to the main purpose of what my service does.</p>
<p>For example:</p>
<pre><code>protected override void OnStart(string[] args)
{
if (condition == false)
{... | [
{
"answer_id": 147127,
"author": "Lounges",
"author_id": 8918,
"author_profile": "https://Stackoverflow.com/users/8918",
"pm_score": 5,
"selected": true,
"text": "<p>Checkout the source for the wordpress app. They might be using XML-RPC. :)</p>\n\n<p><a href=\"http://iphone.wordpress.or... | 2008/09/29 | [
"https://Stackoverflow.com/questions/147083",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2049/"
] | I have a standard windows server that inherits from the ServiceBase class.
On the OnStart method I want to check for certain conditions before I get to the main purpose of what my service does.
For example:
```
protected override void OnStart(string[] args)
{
if (condition == false)
{
EventLog.WriteEntry("Pr... | Checkout the source for the wordpress app. They might be using XML-RPC. :)
<http://iphone.wordpress.org/> |
147,126 | <p>Short Q.: What does this exception mean? "EXC_BAD_ACCESS (0x0001)"</p>
<p>Full Q.: How can I use this error log info (and thread particulars that I omitted here) to diagnosis this app crash? (NB: I have no expertise with crash logs or OS kernels.)</p>
<p>In this case, my email client (Eudora) crashes immediately o... | [
{
"answer_id": 147150,
"author": "Dprado",
"author_id": 21943,
"author_profile": "https://Stackoverflow.com/users/21943",
"pm_score": 1,
"selected": false,
"text": "<p>Even if you page the apps memory to disk and keep it in memory, you would still have to decide when should an applicatio... | 2008/09/29 | [
"https://Stackoverflow.com/questions/147126",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23306/"
] | Short Q.: What does this exception mean? "EXC\_BAD\_ACCESS (0x0001)"
Full Q.: How can I use this error log info (and thread particulars that I omitted here) to diagnosis this app crash? (NB: I have no expertise with crash logs or OS kernels.)
In this case, my email client (Eudora) crashes immediately on launch, every... | According to this [1](http://www.linux-tutorial.info/modules.php?name=MContent&pageid=314) that is exactly what Linux does.
I'm still trying to make sense of a lot of this, so any authoritative links would be appreciated. |
147,129 | <p><strong>Is there a better way of binding a list of base class to a UI other than downcasting e.g:</strong></p>
<pre><code>static void Main(string[] args) {
List<Animal> list = new List<Animal>();
Pig p = new Pig(5);
Dog d = new Dog("/images/dog1.jpg");
list.Add(p);
list.Add(d... | [
{
"answer_id": 147139,
"author": "Dan Herbert",
"author_id": 392,
"author_profile": "https://Stackoverflow.com/users/392",
"pm_score": 3,
"selected": false,
"text": "<p>Why not make Animal include an abstract method that Pig and Dog are forced to implement </p>\n\n<pre><code>public clas... | 2008/09/29 | [
"https://Stackoverflow.com/questions/147129",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1736/"
] | **Is there a better way of binding a list of base class to a UI other than downcasting e.g:**
```
static void Main(string[] args) {
List<Animal> list = new List<Animal>();
Pig p = new Pig(5);
Dog d = new Dog("/images/dog1.jpg");
list.Add(p);
list.Add(d);
foreach (Animal a in list)
... | When faced with this type of problem, I follow the [visitor pattern](http://en.wikipedia.org/wiki/Visitor_pattern).
```
interface IVisitor
{
void DoPigStuff(Piggy p);
void DoDogStuff(Doggy d);
}
class GuiVisitor : IVisitor
{
void DoPigStuff(Piggy p)
{
label1.Text = String.Format("The pigs tail is {0}", p.... |
147,173 | <p>I am trying to understand some assembly.</p>
<p>The assembly as follows, I am interested in the <code>testl</code> line:</p>
<pre><code>000319df 8b4508 movl 0x08(%ebp), %eax
000319e2 8b4004 movl 0x04(%eax), %eax
000319e5 85c0 testl %eax, %eax
000319e7 7407 je 0x00... | [
{
"answer_id": 147176,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 8,
"selected": true,
"text": "<p>It tests whether <code>eax</code> is 0, or above, or below. In this case, the jump is taken if <code>eax</code> is 0.</p>\... | 2008/09/29 | [
"https://Stackoverflow.com/questions/147173",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10733/"
] | I am trying to understand some assembly.
The assembly as follows, I am interested in the `testl` line:
```
000319df 8b4508 movl 0x08(%ebp), %eax
000319e2 8b4004 movl 0x04(%eax), %eax
000319e5 85c0 testl %eax, %eax
000319e7 7407 je 0x000319f0
```
I am trying to un... | It tests whether `eax` is 0, or above, or below. In this case, the jump is taken if `eax` is 0. |
147,178 | <p>Suppose I have a date, i.e. year, month and day, as integers. What's a good (correct), concise and fairly readable algorithm for computing the <a href="http://en.wikipedia.org/wiki/ISO_8601" rel="noreferrer">ISO 8601</a> <a href="http://en.wikipedia.org/wiki/ISO_week_date" rel="noreferrer">week number</a> of the wee... | [
{
"answer_id": 147193,
"author": "technophile",
"author_id": 23029,
"author_profile": "https://Stackoverflow.com/users/23029",
"pm_score": 4,
"selected": false,
"text": "<p>I believe you can use the Calendar object (just set FirstDayOfWeek to Monday and MinimalDaysInFirstWeek to 4 to get... | 2008/09/29 | [
"https://Stackoverflow.com/questions/147178",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9511/"
] | Suppose I have a date, i.e. year, month and day, as integers. What's a good (correct), concise and fairly readable algorithm for computing the [ISO 8601](http://en.wikipedia.org/wiki/ISO_8601) [week number](http://en.wikipedia.org/wiki/ISO_week_date) of the week the given date falls into? I have come across some truly ... | tl;dr
=====
```
LocalDate.of( 2015 , 12 , 30 )
.get (
IsoFields.WEEK_OF_WEEK_BASED_YEAR
)
```
>
> 53
>
>
>
…or…
```
org.threeten.extra.YearWeek.from (
LocalDate.of( 2015 , 12 , 30 )
)
```
>
> 2015-W53
>
>
>
java.time
=========
Support for the [ISO 8601 week](https:/... |
147,208 | <p>Is there a way to hide table rows without affecting the overall table width? I've got some javascript that shows/hides some table rows, but when the rows are set to <code>display: none;</code>, the table with shrinks to fit the contents of the visible rows.</p>
| [
{
"answer_id": 147216,
"author": "levik",
"author_id": 4465,
"author_profile": "https://Stackoverflow.com/users/4465",
"pm_score": 4,
"selected": true,
"text": "<p>If you are looking to preserve the overall width of the table, you can check it prior to hiding a row, and explicitly set th... | 2008/09/29 | [
"https://Stackoverflow.com/questions/147208",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5291/"
] | Is there a way to hide table rows without affecting the overall table width? I've got some javascript that shows/hides some table rows, but when the rows are set to `display: none;`, the table with shrinks to fit the contents of the visible rows. | If you are looking to preserve the overall width of the table, you can check it prior to hiding a row, and explicitly set the width style property to this value:
```
table.style.width = table.clientWidth + "px";
table.rows[3].style.display = "none";
```
However, this may cause the individual columns to reflow when y... |
147,210 | <p>I have a T-SQL <strong>table variable</strong> (not a table) which has an auto incrementing identity column. I want to clear all data from this variable and reset the identity column value to 1. How can this be done?</p>
| [
{
"answer_id": 147224,
"author": "Stephen Wrighton",
"author_id": 7516,
"author_profile": "https://Stackoverflow.com/users/7516",
"pm_score": 5,
"selected": false,
"text": "<p>Truncating the table will dump ALL the data, and reset the identity seed.</p>\n\n<p>Otherwise, you can use this ... | 2008/09/29 | [
"https://Stackoverflow.com/questions/147210",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/747/"
] | I have a T-SQL **table variable** (not a table) which has an auto incrementing identity column. I want to clear all data from this variable and reset the identity column value to 1. How can this be done? | If you're using a table variable, you can't do it. If it were a table, you could truncate it or use `DBCC CHECKIDENT`. But, if you *have* to use a table variable, you have to use something other than an identity column. Or, more accurately, use the identity column in your table variable but output using `ROWNUMBER`:
`... |
147,240 | <pre><code>('1' * N) !~ /^1?$|^(11+?)\1+$/
</code></pre>
<p>On the net, I found this piece of Ruby code that works for N >= 0 that determines whether or not N is a prime. From what I can tell, it looks like play with regex but I have no idea how it works. Could someone tell me how it works?</p>
| [
{
"answer_id": 147251,
"author": "Jay",
"author_id": 20840,
"author_profile": "https://Stackoverflow.com/users/20840",
"pm_score": 6,
"selected": true,
"text": "<p>You can find a lengthy explanation of this code here: \n<a href=\"http://www.noulakaz.net/weblog/2007/03/18/a-regular-expres... | 2008/09/29 | [
"https://Stackoverflow.com/questions/147240",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | ```
('1' * N) !~ /^1?$|^(11+?)\1+$/
```
On the net, I found this piece of Ruby code that works for N >= 0 that determines whether or not N is a prime. From what I can tell, it looks like play with regex but I have no idea how it works. Could someone tell me how it works? | You can find a lengthy explanation of this code here:
<http://www.noulakaz.net/weblog/2007/03/18/a-regular-expression-to-check-for-prime-numbers/> |
147,267 | <p>Here's what I am trying to do: </p>
<pre><code>typedef enum { ONE, TWO, THREE } Numbers;
</code></pre>
<p>I am trying to write a function that would do a switch case similar to the following: </p>
<pre><code>char num_str[10];
int process_numbers_str(Numbers num) {
switch(num) {
case ONE:
case TWO:
... | [
{
"answer_id": 147283,
"author": "sk.",
"author_id": 16399,
"author_profile": "https://Stackoverflow.com/users/16399",
"pm_score": 5,
"selected": true,
"text": "<p>There's no built-in solution. The easiest way is with an array of <code>char*</code> where the enum's int value indexes to a... | 2008/09/29 | [
"https://Stackoverflow.com/questions/147267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9628/"
] | Here's what I am trying to do:
```
typedef enum { ONE, TWO, THREE } Numbers;
```
I am trying to write a function that would do a switch case similar to the following:
```
char num_str[10];
int process_numbers_str(Numbers num) {
switch(num) {
case ONE:
case TWO:
case THREE:
{
strcpy(num_str... | There's no built-in solution. The easiest way is with an array of `char*` where the enum's int value indexes to a string containing the descriptive name of that enum. If you have a sparse `enum` (one that doesn't start at 0 or has gaps in the numbering) where some of the `int` mappings are high enough to make an array-... |
147,307 | <p>The System.Diagnostics.EventLog class provides a way to interact with a windows event log. I use it all the time for simple logging...</p>
<pre><code>System.Diagnostics.EventLog.WriteEntry("MyEventSource", "My Special Message")
</code></pre>
<p>Is there a way to set the user information in the resulting event log... | [
{
"answer_id": 147318,
"author": "Kev",
"author_id": 419,
"author_profile": "https://Stackoverflow.com/users/419",
"pm_score": 0,
"selected": false,
"text": "<p>You need to add it yourself into the event message.</p>\n\n<p>Use the System.Security.Principal namespace to get the current id... | 2008/09/29 | [
"https://Stackoverflow.com/questions/147307",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23303/"
] | The System.Diagnostics.EventLog class provides a way to interact with a windows event log. I use it all the time for simple logging...
```
System.Diagnostics.EventLog.WriteEntry("MyEventSource", "My Special Message")
```
Is there a way to set the user information in the resulting event log entry using .NET? | Toughie ...
I looked for a way to fill the user field with a .NET method. Unfortunately there is none, and you must import the plain old Win32 API [ReportEvent function](<http://msdn.microsoft.com/en-us/library/aa363679(VS.85).aspx)> with a `DLLImportAttribute`
You must also redeclare the function with the right type... |
147,328 | <p>I need to accept form data to a WCF-based service. Here's the interface:</p>
<pre><code>[OperationContract]
[WebInvoke(UriTemplate = "lead/inff",
BodyStyle = WebMessageBodyStyle.WrappedRequest)]
int Inff(Stream input);
</code></pre>
<p>Here's the implementation (sample - no error handling and other safeguards... | [
{
"answer_id": 170398,
"author": "James Bender",
"author_id": 22848,
"author_profile": "https://Stackoverflow.com/users/22848",
"pm_score": 4,
"selected": true,
"text": "<p>I remember speaking to you about this at DevLink.</p>\n\n<p>Since you have to support form fields the mechanics of ... | 2008/09/29 | [
"https://Stackoverflow.com/questions/147328",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14836/"
] | I need to accept form data to a WCF-based service. Here's the interface:
```
[OperationContract]
[WebInvoke(UriTemplate = "lead/inff",
BodyStyle = WebMessageBodyStyle.WrappedRequest)]
int Inff(Stream input);
```
Here's the implementation (sample - no error handling and other safeguards):
```
public int Inff(St... | I remember speaking to you about this at DevLink.
Since you have to support form fields the mechanics of getting those (what you are currently doing) don't change.
Something that might be helpful, especially if you want to reuse your service for new applications that don't require the form fields is to create a chann... |
147,359 | <p>I have this function in VB.net "ENCRYPT" (see below)</p>
<pre><code>Private key() As Byte = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}
Private iv() As Byte = {65, 110, 68, 26, 69, 178, 200, 219}
Public Function Encrypt(ByVal plainText As String) As Byte()
' Declare ... | [
{
"answer_id": 147367,
"author": "Eugene Yokota",
"author_id": 3827,
"author_profile": "https://Stackoverflow.com/users/3827",
"pm_score": 0,
"selected": false,
"text": "<p>Encode the array of byte into a string. 0x00 can be \"00\" and 0xFF can be \"FF.\" Or you can take at look at <a hr... | 2008/09/29 | [
"https://Stackoverflow.com/questions/147359",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21963/"
] | I have this function in VB.net "ENCRYPT" (see below)
```
Private key() As Byte = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}
Private iv() As Byte = {65, 110, 68, 26, 69, 178, 200, 219}
Public Function Encrypt(ByVal plainText As String) As Byte()
' Declare a UTF8Encoding... | Simply store in a binary column. (Mostly done from memory, corrections welcome!)
```
CREATE TABLE [Test]
(
[Id] NOT NULL IDENTITY(1,1) PRIMARY KEY,
[Username] NOT NULL VARCHAR(500),
[Password] NOT NULL VARBINARY(500)
)
```
Then insert such:
```
Dim conn As SqlConnection
Try
conn = New SqlConnection... |
147,364 | <p>In one of my ASP.NET Web Applications, I am using a <a href="http://blogs.msdn.com/mattdotson/articles/490868.aspx" rel="nofollow noreferrer">BulkEditGridView</a> (a GridView which allows all rows to be edited at the same time) to implement an order form. In my grid, I have a column which calculates the total for ea... | [
{
"answer_id": 147620,
"author": "WebDude",
"author_id": 15360,
"author_profile": "https://Stackoverflow.com/users/15360",
"pm_score": 1,
"selected": false,
"text": "<p>One solution is to build some javascript in you RowDataBound method to constantly update those totals when the textboxe... | 2008/09/29 | [
"https://Stackoverflow.com/questions/147364",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/317/"
] | In one of my ASP.NET Web Applications, I am using a [BulkEditGridView](http://blogs.msdn.com/mattdotson/articles/490868.aspx) (a GridView which allows all rows to be edited at the same time) to implement an order form. In my grid, I have a column which calculates the total for each item (cost x quantity) and a grand to... | If your calculations can be reproduced in JavaScript the easiest method would be using jQuery to get all the items like this:
```
$("#myGridView input[type='text']").each(function(){
this.change(function(){
updateTotal(this.value);
});
});
```
Or if your calculations are way too complex to be done in JavaScr... |
147,372 | <pre><code>#include <vector>
std::vector<long int> as;
long int a(size_t n){
if(n==1) return 1;
if(n==2) return -2;
if(as.size()<n+1)
as.resize(n+1);
if(as[n]<=0)
{
as[n]=-4*a(n-1)-4*a(n-2);
}
return mod(as[n], 65535);
}
</code></pre>
<p>The above code sample using memoization ... | [
{
"answer_id": 147374,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 4,
"selected": true,
"text": "<p><code>if (as[n] <= 0)</code> is the check. If valid values can be negative like you say, then you need a different sent... | 2008/09/29 | [
"https://Stackoverflow.com/questions/147372",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23323/"
] | ```
#include <vector>
std::vector<long int> as;
long int a(size_t n){
if(n==1) return 1;
if(n==2) return -2;
if(as.size()<n+1)
as.resize(n+1);
if(as[n]<=0)
{
as[n]=-4*a(n-1)-4*a(n-2);
}
return mod(as[n], 65535);
}
```
The above code sample using memoization to calculate a recursive formula base... | `if (as[n] <= 0)` is the check. If valid values can be negative like you say, then you need a different sentinel to check against. Can valid values ever be zero? If not, then just make the test `if (as[n] == 0)`. This makes your code easier to write, because by default vectors of `int`s are filled with zeroes. |
147,391 | <p>I have a program that uses the mt19937 random number generator from boost::random. I need to do a random_shuffle and want the random numbers generated for this to be from this shared state so that they can be deterministic with respect to the mersenne twister's previously generated numbers.</p>
<p>I tried something... | [
{
"answer_id": 147406,
"author": "coppro",
"author_id": 16855,
"author_profile": "https://Stackoverflow.com/users/16855",
"pm_score": 5,
"selected": true,
"text": "<p>In C++03, you cannot instantiate a template based on a function-local type. If you move the rand class out of the functio... | 2008/09/29 | [
"https://Stackoverflow.com/questions/147391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5963/"
] | I have a program that uses the mt19937 random number generator from boost::random. I need to do a random\_shuffle and want the random numbers generated for this to be from this shared state so that they can be deterministic with respect to the mersenne twister's previously generated numbers.
I tried something like thi... | In C++03, you cannot instantiate a template based on a function-local type. If you move the rand class out of the function, it should work fine (disclaimer: not tested, there could be other sinister bugs).
This requirement has been relaxed in C++0x, but I don't know whether the change has been implemented in GCC's C++... |
147,408 | <p>From what I've seen in the past, StackOverflow seems to like programming challenges, such as the <a href="https://stackoverflow.com/questions/69115/char-to-hex-string-exercise">fast char to string exercise problem</a> which got dozens of responses. This is an optimization challenge: take a very simple function and ... | [
{
"answer_id": 147424,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>Applying the obvious optimisations to your code:</p>\n\n<pre><code>#define unlikely(x) __builtin_expect((x),0)\n\nwhile( sr... | 2008/09/29 | [
"https://Stackoverflow.com/questions/147408",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11206/"
] | From what I've seen in the past, StackOverflow seems to like programming challenges, such as the [fast char to string exercise problem](https://stackoverflow.com/questions/69115/char-to-hex-string-exercise) which got dozens of responses. This is an optimization challenge: take a very simple function and see if you can ... | Hmm...how about something like this?
```
#define likely(x) __builtin_expect((x),1)
#define unlikely(x) __builtin_expect((x),0)
while( likely(src < end) )
{
//Copy non-zero run
int runlen = strlen( src );
if( unlikely(src+runlen >= end) )
{
memcpy( dest, src, end-src );
dest += end-src;... |
147,416 | <p>In .NET (VB), how can I take all of the items in one collection, and add them to a second collection (without losing pre-existing items in the second collection)? I'm looking for something a little more efficient than this:</p>
<pre><code>For Each item As Host In hostCollection1
hostCollection2.Add(item)
Next
<... | [
{
"answer_id": 147418,
"author": "Ben Hoffstein",
"author_id": 4482,
"author_profile": "https://Stackoverflow.com/users/4482",
"pm_score": 3,
"selected": false,
"text": "<p>I know you're asking for VB, but in C# you can just use the constructor of the collection to initialize it with any... | 2008/09/29 | [
"https://Stackoverflow.com/questions/147416",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5473/"
] | In .NET (VB), how can I take all of the items in one collection, and add them to a second collection (without losing pre-existing items in the second collection)? I'm looking for something a little more efficient than this:
```
For Each item As Host In hostCollection1
hostCollection2.Add(item)
Next
```
My collec... | You can use AddRange: `hostCollection2.AddRange(hostCollection1)`. |
147,437 | <p>I am trying to use Difflib.SequenceMatcher to compute the similarities between two files. These two files are almost identical except that one contains some extra whitespaces, empty lines and other doesn't. I am trying to use</p>
<pre><code>s=difflib.SequenceMatcher(isjunk,text1,text2)
ratio =s.ratio()
</code></pre... | [
{
"answer_id": 147443,
"author": "Ben Hoffstein",
"author_id": 4482,
"author_profile": "https://Stackoverflow.com/users/4482",
"pm_score": 1,
"selected": false,
"text": "<p>I haven't used Difflib.SequenceMatcher, but have you considered pre-processing the files to remove all blank lines ... | 2008/09/29 | [
"https://Stackoverflow.com/questions/147437",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3834/"
] | I am trying to use Difflib.SequenceMatcher to compute the similarities between two files. These two files are almost identical except that one contains some extra whitespaces, empty lines and other doesn't. I am trying to use
```
s=difflib.SequenceMatcher(isjunk,text1,text2)
ratio =s.ratio()
```
for this purpose.
S... | If you match all whitespaces the similarity is better:
```
difflib.SequenceMatcher(lambda x: x in " \t\n", doc1, doc2).ratio()
```
However, difflib is not ideal to such a problem because these are two nearly identical documents, but typos and such produce differences for difflib where a human wouldn't see many.
Try... |
147,451 | <p>In an HTML form post what are valid characters for creating a multipart boundary?</p>
| [
{
"answer_id": 147467,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 5,
"selected": true,
"text": "<p>According to <a href=\"https://www.rfc-editor.org/rfc/rfc2046#section-5.1.1\" rel=\"nofollow noreferrer\">RFC 2046</a>, se... | 2008/09/29 | [
"https://Stackoverflow.com/questions/147451",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3740/"
] | In an HTML form post what are valid characters for creating a multipart boundary? | According to [RFC 2046](https://www.rfc-editor.org/rfc/rfc2046#section-5.1.1), section 5.1.1:
```
boundary := 0*69<bchars> bcharsnospace
bchars := bcharsnospace / " "
bcharsnospace := DIGIT / ALPHA / "'" / "(" / ")" /
"+" / "_" / "," / "-" / "." /
"/" / ":" / "=" / "?"
```
So... |
147,454 | <p>It is much more convenient and cleaner to use a single statement like</p>
<pre><code>import java.awt.*;
</code></pre>
<p>than to import a bunch of individual classes</p>
<pre><code>import java.awt.Panel;
import java.awt.Graphics;
import java.awt.Canvas;
...
</code></pre>
<p>What is wrong with using a wildcard in... | [
{
"answer_id": 147461,
"author": "Benjamin Pollack",
"author_id": 2354,
"author_profile": "https://Stackoverflow.com/users/2354",
"pm_score": 10,
"selected": true,
"text": "<p>The only problem with it is that it clutters your local namespace. For example, let's say that you're writing a... | 2008/09/29 | [
"https://Stackoverflow.com/questions/147454",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22807/"
] | It is much more convenient and cleaner to use a single statement like
```
import java.awt.*;
```
than to import a bunch of individual classes
```
import java.awt.Panel;
import java.awt.Graphics;
import java.awt.Canvas;
...
```
What is wrong with using a wildcard in the `import` statement? | The only problem with it is that it clutters your local namespace. For example, let's say that you're writing a Swing app, and so need `java.awt.Event`, and are also interfacing with the company's calendaring system, which has `com.mycompany.calendar.Event`. If you import both using the wildcard method, one of these th... |
147,458 | <p>I have an ASP.NET 3.5 WebForm that leverages the frameworks Page.ClientScript.GetCallbackEventReference() method and I'd like some of the calls to be synchronous. </p>
<p>Now, the documentation says that the 5th parameter (see below) controls this. Specifically, when you pass 'false' it's supposed to be a non-asy... | [
{
"answer_id": 16345178,
"author": "Javal Patel",
"author_id": 896527,
"author_profile": "https://Stackoverflow.com/users/896527",
"pm_score": 1,
"selected": false,
"text": "<p><strong>ASPX Page</strong></p>\n\n<pre><code><%@ Page Language=\"VB\" AutoEventWireup=\"false\" CodeFile=\"H... | 2008/09/29 | [
"https://Stackoverflow.com/questions/147458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4646/"
] | I have an ASP.NET 3.5 WebForm that leverages the frameworks Page.ClientScript.GetCallbackEventReference() method and I'd like some of the calls to be synchronous.
Now, the documentation says that the 5th parameter (see below) controls this. Specifically, when you pass 'false' it's supposed to be a non-asynchronous ca... | **ASPX Page**
```
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="How-to-use-GetCallbackEventReference.aspx.vb" Inherits="How_to_use_Callback" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtm... |