instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>Is there any way to get a String[] with the roles a user has in the JSP or Servlet?</p> <p>I know about request.isUserInRole("role1") but I also want to know all the roles of the user.</p> <p>I searched the servlet source and it seems this is not possible, but this seems odd to me.</p> <p>So... any ideas?</p>
<p>The answer is messy.</p> <p>First you need to find out what type request.getUserPrincipal() returns in your webapp.</p> <pre><code> System.out.println("type = " + request.getUserPrincipal().getClass()); </code></pre> <p>Let's say that returns org.apache.catalina.realm.GenericPrincipal.</p> <p>Then cast the re...
<pre><code>import org.springframework.security.core.context.SecurityContextHolder; @GetMapping(&quot;/&quot;) public String someEndpoint() { System.out.println(SecurityContextHolder.getContext().getAuthentication().getAuthorities()); } </code></pre>
44,762
<p>I am making numerous, minute changes to .php files in Eclipse PDT then committing them and testing on the server.</p> <p>The repetitive six-step commit process is getting tedious:</p> <pre><code>right-click team Commit... click "choose previously selected comment" select in list click OK </code></pre> <p>Does any...
<p>The best I've been able to do is create a key binding for 'Commit' (under Preferences... General->Keys). Then you just need to click on the project and hit a key combination, which saves the whole right-click->Team->Commit... process.</p> <p>If you just want to check in the file you are editing, you don't have to ...
<p>In some versions of Eclipse (or maybe some versions of Subclipse -- are you using SVN?) there was a toolbar button that you could click. It would eliminate the first 2 or 3 steps of your commit process. Maybe you can find that button on the toolbar editor (or perspective editor, or whatever they call it... it's be...
22,128
<p>I've got this small question - given a bitmask of weekdays (e.g., <code>Sunday = 0x01, Monday = 0x02, Tuesday = 0x04</code>, etc...) and today's day (in a form of <code>Sunday = 1, Monday = 2, Tuesday = 3</code>, etc...) - what's the most elegant way to find out the next day from today, that's set in the bitmask? By...
<pre><code>int getNextDay(int days_mask, int today) { if (!days_mask) return -1; // no days set days_mask |= days_mask &lt;&lt; 7; // duplicate days into next week mask = 1 &lt;&lt; (today % 7); // keep track of the day while (!(mask &amp; days_mask)) { mask &lt;&lt;= 1; ++today; } return ...
<p>I understand your question this way:</p> <pre><code>// returns t (today) if no weekday is set in the mask. int getNextDay(int m, int t) { int i, idx; for(i = 0, idx=t%7; i&lt;7 &amp;&amp; !((1&lt;&lt;idx)&amp;m); i++, idx=(idx+1)%7) /* body empty */ ; return (i == 7) ? t : (idx + 1); } // getNe...
45,741
<p>Plastic is used in 3D FDM/FFF printing partly because it had a wide temperature range for its glass state - where it can be flowed with some force, but won't flow due only to gravity.</p> <p>Most metals have a very narrow, or non-existant, glass state. They transition from solid to liquid with almost no flowable-b...
<p>A few things are required for effective extrusion-style 3d printing materials:</p> <ul> <li>It must stay where placed by the nozzle long enough to harden (or, alternately for pastes and such, have a shear-thinning or thixotropic viscous profile so it will not flow under its own weight). </li> <li>If using a filamen...
<p>I spent some time looking at making an FDM machine that would print bronze filament. An alloy commonly made into wire had a difference between the solidus and liquidus temperature of only 50 degrees C. I determined that one could make a conventional hot end, electrically heated, made of either molybdenum or tungst...
85
<p>If I've got a variable that contains the fully-qualified name of a file (for example, a project file), should it be called <code>projectFile</code>, <code>projectFileName</code> or <code>projectPath</code>? Or something else?</p>
<p>I usually go with these:</p> <ul> <li><code>FileName</code> for the file name only (without path)</li> <li><code>FilePath</code> for the parent path only (without the file name)</li> <li><code>FileFullName</code> for the fully qualified name with path</li> </ul> <p>I don't think there is such a thing as an accepte...
<p>All of this depends partly on the <b>size</b> of the method and if the variables are class variables.</p> <p>If they are class variables or in a large complicated method, then follow Kent Fredric's advice and name them something that indicates <b>what</b> the file is used for, i.e. "projectFileName".</p> <p>If thi...
42,604
<p>I need to implement red eye reduction for an application I am working on.</p> <p>Googling mostly provides links to commercial end-user products.</p> <p>Do you know a good red eye reduction algorithm, which could be used in a GPL application?</p>
<p>I'm way late to the party here, but for future searchers I've used the following algorithm for a personal app I wrote.</p> <p>First of all, the region to reduce is selected by the user and passed to the red eye reducing method as a center Point and radius. The method loops through each pixel within the radius and ...
<p>Read this blog, there is a nice explanation regarding detection and correction of red-eye. <a href="http://pytech-solution.blogspot.in" rel="nofollow noreferrer">Red eye correction with OpenCV and python</a></p>
16,177
<p>I've seen well-textured balls, planets, and other spherical objects in couple of games, last time in UFO: aftermath. If you just splatter a texture into latitude/longditude as u and w -coordinates you'll get lots of ugly texture distortion to poles.</p> <p>I can think myself an one way to implement a spherical map ...
<p>The <a href="http://en.wikipedia.org/wiki/Hairy_ball_theorem" rel="nofollow noreferrer">hairy ball theorem</a> states that it is impossible to define continuous texture coordinates on a sphere without any poles that distort the texture.</p>
<p>Do not split sphere by longitude and latitude. Instead use what is called the GeoSphere in 3Ds Max. (Actually, a polyhedron, <a href="http://en.wikipedia.org/wiki/Geodesic_dome#Chord_factors" rel="nofollow noreferrer">the geodesic sphere</a>.)</p>
26,190
<p>In your own application that is.</p> <p>[edit]</p> <p><strong>Alright, so I agree completely -- more than you know -- without equivocation that graphical emoticons are an abomination. But! That doesn't help me when the project owners tell me that we must support graphical emoticons.</strong></p> <p>[/edit]</p> <...
<p>Is it an acceptable answer to suggest you should consider not converting emoticons? The entire point of textual emoticons is that they're recognizable...in text form.</p> <p><em>[edit]</em> Please don't let this opinion/suggestion dissuade anyone from helping answer this question. Sometimes you can't fight the clie...
<p>Here's an idea: don't convert them in any way, but rotate by 90 degrees.</p> <p>For example, you can render the image of the emoticon and then rotate that image 90 degrees clockwise and display it.</p>
20,412
<p>How do you get the caret position in a <code>&lt;textarea&gt;</code> using JavaScript?</p> <p>For example: <code>This is| a text</code></p> <p>This should return <code>7</code>.</p> <p>How would you get it to return the strings surrounding the cursor / selection?</p> <p>E.g.: <code>'This is', '', ' a text'</code...
<p>With Firefox, Safari (and other Gecko based browsers) you can easily use textarea.selectionStart, but for IE that doesn't work, so you will have to do something like this:</p> <pre><code>function getCaret(node) { if (node.selectionStart) { return node.selectionStart; } else if (!document.selection) { re...
<p>I modified the above function to account for carriage returns in IE. It's untested but I did something similar with it in my code so it should be workable.</p> <pre><code>function getCaret(el) { if (el.selectionStart) { return el.selectionStart; } else if (document.selection) { el.focus(); var ...
33,025
<p>I'm trying to upload documents to SharePoint using web services attaching custom metadata to the files. I've searched but have not found a good tutorial covering all these topics. Can anybody point me in the right direction?</p> <p>Here's why I think I need to use web services: I'm developing on XP and the Sharep...
<p>Here is some code <a href="http://geek.hubkey.com/2007/10/upload-file-to-sharepoint-document.html" rel="nofollow noreferrer">http://geek.hubkey.com/2007/10/upload-file-to-sharepoint-document.html</a></p> <p>As for why it is that is the way because Microsoft wrote it that way :). Some people have written custom web...
<p>Here is some stuff on the Sharepoint Designer - <a href="http://office.microsoft.com/en-us/sharepointdesigner/FX100487631033.aspx" rel="nofollow noreferrer">http://office.microsoft.com/en-us/sharepointdesigner/FX100487631033.aspx</a> Hope that helps a little.</p> <p>You can link to the Sharepoint 2007 training from...
30,691
<p>I came across the case where depending on the execution path I may need to invoke an inclusion of .js file from controller. Is there a nice way of doing it? (besides setting some view variable with actual .js include code)?</p>
<p>See the view helper headScript(). I'm just writing this off the top of my head but I think it works like this:</p> <p>From within a view file: <code>$this-&gt;headScript()-&gt;appendFile('filename.js');</code></p> <p>From within a controller: <code>$this-&gt;view-&gt;headScript()-&gt;appendFile('filename.js');</co...
<p>Sure, you could do like @Bill Karwin described.</p> <p>But if you would like to do it really nicely, you need template inheritance - like it is implemented in Django framework for Python for instance. There are some extensions for Zend Framework as well, take a look at <a href="http://www.beberlei.de/calypso/" rel=...
37,470
<p>What do I gain by adding a timestamp column called recordversion to a table in ms-sql?</p>
<p>You can use that column to make sure your users don't overwrite data from another user.</p> <p>Lets say user A pulls up record 1 and at the same time user B pulls up record 1. User A edits the record and saves it. 5 minutes later, User B edits the record - but doesn't know about user A's changes. When he saves h...
<p>Nothing that I'm aware of, or that Google seems to find quickly.</p> <p>You con't get anything inherent by using that name for a column. Sure, you can create a column and do the record versioning as described in the next response, but there's nothing special about the column name. You could call the column anythi...
39,527
<p>I need to retrieve a record from a database, display it on a web page (I'm using ASP.NET) but store the ID (primary key) from that record somewhere so I can go back to the database later with that ID (perhaps to do an update).</p> <p>I know there are probably a few ways to do this, such as storing the ID in ViewSta...
<p>It depends.</p> <p>Do you care if anyone sees the record id? If you do then both hidden fields and viewstate are not suitable; you need to store it in session state, or encrypt viewstate.</p> <p>Do you care if someone submits the form with a bogus id? If you do then you can't use a hidden field (and you need to lo...
<pre><code>Session["MyId"]=myval; </code></pre> <p>It would be a little safer and essentially offers the same mechanics as putting it in the viewstate</p>
12,858
<p>A good while ago, I read <a href="http://www.viemu.com/a-why-vi-vim.html" rel="noreferrer">an article by the creator of viemu</a>, clearing up a lot of the misconceptions about vi, as well as explaining why it's a good idea (and why it's been very popular for the last 30 years+). The same guy also has <a href="http:...
<p>First of all, you may want to pick up Vim; it has a vastly superior feature set along with everything vi has.</p> <p>That said, it takes discipline to learn. If you have a job and can't afford the productivity hit (without getting fired), I'd suggest taking on a weekend project for the sole purpose of learning the ...
<p>delete notepad.exe and create a shortcut to vim called notepad instead :)</p> <p>or do all your coding via ssh or on a machine that has no GUI ;)</p>
10,028
<p>If you have $100 in your hand right now. And have to bet on one of these options. That would you bet it on? The question is:</p> <p>What is the most important factor, that determents the cost of a project. </p> <ol> <li>Typing speed of the programmers.</li> <li>The total amount of characters typed while programmin...
<p>From McConnell:</p> <p><a href="http://www.codinghorror.com/blog/archives/000637.html" rel="noreferrer">http://www.codinghorror.com/blog/archives/000637.html</a></p> <blockquote> <p>[For a software project], size is easily the most significant determinant of effort, cost, and schedule. The kind of software you'r...
<p>I thing the largest amount on large projects are testing and fixing the bugs and fixing misinterpretation of the requirements. First you need write tests. Than you fix the code that the tests run. Than you make the manual tests. Then you must write more tests. On a large project the testing and fixing can consume...
13,399
<p>I've got a <code>DataGridViewCobmoboxColumn</code> that has to be on the far right side of the screen. The items in the cell are wider that the cell width, so the dropdown list is also wider than the cell, so the user can see what top select. When the list drops down, the right side of the dropdown is not visible, a...
<p>If I understand correctly, you need to auto-size the width so that things show up? <a href="http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/a3cab53b-8c03-4f43-83ac-808dc3751db9/" rel="nofollow noreferrer">I found a post on how to do that on MSDN.</a></p>
<p>I understand the question is old, but:</p> <p>The best solution would be using something like <code>ToolStripDropDownDirection.AboveLeft</code> <em>But as far as I see from source code there is nothing like this.</em></p> <p>So another approach could be setting values of DropDownWidth/MaxDropDownItems depending of...
26,162
<p>This may seem like a daft question, but i was wondering about how to use MVC frameworks on hosted servers.</p> <p>I am playing about (albeit slowly) at home with the RoR on Ubuntu and understand that if i want to do a live site then i need hosting with Rails and Ruby.</p> <p>However, what happens about the PHP fra...
<p>Not every framework needs things installed or configured via the command line or even the php.ini file. I believe CodeIgnitor is like this - you can just put the path to the base CI directory in the path and off you go. I'm sure there's documentation about how to use symfony on a hosting solution. In fact, <a href="...
<p>MVC framworks should be hosting independant. But of course they are coded in a programming language so the hosting is important. Apart from that is a matter of permissions. Do you need to modify config files? do you need to access to certain directories? connect to a database? Sure, like any program. But the framew...
14,788
<p>This question is related to (but perhaps not quite the same as):</p> <p><a href="https://stackoverflow.com/questions/61451/does-django-have-html-helpers">Does Django have HTML helpers?</a></p> <p>My problem is this: In Django, I am constantly reproducing the basic formatting for low-level database objects. Here's ...
<p>Sounds like an <a href="http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#inclusion-tags" rel="noreferrer">inclusion tag</a> is what you're looking for. You could have a template and tag for each major variation and use the tag's arguments to customise the context for each template as required.</p> <...
<p>I think template filter will be useful too. You can pass filter on each object, for example:</p> <pre><code>{{ value|linebreaks }} # standard django filter </code></pre> <p>Will produce:</p> <pre><code>If value is Joel\nis a slug, the output will be &lt;p&gt;Joel&lt;br&gt;is a slug&lt;/p&gt;. </code></pre> <p>Se...
17,670
<p>Is there a way to have different application settings per each build configuration?</p> <p>I would like to be able to batch build a few configurations with different settings, instead of having to change the settings and build, rinse repeat.</p> <p>Thanks in advance!</p>
<p>I don't know much about the appsettings architecture (I've never really used it), but you can define different values for constants using a bit of MSBuild magic.</p> <p>Create two .cs files, Constants1.cs and Constants2.cs (or name them after your configurations).</p> <p>In each file, define a class called Constan...
<p>You could add a prebuild or postbuild task to the proj, you have access to the ConfigurationName from there. Would be fairly easy to do something like "copy Web.config.debug Web.config"</p>
43,919
<p>I have a solution with several projects in Visual 2008, let's say SuggestionProcessor (a class library) and Suggestions (a website) with a webhandler GetSuggestions.ashx. I changed a method in SuggestionProcessor which is used in the webhandler. The call in the webhandler has been adjusted to the changed method.</p>...
<p>I solved this one by reverting to a previous state when it still worked. </p> <p>Thanks for the suggestions, I'm sorry they didn't work in my situation. </p> <p>Shall I delete this question now that it doesn't really have a clear use for someone else?</p>
<p>I would check your web.config file, there may be references there that are causing the error since they are missing.</p>
10,763
<p>What's the easiest way to get the UTC offset in PHP, relative to the current (system) timezone?</p>
<pre><code> date('Z'); </code></pre> <p>returns the UTC offset in seconds.</p>
<p><code>date("Z")</code> will return the UTC offset relative to the server timezone not the user's machine timezone. To get the user's machine timezone you could use the javascript <code>getTimezoneOffset()</code> function which returns the time difference between UTC time and local time, in minutes.</p> <pre><code>&...
23,519
<p>With the advent of new features like lambda expressions (inline code), does it mean we dont have to use delegates or anonymous methods anymore? In almost all the samples I have seen, it is for rewriting using the new syntax.</p> <p>Any place where we still have to use delegates and lambda expressions won't work?</p...
<p>Yes there are places where directly using anonymous delegates and lambda expressions won't work.</p> <p>If a method takes an untyped Delegate then the compiler doesn't know what to resolve the anonymous delegate/lambda expression to and you will get a compiler error.</p> <pre><code>public static void Invoke(Delega...
<p>Lambda expressions are just "syntactic sugar", the compiler will generate appropriate delegates for you. You can investigate this by using Lutz Roeder's Reflector.</p>
13,179
<p>Using the same <strong>sort</strong> command with the same input produces different results on different machines. How do I fix that?</p>
<p>The <a href="http://developer.apple.com/documentation/Darwin/Reference/ManPages/man1/sort.1.html" rel="nofollow noreferrer">man-page</a> on OS X says:</p> <blockquote> <p>******* WARNING ******* The locale specified by the environment affects sort order. Set LC_ALL=C to get the traditional sort order that uses nat...
<p>This is probably due to different settings of the <a href="http://publib.boulder.ibm.com/infocenter/systems/index.jsp?topic=/com.ibm.aix.nls/doc/nlsgdrf/locale_env.htm" rel="nofollow noreferrer">locale environment variables</a>. <code>sort</code> will use these settings to determine how to compare strings. By settin...
4,853
<p>ffdshow has this <a href="http://ffdshow-tryout.svn.sourceforge.net/viewvc/ffdshow-tryout/trunk/src/ffdshowRemoteAPI.cpp?view=markup" rel="noreferrer">awesome little API</a> for controlling playback of video files. It allows you to change subtitles, fast forward, get the name of the file playing, etc...</p> <p>Its i...
<p>A plugin in class has been created and is available here: <a href="http://damienbt.free.fr/Information.htm" rel="nofollow noreferrer">http://damienbt.free.fr/Information.htm</a></p>
<p>A plugin in class has been created and is available here: <a href="http://damienbt.free.fr/Information.htm" rel="nofollow noreferrer">http://damienbt.free.fr/Information.htm</a></p>
30,418
<p>What tools are people using for testing SQL Server databases?</p> <p>By this I mean all parts of the database:</p> <ul> <li>configuration</li> <li>tables</li> <li>column type</li> <li>stored procedures</li> <li>constraints</li> </ul> <p>Most likely, there is not one tool to do it all.</p>
<p>How do you mean "Test the database"? </p> <p>If you are testing foreign keys, a simply script to insert invalid data is all you should need.</p> <p>Testing a database could imply a great number of issues. Does it have all the tables? Are the tables correct? Are the indexes in place? Did the latest updates get...
<p>I personally use NHibernate with SqlCe, this provides a "throw-away" database that doesn't need any specialized tear down after the tests are run.</p> <p>It also provides a good way to test your nhibernate mappings if applicable.</p> <p>Here is a link to an article I wrote awhile ago on how to accomplish this: <a ...
4,758
<p>How do I do a diff of two strings or arrays in Ruby?</p>
<p>diff.rb is what you want, which is available at <del><a href="http://users.cybercity.dk/~dsl8950/ruby/diff.html" rel="nofollow noreferrer">http://users.cybercity.dk/~dsl8950/ruby/diff.html</a></del> via internet archive: </p> <p><a href="http://web.archive.org/web/20140421214841/http://users.cybercity.dk:80/~dsl895...
<p>Maybe Array.diff via monkey-patch helps...</p> <p><a href="http://grosser.it/2011/07/07/ruby-array-diffother-difference-between-2-arrays/" rel="nofollow">http://grosser.it/2011/07/07/ruby-array-diffother-difference-between-2-arrays/</a></p>
10,552
<p>I am writing a batch script which I wish to open a file and then change the second line of it. I want to find the string "cat" and replace it with a value that I have SET i.e. %var% . I only want this to happen on the second line (or for the first 3 times). How would you go about doing this?</p>
<p>I just solve it myself. It will lookup var on line two only.</p> <pre><code>@echo OFF SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION SET filename=%1 set LINENO=0 for /F "delims=" %%l in (%filename%) do ( SET /A LINENO=!LINENO!+1 IF "!LINENO!"=="2" ( call echo %%l ) ELSE ( echo %%l ) ) </code></pre> <p>But ...
<p>I would create a script that would:</p> <ol> <li>scan the input file </li> <li>write to a second output file</li> <li>delete the input</li> <li>rename the output</li> </ol> <p>As far as the dos commands to parse, I did a <a href="http://www.google.com/search?hl=en&amp;q=file+parse+batch+ms+dos" rel="nofollow noref...
44,728
<p>I have many sites that use the same root category of the Main Site. Each product that is added is added to the site it was added to (wow.) and also the Main Site. However, I would like categories on a per site basis to only appear if there are products on that site.</p> <p>If I have:</p> <pre><code>Category1 Categ...
<p>Well, what you can do is, create your own helper with a collection (through a model), and then filter the collection based on product count.</p> <p>Only a rough draft, but I've posted some code in another magento related question: <a href="https://stackoverflow.com/questions/272818/magento-products-by-categories">M...
<p>this is a simple solution to hide categories that might help you .</p> <p>The original contents of the top.phtml file should look like below.</p> <pre><code>&lt;?php $_menu = $this-&gt;renderCategoriesMenuHtml(0,'level-top') ?&gt; &lt;?php if($_menu): ?&gt; &lt;div&gt; &lt;ul id="nav"&gt; &lt;?php echo...
48,811
<p>I wonder what is the time complexity of pop method of list objects in Python (in CPython particulary). Also does the value of N for list.pop(N) affects the complexity? </p>
<p><code>Pop()</code> for the last element ought to be O(1) since you only need to return the element referred to by the last element in the array and update the index of the last element. I would expect <code>pop()</code> for an arbitrary element to be O(N) and require on average N/2 operations since you would need t...
<p>The short answer is look here: <a href="https://wiki.python.org/moin/TimeComplexity" rel="nofollow noreferrer">https://wiki.python.org/moin/TimeComplexity</a></p> <p>With no arguments to pop its O(1)</p> <p>With an argument to pop:</p> <ul> <li>Average time Complexity O(k) (k represents the number passed in as an...
23,766
<p>I was planning to use url routing for a Web Forms application. But, after reading some <a href="http://learn.iis.net/page.aspx/496/iis-url-rewriting-and-aspnet-routing/" rel="noreferrer">posts</a>, I am not sure if it is an easy approach.</p> <p>Is it better to use the <a href="http://learn.iis.net/page.aspx/460/us...
<p>There's a <a href="http://ruslany.net/2008/09/aspnet-routing-request-filtering-url-rewriting/" rel="noreferrer">great post here</a> about the differences between the two from a member of the IIS team.</p> <p>One caveat I would advise is that for WebForms, you need to be careful when using Routing. I've written a sa...
<p>The Dynamic Data project that is available with .Net 3.5 SP1 shows a good example of a url routing implementation.</p>
11,552
<p>How can I differentiate a Workflow system from a normal application that automates some work? Are there any specific feature a system must have to be categorized as a workflow system?</p>
<p>Workflow systems manage objects (often logically or actual electronic replacements for documents) that have an associated state. The state of an object in the system is node in a <a href="http://en.wikipedia.org/wiki/State_diagram" rel="noreferrer">state machine</a> (or a <a href="http://en.wikipedia.org/wiki/Petri_...
<p>I don't thing there is a precise definition. Here are some loose criteria:</p> <ul> <li>coordinates the work of more then one person (but not groupware),</li> <li>in a complex, organizational setting,</li> <li>usually as part of a managed business process (as in BPM).</li> </ul>
40,437
<p>I need to bind labels or items in a toolstrip to variables in Design Mode. I don't use the buit-in resources not the settings, so the section Data is not useful. I am taking the values out from an XML that I map to a class.</p> <p>I know there are many programs like: <a href="http://www.jollans.com/tiki/tiki-inde...
<p>Aleksandar's response is one way to accomplish this, but in the long run it's going to be very time consuming and won't really provide much benefit. The bigger question that should be asked is why do you not want to use the tools and features built-in to .NET and Visual Studio or at least use a commercial third-part...
<p>Try with inheriting basic win controls and override OnPaint method. Example bellow is a button that has his text set on paint depending on value contained in his Tag property (let suppose that you will use Tag property to set the key that will be used to read matching resource). Then you can find some way to read al...
36,476
<p><strong>General Description:</strong></p> <p>To start with what works, I have a <code>UITableView</code> which has been placed onto an Xcode-generated view using Interface Builder. The view's File Owner is set to an Xcode-generated subclass of <code>UIViewController</code>. To this subclass I have added working i...
<p>I followed your steps, recreated the project and ran into the same problem. Basically you are almost there. There are 2 things missing (once fixed it works):</p> <ul> <li><p>You need to connect the <code>tableView</code> of the <code>TableTestTableViewController</code> to the <code>UITableView</code> you have on th...
<p>Yes for some reason (please chime in if anybody knows why...) <code>tableView</code> property of the <code>UITableViewController</code> is not exposed as an <code>IBOutlet</code> even though it is a public property. So when you use Interface Builder, you can't see that property to connect to your other <code>UITable...
31,730
<p>For one of the projects I'm doing right now, I need to look at the performance (amongst other things) of different <a href="http://en.wikipedia.org/wiki/Concurrent_computing" rel="nofollow noreferrer">concurrent enabled</a> programming languages.</p> <p>At the moment I'm looking into comparing <a href="http://www.s...
<p>Surely you should be testing hardware and compilers rather than a language for concurrency performance?</p> <p>I would be looking at a language from the point of view of how easy and productive it is in terms of concurrency and how much it 'insulates' the programmer from making locking mistakes.</p> <p>EDIT: from ...
<p>Since the benchmarks game moved to a quad-core machine September 2008, many programs in different programming languages have been re-written to exploit quad-core - <a href="https://benchmarksgame-team.pages.debian.net/benchmarksgame/performance/mandelbrot.html" rel="nofollow noreferrer">for example, the first 10 man...
42,421
<p>While using Vim (at home and at work), I often find myself doing similar things repeatedly. For example, I may turn a bunch of CSV text into a series of SQL inserts. I've been using Vim for years, but only recently have I tried to seriously think about how I could improve my productivity while using it.</p> <p>My q...
<p>You can store your common task macros in .vim files, like <a href="http://www.vanhemert.co.uk/vim/vimacros/html2.vim" rel="noreferrer">this</a> for example, and then you can load them with the command <em>:so file.vim</em></p> <p><a href="http://www.vanhemert.co.uk/vim/" rel="noreferrer">Here</a> you can find a bun...
<p>Personally, and maybe in part because I was using Unix long before vim existed (heck, the first version of Unix I used didn't have "vi" either - but that's another story), I would normally use a 'shell script' (or, more likely, a Perl script) to do the transform. For converting CSV data to INSERT, dealing with quot...
31,899
<p>I have an excel sheet full of times.</p> <p>They are formatted so that they look like: 1:00:15</p> <p>However if I change the format on the cells to text, they change to the underlying numeric representation of the time: 0.041840278</p> <p>How can I convert the cells to be text cells but still have the time in th...
<p>copy the column paste it into notepad copy it again paste special as Text</p>
<p>Copy to a Date variable then transform it into Text with <code>format()</code>. Example:</p> <pre><code>Function GetMyTimeField() Dim myTime As Date, myStrTime As String myTime = [A1] myStrTime = Format(myTime, "hh:mm") Debug.Print myStrTime &amp; " Nice!" End Function </code></pre>
27,176
<p>I'm learning DI, and made my first project recently.</p> <p>In this project I've implement the repository pattern. I have the interfaces and the concrete implementations. I wonder if is possible to build the implementation of my interfaces as "plugins", dlls that my program will load dynamically.</p> <p>So the pro...
<p>While <a href="https://stackoverflow.com/a/1733373">Sean Chambers' solution</a> works in the case that you control the plugins, it does not work in the case where plugins might be developed by third parties and you don't want them to have to be dependent on writing ninject modules.</p> <p>This is pretty easy to do ...
<p>The problem is that you might need to recompile if the object you setup in the load of your module are used inside the program. The reason is that you program might not have the latest version of the assembly of your class. Example, if you create a new concrete class for one of your interface, let say you change the...
42,862
<p>I've got a method JSNI that calls a Java method that take a Hasmap as input. I've tried </p> <pre><code>handler.@com.mypackage::myMethod(Ljava/util/Hashmap;)(myHashMap); handler.@com.mypackage::myMethod(Ljava/util/Hashmap&lt;Ljava/lang/String,Ljava/lang/String&gt;;)(myHashMap); </code></pre> <p>I'm can't seem to ...
<p>Can you post the error that your getting, and also what kind of javascript object your trying to pass as a hashmap. I'm assuming you're getting a compile time error?</p> <p>Here is a good start for JSNI documentation:</p> <p><a href="http://code.google.com/docreader/#p=google-web-toolkit-doc-1-5&amp;s=google-web-t...
<p>Ok, after looking at it...</p> <p>I was unable to find any documentation or arrangement that gives the multidimensional array of strings. Managed to get this done using the HashMap, using:</p> <pre><code>handler.@com.mypackage::myMethod(Ljava/util/Hashmap;)(myHashMap); </code></pre> <p>worked if I define the inpu...
40,192
<p>It's really annoying that visual studio hides typos in aspx pages (not the code behind). If the compiler would compile them, I would get a compile error.</p>
<p>Compile the pages at compile time. See Mike Hadlow's post here:</p> <p><a href="http://mikehadlow.blogspot.com/2008/05/compiling-aspx-templates-using.html" rel="noreferrer">http://mikehadlow.blogspot.com/2008/05/compiling-aspx-templates-using.html</a></p>
<p>There is the possibility to precompile the whole web: usually the pages only get compiled, if they are used.</p> <p>To precompile the web, please refer to <a href="http://msdn.microsoft.com/en-us/library/ms227972.aspx" rel="nofollow noreferrer">MSDN</a></p>
13,378
<p>I'm looking at adding scripting functionality to an existing codebase and am weighing up the pros/cons of various packages. Lua is probably the most obvious choice, but I was wondering if people have any other suggestions based on their experience.</p> <p>Scripts will be triggered upon certain events and may stay r...
<p>Based on my own experience:</p> <ul> <li>Python. IMHO this is a good choice. We have a pretty big code base with a lot of users and they like it a lot.</li> <li>Ruby. There are some really nice apps such as Google Sketchup that use this. I wrote a Sketchup plugin and thought it was pretty nice.</li> <li>Tcl. T...
<p>There were some excellent suggestions already, but I just wanted to mention that Perl can also be called / can call to C/C++.</p>
3,616
<p>The following code executes a simple insert command. If it is called 2,000 times consecutively (to insert 2,000 rows) an OleDbException with message = "System Resources Exceeded" is thrown. Is there something else I should be doing to free up resources?</p> <pre><code>using (OleDbConnection conn = new OleDbConnec...
<p>The system resources exceeded error is not coming from the managed code, its coming from you killing your database (JET?)</p> <p>You are opening way too many connections, way too fast...</p> <p>Some tips:</p> <ul> <li>Avoid round trips by not opening a new connection for every single command, and perform the inserts...
<p>This could be occurring because you are not disposing the Connection and Command object created. Always Dispose the object at the end.</p> <pre><code>OledbCommand.Dispose(); </code></pre>
18,869
<p>I have a WPF app that makes use of a Winforms User Control that I have created using C++/CLI. When my app goes to parse the XAML for my main window, it throws an exception. The information appears to be somewhat abbreviated, but it says:</p> <pre><code>A first chance exception of type 'System.Windows.Markup.XamlPar...
<p>I have experienced problems like that (but not with the exact same error message). It seems as if WPF cannot instantiate your Winforms User Control.</p> <p>The challenge is to find out why. Here are my suggestions that you could try:</p> <ol> <li>Check if you have enabled unmanaged debugging (in Project Properties...
<p>I also had this problem and all I had to do was go into the project properties>Security and click the This is a full trust application. I ran my project again and it worked!</p>
28,166
<p>How can I get precompiled headers working with GCC?</p> <p>I have had no luck in my attempts and I haven't seen many good examples for how to set it up. I've tried on <a href="https://en.wikipedia.org/wiki/Cygwin" rel="nofollow noreferrer">Cygwin</a> GCC 3.4.4 and using 4.0 on <a href="https://en.wikipedia.org/wiki...
<p><a href="http://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html" rel="noreferrer">Firstly, see the documentation here</a>.</p> <p>You compile headers just like any other file but you put the output inside a file with a suffix of <code>.gch</code>. </p> <p>So for example if you precompile stdafx.h you will hav...
<p>A subtle tip about the file extension that tripped me up, because I wasn't paying close enough attention: the <code>.gch</code> extension is added to the precompiled file's full name; it doesn't replace <code>.h</code>. If you get it wrong, the compiler won't find it and silently does not work.</p> <p>precomp.h =&g...
8,329
<p>In the Windows registry, how does <code>CurrentControlSet</code> differ from <code>ControlSet001</code> and <code>ControlSet002</code>? Which should be set when installing for all users?</p> <p>We are trying to add an environment variable for all users. Is this correct?</p> <pre><code>HKLM\SYSTEM\CurrentControlSet\C...
<p>Yes, you only need to update the <code>CurrentControlSet</code> key...</p> <p><code>ControlSet001</code> and <code>ControlSet002</code> are alternating backups of <code>CurrentControlSet</code>, you don't need to update them.</p> <p>Edit: As K noted, <code>CurrentControlSet</code> is an alternating symbolic link t...
<p>The <code>CurrentControlSet</code> subkey is really a pointer to one of the <code>ControlSetXXX</code> keys.</p> <p>The most valuable and reliable control set is <code>CurrentControlSet</code>. If you need to modify system settings in the Registry, <code>CurrentControlSet</code> is the best subkey to choose because...
37,180
<p>I have this <a href="http://www.thingiverse.com/thing:1381474" rel="noreferrer">GoPro mount for a quadcopter as STL file</a>. It looks as follows.</p> <p><a href="https://i.stack.imgur.com/qcZOR.png" rel="noreferrer"><img src="https://i.stack.imgur.com/qcZOR.png" alt="enter image description here"></a></p> <p>How ...
<p>Many resources are available for modification using 3D CAD (including learning a tool such as sketchup, which is VERY beginner friendly). The easiest and fastest solution to your particular problem may be the <a href="https://www.reddit.com/r/3Dprintmything/" rel="nofollow">reddit community "3D Print My Thing"</a> w...
<p>Well. I would cut it into two STLs, using netfabb slice / split tool.</p> <p>in 123d I would fill in the hole with the merge union (with a cylinder object), scale it, and either keep it unfilled and drill it, or do a subtraction union on where you want the holes. (again with a cylinder)</p> <p>Scaling otherwise yo...
315
<p>We have a system written in C and running under Solaris &amp; Linux that uses the Sybase CT-library to access a Sybase database. We generate the table-definitions, indexes, stored procedures and C-code from an in-house developed DDL to reduce the amount of work and errors.</p> <p>We would like to achieve database i...
<p>I would highly recommend <a href="http://www.sqlapi.com/" rel="nofollow noreferrer">SQLAPI++</a> (with the downside, perhaps, that it is a C++ library). There is also <a href="http://www.unixodbc.org/" rel="nofollow noreferrer">unixODBC</a>, though I have never used it in code -- only touched upon it while researchi...
<p>ODBC is going to give you far more portability options over ESQL/C.</p>
17,976
<p>I'm currently creating an explicit reference to this in the outer class so that I have a name to refer to in the anonymous inner class. Is there a better way to do this?</p>
<p>I just found this recently. Use <code>OuterClassName.this</code>.</p> <pre><code>class Outer { void foo() { new Thread() { public void run() { Outer.this.bar(); } }.start(); } void bar() { System.out.println("BAR!"); } } </code></pre> ...
<p>You can still use Outer.class to get the class of the outer class object (which will return the same Class object as Outer.this.getClass() but is more efficient)</p> <p>If you want to access statics in the enclosing class, you can use Outer.name where name is the static field or method.</p>
5,110
<p>I have sets of 5, 6 and 7 digit numbers. I need them to be displayed in the 000/000/000 format. So for example: </p> <p>12345 would be displayed as 000/012/345 </p> <p>and </p> <p>9876543 would be displayed as 009/876/543</p> <p>I know how to do this in a messy way, involving a series of if/else statements, and ...
<p>sprintf and modulo is one option</p> <pre><code>function formatMyNumber($num) { return sprintf('%03d/%03d/%03d', $num / 1000000, ($num / 1000) % 1000, $num % 1000); } </code></pre>
<p>Here's how I'd do it in python (sorry I don't know PHP as well). I'm sure you can convert it.</p> <pre><code>def convert(num): #num is an integer a = str(num) s = "0"*(9-len(a)) + a return "%s/%s/%s" % (s[:3], s[3:6], s[6:9]) </code></pre> <p>This just pads the number to have length 9, then splits the ...
29,589
<p>I've been admiring StackOverflow's default quilt-like profile pictures (which I notice are also on the <a href="http://failblog.org/" rel="nofollow noreferrer">Fail Blog</a>) and am curious what program both are using to generate them.</p> <p>But what I really want to know is: <strong>If you were to design the syst...
<p>FWIW, the default pictures are generated by <a href="http://gravatar.com" rel="noreferrer">gravatar</a>, which is why you'll see them on more than this site.</p>
<p>Use a Julia set or something like that and set the initial conditions to a hash of the user's email address.</p>
15,138
<p>While working on a C++ project, I was looking for a third party library for something that is not my core business. I found a really good library, doing exactly what's needed, but it is written in Python. I decided to experiment with embedding Python code in C++, using the Boost.Python library.</p> <p>The C++ code ...
<p>First of all, change your function to <code>return</code> the value. <code>print</code>ing it will complicate things since you want to get the value back. Suppose your <code>MyModule.py</code> looks like this:</p> <pre><code>import thirdparty def MyFunc(some_arg): result = thirdparty.go() return result </c...
<p>You should be able to return the result from MyFunc, which would then end up in the variable you are currently calling "ignored". This eliminates the need to access it in any other way.</p>
26,522
<p>I have a Java application and I would like to make it extensible. To create an extension, developers within our company will write a Java class that implements a certain interface. They may also wish to write associated helper classes. I would like to load these extensions into the application without an outage.<...
<p>You don't need to look for anything exotic. Handling this scenario is a fundamental feature of the Java security architecture.</p> <p>Every class has a "codebase", the location from which it was loaded. So if you package each extension in a separate JAR (or exploded in a separate directory), you'll be able tailor t...
<p>I don't know the implementation details, but it seems what you have in mind comes close to what the <a href="http://tomcat.apache.org/" rel="nofollow noreferrer">Apache Tomcat</a> server already does. Individual webapps in Tomcat are kept separated having different individual class loaders. Maybe it's worth having a...
40,111
<p>I am not a Delphi programmer, but I I got an old Delphi 7 application that I need to fix and it is using ADO.</p> <p>The database table (MS Accesss) contains +100,000 rows and when I set the ADOTable.Active=true it starts to load the entire table into RAM and that takes a lot of memory and time.</p> <p>How can I p...
<p>You could use TADOQuery to limit the result set with a sql query. Or you could use TADOTable and set the <a href="http://docs.codegear.com/docs/radstudio/radstudio2007/RS2007_helpupdates/HUpdate4/EN/html/delphivclwin32/ADODB_TCustomADODataSet_CursorLocation.html" rel="nofollow noreferrer">CursorLocation</a> to a Ser...
<p>I have found ADO + Access w/Delphi to be painfully slow, for lots of things (big table reads like you're describing, but also inserts as well, etc). My answer became "Quit using ADO and Access altogether." <br><br>Never did understand why it performed so poorly, especially when earlier technologies seemed not to.<...
44,676
<p>I am in charge of about 100+ documents (word document, not source code) that needs revision by different people in my department. Currently all the documents are in a shared folder where they will retrieve, revise and save back into the folder. </p> <p>What I am doing now is looking up the "date modified" in the sh...
<p>I've worked with Word documents in SVN. With <a href="http://tortoisesvn.tigris.org/" rel="noreferrer">TortoiseSVN</a>, you can easily diff Word documents (between working copy and repository, or between two repository revisions). It's really slick and definitely recommended.</p> <p>The other thing to do if you're ...
<p>You could do that, but if that files are binary you should always put a lock on it before editing. You won't get a conflict (which would be unresolvable).</p>
4,960
<p>I'm a beginner at rails programming, attempting to show many images on a page. Some images are to lay on top of others. To make it simple, say I want a blue square, with a red square in the upper right corner of the blue square (but not tight in the corner). I am trying to avoid compositing (with ImageMagick and ...
<p>Ok, after some time, here's what I landed on:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>.parent { position: relative; top: 0; left: 0; } .image1 { position...
<p>@buti-oxa: Not to be pedantic, but your code is invalid. The HTML <code>width</code> and <code>height</code> attributes do not allow for units; you're likely thinking of the CSS <code>width:</code> and <code>height:</code> properties. You should also provide a content-type (<code>text/css</code>; see Espo's code) wi...
7,091
<p>So here is the simple code:</p> <pre><code> [System.ComponentModel.DefaultValue(true)] public bool AnyValue { get; set; } </code></pre> <p>I am sure I don't set AnyValue to false again (I just created it). This property is a property of a Page class of ASP.NET. And I am cheking the value in a button event h...
<p>DefaultValue does <strong>NOT</strong> set the value. </p> <p>What it does is tell VisualStudio what the default value is. When a visual element (Button, listbox etc) is selected on a form, and the Property panel is displayed, VS will <strong>bold</strong> the values of properties which are set to something besid...
<p>So what is the best way to set default value like I meant?</p> <p>This seems a good way for me;</p> <pre><code> private bool myVal = true; public bool MyVal { get { return myVal; } set { myVal = value; } } </code></pre>
33,774
<p>After getting the objectEnumerator in the following code, the set1 retain count goes to 3. I was surprised to see that because I didn't expect it to change. I searched the <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSSet_Class/Reference/Reference.html#//apple_ref/occ/instm/N...
<p>It's generally not a good idea to rely on the retain count of objects, as it's an internal detail of the framework. Instead make sure your code adheres to the memory management principles, particularly ensuring that retain/new/copy and release/autorelease are balanced.</p>
<p>Reusing set1 after the release won't cause problems, because the retain count is on the Object referenced by the variable set1, not on the variable itself.</p>
42,950
<p>I stumbled upon this javascript obfuscator called <a href="http://www.ideareactor.com/idea/HomePage.html" rel="nofollow noreferrer">Squash</a>, I want to use it on my ExtJS project to obfuscate my javascript files. I've tried it and the result are totally obfuscated codes. But it seems that I have to obfuscate the E...
<p>I would like to suggest another javascript obfuscation tool: <a href="http://jscrambler.com" rel="nofollow noreferrer">http://jscrambler.com</a>. </p> <p>The tool is able to detect and replace identifiers with private access so you can/should only obfuscate your extjs application. </p>
<p>try <a href="http://dean.edwards.name/packer/" rel="nofollow noreferrer">http://dean.edwards.name/packer/</a> with check on Base62 encode Shrink variables it worked for me on my extjs application with out the need for to obfuscate the ExtJS library too </p>
37,265
<p>I'm using Emacs with <a href="http://mfgames.com/linux/csharp-mode" rel="nofollow noreferrer">C# Mode</a> and when I turn on the speedbar, no files show up by default. I can choose "show all files" on the speedbar mode, but then every .cs file shows up with a '[?]' next to the name. How do I properly configure s...
<p>I think ECB with CEDET is simply too bloated. I use speedbar alone with emacs and I use the original parser for C/C++. Just add this line to your .emacs and you'll be ok:</p> <pre><code> (speedbar-add-supported-extension ".cs") (add-to-list 'speedbar-fetch-etags-parse-list '("\\.cs" . speedbar-pars...
<p>I used speedbar earlier and got really irritated. I now use <a href="http://ecb.sourceforge.net/" rel="nofollow noreferrer">ECB</a>. <a href="http://ecb.sourceforge.net/" rel="nofollow noreferrer">ECB</a> uses its own buffer for the tree and can optionally show the outline of the CS file in a separate buffer. They a...
32,399
<p>I need to create XML in Perl. From what I read, <a href="http://search.cpan.org/dist/XML-LibXML" rel="noreferrer">XML::LibXML</a> is great for parsing and using XML that comes from somewhere else. Does anyone have any suggestions for an XML Writer? Is <a href="http://search.cpan.org/dist/XML-Writer" rel="noreferr...
<p>XML::Writer is still maintained (at least, as of February of this year), and it's indeed one of the favorite Perl XML writers out there. </p> <p>As for describing the syntax, one is better to look at the module's documentation (the link is already in the question). To wit:</p> <pre><code>use XML::Writer; my $wri...
<p>I like <a href="http://search.cpan.org/dist/XML-TreeBuilder" rel="nofollow noreferrer">XML::TreeBuilder</a> because it fits the way I think. Historically, I've used it more for parsing than emitting.</p> <p>A few weeks after this question was posted, I had occasion to generate some XML from Perl. I surveyed the o...
18,718
<p>One CSS rule I have learned is that you should use the relative "em" font-size unit instead of the absolute "pt". The general idea is to set the font-size in your body tag to e.g. "94%" and then set all other elements with an "em" size like this. The reasoning is:</p> <ul> <li>you can then change the relative size...
<p>Depending on the country where you live, you might actually end up breaking the law using pt instead of em, depending on how hard your legislature want to enforce rules. Here in the UK, there is a disability discrimination act, which has been used to target companies where their websites have been rendered in a fixe...
<p>See also <a href="http://www.killersites.com/mvnforum/mvnforum/viewthread?thread=4084" rel="nofollow noreferrer">http://www.killersites.com/mvnforum/mvnforum/viewthread?thread=4084</a></p>
45,406
<p>I've written PL/SQL code to denormalize a table into a much-easer-to-query form. The code uses a temporary table to do some of its work, merging some rows from the original table together.</p> <p>The logic is written as a <a href="http://www.oreillynet.com/lpt/a/3136" rel="nofollow noreferrer">pipelined table funct...
<p>I think a way to approach this is to use analytic functions...</p> <p>I set up your test case using:</p> <pre><code>create table employee_job ( emp_id integer, job_id integer, status varchar2(1 char), eff_date date ); insert into employee_job values (1,10,'A',to_date('10-JAN-2008','DD-MON-YY...
<p>I couldn't agree with you more, HollyStyles. I also used to be a TSQL guy, and find some of Oracle's idiosyncrasies more than a little perplexing. Unfortunately, temp tables aren't as convenient in Oracle, and in this case, other existing SQL logic is expecting to directly query a table, so I give it this view inste...
4,043
<p>We have a SmartClient built in C# that stubornly remains open when the PC its running on is being restarted. This halts the restart process unless the user first closes the SmartClient or there is some other manual intervention.</p> <p>This is causing problems when the infrastructure team remotely installs new sof...
<p>OK, if you have access to the app, you can handle the SessionEnded event.</p> <pre><code>... Microsoft.Win32.SystemEvents.SessionEnded +=new Microsoft.Win32.SessionEndedEventHandler(shutdownHandler); ... private void shutdownHandler(object sender, Microsoft.Win32.SessionEndedEventArgs e) { // Do stuff } </cod...
<p>Normally a .Net app would respond correctly- at least, that's the 'out of the box' behavior. If it's not, there could be a number of things going on. My best guess without knowing anything more about your program is that you have a long-running process going in the main UI thread that's preventing the app from res...
20,324
<p>I've got some <a href="http://code.google.com/p/protobuf-net/" rel="nofollow noreferrer">library code</a> that works on a range of .NET runtimes (regular, CF, Silverlight, etc) - but a small block of code is breaking <strong>only</strong> on CF 2.0, with a <code>MethodAccessException</code>. I'm pretty sure it is a ...
<p>Have you tried writing your own sort - perhaps the built in one is doing some reflection shenanigans... Not with a view to using your own in the long term - but as a means of debugging the problem. It should be quick to code in something else and at least see whats then.</p> <p>I presume you don't get a stack tra...
<p>I remember having troubles (sometimes) to make sure that the right dotNET stuff is on the target device. This was in dotNET CF 1.0 days. Could this still be the issue here?</p>
39,682
<p>I'm looking to utilize jQuery to handle a few very common requests we get for data tables of varying sizes: scrolling, sorting, and dynamic filtering.</p> <ul> <li>I've handled scrolling in the past by having two separate tables with fixed width columns, along with associated div containers for the "actual" scrolli...
<p>I came across this question as I was searching for a sortable table plugin myself; I really wasn't impressed with any of the suggested widgets, but later I discovered <a href="http://datatables.net/index">DataTables</a>, and I was quite impressed. I recommend checking it out.</p>
<p>I'd like to add the Laravel flavored DataTables (<a href="http://github.com/yajra/laravel-datatables" rel="nofollow noreferrer">GitHub</a>, <a href="https://yajrabox.com/docs/laravel-datatables/master" rel="nofollow noreferrer">jquery DataTables API</a>) - perfect if you already work with PHP/Laravel.</p> <p>Extra,...
23,404
<p>I have a unit test that works fine locally but when uploaded to TeamCity build server fails with "The process cannot access the file because it is being used by another process."</p> <ol> <li>Before I do anything in the Test I check in the setup if the file exists and if so try to delete it. This fails with the sa...
<p>Sysinternals <a href="http://live.sysinternals.com/handle.exe" rel="nofollow noreferrer">handle.exe</a> is the first step. Or use <a href="http://live.sysinternals.com/procexp.exe" rel="nofollow noreferrer">Process Explorer</a>'s <code>Find Handle or DLL</code>. It's always safer to <strong>kill the process</stron...
<p>Sysinternals <a href="http://live.sysinternals.com/handle.exe" rel="nofollow noreferrer">handle.exe</a> is the first step. Or use <a href="http://live.sysinternals.com/procexp.exe" rel="nofollow noreferrer">Process Explorer</a>'s <code>Find Handle or DLL</code>. It's always safer to <strong>kill the process</stron...
39,345
<p>I'm looking for a dbm-like library that I can use in place of Berkeley DB, which I'm currently using. My main reason for switching is the licensing fees for BDB are pretty high (free for open source apps, but my employer does not want to open source this particular app for various reasons).</p> <p>I've looked brief...
<h1>C/C++</h1> <ul> <li><a href="http://sphia.org/" rel="noreferrer">http://sphia.org/</a> a Key/Value Store, Written in C and BSD-Licensed.</li> <li><a href="https://code.google.com/p/leveldb/" rel="noreferrer">https://code.google.com/p/leveldb/</a> Written in C++, also BSD-Licensed</li> <li><a href="http://luxio.sou...
<p>db4o is pretty cheap and fast but it can only be used with java or .net</p>
32,611
<p>I've got several function where I need to do a one-to-many join, using count(), group_by, and order_by. I'm using the sqlalchemy.select function to produce a query that will return me a set of id's, which I then iterate over to do an ORM select on the individual records. What I'm wondering is if there is a way to ...
<p>What you're trying to do maps directly to a SQLAlchemy join between a subquery [made from your current select call] and a table. You'll want to move the ordering out of the subselect and create a separate, labeled column with count(desc); order the outer select by that column.</p> <p>Other than that, I don't see mu...
<p>What you're trying to do maps directly to a SQLAlchemy join between a subquery [made from your current select call] and a table. You'll want to move the ordering out of the subselect and create a separate, labeled column with count(desc); order the outer select by that column.</p> <p>Other than that, I don't see mu...
48,349
<p>How do I get modrewrite to ENTIRELY ignore the /vip/ directory so that all requests pass directly to the folder?</p> <pre><code>&lt;IfModule mod_rewrite.c&gt; RewriteEngine On RewriteBase / RewriteRule ^vip/.$ - [PT] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L...
<p>Replace:</p> <pre><code>RewriteRule ^vip/.$ - [PT] </code></pre> <p>with:</p> <pre><code>RewriteRule ^vip/.*$ - [PT,L] </code></pre>
<p>The easy way I do it when needed is add a new .htaccess file to that folder and in it put</p> <pre><code>RewriteEngine Off </code></pre> <p>edited to fix typo</p>
20,435
<p>In how many languages is Null not equal to anything not even Null?</p>
<p>It's this way in SQL (as a logic language) because null means unknown/undefined.</p> <p>However, in programming languages (like say, C++ or C#), a null pointer/reference is a specific value with a specific meaning -- nothing.</p> <p>Two nothings are equivilent, but two unknowns are not. The confusion comes from t...
<p>In SQL you would have to do something like:</p> <pre><code>WHERE column is NULL </code></pre> <p>rather than</p> <pre><code>WHERE column = NULL </code></pre>
10,091
<p>What is the preferred way using the CF 3.5 to get get data from a web service? I am getting back a series of tables from the web service.</p>
<p>As John points out, its really no different than a desktop call. You can typically add a references to the service from the IDE and let Studio generate the call wrapper, or you can manually hammer it out. Your case might be slightly different if you're attempting to pass a strongly-typed DataSet as the desktop's s...
<p>I've always just used the WebRequest/WebResponse classes; or the HttpWebRequest/HttpWebResponse classes if desired. They are a little tedious to use and not quite as nice as the full frameworks WebClient class, but they work. </p>
27,561
<p>I'm currently using <code>Win32ShellFolderManager2</code> and <code>ShellFolder.getLinkLocation</code> to resolve windows shortcuts in Java. Unfortunately, if the Java program is running as a service under Vista, <code>getLinkLocation</code>, this does not work. Specifically, I get an exception stating "Could not ge...
<p>Added comments (some explanation as well as credit to each contributor so far),additional check on the file magic, a quick test to see if a given file might be a valid link (without reading all of the bytes), a fix to throw a ParseException with appropriate message instead of ArrayIndexOutOfBoundsException if the fi...
<p>The given code works well, but has a bug. A java byte is a signed value from -128 to 127. We want an unsigned value from 0 to 255 to get the correct results. Just change the bytes2short function as follows:</p> <pre><code>static int bytes2short(byte[] bytes, int off) { int low = (bytes[off]&lt;0 ? bytes[off]+...
39,872
<p>Anyone know of a JS library that will allow me to syntax highlight a code block, then highlight line-level diffs? For example, in a subversion diff, I'd like to highlight the characters on the line that have changed (as well as highlighting the fact that there are change(s) on the line).</p> <p>Edit: I'm after som...
<p>Microsoft has no plans to extend LINQ to SQL beyond SQL Server and it wouldn't make much sense to do so. The majority of code in LINQ to SQL is in the implementation of the SQL Provider.</p> <p>Microsoft offers Entity Framework as its cross-database-platform ORM solution and other ORM solutions are implementing LIN...
<p>I do not know whether Microsoft plans to do so, but it is probably unlikely. However, if you want to use something similar, you could probably use <a href="http://www.ohloh.net/projects/dblinq" rel="nofollow noreferrer">DbLinq</a> meanwhile.</p>
27,886
<p>I have a page upon which a user can choose up to many different paragraphs. When the link is clicked (or button), an email will open up and put all those paragraphs into the body of the email, address it, and fill in the subject. However, the text can be too long for a mailto link.</p> <p>Any way around this?</p>...
<p>By putting the data into a form, I was able to make the body around 1800 characters long before the form stopped working.</p> <p>The code looked like this:</p> <pre><code>&lt;form action="mailto:youremail@domain.com"&gt; &lt;input type="hidden" name="Subject" value="Email subject"&gt; &lt;input type="hidde...
<p>Does the e-mail content need to be in the e-mail? Could you store the large content somewhere centrally (file-share/FTP site) then just send a link to the content?</p> <p>This makes the recipient have an extra step, but you have a consistent e-mail size, so won't run into reliability problems due to unexpectedly l...
2,769
<p>I have an asp.net web page with a ton of code that is handled in the Page-Load event of the page. I also have a dropdown box on the page that should reload the page with a new value, but I would like to get this new value before I process the entire Page-Load code. I am trying to get my head around ASP.NET page lif...
<p>I would use Page_PreLoad instead of Page_Init, because it is raised after all postback data is processed.</p>
<p>As noted before, Page_Init is what you want. But I emplore you to make your pages as loosly coupled as posible. Look into the MVP pattern for starters. Also, make sure that most of your logic is in your domain objects.</p> <p>There shouldn't be too much code in the Page_Load event. If there is, it shoud be brok...
48,892
<p>Do you think changing directories inside bash or Perl scripts is acceptable? Or should one avoid doing this at all costs?</p> <p>What is the best practice for this issue?</p>
<p>The current working directory is local to the executing shell, so you can't affect the user unless he is "dotting" (running it in the current shell, as opposed to running it normally creating a new shell process) your script.</p> <p>A very good way of doing this is to use subshells, which i often do in aliases.</p>...
<p>Is it at all feasible to try and use fully-quantified paths, and not make any assumptions on which directory you're currently in? e.g.</p> <pre><code>use FileHandle; use FindBin qw($Bin); # ... my $file = new FileHandle("&lt; $Bin/somefile"); </code></pre> <p>rather than</p> <pre><code>use FileHandle; # ... my $f...
29,789
<p>How do you resolve a domain name to an IP address with .NET/C#?</p>
<pre><code>using System.Net; foreach (IPAddress address in Dns.GetHostAddresses("www.google.com")) { Console.WriteLine(address.ToString()); } </code></pre>
<p>Try using the <a href="https://learn.microsoft.com/en-us/dotnet/api/system.net.dns" rel="nofollow noreferrer">System.Net.Dns</a> class</p>
2,679
<p>How can you avoid circular dependencies when you're designing two classes with a producer/consumer relationship? Here ListenerImpl needs a reference to Broadcaster in order to register/unregister itself, and Broadcaster needs a reference back to the Listeners in order to send messages. This example is in Java but it...
<p>I don't see that being a circular dependency.</p> <p>Listener depends on nothing.</p> <p>ListenerImpl depends on Listener and Broadcaster</p> <p>Broadcaster depends on Listener.</p> <pre><code> Listener ^ ^ / \ / \ Broadcaster &lt;-- ListenerImpl </code></pre>...
<p>I'm not a java dev, but something like this:</p> <pre><code>public class ListenerImpl implements Listener { public Foo() {} public void registerWithBroadcaster(Broadcaster b){ b.register(this); isRegistered = true;} public void callBack(Object arg) { if (!isRegistered) throw ... else ... } public void shutD...
18,008
<p>I want to log the Poison message that my wcf service is dropping using MSMQ 3.0 and windows 2003</p>
<p>You can implement a custom <a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.dispatcher.ierrorhandler.aspx" rel="nofollow noreferrer">IErrorHandler</a> and associate it with your service using a custom behavior. In your implementation, check if the exception raised is of type MsmqPoisonMessageExce...
<p>You could probably add a service like the following that reads messages from your poison queue and logs them. </p> <pre><code>&lt;service name="YourPosionMessageHandler" &lt;endpoint address="net.msq://localhost/private/YourServiceQueue;poison" binding="netMsmqBinding" /&gt; &lt;/service&gt; </code></pre>
14,537
<p>I'm looking for an open source, cross platform (Windows &amp; Linux at least) command line tool to take some code (C++, but multiple languages would be sweet), and spit out valid a XHTML representation of that code, with syntax highlighting included.</p> <p>Ideally the XHTML should just wrap the code with <code>&lt...
<p>I can recommend <a href="http://pygments.org/" rel="noreferrer">Pygments</a>. It's easy to work with and supports a lot of languages. It does what you want, i.e., it wraps the code in <code>&lt;span&gt;</code> tags:</p> <pre><code>from pygments import highlight from pygments.lexers import PythonLexer from pygments....
<p>Not sure how helpful this will be, but my team uses doxygen to produce documentation, which happens to provide color syntax highlighting on our code views as well as a side bonus. Never really needed it, but it does it.</p>
12,570
<p>Can someone explain the difference between:</p> <ul> <li>lock (someobject) {}</li> <li>Using Mutex</li> <li>Using Semaphore</li> <li>Using Monitor</li> <li>Using Other .Net synchronization classes</li> </ul> <p>I just can't figure it out. It seems to me the first two are the same?</p>
<p>Great question. I maybe wrong.. Let me try.. Revision#2 of my orig answer.. with a little bit of more understanding. Thanks for making me read :)</p> <p><strong>lock(obj)</strong> </p> <ul> <li>is a CLR construct that for (intra-object?) thread synchronization. Ensures that only one thread can take ownership of th...
<p>In most cases you <strong>should not</strong> use locks (=Monitors) or mutexes/semaphores. They all block waiting threads for the time of synchronized operation. So they work well only for very small operations.</p> <p>And you definitely <strong>shouldn't use</strong> <code>System.Collections.Concurrent</code> class...
38,621
<p>I need to find out the pixel position of one element in a list that's been displayed using a <code>ListView</code>. It seems like I should get one of the <strong>TextView's</strong> and then use <code>getTop()</code>, but I can't figure out how to get a child view of a <code>ListView</code>.</p> <p><strong>Update:<...
<p>See: <a href="https://stackoverflow.com/questions/2001760/android-listview-get-data-index-of-visible-item/2002413#2002413">Android ListView: get data index of visible item</a> and combine with part of Feet's answer above, can give you something like:</p> <pre><code>int wantedPosition = 10; // Whatever position you'...
<p>This assumes you know the position of the element in the ListView :</p> <pre><code> View element = listView.getListAdapter().getView(position, null, null); </code></pre> <p>Then you should be able to call getLeft() and getTop() to determine the elements on screen position.</p>
32,131
<p>I have a list of elements (the <em>X</em> in the following examples) displayed either in a row or in a column of an HTML table.</p> <p>In HTML code point of view, I have either (horizontal display):</p> <pre><code>&lt;table id="myTable"&gt; &lt;tr&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;B&lt;/td&gt; &lt...
<p>Given the additional information you've provided, I think that this is what you want. It traverses the table moving the cells from every second row into the previous row...</p> <pre><code>var idx = 1; var row, next; while((row = $('#myTable tr:nth-child(' + idx++ + ')')).length) { if((next = $('#myTable tr:nth...
<p>Assuming you are starting with one cell in each row and that each cell has one label and one input then I think that you want something like this:</p> <pre><code>$('#myTable tr').each(function() { $('&lt;td/&gt;').append( $(this).find('td input') ).appendTo(this); }); </code></pre>
32,769
<p>What's the best and/or fastest method of doing multijoin queries in Django using the ORM and QuerySet API? </p>
<p>If you are trying to join across tables linked by ForeignKeys or ManyToManyField relationships then you can use the double underscore syntax. For example if you have the following models:</p> <pre><code>class Foo(models.Model): name = models.CharField(max_length=255) class FizzBuzz(models.Model): bleh = mo...
<p>Caktus blog has an answer to this: <a href="http://www.caktusgroup.com/blog/2009/09/28/custom-joins-with-djangos-queryjoin/" rel="nofollow noreferrer">http://www.caktusgroup.com/blog/2009/09/28/custom-joins-with-djangos-queryjoin/</a></p> <p>Basically there is a hidden QuerySet.query.join method that allows adding ...
9,819
<p>I am modifying a SQL table through C# code and I need to drop a NOT NULL constraint if it exists. How do I check to see if it exists first?</p>
<pre><code>select is_nullable from sys.columns where object_id = OBJECT_ID('tablename') and name = 'columnname'; </code></pre>
<p>I'm not sure about your business rules, so I could be wrong, but what you are proposing sounds like a bad idea.</p> <p>If the NOT NULL constraint shouldn't exist, then remove it from the DB. If it should exist, program around it.</p> <p>If you actually do need to implement DDL to change tables, I'd write a stored...
45,990
<p>I am very curious about the possibility of providing immutability for java beans (by beans here I mean classes with an empty constructor providing getters and setters for members). Clearly these classes are not immutable and where they are used to transport values from the data layer this seems like a real proble...
<p>I think I'd use the delegation pattern - make an ImmutableDate class with a single DateBean member that must be specified in the constructor:</p> <pre><code>public class ImmutableDate implements DateBean { private DateBean delegate; public ImmutableDate(DateBean d) { this.delegate = d; } publ...
<p>I use interfaces and casting to control the mutability of beans. I don't see a good reason to complicate my domain objects with methods like <code>getImmutableInstance()</code> and <code>getMutableInstance()</code>.</p> <p>Why not just make use of inheritance and abstraction? e.g.</p> <pre><code>public interface U...
39,532
<p>I'm trying to make things simpler. Here is my code:</p> <pre><code> If Threading.Monitor.TryEnter(syncRoot) Then Try 'do something Finally Threading.Monitor.Exit(syncRoot) End Try Else 'do something else End If </code></pre> <p>This is even worse t...
<p>Use a delegate?</p> <p>E.g.</p> <pre><code>public bool TryEnter(object lockObject, Action work) { if (Monitor.TryEnter(lockObject)) { try { work(); } finally { Monitor.Exit(lockObject); } return true; } return fals...
<p>This is very similar to your <a href="https://stackoverflow.com/questions/170028/how-would-you-simplfy-entering-and-exiting-a-readerwriterlock">last post</a>, and I would expect a similar answer. The only significant difference is that you might return "null" from your method if the timeout fails - then the "Dispose...
20,525
<p>It seems to me that the most common overly ambitious project that programmers (esp. Comp. Sci. grads) try to tackle is building your own operating system. (Trying to create your own programming language + compiler is probably even more common but not nearly as ambitious.)</p> <p>For those (like myself) foolish enou...
<p>Being able to speak from actual experience (<a href="http://www.aros.org/" rel="noreferrer">AROS</a>, the biggest obstacles are:</p> <ul> <li>Hen and egg (no os &lt;-> no apps &lt;-> no users &lt;-> can't attract developers)</li> <li>Why even try to compete against Windows? Apple doesn't succeed and they have lots ...
<p>Writing an OS encounters the same problems as other large software projects.</p> <p>It lacks clearly defined goals, and has timeline / estimation problems due to lack of experience.</p> <p>Also it would be useful for the programmer first to create a 'hello world' type operating system, so that he/she learns the co...
44,268
<p>Is there a good library for extracting text from a PDF? I'm willing to pay for it if I have to.</p> <p>Something that works with C# or classic ASP (VBScript) would be ideal and I also need to be able to separate the pages from the PDF.</p> <p><a href="https://stackoverflow.com/questions/25665/python-module-for-co...
<p>You can use the IFilter interface built into Windows to extract text and properties (author, title, etc.) from any supported file type. It's a COM interface so you would have use the .NET interop facilities.</p> <p>You'd also have to download the free PDF IFilter driver from Adobe.</p>
<p>Here is a good list: <a href="http://csharp-source.net/open-source/pdf-libraries" rel="nofollow noreferrer">Open Source Libs for PDF/C#</a></p> <p>Most of these are geared toward creating PDFs, but they should have read capability as well.</p> <p>There is this one as well: <a href="http://www.lowagie.com/iText/" r...
6,904
<p>I'd like to get all the permutations of swapped characters pairs of a string. For example:</p> <p>Base string: <code>abcd</code></p> <p>Combinations:</p> <ol> <li><code>bacd</code></li> <li><code>acbd</code></li> <li><code>abdc</code></li> </ol> <p>etc.</p> <h3>Edit</h3> <p>I want to swap only letters that are next ...
<p>Edit: Markdown hates me today...</p> <pre><code>$input = "abcd"; $len = strlen($input); $output = array(); for ($i = 0; $i &lt; $len - 1; ++$i) { $output[] = substr($input, 0, $i) . substr($input, $i + 1, 1) . substr($input, $i, 1) . substr($input, $i + 2); } print_r($...
<p>How about just using the following:</p> <pre><code>function swap($s, $i) { $t = $s[$i]; $s[$i] = $s[$i+1]; $s[$i+1] = $t; return $s; } $s = "abcd"; $l = strlen($s); for ($i=0; $i&lt;$l-1; ++$i) { print swap($s,$i)."\n"; } </code></pre>
23,720
<p>If this question has already been asked I appologies, please point me in the right direction.</p> <p>I was wondering if anyone has any insight into how StackOverflow pops up the "n new answers have been posted, load new answers" thing at the top of a question when you are adding a post. This seems like a very usefu...
<p>Look at this SO blog post: <a href="https://blog.stackoverflow.com/2008/10/solving-the-fastest-gun-in-the-west-problem/">https://blog.stackoverflow.com/2008/10/solving-the-fastest-gun-in-the-west-problem/</a></p> <blockquote> <p>That said, the one implementable recommendation that came out of this discussion is an a...
<p>At a guess it's using a jQuery timer object to query a JSON webservice every <em>n</em> seconds. Check out <a href="http://docs.jquery.com" rel="nofollow noreferrer">http://docs.jquery.com</a> and <a href="https://web.archive.org/web/20200925065333/http://geekswithblogs.net/JuanDoNeblo/archive/2007/10/24/json_in_asp...
31,165
<p>I need to create a nice installer for a Mac application. I want it to be a disk image (DMG), with a predefined size, layout and background image.</p> <p>I need to do this programmatically in a script, to be integrated in an existing build system (more of a pack system really, since it only create installers. The bu...
<p>After lots of research, I've come up with this answer, and I'm hereby putting it here as an answer for my own question, for reference:</p> <ol> <li><p>Make sure that "Enable access for assistive devices" is checked in System Preferences>>Universal Access. It is required for the AppleScript to work. You may have to ...
<p>These answers are way too complicated and times have changed. The following works on 10.9 just fine, permissions are correct and it looks nice.</p> <h3>Create a read-only DMG from a directory</h3> <pre class="lang-sh prettyprint-override"><code>#!/bin/sh # create_dmg Frobulator Frobulator.dmg path/to/frobulator/d...
12,241
<p>Is there a general procedure for programming extensibility capability into your code?</p> <p>I am wondering what the general procedure is for adding extension-type capability to a system you are writing so that functionality can be extended through some kind of plugin API rather than having to modify the core code ...
<p>This is generally something that you'll have to expose yourself, so yes, it will be dependent on the language your system is written in (though often it's possible to write wrappers for other languages as well).</p> <p>If, for example, you had a program written in C, for Windows, plugins would be written for your p...
<ol> <li><p>Find out what minimum requrements you want to put on a plugin writer. Then make one or more Interfaces that the writer must implement for your code to know when and where to execute the code. </p></li> <li><p>Make an API the writer can use to access some of the functionality in your code. </p></li> </ol> ...
2,961
<p>I have named_scope which is reused in multiple ActiveRecord models. For example:</p> <pre><code> named_scope :limit, lambda {|limit| {:limit =&gt; limit}} </code></pre> <p>What is the best practice to extract this code to be shared across models. Is it possible to extract it to a module or should I rather reo...
<p>Use a module. Something like this should work:</p> <pre><code>module CommonScopes def self.included(base) base.class_eval do named_scope :limit, lambda {|limit| {:limit =&gt; limit}} end end end </code></pre> <p>Then just include CommonScopes and you'll be good to go.</p>
<p>@Matt via <a href="http://apidock.com/ruby/v1_9_1_378/BasicObject/instance_eval" rel="nofollow noreferrer">instance_eval</a>, @see <a href="https://stackoverflow.com/questions/7323793/shared-scopes-via-module">Shared scopes via module?</a></p>
22,610
<p>Does anyone know how to change the from user when sending email using the mail command? I have looked through the man page and can not see how to do this. </p> <p>We are running Redhat Linux 5.</p>
<p><a href="http://www.mindspill.org/962" rel="noreferrer">http://www.mindspill.org/962</a> seems to have a solution.</p> <p>Essentially:</p> <p><code>echo "This is the main body of the mail" | mail -s "Subject of the Email" recipent_address@example.com -- -f from_user@example.com</code></p>
<p>Thanks to all example providers, some worked for some not. Below is another simple example format that worked for me.</p> <pre><code>echo "Sample body" | mail -s "Test email" from=sender-addrs@example.com recepient-addres@example.com </code></pre>
14,518
<p>I'm using .NET typed datasets on a project, and I often get into situations where I prefetch data from several tables into a dataset and then pass that dataset to several methods for processing. It seems cleaner to let each method decide exactly which data it needs and then load the data itself. However, several of ...
<p>I think what you want is:</p> <pre><code>type A { Id : Integer32 = AutoNumber(); } where identity Id; As : A*; type B { Id : Integer32 = AutoNumber(); A : A; } where identity Id; Bs : (B where value.A in As)*; type C { Id : Integer32 = AutoNumber(); B : B; } where identity Id &amp;&amp; B in...
<p><a href="http://social.msdn.microsoft.com/Forums/en-US/oslo/thread/05103bf8-4e0f-4976-bcdd-2c724cb08738/" rel="nofollow noreferrer">http://social.msdn.microsoft.com/Forums/en-US/oslo/thread/05103bf8-4e0f-4976-bcdd-2c724cb08738/</a></p>
31,634
<p>My current employer uses a 3rd party hosted CRM provider and we have a fairly sophisticated integration tier between the two systems. Amongst the capabilities of the CRM provider is for developers to author business logic in a Java like language and on events such as the user clicking a button or submitting a new...
<pre><code>Map map = new HashMap(); Hashtable ht = new Hashtable(); </code></pre> <p>Both classes can be found from the java.util package. The difference between the 2 is explained in the following <a href="http://www.jguru.com/faq/view.jsp?EID=430247" rel="noreferrer">jGuru FAQ entry</a>.</p>
<pre><code>Hashtable&lt;Object, Double&gt; hashTable = new Hashtable&lt;&gt;(); </code></pre> <p><strong>put values</strong> ...</p> <p><strong>get max</strong></p> <pre><code>Optional&lt;Double&gt; optionalMax = hashTable.values().stream().max(Comparator.naturalOrder()); if (optionalMax.isPresent()) System.out.pr...
4,898
<p>I am trying to develop a slideshow with a pause between slides. So I'm trying to use the setTimeout statement as shown below. This is written to swap 2.jpg for 1.jpg with a pause of 10 seconds on clicking the button. But it does now work. Can anyone help me. Thanks.</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;scri...
<p>There are a couple of things wrong here. First, its passing code to be eval'ed in the first parameter of <a href="https://developer.mozilla.org/en/DOM/window.setTimeout" rel="noreferrer">setTimeout</a> is not recommended. Better pass a callback instead:</p> <pre><code> setTimeout(function() { swap(); },10000); //O...
<p>Javascript isn't necessary to do a slideshow. All you have to do is put each image into a separate page, then add this single line to the top of each page in the &lt;head> section:</p> <pre><code>&lt;meta http-equiv="refresh" content="10;url=NextPage.html"/&gt; </code></pre> <p>"10" is the number of seconds to wa...
48,819
<p>If the user of my winforms application resizes the main form, I want the 2 panels to stretch out also, along with the child controls.</p> <p>How can I achieve this?</p>
<blockquote> <p>If the user of my winforms application resizes the main form, I want the 2 panels to stretch out also, along with the child controls.</p> </blockquote> <p>You're the ideal use case for <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.tablelayoutpanel.aspx" rel="noreferrer">...
<p>Play around with the <strong>Dock</strong> and <strong>Anchor</strong> properties of your panels.</p>
21,010
<p>Does anyone know if it is possible to detect whether the browser has closed the connection during the execution of a long <code>PHP</code> script, when using <code>apache</code> and <code>mod_php</code>?</p> <p>For example, in <code>Java</code>, the <code>HttpOutputStream</code> will throw an <code>exception</code>...
<p>Use <a href="http://us2.php.net/manual/en/function.connection-aborted.php" rel="noreferrer">connection_aborted()</a></p>
<p><a href="http://nz.php.net/register-shutdown-function" rel="nofollow noreferrer">http://nz.php.net/register-shutdown-function</a> </p> <p>Probably less complicated if you just want a script to die and handle it when a user terminates. </p> <p>( Ie: if it was a lengthy search, this would save you a bunch of operati...
11,171
<p>I'm trying to complete a practice question from a book on generics but the question doesn't make sense to me. Here it goes.</p> <p>Create two classes with identical functionality. Use generics for the first class, and cast the second class to Object types. Create a for loop that uses class and the Object based clas...
<p>I think that the question is asking you to create a collection class, and insert instances of your class into that.</p> <p>E.g., </p> <p>Generics version:</p> <pre><code>List&lt;Human&gt; myList = new List&lt;Human&gt;(); Human h = new Human(); myList.Add(h); </code></pre> <p>Object version:</p> <pre><code>Arra...
<p>I think you've got it right except for the for loops. An int is an object type so replace</p> <pre><code>object her = (object)per.Value; </code></pre> <p>with </p> <pre><code>int her = per.Value; </code></pre> <p>The other thing you're missing is some performance counters. Have a look at the Timer class to see w...
27,299