instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I am saving some small images to Xml as a Byte[] via the following XElement construct..</p> <pre><code>XElement xe = new XElement("Images", from c in qry select new XElement("Image", new XAttribute("Date", c.Date), new XElement("Data", c.Bytes))); </code></pre> <p>the Bytes pr...
<p>I would think about Base64 encoding the byte array. It should be fairly easy to encode/decode this from/to a byte array.</p>
<p>This was very helpful, thank you. For a coding sample see:</p> <p><a href="http://www.nowan.hu/main.aspx?content=9cff1555-26ca-4e6a-910b-6a73463e22b2" rel="nofollow noreferrer">http://www.nowan.hu/main.aspx?content=9cff1555-26ca-4e6a-910b-6a73463e22b2</a></p>
41,297
<p>Today I'm starting a little project to create a Django based school administration program. I'm currently designing the models and their corresponding relationships. Being rather new to Django and relational databases in general, I would like some input.</p> <p>Before I show you the current model layout, you need t...
<p>From a quick look I think that its fairly comprehensive. Perhaps you should allow multiple teachers on a course, and allow reuse of addresses/locations between parents and students.</p> <p>As a general rule I would say that you should start implementing and then you will find where you need improvement.</p>
<p>Looks like an interesting project. Do note that Django has higher-level types than SQL, so you can make use of things like the email address type.</p> <p>If you're planning on targeting <a href="http://code.google.com/appengine/" rel="nofollow noreferrer">GAE</a>, you should find a similarly rich <a href="http://c...
44,859
<p>Why isn't this project maintained anymore? I love this app, however not updating it seems like a crime against all .Net developers. There are several items that I would love to add to it given the chance of a future release. </p> <p>Can anyone share something I don't know?</p>
<p>The NUnit 2.5 Alpha 4 Release was released on September 14, 2008.</p> <p>Do you consider 16 days as not being maintained?</p>
<p>You are right. NUnit is a great app (or rather a system).</p> <p>But since it is a open project, everyone is responsible for maintaining it. The people who originally started the great work might have some personal constraints stopping them actively taking part in development...</p>
18,373
<p>I did some tests a while ago and never figured out how to make this work. </p> <p><strong>The ingredients:</strong></p> <ul> <li>COM+ transactional object (developed in VB6) </li> <li>.Net web application (with transaction) in IIS that...<br> makes a call to the COM+ component<br> updates a row in a SQL database...
<p>Because VB and .NET will use different SQL connections (and there is no way to make ADO and ADO.NET share the same connection), your only possibility is to enlist the DTC (Distributed Transaction Coordinator). The DTC will coordinates the two independent transactions so they commit or are rolled-back together.</p> ...
<p>How are you implementing this? If you are using EnterpriseServices to manage the .NET transaction, then both transactions should get rolled back, since you're using the same context for them both.</p>
4,173
<p>I have a website with a form that uses TinyMCE; independently, I use jQuery. When I load the form from staging server on Firefox 3 (MacOS X, Linux), TinyMCE doesn't finish loading. There is an error in Firefox console, saying that <code>t.getBody()</code> returned <code>null</code>. <code>t.getBody()</code>, as f...
<p>The browser executes scripts in the order they're loaded, not written. Your <strong>immediate</strong> scripts -- <code>tinyMCE.init(...)</code> and <code>$(document.ready(...));</code> -- can execute before the files finish loading.</p> <p>So, the problem is probably network latency -- especially with 6 separate s...
<p>If you are using <code>jquery.tinymce.js</code> then you don't need <code>tiny_mce.js</code> because TinyMCE will try to load it with an ajax request. If you are finding that <code>window.tinymce</code> (or simply <code>tinymce</code>) is <code>undefined</code> then this means that the ajax is not yet complete (whic...
45,140
<p>Modern database systems today come with loads of features. And you would agree with me that to learn one database you must unlearn the concepts you learned in another database. For example, each database would implement locking differently than others. So to carry the concepts of one database to another would be a r...
<p>I think these are the most important things (from most important to least, IMO):</p> <ul> <li><strong>SQL (obviously)</strong> - It helps to know how to at least do basic queries, aggregates (sum(), etc), and inner joins</li> <li><strong>Normalization</strong> - DB design skills are an major requirement</li> <li><s...
<p>Basic things about Sql queries are must. then you can develop simple system. but when you are going to implement Complex systems you should know Normalization, Procedures, Functions, etc.</p>
4,381
<p>Has anyone had experience with developing a distributed system as a grid?</p> <p>By grid, I mean, a distributed system where all nodes are identical and there is no central management, database etc.</p> <p>How can the grid achieve even distribution of: CPU, Memory, Disk, Bandwidth etc.?</p>
<p>Something akin to <a href="http://plan9.bell-labs.com/plan9dist/" rel="nofollow noreferrer">Plan9</a> perhaps? </p> <p><a href="http://en.wikipedia.org/wiki/Plan_9_from_Bell_Labs" rel="nofollow noreferrer">wikipedia</a> entry.</p>
<p>What you're actually talking about is a cluster. There is a lot of software available for load balancing etc, even specific linux distros such as <a href="http://www.rocksclusters.org/wordpress/" rel="nofollow noreferrer">Rocks</a>, which comes complete with MPI/PVM and monitoring tools built in. </p>
27,967
<p>Traditionalist argue that stored procedures provide better security than if you use a Object Relational Mapping (ORM) framework such as NHibernate. </p> <p>To counter that argument what are some approaches that can be used with NHibernate to ensure that proper security is in place (for example, preventing sql injec...
<p>Actually, NHibernate can be vulnerable to SQL injection if you use SQL or HQL to construct your queries. Make sure that you use parameterized queries if you need to do this, otherwise you're setting yourself up for a world of pain.</p>
<p>OWASP mentions one form of SQL injection vulnerability in the context of ORM tools (and gives HQL injection as an example): <a href="http://www.owasp.org/index.php/Interpreter_Injection#ORM_Injection" rel="nofollow">http://www.owasp.org/index.php/Interpreter_Injection#ORM_Injection</a></p>
14,268
<p>I want to build an SQL string to do database manipulation (updates, deletes, inserts, selects, that sort of thing) - instead of the awful string concat method using millions of "+"'s and quotes which is unreadable at best - there must be a better way. </p> <p>I did think of using MessageFormat - but its supposed t...
<p>First of all consider using query parameters in prepared statements:</p> <pre><code>PreparedStatement stm = c.prepareStatement("UPDATE user_table SET name=? WHERE id=?"); stm.setString(1, "the name"); stm.setInt(2, 345); stm.executeUpdate(); </code></pre> <p>The other thing that can be done is to keep all queries ...
<p>How do you get string concatenation, aside from long SQL strings in PreparedStatements (that you could easily provide in a text file and load as a resource anyway) that you break over several lines?</p> <p>You aren't creating SQL strings directly are you? That's the biggest no-no in programming. Please use Prepared...
48,453
<p>I use log4net in just about every code project. I was wondering what other generally useful code projects are available?</p>
<ul> <li><a href="http://ayende.com/projects/rhino-mocks.aspx" rel="noreferrer">Rhino.Mocks</a></li> <li><a href="http://nunit.org" rel="noreferrer">NUnit</a></li> <li><a href="http://www.hibernate.org/343.html" rel="noreferrer">NHibernate</a></li> <li><a href="http://www.springframework.net/" rel="noreferrer">Spring.N...
<p>Some useful open source tools/projects I've used in .NET development:</p> <ul> <li><a href="http://www.7-zip.org/sdk.html" rel="nofollow noreferrer">7Zip</a></li> <li><a href="http://www.codeplex.com/htmlagilitypack" rel="nofollow noreferrer">HtmlAgilityPack</a></li> <li><a href="http://www.mono-project.com/Main_Pa...
22,501
<p>At my workplace, we tend to use <strong>iostream</strong>, <strong>string</strong>, <strong>vector</strong>, <strong>map</strong>, and the odd <strong>algorithm</strong> or two. We haven't actually found many situations where template techniques were a best solution to a problem.</p> <p>What I am looking for here...
<p><strong>General info on templates:</strong></p> <p>Templates are useful anytime you need to use the same code but operating on different data types, where the types are known at compile time. And also when you have any kind of container object.</p> <p>A very common usage is for just about every type of data stru...
<p>I use templates to specify function object types. I often write code that takes a function object as an argument -- a function to integrate, a function to optimize, etc. -- and I find templates more convenient than inheritance. So my code receiving a function object -- such as an integrator or optimizer -- has a t...
29,366
<p>I am trying to use the SGI STL implementation I have downloaded from their site. I want to use a hashmap, because I have to store around 5.000.000 records, but it should be good: I need to be able to access it very quickly. I've tried <code>stedext::hash_map</code>, but it was very slow because I couldn't set the in...
<p>I confess I haven't tried it for myself, but VS2008 is supposed to support TR1 which contains:</p> <pre><code>#include &lt;tr1/unordered_map&gt; </code></pre> <p>it's in a "feature Pack" release. <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=D466226B-8DAB-445F-A7B4-448B326C48E7&amp;displaylang=...
<p>Are there any other error messages showing up when you try to build/compile your project?<br> You mentioned you...</p> <blockquote> <p>added an additional directory to a project where the SGI STL is.</p> </blockquote> <p>Could you expand on that a bit? There are many places you can add directories in visual s...
44,380
<p>I was thinking that i wanted to gain some experience in the new asp.net mvc and some asp.net ajax. So i'd like to get some project suggestions that would suite for this!</p> <p>Would maybe be fun to create a little bigger project on codeplex, like the storefront project.</p>
<p>Whatever you do, do not create an URL Shortening Service because that was <a href="http://codeplex.com/rick" rel="nofollow noreferrer">already my idea</a> :-P</p> <p>Anyway, how about a <a href="http://www.twitter.com" rel="nofollow noreferrer">Twitter</a> Clone?</p>
<p>Well whatever is suggested I imagine there would be a lot of them out there already but some initial thoughts would be:</p> <ul> <li>Blog engine</li> <li>Todo list</li> <li>Wish list</li> </ul> <p>Whatever you decide though look at some of the better options out there and try to pin point what makes them good and ...
45,320
<p>I need to retrieve the Build Status from TeamCity in the form of XML, RSS format would be ideal.</p> <p>I am familiar with the RSS feed within Teamcity but that is of no use as it is more of a history view. I am looking for something more like the page generated by the Status Widget but in XML form. (FYI, the statu...
<p>You can use the <code>Syndication Feed</code> tool under <code>My Settings And Tools</code> to generate an RSS URL (Documentation <a href="http://confluence.jetbrains.net/display/TCD5/Feed+URL+Generator" rel="nofollow">here</a>), and track changes versus build results to determine the status (i.e. building, and prev...
<p>Does <a href="http://confluence.public.thoughtworks.org/display/CI/Multiple+Project+Summary+Reporting+Standard" rel="nofollow noreferrer">this summary of a standard XML status format</a> describe what you mean? I'm pretty sure TeamCity can produce this format, but not exactly sure how. Hudson does it with a URL like...
46,816
<p>What is the Best method to http transfer a file from the client to a server, in Java 1.5?</p>
<p>I'd use <a href="http://hc.apache.org/httpclient-3.x/" rel="nofollow noreferrer">Apache Commons HttpClient</a></p>
<p>I'd use <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/net/URLConnection.html" rel="nofollow noreferrer">URLConnection</a>.</p>
39,615
<p>Is it the case that the entire restful verb is under a single all encompassing transaction? That is to say, if I raise a Error in the validation or callbacks at any point in the handling of a UPDATE, DELETE, or CREATE operation, is every database operation that I may have performed in previous callbacks also rolled ...
<blockquote> <p>Is it the case that the entire restful verb is under a single all encompassing transaction? </p> </blockquote> <p>No</p> <blockquote> <p>if I raise a Error in the validation or callbacks at any point in the handling of a UPDATE, DELETE, or CREATE operation, is every database operation that I may h...
<p>Some methods (create, destroy) go to the database immediately. Transactions occur by using the transaction method on classes derived from ActiveRecord as follows:</p> <pre><code>Student.transaction do Course.transaction do course.enroll(student) student.units += course.units end end </code></pre> <p>(T...
15,141
<p>I have an ASP.NET page that uses a repeater nested within another repeater to generate a listing of data. It's to the effect of the following:</p> <pre><code>&lt;asp:Repeater&gt; &lt;ItemTemplate&gt; &lt;span&gt;&lt;%#Eval("Data1") %&gt;&lt;/span&gt; &lt;!-- and many more --&gt; &lt;asp:...
<p>This won't <strong>hide</strong> the repeater completely, but you can subclass the Repeater control so that it includes a GridView-like empty data template:</p> <pre><code>using System; using System.Web.UI; using System.Web.UI.WebControls; public class EmptyCapableRepeater : Repeater { public ITemplate EmptyDa...
<p>When you get your LINQ query executed, check its Count property (providing its a list of some sort). If its 0, then just turn the Visible property to false.</p>
42,389
<p>Wondering the most efficent way to make a binary search tree into a spell checker by reading in say 1000 word dictionary file and then having it check another document that say has a couple paragraphs. </p>
<p>a ternary tree <a href="http://en.wikipedia.org/wiki/Ternary_search_trie" rel="noreferrer">trie</a> would be more efficient</p>
<p>If you need to do an auto suggest/prefix search as well, then a patricia tree or radix tree is worth looking at.</p>
44,559
<p>When IE8 is released, will the following code work to add a conditional stylesheet?</p> <pre><code>&lt;!--[if IE 8]&gt; &lt;link rel="stylesheet" type="text/css" href="ie-8.0.css" /&gt; &lt;![endif]--&gt; </code></pre> <p>I've read conflicting reports as to whether this works with the beta. I'm hoping someone c...
<p>It worked for me – both in quirks mode and in standards compliance mode. However, it does <em>not</em> work when switching to IE8 compatibility mode.</p>
<p>Thank you for your help. I've discovered the solution, apparently the problem was having each style sheet use its own title attribute. Once I took the title off all but the main style sheet, no prob.</p> <p>This is a weird issue unique to IE8 - and although I've been told its supposed to work that way, something ...
20,252
<p>I have developed some custom DAO-like classes to meet some very specialized requirements for my project that is a server-side process that does not run inside any kind of framework. </p> <p>The solution works great except that every time a new request is made, I open a new connection via MySQLdb.connect. </p> <p...
<p>IMO, the &quot;more obvious/more idiomatic/better solution&quot; is to use an existing ORM rather than invent DAO-like classes.</p> <p>It appears to me that ORM's are more popular than &quot;raw&quot; SQL connections. Why? Because Python <em>is</em> OO, and the mapping from a SQL row to an object <em>is</em> absol...
<p>i did it for opensearch so you can refer it.</p> <pre><code> from opensearchpy import OpenSearch def get_connection(): connection = None try: connection = OpenSearch( hosts=[{'host': settings.OPEN_SEARCH_HOST, 'port':...
12,402
<p>The main web application of my company is crying out for a nifty set of libraries to make it in some way maintainable and scalable, and one of my colleagues has suggested CSLA. So I've bought the book but as :</p> <blockquote> <p><em>programmers don't read books anymore</em></p> </blockquote> <p>I wanted to gaug...
<p>Before I specifically answer your question, I'd like to put a few thoughts down. Is CSLA right for your project? It depends. I would personally consider CSLA for desktop based applications that does not value unit testing as a high priority. CSLA is great if you want to easily scale to an n-tier application. CSLA te...
<p>CSLA is the best application framework that exists. Rocky LHotka is a very but very smart guy. He is writing the history of software development like Martin Fowler, David S Platt, but my favourites writers are Rod Stephens, Mathew mcDonalds Jeff Levinson thearon willis and Louis Davidson alias dr sql. :-) Pros: All...
3,605
<p>I'm trying to get a number of third party applications to work on my Windows Mobile 5 smartphone.</p> <p>I've installed the latest version (3.5) of the Microsoft.NET Compact Framework, but whenever I run the apps I get an error message which states: "This application [Application Name] requires a newer version of t...
<p>It's probably better to <em>not</em> uninstall, and if it's on the device in ROM you can't uninstall it anyway.</p> <p>There are a couple options available to you.</p> <ol> <li>The different CF versions coexist fine, so you can install the older version and leave 3.5 on it.</li> <li>The CF can be set for compatibi...
<p>Have you tried using Microsoft ActiveSync to uninstall it?</p>
12,228
<p>Somebody <strong>please</strong> tell me it is possible to recover Visual Studio source after VS crashes!</p> <p>I have just spent 5 hours writing a new utility app, and running it with the "Save before Build" option turned on, as well as AutoRecover every 5-mins. But after VS crashed I am unabled to find anything ...
<p>In order to make sure this doesn't happen again in the future, you can go to</p> <p><strong>Tools</strong> > <strong>Options</strong> > <strong>Projects and Solutions</strong></p> <p>and check the item</p> <p><strong>Save new projects when created</strong></p>
<p>Indeed it does. Check your two projects folders. Both may contain your project and yet one is a folder with nothing but a .sln file in it.</p> <p>I'm very confident your work is on your disk somewhere in your Documents folder :). If all is set to defaults.</p>
38,267
<p>I'm trying to use the tree command in a windows commandline to generate a text file listing the contents of a directory but when I pipe the output the unicode characters get stuffed up.</p> <p>Here is the command I am using:</p> <pre><code>tree /f /a &gt; output.txt </code></pre> <p>The results in the console win...
<p>Have someone already tried this:</p> <pre><code>tree /f /a |clip </code></pre> <p>Open notepad, ctrl + V, save in notepad as output.txt with unicode support?</p>
<p>I've succeeded getting the output as it is in console, with all non-ascii characters not converted, by outputting to the console (just <code>tree</code>) and then copying from it (system menu -> Edit -> Mark, selecting all, Enter). Console buffer size should be increased in advance, depending on number files/folder...
16,786
<p>I am looking for a plastic which is transparent to radio waves. I want to place my transmitter in a cylinder. That cylinder would be placed in a big RC plane ( whose body is made up of cardboard). I want the plane to be both telemetry, and RC controlled. That cylinder should allow the signals, should be strong a...
<p>For the kind of application you are looking for, transparency to radio signal shouldn't really be an issue, so you are more or less free to choose whatever suits your taste better.</p> <p>Looking at the 3d printed drone community, the 3 most common materials I see being used there are:</p> <ul> <li>impact-resisten...
<p>To second @mac, </p> <p>For drone usage, ABS will be your pal*. Both tough-PLA and PETG are relatively heavy, which is a disadvantage for flying saucers. Unless you power up and don't care!</p> <ul> <li>And I say this as someone who does not recommend ABS for general printing and I don't like printing ABS myself b...
797
<p>I am trying to use the following code to export tables from access to excel</p> <p>I am getting error object does not support property or method at the end</p> <pre><code> Set objexcel = New Excel.Application objexcel.Visible = True If Dir("C:\reports\Data_Analysis1.xls") = "" Then objexcel.Workbooks.Add...
<p>DoCmd as in "DoCmd.TransferSpreadsheet" is an MS Access command, not an excel command. I think that is your problem.</p> <p>If this VBA is running inside MS Access then just refer to it as</p> <pre><code>DoCmd.TransferSpreadsheet </code></pre> <p>Not</p> <pre><code>objexcel.DoCmd.TransferSpreadsheet </code></pre...
<p>This <a href="https://stackoverflow.com/questions/358603/access-table-data-to-excel#362325">answer</a> works with the Excel object and can be helpful, as it allows you to automatically format the excel file. </p>
48,986
<p>How do you handle the Web User Control event? I notice my custom web user control have a event call OnError but it never fire when i tweak the control to fail. The control is basically a custom gridview control. I search for web user control event handling over the net but i haven't find a article that address what ...
<p>You didn't mention what flavour of ASP.NET, so I'll make the assumption of VB - C# is largely the same with the exception of how the event handler is attached.</p> <p>The normal pattern you would expect to see is something along these lines:</p> <p><strong><em>User Control "MyUserControl" CodeBehind</em></strong><...
<p>I had an issue with a custom control that was throwing exceptions which were not firing <code>Error</code> event. Thus I could not catch exceptions from this control and display appropriate message in the ASP.NET page.</p> <p>Here is what I did. I wrapped the code in the custom control in a <code>try..catch</code> ...
44,377
<p>I've always been curious to see if I can show, hide or change a NotifyIcon created by another application via a C# application.</p> <p>Could someone please post an example on how to do this? :)</p>
<p>To modify icons in the systray, you can use <a href="http://msdn.microsoft.com/en-us/library/bb762159.aspx" rel="nofollow noreferrer">Shell_NotifyIcon</a> Win32 API (<a href="http://pinvoke.net/default.aspx/shell32/Shell_NotifyIcon.html" rel="nofollow noreferrer">P/Invoke declaration</a>). The icons are associated w...
<p>I am not aware of anything, unless that other application exposes some public method, or you try to use reflection, but I'm not even sure that you can do that on a running process.</p>
30,993
<p>We have been working with CVS for years, and frequently find it useful to "sticky" a single file here and there.</p> <p>Is there any way to do this in subversion, specifically from TortoiseSVN?</p>
<p>The XOR method fails if a and b point to the same address. The first XOR will clear all of the bits at the memory address pointed to by both variables, so once the function returns (*a == *b == 0), regardless of the initial value.</p> <p>More info on the Wiki page: <a href="http://en.wikipedia.org/wiki/XOR_swap_al...
<p>I just placed both swaps (as macros) in hand written quicksort I've been playing with. The XOR version was much faster (0.1sec) then the one with the temporary variable (0.6sec). The XOR did however corrupt the data in the array (probably the same address thing Ant mentioned).<p> As it was a fat pivot quicksort, the...
5,753
<p>I am in a situation where I must update an existing database structure from varchar to nvarchar using a script. Since this script is run everytime a configuration application is run, I would rather determine if a column has already been changed to nvarchar and not perform an alter on the table. The databases which...
<p>You can run the following script which will give you a set of ALTER commands:</p> <pre><code>SELECT 'ALTER TABLE ' + isnull(schema_name(syo.id), 'dbo') + '.' + syo.name + ' ALTER COLUMN ' + syc.name + ' NVARCHAR(' + case syc.length when -1 then 'MAX' ELSE convert(nvarchar(10),syc.length) end + ');' ...
<p>Further updated to fix MAX being replaced with -1.</p> <pre><code>SELECT cmd = 'ALTER TABLE [' + c.table_schema + '].[' + c.table_name + '] ALTER COLUMN [' + c.column_name + '] NVARCHAR(' +CASE WHEN CHARACTER_MAXIMUM_LENGTH&lt;=4000 THEN CASE WHEN CHARACTER_MAXIMUM_LENGTH = -1 THEN 'MAX' ELSE CAST(CHARACTER_M...
21,714
<p>I run a high school 3D printer lab and we have several 5th generation MakerBot printers. On one of them I have considerable trouble with "thin" prints and filament slip warnings.</p> <p>So far I've tried changing extruders and using different filament rolls with no luck. But, if I move the job and the extruder to a...
<p>Oh interesting. By slips, I take it you mean that the raw filament slips, not the print slips.</p> <p>This will happen for a few reasons. First the tooth gear that grabs the plastic is either:</p> <ul> <li>Worn out</li> <li>Out of place</li> <li>Not the correct distance from the guide wheel. </li> </ul> <p>This i...
<p>So I had this issue for months, was about to either give up and call my printer a paper weight, but I figured it out. And it doesn't cost anything.</p> <p>I literally reprinted the same hose adapter 6 times (every time the filament slipped about 20 times and it was unusable). I changed 4 settings and since then I'v...
460
<p>I would like to create a trivial one-off Python object to hold some command-line options. I would like to do something like this:</p> <pre><code>options = ?????? options.VERBOSE = True options.IGNORE_WARNINGS = False # Then, elsewhere in the code... if options.VERBOSE: ... </code></pre> <p>Of course I could ...
<p>The <a href="http://docs.python.org/library/collections.html" rel="noreferrer">collections module</a> has grown a <em>namedtuple</em> function in 2.6:</p> <pre><code>import collections opt=collections.namedtuple('options','VERBOSE IGNORE_WARNINGS') myoptions=opt(True, False) &gt;&gt;&gt; myoptions options(VERBOSE=...
<p>simple object and named tuples are the way to go</p>
26,020
<p>Is there a plain API to access Mercurial repositories from Java?</p> <p>There are plugins for Netbeans and Eclipse, but unlike their Subversion counterparts, they do not use a common lower-level library but bring their own wrappers to call out to the Mercurial binary. Calling the binary would be okay (for now), but...
<p>A new option is <a href="http://javahg.aragost.com/" rel="nofollow noreferrer"><strong>JavaHg</strong></a>, which gives you a high-level Java API. The <a href="https://bitbucket.org/aragost/javahg/src/tip/src/test/java/com/aragost/javahg/commands/" rel="nofollow noreferrer">unit tests</a> give a good example of how ...
<p>The <a href="http://maven.apache.org/scm/" rel="nofollow noreferrer">Maven SCM plugin</a> seems to have a <a href="http://maven.apache.org/scm/maven-scm-providers/maven-scm-provider-hg/index.html" rel="nofollow noreferrer">Mercurial provider available</a>. However, I don't know how applicable that provider is in you...
49,839
<p>EF has been out for awhile now and I'm considering evaluating it - what have your experiences been?</p> <p>I am interested in both web and desktop applications, and maybe some comparisons between EF and other ORM tools that you've used. </p> <p>Learning curve is a factor since there is a team involved. Is this thi...
<p>Well, I just finished implementing a complete system in EF, it was my first real experience with the EF in a production environment. The app is running now for about 45 days with 100's of users hitting it daily with no issues.</p> <p>I think the largest thing is that you have to change your thinking. If you are t...
<p><strong>EDIT (yes, 3 years later)... I no longer hate EF... Entity Framework 4.1 and up is great - it (finally) solves all of the issues/failings that it has had in the past. Note, not "4.0", but "4.1" finally removed the ugly use of 'magic strings', etc. It has <code>Contains</code> and everything else plus more.</...
42,619
<p>Is there a way to exclude all svn externals when doing a recursive update?</p> <p>Is there a way to exclude only 1 of all of the svn externals when doing a recursive update?</p> <p>Basically I'd like to cut down the svn update time, and a couple of the SVN externals that I have will just about never get updated.</...
<p>Yes, there is an option for this (to ignore all):</p> <pre><code>&gt; svn update --ignore-externals </code></pre> <p>I don't know of any option to specifically ignore one or some externals while updating the rest. </p>
<p>I'd recommend changing the default context menu items to have Update to Revision on the main context menu.</p> <p>In the TortoiseSVN settings, go to 'Look and Feel', then uncheck items you want main folder context menu and check items you want in the submenu.</p> <p>I have the following <strong><em>unchecked</em><...
20,735
<p>I'm messing around with some C code using floats, and I'm getting 1.#INF00, -1.#IND00 and -1.#IND when I try to print floats in the screen. What does those values mean?</p> <p>I believe that 1.#INF00 means positive infinity, but what about -1.#IND00 and -1.#IND? I also saw sometimes this value: 1.$NaN which is Not ...
<p>From <a href="http://www.johndcook.com/IEEE_exceptions_in_cpp.html" rel="noreferrer">IEEE floating-point exceptions in C++</a> :</p> <blockquote> <p>This page will answer the following questions.</p> <ul> <li>My program just printed out 1.#IND or 1.#INF (on Windows) or nan or inf (on Linux). What happened?...
<p>For those of you in a .NET environment the following can be a handy way to filter non-numbers out (this example is in VB.NET, but it's probably similar in C#):</p> <pre class="lang-vb prettyprint-override"><code>If Double.IsNaN(MyVariableName) Then MyVariableName = 0 ' Or whatever you want to do here to "correc...
45,276
<p>I'm compiling library for a private project, which depends on a number of libraries. Specifically one of the dependencies is compiled with Fortran. On some instances, I've seen the dependency compiled with <code>g77</code>, on others I've seen it compiled with <code>gfortran</code>. My project then is <code>./config...
<pre><code>nm filename | fgrep ' __g77' </code></pre> <p>will give results if g77 was used, meanwhile</p> <pre><code>nm filename | fgrep '@@GFORTRAN' </code></pre> <p>will give results if gfortran is used.</p>
<p>You might be able to figure it out by using nm, and seeing if the compiled code uses functions from one or the other, but that's quite a hack. You may be able to figure it out based on which library is available (if there's no libg2c available, then it wasn't g77, for example), but then you still have some ambiguit...
38,794
<p>As someone who is only barely proficient in javascript, is jQuery right for me? Is there a better library to use? I've seen lots of posts related to jQuery and it seems to be the most effective way to incorporate javascript into ASP.NET applications.</p> <p>I've been out to <a href="http://jquery.com/" rel="noref...
<p>Pros: you don't have to deal with the tangled mess that is cross-platform Javascript compatibility. You don't have to worry about which browsers support standard event handlers and which have their own event systems. You don't have to write two hundred lines of DOM manipulation withHugeLongFunctionNamesFromHell to g...
<p>If you are only looking for javascript tool that is browser compatible and quite small in size to do DOM manipulation and ajax, then jQuery might be the one you are looking for.</p> <p>But jQuery is lack in these two areas:</p> <ol> <li>Fullblown widgets (Think of extjs). Note: jQuery-UI is not as complete and qui...
14,958
<p>We're currently having a debate whether it's better to throw faults over a WCF channel, versus passing a message indicating the status or the response from a service.</p> <p>Faults come with built-in support from WCF where by you can use the built-in error handlers and react accordingly. This, however, carries over...
<blockquote> <p>This however carries overhead as throwing exceptions in .NET can be quite costly.</p> </blockquote> <p>You're serializing and de-serializing objects to XML and sending them over a slow network.. the overhead from throwing an exception is negligable compared to that.</p> <p>I usually stick to throwin...
<p>I would seriously consider using the FaultContract and FaultException objects to get around this. This will allow you to pass meaningful error messages back to the client, but only when a fault condition occurs.</p> <p>Unfortunately, I'm in a training course at the moment, so can't write up a full answer, but as l...
10,693
<p>How can I <strong>quickly</strong> create a large file on a Linux (<a href="http://en.wikipedia.org/wiki/Red_Hat_Linux" rel="noreferrer">Red Hat Linux</a>) system?</p> <p><a href="http://en.wikipedia.org/wiki/Dd_%28Unix%29" rel="noreferrer">dd</a> will do the job, but reading from <code>/dev/zero</code> and writing...
<p><code>dd</code> from the other answers is a good solution, but it is slow for this purpose. In Linux (and other POSIX systems), we have <code>fallocate</code>, which uses the desired space without having to actually writing to it, works with most modern disk based file systems, very fast:</p> <p>For example:</p> <...
<p>You could use <a href="https://github.com/flew-software/trash-dump" rel="nofollow noreferrer">https://github.com/flew-software/trash-dump</a> you can create file that is any size and with random data</p> <p>heres a command you can run after installing trash-dump (creates a 1GB file)</p> <pre><code>$ trash-dump --fil...
32,180
<p><a href="https://3dprinting.stackexchange.com/questions/973/which-properties-of-real-organs-do-3d-printed-organs-have">A recent question</a> regarding bio-printing has been put on hold and I'd like to discuss the validity of the question here in the 3D Printing community.</p> <p>I personally feel that the question f...
<p>It seems like a great subject to incorporate, since bioprinting is 1) pretty neat and 2) an important application for 3D printing in general... but I sort of suspect none of our active users have the necessary expertise at the moment. It's a highly specialized field. We don't want the question to sit for an extended...
<p>It seems like a great subject to incorporate, since bioprinting is 1) pretty neat and 2) an important application for 3D printing in general... but I sort of suspect none of our active users have the necessary expertise at the moment. It's a highly specialized field. We don't want the question to sit for an extended...
24
<p>I need to check the <code>RequestType</code> of an <code>HttpRequest</code> in ASP.NET (or <code>WebRequest.Method</code>). I know that I can just use the string values "<code>POST</code>" or "<code>GET</code>" for the request type, but I could have sworn there was a constant somewhere in some class in .NET that con...
<pre><code>System.Net.WebRequestMethods.Http .Connect = "CONNECT" .Get = "GET" .Head = "HEAD" .MkCol = "MKCOL" .Post = "POST" .Put = "PUT" </code></pre> <p>Ultimately, though; since <code>const</code> expressions are burned into the caller, this is identical to using "GET" etc, just without the...
<p>In ASP.NET MVC they're in <strong>System.Web.Mvc.HttpVerbs</strong>. But all methods that take one of these enum values also has a text override, as there is no complete set of HTTP verbs, only a set of currently defined values (see <a href="http://www.ietf.org/rfc/rfc2518.txt" rel="noreferrer">here</a> and <a href...
35,069
<p>I need to create a photo gallery service that is managed by users. I've done this a million times using just Asp.net but I was wondering if there are any special considerations that I need to make when using Asp.net MVC.</p> <p>Basically, I will be storing the actual images on the filesystem and storing the locatio...
<p>This link explains how to create a custom ImageResult class. I was able to do exactly what I needed following it</p> <p><a href="https://blog.maartenballiauw.be/post/2008/05/13/aspnet-mvc-custom-actionresult.html" rel="nofollow noreferrer">https://blog.maartenballiauw.be/post/2008/05/13/aspnet-mvc-custom-actionresu...
<p>It's not a complete answer but I'd look at using a route that restricts access to the actual files themselves and then possibly use authentication of the action that gets an image.</p>
18,858
<p>I installed the wxWidgets source code, compiled it and am linking the libraries thus obtained with my application code. Now I need to use OpenGL in my wxWidgets application. How do I enable this?</p>
<h2>For building on Windows with project files:</h2> <p>Assume $(WXWIDGETSROOT) is the root directory of your wxWidgets installation.</p> <ol> <li>Open the file $(WXWIDGETSROOT)\include\wx\msw\setup.h</li> <li>Search for the <code>#define</code> for <code>wxUSE_GLCANVAS</code>. </li> <li>Change its value from 0 to 1....
<p>(Assume $(WX_WIDGETS_ROOT) is the root directory of your wxWidgets installation.)</p> <ol> <li>Open the file $(WX_WIDGETS_ROOT)\include\wx\msw\setup.h</li> <li>Search and find the option wxUSE_GLCANVAS. Change its value from 0 to 1.</li> <li>Recompile the library.</li> </ol>
3,497
<p>How can I go about making my routes recognise an optional prefix parameter as follows:</p> <pre><code>/*lang/controller/id </code></pre> <p>In that the lang part is optional, and has a default value if it's not specified in the URL:</p> <pre><code>/en/posts/1 =&gt; lang = en /fr/posts/1 =&gt; lang = fr /posts...
<p>OK, I've managed to sort out this problem:</p> <p>THere is no way of doing this in Rails by default (at least, not yet). Instead of using namespaces and default values, I needed to install <a href="http://github.com/svenfuchs/routing-filter/tree/master" rel="noreferrer">Sven Fuchs' routing filter</a>.</p> <p>Once ...
<p>I'm guessing (no time to test right now) that this might work:</p> <pre><code>map.connect ':language/posts/:id', :controller =&gt; 'posts', :action =&gt; 'show' map.connect 'posts/:id', :controller =&gt; 'posts', :action =&gt; 'show' </code></pre> <p>OK, tried it - it works, on Rails 2.1.1 at least. So that's good...
26,108
<p>What's the best open source LINQ provider (in terms of completeness)? </p> <p>I'm developing an open source LINQ provider myself and I'd like to borrow as many ideas as I can, avoid common pitfalls, etc.</p> <p>Do not restrict yourself to database LINQ providers, any provider suggestion is welcome.</p>
<p>There is another implementation "re-linq".</p> <p>Have a look here:</p> <ul> <li><a href="http://www.re-motion.org/blogs/team/archive/2009/04/23/introducing-re-linq-a-general-purpose-linq-provider-infrastructure.aspx" rel="noreferrer">http://www.re-motion.org/blogs/team/archive/2009/04/23/introducing-re-linq-a-gen...
<p><a href="http://www.codeplex.com/LinqExtender" rel="nofollow noreferrer">LinqExtender</a> gives a way to get started with LINQ to anything without doing the complex Expression tree parsing. It gives out more or less easy data structure, without sacrificing things like projection , where , order by etc. Its still und...
21,042
<p>I would like my Core assembly to not expose a certain class and I would still like to be able to test it. How can I do that ?</p>
<p><a href="http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute(VS.80).aspx" rel="noreferrer">InternalsVisibleTo</a> attribute to the rescue!</p> <p>Just add: </p> <pre><code>[assembly:InternalsVisibleToAttribute("UnitTestAssemblyName")] </code></pre> <p>to your Core ...
<h2>Let's start with an example class:</h2> <pre class="lang-cs prettyprint-override"><code>using System.Runtime.CompilerServices; [assembly: InternalsVisibleTo(&quot;App.Infrastructure.UnitTests&quot;)] namespace App.Infrastructure.Data.Repositories { internal class UserRepository : IUserRepository { ...
7,519
<p>Our development uses lots of open-source code and I'm trying to figure out what the best way to manage these external dependencies.</p> <p>Our current configuration:</p> <ul> <li>we are developing for both linux and windows</li> <li>We use svn for our own code</li> <li>external dependencies (boost, log4cpp, etc) a...
<p>I keep them in svn, and manage them as <a href="http://svnbook.red-bean.com/en/1.5/svn.advanced.vendorbr.html" rel="nofollow noreferrer">vendor branches</a>. Keeping them loose externally makes it very hard to go back to a previous build, or fix bugs in a previous build (especially if the bug is from a change to th...
<p>Have you considered <a href="http://maven.apache.org/" rel="nofollow noreferrer">Maven</a>? It's a build system that has excellent support for managing dependencies. For each project you can specify the required dependencies in an xml file as part of that project. The external libraries are held in a dependency re...
21,626
<p>I want to log user's actions in my Ruby on Rails application.</p> <p>So far, I have a model observer that inserts logs to the database after updates and creates. In order to store which user performed the action that was logged, I require access to the session but that is problematic.</p> <p>Firstly, it breaks the...
<p>I find this to be a very interesting question. I'm going to think out loud here a moment...</p> <p>Ultimately, what we are faced with is a decision to violate a design-pattern acceptable practice in order to achieve a specific set of functionality. So, we must ask ourselves</p> <p>1) What are the possible soluti...
<p>In the past, when doing something like this, I have tended towards extending the User model class to include the idea of the 'current user'</p> <p>Looking at the previous answers, I see suggestions to store the actual active record user in the session. This has several disadvantages.</p> <ul> <li>It stores a possi...
16,164
<p>When i use any of the other strongly typed HTML helpers after typing for example </p> <pre><code>Html.Actionlink&lt;HomeController&gt;(x=&gt;x. </code></pre> <p>This pops up intellisense on the methods that the HomeController class has. However for the example above, this does not happen. Only after inserting the ...
<p>You migth forget the controller type generic parameter:</p> <pre><code>Html.Actionlink&lt;YourControllerType&gt;(x=&gt;x. </code></pre> <p>The controller type is needed here because views are not coupled to the controller. Views are coupled to the model only.</p>
<p>In my experience, Intellisense in ASPX pages is flaky to say the least. I experienced the same as you described, as well as other unwanted effects. In some cases, Intellisense stops working at all.</p>
26,597
<p>Since many years a GUI-standard are the menu-bars of applications with menus popping up, if you click or hover an entry in the menu-bar. Some websites implement this feature too, but they are using Javascript, as far as I can see. For different reasons Javascript can be a problem, so the question: Is this possible ...
<p>I've done something like this before, and it's a trick pulled off by placing the menu items in anchor tags, with submenus in hidden divs INSIDE those anchor tags. The CSS trick is to make the inner div appear during the a:hover event.</p> <p>It looks something like:</p> <pre><code>&lt;style&gt; A DIV { displa...
<p>You can use the pseudoclass :hover to get an hover effect.</p> <pre><code>a:link { color: blue; } a:hover { color: red; } </code></pre> <p>I can give a more extensive example but not right now (need to get the kids to the dentist).</p>
28,874
<p>Does anyone use have a good regex library that they like to use? Most of the regexes that you find online either contain bugs or are so focused on the edge cases that it turns into a competition to validate whatever spec 100%. Of course you can write your own, but when you are billing by the hour its handy to have a...
<p>You can search for regular expression in <a href="http://regexlib.com/" rel="nofollow noreferrer">regexlib</a>.</p>
<p>e-texteditor hilights what you're searching for as you type it. This is incredibly useful, as you can paste your 'sample text' into a file, and just type your regex into the search field, and see what it's matching right in front of you.</p> <p>None of these 'visual regex builder' things are substitutes for actuall...
3,181
<p>I'm trying to use the following code but it's returning the wrong day of month.</p> <pre><code>Calendar cal = Calendar.getInstance(); cal.setTime(sampleDay.getTime()); cal.set(Calendar.MONTH, sampleDay.get(Calendar.MONTH)+1); cal.set(Calendar.DAY_OF_MONTH, 0); return cal.getTime(); </code></pre>
<p>Get the number of days for this month:</p> <p><pre><code> Calendar cal = Calendar.getInstance(); cal.setTime(sampleDay.getTime()); int noOfLastDay = cal.getActualMaximum(Calendar.DAY_OF_MONTH); </pre></code></p> <p>Set the Calendar to the last day of this month:</p> <p><pre><code> Calendar cal = Calendar.getInst...
<p>I think this should work nicely:</p> <pre><code>Dim MyDate As Date = #11/14/2012# 'This is just an example date MyDate = MyDate.AddDays(DateTime.DaysInMonth(MyDate.Year, MyDate.Month) - MyDate.Day) </code></pre>
9,800
<p>I'm trying to write a RegEx for a code generator (in C#) to determine a proper class or package name of an AS3 class.</p> <p>I know that class names</p> <ul> <li>must start with a letter (capital or otherwise)</li> <li>any other digit can be alphanumeric</li> <li>cannot have spaces</li> </ul> <p>Is there anything...
<p>Although you can start class names with lower case letters and include underscores and dollar signs, the "naming <strong>convention</strong>" is to start the class name and each separate word with a capital letter (e.g. UsefulThing), and not include underscores. When I see classes like <code>useful_thing</code>, it ...
<p>Here are some more valid classes. </p> <p>Actionscript 3 classes (and packages) must start with a letter, "_", or "$". They may also contain (but not start with) a number.</p> <pre><code>public class $Test {} public class _Test {} public class test {} </code></pre>
4,182
<p>What kind of execution rate do you aim for with your unit tests (# test per second)? How long is too long for an individual unit test? </p> <p>I'd be interested in knowing if people have any specific thresholds for determining whether their tests are too slow, or is it just when the friction of a long running test ...
<p>All unit tests should run in under a second (that is all unit tests combined should run in 1 second). Now I'm sure this has practical limits, but I've had a project with a 1000 tests that run this fast on a laptop. You'll really want this speed so your developers don't dread refactoring some core part of the model...
<p>I judge my unit tests on a per test basis, not by by # of tests per second. The rate I aim for is 500ms or less. If it is above that, I will look into the test to find out why it is taking so long.</p> <p>When I think a test is to slow, it usually means that it is doing too much. Therefore, just refactoring the ...
3,168
<p>I'm wondering if I'll have trouble installing SQL Server 2008 on my development machine whilst our production server is 2005? E.g. is something change so that my 2005 databases/sps/functions/views will not work correctly or other issues I should think about?</p> <p>Would like to do this just to test drive the new S...
<p>I am using only SQL server 2008 on my dev machine against production SQL server 2005 systems, and have not encountered any problem yet.</p>
<p>Yes. We do exactly this even though our production systems are 2005, and have run into very few issues. While there are some compatibility issues you'll want to know about there are also a few benefits:</p> <ul> <li>Sql Management Studio is based off VS 2008 so if you are using VS 2008 you don't get VS 2005 insta...
34,075
<p>I have a set of objects which I iterate through, however I may decide during the iteration that one (or more) of those objects now need to be deleted. </p> <p>My code goes as follows:</p> <pre><code>if( ! m_Container.empty() ) { for( typedefedcontainer::iterator it = m_Container.begin(); ...
<p>It depends on the container. The list container supports deletion during enumeration by returning a new iterator from the erase method that represents the next item in the list. map doesn't support this.</p> <p>A simple method for map is to accumulate the items you want to erase in a separate list, and then itera...
<p>Fixed by the following:</p> <pre><code>for( typedefedcontainer::iterator it = m_Container.begin(); it != m_Container.end(); ) { if( ! ( SomeFunction( (*it), "test", "TEST!", false )) ) { // If function returns false, delete object. m_Container.erase( it++ ); } else {...
46,010
<p>I understand how slicer programs create sets of closed-loop polygons to print on a layer-by-layer basis. For a given closed loop polygon which needs to be printed, the tool path generator will know the coordinates and how those coordinates are connected to each other, such that traversing a set of segments in that ...
<p>While <a href="https://3dprinting.stackexchange.com/a/7972/8884">this</a> answer makes a valid attempt at answering the question, it is based on personal experience.</p> <p>I went to the literature and directly to the source code in Cura to find the answer. In the academic article "<a href="https://link.springer.c...
<h2>Math</h2> <p>In math, there is a way how a path is to be followed, and that is usually counterclockwise:</p> <p>Assuming a perimeter path of a circle with <span class="math-container">$r=1$</span> around <span class="math-container">$(2,2)$</span>, then the path can be defined as <span class="math-container">$f(p)...
1,180
<p>When I look at Amazon.com and I see their URL for pages, it does not have <code>.htm</code>, <code>.html</code> or <code>.php</code> at the end of the URL.</p> <p>It is like:<br> <a href="http://www.amazon.com/books-used-books-textbooks/b/ref=topnav_storetab_b?ie=UTF8&amp;node=283155" rel="noreferrer">http://www.am...
<p>Your browser doesn't care about the extension of the file, only the content type that the server reports. (Well, unless you use IE because at Microsoft they think they know more about what you're serving up than you do). If your server reports that the content being served up is Content-Type: text/html, then your ...
<p>In Django (a web application framework for python), you design the URLs yourself, independent of any file name, or even any path on the server for that matter.</p> <p>You just say something like "I want <code>/news/&lt;number&gt;/</code> urls to be handled by this function"</p>
41,770
<p>I can't, for the life of me, remember what exactly our teacher said that day and I'm hoping you would probably know.</p> <p>The module is "Data Structures and Algorithms" and he told us something along the lines of:</p> <blockquote> <p>The <code>if</code> statement is the most expensive [something]. [something...
<p>At the very lowest level (in the hardware), yes, <strong>if</strong>s are expensive. In order to understand why, you have to understand how <a href="http://en.wikipedia.org/wiki/Pipeline_(computing)" rel="noreferrer">pipelines</a> work.</p> <p>The current instruction to be executed is stored in something typically...
<p>The most expensive in terms of ALU usage? It uses up CPU registers to store the values to be compared and takes up time to fetch and compare the values each time the if statement is run.</p> <p>Therefore an optimization of that is to do one comparison and store the result as a variable before the loop is run.</p> ...
40,704
<p>Why would I choose to use Groovy when I could use Jython or Jruby? Does the language provide any inherent advantages to make up for the fact that Jython and Jruby skills are applicable to their parent languages outside of the JVM? </p> <p>Keep in mind that I purposely keeping this question generic, but if there are...
<p>I've done pretty extensive development in Ruby and Groovy (as well as a little Jython using Grinder as a load testing tool).</p> <p>Of the 3, I prefer Groovy the most. I like the closure syntax the best and I think that it has the tightest integration in how it works with other java classes on the JVM. It's been ...
<p>I've only had experience with Jython and Groovy. The biggest disadvantage with Jython, at the moment, is that the latest release recommended for production (2.2.1) has a feature set that "roughly corresponds to that of Python-2.2" (<a href="http://www.jython.org/Project/userfaq.html#what-is-the-current-status-of-jyt...
36,661
<p>I'm a web developer with no formal computing background behind me, I've been writing code now some years now, but every time I need to create a new class / function / variable, I spend about two minutes just deciding on a name and then how to type it.</p> <p>For instance, if I write a function to sum up a bunch of ...
<p>You're looking for <a href="http://code.msdn.microsoft.com/sourceanalysis" rel="nofollow noreferrer">StyleCop</a>.</p>
<p>Luckily enough I don't believe there is a standardized way this is done. I pick the one that I like, which consequently also seems to be the standard all other source code I've seen uses, and run with it.</p>
31,159
<p>What libraries and/or packages have you used to create blog posts with code blocks? Having a JavaScript library that would support line numbers and indentation is ideal.</p>
<p>The <a href="http://qbnz.com/highlighter/" rel="nofollow noreferrer">GeSHi text highlighter</a> is pretty awesome. If you're using WordPress, <a href="http://wordpress.org/extend/plugins/wp-syntax/" rel="nofollow noreferrer">there's a plugin</a> for you already</p>
<p>If that's my own code, I would just use <a href="http://www.scintilla.org/SciTE.html" rel="nofollow noreferrer" title="SciTE source code editor">SciTE</a>'s export to HTML and paste it. Otherwise (highlighting code like it is done here), I would prefer to do it on server side: JS highlighting (as seen, for example, ...
13,854
<p>What is the best way to divide a 32 bit integer into four (unsigned) chars in C#.</p>
<p>Quick'n'dirty:</p> <pre class="lang-csharp prettyprint-override"><code>int value = 0x48454C4F; Console.WriteLine(Encoding.ASCII.GetString( BitConverter.GetBytes(value).Reverse().ToArray() )); </code></pre> <p>Converting the int to bytes, reversing the byte-array for the correct order and then getting the ASCII cha...
<p>Do get the 8-byte-blocks:</p> <pre><code>int a = i &amp; 255; // bin 11111111 int b = i &amp; 65280; // bin 1111111100000000 </code></pre> <p>Do break the first three bytes down into a single byte, just divide them by the proper number and perform another logical and to get your final byte.</p> <p>Edit: Jason's s...
14,724
<p>I'm working on a webserver that I didn't totally set up and I'm trying to figure out which parts of a web page are being sent encrypted and which aren't. Firefox tells me that parts of the page are encrypted, but I want to know what, specifically, is encrypted.</p>
<p>For each element loaded in page, check their scheme: </p> <ul> <li>it starts with HTTPS: it is encrypted.</li> <li>it starts with HTTP: it's not encrypted.</li> </ul> <p>(you can see a relatively complete list on firefox by right-clicking on the page and selecting "View Page Info" then the "medias"tab.</p> <p>EDI...
<p>The best tool I have found for detecting http links on a https connection is <a href="http://fiddler2.com/fiddler2/version.asp" rel="nofollow noreferrer">Fiddler</a>. It's also great for many other troubleshooting efforts.</p>
39,303
<p>One thing I really like about AS3 over AS2 is how much more compile-time type-checking it adds. However, it seems to be somewhat lacking in that there is no type-checked enumeration structure available. What's a good (best / accepted) way to do custom enumerated types in AS3?</p>
<p>your answer after the jump :-)</p> <p><a href="http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7f2f.html" rel="noreferrer">Enumerations with classes</a></p>
<p>I know, this is a little outdated and does not exactly answer your question, but you might wanna check out <a href="https://haxe.org" rel="nofollow noreferrer">Haxe</a>. You can also use it to generate AS3 for you, plus there are many other reasons to use it. But this'd really get off topic...</p>
42,709
<p>We are struggling to configure our web app to be able to connect with web services via Spring WS. We have tried to use the example from the documentation of client-side Spring-WS, but we end up with a WebServiceTransportException. The XML config looks like this:</p> <pre><code>&lt;bean id="webServiceTemplate" class...
<p>Override HttpClient with a constructor that takes the parameters and wire through Spring using constructor-args</p> <pre><code>public MyHttpClient(HttpClientParams params, UsernamePasswordCredentials usernamePasswordCredentials) { super(params); getState().setCredentials(AuthScope.ANY, usern...
<p>If you are using a defaultHttpClient like you are in your example, Use the afterPropertiesSet method on your HTTPMessageSender and that should fix your problem by applying the credentials correctly </p>
14,089
<p>How should I show users which fields are compulsory in a windows forms application.</p> <p>I have considered changing the label color or maybe the background color of the text box.</p> <p>I use an error provider to show a red exclamation mark next to the field, however this is only visible after they have clicked ...
<ul> <li>Asterisk or icon to the side of control</li> <li>Red border when required validation fails (when user tries to save)</li> <li>Bold Labels</li> <li>Different background color for required controls (perhaps only when user tries to save)</li> </ul>
<p>I would use the ErrorProvider control, possibly with a different icon to represent "required" as opposed to "in error". I would also ensure the fields start with error icon shown next to them and the icon should only disappear once data has been provided for that field.</p> <p>Only doing validation/notification of ...
24,341
<p>It seems to me that it would work perfectly well to do tail-recursion optimization in both C and C++, yet while debugging I never seem to see a frame stack that indicates this optimization. That is kind of good, because the stack tells me how deep the recursion is. However, the optimization would be kind of nice as ...
<p><strong>All current mainstream compilers perform tail call optimisation</strong> fairly well (and have done for more than a decade), <a href="https://godbolt.org/g/TjqTHV" rel="noreferrer">even for mutually recursive calls</a> such as:</p> <pre><code>int bar(int, int); int foo(int n, int acc) { return (n == 0)...
<p>As Greg mentions, compilers won't do it in debug mode. It's ok for debug builds to be slower than a prod build, but they shouldn't crash more often: and if you depend on a tail call optimization, they may do exactly that. Because of this it is often best to rewrite the tail call as an normal loop. :-(</p>
5,429
<p>Just wondering what the difference between <code>BeginInvoke()</code> and <code>Invoke()</code> are? </p> <p>Mainly what each one would be used for.</p> <p>EDIT: What is the difference between creating a threading object and calling invoke on that and just calling <code>BeginInvoke()</code> on a delegate? or are t...
<p>Do you mean <code>Delegate.Invoke</code>/<code>BeginInvoke</code> or <code>Control.Invoke</code>/<code>BeginInvoke</code>?</p> <ul> <li><code>Delegate.Invoke</code>: Executes synchronously, on the same thread.</li> <li><code>Delegate.BeginInvoke</code>: Executes asynchronously, on a <code>threadpool</code> thread.<...
<p>Delegate.BeginInvoke() asynchronously queues the call of a delegate and returns control immediately. When using Delegate.BeginInvoke(), you should call Delegate.EndInvoke() in the callback method to get the results.</p> <p>Delegate.Invoke() synchronously calls the delegate in the same thread.</p> <p><a href="http...
28,414
<p>I would like the version property of my application to be incremented for each build but I'm not sure on how to enable this functionality in Visual Studio (2005/2008). I have tried to specify the AssemblyVersion as 1.0.* but it doesn't get me exactly what I want. </p> <p>I'm also using a settings file and in earlie...
<p>With the "Built in" stuff, you can't, as using 1.0.* or 1.0.0.* will replace the revision and build numbers with a coded date/timestamp, which is usually also a good way. </p> <p>For more info, see the <a href="http://msdn2.microsoft.com/en-us/library/c405shex(vs.80).aspx" rel="noreferrer">Assembly Linker</a> Docum...
<p>If you want an auto incrementing number that updates each time a compilation is done, you can use <a href="http://testdox.wordpress.com/versionupdater/" rel="nofollow noreferrer">VersionUpdater</a> from a pre-build event. Your pre-build event can check the build configuration if you prefer so that the version number...
2,307
<p>How can I find the font that the user has set in their Windows Display Properties using C# in .NET?</p> <p>I want to display a form using the fonts that the user has selected. The fonts I want are those selected in the Windows Display Properties form for 3D-objects, menus and window title bars. But I cannot find a ...
<p>Firstly, you can use "svn info --xml >out.xml" to get the svn information to a text file. You can then use a Nant xml-peek to get a value out of the file into a variable.</p> <pre><code>&lt;xmlpeek file="out.xml" xpath="/info/entry/url" property="svn.url" /&gt; </code></pre>
<p>The entries in the .svn directory are not really meant to be accessed directly. I don't know much about what you're doing but I'd suggest you use the mechanism you use to checkout the project to find the HEAD version and path. (I'd actually assume that becuase you are checking out the project you already know the pa...
23,212
<p>I run into this obstacle when my debugger steps into some classfile without corresponding source. Finding it is often difficult:</p> <ul> <li><p>You have to search for the site hosting the respective project, and find its ``download source'' page (for instance, last time I searched for the JPA API, and it took me ...
<p>Both <a href="https://docs.sonatype.org/display/M2ECLIPSE/Resolving+artifact+sources" rel="nofollow noreferrer">m2eclipse</a> and IDEA will download the sources and javadocs for any dependencies. The m2eclipse sources can be downloaded by right-clicking on a dependency (or the whole project if you want all sources) ...
<p>it may be complicated but it is worth the initial effort.</p> <p>i do it the following way: in my project directory i have three major directories, </p> <ul> <li>src (my own)</li> <li>lib</li> <li>suppl (sources / javadocs when no sources exist)</li> </ul> <p>i put in suppl one zip file per library, containing th...
29,341
<p>I'm trying this:</p> <pre><code>Type ThreadContextType = typeof(Application).GetNestedType("ThreadContext", System.Reflection.BindingFlags.NonPublic); MethodInfo FDoIdleMi = ThreadContextType.GetMethod("FDoIdle", BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(Int32) }, null); </code><...
<p>You need to fully-qualify the method name, because they're using explicit interface implementation:</p> <pre><code>Type type = typeof( Application ).GetNestedType( "ThreadContext", BindingFlags.NonPublic ); MethodInfo doIdle = type.GetMethod( "System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FDoIdle",...
<p>It's hacky, but this works:</p> <pre><code>using System; using System.Linq; using System.Reflection; using System.Windows.Forms; public class Test { static void Main() { Type clazz = typeof(Application).GetNestedType("ThreadContext", BindingFlags.NonPublic); Type iface = typeof(Form).Assem...
26,449
<p>For a .net developer, what's the learning curve to get into mobile development?</p> <p>How many different operating systems are there that run .net?</p> <p>Is windows mobile that same as windows ce?</p>
<p><strong>Learning Curve</strong></p> <p>I hate to say "it depends" but it really does, and on several factors. What is your ".NET development" experience? Keep in mind that the CF supports C# and VB.NET, so if you're a COBOL.NET guy, it's going to be steeper than if you're a C# guy. If you do primarily ASP.NET on...
<p>I think the curve may depend a bit on what kind of .Net world you come from as well as what kind of mobile development you want to get into. For example, if you are a web developer and want to build a site using the Mobile controls within the compact .Net framework this may not be as difficult as say a web develope...
49,605
<p>This is the <code>PATH</code> variable without sudo:</p> <pre><code>$ echo 'echo $PATH' | sh /opt/local/ruby/bin:/usr/bin:/bin </code></pre> <p>This is the <code>PATH</code> variable with sudo:</p> <pre><code>$ echo 'echo $PATH' | sudo sh /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bi...
<p>This is <del>an annoying function</del> <i>a feature</i> of sudo on many distributions.</p> <p>To work around this "problem" on ubuntu I do the following in my ~/.bashrc</p> <pre><code>alias sudo='sudo env PATH=$PATH' </code></pre> <p>Note the above will work for commands that don't reset the $PATH themselves. Ho...
<p>Er, it's not really a test if you don't add something to your path:</p> <pre> bill@bill-desktop:~$ ls -l /opt/pkg/bin total 12 -rwxr-xr-x 1 root root 28 2009-01-22 18:58 foo bill@bill-desktop:~$ which foo /opt/pkg/bin/foo bill@bill-desktop:~$ sudo su root@bill-desktop:/home/bill# which foo root@bill-desktop:/home...
32,148
<p>I have a tab page that should be hidden if a property (BlahType) is set to 1 and shown if set to 0. This is what I <em>WANT</em> to do:</p> <pre><code>&lt;TabItem Header="Blah"&gt; &lt;TabItem.Triggers&gt; &lt;DataTrigger Binding="{Binding BlahType}" Value="0"&gt; &lt;Setter Property="TabIte...
<p>I believe that the Triggers collection of a control only currently supports EventTriggers. If you would like to use a DataTrigger simply place it inside a style, for your example:</p> <pre><code>&lt;TabItem Header="Blah"&gt; &lt;TabItem.Style&gt; &lt;Style&gt; &lt;Style.Triggers&gt; ...
<p>Well, you can't do that using triggers (not unless you are inside a DataTemplate, ControlTemplate or a Style).</p> <p>You can do it using a binding, you will need to write a custom ValueConverter that will translate between 0/1 to Visible/Hidden and then you can bind the Visibility property to the BlhaType property...
38,815
<p>Does anyone know how you setup new commands to launch an application from the Start->Run box?</p> <p>ie. you can type "firefox", "winword" or "excel" into the Run box and those applications will open even though they're not in the system path, but others won't. For example, with Firefox, there's no files named fire...
<p>From <a href="http://commandwindows.com/runline.htm" rel="nofollow noreferrer">http://commandwindows.com/runline.htm</a>:</p> <blockquote> <p><strong>Adding applications to the Path</strong></p> <p>Alternatively, the Registry can be edited to explicitly contain the path to the desired executable file or files. The R...
<p>Run works with search paths, which include the Path environment variable and some others. There might be more information in the MSDN, give me a moment and I'll look it up.</p>
40,141
<p>I have been running <a href="http://en.wikipedia.org/wiki/StyleCop" rel="noreferrer">StyleCop</a> over some C# code, and it keeps reporting that my <code>using</code> directives should be inside the namespace.</p> <p>Is there a technical reason for putting the <code>using</code> directives inside instead of outside...
<p>There is actually a (subtle) difference between the two. Imagine you have the following code in File1.cs:</p> <pre><code>// File1.cs using System; namespace Outer.Inner { class Foo { static void Bar() { double d = Math.PI; } } } </code></pre> <p>Now imagine that some...
<p>It is a better practice if those <strong>default</strong> using i.e. "<em>references</em>" used in your source solution should be outside the namespaces and those that are <strong>"new added reference"</strong> is a good practice is you should put it inside the namespace. This is to distinguish what references are b...
15,232
<p>I am looking for a simple JavaScript example that updates DOM.<br> Any suggestions?</p>
<p>Here is a short pure-javascript example. Assume you have a div with the id "maincontent".</p> <pre><code>var newnode = document.createTextNode('Here is some text.'); document.getElementById('maincontent').appendChild(newnode); </code></pre> <p>Of course, things are a lot easier (especially when you want to do more...
<p>I believe that this tutorial on jQuery has an example that might help you: <a href="http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery" rel="nofollow noreferrer">http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery</a></p>
6,589
<p>I've been working through <a href="http://gigamonkeys.com/book" rel="nofollow noreferrer">Practical Common Lisp</a> and as an exercise decided to write a macro to determine if a number is a multiple of another number:</p> <p><code>(defmacro multp (value factor)<br> `(= (rem ,value ,factor) 0))</code></p> <p>so...
<p>Siebel gives an extensive rundown (for simple cases anyway) of possible sources of leaks, and there aren't any of those here. Both <code>value</code> and <code>factor</code> are evaluated only once and in order, and <code>rem</code> doesn't have any side effects.</p> <p>This is not good Lisp though, because there's...
<p>No, no symbol introduced in the macro's "lexical closure" is released to the outside.</p> <p>Note that leaking isn't NECESSARILY a bad thing, even if accidental leaking almost always is. For one project I worked on, I found that a macro similar to this was useful:</p> <pre><code>(defmacro ana-and (&amp;rest forms)...
8,510
<p>I've been trying to get up to speed on some of the newer features in C# and one of them that I haven't had occasion to use is anonymous types.</p> <p>I understand the usage as it pertains to LINQ queries and I looked at <a href="https://stackoverflow.com/questions/48668/how-should-anonymous-types-be-used-in-c">this...
<p>With a bit of reflection, you can turn an anonymous type into a Dictionary&lt;string, object&gt;; Roy Osherove blogs his technique for this here: <a href="http://weblogs.asp.net/rosherove/archive/2008/03/11/turn-anonymous-types-into-idictionary-of-values.aspx" rel="nofollow noreferrer">http://weblogs.asp.net/roshero...
<p>I've used them for doing templated emails as they are great if you're using reflection and generics.</p> <p>Some info can be found here: <a href="http://www.aaron-powell.com/blog.aspx?id=1247" rel="nofollow noreferrer">http://www.aaron-powell.com/blog.aspx?id=1247</a></p>
20,306
<p>I want to deploy my web application (asp.net mvc), and I need to remove all the codebehind files from my project.</p> <p>Any scripts that you guys know of to do this?</p> <p>I prefer using a script since I can tweak it if need be.</p>
<p>Just select the publish web site option on your project and it should take care of that (if you use vs).</p> <p>Menu Build/Publish Website</p>
<p>I'd recommend using a web deployment project. This will compile your website and copy all of the files needed to for deployment into a new folder (without code-behind files, as they don't need to be deployed). You also get a little more control this way, as you can set up pre-build and post-build events.</p> <p>F...
18,757
<p>I am currently looking into using Lucene.NET for powering the search functionality on a web application I am working on. However, the search functionality I am implementing not only needs to do full text searches, but also needs to rank the results by proximity to a specified address.</p> <p>Can Lucene.NET handle ...
<p>You can implement a custom scorer to rank the results in order of distance, but you must filter the results before to be efficient. You can make use of the bounding boxes method, filtering the results in a square of 20 milles around your address, and after that apply the ranking. </p> <p>If I don't remember bad, In...
<p>What you are looking for is called spatial search. I'm not sure if there are extensions to Lucene.Net to do this but you could take a look at <a href="http://www.codeplex.com/NHibernateSpatial" rel="nofollow noreferrer">NHibernate Spatial</a>. Other than that, these queries are often done within the database. At le...
30,520
<p>In my knowledge, the RESTful WCF still has ".svc" in its URL.</p> <p>For example, if the service interface is like</p> <pre><code>[OperationContract] [WebGet(UriTemplate = "/Value/{value}")] string GetDataStr(string value); </code></pre> <p>The access URI is like "<a href="http://machinename/Service.svc/Value/2" ...
<p>In IIS 7 you can use the <a href="http://learn.iis.net/page.aspx/460/using-url-rewrite-module/" rel="noreferrer">Url Rewrite Module</a> as explained in this blog <a href="http://blogs.msdn.com/endpoint/archive/2008/08/22/rest-in-wcf-part-ix-controlling-the-uri.aspx" rel="noreferrer">post</a>. </p> <p>In IIS 6 you c...
<p>Add this to your global.asax</p> <pre><code>private void Application_BeginRequest(object sender, EventArgs e) { Context.RewritePath(System.Text.RegularExpressions.Regex.Replace( Request.Path, "/rest/(.*)/", "/$1.svc/")); } </code></pre> <p>This will replace /rest/Service1/arg1/arg2 by /Service1....
46,287
<p>I'm using Google App Engine and Django templates.<br> I have a table that I want to display the objects look something like:<br></p> <pre><code>Object Result: Items = [item1,item2] Users = [{name='username',item1=3,item2=4},..] </code></pre> <p>The Django template is:</p> <pre><code>&lt;table&gt; &lt;tr a...
<p>I found a "nicer"/"better" solution for getting variables inside Its not the nicest way, but it works.</p> <p>You install a custom filter into django which gets the key of your dict as a parameter</p> <p>To make it work in google app-engine you need to add a file to your main directory, I called mine <em>django_ha...
<p>shouldn't this:</p> <pre><code>{{ user.item }} </code></pre> <p>be this?</p> <pre><code>{{ item }} </code></pre> <p>there is no user object in the context within that loop....?</p>
5,654
<p>I've recently switched from being an employee of a small consulting company to being an independent consultant and as time goes on I will need to upgrade Windows and Visual Studio. So what is the most affordable way to go about this for a small time developer?</p> <p>My previous boss suggested I get a TechNet Plus ...
<p>I recommend that if VS Express is not good enough, use Professional. Standard is missing some really useful features, like a Remote Debugger. Here is a detailed comparison:</p> <p><a href="http://msdn.microsoft.com/en-us/vs2008/products/cc149003.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/vs2008...
<p>I think that Visual Studio Professional with MSDN Subscription doesn't offer much value compared to just purchasing Visual Studio 2010 Pro. You get testing licenses for Windows Server and MSSQL, but that's it. And you can get by just fine without those 90% of the time.</p> <p>But Visual Studio Premium with MSDN is ...
4,385
<p>I am working on a web application developed on C#/ASP.NET. We are using third-party controls for displaying Grids, Tabs, Trees and other complex controls in our pages. The problem is that these controls render a huge amount of HTML. Due to this the size of pages have grown heavily and the browser takes a while to lo...
<p>There's a Firefox extension, YSlow ( <a href="http://developer.yahoo.com/yslow/" rel="nofollow noreferrer">http://developer.yahoo.com/yslow/</a> ) that analyzes any web page and lists the specific changes to be made, to improve the speed. Some of the changes that it suggests are related to the web server, not the co...
<p>I would take a look at the Viewstate of the controls on the page. You should disable it if at all possible, since it gets serialized (and Base64 encoded I think) and stuffed in the page. If your updating the data in the controls on each post-back you should be able to safely disable viewstate and likely save a goo...
16,291
<p>In my database schema I have an entity that is identified. The identifier can be reused and thus there is a one-to-many relation with the entity. Example: A person can have a nickname. Nicknames are not unique and can be shared amongst many people. So the schema might look like:</p> <pre><code>PERSON id name nickna...
<p>I'm not sure if an ORM can handle this, but in straight SQL you could:</p> <ol> <li>Create a table of name/nickname pairs, </li> <li>INSERT INTO NicknameTable SELECT Nickname FROM temp WHERE Nickname NOT IN (SELECT Nickname FROM NicknameTable) </li> <li>Insert into main table knowing the Nickname exists. </li> <...
<p>Truthfully? I'd make nickname a varchar column in the Person table, and forget about the Nickname table. Nickname is an attribute of a person, not a separate entity.</p> <p>Is this a simplified example, and your 'identifiers' really <em>do</em> benefit from the entity-relationships?</p> <p><strong>edit:</strong>...
45,637
<p>Hi Anyone know of a simple system of getting xml formatted inside an editor. I mainly use textpad so that would be my main interest. What I'm really asking is that when I paste an xml string from a logfile or something into textpad that I can use a plugin or a third party tool to format the xml in textpad so it is...
<p>There are add-ons for textpad that do it. Look at <a href="http://www.textpad.com/add-ons/synu2z.html" rel="nofollow noreferrer">TextPad Syntax Definition Files</a> or <a href="http://www.textpad.com/add-ons/index.html" rel="nofollow noreferrer">TextPad add-ons: utilities</a>.</p>
<p>Notepad2 will be useful here. You can use it for editing and highlighting XML, HTML, Javascript and many other languages. Check it here:</p> <p><a href="http://www.flos-freeware.ch/notepad2.html" rel="nofollow noreferrer">http://www.flos-freeware.ch/notepad2.html</a></p>
26,600
<p>I have a simple software that is made in Delphi 7, and it crashes on Vista after a while. These are totally random crashes, nothing is written in any crash log, just stops working and then Vista tries to find a solution.</p> <p>Does anyone have any ideas ?</p>
<p>Try one of the exception catchers, like madExcept. It can often help you find out what is happening inside your app at the time of trouble. In general though Delphi apps are fine in Vista, so there must be some interaction, perhaps user rights, that is causing trouble.</p>
<p>just to point out--madExcept has a "hang" detection option that should help.</p>
12,632
<p>I have a data stream that may contain \r, \n, \r\n, \n\r or any combination of them. Is there a simple way to normalize the data to make all of them simply become \r\n pairs to make display more consistent?</p> <p>So something that would yield this kind of translation table:</p> <pre><code>\r --&gt; \r\n \n ...
<p>I believe this will do what you need:</p> <pre><code>using System.Text.RegularExpressions; // ... string normalized = Regex.Replace(originalString, @"\r\n|\n\r|\n|\r", "\r\n"); </code></pre> <p>I'm not 100% sure on the exact syntax, and I don't have a .Net compiler handy to check. I wrote it in perl, and converte...
<p>This is the answer to the question. The given solution replaces a string by the given translation table. It does not use an expensive regex function. It also does not use multiple replacement functions that each individually did loop over the data with several checks etc.</p> <p>So the search is done directly in 1 ...
17,026
<p>Has anybody succeeded in customizing the Places Bar for VS 2008? My customizations from VS 2005 did not transfer to 2008 (obviously), and no matter what I do with the registry, I cannot make my custom places appear on the Open dialogs. I have read and applied the relevant MS KB article, to no avail.</p> <p>This use...
<p>some observations:</p> <p>VS2008 uses now Common File Dialog. With Powertoys TweakUK i was able to set all places to 'none' and the VS2008 'Open File' dialog becomes empty.</p> <p>Unfortunately VS2008 ignores user defined places or directories, and shows instead the default places: 'Desktop', 'standard_project_fol...
<p>VS2005 and VS2008 (sp1 anyway) both still use the following registry Key structure</p> <p><strong>So, for vs2008, create these reg paths.</strong></p> <blockquote> <p>HKCU/Software/Microsoft/VisualStudio/9.0/Open Find/Places/UserDefinedPlaces/Place0/Path = (some path</p> <p>HKCU/Software/Microsoft/VisualS...
29,414
<p>I have got a template class as follows:</p> <pre><code>class MyClass&lt;T&gt; { T field; public void myMethod() { field = new T(); // gives compiler error } } </code></pre> <p>How do I create a new instance of T in my class?</p>
<p>After type erasure, all that is known about <code>T</code> is that it is some subclass of <code>Object</code>. You need to specify some factory to create instances of <code>T</code>.</p> <p>One approach could use a <a href="http://docs.oracle.com/javase/8/docs/api/java/util/function/Supplier.html" rel="noreferrer">...
<p>Class classOfT</p> <pre><code> try { t = classOfT.newInstance();//new T(); NOTE: type parameter T cannot be instantiated directly } catch (Exception e) { e.printStackTrace(); } </code></pre>
38,453
<p>I'm currently creating a window system for XNA games from scratch. I'm developing primarily for Windows, but who knows what platforms I might support in the future. Feel free to answer if you know this for native Direct3D, since the performance semantics should be similar. If possible, consider what would change if ...
<ul> <li>If you want that level of control with animations (ie. having multiple going on the same control at once) then you're going to have do multiple passes. So either enable this kind of thing in a shader and do multiple passes with the shader, or do the standard Render->Resolve->Rerender loop.</li> <li>There is in...
<p>The Xbox360 has 10MB of special memory used for the current render target. But the rest said about how it works is not quite accurate. Whatever render target is being used sits in that 10MB of space. Otherwise you can have as many render targets as you want. If your render target is bigger than the 10MB (like 12...
30,173
<p>I'm building a web portal where language content will generally depend on the "accept-language" sent by the browser. The same content-URI will thus serve different content to different users depending on their browser setting.</p> <p>I'm very curious to know how this will affect search indexing. Does Google index u...
<p>They don't send accept-language, so the site will be indexed in the default language that you select.</p> <p>I recommend you to have different URL for each language, not only for the search engines, but for letting the user change the site language without changing the "accept-language" and letting the user to send...
<p>Kien Problem!</p> <p>Google doesnt care what language the text is in it just indexes!</p>
48,120
<p>I'm trying to move my database.mdf file from a development environment to a SQL Server Express server that is hosted on my VPS - but I can't figure out how to attach the file to my database server. Help!</p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms179877.aspx" rel="nofollow noreferrer"><code>sp_attach_db</code></a> (or CREATE DATABASE FOR ATTACH) - don't forget to bring the LDF (log) files, too.</p>
<p>This will help you</p> <p><a href="http://support.microsoft.com/kb/224071" rel="nofollow noreferrer">http://support.microsoft.com/kb/224071</a></p>
38,880
<p>In C, what is the most efficient way to convert a string of hex digits into a binary <code>unsigned int</code> or <code>unsigned long</code>?</p> <p>For example, if I have <code>0xFFFFFFFE</code>, I want an <code>int</code> with the base10 value <code>4294967294</code>.</p>
<p>You want <a href="http://www.cplusplus.com/reference/clibrary/cstdlib/strtol.html" rel="noreferrer"><code>strtol</code></a> or <a href="http://en.cppreference.com/w/c/string/byte/strtoul" rel="noreferrer"><code>strtoul</code></a>. See also the <a href="http://man7.org/linux/man-pages/man3/strtoul.3.html" rel="noref...
<p>This currently only works with lower case but its super easy to make it work with both.</p> <pre><code>cout &lt;&lt; "\nEnter a hexadecimal number: "; cin &gt;&gt; hexNumber; orighex = hexNumber; strlength = hexNumber.length(); for (i=0;i&lt;strlength;i++) { hexa = hexNumber.substr(i,1); if ((hexa&gt;="0"...
3,157
<p>Is there a way to start PowerShell in a specific folder from Windows Explorer, e.g. to right-click in a folder and have an option like "Open PowerShell in this Folder"?</p> <p>It's really annoying to have to change directories to my project folder the first time I run MSBuild every day.</p>
<p>In Windows Explorer, just go to the Address Bar at the top (keyboard shortcuts: <kbd>Alt</kbd>+<kbd>D</kbd> or <kbd>Ctrl</kbd>+<kbd>L</kbd>) and type <code>powershell</code> or <code>powershell_ise</code> and press <kbd>Enter</kbd>. A PowerShell command window opens with the current directory.</p>
<p>to run PowerShell as an admin in any location of file explorer go to that folder and use the shortcut &quot;alt + f + s + a&quot; to open powershell as an admin in that specific folder location</p>
22,235
<p>Everyone in my office uses Macs and therefore most use Safari. </p> <p>We have a page that has 30 checkboxes on it, I didn't even do the HTML myself but no matter if I use the html input checkbox with a label or an asp:Checkbox usig the text property for the label my boss is irritated because the checkbox is a litt...
<p>wow i didn't even really notice the box was slightly lower than the text until you mentioned it. you can work around that in CSS though:</p> <pre><code>label { vertical-align: bottom; } </code></pre> <p>aligns the text to the checkboxes for me (Safari 3.2.1)</p>
<p>I am not sure about the Safari and checkbox issue, but I have experienced the situation where the boss or client focuses on something that seems like a non-issue.</p> <p>The way I handle that is saying something similar to, "I can research this issue and try to find a solution or workaround, but it will probably ta...
42,340