qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
367,030 | <p>Is it possible to get a list of all descendant classes of a particular class in objective-c?</p>
<p>Something like:</p>
<pre><code> @interface A : NSObject
@end
@interface B : A
@end
@interface C : A
@end
NSArray *descendants = [A allDescendants]; // descendants = [B, C]
</code></pre>
| [
{
"answer_id": 367078,
"author": "Matt Gallagher",
"author_id": 36103,
"author_profile": "https://Stackoverflow.com/users/36103",
"pm_score": 3,
"selected": false,
"text": "objc_getClassList"
},
{
"answer_id": 367189,
"author": "Andy",
"author_id": 3857,
"author_profi... | 2008/12/14 | [
"https://Stackoverflow.com/questions/367030",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
367,040 | <p>In Matlab, how can I find value of K, in a system that has oscillation?</p>
<blockquote>
<p>(system's tf, if needed: (K * (s +
25))/(s^3 + 24 s^2 + 100 s) )</p>
</blockquote>
<p>PS. I'm using root locus.</p>
| [
{
"answer_id": 367215,
"author": "Will Robertson",
"author_id": 4161,
"author_profile": "https://Stackoverflow.com/users/4161",
"pm_score": 0,
"selected": false,
"text": "dcgain"
},
{
"answer_id": 425417,
"author": "Stephen Friederichs",
"author_id": 39492,
"author_pr... | 2008/12/14 | [
"https://Stackoverflow.com/questions/367040",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
367,052 | <p>There seems to be no built-in support for case preserving find/replace in VisualStudio (see also a respective <a href="https://developercommunity.visualstudio.com/t/case-preserving-search-replace/580810" rel="nofollow noreferrer">feature request</a>).</p>
<p>What I mean is: searching for 'BadJob' and replacing with 'GoodJob' would do the following replacements</p>
<pre><code>'badjob' -> 'goodjob'
'BadJob' -> 'GoodJob'
'badJob' -> 'goodJob'
'BADJOB' -> 'GOODJOB'
</code></pre>
<p>So I am looking for a macro/add-in which implements case preserving find/replace. And if none exists, what is a good starting point to write my own (preferably based on the built-in find/replace capabilities).</p>
<p>Update:<br />
I know I can make 4 manual replacements doing the job, but I am looking for a way to do it automatically in VS (like e.g. Emacs does it).
A common scenario: a variable named 'foo' and some functions DoFoo(), GetFoo(), ... and some additional comments containing 'foo' 'Foo' etc.
Now rename 'foo' to bar' yielding variable 'bar', functions DoBar(), GetBar() etc. by ONE find/replace.</p>
| [
{
"answer_id": 53559408,
"author": "noelicus",
"author_id": 865643,
"author_profile": "https://Stackoverflow.com/users/865643",
"pm_score": 0,
"selected": false,
"text": "from Npp import *\n\n#Use capitalizeFirst because .capitalize will make the remaining string lower, but in CamelCase ... | 2008/12/14 | [
"https://Stackoverflow.com/questions/367052",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45637/"
] |
367,066 | <p>I am developing an application trying to employ the Observer pattern. Basically I have a base form from which various components (forms) can be loaded.</p>
<p>The base form references each of the components and some of the components reference each other.</p>
<p>If I want one of the components to listen for events raised by the base form (perhaps from a menu etc) I can't seem to achieve this without needing to add a reference to the base form in the component. This causes a "circular reference".</p>
<p>Is it possible to listen/subscribe to events in projects which are not referenced?</p>
| [
{
"answer_id": 371855,
"author": "Nigel Hawkins",
"author_id": 1389021,
"author_profile": "https://Stackoverflow.com/users/1389021",
"pm_score": 0,
"selected": false,
"text": "publisherObject.SomeEvent += MyEventHandler();\n"
},
{
"answer_id": 377415,
"author": "Hinek",
"... | 2008/12/14 | [
"https://Stackoverflow.com/questions/367066",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
367,069 | <p>I'm looking for a simple, but cross-platform <em>negate</em>-process that negates the value a process returns. It should map 0 to some value != 0 and any value != 0 to 0, i.e. the following command should return "yes, nonexistingpath doesn't exist":</p>
<pre><code> ls nonexistingpath | negate && echo "yes, nonexistingpath doesn't exist."
</code></pre>
<p>The ! - operator is great but unfortunately not shell-independent.</p>
| [
{
"answer_id": 367075,
"author": "Jay Conrod",
"author_id": 1891,
"author_profile": "https://Stackoverflow.com/users/1891",
"pm_score": 6,
"selected": false,
"text": "! ls nonexistingpath && echo \"yes, nonexistingpath doesn't exist\"\n"
},
{
"answer_id": 367076,
"author": "E... | 2008/12/14 | [
"https://Stackoverflow.com/questions/367069",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4085/"
] |
367,090 | <p>I was intending on use the Title attribute in the @Page directive to customise each pages title, but it simply doesn't appear to do anything.</p>
<p>The site uses master pages - I don't know if that is a consideration.</p>
<p>Master Page snippet:</p>
<pre><code><%@ Master Language="VB" CodeFile="brightnorth.master.vb" Inherits="brightnorth" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="/css/style.css" />
</head>
<body>
etc....
</code></pre>
<p>Page snippet (from <a href="http://www.brightnorth.com/about/aboutus.aspx" rel="nofollow noreferrer">http://www.brightnorth.com/about/aboutus.aspx</a>):</p>
<pre><code><%@ Page Language="VB" MasterPageFile="~/brightnorth.master" AutoEventWireup="false" CodeFile="aboutus.aspx.vb" Inherits="about_aboutus" Title="Brightnorth.com: About Us" %>
</code></pre>
<p>What is more, if I run the page through the <a href="http://validator.w3.org/check?verbose=1&uri=http%3A%2F%2Fwww.brightnorth.com%2Fabout%2Faboutus.aspx" rel="nofollow noreferrer">validator</a>, it complains about... </p>
<blockquote>
<p>end tag for "head" which is not finished</p>
</blockquote>
<p>..whereas the the tag <em>is</em> present in the source code.</p>
<p>I've already got a workaround in place, but it's annoying the hell out of me, so I'm determined to find a resolution!</p>
| [
{
"answer_id": 367100,
"author": "Strelok",
"author_id": 2788,
"author_profile": "https://Stackoverflow.com/users/2788",
"pm_score": 0,
"selected": false,
"text": "<title><%=Title%></title>\n"
},
{
"answer_id": 367109,
"author": "CJM",
"author_id": 6898,
"author_profi... | 2008/12/14 | [
"https://Stackoverflow.com/questions/367090",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6898/"
] |
367,104 | <p>In java <1.5, constants would be implemented like this</p>
<pre><code>public class MyClass {
public static int VERTICAL = 0;
public static int HORIZONTAL = 1;
private int orientation;
public MyClass(int orientation) {
this.orientation = orientation;
}
...
</code></pre>
<p>and you would use it like this:</p>
<pre><code>MyClass myClass = new MyClass(MyClass.VERTICAL);
</code></pre>
<p>Now, in 1.5 obviously you should be using enums:</p>
<pre><code>public class MyClass {
public static enum Orientation {
VERTICAL, HORIZONTAL;
}
private Orientation orientation;
public MyClass(Orientation orientation) {
this.orientation = orientation;
}
...
</code></pre>
<p>and now you would use it like this:</p>
<pre><code>MyClass myClass = new MyClass(MyClass.Orientation.VERTICAL);
</code></pre>
<p>Which I find slightly ugly. Now I could easily add a couple of static variables:</p>
<pre><code>public class MyClass {
public static Orientation VERTICAL = Orientation.VERTICAL;
public static Orientation HORIZONTAL = Orientation.HORIZONTAL;
public static enum Orientation {
VERTICAL, HORIZONTAL;
}
private Orientation orientation;
public MyClass(Orientation orientation) {
this.orientation = orientation;
}
...
</code></pre>
<p>And now I can do this again:</p>
<pre><code>MyClass myClass = new MyClass(MyClass.VERTICAL);
</code></pre>
<p>With all the type-safe goodness of enums.</p>
<p>Is this good style, bad style or neither. Can you think of a better solution?</p>
<p><strong>Update</strong></p>
<p>Vilx- was the first one to highlight what I feel I was missing - that the enum should be a first-class citizen. In java this means it gets its own file in the package - we don't have namespaces. I had thought this would be a bit heavyweight, but having actually done it, it definitely feels right.</p>
<p>Yuval's answer is fine, but it didn't really emphasise the non-nested enum. Also, as for 1.4 - there are plenty of places in the JDK that use integers, and I was really looking for a way to evolve that sort of code.</p>
| [
{
"answer_id": 367105,
"author": "Yoni Roit",
"author_id": 34161,
"author_profile": "https://Stackoverflow.com/users/34161",
"pm_score": 2,
"selected": false,
"text": "MyClass myClass = new MyClass(Orientation.VERTICAL);\n"
},
{
"answer_id": 367113,
"author": "Vilx-",
"au... | 2008/12/14 | [
"https://Stackoverflow.com/questions/367104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26334/"
] |
367,115 | <p>I know of <code>python -c '<code>'</code>, but I'm wondering if there's a more elegant python equivalent to <code>perl -pi -e '<code>'</code>. I still use it quite a bit for things like find and replace in a whole directory (<code>perl -pi -e s/foo/bar/g *</code> or even <code>find . | xargs perl -pi -e s/foo/bar/g</code> for sub-directories).</p>
<p>I actually feel that that which makes Perl Perl (free form Tim Toady-ness) is what makes <code>perl -pi -e</code> work so well, while with Python you'd have to do something along the lines of importing the re module, creating an re instance and then capture stdin, but maybe there's a Python shortcut that does all that and I missed it (sorely missed it)...</p>
| [
{
"answer_id": 367181,
"author": "Jonathan Leffler",
"author_id": 15168,
"author_profile": "https://Stackoverflow.com/users/15168",
"pm_score": 4,
"selected": true,
"text": "python -h"
},
{
"answer_id": 367238,
"author": "S.Lott",
"author_id": 10661,
"author_profile":... | 2008/12/14 | [
"https://Stackoverflow.com/questions/367115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28421/"
] |
367,130 | <p>I want create a Playlist control. I have a lot of information to display into a TStringList. I want to assign a record to TStringGrid.Objects instead of an object because so many objects may take a while to create/destroy. It also take a lot of RAM.</p>
<p>A record will be much faster and slim.
How can I do that?</p>
<pre><code>TYPE
AMyRec= packed record
FullName : string[255];
RelativePath : boolean;
IsInvalid : boolean;
InCache : boolean;
etc
end;
</code></pre>
| [
{
"answer_id": 367147,
"author": "Cesar Romero",
"author_id": 36875,
"author_profile": "https://Stackoverflow.com/users/36875",
"pm_score": 1,
"selected": false,
"text": "List.AddObject(MyRecord.FullName, @MyRecord);\n"
},
{
"answer_id": 367156,
"author": "JamesSugrue",
"... | 2008/12/14 | [
"https://Stackoverflow.com/questions/367130",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
367,141 | <p>Using Win32-specific APIs, is there an easy way to start an external application to open a file simply by passing in the path/name of the file?</p>
<p>For example, say I have a file called C:\tmp\image.jpg. Is there a single API that I can call to tell Windows to open the application associated with .jpg files? Without having to do a bunch of registry lookups?</p>
<p>I thought I remembered doing this many years ago, but I cannot find it.</p>
| [
{
"answer_id": 367144,
"author": "Igal Serban",
"author_id": 25737,
"author_profile": "https://Stackoverflow.com/users/25737",
"pm_score": 5,
"selected": true,
"text": "HINSTANCE ShellExecute(\n _In_opt_ HWND hwnd,\n _In_opt_ LPCTSTR lpOperation,\n _In_ LPCTSTR lpFile,\n _In_o... | 2008/12/14 | [
"https://Stackoverflow.com/questions/367141",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13022/"
] |
367,155 | <p>I'm trying to split a string up into words and punctuation, adding the punctuation to the list produced by the split.</p>
<p>For instance:</p>
<pre><code>>>> c = "help, me"
>>> print c.split()
['help,', 'me']
</code></pre>
<p>What I really want the list to look like is:</p>
<pre><code>['help', ',', 'me']
</code></pre>
<p>So, I want the string split at whitespace with the punctuation split from the words.</p>
<p>I've tried to parse the string first and then run the split:</p>
<pre><code>>>> for character in c:
... if character in ".,;!?":
... outputCharacter = " %s" % character
... else:
... outputCharacter = character
... separatedPunctuation += outputCharacter
>>> print separatedPunctuation
help , me
>>> print separatedPunctuation.split()
['help', ',', 'me']
</code></pre>
<p>This produces the result I want, but is painfully slow on large files.</p>
<p>Is there a way to do this more efficiently?</p>
| [
{
"answer_id": 367244,
"author": "monkut",
"author_id": 24718,
"author_profile": "https://Stackoverflow.com/users/24718",
"pm_score": 1,
"selected": false,
"text": "import string\n\nd = \"Hello, I'm a string!\"\n\nresult = []\nword = ''\n\nfor char in d:\n if char not in string.whites... | 2008/12/14 | [
"https://Stackoverflow.com/questions/367155",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40429/"
] |
367,178 | <p>I think the answer to this question is so obivous that noone has bothered writing about this, but its late and I really can't get my head around this.</p>
<p>I've been reading into IoC containers (Windsor in this case) and I'm missing how you talk to the container from the various parts of your code.</p>
<p>I get DI, I've been doing poor mans DI (empty constructors calling overloaded injection constructors with default parameter implementations) for some time and I can completely see the benefit of the container. However, Im missing one vital piece of info; how are you supposed to reference the container every time you need a service from it?</p>
<p>Do I create a single global insance which I pass around? Surely not!</p>
<p>I know I should call this:</p>
<pre><code>WindsorContainer container = new WindsorContainer(new XmlInterpreter());
</code></pre>
<p>(for example) when I want to load my XML config, but then what do I do with container? Does creating a new container every time thereafter persist the loaded config through some internal static majicks or otherwise, or do I have to reload the config every time (i guess not, or lifecycles couldnt work).</p>
<p>Failing to understand this is preventing me from working out how the lifecycles work, and getting on with using some IoC awsomeness</p>
<p>Thanks,</p>
<p>Andrew</p>
| [
{
"answer_id": 367190,
"author": "maxnk",
"author_id": 45862,
"author_profile": "https://Stackoverflow.com/users/45862",
"pm_score": 0,
"selected": false,
"text": "public interface IResolver\n{\n object Resolve(Type type);\n object Resolve(string name);\n\n T Resolve<T>() where ... | 2008/12/14 | [
"https://Stackoverflow.com/questions/367178",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28543/"
] |
367,192 | <p>I know java and would normally put in getter/setter methods. I am interested in doing it in C# with the following code, but it throws a StackOverflow exception. What am I doing wrong?</p>
<p>Calling Code</p>
<pre><code>c.firstName = "a";
</code></pre>
<p>Property Code </p>
<pre><code>public String firstName;
{
get
{
return firstName;
}
set
{
firstName = value;
}
}
</code></pre>
| [
{
"answer_id": 367195,
"author": "Greg Beech",
"author_id": 13552,
"author_profile": "https://Stackoverflow.com/users/13552",
"pm_score": 8,
"selected": true,
"text": "set"
},
{
"answer_id": 367196,
"author": "Michael Haren",
"author_id": 29,
"author_profile": "https:... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367192",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/673/"
] |
367,201 | <p>I need to intercept the console output stream(s) in order to capture it for a log but still pass things through to the original stream so the application works properly. This obviously means storing the original <code>Console.Out</code> TextWriter before changing it with <code>Console.SetOut(new MyTextWriterClass(originalOut))</code>.</p>
<p>I assume the individual operations to get the Out property and to call the SetOut() method are implemented by <code>Console</code> in a thread-safe manner. But I'd like to make sure that some other thread (eg. running client application code that I don't control and can't expect to change, and so I can't rely on my own custom locking scheme) can't accidentally change it in between my get and set and end up getting overwritten by my change to it (breaking their application's behavior!). Since the other code may simply call SetOut(), my code should ideally get the same lock used internally by <code>Console</code> (assuming there is one).</p>
<p>Unfortunately, <code>Console</code> is a (static) class, not an instance, so you can't just <code>lock (Console)</code>. And looking in the class documentation there does not seem to be any mention of locking. This is not the normally-expected usage of these Console methods, but there should be some safe way of doing this as an atomic operation.</p>
<p>Failing a standard locking scheme, is there some other way to ensure this? For such a short critical section (and done only once), even momentarily blocking all other threads might be acceptable, if that's the only way to do it. We're using C# and .NET2.0.</p>
<p>If not even <em>that</em> is possible (without disrupting the client application), then we'll just have to rely on it being very unlikely that the client application would redirect its console output <i>and</i> happen to do it in between our get and set operations. I'd just like to cover all the bases, just in case.</p>
<p><strong>Edit</strong>: Now that we have a concrete answer with example code, I've reworded the question title to more generally reflect the use cases where the answer(s) can help, to be more clear. Also, added a tag for "atomic".</p>
| [
{
"answer_id": 367428,
"author": "devstuff",
"author_id": 41321,
"author_profile": "https://Stackoverflow.com/users/41321",
"pm_score": 0,
"selected": false,
"text": "Main()"
},
{
"answer_id": 368584,
"author": "JoshBerke",
"author_id": 26160,
"author_profile": "https... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367201",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/181460/"
] |
367,213 | <p>Is there a way to find the HTML element on the page that a Silverlight control is hosted in from within Silverlight?</p>
| [
{
"answer_id": 367638,
"author": "Boyan",
"author_id": 38106,
"author_profile": "https://Stackoverflow.com/users/38106",
"pm_score": 3,
"selected": true,
"text": "System.Windows.Browser.HtmlElement plugin = System.Windows.Browser.HtmlPage.Plugin;\n"
}
] | 2008/12/15 | [
"https://Stackoverflow.com/questions/367213",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11829/"
] |
367,214 | <p>Consider two web pages with the following in their body respectively:</p>
<pre><code><body>
<script>
document.writeln('<textarea></textarea>')
</script>
</body>
</code></pre>
<p>and</p>
<pre><code><body>
<script>
var t = document.createElement('textarea');
document.body.appendChild(t);
</script>
</body>
</code></pre>
<p>(think of them as part of something larger, where the textareas <em>have</em> to be generated from JavaScript and can't be hard-coded into the page). They both produce the same output, but the former is considered "bad", while the latter is considered the "right" way to do it. (Right?)</p>
<p>On the other hand, if you type something in the page and then either refresh it, or go somewhere else and hit Back, then in the former case, what you typed in the textarea is preserved, while in the later it is lost. (At least on Firefox.)</p>
<p>Is there a way to use the latter method and still have the useful feature that what the user has typed into a form is saved even if they accidentally hit refresh or come back via the Back button (at least on Firefox)?</p>
| [
{
"answer_id": 367982,
"author": "roborourke",
"author_id": 42147,
"author_profile": "https://Stackoverflow.com/users/42147",
"pm_score": 0,
"selected": false,
"text": "<div id=\"addtextarea\"></div>\n\nvar e = document.getElementByID('addtextarea');\ne.innerHTML = '<textarea></textarea>... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367214",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4958/"
] |
367,216 | <p>Does using STL increase footprint significantly? Could you guys share your experience regarding this matter? What are the best practices to build a small footprint library?</p>
| [
{
"answer_id": 367296,
"author": "Tom",
"author_id": 40620,
"author_profile": "https://Stackoverflow.com/users/40620",
"pm_score": 2,
"selected": false,
"text": "std::list<int>"
},
{
"answer_id": 367303,
"author": "Martin York",
"author_id": 14065,
"author_profile": "... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367216",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
367,219 | <p>I'm currently getting through the <a href="http://www.cplusplus.com" rel="nofollow noreferrer">http://www.cplusplus.com</a> tutorial and I came across this section here: <a href="http://www.cplusplus.com/doc/tutorial/inheritance.html" rel="nofollow noreferrer">http://www.cplusplus.com/doc/tutorial/inheritance.html</a> that deals with the subject of <em>friend functions</em> and <em>friend classes</em> in C++. </p>
<p>My question is, when When is it prudent to use friendship when creating a program? </p>
<p>The only clue I got was in an example inside of the article that demonstrated a friend function that 'duplicated' an object. </p>
| [
{
"answer_id": 367313,
"author": "Tom",
"author_id": 40620,
"author_profile": "https://Stackoverflow.com/users/40620",
"pm_score": 2,
"selected": false,
"text": "BigNum"
}
] | 2008/12/15 | [
"https://Stackoverflow.com/questions/367219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
367,226 | <p>Its the weekend again, and that means I get to play with my <a href="https://stackoverflow.com/questions/332585/2d-platformer-physics">hobby project</a>.</p>
<p>I've gotten tired of creating test levels by hand, so I thought I'd take a break from engine development and work on a level editor:</p>
<p><a href="http://gfilter.net/junk/Editor.JPG" rel="nofollow noreferrer">Level Editor http://gfilter.net/junk/Editor.JPG</a></p>
<p>I'd like to implement a flood fill algorithm in the editor, which would work just like in a paint program. Does anyone have any pointers on what technique would work good for me here?</p>
<p>The level is just a 2d array, so it could be considered the same as a bitmap really.</p>
<p>Thanks!</p>
| [
{
"answer_id": 367235,
"author": "AAA",
"author_id": 1977,
"author_profile": "https://Stackoverflow.com/users/1977",
"pm_score": 2,
"selected": false,
"text": "Select Tile To Fill: \nFill Till \nCheck neighbouring Tiles - If Empty Then Fill \nRepeat, for all filled tiles.\n"
}... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367226",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] |
367,257 | <p>I've taken over a mixed PHP4/PHP5 project which has been handed down from developer to developer, with each one making things worse. Before I spend too much time on it I'd like to develop a base-standard, with consistent formatting at a minimum.</p>
<p>Can anyone recommend a utility (Linux or Mac OS X preferably) that will reformat the code?</p>
<p>If I can set parameters which influence output (like tab-indentation, brace/bracket placement, when to split array values onto new lines etc.) then that's a benefit, though not crucial.</p>
<p>Preference goes to Open Source tools, though I'd like to know your experiences with purchased software too.</p>
| [
{
"answer_id": 9628910,
"author": "mlambie",
"author_id": 17453,
"author_profile": "https://Stackoverflow.com/users/17453",
"pm_score": 1,
"selected": false,
"text": "gg=G\n"
}
] | 2008/12/15 | [
"https://Stackoverflow.com/questions/367257",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17453/"
] |
367,262 | <p>I need to make some commits using Git but I would like the timestamp in git-log to be in the future.</p>
<p>How can I do a commit in git that causes a future timestamp to register in the git-log?</p>
| [
{
"answer_id": 367475,
"author": "Dustin",
"author_id": 39975,
"author_profile": "https://Stackoverflow.com/users/39975",
"pm_score": 7,
"selected": true,
"text": "/tmp/x 604% env GIT_AUTHOR_DATE='Wed Dec 19 15:14:05 2029 -0800' git commit -m 'future!'\n[master]: created 6348548: \"Futur... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367262",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
367,276 | <p>I seem to not understand two OOP concepts very well. Could you explain what <strong>abstraction</strong> and <strong>polymorphism</strong> are, preferably with real examples and code?</p>
<p>Thank you.</p>
| [
{
"answer_id": 367289,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 5,
"selected": false,
"text": "class fraction:\n int denominator\n int numerator\n"
},
{
"answer_id": 367306,
"author": ... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367276",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1602746/"
] |
367,278 | <p>I'm a fan of SVN and I am comfortable setting up my own svn repository, but I'm wondering if there are better options than creating a separate repository.</p>
<p>Basically I'm just looking for a way to keep track of or roll back changes before my code is reviewed and checked in to the main repository (SourceSafe). </p>
<p>Note: I can't control which version control system we use (would prefer svn or svk), so stuck with SourceSafe for the main repository.</p>
| [
{
"answer_id": 367302,
"author": "Jörg W Mittag",
"author_id": 2988,
"author_profile": "https://Stackoverflow.com/users/2988",
"pm_score": 3,
"selected": false,
"text": "cd $PROJECT"
}
] | 2008/12/15 | [
"https://Stackoverflow.com/questions/367278",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46225/"
] |
367,282 | <p>I have a content management application in the root of my website, and I'm trying to use a different app (a billing application) under a sub-folder. Unfortunately, the web.config of the root site is interfering with the sub-app.</p>
<p>Is there a way to just disable web.config inheritance for a sub-folder?</p>
<p><strong>Update:</strong>
As linked by <a href="https://stackoverflow.com/users/31474/stephen-b-burris-jr">Stephen Burris</a>, using the <code><location></code> tag can prevent inheritance for part of the web config, as follows:</p>
<pre><code><?xml version="1.0"?>
<configuration>
<configSections>
....
</configSections>
<location path="." inheritInChildApplications="false">
<appSettings>
....
</appSettings>
<connectionStrings/>
<system.web>
....
</system.web>
<system.codedom>
....
</system.codedom>
<system.webServer>
....
</system.webServer>
</location>
<runtime>
....
</runtime>
</configuration>
</code></pre>
<p>The <code><configSections></code> and <code><runtime></code> sections will not accept being enclosed in the tag...so I guess this only does most of the job. Anybody know how to do it better?</p>
| [
{
"answer_id": 367372,
"author": "devstuff",
"author_id": 41321,
"author_profile": "https://Stackoverflow.com/users/41321",
"pm_score": 3,
"selected": false,
"text": "<clear />"
},
{
"answer_id": 367403,
"author": "SBurris",
"author_id": 31474,
"author_profile": "http... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23276/"
] |
367,308 | <p>I'm working on a project where there is a lot of external service messaging. A good way to describe it in only a slightly "hyperbolas" way would be an application where the system has to send messages to the Flicker API, the Facebook API, and the Netflix API.</p>
<p>To support disconnected scenarios, logging concerns, developer usability, configuration, etc... I've experimented using an approach which heavily uses generics and expression trees. The end result looks like this:</p>
<pre><code>Messenger<NetflixApi>.SendCustom( netflix => netflix.RecommendMovie("my message"));
</code></pre>
<p>Overall I'm happy with the end result but feel like I've made a mistake, or overlooked a design principal someplace with regards to testing and disconnected scenarios.</p>
<p>During testing, whether automated, unit, or human based, I've implemented an object factory that initially uses DI to perform the correct action in "Live mode" and used Mocks to provide a sort of sterile messenger that doesn't do anything at all when in a testing mode.</p>
<p>I've only seen or read about Mocks being used in pure TDD mode and not being used to be sort of a dumb object. The approaches I've seen would revolve around stubbing or mocking out the HTTP communication functionality which all the APIs I'm using depend on. </p>
<p>My main concern is that will all the different services I expect to connect to I'd end up having to do a lot of granular work substituting specific HTTP implementation and if I used a stub approach I'd have 3 classes for each of these services( IService, ConcreteService, StubService ) and maintaining those when implementing a new method or changing anything would be a real PITA.</p>
<p>In the current implementation I'm using Mocks to get "sterile mode" for free almost without having to implement anything extra just to conform to a certain testing principal. </p>
<p>The question is am I missing something? Did I violate a design principal using Mocks in a more... convenient way?</p>
<p>Can anybody offer any advice on how to get a sterile mode out of many different outside services without jumping through a lot of hoops?</p>
<p>Does this question make sense? </p>
<p>Thanks for all the answers.</p>
<p>Edit #1:</p>
<p>I wasn't clear in my original question. Any null or mock objects are to be used purely in a development/debug/testing environment. In production the code that sends these messages will be the actual implementation of them.</p>
<p>I voted everybody up because there seem to be a lot of different solutions to this problem and I'll be exploring each one. </p>
<p>Please don't think this question has been answered yet, I'd appreciate as much advice as I can get.</p>
| [
{
"answer_id": 367543,
"author": "NicoGranelli",
"author_id": 451623,
"author_profile": "https://Stackoverflow.com/users/451623",
"pm_score": 4,
"selected": true,
"text": "class Logger{\n private static ILogger _Logger;\n\n static Logger(){\n //DI injection here\n _Logger = new NullLog... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367308",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25300/"
] |
367,310 | <p>I'm working on an embedded processor (400 MHz Intel PXA255 XScale), and I thought I saw one case where there wasn't enough memory to satisfy a 'new' operation. The program didn't crash, so I assumed other threads had freed their memory and it was just a transient thing. This is some pretty critical code, so exiting is not an option, and some sort of error needs to be returned to the remote user.</p>
<p>Would the following small fix be enough to solve the problem, or is there a better way? Before replacing every 'new' with the following code, I thought I'd ask.</p>
<pre><code>char someArr[];
do{
someArr = new char[10];
Sleep(100); // no justification for choosing 100 ms
} while ( someArr == NULL );
</code></pre>
<p>Does the Sleep help? Should I set some max number of retries? Is it possible to use static initialization everywhere?</p>
<p><strong>FINAL UPDATE:</strong> Thank you very much for the helpful responses, but it turns out there was an error in the code checking for failed memory allocation. I will keep all of these answers in mind, and replace as many malloc's and new's as I can, though (especially in error-handling code).</p>
| [
{
"answer_id": 395953,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 1,
"selected": false,
"text": "void my_new_handler() {\n // make room for memory, then return, or throw bad_alloc if\n // nothing ca... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367310",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34910/"
] |
367,325 | <p>Here is an interesting piece of code that my fellow team members were just having a slightly heated discussion about...</p>
<pre><code> Dim fred As Integer
If True Then fred = 5 : fred = 3 : fred = 6 Else fred = 4 : fred = 2 : fred = 1
</code></pre>
<p>After executing the above code snippet, what is the value of <em>fred</em>?</p>
<p>Try not to cheat and debug the code.</p>
<p>This is a highly contrived code example that started out as an example of using the colon with an If statement, but then someone decided to take it upon themselves to proffer a result for <em>fred</em>.</p>
<p><strong>UPDATE</strong>:
I would not normally write code like this and this snippet only serves as an example. As it so happens, this question originated from a discussion involving the creation of a coding standards document for our team.</p>
| [
{
"answer_id": 367342,
"author": "user21826",
"author_id": 21826,
"author_profile": "https://Stackoverflow.com/users/21826",
"pm_score": 0,
"selected": false,
"text": "\nif (condition) then\n statement\n statement\nelse\n statement\n statement\nend if\n"
},
{
"answer_id": 367... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367325",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19377/"
] |
367,328 | <p>I received a dump file of a SVN repository that I'm moving to my server. Let's call it myserver.com/svn. The load statement prints out a long list of files loaded and reports no error. However, once I try to access the repository for checkout, or relocate my existing checkout, I'm told:</p>
<pre><code>Repository moved temporarily to 'http://www.myserver.com/svn'; please relocate
</code></pre>
<p>In other words, my new repository reports that it has temporarily moved to itself. How do I get past that? I can't find anything about this message in documentation about the svnadmin load command.</p>
| [
{
"answer_id": 1118406,
"author": "kikito",
"author_id": 312586,
"author_profile": "https://Stackoverflow.com/users/312586",
"pm_score": 0,
"selected": false,
"text": "ErrorDocument 404 http://www.myserver.com/svn\n"
}
] | 2008/12/15 | [
"https://Stackoverflow.com/questions/367328",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28565/"
] |
367,343 | <p>I have the following code:</p>
<pre><code>abstract class AbstractParent {
function __construct($param) { print_r($param); }
public static function test() { return new self(1234); }
}
class SpecificClass extends AbstractParent {}
</code></pre>
<p>When I invoke <code>SpecificClass::test()</code>, I am getting an error:</p>
<pre>Fatal error: Cannot instantiate abstract class AbstractParent</pre>
<p>So what I basically want is just to let <code>AbstractParent</code>'s <code>test()</code> instantiate class where this <code>test()</code> was called from (so, in my example, instantiate <code>SpecificClass</code>).</p>
| [
{
"answer_id": 367357,
"author": "Alexei Tenitski",
"author_id": 45508,
"author_profile": "https://Stackoverflow.com/users/45508",
"pm_score": 2,
"selected": false,
"text": "abstract class AbstractParent {\n function __construct($param) { print_r($param); }\n abstract public static funct... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367343",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45652/"
] |
367,349 | <p>How do you submit from a dropdownlist "onchange" event from inside of an ajax form?</p>
<p>According to the following question: <a href="https://stackoverflow.com/questions/364505/how-do-you-submit-a-dropdownlist-in-aspnet-mvc">How do you submit a dropdownlist in asp.net mvc</a>, from inside of an Html.BeginFrom you can set onchange="this.form.submit" and changing the dropdown posts back.</p>
<p>However, using the following code (inside an Ajax.BeginFrom):</p>
<pre><code><% using (Ajax.BeginForm("UpdateForm", new AjaxOptions() { UpdateTargetId = "updateText" })) { %>
<h2>Top Authors</h2>
Sort by:&nbsp;<%=Html.DropDownList("sortByList", new SelectList(ViewData["SortOptions"], new { onchange = "this.form.submit()" })%>
<%= Html.TextBox("updateText")%>
<% } %>
</code></pre>
<p>Posts back to the controller action, but the entire page is replaced with the contents of the "updateText" text, rather than just what is inside the "updateText" textbox.</p>
<p>Thus, rather than replacing just the area inside the Ajax.BeginForm, the entire page is replaced.</p>
<p>What is the correct way for the dropdownlist to call this.form.submit such that only the area inside the Ajax.BeginForm?</p>
| [
{
"answer_id": 367401,
"author": "Strelok",
"author_id": 2788,
"author_profile": "https://Stackoverflow.com/users/2788",
"pm_score": 2,
"selected": false,
"text": "$(\"#yourDropdown\").change(function() {\n var f = $(\"#yourForm\");\n var action = f.attr(\"action\");\n var serializedF... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367349",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
367,368 | <p>Is it possible to set a symbol for conditional compilation by setting up properties in an Xcode project?</p>
<p>My aim is to to create a symbol that is available to all files, without having to use import/include, so that a set of common classes can have a special behavior in some projects. Like the following, but with my own symbols.</p>
<pre><code>#if TARGET_IPHONE_SIMULATOR
...
#endif
</code></pre>
| [
{
"answer_id": 367430,
"author": "Ben Gottlieb",
"author_id": 6694,
"author_profile": "https://Stackoverflow.com/users/6694",
"pm_score": 8,
"selected": true,
"text": "GCC_PREPROCESSOR_DEFINITIONS"
},
{
"answer_id": 1384658,
"author": "hEADcRASH",
"author_id": 169138,
... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367368",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36182/"
] |
367,377 | <p>Suppose you have a software package. You want to make it a gem, because gems are the de facto standard way to distribute anything in the Ruby world. Gems are great -- for libraries. But for real applications, the Rubygems system seems lacking. Only "recently" did they introduce a way to mark executables to be placed in somewhere in the system wide executable PATH. Unfortunately, Ruby gems still seems to be wanting in other aspects of software packaging, namely putting configuration files in places like /etc, or documentation under /usr/share/doc. Or is it? My question is:</p>
<p>Can I put instructions or code in a gemspec to have configuration installed into /etc, and documentation under some sensible, standardized place (like /usr/share/doc)? Or perhaps, as a workaround, can a post-install script be run to do these things?</p>
<p>For reference: <a href="http://www.rubygems.org/read/book/4" rel="nofollow noreferrer">the GemSpec specification</a>.</p>
<p>Note that rubygems.org is down at the time of this writing. Here's the Google cache of that page: <a href="http://74.125.95.132/search?q=cache:JwJO6slR4BwJ:www.rubygems.org/read/chapter/20+http://www.rubygems.org/read/chapter/20%23page85&hl=en&ct=clnk&cd=1" rel="nofollow noreferrer">http://74.125.95.132/search?q=cache:JwJO6slR4BwJ:www.rubygems.org/read/chapter/20+http://www.rubygems.org/read/chapter/20%23page85&hl=en&ct=clnk&cd=1</a></p>
<p>If you examine <a href="http://rubygems.rubyforge.org/svn/trunk/lib/rubygems/specification.rb" rel="nofollow noreferrer">the specification.rb file in the repo</a>, and scroll down towards the end (search for ":section: Required gemspec attributes"), you can see what appear to be the currently supported attributes. I see nothing in there that looks like what I want.</p>
| [
{
"answer_id": 367430,
"author": "Ben Gottlieb",
"author_id": 6694,
"author_profile": "https://Stackoverflow.com/users/6694",
"pm_score": 8,
"selected": true,
"text": "GCC_PREPROCESSOR_DEFINITIONS"
},
{
"answer_id": 1384658,
"author": "hEADcRASH",
"author_id": 169138,
... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367377",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28558/"
] |
367,378 | <p>I'm creating my own dictionary and I am having trouble implementing the <a href="http://msdn.microsoft.com/en-us/library/ms132143(VS.85).aspx" rel="noreferrer">TryGetValue</a> function. When the key isn't found, I don't have anything to assign to the out parameter, so I leave it as is. This results in the following error: "The out parameter 'value' must be assigned to before control leaves the current method"</p>
<p>So, basically, I need a way to get the default value (0, false or nullptr depending on type). My code is similar to the following:</p>
<pre><code>class MyEmptyDictionary<K, V> : IDictionary<K, V>
{
bool IDictionary<K, V>.TryGetValue (K key, out V value)
{
return false;
}
....
}
</code></pre>
| [
{
"answer_id": 367380,
"author": "Strelok",
"author_id": 2788,
"author_profile": "https://Stackoverflow.com/users/2788",
"pm_score": 3,
"selected": false,
"text": "return default(int);\n\nreturn default(bool);\n\nreturn default(MyObject);\n"
},
{
"answer_id": 367383,
"author"... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367378",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4891/"
] |
367,400 | <p>Lately I've been seeing a lot of talk regarding PHP's lack of late static binding until 5.3. </p>
<p>From what I've read proper implementations of stuff like ActiveRecord are not possible until the language has this feature.</p>
<p>So, I'm curious about:</p>
<ul>
<li>Which languages do support it,
specifically those commonly
associated with web development such
as Python, Ruby, Perl, Java, C#,
(JavaScript?).</li>
<li>Which actually make use of it on a
regular basis?</li>
</ul>
| [
{
"answer_id": 367410,
"author": "Eugene Yokota",
"author_id": 3827,
"author_profile": "https://Stackoverflow.com/users/3827",
"pm_score": -1,
"selected": false,
"text": "class A {\n static $word = \"hello\";\n static function hello() {print self::$word;}\n}\n\nclass B extends A {\... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41111/"
] |
367,411 | <p>When discussing the evolution of computer languages, Alan Kay says that the single most important attribute of his Smalltalk is late binding; it gives the language its malleability and extensibility, and allows inappropriate coupling to be refactored out over time. Do you agree? Are there compensating advantages for early binding that explain why it seems to be the dominant of the two paradigms for domains where either could be used?</p>
<p>My personal experience (which is not broad or deep enough to be authoritative), based on implement web applications with javascript, jQuery, jsext, actionscript, php, java, RoR and asp.net seems to suggest a positive correlation between late binding and bloat reduction. Early binding I'm sure helps detect and prevent some typesafety errors, but so do autocompletion and a good IDE, and good programming practices in general. So I tend to catch myself rooting for the late binding side, before my risk-avoidance side restores my rational perspective.</p>
<p>But I really don't have a good sense for how to balance the tradeoffs.</p>
| [
{
"answer_id": 368276,
"author": "Peter Gfader",
"author_id": 35693,
"author_profile": "https://Stackoverflow.com/users/35693",
"pm_score": 2,
"selected": false,
"text": "var excel = CreateObject(\"Excel.Application\");\n"
}
] | 2008/12/15 | [
"https://Stackoverflow.com/questions/367411",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31641/"
] |
367,426 | <p>This is a total newbie question, so thanks in advance. I'm trying to get my head around the difference between divs and spans, and when and how to use them.</p>
<p>Say for instance, I want to have an image left justified, and I want the text to flow around the image on the right, while maintaining justification. If the text flows past the image, I want it to wrap around the bottom of the image...same as what we call in the layout world, "wrap".</p>
<p>I'm looking for an example to reference, so in your answer can you provide an example of the mark up?</p>
<p>Huge Thanks!!!</p>
| [
{
"answer_id": 367434,
"author": "Elle H",
"author_id": 23666,
"author_profile": "https://Stackoverflow.com/users/23666",
"pm_score": 2,
"selected": false,
"text": "<img src=\"picture.jpg\" alt=\"An image\" style=\"float: left\" />\nLorem ipsum dolor sit amet, consectetur adipiscing elit... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39781/"
] |
367,440 | <p>I want to create an associative array:</p>
<pre><code>var aa = {} // Equivalent to Object(), new Object(), etc...
</code></pre>
<p>And I want to be sure that any key I access is going to be a number:</p>
<pre><code>aa['hey'] = 4.3;
aa['btar'] = 43.1;
</code></pre>
<p>I know JavaScript doesn't have typing, so I can't automatically check this, but I can ensure in my own code that I only assign strings to this <code>aa</code>.</p>
<p>Now I'm taking keys from the user. I want to display the value for that key. However, if the user gives me something like "toString", the user gets back a function, not an int! Is there a way to make sure any string the user gives me is only something I define?</p>
<p>Is the only solution something like the following?</p>
<pre><code>delete aa['toString'];
delete aa['hasOwnProperty'];
</code></pre>
<p>etc...</p>
| [
{
"answer_id": 367453,
"author": "Moss Collum",
"author_id": 13210,
"author_profile": "https://Stackoverflow.com/users/13210",
"pm_score": 2,
"selected": false,
"text": "function findNumber(userEnteredKey) {\n return aa[userEnteredKey];\n}\n"
},
{
"answer_id": 367454,
"aut... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367440",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15055/"
] |
367,442 | <p>I've been trying to use Zsh within my emacs session, without emacs remapping all the Zsh keys. I found ansi-term works pretty well for this but, I'm still having some problems. I was getting lots of junk characters outputted with, I was able to fix it with:</p>
<pre><code>## Setup proper term information for emacs ansi-term mode
[[ $TERM == eterm-color ]] && export TERM=xterm
</code></pre>
<p>But everything still doesn't work perfectly. Now I am having trouble with output being drawn offscreen , especially when using something like C-r for search.</p>
<p>What I found is that it works fine if you don't resize the window. I can reproduce it like:</p>
<ol>
<li>Launch a clean <code>emacs -q</code></li>
<li>Start <code>ansi-term</code> and use <code>zsh</code></li>
<li>Make window fullscreen</li>
<li>Output something that fills the screen</li>
<li>Type <kbd>C-r</kbd></li>
<li>The prompt will be off the screen</li>
</ol>
<p>Maybe there is some way I can make the space between the output and the minibuffer larger to compensate for the overshoot?</p>
<p>Anyone else have Zsh + Ansi-term working properly?</p>
| [
{
"answer_id": 369938,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "(custom-set-variables\n '(fringe-mode nil nil (fringe))\n '(fringes-outside-margins t t))\n"
},
{
"answer_id": 2879086... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367442",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
367,444 | <p>I need to show an object in PropertyGrid with the following requirements: the object and its sub object must be read-only, able to activate PropertyGrid's CollectionEditors.</p>
<p>I found a sample that's closely match to what I need but there's an unexpected behaviour I couldn't figure out. I have more than one PropertyGrids each for different objects. In SetBrowsablePropertiesAsReadOnly, I loop one object but suprisingly all of PropertyGrids in my project become readonly. Can anybody help me out. Here's the code:</p>
<pre><code>
Imports System.Reflection
Imports System.ComponentModel
Public Class PropertyGridEx
Inherits PropertyGrid
Private isReadOnly As Boolean
Public Property [ReadOnly]() As Boolean
Get
Return Me.isReadOnly
End Get
Set(ByVal value As Boolean)
Me.isReadOnly = value
Me.SetBrowsablePropertiesAsReadOnly(Me.SelectedObject, value)
End Set
End Property
Protected Overloads Sub OnSelectedObjectsChanged(ByVal e As EventArgs)
Me.SetBrowsablePropertiesAsReadOnly(Me.SelectedObject, Me.isReadOnly)
MyBase.OnSelectedObjectsChanged(e)
End Sub
Private Sub SetBrowsablePropertiesAsReadOnly(ByRef selectedObject As Object, ByVal isReadOnly As Boolean)
If selectedObject IsNot Nothing Then
Dim props As PropertyDescriptorCollection = TypeDescriptor.GetProperties(selectedObject)
For Each propDescript As PropertyDescriptor In props
If propDescript.IsBrowsable AndAlso propDescript.PropertyType.GetInterface("ICollection", True) Is Nothing Then
Dim attr As ReadOnlyAttribute = TryCast(propDescript.Attributes(GetType(ReadOnlyAttribute)), ReadOnlyAttribute)
If attr IsNot Nothing Then
Dim field As FieldInfo = attr.[GetType]().GetField("isReadOnly", BindingFlags.NonPublic Or BindingFlags.Instance)
field.SetValue(attr, isReadOnly, BindingFlags.NonPublic Or BindingFlags.Instance, Nothing, Nothing)
End If
End If
Next
End If
End Sub
End Class
</code></pre>
| [
{
"answer_id": 369938,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "(custom-set-variables\n '(fringe-mode nil nil (fringe))\n '(fringes-outside-margins t t))\n"
},
{
"answer_id": 2879086... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367444",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
367,448 | <p>I'm using the following code within a VB 6.0 application to allow give the application a system tray icon:</p>
<pre><code>Option Explicit
'user defined type required by Shell_NotifyIcon API call
Public Type NOTIFYICONDATA
cbSize As Long
hwnd As Long
uId As Long
uFlags As Long
uCallBackMessage As Long
hIcon As Long
szTip As String * 64
End Type
'constants required by Shell_NotifyIcon API call:
Public Const NIM_ADD = &H0
Public Const NIM_MODIFY = &H1
Public Const NIM_DELETE = &H2
Public Const NIF_MESSAGE = &H1
Public Const NIF_ICON = &H2
Public Const NIF_TIP = &H4
Public Const WM_MOUSEMOVE = &H200
Public Const WM_LBUTTONDOWN = &H201 'Button down
Public Const WM_LBUTTONUP = &H202 'Button up
Public Const WM_LBUTTONDBLCLK = &H203 'Double-click
Public Const WM_RBUTTONDOWN = &H204 'Button down
Public Const WM_RBUTTONUP = &H205 'Button up
Public Const WM_RBUTTONDBLCLK = &H206 'Double-click
Public Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
Public nid As NOTIFYICONDATA
</code></pre>
<p>I want the application to minimize to the system tray when you click the Window's X to close it. I accomplish this with the following code in the form's QueryUnload event:</p>
<pre><code>Me.WindowState = vbMinimized
Me.Hide
</code></pre>
<p>In the form's Unload event I do the following:</p>
<pre><code>Shell_NotifyIcon NIM_DELETE, nid
</code></pre>
<p>The PROBLEM is that when I shut down the operating system and Windows sends the WM_CLOSE message to the app, QueryUnload is being fired but apparently not the Unload event, since Windows prompts me that it wants to end my task. </p>
<p>Any ideas on how to get the application to close gracefully on Windows shutdown?</p>
<p>Thanks</p>
| [
{
"answer_id": 367463,
"author": "JFV",
"author_id": 1391,
"author_profile": "https://Stackoverflow.com/users/1391",
"pm_score": 4,
"selected": true,
"text": "Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)\n Select Case UnloadMode\n Case 1, 2, 3 'If the ... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46249/"
] |
367,449 | <p>An RGB color is composed of three components: Red (0-255), Green (0-255) and Blue (0-255).</p>
<p>What exactly is BGR color space? How is it different from RGB color space?</p>
| [
{
"answer_id": 367458,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 1,
"selected": false,
"text": "0"
}
] | 2008/12/15 | [
"https://Stackoverflow.com/questions/367449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43076/"
] |
367,457 | <p>I have a list of objects implementing an interface, and a list of that interface:</p>
<pre><code>public interface IAM
{
int ID { get; set; }
void Save();
}
public class concreteIAM : IAM
{
public int ID { get; set; }
internal void Save(){
//save the object
}
//other staff for this particular class
}
public class MyList : List<IAM>
{
public void Save()
{
foreach (IAM iam in this)
{
iam.Save();
}
}
//other staff for this particular class
}
</code></pre>
<p>The previous code doesn't compile because the compiler requires all the interface members to be public.</p>
<pre><code>internal void Save(){
</code></pre>
<p>But i don't want to allow the from outside my DLL to save the <code>ConcreteIAM</code>, it only should be saved through the <code>MyList</code>.</p>
<p>Any way to do this?</p>
<p><strong>Update#1</strong>: Hi all, thanks for the answers so far, but none of them is exactly what i need:</p>
<p>The interface needs to be public because it is the signature the client from outside the dll will use, along with <code>ID</code> and other properties i didn't bother to write in the example to keep it simple.</p>
<p>Andrew, I don't think the solution is create a factory to create another object that will contain the <code>IAM</code> members + Save. I am still thinking... Any other ideas?</p>
| [
{
"answer_id": 367464,
"author": "Nathan W",
"author_id": 6335,
"author_profile": "https://Stackoverflow.com/users/6335",
"pm_score": 3,
"selected": false,
"text": "public abstract class AM\n{\n public int ID { get; set; }\n internal abstract void Save();\n}\n\npublic class concret... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367457",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
367,461 | <p>I've factored out common attributes from two classes into an abstract base class, however I have another model that needs to reference either one of those classes. It's not possible to reference an ABC as it doesn't actually have a database table.</p>
<p>The following example should illustrate my problem:</p>
<pre><code>class Answer(models.Model):
ovramt = models.ForeignKey("Ovramt")
question = models.ForeignKey("Question")
answer = models.CharField(max_length=3, choices=(("yes","yes"),("no","no") ("NA","N/A"))
likelihood = models.IntegerField(choices=LIKELY_CHOICES)
consequence = models.IntegerField(choices=CONSEQUENCE_CHOICES)
class Meta:
abstract = True
class Answer_A(Answer):
resident = models.ForeignKey("Resident")
def __unicode__(self):
return u"%s - %s - %s" %(self.ovramt.ssa.name, self.resident, self.question)
class Answer_B(Answer):
def __unicode__(self):
return u"%s - %s" %(self.ovramt.ssa.name, self.question)
class Answer_Risk(models.Model):
answer = models.ForeignKey("Answer")
risk = models.CharField(max_length=200)
def __unicode__(self):
return self.risk
</code></pre>
<p>Answer_A and Answer_B are slightly different in that Answer_A also needs a FK relationship to another table. Answer_B may also require some specific attributes later. The problem would STILL exist if I had Answer_B be the superclass - and have Answer_A subclass or compose it.</p>
<p>A 'Risk' is the same whether it's Answer_A or Answer_B. I also have other models that need to reference an 'Answer' regardless of it's sub-type. How can this be done? How can you reference a type regardless of it's sub-type?</p>
<p>Update:<br>
I was trying to avoid a join operation but I don't think I'm going to be able to. Would it be worth having the reference to 'Resident' in all 'Answer's and just nulling it where required? Or is that considered very bad practice? </p>
| [
{
"answer_id": 367765,
"author": "muhuk",
"author_id": 42188,
"author_profile": "https://Stackoverflow.com/users/42188",
"pm_score": 5,
"selected": true,
"text": "Answer"
}
] | 2008/12/15 | [
"https://Stackoverflow.com/questions/367461",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10583/"
] |
367,467 | <p>Timezone information for Java are kept in a folder called "zi". For eg.
C:\Program Files\Java\jdk6\jre\lib\zi</p>
<p>files in this folder are in binary format. But it is very important for me to see exactly what they say.</p>
<p>Can anyone share a way, to read these files, or are they Sun proprietary?</p>
| [
{
"answer_id": 367765,
"author": "muhuk",
"author_id": 42188,
"author_profile": "https://Stackoverflow.com/users/42188",
"pm_score": 5,
"selected": true,
"text": "Answer"
}
] | 2008/12/15 | [
"https://Stackoverflow.com/questions/367467",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
367,471 | <p>In the clocks application, the timer screen shows a picker (probably a <code>UIPicker</code> in <code>UIDatePickerModeCountDownTimer</code> mode) with some text in the selection bar ("hours" and "mins" in this case).</p>
<p>(edit) Note that these labels are <strong>fixed</strong>: They don't move when the picker wheel is rolling.</p>
<p>Is there a way to show such fixed labels in the selection bar of a standard <code>UIPickerView</code> component?</p>
<p>I did not find any API that would help with that. A suggestion was to add a <code>UILabel</code> as a subview of the picker, but that didn't work.</p>
<hr>
<p><strong>Answer</strong></p>
<p>I followed Ed Marty's advice (answer below), and it works! Not perfect but it should fool people. For reference, here's my implementation, feel free to make it better...</p>
<pre><code>- (void)viewDidLoad {
// Add pickerView
self.pickerView = [[UIPickerView alloc] initWithFrame:CGRectZero];
[pickerView release];
CGSize pickerSize = [pickerView sizeThatFits:CGSizeZero];
CGRect screenRect = [[UIScreen mainScreen] applicationFrame];
#define toolbarHeight 40.0
CGFloat pickerTop = screenRect.size.height - toolbarHeight - pickerSize.height;
CGRect pickerRect = CGRectMake(0.0, pickerTop, pickerSize.width, pickerSize.height);
pickerView.frame = pickerRect;
// Add label on top of pickerView
CGFloat top = pickerTop + 2;
CGFloat height = pickerSize.height - 2;
[self addPickerLabel:@"x" rightX:123.0 top:top height:height];
[self addPickerLabel:@"y" rightX:183.0 top:top height:height];
//...
}
- (void)addPickerLabel:(NSString *)labelString rightX:(CGFloat)rightX top:(CGFloat)top height:(CGFloat)height {
#define PICKER_LABEL_FONT_SIZE 18
#define PICKER_LABEL_ALPHA 0.7
UIFont *font = [UIFont boldSystemFontOfSize:PICKER_LABEL_FONT_SIZE];
CGFloat x = rightX - [labelString sizeWithFont:font].width;
// White label 1 pixel below, to simulate embossing.
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(x, top + 1, rightX, height)];
label.text = labelString;
label.font = font;
label.textColor = [UIColor whiteColor];
label.backgroundColor = [UIColor clearColor];
label.opaque = NO;
label.alpha = PICKER_LABEL_ALPHA;
[self.view addSubview:label];
[label release];
// Actual label.
label = [[UILabel alloc] initWithFrame:CGRectMake(x, top, rightX, height)];
label.text = labelString;
label.font = font;
label.backgroundColor = [UIColor clearColor];
label.opaque = NO;
label.alpha = PICKER_LABEL_ALPHA;
[self.view addSubview:label];
[label release];
}
</code></pre>
| [
{
"answer_id": 367763,
"author": "keremk",
"author_id": 29475,
"author_profile": "https://Stackoverflow.com/users/29475",
"pm_score": 2,
"selected": false,
"text": "UIPickerViewDelegate"
},
{
"answer_id": 548104,
"author": "mikechambers",
"author_id": 10232,
"author_p... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42690/"
] |
367,494 | <p>I'm attempting to map a set of key presses to a set of commands. Because I process the commands from several places, I'd like to set up a layer of abstraction between the keys and the commands so that if I change the underlying key mappings, I don't have to change very much code. My current attempt looks like this:</p>
<pre><code>// input.h
enum LOGICAL_KEYS {
DO_SOMETHING_KEY,
DO_SOMETHING_ELSE_KEY,
...
countof_LOGICAL_KEYS
};
static const SDLKey LogicalMappings[countof_LOGICAL_KEYS] = {
SDLK_RETURN, // Do Something
SDLK_ESCAPE, // Do Something Else
...
};
// some_other_file.cpp
...
switch( event.key.keysym.key ) {
case LogicalMappings[ DO_SOMETHING_KEY ]:
doSomething();
break;
case LogicalMappings[ DO_SOMETHING_ELSE_KEY ]:
doSomethingElse();
break;
...
}
</code></pre>
<p>When I try to compile this (gcc 4.3.2) I get the error message:</p>
<blockquote>
<p>error: 'LogicalMappings' cannot appear in a constant-expression</p>
</blockquote>
<p>I don't see why the compiler has a problem with this. I understand why you're not allowed to have variables in a case statement, but I was under the impression that you could use constants, as they could be evaluated at compile-time. Do constant arrays not work with switch statements? If so, I suppose I could just replace the array with something like:</p>
<pre><code>static const SDLKey LOGICAL_MAPPING_DO_SOMETHING = SDLK_RETURN;
static const SDLKey LOGICAL_MAPPING_DO_SOMETHING_ELSE = SDLK_ESCAPE;
...
</code></pre>
<p>But that seems much less elegant. Does anybody know why you can't use a constant array here?</p>
<p>EDIT: I've seen the bit of the C++ standard that claims that, "An integral constant-expression can involve only literals (2.13), enumerators, const variables or static data members of integral or enumeration types initialized with constant expressions (8.5)...". I still don't see why a constant array doesn't count as an "enumeration type initialized with a constant expression." It could just be that the answer to my question is "because that's the way that it is," and I'll have to work around it. But if that's the case, it's sort of disappointing, because the compiler really <i>could</i> determine those values at compile-time.</p>
| [
{
"answer_id": 367525,
"author": "Jonathan Leffler",
"author_id": 15168,
"author_profile": "https://Stackoverflow.com/users/15168",
"pm_score": 2,
"selected": false,
"text": "case"
},
{
"answer_id": 368541,
"author": "Jason S",
"author_id": 44330,
"author_profile": "h... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367494",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19491/"
] |
367,518 | <p>This should be straight forward for a guru. I don't have any code really written out, just a couple of controllers and a custom UIView. All connected through nibs. The app loads without crashing, yet I can't see my NSLog() hit from my custom UIView.</p>
<p>My application delegate has default template code which calls for a class of mine called TabAnimationController. TabAnimationViewController has its view set to TabView. I made sure that in TabAnimationViewController's NIB that File's owner is set to TabAnimationViewController and that my instance of UIView has its class set to TabView.</p>
<p>In TabView.m I'm trying to see how NSLog is going to hit, and it's not showing up at all.</p>
<pre><code>- (void)loadView {
NSLog(@"calling loadView");
}
- (id)initWithFrame:(CGRect)frame {
NSLog(@"Calling initWithFrame:");
return self;
}
</code></pre>
<p>Strange. I'm not sure why even after proper IB connections that my NSLog will not show up. Only anything put into drawRect: will invoke. Why isn't initWithFrame or loadView ever get hit? What if I want to customize this view programmatically?</p>
| [
{
"answer_id": 367668,
"author": "keremk",
"author_id": 29475,
"author_profile": "https://Stackoverflow.com/users/29475",
"pm_score": 4,
"selected": true,
"text": "initWithFrame"
}
] | 2008/12/15 | [
"https://Stackoverflow.com/questions/367518",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40882/"
] |
367,523 | <p>I would like to ensure that I only subscribe once in a particular class for an event on an instance.</p>
<p>For example I would like to be able to do the following:</p>
<pre><code>if (*not already subscribed*)
{
member.Event += new MemeberClass.Delegate(handler);
}
</code></pre>
<p>How would I go about implementing such a guard?</p>
| [
{
"answer_id": 367541,
"author": "Andrew Kennan",
"author_id": 22506,
"author_profile": "https://Stackoverflow.com/users/22506",
"pm_score": 2,
"selected": false,
"text": "class MemberClass\n{\n private EventHandler _event;\n\n public event EventHandler Event\n {\n ... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367523",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40444/"
] |
367,545 | <p>Is there an equivalent of <a href="http://www.php.net/manual/en/function.get-defined-functions.php" rel="noreferrer"><code>get_defined_functions()</code></a> which only shows the functions of a given object?</p>
<p>Example usage and output:</p>
<pre><code>class A {
function foo() { }
function bar() { }
}
class B extends A {
function foobar() { }
}
$b = new B();
print_r(get_object_functions($b));
// Array (
// 0 => "foo",
// 1 => "bar",
// 2 => "foobar"
//)
</code></pre>
| [
{
"answer_id": 367546,
"author": "nickf",
"author_id": 9021,
"author_profile": "https://Stackoverflow.com/users/9021",
"pm_score": 4,
"selected": false,
"text": "get_class_methods()"
},
{
"answer_id": 367548,
"author": "Rob",
"author_id": 3542,
"author_profile": "http... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367545",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] |
367,560 | <p>I'm interested in how much up front validation people do in the Python they write.</p>
<p>Here are a few examples of simple functions:</p>
<pre><code>def factorial(num):
"""Computes the factorial of num."""
def isPalindrome(inputStr):
"""Tests to see if inputStr is the same backwards and forwards."""
def sum(nums):
"""Same as the built-in sum()... computes the sum of all the numbers passed in."""
</code></pre>
<p>How thoroughly do you check the input values before beginning computation, and how do you do your checking? Do you throw some kind of proprietary exception if input is faulty (BadInputException defined in the same module, for example)? Do you just start your calculation and figure it will throw an exception at some point if bad data was passed in ("asd" to factorial, for example)?</p>
<p>When the passed in value is supposed to be a container do you check not only the container but all the values inside it?</p>
<p>What about situations like factorial, where what's passed in might be convertible to an int (e.g. a float) but you might lose precision when doing so?</p>
| [
{
"answer_id": 367568,
"author": "Harley Holcombe",
"author_id": 1057,
"author_profile": "https://Stackoverflow.com/users/1057",
"pm_score": 2,
"selected": false,
"text": "def factorial(num):\n \"\"\"Computes the factorial of num.\"\"\"\n try:\n num = int(num)\n except Va... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367560",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1512/"
] |
367,565 | <p>How can I build a numpy array out of a generator object?</p>
<p>Let me illustrate the problem:</p>
<pre><code>>>> import numpy
>>> def gimme():
... for x in xrange(10):
... yield x
...
>>> gimme()
<generator object at 0x28a1758>
>>> list(gimme())
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> numpy.array(xrange(10))
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> numpy.array(gimme())
array(<generator object at 0x28a1758>, dtype=object)
>>> numpy.array(list(gimme()))
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
</code></pre>
<p>In this instance, <code>gimme()</code> is the generator whose output I'd like to turn into an array. However, the array constructor does not iterate over the generator, it simply stores the generator itself. The behaviour I desire is that from <code>numpy.array(list(gimme()))</code>, but I don't want to pay the memory overhead of having the intermediate list and the final array in memory at the same time. Is there a more space-efficient way?</p>
| [
{
"answer_id": 367599,
"author": "shsmurfy",
"author_id": 2188962,
"author_profile": "https://Stackoverflow.com/users/2188962",
"pm_score": 8,
"selected": true,
"text": "my_array = numpy.empty(predict_length())\nfor i, el in enumerate(gimme()): my_array[i] = el\n"
},
{
"answer_id... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367565",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37984/"
] |
367,571 | <p>I have written a simple <a href="http://en.wikipedia.org/wiki/Brainfuck" rel="noreferrer">brainfuck</a> interpreter in MATLAB script language. It is fed random bf programs to execute (as part of a genetic algorithm project). The problem I face is, the program turns out to have an infinite loop in a sizeable number of cases, and hence the GA gets stuck at the point.<br>
So, I need a mechanism to detect infinite loops and avoid executing that code in bf.<br>
One obvious (trivial) case is when I have</p>
<pre><code>[]
</code></pre>
<p>I can detect this and refuse to run that program.<br>
For the non-trivial cases, I figured out that the basic idea is: to determine how one iteration of the loop changes the current cell. If the change is negative, we're eventually going to reach 0, so it's a finite loop. Otherwise, if the change is non-negative, it's an infinite loop.<br>
Implementing this is easy for the case of a single loop, but with nested loops it becomes very complicated. For example, (in what follows (1) refers to contents of cell 1, etc. )</p>
<pre><code>++++ Put 4 in 1st cell (1)
>+++ Put 3 in (2)
<[ While( (1) is non zero)
-- Decrease (1) by 2
>[ While( (2) is non zero)
- Decrement (2)
<+ Increment (1)
>]
(2) would be 0 at this point
+++ Increase (2) by 3 making (2) = 3
<] (1) was decreased by 2 and then increased by 3, so net effect is increment
</code></pre>
<p>and hence the code runs on and on. A naive check of the number of +'s and -'s done on cell 1, however, would say the number of -'s is more, so would not detect the infinite loop.<br>
Can anyone think of a good algorithm to detect infinite loops, given arbitrary nesting of arbitrary number of loops in bf?</p>
<p>EDIT: I do know that the halting problem is unsolvable in general, but I was not sure whether there did not exist special case exceptions. Like, maybe Matlab might function as a Super Turing machine able to determine the halting of the bf program. I might be horribly wrong, but if so, I would like to know exactly how and why. </p>
<p>SECOND EDIT: I have written what I purport to be infinite loop detector. It probably misses some edge cases (or less probably, somehow escapes Mr. Turing's clutches), but seems to work for me as of now.
In pseudocode form, here it goes:</p>
<pre><code>subroutine bfexec(bfprogram)
begin
Looping through the bfprogram,
If(current character is '[')
Find the corresponding ']'
Store the code between the two brackets in, say, 'subprog'
Save the value of the current cell in oldval
Call bfexec recursively with subprog
Save the value of the current cell in newval
If(newval >= oldval)
Raise an 'infinite loop' error and exit
EndIf
/* Do other character's processings */
EndIf
EndLoop
end
</code></pre>
| [
{
"answer_id": 367758,
"author": "Eugene Yokota",
"author_id": 3827,
"author_profile": "https://Stackoverflow.com/users/3827",
"pm_score": 2,
"selected": false,
"text": "<"
},
{
"answer_id": 19773000,
"author": "Robert",
"author_id": 2953412,
"author_profile": "https:... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8127/"
] |
367,577 | <p>When you have code like the following: </p>
<pre><code>static T GenericConstruct<T>() where T : new()
{
return new T();
}
</code></pre>
<p>The C# compiler insists on emitting a call to Activator.CreateInstance, which is considerably slower than a native constructor. </p>
<p>I have the following workaround:</p>
<pre><code>public static class ParameterlessConstructor<T>
where T : new()
{
public static T Create()
{
return _func();
}
private static Func<T> CreateFunc()
{
return Expression.Lambda<Func<T>>( Expression.New( typeof( T ) ) ).Compile();
}
private static Func<T> _func = CreateFunc();
}
// Example:
// Foo foo = ParameterlessConstructor<Foo>.Create();
</code></pre>
<p>But it doesn't make sense to me why this workaround should be necessary.</p>
| [
{
"answer_id": 367643,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": false,
"text": "List<string>"
},
{
"answer_id": 367648,
"author": "JaredPar",
"author_id": 23283,
"author_profile": ... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367577",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46267/"
] |
367,586 | <p>I need to generate random text strings of a particular format. Would like some ideas so that I can code it up in Python. The format is <8 digit number><15 character string>. </p>
| [
{
"answer_id": 367594,
"author": "gimel",
"author_id": 6491,
"author_profile": "https://Stackoverflow.com/users/6491",
"pm_score": 4,
"selected": false,
"text": "from random import choice\nimport string\n\ndef GenPasswd2(length=8, chars=string.letters + string.digits):\n return ''.joi... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367586",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27474/"
] |
367,617 | <p>In another <a href="https://stackoverflow.com/questions/89193/does-linq-to-sql-support-composable-queries">posting: Does Linq-To-Sql support composable queries</a> there was discussion on how to compose/concat where clauses dynamically. This appears to be done with an "AND" (i.e. the first where clause and the second where clause are joined by an AND). What I am wondering is if there is a way to compose Linq queries with an OR.</p>
<p>Example:</p>
<pre><code>var people = from p in Person
where p.age < 18
select p
var otherPeople = from p in people
where p.firstName equals "Daniel"
select p
</code></pre>
<p>This gives people with a first name of "Daniel" and that are under 18. I'm looking for the syntax to join these to find people who have a first name of "Daniel" or are under 18.</p>
<p>Note: I am using ADO.net Data Services so I do not have .Contains() available to me.</p>
<p><strong>EDIT</strong>: The Union Suggestion (by Garry Shutler) is exactly what I am looking for functionality-wise. I did run into two possible issues with it:</p>
<ol>
<li>It looks like it would make multiple database hits if I was to do a third condition (union seems to take an IEnumerable as its parameter) - I was hoping to build up multiple AND and OR statements in code and then execute one request.</li>
<li>Union is not supported by ADO.Net Data Services (very disappointing)</li>
</ol>
| [
{
"answer_id": 367912,
"author": "Garry Shutler",
"author_id": 6369,
"author_profile": "https://Stackoverflow.com/users/6369",
"pm_score": 4,
"selected": true,
"text": "var people = from p in Person\n where p.age < 18 || p.firstName == \"Daniel\"\n select p;\n"
... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25719/"
] |
367,623 | <p>We are invoking Asp.Net ajax web service from the client side. So the JavaScript functions have calls like:</p>
<p>// The function to alter the server side state object and set the selected node for the case tree.</p>
<pre><code>function JSMethod(caseId, url)
{
Sample.XYZ.Method(param1, param2, OnMethodReturn);
}
function OnMethodReturn(result)
{
var sessionExpiry = CheckForSessionExpiry(result);
var error = CheckForErrors(result);
... process result
}
</code></pre>
<p>And on the server side in the ".asmx.cs" file:
namespace Sample</p>
<pre><code>[ScriptService]
class XYZ : WebService
{
[WebMethod(EnableSession = true)]
public string Method(string param1, string param2)
{
if (SessionExpired())
{
return sessionExpiredMessage;
}
.
.
.
}
}
</code></pre>
<p>The website is setup to use form based authentication. Now if the session has expired and then the JavaScript function "JSMethod" is invoked,
then the following error is obtained:
Microsoft JScript runtime error: Sys.Net.WebServiceFailedException: The server method 'Method' failed with the following error: System.InvalidOperationException-- Authentication failed.</p>
<p>This exception is raised by method "function Sys$Net$WebServiceProxy$invoke" in file "ScriptResource.axd":</p>
<pre><code>function Sys$Net$WebServiceProxy$invoke
{
.
.
.
{
// In debug mode, if no error was registered, display some trace information
var error;
if (result && errorObj) {
// If we got a result, we're likely dealing with an error in the method itself
error = result.get_exceptionType() + "-- " + result.get_message();
}
else {
// Otherwise, it's probably a 'top-level' error, in which case we dump the
// whole response in the trace
error = response.get_responseData();
}
// DevDiv 89485: throw, not alert()
throw Sys.Net.WebServiceProxy._createFailedError(methodName, String.format(Sys.Res.webServiceFailed, methodName, error));
}
</code></pre>
<p>So the problem is that the exception is raised even before "Method" is invoked, the exception occurs during the creation of the Web Proxy. Any ideas on how to resolve this problem</p>
| [
{
"answer_id": 376909,
"author": "Strelok",
"author_id": 2788,
"author_profile": "https://Stackoverflow.com/users/2788",
"pm_score": 0,
"selected": false,
"text": "try { } catch { }"
},
{
"answer_id": 3421097,
"author": "Bharat Patil",
"author_id": 412663,
"author_pro... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367623",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46279/"
] |
367,626 | <p>In the Java snippet:</p>
<pre><code>SyndFeedInput fr = new SyndFeedInput();
SyndFeed sf = fr.build(new XmlReader(myInputStream));
List<SyndEntry> entries = sf.getEntries();
</code></pre>
<p>the last line generates the warning </p>
<p>"The expression of type <code>List</code> needs unchecked conversion to conform to <code>List<SyndEntry></code>"</p>
<p>What's an appropriate way to fix this? </p>
| [
{
"answer_id": 367632,
"author": "Alex B",
"author_id": 6180,
"author_profile": "https://Stackoverflow.com/users/6180",
"pm_score": 3,
"selected": false,
"text": "SyndFeed"
},
{
"answer_id": 367634,
"author": "Shyam Kumar Sundarakumar",
"author_id": 35392,
"author_pro... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367626",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46277/"
] |
367,633 | <p>What are all the common undefined behaviours that a C++ programmer should know about?</p>
<p>Say, like:</p>
<pre><code>a[i] = i++;
</code></pre>
<p></p>
| [
{
"answer_id": 367650,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 2,
"selected": false,
"text": "char"
},
{
"answer_id": 367662,
"author": "Diomidis Spinellis",
"author_id": 20520,
"author_profile":... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367633",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22076/"
] |
367,656 | <p>Currently I am working very basic game using the C++ environment. The game used to be a school project but now that I am done with that programming class, I wanted to expand my skills and put some more flourish on this old assignment.</p>
<p>I have already made a lot of changes that I am pleased with. I have centralized all the data into folder hierarchies and I have gotten the code to read those locations.</p>
<p>However my problem stems from a very fundamental flaw that has been stumping me. </p>
<p>In order to access the image data that I am using I have used the code:</p>
<pre><code>string imageLocation = "..\\DATA\\Images\\";
string bowImage = imageLocation + "bow.png";
</code></pre>
<p>The problem is that when the player picks up an item on the gameboard my code is supposed to use the code:</p>
<pre><code>hud.addLine("You picked up a " + (*itt)->name() + "!");
</code></pre>
<p>to print to the command line, "You picked up a Bow!". But instead it shows "You picked up a ..\DATA\Images\!". </p>
<p>Before I centralized my data I used to use:</p>
<pre><code>name_(item_name.substr(0, item_name.find('.')))
</code></pre>
<p>in my Item class constructor to chop the item name to just something like bow or candle. After I changed how my data was structured I realized that I would have to change how I chop the name down to the same simple 'bow' or 'candle'. </p>
<p>I have changed the above code to reflect my changes in data structure to be:</p>
<pre><code>name_(item_name.substr(item_name.find("..\\DATA\\Images\\"), item_name.find(".png")))
</code></pre>
<p>but unfortunately as I alluded to earlier this change of code is not working as well as I planned it to be.</p>
<p>So now that I have given that real long winded introduction to what my problem is, here is my question.</p>
<p>How do you extract the middle of a string between two sections that you do not want? Also that middle part that is your target is of an unknown length. </p>
<p>Thank you so very much for any help you guys can give. If you need anymore information please ask; I will be more than happy to upload part or even my entire code for more help. Again thank you very much.</p>
| [
{
"answer_id": 367732,
"author": "hamishmcn",
"author_id": 3590,
"author_profile": "https://Stackoverflow.com/users/3590",
"pm_score": 2,
"selected": false,
"text": "string extn = item_name.substr(item_name.find_last_of(\".png\"));\nstring path = item_name.substr(0, item_name.find(\"..\\... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367656",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36254/"
] |
367,684 | <p>I'm using Pyglet(and OpenGL) in Python on an application, I'm trying to use glReadPixels to get the RGBA values for a set of pixels. It's my understanding that OpenGL returns the data as packed integers, since that's how they are stored on the hardware. However for obvious reasons I'd like to get it into a normal format for working with. Based on some reading I've come up with this: <a href="http://dpaste.com/99206/" rel="nofollow noreferrer">http://dpaste.com/99206/</a> , however it fails with an IndexError. How would I go about doing this?</p>
| [
{
"answer_id": 368224,
"author": "nikow",
"author_id": 11992,
"author_profile": "https://Stackoverflow.com/users/11992",
"pm_score": 1,
"selected": false,
"text": " buffer = gl.glReadPixels(0, 0, width, height, gl.GL_RGB, \n gl.GL_UNSIGNED_BYTE)\n image ... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367684",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37181/"
] |
367,695 | <p>I need to get substed drive letter in Perl. Could anyone kindly help me?
$ENV{SYSTEMDRIVE} does not work; it gives me real logical drive letter, not the substed one.</p>
| [
{
"answer_id": 367705,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 0,
"selected": false,
"text": "SUBST [drive1: [drive2:]path]\nSUBST drive1: /D\n drive1: Specifies a virtual drive to which you want to assig... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46289/"
] |
367,703 | <p>This obviously requires the source file to be under source control. I would ideally like a tool which works under the IDE (Eclipse, Visual Studio, etc) - but an external tool would be nice, too. Obviously, it is possible manually go through previous versions of the file, and compare the various versions, but I am looking for a way to be able to see quickly who is responsible for a code section.</p>
<p>I am using CVS, but the tool should ideally work with different source control systems.</p>
| [
{
"answer_id": 367710,
"author": "OscarRyz",
"author_id": 20654,
"author_profile": "https://Stackoverflow.com/users/20654",
"pm_score": 3,
"selected": false,
"text": "svn blame\n"
},
{
"answer_id": 368661,
"author": "PhiLho",
"author_id": 15459,
"author_profile": "htt... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367703",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18651/"
] |
367,706 | <p>What is a good way of parsing command line arguments in Java?</p>
| [
{
"answer_id": 367714,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 10,
"selected": true,
"text": "commons-cli"
},
{
"answer_id": 41022241,
"author": "Paul",
"author_id": 735217,
"author_profile"... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367706",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1428/"
] |
367,709 | <p>I would like to execute the jQuery $(document).ready() in a drupal site. While i know that i can just stick it in the index page , this is really messy and a hack. </p>
<p>What i want to know is where is the correct location to put this, it would also need to be theme specific as i dont want all themes to use it.</p>
<p>Thanks in advance for the help. </p>
<hr>
<p>Sweet success , thanks both of you for the help , i just have one last amend to this question. Now that i have got this far , i need to execute the jQuery code to update the document , can i use the context to modify the document ? </p>
| [
{
"answer_id": 367729,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 3,
"selected": false,
"text": "$(document).ready()"
},
{
"answer_id": 367775,
"author": "gregnostic",
"author_id": 41891,
"author_profile"... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367709",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42069/"
] |
367,711 | <p>I'm wondering if there is a "best" choice for collation in MySQL for a general website where you aren't 100% sure of what will be entered? I understand that all the encodings should be the same, such as MySQL, Apache, the HTML and anything inside PHP.</p>
<p>In the past I have set PHP to output in "UTF-8", but which collation does this match in MySQL? I'm thinking it's one of the UTF-8 ones, but I have used <code>utf8_unicode_ci</code>, <code>utf8_general_ci</code>, and <code>utf8_bin</code> before.</p>
| [
{
"answer_id": 367721,
"author": "mepcotterell",
"author_id": 43312,
"author_profile": "https://Stackoverflow.com/users/43312",
"pm_score": 4,
"selected": false,
"text": "utf8_general_ci"
},
{
"answer_id": 367725,
"author": "Eran Galperin",
"author_id": 10585,
"author... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367711",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5441/"
] |
367,724 | <p>What is the standard way of incorporating helper/utility functions in Obj-C classes?</p>
<p>I.e. General purpose functions which are used throughout the application and called by more than 1 class.</p>
<p>Can an Obj-C method exist outside of a class, or does it need to be a C function for it to have this kind of behaviour?</p>
| [
{
"answer_id": 367773,
"author": "AnthonyLambert",
"author_id": 31762,
"author_profile": "https://Stackoverflow.com/users/31762",
"pm_score": 5,
"selected": false,
"text": "@interface HelperClass: superclassname {\n // instance variables - none if all methods are static.\n}\n\n+ (void... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367724",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26088/"
] |
367,726 | <p>How can two classes in separate projects communicate between one another?</p>
<p>If ClassA references ClassB I can access methods of ClassB in ClassA... How can I make use of Interfaces to access methods of ClassA in ClassB?</p>
<p>Indeed do the classes even need to be linked if I make use of Interfaces?</p>
<p>Can someone please provide me with an example?</p>
<p>Coding in C# 2.0.</p>
<hr>
<p>I do mean classes. If I have two projects which are not referenced, but I would like to access methods in the class of one from the other ... how can I achieve this with Interfaces.</p>
<p>It has been alluded to me that this is what I should use however I am having a hard time understanding how to implement an interface if the projects are not referenced.</p>
| [
{
"answer_id": 367746,
"author": "lubos hasko",
"author_id": 275,
"author_profile": "https://Stackoverflow.com/users/275",
"pm_score": 2,
"selected": false,
"text": "System.Reflection.Assembly.LoadFile(\"MyProject.dll\").GetType(\"MyProject.TestClass\").GetMethod(\"TestMethod\").Invoke()... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367726",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
367,730 | <p>How can I change an attribute of an element in an XML file, using C#?</p>
| [
{
"answer_id": 367772,
"author": "alexmac",
"author_id": 23066,
"author_profile": "https://Stackoverflow.com/users/23066",
"pm_score": 6,
"selected": false,
"text": "using System.Xml.Linq;\n\nXDocument xmlFile = XDocument.Load(\"books.xml\"); \n\nvar query = from c in xmlFile.Elements(\"... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
367,739 | <p>I have a Product Class which has a one to many relationship to a Price class.
So a product can have multiple prices.</p>
<p>I need to query the db to get me 10 products which have Price.amount < $2. In this case its to populate a UI with 10 items in a page.
so i writ the following code:</p>
<pre><code>ICriteria criteria = session.CreateCriteria(typeof(Product));
criteria.SetFirstResult(pageNumber);
criteria.SetMaxResults(numberOfItemInPage);
criteria = criteria.CreateCriteria("PriceCollection");
criteria.Add(Restrictions.Le("Amount", new Decimal(2)));
criteria.SetResultTransformer(CriteriaSpecification.DistinctRootEntity);
</code></pre>
<p>Instead of getting 10 Product on the list, I'm getting less than that (i.e. 5).
The reason being SetMaxResults(10) return me 10 Products but with duplicates. The duplicates are then removed by SetResultTransformer(DistinctRootEntity). </p>
<p>Can anyone tell me any way for me to get 10 unique Products without increasing SetMaxResults()? I need to use pagenumber as some sort of indexing.</p>
| [
{
"answer_id": 367951,
"author": "Bork Blatt",
"author_id": 5381,
"author_profile": "https://Stackoverflow.com/users/5381",
"pm_score": 0,
"selected": false,
"text": "MinimumPrice (numeric(18,2)\nMaximumPrice (numeric(18,2)\n"
}
] | 2008/12/15 | [
"https://Stackoverflow.com/questions/367739",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
367,751 | <p>I want to create a dmg file for my Mac project. Can someone please tell me how to do this? This being my first Mac project, I do not have any idea how to proceed. I also want to give the user an option of running the app on start-up. How do I do this?</p>
<p>Thanks.</p>
<p>P.S. I also want to add a custom license agreement.</p>
| [
{
"answer_id": 367826,
"author": "dbr",
"author_id": 745,
"author_profile": "https://Stackoverflow.com/users/745",
"pm_score": 5,
"selected": false,
"text": "/Applications/Utilities/"
},
{
"answer_id": 976397,
"author": "kent",
"author_id": 78568,
"author_profile": "h... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367751",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46297/"
] |
367,752 | <p>Trying to add an onclick handler to my tabs, and can't seem to get the DOM selection right. Can you guys help?</p>
<pre><code> <div id="tabstrip">
<ul>
<li id="a" class="selected"><a href="#">A</a></li>
<li id="b"><a href="#">B</a></li>
<li id="b"><a href="#">C</a></li>
</ul>
</div>
function initTabStrip()
{
var lis = document.getElementById('tabstrip').getElementsByTagName('li');
for (var i=0;i<items.length;i++)
{
var as = items[i].getElementsByTagName('a');
for (var j=0;j<as.length;j++)
{
as[j].onclick=function(){changeTab(items[i].id);return false}
}
}
}
</code></pre>
| [
{
"answer_id": 367777,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 3,
"selected": true,
"text": "as[j].onclick = function(items, i)\n{\n return function()\n {\n changeTab(items[i].id);\n return false;\n ... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8372/"
] |
367,761 | <h2>Original title: How can I prevent loading a native dll from a .NET app?</h2>
<p><strong>Background:</strong></p>
<p>My C# application includes a plugin framework and generic plugin loader.</p>
<p>The plugin loader enumerates the application directory in order to identify plugin dlls (essentially it searches for *.dll at this time). </p>
<p>Within the same application directory is a native (Windows, non-.net) dll, which, indirectly, one of the plugin dlls depends upon.</p>
<p>The plugin loader blindly assumes that the native.dll is a .NET Assembly dll, simply because it only checks the file extension. When it attempts to load the native dll, an exception is thrown:</p>
<p>"Could not load file or assembly 'native.dll' or one of its dependencies. The module was expected to contain an assembly manifest."</p>
<p>I basically create a diagnostic report if plugin loading fails, so I'm trying to avoid having this log filled up with messages about not being able to load the native dll (which I don't even want to attempt).</p>
<p><strong>The question:</strong></p>
<p>Is there some .NET API call that I can use to determine whether a binary happens to be a .NET assembly so that I don't attempt to load the native dll at all?</p>
<p>Perhaps longer term I will move my plugins to a subdirectory, but for now, I just want a work around that doesn't involve hard-coding the "native.dll" name inside my plugin loader. </p>
<p>I guess I'm looking for some kind of static Assembly.IsManaged() API call that I've overlooked.... presumably no such API exists?</p>
| [
{
"answer_id": 367785,
"author": "Ian",
"author_id": 4396,
"author_profile": "https://Stackoverflow.com/users/4396",
"pm_score": 2,
"selected": false,
"text": "foreach (string aDll in dllCollection) \n{\n try \n {\n Assembly anAssembly = Assembly.LoadFrom(aDll);\n }\n catch (BadI... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367761",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46296/"
] |
367,768 | <p>Given a function:</p>
<pre><code>function x(arg) { return 30; }
</code></pre>
<p>You can call it two ways:</p>
<pre><code>result = x(4);
result = new x(4);
</code></pre>
<p>The first returns 30, the second returns an object.</p>
<p>How can you detect which way the function was called <strong>inside the function itself</strong>?</p>
<p>Whatever your solution is, it must work with the following invocation as well:</p>
<pre><code>var Z = new x();
Z.lolol = x;
Z.lolol();
</code></pre>
<p>All the solutions currently think the <code>Z.lolol()</code> is calling it as a constructor.</p>
| [
{
"answer_id": 367794,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 6,
"selected": false,
"text": "this.constructor"
},
{
"answer_id": 367825,
"author": "annakata",
"author_id": 13018,
"author_profile": "... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367768",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15055/"
] |
367,781 | <p>I have a java me application and now I want to place that application at the server. I want to write the download page with servlet. I mean when the user keys in the servlet url and hit to that servlet, my jad file will send to the phone(user no need to click to download button or link.After page loading, the servlet will automatically send the jad file to the requested mobile phone.). </p>
<p>I tried with this code.</p>
<pre><code>> File exportFile = new File("C:\\Voice.jad");
> response.setContentType("text/vnd.sun.j2me.app-descriptor");
> response.setContentLength((int)
> exportFile.length());
> response.addHeader("Content-Disposition",
> "attachment; filename=" +
> exportFile.getName());
> OutputStream os= response.getOutputStream();
> InputStream is = new FileInputStream("C:\\Voice.jad");
> while (is.available() > 0) { char c =
> (char) is.read();
> os.write(c); }
> os.flush();
> is.close();
</code></pre>
<p>and I tried to download the application from Nokia Series 40th 5rd edition emulator. It shows the jad file's information and try to install. But on the way for installing, it said jar file doesn't exist.</p>
<p>I don't know how to move on. Please give me some information or samples.
How can I write the download page for java me application at the servlet?</p>
<p>Thanks you,
With Regards</p>
| [
{
"answer_id": 368788,
"author": "miceuz",
"author_id": 24443,
"author_profile": "https://Stackoverflow.com/users/24443",
"pm_score": 1,
"selected": false,
"text": "MIDlet-1: BiteTravel, i3.png, main.MainMidlet\nMIDlet-Icon: i1.png\nMIDlet-Jar-Size: 109855 //this is very important -- jar... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
367,786 | <p>It looks like if I load dynamic content using <code>$.get()</code>, the result is cached in browser.</p>
<p>Adding some random string in QueryString seems to solve this issue (I use <code>new Date().toString()</code>), but this feels like a hack. </p>
<p>Is there any other way to achieve this?
Or, if unique string is the only way to achieve this, any suggestions other than <code>new Date()</code>?</p>
| [
{
"answer_id": 367796,
"author": "miceuz",
"author_id": 24443,
"author_profile": "https://Stackoverflow.com/users/24443",
"pm_score": 5,
"selected": false,
"text": "response.setHeader( \"Pragma\", \"no-cache\" );\nresponse.setHeader( \"Cache-Control\", \"no-cache\" );\nresponse.setDateHe... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367786",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10629/"
] |
367,789 | <p>Can you someone please point in me in a direction, sample code or an online resource to accomplish the following:</p>
<p><strong>Requirement:</strong>
I would like to write a simple IVR menu option that will run a script (Bash or Python). For example, phone the Asterisk machine and request to restart a service on another Linux box. The 'other Linux box' details would be hard coded to the IVR menu option and not needed to be supplied as part of the IVR interaction - just restart service X on box Y. I am little worried and unsure how one would secure this with a password (even if it is hard coded in version).</p>
<p><strong>Background:</strong>
I am an Asterisk newbie and installed it from the AsteriskNow distribution and I am still learning the product. The basic PBX functionality is working and is administered through FreePBX. Asterisk is not our main focus of development work but rather a tool in the toolbox. We mostly do .NET work but have Unix skills.</p>
<p>If possible I would not like to spend days learning the integrate details of Asterisk to get the job done...</p>
| [
{
"answer_id": 570816,
"author": "Chochos",
"author_id": 10165,
"author_profile": "https://Stackoverflow.com/users/10165",
"pm_score": 2,
"selected": false,
"text": "exten => 9999,1,GotoIf($[\"${CALLERID(num)}\" = \"yournumber\"]?4)\nexten => 9999,2,Playback(sorry)\nexten => 9999,3,Hangu... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11123/"
] |
367,797 | <p>I am using <code>Path.Combine</code>, and one of the strings contain a Unicode characters. I get <code>{System.ArgumentException} exception; illegal characters in path</code>.</p>
<p>According to <a href="http://msdn.microsoft.com/en-us/library/aa365247.aspx" rel="nofollow noreferrer">MSDN</a> filepath/name can have unicode characters. Why do I get this exception?</p>
<h3>Edit:</h3>
<p>Here is the code:</p>
<pre><code>Path.Combine("C:\PDM\Silver","Amabel Bender QQQ")
</code></pre>
| [
{
"answer_id": 367816,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 2,
"selected": false,
"text": "Path.InvalidPathChars"
},
{
"answer_id": 367835,
"author": "DilbertDave",
"author_id": 31580,
"author_profi... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38997/"
] |
367,817 | <p>I want to achieve the following:</p>
<pre><code>ID | Counter
------------
0 | 343
1 | 8344
</code></pre>
<p>Now say that I want to update counter for ID 1,,, what is the easiest way to do it? Do I use sequences? do I simply read the value and update? Is there any special type for it?</p>
<p>I was thinking about using sequence but then I have to create one for each ID (which potentially can be over a 1000. I will also face the problem that I don't know how many sequences I will need so I would have to check if there is a sequence for that ID and etc... and I don't want that.</p>
<p>Assume that the numbers are users belonging to a certain group, then an alternative I was thinking about was to enter a row for each count and when I want to get the number I perform a select group by the id or something and get the numbers of rows.</p>
<p>EDIT: Clarification
I recieve a list of users in a csv that my program handles several times a day (new csv several times a day). Then depending on if the user has has sent a message today (for example) I increment the counter for the group in which this user belongs to. Now at a certain point I want to extract the groups (which can be dynamic, it depends on what I got during the day) and get the number I incremented and reset it.
Hopefully this explains it more :D</p>
<p>Thanks for the help so far, I will experiment :D</p>
<p>What do you think?</p>
| [
{
"answer_id": 367843,
"author": "annakata",
"author_id": 13018,
"author_profile": "https://Stackoverflow.com/users/13018",
"pm_score": 0,
"selected": false,
"text": "select id, count(users) from foo group by id"
},
{
"answer_id": 367852,
"author": "Jonathan Lonowski",
"a... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46303/"
] |
367,819 | <p>In the external code that I am using there is enum: </p>
<pre><code>enum En {VALUE_A, VALUE_B, VALUE_C};
</code></pre>
<p>In another external code that I am using there are 3 #define directives: </p>
<pre><code>#define ValA 5
#define ValB 6
#define ValC 7
</code></pre>
<p>Many times I have int X which is equal to ValA or ValB or ValC, and I have to cast it to the corresponding value of En (ValA to VALUE_A, ValB to VALUEB, etc) because some function signature has enum En. And many times I have to do the opposite operation, translate enum En to ValA or ValB or ValC. I cannot change the signatures of these functions, and there are many such functions.</p>
<p>The question is: How to do the translation? Should I create 2 cast operators, which will be used implicitly? Or should I just have 2 translation functions which will be used explicitly:</p>
<pre><code>En ToEn(int)
int FromEn(En)
</code></pre>
<p>Or any other solution?</p>
| [
{
"answer_id": 367834,
"author": "Patrick",
"author_id": 38892,
"author_profile": "https://Stackoverflow.com/users/38892",
"pm_score": 1,
"selected": false,
"text": "//libFunc( enum a );\n\nlibFuncOverload( define a ) {\n libFunc( toEn( a ) );\n}\n"
},
{
"answer_id": 367968,
... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367819",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44673/"
] |
367,823 | <p>Can anyone tell me how to write a nested SQL query like </p>
<p>SELECT * FROM X WHERE X.ID IN (SELECT Y.XID FROM Y WHERE .....)</p>
<p>in LINQ?</p>
| [
{
"answer_id": 367829,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 4,
"selected": true,
"text": "var yIds = from y in dataContext.Y\n where ...\n select y.XId;\n\nvar query = from x in dataContext.X... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367823",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34623/"
] |
367,824 | <p><em>It is a messy question, hopefully you can figure out what I want :)</em></p>
<p><strong>What is the best way to use Win32 functionality in a Qt Open Source Edition project?</strong></p>
<p>Currently I have included the necessary Windows SDK libraries and include directories to qmake project file by hand. It works fine on a small scale, but its inconvenient and cumbersome. </p>
<p>So, should I separate the Win32 stuff into a library or is there a sensible way of combining these two? Or have I just overlooked some Qt aspect that simplifies this?</p>
<p><strong>EDIT</strong></p>
<p>Removed the syntax stuff, its not really relevant, just annoying.</p>
| [
{
"answer_id": 368249,
"author": "MSalters",
"author_id": 15416,
"author_profile": "https://Stackoverflow.com/users/15416",
"pm_score": 0,
"selected": false,
"text": "wchar_t const*"
},
{
"answer_id": 406663,
"author": "Henrik Hartz",
"author_id": 50830,
"author_profi... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40657/"
] |
367,846 | <p>I'm currently using the ModelStateDictionary in asp.net mvc to hold validation errors and pass then back to the user. Being able to check if the whole model is valid with ModelState.IsValid is particularly. However, a current application I'm working on has a need to be able to report warnings. These aren't as critical so the form content can still be saved, but they should be shown to the user so that action can be optionally taken.</p>
<p>I've been looking through the framework to see if there are any obvious place to extend it to allow me to do this. I'm thinking that another dictionary with warnings in and a subclass of model error called model warning. I'm not sure how I'd get the framework to use my new container classes in the view etc. though, I still want all of the existing error stuff to work.</p>
<p>If anyone has tried anything similar or has any thoughts I'd appreciate their input.</p>
<p>Update:</p>
<p>I've got as far as extending the ViewDataDictionary to add some warnings</p>
<pre><code>public class AetherViewDataDictionary : ViewDataDictionary
{
public AetherViewDataDictionary()
{
ModelStateWarning = new ModelStateDictionary();
}
public AetherViewDataDictionary(object model) : base(model)
{
ModelStateWarning = new ModelStateDictionary();
}
public AetherViewDataDictionary(ViewDataDictionary viewDataDictionary) : base(viewDataDictionary)
{
ModelStateWarning = new ModelStateDictionary();
}
public ModelStateDictionary ModelStateWarning { get; private set; }
}
</code></pre>
<p>The problem that I'm having now is that when I get to my view code, this is just for debug I'm losing the fact that its my new type, so when I try to cast it back and get access to my new dictionary I have no joy.</p>
<pre><code>public partial class Index : ViewPage<PageViewData>
{
protected override void SetViewData(ViewDataDictionary viewData)
{
base.SetViewData(viewData);
}
}
</code></pre>
<p>It sets it correctly here, but when I check the type its gone.</p>
<p>Edit:
This turned out to be a dumb way of doing things, see answer below.</p>
| [
{
"answer_id": 368155,
"author": "Mike Scott",
"author_id": 43649,
"author_profile": "https://Stackoverflow.com/users/43649",
"pm_score": 2,
"selected": false,
"text": "ViewData[ \"warnings\" ] = new[] { \"You need to snarfle your aardvark\" } ;\n"
},
{
"answer_id": 370779,
"... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367846",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35047/"
] |
367,847 | <p>There is a div that has inner content, a div with a border that's inside a div. Somehow, this div is expanded to encompass the next div. It blows my mind.</p>
<pre><code><div style="background: yellow;">
<div>
<div style="border: 1px solid black; background: green">green background</div>
</div>
</div>
<div style="margin-top: 100px;">
IE gives me a yellow background, unless i take away the border of the green
background div.
</div>
</code></pre>
<p>I'm wondering the cause of this and how to solve it.</p>
| [
{
"answer_id": 367858,
"author": "annakata",
"author_id": 13018,
"author_profile": "https://Stackoverflow.com/users/13018",
"pm_score": 2,
"selected": false,
"text": "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n"
},
{
"answer_id... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367847",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43005/"
] |
367,853 | <p>Below is my stored procedure. I want use stored procedure select all row of date from tbl_member and insert 2 table. But it's not work. Some one can help me?</p>
<pre><code>Create PROCEDURE sp_test
AS
BEGIN
SET NOCOUNT ON;
Declare @A Varchar(255), @B Varchar(255), @C Varchar(255), @D int
Declare Table_Cursor Cursor
For select A, B, C from tbl_Member Open Table_Cursor
Fetch Next From Table_Cursor
Into @A, @B, @C While(@@Fetch_Status=0)
Begin Exec(
'insert into NewMember (A, B, C, D) values (@A, @B, @C, @D)
set @D = @@IDENTITY
Insert into MemberId (Mid) VALUES(@D)
)
Fetch Next From Table_Cursor Into @A, @B, @C End Close Table_Cursor
Deallocate Table_Cursor
END
GO
</code></pre>
| [
{
"answer_id": 367875,
"author": "Pete OHanlon",
"author_id": 43635,
"author_profile": "https://Stackoverflow.com/users/43635",
"pm_score": 4,
"selected": true,
"text": "INSERT INTO NewMember(A, B, C, D)\nSELECT A, B, C, D\nFROM tbl_member\n"
}
] | 2008/12/15 | [
"https://Stackoverflow.com/questions/367853",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44260/"
] |
367,859 | <p>Does any one know of a control that i can use with a ASP.Net gridview that provides the functionality of the ASP.Net Ajax Control PagingBulletedList. I want to provide the users with a easier way to access the data in the grid.</p>
<p>It should ideally work in the same way paging for the grid works except that it should show all the data for the selected option i.e. if the letter a is selected all items that begin with a are shown to the user.</p>
<p>I would prefer not to have to re develop something like this as i am sure it exists, i just have no idea what would you call it.</p>
<p>Thanks in advance.</p>
| [
{
"answer_id": 380120,
"author": "jpsimard-nyx",
"author_id": 47109,
"author_profile": "https://Stackoverflow.com/users/47109",
"pm_score": 2,
"selected": true,
"text": "<asp:UpdatePanel runat=\"server\" ID=\"UpdatePanel\">\n<asp:GridView runat=\"server\" ID=\"GridView\">\n <PagerTempla... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367859",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42069/"
] |
367,862 | <p>I would like to build a regexp in Java that would be passed in a FilenameFilter to filter the files in a dir.</p>
<p>The problem is that I can't get the hang of the regexp "mind model" :)</p>
<p>This is the regexp that I came up with to select the files that I would like to exclude </p>
<p>((ABC|XYZ))+\w*Test.xml</p>
<p>What I would like to do is to select all the files that end with Test.xml but do not start with ABC or XYZ.</p>
<p>Could you please add any resources that could help me in my battle with regexps.</p>
<p>Thanks</p>
<p>The following resource explains a lot of things about regexp <a href="http://www.regular-expressions.info/refadv.html" rel="nofollow noreferrer">regular-expressions.info</a></p>
| [
{
"answer_id": 367868,
"author": "Yoni Roit",
"author_id": 34161,
"author_profile": "https://Stackoverflow.com/users/34161",
"pm_score": 3,
"selected": false,
"text": "if (str.endsWith(\"Test.xml\") && !str.startsWith(\"ABC\"))\n"
},
{
"answer_id": 367882,
"author": "VonC",
... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367862",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38973/"
] |
367,863 | <p>I've got the following two tables (in MySQL):</p>
<pre><code>Phone_book
+----+------+--------------+
| id | name | phone_number |
+----+------+--------------+
| 1 | John | 111111111111 |
+----+------+--------------+
| 2 | Jane | 222222222222 |
+----+------+--------------+
Call
+----+------+--------------+
| id | date | phone_number |
+----+------+--------------+
| 1 | 0945 | 111111111111 |
+----+------+--------------+
| 2 | 0950 | 222222222222 |
+----+------+--------------+
| 3 | 1045 | 333333333333 |
+----+------+--------------+
</code></pre>
<p>How do I find out which calls were made by people whose <code>phone_number</code> is not in the <code>Phone_book</code>? The desired output would be:</p>
<pre><code>Call
+----+------+--------------+
| id | date | phone_number |
+----+------+--------------+
| 3 | 1045 | 333333333333 |
+----+------+--------------+
</code></pre>
| [
{
"answer_id": 367865,
"author": "Alnitak",
"author_id": 6782,
"author_profile": "https://Stackoverflow.com/users/6782",
"pm_score": 10,
"selected": true,
"text": "SELECT *\nFROM Call\nWHERE phone_number NOT IN (SELECT phone_number FROM Phone_book)\n"
},
{
"answer_id": 3678... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367863",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21709/"
] |
367,870 | <p>If someone logs on to my application this user contains a dictionary with certain permissions.</p>
<pre><code>ex: module.view.workspace = true
module.view.reporting = false
...
</code></pre>
<p>Then we know to what parts of the application the user has access.
What I want to know is how we can apply these permissions on the view.
We are working in an AS 3 (FLEX) environment.</p>
<p>This is what we came up with so far (but I wanna have an idea of other possibilities).
We have a modelLocator storing the loggedOnUser (which contains it's permissions).
these permissions are added to a permissionObject in the modellocator.
We Create a SecurityManager class that has a function called hasAccess("permission").
This object will check the PermissionObject in the modellocator and return true/false.
In the view we just check if the user has access and then show the control.</p>
<pre><code>If (SecurityManager.hasAccess("module.view.workspace") {
// code that generates the workspace;
}
</code></pre>
<p>I just don't know if this is the best practice.
Please help me out here.</p>
| [
{
"answer_id": 367865,
"author": "Alnitak",
"author_id": 6782,
"author_profile": "https://Stackoverflow.com/users/6782",
"pm_score": 10,
"selected": true,
"text": "SELECT *\nFROM Call\nWHERE phone_number NOT IN (SELECT phone_number FROM Phone_book)\n"
},
{
"answer_id": 3678... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367870",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29964/"
] |
367,884 | <blockquote>
<p>Possible duplicate
<a href="https://stackoverflow.com/questions/90871/debug-vs-release-in-net">Debug Visual Studio Release in .NET</a></p>
</blockquote>
<p>What is the difference between Debug and Release in Visual Studio?</p>
| [
{
"answer_id": 367903,
"author": "foraidt",
"author_id": 27596,
"author_profile": "https://Stackoverflow.com/users/27596",
"pm_score": 3,
"selected": false,
"text": "MFC90D.DLL"
},
{
"answer_id": 33577702,
"author": "jxramos",
"author_id": 1330381,
"author_profile": "... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367884",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45624/"
] |
367,905 | <p>All the generated webservice-stubs from our backend have an equals-method similar to this one:</p>
<pre><code>private java.lang.Object __equalsCalc = null;
public synchronized boolean equals(java.lang.Object obj) {
if (!(obj instanceof PropertyData)) return false;
PropertyData other = (PropertyData) obj;
if (obj == null) return false;
if (this == obj) return true;
if (__equalsCalc != null) {
return (__equalsCalc == obj);
}
__equalsCalc = obj;
boolean _equals;
_equals = true &&
((this.key==null && other.getKey()==null) ||
(this.key!=null &&
this.key.equals(other.getKey()))) &&
((this.value==null && other.getValue()==null) ||
(this.value!=null &&
this.value.equals(other.getValue())));
__equalsCalc = null;
return _equals;
}
</code></pre>
<p>Can someone please explain to me the purpoise of <code>__equalsCalc</code>? I just don't get it. It is not used somewhere else in the class. The way I see it, it is not null exactly during the calculation of the "equality". However the equals is declared <code>synchronized</code>. Therefore only one thread can be in it at any given time.
I can't see, why <code>if (__equalsCalc != null)</code> should ever be true.</p>
<p>Please show me my stupid misunderstanding ;-)</p>
<p>EDIT: I am new to the project and therefore my answer may be wrong. But if I trace it correctly, the method is generated by axis-wsdl2java</p>
| [
{
"answer_id": 367911,
"author": "David Santamaria",
"author_id": 24097,
"author_profile": "https://Stackoverflow.com/users/24097",
"pm_score": -1,
"selected": false,
"text": "__equalsCalc = null;\n"
},
{
"answer_id": 367923,
"author": "Jon Skeet",
"author_id": 22656,
... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367905",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1870/"
] |
367,907 | <p>I'm trying to follow the directions from this page:<br>
<a href="http://www.opengl.org/resources/faq/technical/color.htm" rel="nofollow noreferrer">http://www.opengl.org/resources/faq/technical/color.htm</a><br>
regarding rendering primitives with a unique color</p>
<p>I've checked the number of bits for every color and the result was 8 for each.<br>
When calling:</p>
<pre><code> glColor3ui(0x80000000, 0, 0xFF000000);
</code></pre>
<p>and reading back the pixel with glReadPixels() I get the color: <code>0xFFFE007F</code><br>
which corresponts to <code>R=0x7F, G=0, B=0xFE</code><br>
The two lower bits of Red and Blue are wrong.</p>
<p>Why is that?<br>
I'm using a brand new nVidia card on a dell laptop with the most current drivers</p>
| [
{
"answer_id": 367921,
"author": "schnaader",
"author_id": 34065,
"author_profile": "https://Stackoverflow.com/users/34065",
"pm_score": 1,
"selected": false,
"text": "In either event, you'll need to ensure that any state that could\naffect the final color has been disabled. The followin... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367907",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9611/"
] |
367,914 | <p>Say I have accepted() a connection to my server (that runs on a Solaris) and the client has closed the connection. What is the state of the socket (in netstat categories) of the socket on the server side before I close() it on the server side? Is it BOUND?</p>
| [
{
"answer_id": 5734167,
"author": "user595997",
"author_id": 595997,
"author_profile": "https://Stackoverflow.com/users/595997",
"pm_score": 0,
"selected": false,
"text": "CLOSE_WAIT"
}
] | 2008/12/15 | [
"https://Stackoverflow.com/questions/367914",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7593/"
] |
367,934 | <p>Having read an existing post on <a href="https://stackoverflow.com/questions/305605/weird-scope-issue-in-bat-file">stackoverflow</a> and done some reading around on the net. I thought it was time to post my question before I lost too much hair!</p>
<p>I have the following code within a batch file which I double click to run, under Windows XP SP3:</p>
<pre><code>SETLOCAL ENABLEDELAYEDEXPANSION
::Observe variable is not defined
SET test
::Define initial value
SET test = "Two"
::Observe initial value is set
SET test
::Verify if the contents of the variable matches our condition
If "!test!" == "Two" GOTO TWO
::First Place holder
:ONE
::Echo first response
ECHO "One"
::Second Place holder
:TWO
::Echo second response
ECHO "Two"
::Await user input
PAUSE
ENDLOCAL
</code></pre>
<p>Basically I am trying to establish if I can navigate through my script using conditionals. It seems apparent that I am getting some issues with variable scope and delayed variable expansion yet I'm a little lost on what I'm doing wrong.</p>
<p>Can anyone point me in the right direction?</p>
| [
{
"answer_id": 368076,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 4,
"selected": true,
"text": "@echo off\n\nSETLOCAL ENABLEDELAYEDEXPANSION\n\n::Observe variable is not defined\nSET test\n\n::Define initial value\nSE... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367934",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40593/"
] |
367,940 | <p>I hope it is correct term-wise to say that components in a GUI is like JButton, JPanel, JTextField, all that good stuff.</p>
<p>I want to create a text field that takes in an integer. Then a submit button can be pressed and based on the integer that was inputted, create that many textfields in a popup window or whatever.</p>
<p>I have no clue, could someone get me started in the right direction?</p>
<p>The trouble I'm having is that I have no clue how to create a for loop to create the GUI components. I mean if I have a for loop and do something like:</p>
<pre><code>print("JTextField num1 = new JTextField()");
</code></pre>
<p>then in a for loop it will only create 1 text field when I want many. How do I generically create variables of JTextFields?</p>
<p>Thanks for your help...</p>
| [
{
"answer_id": 367943,
"author": "Mario Ortegón",
"author_id": 2309,
"author_profile": "https://Stackoverflow.com/users/2309",
"pm_score": 0,
"selected": false,
"text": "List fields = new ArrayList();\n\n// Create as many elements as you need\nfor (int i = 0; i < numberOfElements; i++){\... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367940",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51518/"
] |
367,947 | <p>What is the c# equivalent of the following c++:</p>
<pre><code>srand((unsigned)(time(NULL)));
weight=(double)(rand())/(RAND_MAX/2) - 1;
</code></pre>
| [
{
"answer_id": 367955,
"author": "schnaader",
"author_id": 34065,
"author_profile": "https://Stackoverflow.com/users/34065",
"pm_score": 2,
"selected": false,
"text": "Random rnd = new Random((int)DateTime.Now.Ticks);\nreturn rnd.Next(-1,1);\n"
},
{
"answer_id": 368942,
"auth... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367947",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
367,966 | <p>For testing purposes I'm planning to put together a little app that will listen for a particular event coming from an application and interact with it at that point. </p>
<p>Given that we're at a point in the testing process where changing the application code is out of the question, the ideal from my point of view would be to listen to the debugging trace from the application, a little like debugview does, and respond to that.</p>
<p>Can anyone offer guidance on how best to go about this?</p>
| [
{
"answer_id": 368028,
"author": "Arnout",
"author_id": 3496,
"author_profile": "https://Stackoverflow.com/users/3496",
"pm_score": 1,
"selected": false,
"text": "System.Diagnostics"
},
{
"answer_id": 374392,
"author": "glenatron",
"author_id": 15394,
"author_profile"... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367966",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15394/"
] |
367,971 | <p>Is there a function, that clears last line in command prompt? I dont mean "cls" - it clears the whole sreen, I want to delete just the last line.</p>
<p>e.g. I am searching for a file in a folder and its subfolders and I want to print to cmd current folder - but I want to rewrite it, when the folder changes, not just append to the end. I know, this is just a banality, but I am interested how could be it done.</p>
| [
{
"answer_id": 367977,
"author": "shoosh",
"author_id": 9611,
"author_profile": "https://Stackoverflow.com/users/9611",
"pm_score": 2,
"selected": false,
"text": "\"\\r\""
},
{
"answer_id": 368108,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367971",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46289/"
] |
367,984 | <p>What C++ HTTP frameworks are available that will help in adding HTTP/SOAP serving support to an application?</p>
| [
{
"answer_id": 36845066,
"author": "Vinnie Falco",
"author_id": 150679,
"author_profile": "https://Stackoverflow.com/users/150679",
"pm_score": 2,
"selected": false,
"text": "#include <beast/http.hpp>\n#include <boost/asio.hpp>\n#include <iostream>\n#include <string>\n\nint main()\n{\n ... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367984",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9789/"
] |
368,001 | <p>I have a .NET assembly which I have exposed to COM via a tlb file, and an installer which registers the tlb. I have manually checked that the installer works correctly and that COM clients can access the library. So far, so good...</p>
<p>However, I am trying to put together some automated system tests which check that the installer is working correctly. As part of that I have automated the installation on a VM, and I now want to make some calls to the installed COM library to verify that it is working correctly. I originally thought about writing some tests in VB6, but I already have a large suite of tests written in C#, which reference the .NET assembly. I was hoping that I could change these to reference the .tlb, but I get an error when I try this within VS2008:</p>
<p>The ActiveX type library 'blah.tlb' was exported from a .NET assembly and cannot be added as a reference.</p>
<p>Is there any way I can fool VS2008 into allowing me to add this reference, perhaps by editing the tlb file? </p>
<p>Googling hasn't come up with any solutions. All I've found is a Microsoft Connect article stating that this is "By Design": <a href="http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=120882" rel="noreferrer">http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=120882</a></p>
| [
{
"answer_id": 5707462,
"author": "Warren",
"author_id": 479921,
"author_profile": "https://Stackoverflow.com/users/479921",
"pm_score": 5,
"selected": true,
"text": "using System;\nclass ComClass\n{\n public bool CallFunction(arg1, arg2)\n {\n Type ComType;\n object ... | 2008/12/15 | [
"https://Stackoverflow.com/questions/368001",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32413/"
] |
368,003 | <p>I have a single spool mbox file that was created with evolution, containing a selection of emails that I wish to print. My problem is that the emails are not placed into the mbox file chronologically. I would like to know the best way to place order the files from first to last using bash, perl or python. I would like to oder by received for files addressed to me, and sent for files sent by me. Would it perhaps be easier to use maildir files or such?</p>
<p>The emails currently exist in the format:</p>
<pre><code>From x@blah.com Fri Aug 12 09:34:09 2005
Message-ID: <42FBEE81.9090701@blah.com>
Date: Fri, 12 Aug 2005 09:34:09 +0900
From: me <x@blah.com>
User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716)
X-Accept-Language: en-us, en
MIME-Version: 1.0
To: someone <someone@hotmail.com>
Subject: Re: (no subject)
References: <BAY101-F9353854000A4758A7E2CCA9BD0@phx.gbl>
In-Reply-To: <BAY101-F9353854000A4758A7E2CCA9BD0@phx.gbl>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
Status: RO
X-Status:
X-Keywords:
X-UID: 371
X-Evolution-Source: imap://x+blah.com@blah.com/
X-Evolution: 00000002-0010
Hey
the actual content of the email
someone wrote:
> lines of quotedtext
</code></pre>
<p>I am wondering if there is a way to use this information to easily reorganize the file, perhaps with perl or such.</p>
| [
{
"answer_id": 368067,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 5,
"selected": true,
"text": "#!/usr/bin/python2.5\nfrom email.utils import parsedate\nimport mailbox\n\ndef extract_date(email):\n date = email.get('Date... | 2008/12/15 | [
"https://Stackoverflow.com/questions/368003",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1246613/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.