instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I'd like to hear what is the motivation behind the bulk of sealed classes in the .Net framework. What is the benefit of sealing a class? I cannot fathom how not allowing inheritance can be useful and most likely not the only one fighting these classes.</p>
<p>So, why is the framework designed this way and wouldn't i... | <p>Classes should either be designed for inheritance or prohibit it. There is a cost to designing for inheritance:</p>
<ul>
<li>It can pin down your implementation (you have to declare which methods are going to call which other methods, in case a user overrides one but not the other)</li>
<li>It reveals your implemen... | <p>Sealing allows you to realize some minor performance gains. This is less true in the world of JITs and lazy pessimization than in the world of, say C++, but since .NET is not as good as pessimization as java compilers are mostly because of different design philosophies it is still useful. It tells the compiler that ... | 33,659 |
<p>I need to convert strings with optional trailing signs into actual numbers using Powershell.</p>
<p>Possible strings are:</p>
<ul>
<li>1000-</li>
<li>323+</li>
<li>456</li>
</ul>
<p>I'm trying to use System.Int.TryParse with a NumberStyles of AllowTrailingSign, but I can't work out how to make System.Globalizatio... | <p>EDIT: as per Halr9000's suggestion</p>
<pre><code>$foo = "300-";
$bar = 0;
$numberStyles = [System.Globalization.NumberStyles];
$cultureInfo = [System.Globalization.CultureInfo];
[int]::TryParse($foo, $numberStyles::AllowTrailingSign, $cultureInfo::CurrentCulture, [ref]$bar);
</code></pre>
| <p>If you are sure that the signs could be - or +, String.Replace could help.</p>
<p>If you mean that 323- should return -323, checking for the sign and multiplying it by -1 would help.</p>
| 38,540 |
<p>I am investigating a production system where there are several Windows services communicating with each other through TCP/IP sockets. I'm trying to figure out which executable is listening to which IP address and which port on a given machine.</p>
<p>Other than rummaging through each windows service's obscure confi... | <p>As already mentioned <a href="http://technet.microsoft.com/en-us/sysinternals/bb897437.aspx" rel="noreferrer">TCPView</a> by SysInternals (i.e. Microsoft) is a great tool.
But on production systems you may not be allowed to install additional software, so I think you may want to try out netstat.exe, which is typical... | <p>Command line netstat tool might help you. To learn available parameters run it with /?: netstat /?</p>
<p>Or there is a better GUI alternative: SysInternals TcpView (freely downloadable from ms site)</p>
| 32,217 |
<p>How best can I convert instances of double backslashes to a single backslash in a string, but remove any occurrences of single backslash?</p>
<p>So this:</p>
<pre>
\|Testing|ABC:1234\\1000-1\|
</pre>
<p>Should convert to this:</p>
<pre>
|Testing|ABC:1234\1000-1|
</pre>
<p>Ideally I want to avoid a temporary rep... | <pre><code>Regex.Replace(input, @"\\(.|$)", "$1");
</code></pre>
<p>[Edit: Pattern didn't match all possible cases specified in the OP. Thanks for the suggestions, GONeale and Alan M.]</p>
| <p>Thanks for your response Princess,</p>
<p>However in a few other scenarios it fails. I'm using this input:</p>
<pre><code>Regex.Replace(@"\L\\A\", @"\\(.)", "$1")
</code></pre>
<p>It's returning: <code>L\A\</code>
When it should return <code>L\A</code>. I understand you are seeking any other character with the ... | 44,068 |
<p>I have a remote DB2 database that I'm accessing through ODBC. When I have a query like</p>
<pre><code>SELECT t.foo, t.bar, t.problemcolumn
FROM problemtable t
WHERE t.bar < 60;
</code></pre>
<p>it works like a charm, so the table and columns obviously exist.</p>
<p>But if I specify the problem column in the WH... | <p>Sorry for the obvious answer, but does the problemtable exist? Your code looks like pseudo code because of the table/column names, but be sure to double check your spelling. It's not a view which might even consist of joined tables across different databases/servers?</p>
| <p>Does it work with just:</p>
<pre><code>SELECT t.foo, t.bar, t.problemcolumn
FROM problemtable t
WHERE t.problemcolumn = 'x'
</code></pre>
| 10,772 |
<p>What is a good way to set up a single container div with some border images surrounding it (in my case only on the left, bottom, and right sides)? I have it centered at the top of the page, overlapping everything else (so like that OSX-style slide-down dialog).</p>
<p>Here's the basic layout:</p>
<p><img src="http... | <p>You will probably see that the first 1000 chars will take almost no time opposed to the last 1000 chars. </p>
<p>I would assume that the time-consuming part is the actual copying of the large string into a new memory-area every time you add a char that is the tough work for your computer.</p>
<p>Your optimization ... | <p>Answer to the modified queston ("why does this non-obvious optimization work so well" and "is it true you shouldn't use + operator on strings"):</p>
<p>I'm not sure which non-obvious optimization you are talking about. But the answer to the second question, I think, covers all of the bases.</p>
<p>The way strings... | 35,774 |
<p>I used gdi+'s Image class to decode image files.
But I found if I open a Image, then use GetThumbnail()Method, It is really slow, especially for high resolution images.<p>
Is there any method for get a thumbnail faster?
<p>
Or is there any lib designed especially for fastly retriving thumbnails for most image format... | <p>Can you cache the thumbnails as small image files alongside the main file?</p>
| <p>As suggested by mgb, a cache is probably the solution: in Windows Explorer, when you switch to the move with image preview, it creates a system, hidden file named thumbs.db in the directory it displays. I think you can do something similar.</p>
<p>Or even better, force the creation and use such DB, since it is a st... | 28,745 |
<p>I need to be able to send encrypted data between a Ruby client and a Python server (and vice versa) and have been having trouble with the <a href="http://rubyforge.org/projects/ruby-aes" rel="nofollow noreferrer">ruby-aes</a> gem/library. The library is very easy to use but we've been having trouble passing data bet... | <p>Turns out what happened was that ruby-aes automatically pads data to fill up 16 chars and sticks a null character on the end of the final string as a delimiter. PyCrypto requires you to do multiples of 16 chars so that was how we figured out what ruby-aes was doing.</p>
| <p>Kind of depends on how you are transferring the encrypted data. It is possible that you are writing a file in one language and then trying to read it in from the other. Python (especially on Windows) requires that you specify binary mode for binary files. So in Python, assuming you want to decrypt there, you should ... | 23,911 |
<p>Suppose I have some XAML like this:</p>
<pre><code><Window.Resources>
<v:MyClass x:Key="whatever" Text="foo\nbar" />
</Window.Resources>
</code></pre>
<p>Obviously I want a newline character in the MyClass.Text property, but the XAML parser constructs the object with the literal string "foo\nba... | <p>You can use XML character escaping</p>
<pre><code><TextBlock Text="Hello&#13;World!"/>
</code></pre>
| <p>I would use the default TextBlock control as a reference here. In that control you do line breaks like so:</p>
<pre><code> <TextBlock>
Line 1
<LineBreak />
Line 2
</TextBlock>
</code></pre>
<p>You should be able to do something similar with your control by making th... | 14,074 |
<p><a href="http://twitter.com/codinghorror/statuses/901272685" rel="nofollow noreferrer">Source</a></p>
<blockquote>
<p>RegexOptions.IgnoreCase is more expensive than I would have thought (eg, should be barely measurable)</p>
</blockquote>
<p>Assuming that this applies to PHP, Python, Perl, Ruby etc as well as C# ... | <p>Yes, [A-Za-z] will be much faster than setting the <code>RegexOptions.IgnoreCase</code>, largely because of Unicode strings. But it's also much more limiting -- [A-Za-z] does <em>not</em> match accented international characters, it's literally the A-Za-z ASCII set and nothing more.</p>
<p>I don't know if you saw Tim... | <p>If you're concerned about this, it may be worthwhile to set the case to all upper or all lower before you check.<br>
For instance, in Perl:</p>
<pre><code>$x = "abbCCDGBAdgfabv";
(lc $x) =~ /bad/;
</code></pre>
<p>May in some cases be better than</p>
<pre><code>$x = "abbCCDGBAdgfabv";
$x =~ /bad/i;
</code></pre>
| 5,195 |
<p>I'm looking for an open-source web search library that does not use a search index file.
Do you know any?</p>
<p>Thanks,
Kenneth</p>
| <p>The original poster clarified in a comment to this reply that what he is looking for is essentially "greplike search but through HTTP", and mentioned that he is looking for something that uses little disk as he's working with an embedded system.</p>
<p>I am not aware of any related projects, but you might want to l... | <p>The original poster clarified in a comment to this reply that what he is looking for is essentially "greplike search but through HTTP", and mentioned that he is looking for something that uses little disk as he's working with an embedded system.</p>
<p>I am not aware of any related projects, but you might want to l... | 34,072 |
<p>I believe this question is asked on every private Beta... what should be the name of our chatroom?</p>
| <p><strong>The Hotbed.</strong></p>
<p>Colloquially, "hotbed" generally refers to a center of activity. Here, it will have a double meaning (referencing the hot bed of a 3D printer.</p>
| <h1>Filibusters!</h1>
<p>I've heard that from somewhere. It's a play on the word "filament"</p>
<p><sup>Oh, Just as a heads up, I can think of the weirdest names...</sup></p>
| 12 |
<p>Does anyone know of a good (preferably open source) library for dealing with the Modbus protocol? I have seen a few libraries, but I am looking for some people's personal experiences, not just the top ten Google hits. I figure there has to be at least one other person who deals with PLCs and automation hardware like... | <p>I have done a lot of communication with devices for the past few years, since I work for a home automation company, but we don't use Modbus. We do communication in a standard and open way using Web Services for Devices(WSD) which is also know as <a href="http://en.wikipedia.org/wiki/Devices_Profile_for_Web_Services... | <p>Have a look at the offering from Colway Solutions <a href="http://www.colwaysolutions.com" rel="nofollow">http://www.colwaysolutions.com</a>. They have a unique licensing scheme where you pay for each Modbus function code that you desire to use. Its not free but the pricing seems to be low. I also saw a few ports of... | 7,847 |
<p>I'm a beginning C++ programmer / network admin, but I figure I can learn how to do this if someone points me in the right direction. Most of the tutorials are demonstrated using old code that no longer works for some reason. </p>
<p>Since I'm on Linux, all I need is an explanation on how to write raw Berkeley socke... | <p>Start by reading <a href="http://beej.us/guide/bgnet/output/html/multipage/index.html" rel="noreferrer">Beej's guide on socket programming</a> . It will bring you up to speed on how to start writing network code. After that you should be able to pick up more and more information from reading the man pages.</p>
<p>M... | <p>There are tons of references on this (of course, Stevens' book comes to mind), but I found the <a href="http://beej.us/guide/bgnet/output/html/multipage/index.html" rel="nofollow noreferrer">Beej guide</a> to be incredibly useful for getting started. It's meaty enough that you can understand what's really happening... | 10,365 |
<p>I'm sure we've all seen it before...A code base that has been around for a year or two, and as features have been added and bugs fixed, we end up with pieces of code that aren't actually in use anymore. I'm wondering if there is a way (especially in VS.NET with or without a third-party tool) to search the codebase ... | <p><a href="http://msdn.microsoft.com/en-us/library/bb429476(VS.80).aspx" rel="noreferrer">FxCop</a> will warn you of methods where nothing calls them.</p>
| <p>The following tool can find orphan/unused code:</p>
<p><a href="http://www.mztools.com/index.aspx" rel="nofollow noreferrer">MZ-Tools</a></p>
| 3,585 |
<p>My question is similar to "<a href="https://stackoverflow.com/questions/156362/what-is-the-difference-between-include-and-extend-in-ruby">What is the difference between include and extend in Ruby?</a>".</p>
<p>What's the difference between <code>require</code> and <code>include</code> in Ruby? If I just want to us... | <blockquote>
<p><em>What's the difference between
"include" and "require" in Ruby?</em></p>
<p><strong>Answer:</strong></p>
<p>The include and require methods do
very different things.</p>
<p>The require method does what include
does in most other programming
languages: run another file. It als... | <p>Include
When you Include a module into your class as shown below, it’s as if you took the code defined within the module and inserted it within the class, where you ‘include’ it. It allows the ‘mixin’ behavior. It’s used to DRY up your code to avoid duplication, for instance, if there were multiple classes that woul... | 41,104 |
<p>Currently have the following mapping file:</p>
<pre><code><?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="NHibernateHelpers"
assembly="App_Code.NHibernateHelpers">
<class name="NHibernateHelpers.Fixture, App_Code" table="Fixture_List... | <p>Little kludgy -- but what about not converting the sp to functions, but creating new functions and using them as wrappers around the existing sp? You can add the Id to the function, and have it pass it to the stored procedure, grab the results of executing the sp, and pass them back.</p>
<p><a href="http://sqlblo... | <p>You may have to tweak the parameter a little, but it should work (Id matches up with the name of Fixture.Id):</p>
<pre><code><property name='MatchTime' formula='(EXEC GetMatchTime Id)'/>
</code></pre>
<p><a href="http://ayende.com/Blog/archive/2006/12/26/LocalizingNHibernateContextualParameters.aspx" rel="no... | 35,198 |
<p>For various reasons, we are writing a new business objects/data storage library. One of the requirements of this layer is to separate the logic of the business rules, and the actual data storage layer. </p>
<p>It is possible to have multiple data storage layers that implement access to the same object - for example... | <p>might i suggest another alternative, with possibly better decoupling: business objects <em>use</em> data objects, and data objects <em>implement</em> storage objects. This should keep the business rules in the business objects but without any dependence on the storage source or format, while allowing the data object... | <p>Clients should never deal with storage objects directly. They can deal with DTO's directly, but any object that has any logic for storage that is not wrapped in your business object should not be called by the client directly.</p>
| 14,473 |
<p>Anyone know how to programmatically mute the Windows XP Volume using C#?</p>
| <p>Declare this for P/Invoke:</p>
<pre><code>private const int APPCOMMAND_VOLUME_MUTE = 0x80000;
private const int WM_APPCOMMAND = 0x319;
[DllImport("user32.dll")]
public static extern IntPtr SendMessageW(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
</code></pre>
<p>And then use this line to mute/unmute the ... | <pre><code>CoreAudioDevice defaultPlaybackDevice = new
CoreAudioController().DefaultPlaybackDevice;
if (!defaultPlaybackDevice.IsMuted)
defaultPlaybackDevice.ToggleMute();
</code></pre>
| 18,616 |
<p>Say you have an entity like a vehicle that you are capturing detailed information about. The car you want to capture is painted red, black and white. The front tires are Bridgestone 275/35-18 and the rear tires are 325/30-19. And sometimes you can have just two tires (yes this would be considered a motorcycle which ... | <p>If it's a possibility for your app, you might want to look into <a href="http://incubator.apache.org/couchdb/" rel="nofollow noreferrer">couchdb</a>.</p>
| <p>You're describing a <a href="http://en.wikipedia.org/wiki/Star_schema" rel="nofollow noreferrer">Star Schema</a>. I think its fairly standard practice in your kind of case</p>
<p>Edit: Actually your schema is slightly modified from the Star Schema, you use the primary key of the fact table in each of the dimensio... | 9,147 |
<p>I'm trying out the recorder of the latest Selenium IDE Firefox extension on win32/ff3.</p>
<p>On one page, currently I have to hit Enter to go to the next page, but it's not on a submit button, it's captured manually. This is not picked up by the recorder. I know I can enter it manually myself after recording, bu... | <p>From the Selenium FAQ:</p>
<p><a href="http://wiki.openqa.org/display/SIDE/FAQ" rel="nofollow noreferrer">http://wiki.openqa.org/display/SIDE/FAQ</a></p>
<p>"Not every event will be recorded by Selenium IDE. Usually the ones that won't be recorded are those that involve complex HTML and/or AJAX. We hope to improve... | <p>Have you tried with a different browser? Does it happen the same in FF2, IE ?
Use the latest nightly version. I know that there are some problems with FF3.</p>
| 16,335 |
<p>I’m in the process of installing a BLTouch on a Velleman Vertex K8400. The board doesn’t have a dedicated servo pin, so I’ll assign one. No problem there.</p>
<p>The board only has a Z-min pin, so it’s my understanding that I’m supposed to unplug my Z-min cable and plug the BLTouch into the Z-min port.</p>
<p>My que... | <p><strong><em>Note</strong>: The question has changed after posting this answer. This answer answered the previous question, but is now out-of-date with respect to how the question has changed; I'll update it later, as it is possible what is asked now.</em></p>
<hr>
<p>You can change the Z-min and the Z-max pin assi... | <p><strong><em>Note</strong>: The question has changed after posting this answer. This answer answered the previous question, but is now out-of-date with respect to how the question has changed; I'll update it later, as it is possible what is asked now.</em></p>
<hr>
<p>You can change the Z-min and the Z-max pin assi... | 1,304 |
<p>I am probably doing something wrong -- but cant figure why.
I have a DateTime field in my DB keeping a UTC time </p>
<p>My server is in the US, and the browser is in Europe. </p>
<p>The PageLoad Code is as follow:</p>
<pre><code>DateTime t = DateTime.SpecifyKind((DateTime)rdr["startTime"], DateTimeKind.Utc);
labe... | <p>One technique is to detect the client timezone offset (in minutes) using JavaScript on the client browser:</p>
<pre><code>alert((new Date()).getTimezoneOffset());
</code></pre>
<p>This can then be sent back to the server and stored in the session, or a cookie, and used to offset the UTC dates displayed to them. Al... | <p>As <a href="https://stackoverflow.com/questions/301354/why-localtime-displays-server-time-and-not-browser-time#301385">some wrote</a>, the code is being executed on the server - so it makes sense that the timezone which is applied is the one which is local to the server.</p>
<p>As well as his suggestion of sending ... | 38,651 |
<p>When attempting to print using the SSRS Viewer Web Part in SharePoint I get the following error.</p>
<blockquote>
<p>An error occured during printing. (0x8007F303)</p>
</blockquote>
<p>The settings we are using in this box (production) are exactly the same as the settings in testing where this works perfectly fi... | <p>I found some ideas by Googling.</p>
<ul>
<li><a href="http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=307315" rel="nofollow noreferrer">Someone had issue with "SSRS server configured for Sharepoint Integrated mode with Cumulative update package 3 for SQL Server 2005 Service Pack 2" but ... | <p>You may have a custom authentication in use for Reporting Services defined in your
web.config. Check if that is the case, remove the custom authentication and try again.</p>
| 9,453 |
<p>I have a combobox at the top of a form that loads editable data into fields below. If the user has made changes, but not saved, and tries to select a different option from the combobox, I want to warn them and give them a chance to cancel or save.</p>
<p>I am in need of a "BeforeValueChange" event with a cancelabl... | <p>Save the ComboBox's SelectedIndex when to box if first entered, and then restore it's value when you need to cancel the change. </p>
<pre><code>cbx_Example.Enter += cbx_Example_Enter;
cbx_Example.SelectionChangeCommitted += cbx_Example_SelectionChangeCommitted;
...
private int prevExampleIndex = 0;
private void c... | <p>You could use a <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.imessagefilter.aspx" rel="nofollow noreferrer">message filter</a> to intercept clicks and key presses, which would allow you to prevent the combo box's normal behaviour. But I think you'd be better off disabling the combo box when... | 40,581 |
<p>When a form loads, the code needs to do things like setup datagrids, comboboxes, set the title, etc. I've tended to always use the load event rather than the new (constructor). Are there any guidelines for which one is best for which activities?</p>
| <p>A call to InitializeComponent is automatically inserted in the constructor of your form/page. InitializeComponent is the auto-generated method that </p>
<ul>
<li>creates the various UI elements on your winform / XAML page</li>
<li>initializes their properties with the values stored in the resource file</li>
</ul>
... | <p>Basically you want your constructor to be as light-weight as possible. I try to put most things in the Load event handler as the UI elements have been created and are usable at this time. However, I usually instantiate class objects etc. in the constructor as it is actually part of constructing the object. Someti... | 33,116 |
<p>I was wondering which one should I consider if I need the software to be used on both platforms, WIN and Linux and why?</p>
| <p>Packaging GTK and its dependencies on Windows is a full-time project in itself. Qt is much more easily distributed since it has no dependencies that do not come with Windows.</p>
<p>Qt has been cross platform from the start. GTK has not always been cross platform. Such fundamental decisions shape the overall design... | <p>I recommend to use Qt because:</p>
<ul>
<li>It's cross-platform and and covers wide range of operating systems (including mobile)</li>
<li>It is opensource and has a fast speed in getting better</li>
<li>It has the a nice GUI designer and a very capable IDE (Qt Creator)</li>
<li>The API design is excellent and easy... | 24,330 |
<p>(EDIT: This question is now outdated for my particular issue, as Google Code supports git now and I've converted Protocol Buffers to Mercurial anyway. However, it's still of general interest, IMO.)</p>
<p>My <a href="http://github.com/jskeet/dotnet-protobufs/tree/master" rel="noreferrer">C# Protocol Buffers Port</a... | <p>If you're thinking that you'll really be the <a href="https://stackoverflow.com/questions/3180/anyone-soloing-using-fogbugz#3274">only developer</a>, Fogbugz will help you keep your sanity. Fogbugz is a great product, It builds focused communications and can turn anything into a case (issue). It does all that as wel... | <p>Have you considered CodePlex?</p>
| 40,486 |
<p>When trying to enter a SQL query with parameters using the Oracle OLE DB provider I get the following error:</p>
<blockquote>
<p>Parameters cannot be extracted from the SQL command. The provider might not help to parse parameter information from the command. In that case, use the "SQL command from variable" acces... | <p>To expand on the link given in the question:</p>
<ol>
<li>Create a package variable</li>
<li>Double click on the package variable name. (This allows you to access the properties of the variable)</li>
<li>Set the property 'EvaluateAsExpression' to true</li>
<li>Enter the query in the expression builder.</li>
<li>Set... | <p>If You use Data Flow Task and use OLE DB Source, and you need parameterize your Query : </p>
<ol>
<li>Create Variable to save "Full" of Query statement : Right Click on blank area outside the package - and Click Variables : </li>
</ol>
<p><a href="https://i.stack.imgur.com/yLvNJ.jpg" rel="nofollow noreferrer"><img... | 8,290 |
<p>OK, if anyone could help me with this I'd be much appreciative. If you copy and paste the following and open up in IE or Firefox</p>
<pre><code><div style="border: solid 1px navy; float: left;">
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3<... | <p>If you want the blue box to be beside the list, you need to float it as well:</p>
<pre><code><div style="border: solid 1px navy; float: left;">
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<li>Item 4</li>
<li>Item 5</li... | <p>You want the second div to float next to the first? Then you add <code>float:left</code> to the second div.</p>
<p><strong>Do not</strong> create another div purely for clearing, this is terribly unsemantic.</p>
<p>EDIT: <code>overflow: auto</code> does not work for IE, you need to give the div hasLayour in that c... | 46,532 |
<p>I always use unix timestamps for everything, but am wondering if there is a better way.</p>
<p>What do you use to store timestamps and why?</p>
| <p>However you choose to store a timestamp, it is important to avoid regional interpretation problems and time offset problems. A Unix timestamp is interpreted the same regardless of region, and is calculated from the same point in time regardless of time zone - these are good things.</p>
<p>Beware storing timestamps ... | <p>A timestamp is bascially:</p>
<ul>
<li>a distinct point in time</li>
</ul>
<p>And as a point in time has an endless resolution, the important thing on choosing a timestamp format is: has it enough resolution?</p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Unix_time" rel="nofollow noreferrer">Unix time</a> cou... | 21,542 |
<p>I can't seem to find any GUI framework's for as3 that are as good as any the applications I already see out on the web; Is this something most people code themselves or am I missing something in flash itself?</p>
<p>I'm looking for dialogs/windows, buttons, text boxes, combos, drop downs, menus, etc etc and the abi... | <p><strong>Short answer:</strong> Here is the <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/controls/package-detail.html" rel="nofollow noreferrer">list of base controls</a>.</p>
<p><strong>Long answer:</strong> Yes, there are many controls (such as <a href="http://livedocs.adobe.com/flash/9.0/... | <p>There is also a framework I have been working on called LiquidGear that has taken a lot of tweaks and tips and workarounds and combined them into AS3 elements. It uses the same structure as JQuery.</p>
<p>Using the elements in an MVC framework (the Shell) or individually, you can add an image, for example in just t... | 33,273 |
<p>Imagine the scene, you're updating some legacy Sybase code and come across a cursor. The stored procedure builds up a result set in a #temporary table which is all ready to be returned except that one of columns isn't terribly human readable, it's an alphanumeric code.</p>
<p>What we need to do, is figure out the p... | <p>You have to have a XRef table if you want to take out the cursor. Assuming you know the 100 distinct lookup values (and that they're static) it's simple to generate one by calling proc_code_xref 100 times and inserting the results into a table</p>
| <p>They say, that if you must use cursor, then, you must have done something wrong ;-) here's solution without cursor:</p>
<pre><code>declare @lookup_code char(8)
select distinct lookup_code
into #lookup_codes
from #workinprogress
while 1=1
begin
select @lookup_code = lookup_code from #lookup_codes
if @@row... | 3,538 |
<p>In this <a href="https://stackoverflow.com/questions/275545/does-aspnet-mvc-framework-support-asynchronous-page-execution">question & answer</a>, I found one way to make ASP.NET MVC support asynchronous processing. However, I cannot make it work.</p>
<p>Basically, the idea is to create a new implementation of I... | <p>After hours of hassle with the code, I found out the issue.</p>
<p>In my Visual Studio 2008, when I press Ctrl+F5, the Application Development Server is launched and IE is popped up to access "<a href="http://localhost:3573/" rel="nofollow noreferrer">http://localhost:3573/</a>". In this case, the sync API <strong>... | <p>I have tried to do this in the past, I manage to either get the view to render and then all the async tasks would finish. Or the async tasks to finish but the view would not render.</p>
<p>I created a RouteCollectionExtensions based on the original MVC code. In my AsyncMvcHandler, I had an empty method (no except... | 34,923 |
<p>I'm trying to make <a href="https://stackoverflow.com/questions/298491/how-do-i-receive-clicks-outside-a-forms-window">a window that closes when you click outside it</a>, and at the moment I'm looking into doing that by handling the WndProc function.</p>
<p>None of the messages I'm getting so far seem useful, but t... | <p>0x0118: WM_SYSTIMER (undocumented) used for caret blinks</p>
<p>The other three should be application defined messages (anything in the range 0xC000 to 0xFFFF) so you won't find those defined anywhere. </p>
| <p>An easy way would be to just capture the mouse. When you have the mouse captured you get one click event outside your window, then capturing is turned off.</p>
<p>A harder way would be to set a low-level mouse windows hook. To do a global hook, you'll have to put your hook code in an unmanaged DLL.</p>
<p>A <em>... | 38,236 |
<p>I have a JFrame with a menu bar and a canvas covering all the remaining surface. When I click on the menu bar, the menu opens <strong>behind</strong> the Canvas and I can't see it. Has anyone experienced this? Other than resizing the Canvas (which I am reluctant to do) is there any solution?</p>
<p>Thanks,<br/>
Vla... | <p>You're experiencing heavyweight vs. lightweight issues.</p>
<p>The quick fix: </p>
<pre><code>// Call this sometime before you use your menus
JPopupMenu.setDefaultLightWeightPopupEnabled(false)
</code></pre>
<p><a href="http://java.sun.com/products/jfc/tsc/articles/mixing/index.html" rel="noreferrer">Heavyweight... | <p>That happened to me when i resized a Canvas that is on a JFrame.
I just had to call </p>
<blockquote>
<p>validate()
on the JFrame after the resize.</p>
</blockquote>
<p>Good luck!</p>
| 33,732 |
<p>I have a table that has a <code>processed_timestamp</code> column -- if a record has been processed then that field contains the datetime it was processed, otherwise it is null.</p>
<p>I want to write a query that returns two rows:</p>
<pre><code>NULL xx -- count of records with null timestamps
NOT NULL ... | <p>In MySQL you could do something like</p>
<pre><code>SELECT
IF(ISNULL(processed_timestamp), 'NULL', 'NOT NULL') as myfield,
COUNT(*)
FROM mytable
GROUP BY myfield
</code></pre>
| <p>I personally like Pax's solution, but if you absolutely require only one row returned (as I had recently), In MS SQL Server 2005/2008 you can "stack" the two queries using a CTE</p>
<pre><code>with NullRows (countOf)
AS
(
SELECT count(*)
FORM table
WHERE [processed_timestamp] IS NOT NULL
)
SELECT coun... | 29,642 |
<pre><code><?php
/**
* My codebase is littered with the same conditionals over and over
* again. I'm trying to refactor using inheritance and the Factory
* pattern and I've had some success but I'm now stuck.
*
* I'm stuck because I want to derive a new class from the one
* returned by the Factory. But I can... | <p>If the IndexView code really is the same then you don't need inheritance, but composition. Add, in your base LayoutView class, an instance of IndexView that then you'll be able to call from each *LayoutView.</p>
<p>Inheritance is due only when the relationship between objects is is-a. I deduce that an IndexView is ... | <p>Just pass the template as a parameter to the subviews you'll compose. I don't think that'd be evil in this case. Although if it's a standard framework you might be better asking in their forums, because they might have a functionality we are unaware of for this case (it usually happens)</p>
<p>You could have someth... | 30,696 |
<p>I am having an issue with a custom font that my company has created. When I set the Font property of a control in Visual Studio 2008 to our font, I receive the following error:</p>
<blockquote>
<p>Only TrueType fonts are supported.
This is not a TrueType font.</p>
</blockquote>
<p>The font selection dialog s... | <p>You really need to tell more about your custom font. It sounds like it could be an OpenType font that Server 2003 wouldn't know how to handle, while XP and Vista do. OpenType fonts on Windows usually have the extension .ttf, so you could mistake it for a TrueType font at first glance, but Windows font viewer shoul... | <p>I have a similar but different problem.
In the field we will have XP but no MS Office and probably no "East Asian" font pack installed (a separate search didn't tell me exactly what is in that option). Our goal is to be able to display Asian characters, so I was looking for a solution.
I thought I would try a free U... | 48,597 |
<p>I have written an Eclpise plugin (an Error Parser for the CDT), and it works just fine in the debugger version of eclipse. However I cannot for the life of me figure out how to install the plugin into eclipse. I can export the plugin as a jar file, and it seems to export without errors. I put the plugin jar file ... | <p>Putting the plugin into the eclipse/plugins folder should work. If it doesn't, that usually means Eclipse has cached the plugins configuration for performance reasons. You can force Eclipse to rescan the plugins directory for changes by starting it with the <strong>-clean</strong> command-line argument.</p>
<p>The ... | <p>The reason why my plugin was not being loaded was that my plugin had features of CDT and CDT Development SDK was not installed in eclipse.</p>
<p>Once I installed the CDT Development SDK tools, my plugin was loaded automatically.</p>
| 33,473 |
<p>Using the code below, I am returning an nvarchar field from <em>MS SQL 2005</em> and keep getting a System.InvalidCastException.</p>
<pre><code>vo.PlacementID = dr.IsDBNull(0) ? null : dr.GetString(0);
</code></pre>
<p>The vo.PlacementID variable is of type String so there shouldn't be a problem.
The values I am t... | <p>If you read the exception again it gives you a clue as to the problem:</p>
<blockquote>
<p>System.<strong>InvalidCastException</strong>:
<strong><em>Unable to cast object of type 'System.Int32' to type
'System.String'</em></strong>. at
System.Data.SqlClient.SqlBuffer.get_String()
at
System.Data.SqlClien... | <p>The <code>InvalidCastException</code> isn't raised because of the type incompatibility between the <code>PlacementID</code> property and <code>string</code>. If that was the case, you'd get a compile-time error. The problem is the first field in the result set is not a <code>string</code>, it's something else.</p>
| 49,402 |
<p>I don't want to use Mac or Windows at work but I have a lot of work in Photoshop when I have to create an HTML page from a Photoshop design.</p>
<p>What is the best way to use Photoshop CS3 in Linux, Wine, virtualization, ... ???</p>
| <p>Wine has been a bit flaky with me before when going with Photoshop (keyboard shortcuts behaved weird) and it doesn't support latest versions.</p>
<p>Using virtualization is working like a charm though, and you can go the easy way with software like VirtualBox. It's easy to use, there's plenty of tutorials on the we... | <p>I hate to say it, but you might just have to suck it up and use Windows or OSX if you want to use Photoshop. As already said, Wine doesn't work with CS3 and after giving Photoshop CS3 a try using VirtualBox from Fedora Core it was a less than enjoyable experience. Then again, if you're on a reasonably powerful machi... | 35,821 |
<p>Java has some very good open source static analysis tools such as <a href="http://findbugs.sf.net/" rel="nofollow noreferrer">FindBugs</a>, <a href="http://checkstyle.sf.net/" rel="nofollow noreferrer">Checkstyle</a> and <a href="http://pmd.sf.net/" rel="nofollow noreferrer">PMD</a>. Those tools are easy to use, ve... | <p>Concerning the GNU compiler, gcc has already a builtin option that enables additional <em>warning</em> to those of -Wall. The option is <strong>-Weffc++</strong> and it's about the violations of some guidelines of <em>Scott Meyers</em> published in his books "<em>Effective and More Effective C++</em>".</p>
<p>In pa... | <p>Doxygen does some control flow analysis and generates graphs. Those may not be what you're looking for, but I've foudn them useful to look at.</p>
| 17,099 |
<p>I'm trying to run a freshly created ASP.NET Website using C#, however when I do so it launches FireFox and attempts to connect to <a href="http://localhost:1295/WebSite1/Default.aspx" rel="nofollow noreferrer">http://localhost:1295/WebSite1/Default.aspx</a> (for example), but after about 10-15 seconds it displays a ... | <p>When you launch the application, a little info mark appears at the right bottom of your screen telling you that the local web server was started and on wich port. You should compare that port to the one that appears in your browser. If they are different, an anti-virus could be responsible for that problem.
Another ... | <p>"I had a similar problem on Windows 7 RC and Visual Studio 2008 SP1. Changing localhost to 127.0.0.1 helped. Similar to the hosts file solution, but doesn't require the file editing, you just need to change the project startup url."</p>
<p>This solution is working fine....... </p>
| 36,368 |
<ul>
<li>What are the pros and cons of LINQ (Language-Integrated Query)?</li>
<li>What are the best and worst cases in which to use LINQ?</li>
<li>How have you benefitted or not benefitted from using LINQ?</li>
<li>Which data sources benefit the least and the most from LINQ?</li>
</ul>
| <p>I'm a massive fan of LINQ - although it needs to be kept in perspective, and not treated as a silver bullet.</p>
<p>Pros:</p>
<ul>
<li>Declarative approach makes queries easier to understand and more compact</li>
<li>Extensibility and expression trees allow mostly consistent querying of multiple sources</li>
<li>E... | <p>I've used LINQ mainly to work on collection of objects. LINQ works wonderfully with object collections, removing the need of predicate functions in most cases.</p>
<p>I tried using LINQ to SQL a little while ago, but found it underpowered and clumsy. In particular I couldn't bring myself to use the SQL Database cla... | 34,129 |
<p>Is there some nice documentation for Windows batch scripting I can download and refer to while offline?</p>
| <p>I can recommend:</p>
<blockquote>
<p><a href="http://ss64.com/nt/" rel="noreferrer">An A-Z Index of the Windows XP command line</a>. </p>
</blockquote>
<p>It is more thorough than <code>help</code> and most importantly it provides several examples for each command. Example: <a href="http://ss64.com/nt/find.html"... | <p>Google hits, for "windows batch scripting documentation" - first page:</p>
<ul>
<li><a href="http://labmice.techtarget.com/scripting/batchfiles.htm" rel="nofollow noreferrer">http://labmice.techtarget.com/scripting/batchfiles.htm</a></li>
<li><a href="http://www.allenware.com/icsw/icswidx.htm" rel="nofollow norefer... | 34,116 |
<p>I have a series of ASCII flat files coming in from a mainframe to be processed by a C# application. A new feed has been introduced with a Packed Decimal (COMP-3) field, which needs to be converted to a numerical value.</p>
<p>The files are being transferred via FTP, using ASCII transfer mode. I am concerned that th... | <p>First of all you must eliminate the end of line (EOL) translation problems that will be caused by ASCII transfer mode. You are absolutely right to be concerned about data corruption when the BCD values happen to correspond to EOL characters. The worst aspect of this problem is that it will occur rarely and unexpec... | <p>Some useful links for EBCDIC translation:</p>
<p>Translation table - useful to do check some of the values in the packed decimal fields:
<a href="http://www.simotime.com/asc2ebc1.htm" rel="nofollow noreferrer">http://www.simotime.com/asc2ebc1.htm</a></p>
<p>List of code pages in msdn:<br>
<a href="http://msdn.micr... | 17,273 |
<p>The typical ConfigParser generated file looks like:</p>
<pre><code>[Section]
bar=foo
[Section 2]
bar2= baz
</code></pre>
<p>Now, is there a way to index lists like, for instance:</p>
<pre><code>[Section 3]
barList={
item1,
item2
}
</code></pre>
<p>Related question: <a href="https://stackoverflow.com/ques... | <p>There is nothing stopping you from packing the list into a delimited string and then unpacking it once you get the string from the config. If you did it this way your config section would look like:</p>
<pre><code>[Section 3]
barList=item1,item2
</code></pre>
<p>It's not pretty but it's functional for most simple... | <p><code>json.loads</code> & <code>ast.literal_eval</code> seems to be working but simple list within config is treating each character as byte so returning even square bracket....</p>
<p>meaning if config has <code>fieldvalue = [1,2,3,4,5]</code></p>
<p>then <code>config.read(*.cfg)</code>
<code>config['fieldVal... | 43,548 |
<p>From what I understand, in TDD you have to write a failing test first, then write the code to make it pass, then refactor. But what if your code already accounts for the situation you want to test?</p>
<p>For example, lets say I'm TDD'ing a sorting algorithm (this is just hypothetical). I might write unit tests for... | <p>There are two reasons for writing failing tests first and then making them run;</p>
<p>The first is to check if the test is actually testing what you write it for. You first check if it fails, you change the code to make the test run then you check if it runs. It seems stupid but I've had several occasions where I ... | <p>I have run into this situation many times. Whilst I recommend and try to use TDD, sometimes it breaks the flow too much to stop and write tests.</p>
<p>I have a two-step solution:</p>
<ol>
<li>Once you have your working code and your non-failing test, deliberately insert a change into the code to cause the test to... | 47,093 |
<p>I'm looking for any way that I can improve the selector performance of a jQuery call. Specifically things like this:</p>
<p>Is <code>$("div.myclass")</code> faster than <code>$(".myclass")</code></p>
<p>I would think it might be, but I don't know if jQuery is smart enough to limit the search by tag name first, et... | <p>There is no doubt that <strong>filtering by tag name first is much faster</strong> than filtering by classname.</p>
<p>This will be the case until all browsers implement getElementsByClassName natively, as is the case with getElementsByTagName.</p>
| <p>I've been on some of the jQuery mailing lists and from what I've read there, they most likely filter by tag name then class name (or vice versa if it was faster). They are obsessive about speed and would use anything to gain a smidgen of performance.</p>
<p>I really wouldn't worry about it too much anyway unless yo... | 6,826 |
<p>I realize you can script Microsoft Office apps, but I'm looking for something more general that I can apply to other apps, such as Adobe Acrobat, web browsers and other apps with no scripting ability.</p>
<p>I've used <a href="http://www.autoitscript.com/autoit3/" rel="nofollow noreferrer">AutoIt</a> but it's a bit... | <p>I recommend <a href="http://www.autohotkey.com/" rel="nofollow noreferrer">AutoHotKey</a>. Its syntax is not pretty, but most of the times you don't have to concoct your own scripts, because its community is so large and well organized. Even if you do, the documentation is extensive and good and the forums will answ... | <p>I love AutoHotkey (small k...) too, but beside its odd syntax, it has the same lack of debugging tools...
Basically, that's "show msgbox alerts, send strings to file or debugview, trace". Which is OK for most cases, since you rarely write long and complex applications with these tools.</p>
<p>In both tools, and pro... | 12,585 |
<p>In many languages there's a pair of functions, <code>chr()</code> and <code>ord()</code>, which convert between numbers and character values. In some languages, <code>ord()</code> is called <code>asc()</code>.</p>
<p>Ruby has <code>Integer#chr</code>, which works great:</p>
<pre><code>>> 65.chr
A
</code></pr... | <p>If String#ord didn't exist in 1.9, it does in 2.0:</p>
<pre><code>"A".ord #=> 65
</code></pre>
| <p>I'm writing code for 1.8.6 and 1.9.3 and I couldn't get any of these solutions to work in both environments :(</p>
<p>However, I came across another solution:
<a href="http://smajnr.net/2009/12/ruby-1-8-nomethoderror-undefined-method-ord-for-string.html" rel="nofollow">http://smajnr.net/2009/12/ruby-1-8-nomethoderr... | 39,777 |
<p>I want to know where the solution/project is stored on my hard drive.</p>
<p>I would have thought right clicking on the project from within Visual Studio would have the information on where it is stored on my hard drive, but it doesn't.</p>
| <p>Click on the project itself in the solution explorer and in the properties window it lists the project folder.</p>
<p>Only works if you've actually saved the project though. I.e. newly created projects don't have a location.</p>
| <p>One way is to select the project in the solution explorer and then click File / Save As or press F4 and view the 'Project Folder' property.</p>
| 48,151 |
<p>As the question says, how do I set the value of a DropDownList control using jQuery?</p>
| <pre><code>$("#mydropdownlist").val("thevalue");
</code></pre>
<p>just make sure the value in the options tags matches the value in the val method.</p>
| <p><strong>In case when you load all <code><options ....></options></code> by Ajax call</strong> <br>
Follow these step to do this.</p>
<p>1). Create a separate method for set value of drop-down <br>
For Ex:</p>
<pre><code>function set_ip_base_country(countryCode)
$('#country').val(countryCode)
}
</c... | 37,337 |
<p>Well basically I have this script that takes a long time to execute and occasionally times out and leaves semi-complete data floating around my database. (Yes I know in a perfect world I would fix THAT instead of implementing commits and rollbacks but I am forced to not do that)</p>
<p>Here is my basic code (dumbed... | <p>Take a look at <a href="http://www.phpro.org/tutorials/Introduction-to-PHP-PDO.html#11" rel="noreferrer">this tutorial</a> on transactions with PDO.</p>
<p>Basically wrap the long running code in:</p>
<pre><code>$dbh->beginTransaction();
...
$dbh->commit();
</code></pre>
<p>And <a href="http://usphp.com/man... | <pre><code><?php
//This may help someone....This code commit the transactions
//only if both queries insert and update successfully runs
$mysqli=new mysqli("localhost","user_name","password","db_name");
if(mysqli_connect_errno())
{
echo "Connection failed: ".mysqli_connect_error();
}
else
{
$mysqli->aut... | 42,706 |
<p>I am having an ajax tab control in my page each tab contains some 15 controls. My tab container has some 10 tabs.</p>
<p>Its take some time load in my web page. Please let me know how to reduce the page loading time. or anyother suggestions</p>
<p>Since the number of database calls are less.</p>
<p>The controls a... | <p>No, it does not.</p>
<p>Well, if the user arrived to the previous page by POST (as opposed to GET) and reposts the page, the server is going to process the request again. It won't delete the data in the session though. It is possible to achieve this behaviour with some code, but that's not how it works by default.<... | <p>No. It just causes the browser to either send again what it just sent to the server, or it will cause the browser to fetch the page from its cache, without interacting with the server at all.</p>
| 32,266 |
<p>I've got a large number of integer arrays. Each one has a few thousand integers in it, and each integer is generally the same as the one before it or is different by only a single bit or two. I'd like to shrink each array down as small as possible to reduce my disk IO. </p>
<p>Zlib shrinks it to about 25% of its... | <p>If most of the integers really are the same as the previous, and the inter-symbol difference can usually be expressed as a single bit flip, this sounds like a job for XOR.</p>
<p>Take an input stream like:</p>
<pre><code>1101
1101
1110
1110
0110
</code></pre>
<p>and output:</p>
<pre><code>1101
0000
0010
0000
100... | <p>Did you try bzip2 for this?
<a href="http://bzip.org/" rel="nofollow noreferrer">http://bzip.org/</a></p>
<p>It's always worked better than zlib for me.</p>
| 34,544 |
<p>Is there some way to hide the browser toolbar / statusbar etc in current window via javascript? I know I can do it in a popup with <code>window.open()</code> but I need to do it this way. Is it possible at all?</p>
| <p>As per the previous answer, this isn't possible to my knowledge and is best avoided anyway. Even if a solution can be found, bear in mind that most browsers these days allow the user to prevent Javascript from interfering with their browser settings and window chrome, even when using window.open. So you've got absol... | <p>No. This would be a massive security hole if it were possible... not to mention annoying. </p>
<p>My browser wont even let you do this in popups... which can be annoying aswell!</p>
| 13,879 |
<p>i'm wanting to generate a random salt value and put it into the Application state.</p>
<p>Now, i'm using a web farm, so the Application state will be different per machine. I don't want to purchase distributed state farm apps, either.</p>
<p>So .. what are some solutions for this? I thought i could hard-code it in... | <p>If I understand correctly, you want the machines to share a value, and you don't want the value to be the same forever. Ideally you'd prefer not to store it.</p>
<p>So, have the "first" machine generate a random value at startup, (using whatever entropy it can such as /dev/random. If you don't need a secure value, ... | <p>Here's a fun/interesting way: </p>
<p>At the start of each day, i.e., after 00:00, lookup twitter or digg or friendfeed or anything that has frequently changing data for a detail just before/at 00:00. All the machines would get this same data AND it's guaranteed to be changing. In order to make it a secret, combine... | 42,588 |
<p>I'm trying to use <a href="http://trac.videolan.org/jvlc/" rel="nofollow noreferrer">JVLC</a> but I can't seem to get it work. I've downloaded the jar, I installed <a href="http://www.videolan.org/vlc/" rel="nofollow noreferrer">VLC</a> and passed the -D argument to the JVM telling it where VLC is installed. I also ... | <p>My favorite is the command <code>.cmdtree <file></code> (undocumented, but referenced in previous release notes). This can assist in bringing up another window (that can be docked) to display helpful or commonly used commands. This can help make the user much more productive using the tool.</p>
<p>Initially t... | <p>Do <strong>not</strong> use WinDbg's <code>.heap -stat</code> command. It will sometimes give you incorrect output. Instead, use DebugDiags memory reporting.</p>
<p>Having the correct numbers, you can then use WinDbg's <code>.heap -flt ...</code> command.</p>
| 15,522 |
<p>I wrote the wrong thing in a commit message.</p>
<p>How can I change the message? The commit has not been pushed yet.</p>
| <h1>Amending the most recent commit message</h1>
<pre class="lang-sh prettyprint-override"><code>git commit --amend
</code></pre>
<p>will open your editor, allowing you to change the commit message of the most recent commit. Additionally, you can set the commit message directly in the command line with:</p>
<pre class=... | <p>I have added the aliases <code>reci</code> and <code>recm</code> for <code>recommit (amend)</code> it. Now I can do it with <code>git recm</code> or <code>git recm -m</code>:</p>
<pre><code>$ vim ~/.gitconfig
[alias]
......
cm = commit
reci = commit --amend
recm = commit --amend
......
</code>... | 21,602 |
<p>In T-SQL, SPACE() function is used to add spaces to a string. For e.g. </p>
<pre><code>@s = 'He' + space(5) + 'llo'
</code></pre>
<p>Output</p>
<pre><code>He llo
</code></pre>
<p>So is there any function in PL/SQL that is equivalent to SPACE()?</p>
<p>Thank you.</p>
| <p>You can use RPAD or LPAD functions</p>
<pre><code>select 'He' || rpad(' ',5,' ') || 'llo'
from dual;
/
</code></pre>
<p>or in PL/SQL it would be:</p>
<pre><code>declare
x varchar2(20);
begin
x:= 'He' || rpad(' ',5,' ') || 'llo';
end;
/
</code></pre>
| <p>In Oracle, you can emulate the <code>space()</code> function with:</p>
<pre><code>rpad(' ',n,' ')
</code></pre>
<p>Where <code>n</code> is one less than the total length of the string of spaces you want.</p>
<p>E.g. for a string of 40 spaces:</p>
<pre><code>select rpad(' ',39,' ') as "40 spaces" from dual
</code... | 40,389 |
<p>I have a table inside a div. I want the table to occupy the entire width of the div tag.</p>
<p>In the CSS, I've set the <code>width</code> of the table to <code>100%</code>. Unfortunately, when the div has some <code>margin</code> on it, the table ends up wider than the div it's in.</p>
<p>I need to support IE6 ... | <p>Add the below CSS to your <code><table></code>:</p>
<pre><code>table-layout: fixed;
width: 100%;
</code></pre>
| <p>That is the big problem with the way CSS treats width property and the reason Microsoft implemented box model differently at first. Microsoft lost, and now it's either width or margin/padding/border for an element. </p>
<p>Situation may change to better in CSS3 with <a href="http://www.css3.info/preview/box-sizing/... | 10,024 |
<p>With JSR 311 and its implementations we have a powerful standard for exposing Java objects via REST. However on the client side there seems to be something missing that is comparable to Apache Axis for SOAP - something that hides the web service and marshals the data transparently back to Java objects.</p>
<p>How d... | <p>This is an old question (2008) so there are many more options now than there were then:</p>
<ul>
<li><strong>Apache CXF</strong> has three different <a href="http://cxf.apache.org/docs/jax-rs-client-api.html" rel="noreferrer">REST Client options</a></li>
<li><strong><a href="https://jersey.java.net/" rel="noreferre... | <p>Try looking at http-rest-client</p>
<p><a href="https://github.com/g00dnatur3/http-rest-client" rel="nofollow">https://github.com/g00dnatur3/http-rest-client</a></p>
<p>Here is a simple example:</p>
<pre><code>RestClient client = RestClient.builder().build();
String geocoderUrl = "http://maps.googleapis.com/maps/... | 27,294 |
<p>Does anyone know a good (preferably open source and cross platform) tool to allow simple visualization of mysql databases? I just need a tool I can quickly point at a database and it'll show basic table structure and field types, etc. Nothing too advanced or crazy. </p>
| <p><a href="http://dev.mysql.com/workbench/" rel="noreferrer">MySQL Workbench</a> runs on Windows and Linux. The commercial version will let you reverse engineer and edit the stucture of a live database, with the free one you have first to dump the structure to a file. Its ancestor <a href="http://www.fabforce.net/dbde... | <p>Sqlyog community should be fine</p>
| 47,472 |
<p>This is a problem I've had on my mind for a long time. Being the son of a teacher and a programmer, it occurred to me early on... but I still haven't found a solution for it.</p>
<p>So this is the problem. One needs to create a time schedule for a school, using some constraints. These are generally divided in two c... | <p>I am one of the developer that works on the scheduler part of a student information system.
During our original approach of the scheduling problem, we researched genetic algorithms to solve constraint satisfaction problems, and even though we were successful initially, we realized that there was a less complicated s... | <p>Yes, I think this is NP complete - or at least to find the optimal solution is NP complete. </p>
<p>I worked on a similar problem in college when i told a friend's father (who was a teacher) that I could solve his scheduling problems for him if he did not find a suitable program for it (this was back in 1990 or so... | 25,857 |
<p>I'm looking for the equivalent in Qt to <code>GetTickCount()</code></p>
<p>Something that will allow me to measure the time it takes for a segment of code to run as in:</p>
<pre><code>uint start = GetTickCount();
// do something..
uint timeItTook = GetTickCount() - start;
</code></pre>
<p>any suggestions?</p>
| <p>How about <a href="http://doc.qt.io/qt-5/qtime.html" rel="noreferrer"><code>QTime</code></a>? Depending on your platform it should have 1 millisecond accuracy. Code would look something like this:</p>
<pre><code>QTime myTimer;
myTimer.start();
// do something..
int nMilliseconds = myTimer.elapsed();
</code></pre>... | <p>If you want to use <a href="http://doc.qt.io/qt-5/qelapsedtimer.html" rel="nofollow"><code>QElapsedTimer</code></a>, you should consider the overhead of this class.</p>
<p>For example, the following code run on my machine:</p>
<pre><code>static qint64 time = 0;
static int count = 0;
QElapsedTimer et;
et.start();
t... | 30,338 |
<p>How do you render primitives as wireframes in OpenGL?</p>
| <pre><code>glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
</code></pre>
<p>to switch on,</p>
<pre><code>glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
</code></pre>
<p>to go back to normal.</p>
<p>Note that things like texture-mapping and lighting will still be applied to the wireframe lines if they're enabled, which c... | <p>If it's <strong>OpenGL ES 2.0</strong> you're dealing with, you can choose one of draw mode constants from</p>
<p><code>GL_LINE_STRIP, GL_LINE_LOOP, GL_LINES,</code> to draw lines,</p>
<p><code>GL_POINTS</code> (if you need to draw only vertices), or</p>
<p><code>GL_TRIANGLE_STRIP</code>, <code>GL_TRIANGLE_FAN</... | 16,644 |
<p>In my Delphi7 this code</p>
<pre><code>var MStr: TMemoryStream;
...
FreeAndNil(MStr);
MStr.Size:=0;
</code></pre>
<p>generates an AV: Access violation at address 0041D6D1 in module 'Project1.exe'. Read of address 00000000.
But somebody insists that it should not raise any exception, no matter what. He also says t... | <p>It's always wrong to use methods or properties of a null reference, even if it appears to work sometimes.</p>
<p><code>FreeAndNil</code> indeed cannot be used to detect double frees. It is safe to call <code>FreeAndNil</code> on an already-nil variable. Since it's safe, it doesn't help you detect anything.</p>
<p>... | <p><em>Thomas Mueller</em>: have you tried virtual class methods? A constructor is sort of a virtual method but you call it against the type - not the instance. This means that even some specific virtual methods will not cause AV on a null-reference :D</p>
<p><em>Vegar</em>: You couldn't be more right! FastMM is the b... | 47,544 |
<p>If I try to quit Firefox when it's "Looking up domain.com..." it beachballs (hangs), goes into "not responding" status, then finally quits. It does this without fail.</p>
<p>This is on Mac with the latest FF, but it's always been this way for me, even on Windows with FF and I've noticed it with other applications.... | <p>No. You can use threads or even seperate processes to do this asynchronously (non-blocking). This is just poorly written software.</p>
<p>Aside from that, I don't have this particular problem with FF...</p>
| <p>There is a <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=235853" rel="nofollow noreferrer" title="Mozilla Bug 235853">bug report</a> for this problem. It has been around since at least 2004.</p>
| 40,059 |
<p>There doesn't seem to be a dictionary.AddRange() method. Does anyone know a better way to copy the items to another dictionary without using a foreach loop. </p>
<p>I'm using the System.Collections.Generic.Dictionary. This is for .NET 2.0. </p>
| <p>There's the <code>Dictionary</code> constructor that takes another <code>Dictionary</code>.</p>
<p>You'll have to cast it <code>IDictionary</code>, but there is an <code>Add()</code> overload that takes <code>KeyValuePair<TKey, TValue></code>. You're still using foreach, though.</p>
| <p>If you're dealing with two existing objects, you might get some mileage with the CopyTo method: <a href="http://msdn.microsoft.com/en-us/library/cc645053.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/cc645053.aspx</a></p>
<p>Use the Add method of the other collection (receiver) to absorb t... | 10,725 |
<p>We are designing a web application using ASP.NET and AJAX and we want to host our WCF Service Layer on a different website and make JavaScript calls to the Service Layer from our client pages. We understand that the browser will not allow AJAX calls to a different port or domain. What is the best way to architect ... | <p>It's generally best to limit the number of domains accessed by your page. A server-side proxy is really a good way to go.</p>
| <ul>
<li>You can do virtual hosting of the
service and website under same
domain but different folder.</li>
<li>define the services in different
dlls and create svc files in your
websites and point the svc files to
the dll which has the services</li>
<li>server side proxy. </li>
</ul>
| 18,514 |
<p>I am looking to create an expression tree by parsing xml using C#.
The xml would be like the following:</p>
<pre><code><Expression>
<If>
<Condition>
<GreaterThan>
<X>
<Y>
</GreaterThan>
</Condition>
<Expression />
<If>
<Else>... | <pre><code>using System.Linq.Expressions; //in System.Core.dll
Expression BuildExpr(XmlNode xmlNode)
{ switch(xmlNode.Name)
{ case "Add":
{ return Expression.Add( BuildExpr(xmlNode.ChildNodes[0])
,BuildExpr(xmlNode.ChilNodes[1]));
}
/* ... */
}
}
</code><... | <p>I'd start by looking at the DLR, which has a published expression tree mechanism.</p>
| 44,845 |
<p>I have a cross-platform (Python) application which needs to generate a JPEG preview of the first page of a PDF.</p>
<p>On the Mac I am spawning <a href="http://web.archive.org/web/20090309234215/http://developer.apple.com:80/documentation/Darwin/Reference/ManPages/man1/sips.1.html" rel="noreferrer">sips</a>. Is th... | <p>ImageMagick delegates the PDF->bitmap conversion to GhostScript anyway, so here's a command you can use (it's based on the actual command listed by the <code>ps:alpha</code> delegate in ImageMagick, just adjusted to use JPEG as output):</p>
<pre><code>gs -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT \
-dM... | <p>Is the PC likely to have Acrobat installed? I think Acrobat installs a shell extension so previews of the first page of a PDF document appear in Windows Explorer's thumbnail view. You can get thumbnails yourself via the IExtractImage COM API, which you'll need to wrap. <a href="http://www.vbaccelerator.com/home/net/... | 2,293 |
<p>I keep running into this problem when debugging JSP pages in OpenNMS. The Jetty wiki talks about keepGenerated (<a href="http://docs.codehaus.org/display/JETTY/KeepGenerated" rel="nofollow noreferrer">http://docs.codehaus.org/display/JETTY/KeepGenerated</a>) in webdefault.xml but it seems unclear how this works in e... | <p>If you are using Jetty 6 you can use the following code:</p>
<pre><code>String webApp = "./web/myapp"; // Location of the jsp files
String contextPath = "/myapp";
WebAppContext webAppContext = new WebAppContext(webApp, contextPath);
ServletHandler servletHandler = webAppContext.getServletHandler();
ServletHolder h... | <p>It is dumped already.
for example if you have a file called <code>index.jsp</code>, a file will be created called <code>index_jsp.java</code>
Just search for something like that in the work directory.</p>
| 11,692 |
<p>I'm looking for a good article on using emacs as C/C++ IDE.</p>
<p>Something like Steve Yegge's <a href="http://steve.yegge.googlepages.com/effective-emacs" rel="noreferrer">"Effective emacs"</a>.</p>
| <p>No specific article, really, but I've found <a href="http://www.emacswiki.org/cgi-bin/wiki" rel="noreferrer">EmacsWiki</a> to be full of useful information. Consider checking out these entries:</p>
<ul>
<li><a href="http://www.emacswiki.org/cgi-bin/wiki/CPlusPlus" rel="noreferrer">CPlusPlus</a> as a starting point ... | <p>I recommend <a href="https://github.com/leoliu/ggtags" rel="nofollow">ggtags</a> and <a href="https://github.com/Sarcasm/irony-mode" rel="nofollow">irony-mode</a>. Other then that you may want to use <a href="https://github.com/syohex/emacs-helm-ag" rel="nofollow">helm-ag</a> to search ("grep") for strings in your c... | 3,207 |
<p>Are there any decent PHP libraries available for accessing SVN repositories? Right now I just have some scripts executing commands to the command line and parsing the feedback, I'd love to find something less dependent on the command line and more tightly integrated. Any ideas?</p>
| <p>A quick google search;</p>
<p><a href="http://au2.php.net/svn" rel="nofollow noreferrer">http://au2.php.net/svn</a><br/>
<a href="http://php-svn-client.tigris.org" rel="nofollow noreferrer">http://php-svn-client.tigris.org</a><br/>
<a href="http://pecl.php.net/package/svn" rel="nofollow noreferrer">http://pecl.php.... | <p>I think you are fine just the way you are. WebSvn, from websvn.tigris.org, the Subversion people themselves, does it the same way. I also shell out to the command line and parse the responses in my app BugTracker.NET.</p>
| 20,840 |
<p>I'm writing an application that does async loading of images onto the screen. I have it set up to be NOT concurrent (that is, it spawns a thread and executes them one at a time), so I've only overridden the <code>[NSOperation main]</code> function in my NSOperation subclass. </p>
<p>Anyway, so when I add all of the... | <p>I stepped through <code>-operations</code>, and found that it's basically doing:</p>
<pre><code>[self->data->lock lock];
NSString* copy = [[self->data->operations copy] autorelease];
[self->data->lock unlock];
return copy;
</code></pre>
<p>except, after calling <code>-autorelease</code>, the subs... | <p>No idea why you are seeing this behaviour but as a pure workaround you could keep your own references to the individual operations as they are added into the queue.</p>
| 30,945 |
<p>We've got a page in our asp.net web system that uses response.redirect to redirect the user directly to an excel file so it will download "automatically" without the user having to to a right click / save as.</p>
<p>This works great - except for files over about 100k in IE7. Other browsers just download the large ... | <p>I prefer a different method for sending files. It works for me with all kinds of different types and sizes of files. </p>
<p>Instead of using Response.Redirect, allow the link to the file to do a postback where you modify the response, like so:</p>
<pre><code>Public Shared Sub SendFileToBrowser(ByRef response As H... | <p>I prefer a different method for sending files. It works for me with all kinds of different types and sizes of files. </p>
<p>Instead of using Response.Redirect, allow the link to the file to do a postback where you modify the response, like so:</p>
<pre><code>Public Shared Sub SendFileToBrowser(ByRef response As H... | 48,228 |
<p>I have been making a little toy web application in C# along the lines of Rob Connery's Asp.net MVC storefront.</p>
<p>I find that I have a repository interface, call it IFooRepository, with methods, say</p>
<pre><code>IQueryable<Foo> GetFoo();
void PersistFoo(Foo foo);
</code></pre>
<p>And I have three impl... | <p>Create an abstract class that contains concrete versions of the tests and an abstract GetRepository method which returns IFooRepository.
Create three classes that derive from the abstract class, each of which implements GetRepository in a way that returns the appropriate IFooRepository implementation.
Add all three ... | <pre><code>[TestMethod]
public void GetFoo_NotNull_Test_ForFile()
{
GetFoo_NotNull(new FileRepository().GetRepository());
}
[TestMethod]
public void GetFoo_NotNull_Test_ForSql()
{
GetFoo_NotNull(new SqlRepository().GetRepository());
}
private void GetFoo_NotNull(IFooRepository repository)
{
var results... | 10,694 |
<p>Which JSON rewriter is the best for applications written in Java? Criteria may vary. I'm personally most interested in stability and performance.</p>
| <p>I am using the one from <a href="http://www.json.org" rel="nofollow noreferrer">http://www.json.org</a>. The direct link to the Java code is this:
<a href="http://www.json.org/java/index.html" rel="nofollow noreferrer">http://www.json.org/java/index.html</a>.</p>
<p>The nice thing about it is that it does not requ... | <p>This JsonTools library is very complete. You can find it at <a href="http://jsontools.berlios.de/" rel="nofollow noreferrer">Berlios</a>.</p>
| 31,847 |
<p>How can I obtain the .NET Framework directory path inside my C# application?</p>
<p>The folder that I refer is "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727"</p>
| <p>The path to the installation directory of the CLR active for the current .NET application can be obtained by using the following method:</p>
<pre><code>System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()
</code></pre>
<p>I would <strong>strongly</strong> advice against reading the registry dire... | <p>Read value of the <strong>[HKLM]\Software\Microsoft.NetFramework\InstallRoot</strong> key - you will get "C:\WINDOWS\Microsoft.NET\Framework". Then append with desired framework version.</p>
| 49,182 |
<p>Are there techniques for comparing the same data stored in different schemas? The situation is something like this. If I have a db with schema A and it stores data for a feature in say, 5 tables. Schema A -> Schema B is done during an upgrade process. During the upgrade process some transformation logic is applied a... | <p>Basically, you should create object representations for both schema versions, and then compare objects. This is best done if they all fit into memory simultaneously; if not, you need to iterate over all objects in one representation, fetch the corresponding object in the other representation, compare them, and then ... | <p>I've used SQLAlchemy successfully for migration between one schema and another - that's a similar process (as indicated by Martin v. Löwis) as comparison. Especially if you use an .equals(other) method.</p>
| 47,243 |
<p>let me tell you a bit about where this question came from. I have been playing around with the SDK of Serious Sam 2, a first person shooter which runs on the Serious Engine 2. This engine introduces something called MetaData. MetaData is used in the engine to serialize classes and be able to edit them in the editor ... | <p>To get a definitive answer, study the <a href="http://en.wikipedia.org/wiki/Portable_Executable" rel="nofollow noreferrer">PE File Format</a>. This is the low level file format for binaries on Win32. ie. DLLs, EXEs, COM, etc.</p>
<p>There are many books that discribe PE File layout and features. And many tools t... | <p>Just a stab in the dark here, since I've never looked at the sdk, but I'm guessing that there's a two pass-system happening - once with a C++ compiler, and once with a custom metadata processor that can look for the meta tags and process the associated class names, instance member names and _() tags. Likely some so... | 37,121 |
<p>I am trying to use some pinvoke code to call a C function. The function fills a buffer with data.</p>
<p>The structure is set up as a DWORD for the length, followed by a string. How do I extract the string from the IntPtr?</p>
<pre><code> IntPtr buffer = Marshal.AllocHGlobal(nRequiredSize);
PInvokedFunction(buf... | <p>You should do this:</p>
<pre><code>IntPtr sBuffer = new IntPtr( buffer.ToInt64() + 4 );
string s = Marshal.PtrToStringAuto( sBuffer );
</code></pre>
<p>So your code is 64bit safe.</p>
| <p>The best I could come up with was the following, though the use of the UnmanagedMemoryStream seems a bit of a hack.</p>
<pre><code> IntPtr buffer = Marshal.AllocHGlobal((int)nRequiredSize);
PInvokedFunction(buffer, nRequiredSize);
UnmanagedMemoryStream memStream = new UnmanagedMemoryStream(buffer.ToPointer(), nRe... | 26,502 |
<p>How can I programmatically make a query in MS Access default to landscape when printed, specifically when viewing it as a PivotChart? I'm currently attempting this in MS Access 2003, but would like to see a solution for any version.</p>
| <p>The following function should do the trick:</p>
<pre><code>Function SetLandscape()
Application.Printer.Orientation = acPRORLandscape
End Function
</code></pre>
<p>Should be able to call this from the autoexec function to ensure it always runs.</p>
| <p>Yes ahockley's call sets the application's printer orientation to landscape. I tried an experiment and it worked well. I know this doesn't produce a pivot table, but I didn't setup one to use, so it opens and prints a regular query. </p>
<pre><code>Private sub
Application.Printer.Orientation = acPRORLandscap... | 10,417 |
<p>I am working on a project that has grown to a decent size, and I am the only developer. We currently don't use any version control, but I definitely need to start.</p>
<p>I want to use Subversion. What would be the best way to transfer an existing project to it?</p>
<p>I have a test server that I use for developi... | <p>To expand a little on the previous answer...</p>
<p>1) Create a new SVN repository<br />
2) Commit all the code you've worked on so far to it<br />
3) Check all that code OUT again, to create a working copy on your dev machine<br />
4) Work!</p>
<p>It's definitely not a hurdle, really.</p>
| <p>I use mercurial on my desktop and I love it. Creating the repository is super easy...</p>
<pre><code>hg init /path/to/repository
</code></pre>
<p>Add the files...</p>
<pre><code>hg add /folder/pattern
OR
hg add FILE
</code></pre>
<p>Then you just commit... </p>
<pre><code>hg commit
</code></pre>
<p>And y... | 14,302 |
<p>What is the name of the technology behind Google Maps which allows the server to send only the part of the map requested from the user to enhance the performance, and is there any library to handle this?</p>
| <p>The technology could generically be described as a <strong>map server</strong>. The map server generates a map for the requested location from a large set of pre-generated map tile images covering the entire planet. The map server may overlay data from other databases on top of this. The combination of a map viewer ... | <p><a href="http://en.wikipedia.org/wiki/AJAX" rel="nofollow noreferrer">AJAX</a> allows you to update part of the page from the javascript. Basically the javascript makes a request back to the webserver and replaces part of the existing page with the result.</p>
<p><a href="http://jquery.com/" rel="nofollow noreferre... | 25,055 |
<p>Doxygen is a bit slow - it takes about a couple of minutes to process my whole project, so for small incremental changes this is longer than actually building the rest of my code. There are thousands of files without any documentation so I guess it is spending most of its time processing them. Is there any way to ge... | <p>From Doxygen documentation:</p>
<blockquote>
<p>How can I exclude all test directories
from my directory tree?</p>
<p>Simply put an exclude pattern like
this in the configuration file:</p>
<p>EXCLUDE_PATTERNS = <em>/test/</em></p>
</blockquote>
<p>So, you should be using patterns to exclude files. ... | <p>Doxygen is good at finding connections between files, either changed or not. But Doxygen does not remember informations about unchanged files, so it must process the whole codebase each time.</p>
<p>May be a solution would be to organize the project such that never changed files belong to one module which is exclud... | 24,852 |
<p>I'm not seeing any real advantages, other than the fact that you have a C++ syntax, and with it, things like pointers and destructors.</p>
| <p>If you're talking about why you would use C++/CLI over C#, I think the main reasons are that:</p>
<ol>
<li>it might be more natural for C++ developers (though I think this is probably not true)</li>
<li>C++/CLI has very nice capabilities for bridging the native and managed environments (using the 'IJW' - It Just Wo... | <p>I don't think comparing different flavors of C++ to each other is the same question as comparing C++ to C#. C# is a very different beast compared to the differences between different flavors of C++.</p>
| 38,038 |
<p>Yesterday i replaced the z axis of my diy printer. Now i have some strange waves on the side of my prints. Are the threaded rods bent or could that be a vibration issue? Or is the coupler too stiff?</p>
<p><a href="https://i.stack.imgur.com/IbumF.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ib... | <p>This looks as if there is a side-to-side force being generated as Z is changed. Ideally, the X or Y position is determined by the smooth rods, which should bear any force, not the threaded rod. The threaded rod should cause no motion except upward and downward.</p>
<p>If the rod is bent, but the rod is lightly co... | <p>It is possible that your selected layer height isn't compatible with the pitch of your leadscrew. I believe the reprap website has a layer height calculator based on the pitch of your lead screw. Just another option.</p>
| 642 |
<p>When 3D Printing moves into public beta, you're going to want to get the word out. And fast! One of the best ways to advertise ourselves across the entire Stack Exchange network is through community ads. </p>
<h3>So what are these "Community Ads?"</h3>
<p>Graduated sites allow the community to advertise relevant p... | <p>I'll try my hand at it and try to get the ball rolling.</p>
<p><a href="https://3dprinting.stackexchange.com/"><img src="https://i.stack.imgur.com/CBJNE.png" alt="Been here?"></a></p>
| <p>As mentioned, here's one related to the <a href="http://www.thingiverse.com/thing:30808" rel="nofollow noreferrer"><strong>Occupy Thingiverse</strong></a> movement. It's simple, but it has a bit of history within the 3D printing community.</p>
<p><a href="https://i.stack.imgur.com/9vUg7.png" rel="nofollow noreferre... | 16 |
<p>Greetings!</p>
<p>I have some XML like this:</p>
<pre><code><Root>
<MainSection>
<SomeNode>Some Node Value</SomeNode>
<SomeOtherNode>Some Other Node Value</SomeOtherNode>
<Areas>
<Area someattribute="aaa" name="Alpha" value="0" /&... | <p>XPathSelect doesn't return a DataSource that can be directly bound like that. Just as you had the FormView bound and your bindings with in it used XPath("...") not Bind("..."), you have the same issue with the DropDownList. Either build a standard DataSource with your attributes and bind the DDL to that, or roll you... | <p>Forgive my lack of familiarity with ASP, but shouldn't your paths include the @?</p>
<p><asp:DropDownList ID="MyDdl" runat="server" DataSource='<%# XPathSelect("Areas/*") %>' DataTextField="<strong>@name</strong>" DataValueField="<strong>@value</strong>" /></p>
| 46,586 |
<p>I have a List object being accessed by multiple threads. There is mostly one thread, and in some conditions two threads, that updates the list. There are one to five threads that can read from this list, depending on the number of user requests being processed.
The list is not a queue of tasks to perform, it is a li... | <p>Do you have to use a sequential list? If a map-type structure is more appropriate, you can use a <code>ConcurrentHashMap</code>. With a list, a <code>ReadWriteLock</code> is probably the most effective way.</p>
<p>Edit to reflect OP's edit: Binary search on insertion order? Do you store a timestamp and use that for... | <p>What are the reading threads doing? If they're iterating over the list, then you really need to make sure no-one touches the list during the whole of the iteration process, otherwise you could get very odd results.</p>
<p>If you can define precisely what semantics you need, it should be possible to solve the issue ... | 25,473 |
<p>How do I take a string in Perl and split it up into an array with entries two characters long each?</p>
<p>I attempted this:</p>
<pre><code>@array = split(/../, $string);
</code></pre>
<p>but did not get the expected results.</p>
<p>Ultimately I want to turn something like this</p>
<pre><code>F53CBBA476
</code>... | <pre><code>@array = ( $string =~ m/../g );
</code></pre>
<p>The pattern-matching operator behaves in a special way in a list context in Perl. It processes the operation iteratively, matching the pattern against the remainder of the text after the previous match. Then the list is formed from all the text that matched... | <p>I see a more-intuitive (if perhaps less-efficient) way to solve this issue: slice-off the required 2-character strings from the string with "substr" and push them onto the array with "push":</p>
<pre><code># Start with a string (a hex number in this case):
my $string = "526f62626965204861746... | 48,679 |
<p>If I open files I created in Windows, the lines all end with <code>^M</code>.<br />
How do I delete these characters all at once?</p>
| <p><a href="https://sourceforge.net/projects/dos2unix" rel="noreferrer">dos2unix</a> is a commandline utility that will do this, or <code>:%s/^M//g</code> will if you use <kbd>Ctrl</kbd>-<kbd>v</kbd> <kbd>Ctrl</kbd>-<kbd>m</kbd> to input the ^M, or you can <code>:set ff=unix</code> and Vim will do it for you.</p>
<p>Th... | <p>Usually there is a <code>dos2unix</code> command you can use for this. Just make sure you read the manual as the GNU and BSD versions differ on how they deal with the arguments.</p>
<p>BSD version:</p>
<pre><code>dos2unix $FILENAME $FILENAME_OUT
mv $FILENAME_OUT $FILENAME
</code></pre>
<p>GNU version:</p>
<pre><code... | 10,839 |
<p>I am starting a new distributed project. Should I use SVN or Git, and why?</p>
| <p>SVN is one repo and lots of clients. Git is a repo with lots of client repos, each with a user. It's decentralised to a point where people can track their own edits locally without having to push things to an external server.</p>
<p>SVN is designed to be more central where Git is based on each user having their own... | <p>You have to go with a DVCS, it is like a quantum leap in source management. Personally I use <a href="http://monotone.ca" rel="nofollow noreferrer">Monotone</a> and its sped up development time no end. We are using it for Windows, Linux and Mac and it has been very stable. I even have buildbot doing nightly build... | 19,531 |
<p>I have some hierarchical data - each entry has an id and a (nullable) parent entry id.
I want to retrieve all entries in the tree under a given entry. This is in a SQL Server 2005 database. I am querying it with LINQ to SQL in C# 3.5.</p>
<p>LINQ to SQL does not support <a href="http://msdn.microsoft.com/en-us/libr... | <p>I would set up a view and an associated table-based function based on the CTE. My reasoning for this is that, while you could implement the logic on the application side, this would involve sending the intermediate data over the wire for computation in the application. Using the DBML designer, the view translates ... | <p>The trouble with fetching the data from the client side is that you can never be sure how deep you need to go. This method will do one roundtrip per depth and it could be union'd to do from 0 to a specified depth in one roundtrip.</p>
<pre><code>public IQueryable<Node> GetChildrenAtDepth(int NodeID, int dept... | 24,816 |
<p>The only experience I have so far with a touchscreen interface was one where everything was custom drawn, and I get the feeling it's not the most efficient way of doing it (even the most basic layout change is hell to make). I know plenty of GUI toolkits intended at keyboard & mouse interfaces, but can you advis... | <p>Check out the Windows Presentation Foundation (<a href="http://en.wikipedia.org/wiki/Windows_Presentation_Foundation" rel="nofollow noreferrer">WPF</a>). It uses XML (<a href="http://en.wikipedia.org/wiki/Extensible_Application_Markup_Language" rel="nofollow noreferrer">XAML</a>) to define the interface and it is th... | <p>I work at Little Caesars, and all orders are handled through the computer system. They use a touch screen interface which resembles a blown-up version of normal forms. Buttons are about 20x larger than what you would normally get, and text is enlarged quite a bit as well. It looked rather simple and I doubt they ... | 13,910 |
<p>Using reflection in .Net, what is the differnce between:</p>
<pre><code> if (foo.IsAssignableFrom(typeof(IBar)))
</code></pre>
<p>And</p>
<pre><code> if (foo.GetInterface(typeof(IBar).FullName) != null)
</code></pre>
<p>Which is more appropriate, why?<br></p>
<p>When could one or the other fail?</p>
| <p>If you just want to see if a type implements a given interface, either is fine, though GetInterface() is probably faster since IsAssignableFrom() does more internal checks than GetInterface(). It'll probably even faster to check the results of Type.GetInterfaces() which returns the same internal list that both of th... | <p><strong>Edit: This answer is wrong! Please see comments.</strong></p>
<p>There is a difference in how internal classes are handled. Take the following class:</p>
<pre><code>public interface IFoo
{
}
internal class Foo: IFoo
{
}
</code></pre>
<p>This will give you a list of one item:</p>
<pre><code>var types... | 12,493 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.