qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
274,465
<p>I have some question:</p> <p>How to make a role based web application? Such as in forum sites, there is many user types, admin, moderator etc... is the roles of these user types stored in database or web.config? And when a user login to our site, how to control this users roles? In short I want to learn about authorization and authentication. </p> <p>Thanks..</p>
[ { "answer_id": 274486, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 1, "selected": true, "text": "TblUsers:\n-----------------------------------------------------------------\n| UserID (PK) | UserName | HashedPassword | Per...
2008/11/08
[ "https://Stackoverflow.com/questions/274465", "https://Stackoverflow.com", "https://Stackoverflow.com/users/439507/" ]
274,469
<p>This works (prints, for example, “3 arguments”):</p> <pre><code>to run argv do shell script "echo " &amp; (count argv) &amp; " arguments" end run </code></pre> <p>This doesn't (prints only “Argument 3: three”, and not the previous two arguments):</p> <pre><code>to run argv do shell script "echo " &amp; (count argv) &amp; " arguments" repeat with i from 1 to (count argv) do shell script "echo 'Argument " &amp; i &amp; ": " &amp; (item i of argv) &amp; "'" end repeat end run </code></pre> <p>In both cases, I'm running the script using <code>osascript</code> on Mac OS X 10.5.5. Example invocation:</p> <pre><code>osascript 'Script that takes arguments.applescript' Test argument three </code></pre> <p>I'm not redirecting the output, so I know that the script is not throwing an error.</p> <p>If I add a <code>display dialog</code> statement above the <code>do shell script</code>, it throws a “no user interaction allowed” error, so I know that it is executing the loop body.</p> <p>What am I doing wrong? What is it about this loop that causes osascript to not print anything?</p>
[ { "answer_id": 274526, "author": "Sören Kuklau", "author_id": 1600, "author_profile": "https://Stackoverflow.com/users/1600", "pm_score": 0, "selected": false, "text": "do shell script" }, { "answer_id": 274541, "author": "tvanfosson", "author_id": 12950, "author_prof...
2008/11/08
[ "https://Stackoverflow.com/questions/274469", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30461/" ]
274,474
<p>My usage case is compiling generated source files from a java program using the ToolProvider and JavaCompiler classes provided in JDK 6. The source files contain references to classes in the context classloader (it runs in a J2EE container), but not in the system classloader. My understanding is that by default the ToolProvider will create the JavaCompiler instance with the system classloader.</p> <p>Is there a way to specify a classloader for JavaCompiler to use?</p> <p>I tried this approach, modified from something on IBM DeveloperWorks:</p> <pre><code>FileManagerImpl fm = new FileManagerImpl(compiler.getStandardFileManager(null, null, null);); </code></pre> <p>with FileManagerImpl defined as:</p> <pre><code>static final class FileManagerImpl extends ForwardingJavaFileManager&lt;JavaFileManager&gt; { public FileManagerImpl(JavaFileManager fileManager) { super(fileManager); } @Override public ClassLoader getClassLoader(JavaFileManager.Location location) { new Exception().printStackTrace(); return Thread.currentThread().getContextClassLoader(); } } </code></pre> <p>The stacktrace indicates it's only called once during annotation processing. I verified the class referenced in the source file to be compiled is not on the system classpath but is available from the context classloader.</p>
[ { "answer_id": 665896, "author": "Leihca", "author_id": 74289, "author_profile": "https://Stackoverflow.com/users/74289", "pm_score": 3, "selected": false, "text": " StandardJavaFileManager fileManager = compiler.getStandardFileManager(this /* diagnosticlistener */, null, null);\n// g...
2008/11/08
[ "https://Stackoverflow.com/questions/274474", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33897/" ]
274,482
<p>I am just getting started with CodeIgniter, and I am trying to hash out my regular modules/functions to get them working properly within the MVC framework. I have a few specific questions for anyone who has a strong CodeIgniter background:</p> <p><strong>SESSIONS</strong></p> <p>The CodeIgniter session stores session data on the client side in a cookie, which just isn't going to work for me. I know there are a few replacements for it, or I could build my own library/helper; but I just don't see any benefit over just using <code>$_SESSION</code>.</p> <p>If I just use <code>$_SESSION</code>, will I have any problems with the rest of the framework? Does any other part of the framework depend on using the CodeIgniter session?</p> <p>I feel a bit weird about stepping outside the framework for something so basic, but I am pretty comfortable with plain PHP. I am basically just looking to use CodeIgniter for MVC, and to enforce a more modular aspect for my projects.</p> <p><strong>CODE FLOW &amp; CONFIG</strong></p> <p>I have a few config items that need to be done before almost anything else. </p> <p>For example, say I have a constant <code>APP_LIVE</code>, which is set true/false based on the name of the current server. This has to happen really early as paths, error reporting, the CodeIgniter system, and application folders, etc. will be set based on it.</p> <p>The problem is that the <code>system_folder</code>, and <code>application_folder</code> (which will be set based on which server the code is running on) are set first thing in the <code>index.php</code> file, before any of the configs have loaded.</p> <p>Also, I have a functions that check for things in the URL, and may redirect before the page ever loads. For example, some pages need to enfore the presence of <code>www.</code> in the URL (for SEO), track affiliates, visitor sources, marketing flags, etc.</p> <p>Where is the best place to put things like this that have to happen really early? I know there is a config file, an autoload file, a constants file, etc., but those are too late for some items. Is it a bad practice to simply put these things into the top of the main <code>index.php</code> file, or to make an include there to a global config file? Again, I feel like I am stepping outside the framework, and wonder if I'm just doing that because I don't have a solid understanding of it yet?</p> <p><strong>LAYOUT / HEADER FOOTER</strong></p> <p>Like most people, I have a top header, navigation, footer, etc. I am used to just having them in files, which are included into my page template. I believe I can do that the same way by just making them views and including them into my main page view. Is that the best way to go? Some of them need a bit of data; like what page they are on for the navigation, etc. What's the best way to handle navigation, shared header/footer, etc.?</p>
[ { "answer_id": 274506, "author": "John McCollum", "author_id": 22946, "author_profile": "https://Stackoverflow.com/users/22946", "pm_score": 2, "selected": false, "text": "$data['title'] = 'about us';\n$data['content'] = 'hello world!';\n\n$this->load->view('headerview', $data);\n$this->...
2008/11/08
[ "https://Stackoverflow.com/questions/274482", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27580/" ]
274,493
<p>When copying large files using <code>shutil.copy()</code>, you get no indication of how the operation is progressing..</p> <p>I have put together something that works - it uses a simple ProgressBar class (which simple returns a simple ASCII progress bar, as a string), and a loop of <code>open().read()</code> and <code>.write()</code> to do the actual copying. It displays the progress bar using <code>sys.stdout.write("\r%s\r" % (the_progress_bar))</code> which is a little hackish, but it works.</p> <p>You can see the code (in context) <a href="http://github.com/dbr/checktveps/tree/1be8f4445fbf766eba25f98f78ec52e955571608/autoPathTv.py#L64-153" rel="noreferrer">on github here</a></p> <p>Is there any built-in module that will do this better? Is there any improvements that can be made to this code?</p>
[ { "answer_id": 274497, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 5, "selected": true, "text": "copy_with_prog" }, { "answer_id": 275945, "author": "Jim Carroll", "author_id": 35922, "author_profile...
2008/11/08
[ "https://Stackoverflow.com/questions/274493", "https://Stackoverflow.com", "https://Stackoverflow.com/users/745/" ]
274,496
<p>I've built web apps before that utilize phpBB session, and user data. The common move is to use code like this:</p> <pre><code>define('IN_PHPBB', true); //replace $phpbb_root_path with path to your forum $phpbb_root_path = '../forum/'; $phpEx = substr(strrchr(__FILE__, '.'), 1); include($phpbb_root_path . 'common.' . $phpEx); // Start session management $user-&gt;session_begin(); $auth-&gt;acl($user-&gt;data); $user-&gt;setup(); </code></pre> <p>However, by including <code>common.php</code>, I bring along a crap-load of other methods that run into other methods I've got setup.</p> <p>In my example, I'm running the application using CodeIgniter, which already has a "redirect" method. This question should apply to anyone who has pre-built methods that may run into the phpBB methods.</p> <p>Basically, all I need to do is:</p> <ol> <li>Make sure the user is logged in <code>$user-&gt;data[username] == Anonymous</code></li> <li>Utilize data from '$user->data' such as the user's ID, screenname, etc.</li> </ol> <p>Could I grab the <code>$user-&gt;data</code> array, and somehow save it to my own session? Does anyone have any ideas on this? Thanks in advance!</p>
[ { "answer_id": 274497, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 5, "selected": true, "text": "copy_with_prog" }, { "answer_id": 275945, "author": "Jim Carroll", "author_id": 35922, "author_profile...
2008/11/08
[ "https://Stackoverflow.com/questions/274496", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24708/" ]
274,512
<p>I'm going to have my website hosted soon on a VPS or dedicated server (with Windows 2008), so I'm trying to plan ahead. I wonder whether the built-in SMTP server that comes with IIS7 is reliable enough for a production server or should I look for an alternative? I heard good things about hmailserver and best of all it's free, do you have any experience with using the bulit-in SMTP on a high traffic website.</p> <p>Thanks a lot for any suggestions</p>
[ { "answer_id": 10336338, "author": "Jess Coburn", "author_id": 489393, "author_profile": "https://Stackoverflow.com/users/489393", "pm_score": 2, "selected": false, "text": "VPS/Dedicated" } ]
2008/11/08
[ "https://Stackoverflow.com/questions/274512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/676066/" ]
274,523
<p>if Form.Release is called after using the form, it will free all related memory but not set the form variable to nil.</p> <pre><code>if not assigned (Form1) then begin Application.CreateForm(Tform1, Form1); try // Do something finally Form1.Release end; end; </code></pre> <p>To be able to call the same code again, Form1 would have to be set to nil at some point. From the description of Release I cannot do</p> <pre><code>Form1 := nil; </code></pre> <p>right after Release, because the Release procedure will return directly after being called and before the form is actually freed. I cannot detect when Form.Release is finished to set the form var to nil.</p> <p>What is the best way to do this?</p>
[ { "answer_id": 274535, "author": "Roddy", "author_id": 1737, "author_profile": "https://Stackoverflow.com/users/1737", "pm_score": 1, "selected": false, "text": "FreeAndNil(Form1)\n" }, { "answer_id": 274546, "author": "Community", "author_id": -1, "author_profile": "...
2008/11/08
[ "https://Stackoverflow.com/questions/274523", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5015/" ]
274,529
<p>Am working with django Publisher example, I want to list all the publishers in the db via my list_publisher.html template, my template looks like;</p> <pre><code>{% extends "admin/base_site.html" %} {% block title %}List of books by publisher{% endblock %} {% block content %} &lt;div id="content-main"&gt; &lt;h1&gt;List of publisher:&lt;/h1&gt; {%regroup publisher by name as pub_list %} {% for pub in pub_list %} &lt;li&gt;{{ pub.name }}&lt;/li&gt; {% endfor %} &lt;/div&gt; {% endblock %} </code></pre> <p>but when I run "<a href="http://127.0.0.1:8000/list_publisher/" rel="nofollow noreferrer">http://127.0.0.1:8000/list_publisher/</a>" the template just prints the page title with no error! What am I doing wrong?</p>
[ { "answer_id": 274537, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 3, "selected": true, "text": "{% block content %}{% endblock %}" }, { "answer_id": 274975, "author": "Peter Rowell", "author_id": 17017, "...
2008/11/08
[ "https://Stackoverflow.com/questions/274529", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26143/" ]
274,560
<p>Is there an easy way to verify that a given private key matches a given public key? I have a few <code>*.pub</code>and a few <code>*.key</code> files, and I need to check which go with which.</p> <p>Again, these are pub/key files, DSA.</p> <p>I would really prefer a one-liner of some sort...</p>
[ { "answer_id": 274570, "author": "Martin v. Löwis", "author_id": 33006, "author_profile": "https://Stackoverflow.com/users/33006", "pm_score": 4, "selected": false, "text": " openssl x509 -in certfile -modulus -noout\n" }, { "answer_id": 274622, "author": "Martin v. Löwis"...
2008/11/08
[ "https://Stackoverflow.com/questions/274560", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17324/" ]
274,567
<p>Can someone please derive a concrete example from the following:</p> <p><a href="http://www.urdalen.com/blog/?p=210" rel="nofollow noreferrer">http://www.urdalen.com/blog/?p=210</a></p> <p>..that shows how to deal with <code>one-to-many</code> and <code>many-to-many</code> relationships?</p> <p>I've emailed the author some time ago but received no reply. I like his idea, but can't figure out how to implement it beyond simple single table relations.</p> <p>Note: I don't want to use a full-blown ORM. I like doing my SQL by hand. I would like to improve the design of my app code though. Right now each domain object has its own class full of queries wrapped in static methods. They just return scalar, 1d-array (record) or 2d-array (recordset) depending on the query.</p>
[ { "answer_id": 274684, "author": "troelskn", "author_id": 18180, "author_profile": "https://Stackoverflow.com/users/18180", "pm_score": 4, "selected": true, "text": "$car42 = $car_gateway->fetch(42);\n$wheels = $wheel_gateway->selectByCar($car42);\n" } ]
2008/11/08
[ "https://Stackoverflow.com/questions/274567", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
274,575
<p>While LOC (# lines of code) is a problematic measurement of a code's complexity, it is the most popular one, and when used very carefully, can provide a rough estimate of at least relative complexities of code bases (i.e. if one program is 10KLOC and another is 100KLOC, written in the same language, by teams of roughly the same competence, the second program is almost certainly much more complex).</p> <p>When counting lines of code, do you prefer to count comments in ? What about tests? </p> <p>I've seen various approaches to this. Tools like cloc and sloccount allow to either include or exclude comments. Other people consider comments part of the code and its complexity. </p> <p>The same dilemma exists for unit tests, that can sometimes reach the size of the tested code itself, and even exceed it.</p> <p>I've seen approaches all over the spectrum, from counting only "operational" non-comment non-blank lines, to "XXX lines of tested, commented code", which is more like running "wc -l on all code files in the project".</p> <p>What is your personal preference, and why?</p>
[ { "answer_id": 274600, "author": "Treb", "author_id": 22114, "author_profile": "https://Stackoverflow.com/users/22114", "pm_score": 1, "selected": false, "text": "for (int i = 0; i < list.count; i++)\n{\n // do some stuff\n}\n\nfor (int i = 0; i < list.count; i++){\n // do some stu...
2008/11/08
[ "https://Stackoverflow.com/questions/274575", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8206/" ]
274,586
<p>In ASP.NET MVC, I'm trying to create a link that includes an anchor tag (that is, directing the user to a page, and a specific section of the page).</p> <p>The URL I am trying to create should look like the following:</p> <pre><code>&lt;a href="/category/subcategory/1#section12"&gt;Title for a section on the page&lt;/a&gt; </code></pre> <p>My routing is set up with the standard: </p> <pre><code>routes.MapRoute("Default", "{controller}/{action}/{categoryid}"); </code></pre> <p>The action link syntax that I am using is: </p> <pre><code>&lt;%foreach (Category parent in ViewData.Model) { %&gt; &lt;h3&gt;&lt;%=parent.Name %&gt;&lt;/h3&gt; &lt;ul&gt; &lt;%foreach (Category child in parent.SubCategories) { %&gt; &lt;li&gt;&lt;%=Html.ActionLink&lt;CategoryController&gt;(x =&gt; x.Subcategory(parent.ID), child.Name) %&gt;&lt;/li&gt; &lt;%} %&gt; &lt;/ul&gt; &lt;%} %&gt; </code></pre> <p>My controller method is as follows:</p> <pre><code>public ActionResult Subcategory(int categoryID) { //return itemList return View(itemList); } </code></pre> <p>The above correctly returns a URL as follows:</p> <pre><code>&lt;a href="/category/subcategory/1"&gt;Title for a section on the page&lt;/a&gt; </code></pre> <p>I can't figure out how to add the <strong>#section12</strong> part. The "section" word is just the convention I am using to break up the page sections, and the 12 is the ID of the subcategory, i.e., child.ID.</p> <p>How can I do this?</p>
[ { "answer_id": 274637, "author": "LorenzCK", "author_id": 3118, "author_profile": "https://Stackoverflow.com/users/3118", "pm_score": 8, "selected": true, "text": "<a href=\"<%=Url.Action(\"Subcategory\", \"Category\", new { categoryID = parent.ID }) %>#section12\">link text</a>\n" }, ...
2008/11/08
[ "https://Stackoverflow.com/questions/274586", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29092/" ]
274,619
<p>My platform: Visual C# 2008 Express Edition with NUnit 2.2.7</p> <p>I have a solution with my code in one project and my NUnit unit tests in a different project in the same solution.</p> <p>I have been struggling hard to debug and single-step through the NUnit tests. I found some references online that suggested calling the following:</p> <pre><code>NUnit.ConsoleRunner.Runner.Main(args); </code></pre> <p>But this doesn't even compile - it has the compiler error:</p> <blockquote> <p>Error 1 The type or namespace name 'Runner' does not exist in the namespace 'NUnit.ConsoleRunner' (are you missing an assembly reference?)</p> </blockquote> <p>I've added every assembly reference I could find, to no effect.</p> <p>Finally, this is what I have hacked together and it works, but perhaps you good readers could suggest a better solution:</p> <p>1) In my test project, the class name of a test case that I want to debug is MyTestClass. It has a [TestFixtureSetUp] method named Init() and the actual test case is in [Test] function MyTest()</p> <p>2) In my code project, I have a console program TestProgram.cs which compiles to an EXE.</p> <p>In TestProgram.cs, I call the test cases in the following way</p> <pre><code>// First instantiate the test class MyTestClass tc = new MyTestClass(); // Call the TestFixtureSetup method tc.Init(); // Now call the actual test tc.MyTest(); </code></pre> <p>This works and I can debug and single step through the test cases.</p> <p>If anyone has any better suggestions using Visual Studio 2008 Express <em>without paying for additional plugins</em>, I appreciate your advice.</p>
[ { "answer_id": 274628, "author": "Kent Boogaart", "author_id": 5380, "author_profile": "https://Stackoverflow.com/users/5380", "pm_score": 2, "selected": false, "text": "Runner" }, { "answer_id": 274701, "author": "Gishu", "author_id": 1695, "author_profile": "https:/...
2008/11/08
[ "https://Stackoverflow.com/questions/274619", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18542/" ]
274,626
<p>In c++ what is object slicing and when does it occur?</p>
[ { "answer_id": 274634, "author": "David Dibben", "author_id": 5022, "author_profile": "https://Stackoverflow.com/users/5022", "pm_score": 9, "selected": false, "text": "class A {\n int foo;\n};\n\nclass B : public A {\n int bar;\n};\n" }, { "answer_id": 274636, "author": ...
2008/11/08
[ "https://Stackoverflow.com/questions/274626", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35737/" ]
274,639
<p>What the minimum basic setup required to begin developing a Firefox extension?</p>
[ { "answer_id": 274647, "author": "Balaji Sowmyanarayanan", "author_id": 35738, "author_profile": "https://Stackoverflow.com/users/35738", "pm_score": 4, "selected": false, "text": "firefox.exe -profilemanager\n" }, { "answer_id": 274663, "author": "rogeriopvl", "author_id...
2008/11/08
[ "https://Stackoverflow.com/questions/274639", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35738/" ]
274,646
<p>I am getting the following error while loading a page.</p> <p>[HttpException (0x80004005): Cannot use a leading .. to exit above the top directory.]</p> <p>No idea what to do ? Can anyone help me ?</p>
[ { "answer_id": 274688, "author": "Martin Brown", "author_id": 20553, "author_profile": "https://Stackoverflow.com/users/20553", "pm_score": 2, "selected": false, "text": "Response.Redirect(\"../SomePage.aspx\");\n" }, { "answer_id": 932170, "author": "salle55", "author_id...
2008/11/08
[ "https://Stackoverflow.com/questions/274646", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29982/" ]
274,656
<p>I've been trying to build subversion (on a limited account) for a long time but without any luck :(</p> <p>The instructions I'm following: <a href="http://wiki.dreamhost.com/Subversion_Installation" rel="nofollow noreferrer">http://wiki.dreamhost.com/Subversion_Installation</a></p> <p>Running this:</p> <pre><code>./configure --prefix=${RUN} --without-berkeley-db --with-ssl --with-zlib --enable-shared </code></pre> <p>Gives me this error:</p> <pre><code>checking for library containing RSA_new... not found configure: error: could not find library containing RSA_new configure failed for neon </code></pre> <p>Can someone explain to me:</p> <ol> <li>Possible reasons for this</li> <li>Possible ways to circumvent it</li> <li>Optional: What these modules are and what their purpose is (Neon/RSA_new)</li> </ol> <p>Thanks!</p> <h2>Log file contents:</h2> <p>Trying to find interesting bits from the neon config.log file:</p> <pre><code>configure:27693: gcc -o conftest -g -O2 conftest.c &gt;&amp;5 /tmp/ccazXdJz.o: In function `main': /home/stpinst/soft/subversion-1.5.4/neon/conftest.c:93: undefined reference to `RSA_new' collect2: ld returned 1 exit status configure:27699: $? = 1 configure: failed program was: ... | int | main () | { | RSA_new(); | ; | return 0; | } configure:27742: gcc -o conftest -g -O2 conftest.c -lcrypto -lz &gt;&amp;5 /usr/bin/ld: cannot find -lcrypto collect2: ld returned 1 exit status configure:27748: $? = 1 </code></pre> <p>--</p>
[ { "answer_id": 274661, "author": "Martin v. Löwis", "author_id": 33006, "author_profile": "https://Stackoverflow.com/users/33006", "pm_score": 3, "selected": false, "text": "aptitude install libssl-dev" }, { "answer_id": 274666, "author": "VonC", "author_id": 6309, "a...
2008/11/08
[ "https://Stackoverflow.com/questions/274656", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18274/" ]
274,668
<p>I want to be able to change the status message for Live Messenger, but everything I've found only works for the music message (see <a href="http://coldacid.net/images/screenshots/live-messenger-status-and-music-messages" rel="nofollow noreferrer">this screenshot</a> to see the difference between the two).</p> <p>It is possible to do this, as there are programs that have the ability to change it, and some alternate clients for Live Messenger can also set the status message themselves. I just need to know how to do this myself.</p> <p><strong>Clarification:</strong> The solution needs to work with the latest versions of Live Messenger (i.e. the wave 3 beta). Working with older versions is good too, but it's the 14.x versions that I'm working with.</p>
[ { "answer_id": 274676, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 1, "selected": false, "text": "/psm new message" } ]
2008/11/08
[ "https://Stackoverflow.com/questions/274668", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5697/" ]
274,753
<p>There seem to be 3 ways of telling GCC to weak link a symbol:</p> <ul> <li><code>__attribute__((weak_import))</code></li> <li><code>__attribute__((weak))</code></li> <li><code>#pragma weak symbol_name</code></li> </ul> <p>None of these work for me:</p> <pre><code>#pragma weak asdf extern void asdf(void) __attribute__((weak_import, weak)); ... { if(asdf != NULL) asdf(); } </code></pre> <p>I always get a link error like this:</p> <pre>Undefined symbols: "_asdf", referenced from: _asdf$non_lazy_ptr in ccFA05kN.o ld: symbol(s) not found collect2: ld returned 1 exit status</pre> <p>I am using GCC 4.0.1 on OS X 10.5.5. What am I doing wrong?</p>
[ { "answer_id": 730267, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": false, "text": "-Wl,-flat_namespace,-undefined,dynamic_lookup" }, { "answer_id": 3749780, "author": "Jeffrey Scofield", "autho...
2008/11/08
[ "https://Stackoverflow.com/questions/274753", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
274,762
<p>I read somewhere in the Microsoft documentation that the content of the ASP.NET's <strong>web.config is cached</strong>. If that is true, <strong>where</strong> is it cached - in <strong>memory or on disk</strong>?</p> <p>And a follow-up question: are there any performance considerations I have to make, if I have to access the web.config intensively?</p>
[ { "answer_id": 274851, "author": "AnthonyWJones", "author_id": 17516, "author_profile": "https://Stackoverflow.com/users/17516", "pm_score": 4, "selected": true, "text": "GetSection" }, { "answer_id": 67498636, "author": "Shirish Patel", "author_id": 9733212, "author_...
2008/11/08
[ "https://Stackoverflow.com/questions/274762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6461/" ]
274,785
<p>I would like to provide two different versions of my iPhone app on the App Store -- one free that is limited by the number of items displayed through the application, and another one completely unlimited.</p> <p>The source code for both apps will be exactly the same, the only difference would be the SQLite database that stores the items in the app.</p> <p>I understand that both versions of the app will need to have different bundle names, and different icons. I'm trying to find a way to avoid completely copying the source code directory to be able to customize some of these things: database, icons, nib strings, etc.</p> <p>Is there a good way to do this without duplicating everything?</p>
[ { "answer_id": 274956, "author": "mxg", "author_id": 11157, "author_profile": "https://Stackoverflow.com/users/11157", "pm_score": 3, "selected": false, "text": "#ifdef FULL_APP\n // unlimited size\n #define SIZE -1\n#else\n #define SIZE 100\n#endif\n" } ]
2008/11/08
[ "https://Stackoverflow.com/questions/274785", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35478/" ]
274,796
<p>I have the following code which plays a video clip but when it is finished it does not release the form but instead leaves the last frame of the video. how do I get it to clear when playback ends so that I can see the orignal contents of the form it took over to play the video?</p> <pre><code>_video = new Video("video.wmv"); _video.Owner = frmVideoWindow; _video.Play(); </code></pre>
[ { "answer_id": 274847, "author": "user38275", "author_id": 38275, "author_profile": "https://Stackoverflow.com/users/38275", "pm_score": 1, "selected": false, "text": "_video.Ending += new System.EventHandler(this.video_stopped);\n\nprivate void video_stopped(object sender, EventArgs e)\...
2008/11/08
[ "https://Stackoverflow.com/questions/274796", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38275/" ]
274,806
<p>I have an app built against MVC Preview 3 (referencing local copies of the MVC assemblies) that I'm trying to modify/test on a machine with the ASP.NET MVC beta installed. I am not interesting in updating this app to run against MVC beta yet - I just need to make a few small changes.</p> <p>It's failing with MissingMethodExceptions on RouteCollection.IgnoreRoutes (in global.asax.cs) because at runtime, the CLR is always finding the beta version of System.Web.Mvc in the GAC and loading this instead of the preview 3 version in my site's \bin directory.</p> <p>Since the assemblies have the same name, version and public key, I believe there's no way of distinguishing between them within web.config, so I think the only solution here is to remove the ASP.NET MVC beta assemblies from the GAC.</p> <p>Only - I can't do this, because they're installed by Windows Installer, so I can't remove them using gacutil.exe /u, and I'm getting "Access is denied" when I try and remove them directly.</p> <p>Anyone know how I can remove this assembly - or, failing that, how to run/host an app that needs System.Web.Mvc preview 3 on a system that has System.Web.Mvc beta in the GAC?</p>
[ { "answer_id": 297717, "author": "Matt Mitchell", "author_id": 364, "author_profile": "https://Stackoverflow.com/users/364", "pm_score": 0, "selected": false, "text": "System.Web.Mvc,version=\"1.0.0.0\",culture=\"neutral\",publicKeyToken=\"31BF3856AD364E35\",processorArchitecture=\"MSIL\...
2008/11/08
[ "https://Stackoverflow.com/questions/274806", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5017/" ]
274,814
<p>How do I get a list of all the headings in a word document by using VBA?</p>
[ { "answer_id": 274830, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 6, "selected": true, "text": "astrHeadings = docSource.GetCrossReferenceItems(wdRefTypeHeading)" }, { "answer_id": 276397, "author": "JonnyGold", ...
2008/11/08
[ "https://Stackoverflow.com/questions/274814", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35762/" ]
274,822
<p>How do I check for an open connection in jdbc for oracle database?</p> <p>Note: <code>conn.isClosed()</code> cannot be used for this.</p>
[ { "answer_id": 274870, "author": "RealHowTo", "author_id": 25122, "author_profile": "https://Stackoverflow.com/users/25122", "pm_score": 3, "selected": false, "text": "Statement stmt = null;\nResultSet rs =null;\ntry {\n stmt = conn.createStatement();\n // oracle\n rs = stmt.execut...
2008/11/08
[ "https://Stackoverflow.com/questions/274822", "https://Stackoverflow.com", "https://Stackoverflow.com/users/450206/" ]
274,823
<p>(This is a question about the UI rather than the technology required to do it)</p> <p>What is the clearest way to display a time for events occurring in different timezones to a user? Does your "average" user understand UTC and timezones?</p> <p>We capture the local time and UTC offset and store it in the database (SQL 2008 DateTimeOffset) for events happening in different timezones. Users are also in a variety of timezones.</p> <p>I'll suggest a couple of answers below so they can be rated but I'd appreciate alternative suggestions.</p> <p>EDIT: I'd like to avoid displaying the time in the user's timezone. Users in different timezones will be discussing the same events and if they're local to different timezones, there'll be confusion.</p> <p>EDIT: I wanted to make the question generic and hopefully useful to more people but for some specific context, this is a web application for tracking parcels (think FedEx). Parcels will cross timezones. Customer support is in the UK but the recipient may be elsewhere.</p>
[ { "answer_id": 274832, "author": "Toby Allen", "author_id": 6244, "author_profile": "https://Stackoverflow.com/users/6244", "pm_score": 2, "selected": false, "text": "15:18 GMT+1\n" }, { "answer_id": 327294, "author": "benc", "author_id": 2910, "author_profile": "http...
2008/11/08
[ "https://Stackoverflow.com/questions/274823", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1456/" ]
274,826
<p>When I use <code>DateTime.Now</code> I get the date and time from the server point of view. Is there any way to get the <em>client</em> date and time in ASP.NET?</p>
[ { "answer_id": 274987, "author": "Ryan", "author_id": 29762, "author_profile": "https://Stackoverflow.com/users/29762", "pm_score": 4, "selected": false, "text": "<script language=\"javascript\">\nfunction checkClientTimeZone()\n{\n // Set the client time zone\n var dt = new Date()...
2008/11/08
[ "https://Stackoverflow.com/questions/274826", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34096/" ]
274,840
<p>I have a Perl module that I would like to use from Java. Is there a way to call this code using either ActiveState Perl on Windows or the generic Perl that comes with Linux? I have found references to JPL but it doesn’t appear to be maintained anymore.</p>
[ { "answer_id": 274849, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 5, "selected": true, "text": "org.perl.inline.java.InlinePerlCaller" }, { "answer_id": 274886, "author": "Olie", "author_id": 34820, "auth...
2008/11/08
[ "https://Stackoverflow.com/questions/274840", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14744/" ]
274,841
<p>I am writing multi-thread socket chat in C++Builder 2009.<br> It is almost complete in accordance with what I need to do but I have a little problem. I need to pass the TMemo* pointer into CreateThread WinAPI function which upcasts it to void*.</p> <p>I tryed this way:<br></p> <pre><code>HANDLE xxx = MemoChat-&gt;Handle; hNetThread = CreateThread(NULL, 0, NetThread, xxx, 0, &amp;dwNetThreadId); //... </code></pre> <p>and then, in NetThread function,</p> <pre><code>TMemo* MyMemo((HANDLE)lpParam); TMemo* MyMemo((TMemo*)lpParam); </code></pre> <p>but it didn`t work:(</p> <p>The question is how I can really downcast it correctly so I can use my Memo Component in this new thread?</p>
[ { "answer_id": 274856, "author": "Martin v. Löwis", "author_id": 33006, "author_profile": "https://Stackoverflow.com/users/33006", "pm_score": 2, "selected": false, "text": "hNetThread = CreateThread(NULL, 0, NetThread, MemoChat, 0, &dwNetThreadId);\n" }, { "answer_id": 275036, ...
2008/11/08
[ "https://Stackoverflow.com/questions/274841", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28298/" ]
274,843
<p>I have some elements on a page which are draggable. These same elements have a click event which navigates to another page. I'm trying to determine the best way of preventing the click event from firing if the user is dragging but still allow the click event if not dragging. Anyone have any ideas of the best way to accomplish this?</p>
[ { "answer_id": 274875, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 0, "selected": false, "text": "new Draggable('tag', \n {\n revert:function()\n {\n $('tag').onclick = function(){return false;};\...
2008/11/08
[ "https://Stackoverflow.com/questions/274843", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22436/" ]
274,857
<p>is there an easy way to reset ALL text fields in an asp.net form - like the reset button for html controls?</p>
[ { "answer_id": 274866, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 2, "selected": false, "text": "document.forms[0].reset();\n" }, { "answer_id": 274871, "author": "aanund", "author_id": 7335, "aut...
2008/11/08
[ "https://Stackoverflow.com/questions/274857", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
274,861
<p>If I have a date, how do I calculate the week number for that date within that year?</p> <p>For example, in 2008, January 1st to January 6th are in week 1 and January 7th to the 13th are in week 2, so if my date was January 10th 2008, my week number would be 2.</p> <p>An algorithm would be great to get me started and sample code would also help - I'm developing in C++ on Windows.</p> <h3>Related:</h3> <blockquote> <p><a href="https://stackoverflow.com/questions/348880/getting-week-number-off-a-date-in-ms-sql-server-2005">Getting week number off a date in MS SQL Server 2005?</a></p> </blockquote>
[ { "answer_id": 274913, "author": "Olie", "author_id": 34820, "author_profile": "https://Stackoverflow.com/users/34820", "pm_score": 6, "selected": true, "text": "int julian = getDayOfYear(myDate) // Jan 1 = 1, Jan 2 = 2, etc...\nint dow = getDayOfWeek(myDate) // Sun = 0, Mon = 1, et...
2008/11/08
[ "https://Stackoverflow.com/questions/274861", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15669/" ]
274,865
<p>I am modifying some code and came across a declaration that I am having trouble understanding:</p> <pre><code>int *userMask[3][4] = {0}; </code></pre> <p>What exactly is this pointing to? Is it a matrix where every element is a pointer? Or is it pointing to a matrix of size [3][4]?</p> <p>Thanks</p> <hr> <p>I guess my question is how <code>userMask[2][maskElement][user]</code> can work when it is declared as <code>int</code>. Wouldn't userMask have to be <code>int[]</code> for that to work properly? I must not be understanding this right...</p> <p>On a side note, thanks for your suggestion about cdecl Robert. However, does anyone know how to use it in an XP command prompt? All I can get is syntax error :(</p>
[ { "answer_id": 274869, "author": "ChrisN", "author_id": 3853, "author_profile": "https://Stackoverflow.com/users/3853", "pm_score": 4, "selected": false, "text": "int" }, { "answer_id": 274874, "author": "martjno", "author_id": 3373, "author_profile": "https://Stackov...
2008/11/08
[ "https://Stackoverflow.com/questions/274865", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35767/" ]
274,892
<p>I have information spread out across a few databases and want to put all the information onto one webpage using PHP. I was wondering how I can connect to multiple databases on a single PHP webpage.</p> <p>I know how to connect to a single database using:</p> <pre><code>$dbh = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); </code></pre> <p>However, can I just use multiple "mysql_connect" commands to open the other databases, and how would PHP know what database I want the information pulled from if I do have multiple databases connected.</p>
[ { "answer_id": 274919, "author": "Tom Haigh", "author_id": 22224, "author_profile": "https://Stackoverflow.com/users/22224", "pm_score": 9, "selected": true, "text": "mysql_xx" }, { "answer_id": 275013, "author": "troelskn", "author_id": 18180, "author_profile": "http...
2008/11/08
[ "https://Stackoverflow.com/questions/274892", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33194/" ]
274,894
<p>I have a bit of an unusual question. I'm running an old DOS game in dosbox under windows xp and i'm trying to determine when and where it access it's data file.</p> <p>what can i use that will give me a log of all read requests made to a file? I want to know the "when", "from" and "size" of each file read.</p> <p>I know my basic 8086/8088 assembly but nothing more. so if there's no shortcut tool available, a recommendation of a debugging tool / tutorial that can help me get on the right track can be great also.</p> <p>the game's "below the roots", if anyone can shed some light about this game's internals, it will be a great help :)</p>
[ { "answer_id": 277194, "author": "Artelius", "author_id": 31945, "author_profile": "https://Stackoverflow.com/users/31945", "pm_score": 2, "selected": false, "text": "fread()" } ]
2008/11/08
[ "https://Stackoverflow.com/questions/274894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11813/" ]
274,899
<p>How have you guys handled working with jQuery includes </p> <pre><code>&lt;script type="text/javascript" src="jquery.js"&gt;&lt;/script&gt; </code></pre> <p>in Asp.Net MVC when working with partial views/view controls? Basically, I don't want to make the jquery include in the master page because I am not using jquery in all of my views, but I also want an easy way for a user control to be able to create the jquery include in the right location ('head') without creating duplicate jquery includes.</p> <p>The best way would be to use a ScriptManaager, but I do not want to rely on ASP.Net Ajax for this in my application. Is there a 'lightweight' ScriptManager that I could use that would also allow the newly released intellisense for jquery? </p> <p>I've created a WebControl that provides this functionality, but I don't get the intellisense support for VS2008, which I would really like.</p> <p>Hope this makes sense.</p>
[ { "answer_id": 274906, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 0, "selected": false, "text": "function loadJSInclude(scriptPath, callback)\n{\n var scriptNode = document.createElement('SCRIPT');\n scriptNode.type...
2008/11/08
[ "https://Stackoverflow.com/questions/274899", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8534/" ]
274,915
<p>What is the best way to call C/C++ from other languages such as Java, Python, Perl, PHP, etc?</p>
[ { "answer_id": 274924, "author": "Ned Batchelder", "author_id": 14343, "author_profile": "https://Stackoverflow.com/users/14343", "pm_score": 2, "selected": false, "text": "os.system(\"myccode -v args etc\")\n" }, { "answer_id": 274979, "author": "Brad Gilbert", "author_i...
2008/11/08
[ "https://Stackoverflow.com/questions/274915", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14744/" ]
274,918
<p>The CSS Friendly Control Adapters for ASP.NET are great for creating markup that is easy to style. A big benefit of the GridView adapter is that it generates THEAD, TBODY, and TFOOT tags, which allow you to do some really great things with libraries like jQuery - for instance, <a href="http://tablesorter.com/docs/" rel="nofollow noreferrer">Tablesorter</a> for client-side table sorting.</p> <p>The problem is that it seems to be a global on/off for the adapters through the CSSFriendlyAdapters.browser file. What do I do if I already have a slew of GridViews currently in production and only want to use the CSS Friendly Adapters for a new one?</p> <p>So I would be interested in two types of solutions:</p> <p>1) A way to extend or modify GridView (a new tag is acceptable) to output THEAD and TBODY tags.</p> <p>2) A way to conditionally apply or disable CSS Friendly Control Adapters.</p>
[ { "answer_id": 279464, "author": "David Boike", "author_id": 10039, "author_profile": "https://Stackoverflow.com/users/10039", "pm_score": 0, "selected": false, "text": "myGrid.UseAccessibleHeader = true;\nmyGrid.HeaderRow.TableSection = TableRowSection.TableHeader;\nmyGrid.FooterRow.Tab...
2008/11/08
[ "https://Stackoverflow.com/questions/274918", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10039/" ]
274,951
<p>You can pass a function pointer, function object (or boost lambda) to std::sort to define a strict weak ordering of the elements of the container you want sorted.</p> <p>However, sometimes (enough that I've hit this several times), you want to be able to chain "primitive" comparisons.</p> <p>A trivial example would be if you were sorting a collection of objects that represent contact data. Sometimes you will want to sort by <pre>last name, first name, area code</pre>. Other times <pre>first name, last name</pre> - yet other times <pre>age, first name, area code</pre>... etc</p> <p>Now, you can certainly write an additional function object for each case, but that violates the DRY principle - especially if each comparison is less trivial.</p> <p>It seems like you should be able to write a hierarchy of comparison functions - the low level ones do the single, primitive, comparisons (e.g. first name &lt; first name), then higher level ones call the lower level ones in succession (probably chaining with &amp;&amp; to make use of short circuit evaluation) to generate the composite functions.</p> <p>The trouble with this approach is that std::sort takes a binary predicate - the predicate can only return a bool. So if you're composing them you can't tell if a "false" indicates equality or greater than. You can make your lower level predicates return an int, with three states - but then you would have to wrap those in higher level predicates before they could be used with std::sort on their own.</p> <p>In all, these are not insurmountable problems. It just seems harder than it should be - and certainly invites a helper library implementation.</p> <p>Therefore, does anyone know of any pre-existing library (esp. if it's a std or boost library) that can help here - of have any other thoughts on the matter?</p> <p>[Update]</p> <p>As mentioned in some of the comments - I've gone ahead and written my own implementation of a class to manage this. It's fairly minimal, and probably has some issues with it in general. but on that basis, for anyone interested, the class is here:</p> <p><a href="http://pastebin.com/f52a85e4f" rel="noreferrer">http://pastebin.com/f52a85e4f</a></p> <p>And some helper functions (to avoid the need to specify template args) is here:</p> <p><a href="http://pastebin.com/fa03d66e" rel="noreferrer">http://pastebin.com/fa03d66e</a></p>
[ { "answer_id": 274963, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 2, "selected": false, "text": "std::sort" }, { "answer_id": 275014, "author": "siukurnin", "author_id": 35273, "author_profile":...
2008/11/08
[ "https://Stackoverflow.com/questions/274951", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32136/" ]
274,958
<p>According to <a href="http://www.scalabium.com/faq/dct0150.htm" rel="noreferrer">this page,</a> it's possible to use <code>TClientDataset</code> as an in-memory dataset, completely independent of any actual databases or files. It describes how to setup the dataset's table structure and how to load data into it at runtime. But when I tried to follow its instructions in D2009, step 4 (<code>table.Open</code>) raised an exception. It said that it didn't have a provider specified.</p> <p>The entire point of the example on that page is to build a dataset that doesn't need a provider. Is the page wrong, is it outdated, or am I missing a step somewhere? And if the page is wrong, what do I need to use instead to create a completely independent in-memory dataset? I've been using <code>TJvMemoryData</code>, but if possible I'd like to reduce the amount of extra dependencies that my dataset adds into my project.</p>
[ { "answer_id": 274976, "author": "Tom", "author_id": 13219, "author_profile": "https://Stackoverflow.com/users/13219", "pm_score": 3, "selected": false, "text": "table.CreateDataSet" }, { "answer_id": 274989, "author": "MikeJ", "author_id": 10676, "author_profile": "h...
2008/11/08
[ "https://Stackoverflow.com/questions/274958", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32914/" ]
274,984
<p>How can I correctly serve WSDL of a WCF webservice located in a private LAN from behind a reverse proxy listening on public IP?</p> <p>I have an Apache webserver configured in reverse proxy mode which listens for requests on a public IP address and serves them from the internal IIS host. WCF webservice generates WSDL using the FQDN address of the LAN host which, of course, cannot be read by an internet web service client.</p> <p>Is there any setting that can be configured in wcf application's web.config or in IIS in order to customize the WSDL generated containing host address and put public address instead?</p>
[ { "answer_id": 947276, "author": "Richard Collette", "author_id": 107683, "author_profile": "https://Stackoverflow.com/users/107683", "pm_score": 4, "selected": false, "text": "<ServiceBehavior(AddressFilterMode:=AddressFilterMode.Any)>\n" } ]
2008/11/08
[ "https://Stackoverflow.com/questions/274984", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5970/" ]
274,994
<p>I know we are <em>really</em> behind the times here, but we are just about to upgrade from .NET 1.1 to .NET 2.0. </p> <p>Thank you for your sympathy. </p> <p>Anyhow, are there any gotchas we should look out for?<br> Do you have any general advice before we jump in? </p> <p>Please do not post telling me to go straight to 3.5: 2.0 is all we're allowed! </p> <p>We're using mostly C#. </p>
[ { "answer_id": 275020, "author": "splattne", "author_id": 6461, "author_profile": "https://Stackoverflow.com/users/6461", "pm_score": 1, "selected": false, "text": "ctl0_" } ]
2008/11/08
[ "https://Stackoverflow.com/questions/274994", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7211/" ]
274,996
<p>First, I am Linq to Sql newbie, so please be gentle :).</p> <p>I have existing ASP.Net application developed over last 3.5 years. It has pretty big data model underneath, around 350 tables. I am trying to do some new things with Linq to SQL. </p> <p>First impression is that linq designer and SqlMetal are built for databases not bigger than NorthWind example. Here are some problems I have:</p> <ol> <li>I have table <code>Products</code> that is needed in lots of places (inventory, invoicing, production, ...). If I put table <code>Products</code> in each dbml file, linq designer is going to create <code>Product</code> class in each of them. I don't want that. I want to only one <code>Product</code> class.</li> <li>I have DataContext about shipping. It needs around 40 tables. This makes dbml file very hard to manage. Is there a way to create smaller dbml files and then include them (as reference) into some "major" dbml?</li> </ol> <p>For now, I really like Linq, but I think it is still seriously lacking design tool for anything bigger than 10 tables.</p> <p>My solution now is building smaller models with Linq designer and then manually merging them (adding properties and references), so lots of code will be generated, but there will also be lots of manual work. </p> <p>Did I miss something big or is this current state of affair with Linq to Sql?</p>
[ { "answer_id": 3675696, "author": "James McCormack", "author_id": 71906, "author_profile": "https://Stackoverflow.com/users/71906", "pm_score": 2, "selected": false, "text": "/code" } ]
2008/11/08
[ "https://Stackoverflow.com/questions/274996", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25732/" ]
275,004
<p>I wish to calculate the time it took for an API to return a value. The time taken for such an action is in the space of nanoseconds. As the API is a C++ class/function, I am using the timer.h to calculate the same:</p> <pre><code> #include &lt;ctime&gt; #include &lt;iostream&gt; using namespace std; int main(int argc, char** argv) { clock_t start; double diff; start = clock(); diff = ( std::clock() - start ) / (double)CLOCKS_PER_SEC; cout&lt;&lt;&quot;printf: &quot;&lt;&lt; diff &lt;&lt;'\n'; return 0; } </code></pre> <p>The above code gives the time in seconds. How do I get the same in nano seconds and with more precision?</p>
[ { "answer_id": 275031, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 5, "selected": false, "text": "inline __int64 GetCpuClocks()\n{\n\n // Counter\n struct { int32 low, high; } counter;\n\n // Use RDTSC instruction to...
2008/11/08
[ "https://Stackoverflow.com/questions/275004", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35416/" ]
275,005
<p>I am writing a program that will draw a solid along the curve of a spline. I am using visual studio 2005, and writing in C++ for OpenGL. I'm using FLTK to open my windows (fast and light toolkit).</p> <p>I currently have an algorithm that will draw a Cardinal Cubic Spline, given a set of control points, by breaking the intervals between the points up into subintervals and drawing linesegments between these sub points. The number of subintervals is variable.</p> <p>The line drawing code works wonderfully, and basically works as follows: I generate a set of points along the spline curve using the spline equation and store them in an array (as a special datastructure called Pnt3f, where the coordinates are 3 floats and there are some handy functions such as distance, length, dot and crossproduct). Then i have a single loop that iterates through the array of points and draws them as so:</p> <pre><code>glBegin(GL_LINE_STRIP); for(pt = 0; pt&lt;=numsubsegements ; ++pt) { glVertex3fv(pt.v()); } glEnd(); </code></pre> <p>As stated, this code works great. Now what i want to do is, instead of drawing a line, I want to extrude a solid. My current exploration is using a 'cylinder' quadric to create a tube along the line. This is a bit trickier, as I have to orient openGL in the direction i want to draw the cylinder. My idea is to do this:</p> <p>Psuedocode:</p> <pre><code>Push the current matrix, translate to the first control point rotate to face the next point draw a cylinder (length = distance between the points) Pop the matrix repeat </code></pre> <p>My problem is getting the angles between the points. I only need yaw and pitch, roll isnt important. I know take the arc-cosine of the dot product of the two points divided by the magnitude of both points, will return the angle between them, but this is not something i can feed to OpenGL to rotate with. I've tried doing this in 2d, using the XZ plane to get x rotation, and making the points vectors from the origin, but it does not return the correct angle.</p> <p>My current approach is much simpler. For each plane of rotation (X and Y), find the angle by:</p> <p>arc-cosine( (difference in 'x' values)/distance between the points)</p> <p>the 'x' value depends on how your set your plane up, though for my calculations I always use world x.</p> <p>Barring a few issues of it making it draw in the correct quadrant that I havent worked out yet, I want to get advice to see if this was a good implementation, or to see if someone knew a better way.</p>
[ { "answer_id": 275040, "author": "Sunlight", "author_id": 33650, "author_profile": "https://Stackoverflow.com/users/33650", "pm_score": 0, "selected": false, "text": "gluLookAt" }, { "answer_id": 275152, "author": "shoosh", "author_id": 9611, "author_profile": "https:...
2008/11/08
[ "https://Stackoverflow.com/questions/275005", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33583/" ]
275,011
<p>I am having a problem displaying a Javascript string with embedded Unicode character escape sequences (\uXXXX) where the initial "\" character is itself escaped as "&amp;#92;" What do I need to do to transform the string so that it properly evaluates the escape sequences and produces output with the correct Unicode character?</p> <p>For example, I am dealing with input such as:</p> <p><pre><code>"this is a &amp;#92;u201ctest&amp;#92;u201d";</code></pre></p> <p>attempting to decode the "&amp;#92;" using a regex expression, e.g.:</p> <p><pre><code>var out = text.replace('/&amp;#92;/g','\');</code></pre></p> <p>results in the output text:</p> <p><pre><code>"this is a \u201ctest\u201d";</code></pre></p> <p>that is, the Unicode escape sequences are displayed as actual escape sequences, not the double quote characters I would like.</p>
[ { "answer_id": 275032, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "eval(new String(\"this is a &#92;u201ctest&#amp;92;u201d\"));" }, { "answer_id": 275057, "author": "JW.", "aut...
2008/11/08
[ "https://Stackoverflow.com/questions/275011", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
275,018
<p>How do I remove the last character of a string if it is a newline?</p> <pre><code>&quot;abc\n&quot; --&gt; &quot;abc&quot; </code></pre>
[ { "answer_id": 275025, "author": "Rich Bradshaw", "author_id": 16511, "author_profile": "https://Stackoverflow.com/users/16511", "pm_score": 11, "selected": false, "text": "rstrip()" }, { "answer_id": 275401, "author": "Mike", "author_id": 19215, "author_profile": "ht...
2008/11/08
[ "https://Stackoverflow.com/questions/275018", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
275,022
<p>With squid, we can cache webpages. I am not sure if it provides the same number of caching methods as ASP.NET caching (I primarily use ASP.NET), but it's a tool to cache webpages.</p> <p>Then we have memcached, which can cache database tables. I believe this is correct, and it is like SqlCacheDependency (correct me if I am wrong).</p> <p>However, is there any situation in a large web application where one would find room to use memcached, squid, AND ASP.NET (or PHP, JSP - application framework-level) caching.</p> <p>Thanks!</p>
[ { "answer_id": 275025, "author": "Rich Bradshaw", "author_id": 16511, "author_profile": "https://Stackoverflow.com/users/16511", "pm_score": 11, "selected": false, "text": "rstrip()" }, { "answer_id": 275401, "author": "Mike", "author_id": 19215, "author_profile": "ht...
2008/11/08
[ "https://Stackoverflow.com/questions/275022", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32484/" ]
275,034
<p>One of the features of the modern (64 bit OS X and iPhone OS) Objective C runtime is the ability for properties to dynamically synthesize ivars without explicitly declaring them in the class:</p> <pre><code>@interface MyClass : NSObject { // NSString *name; unnecessary on modern runtimes } @property (retain) NSStrng *name; @end @implementation MyClass @synthesize name; @end </code></pre> <p>In quite a bit of my code I use custom getter implementations in order to initialize the properties:</p> <pre><code>- (NSString *) name { if (!name) { name = @"Louis"; } return name; } </code></pre> <p>The above is incompatible with synthesized ivars since it needs to access a an ivar that is not declared in the header. For various reasons I would like to update a number of my personal frameworks to use synthesized ivars when built on the modern runtimes, the above code needs to be modified to work with synthesized ivars in order to achieve that goal.</p> <p>While the Objective C 2.0 documentation states that the synthesized accessors on the modern runtime will synthesize the ivar on first use. It does not specify what low level mechanism is used to do this. Is it done by class_getInstanceVariable(), are the restrictions on class_addIvar() loosened, is it an undocumented function int he objective C 2.0 runtime? While I could implement my own side storage for the data backing my properties, I would much rather use the mechanism that synthesized accessors are using.</p>
[ { "answer_id": 5542886, "author": "JD Brennan", "author_id": 304712, "author_profile": "https://Stackoverflow.com/users/304712", "pm_score": -1, "selected": false, "text": "[myObject setValue:@\"whatever\" forKey:@\"foo\"];\n" }, { "answer_id": 9045742, "author": "Farcaller",...
2008/11/08
[ "https://Stackoverflow.com/questions/275034", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30506/" ]
275,038
<p>I wish to convert a single string with multiple delimiters into a key=>value hash structure. Is there a simple way to accomplish this? My current implementation is:</p> <pre><code>sub readConfigFile() { my %CONFIG; my $index = 0; open(CON_FILE, "config"); my @lines = &lt;CON_FILE&gt;; close(CON_FILE); my @array = split(/&gt;/, $lines[0]); my $total = @array; while($index &lt; $total) { my @arr = split(/=/, $array[$index]); chomp($arr[1]); $CONFIG{$arr[0]} = $arr[1]; $index = $index + 1; } while ( ($k,$v) = each %CONFIG ) { print "$k =&gt; $v\n"; } return; } </code></pre> <p>where 'config' contains:</p> <pre><code>pub=3&gt;rec=0&gt;size=3&gt;adv=1234 123 4.5 6.00 pub=1&gt;rec=1&gt;size=2&gt;adv=111 22 3456 .76 </code></pre> <p>The last digits need to be also removed, and kept in a separate key=>value pair whose name can be 'ip'. (I have not been able to accomplish this without making the code too lengthy and complicated).</p>
[ { "answer_id": 275127, "author": "brian d foy", "author_id": 2766176, "author_profile": "https://Stackoverflow.com/users/2766176", "pm_score": 3, "selected": true, "text": "$." }, { "answer_id": 275163, "author": "Jonathan Leffler", "author_id": 15168, "author_profile...
2008/11/08
[ "https://Stackoverflow.com/questions/275038", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35416/" ]
275,039
<p>I got an image with which links to another page using <code>&lt;a href="..."&gt; &lt;img ...&gt; &lt;/a&gt;</code>.</p> <p>How can I make it make a post like if it was a button <code>&lt;input type="submit"...&gt;</code>?</p>
[ { "answer_id": 275048, "author": "Shawn", "author_id": 26, "author_profile": "https://Stackoverflow.com/users/26", "pm_score": 3, "selected": false, "text": "<form action=\"page-you're-submitting-to.html\" method=\"POST\">\n <a href=\"#\" onclick=\"document.forms[0].submit();return fa...
2008/11/08
[ "https://Stackoverflow.com/questions/275039", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26004/" ]
275,062
<p>So I was hoping that some old school Vim'ers could help me out. These are all separate questions and normally I would put them up each on their own but I'm not sure if that qualifies as question whoring here. </p> <p>Plus I think if you know enough to be asking any of these questions they will all be coming up in the near future:</p> <ol> <li>I have a library I'm writing and a series of applications that use that library. There doesn't seem to be an easy way(from what I can tell) to build a <strong>ctags file</strong> for the library and build one for each of my applications and make sure one references the other when I'm in vim.</li> <li>Using gf to open files from command mode is awesome, but a lot of my include files don't contain the full path. They refer to an include directory I set in the IDE. How can I set this directory as another point for Vim to start looking for files?</li> <li>Is there a way to compile a file inside Vim and send the output to a buffer? I'm currently using MSVS 2k3 but I'll be porting over to Linux in a few weeks so if this is possible on either system I'd appreciate it.</li> </ol>
[ { "answer_id": 275108, "author": "Ali Afshar", "author_id": 28380, "author_profile": "https://Stackoverflow.com/users/28380", "pm_score": 0, "selected": false, "text": ":cd {path}\n" }, { "answer_id": 275167, "author": "Luc Hermitte", "author_id": 15934, "author_profi...
2008/11/08
[ "https://Stackoverflow.com/questions/275062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23829/" ]
275,063
<p>I would like to be able to set "Extend my Windows desktop onto this monitor" via code. A PowerShell script would be ideal. WMI seems the way forward but I have zero knowledge in WMI.</p>
[ { "answer_id": 275123, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 2, "selected": false, "text": "Option Explicit\nDim WshShell, Dummy, Splash\n\nOn Error Resume Next\n\nSet WshShell = WScript.CreateObject(\"WScript.Shell\")\...
2008/11/08
[ "https://Stackoverflow.com/questions/275063", "https://Stackoverflow.com", "https://Stackoverflow.com/users/176626/" ]
275,064
<p>I read a properties-file at the webapplication startup phase (contextInitialized()) and I started to think about how to make these settings 'visible' to the servlets. Do I need to loop through the keys and add each and every one to the context, like this</p> <pre><code>Iterator i = settings.keySet().iterator(); while (i.hasNext()) { key = (String) i.next(); value = (String) settings.get(key); context.setAttribute(key, value); } </code></pre> <p>or are there better methods?</p> <p>Thank you!</p> <p>/Adam</p>
[ { "answer_id": 275065, "author": "Josh", "author_id": 2204759, "author_profile": "https://Stackoverflow.com/users/2204759", "pm_score": 1, "selected": false, "text": "String key = null;\nIterator<String> i = settings.keySet().iterator();\nwhile (i.hasNext())\n context.setAttribute(key = ...
2008/11/08
[ "https://Stackoverflow.com/questions/275064", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31518/" ]
275,073
<p>I have just noticed that a multidimensional array in C# does not implement <code>IEnumerable&lt;T&gt;</code>, while it does implement <code>IEnumerable</code>. For single-dimensional arrays, both <code>IEnumerable&lt;T&gt;</code> and <code>IEnumerable</code> are implemented.</p> <p>Why this difference? If a multi-dimensional array is <code>IEnumerable</code>, surely it should also implement the generic version? I noticed this because I tried to use an extension method on a multidimensional array, which fails unless you use <code>Cast&lt;T&gt;</code> or similar; so I can definitely see the an argument for making multidimensional arrays implement <code>IEnumerable&lt;T&gt;</code>.</p> <p>To clarify my question in code, I would expect the following code to print <code>true</code> four times, while it actually prints <code>true</code>, <code>false</code>, <code>true</code>, <code>true</code>:</p> <pre><code>int[] singleDimensionArray = new int[10]; int[,] multiDimensional = new int[10, 10]; Debug.WriteLine(singleDimensionArray is IEnumerable&lt;int&gt;); Debug.WriteLine(multiDimensional is IEnumerable&lt;int&gt;); Debug.WriteLine(singleDimensionArray is IEnumerable); Debug.WriteLine(multiDimensional is IEnumerable); </code></pre>
[ { "answer_id": 275107, "author": "Matthew Scharley", "author_id": 15537, "author_profile": "https://Stackoverflow.com/users/15537", "pm_score": 1, "selected": false, "text": "IEnumerable<int>" }, { "answer_id": 275129, "author": "Jon Skeet", "author_id": 22656, "autho...
2008/11/08
[ "https://Stackoverflow.com/questions/275073", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13627/" ]
275,092
<p>We have a JavaScript function named "move" which does just "windows.location.href = <em>any given anchor</em>". <br/> This function works on IE, Opera and Safari, but somehow is ignored in Firefox. Researching on Google doesn't produce a satisfactory answer <strong>why</strong> it doesn't work. <br/> Does any JavaScript guru knows about this behavior, and what would be the best practice to jump to an anchor via JavaScript?</p>
[ { "answer_id": 275102, "author": "Dan Herbert", "author_id": 392, "author_profile": "https://Stackoverflow.com/users/392", "pm_score": 6, "selected": true, "text": "window.location = 'url';\n" }, { "answer_id": 275104, "author": "PhiLho", "author_id": 15459, "author_p...
2008/11/08
[ "https://Stackoverflow.com/questions/275092", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34815/" ]
275,109
<p>I'm writing a url rewrite in django that when a person goes to <a href="http://mysite.com/urlchecker/http://www.google.com" rel="nofollow noreferrer">http://mysite.com/urlchecker/http://www.google.com</a> it sends the url: <a href="http://ww.google.com" rel="nofollow noreferrer">http://ww.google.com</a> to a view as a string variable. </p> <p>I tried doing:</p> <pre><code>(r'^urlchecker/(?P&lt;url&gt;\w+)/$', 'mysite.main.views.urlchecker'), </code></pre> <p>But that didn't work. Anyone know what I'm doing wrong?</p> <p>Also, generally is there a good resource to learn regular expressions specifically for python/django?</p> <p>Thanks guys!</p>
[ { "answer_id": 275117, "author": "Peter Rowell", "author_id": 17017, "author_profile": "https://Stackoverflow.com/users/17017", "pm_score": 3, "selected": true, "text": "(r'^urlchecker/(?P<url>.+)$', 'mysite.main.views.urlchecker')," } ]
2008/11/08
[ "https://Stackoverflow.com/questions/275109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23695/" ]
275,120
<p>Given a class, <a href="http://help.eclipse.org/stable/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/org/eclipse/ui/views/navigator/ResourceNavigator.html" rel="noreferrer">org.eclipse.ui.views.navigator.ResourceNavigator</a> for example, how do I find out which jar file to use? I know it's in org.eclipse.ui.ide, but how would I find that out?</p> <p><strong>Edit</strong>: Thank you to all of you who answered. Like many things, there seems to be several ways to skin this cat. I wish javadoc contained this info. So far here are the different methods:</p> <ol> <li><p>Without Internet, Eclipse or NetBeans:</p> <pre><code>for f in `find . -name '*.jar'`; do echo $f &amp;&amp; jar tvf $f | grep -i $1; done </code></pre></li> <li><p>If you want to find out locally using Eclipse:</p> <ul> <li><a href="http://www.alphaworks.ibm.com/tech/jarclassfinder" rel="noreferrer">JAR Class Finder Plug-in</a></li> <li><a href="http://classlocator.sourceforge.net/" rel="noreferrer">Class Locator Plug-in</a></li> </ul></li> <li><p>If you want to find out from Internet or you do not have the jar yet:</p> <ul> <li><a href="http://www.jarfinder.com/" rel="noreferrer">jarFinder</a></li> <li><a href="http://findjar.com/" rel="noreferrer">findjar.com</a></li> </ul></li> </ol>
[ { "answer_id": 275125, "author": "PhiLho", "author_id": 15459, "author_profile": "https://Stackoverflow.com/users/15459", "pm_score": 1, "selected": false, "text": "jar -vtf foo.jar" }, { "answer_id": 275144, "author": "user28791", "author_id": 28791, "author_profile"...
2008/11/08
[ "https://Stackoverflow.com/questions/275120", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3827/" ]
275,128
<p>Is there any way of doing parallel assignment in C++? Currently, the below compiles (with warnings)</p> <pre><code>#include &lt;iostream&gt; int main() { int a = 4; int b = 5; a, b = b, a; std::cout &lt;&lt; "a: " &lt;&lt; a &lt;&lt; endl &lt;&lt; "b: " &lt;&lt; b &lt;&lt; endl; return 0; } </code></pre> <p>and prints:</p> <pre><code>a: 4 b: 5 </code></pre> <p>What I'd like it to print ... if it weren't obvious, is:</p> <pre><code>a: 5 b: 4 </code></pre> <p>As in, say, ruby, or python.</p>
[ { "answer_id": 275146, "author": "Matthew Scharley", "author_id": 15537, "author_profile": "https://Stackoverflow.com/users/15537", "pm_score": 1, "selected": false, "text": "int a = 4;\nint b = 5;\n\n{\n int tmp = a;\n a = b;\n b = tmp;\n}\n" }, { "answer_id": 275149, ...
2008/11/08
[ "https://Stackoverflow.com/questions/275128", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35807/" ]
275,150
<p>My website is XHTML Transitional compliant <strong>except for one thing</strong>: the &amp; (ampersand) in the URL are written as it is, instead of <code>&amp;amp;</code></p> <p>That is, all the URLs in my pages are usually like this:</p> <pre><code>&lt;a href=&quot;http://www.example.org/page.aspx?x=1&amp;y=2&quot;&gt;Foo&lt;/a&gt; </code></pre> <p>But <a href="http://validator.w3.org/" rel="nofollow noreferrer">XHTML validator</a> generates this error:</p> <blockquote> <p>cannot generate system identifier for general entity &quot;y&quot;</p> </blockquote> <p>... and it wants the URL to be written like this:</p> <pre><code>&lt;a href=&quot;http://www.example.org/page.aspx?x=1&amp;amp;y=2&quot;&gt;Foo&lt;/a&gt; </code></pre> <p>The problem is that Internet Explorer and Firefox don't handle the URL correctly and ignore the y parameter. <strong>How can I make this link work and validate correctly?</strong></p> <p>It seems to me that it is impossible to write XHTML pages if the browsers don't work with strict encoded XHTML URLs.</p> <p>Do you want to see in action? See the difference between these two links (copy and paste them as they are):</p> <pre><code>http://stackoverflow.com/search?q=ff&amp;sort=newest </code></pre> <p>and</p> <pre><code>http://stackoverflow.com/search?q=ff&amp;amp;sort=newest </code></pre>
[ { "answer_id": 275154, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 3, "selected": false, "text": "&amp;" }, { "answer_id": 275252, "author": "pipTheGeek", "author_id": 28552, "author_profile": "https://Sta...
2008/11/08
[ "https://Stackoverflow.com/questions/275150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
275,153
<p>Basically I have a website. I have a properly setup sitemap so I assume Google knows about all of my pages. And I've seen on some sites, the search form leads to a page with the shell of the original site but the results are clearly provided by Google. Similar to codinghorror.com's search, however his results aren't shown within his website's layout.</p> <p>Any idea what I'm talking about or how to achieve this?</p>
[ { "answer_id": 275157, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 4, "selected": false, "text": "<form method=\"get\" action=\"http://www.google.com/search\">\n\n<div style=\"border:1px solid black;padding:4px;width:20em;\">...
2008/11/08
[ "https://Stackoverflow.com/questions/275153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/428190/" ]
275,160
<p>Just starting to explore the 'wonders' of regex. Being someone who learns from trial and error, I'm really struggling because my trials are throwing up a disproportionate amount of errors... My experiments are in PHP using ereg().</p> <p>Anyway. I work with first and last names separately but for now using the same regex. So far I have:</p> <pre><code>^[A-Z][a-zA-Z]+$ </code></pre> <p>Any length string that starts with a capital and has only letters (capital or not) for the rest. But where I fall apart is dealing with the special situations that can pretty much occur anywhere.</p> <ul> <li>Hyphenated Names (Worthington-Smythe) </li> <li>Names with Apostophies (D'Angelo) </li> <li>Names with Spaces (Van der Humpton) - capitals in the middle which may or may not be required is way beyond my interest at this stage.</li> <li>Joint Names (Ben &amp; Jerry)</li> </ul> <p>Maybe there's some other way a name can be that I'm no thinking of, but I suspect if I can get my head around this, I can add to it. I'm pretty sure there will be instances where more than one of these situations comes up in one name.</p> <p>So, I think the bottom line is to have my regex also accept a space, hyphens, ampersands and apostrophes - but not at the start or end of the name to be technically correct.</p>
[ { "answer_id": 275177, "author": "Matthew Scharley", "author_id": 15537, "author_profile": "https://Stackoverflow.com/users/15537", "pm_score": 7, "selected": true, "text": "a-z" }, { "answer_id": 275180, "author": "Robert Gamble", "author_id": 25222, "author_profile"...
2008/11/08
[ "https://Stackoverflow.com/questions/275160", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1444/" ]
275,169
<p>I have 2 files:</p> <pre><code>/****demo.cpp****/ #include &lt;iostream.h&gt; #include "gc.h" class foo{}; int main(){ gc&lt;foo&gt; x1; cout&lt;&lt;x1; } /*****gc.h*****/ template &lt;class T&gt; class gc { T* ptr; public: operator T*(){} }; </code></pre> <p>If I don't write <code>operator T*(){}</code> then I get a lot of compiler errors.</p> <p>So plz tell me what is <code>operator T*(void)</code> and when it is invoked?</p>
[ { "answer_id": 275176, "author": "Rob Walker", "author_id": 3631, "author_profile": "https://Stackoverflow.com/users/3631", "pm_score": 2, "selected": false, "text": "T*(){}" }, { "answer_id": 275183, "author": "Johannes Schaub - litb", "author_id": 34509, "author_pro...
2008/11/08
[ "https://Stackoverflow.com/questions/275169", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
275,174
<p>I have a string that is HTML encoded: </p> <pre><code>'''&amp;lt;img class=&amp;quot;size-medium wp-image-113&amp;quot;\ style=&amp;quot;margin-left: 15px;&amp;quot; title=&amp;quot;su1&amp;quot;\ src=&amp;quot;http://blah.org/wp-content/uploads/2008/10/su1-300x194.jpg&amp;quot;\ alt=&amp;quot;&amp;quot; width=&amp;quot;300&amp;quot; height=&amp;quot;194&amp;quot; /&amp;gt;''' </code></pre> <p>I want to change that to:</p> <pre class="lang-html prettyprint-override"><code>&lt;img class="size-medium wp-image-113" style="margin-left: 15px;" title="su1" src="http://blah.org/wp-content/uploads/2008/10/su1-300x194.jpg" alt="" width="300" height="194" /&gt; </code></pre> <p>I want this to register as HTML so that it is rendered as an image by the browser instead of being displayed as text. </p> <p>The string is stored like that because I am using a web-scraping tool called <a href="https://www.crummy.com/software/BeautifulSoup/bs4/doc/" rel="noreferrer"><code>BeautifulSoup</code></a>, it "scans" a web-page and gets certain content from it, then returns the string in that format.</p> <p>I've found how to do this in <strong>C#</strong> but not in <strong>Python</strong>. Can someone help me out?</p> <h3>Related</h3> <ul> <li><a href="https://stackoverflow.com/questions/57708/convert-xml-html-entities-into-unicode-string-in-python">Convert XML/HTML Entities into Unicode String in Python</a></li> </ul>
[ { "answer_id": 275195, "author": "Jake", "author_id": 24730, "author_profile": "https://Stackoverflow.com/users/24730", "pm_score": 2, "selected": false, "text": "htmlCodes = [\n ['&', '&amp;'],\n ['<', '&lt;'],\n ['>', '&gt;'],\n ['\"', '&quot;'],\n]\nhtmlCodesReversed = htm...
2008/11/08
[ "https://Stackoverflow.com/questions/275174", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23695/" ]
275,178
<p>We are using IIS 6 and ASP.Net, When users make secure page requests using </p> <blockquote> <p><strong><a href="https://somesite.com/securePage.aspx" rel="nofollow noreferrer">https://somesite.com/securePage.aspx</a></strong></p> </blockquote> <p>the user gets an error:</p> <hr> <blockquote> <p><strong>Error code: ssl error bad cert domain</strong></p> </blockquote> <hr> <p>The certificate was issued to <strong>www.somesite.com</strong> and indicates that <strong>somesite.com</strong> uses an invalid security certificate.</p> <p>I was hoping to be able to catch the request in the Application BeginRequest event but the SSL error occurs before this. In order to invoke the Application BeginRequest event the user needs to click through the certificate error message. Is it possible to redirect in code or does this fix need to occur within IIS?</p>
[ { "answer_id": 275210, "author": "djn", "author_id": 9673, "author_profile": "https://Stackoverflow.com/users/9673", "pm_score": -1, "selected": false, "text": "RewriteEngine On\nRewriteCond %{HTTP_HOST} ^example\\.com$ [NC]\nRewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]\n" },...
2008/11/08
[ "https://Stackoverflow.com/questions/275178", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4814/" ]
275,194
<p>How can I format data coming from a DataBinder.Eval statement in an ASPX page?</p> <p>For example, I want to display the published date of the news items in a particular format in the homepage. I'm using the ASP.NET 2.0 Repeater control to show the list of news items.</p> <p>The code for this goes like this:</p> <pre><code>&lt;asp:Repeater ID="Repeater1" runat="server" DataSourceID="ObjectDataSource1"&gt; &lt;HeaderTemplate&gt;&lt;table cellpadding="0" cellspacing="0" width="255"&gt;&lt;/HeaderTemplate&gt; &lt;ItemTemplate&gt; &lt;tr&gt;&lt;td &gt; &lt;a href='/content/latestNews.aspx?id=&lt;%#DataBinder.Eval(Container.DataItem, "id") %&gt;'&gt; &lt;asp:Label ID="lblNewsTitle" runat="server" Text='&lt;%# DataBinder.Eval(Container.DataItem, "title") %&gt;'&gt;&lt;/asp:Label&gt; &lt;/a&gt; &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt; &lt;asp:Label ID="lblNewsDate" runat="server" Text='&lt;%# DataBinder.Eval(Container.DataItem, "publishedDate"))%&gt;'&gt;&lt;/asp:Label&gt; &lt;/td&gt;&lt;/tr&gt; &lt;/ItemTemplate&gt; &lt;FooterTemplate&gt;&lt;/table&gt;&lt;/FooterTemplate&gt;&lt;/asp:Repeater&gt; </code></pre> <p>Is there a way I could call a custom method with the DataBinder.Eval value as its parameter (something like below)?</p> <pre><code>&lt;asp:Label ID="lblNewsDate" runat="server" Text='&lt;%# GetDateInHomepageFormat(DataBinder.Eval(Container.DataItem, "publishedDate")) )%&gt;'&gt;&lt;/asp:Label&gt; </code></pre> <p>If yes, then where do I write the GetDateInHomepageFormat method? I tried out in the code behind page but got a run time error? If this is not possible, is there a way to do inline formatting?</p>
[ { "answer_id": 275218, "author": "DOK", "author_id": 27637, "author_profile": "https://Stackoverflow.com/users/27637", "pm_score": 7, "selected": true, "text": "<%# DataBinder.Eval(Container.DataItem, \"expression\"[, \"format\"]) %>\n" }, { "answer_id": 275319, "author": "de...
2008/11/08
[ "https://Stackoverflow.com/questions/275194", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11172/" ]
275,199
<p>How do you do the following operations in C++?</p> <ol> <li>Opening Files</li> <li>Closing Files</li> <li>Reading Files</li> <li>Writing Files</li> </ol>
[ { "answer_id": 275224, "author": "Martin York", "author_id": 14065, "author_profile": "https://Stackoverflow.com/users/14065", "pm_score": 4, "selected": false, "text": "#include <fstream>\nint main()\n{\n std::ifstream inputFile(\"MyFileName\") // Opens a File.\n\n int x;\n ...
2008/11/08
[ "https://Stackoverflow.com/questions/275199", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35821/" ]
275,207
<p>My friend produced a small proof-of-concept assembler that worked on x86. I decided to port it for x86_64 as well, but I immediately hit a problem.</p> <p>I wrote a small piece of program in C, then compiled and objdumped the code. After that I inserted it to my python script, therefore the x86_64 code is correct:</p> <pre><code>from ctypes import cast, CFUNCTYPE, c_char_p, c_long buffer = ''.join(map(chr, [ #0000000000000000 &lt;add&gt;: 0x55, # push %rbp 0x48, 0x89, 0xe5, # mov %rsp,%rbp 0x48, 0x89, 0x7d, 0xf8, # mov %rdi,-0x8(%rbp) 0x48, 0x8b, 0x45, 0xf8, # mov -0x8(%rbp),%rax 0x48, 0x83, 0xc0, 0x0a, # add $0xa,%rax 0xc9, # leaveq 0xc3, # retq ])) fptr = cast(c_char_p(buffer), CFUNCTYPE(c_long, c_long)) print fptr(1234) </code></pre> <p>Now, why does this script keeps doing segmentation fault whenever I run it?</p> <p>I have yet a question about mprotect and no execution flag. It is said to protect against most basic security exploits like buffer overruns. But what is the real reason it's in use? You could just keep on writing until you hit the .text, then inject your instructions into a nice, PROT_EXEC -area. Unless, of course, you use a write protection in .text</p> <p>But then, why have that PROT_EXEC everywhere anyway? Wouldn't it just help tremendously that your .text section is write protected?</p>
[ { "answer_id": 275333, "author": "vincent", "author_id": 34871, "author_profile": "https://Stackoverflow.com/users/34871", "pm_score": 2, "selected": false, "text": "mprotect" }, { "answer_id": 275426, "author": "Cheery", "author_id": 21711, "author_profile": "https:/...
2008/11/08
[ "https://Stackoverflow.com/questions/275207", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21711/" ]
275,213
<p>Previously, I had a class that wrapped an internal <code>System.Collections.Generic.List&lt;Item&gt;</code> (where Item is a class I created). The wrapper class provided several collection-level properties that provided totals, averages, and other computations on items in the list. I was creating a <code>BindingSource</code> around this wrapped <code>List&lt;&gt;</code> and another <code>BindingSource</code> around my class and was able to get at the Items in the wrapped list through the first <code>BindingSource</code> and the collection-level properties of the wrapper class using the second. </p> <p>A simplified example looks like: </p> <pre><code>public class OldClass() { private List&lt;Item&gt; _Items; public OldClass() { _Items = new List&lt;Item&gt;(); } public List&lt;Item&gt; Items { get { return _Items; } } // collection-level properties public float AverageValue { get { return Average() } } public float TotalValue { get { return Total() } } // ... other properties like this } </code></pre> <p>With the binding sources created in this way:</p> <pre><code>_itemsBindingSource = new BindingSource(oldClass.Items); _summaryBindingSource = new BindingSource(oldClass); </code></pre> <p>Recently, I tried to change this class to be derived from <code>System.Collections.Generic.List&lt;Item&gt;</code> instead of keeping a wrapped <code>List&lt;&gt;</code> member. My hope was to get rid of the extra wrapper layer and use only one <code>BindingSource</code> instead of two. However, now I find that I cannot get at the properties that apply to all items in the list (such as <code>AverageValue</code>) when I do data binding. Only the properties of list items are available. </p> <p>Am I forced to go back to using a wrapped <code>List&lt;&gt;</code> of <code>Item</code>s? Or is there a way that I can get at both the properties of <code>Item</code>s stored my new class as well as the properties that apply to the collection itself?</p>
[ { "answer_id": 275392, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 4, "selected": true, "text": "IList" }, { "answer_id": 276037, "author": "Keltex", "author_id": 28260, "author_profile": "https:...
2008/11/08
[ "https://Stackoverflow.com/questions/275213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4849/" ]
275,214
<p>I am starting again with c++ and was thinking about the scope of variables. If I have a variable inside a function and then I return that variable will the variable not be "dead" when it's returned because the scope it was in has ended?</p> <p>I have tried this with a function returning a string and it did work. Can anyone explain this? Or at least point me to some place that can explain this to me please.</p> <p>Thanks</p>
[ { "answer_id": 275225, "author": "Kieveli", "author_id": 15852, "author_profile": "https://Stackoverflow.com/users/15852", "pm_score": 2, "selected": false, "text": "int funcB() {\n int j = 12;\n return j;\n}\n\nvoid A() {\n int i;\n i = funcB();\n}\n" }, { "answer_id": 27522...
2008/11/08
[ "https://Stackoverflow.com/questions/275214", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8715/" ]
275,230
<p>I know how to use the OleDbConnection class to open an excel file and select from it, but is there a simple method to read the data from an excel file that has been read into a Stream? And is there also a similar method for QuickBooks?</p>
[ { "answer_id": 275225, "author": "Kieveli", "author_id": 15852, "author_profile": "https://Stackoverflow.com/users/15852", "pm_score": 2, "selected": false, "text": "int funcB() {\n int j = 12;\n return j;\n}\n\nvoid A() {\n int i;\n i = funcB();\n}\n" }, { "answer_id": 27522...
2008/11/08
[ "https://Stackoverflow.com/questions/275230", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13855/" ]
275,233
<p>What I would like to do is the following. I have a single table, Products, containing a private key ProductID. Instead of having SQL Server auto-increment ProductID on inserts, I want to increment it in the DataContext partial method "InsertProduct":</p> <pre><code>Partial Public Class MyDataContext Private Sub InsertProduct(ByVal instance As Product) Dim id As Integer = Me.Products.Max(Function(p As Product) p.ProductID) + 1 instance.ProductID = id Me.ExecuteDynamicInsert(instance) End Sub End Class </code></pre> <p>However, this will only work when inserting the first Product instance. When attempting to insert a second instance, the id retrieved is the same as for the first,</p> <pre><code>Using context As New MyDataContext Dim product1 As New Product context.Products.InsertOnSubmit(product1) context.SubmitChanges() 'This works Dim product2 As New Product context.Products.InsertOnSubmit(product2) context.SubmitChanges() 'DuplicateKeyException End Using </code></pre> <p>Am I missing something obvious here?</p>
[ { "answer_id": 275350, "author": "valure", "author_id": 9919, "author_profile": "https://Stackoverflow.com/users/9919", "pm_score": 0, "selected": false, "text": "context.SubmitChanges()" } ]
2008/11/08
[ "https://Stackoverflow.com/questions/275233", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9919/" ]
275,237
<p>i.e. I just want them to be permanently accepted all the time.</p>
[ { "answer_id": 3506961, "author": "Doug K", "author_id": 423329, "author_profile": "https://Stackoverflow.com/users/423329", "pm_score": 3, "selected": false, "text": "* Tools -> Options -> Advanced -> Encryption -> View Certificates\n* Under Authorities tab, enter \"RSA Security 1024\" ...
2008/11/08
[ "https://Stackoverflow.com/questions/275237", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34594/" ]
275,249
<p>What is a good use case for uncaught_exception?</p>
[ { "answer_id": 275537, "author": "coppro", "author_id": 16855, "author_profile": "https://Stackoverflow.com/users/16855", "pm_score": 2, "selected": false, "text": "uncaught_exception" } ]
2008/11/08
[ "https://Stackoverflow.com/questions/275249", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14069/" ]
275,250
<p>I'm writing some disposable Haskell scripts to solve some of the <a href="http://projecteuler.net" rel="nofollow noreferrer">Project Euler</a> problems. I don't really want to have to compile them because of the number of changes I'm constantly having to make, but in a few cases I've found that I've run out of stack space.</p> <p>The documentation for <code>runhaskell</code> says that the following syntax should increase the stack space:</p> <pre><code>runhaskell +RTS -K5M -RTS Script.hs </code></pre> <p>This never, ever works (in any permutation I've tried). The stack size always remains 8,388,608. This is maddening, and I haven't found much help on Google.</p> <p>Any suggestions? What am I doing wrong?</p>
[ { "answer_id": 275623, "author": "yfeldblum", "author_id": 12349, "author_profile": "https://Stackoverflow.com/users/12349", "pm_score": 1, "selected": false, "text": "module Main where\nmain = do\n print solution\nsolution = ...\n" }, { "answer_id": 431989, "author": "Com...
2008/11/08
[ "https://Stackoverflow.com/questions/275250", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27779/" ]
275,273
<p>I recently downloaded PLT Scheme and DrScheme. When I open DrScheme, I am told to choose a language. However, I'm not familiar with any of my options, and the help guides don't really break it down to help me easily choose which choice.</p> <p>So, first - is DrScheme and PLT Scheme really the tools I need to learn Lisp and/or Scheme? If so, what are the different languages and which one(s) should I be using?</p>
[ { "answer_id": 275313, "author": "Kyle Cronin", "author_id": 658, "author_profile": "https://Stackoverflow.com/users/658", "pm_score": 5, "selected": true, "text": "#lang scheme\n" } ]
2008/11/08
[ "https://Stackoverflow.com/questions/275273", "https://Stackoverflow.com", "https://Stackoverflow.com/users/572/" ]
275,314
<p>When using MYSQL C API to query results. The results are returned as a <code>MYSQL_ROW</code> type, which according to the MYSQL C API documentation, I can easily <code>printf("%s", row[0])</code>. But what if I want to transfer the contents of <code>row[0]</code> into a string or a char*?</p>
[ { "answer_id": 54962732, "author": "jww", "author_id": 608639, "author_profile": "https://Stackoverflow.com/users/608639", "pm_score": 0, "selected": false, "text": "mysql_fetch_lengths" } ]
2008/11/08
[ "https://Stackoverflow.com/questions/275314", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28462/" ]
275,338
<p>What is the <em>best</em> way to print the cells of a <code>String[][]</code> array as a right-justified table? For example, the input</p> <pre><code>{ { "x", "xxx" }, { "yyy", "y" }, { "zz", "zz" } } </code></pre> <p>should yield the output</p> <pre><code> x xxx yyy y zz zz </code></pre> <p>This seems like something that one <em>should</em> be able to accomplish using <code>java.util.Formatter</code>, but it doesn't seem to allow non-constant field widths. The best answer will use some standard method for padding the table cells, not the manual insertion of space characters.</p>
[ { "answer_id": 275438, "author": "Chris Conway", "author_id": 1412, "author_profile": "https://Stackoverflow.com/users/1412", "pm_score": 3, "selected": false, "text": "public static void printTable(String[][] table) {\n // Find out what the maximum number of columns is in any row\n in...
2008/11/08
[ "https://Stackoverflow.com/questions/275338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1412/" ]
275,351
<p>Is there a way to get all methods (private, privileged, or public) of a javascript object from within? Here's the sample object:</p> <pre><code>var Test = function() { // private methods function testOne() {} function testTwo() {} function testThree() {} // public methods function getMethods() { for (i in this) { alert(i); // shows getMethods, but not private methods } } return { getMethods : getMethods } }(); // should return ['testOne', 'testTwo', 'testThree', 'getMethods'] Test.getMethods(); </code></pre> <p>The current issue is the code in <code>getMethods()</code>, the simplified example will return just the public methods, but not to private ones.</p> <p><strong>edit</strong>: my test code may (or may not) be overcomplicating what i'm hoping to get at. given the following:</p> <pre><code>function myFunction() { var test1 = 1; var test2 = 2; var test3 = 3; } </code></pre> <p>is there a way to find out what variables exist in <code>myFunction()</code> from within <code>myFunction()</code>. the pseudo-code would look like this:</p> <pre><code>function myFunction() { var test1 = 1; var test2 = 2; var test3 = 3; alert(current.properties); // would be nice to get ['test1', 'test2', 'test3'] } </code></pre>
[ { "answer_id": 275362, "author": "Oli", "author_id": 12870, "author_profile": "https://Stackoverflow.com/users/12870", "pm_score": 0, "selected": false, "text": "this" }, { "answer_id": 275390, "author": "eswald", "author_id": 21229, "author_profile": "https://Stackov...
2008/11/08
[ "https://Stackoverflow.com/questions/275351", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4853/" ]
275,355
<p>another request sorry.. Right now I am reading the tokens in one by one and it works, but I want to know when there is a new line..</p> <p>if my file contains</p> <pre><code>Hey Bob Now </code></pre> <p>should give me</p> <pre><code>Hey Bob [NEW LINE] NOW </code></pre> <p>Is there a way to do this without using getline?</p>
[ { "answer_id": 275405, "author": "Martin York", "author_id": 14065, "author_profile": "https://Stackoverflow.com/users/14065", "pm_score": 5, "selected": true, "text": "std::string line;\nwhile(std::getline(std::cin,line))\n{\n\n // If you then want to tokenize the line use a string...
2008/11/08
[ "https://Stackoverflow.com/questions/275355", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33481/" ]
275,374
<p>I am trying to make a basic API for my website so certain other websites that I approve of can show content from my site. I have a PHP script on my server that the other websites can access to pull content in XML format. How can I make sure that only certain websites can access this php page on my server?</p>
[ { "answer_id": 275379, "author": "Bill the Lizard", "author_id": 1288, "author_profile": "https://Stackoverflow.com/users/1288", "pm_score": 2, "selected": false, "text": "Order allow, deny\nDeny from 192.168.0.10\nDeny from 212.155.\nDeny from 1.2.3.4 5.6.7.8 127.0.0.1\nAllow from all\...
2008/11/08
[ "https://Stackoverflow.com/questions/275374", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
275,375
<p>From googling around it looks like Xcode (3.1 in my case) should be at least trying to give me a sane debug view of STL containers - or at least vectors.</p> <p>However, whenever I go to look at a vector in the debugger I just see M_impl, with M_start and M_finish members (and a couple of others) - but nothing in-between! (it's a debug build, btw).</p> <p>Am I missing a setting or something somewhere?</p> <p>I've also read that there are macros available that can augment the debug viewer even further to inspect more complex containers - but have been unable to find any.</p> <p>I'd also like to be able to view std::wstrings, without having to drop to the memory viewer. It shows std::string fine. Is there anything I can do to show std::wstring?</p> <p>I realise this is a bit of a composite question - but it's all really part of the same subject.</p>
[ { "answer_id": 275398, "author": "Michel", "author_id": 31122, "author_profile": "https://Stackoverflow.com/users/31122", "pm_score": 2, "selected": true, "text": "template <class T> struct S { T m_t; }\n" } ]
2008/11/08
[ "https://Stackoverflow.com/questions/275375", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32136/" ]
275,382
<p>I currently have 2 domain names that I want to setup different websites for. I am currently looking at using some free hosting that works well for my current needs but doesn't give me any way to point "mydomain.com" to the actual site. Instead I have to give users a longer, harder to remember url.</p> <p>My proposed solution is to point my domains to my home ip and host a small ASP.NET app through IIS consisting of a redirect page that simply redirects to the appropriate site. Is there a way in ASP.NET to recognize which domain url was requested in order to know where to redirect the page to?</p>
[ { "answer_id": 275388, "author": "Cristian Libardo", "author_id": 16526, "author_profile": "https://Stackoverflow.com/users/16526", "pm_score": 1, "selected": false, "text": "if(Request.Url.Authority == \"www.site1.com\")\n Response.Redirect(...);\n" }, { "answer_id": 276556, ...
2008/11/08
[ "https://Stackoverflow.com/questions/275382", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20489/" ]
275,386
<p>I'm writing a Linux kernel module that needs to open and read files. What's the best way to accomplish that?</p>
[ { "answer_id": 275396, "author": "Evan Teran", "author_id": 13430, "author_profile": "https://Stackoverflow.com/users/13430", "pm_score": 3, "selected": false, "text": "open" }, { "answer_id": 53622925, "author": "Billy", "author_id": 5849262, "author_profile": "https...
2008/11/08
[ "https://Stackoverflow.com/questions/275386", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28804/" ]
275,404
<p>How do you split a string into tokens in C++?</p>
[ { "answer_id": 275413, "author": "Martin York", "author_id": 14065, "author_profile": "https://Stackoverflow.com/users/14065", "pm_score": 2, "selected": false, "text": "std::string line(\"A line of tokens\");\nstd::stringstream lineStream(line);\n\nstd::string token;\nwhile(lineStream...
2008/11/09
[ "https://Stackoverflow.com/questions/275404", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33481/" ]
275,411
<p>I'm writing a php program that pulls from a database source. Some of the varchars have quotes that are displaying as black diamonds with a question mark in them (�, <a href="http://www.fileformat.info/info/unicode/char/fffd/index.htm" rel="noreferrer">REPLACEMENT CHARACTER</a>, I assume from Microsoft Word text).</p> <p>How can I use php to strip these characters out?</p>
[ { "answer_id": 275448, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 6, "selected": false, "text": "header(\"Content-Type: text/html; charset=ISO-8859-1\");\n" }, { "answer_id": 275449, "author": "troelskn", "a...
2008/11/09
[ "https://Stackoverflow.com/questions/275411", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
275,437
<p>I want to display the "infinity" symbol using </p> <pre><code>CGContextSelectFont(context, "HelveticaNeue", textSize, kCGEncodingMacRoman); CGContextShowTextAtPoint(context, myCenter.x, myCenter.y + textHeight, [sName cStringUsingEncoding:NSMacOSRomanStringEncoding], [sName length]); </code></pre> <p>It is displayed as a square box, or a circle. I have found out this symbol is in decimal 176 and 221E in Hexadecimal format. I am using Helvetica as my font, and have tried others with no luck. Is this a problem with the encoding I am using?</p>
[ { "answer_id": 275447, "author": "Jason Coco", "author_id": 34218, "author_profile": "https://Stackoverflow.com/users/34218", "pm_score": 5, "selected": true, "text": "- (void)drawRect:(CGRect)rect {\n unichar inf = 0x221E; // infinity symbol\n NSString* sName = [[NSString alloc] i...
2008/11/09
[ "https://Stackoverflow.com/questions/275437", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29642/" ]
275,442
<p>How can I make a local drive visible to a Windows XP VMWare image?</p> <p>Preferably, I'd like to make local drives available as Drive Letters within the VM Ware Image.</p>
[ { "answer_id": 275451, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 4, "selected": true, "text": "vm > settings > options > shared folders\n" }, { "answer_id": 10649033, "author": "ntg", "author_id": 508907, ...
2008/11/09
[ "https://Stackoverflow.com/questions/275442", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9467/" ]
275,444
<p>What are the things that Medium Trust stops you from doing? For example, I've already learned that Medium Trust stops you from using System.IO.Path.GetTempPath(). What other things like that?</p>
[ { "answer_id": 275445, "author": "Shawn", "author_id": 26, "author_profile": "https://Stackoverflow.com/users/26", "pm_score": 2, "selected": false, "text": " <trust level=\"Full|High|Medium|Low|Minimal\" />\n" }, { "answer_id": 275533, "author": "Corey Trager", "author_i...
2008/11/09
[ "https://Stackoverflow.com/questions/275444", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9328/" ]
275,453
<p>I can't seem to get a scrollbar to work in an inner stack/flow. Does anyone know how to?</p>
[ { "answer_id": 358198, "author": "user45200", "author_id": 45200, "author_profile": "https://Stackoverflow.com/users/45200", "pm_score": 1, "selected": false, "text": "<div>" }, { "answer_id": 610273, "author": "Sergei Silnov", "author_id": 73642, "author_profile": "h...
2008/11/09
[ "https://Stackoverflow.com/questions/275453", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35852/" ]
275,456
<p>Working with a traditional listener callback model. I have several listeners that collect various stuff. Each listener's collected stuff is inside the listener in internal structures.</p> <p>The problem is that I want some of the listeners to be aware of some of the "stuff" in the other listeners.</p> <p>I enforce listener registration order, so if I knowingly register events in some order a later listener can be sure that a previously listener updated its stuff and somehow access it to do more stuff. </p> <p>My first attempt at this is to have each listener store a reference to the listeners upon which it depends. So I register listeners in the order of those without dependencies to those with prior-registered dependencies, and then set the references between the listeners in various methods.</p> <p>I am starting to realize how bad this feels and I was wondering if somehow has been down this road before. What would be a more appropriate pattern when one of the listeners needs to access stuff in another?</p> <p>Here is some pseudocode to illustrate:</p> <pre><code>interface Listener { onEvent(char e); } class A implements Listener { private int count; public void onEvent(char e) { if(e == 'a') count++; } public int getCount() { return count; } } class B implements Listener { private int count; // private A a; // private void setA(A a) { this.a = a; } public void onEvent(char e) { if(e == 'b') count++; } public int getCount() { return count; } public int getAPlusBCount() { // We know B count, but we don't know A so how would we change this // so B is A aware? Or not even aware, just somehow coupled? This // is the question // return a.getCount() + count; } public void doConditionalHere() { // Do some condition in B that relies on the state of data in A int acount = 0; // a.getCount(); ??? if(acount % 2 == 0) { this.count--; } } } class Run { A a = new A(); B b = new B(); List listeners = new List(); listeners.add(a); listeners.add(b); // The ugly way I add coupling right now is to keep a reference to A // inside B. It's commented out because I am hoping there is a more intelligent approach // b.setA(a); for(char c : "ababbabab") { for(listener : listeners) { listener.onEvent(c); } } } </code></pre>
[ { "answer_id": 275470, "author": "sblundy", "author_id": 4893, "author_profile": "https://Stackoverflow.com/users/4893", "pm_score": 2, "selected": false, "text": "interface Listener {\n String getId();\n Collection<String> getDependencies();\n onEvent(char e);\n}\n" }, { "ans...
2008/11/09
[ "https://Stackoverflow.com/questions/275456", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2204759/" ]
275,458
<p>Has anyone converted a large (ours is 550,000 lines) program of Fortran 77 code to C++ ? What pitfalls did you run into ? Was the conversion a success ? Did you use a tool like <code>for_c</code> ( <a href="http://www.cobalt-blue.com/fc/fcmain.htm" rel="noreferrer">http://www.cobalt-blue.com/fc/fcmain.htm</a> ) ? Was the resulting C++ code significantly faster or slower ?</p>
[ { "answer_id": 275488, "author": "EvilTeach", "author_id": 7734, "author_profile": "https://Stackoverflow.com/users/7734", "pm_score": 3, "selected": false, "text": "label10:;\n\n goto label10;\n" } ]
2008/11/09
[ "https://Stackoverflow.com/questions/275458", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35854/" ]
275,464
<p>What does the following error mean? </p> <p>Geeneration of designer file failed: Exception from HRESULT: 0x80042929 </p> <p>It started showing up in my application when building and I'm not sure what's causing it. I'm using VS.Net 2008 and .Net 3.5</p>
[ { "answer_id": 275488, "author": "EvilTeach", "author_id": 7734, "author_profile": "https://Stackoverflow.com/users/7734", "pm_score": 3, "selected": false, "text": "label10:;\n\n goto label10;\n" } ]
2008/11/09
[ "https://Stackoverflow.com/questions/275464", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33633/" ]
275,471
<p>I'm trying to use GDB to debug (to find an annoying segfault). When I run:</p> <pre><code>gdb ./filename </code></pre> <p>from the command line, I get the following error:</p> <pre><code>This GDB was configured as "i686-pc-linux- gnu"..."/path/exec": not in executable format: File format not recognized </code></pre> <p>When I execute:</p> <pre><code>file /path/executable/ </code></pre> <p>I get the following info:</p> <pre><code> ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.4.0, dynamically linked (uses shared libs), not stripped </code></pre> <p>I am using GDB 6.1, and the executable is compiled with gcc version 3.4.6.</p> <p>I'm a little out of my water in terms of using gdb, but as far as I can tell it should be working in this instance. Any ideas what's going wrong?</p>
[ { "answer_id": 275763, "author": "Jonathan Leffler", "author_id": 15168, "author_profile": "https://Stackoverflow.com/users/15168", "pm_score": 2, "selected": false, "text": "gdb executable-file core-file\n" }, { "answer_id": 1123312, "author": "RandomNickName42", "author...
2008/11/09
[ "https://Stackoverflow.com/questions/275471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1266/" ]
275,484
<p>I'm pretty sure this is a simple question in regards to formatting but here's what I want to accomplish:</p> <p>I want to output data onto the screen using <code>cout</code>. I want to output this in the form of a table format. What I mean by this is the columns and rows should be properly aligned. Example:</p> <pre><code>Test 1 Test2 2 Iamlongverylongblah 2 Etc 1 </code></pre> <p>I am only concerned with the individual line so my line to output now (not working) is</p> <p><code>cout &lt;&lt; var1 &lt;&lt; "\t\t" &lt;&lt; var2 &lt;&lt; endl;</code></p> <p>Which gives me something like:</p> <pre><code>Test 1 Test2 2 Iamlongverylongblah 2 Etc 1 </code></pre>
[ { "answer_id": 275489, "author": "Leon Timmermans", "author_id": 4727, "author_profile": "https://Stackoverflow.com/users/4727", "pm_score": 3, "selected": false, "text": "cout << format(\"%|1$30| %2%\") % var1 % var2;\n" }, { "answer_id": 275494, "author": "Eugene Yokota", ...
2008/11/09
[ "https://Stackoverflow.com/questions/275484", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33481/" ]
275,493
<p>I'm using a RichTextBox in WinForms 3.5 and I found that when I programmatically edit the contained text, those changes are no longer available to the built in undo functionality.</p> <p>Is there a way to make it so these changes are available for undo/redo?</p>
[ { "answer_id": 275621, "author": "BFree", "author_id": 15861, "author_profile": "https://Stackoverflow.com/users/15861", "pm_score": 3, "selected": true, "text": " string buffer = String.Empty;\n string buffer2 = String.Empty;\n public Form3()\n {\n ...
2008/11/09
[ "https://Stackoverflow.com/questions/275493", "https://Stackoverflow.com", "https://Stackoverflow.com/users/194/" ]
275,514
<p>Something is eluding me ... it seems obvious, but I can't quite figure it out.</p> <p>I want to add/remove a couple of HTML controls to a page (plain old html) when a user changes value of a dropdown list. An example is to add or remove a "number of guests in this room" textbox for each (of a number) of rooms requested ... </p> <p>So if a user selects:</p> <p>1 room, there is one text box</p> <p>2 rooms, there are two text boxes</p> <p>3 rooms, three text boxes </p> <p>back to 2 rooms, two text boxes</p> <p>and so on ...</p>
[ { "answer_id": 275521, "author": "scunliffe", "author_id": 6144, "author_profile": "https://Stackoverflow.com/users/6144", "pm_score": 2, "selected": false, "text": "<script>\n //swap $ with applicable lib call (if avail)\n function $(id){\n return document.getElementById(id);\n }\...
2008/11/09
[ "https://Stackoverflow.com/questions/275514", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34770/" ]
275,536
<p>Where would the physical files be?</p>
[ { "answer_id": 275538, "author": "Blair Conrad", "author_id": 1199, "author_profile": "https://Stackoverflow.com/users/1199", "pm_score": 6, "selected": true, "text": "<SYSTEMDRIVE>\\Documents and Settings\\<user>\\Local Settings\\Application Data\\Microsoft\\IsolatedStorage \n" }, {...
2008/11/09
[ "https://Stackoverflow.com/questions/275536", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9328/" ]
275,540
<p>I would like to call an ejb3 at runtime. The name of the ejb and the method name will only be available at runtime, so I cannot include any remote interfaces at compile time.</p> <pre><code>String bean = 'some/Bean'; String meth = 'doStuff'; //lookup the bean Object remoteInterface = (Object) new InitialContext().lookup(bean); //search the method .. // foreach (methods) // if method == meth, method.invoke(bean); </code></pre> <p>the beans should be distributed accross multiple application servers, and all beans are to be called remotely.</p> <p>Any hints? specifically i do <strong>not</strong> want:</p> <ol> <li>dependency injection</li> <li>inclusion of appliation specific ejb interfaces in the dispatcher (above)</li> <li>webservices, thats like throwing out processing power for nothing, all the xml crap</li> </ol> <p>Is it possible to load an ejb3 remote interface over the network (if yes, how?), so I could cache the interface in some hashmap or something.</p> <p>I have a solution with a remote dispatcher bean, which I can include in the above main dispatcher, which does essentially the same, but just relays the call to a local ejb (which I can lookup how? naming lookup fails). Given the remote dispatcher bean, I can use dependency injection.</p> <p>thanks for any help</p> <p>(netbeans and glassfish btw)</p>
[ { "answer_id": 461625, "author": "Pavel", "author_id": 48340, "author_profile": "https://Stackoverflow.com/users/48340", "pm_score": 0, "selected": false, "text": "Object ejb = ctx.lookup(bean);\nfor (Method m : ejb.getClass().getMethods()) {\n if (m.getName().equals(meth) && m.getPar...
2008/11/09
[ "https://Stackoverflow.com/questions/275540", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]