qid
int64
4
19.1M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
414,738
<p>I am relatively new to web development and learning all the time. I have recently come across 'Conditional Comments' when viewing source code for different websites. I think i now understand what they do but am unsure as to when to use them.</p> <p>I have seen them mainly used for implementing different stylesheets when it comes to IE and would like to know if this is good practice?</p> <p>In which case if the answer is 'Yes'. Then when developing a site is it 'common place' to use two separate stylesheets to fix bugs, for example create one stylesheet for IE and one for Firefox, Opera etc?</p> <p>Thanks in advance.</p>
[ { "answer_id": 414784, "author": "George Stocker", "author_id": 16587, "author_profile": "https://Stackoverflow.com/users/16587", "pm_score": 2, "selected": false, "text": "hover <!--[if IE]>\n<style type=\"text/css\" media=\"screen\">\n#menu ul li {float: left; width: 100%;}\n</sty...
2009/01/05
[ "https://Stackoverflow.com/questions/414738", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50057/" ]
414,741
<p>I would like to pass a reference of a method into another method and store it as a variable. Later, I would like to use this reference to define an event handler.</p> <p>When making an event handler, a method reference is passed like:</p> <pre><code>myButton.Click += new RoutedEventHandler(myButton_Click); </code></pre> <p>And if you look at the constructor for "RoutedEventHandler" from intelliSense, it looks like:</p> <pre><code>RoutedEventHandler(void(object, RoutedEventArgs)) </code></pre> <p>What I would like to do is pass the method "myButton_Click" to a different static method and then create an event handler there. How do I pass the reference to the static method? I tried the following but it doesn't compile:</p> <pre><code>public class EventBuilder { private static void(object, RoutedEventArgs) _buttonClickHandler; public static void EventBuilder(void(object, RoutedEventArgs) buttonClickHandler) { _buttonClickHandler = buttonClickHandler; } public static void EnableClickEvent() { myButton.Click += new RoutedEventHandler(_buttonClickHandler); } } </code></pre> <p>Thanks, Ben</p>
[ { "answer_id": 414754, "author": "Jacob Adams", "author_id": 32518, "author_profile": "https://Stackoverflow.com/users/32518", "pm_score": 0, "selected": false, "text": "private static delegate void(object sender, RoutedEventArgs e) _buttonClickHandler;\n" }, { "answer_id": 41475...
2009/01/05
[ "https://Stackoverflow.com/questions/414741", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50859/" ]
414,746
<p>How do you declare a method in C# that should be overridden (or overridable) by a dereived class - possibly even outside your assembly - but that should be callable only from within the actual class?</p> <p>(i.e. like a private virtual function in C++)</p> <p><strong>[edit]</strong><br> <em><code>private</code></em> <code>virtual</code> is exactly what I intend: "Here's a way to modify my behavior, but you are still not allowed to call this function directly (because calling it requires arcane invocations that only my base class shall do)"</p> <p>So to clarify it: what is the best expression for that in C#?</p>
[ { "answer_id": 414770, "author": "Timothy Carter", "author_id": 4660, "author_profile": "https://Stackoverflow.com/users/4660", "pm_score": 2, "selected": false, "text": "public abstract class Animal\n{\n public void DisplayAttributes()\n {\n Console.WriteLine(Header());\n ...
2009/01/05
[ "https://Stackoverflow.com/questions/414746", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31317/" ]
414,749
<p>in that specific case</p> <pre><code> Const debugTime As String = "hh:mm:ss.fffffff" Dim i As Integer Debug.Print("Start " &amp; Now.ToString(debugTime)) For i = 0 To 4000000 j = 5 - 4 Next Debug.Print("End " &amp; Now.ToString(debugTime)) Debug.Print("Start " &amp; Now.ToString(debugTime)) For i = 0 To 4000000 j = 5 Mod 4 Next Debug.Print("End " &amp; Now.ToString(debugTime)) </code></pre> <p>result</p> <p>Start 05:33:39.8281250</p> <p>End 05:33:39.8437500</p> <p>Start 05:33:39.8437500</p> <p>End 05:33:39.8437500</p> <p><strong>* EDIT *</strong></p> <p>modified the code to make it look like that</p> <pre><code> Const debugTime As String = "hh:mm:ss.fffffff" Dim i As Long, j As Integer Dim r As Random r = New Random(1) Debug.Print("Start " &amp; Now.ToString(debugTime)) For i = 0 To 400000000 j = 5 - r.Next(1, 5) Next Debug.Print("End " &amp; Now.ToString(debugTime)) r = New Random(1) Debug.Print("Start " &amp; Now.ToString(debugTime)) For i = 0 To 400000000 j = 5 Mod r.Next(1, 5) Next Debug.Print("End " &amp; Now.ToString(debugTime)) </code></pre> <p>now the minus is faster...</p> <p>Start 05:49:25.0156250</p> <p>End 05:49:35.7031250</p> <p>Start 05:49:35.7031250</p> <p>End 05:49:48.2187500</p>
[ { "answer_id": 414763, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 3, "selected": false, "text": "a.asm yasm -f macho64 a.asm SECTION .text\nglobal _bmod, _bmin\n_bmod: push rdx\n push rbx\n mov rcx, 1000000000\n m...
2009/01/05
[ "https://Stackoverflow.com/questions/414749", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40868/" ]
414,761
<p>I have a C++ driver I'm trying to compile, and it has this line in the code:</p> <pre><code>#import "msado15.dll" no_namespace rename("EOF", "EndOfFile") </code></pre> <p>But when I compile the project, I get the error:</p> <p>Error 1 fatal error C1083: Cannot open type library file: 'msado15.dll': No such file or directory </p> <p>I have the DLL, but where do I put it so that the compiler can see it?</p>
[ { "answer_id": 17170133, "author": "declanh", "author_id": 723554, "author_profile": "https://Stackoverflow.com/users/723554", "pm_score": 2, "selected": false, "text": "C:\\Program Files\\Common Files\\System\\ado\n" } ]
2009/01/05
[ "https://Stackoverflow.com/questions/414761", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14537/" ]
414,788
<p>In C++ you are able to compile files that are not included in the solution, with c# this is not the case.</p> <p>Is there a way to keep a file in a project but not have the standard SCCI provider attempt to keep checking in the file?</p> <p>Essentially what we are wanting to do is to create "by developer" code ability similar to how we code in c++, this allows for us to let our developers do nightly check-ins with pseudo code and by-developer utilities.</p> <pre><code>#ifdef (TOM) #include "Tom.h"; #endif </code></pre> <hr> <p><strong>EDIT</strong> I don't want to create new configurations in the solution file either, I want these to be as machine specific as possible, without source control bindings to the user on the file/setting.</p>
[ { "answer_id": 414806, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "<When Condition=\" '$(Configuration)'=='TOM' \">\n <ItemGroup>\n <Compile Include=\"tomCode\\*.cs\" /> \n </ItemGro...
2009/01/05
[ "https://Stackoverflow.com/questions/414788", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13502/" ]
414,789
<p>In one form I am creating a territory and editing multiple users. The &quot;user_attributes&quot; below are for the users and the &quot;name&quot; is for the territory. So for each user_attribute I wanted to update the user model.</p> <h1>params</h1> <pre><code>{ &quot;territory&quot;=&gt;{&quot;name&quot;=&gt;&quot;Central Canada&quot;, &quot;user_attributes&quot;=&gt;[{&quot;user_id&quot;=&gt;&quot;30&quot;},{&quot;user_id&quot;=&gt;&quot;30&quot;}]} } </code></pre> <h1>create action</h1> <pre><code>@territory = @current_account.territories.new[:territory] params[:user_attributes].each do |item| @user = User.find(item[:user_id]) @user.update_attribute(:territory_id, @territory.id) end </code></pre> <p>But rails is kicking back that params[:user_attributes] is nil. But you can see from the params its not. Am I missing something??</p>
[ { "answer_id": 414872, "author": "J Cooper", "author_id": 38803, "author_profile": "https://Stackoverflow.com/users/38803", "pm_score": 4, "selected": true, "text": "user_attributes territory params[:territory][:user_attributes]" } ]
2009/01/05
[ "https://Stackoverflow.com/questions/414789", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10258/" ]
414,801
<p>I am wondering if there are any additional optimizations I can implement to improve the speed of reflective invocations in Java. Not that the performance is prohibitive, but I get the willies when thinking about some piece of code in a library I am writing being implemented in a tight loop somewhere.</p> <p>Consider a utility method to invoke reflectively:</p> <pre><code>public static Object invoke(Object targetObject, String methodName, Object[] arguments, Class&lt;?&gt;[] signature) </code></pre> <p>The basic operation is</p> <pre><code>return method.invoke(targetObject, arguments); </code></pre> <p>As a performance optimization, I cache the method using a hash of the target object's class, method name and signature (the code of which might use some improvement) but beyond that, is there anything else I can do ? I have heard references to some early implementations of <strong>InvokeDynamic</strong> that sound promising, but I just assumed that they were probably not applicable yet, and I discounted my own byte code manipulation as I would like to keep the utility simple (but fast).</p> <p>Cheers.</p>
[ { "answer_id": 414823, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 7, "selected": true, "text": "java.lang.Class" }, { "answer_id": 428311, "author": "Nicholas", "author_id": 43786, "author_profile": "h...
2009/01/05
[ "https://Stackoverflow.com/questions/414801", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43786/" ]
414,809
<p>I want to know if the page is being accessed via http or https using JavaScript. Is there some sort of isSecure() method, or should I just parse it out of the URL somehow?</p>
[ { "answer_id": 414827, "author": "Peter Stone", "author_id": 1806, "author_profile": "https://Stackoverflow.com/users/1806", "pm_score": 8, "selected": true, "text": "location.protocol if (location.protocol === 'https:') {\n // page is secure\n}\n" }, { "answer_id": 414829, ...
2009/01/05
[ "https://Stackoverflow.com/questions/414809", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28991/" ]
414,828
<p>Is it possible to run an UPDATE command on mysql 5.0 with a sub select.</p> <p>The command I would like to run is this:</p> <pre><code>UPDATE book_details SET live = 1 WHERE ISBN13 = '(SELECT ISBN13 FROM book_details_old WHERE live = 1)'; </code></pre> <p>ISBN13 is currently stored as a string.</p> <p>This should be updating 10k+ rows.</p> <p>Thanks,</p> <p>William</p>
[ { "answer_id": 414841, "author": "Rob", "author_id": 41908, "author_profile": "https://Stackoverflow.com/users/41908", "pm_score": 5, "selected": false, "text": "UPDATE book_details AS bd, book_details_old AS old\nSET bd.live=1 \nWHERE bd.isbn13=old.isbn13 \nAND old.live=1;\n" }, {...
2009/01/05
[ "https://Stackoverflow.com/questions/414828", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2725/" ]
414,835
<p>A while back, online apps used to say, "do not click submit more than once." That's gone now, right? How do you guard against that in, say, PHP?</p> <p>One solution I'm using involves putting a variable in the Session, so you cannot submit to a page more than once every 10 seconds. That way the database work will have completed so the normal checks can take place. Obviously, this feels like a hack and probably is.</p> <p><strong>Edit:</strong> Thanks everybody for the Javascript solution. That's fine, but it is a bit of work. 1) It's an input type=image and 2) The submit has to keep firing until the <a href="http://labs.adobe.com/technologies/spry/" rel="nofollow noreferrer">Spry stuff</a> says it's okay. This edit is just me complaining, basically, since I imagine that after looking at the Spry stuff I'll be able to figure it out.</p> <p><strong>Edit:</strong> Not that anyone will be integrating with the Spry stuff, but here's my final code using Prototype for the document.getElementByid. Comments welcome!</p> <pre><code>function onSubmitClick() { var allValid = true; var queue = Spry.Widget.Form.onSubmitWidgetQueue; for (var i=0;i&lt;queue.length; i++) { if (!queue[i].validate()) { allValid = false; break; } } if (allValid) { $("theSubmitButton").disabled = true; $("form").submit(); } } </code></pre> <p>For some reason, the second form submit was necessary...</p>
[ { "answer_id": 414854, "author": "cletus", "author_id": 18393, "author_profile": "https://Stackoverflow.com/users/18393", "pm_score": 3, "selected": false, "text": "$(\"form\").submit(function() {\n $(\":submit\",this).attr(\"disabled\", \"disabled\");\n});\n" }, { "answer_id": ...
2009/01/05
[ "https://Stackoverflow.com/questions/414835", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8047/" ]
414,849
<p>I've got a production DB with, say, ten million rows. I'd like to extract the 10,000 or so rows from the past hour off of production and copy them to my local box. How do I do that?</p> <p>Let's say the query is:</p> <pre><code>SELECT * FROM mytable WHERE date &gt; '2009-01-05 12:00:00'; </code></pre> <p>How do I take the output, export it to some sort of dump file, and then import that dump file into my local development copy of the database -- as quickly and easily as possible?</p>
[ { "answer_id": 414902, "author": "Keltia", "author_id": 16143, "author_profile": "https://Stackoverflow.com/users/16143", "pm_score": 2, "selected": false, "text": "psql copy \\c \\h copy psql" }, { "answer_id": 415872, "author": "bortzmeyer", "author_id": 15625, "aut...
2009/01/05
[ "https://Stackoverflow.com/questions/414849", "https://Stackoverflow.com", "https://Stackoverflow.com/users/91385/" ]
414,852
<p>I wonder if this is even possible. I have an application that adds a context menu when you right click a file. It all works fine but here is what I'd like to do:</p> <p>If the file is a PSD then I want the program to extract the image. Is this possible to do without having Photoshop installed?</p> <p>Basically I want the user to right click and click "image" which would save a .jpg of the file for them.</p> <p>edit: will be using c# Thanks</p>
[ { "answer_id": 414944, "author": "Dirk Vollmar", "author_id": 40347, "author_profile": "https://Stackoverflow.com/users/40347", "pm_score": 4, "selected": false, "text": "using System;\n\nstatic void Main(string[] args)\n{\n MagickNet.Magick.Init();\n MagicNet.Image img = new Magic...
2009/01/05
[ "https://Stackoverflow.com/questions/414852", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50312/" ]
414,879
<p>This sounds like a look-up-in-the-manual question to me, but I can't find it. Suppose we have a repository with files and directories in it that shouldn't be under version control but rather should be on the ignore list (such as Eclipse files <code>.settings</code>, <code>.project</code>, generated documentation files - things that should never have been added and committed in the first place). What is the best way of deleting these files from the repository and moving them straight onto the ignore list?</p> <p><strong>Update:</strong> The accepted answer below details a good way of setting up your local subversion repositories to avoid the problem described above. However, if you still have to solve this, it seems that you have to do some manual fiddling to get files/folders out of the repository and onto the ignore list. </p> <p>For instance, for the <code>.settings</code> folder, first add this to the global ignores list and then run the following command:</p> <pre><code>$REMOVE=".settings" cp -r "$REMOVE" /tmp/ &amp;&amp; \ svn rm "$REMOVE" &amp;&amp; \ svn commit -m "Moving to ignore list" "$REMOVE" &amp;&amp; \ mv "/tmp/$REMOVE" . </code></pre> <p>This copies the file/folder to a temporary location and then removes it from SVN and commits the remove - finally the file/folder is copied back, but as it is now on the ignore list it will be ignored by SVN.</p>
[ { "answer_id": 414888, "author": "Kevin Davis", "author_id": 49993, "author_profile": "https://Stackoverflow.com/users/49993", "pm_score": 3, "selected": false, "text": "svn remove filename\n svn propset svn:ignore filename|pattern\n" }, { "answer_id": 414890, "author": "Kelt...
2009/01/05
[ "https://Stackoverflow.com/questions/414879", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25517/" ]
414,889
<p>I'm trying to insert some new objects into a firebird database using NHibernate. </p> <p>I get the error "could not get next sequence value[SQL: SQL not available]"</p> <p>Here is the mapping I'm using at present. Note ANML_EVNT is the name of the generator I want to use.</p> <pre><code> &lt;id name="Id" column="ID" type="integer"&gt; &lt;generator class="sequence"&gt; &lt;param name="sequence"&gt;ANML_EVNT&gt;&lt;/param&gt; &lt;/generator&gt; &lt;/id&gt; </code></pre>
[ { "answer_id": 414967, "author": "gcores", "author_id": 40256, "author_profile": "https://Stackoverflow.com/users/40256", "pm_score": 2, "selected": false, "text": " <id name=\"Id\" column=\"ID\" type=\"integer\">\n <generator class=\"sequence\">\n <param name=\"sequence\">...
2009/01/05
[ "https://Stackoverflow.com/questions/414889", "https://Stackoverflow.com", "https://Stackoverflow.com/users/74652/" ]
414,891
<ul> <li>What is DOCTYPE and why do I want to use it?</li> <li>What are the different DOCTYPEs I can use?</li> <li>What is the difference between standards and quirks mode, and what are some quirks I may run into with differently set DOCTYPEs?</li> </ul> <p>Lastly, what is the proper DOCTYPE that I should be using?</p>
[ { "answer_id": 414913, "author": "Henrik Paul", "author_id": 2238, "author_profile": "https://Stackoverflow.com/users/2238", "pm_score": 2, "selected": false, "text": "<table>" }, { "answer_id": 414920, "author": "Georg Schölly", "author_id": 24587, "author_profile": ...
2009/01/05
[ "https://Stackoverflow.com/questions/414891", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45/" ]
414,893
<p>Is there a way to programmatically list all geo-tagged Wikipedia entries within a radius of a long/lat point? I'm thinking this is possible with the google maps API but I am interested in any method. NOTE: I do not want to display a googlemap.</p>
[ { "answer_id": 415682, "author": "guerda", "author_id": 32043, "author_profile": "https://Stackoverflow.com/users/32043", "pm_score": 2, "selected": false, "text": "findNearByWikipedia" }, { "answer_id": 9188267, "author": "Maksym Kozlenko", "author_id": 171847, "auth...
2009/01/05
[ "https://Stackoverflow.com/questions/414893", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6193/" ]
414,894
<p>The Ubuntu startup/login sound can be very loud, but I do like having it. I wrote a script that uses amixer to set the volume to 25%. This is the level I like to have it at, but when I use TV out or headphones I have to turn up the volume. I cannot seem to get the script to run before the login sound plays. I have tried a cron @reboot, and putting a symlink to the script in /etc/rc3.d/, and in my .bash_profile script. Only the 3rd method actually sets the volume correctly, but after the login sound plays.</p> <p>Ideally I want to have the script run when I am logging out for the night, or just before the ubuntu login screen displays.</p> <p>Here is the command to set the volume:</p> <pre><code>`/usr/bin/amixer -c 0 sset Master,0 25% &gt; /dev/null` </code></pre> <p>Suggestions for other methods to try are appreciated.</p>
[ { "answer_id": 415071, "author": "Zoredache", "author_id": 20267, "author_profile": "https://Stackoverflow.com/users/20267", "pm_score": 3, "selected": true, "text": "/etc/rc.local" }, { "answer_id": 905566, "author": "Maksim", "author_id": 51230, "author_profile": "h...
2009/01/05
[ "https://Stackoverflow.com/questions/414894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41908/" ]
414,896
<p>I'm trying to determine what is the fastest way to read in large text files with many rows, do some processing, and write them to a new file. In C#/.net, it appears StreamReader is a seemingly quick way of doing this but when I try to use for this file (reading line by line), it goes about 1/3 the speed of python's I/O (which worries me because I keep hearing that Python 2.6's IO was relatively slow). </p> <p>If there isn't faster .Net solution for this, would it be possible to write a solution faster than StreamReader or does it already use complicated buffer/algorithm/optimizations that I would never hope to beat?</p>
[ { "answer_id": 415283, "author": "Norman Ramsey", "author_id": 41661, "author_profile": "https://Stackoverflow.com/users/41661", "pm_score": 2, "selected": false, "text": "re2c re2c" } ]
2009/01/05
[ "https://Stackoverflow.com/questions/414896", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1469014/" ]
414,905
<p>I have a whole heap of legacy code that I checked into my SVN repository. I checked it in under my user name. I'd like to change the author of that commit to another user, 'legacy', in order to clean up the <code>svn blame</code> printouts.</p>
[ { "answer_id": 414914, "author": "Keltia", "author_id": 16143, "author_profile": "https://Stackoverflow.com/users/16143", "pm_score": 2, "selected": false, "text": "sed" } ]
2009/01/05
[ "https://Stackoverflow.com/questions/414905", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23071/" ]
414,906
<p>Basically I have a setup like the following:</p> <pre><code>Array ( [0] =&gt; Array ( [0] =&gt; stdClass Object ( [nid] =&gt; 1 [title] =&gt; title1 [uid] =&gt; 1 [parent] =&gt; 0 [weight] =&gt; -15 [name] =&gt; name1 [value] =&gt; 0 ) [1] =&gt; stdClass Object ( [nid] =&gt; 2 [title] =&gt; title2 [uid] =&gt; 1 [parent] =&gt; 0 [weight] =&gt; -7 [name] =&gt; name2 [value] =&gt; 100 ) [2] =&gt; stdClass Object ( [nid] =&gt; 3 [title] =&gt; title3 [uid] =&gt; 2 [parent] =&gt; 0 [weight] =&gt; -1 [name] =&gt; name3 [value] =&gt; 0 ) [3] =&gt; stdClass Object ( [nid] =&gt; 4 [title] =&gt; title4 [uid] =&gt; 2 [parent] =&gt; 0 [weight] =&gt; 1 [name] =&gt; name4 [value] =&gt; 80 ) ) ) </code></pre> <p>What I need is a way to sort all the arrays inside the parent array by the [value] key in the Object. I've been trying for about 2 days now with usort and different methods but I just can't seem to get my head around it. The [value] key will range anywhere from 0 to 100 and I need all of the arrays sorted in decreasing order (IE: 100 down to 0). </p>
[ { "answer_id": 414924, "author": "cletus", "author_id": 18393, "author_profile": "https://Stackoverflow.com/users/18393", "pm_score": 4, "selected": false, "text": "function cmp($a, $b) {\n if ($a->value == $b->value) {\n return 0;\n } else {\n return $a->value < $b->value ? 1 : ...
2009/01/05
[ "https://Stackoverflow.com/questions/414906", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
414,915
<p>Clicking through JMenu options is causing my JOGL GLCanvas to flicker. </p> <p>The JMenu has the setDefaultLightWeightPopupEnabled set to false. I don't want to use JGLPanel because it runs slower (the application needs to run in full screen mode).</p> <p>Interesting, the flicker stops if I set sun.java2d.opengl=true on the command line. However, the fact that sun doesn't enable this by default makes me worry that I would risk my users having trouble with hardware incompatibilities.</p> <p>Do other people see the flicker with the code below when clicking on the menu?</p> <p>I've tried all sorts of things, such as playing with the double-buffering options for the JFrame and for the canvas, but had no luck getting the canvas to not flicker.</p> <p>Can anyone get this not to flicker when the menu options are looked at?</p> <p>Thanks!</p> <p>-Dan</p> <pre><code>import javax.media.opengl.*; import javax.swing.*; public class FlickerTest extends JFrame { private GLCapabilities m_caps = new GLCapabilities(); public FlickerTest() { super("FlickerTest"); GLCanvas canvas = new GLCanvas(m_caps); add( canvas ); canvas.addGLEventListener( new MyGLEventListener() ); setSize( 640, 480 ); setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); // false lets the JMenuBar appear on top of the remote image openGL canvas JPopupMenu.setDefaultLightWeightPopupEnabled(false); setJMenuBar( getMyMenuBar() ); setVisible( true ); } public static void main(String[] args) { new FlickerTest(); } private static JMenuBar getMyMenuBar() { JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); JMenuItem quitMenuItem = new JMenuItem( "Quit" ); JMenuItem doSomething = new JMenuItem("Do Something"); fileMenu.add( quitMenuItem ); fileMenu.add( doSomething ); menuBar.add( fileMenu ); return menuBar; } private class MyGLEventListener implements GLEventListener { private MyGLEventListener() { } public void init(GLAutoDrawable drawable) { GL gl = drawable.getGL(); gl.glClearColor(1,1,0,0); gl.glBlendFunc(GL.GL_ONE,GL.GL_ONE); gl.glEnable(GL.GL_BLEND); } public synchronized void display( GLAutoDrawable p_glAutoDrawable ) { GL gl = p_glAutoDrawable.getGL(); gl.glClear(GL.GL_COLOR_BUFFER_BIT); gl.glColor3f(0,0,1); gl.glRectf(-.5f,-.5f,.5f,.5f); gl.glFlush(); } public void reshape(GLAutoDrawable p_drawable, int x, int y, int w, int h) { } public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) { } } } </code></pre>
[ { "answer_id": 415038, "author": "wusher", "author_id": 1632, "author_profile": "https://Stackoverflow.com/users/1632", "pm_score": 2, "selected": false, "text": "createBufferStrategy(2);" }, { "answer_id": 420677, "author": "wusher", "author_id": 1632, "author_profil...
2009/01/05
[ "https://Stackoverflow.com/questions/414915", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41762/" ]
414,922
<p>Anyone knows if there is an easy or known way to write a deep copy method that's gonna work on arrays of any kind, ie jagged, multidimensional, etc? I plan to write it as an extension method.</p> <p>There isn't a default method in the framework to do this, right? I am surprised not to find one.</p> <p>I have seen some serialization-based implementation and they were slow as hell, so I would like a solution which does not use any type of serialization.</p>
[ { "answer_id": 415557, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 4, "selected": true, "text": "ICloneable BinaryFormatter XmlSerializer T DeepClone<T>(T) [DataContract] [ProtoContract] Func<T,T> Converter<T,T> Exp...
2009/01/05
[ "https://Stackoverflow.com/questions/414922", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51816/" ]
414,928
<p>I've got a form with a bunch of controls on it, and I wanted to iterate through all the controls on a certain panel and enable/disable them.</p> <p>I tried this:</p> <pre><code>var component: TComponent; begin for component in myPanel do (component as TControl).Enabled := Value; end; </code></pre> <p>But that did nothing. Turns out all components are in the form's component collection, not their parent object's. So does anyone know if there's any way to get all the controls inside a control? (Besides an ugly workaround like this, which is what I ended up having to do):</p> <pre><code>var component: TComponent; begin for component in myPanel do if (component is TControl) and (TControl(component).parent = myPanel) then TControl(component).Enabled := Value; end; </code></pre> <p>Someone please tell me there's a better way...</p>
[ { "answer_id": 414940, "author": "Rob Kennedy", "author_id": 33732, "author_profile": "https://Stackoverflow.com/users/33732", "pm_score": 6, "selected": true, "text": "TWinControl.Controls ControlCount Components for in" }, { "answer_id": 414948, "author": "Toon Krijthe", ...
2009/01/05
[ "https://Stackoverflow.com/questions/414928", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32914/" ]
414,931
<p>I am currently playing around with the Asp.Net mvc framework and loving it compared to the classic asp.net way. One thing I am mooting is whether or not it is acceptable for a View to cause (indirectly) access to the database?</p> <p>For example, I am using the controller to populate a custom data class with all the information I think the View needs to go about doing its job, however as I am passing objects to the view it also can cause database reads.</p> <p>A quick pseudo example.</p> <pre><code>public interface IProduct { /* Some Members */ /* Some Methods */ decimal GetDiscount(); } public class Product : IProduct { public decimal GetDiscount(){ ... /* causes database access */ } } </code></pre> <p>If the View has access to the Product class (it gets passed an IProduct object), it can call GetDiscount() and cause database access. </p> <p>I am thinking of ways to prevent this. Currently I am only coming up with multiple interface inheritance for the <code>Product</code> class. Instead of implementing just IProduct it would now implement <code>IProduct</code> and <code>IProductView</code>. IProductView would list the members of the class, IProduct would contain the method calls which could cause database access.</p> <p>The 'View' will only know about the <code>IProductView</code> interface onto the class and be unable to call methods which cause data access. </p> <p>I have other vague thoughts about 'locking' an object before it is passed to the view, but I can foresee huge scope for side effects with such a method.</p> <p>So, My questions:</p> <ul> <li>Are there any best practices regarding this issue? </li> <li>How do other people using MVC stop the View being naughty and doing more to objects than they should?</li> </ul>
[ { "answer_id": 415025, "author": "Nicholas Piasecki", "author_id": 32187, "author_profile": "https://Stackoverflow.com/users/32187", "pm_score": 0, "selected": false, "text": "Document ViewData" } ]
2009/01/05
[ "https://Stackoverflow.com/questions/414931", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31128/" ]
414,932
<p>how do you run the cmdlet "get-mailbox" outside the current default scope of the current domain?</p> <p>When I run get-mailbox -OrganizationalUnit bob.com/bobsage I get an error message saying: Get-mailbox: The requested search root 'rss.com/rsstoilet' is not in the current default scope 'ens.com'. Cannot perform searches outside the current default scope.</p> <p>thanks in advance </p>
[ { "answer_id": 415903, "author": "Shay Levy", "author_id": 9833, "author_profile": "https://Stackoverflow.com/users/9833", "pm_score": 3, "selected": true, "text": "$AdminSessionADSettings.ViewEntireForest = $True Set-ADServerSettings -ViewEntireForest $True Get-Mailbox -IgnoreDefaultSco...
2009/01/05
[ "https://Stackoverflow.com/questions/414932", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18853/" ]
414,943
<p>I am inserting the HTML response from an AJAX call into my page, but then when I try to access those elements after they have been created, it fails..</p> <p>This is how i retrieve and insert the HTML:</p> <pre><code>$.ajax({url: 'output.aspx', data: 'id=5', type: 'get', datatype: 'html', success: function(outData) {$('#my_container').html(outData);} }) </code></pre> <p>The outcome HTML, which is inserted into the <code>&lt;div&gt;</code> (id = <code>my_container</code>) looks like:</p> <pre><code>&lt;div id="my_container"&gt; &lt;ul&gt; &lt;li id="578" class="notselected"&gt;milk&lt;/li&gt; &lt;li id="579" class="notselected"&gt;ice cream&lt;/li&gt; &lt;li id="580" class="selected"&gt;chewing gum&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>...and afterwards, when I try to access any of the <code>&lt;li&gt;</code> elements using queries like: <code>$('#my_container li:first')</code> or <code>$('#my_container ul:first-child')</code> or similar, nothing gets selected.</p> <p>I am using the <a href="http://plugins.jquery.com/project/Listen" rel="nofollow noreferrer">Listen plugin</a> to detect any click events on the <code>&lt;li&gt;</code>elements and it works... But i couldn't figure out how to detect if the div is populated with the output HTML and accordingly change one of the <code>&lt;li&gt;</code>'s class for example... </p> <p><code>$(document).ready</code> does not work either... </p> <p>Imagine I need to change the css style of the second <code>&lt;li&gt;</code>.. what is the solution to this?</p>
[ { "answer_id": 414971, "author": "Ben Blank", "author_id": 46387, "author_profile": "https://Stackoverflow.com/users/46387", "pm_score": 3, "selected": true, "text": "$.ajax(…) success" }, { "answer_id": 414985, "author": "William Brendel", "author_id": 2405, "author_...
2009/01/05
[ "https://Stackoverflow.com/questions/414943", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49742/" ]
414,945
<p>I have a self-referencing table with an Id, CategoryName, and ParentId. It's a typical scenario of a hierarchy table of categories that can themselves be divided into categories that DB experts tell me is called the adjacency model. </p> <p>What I want is to use Linq to SQL to query for subcategories that themselves are related to no other subcategories, ie they are immediate leaf nodes of some given category or subcategory. </p> <p>The easy part, I got, which is just getting the subcategories. Almost embarrassed to put the code here. But we do like to see code..</p> <pre><code>IList&lt;Categories&gt; subcategories = context.Where( c =&gt; c.ParentId == 1).ToList(); </code></pre> <p>But narrowing it to categories with no subcategories is turning me around. Any help would be much appreciated.</p> <p>Thanks for you help. Jeff</p> <p>UPDATE** It would appear this works, but if someone could confirm that it is "proper" I'd be grateful. So, if I want leaf nodes under a category with Id = 1, I would do this: </p> <pre><code>Categories.Where( c =&gt; !c.Children.Any ( d =&gt; d.ParentId == c.Id)).Where( e =&gt; e.ParentId == 1) </code></pre> <p>"Children" is the name Linq gives the self-referencing association.</p>
[ { "answer_id": 415079, "author": "Noah", "author_id": 47496, "author_profile": "https://Stackoverflow.com/users/47496", "pm_score": 0, "selected": false, "text": " (from c in context\n join cc in context on c.id equals cc.parentid into temp\n from t in temp.DefaultIfEmpty()\n ...
2009/01/05
[ "https://Stackoverflow.com/questions/414945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16426/" ]
414,946
<p>Is there a way to check if a ValidationSummary control has its IsValid property set to true using Javascript in the OnClientClick event of a button? </p> <p>What I'm trying to do is to show a message that says "please wait while your file is uploading" on an upload page, but if I use javascript to show that message, it shows up even when the ValidationSummary has errors, so the message shows up along with the errors underneath, which confuses users.</p>
[ { "answer_id": 415042, "author": "John MacIntyre", "author_id": 29043, "author_profile": "https://Stackoverflow.com/users/29043", "pm_score": 2, "selected": false, "text": "var isValid = false;\nif (typeof(Page_ClientValidate) == 'function') \n{\n isValid = Page_ClientValidate();\n}\n\...
2009/01/05
[ "https://Stackoverflow.com/questions/414946", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18234/" ]
414,952
<p>SQLAlchemy's <code>DateTime</code> type allows for a <code>timezone=True</code> argument to save a non-naive datetime object to the database, and to return it as such. Is there any way to modify the timezone of the <code>tzinfo</code> that SQLAlchemy passes in so it could be, for instance, UTC? I realize that I could just use <code>default=datetime.datetime.utcnow</code>; however, this is a naive time that would happily accept someone passing in a naive localtime-based datetime, even if I used <code>timezone=True</code> with it, because it makes local or UTC time non-naive without having a base timezone to normalize it with. I have tried (using <a href="http://pytz.sourceforge.net/" rel="noreferrer">pytz</a>) to make the datetime object non-naive, but when I save this to the DB it comes back as naive.</p> <p>Note how datetime.datetime.utcnow does not work with <code>timezone=True</code> so well:</p> <pre><code>import sqlalchemy as sa from sqlalchemy.sql import select import datetime metadata = sa.MetaData('postgres://user:pass@machine/db') data_table = sa.Table('data', metadata, sa.Column('id', sa.types.Integer, primary_key=True), sa.Column('date', sa.types.DateTime(timezone=True), default=datetime.datetime.utcnow) ) metadata.create_all() engine = metadata.bind conn = engine.connect() result = conn.execute(data_table.insert().values(id=1)) s = select([data_table]) result = conn.execute(s) row = result.fetchone() </code></pre> <blockquote> <p>(1, datetime.datetime(2009, 1, 6, 0, 9, 36, 891887))</p> </blockquote> <pre><code>row[1].utcoffset() </code></pre> <blockquote> <p>datetime.timedelta(-1, 64800) # that's my localtime offset!!</p> </blockquote> <pre><code>datetime.datetime.now(tz=pytz.timezone("US/Central")) </code></pre> <blockquote> <p>datetime.timedelta(-1, 64800)</p> </blockquote> <pre><code>datetime.datetime.now(tz=pytz.timezone("UTC")) </code></pre> <blockquote> <p>datetime.timedelta(0) #UTC</p> </blockquote> <p>Even if I change it to explicitly use UTC:</p> <p>...</p> <pre><code>data_table = sa.Table('data', metadata, sa.Column('id', sa.types.Integer, primary_key=True), sa.Column('date', sa.types.DateTime(timezone=True), default=datetime.datetime.now(tz=pytz.timezone('UTC'))) ) row[1].utcoffset() </code></pre> <p>...</p> <blockquote> <p>datetime.timedelta(-1, 64800) # it did not use the timezone I explicitly added</p> </blockquote> <p>Or if I drop the <code>timezone=True</code>:</p> <p>...</p> <pre><code>data_table = sa.Table('data', metadata, sa.Column('id', sa.types.Integer, primary_key=True), sa.Column('date', sa.types.DateTime(), default=datetime.datetime.now(tz=pytz.timezone('UTC'))) ) row[1].utcoffset() is None </code></pre> <p>...</p> <blockquote> <p>True # it didn't even save a timezone to the db this time</p> </blockquote>
[ { "answer_id": 59932909, "author": "Caner", "author_id": 448625, "author_profile": "https://Stackoverflow.com/users/448625", "pm_score": 4, "selected": false, "text": "2003-04-12 23:05:06 +01:00\n2003-04-13 00:05:06 +02:00 # This is the same time as above!\n UTC engine = create_engine(.....
2009/01/05
[ "https://Stackoverflow.com/questions/414952", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12650/" ]
414,954
<p>I get this fatal error only when I run on a Macintosh, but not on a windows browser, which doesn't make sense since, other than checking for the Browser condition, the conditional loops run the same code:</p> <p>Can someone help me understand how to stop this error in php? The error occurs on the FIRST instance of QEnterKeyEvent...and NOT the second. This doesn't make sense.</p> <p>In the code, the first instance is the first time it is ever called, so the class has not yet been created as far as I can tell.</p> <p>Yet the error says: cannot redeclare class QEnterKeyEvent</p> <pre><code>// Key-Specific Events (EnterKey, EscapeKey, UpArrowKey, DownArrowKey, etc.) if (QApplication::IsBrowser(QBrowserType::Macintosh)) { echo "keyspecific events - macintosh"; class QEnterKeyEvent extends QKeyPressEvent { protected $strCondition = 'event.keyCode == 13'; } class QEscapeKeyEvent extends QKeyPressEvent { protected $strCondition = 'event.keyCode == 27'; } class QUpArrowKeyEvent extends QKeyPressEvent { protected $strCondition = 'event.keyCode == 38'; } class QDownArrowKeyEvent extends QKeyPressEvent { protected $strCondition = 'event.keyCode == 40'; } } else { echo "key specific events - windows"; class QEnterKeyEvent extends QKeyDownEvent { protected $strCondition = 'event.keyCode == 13'; } class QEscapeKeyEvent extends QKeyDownEvent { protected $strCondition = 'event.keyCode == 27'; } class QUpArrowKeyEvent extends QKeyDownEvent { protected $strCondition = 'event.keyCode == 38'; } class QDownArrowKeyEvent extends QKeyDownEvent { protected $strCondition = 'event.keyCode == 40'; } } </code></pre>
[ { "answer_id": 415086, "author": "Chris Burgess", "author_id": 43034, "author_profile": "https://Stackoverflow.com/users/43034", "pm_score": 0, "selected": false, "text": "class QEnterKeyEvent extends QKeyDownEvent {\n protected $strCondition = 'event.keyCode == 13';\n}\n } el...
2009/01/05
[ "https://Stackoverflow.com/questions/414954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43980/" ]
414,959
<p>I have a user control and I want to create a property of type storyboard which I can set in xaml, so I tried to following, but I get a bad property error when I run it:</p> <pre><code>private Storyboard sbTransitionIn_m; public Storyboard TransitionIn { get {return sbTransitionIn_m;} set {sbTransitionIn_m = value;} } </code></pre> <p>xaml:</p> <pre><code>&lt;MyStuff:MyUserControl x:Name="ctlTest" TransitionIn="sbShow"/&gt; </code></pre>
[ { "answer_id": 415046, "author": "Michael S. Scherotter", "author_id": 27306, "author_profile": "https://Stackoverflow.com/users/27306", "pm_score": 1, "selected": false, "text": "<MyStuff:MyUserControl x:Name=\"ctlTest\">\n <MyStuff:MyUserControl.TransitionIn>\n <Storyboard/>\...
2009/01/05
[ "https://Stackoverflow.com/questions/414959", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9266/" ]
414,976
<p>I have 4 images on a page. I want to trigger a JS event once all 4 images are loaded. I of course can't be sure which order the images will be loaded in, so I can't trigger the event on the last image. One thought was to have a counter, but I can't think of the best way to check when that counter is equal to 4 as I don't like the idea of a setTimeout() checking every 200ms.</p> <p>Any other ideas?</p> <p>I'm using jQuery on the site, so I'm thinking that might be some help.</p> <p>This is the image HTML code:</p> <pre><code>&lt;img src="/images/hp_image-1.jpg" width="553" height="180" id="featureImg1" /&gt; &lt;img src="/images/hp_image-2.jpg" width="553" height="180" id="featureImg2" /&gt; &lt;img src="/images/hp_image-3.jpg" width="553" height="180" id="featureImg3" /&gt; &lt;img src="/images/hp_image-4.jpg" width="553" height="180" id="featureImg4" /&gt; </code></pre>
[ { "answer_id": 414980, "author": "Salty", "author_id": 50548, "author_profile": "https://Stackoverflow.com/users/50548", "pm_score": 2, "selected": false, "text": "count=0;\n$(\"img\").load(function() {\n count++;\n if(count==4) { //All images have loaded\n //Do something!\n...
2009/01/05
[ "https://Stackoverflow.com/questions/414976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5441/" ]
414,978
<p>Not sure how best to explain it, other than using an example...</p> <p>Imagine having a client with 10 outstanding invoices, and one day they provide you with a cheque, but do not tell you which invoices it's for.</p> <p>What would be the best way to return all the possible combination of values which can produce the required total?</p> <hr> <p>My current thinking is a kind of brute force method, which involves using a self-calling function that runs though all the possibilities (<a href="http://www.craigfrancis.co.uk/features/code/phpAddition/" rel="nofollow noreferrer">see current version</a>).</p> <p>For example, with 3 numbers, there are 15 ways to add them together:</p> <ol> <li>A</li> <li>A + B</li> <li>A + B + C</li> <li>A + C</li> <li>A + C + B</li> <li>B</li> <li>B + A</li> <li>B + A + C</li> <li>B + C</li> <li>B + C + A</li> <li>C</li> <li>C + A</li> <li>C + A + B</li> <li>C + B</li> <li>C + B + A</li> </ol> <p>Which, if you remove the duplicates, give you 7 unique ways to add them together:</p> <ol> <li>A</li> <li>A + B</li> <li>A + B + C</li> <li>A + C</li> <li>B</li> <li>B + C</li> <li>C</li> </ol> <p>However, this kind of falls apart after you have:</p> <ul> <li>15 numbers (32,767 possibilities / ~2 seconds to calculate)</li> <li>16 numbers (65,535 possibilities / ~6 seconds to calculate)</li> <li>17 numbers (131,071 possibilities / ~9 seconds to calculate)</li> <li>18 numbers (262,143 possibilities / ~20 seconds to calculate)</li> </ul> <p>Where, I would like this function to handle at least 100 numbers.</p> <p>So, any ideas on how to improve it? (in any language)</p>
[ { "answer_id": 414991, "author": "Toon Krijthe", "author_id": 18061, "author_profile": "https://Stackoverflow.com/users/18061", "pm_score": 1, "selected": false, "text": "001 = A\n010 = B\n011 = A+B\n100 = C\n101 = A+C\n110 = B+C\n111 = A+B+C\n" }, { "answer_id": 416131, "aut...
2009/01/05
[ "https://Stackoverflow.com/questions/414978", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6632/" ]
414,981
<p>I have this struct:</p> <pre><code>struct Map { public int Size; public Map ( int size ) { this.Size = size; } public override string ToString ( ) { return String.Format ( "Size: {0}", this.Size ); } } </code></pre> <p>When using array, it works:</p> <pre><code>Map [ ] arr = new Map [ 4 ] { new Map(10), new Map(20), new Map(30), new Map(40)}; arr [ 2 ].Size = 0; </code></pre> <p>But when using List, it doesn't compile:</p> <pre><code>List&lt;Map&gt; list = new List&lt;Map&gt; ( ) { new Map(10), new Map(20), new Map(30), new Map(40)}; list [ 2 ].Size = 0; </code></pre> <p>Why?</p>
[ { "answer_id": 414989, "author": "Dirk Vollmar", "author_id": 40347, "author_profile": "https://Stackoverflow.com/users/40347", "pm_score": 7, "selected": true, "text": "List<Map> list = new List<Map>() { \n new Map(10), \n new Map(20), \n new Map(30), \n new Map(40)\n};\n\nM...
2009/01/06
[ "https://Stackoverflow.com/questions/414981", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51816/" ]
414,984
<p>Given the following code:</p> <pre><code>var people = new List&lt;person&gt;(){ new person { Name = "John", FamilyName = "Pendray" }, new person { FamilyName = "Emery", Name = "Jake"}, new person { FamilyName = "Pendray", Name = "Richard" } }; var q = from p in people orderby p.Name group p by p.FamilyName into fam orderby fam.Key select new { fam.Key, members = from p in fam select p }; </code></pre> <p>Is it possible to replace the last line with a select that will output a IEnumerable<code>&lt;string</code>> that contains these two strings: "Pendray John Richard" "Emery Jake"? Is it possible to project a linq query into strings like this?</p> <p>Edit: I know this is possible with further code but I'm interested in whether this can be done from within the linq query itself in a similar way to VB being able to project xml out of a query as in <a href="http://www.thinqlinq.com/default/Projecting-XML-from-LINQ-to-SQL.aspx" rel="nofollow noreferrer">http://www.thinqlinq.com/default/Projecting-XML-from-LINQ-to-SQL.aspx</a> (particularly the last code block on this page)</p>
[ { "answer_id": 415148, "author": "configurator", "author_id": 9536, "author_profile": "https://Stackoverflow.com/users/9536", "pm_score": 0, "selected": false, "text": "people = new List<person>(){ new person { Name = \"John\", FamilyName = \"Pendray\" },\n new person { FamilyNam...
2009/01/06
[ "https://Stackoverflow.com/questions/414984", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18899/" ]
414,986
<p>I have a chunk of code where it appears that a variable is changing at the end of a pre-processor block of code.</p> <pre><code>int initialKeyCount; #if(DEBUG) // int initialKeyCount = _root.CountAllKeys(); initialKeyCount = 20000; #endif currNode = currNode.EnsureDegreeKeysPresent(parent); //initialKeyCount = 19969 here #if(DEBUG) int currentKeyCount = _root.CountAllKeys(); Debug.Assert(initialKeyCount == currentKeyCount, string.Format("EnsureDegreeNodesPresent changed the node count from {0} to {1}.", initialKeyCount, currentKeyCount)); #endif </code></pre> <p>When executing this in the debugger initialKeyCount = 19969 after supposedly assigning 20000. I have played around with this a bit and found that assignment to initialKeyCount is correct inside the first pre-processor block, but as soon as the code leaves the first pre-processor block the value magically changes to 19969.</p> <p>This behavior is the same regardless of whether the variable is declared inside or outside the first pre-processor block. The value remains 19969 inside the second pre-processor block.</p> <p>Are assignments made in a pre-processor block undefined outside of that block? That seems wrong but appears to be what is happening here.</p>
[ { "answer_id": 415145, "author": "ScottS", "author_id": 51851, "author_profile": "https://Stackoverflow.com/users/51851", "pm_score": 0, "selected": false, "text": "int initialKeyCount;\n#if(DEBUG)\n// int initialKeyCount = _root.CountAllKeys();\n initialKeyCount = 20000;\n...
2009/01/06
[ "https://Stackoverflow.com/questions/414986", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51851/" ]
415,005
<p>I'm using <strong>PHP 4.3.9, Apache/2.0.52</strong></p> <p>I'm trying to get a login system working that registers DB values in a session where they're available once logged in. <strong>I'm losing the session variables once I'm redirected</strong>.</p> <p>I'm using the following code to print the session ID/values on my login form page and the redirected page:</p> <pre><code>echo '&lt;font color="red"&gt;session id:&lt;/font&gt; ' . session_id() . '&lt;br&gt;'; echo '&lt;font color="red"&gt;session first name:&lt;/font&gt; ' . $_SESSION['first_name'] . '&lt;br&gt;'; echo '&lt;font color="red"&gt;session user id:&lt;/font&gt; ' . $_SESSION['user_id'] . '&lt;br&gt;'; echo '&lt;font color="red"&gt;session user level:&lt;/font&gt; ' . $_SESSION['user_level'] . '&lt;br&gt;&lt;br&gt;'; </code></pre> <p>This is what's printed in my browser from my login page (I just comment out the header redirect to the logged in page). <strong>This is the correct info coming from my DB as well, so all is fine at this point</strong>.</p> <pre><code>session id: 1ce7ca8e7102b6fa4cf5b61722aecfbc session first name: elvis session user id: 2 session user level: 1 </code></pre> <p>This is what's printed on my redirected/logged in page (when I uncomment the header/redirect). <strong>Session ID is the same</strong>, but I get no values for the individual session variables.</p> <pre><code>session id: 1ce7ca8e7102b6fa4cf5b61722aecfbc session first name: session user id: session user level: </code></pre> <p>I get the following errors:</p> <p><strong>Undefined index: first_name<br> Undefined index: user_id<br> Undefined index: user_level</strong></p> <p>I have a global <strong>header.php</strong> file which my loggedIN.php does NOT call, though loggedOUT.php does - to toast the session):</p> <p><strong>header.php</strong> </p> <pre><code>&lt;?php ob_start(); session_start(); //if NOT on loggedout.php, check for cookie. if exists, they haven't explicity logged out so take user to loggedin.php if (!strpos($_SERVER['PHP_SELF'], 'loggedout.php')) { /*if (isset($_COOKIE['access'])) { header('Location: www.mydomain.com/loggedin.php'); }*/ } else { //if on loggedout.php delete cookie //setcookie('access', '', time()-3600); //destroy session $_SESSION = array(); session_destroy(); setcookie(session_name(), '', time()-3600); } //defines constants and sets up custom error handler require_once('config.php'); ?&gt;&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; some page layout stuff Login portion is eventually called via include footer stuff </code></pre> <p>My <strong>loggedIN.php</strong> does nothing but start the session</p> <pre><code>&lt;?php session_start(); ?&gt;&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; </code></pre> <p>The <strong>logic of my login script</strong>, the key part being I'm fetching the DB results right into $_SESSION (about half way down):</p> <pre><code>if (isset($_POST['login'])) { //access db require_once(MYSQL); //initialize an errors array for non-filled out form fields $errors = array(); //setup $_POST aliases, clean for db and trim any whitespace $email = mysql_real_escape_string(trim($_POST['email']), $dbc); $pass = mysql_real_escape_string(trim($_POST['pass']), $dbc); if (empty($email)) { $errors[] = 'Please enter your e-mail address.'; } if (empty($pass)) { $errors[] = 'Please enter your password.'; } //if all fields filled out and everything is OK if (empty($errors)) { //check db for a match $query = "SELECT user_id, first_name, user_level FROM the rest of my sql here, blah blah blah"; $result = @mysql_query($query, $dbc) OR trigger_error("Query: $query\n&lt;br /&gt;MySQL Error: " . mysql_error($dbc)); if (@mysql_num_rows($result) == 1) { //a match was made, OK to login //register the retrieved values into $_SESSION $_SESSION = mysql_fetch_array($result); mysql_free_result($result); mysql_close($dbc); /* setcookie('access'); //if "remember me" not checked, session cookie, expires when browser closes //in FF you must close the tab before quitting/relaunching, otherwise cookie persists //"remember me" checked? if(isset($_POST['remember'])){ //expire in 1 hour (3600 = 60 seconds * 60 minutes) setcookie('access', md5(uniqid(rand())), time()+60); //EXPIRES IN ONE MINUTE FOR TESTING } */ echo '&lt;font color="red"&gt;cookie:&lt;/font&gt; ' . print_r($_COOKIE) . '&lt;br&gt;&lt;br&gt;'; echo '&lt;font color="red"&gt;session id:&lt;/font&gt; ' . session_id() . '&lt;br&gt;'; echo '&lt;font color="red"&gt;session first name:&lt;/font&gt; ' . $_SESSION['first_name'] . '&lt;br&gt;'; echo '&lt;font color="red"&gt;session user id:&lt;/font&gt; ' . $_SESSION['user_id'] . '&lt;br&gt;'; echo '&lt;font color="red"&gt;session user level:&lt;/font&gt; ' . $_SESSION['user_level'] . '&lt;br&gt;&lt;br&gt;'; ob_end_clean(); session_write_close(); $url = BASE_URL . 'loggedin_test2.php'; header("Location: $url"); exit(); } else { //wrong username/password combo echo '&lt;div id="errors"&gt;&lt;span&gt;Either the e-mail address or password entered is incorrect or you have not activated your account. Please try again.&lt;/span&gt;&lt;/div&gt;'; } //clear $_POST so the form isn't sticky $_POST = array(); } else { //report the errors echo '&lt;div id="errors"&gt;&lt;span&gt;The following error(s) occurred:&lt;/span&gt;'; echo '&lt;ul&gt;'; foreach($errors as $error) { echo "&lt;li&gt;$error&lt;/li&gt;"; } echo '&lt;/ul&gt;&lt;/div&gt;'; } } // end isset($_POST['login']) </code></pre> <p><strong>if I comment out the header redirect on the login page, I can echo out the $_SESSION variables with the right info from the DB. Once redirected to the login page, however, they're gone/unset.</strong></p> <p>Anyone have any ideas? I've spent nearly all day on this and can't say I'm any closer to figuring it out.</p> <p>BTW, I recently made 2 simple test pages, one started a session, set some variables on it, had a form submit which redirected to a second page which did nothing but read/output the session vars. It all seems to work fine, I'm just having issues with something I'm doing in my main app.</p>
[ { "answer_id": 415017, "author": "Ólafur Waage", "author_id": 22459, "author_profile": "https://Stackoverflow.com/users/22459", "pm_score": 2, "selected": false, "text": "session_regenerate_id(true); \n session_write_close();\n" }, { "answer_id": 415034, "author": "Rob Booth"...
2009/01/06
[ "https://Stackoverflow.com/questions/415005", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
415,018
<p>I am trying to float columns using CSS so they stack up evenly like on this blog: <a href="http://typeneu.com" rel="nofollow noreferrer">http://typeneu.com</a></p> <p>It seems to be impossible using CSS so I am looking into JavaScript.</p> <p>The website listed above uses this JavaScript file: <a href="http://typeneu.com/wp-content/themes/grid-a-licious/scripts/grid-a-licious.js" rel="nofollow noreferrer">http://typeneu.com/wp-content/themes/grid-a-licious/scripts/grid-a-licious.js</a></p> <p>I have tried to implement it to experiment but it doesn't seem to be working.</p> <p>Any links to tutorials on this subject or suggestions for getting it to work with JavaScript or CSS?</p> <p>Edit: I would like the number of columns to be flexible with the screen resolution.</p>
[ { "answer_id": 415017, "author": "Ólafur Waage", "author_id": 22459, "author_profile": "https://Stackoverflow.com/users/22459", "pm_score": 2, "selected": false, "text": "session_regenerate_id(true); \n session_write_close();\n" }, { "answer_id": 415034, "author": "Rob Booth"...
2009/01/06
[ "https://Stackoverflow.com/questions/415018", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51858/" ]
415,020
<p>We are looking to implement Optimistic locking in our WCF/WPF application. So far the best way I've come up with doing this is to implement a generic Optimistic which will store a copy of the original and any changes (so it will store two copies: the original and modified) of any value object that can be modified. Is this the best way of doing it?</p> <p>For example: a UserVO will be wrapped by the generic as a Optimistic. When a change is made to the Optimistic, the change will be made to the modified copy stored in the Optimistic while the original also stored in the Optimistic will remain intact. The main issue seems to be that it will use up twice the space and hence bandwidth.</p> <p>Thanks</p> <p><strong>EDIT</strong> The solution needs to be database independent, and it would be useful to be able to specify an conflict resolution policy per value object. (eg. A user object might try and merge if the updated rows weren't changed, but a transaction object would always require user intervention).</p>
[ { "answer_id": 415017, "author": "Ólafur Waage", "author_id": 22459, "author_profile": "https://Stackoverflow.com/users/22459", "pm_score": 2, "selected": false, "text": "session_regenerate_id(true); \n session_write_close();\n" }, { "answer_id": 415034, "author": "Rob Booth"...
2009/01/06
[ "https://Stackoverflow.com/questions/415020", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49142/" ]
415,035
<p>I'm trying out <a href="http://emacspeak.sourceforge.net" rel="nofollow noreferrer">http://emacspeak.sourceforge.net</a> now that I have it running on windows. I'd like to use emacs as more than a plain text editor and was wondering what extensions/packages everyone can't live with out? The languages I use the most are Perl, Java, and some C/C++.</p>
[ { "answer_id": 416776, "author": "Michael Paulukonis", "author_id": 41153, "author_profile": "https://Stackoverflow.com/users/41153", "pm_score": 1, "selected": false, "text": "(setq inhibit-startup-message t)\n\n;; window maximized\n(when (fboundp 'w32-send-sys-command)\n (w32-send-sys-...
2009/01/06
[ "https://Stackoverflow.com/questions/415035", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14744/" ]
415,036
<p>I'm trying to sort through a collection of DeepZoom sub-images based on arbitrary data associated with each image. The sub-images get loaded automagically through an XML file generated by DeepZoom Composer. I don't see a clear way to associate arbitrary data with a DeepZoom sub-image. </p> <p>The solutions that seem most obvious to me are brittle and don't scale well. Ideally, I'd like to put the relevant data in the generated XML file, but I'd lose that information on the next set of generated images. </p> <p>Is there a well-established way of accomplishing this goal?</p>
[ { "answer_id": 665241, "author": "Conceptdev", "author_id": 25673, "author_profile": "https://Stackoverflow.com/users/25673", "pm_score": 3, "selected": true, "text": "<Tag></Tag> TagUpdater.exe Metadata.xml Metadata.xml <Tag> <Image>\n<FileName>C:\\Documents and Settings\\xxxxxx\\My Doc...
2009/01/06
[ "https://Stackoverflow.com/questions/415036", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1473493/" ]
415,063
<p>I am compiling some benchmarks, and it says that I can try the option gcc-serial instead of only gcc, can anyone please explain the difference between gcc and gcc serial?.</p> <p>The place where that appears is <a href="http://parsec.cs.princeton.edu/download/tutorial/parsec-tutorial.pdf" rel="nofollow noreferrer">here</a> and it is mentioned for example in the slide 71. It is mentioned in more places but in none of them say what is gcc-serial.</p> <p>Thank you.</p>
[ { "answer_id": 415097, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 1, "selected": false, "text": "gcc-serial gcc gcc -serial gcc -serial -serial gcc gcc -mserialize-volatile -mno-serialize-volatile" }, { "a...
2009/01/06
[ "https://Stackoverflow.com/questions/415063", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39160/" ]
415,065
<p>I am trying to write a CSS in which when the user writes text and it overflows instead of having a scrollbar or hiding, it just goes down like in a normal Word Document or so. I have this code:</p> <pre><code>#content-text { width: 960px; padding-left: 10px; padding-right:10px; text-align: left; color:#000; height:100%; margin-left: 25px; margin-right:25px; } </code></pre> <p>The odd thing, is that while this code actually does what I want in IE in Firefox it overflows and becomes a scrollbar. I've tried overflow:auto; overflow:hidden; and overflow:inherit; just to see if any helped but no luck so far, and I honestly have no idea of why is this happening in Firefox, =/ would any of you know?</p> <hr> <p>Update: I tried with overflow:visible; but I just get the overflow...well visible but still it doesn't wraps. and ONLY in Firefox so far. =/</p> <hr> <p>Update: The only other thing that could be affecting is that I have another CSS code and the first is contained:</p> <pre><code>#content-title{ background-color: transparent; background-image: url(../img/content-title-body.png); background-repeat: repeat-y; background-attachment: scroll; background-x-position: 0%; background-y-position: 0%; height:auto; position:absolute; z-index :100; /* ensure the content-title is on top of navigation area */ width:1026px;/*1050px*/ margin: 160px 100px 5px 100px; overflow: visible; top: 55px; } </code></pre> <p>and the HTML that uses this is:</p> <pre><code>&lt;div id="content-title"&gt; &lt;div id="content-text"&gt; Hola!Hola!Hola!Hola!Hola!Hola!Hola!Hola!Hola!Hola!Hola!Hola!Hola!Hola!Hola!Hola!Hola!Hola!Hola!Hola!Hola!Hola!Hola!Hola!Hola!Hola!Hola!Hola!Hola!Hola!Hola!Hola!Hola!Hola!Hola!Hola!&lt;p&gt;Hola!Hola!Hola!Hola!Hola!Hola!&lt;p&gt;Hola!Hola!Hola!Hola!&lt;p&gt;Hola!Hola!Hola!Hola!&lt;p&gt;Hola!Hola!Hola!&lt;p&gt;Hola!Hola!Hola!Hola!&lt;p&gt;Hola!Hola! &lt;/div&gt; &lt;/div&gt; </code></pre>
[ { "answer_id": 415072, "author": "Shog9", "author_id": 811, "author_profile": "https://Stackoverflow.com/users/811", "pm_score": 2, "selected": false, "text": "overflow: visible" }, { "answer_id": 415114, "author": "Alex", "author_id": 30181, "author_profile": "https:...
2009/01/06
[ "https://Stackoverflow.com/questions/415065", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28586/" ]
415,092
<p>I'm writing my first PHP app that has to directly deal with dates, and thus to directly deal with the fact that PHP and MySQL have different date formats.</p> <p>My question is: what's the most elegant way to manage this difference?</p> <p>I have the following two functions to manage the difference using php:</p> <pre><code>function mysql_date($php_date) { return date( 'Y-m-d H:i:s', $php_date ); } function php_date($mysql_date) { $val = explode(" ",$mysql_date); $date = explode("-",$val[0]); $time = explode(":",$val[1]); return mktime($time[0],$time[1],$time[2],$date[1],$date[2],$date[0]); } </code></pre> <p>is there a simpler way to manage this directly within my SQL queries?</p> <p>Or could you suggest any other more elegant way to manage this?</p>
[ { "answer_id": 415122, "author": "too much php", "author_id": 28835, "author_profile": "https://Stackoverflow.com/users/28835", "pm_score": 2, "selected": false, "text": "$ymdDateAdded = date('Y-m-d');\n$timeDateAdded = strtotime($ymdDateAdded);\n$userDateadded = date('j F Y', $timeDateA...
2009/01/06
[ "https://Stackoverflow.com/questions/415092", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36848/" ]
415,094
<p>I do this all the time using VNC and it is very easy, but I am curious about a few things like XDMCP. As I understand it, this is a way of creating the entire desktop on a remote X-Server which seems fairly elegant.</p> <p>Several years ago, I worked on a Solaris server and multiple developers had X-Servers running in Windows and we were able to access a full remote X-desktop. All my efforts so far in X based systems seem to indicate that only one instance, remote or local, of the desktop can be loaded, so I guess this Solaris thing was an actual application that "emulated" a desktop, but who knows....</p> <p>Any input ?</p>
[ { "answer_id": 57548315, "author": "Yop", "author_id": 11943935, "author_profile": "https://Stackoverflow.com/users/11943935", "pm_score": 1, "selected": false, "text": "listen -query" } ]
2009/01/06
[ "https://Stackoverflow.com/questions/415094", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43786/" ]
415,095
<p>I have a form in an ASP file that I would like to pass to a php script for processing. Is this possible? I don't see why it wouldn't be, but I tried a dummy form on an asp file, with the action="phptest.php" and when submitting it just reloads the form page.</p>
[ { "answer_id": 416203, "author": "Jon Cram", "author_id": 5343, "author_profile": "https://Stackoverflow.com/users/5343", "pm_score": 2, "selected": false, "text": "action" } ]
2009/01/06
[ "https://Stackoverflow.com/questions/415095", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47858/" ]
415,101
<p>Can someone post a Visual Studio macro which goes through all C# source files in a project and adds a file banner? Extra credit if it works for any type of source file (.cs, .xaml, etc).</p>
[ { "answer_id": 415164, "author": "LarryF", "author_id": 18518, "author_profile": "https://Stackoverflow.com/users/18518", "pm_score": 1, "selected": false, "text": "function CommentAllFiles\n option explicit\n\n Dim ActiveProjectFullName\n Dim dte80 As EnvDTE80.Solution2\n\n ...
2009/01/06
[ "https://Stackoverflow.com/questions/415101", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38087/" ]
415,160
<p>What is the best method for creating an <a href="http://en.wikipedia.org/wiki/XMLHttpRequest" rel="noreferrer">XMLHttpRequest</a> object?</p> <p>It should work in all capable browsers.</p>
[ { "answer_id": 415165, "author": "cletus", "author_id": 18393, "author_profile": "https://Stackoverflow.com/users/18393", "pm_score": 3, "selected": false, "text": "$.ajax({\n url: 'document.xml',\n type: 'GET',\n dataType: 'xml',\n timeout: 1000,\n error: function(){\n ...
2009/01/06
[ "https://Stackoverflow.com/questions/415160", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51886/" ]
415,170
<p>I am working on my first project using ExtJS.</p> <p>I have a Data Grid sitting inside a Tab that is inside a Window.</p> <p>I want to add a link or button to the each element of the grid (I am using extended elements at the moment with HTML content through the RowExpander) that will make an AJAX call and open another tab.</p>
[ { "answer_id": 415165, "author": "cletus", "author_id": 18393, "author_profile": "https://Stackoverflow.com/users/18393", "pm_score": 3, "selected": false, "text": "$.ajax({\n url: 'document.xml',\n type: 'GET',\n dataType: 'xml',\n timeout: 1000,\n error: function(){\n ...
2009/01/06
[ "https://Stackoverflow.com/questions/415170", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14971/" ]
415,192
<p>I've been using python for years, but I have little experience with python web programming. I'd like to create a very simple web service that exposes some functionality from an existing python script for use within my company. It will likely return the results in csv. What's the quickest way to get something up? If it affects your suggestion, I will likely be adding more functionality to this, down the road.</p>
[ { "answer_id": 415248, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 4, "selected": false, "text": "#!/usr/bin/python\n\nprint \"Content-type: text/html\"\nprint\n\nprint \"<p>Hello world.</p>\"\n cgi" }, { "answe...
2009/01/06
[ "https://Stackoverflow.com/questions/415192", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18866/" ]
415,199
<p>I understand that const_cast to remove constness of objects is bad, </p> <p>I have the following use case, </p> <pre><code>//note I cannot remove constness in the foo function foo(const std::vector&lt;Object&gt; &amp; objectVec) { ... int size = (int) objectVec.size(); std::vector&lt;Object&gt; tempObjectVec; //Indexing here is to just show a part of the vector being //modified for (int i=0; i &lt; (int) size-5; ++i) { Object &amp;a = const_cast&lt;Object&amp;&gt; objectVec[i]; tempObjectVec.push_back(a); } foo1(tempObjectVec); } </code></pre> <p>If i change tempObjectVec objects in foo1, will the original objects in ObjectVec change, I say yes since I am passing references, further is this efficient. Can you suggest alternatives. </p>
[ { "answer_id": 415226, "author": "luqui", "author_id": 33796, "author_profile": "https://Stackoverflow.com/users/33796", "pm_score": 3, "selected": true, "text": "void foo1(std::vector<Object>::const_iterator start,\n std::vector<Object>::const_iterator end);\n\n...\nfoo1(object...
2009/01/06
[ "https://Stackoverflow.com/questions/415199", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43756/" ]
415,213
<p>I have a PHP IRC Robot that I use in my channel and I need it to make OPs to specific set users in the script by me. Anyways I want the robot to check if the user is logged into NickServ to prevent any sort of fraud or anything.</p> <p>Anyways, here is my connect and DO things code, followed by what I really need help with below it. All help is appreciated. :) On Freenode, typing /NS ACC [user] will return whether or not the [user] is logged in with a numerical value, they decided 3 would be logged in. and 0-2 as some sort of not logged in.</p> <p>So here is how the bot logs into my IRC channel... (feel free to join #tyreus on freenode, ask for BwaddArr (or his email))</p> <pre><code>&lt;?php set_time_limit(0); //Stop the script timing out $server = "irc.freenode.net"; //server to connect to $channel = "#tyreus"; //channel to connect to initialy $password = "sumpass"; //password for bot to login to irc $pass2 = "anotherpass"; //password to make the bot do stuff $users[0] = "0"; //array of logged in users $nickname = "Samcal"; //Set the bot's nick here $logger = FALSE; //for the channel logger $takeover = FALSE; //for the auto banner $socket=fsockopen($server,'6667') ; //Connect and join the channel stream_set_timeout($socket, 300); //Set a timeout value (so the bot quits if it's disconnected) fwrite($socket, "NICK ".$nickname."\r\n"); fwrite($socket, "USER ".$nickname." 8 * ::\x01VERSON 1.0 Brad's bot\x01\n"); //read rfc 1459 to understand this line while ($line=fgets($socket)) { echo htmlentities($line)."&lt;br&gt;"; if (strpos($line, "433")&gt;0) die("error nick in use"); //Quit if bot's nick is already taken (irc code 433 is received) if (strpos($line, "004")&gt;0) { fwrite($socket, "JOIN ".$channel."\r\n"); //Join the channel if everything is ok (irc code 004 is received) fwrite($socket, "NickServ IDENTIFY ".$nickname." ".$password."\r\n"); fwrite($socket, "ChanServ OP ".$channel." Samcal\r\n"); fwrite($socket, "MODE ".$channel." +v Samcal \r\n"); break; } } </code></pre> <p>And this is where i really need all the help! :)</p> <pre><code> if(strpos($line, "PRIVMSG ".$channel." :+oB\r\n")&gt;0) { //Command to make the bot run the command $name = "BwaddArr"; // my username, this can be easily changed to the other users who will need opping $command = "NickServ ACC $name"; // the NickServ command I was talking about $result = fwrite($socket, "$command \r\n"); // my attempt at retrieving the result $accr = readline(strpos($line, "$result \r\n")); //part 2 of my failure to retrieve a result $loggd = str_replace("3","three","$accr"); // replace '3' with 'three' if($loggd != "three") { // if result is not three do below fwrite($socket, "PRIVMSG ".$channel." :$name is not logged in. \r\n"); // write into the chat that the user is not logged in } if($loggd == "three") { // OP the user if they are logged in fwrite($socket, "MODE ".$channel." +ov $name\r\n"); // sends the OPping command } } ?&gt; </code></pre>
[ { "answer_id": 415810, "author": "Karsten", "author_id": 28144, "author_profile": "https://Stackoverflow.com/users/28144", "pm_score": 1, "selected": false, "text": "$result = fwrite($socket, \"$command \\r\\n\");\n" }, { "answer_id": 416845, "author": "Aif", "author_id":...
2009/01/06
[ "https://Stackoverflow.com/questions/415213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
415,214
<p>I need to create a structure or series of strings that are fixed lenght for a project I am working on. Currently it is written in COBOL and is a communication application. It sends a fixed length record via the web and recieves a fixed length record back. I would like to write it as a structure for simplicity, but so far the best thing I have found is a method that uses string.padright to put the string terminator in the correct place.</p> <p>I could write a class that encapsulates this and returns a fixed length string, but I'm hoping to find a simple way to fill a structure and use it as a fixed length record.</p> <p>edit--</p> <p>The fixed length record is used as a parameter in a URL, so its http:\somewebsite.com\parseme?record="firstname lastname address city state zip". I'm pretty sure I won't have to worry about ascii to unicode conversions since it's in a url. It's a little larger than that and more information is passed than address, about 30 or 35 fields.</p>
[ { "answer_id": 415232, "author": "Jonathan Allen", "author_id": 5274, "author_profile": "https://Stackoverflow.com/users/5274", "pm_score": 2, "selected": false, "text": "<StructLayout (LayoutKind.Sequential, CharSet:=CharSet.Auto)> _\nPublic Structure OSVERSIONINFO\n Public dwOSVersi...
2009/01/06
[ "https://Stackoverflow.com/questions/415214", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51890/" ]
415,218
<p>I have this function from a plugin (from a previous post)</p> <pre><code>// This method implements the test condition for // finding the ResolutionInfo. private static bool IsResolutionInfo(ImageResource res) { return res.ID == (int)ResourceIDs.ResolutionInfo; } </code></pre> <p>And the line thats calling this function:</p> <pre><code> get { return (ResolutionInfo)m_imageResources.Find(IsResolutionInfo); } </code></pre> <p>So basically I'd like to get rid of the calling function. It's only called twice (once in the get and the other in the set). And It could possible help me to understand inline functions in c#.</p>
[ { "answer_id": 415227, "author": "BFree", "author_id": 15861, "author_profile": "https://Stackoverflow.com/users/15861", "pm_score": 3, "selected": true, "text": "get\n {\n return (ResolutionInfo)m_imageResources.Find(res => res.ID == (int)ResourceIDs.ResolutionInfo);\n }\n public T...
2009/01/06
[ "https://Stackoverflow.com/questions/415218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50312/" ]
415,234
<p>I just found out (the hard way), that when you have a HTML form with <code>action=""</code>, Webkit browsers treat it differently to Firefox and Internet Explorer.</p> <p>In FF and IE, these two form tags are equivalent:</p> <pre><code>&lt;form method="post" action=""&gt; &lt;form method="post"&gt; </code></pre> <p>They will both submit the form back to the same page. Safari and Chrome however will send that first form to the default page (index.php, or whatever) - the second form works the same as FF/IE.</p> <p>I've quickly hacked my code so that anywhere where it would normally print an empty action, it doesn't add an action attribute at all.</p> <p>This seems very messy and not the best way to be doing things. Can anyone suggest a better method? Also, can anyone enlighten me about why Webkit would do such a thing?</p>
[ { "answer_id": 415335, "author": "staticsan", "author_id": 28832, "author_profile": "https://Stackoverflow.com/users/28832", "pm_score": 5, "selected": false, "text": "<form method='POST' action='?'>\n" }, { "answer_id": 613401, "author": "alex", "author_id": 31671, "...
2009/01/06
[ "https://Stackoverflow.com/questions/415234", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
415,240
<p>So I'm refactoring a legacy codebase I've inherited, and in the process I found a static class that encapsulates the logic for launching 3rd party applications. It essentially looks like this (shortened for brevity to only show one application):</p> <pre><code>using System.IO; using System.Configuration; public static class ExternalApplications { public string App1Path { get { if(null == thisApp1Path) thisApp1Path = Configuration.AppSettings.Get("App1Path"); return thisApp1Path; } } private string thisApp1Path = null; public bool App1Exists() { if(string.IsNullOrEmpty(App1Path)) throw new ConfigurationException("App1Path not specified."); return File.Exists(App1Path); } public void ExecuteApp1(string args) { // Code to launch the application. } } </code></pre> <p>It's a nice attempt to separate the external applications from the rest of the code, but it occurs to me that this could have been refactored further. What I have in mind is something like this:</p> <pre><code>using System.IO; public abstract class ExternalApplicationBase { protected ExternalApplicationBase() { InitializeFromConfiguration(); } public string Path { get; protected set; } public bool Exists() { if(string.IsNullOrEmpty(this.Path)) throw new ConfigurationException("Path not specified."); return File.Exists(this.Path); } public virtual void Execute(string args) { // Implementation to launch the application } protected abstract InitializeFromConfiguration(); } public class App1 : ExternalApplicationBase { protected virtual void InitializeFromConfiguration() { // Implementation to initialize this application from // the application's configuration file. } } public class App2 : ExternalApplicationBase { protected virtual void InitializeFromConfiguration() { // Implementation to initialize this application from // the application's configuration file. } } </code></pre> <p>My concerns are as follows:</p> <ol> <li><p>A class, interface, or other construct may already exist that does this, and I just haven't stumbled across it.</p></li> <li><p>It may be overkill for what I want to do. Note, however, that the application uses at least three separate 3rd party applications that I have identified so far (and more are almost certain to pop up). </p></li> <li><p>I'm not entirely comfortable with the name of the base class. It seems fuzzy, and not very informative (but I couldn't think of much better, given that Application is already well defined, reserved by the Framework, and would create a gross level of confusion were I to use it).</p></li> <li><p>The idea is that I want to be able to keep the application configuration data (it's path and executable name) in the App.Config file, and check for its existence when my application starts up; when my software needs to launch the software, I want to do it through a single method call, and not have the code building command lines and trying to launch the software manually (as it currently does).</p></li> </ol> <p>So I'm sending out a request for help, guidance, and suggestions. Anything you can profer is greatly appreciated.</p> <p>P.S. I'm asking this here because I work, as I frequently do, as a sole developer at my firm; I don't have anyone else to bounce these ideas off of. You guys have tons of experience with this stuff, and it would be foolish of me not to ask for your advice, so I hope you'll all bear with me. Thanks in advance!</p>
[ { "answer_id": 415691, "author": "jop", "author_id": 11830, "author_profile": "https://Stackoverflow.com/users/11830", "pm_score": 3, "selected": true, "text": "using System.IO;\npublic class ExternalApplication\n{\n public ExternalApplication(string path)\n {\n this.Path = path...
2009/01/06
[ "https://Stackoverflow.com/questions/415240", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47580/" ]
415,279
<p>I am trying to get PhysX working using Ubuntu.</p> <p>First, I downloaded the SDK here:</p> <ul> <li><a href="http://developer.download.nvidia.com/PhysX/2.8.1/PhysX_2.8.1_SDK_CoreLinux_deb.tar.gz" rel="nofollow noreferrer">http://developer.download.nvidia.com/PhysX/2.8.1/PhysX_2.8.1_SDK_CoreLinux_deb.tar.gz</a></li> </ul> <hr> <p>Next, I extracted the files and installed each package with:</p> <pre><code>dpkg -i filename.deb </code></pre> <p>This gives me the following files located in /usr/lib/PhysX/v2.8.1:</p> <ul> <li>libNxCharacter.so</li> <li>libNxCooking.so</li> <li>libPhysXCore.so</li> <li>libNxCharacter.so.1</li> <li>libNxCooking.so.1</li> <li>libPhysXCore.so.1</li> </ul> <hr> <p>Next, I created symbolic links to /usr/lib:</p> <pre><code>sudo ln -s /usr/lib/PhysX/v2.8.1/libNxCharacter.so.1 /usr/lib/libNxCharacter.so.1 sudo ln -s /usr/lib/PhysX/v2.8.1/libNxCooking.so.1 /usr/lib/libNxCooking.so.1 sudo ln -s /usr/lib/PhysX/v2.8.1/libPhysXCore.so.1 /usr/lib/libPhysXCore.so.1 </code></pre> <hr> <p>Now, using Eclipse, I have specified the following libraries (-l):</p> <ul> <li>libNxCharacter.so.1</li> <li>libNxCooking.so.1</li> <li>libPhysXCore.so.1</li> </ul> <p>And the following search paths just in case (-L):</p> <ul> <li>/usr/lib/PhysX/v2.8.1</li> <li>/usr/lib</li> </ul> <p>Also, as Gerald Kaszuba suggested, I added the following include paths (-I):</p> <ul> <li>/usr/lib/PhysX/v2.8.1</li> <li>/usr/lib</li> </ul> <hr> <p>Then, I attempted to compile the following code:</p> <pre><code>#include "NxPhysics.h" NxPhysicsSDK* gPhysicsSDK = NULL; NxScene* gScene = NULL; NxVec3 gDefaultGravity(0,-9.8,0); void InitNx() { gPhysicsSDK = NxCreatePhysicsSDK(NX_PHYSICS_SDK_VERSION); if (!gPhysicsSDK) { std::cout&lt;&lt;"Error"&lt;&lt;std::endl; return; } NxSceneDesc sceneDesc; sceneDesc.gravity = gDefaultGravity; gScene = gPhysicsSDK-&gt;createScene(sceneDesc); } int main(int arc, char** argv) { InitNx(); return 0; } </code></pre> <p>The first error I get is:</p> <blockquote> <p>NxPhysics.h: No such file or directory</p> </blockquote> <p>Which tells me that the project is obviously not linking properly. Can anyone tell me what I have done wrong, or what else I need to do to get my project to compile? I am using the GCC C++ Compiler. Thanks in advance!</p>
[ { "answer_id": 415487, "author": "Mr Fooz", "author_id": 25050, "author_profile": "https://Stackoverflow.com/users/25050", "pm_score": 3, "selected": true, "text": "gcc hello.c -o hello\n" }, { "answer_id": 415798, "author": "Scott", "author_id": 48096, "author_profil...
2009/01/06
[ "https://Stackoverflow.com/questions/415279", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48096/" ]
415,287
<p>I'd like to know which is the preferred way to add records to a database table in a Rails Migration. I've read on Ola Bini's book (Jruby on Rails) that he does something like this:</p> <pre><code>class CreateProductCategories &lt; ActiveRecord::Migration #defines the AR class class ProductType &lt; ActiveRecord::Base; end def self.up #CREATE THE TABLES... load_data end def self.load_data #Use AR object to create default data ProductType.create(:name =&gt; "type") end end </code></pre> <p>This is nice and clean but for some reason, doesn't work on the lasts versions of rails...</p> <p>The question is, how do you populate the database with default data (like users or something)?</p> <p>Thanks!</p>
[ { "answer_id": 418678, "author": "user52227", "author_id": 52227, "author_profile": "https://Stackoverflow.com/users/52227", "pm_score": 2, "selected": false, "text": "ActiveRecord::Base.connection.execute(\"INSERT INTO product_types (name) VALUES ('type1'), ('type2')\") mysqldump -uroot...
2009/01/06
[ "https://Stackoverflow.com/questions/415287", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7595/" ]
415,291
<p>I have 3 byte arrays in C# that I need to combine into one. What would be the most efficient method to complete this task?</p>
[ { "answer_id": 415307, "author": "FryGuy", "author_id": 28776, "author_profile": "https://Stackoverflow.com/users/28776", "pm_score": 5, "selected": false, "text": "byte[] Combine(byte[] a1, byte[] a2, byte[] a3)\n{\n byte[] ret = new byte[a1.Length + a2.Length + a3.Length];\n Arra...
2009/01/06
[ "https://Stackoverflow.com/questions/415291", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20183/" ]
415,297
<p>Let us ignore for a moment Damian Conway's best practice of no more than three positional parameters for any given subroutine.</p> <p>Is there any difference between the two examples below in regards to performance or functionality?</p> <p>Using <code>shift</code>:</p> <pre><code>sub do_something_fantastical { my $foo = shift; my $bar = shift; my $baz = shift; my $qux = shift; my $quux = shift; my $corge = shift; } </code></pre> <p>Using <code>@_</code>:</p> <pre><code>sub do_something_fantastical { my ($foo, $bar, $baz, $qux, $quux, $corge) = @_; } </code></pre> <p>Provided that both examples are the same in terms of performance and functionality, what do people think about one format over the other? Obviously the example using <code>@_</code> is fewer lines of code, but isn't it more legible to use <code>shift</code> as shown in the other example? Opinions with good reasoning are welcome.</p>
[ { "answer_id": 415390, "author": "Joe Casadonte", "author_id": 45978, "author_profile": "https://Stackoverflow.com/users/45978", "pm_score": 3, "selected": false, "text": "sub do_something {\n my $foo = shift;\n $foo .= \".1\";\n\n my $baz = shift;\n $baz .= \".bak\";\n\n my $b...
2009/01/06
[ "https://Stackoverflow.com/questions/415297", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6406/" ]
415,302
<pre><code>&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; function bigtosmalltriangle() { $(this).siblings("div.break").removeClass('triangle3').addClass('triangle1'); setTimeout ( "smalltomediumtriangle()", 400 ); } function smalltomediumtriangle() { $(this).siblings("div.break").removeClass('triangle1').addClass('triangle2'); setTimeout ( "mediumtobigtriangle()", 400 ); } function mediumtobigtriangle() { $(this).siblings("div.break").removeClass('triangle2').addClass('triangle3'); setTimeout ( "bigtosmalltriangle()", 400 ); } $(function() { $("span#clickhere").click( function() { /* do a lot stuff here */ bigtosmalltriangle(); $(this).hide(); } ); }); &lt;/script&gt; &lt;style type="text/css"&gt; .triangle1 {background:#000;} .triangle2 {background:red;} .triangle3 {background:white;} &lt;/style&gt; </code></pre> <p></p> <pre><code>&lt;div&gt;&lt;div class="break"&gt;Hello World&lt;/div&gt;&lt;span id="clickhere"&gt;asdf&lt;/span&gt;&lt;/div&gt; </code></pre> <p>I'm trying to get get the div.break to scroll through 3 bgcolors, but when I click on the span it has no effect. Does anyone know what I should do?</p> <p>Thanks.</p>
[ { "answer_id": 415325, "author": "Matthew Crumley", "author_id": 2214, "author_profile": "https://Stackoverflow.com/users/2214", "pm_score": 3, "selected": true, "text": "function bigtosmalltriangle(elements) {\n elements.removeClass('triangle3').addClass('triangle1');\n setTimeout...
2009/01/06
[ "https://Stackoverflow.com/questions/415302", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
415,313
<p>Say I'm working with Sharepoint (this applies to other object models as well) and in the middle of my statement, I call a method, in this case "OpenWeb()", which creates an IDisposable SPWeb object. Now, I cannot call Dispose() on the SPWeb object because I don't have the reference to it. <strong>So do I need to be concerned about this leaking memory?</strong> </p> <pre><code>SPUser spUser = SPControl.GetContextSite(HttpContext.Current).OpenWeb().SiteUsers[@"foo\bar"]; </code></pre> <p>I know that I could have broken up the statement into multiple lines and get the SPWeb reference to call Dispose:</p> <pre><code>SPWeb spWeb = SPControl.GetContextSite(HttpContext.Current).OpenWeb(); SPUser spUser = spWeb.SiteUsers[@"foo\bar"]; spWeb.Dispose(); </code></pre> <p>Please keep in mind that my question is not about aesthetics, but more about what happens to the IDisposable object that I cannot explicitly call Dispose() on, since I don't have the reference. </p> <p>Sorry about not being clear enough when I first asked the question. I've since rephrased it. Thanks for all the responses so far.</p>
[ { "answer_id": 415323, "author": "denis phillips", "author_id": 748, "author_profile": "https://Stackoverflow.com/users/748", "pm_score": 2, "selected": false, "text": "using (SPWeb spWeb = SPControl.GetContextSite(HttpContext.Current).OpenWeb())\n{\n SPUser spUser = spWeb.SiteUsers[@...
2009/01/06
[ "https://Stackoverflow.com/questions/415313", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48988/" ]
415,315
<p>Is there a way to use fields_for with in a form without having a scope?</p> <p>For example:</p> <pre><code>&lt;% fields_for "user[]" do |x| &lt;%= x.text_field :name %&gt; &lt;% end %&gt; </code></pre> <p>Without the user model being loaded in memory?</p> <p>I got it working using territory[user][][name], but I would like to keep it in ERB.</p>
[ { "answer_id": 415328, "author": "Derek P.", "author_id": 45615, "author_profile": "https://Stackoverflow.com/users/45615", "pm_score": 0, "selected": false, "text": "<%form_tag :my_form do %>\n <%= text_field_tag :foo, :bar %>\n<%end%>\n" }, { "answer_id": 416603, "author": ...
2009/01/06
[ "https://Stackoverflow.com/questions/415315", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10258/" ]
415,368
<p>LCDs have 4 data lines. But the data to be displayed in the LCD is given in the ASCII form which is 7 bits. How is that possible?</p>
[ { "answer_id": 415379, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 2, "selected": false, "text": "f f ; sync\n0 ; clear display (cmd = 0).\n1 0 3 ; set cursor (cmd = 1) to offset 3.\n2 H e...
2009/01/06
[ "https://Stackoverflow.com/questions/415368", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
415,375
<p>I was reading a question about c# code optimization and one solution was to use c++ with SSE. Is it possible to do SSE directly from a c# program?</p>
[ { "answer_id": 22860718, "author": "KindDragon", "author_id": 61505, "author_profile": "https://Stackoverflow.com/users/61505", "pm_score": 3, "selected": false, "text": "Microsoft.Numerics.Vectors.Vector<T>" }, { "answer_id": 58333083, "author": "DragonSpit", "author_id"...
2009/01/06
[ "https://Stackoverflow.com/questions/415375", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32958/" ]
415,403
<p>I've used a number of different *nix-based systems of the years, and it seems like every flavor of Bash I use has a different algorithm for deciding which startup scripts to run. For the purposes of tasks like setting up environment variables and aliases and printing startup messages (e.g. MOTDs), which startup script is the appropriate place to do these?</p> <p>What's the difference between putting things in <code>.bashrc</code>, <code>.bash_profile</code>, and <code>.environment</code>? I've also seen other files such as <code>.login</code>, <code>.bash_login</code>, and <code>.profile</code>; are these ever relevant? What are the differences in which ones get run when logging in physically, logging in remotely via ssh, and opening a new terminal window? Are there any significant differences across platforms (including Mac OS X (and its Terminal.app) and Cygwin Bash)?</p>
[ { "answer_id": 415437, "author": "Jonathan Leffler", "author_id": 15168, "author_profile": "https://Stackoverflow.com/users/15168", "pm_score": 3, "selected": false, "text": "~/.profile ~/.login ~/.cshrc ~/.bash_profile ~/.bashrc /.cshrc ~/.bashrc ~/.environment" }, { "answer_id"...
2009/01/06
[ "https://Stackoverflow.com/questions/415403", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9530/" ]
415,407
<p>I'm working on making a simple server application with python, and I'm trying to get the IP to bind the listening socket to. An example I looked at uses this: </p> <pre><code>HOST = gethostbyaddr(gethostname()) </code></pre> <p>With a little more processing after this, it should give me just the host IP as a string. This should return the IPv4 address. But when I run this code, it returns my IPv6 address. Why does it do this and how can I get my IPv4 address?</p> <p>If its relevant, I'm using windows vista and python 2.5</p>
[ { "answer_id": 415417, "author": "Harley Holcombe", "author_id": 1057, "author_profile": "https://Stackoverflow.com/users/1057", "pm_score": 5, "selected": true, "text": "netifaces >>> import netifaces\n>>> netifaces.interfaces()\n['lo', 'eth0']\n>>> netifaces.ifaddresses('eth0')\n{17: [...
2009/01/06
[ "https://Stackoverflow.com/questions/415407", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2128/" ]
415,409
<p>In order to run one application, a batch file has to be kicked off (which does things like start Jetty, display live logs, etc). The application will work only if this batch file is running. I am hence forced to have this batch file running and not logout from the Windows server.</p> <p>Can this batch file be run as a service? I am experimenting with one of the suggestions from a <a href="https://stackoverflow.com/questions/298562/windows-xp-or-vista-how-can-i-run-a-batch-file-in-the-background-no-windows-dis#298564">similar question</a>.</p>
[ { "answer_id": 13294293, "author": "Junior Mayhé", "author_id": 66708, "author_profile": "https://Stackoverflow.com/users/66708", "pm_score": 8, "selected": false, "text": "nssm install \"YourCoolServiceNameLabel\"\n nssm remove \"YourCoolServiceNameLabel\"\n" }, { "answer_id": 5...
2009/01/06
[ "https://Stackoverflow.com/questions/415409", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28609/" ]
415,432
<p>How to mock ObjectContext or ObjectQuery in Entity Framework?</p>
[ { "answer_id": 18645613, "author": "Zorayr", "author_id": 577878, "author_profile": "https://Stackoverflow.com/users/577878", "pm_score": 2, "selected": false, "text": "App.Config" }, { "answer_id": 47349104, "author": "Major", "author_id": 3706778, "author_profile": ...
2009/01/06
[ "https://Stackoverflow.com/questions/415432", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
415,433
<p>sometimes, git will spontaneously (during some, but not all, "pull" or "clone" operations) copy all of the remote branches of a repository into my local repository (and even set them all up to track the corresponding remote branches correctly). What causes this? Is there a way I can do this on purpose?</p>
[ { "answer_id": 415542, "author": "Dustin", "author_id": 39975, "author_profile": "https://Stackoverflow.com/users/39975", "pm_score": 3, "selected": false, "text": "git checkout -b somebranch origin/somebranch\n git checkout -t origin/somebranch\n" }, { "answer_id": 9641303, ...
2009/01/06
[ "https://Stackoverflow.com/questions/415433", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13195/" ]
415,434
<p>I've started to look into the whole unit testing/test-driven development idea, and the more I think about it, the more it seems to fill a similar role to static type checking. Both techniques provide a compile-time, rapid-response check for certain kinds of errors in your program. However, correct me if I'm wrong, but it seems that a unit test suite with full coverage would test everything static type checking would test, and then some. Or phrased another way, static type checks only go part of the way to "prove" that your program is correct, whereas unit tests will let you "prove" as much as you want (to a certain extent).</p> <p>So, is there any reason to use a language with static type checking if you're using unit testing as well? A somewhat similar question was asked <a href="https://stackoverflow.com/questions/236407/python-for-large-scale-development">here</a>, but I'd like to get into more detail. What specific advantages, if any, does static type checking have over unit tests? A few issues like compiler optimizations and intellisense come to mind, but are there other solutions for those problems? Are there other advantages/disadvantages I haven't thought of?</p>
[ { "answer_id": 415495, "author": "Brian Matthews", "author_id": 1969, "author_profile": "https://Stackoverflow.com/users/1969", "pm_score": 2, "selected": false, "text": "if (qty > 3)\n{\n applyShippingDiscount();\n}\nelse\n{\n chargeFullAmountForShipping();\n}\n" }, { "ans...
2009/01/06
[ "https://Stackoverflow.com/questions/415434", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21957/" ]
415,442
<p>So I have an app which plays many short sound clips. I need to know when the sounds are finished playing, and I need to use mp3s, so I'm using AVFoundation for the sound playback.</p> <p>When a sound is actively playing, and the user uses the hardware volume buttons, the playback volume changes. Problem is, the app is NOT constantly playing sounds, and when it's not, and the hardware buttons are used, the RINGER volume gets adjusted instead.</p> <p>How do I set it up so, as long as the app is running, the user can adjust the playback volume?</p> <p>Thanks!</p>
[ { "answer_id": 505893, "author": "DanM", "author_id": 47450, "author_profile": "https://Stackoverflow.com/users/47450", "pm_score": 4, "selected": true, "text": "AVAudioPlayer prepareToPlay play" } ]
2009/01/06
[ "https://Stackoverflow.com/questions/415442", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47450/" ]
415,452
<p>What would be a set of nifty preprocessor hacks (ANSI C89/ISO C90 compatible) which enable some kind of ugly (but usable) object-orientation in C?</p> <p>I am familiar with a few different object-oriented languages, so please don't respond with answers like &quot;Learn C++!&quot;. I have read &quot;<a href="https://www.cs.rit.edu/%7Eats/books/ooc.pdf" rel="nofollow noreferrer" title="Object-Oriented Programming With ANSI C">Object-Oriented Programming With ANSI C</a>&quot; (beware: <strong>PDF format</strong>) and several other interesting solutions, but I'm mostly interested in yours :-)!</p> <hr /> <p>See also <em><a href="https://stackoverflow.com/questions/351733" title="Can you write object oriented code in C?">Can you write object oriented code in C?</a></em></p>
[ { "answer_id": 415459, "author": "Kieveli", "author_id": 15852, "author_profile": "https://Stackoverflow.com/users/15852", "pm_score": 5, "selected": false, "text": "struct vehicle {\n int power;\n int weight;\n}\n struct van {\n struct vehicle base;\n int cubic_size;\n}\n struct...
2009/01/06
[ "https://Stackoverflow.com/questions/415452", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
415,455
<p>I have some old software (in a language that's not dead but is dead to me ;-)) that implements a basic pattern-matching and -rewriting system for source code. I am considering resurrecting this code, translating it into a modern language, and open-sourcing the project as a refactoring power-tool. Before I go much further, I want to know if anything like this exists already (my google-fu is fanning air on this tonight).</p> <p>Here's how it works:</p> <ul> <li>the pattern-matching part matches source-code patterns spanning multiple lines of code using a template with binding variables, </li> <li>the pattern-rewriting part uses a template to rewrite the matched code, inserting the contents of the bound variables from the matching template</li> <li>matching and rewriting templates are associated (1:1) by a simple (unconditional) rewrite rule</li> </ul> <p>the software operates on the abstract syntax tree (AST) of the input application, and outputs a modified AST which can then be regenerated into new source code</p> <p>for example, suppose we find a bunch of while-loops that really should be for-loops. The following template will match the while-loop pattern:</p> <pre><code>Template oldLoopPtrn int @cnt@ = 0; while (@cnt@ &lt; @max@) { … @body@ ++@cnt@; } End_Template </code></pre> <p>while the following template will specify the output rewrite pattern:</p> <pre><code>Template newLoopPtrn for(int @cnt@ = 0; @cnt@ &lt; @max@; @cnt@++) { @body@ } End_Template </code></pre> <p>and a simple rule to associate them</p> <pre><code>Rule oldLoopPtrn --&gt; newLoopPtrn </code></pre> <p>so code that looks like this</p> <pre><code>int i=0; while(i&lt;arrlen) { printf("element %d: %f\n",i,arr[i]); ++i; } </code></pre> <p>gets automatically rewritten to look like this</p> <pre><code>for(int i = 0; i &lt; arrlen; i++) { printf("element %d: %f\n",i,arr[i]); } </code></pre> <p>The closest thing I've seen like this is some of the code-refactoring tools, but they seem to be geared towards interactive rewriting of selected snippets, not wholesale automated changes.</p> <p>I believe that this kind of tool could supercharge refactoring, and would work on multiple languages (even HTML/CSS). I also believe that converting and polishing the code base would be a huge project that I simply cannot do alone in any reasonable amount of time.</p> <p>So, anything like this out there already? If not, any obvious features (besides rewrite-rule conditions) to consider?</p> <p>EDIT: The one feature of this system that I like very much is that the template patterns are fairly obvious and easy to read because <em>they're written in the same language as the target source code</em>, not in some esoteric mutated regex/BNF format.</p>
[ { "answer_id": 10868828, "author": "TXL Pro", "author_id": 1433282, "author_profile": "https://Stackoverflow.com/users/1433282", "pm_score": 2, "selected": false, "text": "include \"c.grm\"\n\nrule main\n replace [declaration_or_statement*]\n int cnt [id] = 0;\n while (c...
2009/01/06
[ "https://Stackoverflow.com/questions/415455", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9345/" ]
415,483
<p>I have a file input element that needs to be cloned after the user has browsed and selected a file to upload. I started by using obj.cloneNode() and everything worked fine, that is until I tried using it in IE. </p> <p>I've since tried using jQuery's clone method as follows:</p> <pre><code>var tmp = jQuery('#categoryImageFileInput_'+id).clone(); var clone = tmp[0]; </code></pre> <p>Works as expected in FireFox, but again not in IE. </p> <p>I'm stuck. Anyone have some suggestions? </p>
[ { "answer_id": 528996, "author": "Mark Allen", "author_id": 64245, "author_profile": "https://Stackoverflow.com/users/64245", "pm_score": 6, "selected": false, "text": "// Clone the \"real\" input element\nvar real = $(\"#categoryImageFileInput_\" + id);\nvar cloned = real.clone(true);\n...
2009/01/06
[ "https://Stackoverflow.com/questions/415483", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42033/" ]
415,511
<p>How do I get the current time?</p>
[ { "answer_id": 415519, "author": "Harley Holcombe", "author_id": 1057, "author_profile": "https://Stackoverflow.com/users/1057", "pm_score": 13, "selected": true, "text": "datetime >>> import datetime\n>>> now = datetime.datetime.now()\n>>> now\ndatetime.datetime(2009, 1, 6, 15, 8, 24, 7...
2009/01/06
[ "https://Stackoverflow.com/questions/415511", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46646/" ]
415,515
<p>Pretty self-explanatory, I tried google and got a lot of the dreaded expertsexchange, I searched here as well to no avail. An online tutorial or example would be best. Thanks guys.</p>
[ { "answer_id": 415547, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": false, "text": "CSVDocument doc;\ndoc.Load(\"file.csv\");\nCSVDocumentBody* body = doc.GetBody();\n\nCSVDocumentRow* header = body->GetRow(0);...
2009/01/06
[ "https://Stackoverflow.com/questions/415515", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50391/" ]
415,520
<p>I'm learning Servlets programming, using Apache Tomcat 6 on a Ubuntu 8.10 machine, and I'm running with a very annoying issue -- apparently, related to caching.</p> <p>This is what I'm doing: I write a servlet, put it in a nice directory structure and deploy it using the Tomcat Web Application Manager. It works as expected. Then I edit the servlet, recompile and try to access it again, but Tomcat keeps returning the same old version. Reloading the Application or even restarting the server does not work. The only thing that works is "Undeploying" the Application, then deploying it all over again. </p> <p>I have to do this every single time I make any small change on my code. It sucks.</p> <p>I'm sure there is a way around this, but I couldn't find the answer anywhere on the web (and I did search a lot). I would really appreciate any help. Thanks!</p>
[ { "answer_id": 415541, "author": "Adeel Ansari", "author_id": 42769, "author_profile": "https://Stackoverflow.com/users/42769", "pm_score": 2, "selected": false, "text": "<Context>\n <!-- Default set of monitored resources -->\n <WatchedResource>WEB-INF/web.xml</WatchedResource>\n ...
2009/01/06
[ "https://Stackoverflow.com/questions/415520", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
415,532
<p>I see some interesting discussions here about static vs. dynamic typing. I generally prefer static typing, due to compile type checking, better documented code, etc. However, I do agree that they do clutter up the code if done the way Java does it, for example.</p> <p>So I'm about to start building a functional style language of my own, and type inference is one of the things that I want to implement. I do understand that it is a big subject, and I'm not trying to create something that has not been done before, just basic inferencing...</p> <p>Any pointers on what to read up that will help me with this? Preferably something more pragmatic/practical as opposed to more theoretical category theory/type theory texts. If there's an implementation discussion text out there, with data structures/algorithms, that would just be lovely.</p>
[ { "answer_id": 415617, "author": "Paul", "author_id": 51102, "author_profile": "https://Stackoverflow.com/users/51102", "pm_score": 5, "selected": false, "text": "+ let (if (= 1 2) \n 1 \n 2)\n then else 1 2 if (let ((id (lambda (x) x)))\n (id id))\n id x id id a -> a a (a -> a)...
2009/01/06
[ "https://Stackoverflow.com/questions/415532", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51923/" ]
415,550
<p>I know very little about JavaScript but despite this I'm trying to cobble something together on my wordpress blog. It's not working, and I don't know how to resolve it, and hey, that's what StackOverflow is for, right?</p> <p>Firstly, the error message is:</p> <pre><code>Error: element.dispatchEvent is not a function Source File: http://.../wp-includes/js/prototype.js?ver=1.6 Line: 3936 </code></pre> <p>It happens on page load. My page load handler is registered thusly:</p> <pre><code>Event.observe(window, 'load', show_dates_as_local_time); </code></pre> <p>The error goes away if I disable some other plugins, and this (plus googling) led me to conclude that it was a conflict between prototype and jQuery (which is used by some of the other plugins).</p> <p>Secondly I'm following the wordpress recommended practice of using <a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script" rel="nofollow noreferrer"><code>wp_enqeue_script</code></a> to add a dependency from my JavaScript to the Prototype library, as follows:</p> <pre><code>add_action( 'wp_print_scripts', 'depo_theme_add_javascript' ); function depo_theme_add_javascript() { wp_enqueue_script('friendly_dates', 'javascript/friendly_dates.js', array('prototype')); } </code></pre> <p>Now I'm also aware that there are some potential conflicts between jQuery and Prototype which are resolved using the jQuery <code>noConflicts</code> method. I've tried calling that from various places but no good. I don't <em>think</em> this is the problem because a) the <code>noConflict</code> function relates solely to the <code>$</code> variable, which doesn't seem to be the problem here, and b) I would <em>expect</em> wordpress to sort it out for me because it can...</p> <p>Lastly, using the Venkman debugger I've determined that the <code>element</code> referenced in the error message is indeed an <code>HTMLDocument</code> but also does lack a <code>dispatchEvent</code>. Not sure how this could happen, given it's a standard DOM method?</p>
[ { "answer_id": 415626, "author": "Kent Fredric", "author_id": 15614, "author_profile": "https://Stackoverflow.com/users/15614", "pm_score": 4, "selected": false, "text": " jQuery(function($){ \n code_with_$_here; \n }); \n (function($){ \n code_with_$_here; \n})(jQuery); \n" },...
2009/01/06
[ "https://Stackoverflow.com/questions/415550", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31038/" ]
415,562
<p>Is there a way to test code coverage within visual studio if I'm using MSTest? Or do I have to buy NCover? </p> <p>Is the NCover Enterprise worth the money or are the old betas good enough if Microsoft doesn't provide built in tools to do code coverage?</p> <p>EDIT: Description of VS Products and which ones include code coverage <a href="https://www.visualstudio.com/vs/compare/" rel="nofollow noreferrer">https://www.visualstudio.com/vs/compare/</a></p> <p>TestDriven.NET (<a href="http://testdriven.net/" rel="nofollow noreferrer">http://testdriven.net/</a>) can be used if your VS version doesn't support it.</p>
[ { "answer_id": 37005493, "author": "granadaCoder", "author_id": 214977, "author_profile": "https://Stackoverflow.com/users/214977", "pm_score": 3, "selected": false, "text": "set __msTestExe=C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\MSTest.exe\nset __codeCovera...
2009/01/06
[ "https://Stackoverflow.com/questions/415562", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17176/" ]
415,571
<p>Given two tables, one for workers and one for tasks completed by workers,</p> <pre><code>CREATE TABLE IF NOT EXISTS `workers` ( `id` int(11) NOT NULL, PRIMARY KEY (`id`) ); INSERT INTO `workers` (`id`) VALUES (1); CREATE TABLE IF NOT EXISTS `tasks` ( `id` int(11) NOT NULL, `worker_id` int(11) NOT NULL, `status` int(11) NOT NULL, PRIMARY KEY (`id`) ); INSERT INTO `tasks` (`id`, `worker_id`, `status`) VALUES (1, 1, 1), (2, 1, 1), (3, 1, 2), (4, 1, 2), (5, 1, 2); </code></pre> <p>I'm trying to get the number of tasks each worker has with each status code.</p> <p>I can say either</p> <pre><code>SELECT w.* ,COUNT(t1.worker_id) as status_1_count FROM workers w LEFT JOIN tasks t1 ON w.id = t1.worker_id AND t1.status = 1 WHERE 1 GROUP BY t1.worker_id ORDER BY w.id </code></pre> <p>or</p> <pre><code>SELECT w.* ,COUNT(t2.worker_id) as status_2_count FROM workers w LEFT JOIN tasks t2 ON w.id = t2.worker_id AND t2.status = 2 WHERE 1 GROUP BY t2.worker_id ORDER BY w.id </code></pre> <p>and get the number of tasks with a single given status code, but when I try to get the counts for multiple task statuses in a single query, it doesn't work!</p> <pre><code>SELECT w.* ,COUNT(t1.worker_id) as status_1_count ,COUNT(t2.worker_id) as status_2_count FROM workers w LEFT JOIN tasks t1 ON w.id = t1.worker_id AND t1.status = 1 LEFT JOIN tasks t2 ON w.id = t2.worker_id AND t2.status = 2 WHERE 1 GROUP BY t1.worker_id ,t2.worker_id ORDER BY w.id </code></pre> <p>The tasks table is cross-joining against itself when I would rather it wouldn't!</p> <p>Is there any way to combine these two queries into one such that we can retrieve the counts for multiple task statuses in a single query?</p> <p>Thanks!</p>
[ { "answer_id": 415577, "author": "Jonathan Leffler", "author_id": 15168, "author_profile": "https://Stackoverflow.com/users/15168", "pm_score": 2, "selected": false, "text": "SELECT worker_id, status, COUNT(*)\n FROM tasks\n GROUP BY worker_id, status;\n" }, { "answer_id": ...
2009/01/06
[ "https://Stackoverflow.com/questions/415571", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51928/" ]
415,580
<p>It is my understanding that the <code>java.regex</code> package does not have support for named groups (<a href="http://www.regular-expressions.info/named.html" rel="noreferrer">http://www.regular-expressions.info/named.html</a>) so can anyone point me towards a third-party library that does?</p> <p>I've looked at <a href="http://jregex.sourceforge.net/" rel="noreferrer">jregex</a> but its last release was in 2002 and it didn't work for me (admittedly I only tried briefly) under java5.</p>
[ { "answer_id": 415635, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 9, "selected": true, "text": "(?<name>capturing text) \\k<name> ${name} Matcher.group(String name) \"TEST 123\"\n \"(?<login>\\\\w+) (?<id>\\\\d+)\"\n matcher...
2009/01/06
[ "https://Stackoverflow.com/questions/415580", "https://Stackoverflow.com", "https://Stackoverflow.com/users/444/" ]
415,602
<p>I am attempting to set a value in a textarea field using jquery with the following code:</p> <pre><code>$("textarea#ExampleMessage").attr("value", result.exampleMessage); </code></pre> <p>The issue is, once this code executes, it is not altering the text in the textarea?</p> <p>However when performing an <code>alert($("textarea#ExampleMessage").attr("value"))</code> the newly set value is returned?</p>
[ { "answer_id": 415609, "author": "enobrev", "author_id": 14651, "author_profile": "https://Stackoverflow.com/users/14651", "pm_score": 11, "selected": true, "text": "$(\"textarea#ExampleMessage\").val(result.exampleMessage);\n" }, { "answer_id": 415618, "author": "Jomit", ...
2009/01/06
[ "https://Stackoverflow.com/questions/415602", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41211/" ]
415,605
<p>Can someone tell me what exactly the two above lines of javascript do? And more importantly, what it's called so I can search some javascript references to learn about it? I assume they are both creating some form of an array that objects can be added to...?</p>
[ { "answer_id": 415611, "author": "Sophie Alpert", "author_id": 49485, "author_profile": "https://Stackoverflow.com/users/49485", "pm_score": 3, "selected": true, "text": "map list" } ]
2009/01/06
[ "https://Stackoverflow.com/questions/415605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13413/" ]
415,620
<p>I'm developing an Windows Forms application that requires me to call a separate program to perform a task. The program is a console application and I need to redirect standard output from the console to a TextBox in my program. </p> <p>I have no problem executing the program from my application, but I don't know how to redirect the output to my application. I need to capture output while the program is running using events. </p> <p>The console program isn't meant to stop running until my application stops and the text changes constantly at random intervals. What I'm attempting to do is simply hook output from the console to trigger an event handler which can then be used to update the TextBox.</p> <p>I am using C# to code the program and using the .NET framework for development. The original application is not a .NET program.</p> <p>EDIT: Here's example code of what I'm trying to do. In my final app, I'll replace Console.WriteLine with code to update the TextBox. I tried to set a breakpoint in my event handler, and it isn't even reached.</p> <pre><code> void Method() { var p = new Process(); var path = @"C:\ConsoleApp.exe"; p.StartInfo.FileName = path; p.StartInfo.UseShellExecute = false; p.OutputDataReceived += p_OutputDataReceived; p.Start(); } static void p_OutputDataReceived(object sender, DataReceivedEventArgs e) { Console.WriteLine("&gt;&gt;&gt; {0}", e.Data); } </code></pre>
[ { "answer_id": 415655, "author": "Mark Maxham", "author_id": 49737, "author_profile": "https://Stackoverflow.com/users/49737", "pm_score": 7, "selected": true, "text": "void RunWithRedirect(string cmdPath)\n{\n var proc = new Process();\n proc.StartInfo.FileName = cmdPath;\n\n /...
2009/01/06
[ "https://Stackoverflow.com/questions/415620", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
415,629
<p>If I have a CSS class which I <em>only</em> ever apply to form elements, eg:</p> <pre><code>&lt;form class="myForm"&gt; </code></pre> <p>Which of these two jQuery selectors is most efficient, and why?</p> <pre><code>a) $('form.myForm') b) $('.myForm') </code></pre>
[ { "answer_id": 415648, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 5, "selected": false, "text": "$('form.myForm') $('.myForm') $('form.myForm') $('.myForm') <p> <form> <p>" }, { "answer_id": 415794, "author": "r...
2009/01/06
[ "https://Stackoverflow.com/questions/415629", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
415,649
<p>I am learning Jsf.Is there any method for making the spinners read only?I should change the value only using spinners and not directly typing the number.Can i implement that by setting attribute in the spinners.tld file?</p>
[ { "answer_id": 506780, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 2, "selected": true, "text": " <h:inputText id=\"number\" value=\"#{compositeComponent.attrs.value}\"/>\n outputLabel <h:outputLabel for=\"number\" value=\"#{...
2009/01/06
[ "https://Stackoverflow.com/questions/415649", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40933/" ]
415,654
<p>I'm trying to use Expression.Dynamic() to build an assignment operation... I want to use this to selectively offer value type semantics to certain custom type instances in my language. I can't do this with a "static" (?) Expression because I don't know what the actual type is (I need the MetaObject instance and its LimitType... hence Expression.Dynamic() ).</p> <p>This isn't working for me... Expression.Assign() does nothing if used to build a MetaObject from my OperationBinder subclass.</p> <p>Head. Pounding. On. Desk. For. Hours.</p> <p>Just wondering if this is a supported behavior, or if I'm barking up the wrong tree?</p> <p>Thanks...</p>
[ { "answer_id": 415761, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 0, "selected": false, "text": "Expression" }, { "answer_id": 419134, "author": "Community", "author_id": -1, "author_profile": "...
2009/01/06
[ "https://Stackoverflow.com/questions/415654", "https://Stackoverflow.com", "https://Stackoverflow.com/users/630/" ]
415,677
<p>I want to pipe the output of a &quot;template&quot; file into MySQL, the file having variables like <code>${dbName}</code> interspersed. What is the command line utility to replace these instances and dump the output to standard output?</p> <p>The input file is considered to be safe, but faulty substitution definitions could exist. Performing the replacement should avoid performing unintended code execution.</p>
[ { "answer_id": 415693, "author": "Beau Simensen", "author_id": 50453, "author_profile": "https://Stackoverflow.com/users/50453", "pm_score": 3, "selected": false, "text": "perl -p -e 's/\\$\\{dbName\\}/testdb/s' yourfile | mysql\n #!/usr/bin/env perl\nmy %replace = ( 'dbName' => 'testdb'...
2009/01/06
[ "https://Stackoverflow.com/questions/415677", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2567/" ]
415,687
<p>Was there any reason why the designers of Java felt that local variables should not be given a default value? Seriously, if instance variables can be given a default value, then why can't we do the same for local variables?</p> <p>And it also leads to problems as explained in <a href="http://javahowto.blogspot.com/2007/01/variable-might-not-have-been.html?showComment=1206851400000#c1463508649088298714" rel="noreferrer">this comment to a blog post</a>:</p> <blockquote> <p>Well this rule is most frustrating when trying to close a resource in a finally block. If I instantiate the resource inside a try, but try to close it within the finally, I get this error. If I move the instantiation outside the try, I get another error stating that a it must be within a try.</p> <p>Very frustrating.</p> </blockquote>
[ { "answer_id": 415771, "author": "Rob Kennedy", "author_id": 33732, "author_profile": "https://Stackoverflow.com/users/33732", "pm_score": 5, "selected": false, "text": "SomeObject so;\ntry {\n // Do some work here ...\n so = new SomeObject();\n so.DoUsefulThings();\n} finally {\n so...
2009/01/06
[ "https://Stackoverflow.com/questions/415687", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9195/" ]
415,692
<p>I have two forms in my rails app. They both exist in separate tabs and I when I submit one form I want the data in the other form to be saved as well. How should I do that? Or Is there a better way of doing this instead of using two separate forms? Is there a better way to spread a long form into multiple tabs and when I press submit all the data from all the tabs should reach my action. Thanks.</p>
[ { "answer_id": 415731, "author": "Eli", "author_id": 27580, "author_profile": "https://Stackoverflow.com/users/27580", "pm_score": 4, "selected": true, "text": "<form action='action1'>\n <!-- All elements from both forms, plus tabs, etc. -->\n</form>\n <form action='action1'>\n\n <...
2009/01/06
[ "https://Stackoverflow.com/questions/415692", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44916/" ]
415,711
<p>I'm using UpdatePanel to asynchronously call a button click event in a page that calls a method in another class which writes out an XML file on the output. Is there a way to do this with JQuery instead of UpdatePanel?</p>
[ { "answer_id": 415829, "author": "Rik Heywood", "author_id": 4012, "author_profile": "https://Stackoverflow.com/users/4012", "pm_score": -1, "selected": false, "text": "$(\"#MyButtonID\").click();\n <input type=\"button\" id=\"MyButtonID\" value=\"Press Me\" />\n" }, { "answer_id...
2009/01/06
[ "https://Stackoverflow.com/questions/415711", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1688440/" ]
415,730
<p>I'd like to have the nightly build check for how many NotImplementedExeptions there are in my .NET code so hopefully we can remove them all before releasing. My first thought is that FxCop might be a good tool to do this. Does anyone have a custom FxCop rule for this? How would I go about creating one myself?</p>
[ { "answer_id": 415875, "author": "Rowland Shaw", "author_id": 50447, "author_profile": "https://Stackoverflow.com/users/50447", "pm_score": 0, "selected": false, "text": "NotImplementedExeption IBindingList" }, { "answer_id": 417053, "author": "Rinat Abdullin", "author_id...
2009/01/06
[ "https://Stackoverflow.com/questions/415730", "https://Stackoverflow.com", "https://Stackoverflow.com/users/571/" ]
415,753
<p>I want to cache the instances of a certain class. The class keeps a dictionary of all its instances and when somebody requests a new instance, the class tries to satisfy the request from the cache first. There is a small problem with memory management though: The dictionary cache retains the inserted objects, so that they never get deallocated. I do want them to get deallocated, so that I had to overload the <code>release</code> method and when the retain count drops to one, I can remove the instance from cache and let it get deallocated.</p> <p>This works, but I am not comfortable mucking around the <code>release</code> method and find the solution overly complicated. I thought I could use some hashing class that does not retain the objects it stores. Is there such? The idea is that when the last user of a certain instance releases it, the instance would automatically disappear from the cache.</p> <p><a href="http://developer.apple.com/documentation/Cocoa/Reference/NSHashTable_class/Introduction/Introduction.html" rel="nofollow noreferrer">NSHashTable</a> seems to be what I am looking for, but the documentation talks about “supporting weak relationships in a garbage-collected environment.” Does it also work without garbage collection?</p> <hr> <p><em>Clarification:</em> I cannot afford to keep the instances in memory unless somebody really needs them, that is why I want to purge the instance from the cache when the last “real” user releases it.</p> <hr> <p><em>Better solution:</em> This was on the iPhone, I wanted to cache some textures and on the other hand I wanted to free them from memory as soon as the last real holder released them. The easier way to code this is through another class (let’s call it <code>TextureManager</code>). This class manages the texture instances and caches them, so that subsequent calls for texture with the same name are served from the cache. There is no need to purge the cache immediately as the last user releases the texture. We can simply keep the texture cached in memory and when the device gets short on memory, we receive the low memory warning and can purge the cache. This is a better solution, because the caching stuff does not pollute the <code>Texture</code> class, we do not have to mess with <code>release</code> and there is even a higher chance for cache hits. The <code>TextureManager</code> can be abstracted into a <code>ResourceManager</code>, so that it can cache other data, not only textures.</p>
[ { "answer_id": 416759, "author": "Marc Charbonneau", "author_id": 35136, "author_profile": "https://Stackoverflow.com/users/35136", "pm_score": 0, "selected": false, "text": "valueWithNonretainedObject:" } ]
2009/01/06
[ "https://Stackoverflow.com/questions/415753", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17279/" ]
415,764
<p>If you use <a href="http://maven.apache.org/" rel="nofollow noreferrer">Maven2</a> as a build system for a project containing many artefacts with the same version number, you have the version of the resulting build scattered in all pom.xml. In many of them even twice - in the version tag of the artefact itself and in the version tag of the parent. Thus, you have to change and check in new versions of all pom.xml on every version switch. This is somewhat annoying, especially if you have to code for several bug fixing and a development version in parallel. Is there a way around that?</p> <p>CLARIFICATION: My question is about the many versions of every single pom.xml that you get over time in your source control system that differ only by the version number of the pom and / or the version number of the parent pom. Ideally, you should only need to change the pom whenever you add a dependency or something.</p> <p>For example you have a project with the artifacts foo-pom (the parent pom to all), foobar-jar, foobaz-jar and foo-war. In the first release the version is 1.0 - which appears in every pom.xml. In the second release the version is 1.1 - which again appears in every pom.xml. So you have to change every pom.xml - this is annoying if you release as often as you should.</p> <p>UPDATE: If you think this is important: not having to specify the parent version is already being considered. Please go to the <a href="http://jira.codehaus.org/browse/MNG-624" rel="nofollow noreferrer">maven JIRA issue</a> and vote for it to get it more noticed and more likely to be added as an enhancement in an upcoming release. You need to create/have a JIRA login for that.</p> <p>There is <a href="https://stackoverflow.com/questions/545131/maven2-inheritence/549853#549853">another Stackoverflow Question</a> that is basically about the same problem. </p>
[ { "answer_id": 415782, "author": "Romain Linsolas", "author_id": 26457, "author_profile": "https://Stackoverflow.com/users/26457", "pm_score": 3, "selected": false, "text": "<properties>\n <project-version>1.0.0</project-version>\n <!-- Same version than the parent for the module '...
2009/01/06
[ "https://Stackoverflow.com/questions/415764", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21499/" ]
415,766
<p>I called this function once per frame and it took my FPS from >400 to 33. Why?</p> <pre><code>sw blt(const PtRect *dstRect, Texture *src, const PtRect *srcRect, RenderDevice::bltFlags flags=RenderDevice::bltDefault) { assert(src); GL_Texture *glsrc = dynamic_cast&lt;GL_Texture*&gt;(src); if (glsrc == 0) return -1; PtRect srcRect2(0, 0, src-&gt;width, src-&gt;height); if (srcRect == 0) srcRect = &amp;srcRect2; PtRect dstRect2(0, 0, srcRect-&gt;makeWidth(), srcRect-&gt;makeHeight()); if (dstRect == 0) dstRect = &amp;dstRect2; glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, *glsrc-&gt;getTex()); glBegin( GL_QUADS ); glNormal3f( 0.0f, 0.0f, 1.0f ); for (size_t i=0; i&lt;350; i++) { glTexCoord2f( srcRect-&gt;left /src-&gt;width, srcRect-&gt;top/src-&gt;height); glVertex2f(dstRect-&gt;left, dstRect-&gt;top); glTexCoord2f( srcRect-&gt;right/src-&gt;width, srcRect-&gt;top/src-&gt;height); glVertex2f(dstRect-&gt;right, dstRect-&gt;top); glTexCoord2f( srcRect-&gt;right/src-&gt;width, srcRect-&gt;bottom/src-&gt;height); glVertex2f(dstRect-&gt;right, dstRect-&gt;bottom); glTexCoord2f( srcRect-&gt;left /src-&gt;width, srcRect-&gt;bottom/src-&gt;height); glVertex2f(dstRect-&gt;left, dstRect-&gt;bottom); } glEnd(); return 0; } </code></pre>
[ { "answer_id": 415819, "author": "Paulo Lopes", "author_id": 51560, "author_profile": "https://Stackoverflow.com/users/51560", "pm_score": 2, "selected": true, "text": "// Generate texture object ID\nglGenTextures(1, img);\nglBindTexture(GL_TEXTURE_2D, img);\n\n// Set Texture mapping par...
2009/01/06
[ "https://Stackoverflow.com/questions/415766", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
415,801
<p>This error message is being presented, any suggestions?</p> <blockquote> <p>Allowed memory size of 33554432 bytes exhausted (tried to allocate 43148176 bytes) in php</p> </blockquote>
[ { "answer_id": 415818, "author": "Rik Heywood", "author_id": 4012, "author_profile": "https://Stackoverflow.com/users/4012", "pm_score": 6, "selected": false, "text": "$OldVar = null;" }, { "answer_id": 418426, "author": "staticsan", "author_id": 28832, "author_profil...
2009/01/06
[ "https://Stackoverflow.com/questions/415801", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51950/" ]
415,804
<p>I want to provide feed in my merb application. After reading wikipedia, <a href="https://stackoverflow.com/questions/347504/providing-rss-and-atom-feeds-do-we-need-both-or-has-rss-won">RSSvsAtom</a> and seeing that StackOverflow uses it, I think I will use Atom. What library should I use? I have found <a href="http://ratom.rubyforge.org/" rel="nofollow noreferrer">rAtom</a> that looks quite good. Are there better alternatives? Or does merb has anything built in to help me? </p> <p><strong>UPDATE:</strong> maybe I should just do the news in plain html and use FeedBurner?</p>
[ { "answer_id": 415818, "author": "Rik Heywood", "author_id": 4012, "author_profile": "https://Stackoverflow.com/users/4012", "pm_score": 6, "selected": false, "text": "$OldVar = null;" }, { "answer_id": 418426, "author": "staticsan", "author_id": 28832, "author_profil...
2009/01/06
[ "https://Stackoverflow.com/questions/415804", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37086/" ]