qid
int64 4
22.2M
| question
stringlengths 18
48.3k
| answers
list | date
stringlengths 10
10
| metadata
list |
|---|---|---|---|---|
97,370
|
<p>I have a macro which refreshes all fields in a document (the equivalent of doing an <kbd>F9</kbd> on the fields). I'd like to fire this macro automatically when the user saves the document.</p>
<p>Under options I can select "update fields when document is printed", but that's not what I want. In the VBA editor I only seem to find events for the <code>Document_Open()</code> event, not the <code>Document_Save()</code> event.</p>
<p>Is it possible to get the macro to fire when the user saves the document?</p>
<p>Please note:</p>
<ol>
<li>This is Word 97. I know it is
possible in later versions of Word</li>
<li>I don't want to replace the standard
Save button on the toolbar with a
button to run my custom macro.
Replacing the button on the toolbar
applies to all documents and I only
want it to affect this one document.</li>
</ol>
<p>To understand why I need this, the document contains a "SaveDate" field and I'd like this field to update on the screen when the user clicks Save. So if you can suggest another way to achieve this, then that would be just as good.</p>
|
[
{
"answer_id": 97486,
"author": "Gregg",
"author_id": 18266,
"author_profile": "https://Stackoverflow.com/users/18266",
"pm_score": 1,
"selected": false,
"text": "<Import Project=\"$(MSBuildProjectDirectory)\\my.team.build.targets.proj\" />\n"
},
{
"answer_id": 99893,
"author": "Mr. Kraus",
"author_id": 5132,
"author_profile": "https://Stackoverflow.com/users/5132",
"pm_score": 0,
"selected": false,
"text": "<Import Project=\"$(MSBuildProjectDirectory)\\TeamBuildOverrides.targets\" />\n"
},
{
"answer_id": 100493,
"author": "Martin Woodward",
"author_id": 6438,
"author_profile": "https://Stackoverflow.com/users/6438",
"pm_score": 5,
"selected": true,
"text": "<Import Project=\"myTeamBuild.targets\"/>\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/97370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9625/"
] |
97,371
|
<p>I need to copy the newest file in a directory to a new location. So far I've found resources on the <a href="http://www.ss64.com/nt/forfiles.html" rel="noreferrer">forfiles</a> command, a <a href="https://stackoverflow.com/q/51837">date-related question</a> here, and another <a href="https://stackoverflow.com/q/50902">related question</a>. I'm just having a bit of trouble putting the pieces together! How do I copy the newest file in that directory to a new place?</p>
|
[
{
"answer_id": 97414,
"author": "Robert Swisher",
"author_id": 1852,
"author_profile": "https://Stackoverflow.com/users/1852",
"pm_score": 2,
"selected": false,
"text": "cp `ls -t1 | head -1` /somedir/\n"
},
{
"answer_id": 97427,
"author": "moswald",
"author_id": 8368,
"author_profile": "https://Stackoverflow.com/users/8368",
"pm_score": 2,
"selected": false,
"text": "@echo off\nfor /F %%i in ('dir /B /O:-D *.txt') do (\n call :open \"%%i\"\n exit /B 0\n)\n:open\n start \"window title\" \"cmd /K copy %~1 new_file_loc\"\nexit /B 0\n"
},
{
"answer_id": 97438,
"author": "Kent Fredric",
"author_id": 15614,
"author_profile": "https://Stackoverflow.com/users/15614",
"pm_score": -1,
"selected": false,
"text": " find -type f -printf \"%T@ %p \\n\" \\\n | sort \\\n | tail -n 1 \\\n | sed -r \"s/^\\S+\\s//;s/\\s*$//\" \\\n | xargs -iSTR cp STR newestfile\n"
},
{
"answer_id": 97782,
"author": "PabloG",
"author_id": 394,
"author_profile": "https://Stackoverflow.com/users/394",
"pm_score": 7,
"selected": true,
"text": "FOR /F \"delims=\" %%I IN ('DIR *.* /A-D /B /O:-D') DO COPY \"%%I\" <<NewDir>> & EXIT\n"
},
{
"answer_id": 978259,
"author": "Chris Magnuson",
"author_id": 101679,
"author_profile": "https://Stackoverflow.com/users/101679",
"pm_score": 7,
"selected": false,
"text": "FOR /F \"delims=\" %%I IN ('DIR \"*.*\" /A-D /B /O:D') DO SET \"NewestFile=%%I\"\n"
},
{
"answer_id": 5082562,
"author": "TimH - Codidact",
"author_id": 382254,
"author_profile": "https://Stackoverflow.com/users/382254",
"pm_score": 4,
"selected": false,
"text": "FOR /F \"delims=\" %%I IN ('DIR . /B /O:-D') DO COPY \"%%I\" <<NewDir>> & GOTO :END\n:END\n"
},
{
"answer_id": 6524910,
"author": "Richard",
"author_id": 821597,
"author_profile": "https://Stackoverflow.com/users/821597",
"pm_score": 2,
"selected": false,
"text": "FOR /F %%I IN ('DIR \"*.*\" /B /O:D') DO (SET NewestFile=%%I)"
},
{
"answer_id": 27028828,
"author": "DoTheEvo",
"author_id": 1383369,
"author_profile": "https://Stackoverflow.com/users/1383369",
"pm_score": 3,
"selected": false,
"text": "@echo off\nset source=\"C:\\test case\"\nset target=\"C:\\Users\\Alexander\\Desktop\\random folder\"\n\nFOR /F \"delims=\" %%I IN ('DIR %source%\\*.* /A:-D /O:-D /B') DO COPY %source%\\\"%%I\" %target% & echo %%I & GOTO :END\n:END\nTIMEOUT 4\n"
},
{
"answer_id": 68243394,
"author": "Bharathiraja",
"author_id": 2648257,
"author_profile": "https://Stackoverflow.com/users/2648257",
"pm_score": 0,
"selected": false,
"text": "date"
},
{
"answer_id": 72858926,
"author": "YazanGhafir",
"author_id": 11886045,
"author_profile": "https://Stackoverflow.com/users/11886045",
"pm_score": 1,
"selected": false,
"text": "set origFolderPath=..\\Source\\Customization.Solution\nset distFolderPath=.\\PublishCustomization.Solution\n\nFOR /F \"tokens=*\" %%I IN ('DIR \"%origFolderPath%\\*.zip\" /T:C /B /O:D') DO SET \"NewestFile=%%I\"\ncopy %origFolderPath%\\%NewestFile% %distFolderPath%\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/97371",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5269/"
] |
97,381
|
<p>C# has the keyword called <a href="http://msdn.microsoft.com/en-us/library/9k7k7cf0(VS.80).aspx" rel="noreferrer">yield</a>. VB.NET lacks this keyword. How have the Visual Basic programmers gotten around the lack of this keyword? Do they implement they own iterator class? Or do they try and code to avoid the need of an iterator?</p>
<p>The <a href="http://msdn.microsoft.com/en-us/library/9k7k7cf0(VS.80).aspx" rel="noreferrer">yield</a> keyword does force the compiler to do some coding behind the scenes. <em><a href="http://blogs.msdn.com/oldnewthing/archive/2008/08/12/8849519.aspx" rel="noreferrer">The implementation of iterators in C# and its consequences (part 1)</a></em> has a good example of that. </p>
|
[
{
"answer_id": 97398,
"author": "MagicKat",
"author_id": 8505,
"author_profile": "https://Stackoverflow.com/users/8505",
"pm_score": 1,
"selected": false,
"text": "IEnumerator(Of T)"
},
{
"answer_id": 382189,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 6,
"selected": false,
"text": "static"
},
{
"answer_id": 1480667,
"author": "MarkJ",
"author_id": 15639,
"author_profile": "https://Stackoverflow.com/users/15639",
"pm_score": 4,
"selected": false,
"text": "yield"
},
{
"answer_id": 5855766,
"author": "meenakshisundaram muthukrishna",
"author_id": 734254,
"author_profile": "https://Stackoverflow.com/users/734254",
"pm_score": -1,
"selected": false,
"text": "Public Shared Function setofNumbers() As Integer()\n Dim counter As Integer = 0\n Dim results As New List(Of Integer)\n Dim result As Integer = 1\n While counter < 5\n result = result * 2\n results.Add(result)\n counter += 1\n End While\n Return results.ToArray()\nEnd Function\n\nPrivate Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load\n For Each i As Integer In setofNumbers()\n MessageBox.Show(i)\n Next\nEnd Sub\n"
},
{
"answer_id": 5899580,
"author": "CoderDennis",
"author_id": 69527,
"author_profile": "https://Stackoverflow.com/users/69527",
"pm_score": 4,
"selected": false,
"text": "Yield"
},
{
"answer_id": 44701114,
"author": "Luke T O'Brien",
"author_id": 2137483,
"author_profile": "https://Stackoverflow.com/users/2137483",
"pm_score": 1,
"selected": false,
"text": "Iterator"
},
{
"answer_id": 48730455,
"author": "Jonathan Applebaum",
"author_id": 5718868,
"author_profile": "https://Stackoverflow.com/users/5718868",
"pm_score": 2,
"selected": false,
"text": "Yield"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/97381",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8505/"
] |
97,391
|
<p>I have the following enum declared:</p>
<pre><code> public enum TransactionTypeCode { Shipment = 'S', Receipt = 'R' }
</code></pre>
<p>How do I get the value 'S' from a TransactionTypeCode.Shipment or 'R' from TransactionTypeCode.Receipt ?</p>
<p>Simply doing TransactionTypeCode.ToString() gives a string of the Enum name "Shipment" or "Receipt" so it doesn't cut the mustard.</p>
|
[
{
"answer_id": 97397,
"author": "J D OConal",
"author_id": 17023,
"author_profile": "https://Stackoverflow.com/users/17023",
"pm_score": -1,
"selected": true,
"text": "string value = (string)TransactionTypeCode.Shipment;\n"
},
{
"answer_id": 123545,
"author": "IaCoder",
"author_id": 17337,
"author_profile": "https://Stackoverflow.com/users/17337",
"pm_score": -1,
"selected": false,
"text": "public enum TransactionTypeCode {\n\n Shipment(\"S\"),Receipt (\"R\");\n\n private final String val;\n\n TransactionTypeCode(String val){\n this.val = val;\n }\n\n public String getTypeCode(){\n return val;\n }\n}\n\nSystem.out.println(TransactionTypeCode.Shipment.getTypeCode());\n"
},
{
"answer_id": 703937,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "int value = Convert.ToInt32(TransactionTypeCode.Shipment);\n"
},
{
"answer_id": 2292564,
"author": "Andre",
"author_id": 276515,
"author_profile": "https://Stackoverflow.com/users/276515",
"pm_score": 5,
"selected": false,
"text": "public enum SuperTasks : int\n {\n Sleep = 5,\n Walk = 7,\n Run = 9\n }\n\n private void btnTestEnumWithReflection_Click(object sender, EventArgs e)\n {\n SuperTasks task = SuperTasks.Walk;\n Type underlyingType = Enum.GetUnderlyingType(task.GetType());\n object value = Convert.ChangeType(task, underlyingType); // x will be int\n } \n"
},
{
"answer_id": 20312247,
"author": "nawfal",
"author_id": 661933,
"author_profile": "https://Stackoverflow.com/users/661933",
"pm_score": 1,
"selected": false,
"text": "char"
},
{
"answer_id": 31048652,
"author": "Tonio",
"author_id": 5048578,
"author_profile": "https://Stackoverflow.com/users/5048578",
"pm_score": 0,
"selected": false,
"text": "enum myEnum : byte {Some = 1, SomeMore, Alot, TooMuch};\nmyEnum HowMuch = myEnum.Alot;\nConsole.Writeline(\"How much: {0}\", (byte)HowMuch);\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/97391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5056/"
] |
97,392
|
<p>How do I get the physical addresses of my machine in <strong>Java</strong>?</p>
|
[
{
"answer_id": 97411,
"author": "Joe Dean",
"author_id": 5917,
"author_profile": "https://Stackoverflow.com/users/5917",
"pm_score": 0,
"selected": false,
"text": "try {\n InetAddress addr = InetAddress.getLocalHost();\n\n // Get IP Address\n byte[] ipAddr = addr.getAddress();\n\n // Get hostname\n String hostname = addr.getHostName();\n} catch (UnknownHostException e) {\n}\n"
},
{
"answer_id": 97415,
"author": "zxcv",
"author_id": 9628,
"author_profile": "https://Stackoverflow.com/users/9628",
"pm_score": 0,
"selected": false,
"text": "getLocalHost() \n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/97392",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16949/"
] |
97,421
|
<p>Will IE6 negotiate a 256 bit AES SSL connection if the server is capable?</p>
|
[
{
"answer_id": 31424019,
"author": "hairysocks",
"author_id": 1782344,
"author_profile": "https://Stackoverflow.com/users/1782344",
"pm_score": 0,
"selected": false,
"text": "SSLCipherSuite ALL:!ADH:RC4+RSA:+HIGH:!MEDIUM:!LOW:!SSLv2:!EXP:!NULL\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/97421",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17583/"
] |
97,435
|
<p>Suppose you have the following string:</p>
<pre><code>white sand, tall waves, warm sun
</code></pre>
<p>It's easy to write a regular expression that will match the delimiters, which the Java String.split() method can use to give you an array containing the tokens "white sand", "tall waves" and "warm sun":</p>
<pre><code>\s*,\s*
</code></pre>
<p>Now say you have this string:</p>
<pre><code>white sand and tall waves and warm sun
</code></pre>
<p>Again, the regex to split the tokens is easy (ensuring you don't get the "and" inside the word "sand"):</p>
<pre><code>\s+and\s+
</code></pre>
<p>Now, consider this string:</p>
<pre><code>white sand, tall waves and warm sun
</code></pre>
<p>Can a regex be written that will match the delimiters correctly, allowing you to split the string into the same tokens as in the previous two cases? Alternatively, can a regex be written that will match the tokens themselves and omit the delimiters? (Any amount of white space on either side of a comma or the word "and" should be considered part of the delimiter.)</p>
<p>Edit: As has been pointed out in the comments, the correct answer should robustly handle delimiters at the beginning or end of the input string. The <em>ideal</em> answer should be able to take a string like ",white sand, tall waves and warm sun and " and provide these exact three tokens:</p>
<pre><code>[ "white sand", "tall waves", "warm sun" ]
</code></pre>
<p>...without <del>extra empty tokens or</del> extra white space at the start or end of any token.</p>
<p>Edit: It's been pointed out that extra empty tokens are unavoidable with String.split(), so that's been removed as a criterion for the "perfect" regex.</p>
<hr>
<p>Thanks everyone for your responses! I've tried to make sure I upvoted everyone who contributed a workable regex that wasn't essentially a duplicate. Dan's answer was the most robust (it even handles ",white sand, tall waves,and warm sun and " reasonably, with that odd comma placement after the word "waves"), so I've marked his as the accepted answer. The regex provided by nsayer was a close second.</p>
|
[
{
"answer_id": 97457,
"author": "UnkwnTech",
"author_id": 115,
"author_profile": "https://Stackoverflow.com/users/115",
"pm_score": 2,
"selected": false,
"text": "(?:\\sand|,)\\s\n"
},
{
"answer_id": 97458,
"author": "e-satis",
"author_id": 9951,
"author_profile": "https://Stackoverflow.com/users/9951",
"pm_score": 1,
"selected": false,
"text": "\\s*(?:and|,)\\s*\n"
},
{
"answer_id": 97470,
"author": "nsayer",
"author_id": 13757,
"author_profile": "https://Stackoverflow.com/users/13757",
"pm_score": 2,
"selected": false,
"text": "\\s*(,|(and))\\s*\n"
},
{
"answer_id": 97482,
"author": "Shinhan",
"author_id": 18219,
"author_profile": "https://Stackoverflow.com/users/18219",
"pm_score": 2,
"selected": false,
"text": "\\s*(,|\\s+and)\\s+\n"
},
{
"answer_id": 97494,
"author": "Quintin Robinson",
"author_id": 12707,
"author_profile": "https://Stackoverflow.com/users/12707",
"pm_score": 0,
"selected": false,
"text": "(?:(?<!s)and\\s+|\\,\\s+)\n"
},
{
"answer_id": 97632,
"author": "Dan",
"author_id": 17121,
"author_profile": "https://Stackoverflow.com/users/17121",
"pm_score": 4,
"selected": true,
"text": "\\s*(?:\\band\\b|,)\\s*\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/97435",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4287/"
] |
97,447
|
<p>If I am writing a library and I have a function that needs to return a sequence of values, I could do something like:</p>
<pre><code>std::vector<int> get_sequence();
</code></pre>
<p>However, this requires the library user to use the std::vector<> container rather than allowing them to use whatever container they want to use. In addition, it can add an extra copy of the returned array (depending on whether the compiler could optimize this or not) that might have a negative impact on performance.</p>
<p>You could theoretically enable the use of arbitrary containers (and avoid the unnecessary extra copying) by making a templated function that takes a start and an end iter:</p>
<pre><code>template<class T_iter> void get_sequence(T_iter begin, T_iter end);
</code></pre>
<p>The function would then store the sequence values in the range given by the iterators. But the problem with this is that it requires you to know the size of the sequence so you have enough elements between <code>begin</code> and <code>end</code> to store all of the values in the sequence.</p>
<p>I thought about an interface such as:</p>
<pre><code>template<T_insertIter> get_sequence(T_insertIter inserter);
</code></pre>
<p>which requires that the T_insertIter be an insert iterator (e.g. created with <code>std::back_inserter(my_vector)</code>), but this seems way too easy to misuse since the compiler would happily accept a non-insert iterator but would behave incorrectly at run-time.</p>
<p>So is there a best practice for designing generic interfaces that return sequences of arbitrary length?</p>
|
[
{
"answer_id": 97519,
"author": "Matt Cruikshank",
"author_id": 8643,
"author_profile": "https://Stackoverflow.com/users/8643",
"pm_score": 0,
"selected": false,
"text": "std::list<int>"
},
{
"answer_id": 97541,
"author": "moswald",
"author_id": 8368,
"author_profile": "https://Stackoverflow.com/users/8368",
"pm_score": 0,
"selected": false,
"text": "template<typename container>\ncontainer get_sequence();\n"
},
{
"answer_id": 97551,
"author": "user17481",
"author_id": 17481,
"author_profile": "https://Stackoverflow.com/users/17481",
"pm_score": 2,
"selected": false,
"text": "\ntemplate void get_sequence(T_Container & container)\n{\n //...\n container.assign(iter1, iter2);\n //...\n}\n"
},
{
"answer_id": 97597,
"author": "David Pierre",
"author_id": 18296,
"author_profile": "https://Stackoverflow.com/users/18296",
"pm_score": 0,
"selected": false,
"text": "template<T_insertIter> get_sequence(T_insertIter inserter)\n{\n return get_sequence(inserter, typename iterator_traits<Iterator>::iterator_category());\n}\n\ntemplate<T_insertIter> get_sequence(T_insertIter inserter, input_iterator_tag);\n"
},
{
"answer_id": 97623,
"author": "cjm",
"author_id": 8355,
"author_profile": "https://Stackoverflow.com/users/8355",
"pm_score": 3,
"selected": false,
"text": "forward_iterator"
},
{
"answer_id": 97628,
"author": "Johann Gerell",
"author_id": 6345,
"author_profile": "https://Stackoverflow.com/users/6345",
"pm_score": 2,
"selected": false,
"text": "std::vector<>"
},
{
"answer_id": 97712,
"author": "paercebal",
"author_id": 14089,
"author_profile": "https://Stackoverflow.com/users/14089",
"pm_score": 2,
"selected": false,
"text": "void get_sequence(std::vector<int> & p_aInt);\n"
},
{
"answer_id": 3736379,
"author": "Alexandre C.",
"author_id": 373025,
"author_profile": "https://Stackoverflow.com/users/373025",
"pm_score": 0,
"selected": false,
"text": "template <typename OutputIter>\nvoid generate_sequence(OutputIter out)\n{\n //...\n while (...) { *out = ...; ++out; }\n}\n"
},
{
"answer_id": 3736499,
"author": "Ferruccio",
"author_id": 4086,
"author_profile": "https://Stackoverflow.com/users/4086",
"pm_score": 0,
"selected": false,
"text": "struct vector_adder {\n vector_adder(std::vector<int>& v) : v(v) {}\n void operator()(int n) { v.push_back(n); }\n std::vector<int>& v;\n};\n\nvoid gen_sequence(boost::function< void(int) > f) {\n ...\n f(n);\n ...\n}\n\nmain() {\n std::vector<int> vi;\n gen_sequence(vector_adder(vi));\n}\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/97447",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/78437/"
] |
97,459
|
<p>When a C# WinForms textbox receives focus, I want it to behave like your browser's address bar.</p>
<p>To see what I mean, click in your web browser's address bar. You'll notice the following behavior: </p>
<ol>
<li>Clicking in the textbox should select all the text if the textbox wasn't previously focused.</li>
<li>Mouse down and drag in the textbox should select only the text I've highlighted with the mouse.</li>
<li>If the textbox is already focused, clicking does not select all text.</li>
<li>Focusing the textbox programmatically or via keyboard tabbing should select all text.</li>
</ol>
<p>I want to do exactly this in WinForms.</p>
<p><strong>FASTEST GUN ALERT: please read the following before answering!</strong> Thanks guys. :-)</p>
<blockquote>
<p><strong>Calling .SelectAll() during
the .Enter or .GotFocus events won't
work</strong> because if the user clicked the
textbox, the caret will be placed
where he clicked, thus deselecting all
text.</p>
<p><strong>Calling .SelectAll() during the .Click event won't work</strong> because the user won't be able to select any text with the mouse; the .SelectAll() call will keep overwriting the user's text selection.</p>
<p><strong>Calling BeginInvoke((Action)textbox.SelectAll) on focus/enter event enter doesn't work</strong> because it breaks rule #2 above, it will keep overriding the user's selection on focus.</p>
</blockquote>
|
[
{
"answer_id": 97499,
"author": "Jakub Kotrla",
"author_id": 16943,
"author_profile": "https://Stackoverflow.com/users/16943",
"pm_score": 2,
"selected": false,
"text": "private bool f = false;\n\nprivate void textBox_MouseClick(object sender, MouseEventArgs e)\n{ \n if (this.f) { this.textBox.SelectAll(); }\n this.f = false;\n}\n\nprivate void textBox_Enter(object sender, EventArgs e)\n{\n this.f = true;\n this.textBox.SelectAll();\n}\nprivate void textBox_MouseMove(object sender, MouseEventArgs e) // idea from the other answer\n{\n this.f = false; \n}\n"
},
{
"answer_id": 97509,
"author": "Todd Benning",
"author_id": 18298,
"author_profile": "https://Stackoverflow.com/users/18298",
"pm_score": 3,
"selected": false,
"text": "SendKeys.Send( \"{HOME}+{END}\" );"
},
{
"answer_id": 97515,
"author": "MagicKat",
"author_id": 8505,
"author_profile": "https://Stackoverflow.com/users/8505",
"pm_score": 2,
"selected": false,
"text": "'Inside the Enter event\nTextBox1.SelectAll();\n"
},
{
"answer_id": 97664,
"author": "Nescio",
"author_id": 14484,
"author_profile": "https://Stackoverflow.com/users/14484",
"pm_score": 0,
"selected": false,
"text": "private bool _isSelected = false;\nprivate void textBox_Validated(object sender, EventArgs e)\n{\n _isSelected = false;\n}\n\nprivate void textBox_MouseClick(object sender, MouseEventArgs e)\n{\n SelectAllText(textBox);\n}\n\nprivate void textBox_Enter(object sender, EventArgs e)\n{\n SelectAllText(textBox);\n}\n\nprivate void SelectAllText(TextBox text)\n{\n if (!_isSelected)\n {\n _isSelected = true;\n textBox.SelectAll();\n }\n}\n"
},
{
"answer_id": 97735,
"author": "benPearce",
"author_id": 4490,
"author_profile": "https://Stackoverflow.com/users/4490",
"pm_score": -1,
"selected": false,
"text": " private ########### void textBox1_Enter(object sender, EventArgs e)\n {\n textBox1.SelectAll();\n }\n\n private void textBox1_MouseDown(object sender, MouseEventArgs e)\n {\n if (textBox1.Focused)\n textBox1.SelectAll();\n }\n"
},
{
"answer_id": 100362,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "public partial class Form1 : Form\n{\n public Form1()\n {\n InitializeComponent();\n this.textBox1.GotFocus += new EventHandler(textBox1_GotFocus);\n }\n\n private delegate void SelectAllDelegate(); \n private IAsyncResult _selectAllar = null; //So we can clean up afterwards.\n\n //Catch the input focus event\n void textBox1_GotFocus(object sender, EventArgs e)\n {\n //We could have gotten here many ways (including mouse click)\n //so there could be other messages queued up already that might change the selection.\n //Don't call SelectAll here, since it might get undone by things such as positioning the cursor.\n //Instead use BeginInvoke on the form to queue up a message\n //to select all the text after everything caused by the current event is processed.\n this._selectAllar = this.BeginInvoke(new SelectAllDelegate(this._SelectAll));\n }\n\n private void _SelectAll()\n {\n //Clean-up the BeginInvoke\n if (this._selectAllar != null)\n {\n this.EndInvoke(this._selectAllar);\n }\n //Now select everything.\n this.textBox1.SelectAll();\n }\n}\n"
},
{
"answer_id": 102095,
"author": "Judah Gabriel Himango",
"author_id": 536,
"author_profile": "https://Stackoverflow.com/users/536",
"pm_score": 8,
"selected": true,
"text": "bool alreadyFocused;\n\n...\n\ntextBox1.GotFocus += textBox1_GotFocus;\ntextBox1.MouseUp += textBox1_MouseUp;\ntextBox1.Leave += textBox1_Leave;\n\n...\n\nvoid textBox1_Leave(object sender, EventArgs e)\n{\n alreadyFocused = false;\n}\n\n\nvoid textBox1_GotFocus(object sender, EventArgs e)\n{\n // Select all text only if the mouse isn't down.\n // This makes tabbing to the textbox give focus.\n if (MouseButtons == MouseButtons.None)\n {\n this.textBox1.SelectAll();\n alreadyFocused = true;\n }\n}\n\nvoid textBox1_MouseUp(object sender, MouseEventArgs e)\n{\n // Web browsers like Google Chrome select the text on mouse up.\n // They only do it if the textbox isn't already focused,\n // and if the user hasn't selected all text.\n if (!alreadyFocused && this.textBox1.SelectionLength == 0)\n {\n alreadyFocused = true;\n this.textBox1.SelectAll();\n }\n}\n"
},
{
"answer_id": 277254,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "private void textbox_MouseDown(object sender, MouseEventArgs e) {\n if (textbox != null && !string.IsNullOrEmpty(textbox.Text))\n {\n textbox.SelectAll();\n } }\n"
},
{
"answer_id": 1625439,
"author": "Sreejith K.",
"author_id": 196700,
"author_profile": "https://Stackoverflow.com/users/196700",
"pm_score": 0,
"selected": false,
"text": " private bool _tailTextBoxFirstClick = false;\n\n private void textBox1_MouseUp(object sender, MouseEventArgs e)\n {\n if(_textBoxFirstClick) \n textBox1.SelectAll();\n\n _textBoxFirstClick = false;\n } \n\n private void textBox1_Leave(object sender, EventArgs e)\n {\n _textBoxFirstClick = true;\n textBox1.Select(0, 0);\n }\n"
},
{
"answer_id": 2011104,
"author": "Mohammad Mahdipour",
"author_id": 244468,
"author_profile": "https://Stackoverflow.com/users/244468",
"pm_score": 0,
"selected": false,
"text": "public class SMaskedTextBox : MaskedTextBox\n{\n protected override void OnGotFocus(EventArgs e)\n {\n base.OnGotFocus(e);\n this.SelectAll();\n }\n}\n"
},
{
"answer_id": 2647823,
"author": "BSalita",
"author_id": 317797,
"author_profile": "https://Stackoverflow.com/users/317797",
"pm_score": -1,
"selected": false,
"text": "Class MainWindow \n\n Sub New()\n\n ' This call is required by the designer.\n InitializeComponent()\n\n ' Add any initialization after the InitializeComponent() call.\n AddHandler PreviewMouseLeftButtonDown, New MouseButtonEventHandler(AddressOf SelectivelyIgnoreMouseButton)\n AddHandler GotKeyboardFocus, New KeyboardFocusChangedEventHandler(AddressOf SelectAllText)\n AddHandler MouseDoubleClick, New MouseButtonEventHandler(AddressOf SelectAllText)\n End Sub\n\n Private Shared Sub SelectivelyIgnoreMouseButton(ByVal sender As Object, ByVal e As MouseButtonEventArgs)\n ' Find the TextBox\n Dim parent As DependencyObject = TryCast(e.OriginalSource, UIElement)\n While parent IsNot Nothing AndAlso Not (TypeOf parent Is TextBox)\n parent = VisualTreeHelper.GetParent(parent)\n End While\n\n If parent IsNot Nothing Then\n Dim textBox As Object = DirectCast(parent, TextBox)\n If Not textBox.IsKeyboardFocusWithin Then\n ' If the text box is not yet focussed, give it the focus and\n ' stop further processing of this click event.\n textBox.Focus()\n e.Handled = True\n End If\n End If\n End Sub\n\n Private Shared Sub SelectAllText(ByVal sender As Object, ByVal e As RoutedEventArgs)\n Dim textBox As Object = TryCast(e.OriginalSource, TextBox)\n If textBox IsNot Nothing Then\n textBox.SelectAll()\n End If\n End Sub\n\nEnd Class\n"
},
{
"answer_id": 3678888,
"author": "nzhenry",
"author_id": 443649,
"author_profile": "https://Stackoverflow.com/users/443649",
"pm_score": 5,
"selected": false,
"text": "public class MyTextBox : System.Windows.Forms.TextBox\n{\n private bool _focused;\n\n protected override void OnEnter(EventArgs e)\n {\n base.OnEnter(e);\n if (MouseButtons == MouseButtons.None)\n {\n SelectAll();\n _focused = true;\n }\n }\n\n protected override void OnLeave(EventArgs e)\n {\n base.OnLeave(e);\n _focused = false;\n }\n\n protected override void OnMouseUp(MouseEventArgs mevent)\n {\n base.OnMouseUp(mevent);\n if (!_focused)\n {\n if (SelectionLength == 0)\n SelectAll();\n _focused = true;\n }\n }\n}\n"
},
{
"answer_id": 6101372,
"author": "Yfiua",
"author_id": 766508,
"author_profile": "https://Stackoverflow.com/users/766508",
"pm_score": 0,
"selected": false,
"text": "private System.Windows.Forms.TextBox lastFocus; \n\nprivate void textBox_GotFocus(object sender, System.Windows.Forms.MouseEventArgs e) \n{\n TextBox senderTextBox = sender as TextBox;\n if (lastFocus!=senderTextBox){\n senderTextBox.SelectAll();\n }\n lastFocus = senderTextBox; \n}\n"
},
{
"answer_id": 6857301,
"author": "Duncan Smart",
"author_id": 1278,
"author_profile": "https://Stackoverflow.com/users/1278",
"pm_score": 6,
"selected": false,
"text": "Control.BeginInvoke"
},
{
"answer_id": 6970941,
"author": "Ross K.",
"author_id": 882448,
"author_profile": "https://Stackoverflow.com/users/882448",
"pm_score": 2,
"selected": false,
"text": " public static void WireSelectAllOnFocus( TextBox aTextBox )\n {\n bool lActive = false;\n aTextBox.GotFocus += new EventHandler( ( sender, e ) =>\n {\n if ( System.Windows.Forms.Control.MouseButtons == MouseButtons.None )\n {\n aTextBox.SelectAll();\n lActive = true;\n }\n } );\n\n aTextBox.Leave += new EventHandler( (sender, e ) => {\n lActive = false;\n } );\n\n aTextBox.MouseUp += new MouseEventHandler( (sender, e ) => {\n if ( !lActive )\n {\n lActive = true;\n if ( aTextBox.SelectionLength == 0 ) aTextBox.SelectAll();\n } \n });\n }\n"
},
{
"answer_id": 8853861,
"author": "Eluem",
"author_id": 1148085,
"author_profile": "https://Stackoverflow.com/users/1148085",
"pm_score": 0,
"selected": false,
"text": "if(textBox.SelectionLength = 0)\n{\n textBox.SelectAll();\n}\n"
},
{
"answer_id": 10416412,
"author": "Chris",
"author_id": 1370369,
"author_profile": "https://Stackoverflow.com/users/1370369",
"pm_score": 2,
"selected": false,
"text": "Private LastFocused As Control = Nothing\n\nPrivate Sub TextBox1_Enter(sender As Object, e As System.EventArgs) Handles TextBox1.Enter, TextBox2.Enter, TextBox3.Enter\n If MouseButtons = Windows.Forms.MouseButtons.None Then LastFocused = sender\nEnd Sub\n\nPrivate Sub TextBox1_Leave(sender As Object, e As System.EventArgs) Handles TextBox1.Leave, TextBox2.Leave, TextBox3.Leave\n LastFocused = Nothing\nEnd Sub\n\nPrivate Sub TextBox1_MouseUp(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseUp, TextBox2.MouseUp, TextBox3.MouseUp\n With CType(sender, TextBox)\n If LastFocused IsNot sender AndAlso .SelectionLength = 0 Then .SelectAll()\n End With\n LastFocused = sender\nEnd Sub\n"
},
{
"answer_id": 10420952,
"author": "Adam Bruss",
"author_id": 638740,
"author_profile": "https://Stackoverflow.com/users/638740",
"pm_score": 1,
"selected": false,
"text": "ActiveControl = textBox1;\ntextBox1->SelectionStart = 0;\ntextBox1->SelectionLength = textBox1->Text->Length;\n"
},
{
"answer_id": 12212017,
"author": "abrfra",
"author_id": 978489,
"author_profile": "https://Stackoverflow.com/users/978489",
"pm_score": 0,
"selected": false,
"text": "OnKeyDown"
},
{
"answer_id": 15284242,
"author": "slobs",
"author_id": 2146540,
"author_profile": "https://Stackoverflow.com/users/2146540",
"pm_score": 2,
"selected": false,
"text": " private bool initialEntry = true;\n private void TextBox_SelectionChanged(object sender, RoutedEventArgs e)\n {\n if (initialEntry)\n {\n e.Handled = true;\n initialEntry = false;\n TextBox.SelectAll();\n }\n }\n private void TextBox_GotFocus(object sender, RoutedEventArgs e)\n {\n TextBox.SelectAll();\n initialEntry = true; \n }\n"
},
{
"answer_id": 17221130,
"author": "Joel",
"author_id": 2506459,
"author_profile": "https://Stackoverflow.com/users/2506459",
"pm_score": 0,
"selected": false,
"text": "private void maskedTextBox1_Leave(object sender, CancelEventArgs e)\n {\n maskedTextBox1.SelectAll();\n }\n"
},
{
"answer_id": 22812804,
"author": "MDB",
"author_id": 3489564,
"author_profile": "https://Stackoverflow.com/users/3489564",
"pm_score": -1,
"selected": false,
"text": "public void YourTextBox_MouseEnter(object sender, MouseEventArgs e)\n {\n YourTextBox.Focus();\n YourTextBox.SelectAll();\n }\n"
},
{
"answer_id": 25998482,
"author": "Mauro Sampietro",
"author_id": 711061,
"author_profile": "https://Stackoverflow.com/users/711061",
"pm_score": 0,
"selected": false,
"text": " private bool _focusing = false;\n\n protected override void OnEnter( EventArgs e )\n {\n _focusing = true;\n base.OnEnter( e );\n }\n\n protected override void OnMouseUp( MouseEventArgs mevent )\n {\n base.OnMouseUp( mevent );\n\n if( _focusing )\n {\n this.SelectAll();\n _focusing = false;\n }\n }\n"
},
{
"answer_id": 27229467,
"author": "Pieter Heemeryck",
"author_id": 2568944,
"author_profile": "https://Stackoverflow.com/users/2568944",
"pm_score": 1,
"selected": false,
"text": "private void textBox1_Click(object sender, EventArgs e){\n textBox1_Enter(sender, e);\n }\n\nprivate void textBox1_Enter(object sender, EventArgs e){\n TextBox tb = ((TextBox)sender);\n tb.SelectAll();\n }\n"
},
{
"answer_id": 29624996,
"author": "EKanadily",
"author_id": 365867,
"author_profile": "https://Stackoverflow.com/users/365867",
"pm_score": -1,
"selected": false,
"text": "private void textBox1_Enter(object sender, EventArgs e)\n {\n\n textBox1.SelectAll();\n }\n private void textBox1_Click(object sender, EventArgs e)\n {\n textBox1.SelectAll();\n }\n"
},
{
"answer_id": 30487179,
"author": "Hawston",
"author_id": 3729779,
"author_profile": "https://Stackoverflow.com/users/3729779",
"pm_score": 0,
"selected": false,
"text": " private bool SearchBoxInFocusAlready = false;\n private void SearchBox_LostFocus(object sender, RoutedEventArgs e)\n {\n SearchBoxInFocusAlready = false;\n }\n\n private void SearchBox_PreviewMouseUp(object sender, MouseButtonEventArgs e)\n {\n if (e.ButtonState == MouseButtonState.Released && e.ChangedButton == MouseButton.Left &&\n SearchBox.SelectionLength == 0 && SearchBoxInFocusAlready == false)\n {\n SearchBox.SelectAll();\n }\n\n SearchBoxInFocusAlready = true;\n }\n"
},
{
"answer_id": 31502179,
"author": "BlueWizard",
"author_id": 4773888,
"author_profile": "https://Stackoverflow.com/users/4773888",
"pm_score": 0,
"selected": false,
"text": "private async void TextBox_GotFocus(object sender, RoutedEventArgs e)\n{\n if (sender is TextBox)\n {\n await Task.Delay(100);\n (sender as TextBox).SelectAll();\n }\n}\n"
},
{
"answer_id": 34028458,
"author": "Cody",
"author_id": 5627196,
"author_profile": "https://Stackoverflow.com/users/5627196",
"pm_score": -1,
"selected": false,
"text": " ' * if the mouse button is down, do not run the select all.\n If MouseButtons = Windows.Forms.MouseButtons.Left Then\n Exit Sub\n End If\n\n ' * OTHERWISE INVOKE THE SELECT ALL AS DISCUSSED.\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/97459",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/536/"
] |
97,465
|
<p>Has anyone figured out how to use Crystal Reports with Linq to SQL?</p>
|
[
{
"answer_id": 7691717,
"author": "Mohammad Sepahvand",
"author_id": 189756,
"author_profile": "https://Stackoverflow.com/users/189756",
"pm_score": 3,
"selected": true,
"text": "List"
},
{
"answer_id": 23882327,
"author": "user3243012",
"author_id": 3243012,
"author_profile": "https://Stackoverflow.com/users/3243012",
"pm_score": 0,
"selected": false,
"text": " public class CollectionHelper\n {\n public CollectionHelper()\n {\n }\n\n // this is the method I have been using\n public DataTable ConvertTo<T>(IList<T> list)\n {\n DataTable table = CreateTable<T>();\n Type entityType = typeof(T);\n PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(entityType);\n\n foreach (T item in list)\n {\n DataRow row = table.NewRow();\n\n foreach (PropertyDescriptor prop in properties)\n {\n row[prop.Name] = prop.GetValue(item) ?? DBNull.Value;\n }\n\n table.Rows.Add(row);\n }\n\n return table;\n }\n\n public static DataTable CreateTable<T>()\n {\n Type entityType = typeof(T);\n DataTable table = new DataTable(entityType.Name);\n PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(entityType);\n\n foreach (PropertyDescriptor prop in properties)\n {\n // HERE IS WHERE THE ERROR IS THROWN FOR NULLABLE TYPES\n table.Columns.Add(prop.Name, Nullable.GetUnderlyingType(\n prop.PropertyType) ?? prop.PropertyType);\n }\n\n return table;\n }\n }\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/97465",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11063/"
] |
97,468
|
<p><a href="http://github.com/rails/ssl_requirement/tree/master/lib/ssl_requirement.rb" rel="nofollow noreferrer">Take a look at the ssl_requirement plugin.</a></p>
<p>Shouldn't it check to see if you're in production mode? We're seeing a redirect to https in development mode, which seems odd. Or is that the normal behavior for the plugin? I thought it behaved differently in the past.</p>
|
[
{
"answer_id": 98697,
"author": "Nathan de Vries",
"author_id": 11109,
"author_profile": "https://Stackoverflow.com/users/11109",
"pm_score": 4,
"selected": true,
"text": "class YourController < ApplicationController\n ssl_required :update unless Rails.env.development?\nend\n"
},
{
"answer_id": 2152995,
"author": "tfentonz",
"author_id": 254356,
"author_profile": "https://Stackoverflow.com/users/254356",
"pm_score": 0,
"selected": false,
"text": "require 'controllers/application_controller'\n\nclass ApplicationController < ActionController::Base\n def ssl_required?\n false\n end\nend\n"
},
{
"answer_id": 2482569,
"author": "Anatoly",
"author_id": 290338,
"author_profile": "https://Stackoverflow.com/users/290338",
"pm_score": 2,
"selected": false,
"text": " def ssl_required?\n return false if local_request? || RAILS_ENV == 'test' || RAILS_ENV == 'development'\n super\n end\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/97468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17076/"
] |
97,474
|
<p>I need to get the value of the 'test' attribute in the xsl:when tag, and the 'name' attribute in the xsl:call-template tag. This xpath gets me pretty close: </p>
<pre><code>..../xsl:template/xsl:choose/xsl:when
</code></pre>
<p>But that just returns the 'when' elements, not the exact attribute values I need.</p>
<p>Here is a snippet of my XML:</p>
<pre><code><xsl:template match="field">
<xsl:choose>
<xsl:when test="@name='First Name'">
<xsl:call-template name="handleColumn_1" />
</xsl:when>
</xsl:choose>
</code></pre>
|
[
{
"answer_id": 97500,
"author": "Steve Cooper",
"author_id": 6722,
"author_profile": "https://Stackoverflow.com/users/6722",
"pm_score": 2,
"selected": false,
"text": ".../xsl:template/xsl:choose/xsl:when/@test"
},
{
"answer_id": 97738,
"author": "Mike Tunnicliffe",
"author_id": 13956,
"author_profile": "https://Stackoverflow.com/users/13956",
"pm_score": 2,
"selected": true,
"text": ".../xsl:template/xsl:choose/xsl:when[@test=\"@name='First Name'\"]/xsl:call-template/@name\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/97474",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10876/"
] |
97,480
|
<p>I have a Progress database that I'm performing an ETL from. One of the tables that I'm reading from does not have a unique key on it, so I need to access the ROWID to be able to uniquely identify the row. What is the syntax for accessing the ROWID in Progress?</p>
<p>I understand there are problems with using ROWID for row identification, but it's all I have right now.</p>
|
[
{
"answer_id": 100430,
"author": "David Webb",
"author_id": 3171,
"author_profile": "https://Stackoverflow.com/users/3171",
"pm_score": 4,
"selected": true,
"text": "ROWID"
},
{
"answer_id": 102910,
"author": "Stefan Moser",
"author_id": 8739,
"author_profile": "https://Stackoverflow.com/users/8739",
"pm_score": 2,
"selected": false,
"text": "SELECT ROWID, * FROM customer WHERE cust-num = 123\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/97480",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8739/"
] |
97,505
|
<p>Working on a somewhat complex page for configuring customers at work. The setup is that there's a main page, which contains various "panels" for various groups of settings. </p>
<p>In one case, there's an email address field on the main table and an "export" configuration that controls how emails are sent out. I created a main panel that selects the company, and binds to a FormView. The FormView contains a Web User Control that handles the display/configuration of the export details.</p>
<p>The Web User Control Contains a property to define which Config it should be handling, and it gets the value from the FormView using Bind().</p>
<p>Basically the control is used like this:</p>
<pre><code><syn:ExportInfo ID="eiConfigDetails" ExportInfoID='<%# Bind("ExportInfoID" ) %>' runat="server" />
</code></pre>
<p>The property being bound is declared like this in CodeBehind:</p>
<pre><code>public int ExportInfoID
{
get
{
return Convert.ToInt32(hfID.Value);
}
set
{
try
{
hfID.Value = value.ToString();
}
catch(Exception)
{
hfID.Value="-1";
}
}
}
</code></pre>
<p>Whenever the <code>ExportInfoID</code> is null I get a null reference exception, but the kicker is that it happens BEFORE it actually tries to set the property (or it would be caught in this version.)</p>
<p>Anyone know what's going on or, more importantly, how to fix it...?</p>
|
[
{
"answer_id": 100430,
"author": "David Webb",
"author_id": 3171,
"author_profile": "https://Stackoverflow.com/users/3171",
"pm_score": 4,
"selected": true,
"text": "ROWID"
},
{
"answer_id": 102910,
"author": "Stefan Moser",
"author_id": 8739,
"author_profile": "https://Stackoverflow.com/users/8739",
"pm_score": 2,
"selected": false,
"text": "SELECT ROWID, * FROM customer WHERE cust-num = 123\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/97505",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17145/"
] |
97,506
|
<p><strong>This isn't a holy war, this isn't a question of "which is better".</strong></p>
<p>What are the pros of using the following format for single statement if blocks.</p>
<pre><code>if (x) print "x is true";
if(x)
print "x is true";
</code></pre>
<p>As opposed to</p>
<pre><code>if (x) { print "x is true"; }
if(x) {
print "x is true";
}
</code></pre>
<p><strong>If you format your single statement ifs without brackets</strong> or know a programmer that does, what led you/them to adopt this style in the first place? I'm specifically interested in what benefits this has brought you.</p>
<p><strong>Update</strong>: As the most popular answer ignores the actual question (even if it presents the most sane advice), here's a roundup of the bracket-less pros.</p>
<ol>
<li>Compactness</li>
<li>More readable to some</li>
<li>Brackets invoke scope, which has a theoretical overhead in some cases</li>
</ol>
|
[
{
"answer_id": 97525,
"author": "MagicKat",
"author_id": 8505,
"author_profile": "https://Stackoverflow.com/users/8505",
"pm_score": 2,
"selected": false,
"text": "if (foo)\n{\n Console.WriteLine(\"Foobar\");\n}\n"
},
{
"answer_id": 97526,
"author": "Matt Dillard",
"author_id": 863,
"author_profile": "https://Stackoverflow.com/users/863",
"pm_score": 7,
"selected": true,
"text": "if( true ) {\n DoSomething();\n} else {\n DoSomethingElse();\n}\n"
},
{
"answer_id": 97529,
"author": "user18301",
"author_id": 18301,
"author_profile": "https://Stackoverflow.com/users/18301",
"pm_score": 4,
"selected": false,
"text": "if(x) \n{\n print \"x is true\"; \n}\n"
},
{
"answer_id": 97531,
"author": "Darren Kopp",
"author_id": 77,
"author_profile": "https://Stackoverflow.com/users/77",
"pm_score": 3,
"selected": false,
"text": "if\n{\n// code\n}\nelse \n{\n// else code\n}\n"
},
{
"answer_id": 97549,
"author": "Chris Pietschmann",
"author_id": 7831,
"author_profile": "https://Stackoverflow.com/users/7831",
"pm_score": 0,
"selected": false,
"text": "// Do this if you only have one line of code\n// executing within the if statement\nif (x)\n print \"x is true\";\n\n// Do this when you have multiple lines of code\n// getting executed within the if statement \nif (x)\n{\n print \"x is true\";\n}\n"
},
{
"answer_id": 97552,
"author": "ConroyP",
"author_id": 2287,
"author_profile": "https://Stackoverflow.com/users/2287",
"pm_score": 3,
"selected": false,
"text": "if(x) \n print \"x is true\";\n"
},
{
"answer_id": 97562,
"author": "Lucas Oman",
"author_id": 6726,
"author_profile": "https://Stackoverflow.com/users/6726",
"pm_score": 2,
"selected": false,
"text": "if (cond) {\n ...\n} else {\n ...\n}\n"
},
{
"answer_id": 97564,
"author": "moonshadow",
"author_id": 11834,
"author_profile": "https://Stackoverflow.com/users/11834",
"pm_score": 2,
"selected": false,
"text": "if (x)\n{\n print \"x is true\";\n}\n"
},
{
"answer_id": 97583,
"author": "Matthew Jaskula",
"author_id": 4356,
"author_profile": "https://Stackoverflow.com/users/4356",
"pm_score": 3,
"selected": false,
"text": "if(x) \n print \"x is true\";\n print \"something else\";\n"
},
{
"answer_id": 97596,
"author": "user17000",
"author_id": 17000,
"author_profile": "https://Stackoverflow.com/users/17000",
"pm_score": 1,
"selected": false,
"text": "If(x)\n{\n print \"Hello World !!\"\n}\nElse\n{\n print \"Good bye!!\"\n}\n"
},
{
"answer_id": 97680,
"author": "Zack Peterson",
"author_id": 83,
"author_profile": "https://Stackoverflow.com/users/83",
"pm_score": 2,
"selected": false,
"text": "if (i != 0) \n foo(i);\n"
},
{
"answer_id": 97791,
"author": "mike511",
"author_id": 9593,
"author_profile": "https://Stackoverflow.com/users/9593",
"pm_score": 1,
"selected": false,
"text": "if(x)\n{\n somecode;\n}\nelse\n{\n morecode;\n}\n"
},
{
"answer_id": 97917,
"author": "Jeff",
"author_id": 16639,
"author_profile": "https://Stackoverflow.com/users/16639",
"pm_score": 2,
"selected": false,
"text": "if (a)\n foo();\n bar();\n"
},
{
"answer_id": 97918,
"author": "johnc",
"author_id": 5302,
"author_profile": "https://Stackoverflow.com/users/5302",
"pm_score": 3,
"selected": false,
"text": "public void MyFunction(object param)\n{\n if (param == null) return;\n\n ...\n}\n"
},
{
"answer_id": 97919,
"author": "Jason Hanford-Smith",
"author_id": 18345,
"author_profile": "https://Stackoverflow.com/users/18345",
"pm_score": 3,
"selected": false,
"text": "if (x)\n{\n ...statement1\n ...statement2\n}\n"
},
{
"answer_id": 97921,
"author": "Doron Yaacoby",
"author_id": 3389,
"author_profile": "https://Stackoverflow.com/users/3389",
"pm_score": 2,
"selected": false,
"text": "if (x)\n print \"x is true\"\nfor (int i=0; i<10; i++)\n print \"y is true\"\n"
},
{
"answer_id": 98086,
"author": "easeout",
"author_id": 10906,
"author_profile": "https://Stackoverflow.com/users/10906",
"pm_score": 2,
"selected": false,
"text": "if (x) {\n print \"x is true\"; \n}\nelse {\n do something else;\n}\n"
},
{
"answer_id": 98569,
"author": "Ferruccio",
"author_id": 4086,
"author_profile": "https://Stackoverflow.com/users/4086",
"pm_score": 5,
"selected": false,
"text": "if (condition)\n do_something();\nelse\n do_something_else();\n"
},
{
"answer_id": 98646,
"author": "spoulson",
"author_id": 3347,
"author_profile": "https://Stackoverflow.com/users/3347",
"pm_score": 0,
"selected": false,
"text": "if (expr) {\n funcA();\n}\nelse {\n funcB();\n}\n"
},
{
"answer_id": 99615,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "/* I type one liners with brackets like this */\nif(0){return(0);}\n/* If else blocks like this */\nif(0){\n return(0);\n}else{\n return(-1);\n}\n"
},
{
"answer_id": 99898,
"author": "Robert Paulson",
"author_id": 14033,
"author_profile": "https://Stackoverflow.com/users/14033",
"pm_score": 2,
"selected": false,
"text": "public int IndexOf(string haystack, string needle)\n{\n // check parameters.\n if (haystack == null)\n throw new ArgumentNullException(\"haystack\");\n if (string.IsNullOrEmpty(needle))\n return -1;\n\n // rest of method here ...\n"
},
{
"answer_id": 103168,
"author": "Dave Sherohman",
"author_id": 18914,
"author_profile": "https://Stackoverflow.com/users/18914",
"pm_score": 0,
"selected": false,
"text": "if (x) {\n print \"x is true\"; \n}\n"
},
{
"answer_id": 109750,
"author": "quinmars",
"author_id": 18687,
"author_profile": "https://Stackoverflow.com/users/18687",
"pm_score": 0,
"selected": false,
"text": "\nif (x)\n x = x + 1;\n printf(\"%d\\n\", x);\n"
},
{
"answer_id": 118679,
"author": "Dan Adams",
"author_id": 1628,
"author_profile": "https://Stackoverflow.com/users/1628",
"pm_score": 0,
"selected": false,
"text": "if(x)\n{\n code;\n}\nelse\n{\n other code;\n}\n"
},
{
"answer_id": 154813,
"author": "Lucas Gabriel Sánchez",
"author_id": 20601,
"author_profile": "https://Stackoverflow.com/users/20601",
"pm_score": 1,
"selected": false,
"text": "if (x) doSomething();\n\nif (x) {\n doSomthing();\n doOtherthing();\n}\n"
},
{
"answer_id": 1107746,
"author": "TSomKes",
"author_id": 18347,
"author_profile": "https://Stackoverflow.com/users/18347",
"pm_score": 0,
"selected": false,
"text": "if (x)\n{ foo(); }\n"
},
{
"answer_id": 1107839,
"author": "Newtopian",
"author_id": 25812,
"author_profile": "https://Stackoverflow.com/users/25812",
"pm_score": 0,
"selected": false,
"text": "if (param == null || parameterDoesNotValidateForMethod) throw new InvalidArgumentExeption(\"Parameter null or invalid\");\n"
},
{
"answer_id": 28863415,
"author": "RicardoVallejo",
"author_id": 3429457,
"author_profile": "https://Stackoverflow.com/users/3429457",
"pm_score": 2,
"selected": false,
"text": "(a==b) ? printf(\"yup true\") : printf(\"nop false\");\n"
},
{
"answer_id": 37676645,
"author": "user160917",
"author_id": 160917,
"author_profile": "https://Stackoverflow.com/users/160917",
"pm_score": 2,
"selected": false,
"text": "if(x > y) { xIsGreaterThanY(); }\nelse if(y > x) { yIsGreaterThanX; }\nelse { xEqualsY(); }\n"
},
{
"answer_id": 45828183,
"author": "Scott - Слава Україні",
"author_id": 1672723,
"author_profile": "https://Stackoverflow.com/users/1672723",
"pm_score": 0,
"selected": false,
"text": "if (x)\n DoSomething();\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/97506",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4668/"
] |
97,520
|
<p>How is possible to set some special column values when update/insert entities via NHibernate without extending domain classes with special properties?</p>
<p>E.g. every table contains audit columns like CreatedBy, CreatedDate, UpdatedBy, UpdatedDate. But I dont want to add these poperties to the domain classes. I want to keep domain modedl Percistence Ignorance factor as high as possible.</p>
|
[
{
"answer_id": 101037,
"author": "noetic",
"author_id": 9198,
"author_profile": "https://Stackoverflow.com/users/9198",
"pm_score": 1,
"selected": false,
"text": "private IDictionary _infrastructureProperties = new Dictionary<object, object>();\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/97520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9198/"
] |
97,522
|
<p>What are all the valid self-closing elements (e.g. <br/>) in XHTML (as implemented by the major browsers)?</p>
<p>I know that XHTML technically allows any element to be self-closed, but I'm looking for a list of those elements supported by all major browsers. See <a href="http://dusan.fora.si/blog/self-closing-tags" rel="noreferrer">http://dusan.fora.si/blog/self-closing-tags</a> for examples of some problems caused by self-closing elements such as <div />.</p>
|
[
{
"answer_id": 97575,
"author": "e-satis",
"author_id": 9951,
"author_profile": "https://Stackoverflow.com/users/9951",
"pm_score": 3,
"selected": false,
"text": "<br />\n<hr />\n<img />\n<input />\n"
},
{
"answer_id": 97585,
"author": "ConroyP",
"author_id": 2287,
"author_profile": "https://Stackoverflow.com/users/2287",
"pm_score": 5,
"selected": false,
"text": "<area />\n<base />\n<basefont />\n<br />\n<hr />\n<input />\n<img />\n<link />\n<meta />\n"
},
{
"answer_id": 142447,
"author": "AmbroseChapel",
"author_id": 242241,
"author_profile": "https://Stackoverflow.com/users/242241",
"pm_score": 3,
"selected": false,
"text": "<meta>"
},
{
"answer_id": 142457,
"author": "Erik van Brakel",
"author_id": 909,
"author_profile": "https://Stackoverflow.com/users/909",
"pm_score": 5,
"selected": false,
"text": "<script"
},
{
"answer_id": 196249,
"author": "Kevin Hakanson",
"author_id": 22514,
"author_profile": "https://Stackoverflow.com/users/22514",
"pm_score": 2,
"selected": false,
"text": "<title/>\n"
},
{
"answer_id": 206409,
"author": "Kornel",
"author_id": 27009,
"author_profile": "https://Stackoverflow.com/users/27009",
"pm_score": 9,
"selected": true,
"text": "<div/>"
},
{
"answer_id": 1735748,
"author": "Jeff",
"author_id": 142233,
"author_profile": "https://Stackoverflow.com/users/142233",
"pm_score": 4,
"selected": false,
"text": "<base />\n<basefont />\n<frame />\n<link />\n<meta />\n\n<area />\n<br />\n<col />\n<hr />\n<img />\n<input />\n<param />\n"
},
{
"answer_id": 3581293,
"author": "Nathan Sokalski",
"author_id": 432546,
"author_profile": "https://Stackoverflow.com/users/432546",
"pm_score": 2,
"selected": false,
"text": "<title/>"
},
{
"answer_id": 8853550,
"author": "Dmitry Osinovskiy",
"author_id": 194020,
"author_profile": "https://Stackoverflow.com/users/194020",
"pm_score": 5,
"selected": false,
"text": "area, base, br, col, embed, hr, img, input, keygen, link, menuitem, meta, param, source, track, wbr"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/97522",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1335/"
] |
97,565
|
<p>C# question (.net 3.5). I have a class, ImageData, that has a field ushort[,] pixels. I am dealing with proprietary image formats. The ImageData class takes a file location in the constructor, then switches on file extension to determine how to decode. In several of the image files, there is a "bit depth" field in the header. After I decode the header I read the pixel values into the "pixels" array. So far I have not had more than 16bpp, so I'm okay. But what if I have 32bpp?</p>
<p>What I want to do is have the type of pixels be determined at runtime. I want to do this after I read the bit depth out of the header and before I copy the pixel data into memory. Any ideas?</p>
|
[
{
"answer_id": 97788,
"author": "Wedge",
"author_id": 332,
"author_profile": "https://Stackoverflow.com/users/332",
"pm_score": 3,
"selected": true,
"text": "public static ImageData Create(string imageFilename)\n{\n // ...\n ImageDataHeader imageHeader = ParseHeader(imageFilename);\n ImageData newImageData;\n if (imageHeader.bpp == 32)\n {\n newImageData = new ImageData32(imageFilename, imageHeader);\n }\n else\n {\n newImageData = new ImageData16(imageFilename, imageHeader);\n }\n // ...\n return newImageData;\n}\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/97565",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1812999/"
] |
97,578
|
<p>Maybe I'm just thinking about this too hard, but I'm having a problem figuring out what escaping to use on a string in some JavaScript code inside a link's onClick handler. Example:</p>
<pre><code><a href="#" onclick="SelectSurveyItem('<%itemid%>', '<%itemname%>'); return false;">Select</a>
</code></pre>
<p>The <code><%itemid%></code> and <code><%itemname%></code> are where template substitution occurs. My problem is that the item name can contain any character, including single and double quotes. Currently, if it contains single quotes it breaks the JavaScript code.</p>
<p>My first thought was to use the template language's function to JavaScript-escape the item name, which just escapes the quotes. That will not fix the case of the string containing double quotes which breaks the HTML of the link. How is this problem normally addressed? Do I need to HTML-escape the entire onClick handler?</p>
<p>If so, that would look really strange since the template language's escape function for that would also HTMLify the parentheses, quotes, and semicolons...</p>
<p>This link is being generated for every result in a search results page, so creating a separate method inside a JavaScript tag is not possible, because I'd need to generate one per result.</p>
<p>Also, I'm using a templating engine that was home-grown at the company I work for, so toolkit-specific solutions will be of no use to me.</p>
|
[
{
"answer_id": 97613,
"author": "Dan",
"author_id": 17121,
"author_profile": "https://Stackoverflow.com/users/17121",
"pm_score": 3,
"selected": false,
"text": ">"
},
{
"answer_id": 97670,
"author": "Alexandre Victoor",
"author_id": 11897,
"author_profile": "https://Stackoverflow.com/users/11897",
"pm_score": 1,
"selected": false,
"text": "<a id=\"someLinkId\"href=\"#\">Select</a>\n<script type=\"text/javascript\">\n document.getElementById(\"someLinkId\").onClick = \n function() {\n SelectSurveyItem('<%itemid%>', '<%itemname%>'); return false;\n };\n\n</script>\n"
},
{
"answer_id": 97687,
"author": "Kent Fredric",
"author_id": 15614,
"author_profile": "https://Stackoverflow.com/users/15614",
"pm_score": 3,
"selected": false,
"text": "<a id=\"tehbutton\" href=\"somewhereToGoWithoutWorkingJavascript.com\">Select</a>\n"
},
{
"answer_id": 97724,
"author": "Dan",
"author_id": 17121,
"author_profile": "https://Stackoverflow.com/users/17121",
"pm_score": 2,
"selected": false,
"text": "<a href=\"#\" itemid=\"<%itemid%>\" itemname=\"<%itemname%>\" onclick=\"SelectSurveyItem(this.itemid, this.itemname); return false;\">Select</a>\n"
},
{
"answer_id": 97804,
"author": "Duncan Smart",
"author_id": 1278,
"author_profile": "https://Stackoverflow.com/users/1278",
"pm_score": 7,
"selected": true,
"text": "<a href=\"#\" onclick=\"SelectSurveyItem('<% JSEncode(itemid) %>', '<% JSEncode(itemname) %>'); return false;\">Select</a>\n"
},
{
"answer_id": 506347,
"author": "Shyam Kumar Sundarakumar",
"author_id": 35392,
"author_profile": "https://Stackoverflow.com/users/35392",
"pm_score": 4,
"selected": false,
"text": "<%itemid%>"
},
{
"answer_id": 5273245,
"author": "AhmedGamal",
"author_id": 655389,
"author_profile": "https://Stackoverflow.com/users/655389",
"pm_score": 0,
"selected": false,
"text": "onclick=\"myfun(1)\"\nonclick=\"myfun(2)\"\nonclick=\"myfun(3)\"\n\nfunction myfun(var)\n{\n if (var ==1)\n alert(v1);\n\n if (var ==2)\n alert(v2);\n\n if (var ==3)\n alert(v3);\n}\n"
},
{
"answer_id": 8611916,
"author": "Vitalii Fedorenko",
"author_id": 288671,
"author_profile": "https://Stackoverflow.com/users/288671",
"pm_score": 5,
"selected": false,
"text": "string result = System.Web.HttpUtility.JavaScriptStringEncode(\"jsString\")\n"
},
{
"answer_id": 9303208,
"author": "Starbuck Johnson",
"author_id": 1212632,
"author_profile": "https://Stackoverflow.com/users/1212632",
"pm_score": 1,
"selected": false,
"text": "function noQuote(text)\n{\n var newtext = \"\";\n for (var i = 0; i < text.length; i++) {\n if (text[i] == \"'\") {\n newtext += \"\\\"\";\n }\n else {\n newtext += text[i];\n }\n }\n return newtext;\n}\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/97578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10861/"
] |
97,586
|
<p>My boss loves VB (we work in a Java shop) because he thinks it's easy to learn and maintain. We want to replace some of the VB with java equivalents using the Eclipse SWT editor, because we think it is almost as easy to maintain. To sell this, we'd like to use an aerith style L&F.</p>
<p>Can anyone provide an example of an SWT application still being able to edit the GUI in eclipse, but having the Aerith L&F?</p>
|
[
{
"answer_id": 97613,
"author": "Dan",
"author_id": 17121,
"author_profile": "https://Stackoverflow.com/users/17121",
"pm_score": 3,
"selected": false,
"text": ">"
},
{
"answer_id": 97670,
"author": "Alexandre Victoor",
"author_id": 11897,
"author_profile": "https://Stackoverflow.com/users/11897",
"pm_score": 1,
"selected": false,
"text": "<a id=\"someLinkId\"href=\"#\">Select</a>\n<script type=\"text/javascript\">\n document.getElementById(\"someLinkId\").onClick = \n function() {\n SelectSurveyItem('<%itemid%>', '<%itemname%>'); return false;\n };\n\n</script>\n"
},
{
"answer_id": 97687,
"author": "Kent Fredric",
"author_id": 15614,
"author_profile": "https://Stackoverflow.com/users/15614",
"pm_score": 3,
"selected": false,
"text": "<a id=\"tehbutton\" href=\"somewhereToGoWithoutWorkingJavascript.com\">Select</a>\n"
},
{
"answer_id": 97724,
"author": "Dan",
"author_id": 17121,
"author_profile": "https://Stackoverflow.com/users/17121",
"pm_score": 2,
"selected": false,
"text": "<a href=\"#\" itemid=\"<%itemid%>\" itemname=\"<%itemname%>\" onclick=\"SelectSurveyItem(this.itemid, this.itemname); return false;\">Select</a>\n"
},
{
"answer_id": 97804,
"author": "Duncan Smart",
"author_id": 1278,
"author_profile": "https://Stackoverflow.com/users/1278",
"pm_score": 7,
"selected": true,
"text": "<a href=\"#\" onclick=\"SelectSurveyItem('<% JSEncode(itemid) %>', '<% JSEncode(itemname) %>'); return false;\">Select</a>\n"
},
{
"answer_id": 506347,
"author": "Shyam Kumar Sundarakumar",
"author_id": 35392,
"author_profile": "https://Stackoverflow.com/users/35392",
"pm_score": 4,
"selected": false,
"text": "<%itemid%>"
},
{
"answer_id": 5273245,
"author": "AhmedGamal",
"author_id": 655389,
"author_profile": "https://Stackoverflow.com/users/655389",
"pm_score": 0,
"selected": false,
"text": "onclick=\"myfun(1)\"\nonclick=\"myfun(2)\"\nonclick=\"myfun(3)\"\n\nfunction myfun(var)\n{\n if (var ==1)\n alert(v1);\n\n if (var ==2)\n alert(v2);\n\n if (var ==3)\n alert(v3);\n}\n"
},
{
"answer_id": 8611916,
"author": "Vitalii Fedorenko",
"author_id": 288671,
"author_profile": "https://Stackoverflow.com/users/288671",
"pm_score": 5,
"selected": false,
"text": "string result = System.Web.HttpUtility.JavaScriptStringEncode(\"jsString\")\n"
},
{
"answer_id": 9303208,
"author": "Starbuck Johnson",
"author_id": 1212632,
"author_profile": "https://Stackoverflow.com/users/1212632",
"pm_score": 1,
"selected": false,
"text": "function noQuote(text)\n{\n var newtext = \"\";\n for (var i = 0; i < text.length; i++) {\n if (text[i] == \"'\") {\n newtext += \"\\\"\";\n }\n else {\n newtext += text[i];\n }\n }\n return newtext;\n}\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/97586",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15441/"
] |
97,637
|
<p>Anyone got a good explanation of "combinators" (Y-combinators etc. and <strong>NOT</strong> <a href="https://en.wikipedia.org/wiki/Y_Combinator_(company)" rel="noreferrer">the company</a>)?</p>
<p>I'm looking for one for the practical programmer who understands recursion and higher-order functions, but doesn't have a strong theory or math background.</p>
<p>(Note: that I'm talking about <a href="https://en.wikipedia.org/wiki/Fixed-point_combinator#Fixed_point_combinators_in_lambda_calculus" rel="noreferrer">these things</a>)</p>
|
[
{
"answer_id": 101932,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 5,
"selected": false,
"text": "> def fun():\n> print \"bla\"\n> fun()\n\n> fun()\nbla\nbla\nbla\n...\n"
},
{
"answer_id": 286014,
"author": "mbac32768",
"author_id": 18446,
"author_profile": "https://Stackoverflow.com/users/18446",
"pm_score": 1,
"selected": false,
"text": "tru = lambda x,y: x\nfls = lambda x,y: y \n\ntest = lambda l,m,n: l(m,n)\n"
},
{
"answer_id": 2215223,
"author": "Thomas Eding",
"author_id": 239916,
"author_profile": "https://Stackoverflow.com/users/239916",
"pm_score": 4,
"selected": false,
"text": "(f o g)(x) = f(g(x))"
},
{
"answer_id": 2215293,
"author": "Igor Zevaka",
"author_id": 129404,
"author_profile": "https://Stackoverflow.com/users/129404",
"pm_score": 3,
"selected": false,
"text": "let sum a b = a + b;; //sum function (lambda)\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/97637",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8482/"
] |
97,640
|
<p>How do I get my project's runtime dependencies copied into the <code>target/lib</code> folder? </p>
<p>As it is right now, after <code>mvn clean install</code> the <code>target</code> folder contains only my project's jar, but none of the runtime dependencies.</p>
|
[
{
"answer_id": 996915,
"author": "Georgy Bolyuba",
"author_id": 4052,
"author_profile": "https://Stackoverflow.com/users/4052",
"pm_score": 8,
"selected": false,
"text": "<project>\n ...\n <profiles>\n <profile>\n <id>qa</id>\n <build>\n <plugins>\n <plugin>\n <artifactId>maven-dependency-plugin</artifactId>\n <executions>\n <execution>\n <phase>install</phase>\n <goals>\n <goal>copy-dependencies</goal>\n </goals>\n <configuration>\n <outputDirectory>${project.build.directory}/lib</outputDirectory>\n </configuration>\n </execution>\n </executions>\n </plugin>\n </plugins>\n </build>\n </profile>\n </profiles>\n</project>\n"
},
{
"answer_id": 1449651,
"author": "Rich Seller",
"author_id": 123582,
"author_profile": "https://Stackoverflow.com/users/123582",
"pm_score": 3,
"selected": false,
"text": " <plugin>\n <groupId>org.codehaus.mojo</groupId>\n <artifactId>appassembler-maven-plugin</artifactId>\n <version>1.0</version>\n <executions>\n <execution>\n <id>generate-jsw-scripts</id>\n <phase>package</phase>\n <goals>\n <goal>generate-daemons</goal>\n </goals>\n <configuration>\n <!--declare the JSW config -->\n <daemons>\n <daemon>\n <id>myApp</id>\n <mainClass>name.seller.rich.MyMainClass</mainClass>\n <commandLineArguments>\n <commandLineArgument>start</commandLineArgument>\n </commandLineArguments>\n <platforms>\n <platform>jsw</platform>\n </platforms> \n </daemon>\n </daemons>\n <target>${project.build.directory}/appassembler</target>\n </configuration>\n </execution>\n <execution>\n <id>assemble-standalone</id>\n <phase>integration-test</phase>\n <goals>\n <goal>assemble</goal>\n </goals>\n <configuration>\n <programs>\n <program>\n <mainClass>name.seller.rich.MyMainClass</mainClass>\n <!-- the name of the bat/sh files to be generated -->\n <name>mymain</name>\n </program>\n </programs>\n <platforms>\n <platform>windows</platform>\n <platform>unix</platform>\n </platforms>\n <repositoryLayout>flat</repositoryLayout>\n <repositoryName>lib</repositoryName>\n </configuration>\n </execution>\n </executions>\n </plugin>\n <plugin>\n <artifactId>maven-assembly-plugin</artifactId>\n <version>2.2-beta-4</version>\n <executions>\n <execution>\n <phase>integration-test</phase>\n <goals>\n <goal>single</goal>\n </goals>\n <configuration>\n <descriptors>\n <descriptor>src/main/assembly/archive.xml</descriptor>\n </descriptors>\n </configuration>\n </execution>\n </executions>\n </plugin> \n"
},
{
"answer_id": 3769147,
"author": "OleVV",
"author_id": 455012,
"author_profile": "https://Stackoverflow.com/users/455012",
"pm_score": 1,
"selected": false,
"text": "<plugin>\n <artifactId>maven-assembly-plugin</artifactId>\n <version>2.2-beta-5</version>\n <configuration>\n <archive>\n <manifest>\n <mainClass>dk.certifikat.oces2.some.package.MyMainClass</mainClass>\n </manifest>\n </archive>\n <descriptorRefs>\n <descriptorRef>jar-with-dependencies</descriptorRef>\n </descriptorRefs>\n </configuration>\n</plugin>\n"
},
{
"answer_id": 6536190,
"author": "ruhsuzbaykus",
"author_id": 453708,
"author_profile": "https://Stackoverflow.com/users/453708",
"pm_score": 5,
"selected": false,
"text": "<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">\n\n <modelVersion>4.0.0</modelVersion>\n <groupId>groupId</groupId>\n <artifactId>artifactId</artifactId>\n <version>1.0</version>\n\n <dependencies>\n <dependency>\n <groupId>org.mybatis</groupId>\n <artifactId>mybatis-spring</artifactId>\n <version>1.1.1</version>\n </dependency>\n </dependencies>\n\n <build>\n <plugins>\n <plugin>\n <artifactId>maven-dependency-plugin</artifactId>\n <executions>\n <execution>\n <phase>process-sources</phase>\n\n <goals>\n <goal>copy-dependencies</goal>\n </goals>\n\n <configuration>\n <outputDirectory>${targetdirectory}</outputDirectory>\n </configuration>\n </execution>\n </executions>\n </plugin>\n </plugins>\n </build>\n</project>\n"
},
{
"answer_id": 9087972,
"author": "RubyTuesdayDONO",
"author_id": 155090,
"author_profile": "https://Stackoverflow.com/users/155090",
"pm_score": 2,
"selected": false,
"text": "<project>\n <build>\n <plugins>\n <plugin>\n <artifactId>maven-assembly-plugin</artifactId>\n <version>2.2.2</version>\n <configuration>\n <descriptorRefs>\n <descriptorRef>jar-with-dependencies</descriptorRef>\n </descriptorRefs>\n </configuration>\n </plugin>\n </plugins>\n </build>\n</project>\n"
},
{
"answer_id": 10395558,
"author": "adjablon",
"author_id": 1075955,
"author_profile": "https://Stackoverflow.com/users/1075955",
"pm_score": 5,
"selected": false,
"text": "<plugin>\n<groupId>org.apache.maven.plugins</groupId>\n<artifactId>maven-jar-plugin</artifactId>\n<version>2.4</version>\n<configuration>\n <archive>\n <manifest> \n <addClasspath>true</addClasspath>\n <classpathPrefix>lib/</classpathPrefix>\n <mainClass>MainClass</mainClass>\n </manifest>\n </archive>\n </configuration>\n</plugin>\n<plugin>\n <groupId>org.apache.maven.plugins</groupId>\n <artifactId>maven-dependency-plugin</artifactId>\n <version>2.4</version>\n <executions>\n <execution>\n <id>copy</id>\n <phase>install</phase>\n <goals>\n <goal>copy-dependencies</goal>\n </goals>\n <configuration>\n <outputDirectory>\n ${project.build.directory}/lib\n </outputDirectory>\n </configuration>\n </execution>\n </executions>\n</plugin>\n"
},
{
"answer_id": 21641165,
"author": "user3286149",
"author_id": 3286149,
"author_profile": "https://Stackoverflow.com/users/3286149",
"pm_score": 7,
"selected": false,
"text": "mvn install dependency:copy-dependencies \n"
},
{
"answer_id": 25441276,
"author": "Duncan Jones",
"author_id": 474189,
"author_profile": "https://Stackoverflow.com/users/474189",
"pm_score": 5,
"selected": false,
"text": "target/dependencies"
},
{
"answer_id": 47963667,
"author": "isapir",
"author_id": 968244,
"author_profile": "https://Stackoverflow.com/users/968244",
"pm_score": 5,
"selected": false,
"text": "build/plugins"
},
{
"answer_id": 70747872,
"author": "Times",
"author_id": 5151202,
"author_profile": "https://Stackoverflow.com/users/5151202",
"pm_score": 0,
"selected": false,
"text": "settings.xml"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/97640",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18320/"
] |
97,646
|
<p>Given a source color of any hue by the system or user, I'd like a simple algorithm I can use to work out a lighter or darker variants of the selected color. Similar to effects used on Windows Live Messenger for styling the user interface.</p>
<p>Language is C# with .net 3.5.</p>
<p><strong>Responding to comment:</strong> Color format is (Alpha)RGB. With values as bytes or floats.</p>
<p><strong>Marking answer:</strong> For the context of my use (a few simple UI effects), the answer I'm marking as accepted is actually the most simple for this context. However, I've given up votes to the more complex and accurate answers too. Anyone doing more advanced color operations and finding this thread in future should definitely check those out. Thanks SO. :)</p>
|
[
{
"answer_id": 97697,
"author": "KPexEA",
"author_id": 13676,
"author_profile": "https://Stackoverflow.com/users/13676",
"pm_score": 4,
"selected": false,
"text": "void RGBToHSV(unsigned char cr, unsigned char cg, unsigned char cb,double *ph,double *ps,double *pv)\n{\ndouble r,g,b;\ndouble max, min, delta;\n\n/* convert RGB to [0,1] */\n\nr = (double)cr/255.0f;\ng = (double)cg/255.0f;\nb = (double)cb/255.0f;\n\nmax = MAXx(r,(MAXx(g,b)));\nmin = MINx(r,(MINx(g,b)));\n\npv[0] = max;\n\n/* Calculate saturation */\n\nif (max != 0.0)\n ps[0] = (max-min)/max;\nelse\n ps[0] = 0.0; \n\nif (ps[0] == 0.0)\n{\n ph[0] = 0.0f; //UNDEFINED;\n return;\n}\n/* chromatic case: Saturation is not 0, so determine hue */\ndelta = max-min;\n\nif (r==max)\n{\n ph[0] = (g-b)/delta;\n}\nelse if (g==max)\n{\n ph[0] = 2.0 + (b-r)/delta;\n}\nelse if (b==max)\n{\n ph[0] = 4.0 + (r-g)/delta;\n}\nph[0] = ph[0] * 60.0;\nif (ph[0] < 0.0)\n ph[0] += 360.0;\n}\n\nvoid HSVToRGB(double h,double s,double v,unsigned char *pr,unsigned char *pg,unsigned char *pb)\n{\nint i;\ndouble f, p, q, t;\ndouble r,g,b;\n\nif( s == 0 )\n{\n // achromatic (grey)\n r = g = b = v;\n}\nelse\n{\n h /= 60; // sector 0 to 5\n i = (int)floor( h );\n f = h - i; // factorial part of h\n p = v * ( 1 - s );\n q = v * ( 1 - s * f );\n t = v * ( 1 - s * ( 1 - f ) );\n switch( i )\n {\n case 0:\n r = v;\n g = t;\n b = p;\n break;\n case 1:\n r = q;\n g = v;\n b = p;\n break;\n case 2:\n r = p;\n g = v;\n b = t;\n break;\n case 3:\n r = p;\n g = q;\n b = v;\n break;\n case 4:\n r = t;\n g = p;\n b = v;\n break;\n default: // case 5:\n r = v;\n g = p;\n b = q;\n break;\n }\n}\nr*=255;\ng*=255;\nb*=255;\n\npr[0]=(unsigned char)r;\npg[0]=(unsigned char)g;\npb[0]=(unsigned char)b;\n}\n"
},
{
"answer_id": 97796,
"author": "DarenW",
"author_id": 10468,
"author_profile": "https://Stackoverflow.com/users/10468",
"pm_score": 3,
"selected": false,
"text": "f"
},
{
"answer_id": 214350,
"author": "GregUzelac",
"author_id": 27068,
"author_profile": "https://Stackoverflow.com/users/27068",
"pm_score": 3,
"selected": false,
"text": "ControlPaint.Dark()"
},
{
"answer_id": 2690026,
"author": "Keith",
"author_id": 905,
"author_profile": "https://Stackoverflow.com/users/905",
"pm_score": 6,
"selected": false,
"text": "Color.Lerp"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/97646",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/483/"
] |
97,663
|
<p>Programming PHP in Eclipse PDT is predominately a joy: code completion, templates, method jumping, etc.</p>
<p>However, one thing that drives me crazy is that I can't get my lines in PHP files to word wrap so on long lines I'm typing out indefinitely to the right.</p>
<p>I click on Windows|Preferences and type in "wrap" and get:</p>
<pre><code>- Java | Code Style | Formatter
- Java | Editor | Typing
- Web and XML | CSS Files | Source
</code></pre>
<p>I've tried changing the "wrap automatically" that I found there and the "Line width" to 72 but they had no effect.</p>
<p>How can I get word wrap to work in Eclipse PDT for PHP files?</p>
|
[
{
"answer_id": 15783091,
"author": "Fedir RYKHTIK",
"author_id": 634275,
"author_profile": "https://Stackoverflow.com/users/634275",
"pm_score": 4,
"selected": false,
"text": "-clean"
},
{
"answer_id": 37103016,
"author": "KrisWebDev",
"author_id": 2227298,
"author_profile": "https://Stackoverflow.com/users/2227298",
"pm_score": 3,
"selected": false,
"text": "ADVANCED MODE"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/97663",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4639/"
] |
97,683
|
<p>Here is a snippet of CSS that I need explained:</p>
<pre class="lang-css prettyprint-override"><code>#section {
width: 860px;
background: url(/blah.png);
position: absolute;
top: 0;
left: 50%;
margin-left: -445px;
}
</code></pre>
<p>Ok so it's absolute positioning of an image, obviously.</p>
<ol>
<li>top is like padding from the top, right?</li>
<li>what does left 50% do?</li>
<li>why is the left margin at -445px? </li>
</ol>
<p><b>Update:</b>
width is 860px.
The actual image is 100x100 if that makes a difference??</p>
|
[
{
"answer_id": 97747,
"author": "pilsetnieks",
"author_id": 6615,
"author_profile": "https://Stackoverflow.com/users/6615",
"pm_score": 3,
"selected": true,
"text": "top: 50%\nmargin-top: -(height/2)px;\n"
},
{
"answer_id": 97761,
"author": "Dan",
"author_id": 17121,
"author_profile": "https://Stackoverflow.com/users/17121",
"pm_score": 2,
"selected": false,
"text": "position:absolute"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/97683",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1368/"
] |
97,694
|
<p>I've been somewhat spoiled using Eclipse and java. I started using vim to do C coding in a linux environment, is there a way to have vim automatically do the proper spacing for blocks? </p>
<p>So after typing a { the next line will have 2 spaces indented in, and a return on that line will keep it at the same indentation, and a } will shift back 2 spaces?</p>
|
[
{
"answer_id": 97723,
"author": "davr",
"author_id": 14569,
"author_profile": "https://Stackoverflow.com/users/14569",
"pm_score": 8,
"selected": true,
"text": ":set autoindent\n:set cindent\n"
},
{
"answer_id": 97775,
"author": "Commodore Jaeger",
"author_id": 4659,
"author_profile": "https://Stackoverflow.com/users/4659",
"pm_score": 6,
"selected": false,
"text": ":set cindent\n"
},
{
"answer_id": 98367,
"author": "rampion",
"author_id": 9859,
"author_profile": "https://Stackoverflow.com/users/9859",
"pm_score": 3,
"selected": false,
"text": "autoindent"
},
{
"answer_id": 2657596,
"author": "JamesM-SiteGen",
"author_id": 407348,
"author_profile": "https://Stackoverflow.com/users/407348",
"pm_score": 3,
"selected": false,
"text": "user@host:~ $ echo set autoindent >> .vimrc\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/97694",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9628/"
] |
97,732
|
<p>I have a certain page (we'll call it MyPage) that can be accessed from three different pages. In the Web.sitemap file, I tried to stuff the XML for this page under the three separate nodes like this:</p>
<p>< Page 1 ><br>
< MyPage / ><br>
...<br>
< /Page 1 ><br><br>
< Page 2 ><br>
< MyPage / ><br>
...<br>
< /Page 2 ><br><br>
< Page 3 ><br>
< MyPage / ><br>
...<br>
< /Page 3 ><br></p>
<p>In doing so I received the following error:</p>
<p>Multiple nodes with the same URL 'Default.aspx' were found.
XmlSiteMapProvider requires that sitemap nodes have unique URLs.</p>
<p>I read online that the SiteMapNodes are stored as a dictionary internally which explains why I can't use the same URL. In any case, I'm just looking for alternate ways to go about solving this problem. Any suggestions would be greatly appreciated.</p>
|
[
{
"answer_id": 202251,
"author": "Beaker",
"author_id": 8673,
"author_profile": "https://Stackoverflow.com/users/8673",
"pm_score": 0,
"selected": false,
"text": "<siteMapNode url=\"ListAll.aspx\">\n <siteMapNode url =\"Detail.aspx?node=all\" />\n</siteMapNode>\n<siteMapNode url=\"ListMine.aspx\">\n <siteMapNode url =\"Detail.aspx?node=mine\" />\n</siteMapNode>\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/97732",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16830/"
] |
97,762
|
<p>I have a collection of non-overlapping rectangles that cover an enclosing rectangle. What is the best way to find the containing rectangle for a mouse click?</p>
<p>The obvious answer is to have an array of rectangles and to search them in sequence, making the search O(n). Is there some way to order them by position so that the algorithm is less than O(n), say, O(log n) or O(sqrt(n))?</p>
|
[
{
"answer_id": 97806,
"author": "Nils Pipenbrinck",
"author_id": 15955,
"author_profile": "https://Stackoverflow.com/users/15955",
"pm_score": 4,
"selected": true,
"text": " int id = bitmap_getpixel (mouse.x, mouse.y)\n if (id != -1)\n {\n hit_rectange (id);\n }\n else\n {\n no_hit();\n }\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/97762",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10293/"
] |
97,781
|
<p>Part of a new product I have been assigned to work on involves server-side conversion of the 'common' video formats to something that Flash can play.</p>
<p>As far as I know, my only option is to convert to FLV. I have been giving ffmpeg a go around, but I'm finding a few WMV files that come out with garbled sound (I've tried playing with the audio rates).</p>
<p>Are there any other 'good' CLI converters for Linux? Or are there other video formats that Flash can play?</p>
|
[
{
"answer_id": 97799,
"author": "Dark Shikari",
"author_id": 11206,
"author_profile": "https://Stackoverflow.com/users/11206",
"pm_score": 5,
"selected": true,
"text": "FLV with AAC or MP3 audio, and FLV1 (Sorenson Spark H.263), VP6, or H.264 video.\nMP4 with AAC or MP3 audio, and H.264 video (mp4s must be hinted with qt-faststart or mp4box).\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/97781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2192/"
] |
97,816
|
<p>I want to know if people here typically disable SELinux on installations where it is on by default? If so can you explain why, what kind of system it was, etc?</p>
<p>I'd like to get as many opinions on this as possible.</p>
|
[
{
"answer_id": 97881,
"author": "hoyhoy",
"author_id": 3499,
"author_profile": "https://Stackoverflow.com/users/3499",
"pm_score": 2,
"selected": false,
"text": "chcon -R -h -t httpd_sys_content_t /var/www/html \n"
},
{
"answer_id": 98219,
"author": "mike511",
"author_id": 9593,
"author_profile": "https://Stackoverflow.com/users/9593",
"pm_score": 1,
"selected": false,
"text": "/dev/sda*"
},
{
"answer_id": 98238,
"author": "jtimberman",
"author_id": 7672,
"author_profile": "https://Stackoverflow.com/users/7672",
"pm_score": 3,
"selected": false,
"text": "sudo audit2allow -m \"${name}\" -i /var/log/audit/audit.log > ${name}.te\n"
},
{
"answer_id": 102091,
"author": "Scott",
"author_id": 7399,
"author_profile": "https://Stackoverflow.com/users/7399",
"pm_score": -1,
"selected": false,
"text": "/etc/sysconfig/selinux"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/97816",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12098/"
] |
97,850
|
<p>For my school work, I do a lot of switching computers (from labs to my laptop to the library). I'd kind of like to put this code under some kind of version control. Of course the problem is that I can't always install additional software on the computers I use. Is there any kind of version control system that I can keep on a thumb drive? I have a 2GB drive to put this on, but I can get a bigger one if necessary.</p>
<p>The projects I'm doing aren't especially big FYI.</p>
<p><strong>EDIT:</strong> This needs to work under windows.</p>
<p><strong>EDIT II:</strong> Bazaar ended up being what I chose. It's even better if you go with TortoiseBzr.</p>
|
[
{
"answer_id": 97922,
"author": "Milan Babuškov",
"author_id": 14690,
"author_profile": "https://Stackoverflow.com/users/14690",
"pm_score": 4,
"selected": false,
"text": "git-init\ngit add .\ngit commit -m \"Done\"\n"
},
{
"answer_id": 97955,
"author": "Jonny Buchanan",
"author_id": 6760,
"author_profile": "https://Stackoverflow.com/users/6760",
"pm_score": 4,
"selected": false,
"text": "darcs init\ndarcs add -r *\ndarcs record -am \"Initial commit\"\n"
},
{
"answer_id": 98143,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 2,
"selected": false,
"text": "RCS"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/97850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2147/"
] |
97,875
|
<p>I need a way to recursively delete a folder and its children.</p>
<p>Is there a prebuilt tool for this, or do I need to write one?</p>
<p><code>DEL /S</code> doesn't delete directories.</p>
<p><code>DELTREE</code> was removed from Windows 2000+</p>
|
[
{
"answer_id": 97895,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 3,
"selected": false,
"text": "del /s foldername\n"
},
{
"answer_id": 97896,
"author": "Duncan Smart",
"author_id": 1278,
"author_profile": "https://Stackoverflow.com/users/1278",
"pm_score": 11,
"selected": true,
"text": "rd /s /q \"path\"\n"
},
{
"answer_id": 97900,
"author": "Branan",
"author_id": 13894,
"author_profile": "https://Stackoverflow.com/users/13894",
"pm_score": 3,
"selected": false,
"text": "rmdir /S /Q %DIRNAME%"
},
{
"answer_id": 97911,
"author": "Jim McKeeth",
"author_id": 255,
"author_profile": "https://Stackoverflow.com/users/255",
"pm_score": 7,
"selected": false,
"text": "RMDIR [/S] [/Q] [drive:]path"
},
{
"answer_id": 97924,
"author": "user17481",
"author_id": 17481,
"author_profile": "https://Stackoverflow.com/users/17481",
"pm_score": 4,
"selected": false,
"text": "rm"
},
{
"answer_id": 98069,
"author": "wbkang",
"author_id": 2710,
"author_profile": "https://Stackoverflow.com/users/2710",
"pm_score": 7,
"selected": false,
"text": "takeown /r /f folder\ncacls folder /c /G \"ADMINNAME\":F /T\nrmdir /s folder\n"
},
{
"answer_id": 12255881,
"author": "Louis",
"author_id": 1644882,
"author_profile": "https://Stackoverflow.com/users/1644882",
"pm_score": 2,
"selected": false,
"text": "RMDIR /S %1"
},
{
"answer_id": 29779439,
"author": "binki",
"author_id": 429091,
"author_profile": "https://Stackoverflow.com/users/429091",
"pm_score": 2,
"selected": false,
"text": "rm -rf"
},
{
"answer_id": 35731786,
"author": "Sireesh Yarlagadda",
"author_id": 2057902,
"author_profile": "https://Stackoverflow.com/users/2057902",
"pm_score": 5,
"selected": false,
"text": "rd /s /q \"FOLDER_NAME\"\n"
},
{
"answer_id": 37577718,
"author": "Clay",
"author_id": 444917,
"author_profile": "https://Stackoverflow.com/users/444917",
"pm_score": 4,
"selected": false,
"text": "if exist myfolder ( rmdir /s/q myfolder )\n"
},
{
"answer_id": 52144579,
"author": "gdenuf",
"author_id": 582398,
"author_profile": "https://Stackoverflow.com/users/582398",
"pm_score": 2,
"selected": false,
"text": " get-childitem *logs* -path .\\ -directory -recurse | remove-item -confirm:$false -recurse -force\n"
},
{
"answer_id": 53859156,
"author": "cilerler",
"author_id": 439130,
"author_profile": "https://Stackoverflow.com/users/439130",
"pm_score": 3,
"selected": false,
"text": " Remove-Item -Recurse -Force \"TestDirectory\"\n"
},
{
"answer_id": 54947647,
"author": "Artif3x",
"author_id": 2487033,
"author_profile": "https://Stackoverflow.com/users/2487033",
"pm_score": 4,
"selected": false,
"text": "yarn global add rimraf\n"
},
{
"answer_id": 56571474,
"author": "Roel Van de Paar",
"author_id": 1208218,
"author_profile": "https://Stackoverflow.com/users/1208218",
"pm_score": 2,
"selected": false,
"text": "rd -r -include *.* -force somedir\n"
},
{
"answer_id": 61047316,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "rm -rf..."
},
{
"answer_id": 63745519,
"author": "stackprotector",
"author_id": 11942268,
"author_profile": "https://Stackoverflow.com/users/11942268",
"pm_score": 4,
"selected": false,
"text": "rm -r -fo <path>\n"
},
{
"answer_id": 68315523,
"author": "faester",
"author_id": 540968,
"author_profile": "https://Stackoverflow.com/users/540968",
"pm_score": 2,
"selected": false,
"text": "rm -recurse -force"
},
{
"answer_id": 68369398,
"author": "BananaAcid",
"author_id": 1644202,
"author_profile": "https://Stackoverflow.com/users/1644202",
"pm_score": 2,
"selected": false,
"text": "$ rm -rf ./path"
},
{
"answer_id": 69406402,
"author": "jianyongli",
"author_id": 4046647,
"author_profile": "https://Stackoverflow.com/users/4046647",
"pm_score": 2,
"selected": false,
"text": "Remove-Item"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/97875",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] |
97,913
|
<p>What are your best usability testing tips?
I need quick & cheap. </p>
|
[
{
"answer_id": 98664,
"author": "therealhoff",
"author_id": 18175,
"author_profile": "https://Stackoverflow.com/users/18175",
"pm_score": 3,
"selected": false,
"text": "The archetypal non-technical user, one's elderly and scatterbrained maiden aunt. Invoked in discussions of usability for people who are not hackers and geeks; one sees references to the “Aunt Tillie test”."
},
{
"answer_id": 105815,
"author": "pcorcoran",
"author_id": 15992,
"author_profile": "https://Stackoverflow.com/users/15992",
"pm_score": 1,
"selected": false,
"text": "\"John spent 15 seconds looking at the screen before acting. He moused over the top nav to see if it contained popup menus. He first clicked \"About Us\" even though it wasn't central to his task.\""
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/97913",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17398/"
] |
97,948
|
<p>What is <code>std::pair</code> for, why would I use it, and what benefits does <code>boost::compressed_pair</code> bring?</p>
|
[
{
"answer_id": 97968,
"author": "John Mulder",
"author_id": 2242,
"author_profile": "https://Stackoverflow.com/users/2242",
"pm_score": 2,
"selected": false,
"text": "std::map<>\nstd::multimap<> \n"
},
{
"answer_id": 97973,
"author": "user17481",
"author_id": 17481,
"author_profile": "https://Stackoverflow.com/users/17481",
"pm_score": 2,
"selected": false,
"text": "std::map::insert"
},
{
"answer_id": 98022,
"author": "jwfearn",
"author_id": 10559,
"author_profile": "https://Stackoverflow.com/users/10559",
"pm_score": 6,
"selected": true,
"text": "std::pair"
},
{
"answer_id": 573457,
"author": "Logan Capaldo",
"author_id": 61289,
"author_profile": "https://Stackoverflow.com/users/61289",
"pm_score": 6,
"selected": false,
"text": "compressed_pair"
},
{
"answer_id": 573582,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 4,
"selected": false,
"text": "boost::function<void(int)> f(boost::bind(&f, _1));\n"
},
{
"answer_id": 2124394,
"author": "mloskot",
"author_id": 151641,
"author_profile": "https://Stackoverflow.com/users/151641",
"pm_score": 2,
"selected": false,
"text": "std::pair"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/97948",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18352/"
] |
97,962
|
<p>A poorly-written back-end system we interface with is having trouble with handling the load we're producing. While they fix their load problems, we're trying to reduce any additional load we're generating, one of which is that the back-end system continues to try and service a form submission even if another submission has come from the same user.</p>
<p>One thing we've noticed is users double-clicking the form submission button. I need to de-bounce these clicks, and prevent a second form submission.<br>
My approach (using Prototype) places an <code>onSubmit</code> on the form that calls the following function which hides the form submission button and displays a "loading..." <code>div</code>.</p>
<pre><code>function disableSubmit(id1, id2) {
$(id1).style.display = 'none';
$(id2).style.display = 'inline';
}
</code></pre>
<p>The problem I've found with this approach is that if I use an animated gif in the "loading..." <code>div</code>, it loads fine but doesn't animate while the form is submitting.</p>
<p>Is there a better way to do this de-bouncing and continue to show animation on the page while waiting for the form result to (finally) load?
</p>
|
[
{
"answer_id": 99366,
"author": "matt lohkamp",
"author_id": 14026,
"author_profile": "https://Stackoverflow.com/users/14026",
"pm_score": 3,
"selected": true,
"text": "$('input[type=\"submit\"]').click(function(event){\n event.preventDefault();\n this.click(null);\n});\n"
},
{
"answer_id": 142983,
"author": "Fczbkk",
"author_id": 22920,
"author_profile": "https://Stackoverflow.com/users/22920",
"pm_score": 3,
"selected": false,
"text": "document.observe( 'dom:loaded', function() { // when document is loaded\n $$( 'form' ).each( function( form ) { // find all FORM elements in the document\n form.observe( 'submit', function() { // when any form is submitted\n $$( 'input[type=\"submit\"]' ).invoke( 'disable' ); // disable all submit buttons\n } );\n } );\n} );\n"
},
{
"answer_id": 667104,
"author": "unscriptable",
"author_id": 80593,
"author_profile": "https://Stackoverflow.com/users/80593",
"pm_score": 2,
"selected": false,
"text": "var debounce = function (func, threshold, execAsap) {\n\n var timeout;\n\n return function debounced () {\n var obj = this, args = arguments;\n function delayed () {\n if (!execAsap)\n func.apply(obj, args);\n timeout = null; \n };\n\n if (timeout)\n clearTimeout(timeout);\n else if (execAsap)\n func.apply(obj, args);\n\n timeout = setTimeout(delayed, threshold || 100); \n };\n\n}\n"
},
{
"answer_id": 73077049,
"author": "Bhola Kr. Khawas",
"author_id": 9985883,
"author_profile": "https://Stackoverflow.com/users/9985883",
"pm_score": 0,
"selected": false,
"text": "<i class=\"spinner hidden fa fa-spinner fa-spin\" style=\"margin-right: 2px\"></i>\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/97962",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10788/"
] |
97,971
|
<p>Having programmed through emacs and vi for years and years at this point, I have heard that using an IDE is a very good way of becoming more efficient.</p>
<p>To that end, I have decided to try using Eclipse for a lot of coding and seeing how I get on.</p>
<p>Are there any suggestions for easing the transition over to an IDE. Obviously, some will think none of this is worth the bother, but I think with Eclipse allowing emacs-style key bindings and having code completion and in-built debugging, I reckon it is well worth trying to move over to a more feature-rich environment for the bulk of my development worth.</p>
<p>So what suggestions do you have for easing the transition?</p>
|
[
{
"answer_id": 98151,
"author": "Desty",
"author_id": 2161072,
"author_profile": "https://Stackoverflow.com/users/2161072",
"pm_score": 3,
"selected": true,
"text": "String messageXml = in.read();\nMessage response = messageParser.parse(messageXml);\nreturn response;"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/97971",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/277/"
] |
97,976
|
<p>I have a datagridview that accepts a list(of myObject) as a datasource. I want to add a new row to the datagrid to add to the database. I get this done by getting the list... adding a blank myObject to the list and then reseting the datasource. I now want to set the focus to the second cell in the new row.</p>
<p>To CLARIFY i am trying to set the focus</p>
|
[
{
"answer_id": 97986,
"author": "ine",
"author_id": 4965,
"author_profile": "https://Stackoverflow.com/users/4965",
"pm_score": 0,
"selected": false,
"text": "Me.dataEvidence.SelectedRows\n"
},
{
"answer_id": 1213548,
"author": "Michael Todd",
"author_id": 16623,
"author_profile": "https://Stackoverflow.com/users/16623",
"pm_score": 3,
"selected": true,
"text": "dataGridView.Rows[rowNumber].Cells[columnNumber].Selected = true;\n"
},
{
"answer_id": 18220884,
"author": "Elias",
"author_id": 2414458,
"author_profile": "https://Stackoverflow.com/users/2414458",
"pm_score": 0,
"selected": false,
"text": "Sub Whatever()\n\n ' all above code\n\n DataGridView1.Focus()\n DataGridView1.CurrentCell = DataGridView1.Rows(x).Cells(y) 'x is your desired row number, y is your desired column number\n\n ' all below code\n\nEnd Sub\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/97976",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16820/"
] |
97,982
|
<p>A Google search for "site:example.com" will tell you the number of pages of example.com that are currently in Google's index. Is it possible to find out how this number has changed over time?</p>
|
[
{
"answer_id": 172539,
"author": "Peter Boughton",
"author_id": 9360,
"author_profile": "https://Stackoverflow.com/users/9360",
"pm_score": 0,
"selected": false,
"text": "\\d+(?=</b> from <b>domain\\.net</b>)\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/97982",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18333/"
] |
97,984
|
<p>When a PHP application makes a database connection it of course generally needs to pass a login and password. If I'm using a single, minimum-permission login for my application, then the PHP needs to know that login and password somewhere. What is the best way to secure that password? It seems like just writing it in the PHP code isn't a good idea.</p>
|
[
{
"answer_id": 98120,
"author": "Jim",
"author_id": 8427,
"author_profile": "https://Stackoverflow.com/users/8427",
"pm_score": 3,
"selected": false,
"text": "~/.pgpass"
},
{
"answer_id": 101696,
"author": "e-satis",
"author_id": 9951,
"author_profile": "https://Stackoverflow.com/users/9951",
"pm_score": 2,
"selected": false,
"text": "<?php exit() ?>\n\n[...]\n\nPlain text data including password\n"
},
{
"answer_id": 104790,
"author": "Bob Fanger",
"author_id": 19165,
"author_profile": "https://Stackoverflow.com/users/19165",
"pm_score": 4,
"selected": false,
"text": "mysql_connect(\"localhost\", \"me\", \"mypass\");\n"
},
{
"answer_id": 1223883,
"author": "kellen",
"author_id": 94671,
"author_profile": "https://Stackoverflow.com/users/94671",
"pm_score": 7,
"selected": false,
"text": "<files mypasswdfile>\norder allow,deny\ndeny from all\n</files>\n"
},
{
"answer_id": 10176831,
"author": "Lars Nyström",
"author_id": 1227116,
"author_profile": "https://Stackoverflow.com/users/1227116",
"pm_score": 6,
"selected": false,
"text": "php_value mysql.default.user myusername\nphp_value mysql.default.password mypassword\nphp_value mysql.default.host server\n"
},
{
"answer_id": 42239784,
"author": "Courtney Miles",
"author_id": 2045006,
"author_profile": "https://Stackoverflow.com/users/2045006",
"pm_score": 3,
"selected": false,
"text": "phpinfo()"
},
{
"answer_id": 65475916,
"author": "Bruno Guignard",
"author_id": 10313805,
"author_profile": "https://Stackoverflow.com/users/10313805",
"pm_score": 0,
"selected": false,
"text": "$_ENV['MYVAR'] = $myvar"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/97984",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18359/"
] |
97,987
|
<p>What's the best practice for using a <code>switch</code> statement vs using an <code>if</code> statement for 30 <code>unsigned</code> enumerations where about 10 have an expected action (that presently is the same action). Performance and space need to be considered but are not critical. I've abstracted the snippet so don't hate me for the naming conventions.</p>
<p><code>switch</code> statement:</p>
<pre><code>// numError is an error enumeration type, with 0 being the non-error case
// fire_special_event() is a stub method for the shared processing
switch (numError)
{
case ERROR_01 : // intentional fall-through
case ERROR_07 : // intentional fall-through
case ERROR_0A : // intentional fall-through
case ERROR_10 : // intentional fall-through
case ERROR_15 : // intentional fall-through
case ERROR_16 : // intentional fall-through
case ERROR_20 :
{
fire_special_event();
}
break;
default:
{
// error codes that require no additional action
}
break;
}
</code></pre>
<p><code>if</code> statement:</p>
<pre><code>if ((ERROR_01 == numError) ||
(ERROR_07 == numError) ||
(ERROR_0A == numError) ||
(ERROR_10 == numError) ||
(ERROR_15 == numError) ||
(ERROR_16 == numError) ||
(ERROR_20 == numError))
{
fire_special_event();
}
</code></pre>
|
[
{
"answer_id": 98011,
"author": "William Keller",
"author_id": 17095,
"author_profile": "https://Stackoverflow.com/users/17095",
"pm_score": 0,
"selected": false,
"text": "if"
},
{
"answer_id": 98036,
"author": "Jay Bazuzi",
"author_id": 5314,
"author_profile": "https://Stackoverflow.com/users/5314",
"pm_score": 1,
"selected": false,
"text": "if"
},
{
"answer_id": 98052,
"author": "lewis",
"author_id": 14442,
"author_profile": "https://Stackoverflow.com/users/14442",
"pm_score": 0,
"selected": false,
"text": "switch(numerror){\n ERROR_20 : { fire_special_event(); } break;\n default : { null; } break;\n}\n"
},
{
"answer_id": 103332,
"author": "paercebal",
"author_id": 14089,
"author_profile": "https://Stackoverflow.com/users/14089",
"pm_score": 5,
"selected": false,
"text": "// WON'T COMPILE\nextern const int MY_VALUE ;\n\nvoid doSomething(const int p_iValue)\n{\n switch(p_iValue)\n {\n case MY_VALUE : /* do something */ ; break ;\n default : /* do something else */ ; break ;\n }\n}\n"
},
{
"answer_id": 129515,
"author": "Mark Ransom",
"author_id": 5987,
"author_profile": "https://Stackoverflow.com/users/5987",
"pm_score": 6,
"selected": false,
"text": "if (RequiresSpecialEvent(numError))\n fire_special_event();\n"
},
{
"answer_id": 129860,
"author": "mbac32768",
"author_id": 18446,
"author_profile": "https://Stackoverflow.com/users/18446",
"pm_score": 1,
"selected": false,
"text": "unsigned int special_events[] = {\n ERROR_01,\n ERROR_07,\n ERROR_0A,\n ERROR_10,\n ERROR_15,\n ERROR_16,\n ERROR_20\n };\n int special_events_length = sizeof (special_events) / sizeof (unsigned int);\n\n void process_event(unsigned int numError) {\n for (int i = 0; i < special_events_length; i++) {\n if (numError == special_events[i]) {\n fire_special_event();\n break;\n }\n }\n }\n"
},
{
"answer_id": 1783241,
"author": "McAnix",
"author_id": 190401,
"author_profile": "https://Stackoverflow.com/users/190401",
"pm_score": 0,
"selected": false,
"text": "public class SwitchTest {\nstatic final int max = 100000;\n\npublic static void main(String[] args) {\n\nint counter1 = 0;\nlong start1 = 0l;\nlong total1 = 0l;\n\nint counter2 = 0;\nlong start2 = 0l;\nlong total2 = 0l;\nboolean loop = true;\n\nstart1 = System.currentTimeMillis();\nwhile (true) {\n if (counter1 == max) {\n break;\n } else {\n counter1++;\n }\n}\ntotal1 = System.currentTimeMillis() - start1;\n\nstart2 = System.currentTimeMillis();\nwhile (loop) {\n switch (counter2) {\n case max:\n loop = false;\n break;\n default:\n counter2++;\n }\n}\ntotal2 = System.currentTimeMillis() - start2;\n\nSystem.out.println(\"While if/else: \" + total1 + \"ms\");\nSystem.out.println(\"Switch: \" + total2 + \"ms\");\nSystem.out.println(\"Max Loops: \" + max);\n\nSystem.exit(0);\n}\n}\n"
},
{
"answer_id": 3834930,
"author": "MarioFrost",
"author_id": 463312,
"author_profile": "https://Stackoverflow.com/users/463312",
"pm_score": 1,
"selected": false,
"text": "while (true) != while (loop)\n"
},
{
"answer_id": 32356125,
"author": "Peter Cordes",
"author_id": 224132,
"author_profile": "https://Stackoverflow.com/users/224132",
"pm_score": 3,
"selected": false,
"text": "switch"
},
{
"answer_id": 42406571,
"author": "Jordan Effinger",
"author_id": 7455487,
"author_profile": "https://Stackoverflow.com/users/7455487",
"pm_score": 0,
"selected": false,
"text": "`int a;\n cout<<\"enter value:\\n\";\n cin>>a;\n\n if( a > 0 && a < 5)\n {\n cout<<\"a is between 0, 5\\n\";\n\n }else if(a > 5 && a < 10)\n\n cout<<\"a is between 5,10\\n\";\n\n }else{\n\n \"a is not an integer, or is not in range 0,10\\n\";\n"
},
{
"answer_id": 66429462,
"author": "Kai Petzke",
"author_id": 2528436,
"author_profile": "https://Stackoverflow.com/users/2528436",
"pm_score": 3,
"selected": false,
"text": "switch"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/97987",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8883/"
] |
98,033
|
<p>Several Linq.Enumerable functions take an <code>IEqualityComparer<T></code>. Is there a convenient wrapper class that adapts a <code>delegate(T,T)=>bool</code> to implement <code>IEqualityComparer<T></code>? It's easy enough to write one (if your ignore problems with defining a correct hashcode), but I'd like to know if there is an out-of-the-box solution.</p>
<p>Specifically, I want to do set operations on <code>Dictionary</code>s, using only the Keys to define membership (while retaining the values according to different rules).</p>
|
[
{
"answer_id": 98119,
"author": "aku",
"author_id": 1196,
"author_profile": "https://Stackoverflow.com/users/1196",
"pm_score": 6,
"selected": false,
"text": "class Comparer<T>: IEqualityComparer<T>\n{\n private readonly Func<T, T, bool> _comparer;\n\n public Comparer(Func<T, T, bool> comparer)\n {\n if (comparer == null)\n throw new ArgumentNullException(\"comparer\");\n\n _comparer = comparer;\n }\n\n public bool Equals(T x, T y)\n {\n return _comparer(x, y);\n }\n\n public int GetHashCode(T obj)\n {\n return obj.ToString().ToLower().GetHashCode();\n }\n}\n\n...\n\nFunc<int, int, bool> f = (x, y) => x == y;\nvar comparer = new Comparer<int>(f);\nConsole.WriteLine(comparer.Equals(1, 1));\nConsole.WriteLine(comparer.Equals(1, 2));\n"
},
{
"answer_id": 98138,
"author": "Gregg",
"author_id": 18266,
"author_profile": "https://Stackoverflow.com/users/18266",
"pm_score": -1,
"selected": false,
"text": "public class MyComparer<T> : IEqualityComparer<T>\n{\n private Func<T, T, bool> _compare;\n MyComparer(Func<T, T, bool> compare)\n {\n _compare = compare;\n }\n\n public bool Equals(T x, Ty)\n {\n return _compare(x, y);\n }\n\n public int GetHashCode(T obj)\n {\n return obj.GetHashCode();\n }\n}\n"
},
{
"answer_id": 270203,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": false,
"text": "public class FuncEqualityComparer<T> : IEqualityComparer<T>\n{\n readonly Func<T, T, bool> _comparer;\n readonly Func<T, int> _hash;\n\n public FuncEqualityComparer( Func<T, T, bool> comparer )\n : this( comparer, t => t.GetHashCode())\n {\n }\n\n public FuncEqualityComparer( Func<T, T, bool> comparer, Func<T, int> hash )\n {\n _comparer = comparer;\n _hash = hash;\n }\n\n public bool Equals( T x, T y )\n {\n return _comparer( x, y );\n }\n\n public int GetHashCode( T obj )\n {\n return _hash( obj );\n }\n}\n"
},
{
"answer_id": 1239337,
"author": "orip",
"author_id": 37020,
"author_profile": "https://Stackoverflow.com/users/37020",
"pm_score": 7,
"selected": false,
"text": "var foo = new List<string> { \"abc\", \"de\", \"DE\" };\n\n// case-insensitive distinct\nvar distinct = foo.Distinct(new KeyEqualityComparer<string>( x => x.ToLower() ) );\n"
},
{
"answer_id": 3142096,
"author": "Sushil",
"author_id": 379132,
"author_profile": "https://Stackoverflow.com/users/379132",
"pm_score": 1,
"selected": false,
"text": "public class MyComparer<T> : IEqualityComparer<T> \n{ \n public bool Equals(T x, T y) \n { \n return EqualityComparer<T>.Default.Equals(x, y); \n } \n\n public int GetHashCode(T obj) \n { \n return obj.GetHashCode(); \n } \n} \n"
},
{
"answer_id": 3719617,
"author": "Ruben Bartelink",
"author_id": 11635,
"author_profile": "https://Stackoverflow.com/users/11635",
"pm_score": 7,
"selected": true,
"text": "class FuncEqualityComparer<T> : IEqualityComparer<T>\n{\n readonly Func<T, T, bool> _comparer;\n readonly Func<T, int> _hash;\n\n public FuncEqualityComparer( Func<T, T, bool> comparer )\n : this( comparer, t => 0 ) // NB Cannot assume anything about how e.g., t.GetHashCode() interacts with the comparer's behavior\n {\n }\n\n public FuncEqualityComparer( Func<T, T, bool> comparer, Func<T, int> hash )\n {\n _comparer = comparer;\n _hash = hash;\n }\n\n public bool Equals( T x, T y )\n {\n return _comparer( x, y );\n }\n\n public int GetHashCode( T obj )\n {\n return _hash( obj );\n }\n}\n"
},
{
"answer_id": 3719802,
"author": "Dan Tao",
"author_id": 105570,
"author_profile": "https://Stackoverflow.com/users/105570",
"pm_score": 7,
"selected": false,
"text": "GetHashCode"
},
{
"answer_id": 6150492,
"author": "Bruno",
"author_id": 168043,
"author_profile": "https://Stackoverflow.com/users/168043",
"pm_score": 3,
"selected": false,
"text": "public static IEnumerable<T> Distinct<T>(this IEnumerable<T> list, Func<T, object> keyExtractor)\n{\n return list.Distinct(new KeyEqualityComparer<T>(keyExtractor));\n}\nvar distinct = foo.Distinct(x => x.ToLower())\n"
},
{
"answer_id": 6176711,
"author": "Max",
"author_id": 260093,
"author_profile": "https://Stackoverflow.com/users/260093",
"pm_score": 0,
"selected": false,
"text": "public static Dictionary<TKey, TValue> Distinct<TKey, TValue>(this IEnumerable<TValue> items, Func<TValue, TKey> selector)\n {\n Dictionary<TKey, TValue> result = null;\n ICollection collection = items as ICollection;\n if (collection != null)\n result = new Dictionary<TKey, TValue>(collection.Count);\n else\n result = new Dictionary<TKey, TValue>();\n foreach (TValue item in items)\n result[selector(item)] = item;\n return result;\n }\n"
},
{
"answer_id": 6913646,
"author": "ldp615",
"author_id": 285996,
"author_profile": "https://Stackoverflow.com/users/285996",
"pm_score": 5,
"selected": false,
"text": "EqualityComparer<>.Default"
},
{
"answer_id": 10040172,
"author": "matrix",
"author_id": 1295274,
"author_profile": "https://Stackoverflow.com/users/1295274",
"pm_score": 1,
"selected": false,
"text": " public static class Comparer \n {\n public static IEqualityComparer<T> CreateComparerForElements<T>(this IEnumerable<T> enumerable, Func<T, object> keyExtractor)\n {\n return new KeyEqualityComparer<T>(keyExtractor);\n }\n }\n"
},
{
"answer_id": 17379690,
"author": "Fried",
"author_id": 2534462,
"author_profile": "https://Stackoverflow.com/users/2534462",
"pm_score": 2,
"selected": false,
"text": "persons1.Union(persons2, person => person.LastName)\n"
},
{
"answer_id": 73979911,
"author": "Tomas C",
"author_id": 7226886,
"author_profile": "https://Stackoverflow.com/users/7226886",
"pm_score": 0,
"selected": false,
"text": "public class DelegateEqualityComparer<T>: IEqualityComparer<T>\n{\n private readonly Func<T, T, bool> _equalsDelegate;\n private readonly Func<T, int> _getHashCodeDelegate;\n\n public DelegateEqualityComparer(Func<T, T, bool> equalsDelegate, Func<T, int> getHashCodeDelegate)\n {\n _equalsDelegate = equalsDelegate ?? ((tx, ty) => object.Equals(tx, ty));\n _getHashCodeDelegate = getHashCodeDelegate ?? (t => t.GetSafeHashCode());\n }\n\n public bool Equals(T x, T y) => _equalsDelegate(x, y);\n\n public int GetHashCode(T obj) => _getHashCodeDelegate(obj);\n}\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/98033",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9990/"
] |
98,096
|
<p>I've seen some people use <code>EXISTS (SELECT 1 FROM ...)</code> rather than <code>EXISTS (SELECT id FROM ...)</code> as an optimization--rather than looking up and returning a value, SQL Server can simply return the literal it was given.</p>
<p>Is <code>SELECT(1)</code> always faster? Would Selecting a value from the table require work that Selecting a literal would avoid?</p>
|
[
{
"answer_id": 99340,
"author": "jalbert",
"author_id": 1360388,
"author_profile": "https://Stackoverflow.com/users/1360388",
"pm_score": 3,
"selected": false,
"text": "SELECT 1"
},
{
"answer_id": 115881,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "SELECT null ..."
},
{
"answer_id": 1602714,
"author": "Matt Rogish",
"author_id": 2590,
"author_profile": "https://Stackoverflow.com/users/2590",
"pm_score": 4,
"selected": true,
"text": "SELECT whatever\n FROM yourtable\n WHERE EXISTS( SELECT 1/0\n FROM someothertable \n WHERE a_valid_clause )\n"
},
{
"answer_id": 4348102,
"author": "Martin Smith",
"author_id": 73226,
"author_profile": "https://Stackoverflow.com/users/73226",
"pm_score": 1,
"selected": false,
"text": "select COUNT(1) from master..spt_values\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/98096",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18347/"
] |
98,098
|
<p>Is the a VS2005 C++ compiler flag like the Xmx???M java flag so I can limit the heap size of my application running on Windows. </p>
<p>I need to limit the heap size so I can fill the memory to find out the current free memory. (The code also runs on an embedded system where this is the best method to get the memory usage)</p>
|
[
{
"answer_id": 98217,
"author": "jfs",
"author_id": 6223,
"author_profile": "https://Stackoverflow.com/users/6223",
"pm_score": 0,
"selected": false,
"text": "malloc()"
},
{
"answer_id": 641887,
"author": "Ashwin Nanjappa",
"author_id": 1630,
"author_profile": "https://Stackoverflow.com/users/1630",
"pm_score": 1,
"selected": false,
"text": "Linker -> System -> Heap Reserve Size"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/98098",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2731698/"
] |
98,124
|
<p>Why does this javascript return 108 instead of 2008? it gets the day and month correct but not the year?</p>
<pre><code>myDate = new Date();
year = myDate.getYear();
</code></pre>
<p>year = 108?</p>
|
[
{
"answer_id": 98136,
"author": "Dan",
"author_id": 17121,
"author_profile": "https://Stackoverflow.com/users/17121",
"pm_score": 2,
"selected": false,
"text": "date.getFullYear()"
},
{
"answer_id": 98162,
"author": "ConroyP",
"author_id": 2287,
"author_profile": "https://Stackoverflow.com/users/2287",
"pm_score": 8,
"selected": true,
"text": "getYear()"
},
{
"answer_id": 98237,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 5,
"selected": false,
"text": "Date.prototype.getRealYear = function() \n{ \n if(this.getFullYear)\n return this.getFullYear();\n else\n return this.getYear() + 1900; \n};\n"
},
{
"answer_id": 100802,
"author": "Arve",
"author_id": 9595,
"author_profile": "https://Stackoverflow.com/users/9595",
"pm_score": 2,
"selected": false,
"text": "getYear()"
},
{
"answer_id": 3447564,
"author": "D3vito",
"author_id": 415976,
"author_profile": "https://Stackoverflow.com/users/415976",
"pm_score": 1,
"selected": false,
"text": "date.getUTCFullYear()"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/98124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6161/"
] |
98,134
|
<p>I'm using a build script that calls Wise to create some install files. The problem is that the Wise license only allows it to be run under one particular user account, which is not the same account that my build script will run under. I know Windows has the <strong>runas</strong> command but this won't work for an automated script as there is no way to enter the password via the command line.</p>
|
[
{
"answer_id": 98323,
"author": "Jeffrey Vanneste",
"author_id": 5497,
"author_profile": "https://Stackoverflow.com/users/5497",
"pm_score": 2,
"selected": false,
"text": "CPAU -u user [-p password] -ex \"WhatToRun\" [switches]\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/98134",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/327/"
] |
98,135
|
<p>I want to use the Django template engine in my (Python) code, but I'm not building a Django-based web site. How do I use it without having a settings.py file (and others) and having to set the DJANGO_SETTINGS_MODULE environment variable?</p>
<p>If I run the following code:</p>
<pre><code>>>> import django.template
>>> from django.template import Template, Context
>>> t = Template('My name is {{ my_name }}.')
</code></pre>
<p>I get:</p>
<pre><code>ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.
</code></pre>
|
[
{
"answer_id": 98146,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "https://Stackoverflow.com/users/3560",
"pm_score": 3,
"selected": false,
"text": "settings.py"
},
{
"answer_id": 98150,
"author": "William Keller",
"author_id": 17095,
"author_profile": "https://Stackoverflow.com/users/17095",
"pm_score": 0,
"selected": false,
"text": "AppEngine"
},
{
"answer_id": 98178,
"author": "Daryl Spitzer",
"author_id": 4766,
"author_profile": "https://Stackoverflow.com/users/4766",
"pm_score": 8,
"selected": true,
"text": ">>> from django.template import Template, Context\n>>> from django.conf import settings\n>>> settings.configure()\n>>> t = Template('My name is {{ my_name }}.')\n>>> c = Context({'my_name': 'Daryl Spitzer'})\n>>> t.render(c)\nu'My name is Daryl Spitzer.'\n"
},
{
"answer_id": 98214,
"author": "nosklo",
"author_id": 17160,
"author_profile": "https://Stackoverflow.com/users/17160",
"pm_score": 6,
"selected": false,
"text": ">>> import jinja2\n>>> print jinja2.Environment().compile('{% for row in data %}{{ row.name | upper }}{% endfor %}', raw=True) \nfrom __future__ import division\nfrom jinja2.runtime import LoopContext, Context, TemplateReference, Macro, Markup, TemplateRuntimeError, missing, concat, escape, markup_join, unicode_join\nname = None\n\ndef root(context, environment=environment):\n l_data = context.resolve('data')\n t_1 = environment.filters['upper']\n if 0: yield None\n for l_row in l_data:\n if 0: yield None\n yield unicode(t_1(environment.getattr(l_row, 'name')))\n\nblocks = {}\ndebug_info = '1=9'\n"
},
{
"answer_id": 109380,
"author": "olt",
"author_id": 19759,
"author_profile": "https://Stackoverflow.com/users/19759",
"pm_score": 3,
"selected": false,
"text": "django"
},
{
"answer_id": 345360,
"author": "muhuk",
"author_id": 42188,
"author_profile": "https://Stackoverflow.com/users/42188",
"pm_score": 2,
"selected": false,
"text": "manage.py generatereports --format=html\n"
},
{
"answer_id": 11519049,
"author": "hupantingxue",
"author_id": 1318785,
"author_profile": "https://Stackoverflow.com/users/1318785",
"pm_score": 0,
"selected": false,
"text": "manage.py"
},
{
"answer_id": 20480267,
"author": "Gourneau",
"author_id": 56069,
"author_profile": "https://Stackoverflow.com/users/56069",
"pm_score": 2,
"selected": false,
"text": "from django import template\n\nregister = template.Library()\n\n@register.filter(name='bracewrap')\ndef bracewrap(value):\n return \"{\" + value + \"}\"\n"
},
{
"answer_id": 34494931,
"author": "Pramod",
"author_id": 817277,
"author_profile": "https://Stackoverflow.com/users/817277",
"pm_score": 3,
"selected": false,
"text": "settings.DEBUG"
},
{
"answer_id": 47465370,
"author": "Robert Vanden Eynde",
"author_id": 1980630,
"author_profile": "https://Stackoverflow.com/users/1980630",
"pm_score": 3,
"selected": false,
"text": "from django.conf import settings\n\nsettings.configure(TEMPLATES=[\n {\n 'BACKEND': 'django.template.backends.django.DjangoTemplates',\n 'DIRS': ['.'], # if you want the templates from a file\n 'APP_DIRS': False, # we have no apps\n },\n])\n\nimport django\ndjango.setup()\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/98135",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4766/"
] |
98,153
|
<p>I've found the standard hashing function on VS2005 is painfully slow when trying to achieve high performance look ups. What are some good examples of fast and efficient hashing algorithms that should void most collisions?</p>
|
[
{
"answer_id": 98179,
"author": "Dark Shikari",
"author_id": 11206,
"author_profile": "https://Stackoverflow.com/users/11206",
"pm_score": 4,
"selected": false,
"text": "/* magic numbers from http://www.isthe.com/chongo/tech/comp/fnv/ */\nstatic const size_t InitialFNV = 2166136261U;\nstatic const size_t FNVMultiple = 16777619;\n\n/* Fowler / Noll / Vo (FNV) Hash */\nsize_t myhash(const string &s)\n{\n size_t hash = InitialFNV;\n for(size_t i = 0; i < s.length(); i++)\n {\n hash = hash ^ (s[i]); /* xor the low 8 bits */\n hash = hash * FNVMultiple; /* multiply by the magic number */\n }\n return hash;\n}\n"
},
{
"answer_id": 98280,
"author": "Brian",
"author_id": 8959,
"author_profile": "https://Stackoverflow.com/users/8959",
"pm_score": 2,
"selected": false,
"text": " template <> struct myhash{};\n\n template <> struct myhash<string>\n {\n size_t operator()(string &to_hash) const\n {\n const char * in = to_hash.c_str();\n size_t out=0;\n while(NULL != *in)\n {\n out*= 53; //just a prime number\n out+= *in;\n ++in;\n }\n return out;\n }\n };\n\n hash_map<string, int, myhash<string> > my_hash_map;\n"
},
{
"answer_id": 99214,
"author": "bk1e",
"author_id": 8090,
"author_profile": "https://Stackoverflow.com/users/8090",
"pm_score": 3,
"selected": false,
"text": "hash_map"
},
{
"answer_id": 107657,
"author": "George V. Reilly",
"author_id": 6364,
"author_profile": "https://Stackoverflow.com/users/6364",
"pm_score": 6,
"selected": false,
"text": "unsigned int\nhash(\n const char* s,\n unsigned int seed = 0)\n{\n unsigned int hash = seed;\n while (*s)\n {\n hash = hash * 101 + *s++;\n }\n return hash;\n}\n"
},
{
"answer_id": 41314400,
"author": "philix",
"author_id": 707094,
"author_profile": "https://Stackoverflow.com/users/707094",
"pm_score": 1,
"selected": false,
"text": "unsigned long\nhash(unsigned char *str)\n{\n unsigned long hash = 5381;\n int c;\n\n while (c = *str++)\n hash = ((hash << 5) + hash) + c; /* hash * 33 + c */\n\n return hash;\n}\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/98153",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13646/"
] |
98,205
|
<p>I'm gearing up to do some Ajax style client-side JavaScript code in the near future, and I've heard rave reviews of jQuery when it comes to this realm. What I'm wondering is:</p>
<ul>
<li><strong>What are all the cross-browser JavaScript libraries out there?</strong></li>
</ul>
<p>What is the experience using them?</p>
|
[
{
"answer_id": 11110702,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "Element::classList"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98205",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/145/"
] |
98,212
|
<p>I am wondering what methods people are using for validating check boxes in ASP.NET MVC (both client and server side).</p>
<p>I am using JQuery currently for client side validation but I am curious what methods people are using, ideally with the least amount of fuss (I am looking for a new solution).</p>
<p>I should mention that I am currently using MVC Preview 4, and while I could upgrade to MVC Preview 5 if there is no elegant solution in MVC Preview 4, I would prefer not to at this stage just for compatibility purposes with other developers and existing solutions.</p>
<p>Note, I have seen these related posts:</p>
<ul>
<li><a href="https://stackoverflow.com/questions/10300/validating-posted-form-data-in-the-aspnet-mvc-framework">Validating posted form data in the
ASP.NET MVC framework</a></li>
<li><a href="https://stackoverflow.com/questions/16747/whats-the-best-way-to-implement-field-validation-using-aspnet-mvc">What’s the best way to implement field validation using ASP.NET MVC?</a></li>
<li><a href="https://stackoverflow.com/questions/61456/mvcnet-jquery-validation">MVC.net JQuery Validation</a></li>
</ul>
|
[
{
"answer_id": 98227,
"author": "Thomas R",
"author_id": 2192,
"author_profile": "https://Stackoverflow.com/users/2192",
"pm_score": 0,
"selected": false,
"text": "<?php echo isset($_POST['checkbox_name']) ? 'checked' : 'not checked'; ?>\n"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98212",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/364/"
] |
98,224
|
<p>After downloading files from a remote UNIX FTP server, you want to verify that you have downloaded all the files correctly. Minimal you will get information similar to "dir /s" command in Windows command prompt. The FTP client runs on Windows.</p>
|
[
{
"answer_id": 4414456,
"author": "jamesmar",
"author_id": 538522,
"author_profile": "https://Stackoverflow.com/users/538522",
"pm_score": 3,
"selected": false,
"text": "ls -lR\n"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98224",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13584/"
] |
98,225
|
<p>Any other tweaks for making emacs as vim-like as possible would be appreciated as well.</p>
<p>Addendum: The main reason I don't just use vim is that I love how emacs lets you open a file in two different frames [ADDED: sorry, this was confusing: I mean separate <em>windows</em>, which emacs calls "frames"]. It's like making a vertical split but I don't have to have one enormous window.</p>
|
[
{
"answer_id": 482859,
"author": "Sébastien RoccaSerra",
"author_id": 2797,
"author_profile": "https://Stackoverflow.com/users/2797",
"pm_score": 2,
"selected": false,
"text": "(define-key viper-vi-global-user-map [(delete)] 'delete-char)\n(define-key viper-vi-global-user-map \"/\" 'isearch-forward-regexp)\n(define-key viper-vi-global-user-map \"?\" 'isearch-backward-regexp)\n(define-key viper-vi-global-user-map \"\\C-wh\" 'windmove-left)\n(define-key viper-vi-global-user-map \"\\C-wj\" 'windmove-down)\n(define-key viper-vi-global-user-map \"\\C-wk\" 'windmove-up)\n(define-key viper-vi-global-user-map \"\\C-wl\" 'windmove-right)\n(define-key viper-vi-global-user-map \"\\C-wv\" '(lambda () (interactive)\n (split-window-horizontally)\n (other-window 1)\n (switch-to-buffer (other-buffer))))\n\n(define-key viper-visual-mode-map \"F\" 'viper-find-char-backward)\n(define-key viper-visual-mode-map \"t\" 'viper-goto-char-forward)\n(define-key viper-visual-mode-map \"T\" 'viper-goto-char-backward)\n(define-key viper-visual-mode-map \"e\" '(lambda ()\n (interactive)\n (viper-end-of-word 1)\n (viper-forward-char 1)))\n\n(push '(\"only\" (delete-other-windows)) ex-token-alist)\n(push '(\"close\" (delete-window)) ex-token-alist)\n"
},
{
"answer_id": 488044,
"author": "MCS",
"author_id": 1094969,
"author_profile": "https://Stackoverflow.com/users/1094969",
"pm_score": 1,
"selected": false,
"text": ":split"
},
{
"answer_id": 6079323,
"author": "tbear",
"author_id": 238973,
"author_profile": "https://Stackoverflow.com/users/238973",
"pm_score": 1,
"selected": false,
"text": " ; I use C-d to quit emacs and vim\n (vimpulse-global-set-key 'vi-state (kbd \"C-d\") 'save-buffers-kill-terminal)\n ; use ; instead of :\n (vimpulse-global-set-key 'vi-state (kbd \";\") 'viper-ex)\n ; use C-e instead of $. This works for all motion command too! (e.g. d C-e is easier to type than d$)\n (vimpulse-global-set-key 'vi-state (kbd \"C-e\") 'viper-goto-eol)\n (defun t_save() (interactive)(save-buffer)(viper-change-state-to-vi)) \n (global-set-key (kbd \"\\C-s\") 't_save) ; save using C-s instead of :w<CR> or C-x-s\n\n (defun command-line-diff (switch)\n (let ((file1 (pop command-line-args-left))\n (file2 (pop command-line-args-left)))\n (ediff file1 file2)))\n\n ;; Usage: emacs -diff file1 file2 (much better then vimdiff)\n (add-to-list 'command-switch-alist '(\"-diff\" . command-line-diff))\n"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98225",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4234/"
] |
98,242
|
<blockquote>
<p><strong>Possible Duplicate:</strong><br />
<a href="https://stackoverflow.com/questions/6457130/pre-post-increment-operator-behavior-in-c-c-java-c-sharp">Pre & post increment operator behavior in C, C++, Java, & C#</a></p>
</blockquote>
<p>Here is a test case:</p>
<pre><code>
void foo(int i, int j)
{
printf("%d %d", i, j);
}
...
test = 0;
foo(test++, test);
</code></pre>
<p>I would expect to get a "0 1" output, but I get "0 0"
What gives??</p>
|
[
{
"answer_id": 98263,
"author": "Mike Thompson",
"author_id": 2754,
"author_profile": "https://Stackoverflow.com/users/2754",
"pm_score": 4,
"selected": false,
"text": "mov ecx, DWORD PTR _i$[ebp]\npush ecx\nmov edx, DWORD PTR tv66[ebp]\npush edx\ncall _foo\nadd esp, 8\nmov eax, DWORD PTR _i$[ebp]\nadd eax, 1\nmov DWORD PTR _i$[ebp], eax\n"
},
{
"answer_id": 99363,
"author": "Benjamin Autin",
"author_id": 1440933,
"author_profile": "https://Stackoverflow.com/users/1440933",
"pm_score": 3,
"selected": false,
"text": "int printf(const char *format, ...);\n"
},
{
"answer_id": 100634,
"author": "Anthony Williams",
"author_id": 5597,
"author_profile": "https://Stackoverflow.com/users/5597",
"pm_score": 5,
"selected": false,
"text": "f(test,test++)"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98242",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10703/"
] |
98,274
|
<p>Is it possible to integrate SSRS reports to the webforms..an example will be enough to keep me moving. </p>
|
[
{
"answer_id": 98344,
"author": "John Christensen",
"author_id": 1194,
"author_profile": "https://Stackoverflow.com/users/1194",
"pm_score": 3,
"selected": false,
"text": "public void ProcessRequest(HttpContext context)\n{\n string report = null;\n int managerId = -1;\n int planId = -1;\n GetParametersFromSession(context.Session, out report, out managerId, out planId);\n if (report == null || managerId == -1 || planId == -1)\n {\n return;\n }\n\n CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;\n\n List<ReportParameter> parameters = new List<ReportParameter>();\n parameters.Add(new ReportParameter(\"Prefix\", report));\n parameters.Add(new ReportParameter(\"ManagerId\", managerId.ToString()));\n parameters.Add(new ReportParameter(\"ActionPlanId\", planId.ToString()));\n string language = Thread.CurrentThread.CurrentCulture.Name;\n language = String.Format(\"{0}_{1}\", language.Substring(0, 2), language.Substring(3, 2).ToLower());\n parameters.Add(new ReportParameter(\"Lang\", language));\n\n ReportViewer rv = new ReportViewer();\n rv.ProcessingMode = ProcessingMode.Remote;\n rv.ServerReport.ReportServerUrl = new Uri(ConfigurationManager.AppSettings[\"ReportServer\"]);\n if (ConfigurationManager.AppSettings[\"DbYear\"] == \"2007\")\n {\n rv.ServerReport.ReportPath = \"/ActionPlanning/Plan\";\n }\n else\n {\n rv.ServerReport.ReportPath = String.Format(\"/ActionPlanning{0}/Plan\", ConfigurationManager.AppSettings[\"DbYear\"]);\n }\n rv.ServerReport.SetParameters(parameters);\n\n string mimeType = null;\n string encoding = null;\n string extension = null;\n string[] streamIds = null;\n Warning[] warnings = null;\n byte[] output = rv.ServerReport.Render(\"pdf\", null, out mimeType, out encoding, out extension, out streamIds, out warnings);\n\n context.Response.ContentType = mimeType;\n context.Response.BinaryWrite(output);\n}\n"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98274",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14752/"
] |
98,310
|
<p>(I don't want to hear about how crazy I am to want that! :)</p>
<p>Focus-follows-mouse is also known as point-to-focus, pointer focus, and (in some implementations) sloppy focus. [Add other terms that will make this more searchable!] X-mouse</p>
|
[
{
"answer_id": 98331,
"author": "Clint Ecker",
"author_id": 13668,
"author_profile": "https://Stackoverflow.com/users/13668",
"pm_score": 6,
"selected": false,
"text": "defaults write com.apple.Terminal FocusFollowsMouse -bool true\n"
},
{
"answer_id": 98357,
"author": "dreeves",
"author_id": 4234,
"author_profile": "https://Stackoverflow.com/users/4234",
"pm_score": 3,
"selected": false,
"text": "defaults write com.apple.Terminal FocusFollowsMouse -string YES\n"
},
{
"answer_id": 29159270,
"author": "wprl",
"author_id": 17847,
"author_profile": "https://Stackoverflow.com/users/17847",
"pm_score": 4,
"selected": false,
"text": "brew install amethyst"
},
{
"answer_id": 35073462,
"author": "sbmpost",
"author_id": 5394382,
"author_profile": "https://Stackoverflow.com/users/5394382",
"pm_score": 5,
"selected": false,
"text": "on run {input, parameters}\n tell application \"Finder\"\n if exists of application process \"AutoRaise\" then\n quit application \"/Applications/AutoRaise\"\n display notification \"AutoRaise Stopped\"\n else\n launch application \"/Applications/AutoRaise\"\n display notification \"AutoRaise Started\"\n end if\n end tell\n return input\nend run\n"
},
{
"answer_id": 55970830,
"author": "Les Grieve",
"author_id": 4637974,
"author_profile": "https://Stackoverflow.com/users/4637974",
"pm_score": 4,
"selected": false,
"text": "chunkc set ffm_disable_autoraise 0\n"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98310",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4234/"
] |
98,320
|
<p>My model layer is being used by a handful of different projects and I'd like to use a single XML Spring Configuration file for the model regardless of which project is using it.</p>
<p>My question is: Since not all beans are used in all projects am I wasting resources to any significant amount if there not being instantiated? I'm not too sure how lazy Spring is about loading them since it's never been an issue until now.</p>
<p>Any ideas?</p>
|
[
{
"answer_id": 98544,
"author": "MetroidFan2002",
"author_id": 8026,
"author_profile": "https://Stackoverflow.com/users/8026",
"pm_score": 4,
"selected": true,
"text": "<bean id=\"lazy\" class=\"com.foo.ExpensiveToCreateBean\" lazy-init=\"true\"/>\n"
},
{
"answer_id": 150210,
"author": "Tom De Leu",
"author_id": 22263,
"author_profile": "https://Stackoverflow.com/users/22263",
"pm_score": 3,
"selected": false,
"text": "<beans/>"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98320",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2443/"
] |
98,340
|
<p>An example of unspecified behavior in the C language is the order of evaluation of arguments to a function. It might be left to right or right to left, you just don't know. This would affect how <code>foo(c++, c)</code> or <code>foo(++c, c)</code> gets evaluated.</p>
<p>What other unspecified behavior is there that can surprise the unaware programmer?</p>
|
[
{
"answer_id": 98356,
"author": "Nils Pipenbrinck",
"author_id": 15955,
"author_profile": "https://Stackoverflow.com/users/15955",
"pm_score": 7,
"selected": true,
"text": "float funky_float_abs (float a)\n{\n unsigned int temp = *(unsigned int *)&a;\n temp &= 0x7fffffff;\n return *(float *)&temp;\n}\n"
},
{
"answer_id": 98358,
"author": "1800 INFORMATION",
"author_id": 3146,
"author_profile": "https://Stackoverflow.com/users/3146",
"pm_score": 4,
"selected": false,
"text": "// what does this do?\nx = x++;\n"
},
{
"answer_id": 98414,
"author": "Adam Pierce",
"author_id": 5324,
"author_profile": "https://Stackoverflow.com/users/5324",
"pm_score": 4,
"selected": false,
"text": "result = x/*y;\n"
},
{
"answer_id": 98589,
"author": "Steve Jessop",
"author_id": 13005,
"author_profile": "https://Stackoverflow.com/users/13005",
"pm_score": 5,
"selected": false,
"text": "if (x+1 < x)"
},
{
"answer_id": 18260275,
"author": "Jens",
"author_id": 648658,
"author_profile": "https://Stackoverflow.com/users/648658",
"pm_score": 4,
"selected": false,
"text": "int"
},
{
"answer_id": 18261067,
"author": "Keith Thompson",
"author_id": 827263,
"author_profile": "https://Stackoverflow.com/users/827263",
"pm_score": 3,
"selected": false,
"text": "\"x\"\n"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98340",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10703/"
] |
98,359
|
<p>How do you implement the fastest possible <a href="http://en.wikipedia.org/wiki/Gaussian_blur" rel="noreferrer">Gaussian blur</a> algorithm?</p>
<p>I am going to implement it in Java, so <a href="http://en.wikipedia.org/wiki/Graphics_processing_unit" rel="noreferrer">GPU</a> solutions are ruled out. My application, <a href="http://planetGenesis.sourceforge.net" rel="noreferrer">planetGenesis</a>, is cross platform, so I don't want <a href="http://en.wikipedia.org/wiki/Java_Native_Interface" rel="noreferrer">JNI</a>.</p>
|
[
{
"answer_id": 1377012,
"author": "Paul Harrison",
"author_id": 102709,
"author_profile": "https://Stackoverflow.com/users/102709",
"pm_score": 2,
"selected": false,
"text": "y(i) = y(i-1) + x(i)\n"
},
{
"answer_id": 3712073,
"author": "Ben McIntosh",
"author_id": 50859,
"author_profile": "https://Stackoverflow.com/users/50859",
"pm_score": 2,
"selected": false,
"text": "Gaussian coefficient"
},
{
"answer_id": 38285167,
"author": "Ali Akdurak",
"author_id": 306711,
"author_profile": "https://Stackoverflow.com/users/306711",
"pm_score": 2,
"selected": false,
"text": "@Override\npublic BufferedImage ProcessImage(BufferedImage image) {\n int width = image.getWidth();\n int height = image.getHeight();\n\n int[] pixels = image.getRGB(0, 0, width, height, null, 0, width);\n int[] changedPixels = new int[pixels.length];\n\n FastGaussianBlur(pixels, changedPixels, width, height, 12);\n\n BufferedImage newImage = new BufferedImage(width, height, image.getType());\n newImage.setRGB(0, 0, width, height, changedPixels, 0, width);\n\n return newImage;\n}\n\nprivate void FastGaussianBlur(int[] source, int[] output, int width, int height, int radius) {\n ArrayList<Integer> gaussianBoxes = CreateGausianBoxes(radius, 3);\n BoxBlur(source, output, width, height, (gaussianBoxes.get(0) - 1) / 2);\n BoxBlur(output, source, width, height, (gaussianBoxes.get(1) - 1) / 2);\n BoxBlur(source, output, width, height, (gaussianBoxes.get(2) - 1) / 2);\n}\n\nprivate ArrayList<Integer> CreateGausianBoxes(double sigma, int n) {\n double idealFilterWidth = Math.sqrt((12 * sigma * sigma / n) + 1);\n\n int filterWidth = (int) Math.floor(idealFilterWidth);\n\n if (filterWidth % 2 == 0) {\n filterWidth--;\n }\n\n int filterWidthU = filterWidth + 2;\n\n double mIdeal = (12 * sigma * sigma - n * filterWidth * filterWidth - 4 * n * filterWidth - 3 * n) / (-4 * filterWidth - 4);\n double m = Math.round(mIdeal);\n\n ArrayList<Integer> result = new ArrayList<>();\n\n for (int i = 0; i < n; i++) {\n result.add(i < m ? filterWidth : filterWidthU);\n }\n\n return result;\n}\n\nprivate void BoxBlur(int[] source, int[] output, int width, int height, int radius) {\n System.arraycopy(source, 0, output, 0, source.length);\n BoxBlurHorizantal(output, source, width, height, radius);\n BoxBlurVertical(source, output, width, height, radius);\n}\n\nprivate void BoxBlurHorizontal(int[] sourcePixels, int[] outputPixels, int width, int height, int radius) {\n int resultingColorPixel;\n float iarr = 1f / (radius + radius);\n for (int i = 0; i < height; i++) {\n int outputIndex = i * width;\n int li = outputIndex;\n int sourceIndex = outputIndex + radius;\n\n int fv = Byte.toUnsignedInt((byte) sourcePixels[outputIndex]);\n int lv = Byte.toUnsignedInt((byte) sourcePixels[outputIndex + width - 1]);\n float val = (radius) * fv;\n\n for (int j = 0; j < radius; j++) {\n val += Byte.toUnsignedInt((byte) (sourcePixels[outputIndex + j]));\n }\n\n for (int j = 0; j < radius; j++) {\n val += Byte.toUnsignedInt((byte) sourcePixels[sourceIndex++]) - fv;\n resultingColorPixel = Byte.toUnsignedInt(((Integer) Math.round(val * iarr)).byteValue());\n outputPixels[outputIndex++] = (0xFF << 24) | (resultingColorPixel << 16) | (resultingColorPixel << 8) | (resultingColorPixel);\n }\n\n for (int j = (radius + 1); j < (width - radius); j++) {\n val += Byte.toUnsignedInt((byte) sourcePixels[sourceIndex++]) - Byte.toUnsignedInt((byte) sourcePixels[li++]);\n resultingColorPixel = Byte.toUnsignedInt(((Integer) Math.round(val * iarr)).byteValue());\n outputPixels[outputIndex++] = (0xFF << 24) | (resultingColorPixel << 16) | (resultingColorPixel << 8) | (resultingColorPixel);\n }\n\n for (int j = (width - radius); j < width; j++) {\n val += lv - Byte.toUnsignedInt((byte) sourcePixels[li++]);\n resultingColorPixel = Byte.toUnsignedInt(((Integer) Math.round(val * iarr)).byteValue());\n outputPixels[outputIndex++] = (0xFF << 24) | (resultingColorPixel << 16) | (resultingColorPixel << 8) | (resultingColorPixel);\n }\n }\n}\n\nprivate void BoxBlurVertical(int[] sourcePixels, int[] outputPixels, int width, int height, int radius) {\n int resultingColorPixel;\n float iarr = 1f / (radius + radius + 1);\n for (int i = 0; i < width; i++) {\n int outputIndex = i;\n int li = outputIndex;\n int sourceIndex = outputIndex + radius * width;\n\n int fv = Byte.toUnsignedInt((byte) sourcePixels[outputIndex]);\n int lv = Byte.toUnsignedInt((byte) sourcePixels[outputIndex + width * (height - 1)]);\n float val = (radius + 1) * fv;\n\n for (int j = 0; j < radius; j++) {\n val += Byte.toUnsignedInt((byte) sourcePixels[outputIndex + j * width]);\n }\n for (int j = 0; j <= radius; j++) {\n val += Byte.toUnsignedInt((byte) sourcePixels[sourceIndex]) - fv;\n resultingColorPixel = Byte.toUnsignedInt(((Integer) Math.round(val * iarr)).byteValue());\n outputPixels[outputIndex] = (0xFF << 24) | (resultingColorPixel << 16) | (resultingColorPixel << 8) | (resultingColorPixel);\n sourceIndex += width;\n outputIndex += width;\n }\n for (int j = radius + 1; j < (height - radius); j++) {\n val += Byte.toUnsignedInt((byte) sourcePixels[sourceIndex]) - Byte.toUnsignedInt((byte) sourcePixels[li]);\n resultingColorPixel = Byte.toUnsignedInt(((Integer) Math.round(val * iarr)).byteValue());\n outputPixels[outputIndex] = (0xFF << 24) | (resultingColorPixel << 16) | (resultingColorPixel << 8) | (resultingColorPixel);\n li += width;\n sourceIndex += width;\n outputIndex += width;\n }\n for (int j = (height - radius); j < height; j++) {\n val += lv - Byte.toUnsignedInt((byte) sourcePixels[li]);\n resultingColorPixel = Byte.toUnsignedInt(((Integer) Math.round(val * iarr)).byteValue());\n outputPixels[outputIndex] = (0xFF << 24) | (resultingColorPixel << 16) | (resultingColorPixel << 8) | (resultingColorPixel);\n li += width;\n outputIndex += width;\n }\n }\n}\n"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98359",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18390/"
] |
98,376
|
<p>I need to store some simple properties in a file and access them from Ruby.</p>
<p>I absolutely love the .properties file format that is the standard for such things in Java (using the java.util.Properties class)... it is simple, easy to use and easy to read.</p>
<p>So, is there a Ruby class somewhere that will let me load up some key value pairs from a file like that without a lot of effort?</p>
<p>I don't want to use XML, so please don't suggest REXML (my purpose does not warrant the "angle bracket tax").</p>
<p>I have considered rolling my own solution... it would probably be about 5-10 lines of code tops, but I would still rather use an existing library (if it is essentially a hash built from a file)... as that would bring it down to 1 line....</p>
<hr>
<p>UPDATE: It's actually a straight Ruby app, not rails, but I think YAML will do nicely (it was in the back of my mind, but I had forgotten about it... have seen but never used as of yet), thanks everyone!</p>
|
[
{
"answer_id": 98415,
"author": "Ryan Bigg",
"author_id": 15245,
"author_profile": "https://Stackoverflow.com/users/15245",
"pm_score": 6,
"selected": true,
"text": "YAML::Load(File.open(\"file\"))"
},
{
"answer_id": 99032,
"author": "Dan Harper",
"author_id": 14530,
"author_profile": "https://Stackoverflow.com/users/14530",
"pm_score": 3,
"selected": false,
"text": "migration:\n customer: Example Customer\n test: false\nsources:\n- name: Use the Source\n engine: Foo\n- name: Sourcey\n engine: Bar\n"
},
{
"answer_id": 99695,
"author": "Aaron Hinni",
"author_id": 12086,
"author_profile": "https://Stackoverflow.com/users/12086",
"pm_score": 3,
"selected": false,
"text": "{\n :blah => 'blee',\n :foo => 'bar',\n :items => ['item1', 'item2'],\n :stuff => true\n}\n"
},
{
"answer_id": 15607254,
"author": "Ross Attrill",
"author_id": 556644,
"author_profile": "https://Stackoverflow.com/users/556644",
"pm_score": 3,
"selected": false,
"text": "[SECTION]\nkey=value\n"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/122/"
] |
98,394
|
<p>I looked for the name of a procedure, which applies a tree structure of procedures to a tree structure of data, yielding a tree structure of results - all three trees having the same structure. </p>
<p>Such a procedure might have the signature: </p>
<pre>(map-tree data functree)</pre>
<p>Its return value would be the result of elementwise application of functree's elements on the corresponding data elements. </p>
<p>Examples (assuming that the procedure is called map-tree): </p>
<p>Example 1: </p>
<pre>(define *2 (lambda (x) (* 2 x)))
; and similar definitions for *3 and *5
(map-tree '(100 (10 1)) '(*2 (*3 *5)))</pre>
<p>would yield the result <pre>(200 (30 5))</pre></p>
<p>Example 2: </p>
<pre>(map-tree '(((aa . ab) (bb . bc)) (cc . (cd . ce)))
'((car cdr) cadr))</pre>
<p>yields the result <pre>((aa bc) cd)</pre></p>
<p>However I did not find such a function in the SLIB documentation, which I consulted. </p>
<p>Does such a procedure already exist?<br>
If not, what would be a suitable name for the procedure, and how would you order its arguments?</p>
|
[
{
"answer_id": 98520,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 3,
"selected": true,
"text": "map-traversing"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98394",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11886/"
] |
98,400
|
<p>I've got a git-svn clone of an svn repo, and I want to encourage my colleagues to look at git as an option. The problem is that cloning the repo out of svn takes 3 days, but cloning from my git instance takes 10 minutes.</p>
<p>I've got a script that will allow people to clone my git repo and re-point it at the original SVN, but it requires knowing how I set some of my config values. I'd prefer the script be able to pull those values over the wire.</p>
|
[
{
"answer_id": 107740,
"author": "Pat Notz",
"author_id": 825,
"author_profile": "https://Stackoverflow.com/users/825",
"pm_score": 2,
"selected": false,
"text": "\ngit config -f/path/to/your/repo/.git/config --get ...\n"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9700/"
] |
98,426
|
<p>I am working on an application that is about 250,000 lines of code. I'm currently the only developer working on this application that was originally built in .NET 1.1. Pervasive throughout is a class that inherits from CollectionBase. All database collections inherit from this class. I am considering refactoring to inherit from the generic collection List instead. Needless to say, Martin Fowler's Refactoring book has no suggestions. Should I attempt this refactor? If so, what is the best way to tackle this refactor?</p>
<p>And yes, there are unit tests throughout, but no QA team.</p>
|
[
{
"answer_id": 99555,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 2,
"selected": false,
"text": "Collection<T>"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18372/"
] |
98,449
|
<p>How would I go about converting an address or city to a latitude/longitude? Are there commercial outfits I can "rent" this service from? This would be used in a commercial desktop application on a Windows PC with fulltime internet access.</p>
|
[
{
"answer_id": 25066314,
"author": "MilanNz",
"author_id": 2922851,
"author_profile": "https://Stackoverflow.com/users/2922851",
"pm_score": 2,
"selected": false,
"text": " public static String GET(String url) throws Exception {//GET Method\n String result = null;\n InputStream inputStream = null;\n try {\n HttpClient httpclient = new DefaultHttpClient();\n HttpGet httpGet = new HttpGet(url);\n\n Log.v(\"ExecuteGET: \", httpGet.getRequestLine().toString());\n\n HttpResponse httpResponse = httpclient.execute(httpGet);\n inputStream = httpResponse.getEntity().getContent();\n if (inputStream != null) {\n result = convertInputStreamToString(inputStream);\n Log.v(\"Result: \", \"result\\n\" + result);\n } \n } catch (Exception e) {\n e.printStackTrace();\n }\n return result;\n}\n"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17259/"
] |
98,454
|
<p>There are a number of other questions related to this topic:</p>
<ol>
<li><s><a href="https://stackoverflow.com/questions/5214/whats-a-good-standard-code-layout-for-a-php-application">Whats a good standard code layout for a php application</a></s> (deleted)</li>
<li><a href="https://stackoverflow.com/questions/7596/how-to-structure-a-java-application-in-other-words-where-do-i-put-my-classes">How to structure a java application, in other words: where do I put my classes?</a></li>
<li><a href="https://stackoverflow.com/questions/41513/recommended-source-control-directory-structure">Recommended Source Control Directory Structure?</a> </li>
<li><a href="https://stackoverflow.com/questions/16829/structure-of-projects-in-version-control">Structure of Projects in Version Control</a></li>
</ol>
<p>I could not find any specific to VSTF, which has some capabilities like Team Build, integrated Unit Testing, etc. I'm wondering if these capabilities lead to a slightly different source layout recommendation.</p>
<p>Please post example of high level directory structures that you have had good luck with an explain why you like them. I'll let people vote on a "best" approach and I'll award the answer in a few days.</p>
|
[
{
"answer_id": 25066314,
"author": "MilanNz",
"author_id": 2922851,
"author_profile": "https://Stackoverflow.com/users/2922851",
"pm_score": 2,
"selected": false,
"text": " public static String GET(String url) throws Exception {//GET Method\n String result = null;\n InputStream inputStream = null;\n try {\n HttpClient httpclient = new DefaultHttpClient();\n HttpGet httpGet = new HttpGet(url);\n\n Log.v(\"ExecuteGET: \", httpGet.getRequestLine().toString());\n\n HttpResponse httpResponse = httpclient.execute(httpGet);\n inputStream = httpResponse.getEntity().getContent();\n if (inputStream != null) {\n result = convertInputStreamToString(inputStream);\n Log.v(\"Result: \", \"result\\n\" + result);\n } \n } catch (Exception e) {\n e.printStackTrace();\n }\n return result;\n}\n"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98454",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3957/"
] |
98,479
|
<p>What is the maximum value of an int in ChucK? Is there a symbolic constant for it?</p>
|
[
{
"answer_id": 98500,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "https://Stackoverflow.com/users/3560",
"pm_score": 1,
"selected": false,
"text": "int"
},
{
"answer_id": 98865,
"author": "Paul Reiners",
"author_id": 7648,
"author_profile": "https://Stackoverflow.com/users/7648",
"pm_score": 4,
"selected": true,
"text": "<<<Math.INT_MAX>>>;\n"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98479",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7648/"
] |
98,484
|
<p>I have a huge file, where I have to insert certain characters at a specific location. What is the easiest way to do that in C# without rewriting the whole file again.</p>
|
[
{
"answer_id": 469174,
"author": "Scott Marlowe",
"author_id": 1683,
"author_profile": "https://Stackoverflow.com/users/1683",
"pm_score": 1,
"selected": false,
"text": "using (BinaryWriter bw = new BinaryWriter (File.Open (strFile, FileMode.Open)))\n{\n string strNewData = \"this is some new data\";\n byte[] byteNewData = new byte[strNewData.Length];\n\n // copy contents of string to byte array\n for (var i = 0; i < strNewData.Length; i++)\n {\n byteNewData[i] = Convert.ToByte (strNewData[i]);\n }\n\n // write new data to file\n bw.Seek (15, SeekOrigin.Begin); // seek to position 15\n bw.Write (byteNewData, 0, byteNewData.Length);\n}\n"
},
{
"answer_id": 8437274,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "var sw = new Stopwatch();\nvar ab = \"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ \";\n\n// create\nvar fs = new FileStream(@\"d:\\test.txt\", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite, 262144, FileOptions.None);\nsw.Restart();\nfs.Seek(0, SeekOrigin.Begin);\nfor (var i = 0; i < 40000000; i++) fs.Write(ASCIIEncoding.ASCII.GetBytes(ab), 0, ab.Length);\nsw.Stop();\nConsole.WriteLine(\"{0} ms\", sw.Elapsed.TotalMilliseconds);\nfs.Dispose();\n\n// insert\nfs = new FileStream(@\"d:\\test.txt\", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite, 262144, FileOptions.None);\nsw.Restart();\nbyte[] b = new byte[262144];\nlong target = 10, offset = fs.Length - b.Length;\nwhile (offset != 0)\n{\n if (offset < 0)\n {\n offset = b.Length - target;\n b = new byte[offset];\n }\n fs.Position = offset; fs.Read(b, 0, b.Length);\n fs.Position = offset + target; fs.Write(b, 0, b.Length);\n offset -= b.Length;\n}\nfs.Position = target; fs.Write(ASCIIEncoding.ASCII.GetBytes(ab), 0, ab.Length);\nsw.Stop();\nConsole.WriteLine(\"{0} ms\", sw.Elapsed.TotalMilliseconds);\n"
},
{
"answer_id": 36748251,
"author": "Fabrizio Stellato",
"author_id": 3042207,
"author_profile": "https://Stackoverflow.com/users/3042207",
"pm_score": 1,
"selected": false,
"text": "// this.Stream is the stream in which you insert data\n\n{\n\nlong position = this.Stream.Position;\n\nlong length = this.Stream.Length;\n\nMemoryStream ms = new MemoryStream();\n\nthis.Stream.Position = 0;\n\nDIUtils.CopyStream(this.Stream, ms, position, progressCallback);\n\nms.Write(data, 0, data.Length);\n\nthis.Stream.Position = position;\n\nDIUtils.CopyStream(this.Stream, ms, this.Stream.Length - position, progressCallback);\n\nthis.Stream = ms;\n\n}\n\n#region Delegates\n\npublic delegate void ProgressCallback(long position, long total);\n\n#endregion\n"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98484",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4337/"
] |
98,497
|
<p>Hi i need to generate 9 digit unique account numbers. Here is my pseudocode:</p>
<pre><code>function generateAccNo()
generate an account number between 100,000,000 and 999,999,999
if the account number already exists in the DB
call generateAccNo() /* recursive call */
else
return new accout number
end if
end function
</code></pre>
<p>The function seems to be working well, however I am a bit worried about the recursive call. </p>
<p>Will this cause any memory leaks (PHP 5 under apache)?</p>
<p>Is this an acceptable way to tackle this problem?</p>
<p>Thanks for your input.</p>
|
[
{
"answer_id": 98513,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 0,
"selected": false,
"text": "function generateAccNo()\n\n while (true) { \n\n generate an account number between 100,000,000 and 999,999,999\n\n if the account number already exists in the DB \n /* do nothing */\n else\n return new accout number\n end if\n }\n\nend function\n"
},
{
"answer_id": 98522,
"author": "Josh Millard",
"author_id": 13600,
"author_profile": "https://Stackoverflow.com/users/13600",
"pm_score": 2,
"selected": false,
"text": "function generateAccNo()\n\n generate an account number between 100,000,000 and 999,999,999\n\n while ( the account number already exists in the DB ) {\n generate new account number;\n }\n return new account number\n\nend function\n"
},
{
"answer_id": 98529,
"author": "Wesley Tarle",
"author_id": 17057,
"author_profile": "https://Stackoverflow.com/users/17057",
"pm_score": 0,
"selected": false,
"text": "lock_db\ndo\n account_num <= generate number\nwhile account_num in db\n\nput row with account_num in db\n\nunlock_db\n"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98497",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
98,559
|
<pre><code>uint color;
bool parsedhex = uint.TryParse(TextBox1.Text, out color);
//where Text is of the form 0xFF0000
if(parsedhex)
//...
</code></pre>
<p>doesn't work. What am i doing wrong?</p>
|
[
{
"answer_id": 98572,
"author": "Nescio",
"author_id": 14484,
"author_profile": "https://Stackoverflow.com/users/14484",
"pm_score": 8,
"selected": true,
"text": "Convert.ToUInt32(hex, 16) //Using ToUInt32 not ToUInt64, as per OP comment\n"
},
{
"answer_id": 98588,
"author": "Corey Ross",
"author_id": 5927,
"author_profile": "https://Stackoverflow.com/users/5927",
"pm_score": 4,
"selected": false,
"text": "string hexNum = \"0xFFFF\";\nstring hexNumWithoutPrefix = hexNum.Substring(2);\n\nuint i;\nbool success = uint.TryParse(hexNumWithoutPrefix, System.Globalization.NumberStyles.HexNumber, null, out i);\n"
},
{
"answer_id": 98592,
"author": "Jeremy Wiebe",
"author_id": 11807,
"author_profile": "https://Stackoverflow.com/users/11807",
"pm_score": 6,
"selected": false,
"text": "TryParse()"
},
{
"answer_id": 19301980,
"author": "Curtis Yallop",
"author_id": 854342,
"author_profile": "https://Stackoverflow.com/users/854342",
"pm_score": 3,
"selected": false,
"text": " private static bool TryParseHex(string hex, out UInt32 result)\n {\n result = 0;\n\n if (hex == null)\n {\n return false;\n }\n\n try\n {\n result = Convert.ToUInt32(hex, 16);\n\n return true;\n }\n catch (Exception exception)\n {\n return false;\n }\n }\n"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98559",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1748529/"
] |
98,586
|
<p>I'm looking for an extremely fast atof() implementation on IA32 optimized for US-en locale, ASCII, and non-scientific notation. The windows multithreaded CRT falls down miserably here as it checks for locale changes on every call to isdigit(). Our current best is derived from the best of perl + tcl's atof implementation, and outperforms msvcrt.dll's atof by an order of magnitude. I want to do better, but am out of ideas. The BCD related x86 instructions seemed promising, but I couldn't get it to outperform the perl/tcl C code. Can any SO'ers dig up a link to the best out there? Non x86 assembly based solutions are also welcome.</p>
<p>Clarifications based upon initial answers:</p>
<p>Inaccuracies of ~2 ulp are fine for this application.<br>
The numbers to be converted will arrive in ascii messages over the network in small batches and our application needs to convert them in the lowest latency possible.</p>
|
[
{
"answer_id": 1638340,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "__forceinline"
},
{
"answer_id": 10425062,
"author": "Ira Baxter",
"author_id": 120163,
"author_profile": "https://Stackoverflow.com/users/120163",
"pm_score": 2,
"selected": false,
"text": "getchar"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98586",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6996/"
] |
98,597
|
<p>I use AutoHotKey for Windows macros. Most commonly I use it to define hotkeys that start/focus particular apps, and one to send an instant email message into my ToDo list. I also have an emergency one that kills all of my big memory-hogging apps (Outlook, Firefox, etc).</p>
<p>So, does anyone have any good AHK macros to share?</p>
|
[
{
"answer_id": 100648,
"author": "Eli Bendersky",
"author_id": 8206,
"author_profile": "https://Stackoverflow.com/users/8206",
"pm_score": 4,
"selected": false,
"text": "SetTitleMatchMode RegEx ;\n; Stuff to do when Windows Explorer is open\n;\n#IfWinActive ahk_class ExploreWClass|CabinetWClass\n ; create new folder\n ;\n ^!n::Send !fwf\n\n ; create new text file\n ;\n ^!t::Send !fwt\n\n ; open 'cmd' in the current directory\n ;\n ^!c::\n OpenCmdInCurrent()\n return\n#IfWinActive\n\n; Opens the command shell 'cmd' in the directory browsed in Explorer.\n; Note: expecting to be run when the active window is Explorer.\n;\nOpenCmdInCurrent()\n{\n WinGetText, full_path, A ; This is required to get the full path of the file from the address bar\n\n ; Split on newline (`n)\n StringSplit, word_array, full_path, `n\n full_path = %word_array1% ; Take the first element from the array\n\n ; Just in case - remove all carriage returns (`r)\n StringReplace, full_path, full_path, `r, , all \n full_path := RegExReplace(full_path, \"^Address: \", \"\") ;\n\n IfInString full_path, \\\n {\n Run, cmd /K cd /D \"%full_path%\"\n }\n else\n {\n Run, cmd /K cd /D \"C:\\ \"\n }\n}\n"
},
{
"answer_id": 780626,
"author": "Bård",
"author_id": 89349,
"author_profile": "https://Stackoverflow.com/users/89349",
"pm_score": 3,
"selected": false,
"text": "sleep, 5000\nSoundSet, 1.5 ; really low volume\n"
},
{
"answer_id": 2331289,
"author": "Peter Gfader",
"author_id": 35693,
"author_profile": "https://Stackoverflow.com/users/35693",
"pm_score": 2,
"selected": false,
"text": "#+m:: Run \"mailto:\"\n"
},
{
"answer_id": 2331297,
"author": "Peter Gfader",
"author_id": 35693,
"author_profile": "https://Stackoverflow.com/users/35693",
"pm_score": 3,
"selected": false,
"text": "; Win + X\n#x:: ; Attention: Strips formatting from the clipboard too!\nSend ^c\nclipboard = \"%clipboard%\"\n; Remove space introduced by WORD\nStringReplace, clipboard, clipboard,%A_SPACE%\",\", All\nSend ^v\nreturn\n"
},
{
"answer_id": 5336476,
"author": "rkagerer",
"author_id": 589059,
"author_profile": "https://Stackoverflow.com/users/589059",
"pm_score": 2,
"selected": false,
"text": "#IfWinActive ;Close active window when mouse button 5 is pressed\n XButton2::\n SendInput {Alt Down}{F4}{Alt Up}\n Return\n#IfWinActive \n"
},
{
"answer_id": 9555021,
"author": "EvanBlack",
"author_id": 394622,
"author_profile": "https://Stackoverflow.com/users/394622",
"pm_score": 4,
"selected": false,
"text": "^SPACE:: Winset, Alwaysontop, , A\n"
},
{
"answer_id": 14455149,
"author": "Johann",
"author_id": 638040,
"author_profile": "https://Stackoverflow.com/users/638040",
"pm_score": 2,
"selected": false,
"text": "SetTimer, FocusOnWindow, 500\nreturn\n\nFocusOnWindow:\nIfWinExist, Confirm File Replace\n WinActivate\nreturn\n"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98597",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10934/"
] |
98,606
|
<p>What is your favorite Visual Studio keyboard shortcut? I'm always up for leaving my hands on the keyboard and away from the mouse! <br /></p>
<p><strong>One</strong> per answer please.</p>
|
[
{
"answer_id": 98629,
"author": "Eric Schoonover",
"author_id": 3957,
"author_profile": "https://Stackoverflow.com/users/3957",
"pm_score": 5,
"selected": false,
"text": "Collection<string>"
},
{
"answer_id": 98779,
"author": "rbrayb",
"author_id": 9922,
"author_profile": "https://Stackoverflow.com/users/9922",
"pm_score": 6,
"selected": false,
"text": "try"
},
{
"answer_id": 162470,
"author": "Herb Caudill",
"author_id": 239663,
"author_profile": "https://Stackoverflow.com/users/239663",
"pm_score": 0,
"selected": false,
"text": "<table>"
},
{
"answer_id": 277004,
"author": "Keith Elder",
"author_id": 10624,
"author_profile": "https://Stackoverflow.com/users/10624",
"pm_score": 5,
"selected": false,
"text": "**int** x = 1;\n**int** y = 2;\n**int** z = 3;\n"
},
{
"answer_id": 917439,
"author": "callisto",
"author_id": 67249,
"author_profile": "https://Stackoverflow.com/users/67249",
"pm_score": 1,
"selected": false,
"text": "try..catch"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13791/"
] |
98,610
|
<p>By default, Eclipse won't show my .htaccess file that I maintain in my project. It just shows an empty folder in the Package Viewer tree. How can I get it to show up? No obvious preferences.</p>
|
[
{
"answer_id": 98634,
"author": "scubabbl",
"author_id": 9450,
"author_profile": "https://Stackoverflow.com/users/9450",
"pm_score": 11,
"selected": true,
"text": "Package Explorer -> View Menu -> Filters -> uncheck .* resources"
},
{
"answer_id": 26042251,
"author": "kakhkAtion",
"author_id": 3434053,
"author_profile": "https://Stackoverflow.com/users/3434053",
"pm_score": 2,
"selected": false,
"text": "Preferences -> Remote Systems -> Files -> Show hidden files"
},
{
"answer_id": 51046273,
"author": "Saikat",
"author_id": 1594823,
"author_profile": "https://Stackoverflow.com/users/1594823",
"pm_score": 4,
"selected": false,
"text": "Package Explorer"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98610",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4223/"
] |
98,622
|
<p>In VisualStudio (Pro 2008), I have just noticed some inconsistent behaviour and wondered if there was any logical reasoning behind it</p>
<p>In a WinForms project, if I use the line</p>
<pre><code>if(myComboBox.Items[i] == myObject)
</code></pre>
<p>I get a compiler warning that I might get 'Possible unintended references' as I am comparing type object to type MyObject. Fair enough.</p>
<p>However, if I instead use an interface to compare against:</p>
<pre><code>if(myComboBox.Items[i] == iMyInterface)
</code></pre>
<p>the compile warning goes away.</p>
<p>Can anyone think if there is any logical reason why this should happen, or just an artifact of the compiler not to check interfaces for comparison warnings. Any thoughts?</p>
<p><strong>EDIT</strong> In my example, the combobox was bound to a List, but that list was generated using <code>list<IMyInterface>.Cast<MyObject>().ToList<MyObject>()</code></p>
<p>Its as if the compiler is only taking still assuming I am binding to the List of IMyInterface.</p>
<p>(Object and Interface methods have been changed to protect the innocent)</p>
|
[
{
"answer_id": 98708,
"author": "Jason Stevenson",
"author_id": 13368,
"author_profile": "https://Stackoverflow.com/users/13368",
"pm_score": 0,
"selected": false,
"text": "myComboBox.DataSource = Collection<Car>;\n"
},
{
"answer_id": 171045,
"author": "Danny Tuppeny",
"author_id": 25124,
"author_profile": "https://Stackoverflow.com/users/25124",
"pm_score": 2,
"selected": true,
"text": "class Program\n{\n static void Main(string[] args)\n {\n object t1 = new MyTest() { Key = 1 };\n MyTest t2 = new MyTest() { Key = 1 };\n\n Console.WriteLine((MyTest)t1 == t2); // Uses overriden == operator, returns true\n Console.WriteLine(t1 == t2); // Reference comparison, returns false\n }\n}\n\npublic class MyTest\n{\n public int Key { get; set; }\n\n public override bool Equals(object obj)\n {\n return this.Key == (obj as MyTest).Key;\n }\n\n public override int GetHashCode()\n {\n return this.Key.GetHashCode();\n }\n\n public static bool operator ==(MyTest t1, MyTest t2)\n {\n return t1.Equals(t2);\n }\n\n public static bool operator !=(MyTest t1, MyTest t2)\n {\n return !t1.Equals(t2);\n }\n\n}\n"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5302/"
] |
98,650
|
<p>When asking about <a href="https://stackoverflow.com/questions/98340/what-are-the-common-undefinedunspecified-behavior-for-c-that-you-run-into">common undefined behavior in C</a>, people sometimes refer to the strict aliasing rule.<br>
What are they talking about?</p>
|
[
{
"answer_id": 98702,
"author": "Niall",
"author_id": 6049,
"author_profile": "https://Stackoverflow.com/users/6049",
"pm_score": 8,
"selected": false,
"text": "int*"
},
{
"answer_id": 99010,
"author": "Doug T.",
"author_id": 8123,
"author_profile": "https://Stackoverflow.com/users/8123",
"pm_score": 10,
"selected": true,
"text": "uint32_t"
},
{
"answer_id": 7005988,
"author": "Ben Voigt",
"author_id": 103167,
"author_profile": "https://Stackoverflow.com/users/103167",
"pm_score": 7,
"selected": false,
"text": "char"
},
{
"answer_id": 16534243,
"author": "Ingo Blackman",
"author_id": 1917520,
"author_profile": "https://Stackoverflow.com/users/1917520",
"pm_score": 5,
"selected": false,
"text": "#include <stdio.h>\n\nvoid check(short *h,long *k)\n{\n *h=5;\n *k=6;\n if (*h == 5)\n printf(\"strict aliasing problem\\n\");\n}\n\nint main(void)\n{\n long k[1];\n check((short *)k,k);\n return 0;\n}\n"
},
{
"answer_id": 43645721,
"author": "supercat",
"author_id": 363751,
"author_profile": "https://Stackoverflow.com/users/363751",
"pm_score": 5,
"selected": false,
"text": "int x;\nint test(double *p)\n{\n x=5;\n *p = 1.0;\n return x;\n}\n"
},
{
"answer_id": 47960435,
"author": "Myst",
"author_id": 4025095,
"author_profile": "https://Stackoverflow.com/users/4025095",
"pm_score": 4,
"selected": false,
"text": "restrict"
},
{
"answer_id": 51228315,
"author": "Shafik Yaghmour",
"author_id": 1708801,
"author_profile": "https://Stackoverflow.com/users/1708801",
"pm_score": 7,
"selected": false,
"text": "int x = 10;\nint *ip = &x;\n\nstd::cout << *ip << \"\\n\";\n*ip = 12;\nstd::cout << x << \"\\n\";\n"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98650",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10703/"
] |
98,687
|
<p>I have developed some custom DAO-like classes to meet some very specialized requirements for my project that is a server-side process that does not run inside any kind of framework. </p>
<p>The solution works great except that every time a new request is made, I open a new connection via MySQLdb.connect. </p>
<p>What is the best "drop in" solution to switch this over to using connection pooling in python? I am imagining something like the commons DBCP solution for Java. </p>
<p>The process is long running and has many threads that need to make requests, but not all at the same time... specifically they do quite a lot of work before brief bursts of writing out a chunk of their results.</p>
<p>Edited to add:
After some more searching I found <a href="http://furius.ca/antiorm/" rel="noreferrer">anitpool.py</a> which looks decent, but as I'm relatively new to python I guess I just want to make sure I'm not missing a more obvious/more idiomatic/better solution. </p>
|
[
{
"answer_id": 98703,
"author": "Chris",
"author_id": 15578,
"author_profile": "https://Stackoverflow.com/users/15578",
"pm_score": 4,
"selected": false,
"text": "import sqlalchemy.pool as pool\nimport MySQLdb as mysql\nmysql = pool.manage(mysql)\n"
},
{
"answer_id": 24741694,
"author": "metaperture",
"author_id": 955854,
"author_profile": "https://Stackoverflow.com/users/955854",
"pm_score": 3,
"selected": false,
"text": "def pool(ctor, limit=None):\n local_pool = multiprocessing.Queue()\n n = multiprocesing.Value('i', 0)\n @contextlib.contextmanager\n def pooled(ctor=ctor, lpool=local_pool, n=n):\n # block iff at limit\n try: i = lpool.get(limit and n.value >= limit)\n except multiprocessing.queues.Empty:\n n.value += 1\n i = ctor()\n yield i\n lpool.put(i)\n return pooled\n"
},
{
"answer_id": 44476153,
"author": "kilokahn",
"author_id": 8129808,
"author_profile": "https://Stackoverflow.com/users/8129808",
"pm_score": 2,
"selected": false,
"text": "dbconfig = { \"database\": \"test\", \"user\":\"joe\" }\ncnxpool = mysql.connector.pooling.MySQLConnectionPool(pool_name = \"mypool\",pool_size = 3, **dbconfig)\n"
},
{
"answer_id": 53246568,
"author": "ospider",
"author_id": 1061155,
"author_profile": "https://Stackoverflow.com/users/1061155",
"pm_score": 1,
"selected": false,
"text": "DBUtils"
},
{
"answer_id": 72698613,
"author": "mahesh langote",
"author_id": 9153368,
"author_profile": "https://Stackoverflow.com/users/9153368",
"pm_score": 0,
"selected": false,
"text": " from opensearchpy import OpenSearch\n\n def get_connection():\n connection = None\n try:\n connection = OpenSearch(\n hosts=[{'host': settings.OPEN_SEARCH_HOST, 'port': settings.OPEN_SEARCH_PORT}],\n http_compress=True,\n http_auth=(settings.OPEN_SEARCH_USER, settings.OPEN_SEARCH_PASSWORD),\n use_ssl=True,\n verify_certs=True,\n ssl_assert_hostname=False,\n ssl_show_warn=False,\n )\n except Exception as error:\n print(\"Error: Connection not established {}\".format(error))\n else:\n print(\"Connection established\")\n return connection\n\n class OpenSearchClient(object):\n connection_pool = []\n connection_in_use = []\n\n def __init__(self):\n if OpenSearchClient.connection_pool:\n pass\n else:\n\n OpenSearchClient.connection_pool = [get_connection() for i in range(0, settings.CONNECTION_POOL_SIZE)]\n\n def search_data(self, query=\"\", index_name=settings.OPEN_SEARCH_INDEX):\n available_cursor = OpenSearchClient.connection_pool.pop(0)\n OpenSearchClient.connection_in_use.append(available_cursor)\n response = available_cursor.search(body=query, index=index_name)\n available_cursor.close()\n OpenSearchClient.connection_pool.append(available_cursor)\n OpenSearchClient.connection_in_use.pop(-1)\n return response\n"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98687",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2168/"
] |
98,693
|
<p>First of all, I don't need a textual comparison so Beyond Compare doesn't do what I need.</p>
<p>I'm looking for a util that can report on the differences between two files, at the byte level. Bare minimum is the need to see the percentage change in the file, or a report on affected bytes/sectors. </p>
<p>Is there anything available to save me the trouble of doing this myself?</p>
|
[
{
"answer_id": 98723,
"author": "Steve Moyer",
"author_id": 17008,
"author_profile": "https://Stackoverflow.com/users/17008",
"pm_score": 2,
"selected": false,
"text": "hexdump file1 > file1.tmp\nhexdump file2 > file2.tmp\ndiff file1.tmp file2.tmp\n"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13132/"
] |
98,705
|
<p>I understand that the function is not allowed to change the state of the object, but I thought I read somewhere that the compiler was allowed to assume that if the function was called with the same arguments, it would return the same value and thus could reuse a cached value if it was available. e.g.</p>
<pre><code>class object
{
int get_value(int n) const
{
...
}
...
object x;
int a = x.get_value(1);
...
int b = x.get_value(1);
</code></pre>
<p>then the compiler could optimize the second call away and either use the value in a register or simply do <code>b = a;</code></p>
<p>Is this true?</p>
|
[
{
"answer_id": 98762,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 2,
"selected": false,
"text": "const"
},
{
"answer_id": 98787,
"author": "blackwing",
"author_id": 9107,
"author_profile": "https://Stackoverflow.com/users/9107",
"pm_score": 2,
"selected": false,
"text": "const"
},
{
"answer_id": 98804,
"author": "Statement",
"author_id": 2166173,
"author_profile": "https://Stackoverflow.com/users/2166173",
"pm_score": 2,
"selected": false,
"text": "int something() const { return m_pSomeObject->NextValue(); }\n"
},
{
"answer_id": 100593,
"author": "Anthony Williams",
"author_id": 5597,
"author_profile": "https://Stackoverflow.com/users/5597",
"pm_score": 6,
"selected": true,
"text": "const"
},
{
"answer_id": 106578,
"author": "nobody",
"author_id": 19405,
"author_profile": "https://Stackoverflow.com/users/19405",
"pm_score": 0,
"selected": false,
"text": "class Foo\n{\npublic:\n int bar() const\n {\n static int x = 0;\n return x++;\n }\n};\n"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98705",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4086/"
] |
98,739
|
<p>Should entities have behavior? or not?</p>
<p>Why or why not?</p>
<p>If not, does that violate Encapsulation?</p>
|
[
{
"answer_id": 5527174,
"author": "Eduard",
"author_id": 689450,
"author_profile": "https://Stackoverflow.com/users/689450",
"pm_score": 3,
"selected": false,
"text": "book.Write(); \nbook.Print(); \nbook.Publish(); \nbook.Buy(); \nbook.Open(); \nbook.Read(); \nbook.Highlight(); \nbook.Bookmark(); \nbook.GetRelatedBooks(); \n"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98739",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18175/"
] |
98,768
|
<p>I can understand that imposing a minimum length on passwords makes a lot of sense (to save users from themselves), but my <strong>bank</strong> has a requirement that passwords are between 6 and 8 characters long, and I started wondering...</p>
<ul>
<li>Wouldn't this just make it easier for brute force attacks? (Bad)</li>
<li>Does this imply that my password is being stored unencrypted? (Bad)</li>
</ul>
<p>If someone with (hopefully) some good IT security professionals working for them are imposing a max password length, should I think about doing similar? What are the pros/cons of this?</p>
|
[
{
"answer_id": 72495962,
"author": "dewd",
"author_id": 2298108,
"author_profile": "https://Stackoverflow.com/users/2298108",
"pm_score": 0,
"selected": false,
"text": "password_hash()"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98768",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] |
98,774
|
<p>I am creating a downloading application and I wish to preallocate room on the harddrive for the files before they are actually downloaded as they could potentially be rather large, and noone likes to see "This drive is full, please delete some files and try again." So, in that light, I wrote this.</p>
<pre><code>// Quick, and very dirty
System.IO.File.WriteAllBytes(filename, new byte[f.Length]);
</code></pre>
<p>It works, atleast until you download a file that is several hundred MB's, or potentially even GB's and you throw Windows into a thrashing frenzy if not totally wipe out the pagefile and kill your systems memory altogether. Oops.</p>
<p>So, with a little more enlightenment, I set out with the following algorithm.</p>
<pre><code>using (FileStream outFile = System.IO.File.Create(filename))
{
// 4194304 = 4MB; loops from 1 block in so that we leave the loop one
// block short
byte[] buff = new byte[4194304];
for (int i = buff.Length; i < f.Length; i += buff.Length)
{
outFile.Write(buff, 0, buff.Length);
}
outFile.Write(buff, 0, f.Length % buff.Length);
}
</code></pre>
<p>This works, well even, and doesn't suffer the crippling memory problem of the last solution. It's still slow though, especially on older hardware since it writes out (potentially GB's worth of) data out to the disk.</p>
<p>The question is this: Is there a better way of accomplishing the same thing? Is there a way of telling Windows to create a file of x size and simply allocate the space on the filesystem rather than actually write out a tonne of data. I don't care about initialising the data in the file at all (the protocol I'm using - bittorrent - provides hashes for the files it sends, hence worst case for random uninitialised data is I get a lucky coincidence and part of the file is correct).</p>
|
[
{
"answer_id": 98822,
"author": "Mark",
"author_id": 4405,
"author_profile": "https://Stackoverflow.com/users/4405",
"pm_score": 3,
"selected": false,
"text": "using (FileStream outFile = System.IO.File.Create(filename))\n{\n outFile.Seek(<length_to_write>-1, SeekOrigin.Begin);\n OutFile.WriteByte(0);\n}\n"
},
{
"answer_id": 98838,
"author": "Doug McClean",
"author_id": 11173,
"author_profile": "https://Stackoverflow.com/users/11173",
"pm_score": 6,
"selected": true,
"text": "public override void SetLength(\n long value\n)\n"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98774",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15537/"
] |
98,778
|
<p>I need to execute a batch file as part of the un-install process in a Windows installer project (standard OOTB VS 2008 installer project-vdproj). One cannot execute a bat file directly from the Custom Actions in the installer project, so I wrote a quick vbs script to call the required bat file.<br>
vbs code: </p>
<pre><code>Set WshShell = WScript.CreateObject( "WScript.Shell" )
command = "uninstall-windows-serivce.bat"
msgbox command
WshShell.Run ("cmd /C " & """" & command & """")
Set WshShell = Nothing
</code></pre>
<p>When this script is run independent of the uninstall, it works perfectly. However, when run as part of the uninstall, it does not execute the bat file (but the message box is shown, so I know the vbs file is called). No errors reported (at least that I can tell). Why doesn't this script work as part of the "Uninstall Custom Action"</p>
|
[
{
"answer_id": 98839,
"author": "Mike L",
"author_id": 12085,
"author_profile": "https://Stackoverflow.com/users/12085",
"pm_score": 0,
"selected": false,
"text": " Public Overrides Sub Uninstall(ByVal savedState As System.Collections.IDictionary)\n MyBase.Uninstall(savedState)\n 'Shell to batch file here\n End Sub\n"
},
{
"answer_id": 123766,
"author": "JustinD",
"author_id": 12063,
"author_profile": "https://Stackoverflow.com/users/12063",
"pm_score": 3,
"selected": false,
"text": "Set WshShell = CreateObject( \"WScript.Shell\" )\ncommand = \"uninstall-windows-serivce.bat\"\nmsgbox command\nWshShell.Run (\"cmd /C \" & \"\"\"\" & command & \"\"\"\")\nSet WshShell = Nothing\n"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98778",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18449/"
] |
98,827
|
<p>I'm looking for a method to assign variables with patterns in regular expressions with C++ .NET
something like </p>
<pre><code>String^ speed;
String^ size;
</code></pre>
<p>"command SPEED=[speed] SIZE=[size]"</p>
<p>Right now I'm using IndexOf() and Substring() but it is quite ugly</p>
|
[
{
"answer_id": 98946,
"author": "user10392",
"author_id": 10392,
"author_profile": "https://Stackoverflow.com/users/10392",
"pm_score": 0,
"selected": false,
"text": "foreach (FieldInfo f in typeof(InputArgs).GetFields()) {\n string = Regex.replace(\"\\\\[\" + f.Name + \"\\\\]\",\n f.GetValue(InputArgs).ToString());\n}\n"
},
{
"answer_id": 99048,
"author": "Sparr",
"author_id": 13675,
"author_profile": "https://Stackoverflow.com/users/13675",
"pm_score": 3,
"selected": true,
"text": "String^ speed; String^ size;\nMatch m;\nRegex theregex = new Regex (\n \"SPEED=(?<speed>(.*?)) SIZE=(?<size>(.*?)) \",\n RegexOptions::ExplicitCapture);\nm = theregex.Match (yourinputstring);\nif (m.Success)\n{\n if (m.Groups[\"speed\"].Success)\n speed = m.Groups[\"speed\"].Value;\n if (m.Groups[\"size\"].Success)\n size = m.Groups[\"size\"].Value;\n}\nelse\n throw new FormatException (\"Input options not recognized\");\n"
},
{
"answer_id": 99114,
"author": "jon",
"author_id": 12215,
"author_profile": "https://Stackoverflow.com/users/12215",
"pm_score": 2,
"selected": false,
"text": "Pattern pattern = Pattern.compile(\"command SPEED=(\\d+) SIZE=(\\d+)\");\nMatcher matcher = pattern.matcher(inputStr);\nif (matcher.find()) {\n speed = matcher.group(1);\n size = matcher.group(2);\n}\n"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98827",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6367/"
] |
98,859
|
<p>Does Information Hiding mean I should minimize the number of properties my classes have? Is that right? Do you tend to make your classes private fields with methods?</p>
|
[
{
"answer_id": 98939,
"author": "Benjamin Autin",
"author_id": 1440933,
"author_profile": "https://Stackoverflow.com/users/1440933",
"pm_score": 0,
"selected": false,
"text": "private int _myInt;\npublic int MyInt\n{\n get { return _myInt; }\n set { _myInt = value; }\n}\n"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98859",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18175/"
] |
98,867
|
<p>In c#, we have interfaces. Where did these come from? They didn't exist in c++.</p>
|
[
{
"answer_id": 98881,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 2,
"selected": false,
"text": "public class Dog : Animal, IMammal\n"
},
{
"answer_id": 98891,
"author": "Statement",
"author_id": 2166173,
"author_profile": "https://Stackoverflow.com/users/2166173",
"pm_score": 0,
"selected": false,
"text": "class IFoo\n{\npublic:\n void Bar() =0;\n void Bar2() =0;\n};\n\nclass Concrete : public IFoo\n{\npublic:\n void Bar() { ... }\n void Bar2() { ... }\n}\n"
},
{
"answer_id": 100150,
"author": "Max Galkin",
"author_id": 2351099,
"author_profile": "https://Stackoverflow.com/users/2351099",
"pm_score": 0,
"selected": false,
"text": "class IExecutable\n{\npublic:\n virtual void Execute() = 0;\n};\n\nclass MyClass : public IExecutable\n{\npublic:\n void Execute() { return; };\n};\n"
},
{
"answer_id": 478903,
"author": "BBetances",
"author_id": 53599,
"author_profile": "https://Stackoverflow.com/users/53599",
"pm_score": 1,
"selected": false,
"text": "static string Method(int i)\n"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98867",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18175/"
] |
98,878
|
<p>I've always been wondering how people use CRC (class responsiblity collaboration) cards. I've read about them in books, found vague information on the internet, but never grasped it really. I think someone ought to make a youtube video showing a session with CRC cards, since one of my books described it as being very hard to formulate in text, that it should be "taught by someone who already masters it". Sadly, I know noone around here who uses CRC cards and I'd like to learn more.</p>
<h2>UPDATE</h2>
<p>Any links to videos showing people elaborating with this technique would be appreciated.</p>
|
[
{
"answer_id": 99384,
"author": "Robert Gould",
"author_id": 15124,
"author_profile": "https://Stackoverflow.com/users/15124",
"pm_score": 3,
"selected": false,
"text": "///////////////////////\n//* CRC CARD\n//* Class: UISliderEvent\n//* Responsability: Event that holds the value and id of a Slider's movement\n//* Collaborators: UISlider, UIEvent\n//////////////////////\n"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2166173/"
] |
98,895
|
<p>I'm having problems refreshing .Net 2.0 with IIS 6.</p>
<p>I have been able to successfully execute "aspnet_regiis.exe -i", but when I try to register the aspnet_isapi.dll:</p>
<pre><code>regsvr32 “C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll"
</code></pre>
<p>I get the error</p>
<blockquote>
<p>C:\Windows..\aspnet_isapi.dll was loaded, but the DllRegisterServer entry point was not found.</p>
<p>The file cannot be registered.</p>
</blockquote>
<p>Does anyone know how to resolve this? Google hasn't been very helpful.</p>
<p><strong>Edit:</strong> My problem is actually that IIS isn't serving my webpages properly - that is, it's returning 404s when I try to request .aspx files that I know exist.</p>
<p>I can access .gif and .js files OK, but I can't access .aspx or other .Net files. I know this is related to .Net being properly configured with IIS, and the above commands are supposed to be the solution, but the second command doesn't work.</p>
<p><strong>@aaronjensen</strong>: Your command to register scripts worked successfully, and investigating the logs I find that I'm getting an entry for my failed request with status 404, substatus 2.</p>
<p>Microsoft tells me this because "<a href="http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/0f4ac79a-dc2b-4a5f-89c1-d57266aa6ffe.mspx?mfr=true" rel="nofollow noreferrer">Lockdown Policy Prevents This Request</a>".</p>
<blockquote>
<p>If a request is denied because the
associated ISAPI or CGI has not been
unlocked, a 404.2 error is returned.</p>
</blockquote>
<p>Which I assume is due to the isapi DLL in my original query being denied?</p>
|
[
{
"answer_id": 1052042,
"author": "Dexter",
"author_id": 10717,
"author_profile": "https://Stackoverflow.com/users/10717",
"pm_score": 3,
"selected": true,
"text": "C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\aspnet_regiis -s /w3svc/1/root"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98895",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10717/"
] |
98,901
|
<p>In any language really, im looking for a simple (very simple) way to control the position of a shortcut on the users desktop. I already make the assumption that Auto Arrange and Align to Grid are unchecked.</p>
<p>Ex: The program creates the shortcut to the desktop than places it at position (450,302) on the desktop. </p>
<p>I know how to create shortcuts, but i dont know how to control their placement on the desktop.</p>
|
[
{
"answer_id": 1052042,
"author": "Dexter",
"author_id": 10717,
"author_profile": "https://Stackoverflow.com/users/10717",
"pm_score": 3,
"selected": true,
"text": "C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\aspnet_regiis -s /w3svc/1/root"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98901",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18431/"
] |
98,915
|
<p>I realize that this question has been <a href="https://stackoverflow.com/questions/10293/has-anyone-used-jaxer-in-production">asked before</a>, but it has been a month with no decent responses... I'm looking at <a href="http://web.archive.org/web/20090803092709/http://www.aptana.com:80/Jaxer" rel="nofollow noreferrer">Aptana's Jaxer</a> and I find the concept to be very exciting.</p>
<p>Here is a quick overview for those who are not familiar with it:</p>
<p>Jaxer is, in their words, "the world's first true AJAX server". It is based on the Mozilla engine so scripts are written with javascript and you have complete access to the DOM on the server-side. </p>
<p>Scripts are placed on your pages with <code><script></code> tags and you can specify a <code>runat</code> attribute (ala ASP.NET) to mark scripts for execution on the client, server, both, or as a "server-proxy" which makes the functions available on the client, but they execute on the server via AJAX. This also means that you can use your favorite client-side libraries (jQuery, Prototype) on the server as well as the client.</p>
<p>It also can be used to process documents that are generated in another language (e.g. php, ruby) which I imagine is not practical except to help in transitioning existing applications to use Jaxer.</p>
<ul>
<li>What are the pros and cons?</li>
<li>How mature/stable is it the API?</li>
<li>How good is performance compared to
other server-side html
preprocessors?</li>
<li>Has anyone used Jaxer with another
technology (php, pearl, ruby, etc.)
and what were your experiences?</li>
</ul>
<p>EDIT: I've posted another question regarding a drawback I discovered while playing with Jaxer: <a href="https://stackoverflow.com/questions/109762/defining-objects-when-using-jaxer">Defining objects when using Jaxer</a></p>
|
[
{
"answer_id": 105555,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<jaxer:include"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98915",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5628/"
] |
98,916
|
<p>How do you programmatically find the number of hosts that a netmask supports.</p>
<p>Eg, If you have a /30 , how do you find how many IP's are in it without using a lookup table?</p>
<p>Preferably would be able to work with the "/" notation, rather than 255.xxx.xxx.xxx notation.</p>
|
[
{
"answer_id": 98935,
"author": "Aaron Maenpaa",
"author_id": 2603,
"author_profile": "https://Stackoverflow.com/users/2603",
"pm_score": 2,
"selected": false,
"text": ">>> def number_of_hosts(n):\n... return 2 ** (32 - n)\n... \n>>> number_of_hosts(32)\n1\n>>> number_of_hosts(30)\n4\n"
},
{
"answer_id": 9394944,
"author": "SHEEN",
"author_id": 1225814,
"author_profile": "https://Stackoverflow.com/users/1225814",
"pm_score": 2,
"selected": false,
"text": " package com.test;\n\nimport java.net.InetAddress;\nimport java.net.NetworkInterface;\nimport java.net.SocketException;\nimport java.net.UnknownHostException;\nimport java.util.Enumeration;\n\npublic class EasyNet {\n\n /**\n * @param args\n */\n public static void main(String[] args) {\n // TODO Auto-generated method stub\n\n try {\n InetAddress localhost = InetAddress.getLocalHost();\n System.out.println(\" IP Addr: \" + localhost.getHostAddress());\n // Just in case this host has multiple IP addresses....\n InetAddress[] allMyIps = InetAddress.getAllByName(localhost.getCanonicalHostName());\n if (allMyIps != null && allMyIps.length > 1) {\n System.out.println(\" Full list of IP addresses:\");\n for (int i = 0; i < allMyIps.length; i++) {\n System.out.println(\" \" + allMyIps[i]);\n }\n }\n } catch (UnknownHostException e) {\n System.out.println(\" (error retrieving server host name)\");\n }\n\n try {\n System.out.println(\"Full list of Network Interfaces:\");\n for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {\n NetworkInterface intf = en.nextElement();\n System.out.println(\" \" + intf.getName() + \" \" + intf.getDisplayName());\n for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements(); ) \n {\n System.out.println(\" \" + enumIpAddr.nextElement().toString());\n }\n }\n } catch (SocketException e) {\n System.out.println(\" (error retrieving network interface list)\");\n }\n }\n\n}\n"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98916",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3839/"
] |
98,930
|
<p>In an environment with multiple windows servers what is the best way to ensure patch compliance accross all systems? </p>
<p>Is there a simple tool (some sort of client/server app?) that allows reports to be generated showing the status of all the systems so any that aren't automatically patching themselves can be fixed without having to manually check each systemevery time an audit is needed?</p>
|
[
{
"answer_id": 98935,
"author": "Aaron Maenpaa",
"author_id": 2603,
"author_profile": "https://Stackoverflow.com/users/2603",
"pm_score": 2,
"selected": false,
"text": ">>> def number_of_hosts(n):\n... return 2 ** (32 - n)\n... \n>>> number_of_hosts(32)\n1\n>>> number_of_hosts(30)\n4\n"
},
{
"answer_id": 9394944,
"author": "SHEEN",
"author_id": 1225814,
"author_profile": "https://Stackoverflow.com/users/1225814",
"pm_score": 2,
"selected": false,
"text": " package com.test;\n\nimport java.net.InetAddress;\nimport java.net.NetworkInterface;\nimport java.net.SocketException;\nimport java.net.UnknownHostException;\nimport java.util.Enumeration;\n\npublic class EasyNet {\n\n /**\n * @param args\n */\n public static void main(String[] args) {\n // TODO Auto-generated method stub\n\n try {\n InetAddress localhost = InetAddress.getLocalHost();\n System.out.println(\" IP Addr: \" + localhost.getHostAddress());\n // Just in case this host has multiple IP addresses....\n InetAddress[] allMyIps = InetAddress.getAllByName(localhost.getCanonicalHostName());\n if (allMyIps != null && allMyIps.length > 1) {\n System.out.println(\" Full list of IP addresses:\");\n for (int i = 0; i < allMyIps.length; i++) {\n System.out.println(\" \" + allMyIps[i]);\n }\n }\n } catch (UnknownHostException e) {\n System.out.println(\" (error retrieving server host name)\");\n }\n\n try {\n System.out.println(\"Full list of Network Interfaces:\");\n for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {\n NetworkInterface intf = en.nextElement();\n System.out.println(\" \" + intf.getName() + \" \" + intf.getDisplayName());\n for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements(); ) \n {\n System.out.println(\" \" + enumIpAddr.nextElement().toString());\n }\n }\n } catch (SocketException e) {\n System.out.println(\" (error retrieving network interface list)\");\n }\n }\n\n}\n"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98930",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17007/"
] |
98,944
|
<p>How do I write a cpp macro which expands to include newlines?</p>
|
[
{
"answer_id": 98956,
"author": "Branan",
"author_id": 13894,
"author_profile": "https://Stackoverflow.com/users/13894",
"pm_score": -1,
"selected": false,
"text": "\\"
},
{
"answer_id": 98972,
"author": "PiNoYBoY82",
"author_id": 13646,
"author_profile": "https://Stackoverflow.com/users/13646",
"pm_score": -1,
"selected": false,
"text": "#define NEWLINE_MACRO(x) line1 \\\nline2 \\\nline3\n"
},
{
"answer_id": 98973,
"author": "David L Morris",
"author_id": 3137,
"author_profile": "https://Stackoverflow.com/users/3137",
"pm_score": 3,
"selected": false,
"text": "#define SOME_STRING \"Some string\\n with a new line.\"\n"
},
{
"answer_id": 99017,
"author": "Charles Graham",
"author_id": 7705,
"author_profile": "https://Stackoverflow.com/users/7705",
"pm_score": -1,
"selected": false,
"text": "#define foo() do \\\n{\n //code goes here \\\n \\\n \\\n}while(0);\n"
},
{
"answer_id": 36384452,
"author": "Florian Fleissner",
"author_id": 6151578,
"author_profile": "https://Stackoverflow.com/users/6151578",
"pm_score": 4,
"selected": false,
"text": "// Content of MyMacro.hpp\n\n#include \"MultilineMacroDebugging.hpp\"\n\n#define PRINT_VARIABLE(S) \\\n__NL__ std::cout << #S << \": \" << S << std::endl; \\\n__NL__ /* more lines if necessary */ \\\n__NL__ /* even more lines */\n"
},
{
"answer_id": 74238404,
"author": "Björn Grieger",
"author_id": 20360122,
"author_profile": "https://Stackoverflow.com/users/20360122",
"pm_score": 0,
"selected": false,
"text": "sed s/'\\\\ '/'\\n'/g\n"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/98944",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18458/"
] |
99,013
|
<p>Is it possible to use stored procedures for designing Reports in Report builder?</p>
|
[
{
"answer_id": 123573,
"author": "jimmyorr",
"author_id": 19239,
"author_profile": "https://Stackoverflow.com/users/19239",
"pm_score": 0,
"selected": false,
"text": "select * from table (f_foo(:p_bar))\n"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/99013",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14752/"
] |
99,020
|
<p>I have a java app (not running in any application container) which listens on a ServerSocket for connections. I would like it to only accept connections which come from localhost. Currently, after a connection is accepted, it checks the peer IP and rejects it if it is not the loopback address, but I know that peer IP addresses can be spoofed. So, if possible, I'd prefer to bind to a socket that only listens on the loopback interface; is this possible?</p>
<p>I've tried a few different things (such as specifying "127.0.0.1" as the local address when calling bind()) with no luck.</p>
<hr />
<p><strong>Update:</strong></p>
<p>I'm embarrassed to admit that this was all my mistake. Our application listens on two different ports, and I was binding one to the loopback interface but testing against the other. When I actually try to telnet to the correct port, everything works fine (i.e., binding to "127.0.0.1" does exactly what it's supposed to).</p>
<p>As for spoofing the loopback address, you guys are right. I shouldn't have made it sound like the primary concern. Really, the desired behavior is to only take local connections, and binding to only the local interface is a more direct way of achieving that than accepting all connections and then closing non-local ones.</p>
|
[
{
"answer_id": 99430,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 2,
"selected": false,
"text": "127.0.0.1"
},
{
"answer_id": 9271782,
"author": "Selfmade Javaman",
"author_id": 1208324,
"author_profile": "https://Stackoverflow.com/users/1208324",
"pm_score": 2,
"selected": false,
"text": "if (socket.getInetAddress().isLoopbackAddress()){\n //Your code goes here\n}\n"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/99020",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
99,045
|
<p>We are running Selenium regression tests against our existing code base, and certain screens in our web app use pop-ups for intermediate steps.</p>
<p>Currently we use the commands in the test:</p>
<pre><code>// force new window to open at this point - so we can select it later
selenium().getEval("this.browserbot.getCurrentWindow().open('', 'enquiryPopup')");
selenium().click("//input[@value='Submit']");
selenium().waitForPopUp("enquiryPopup", getWaitTime());
selenium().selectWindow("enquiryPopup");
</code></pre>
<p>...which works <em>most of the time</em>. Occasionally the test will fail on the <code>waitForPopUp()</code> line with </p>
<pre><code>com.thoughtworks.selenium.SeleniumException: Permission denied
</code></pre>
<p>Can anyone suggest a better, more <em>reliable</em> method?</p>
<p>Also, we primarily run these tests on IE6 and 7.</p>
|
[
{
"answer_id": 99372,
"author": "brasskazoo",
"author_id": 6340,
"author_profile": "https://Stackoverflow.com/users/6340",
"pm_score": 0,
"selected": false,
"text": "windowFocus()"
},
{
"answer_id": 429196,
"author": "branchgabriel",
"author_id": 30807,
"author_profile": "https://Stackoverflow.com/users/30807",
"pm_score": 3,
"selected": true,
"text": "<tr>\n <td>getEval</td>\n <td>selenium.browserbot.getCurrentWindow().open('', 'windowName');</td>\n <td></td>\n</tr>\n<tr>\n <td>click</td>\n <td>buttonName</td>\n <td></td>\n</tr>\n<tr>\n <td>windowFocus</td>\n <td>windowName</td>\n <td></td>\n</tr>\n<tr>\n <td>waitForPopUp</td>\n <td>windowName</td>\n <td>3000</td>\n</tr>\n<tr>\n <td>selectWindow</td>\n <td>windowName</td>\n <td></td>\n</tr>\n"
},
{
"answer_id": 1941915,
"author": "nicholasklick",
"author_id": 236260,
"author_profile": "https://Stackoverflow.com/users/236260",
"pm_score": 0,
"selected": false,
"text": "<tr>\n <td>click</td>\n <td>//a[@class='item_add']</td>\n <td></td>\n</tr>\n<tr>\n <td>windowFocus</td>\n <td>account_frame</td>\n <td></td>\n</tr>\n<tr>\n <td>waitForPopUp</td>\n <td>account_frame</td>\n <td>10000</td>\n</tr>\n"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/99045",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6340/"
] |
99,056
|
<p>If given the choice, which path would you take?</p>
<blockquote>
<p>ASP.NET Webforms + ASP.NET AJAX</p>
</blockquote>
<p><strong>or</strong></p>
<blockquote>
<p>ASP.NET MVC + JavaScript Framework of your Choice</p>
</blockquote>
<p>Are there any limitations that ASP.NET Webforms / ASP.NET AJAX has vis-a-vis MVC? </p>
|
[
{
"answer_id": 1651600,
"author": "Mike",
"author_id": 199673,
"author_profile": "https://Stackoverflow.com/users/199673",
"pm_score": 4,
"selected": false,
"text": "public partial class SamplePage : System.Web.Mvc.ViewPage\n{\n protected void Page_Load(object sender, EventArgs e)\n {\n }\n}\n"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/99056",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1368/"
] |
99,074
|
<p>Would it be useful to be able to provide method return value for null objects?</p>
<p>For a List the null return values might be:</p>
<pre><code>get(int) : null
size() : 0
iterator() : empty iterator
</code></pre>
<p>That would allow the following code that has less null checks.</p>
<pre><code>List items = null;
if(something) {
items = ...
}
for(int index = 0; index < items.size(); index++) {
Object obj = items.get(index);
}
</code></pre>
<p>This would only be used if the class or interface defined it and a null check would still work. Sometimes you don't want to do null checks so it seems like it could be beneficial to have this as an option.</p>
<p>From: <a href="http://jamesjava.blogspot.com/2007/05/method-return-values-for-null-objects.html" rel="nofollow noreferrer">http://jamesjava.blogspot.com/2007/05/method-return-values-for-null-objects.html</a></p>
|
[
{
"answer_id": 99332,
"author": "Amy B",
"author_id": 8155,
"author_profile": "https://Stackoverflow.com/users/8155",
"pm_score": 0,
"selected": false,
"text": "Foo x = null;\nif (x.Bar() == 0)\n{\n Console.WriteLine(\"I win\");\n}\n"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/99074",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6770/"
] |
99,098
|
<p>What is the best way to generate a current datestamp in Java? </p>
<p>YYYY-MM-DD:hh-mm-ss</p>
|
[
{
"answer_id": 99105,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "https://Stackoverflow.com/users/3560",
"pm_score": 3,
"selected": false,
"text": "Date d = new Date();\nString formatted = new SimpleDateFormat (\"yyyy-MM-dd:HH-mm-ss\").format (d);\nSystem.out.println (formatted);\n"
},
{
"answer_id": 99133,
"author": "sblundy",
"author_id": 4893,
"author_profile": "https://Stackoverflow.com/users/4893",
"pm_score": 1,
"selected": false,
"text": "long timestamp = System.currentTimeMillis() \n"
},
{
"answer_id": 99152,
"author": "Walter Rumsby",
"author_id": 1654,
"author_profile": "https://Stackoverflow.com/users/1654",
"pm_score": 0,
"selected": false,
"text": "final DateFormat formatter = new SimpleDateFormat(\"yyyy-MM-dd:hh-mm-ss\");\n\nformatter.format(new Date());\n"
},
{
"answer_id": 99175,
"author": "jt.",
"author_id": 4362,
"author_profile": "https://Stackoverflow.com/users/4362",
"pm_score": 6,
"selected": true,
"text": "Date myDate = new Date();\nSimpleDateFormat sdf = new SimpleDateFormat(\"yyyy-MM-dd:HH-mm-ss\");\nString myDateString = sdf.format(myDate);\n"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/99098",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3020/"
] |
99,118
|
<p>Is there any downside or problem potential to change the Java compiler to automatically cast? In the example below the result of list.get(0) would automatically be casted to the type of the variable hi.</p>
<pre><code>List list = new ArrayList();
list.add("hi");
String hi = list.get(0);
</code></pre>
<p>I know that generics allow you to reduce casting but they do so at the expense of making declaration more difficult. To me, the benefit of generics is that they allow you to have the complier enforce more rules -- not they they reduce casting (but I haven't used them much so I am somewhat uninformed). This proposal would only reduce the amount of code to type, not move it to another place.
Also there are instances where generics can't be used because a collection can have different objectis.
If that "looks too surprising" based on current usage maybe there could be a syntax tweak to use it.</p>
<p>From: <a href="http://jamesjava.blogspot.com/2007/01/automatic-casting.html" rel="nofollow noreferrer">http://jamesjava.blogspot.com/2007/01/automatic-casting.html</a></p>
|
[
{
"answer_id": 99216,
"author": "jon",
"author_id": 12215,
"author_profile": "https://Stackoverflow.com/users/12215",
"pm_score": 2,
"selected": false,
"text": "List list = new ArrayList();\nlist.add(new Integer(42));\nString hi = (String) list.get(0); // run time error\n\nList<String> list = new ArrayList<String>();\nlist.add(new Integer(42)); // compile time error\nString hi = list.get(0);\n"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/99118",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6770/"
] |
99,132
|
<p>I need to generate a directory in my makefile and I would like to not get the "directory already exists error" over and over even though I can easily ignore it.</p>
<p>I mainly use mingw/msys but would like something that works across other shells/systems too.</p>
<p>I tried this but it didn't work, any ideas?</p>
<pre><code>ifeq (,$(findstring $(OBJDIR),$(wildcard $(OBJDIR) )))
-mkdir $(OBJDIR)
endif
</code></pre>
|
[
{
"answer_id": 99156,
"author": "andrewdotnich",
"author_id": 10569,
"author_profile": "https://Stackoverflow.com/users/10569",
"pm_score": 4,
"selected": false,
"text": "-mkdir $(OBJDIR) 2>/dev/null\n"
},
{
"answer_id": 99174,
"author": "tchen",
"author_id": 18417,
"author_profile": "https://Stackoverflow.com/users/18417",
"pm_score": 8,
"selected": true,
"text": "mkdir -p $(OBJDIR)\n"
},
{
"answer_id": 99176,
"author": "Lee H",
"author_id": 18201,
"author_profile": "https://Stackoverflow.com/users/18201",
"pm_score": 4,
"selected": false,
"text": "target:\n if test -d dir; then echo \"hello world!\"; else mkdir dir; fi\n"
},
{
"answer_id": 99188,
"author": "skymt",
"author_id": 18370,
"author_profile": "https://Stackoverflow.com/users/18370",
"pm_score": 6,
"selected": false,
"text": "test -d $(OBJDIR) || mkdir $(OBJDIR)\n"
},
{
"answer_id": 175750,
"author": "Michael McCarty",
"author_id": 25007,
"author_profile": "https://Stackoverflow.com/users/25007",
"pm_score": 3,
"selected": false,
"text": "ifeq \"$(wildcard $(MY_DIRNAME) )\" \"\"\n -mkdir $(MY_DIRNAME)\nendif\n"
},
{
"answer_id": 511665,
"author": "Martin Fido",
"author_id": 62457,
"author_profile": "https://Stackoverflow.com/users/62457",
"pm_score": 3,
"selected": false,
"text": "$(OBJDIR):\n mkdir $@\n"
},
{
"answer_id": 3300436,
"author": "wmad",
"author_id": 398088,
"author_profile": "https://Stackoverflow.com/users/398088",
"pm_score": 3,
"selected": false,
"text": "if not exist \"$(OBJDIR)\" mkdir $(OBJDIR)\n"
},
{
"answer_id": 3739843,
"author": "Northern Stream",
"author_id": 1167733,
"author_profile": "https://Stackoverflow.com/users/1167733",
"pm_score": 4,
"selected": false,
"text": " %/.d:\n mkdir -p $(@D)\n touch $@\n"
},
{
"answer_id": 6170280,
"author": "ofavre",
"author_id": 508831,
"author_profile": "https://Stackoverflow.com/users/508831",
"pm_score": 7,
"selected": false,
"text": "OBJDIR := objdir\nOBJS := $(addprefix $(OBJDIR)/,foo.o bar.o baz.o)\n\n$(OBJDIR)/%.o : %.c\n $(COMPILE.c) $(OUTPUT_OPTION) $<\n\nall: $(OBJS)\n\n$(OBJS): | $(OBJDIR)\n\n$(OBJDIR):\n mkdir -p $(OBJDIR)\n"
},
{
"answer_id": 10100865,
"author": "lygstate",
"author_id": 321938,
"author_profile": "https://Stackoverflow.com/users/321938",
"pm_score": 2,
"selected": false,
"text": "ifeq \"$(wildcard .dep)\" \"\"\n-include $(shell mkdir .dep) $(wildcard .dep/*)\nendif\n"
},
{
"answer_id": 17385817,
"author": "Mischa",
"author_id": 205874,
"author_profile": "https://Stackoverflow.com/users/205874",
"pm_score": 0,
"selected": false,
"text": "something_needs_directory_xxx : xxx/..\n"
},
{
"answer_id": 32495400,
"author": "Andrew",
"author_id": 383188,
"author_profile": "https://Stackoverflow.com/users/383188",
"pm_score": 0,
"selected": false,
"text": "mkdir 2>/dev/null || true\n"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/99132",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13676/"
] |
99,161
|
<p>I search for "nurple" in a file. I found it, great. But now, every occurrence of "nurple" is rendered in sick black on yellow. Forever.</p>
<p>Forever, that is, until I search for something I know won't be found, such as "asdhfalsdflajdflakjdf" simply so it clears the previous search highlighting.</p>
<p>Can't I just hit a magic key to kill the highlights when I'm done searching?</p>
|
[
{
"answer_id": 99182,
"author": "Lee H",
"author_id": 18201,
"author_profile": "https://Stackoverflow.com/users/18201",
"pm_score": 9,
"selected": false,
"text": ":noh"
},
{
"answer_id": 99186,
"author": "Lucas S.",
"author_id": 7363,
"author_profile": "https://Stackoverflow.com/users/7363",
"pm_score": 9,
"selected": true,
"text": "\" <Ctrl-l> redraws the screen and removes any search highlighting.\nnnoremap <silent> <C-l> :nohl<CR><C-l>\n"
},
{
"answer_id": 99196,
"author": "Kent Fredric",
"author_id": 15614,
"author_profile": "https://Stackoverflow.com/users/15614",
"pm_score": 3,
"selected": false,
"text": ":help #"
},
{
"answer_id": 99207,
"author": "Daniel Bruce",
"author_id": 6456,
"author_profile": "https://Stackoverflow.com/users/6456",
"pm_score": 4,
"selected": false,
"text": ".vimrc"
},
{
"answer_id": 99208,
"author": "Jeffrey Vanneste",
"author_id": 5497,
"author_profile": "https://Stackoverflow.com/users/5497",
"pm_score": 2,
"selected": false,
"text": "hlsearch"
},
{
"answer_id": 99226,
"author": "jon",
"author_id": 12215,
"author_profile": "https://Stackoverflow.com/users/12215",
"pm_score": 7,
"selected": false,
"text": "/lkjasdf"
},
{
"answer_id": 99982,
"author": "Zsolt Botykai",
"author_id": 11621,
"author_profile": "https://Stackoverflow.com/users/11621",
"pm_score": 4,
"selected": false,
"text": "map <F12> :set hls!<CR>\nimap <F12> <ESC>:set hls!<CR>a\nvmap <F12> <ESC>:set hls!<CR>gv\n"
},
{
"answer_id": 100141,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "nnoremap <silent> _ :nohl<CR>\n"
},
{
"answer_id": 101756,
"author": "Max Cantor",
"author_id": 16034,
"author_profile": "https://Stackoverflow.com/users/16034",
"pm_score": 2,
"selected": false,
"text": "nnoremap ; :set invhlsearch<CR>\n"
},
{
"answer_id": 19865983,
"author": "Daniel Miessler",
"author_id": 500958,
"author_profile": "https://Stackoverflow.com/users/500958",
"pm_score": 2,
"selected": false,
"text": "<leader>c :nohl<CR>\n"
},
{
"answer_id": 19877212,
"author": "Andy Lester",
"author_id": 8454,
"author_profile": "https://Stackoverflow.com/users/8454",
"pm_score": 5,
"selected": false,
"text": "\" Make double-<Esc> clear search highlights\nnnoremap <silent> <Esc><Esc> <Esc>:nohlsearch<CR><Esc>\n"
},
{
"answer_id": 22807541,
"author": "nocache",
"author_id": 778675,
"author_profile": "https://Stackoverflow.com/users/778675",
"pm_score": 2,
"selected": false,
"text": ":let @/ = \"\"\n"
},
{
"answer_id": 23416923,
"author": "Aman Jain",
"author_id": 29405,
"author_profile": "https://Stackoverflow.com/users/29405",
"pm_score": -1,
"selected": false,
"text": "map e/ /sdfdskfxxxxy\n"
},
{
"answer_id": 24951879,
"author": "Guillaume",
"author_id": 857728,
"author_profile": "https://Stackoverflow.com/users/857728",
"pm_score": 0,
"selected": false,
"text": "nmap <F12> :set hls!<CR>\nnnoremap / :set hls<CR>/\n"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/99161",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18446/"
] |
99,164
|
<p>I often see code like:</p>
<pre><code>Iterator i = list.iterator();
while(i.hasNext()) {
...
}
</code></pre>
<p>but I write that (when Java 1.5 isn't available or for each can't be used) as:</p>
<pre><code>for(Iterator i = list.iterator(); i.hasNext(); ) {
...
}
</code></pre>
<p>because</p>
<ul>
<li>It is shorter</li>
<li>It keeps <code>i</code> in a smaller scope</li>
<li>It reduces the chance of confusion. (Is <code>i</code> used outside the
while? Where is <code>i</code> declared?)</li>
</ul>
<p>I think code should be as simple to understand as possible so that I only have to make complex code to do complex things. What do you think? Which is better?</p>
<p>From: <a href="http://jamesjava.blogspot.com/2006/04/iterating.html" rel="noreferrer">http://jamesjava.blogspot.com/2006/04/iterating.html</a></p>
|
[
{
"answer_id": 99189,
"author": "Giorgio Galante",
"author_id": 18269,
"author_profile": "https://Stackoverflow.com/users/18269",
"pm_score": 3,
"selected": false,
"text": "List<String> names = new ArrayList<String>();\nnames.add(\"a\");\nnames.add(\"b\");\nnames.add(\"c\");\n\nfor (String name : names)\n System.out.println(name.charAt(0));\n"
},
{
"answer_id": 99246,
"author": "Jon Limjap",
"author_id": 372,
"author_profile": "https://Stackoverflow.com/users/372",
"pm_score": 4,
"selected": false,
"text": "while"
},
{
"answer_id": 8435741,
"author": "Igor Vaschuk",
"author_id": 154664,
"author_profile": "https://Stackoverflow.com/users/154664",
"pm_score": 2,
"selected": false,
"text": "for (; (currUserObjectIndex < _domainObjectReferences.Length) && (_domainObjectReferences[currUserObjectIndex].VisualIndex == index); ++currUserObjectIndex)\n ++currNumUserObjects;\n"
}
] |
2008/09/19
|
[
"https://Stackoverflow.com/questions/99164",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6770/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.