qid int64 4 8.14M | question stringlengths 20 48.3k | answers list | date stringlengths 10 10 | metadata list | input stringlengths 12 45k | output stringlengths 2 31.8k |
|---|---|---|---|---|---|---|
135,909 | <p>I run into this occasionally and always forget how to do it.</p>
<p>One of those things that pop up ever so often.</p>
<p>Also, what's the formula to convert angles expressed in radians to degrees and back again?</p>
| [
{
"answer_id": 135925,
"author": "Charles Graham",
"author_id": 7705,
"author_profile": "https://Stackoverflow.com/users/7705",
"pm_score": 0,
"selected": false,
"text": "<p>180 degrees = PI * radians</p>\n"
},
{
"answer_id": 135927,
"author": "thesmallprint",
"author_id"... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8683/"
] | I run into this occasionally and always forget how to do it.
One of those things that pop up ever so often.
Also, what's the formula to convert angles expressed in radians to degrees and back again? | ```
radians = degrees * (pi/180)
degrees = radians * (180/pi)
```
As for implementation, the main question is how precise you want to be about the value of pi. There is some related discussion [here](https://stackoverflow.com/questions/19/fastest-way-to-get-value-of-pi) |
135,919 | <p>I haven't been able to find an adequate answer to what exactly the following error means:</p>
<p><code>java.net.SocketException: Software caused connection abort: recv failed</code> </p>
<p>Notes:</p>
<ul>
<li>This error is infrequent and unpredictable; although getting this error means that all future requests f... | [
{
"answer_id": 135983,
"author": "Ken",
"author_id": 20621,
"author_profile": "https://Stackoverflow.com/users/20621",
"pm_score": 2,
"selected": false,
"text": "<p>Are you accessing http data? Can you use the HttpClient library instead of the standard library? The library has more opt... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135919",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12815/"
] | I haven't been able to find an adequate answer to what exactly the following error means:
`java.net.SocketException: Software caused connection abort: recv failed`
Notes:
* This error is infrequent and unpredictable; although getting this error means that all future requests for URIs will also fail.
* The only solu... | This usually means that there was a network error, such as a TCP timeout. I would start by placing a sniffer (wireshark) on the connection to see if you can see any problems. If there is a TCP error, you should be able to see it. Also, you can check your router logs, if this is applicable. If wireless is involved anywh... |
135,929 | <p>I'd like to just put in a comment in the block of my if-statement, but I get an error when I try. I want to be more like Steve McConnell.</p>
<pre><code>declare @ConstraintName varchar(255)
set @ConstraintName = 'PK_Whatever'
IF LEFT(@ConstraintName, 2) = 'PK'
BEGIN
--can't drop primary keys
END
</code></pre>
... | [
{
"answer_id": 135962,
"author": "Dave Costa",
"author_id": 6568,
"author_profile": "https://Stackoverflow.com/users/6568",
"pm_score": 2,
"selected": false,
"text": "<p>I can't say for sure in SQL Server, but in Oracle PL/SQL you would put a NULL statement in a block that you want to do... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135929",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/73794/"
] | I'd like to just put in a comment in the block of my if-statement, but I get an error when I try. I want to be more like Steve McConnell.
```
declare @ConstraintName varchar(255)
set @ConstraintName = 'PK_Whatever'
IF LEFT(@ConstraintName, 2) = 'PK'
BEGIN
--can't drop primary keys
END
```
The error I get is:
`... | No, you cannot have an empty if block (or one that contains only comments).
You don't say why you would want this. If you are just trying to comment out the contents of the if for debugging, you should comment the entire if. |
135,934 | <p>I need to show a camera capture dialog in a compact framework 3.7 application by pinvoking SHCameraCapture from the dll Aygshell.dll. I cannont use the managed object CameraCaptureDialog because of limitations with the technology I'm working with. Instead, I need to access it by Pinvoking it.</p>
<p>See <a href="... | [
{
"answer_id": 138398,
"author": "Grokys",
"author_id": 6448,
"author_profile": "https://Stackoverflow.com/users/6448",
"pm_score": 0,
"selected": false,
"text": "<p>I've not been able to test this, but your struct/function should look something like this:</p>\n\n<pre><code>struct SHCAME... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135934",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12497/"
] | I need to show a camera capture dialog in a compact framework 3.7 application by pinvoking SHCameraCapture from the dll Aygshell.dll. I cannont use the managed object CameraCaptureDialog because of limitations with the technology I'm working with. Instead, I need to access it by Pinvoking it.
See <http://msdn.microsof... | this code works....
```
#region Enumerations
public enum CAMERACAPTURE_STILLQUALITY
{
CAMERACAPTURE_STILLQUALITY_DEFAULT = 0,
CAMERACAPTURE_STILLQUALITY_LOW = 1,
CAMERACAPTURE_STILLQUALITY_NORMAL = 2,
CAMERACAPTURE_STILLQUALITY_HIGH = 3
}
public enum CAMERACAPTURE_VIDEOTYPES
{
CAMERACAPTURE_VIDEOT... |
135,938 | <p>It's not a matter of life or death but I wonder if this could be possible:</p>
<p>I got a couple of events from one type of custom event (FormEvent) now I got a FormListener that listens to all those events and handles them according to the event type. Instead of adding one eventListener at the time I wish to add a... | [
{
"answer_id": 136258,
"author": "Matt Dillard",
"author_id": 863,
"author_profile": "https://Stackoverflow.com/users/863",
"pm_score": 0,
"selected": false,
"text": "<p>I don't know of any routines that let you do that directly, but you could write your own. The syntax here won't be pe... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135938",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18671/"
] | It's not a matter of life or death but I wonder if this could be possible:
I got a couple of events from one type of custom event (FormEvent) now I got a FormListener that listens to all those events and handles them according to the event type. Instead of adding one eventListener at the time I wish to add all events ... | You only really need one event listener in this case anyhow. That listener will be listening for any change with the form and a parameter equal to what the change was becomes available to the event listener function. I will show you, but please remember that this is a pseudo situation and normally I wouldn't dispatch a... |
135,944 | <p>Stored procs in SQL Server sometimes finish with a return code, as opposed to a recordset of data. I've seen ASP code that's able to get this return code, but I can't figure out how to get this code with PHP's mssql driver.</p>
<p>mssql_get_last_message() always returns nothing, and I'm thinking it's because it on... | [
{
"answer_id": 135963,
"author": "Matt Rogish",
"author_id": 2590,
"author_profile": "https://Stackoverflow.com/users/2590",
"pm_score": 3,
"selected": true,
"text": "<p>Are you talking about SQL Server error codes, e.g. RAISERRROR or other failures? If so, last time I checked in PHP you... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135944",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12308/"
] | Stored procs in SQL Server sometimes finish with a return code, as opposed to a recordset of data. I've seen ASP code that's able to get this return code, but I can't figure out how to get this code with PHP's mssql driver.
mssql\_get\_last\_message() always returns nothing, and I'm thinking it's because it only retur... | Are you talking about SQL Server error codes, e.g. RAISERRROR or other failures? If so, last time I checked in PHP you need to ask for @@ERROR (e.g. select @@error) instead.
If it is a return code, you must explicitly catch it, e.g.
```
DECLARE @return_code INT
EXEC @return_code = your_stored_procedure 1123
SELECT @r... |
135,971 | <p>If you have two jars in your classpath that contain different versions of the same class, the classpath order becomes critical.</p>
<p>I am looking for a tool that can detect and flag such potential conflicts in a given classpath or set of folders.</p>
<p>Certainly a script that starts:</p>
<pre><code>classes=`mk... | [
{
"answer_id": 136252,
"author": "ferbs",
"author_id": 22406,
"author_profile": "https://Stackoverflow.com/users/22406",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://classpathhelper.sourceforge.net/\" rel=\"nofollow noreferrer\">Classpath Helper</a> is an Eclipse plug-i... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135971",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5309/"
] | If you have two jars in your classpath that contain different versions of the same class, the classpath order becomes critical.
I am looking for a tool that can detect and flag such potential conflicts in a given classpath or set of folders.
Certainly a script that starts:
```
classes=`mktemp`
for i in `find . -name... | The [Tattletale](http://www.jboss.org/tattletale) tool from JBoss is another candidate: "Spot if a class/package is located in multiple JAR files" |
135,995 | <p>So, I want to define a singleton method for an object, but I want to do it using a closure.</p>
<p>For example,</p>
<pre><code>def define_say(obj, msg)
def obj.say
puts msg
end
end
o = Object.new
define_say o, "hello world!"
o.say
</code></pre>
<p>This doesn't work because defining a singleton method via... | [
{
"answer_id": 136194,
"author": "Orion Edwards",
"author_id": 234,
"author_profile": "https://Stackoverflow.com/users/234",
"pm_score": 4,
"selected": true,
"text": "<p>Here's an answer which does what you're looking for</p>\n\n<pre><code>def define_say(obj, msg)\n # Get a handle to th... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135995",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/122/"
] | So, I want to define a singleton method for an object, but I want to do it using a closure.
For example,
```
def define_say(obj, msg)
def obj.say
puts msg
end
end
o = Object.new
define_say o, "hello world!"
o.say
```
This doesn't work because defining a singleton method via "def" is not a closure, so I get... | Here's an answer which does what you're looking for
```
def define_say(obj, msg)
# Get a handle to the singleton class of obj
metaclass = class << obj; self; end
# add the method using define_method instead of def x.say so we can use a closure
metaclass.send :define_method, :say do
puts msg
end
end
``... |
136,028 | <p>I realize there is a somewhat related thread on this here:
<a href="https://stackoverflow.com/questions/22012/loading-assemblies-and-its-dependencies">Loading assemblies and its dependencies</a></p>
<p>But I am modifying something and this doesn't exactly apply. </p>
<pre><code>string path = Path.GetDirectoryName... | [
{
"answer_id": 136072,
"author": "benPearce",
"author_id": 4490,
"author_profile": "https://Stackoverflow.com/users/4490",
"pm_score": 4,
"selected": true,
"text": "<p>Looks like the \"Department of Redundancy Department.\"</p>\n\n<p>A lot more code than is necessary. Less is more!</p>\n... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136028",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13688/"
] | I realize there is a somewhat related thread on this here:
[Loading assemblies and its dependencies](https://stackoverflow.com/questions/22012/loading-assemblies-and-its-dependencies)
But I am modifying something and this doesn't exactly apply.
```
string path = Path.GetDirectoryName( pathOfAssembly );
Environment... | Looks like the "Department of Redundancy Department."
A lot more code than is necessary. Less is more!
**Edit:** On second thought, it could be that the assembly you are loading has dependencies that live in its own folder that may be required to use the first assembly. |
136,034 | <p>I've looked around for a good example of this, but I haven't run into one yet. I want to pass a custom string array from java to oracle and back, using the IBATIS framework. Does anyone have a good link to an example? I'm calling stored procs from IBATIS.</p>
<p>Thanks</p>
| [
{
"answer_id": 137693,
"author": "bsanders",
"author_id": 22200,
"author_profile": "https://Stackoverflow.com/users/22200",
"pm_score": 2,
"selected": false,
"text": "<p>You've got to start with a custom instance of <code>TypeHandler</code>. We'd prefer to implement the simpler <code>Ty... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136034",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22365/"
] | I've looked around for a good example of this, but I haven't run into one yet. I want to pass a custom string array from java to oracle and back, using the IBATIS framework. Does anyone have a good link to an example? I'm calling stored procs from IBATIS.
Thanks | You've got to start with a custom instance of `TypeHandler`. We'd prefer to implement the simpler `TypeHandlerCallback`, but in this scenario we need access to the underlying `Connection`.
```
public class ArrayTypeHandler implements TypeHandler {
public void setParameter(PreparedStatement ps, int i, Object param... |
136,035 | <p>It is discouraged to simply catch <code>System.Exception</code>. Instead, only the "known" exceptions should be caught.</p>
<p>Now, this sometimes leads to unnecessary repetitive code, for example:</p>
<pre><code>try
{
WebId = new Guid(queryString["web"]);
}
catch (FormatException)
{
WebI... | [
{
"answer_id": 136038,
"author": "Michael Stum",
"author_id": 91,
"author_profile": "https://Stackoverflow.com/users/91",
"pm_score": 3,
"selected": false,
"text": "<p>Note that I did find one way to do it, but this looks more like material for <a href=\"https://en.wikipedia.org/wiki/The... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136035",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91/"
] | It is discouraged to simply catch `System.Exception`. Instead, only the "known" exceptions should be caught.
Now, this sometimes leads to unnecessary repetitive code, for example:
```
try
{
WebId = new Guid(queryString["web"]);
}
catch (FormatException)
{
WebId = Guid.Empty;
}
catch (OverflowException)
{
... | Catch `System.Exception` and switch on the types
```
catch (Exception ex)
{
if (ex is FormatException || ex is OverflowException)
{
WebId = Guid.Empty;
return;
}
throw;
}
``` |
136,050 | <p>Is there a way to prevent VS2008 creating browse info file files for C++ projects.<br>
I rarely use the class browser and it isn't worth the time it takes to recreate it after every build, especially since it runs even if the build failed.</p>
<p>EDIT - it's also needed for go to declaration/definition</p>
| [
{
"answer_id": 136075,
"author": "Jordan Parmer",
"author_id": 20133,
"author_profile": "https://Stackoverflow.com/users/20133",
"pm_score": 3,
"selected": false,
"text": "<p>In the project properties, you will find the browse information under:</p>\n\n<p>Configuration Properties -> C/C+... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136050",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10897/"
] | Is there a way to prevent VS2008 creating browse info file files for C++ projects.
I rarely use the class browser and it isn't worth the time it takes to recreate it after every build, especially since it runs even if the build failed.
EDIT - it's also needed for go to declaration/definition | There is a registry key for this as well: `[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\Languages\Language Services\C/C++]`
Intellisense ON
```
"IntellisenseOptions"=dword:00000000
```
Intellisense OFF
```
"IntellisenseOptions"=dword:00000007
```
Intellisense ON - NO Background UPDATE
```
"Intellisens... |
136,097 | <p>What is the difference between a function decorated with <a href="http://docs.python.org/library/functions.html#staticmethod" rel="noreferrer"><code>@staticmethod</code></a> and one decorated with <a href="http://docs.python.org/library/functions.html#classmethod" rel="noreferrer"><code>@classmethod</code></a>?</p>
| [
{
"answer_id": 136138,
"author": "Thomas Wouters",
"author_id": 17624,
"author_profile": "https://Stackoverflow.com/users/17624",
"pm_score": 10,
"selected": false,
"text": "<p>A <strong>staticmethod</strong> is a method that knows nothing about the class or instance it was called on. It... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136097",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4766/"
] | What is the difference between a function decorated with [`@staticmethod`](http://docs.python.org/library/functions.html#staticmethod) and one decorated with [`@classmethod`](http://docs.python.org/library/functions.html#classmethod)? | Maybe a bit of example code will help: Notice the difference in the call signatures of `foo`, `class_foo` and `static_foo`:
```
class A(object):
def foo(self, x):
print(f"executing foo({self}, {x})")
@classmethod
def class_foo(cls, x):
print(f"executing class_foo({cls}, {x})")
@static... |
136,098 | <p>Browsing to a dynamic web page built using Grails version 1.0.3 the console log shows the following errors for each page request:</p>
<pre><code>[Fatal Error] :-1:-1: Premature end of file.
</code></pre>
<p>How do I stop this error from appearing for each request?</p>
| [
{
"answer_id": 136125,
"author": "marcospereira",
"author_id": 4600,
"author_profile": "https://Stackoverflow.com/users/4600",
"pm_score": 4,
"selected": false,
"text": "<p>This bug was already fixed:\n<a href=\"http://jira.codehaus.org/browse/GRAILS-3088\" rel=\"nofollow noreferrer\">ht... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136098",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16175/"
] | Browsing to a dynamic web page built using Grails version 1.0.3 the console log shows the following errors for each page request:
```
[Fatal Error] :-1:-1: Premature end of file.
```
How do I stop this error from appearing for each request? | The log entry occurs when http requests are made from Firefox 3 browsers.
The workaround on Grails 1.0.3 is to open Config.groovy in your project and find the following:
```
grails.mime.types = [ html: ['text/html','application/xhtml+xml'],
xml: ['text/xml', 'application/xml'], ...
```
The second line above, pertai... |
136,104 | <p>Why isn't Visual Studio 2005 generating a serialization setting when I set the project setting "Generate Serialization Assembly" to "On"?</p>
| [
{
"answer_id": 136109,
"author": "Adam Tegen",
"author_id": 4066,
"author_profile": "https://Stackoverflow.com/users/4066",
"pm_score": 4,
"selected": true,
"text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/ms164303.aspx\" rel=\"noreferrer\">It turns out that Dev Studio only ... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4066/"
] | Why isn't Visual Studio 2005 generating a serialization setting when I set the project setting "Generate Serialization Assembly" to "On"? | [It turns out that Dev Studio only honors this setting for Web Services.](http://msdn.microsoft.com/en-us/library/ms164303.aspx)
For non-web services you can get this to work by adding an AfterBuild target to your project file:
```
<Target Name="AfterBuild" DependsOnTargets="AssignTargetPaths;Compile;ResolveKeySour... |
136,129 | <p>I am trying to set the disabled font characteristics for a Label Control. I can set all of the Font characteristics (size, bold, etc), but the color is overridden by the default windows behavior which seems to be one of these two colors:</p>
<ul>
<li>If background color is transparent then ForeColor is same as Tex... | [
{
"answer_id": 136142,
"author": "Austin Salonen",
"author_id": 4068,
"author_profile": "https://Stackoverflow.com/users/4068",
"pm_score": 2,
"selected": false,
"text": "<p>Have you tried implementing the EnabledChanged event? Or are you looking for more of a \"styles\" property on the... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136129",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19242/"
] | I am trying to set the disabled font characteristics for a Label Control. I can set all of the Font characteristics (size, bold, etc), but the color is overridden by the default windows behavior which seems to be one of these two colors:
* If background color is transparent then ForeColor is same as TextBox disabled C... | Take a look at the [ControlPaint.DrawStringDisabled](http://msdn.microsoft.com/en-us/library/system.windows.forms.controlpaint.drawstringdisabled.aspx) method; it might be something helpful. I've used it when overriding the OnPaint event for custom controls.
```
ControlPaint.DrawStringDisabled(g, this.Text, this.Font,... |
136,132 | <p>I need to create and copy to the clipboard some RichText with standard "formatting" like bold/italics, indents and the like. The way I'm doing it now seems kind of inelegant... I'm creating a RichTextBox item and applying my formatting through that like so:</p>
<pre><code>RichTextBox rtb = new RichTextBox();
Font ... | [
{
"answer_id": 136169,
"author": "hova",
"author_id": 2170,
"author_profile": "https://Stackoverflow.com/users/2170",
"pm_score": 2,
"selected": false,
"text": "<p>You may want to suspend the layout of the richtextbox before you do all of that, to avoid unecessary flicker. That's one o... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136132",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13776/"
] | I need to create and copy to the clipboard some RichText with standard "formatting" like bold/italics, indents and the like. The way I'm doing it now seems kind of inelegant... I'm creating a RichTextBox item and applying my formatting through that like so:
```
RichTextBox rtb = new RichTextBox();
Font boldfont = new ... | You may want to suspend the layout of the richtextbox before you do all of that, to avoid unecessary flicker. That's one of the common mistakes I used to make which made it seem "inelegant" |
136,146 | <p>Examples:</p>
<pre><code>"1" yes
"-1" yes
"- 3" no
"1.2" yes
"1.2.3" no
"7e4" no (though in some cases you may want to allow scientific notation)
".123" yes
"123." yes
"." no
"-.5" yes
"007" yes
"00" yes
</code></pre>
| [
{
"answer_id": 136157,
"author": "dreeves",
"author_id": 4234,
"author_profile": "https://Stackoverflow.com/users/4234",
"pm_score": 2,
"selected": false,
"text": "<p>This allows for optional \"+\" and \"-\" in front. And allows trailing or initial whitespace.</p>\n\n<pre><code>/^\\s*[+... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136146",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4234/"
] | Examples:
```
"1" yes
"-1" yes
"- 3" no
"1.2" yes
"1.2.3" no
"7e4" no (though in some cases you may want to allow scientific notation)
".123" yes
"123." yes
"." no
"-.5" yes
"007" yes
"00" yes
``` | This allows for optional "+" and "-" in front. And allows trailing or initial whitespace.
```
/^\s*[+-]?(?:\d+\.?\d*|\d*\.\d+)\s*$/
``` |
136,168 | <p>I'm writing a log file viewer for a web application and for that I want to paginate through the lines of the log file. The items in the file are line based with the newest item at the bottom.</p>
<p>So I need a <code>tail()</code> method that can read <code>n</code> lines from the bottom and support an offset. Thi... | [
{
"answer_id": 136280,
"author": "Mark",
"author_id": 16363,
"author_profile": "https://Stackoverflow.com/users/16363",
"pm_score": 7,
"selected": false,
"text": "<p>Assumes a unix-like system on Python 2 you can do:</p>\n\n<pre><code>import os\ndef tail(f, n, offset=0):\n stdin,stdout ... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136168",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19990/"
] | I'm writing a log file viewer for a web application and for that I want to paginate through the lines of the log file. The items in the file are line based with the newest item at the bottom.
So I need a `tail()` method that can read `n` lines from the bottom and support an offset. This is hat I came up with:
```
def... | The code I ended up using. I think this is the best so far:
```
def tail(f, n, offset=None):
"""Reads a n lines from f with an offset of offset lines. The return
value is a tuple in the form ``(lines, has_more)`` where `has_more` is
an indicator that is `True` if there are more lines in the file.
"""
... |
136,172 | <p>I have a single-threaded application that loads several assemblies at runtime using the following:</p>
<pre><code>objDLL = Assembly.LoadFrom(strDLLs[i]);
</code></pre>
<p>I would like the assemblies loaded in this manner to use the same log4net.ILog reference as the rest of the assemblies do. But it appears the ru... | [
{
"answer_id": 136305,
"author": "JPrescottSanders",
"author_id": 19444,
"author_profile": "https://Stackoverflow.com/users/19444",
"pm_score": 2,
"selected": false,
"text": "<p>If all your assemblies implement a common interface, then you could have a property or constructor parameter t... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136172",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a single-threaded application that loads several assemblies at runtime using the following:
```
objDLL = Assembly.LoadFrom(strDLLs[i]);
```
I would like the assemblies loaded in this manner to use the same log4net.ILog reference as the rest of the assemblies do. But it appears the runtime loaded assemblies ha... | If all your assemblies implement a common interface, then you could have a property or constructor parameter that allows you to pass your local instance of ILog to the dynamically loaded assemblies. |
136,178 | <p>I'm running <a href="http://www.git-scm.com/docs/git-diff" rel="noreferrer">git-diff</a> on a file, but the change is at the end of a long line.</p>
<p>If I use cursor keys to move right, it loses colour-coding—and worse the lines don't line up—making it harder to track the change.</p>
<p>Is there a wa... | [
{
"answer_id": 136396,
"author": "Peter Boughton",
"author_id": 9360,
"author_profile": "https://Stackoverflow.com/users/9360",
"pm_score": 2,
"selected": false,
"text": "<p>Not a perfect solution, but <code>gitk</code> and <code>git-gui</code> can both show this information,\nand have s... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136178",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9360/"
] | I'm running [git-diff](http://www.git-scm.com/docs/git-diff) on a file, but the change is at the end of a long line.
If I use cursor keys to move right, it loses colour-coding—and worse the lines don't line up—making it harder to track the change.
Is there a way to prevent that problem or to simply make the lines wra... | The display of the output of `git diff` is handled by whatever pager you are using.
Commonly, under Linux, `less` would be used.
You can tell git to use a different pager by setting the `GIT_PAGER` environment variable. If you don't mind about paging (for example, your terminal allows you to scroll back) you might tr... |
136,191 | <p>Let's say I want to write a regular expression to change all <code><abc></code>, <code><def></code>, and <code><ghi></code> tags into <code><xyz></code> tags.. and I also want to change their closing tags to <code></xyz></code>. This seems like a reasonable regex (ignore the backticks; ... | [
{
"answer_id": 136267,
"author": "Kevin Crumley",
"author_id": 1818,
"author_profile": "https://Stackoverflow.com/users/1818",
"pm_score": 1,
"selected": false,
"text": "<p>You could just make your first match be <code>(</?)</code>, and get rid of the hard-coded <code><</code> on t... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136191",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7598/"
] | Let's say I want to write a regular expression to change all `<abc>`, `<def>`, and `<ghi>` tags into `<xyz>` tags.. and I also want to change their closing tags to `</xyz>`. This seems like a reasonable regex (ignore the backticks; StackOverflow has trouble with the less-than signs if I don't include them):
```
`s!<(/... | Move the question mark inside the capturing bracket. That way $1 will always be defined, but may be a zero-length string. |
136,195 | <p>We have a windows application that contains an ActiveX WebBrowser control. As part of the regular operation of this application modifications are made to the pages that are displayed by the ActiveX WebBrowser control. Part of these modifications involve setting a JavaScript variable in a web page being loaded into t... | [
{
"answer_id": 136213,
"author": "CMPalmer",
"author_id": 14894,
"author_profile": "https://Stackoverflow.com/users/14894",
"pm_score": 0,
"selected": false,
"text": "<p>The usual method we use is to add a hidden text input box (the ASP.Net control version) on the page. That way you can ... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136195",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14177/"
] | We have a windows application that contains an ActiveX WebBrowser control. As part of the regular operation of this application modifications are made to the pages that are displayed by the ActiveX WebBrowser control. Part of these modifications involve setting a JavaScript variable in a web page being loaded into the ... | These two articles helped us find a solution to our problem. They outline the basics of what one needs to know:
[Microsoft Web Browser Automation using C#](http://www.codeproject.com/KB/cs/mshtml_automation.aspx)
[Using MSHTML Advanced Hosting Interfaces](http://www.codeproject.com/KB/cs/advhost.aspx?target=idochostu... |
136,204 | <p>Not really getting the point of the map function. Can anyone explain with examples its use?</p>
<p>Are there any performance benefits to using this instead of a loop or is it just sugar?</p>
| [
{
"answer_id": 136228,
"author": "Adam Bellaire",
"author_id": 21632,
"author_profile": "https://Stackoverflow.com/users/21632",
"pm_score": 7,
"selected": true,
"text": "<p>Any time you want to generate a list based another list:</p>\n\n<pre><code># Double all elements of a list\nmy @do... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136204",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3208/"
] | Not really getting the point of the map function. Can anyone explain with examples its use?
Are there any performance benefits to using this instead of a loop or is it just sugar? | Any time you want to generate a list based another list:
```
# Double all elements of a list
my @double = map { $_ * 2 } (1,2,3,4,5);
# @double = (2,4,6,8,10);
```
Since lists are easily converted pairwise into hashes, if you want a hash table for objects based on a particular attribute:
```
# @user_objects is a li... |
136,233 | <p>in tcsh I'm trying to redirect STDERR from a command from my .aliases file.</p>
<p>I found that I can redirect STDERR from the command line like this. . .</p>
<pre><code>$ (xemacs > /dev/tty) >& /dev/null
</code></pre>
<p>. . . but when I put this in my .aliases file I get an alias loop. . .</p>
<pre><... | [
{
"answer_id": 136313,
"author": "Dominic Eidson",
"author_id": 5042,
"author_profile": "https://Stackoverflow.com/users/5042",
"pm_score": 4,
"selected": true,
"text": "<p>I suspect this is a case where NOT using an alias is the best option - try using a shell script instead:</p>\n\n<pr... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136233",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | in tcsh I'm trying to redirect STDERR from a command from my .aliases file.
I found that I can redirect STDERR from the command line like this. . .
```
$ (xemacs > /dev/tty) >& /dev/null
```
. . . but when I put this in my .aliases file I get an alias loop. . .
```
$ cat .aliases
alias xemacs '(xemacs > /dev/tty )... | I suspect this is a case where NOT using an alias is the best option - try using a shell script instead:
```
#!/bin/tcsh
(xemacs $* > /dev/tty ) >& /dev/null
``` |
136,278 | <p>For example, I rarely need:</p>
<pre><code>using System.Text;
</code></pre>
<p>but it's always there by default. I assume the application will use more memory if your code contains unnecessary <a href="http://msdn.microsoft.com/en-us/library/aa664764(VS.71).aspx" rel="noreferrer">using directives</a>. But is there... | [
{
"answer_id": 136285,
"author": "Darren Kopp",
"author_id": 77,
"author_profile": "https://Stackoverflow.com/users/77",
"pm_score": 9,
"selected": true,
"text": "<p>It won't change anything when your program runs. Everything that's needed is loaded on demand. So even if you have that us... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136278",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15328/"
] | For example, I rarely need:
```
using System.Text;
```
but it's always there by default. I assume the application will use more memory if your code contains unnecessary [using directives](http://msdn.microsoft.com/en-us/library/aa664764(VS.71).aspx). But is there anything else I should be aware of?
Also, does it ma... | It won't change anything when your program runs. Everything that's needed is loaded on demand. So even if you have that using statement, unless you actually use a type in that namespace / assembly, the assembly that using statement is correlated to won't be loaded.
Mainly, it's just to clean up for personal preference... |
136,288 | <p>I have this PHP code that I am trying to use to let a user edit a news record in a form and then when they hit the submit button, it will update the record in a database. The problem is that everything works but the record is not actually updated in the database.</p>
<p>Could someone look at my code and see where a... | [
{
"answer_id": 136316,
"author": "J.J.",
"author_id": 21204,
"author_profile": "https://Stackoverflow.com/users/21204",
"pm_score": 0,
"selected": false,
"text": "<p>If you run that UPDATE from the mysql cli with the same data the user sends does it update?</p>\n\n<p>If not check for esc... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136288",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have this PHP code that I am trying to use to let a user edit a news record in a form and then when they hit the submit button, it will update the record in a database. The problem is that everything works but the record is not actually updated in the database.
Could someone look at my code and see where a problem c... | ```
if ($_GET && !$_POST) {
```
...
```
if (array_key_exists('update', $_POST)) {
```
Won't that ensure the update code never fires? |
136,362 | <p>Right now, I have two Eclipse projects - they both use Maven 2 for all their jar-dependency goodness.</p>
<p>Inside Eclipse, I have project Foo included in project Bar's build path, so that I can use Foo's classes from project Bar. This works really well in Eclipse land, but when I try:</p>
<pre><code>mvn compile... | [
{
"answer_id": 136395,
"author": "Chris Vest",
"author_id": 13251,
"author_profile": "https://Stackoverflow.com/users/13251",
"pm_score": 1,
"selected": false,
"text": "<p>I think the best way to handle it is to make Bar a Maven project just like Foo, and then <code>mvn install</code> it... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136362",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8178/"
] | Right now, I have two Eclipse projects - they both use Maven 2 for all their jar-dependency goodness.
Inside Eclipse, I have project Foo included in project Bar's build path, so that I can use Foo's classes from project Bar. This works really well in Eclipse land, but when I try:
```
mvn compile
```
inside Bar's d... | Maybe you are referencing the other project via Eclipse configure-> build path only. This works as long as you use Eclipse to build your project.
Try running first `mvn install` in project Bar (in order to put Bar in your Maven repository), and then add the dependency to Foo's pom.xml.
That should work!. |
136,401 | <p>This could be weird, Have you ever come across a blog which you wanted to read in the chronological order? And that blog could be old, with several hundred posts. When i add this feed to my feed reader, say googlereader, the latest feed comes on top and as i scroll down further, the older posts appear. This could be... | [
{
"answer_id": 136416,
"author": "Forgotten Semicolon",
"author_id": 1960,
"author_profile": "https://Stackoverflow.com/users/1960",
"pm_score": 2,
"selected": false,
"text": "<p>In Google Reader, when you're reading a feed, there is a \"Feed settings...\" menu with the options: \"Sort b... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1909/"
] | This could be weird, Have you ever come across a blog which you wanted to read in the chronological order? And that blog could be old, with several hundred posts. When i add this feed to my feed reader, say googlereader, the latest feed comes on top and as i scroll down further, the older posts appear. This could be fr... | If you do decide to roll your own C# application to do this, it is very straightforward in the current version of the .NET Framework.
Look for the [System.ServiceModel.Syndication](http://msdn.microsoft.com/en-us/library/system.servicemodel.syndication.aspx) namespace. That has classes related to RSS and Atom feeds. I... |
136,413 | <p>I have a Flex application where I'm using a Canvas to contain several other components. On that Canvas there is a Button which is used to invoke a particular flow through the system. Clicking anywhere else on the Canvas should cause cause a details pane to appear showing more information about the record represent... | [
{
"answer_id": 136569,
"author": "Laplie Anderson",
"author_id": 14204,
"author_profile": "https://Stackoverflow.com/users/14204",
"pm_score": 4,
"selected": true,
"text": "<p>The event continues on because event.bubbles is set to true. This means everything in the display heirarchy get... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136413",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1247/"
] | I have a Flex application where I'm using a Canvas to contain several other components. On that Canvas there is a Button which is used to invoke a particular flow through the system. Clicking anywhere else on the Canvas should cause cause a details pane to appear showing more information about the record represented by... | The event continues on because event.bubbles is set to true. This means everything in the display heirarchy gets the event. To stop the event from continuing, you call
```
event.stopImmediatePropagation()
``` |
136,419 | <p>I need to determine the current year in Java as an integer. I could just use <code>java.util.Date()</code>, but it is deprecated.</p>
| [
{
"answer_id": 136434,
"author": "cagcowboy",
"author_id": 19629,
"author_profile": "https://Stackoverflow.com/users/19629",
"pm_score": 11,
"selected": true,
"text": "<p>For Java 8 onwards:</p>\n<pre><code>int year = Year.now().getValue();\n</code></pre>\n<p>For older version of Java:</... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136419",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/318/"
] | I need to determine the current year in Java as an integer. I could just use `java.util.Date()`, but it is deprecated. | For Java 8 onwards:
```
int year = Year.now().getValue();
```
For older version of Java:
```
int year = Calendar.getInstance().get(Calendar.YEAR);
``` |
136,432 | <p>I have a client/server system that performs communication using XML transferred using HTTP requests and responses with the client using Perl's LWP and the server running Perl's CGI.pm through Apache. In addition the stream is encrypted using SSL with certificates for both the server and all clients.</p>
<p>This sy... | [
{
"answer_id": 137279,
"author": "J.J.",
"author_id": 21204,
"author_profile": "https://Stackoverflow.com/users/21204",
"pm_score": -1,
"selected": false,
"text": "<p>I am not sure if I am following you with what you want, but I have a custom get/post module, that I use to do some non st... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136432",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22410/"
] | I have a client/server system that performs communication using XML transferred using HTTP requests and responses with the client using Perl's LWP and the server running Perl's CGI.pm through Apache. In addition the stream is encrypted using SSL with certificates for both the server and all clients.
This system works ... | I don't think you can change the Content-Length like that. It would confuse Apache, because mod\_deflate wouldn't know how much compressed data to read. What about having the client add an X-Uncompressed-Length header, and then use a modified version of CGI.pm that uses X-Uncompressed-Length (if present) instead of Con... |
136,435 | <p>How to allow <code>TextBlock</code>'s text to be selectable?</p>
<p>I tried to get it to work by displaying the text using a read-only TextBox styled to look like a textblock but this will not work in my case because a TextBox does not have inlines. In other words, how to make it selectable?</p>
| [
{
"answer_id": 136675,
"author": "Bruce",
"author_id": 6310,
"author_profile": "https://Stackoverflow.com/users/6310",
"pm_score": 4,
"selected": false,
"text": "<p>I'm not sure if you can make a TextBlock selectable, but another option would be to use a RichTextBox - it is like a TextBo... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136435",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1133/"
] | How to allow `TextBlock`'s text to be selectable?
I tried to get it to work by displaying the text using a read-only TextBox styled to look like a textblock but this will not work in my case because a TextBox does not have inlines. In other words, how to make it selectable? | Use a `TextBox` with these settings instead to make it read only and to look like a `TextBlock` control.
```
<TextBox Background="Transparent"
BorderThickness="0"
Text="{Binding Text, Mode=OneWay}"
IsReadOnly="True"
TextWrapping="Wrap" />
``` |
136,436 | <p>I am developing an auto-builder that will run a series of steps in our build process and build our target application. We used to use a batch file which set up a bunch of environment variables or called tools that setup environment variables and ultimately runs a 'make'. </p>
<p>I've been using the 'Process' class ... | [
{
"answer_id": 136675,
"author": "Bruce",
"author_id": 6310,
"author_profile": "https://Stackoverflow.com/users/6310",
"pm_score": 4,
"selected": false,
"text": "<p>I'm not sure if you can make a TextBlock selectable, but another option would be to use a RichTextBox - it is like a TextBo... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136436",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/424554/"
] | I am developing an auto-builder that will run a series of steps in our build process and build our target application. We used to use a batch file which set up a bunch of environment variables or called tools that setup environment variables and ultimately runs a 'make'.
I've been using the 'Process' class which work... | Use a `TextBox` with these settings instead to make it read only and to look like a `TextBlock` control.
```
<TextBox Background="Transparent"
BorderThickness="0"
Text="{Binding Text, Mode=OneWay}"
IsReadOnly="True"
TextWrapping="Wrap" />
``` |
136,443 | <p>We've noticed that IE7 has an odd behavor with code blocks posted on Stack Overflow. For example, this little code block:</p>
<pre><code>public PageSizer(string href, int index)
{
HRef = href;
PageIndex = index;
}
</code></pre>
<p>Copy and pasted from IE7, ends up like this:</p>
<pre>
public PageSizer(str... | [
{
"answer_id": 136510,
"author": "Armin Ronacher",
"author_id": 19990,
"author_profile": "https://Stackoverflow.com/users/19990",
"pm_score": -1,
"selected": false,
"text": "<p>Remove the inner <code><code></code>. IE's copy/paste behavior could see that as an inline tag and forge... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136443",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1/"
] | We've noticed that IE7 has an odd behavor with code blocks posted on Stack Overflow. For example, this little code block:
```
public PageSizer(string href, int index)
{
HRef = href;
PageIndex = index;
}
```
Copy and pasted from IE7, ends up like this:
```
public PageSizer(string href, int index){ HRef =... | It seems that this is a known bug for IE6 and prettify.js has a workaround for it. Specifically it replaces the BR tags with '\r\n'.
By modifying the check to allow for IE6 or 7 then the cut-and-paste will work correctly from IE7, but it will render with a *newline* followed by a *space*. By checking for IE7 and provi... |
136,444 | <p>I'm working on an embedded linux system in C, I'm looking for the source code to the equivalet of SendARP in Windows. Any pointers?</p>
| [
{
"answer_id": 136492,
"author": "mmattax",
"author_id": 1638,
"author_profile": "https://Stackoverflow.com/users/1638",
"pm_score": 0,
"selected": false,
"text": "<p>This may be of interest: <a href=\"http://cvs.linux-ha.org/viewcvs/viewcvs.cgi/linux-ha/resources/heartbeat/SendArp.in?re... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136444",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15797/"
] | I'm working on an embedded linux system in C, I'm looking for the source code to the equivalet of SendARP in Windows. Any pointers? | Take a look at [arping](http://freshmeat.net/projects/arping/). The quick and dirty way of sending an arp would be to do:
```
foo = system("/somepath/arping somehost");
```
But a look through the arping source should be able to give you a better solution.
For the all-out solution though, you can construct your own... |
136,456 | <p>I need to explain to the client why dupes are showing up between 2 supposedly different exams. It's been 20 years since Prob and Stats.</p>
<p>I have a generated Multiple choice exam.
There are 192 questions in the database,
100 are chosen at random (no dupes).</p>
<p>Obviously, there is a 100% chance of there be... | [
{
"answer_id": 136471,
"author": "Chris",
"author_id": 19290,
"author_profile": "https://Stackoverflow.com/users/19290",
"pm_score": 0,
"selected": false,
"text": "<p>Its probably higher than you think. I won't attempt to duplicate this article: <a href=\"http://en.wikipedia.org/wiki/Bir... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136456",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18907/"
] | I need to explain to the client why dupes are showing up between 2 supposedly different exams. It's been 20 years since Prob and Stats.
I have a generated Multiple choice exam.
There are 192 questions in the database,
100 are chosen at random (no dupes).
Obviously, there is a 100% chance of there being at least 8 dup... | Erm, this is really really hazy for me. But there are (192 choose 100) possible exams, right?
And there are (100 choose N) ways of picking N dupes, each with (92 choose 100-N) ways of picking the rest of the questions, no?
So isn't the probability of picking N dupes just:
(100 choose N) \* (92 choose 100-N) / (192 c... |
136,458 | <p>How would I have a <a href="http://en.wikipedia.org/wiki/JavaScript" rel="noreferrer">JavaScript</a> action that may have some effects on the current page but would also change the URL in the browser so if the user hits reload or bookmark, then the new URL is used? </p>
<p>It would also be nice if the back button ... | [
{
"answer_id": 136496,
"author": "Paul Dixon",
"author_id": 6521,
"author_profile": "https://Stackoverflow.com/users/6521",
"pm_score": 4,
"selected": false,
"text": "<p>I would strongly suspect this is not possible, because it would be an incredible security problem if it were. For exam... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10393/"
] | How would I have a [JavaScript](http://en.wikipedia.org/wiki/JavaScript) action that may have some effects on the current page but would also change the URL in the browser so if the user hits reload or bookmark, then the new URL is used?
It would also be nice if the back button would reload the original URL.
I am tr... | With HTML 5, use the [`history.pushState` function](http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html). As an example:
```
<script type="text/javascript">
var stateObj = { foo: "bar" };
function change_my_url()
{
history.pushState(stateObj, "page 2", "bar.html");
}
var link = document.getElem... |
136,467 | <p>short:</p>
<p>Is there a way in Ruby to DRY-ify this:</p>
<pre><code>def entry_point_one
begin
do_something
rescue MySyntaxErrorOne, MySyntaxErrorTwo, MySyntaxErrorEtc => syn_err
raise syn_err.exception(syn_err.message)
end
end
def entry_point_two
begin
do_something_else
rescue MySyntaxEr... | [
{
"answer_id": 136541,
"author": "Patrick Huizinga",
"author_id": 15200,
"author_profile": "https://Stackoverflow.com/users/15200",
"pm_score": 2,
"selected": false,
"text": "<p>while thinking about it a bit more, I came up with this:</p>\n\n<pre><code>interpreter_block {do_something}\n\... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136467",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15200/"
] | short:
Is there a way in Ruby to DRY-ify this:
```
def entry_point_one
begin
do_something
rescue MySyntaxErrorOne, MySyntaxErrorTwo, MySyntaxErrorEtc => syn_err
raise syn_err.exception(syn_err.message)
end
end
def entry_point_two
begin
do_something_else
rescue MySyntaxErrorOne, MySyntaxErrorTwo... | while thinking about it a bit more, I came up with this:
```
interpreter_block {do_something}
def interpreter_block
yield
rescue ExceptionOne, ExceptionTwo, ExceptionEtc => exc
raise exc.exception(exc.message)
end
```
Although it's still not quiet what I would like to have, at least now the extra entry in the b... |
136,474 | <p>I have a set of objects in a Vector from which I'd like to select a random subset (e.g. 100 items coming back; pick 5 randomly). In my first (very hasty) pass I did an extremely simple and perhaps overly clever solution:</p>
<pre><code>Vector itemsVector = getItems();
Collections.shuffle(itemsVector);
itemsVector.... | [
{
"answer_id": 136513,
"author": "qualidafial",
"author_id": 13253,
"author_profile": "https://Stackoverflow.com/users/13253",
"pm_score": 2,
"selected": false,
"text": "<p>Your second solution of using Random to pick element seems sound, however:</p>\n\n<ul>\n<li><p>Depending on how sen... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136474",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4459/"
] | I have a set of objects in a Vector from which I'd like to select a random subset (e.g. 100 items coming back; pick 5 randomly). In my first (very hasty) pass I did an extremely simple and perhaps overly clever solution:
```
Vector itemsVector = getItems();
Collections.shuffle(itemsVector);
itemsVector.setSize(5);
`... | Jon Bentley discusses this in either 'Programming Pearls' or 'More Programming Pearls'. You need to be careful with your N of M selection process, but I think the code shown works correctly. Rather than randomly shuffle all the items, you can do the random shuffle only shuffling the first N positions - which is a usefu... |
136,485 | <p>I want to copy and paste text from a Office 2007 document (docx) into a textarea. On Window, using Firefox 3, there is additional jiberish that gets put into the field:</p>
<pre><code>...Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 Normal
0 false false false EN-US X-NONE X-NONE Micros... | [
{
"answer_id": 136567,
"author": "Lincoln Johnson",
"author_id": 13419,
"author_profile": "https://Stackoverflow.com/users/13419",
"pm_score": -1,
"selected": false,
"text": "<p>I find the easiest way to eliminate this random jibberish is to copy the text you want, paste it into notepad ... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136485",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21980/"
] | I want to copy and paste text from a Office 2007 document (docx) into a textarea. On Window, using Firefox 3, there is additional jiberish that gets put into the field:
```
...Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 Normal
0 false false false EN-US X-NONE X-NONE MicrosoftInternetExpl... | Similar to Lincoln's idea, you can use [PureText](http://www.stevemiller.net/puretext/) to automate the process. Basically, you press its hotkey instead of `Ctrl`+`V` (I have mine set to `Win`+`V`), and it pastes the plain text version of whatever is on your clipboard. I'm not sure if that will remove the extra data th... |
136,500 | <p>I have a string in a node and I'd like to split the string on '?' and return the last item in the array.</p>
<p>For example, in the block below:</p>
<pre><code><a>
<xsl:attribute name="href">
/newpage.aspx?<xsl:value-of select="someNode"/>
</xsl:attribute>
Link text
<... | [
{
"answer_id": 136531,
"author": "Jacob",
"author_id": 22107,
"author_profile": "https://Stackoverflow.com/users/22107",
"pm_score": 4,
"selected": false,
"text": "<p>If you can use XSLT 2.0 or higher, you can use <code>tokenize(string, separator)</code>: </p>\n\n<pre><code>tokenize(\"XP... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1414/"
] | I have a string in a node and I'd like to split the string on '?' and return the last item in the array.
For example, in the block below:
```
<a>
<xsl:attribute name="href">
/newpage.aspx?<xsl:value-of select="someNode"/>
</xsl:attribute>
Link text
</a>
```
I'd like to split the `someNode` value... | Use a recursive method:
```
<xsl:template name="output-tokens">
<xsl:param name="list" />
<xsl:variable name="newlist" select="concat(normalize-space($list), ' ')" />
<xsl:variable name="first" select="substring-before($newlist, ' ')" />
<xsl:variable name="remaining" select="substring-after($newlis... |
136,505 | <p>I'm searching for UUIDs in blocks of text using a regex. Currently I'm relying on the assumption that all UUIDs will follow a patttern of 8-4-4-4-12 hexadecimal digits.</p>
<p>Can anyone think of a use case where this assumption would be invalid and would cause me to miss some UUIDs?</p>
| [
{
"answer_id": 136532,
"author": "pix0r",
"author_id": 72,
"author_profile": "https://Stackoverflow.com/users/72",
"pm_score": 3,
"selected": false,
"text": "<p>By definition, a UUID is 32 hexadecimal digits, separated in 5 groups by hyphens, just as you have described. You shouldn't mi... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136505",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1463/"
] | I'm searching for UUIDs in blocks of text using a regex. Currently I'm relying on the assumption that all UUIDs will follow a patttern of 8-4-4-4-12 hexadecimal digits.
Can anyone think of a use case where this assumption would be invalid and would cause me to miss some UUIDs? | I agree that by definition your regex does not miss any UUID. However it may be useful to note that if you are searching especially for Microsoft's Globally Unique Identifiers (GUIDs), there are five equivalent string representations for a GUID:
```
"ca761232ed4211cebacd00aa0057b223"
"CA761232-ED42-11CE-BACD-00AA005... |
136,536 | <p>FYI: I am running on dotnet 3.5 SP1</p>
<p>I am trying to retrieve the value of an identity column into my dataset after performing an update (using a SqlDataAdapter and SqlCommandBuilder).
After performing SqlDataAdapter.Update(myDataset), I want to be able to read the auto-assigned value of <code>myDataset.tables... | [
{
"answer_id": 137331,
"author": "Jon Adams",
"author_id": 2291,
"author_profile": "https://Stackoverflow.com/users/2291",
"pm_score": 1,
"selected": false,
"text": "<p>If those other methods didn't work for you, the .Net provided tools (SqlDataAdapter) etc. don't really offer much else ... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8678/"
] | FYI: I am running on dotnet 3.5 SP1
I am trying to retrieve the value of an identity column into my dataset after performing an update (using a SqlDataAdapter and SqlCommandBuilder).
After performing SqlDataAdapter.Update(myDataset), I want to be able to read the auto-assigned value of `myDataset.tables(0).Rows(0)("ID... | This is a problem that I've run into before, the bug seems to be that when you call
da.Update(ds);
the parameters array of the insert command gets reset to the inital list that was created form your command builder, it removes your added output parameters for the identity.
The solution is to create a new dataAdapter a... |
136,548 | <p>In C++ you can initialize a variable in an if statement, like so:</p>
<pre><code>if (CThing* pThing = GetThing())
{
}
</code></pre>
<p>Why would one consider this bad or good style? What are the benefits and disadvantages?</p>
<p>Personally i like this style because it limits the scope of the pThing variable, so ... | [
{
"answer_id": 136590,
"author": "Luke",
"author_id": 327,
"author_profile": "https://Stackoverflow.com/users/327",
"pm_score": 2,
"selected": false,
"text": "<p>This <strike><strong>should</strong></strike>doesn't work in C++ <strike>since</strike>even though it supports <a href=\"http:... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136548",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15328/"
] | In C++ you can initialize a variable in an if statement, like so:
```
if (CThing* pThing = GetThing())
{
}
```
Why would one consider this bad or good style? What are the benefits and disadvantages?
Personally i like this style because it limits the scope of the pThing variable, so it can never be used accidentally... | The important thing is that a declaration in C++ is not an expression.
```
bool a = (CThing* pThing = GetThing()); // not legit!!
```
You can't do both a declaration and boolean logic in an if statement, C++ language spec specifically allows either an expression or a declaration.
```
if(A *a = new A)
{
// this ... |
136,554 | <p>I'm trying to get an expect script to work, and when I use the -re flag (to invoke regular expression parsing), the 'timeout' keyword seems to no longer work. When the following script is run, I get the message 'timed out at step 1', then 'starting step 2' and then it times out but does NOT print the 'timed out at s... | [
{
"answer_id": 136590,
"author": "Luke",
"author_id": 327,
"author_profile": "https://Stackoverflow.com/users/327",
"pm_score": 2,
"selected": false,
"text": "<p>This <strike><strong>should</strong></strike>doesn't work in C++ <strike>since</strike>even though it supports <a href=\"http:... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10888/"
] | I'm trying to get an expect script to work, and when I use the -re flag (to invoke regular expression parsing), the 'timeout' keyword seems to no longer work. When the following script is run, I get the message 'timed out at step 1', then 'starting step 2' and then it times out but does NOT print the 'timed out at step... | The important thing is that a declaration in C++ is not an expression.
```
bool a = (CThing* pThing = GetThing()); // not legit!!
```
You can't do both a declaration and boolean logic in an if statement, C++ language spec specifically allows either an expression or a declaration.
```
if(A *a = new A)
{
// this ... |
136,580 | <p>I'm writing an app and our designers want to use gradients for some of the backgrounds on a few of our composites. </p>
<p>I wrote the following code:</p>
<pre><code>composite.addListener (SWT.Paint, new Listener () {
public void handleEvent (Event e) {
GC gc = e.gc;
Rectangle rect = co... | [
{
"answer_id": 136668,
"author": "qualidafial",
"author_id": 13253,
"author_profile": "https://Stackoverflow.com/users/13253",
"pm_score": -1,
"selected": false,
"text": "<p>The first thing I would try is to <a href=\"http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/org.eclipse.sw... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136580",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3415/"
] | I'm writing an app and our designers want to use gradients for some of the backgrounds on a few of our composites.
I wrote the following code:
```
composite.addListener (SWT.Paint, new Listener () {
public void handleEvent (Event e) {
GC gc = e.gc;
Rectangle rect = composite.getClientArea... | Use **composite.setBackgroundMode(SWT.INHERIT\_DEFAULT)**, but do not paint the composite directly - paint an image and set it as the background image using **composite.setBackgroundImage(Image)**. Unless I'm missing a trick, this means you only have to regenerate the image when the composite is resized too.
You shoul... |
136,581 | <p>Is there a way to keep the "Loading..." graphic from appearing when cfdiv refreshes? I'd like to prevent the flicker of loading the graphic then loading the new html.</p>
| [
{
"answer_id": 140429,
"author": "bhinks",
"author_id": 5877,
"author_profile": "https://Stackoverflow.com/users/5877",
"pm_score": 1,
"selected": false,
"text": "<p>I don't think there is currently a way to do this programmatically within the <code>cfdiv</code> tag. If you really want t... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136581",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3420/"
] | Is there a way to keep the "Loading..." graphic from appearing when cfdiv refreshes? I'd like to prevent the flicker of loading the graphic then loading the new html. | By adding these lines at the bottom of the header, it overwrites the "Loading..." html and seems to prevent the flickering effect in both IE and FireFox:
```
<script language="JavaScript">
_cf_loadingtexthtml="";
</script>
```
While this seems to do the trick, it would be nice if there was an officially suppo... |
136,604 | <p>Sorry if the title is poorly descriptive, but I can't do better right now =(</p>
<p>So, I have this master-detail scheme, with the detail being a tree structure (one to many self relation) with n levels (on SQLServer 2005)</p>
<p>I need to copy a detail structure from one master to the another using a stored proce... | [
{
"answer_id": 136677,
"author": "Mladen",
"author_id": 21404,
"author_profile": "https://Stackoverflow.com/users/21404",
"pm_score": 0,
"selected": false,
"text": "<p>you'll have to provide create table and insert into statements for little sample data.\nand expected results based on th... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136604",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6359/"
] | Sorry if the title is poorly descriptive, but I can't do better right now =(
So, I have this master-detail scheme, with the detail being a tree structure (one to many self relation) with n levels (on SQLServer 2005)
I need to copy a detail structure from one master to the another using a stored procedure, by passing ... | If I understand the problem, this might be what you want:
```
INSERT dbo.Master VALUES (@NewMaster_ID, @NewDescription)
INSERT dbo.Detail (parent_id, master_id, [name])
SELECT detail_ID, @NewMaster_ID, [name]
FROM dbo.Detail
WHERE master_id = @OldMaster_ID
UPDATE NewChild
SET parent_id = NewParent.detail_id
FROM db... |
136,615 | <p>How can I <em>programmatically</em> determine if I have access to a server (TCP) with a given IP address and port using C#?</p>
| [
{
"answer_id": 136625,
"author": "GEOCHET",
"author_id": 5640,
"author_profile": "https://Stackoverflow.com/users/5640",
"pm_score": 5,
"selected": true,
"text": "<p>Assuming you mean through a TCP socket:</p>\n\n<pre><code>IPAddress IP;\nif(IPAddress.TryParse(\"127.0.0.1\",out IP)){\n ... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136615",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How can I *programmatically* determine if I have access to a server (TCP) with a given IP address and port using C#? | Assuming you mean through a TCP socket:
```
IPAddress IP;
if(IPAddress.TryParse("127.0.0.1",out IP)){
Socket s = new Socket(AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp);
try{
s.Connect(IPs[0], port);
}
catch(Exception ex){
// something went wrong
}
}
... |
136,617 | <p>How do I programmatically force an onchange event on an input?</p>
<p>I've tried something like this:</p>
<pre><code>var code = ele.getAttribute('onchange');
eval(code);
</code></pre>
<p>But my end goal is to fire any listener functions, and that doesn't seem to work. Neither does just updating the 'value' attri... | [
{
"answer_id": 136633,
"author": "Aaron Powell",
"author_id": 11388,
"author_profile": "https://Stackoverflow.com/users/11388",
"pm_score": -1,
"selected": false,
"text": "<p>if you're using jQuery you would have:</p>\n\n<pre><code>$('#elementId').change(function() { alert('Do Stuff'); }... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3420/"
] | How do I programmatically force an onchange event on an input?
I've tried something like this:
```
var code = ele.getAttribute('onchange');
eval(code);
```
But my end goal is to fire any listener functions, and that doesn't seem to work. Neither does just updating the 'value' attribute. | Create an `Event` object and pass it to the `dispatchEvent` method of the element:
```
var element = document.getElementById('just_an_example');
var event = new Event('change');
element.dispatchEvent(event);
```
This will trigger event listeners regardless of whether they were registered by calling the `addEventList... |
136,628 | <p>I have a model and two views set up like this:</p>
<pre><code>Model ---> OSortFilterProxyModel ---> OListView
Model ------------------------------> OTableView
</code></pre>
<p>When the user selects something in one of the views, I want the other view to mirror that selection. So I thought I'd use a QSelec... | [
{
"answer_id": 136936,
"author": "Caleb Huitt - cjhuitt",
"author_id": 9876,
"author_profile": "https://Stackoverflow.com/users/9876",
"pm_score": 2,
"selected": false,
"text": "<p>What is probably happening is that the views do have two different models. One is your original model, the... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136628",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1585/"
] | I have a model and two views set up like this:
```
Model ---> OSortFilterProxyModel ---> OListView
Model ------------------------------> OTableView
```
When the user selects something in one of the views, I want the other view to mirror that selection. So I thought I'd use a QSelectionModel to link them together. Bu... | What is probably happening is that the views do have two different models. One is your original model, the other is the sort filter model.
I'm not sure if this would work, and it depends on what Qt considers "activated", but you could connect a function to each of the view's activated slots. These will pass you a mode... |
136,635 | <p>We have a .NET 2.0 application which we normally run on IIS6, and used to run fine on IIS7, but recently after installing SP1 for Vista IIS7 seems to be choking on a line in the Web.Config file:</p>
<pre><code><system.web AllowLocation="true">
</code></pre>
<p>Is it safe to remove the AllowLocation attribut... | [
{
"answer_id": 136676,
"author": "ironsam",
"author_id": 3539,
"author_profile": "https://Stackoverflow.com/users/3539",
"pm_score": 0,
"selected": false,
"text": "<p>Having this set to true should enable any <code><location></code> sections in your web.config, so you should be fin... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136635",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8432/"
] | We have a .NET 2.0 application which we normally run on IIS6, and used to run fine on IIS7, but recently after installing SP1 for Vista IIS7 seems to be choking on a line in the Web.Config file:
```
<system.web AllowLocation="true">
```
Is it safe to remove the AllowLocation attribute? What does this attribute do? | From MSDN:
>
> When set to false, the AllowLocation property indicates that the section is accessed by native-code readers. Therefore, the use of the location attribute is not allowed, because the native-code readers do not support the concept of location.
>
>
>
The default value is true, so you should be able to... |
136,642 | <p>I'm having trouble coming up with the correct regex string to remove a sequence of multiple ? characters. I want to replace more than one sequential ? with a single ?, but which characters to escape...is escaping me.</p>
<p>Example input:</p>
<blockquote>
<p>Is this thing on??? or what???</p>
</blockquote>
<p>D... | [
{
"answer_id": 136654,
"author": "pilsetnieks",
"author_id": 6615,
"author_profile": "https://Stackoverflow.com/users/6615",
"pm_score": 4,
"selected": true,
"text": "<pre><code>preg_replace('{\\?+}', '?', 'Is this thing on??? or what???');\n</code></pre>\n\n<p>That is, you only have to ... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136642",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14569/"
] | I'm having trouble coming up with the correct regex string to remove a sequence of multiple ? characters. I want to replace more than one sequential ? with a single ?, but which characters to escape...is escaping me.
Example input:
>
> Is this thing on??? or what???
>
>
>
Desired output:
>
> Is this thing on? ... | ```
preg_replace('{\?+}', '?', 'Is this thing on??? or what???');
```
That is, you only have to escape the question mark, the plus in "\?+" means that we're replacing every instance with one or more characters, though I suspect "\?{2,}" might be even better and more efficient (replacing every instance with two or mor... |
136,672 | <p>I'd like to log stuff in my Sharepoint Web Parts, but I want it to go into the ULS. Most examples that I've found log into the Event Log or some other file, but I did not really find one yet for logging into the ULS.</p>
<p>Annoyingly, Microsoft.SharePoint.Diagnostics Classes are all marked Internal. I did find <a ... | [
{
"answer_id": 137836,
"author": "Jason Stevenson",
"author_id": 13368,
"author_profile": "https://Stackoverflow.com/users/13368",
"pm_score": 4,
"selected": true,
"text": "<p>Yes this is possible, see this MSDN article: <a href=\"http://msdn2.microsoft.com/hi-in/library/aa979595(en-us).... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136672",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91/"
] | I'd like to log stuff in my Sharepoint Web Parts, but I want it to go into the ULS. Most examples that I've found log into the Event Log or some other file, but I did not really find one yet for logging into the ULS.
Annoyingly, Microsoft.SharePoint.Diagnostics Classes are all marked Internal. I did find [one example]... | Yes this is possible, see this MSDN article: <http://msdn2.microsoft.com/hi-in/library/aa979595(en-us).aspx>
And here is some sample code in C#:
```
using System;
using System.Runtime.InteropServices;
using Microsoft.SharePoint.Administration;
namespace ManagedTraceProvider
{
class Program
{
static void Main(str... |
136,682 | <p>I've got a code like this : </p>
<pre><code>Dim Document As New mshtml.HTMLDocument
Dim iDoc As mshtml.IHTMLDocument2 = CType(Document, mshtml.IHTMLDocument2)
iDoc.write(html)
iDoc.close()
</code></pre>
<p>However when I load an HTML like this it executes all Javascripts in it as well as doing request to some reso... | [
{
"answer_id": 139224,
"author": "scunliffe",
"author_id": 6144,
"author_profile": "https://Stackoverflow.com/users/6144",
"pm_score": 1,
"selected": false,
"text": "<p>If you have the 'html' as a string already, and you just want access to the DOM view of it, why \"render\" it to a brow... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136682",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I've got a code like this :
```
Dim Document As New mshtml.HTMLDocument
Dim iDoc As mshtml.IHTMLDocument2 = CType(Document, mshtml.IHTMLDocument2)
iDoc.write(html)
iDoc.close()
```
However when I load an HTML like this it executes all Javascripts in it as well as doing request to some resources from "html" code.
I... | ```
Dim Document As New mshtml.HTMLDocument
Dim iDoc As mshtml.IHTMLDocument2 = CType(Document, mshtml.IHTMLDocument2)
'add this code
iDoc.designMode="On"
iDoc.write(html)iDoc.close()
``` |
136,696 | <p>I have a Hashtable<Integer, Sport> called sportMap and a list of sportIds (List<Integer> sportIds) from my backing bean. The Sport object has a List<String> equipmentList. Can I do the following using the unified EL to get the list of equipment for each sport?</p>
<pre><code><h:dataTable value="#{bean... | [
{
"answer_id": 137188,
"author": "user13229",
"author_id": 13229,
"author_profile": "https://Stackoverflow.com/users/13229",
"pm_score": -1,
"selected": false,
"text": "<p>Two issues: </p>\n\n<ol>\n<li>A dataTable can only have the following children: header facet, footer facet, column. ... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136696",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5917/"
] | I have a Hashtable<Integer, Sport> called sportMap and a list of sportIds (List<Integer> sportIds) from my backing bean. The Sport object has a List<String> equipmentList. Can I do the following using the unified EL to get the list of equipment for each sport?
```
<h:dataTable value="#{bean.sportIds}" var="_sportId" >... | @[keith30xi.myopenid.com](https://stackoverflow.com/questions/136696/can-i-use-a-hashtable-in-a-unified-el-expression-on-a-cforeach-tag-using-jsf-12#137188)
**Not TRUE in JSF 1.2**. According to the [java.net wiki faq](http://wiki.java.net/bin/view/Projects/JavaServerFacesSpecFaq#12coreTags) they should work together ... |
136,703 | <p>I need a quick easy way to get a string from a file in standard C++. I can write my own, but just want to know if there is already a standard way, in C++.</p>
<p>Equivalent of this if you know Cocoa:</p>
<pre><code>NSString *string = [NSString stringWithContentsOfFile:file];
</code></pre>
| [
{
"answer_id": 136710,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 2,
"selected": false,
"text": "<p>The standard C++ library doesn't provide a function to do this.</p>\n"
},
{
"answer_id": 136743,
"author":... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136703",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10184/"
] | I need a quick easy way to get a string from a file in standard C++. I can write my own, but just want to know if there is already a standard way, in C++.
Equivalent of this if you know Cocoa:
```
NSString *string = [NSString stringWithContentsOfFile:file];
``` | We can do it but it's a long line :
```
#include<fstream>
#include<iostream>
#include<iterator>
#include<string>
using namespace std;
int main()
{
// The one-liner
string fileContents(istreambuf_iterator<char>(ifstream("filename.txt")), istreambuf_iterator<char>());
// Check result
cout << fileConte... |
136,727 | <p>From my understanding of the CSS spec, a table above or below a paragraph should collapse vertical margins with it. However, that's not happening here:</p>
<p><div class="snippet" data-lang="js" data-hide="true" data-console="true" data-babel="false">
<div class="snippet-code snippet-currently-hidden">
<pre class... | [
{
"answer_id": 136774,
"author": "flash",
"author_id": 11539,
"author_profile": "https://Stackoverflow.com/users/11539",
"pm_score": 2,
"selected": false,
"text": "<p>I think this is down to different browser implementations of CSS. I've just tried your code, and Firefox3 doesn't collap... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136727",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7598/"
] | From my understanding of the CSS spec, a table above or below a paragraph should collapse vertical margins with it. However, that's not happening here:
```css
table {
margin: 100px;
border: solid red 2px;
}
p {
margin: 100px
}
```
```html
<table>
<tr>
<td>
This is a one-celled table with 10... | Margin collapsing is only defined for block elements. Try it - add `display: block` to the table styles, and suddenly it works (and alters the display of the table...)
Tables are special. In the CSS specs, they're not *quite* block elements - special rules apply to size and position, both of their children (obviously)... |
136,734 | <p>Is it possible to make it appear to a system that a key was pressed, for example I need to make <kbd>A</kbd> key be pressed thousands of times, and it is much to time consuming to do it manually, I would like to write something to do it for me, and the only thing I know well enough is Python.</p>
<p>A better way t... | [
{
"answer_id": 136759,
"author": "PabloG",
"author_id": 394,
"author_profile": "https://Stackoverflow.com/users/394",
"pm_score": 4,
"selected": false,
"text": "<p><a href=\"http://www.autohotkey.com/\" rel=\"noreferrer\">AutoHotKey</a> is perfect for this kind of tasks (keyboard automat... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136734",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/115/"
] | Is it possible to make it appear to a system that a key was pressed, for example I need to make `A` key be pressed thousands of times, and it is much to time consuming to do it manually, I would like to write something to do it for me, and the only thing I know well enough is Python.
A better way to put it, I need to ... | Install the [pywin32](https://github.com/mhammond/pywin32) extensions. Then you can do the following:
```
import win32com.client as comclt
wsh= comclt.Dispatch("WScript.Shell")
wsh.AppActivate("Notepad") # select another application
wsh.SendKeys("a") # send the keys you want
```
Search for documentation of the WScri... |
136,752 | <p>I have a C++ tool that walks the call stack at one point. In the code, it first gets a copy of the live CPU registers (via RtlCaptureContext()), then uses a few "<code>#ifdef ...</code>" blocks to save the CPU-specific register names into <code>stackframe.AddrPC.Offset</code>, ...<code>AddrStack</code>..., and ...<... | [
{
"answer_id": 136942,
"author": "Adam Mitz",
"author_id": 2574,
"author_profile": "https://Stackoverflow.com/users/2574",
"pm_score": 2,
"selected": false,
"text": "<p>Given that fs.sf is a STACKFRAME64 structure, you need to initialize it like this before passing it to StackWalk64: (c ... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19505/"
] | I have a C++ tool that walks the call stack at one point. In the code, it first gets a copy of the live CPU registers (via RtlCaptureContext()), then uses a few "`#ifdef ...`" blocks to save the CPU-specific register names into `stackframe.AddrPC.Offset`, ...`AddrStack`..., and ...`AddrFrame`...; also, for each of the ... | Given that fs.sf is a STACKFRAME64 structure, you need to initialize it like this before passing it to StackWalk64: (c is a CONTEXT structure)
```
DWORD machine = IMAGE_FILE_MACHINE_AMD64;
RtlCaptureContext (&c);
fs.sf.AddrPC.Offset = c.Rip;
fs.sf.AddrFrame.Offset = c.Rsp;
fs.sf.AddrStack.Offset = c.Rsp;
f... |
136,771 | <p>How can I drop sql server agent jobs, if (and only if) it exists?</p>
<p>This is a well functioning script for <em>stored procedures</em>. How can I do the same to sql server agent jobs?</p>
<pre><code>if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[storedproc]') and OBJECTPROPERTY(id, N'IsProc... | [
{
"answer_id": 137159,
"author": "Codewerks",
"author_id": 17729,
"author_profile": "https://Stackoverflow.com/users/17729",
"pm_score": 8,
"selected": true,
"text": "<p>Try something like this:</p>\n\n<pre><code>DECLARE @jobId binary(16)\n\nSELECT @jobId = job_id FROM msdb.dbo.sysjobs W... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136771",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13954/"
] | How can I drop sql server agent jobs, if (and only if) it exists?
This is a well functioning script for *stored procedures*. How can I do the same to sql server agent jobs?
```
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[storedproc]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop proc... | Try something like this:
```
DECLARE @jobId binary(16)
SELECT @jobId = job_id FROM msdb.dbo.sysjobs WHERE (name = N'Name of Your Job')
IF (@jobId IS NOT NULL)
BEGIN
EXEC msdb.dbo.sp_delete_job @jobId
END
DECLARE @ReturnCode int
EXEC @ReturnCode = msdb.dbo.sp_add_job @job_name=N'Name of Your Job'
```
Best to r... |
136,782 | <p>I have a <code>datetime</code> column in MySQL. </p>
<p>How can I convert it to the display as <strong>mm/dd/yy H:M (AM/PM)</strong> using PHP?</p>
| [
{
"answer_id": 136796,
"author": "flash",
"author_id": 11539,
"author_profile": "https://Stackoverflow.com/users/11539",
"pm_score": 4,
"selected": false,
"text": "<p>An easier way would be to format the date directly in the MySQL query, instead of PHP. See the <a href=\"http://dev.mysq... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136782",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/70/"
] | I have a `datetime` column in MySQL.
How can I convert it to the display as **mm/dd/yy H:M (AM/PM)** using PHP? | If you're looking for a way to normalize a date into MySQL format, use the following
```
$phpdate = strtotime( $mysqldate );
$mysqldate = date( 'Y-m-d H:i:s', $phpdate );
```
The line `$phpdate = strtotime( $mysqldate )` accepts a string and performs a series of heuristics to turn that string into a unix timestamp.
... |
136,789 | <p>Right now I have a log parser reading through 515mb of plain-text files (a file for each day over the past 4 years). My code currently stands as this: <a href="http://gist.github.com/12978" rel="nofollow noreferrer">http://gist.github.com/12978</a>. I've used psyco (as seen in the code) and I'm also compiling it and... | [
{
"answer_id": 136870,
"author": "Mark Roddy",
"author_id": 9940,
"author_profile": "https://Stackoverflow.com/users/9940",
"pm_score": 2,
"selected": false,
"text": "<p>Use bind variables instead of literal values in the sql statements and create a cursor for \neach unique sql statement... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15245/"
] | Right now I have a log parser reading through 515mb of plain-text files (a file for each day over the past 4 years). My code currently stands as this: <http://gist.github.com/12978>. I've used psyco (as seen in the code) and I'm also compiling it and using the compiled version. It's doing about 100 lines every 0.3 seco... | Don't waste time profiling. The time is always in the database operations. Do as few as possible. Just the minimum number of inserts.
Three Things.
One. Don't SELECT over and over again to conform the Date, Hostname and Person dimensions. Fetch all the data ONCE into a Python dictionary and use it in memory. Don't do... |
136,793 | <p>I'm using this code to let the user enter in names while the program stores them in an array until they enter an empty string (they must press enter after each name):</p>
<pre><code>people = []
info = 'a' # must fill variable with something, otherwise loop won't execute
while not info.empty?
info = gets.chomp
... | [
{
"answer_id": 136815,
"author": "hubbardr",
"author_id": 22457,
"author_profile": "https://Stackoverflow.com/users/22457",
"pm_score": 8,
"selected": false,
"text": "<blockquote>\n<p>I found the following snippet while reading the source for <code>Tempfile#initialize</code> in the Ruby ... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/813/"
] | I'm using this code to let the user enter in names while the program stores them in an array until they enter an empty string (they must press enter after each name):
```
people = []
info = 'a' # must fill variable with something, otherwise loop won't execute
while not info.empty?
info = gets.chomp
people += ... | **CAUTION**:
The `begin <code> end while <condition>` is rejected by Ruby's author Matz. Instead he suggests using `Kernel#loop`, e.g.
```
loop do
# some code here
break if <condition>
end
```
Here's [an email exchange](http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/6745) in 23 Nov 2005 where Mat... |
136,823 | <p>I am trying to integrate the SSRS report to my web page.
The code is as follows:</p>
<pre><code>ReportViewer1.ProcessingMode = rocessingMode.Remote;
ReportViewer1.ServerReport.ReportServerUrl = new Uri("http://localhost/reportserver");
ReportViewer1.ServerReport.ReportPath = "/Report Project1/Reconciliation";
List&... | [
{
"answer_id": 136853,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 1,
"selected": false,
"text": "<p>The problem is that your ASP.NET worker process does not have the permissions to do what you want.</p>\n\n<p>Edit this us... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136823",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14752/"
] | I am trying to integrate the SSRS report to my web page.
The code is as follows:
```
ReportViewer1.ProcessingMode = rocessingMode.Remote;
ReportViewer1.ServerReport.ReportServerUrl = new Uri("http://localhost/reportserver");
ReportViewer1.ServerReport.ReportPath = "/Report Project1/Reconciliation";
List<ReportParamete... | To clarify Erikk's answer a little bit.
The particular set of security permissions you want to set to fix this error (there are at least another two types of security settings in Reports Manager) are available in the "security" menu option of the "Properties" tab of the reports folder you are looking at.
Obiously it... |
136,829 | <p>In VB.NET (or C#) how can I determine programmatically if a public variable in class helper.vb is used anywhere within a project?</p>
| [
{
"answer_id": 136847,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 0,
"selected": false,
"text": "<p>You would need to use reflection and it would be complicated.</p>\n\n<p>Why are you doing this programmaticly? You know t... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136829",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22301/"
] | In VB.NET (or C#) how can I determine programmatically if a public variable in class helper.vb is used anywhere within a project? | From [MSDN](http://msdn.microsoft.com/en-us/library/aa300858(VS.71).aspx)
The Find object allows you to search for and replace text in places of the environment that support such operations, such as the Code editor.
It is intended primarily for macro recording purposes. The editor's macro recording mechanism uses Fi... |
136,836 | <p>What is the slickest way to initialize an array of dynamic size in C# that you know of?</p>
<p>This is the best I could come up with</p>
<pre><code>private bool[] GetPageNumbersToLink(IPagedResult result)
{
if (result.TotalPages <= 9)
return new bool[result.TotalPages + 1].Select(b => true).ToArray(... | [
{
"answer_id": 136890,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 0,
"selected": false,
"text": "<p>Untested, but could you just do this?</p>\n\n<pre><code>return result.Select(p => true).ToArray();\n</code></pre>\... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136836",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2595/"
] | What is the slickest way to initialize an array of dynamic size in C# that you know of?
This is the best I could come up with
```
private bool[] GetPageNumbersToLink(IPagedResult result)
{
if (result.TotalPages <= 9)
return new bool[result.TotalPages + 1].Select(b => true).ToArray();
...
``` | use [Enumerable.Repeat](http://msdn.microsoft.com/en-us/library/bb348899%28v=vs.110%29.aspx)
```
Enumerable.Repeat(true, result.TotalPages + 1).ToArray()
``` |
136,837 | <p>A few years ago I developed a web app for which we wanted to make sure the users weren't sharing credentials.</p>
<p>One of the things we decided to to, was only allow the user to be logged in from one computer at a time. The way I did this, was to have a little iframe ping the server every N seconds; as long as th... | [
{
"answer_id": 136862,
"author": "Taptronic",
"author_id": 14728,
"author_profile": "https://Stackoverflow.com/users/14728",
"pm_score": 1,
"selected": false,
"text": "<p>In a highly secure application, you may be required to do such. What you can do is keep a login count incrementing t... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136837",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/781/"
] | A few years ago I developed a web app for which we wanted to make sure the users weren't sharing credentials.
One of the things we decided to to, was only allow the user to be logged in from one computer at a time. The way I did this, was to have a little iframe ping the server every N seconds; as long as the server h... | I've implemented this by maintaining a hashtable of currently logged in users, the key was the username, the value was their last activity time.
When logging in, you just check this hashtable for the key, and if it exists, reject the login.
When the user does anything, you update the hashtable with the time (This is ... |
136,880 | <p>So why exactly is it that it's always recommended to use const as often as possible? It seems to me that using const can be more of a pain than a help in C++. But then again, I'm coming at this from the python perspective: if you don't want something to be changed, don't change it. So with that said, here are a ... | [
{
"answer_id": 136895,
"author": "Doug T.",
"author_id": 8123,
"author_profile": "https://Stackoverflow.com/users/8123",
"pm_score": 7,
"selected": false,
"text": "<p>Here's a piece of code with a common error that const correctness can protect you against:</p>\n\n<pre><code>void foo(con... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136880",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2147/"
] | So why exactly is it that it's always recommended to use const as often as possible? It seems to me that using const can be more of a pain than a help in C++. But then again, I'm coming at this from the python perspective: if you don't want something to be changed, don't change it. So with that said, here are a few que... | This is the definitive article on "const correctness": <https://isocpp.org/wiki/faq/const-correctness>.
In a nutshell, using const is good practice because...
1. It protects you from accidentally changing variables that aren't intended be changed,
2. It protects you from making accidental variable assignments, and
3.... |
136,884 | <p>Is it possible to have a <code><div></code> simultaneously (1) not take up all available width and (2) collapse margins with its neighbors?</p>
<p>I learned recently that setting a <code>div</code> to <code>display:table</code> will stop it from expanding to take up the whole width of the parent container -- ... | [
{
"answer_id": 136921,
"author": "Jonny Buchanan",
"author_id": 6760,
"author_profile": "https://Stackoverflow.com/users/6760",
"pm_score": 2,
"selected": true,
"text": "<p>You could wrap the <code>display: table</code> <code>div</code> with another <code>div</code> and put the margin on... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136884",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7598/"
] | Is it possible to have a `<div>` simultaneously (1) not take up all available width and (2) collapse margins with its neighbors?
I learned recently that setting a `div` to `display:table` will stop it from expanding to take up the whole width of the parent container -- but now I realize that this introduces a new prob... | You could wrap the `display: table` `div` with another `div` and put the margin on the wrapper `div` instead. Nasty, but it works.
```
<p style="margin:100px">This is a paragraph with 100px margin all around.</p>
<div style="margin: 100px"><div style="border: solid red 2px; display: table;">
This is a div which had... |
136,899 | <p>In your opinion, is it ever valid to use the @ operator to suppress an error/warning in PHP whereas you may be handling the error?</p>
<p>If so, in what circumstances would you use this?</p>
<p>Code examples are welcome.</p>
<p>Edit: Note to repliers. I'm not looking to turn error reporting off, but, for example,... | [
{
"answer_id": 136912,
"author": "Jason Cohen",
"author_id": 4926,
"author_profile": "https://Stackoverflow.com/users/4926",
"pm_score": 5,
"selected": false,
"text": "<p>Yes suppression makes sense.</p>\n\n<p>For example, the <code>fopen()</code> command returns <code>FALSE</code> if th... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136899",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20010/"
] | In your opinion, is it ever valid to use the @ operator to suppress an error/warning in PHP whereas you may be handling the error?
If so, in what circumstances would you use this?
Code examples are welcome.
Edit: Note to repliers. I'm not looking to turn error reporting off, but, for example, common practice is to u... | I would suppress the error **and handle it**. Otherwise you may have a **TOCTOU** issue (Time-of-check, time-of-use. For example a file may get deleted after file\_exists returns true, but before fopen).
But I wouldn't just suppress errors to make them go away. These better be visible. |
136,937 | <p>Is there a way to respond to the back button being hit (or backspace being pressed) in javascript when only the location hash changes? That is to say when the browser is not communicating with the server or reloading the page.</p>
| [
{
"answer_id": 136957,
"author": "pix0r",
"author_id": 72,
"author_profile": "https://Stackoverflow.com/users/72",
"pm_score": 1,
"selected": false,
"text": "<p><code>onLocationChange</code> may also be useful. Not sure if this is a Mozilla-only thing though, appears that it might be.</... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136937",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10393/"
] | Is there a way to respond to the back button being hit (or backspace being pressed) in javascript when only the location hash changes? That is to say when the browser is not communicating with the server or reloading the page. | Use the [`hashchange`](https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers.onhashchange) event:
```
window.addEventListener("hashchange", function(e) {
// ...
})
```
If you need to support older browsers, check out the [`hashChange` Event section](https://github.com/Modernizr/Modernizr/wiki/HTML5-... |
136,946 | <p>What's the difference between using a define statement and an enum statement in C/C++ (and is there any difference when using them with either C or C++)?</p>
<p>For example, when should one use</p>
<pre><code>enum {BUFFER = 1234};
</code></pre>
<p>over</p>
<pre><code>#define BUFFER 1234
</code></pre>
| [
{
"answer_id": 136954,
"author": "Jason Cohen",
"author_id": 4926,
"author_profile": "https://Stackoverflow.com/users/4926",
"pm_score": 7,
"selected": true,
"text": "<p><code>enum</code> defines a syntactical element.</p>\n\n<p><code>#define</code> is a pre-preprocessor directive, execu... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136946",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21539/"
] | What's the difference between using a define statement and an enum statement in C/C++ (and is there any difference when using them with either C or C++)?
For example, when should one use
```
enum {BUFFER = 1234};
```
over
```
#define BUFFER 1234
``` | `enum` defines a syntactical element.
`#define` is a pre-preprocessor directive, executed *before* the compiler sees the code, and therefore is not a language element of C itself.
Generally enums are preferred as they are type-safe and more easily discoverable. Defines are harder to locate and can have complex behavi... |
136,948 | <p>I used to be able to launch a locally installed helper application by registering a given mime-type in the Windows registry. This enabled me to allow users to be able to click once on a link to the current install of our internal browser application. This worked fine in Internet Explorer 5 (most of the time) and Fir... | [
{
"answer_id": 136954,
"author": "Jason Cohen",
"author_id": 4926,
"author_profile": "https://Stackoverflow.com/users/4926",
"pm_score": 7,
"selected": true,
"text": "<p><code>enum</code> defines a syntactical element.</p>\n\n<p><code>#define</code> is a pre-preprocessor directive, execu... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136948",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13183/"
] | I used to be able to launch a locally installed helper application by registering a given mime-type in the Windows registry. This enabled me to allow users to be able to click once on a link to the current install of our internal browser application. This worked fine in Internet Explorer 5 (most of the time) and Firefo... | `enum` defines a syntactical element.
`#define` is a pre-preprocessor directive, executed *before* the compiler sees the code, and therefore is not a language element of C itself.
Generally enums are preferred as they are type-safe and more easily discoverable. Defines are harder to locate and can have complex behavi... |
136,961 | <p>I'm using the jQuery Form plugin to upload an image. I've assigned a fade animation to happen the <code>beforeSubmit</code> callback, but as I'm running locally, it doesn't have time to finish before the <code>success</code> function is called. </p>
<p>I am using a callback function in my <code>fade();</code> call ... | [
{
"answer_id": 137035,
"author": "Ricky",
"author_id": 653,
"author_profile": "https://Stackoverflow.com/users/653",
"pm_score": 3,
"selected": true,
"text": "<p>I think you may be getting too fancy with those fade animations :)... In the beforeSubmit the fadeOut is setup but the functio... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136961",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4636/"
] | I'm using the jQuery Form plugin to upload an image. I've assigned a fade animation to happen the `beforeSubmit` callback, but as I'm running locally, it doesn't have time to finish before the `success` function is called.
I am using a callback function in my `fade();` call to make sure that one fade completes, befor... | I think you may be getting too fancy with those fade animations :)... In the beforeSubmit the fadeOut is setup but the function returns immediately causing the submit to happen. I guess the upload is happening under 3 seconds causing the new image to appear before your animations are complete.
So if you really really ... |
136,975 | <p>Is there a way to tell if an event handler has been added to an object? I'm serializing a list of objects into/out of session state so we can use SQL based session state... When an object in the list has a property changed it needs to be flagged, which the event handler took care of properly before. However now wh... | [
{
"answer_id": 136994,
"author": "Lou Franco",
"author_id": 3937,
"author_profile": "https://Stackoverflow.com/users/3937",
"pm_score": 4,
"selected": false,
"text": "<p>If this is the only handler, you can check to see if the event is null, if it isn't, the handler has been added.</p>\n... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136975",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17145/"
] | Is there a way to tell if an event handler has been added to an object? I'm serializing a list of objects into/out of session state so we can use SQL based session state... When an object in the list has a property changed it needs to be flagged, which the event handler took care of properly before. However now when th... | From outside the defining class, as @Telos mentions, you can only use EventHandler on the left-hand side of a `+=` or a `-=`. So, if you have the ability to modify the defining class, you could provide a method to perform the check by checking if the event handler is `null` - if so, then no event handler has been added... |
136,986 | <p>2 tables: </p>
<pre><code>Employees
- EmployeeID
- LeadCount
Leads
- leadID
- employeeID
</code></pre>
<p>I want to update the <code>Employees.LeadCount</code> column by counting the # of leads in the <code>Leads</code> table that have the same <code>EmployeeID</code>.</p>
<p>Note: There may be more than 1 lea... | [
{
"answer_id": 137001,
"author": "Jason Cohen",
"author_id": 4926,
"author_profile": "https://Stackoverflow.com/users/4926",
"pm_score": 1,
"selected": false,
"text": "<pre><code>UPDATE Employees SET LeadCount = (\n SELECT Distinct(SUM(employeeID)) FROM Leads WHERE Leads.employeeId = Em... | 2008/09/25 | [
"https://Stackoverflow.com/questions/136986",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1368/"
] | 2 tables:
```
Employees
- EmployeeID
- LeadCount
Leads
- leadID
- employeeID
```
I want to update the `Employees.LeadCount` column by counting the # of leads in the `Leads` table that have the same `EmployeeID`.
Note: There may be more than 1 lead with the same employeeID, so I have to do a `DISTINCT(SUM(employee... | ```
UPDATE
Employees E
SET
E.LeadCount = (
SELECT COUNT(L.EmployeeID)
FROM Leads L
WHERE L.EmployeeID = E.EmployeeID
)
``` |
137,006 | <p>Is there any way to redefine a class or some of its methods without using typical inheritance? For example:</p>
<pre><code>class third_party_library {
function buggy_function() {
return 'bad result';
}
function other_functions(){
return 'blah';
}
}
</code></pre>
<p>What can I do to re... | [
{
"answer_id": 137017,
"author": "Ólafur Waage",
"author_id": 22459,
"author_profile": "https://Stackoverflow.com/users/22459",
"pm_score": 1,
"selected": false,
"text": "<p>Zend Studio and PDT (eclipse based ide) have some built in refractoring tools. But there are no built in methods t... | 2008/09/26 | [
"https://Stackoverflow.com/questions/137006",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5261/"
] | Is there any way to redefine a class or some of its methods without using typical inheritance? For example:
```
class third_party_library {
function buggy_function() {
return 'bad result';
}
function other_functions(){
return 'blah';
}
}
```
What can I do to replace `buggy_function()`... | It's called [monkey patching](http://en.wikipedia.org/wiki/Monkey_patch). But, PHP doesn't have native support for it.
Though, as others have also pointed out, the [runkit library](http://docs.php.net/runkit) is available for adding support to the language and is the successor to [classkit](http://docs.php.net/manual/... |
137,038 | <p>How does one do this?</p>
<p>If I want to analyze how something is getting compiled, how would I get the emitted assembly code?</p>
| [
{
"answer_id": 137044,
"author": "Doug T.",
"author_id": 8123,
"author_profile": "https://Stackoverflow.com/users/8123",
"pm_score": 5,
"selected": false,
"text": "<p>Use the <a href=\"https://gcc.gnu.org/onlinedocs/gcc/Overall-Options.html#index-S\" rel=\"nofollow noreferrer\">-S</a> sw... | 2008/09/26 | [
"https://Stackoverflow.com/questions/137038",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8123/"
] | How does one do this?
If I want to analyze how something is getting compiled, how would I get the emitted assembly code? | Use the [-S](https://gcc.gnu.org/onlinedocs/gcc/Overall-Options.html#index-S) option to `gcc` (or `g++`), optionally with [-fverbose-asm](https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#index-fverbose-asm) which works well at the default [-O0](https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-O0) ... |
137,043 | <p>When editing HTML in emacs, is there a way to automatically pretty-format a blob of markup, changing something like this:</p>
<pre><code> <table>
<tr>
<td>blah</td></tr></table>
</code></pre>
<p>...into this:</p>
<pre><code><table>
<tr>
<td>
blah
&l... | [
{
"answer_id": 137139,
"author": "Jay",
"author_id": 20840,
"author_profile": "https://Stackoverflow.com/users/20840",
"pm_score": 4,
"selected": false,
"text": "<p><a href=\"http://www.delorie.com/gnu/docs/emacs/emacs_277.html\" rel=\"noreferrer\">http://www.delorie.com/gnu/docs/emacs/e... | 2008/09/26 | [
"https://Stackoverflow.com/questions/137043",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7598/"
] | When editing HTML in emacs, is there a way to automatically pretty-format a blob of markup, changing something like this:
```
<table>
<tr>
<td>blah</td></tr></table>
```
...into this:
```
<table>
<tr>
<td>
blah
</td>
</tr>
</table>
``` | By default, when you visit a `.html` file in Emacs (22 or 23), it will put you in `html-mode`. That is probably not what you want. You probably want `nxml-mode`, which is seriously fancy. `nxml-mode` seems to only come with Emacs 23, although you can download it for earlier versions of emacs from the [nXML web site](ht... |
137,054 | <p>How can I validate that my ASPNET AJAX installation is correct.</p>
<p>I have Visual Studio 2008 and had never previously installed any AJAX version.</p>
<p>My UpdatePanel is nto working within IIS6, although it works ok within Visual Studio's web server. The behaviour I get is as if the UpdatePanel doesnt exist a... | [
{
"answer_id": 137139,
"author": "Jay",
"author_id": 20840,
"author_profile": "https://Stackoverflow.com/users/20840",
"pm_score": 4,
"selected": false,
"text": "<p><a href=\"http://www.delorie.com/gnu/docs/emacs/emacs_277.html\" rel=\"noreferrer\">http://www.delorie.com/gnu/docs/emacs/e... | 2008/09/26 | [
"https://Stackoverflow.com/questions/137054",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16940/"
] | How can I validate that my ASPNET AJAX installation is correct.
I have Visual Studio 2008 and had never previously installed any AJAX version.
My UpdatePanel is nto working within IIS6, although it works ok within Visual Studio's web server. The behaviour I get is as if the UpdatePanel doesnt exist at all - i.e. it r... | By default, when you visit a `.html` file in Emacs (22 or 23), it will put you in `html-mode`. That is probably not what you want. You probably want `nxml-mode`, which is seriously fancy. `nxml-mode` seems to only come with Emacs 23, although you can download it for earlier versions of emacs from the [nXML web site](ht... |
137,089 | <p>I'm trying to use boost::signal to implement a callback mechanism, and I'm getting a memory access assert in the boost::signal code on even the most trivial usage of the library. I have simplified it down to this code:</p>
<pre><code>#include <boost/signal.hpp>
typedef boost::signal<void (void)> Event;... | [
{
"answer_id": 137175,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 2,
"selected": true,
"text": "<p>I've tested your code on my system, and it works fine. I think that there's a mismatch between your compiler, and the comp... | 2008/09/26 | [
"https://Stackoverflow.com/questions/137089",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3114/"
] | I'm trying to use boost::signal to implement a callback mechanism, and I'm getting a memory access assert in the boost::signal code on even the most trivial usage of the library. I have simplified it down to this code:
```
#include <boost/signal.hpp>
typedef boost::signal<void (void)> Event;
int main(int argc, char*... | I've tested your code on my system, and it works fine. I think that there's a mismatch between your compiler, and the compiler that your Boost.Signals library is built on. Try to download the Boost source, and compile Boost.Signals using the same compiler as you use for building your code.
Just for my info, what compi... |
137,091 | <p>At my new workplace, they represent a lot of dates as "days since epoch" (which I will hereafter call DSE). I'm running into issues in JavaScript converting from DSE to seconds since epoch (UNIX timestamps). Here's my function to do the conversion:</p>
<pre><code>function daysToTimestamp(days) {
return Math.rou... | [
{
"answer_id": 137119,
"author": "pfranza",
"author_id": 22221,
"author_profile": "https://Stackoverflow.com/users/22221",
"pm_score": 2,
"selected": false,
"text": "<p>It is because it is neither a linear representation of time nor a true representation of UTC (though it is frequently m... | 2008/09/26 | [
"https://Stackoverflow.com/questions/137091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11577/"
] | At my new workplace, they represent a lot of dates as "days since epoch" (which I will hereafter call DSE). I'm running into issues in JavaScript converting from DSE to seconds since epoch (UNIX timestamps). Here's my function to do the conversion:
```
function daysToTimestamp(days) {
return Math.round(+days * 864... | It is because it is neither a linear representation of time nor a true representation of UTC (though it is frequently mistaken for both) as the times it represents are UTC but it has no way of representing UTC leap seconds
<http://en.wikipedia.org/wiki/Unix_time> |
137,092 | <p>I will soon be working on AJAX driven web pages that have a lot of content generated from a Web Service (WCF).</p>
<p>I've tested this sort of thing in the past (and found it easy) but not with this level of dynamic content.</p>
<p>I'm developing in .NET 3.5 using Visual Studio 2008. I envisage this testing in:</... | [
{
"answer_id": 137546,
"author": "Alan",
"author_id": 9916,
"author_profile": "https://Stackoverflow.com/users/9916",
"pm_score": 2,
"selected": false,
"text": "<p>Most automation frameworks have some synchronizationfunctions built in. Selenium is no exception, and includes functionality... | 2008/09/26 | [
"https://Stackoverflow.com/questions/137092",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21930/"
] | I will soon be working on AJAX driven web pages that have a lot of content generated from a Web Service (WCF).
I've tested this sort of thing in the past (and found it easy) but not with this level of dynamic content.
I'm developing in .NET 3.5 using Visual Studio 2008. I envisage this testing in:
1. TestDriven.NET
... | Most automation frameworks have some synchronizationfunctions built in. Selenium is no exception, and includes functionality like waitForText, waitForElementPresent,etc.
I just realized that you mentioned "waits" above, which I interpreted as Sleeps (which aren't good in automation). Let me know if I misinterpreted, a... |
137,114 | <p>Whats the best way to round in VBA Access?</p>
<p>My current method utilizes the Excel method</p>
<pre><code>Excel.WorksheetFunction.Round(...
</code></pre>
<p>But I am looking for a means that does not rely on Excel.</p>
| [
{
"answer_id": 137136,
"author": "inglesp",
"author_id": 10439,
"author_profile": "https://Stackoverflow.com/users/10439",
"pm_score": 2,
"selected": false,
"text": "<p>Int and Fix are both useful rounding functions, which give you the integer part of a number.</p>\n\n<p>Int always round... | 2008/09/26 | [
"https://Stackoverflow.com/questions/137114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3155/"
] | Whats the best way to round in VBA Access?
My current method utilizes the Excel method
```
Excel.WorksheetFunction.Round(...
```
But I am looking for a means that does not rely on Excel. | Be careful, the VBA Round function uses Banker's rounding, where it rounds .5 to an even number, like so:
```
Round (12.55, 1) would return 12.6 (rounds up)
Round (12.65, 1) would return 12.6 (rounds down)
Round (12.75, 1) would return 12.8 (rounds up)
```
Whereas the Excel Worksheet Function Round, always rou... |
137,147 | <p>For example</p>
<pre><code>int f(int a) {
...
return a > 10;
}
</code></pre>
<p>is that considered acceptable (not legal, I mean is it ``good code''), or should it always be in a conditional, like this</p>
<pre><code>int f(int a) {
...
if (a > 10)
return 1;
else
return 0;
}
</code... | [
{
"answer_id": 137152,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 5,
"selected": false,
"text": "<p>This is absolutely acceptable! In fact, Joel mentioned this on the latest stackoverflow podcast. He said it was the on... | 2008/09/26 | [
"https://Stackoverflow.com/questions/137147",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | For example
```
int f(int a) {
...
return a > 10;
}
```
is that considered acceptable (not legal, I mean is it ``good code''), or should it always be in a conditional, like this
```
int f(int a) {
...
if (a > 10)
return 1;
else
return 0;
}
``` | This is absolutely acceptable! In fact, Joel mentioned this on the latest stackoverflow podcast. He said it was the one thing he's had to show almost every programmer that starts at Fog Creek. |
137,181 | <p>I need to rebuild an apache server, but the original source is no longer available. Is there any way ( command line switch to httpd? ) to get the build options which were originally used?</p>
| [
{
"answer_id": 137200,
"author": "David Schlosnagle",
"author_id": 1750,
"author_profile": "https://Stackoverflow.com/users/1750",
"pm_score": 4,
"selected": true,
"text": "<p>Try -V which \"Print the version and build parameters of httpd, and then exit.\"</p>\n\n<pre><code>httpd -V\n</c... | 2008/09/26 | [
"https://Stackoverflow.com/questions/137181",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3839/"
] | I need to rebuild an apache server, but the original source is no longer available. Is there any way ( command line switch to httpd? ) to get the build options which were originally used? | Try -V which "Print the version and build parameters of httpd, and then exit."
```
httpd -V
```
Also, you can see the options for httpd via:
```
httpd -h
``` |
137,212 | <p>If you want a cryptographically strong random numbers in Java, you use <code>SecureRandom</code>. Unfortunately, <code>SecureRandom</code> can be very slow. If it uses <code>/dev/random</code> on Linux, it can block waiting for sufficient entropy to build up. How do you avoid the performance penalty?</p>
<p>Has any... | [
{
"answer_id": 137223,
"author": "Nick",
"author_id": 1490,
"author_profile": "https://Stackoverflow.com/users/1490",
"pm_score": 2,
"selected": false,
"text": "<p>I haven't hit against this problem myself, but I'd spawn a thread at program start which immediately tries to generate a see... | 2008/09/26 | [
"https://Stackoverflow.com/questions/137212",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3150/"
] | If you want a cryptographically strong random numbers in Java, you use `SecureRandom`. Unfortunately, `SecureRandom` can be very slow. If it uses `/dev/random` on Linux, it can block waiting for sufficient entropy to build up. How do you avoid the performance penalty?
Has anyone used [Uncommon Maths](https://uncommons... | If you want true random data, then unfortunately you have to wait for it. This includes the seed for a `SecureRandom` PRNG. Uncommon Maths can't gather true random data any faster than `SecureRandom`, although it can connect to the internet to download seed data from a particular website. My guess is that this is unlik... |
137,219 | <p>I am looking for the way to mount NTFS hard disk on FreeBSD 6.2 in read/write mode.</p>
<p>searching google, I found that NTFS-3G can be a help.</p>
<p>Using NTFS-3G, there is no problem when I try to mount/unmount NTFS manually:</p>
<p>mount: ntfs-3g /dev/ad1s1 /home/admin/data -o uid=1002,</p>
<p>or</p>
<p>um... | [
{
"answer_id": 137223,
"author": "Nick",
"author_id": 1490,
"author_profile": "https://Stackoverflow.com/users/1490",
"pm_score": 2,
"selected": false,
"text": "<p>I haven't hit against this problem myself, but I'd spawn a thread at program start which immediately tries to generate a see... | 2008/09/26 | [
"https://Stackoverflow.com/questions/137219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am looking for the way to mount NTFS hard disk on FreeBSD 6.2 in read/write mode.
searching google, I found that NTFS-3G can be a help.
Using NTFS-3G, there is no problem when I try to mount/unmount NTFS manually:
mount: ntfs-3g /dev/ad1s1 /home/admin/data -o uid=1002,
or
umount: umount /home/admin/data
But I h... | If you want true random data, then unfortunately you have to wait for it. This includes the seed for a `SecureRandom` PRNG. Uncommon Maths can't gather true random data any faster than `SecureRandom`, although it can connect to the internet to download seed data from a particular website. My guess is that this is unlik... |
137,221 | <p>I've searched around for a while today, but I haven't been able to come up with an AutoComplete TextBox code sample for Silverlight 2 Beta 2. The most promising reference was found on <a href="http://www.nikhilk.net/Silverlight-AutoComplete.aspx/" rel="nofollow noreferrer">nikhilk.net</a> but the online demo doesn'... | [
{
"answer_id": 137231,
"author": "Aaron Fischer",
"author_id": 5618,
"author_profile": "https://Stackoverflow.com/users/5618",
"pm_score": 1,
"selected": false,
"text": "<p>Take a look at the combobox(very close to a autocomplete text box) at worksight's blog <a href=\"http://worksightbl... | 2008/09/26 | [
"https://Stackoverflow.com/questions/137221",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4115/"
] | I've searched around for a while today, but I haven't been able to come up with an AutoComplete TextBox code sample for Silverlight 2 Beta 2. The most promising reference was found on [nikhilk.net](http://www.nikhilk.net/Silverlight-AutoComplete.aspx/) but the online demo doesn't currently render and after downloading ... | You may want to take a look at my blog: <http://weblogs.manas.com.ar/ary/2008/09/26/autocomplete-in-silverlight/>
You simply write in your XAML:
```
manas:Autocomplete.Suggest="DoSuggest"
```
and then in the class file, you need to implement that method, which report suggestions to a delegate. The options can be ha... |
137,227 | <p>How can I list all the types that are declared by a module in Ruby?</p>
| [
{
"answer_id": 137311,
"author": "Bruno Gomes",
"author_id": 8669,
"author_profile": "https://Stackoverflow.com/users/8669",
"pm_score": 6,
"selected": true,
"text": "<p>Use the <em>constants</em> method defined in the <em>Module</em> module. From the Ruby documentation:</p>\n\n<blockquo... | 2008/09/26 | [
"https://Stackoverflow.com/questions/137227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4883/"
] | How can I list all the types that are declared by a module in Ruby? | Use the *constants* method defined in the *Module* module. From the Ruby documentation:
>
> Module.constants => array
>
>
> Returns an array of the names of all
> constants defined in the system. This
> list includes the names of all modules
> and classes.
>
>
> p Module.constants.sort[1..5]
>
>
> produces:
... |
137,255 | <p>How can I determine if a remote drive has enough space for me to upload a given file using C# in .Net?</p>
| [
{
"answer_id": 137294,
"author": "Kepboy",
"author_id": 21429,
"author_profile": "https://Stackoverflow.com/users/21429",
"pm_score": 2,
"selected": false,
"text": "<p>Are you talking about mapping a network share to a logical drive on you computer?</p>\n\n<p>If so you can use DriveInfo.... | 2008/09/26 | [
"https://Stackoverflow.com/questions/137255",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22471/"
] | How can I determine if a remote drive has enough space for me to upload a given file using C# in .Net? | There are two possible solutions.
1. Call the Win32 function GetDiskFreeSpaceEx. Here is a sample program:
```
internal static class Win32
{
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
internal static extern bool GetDiskFreeSpaceEx(string drive, out long freeBytesForUser, out lon... |
137,258 | <p>Here's a common code pattern I have to work with:</p>
<pre><code>class foo {
public:
void InitMap();
void InvokeMethodsInMap();
static void abcMethod();
static void defMethod();
private:
typedef std::map<const char*, pMethod> TMyMap;
TMyMap m_MyMap;
}
void
foo::InitMap()
{
m_MyMap... | [
{
"answer_id": 137264,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 5,
"selected": true,
"text": "<p>Don't use <code>const char*</code> as the key for maps. That means the map is ordered by the addresses of the strings, not... | 2008/09/26 | [
"https://Stackoverflow.com/questions/137258",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22489/"
] | Here's a common code pattern I have to work with:
```
class foo {
public:
void InitMap();
void InvokeMethodsInMap();
static void abcMethod();
static void defMethod();
private:
typedef std::map<const char*, pMethod> TMyMap;
TMyMap m_MyMap;
}
void
foo::InitMap()
{
m_MyMap["abc"] = &foo::abcM... | Don't use `const char*` as the key for maps. That means the map is ordered by the addresses of the strings, not the contents of the strings. Use a `std::string` as the key type, instead.
`std::map` is not a hash table, it's usually implemented as a red-black tree, and elements are guaranteed to be ordered by some crit... |
137,260 | <p>I've been doing some mocking with RhinoMocks and it requires that mocked methods be made virtual. This is fine except we have a custom framework which contains the methods that I want to mock which are currently not marked as virtual.</p>
<p>I can't forsee any problem with making these methods virtual but I was won... | [
{
"answer_id": 137274,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 2,
"selected": false,
"text": "<ul>\n<li>If you have users that override your virtual methods you can't seal them again without breaking code.</li>\n<l... | 2008/09/26 | [
"https://Stackoverflow.com/questions/137260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/493/"
] | I've been doing some mocking with RhinoMocks and it requires that mocked methods be made virtual. This is fine except we have a custom framework which contains the methods that I want to mock which are currently not marked as virtual.
I can't forsee any problem with making these methods virtual but I was wondering wha... | Actually it can be very problematic if the method is not designed to be overridden and someone overrides it. In particular, never call a virtual method from a constructor. Consider:
```
class Base {
public Base() {
InitializeComponent();
}
protected virtual void InitializeComponent() {
...
... |
137,282 | <p><a href="http://en.wikipedia.org/wiki/Diamond_problem" rel="noreferrer">http://en.wikipedia.org/wiki/Diamond_problem</a></p>
<p>I know what it means, but what steps can I take to avoid it?</p>
| [
{
"answer_id": 137289,
"author": "eduffy",
"author_id": 7536,
"author_profile": "https://Stackoverflow.com/users/7536",
"pm_score": 4,
"selected": false,
"text": "<p>virtual inheritance. That's what it's there for.</p>\n"
},
{
"answer_id": 137317,
"author": "Bob Somers",
... | 2008/09/26 | [
"https://Stackoverflow.com/questions/137282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9825/"
] | <http://en.wikipedia.org/wiki/Diamond_problem>
I know what it means, but what steps can I take to avoid it? | A practical example:
```
class A {};
class B : public A {};
class C : public A {};
class D : public B, public C {};
```
Notice how class D inherits from both B & C. But both B & C inherit from A. That will result in 2 copies of the class A being included in the vtable.
To solve this, we need virtual inheritance. It... |
137,285 | <p>What is the best way to read an HTTP response from GetResponseStream ?</p>
<p>Currently I'm using the following approach.</p>
<pre><code>Using SReader As StreamReader = New StreamReader(HttpRes.GetResponseStream)
SourceCode = SReader.ReadToEnd()
End Using
</code></pre>
<p>I'm not quite sure if this is the most... | [
{
"answer_id": 137300,
"author": "Mitch Wheat",
"author_id": 16076,
"author_profile": "https://Stackoverflow.com/users/16076",
"pm_score": 4,
"selected": false,
"text": "<p>I use something like this to download a file from a URL:</p>\n\n<pre><code>if (!Directory.Exists(localFolder))\n{\n... | 2008/09/26 | [
"https://Stackoverflow.com/questions/137285",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | What is the best way to read an HTTP response from GetResponseStream ?
Currently I'm using the following approach.
```
Using SReader As StreamReader = New StreamReader(HttpRes.GetResponseStream)
SourceCode = SReader.ReadToEnd()
End Using
```
I'm not quite sure if this is the most efficient way to read an http re... | I use something like this to download a file from a URL:
```
if (!Directory.Exists(localFolder))
{
Directory.CreateDirectory(localFolder);
}
try
{
HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(Path.Combine(uri, filename));
httpRequest.Method = "GET";
// if the URI doesn't exist, a... |
137,313 | <p>I've been parsing through some log files and I've found that some of the lines are too long to display on one line so Terminal.app kindly wraps them onto the next line. However, I've been looking for a way to truncate a line after a certain number of characters so that Terminal doesn't wrap, making it much easier to... | [
{
"answer_id": 137323,
"author": "nobody",
"author_id": 19405,
"author_profile": "https://Stackoverflow.com/users/19405",
"pm_score": 5,
"selected": true,
"text": "<p>Pipe output to:</p>\n\n<pre><code>cut -b 1-LIMIT\n</code></pre>\n\n<p>Where LIMIT is the desired line width.</p>\n"
},
... | 2008/09/26 | [
"https://Stackoverflow.com/questions/137313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/658/"
] | I've been parsing through some log files and I've found that some of the lines are too long to display on one line so Terminal.app kindly wraps them onto the next line. However, I've been looking for a way to truncate a line after a certain number of characters so that Terminal doesn't wrap, making it much easier to sp... | Pipe output to:
```
cut -b 1-LIMIT
```
Where LIMIT is the desired line width. |
137,314 | <p>I've got a CAkePHP 1.2 site. I've got three related Models/tables:
A Comment has exactly one Touch, a Touch has exactly one Touchtype.</p>
<p>In each model, I have a belongs to, so I have
Comments belongs to Touch, Touch belongs to Touchtype.</p>
<p>I'm trying to get a list of comments that includes information ab... | [
{
"answer_id": 137323,
"author": "nobody",
"author_id": 19405,
"author_profile": "https://Stackoverflow.com/users/19405",
"pm_score": 5,
"selected": true,
"text": "<p>Pipe output to:</p>\n\n<pre><code>cut -b 1-LIMIT\n</code></pre>\n\n<p>Where LIMIT is the desired line width.</p>\n"
},
... | 2008/09/26 | [
"https://Stackoverflow.com/questions/137314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43/"
] | I've got a CAkePHP 1.2 site. I've got three related Models/tables:
A Comment has exactly one Touch, a Touch has exactly one Touchtype.
In each model, I have a belongs to, so I have
Comments belongs to Touch, Touch belongs to Touchtype.
I'm trying to get a list of comments that includes information about the touch sto... | Pipe output to:
```
cut -b 1-LIMIT
```
Where LIMIT is the desired line width. |
137,326 | <p>How do you embed a SWF file in an HTML page?</p>
| [
{
"answer_id": 137332,
"author": "Ólafur Waage",
"author_id": 22459,
"author_profile": "https://Stackoverflow.com/users/22459",
"pm_score": 7,
"selected": false,
"text": "<pre><code><object width=\"100\" height=\"100\">\n <param name=\"movie\" value=\"file.swf\">\n <... | 2008/09/26 | [
"https://Stackoverflow.com/questions/137326",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18309/"
] | How do you embed a SWF file in an HTML page? | The best approach to embed a SWF into an HTML page is to use [SWFObject](https://github.com/swfobject/swfobject/).
It is a simple open-source JavaScript library that is easy-to-use and standards-friendly method to embed Flash content.
It also offers Flash player version detection. If the user does not have the versio... |