instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I have mounted two radial fan on my printer as a part cooling solution.</p> <p><a href="https://i.stack.imgur.com/MTeZ5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MTeZ5.png" alt="radial blower fan"></a></p> <p>As you can see, the fan has input on the left side and blows air down. Does a mir...
<p>Yes these do exist, but I've never seen them in the size you are interested in, see e.g. these projector fans:</p> <p><a href="https://i.stack.imgur.com/Jw36Y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Jw36Y.png" alt="enter image description here"></a></p> <p>An alternative are fans that at...
<p>I did also some research on this and decided to go with this solution. This fan only measures 50x50x10mm and is easy flippable: <a href="https://de.aliexpress.com/item/1005001894771961.html" rel="nofollow noreferrer">https://de.aliexpress.com/item/1005001894771961.html</a></p> <p><a href="https://i.stack.imgur.com/W...
1,478
<p>In looking at the use of C# in a ISV setting, I'm wondering what prominent C# based desktop apps are out there? I can think of only Paint .NET. </p> <p>Is C# a good idea for an ISV, or should one stick to more native environments like Delphi or even QT?</p> <p>Of course any experienced based advise or feedback wou...
<p>Yes, C# can be used quite effectivly to build applications. In regards what applciations are out there, what are you looking for? Big apps, little apps?</p> <p>I know of a big app that is built on the .NET framework (unsure if C# or VB) and that is Quickbooks.</p>
<p>I believe that MS use C# to build many of their apps both Windows and Web. At this time, C# is a great language to go with because of the flexibility of the language/framework.</p>
25,650
<p>How can I check in C# if button.Click event has any handlers associated? If (button.Click != null) throws compile error.</p>
<p>You can't. Events just expose "add a handler" and "remove a handler" - that's all. (In fact in the CLR you can also have metadata to associate a method with "fire the event" but the C# compiler never generates that.) Some event publishers may offer additional means to check whether or not there are any subscribers (...
<p>I think you can if you are in the class that raises the event.</p> <p>You can define the handler and enumerate each.</p> <p>e.g. If your event is defined as </p> <pre><code>event System.EventHandler NewEvent; </code></pre> <p>Then on the raise event method you might create you can do...</p> <pre><code> Even...
28,817
<p>How can I visually customize autocomplete fields in Wicket (change colors, fonts, etc.)?</p>
<p>You can use CSS to modify the look of this component. For the Ajax auto-complete component in 1.3 the element you want to override is div.wicket-aa, so for example you might do:</p> <pre><code>div.wicket-aa { background-color:white; border:1px solid #CCCCCC; color:black; } div.wicket-aa ul { list-st...
<p>Perilandmishap has probably the most usefull answer for your needs. Personally, I always found the default Ajax auto complete control in Wicket to be woefully insufficient for my needs. If you really want a professional "feel" to your auto complete, roll your an using Wicket's Ajax libraries.</p>
9,548
<p>I've got a question concerning fields in databases which are measures that might be displayed in different units but are stored only in one, such as &quot;height&quot;, for example.</p> <p>Where should the &quot;pattern unit&quot; be stated?. Of course, in the documentation, etc... But we all know nobody reads the d...
<p>What's weird about height_cm? Looks good to me. </p> <p>Sometimes you see measures and units in two separate fields, which is much more painful.</p> <p>As long as you know the units aren't going to change, I think height_cm is a good way to deal with it.</p>
<p>I agree, nothing wrong with adding the unit to the field name.</p> <p>The only thing I'd say is to make the naming convention consistent across your database - i.e. avoid situations where you have both <code>height_cm</code> and <code>mm_width</code> present in the same database!</p>
21,019
<p>I'm looking for a way of getting a <strong>concurrent collection</strong> in <strong>C#</strong> or at least a collection which supports a <strong>concurrent enumerator</strong>. Right now I'm getting an <code>InvalidOperationException</code> when the collection over which I'm iterating changes. </p> <p>I could j...
<p>Other than doing a deep-copy your best bet might be to lock the collection:</p> <pre><code> List&lt;string&gt; theList = (List&lt;String&gt; )callingForm.Invoke(callingForm.delegateGetKillStrings); lock(theList.SyncRoot) { foreach(string s in theList) { // Do some Jazz } } <...
<p>If you want to use the FCL collections, then locking is the only way to support iteration / modification from multiple threads that may overlap.</p> <p>Be careful what you use as your lock object, though. Using SyncRoot is only a good idea if the collection itself is a private member of the class that uses it. If t...
5,970
<p>(See related question: <a href="https://stackoverflow.com/questions/162917/how-do-i-report-an-error-midway-through-a-chunked-http-repsonse-without-closing">How do I report an error midway through a chunked http repsonse without closing the connection?</a>)</p> <p>In my case, the #1 desire is for the browser to disp...
<p>My own answer, after research.</p> <p>Part one: There seems to be no way to convince the application servers that I tested to put an error onto the wire past the "committed" phase. The following Servlet code results in legal HTTP Chunked Transfer headers on the socket. Interestingly, in the case of WebSphere an e...
<p>I think you're going about it the wrong way. It seems like it would be simpler to not actually start sending the data until you're sure if will be a success or a failure. That way you can send an error message at the start if needed, instead of sending partial data that's not valid.</p> <p>If you really must, you m...
22,937
<p>What query can return the names of all the stored procedures in a SQL Server database</p> <p>If the query could exclude system stored procedures, that would be even more helpful.</p>
<p>As Mike stated, the best way is to use <code>information_schema</code>. As long as you're not in the master database, system stored procedures won't be returned.</p> <pre><code>SELECT * FROM DatabaseName.INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_TYPE = 'PROCEDURE' </code></pre> <p>If for some reason you had n...
<p>This, list all things that you want</p> <p>In Sql Server 2005, 2008, 2012 :</p> <pre><code>Use [YourDataBase] EXEC sp_tables @table_type = "'PROCEDURE'" EXEC sp_tables @table_type = "'TABLE'" EXEC sp_tables @table_type = "'VIEW'" </code></pre> <p>OR</p> <pre><code>SELECT * FROM information_schema.tables SELEC...
27,012
<p>I am tired of doing typical CRUD programming type applications. I would like to work on some interesting (not too hard) programming problems. Are there any sites out there to help me exercise my brain?</p>
<p>Project Euler: <a href="http://projecteuler.net/" rel="noreferrer">http://projecteuler.net/</a> is a nice collection of randomly interesting problems.</p> <p>Somewhat related (not always programming, but generally interesting to programmers) is the IBM ponder this site: <a href="http://domino.research.ibm.com/Comm/...
<p>Checkout for <a href="http://www.codechef.com/" rel="nofollow">CodeChef</a> Interesting problems here any language vl do</p>
34,963
<p>I want to find a sql command or something that can do this where I have a table named tblFoo and I want to name it tblFooBar. However, I want the primary key to also be change, for example, currently it is:</p> <pre><code>CONSTRAINT [PK_tblFoo] PRIMARY KEY CLUSTERED </code></pre> <p>And I want a name change to ch...
<p>This is just off the top of my head and isn't complete (you'd need to add similar code for indexes). Also, you would need to either add code to avoid renaming objects from a table with the same base name, but additional characters - for example, this code would also list tblFoo2 and all of its associated objects. Ho...
<p>SQL Server won't do this directly as far as I am aware. You would have to manually build the script to do the change. This can be achieved by generating the SQL for the table definition (SSMS will do this) and doing a search and replace on the names.</p>
23,290
<p>Say for example I have the following string:</p> <p>var testString = "Hello, world";</p> <p>And I want to call the following methods:</p> <p>var newString = testString.Replace("Hello", "").Replace("world", "");</p> <p>Is there some code construct that simplifies this, so that I only have to specify the Replace m...
<p>Create a function to which you pass the <code>String</code> and a <code>Dictionary(String, String)</code>. Iterate over each item in the Dictionary and <code>InputString.Replace(DictionaryEntry.Key, DictionaryEntry.Value)</code>. Return the string with the replaced values.</p> <p>But I'd just do <code>.Replace.Repl...
<p>I don't know if this is any sweeter, but you can do:</p> <pre><code>string inputString = "Hello, world"; string newString = new[] { "Hello", "world" }.Aggregate(inputString, (result, replace) =&gt; result.Replace(replace, "")); </code></pre> <p>This will start with the input string as the seed, and run thefunction...
42,060
<p>My printer ran out of black toner and I didn’t have a spare, so I thought it’d be a good idea to “print” documents to .XPS files for now, then print them when the new toner arrives.</p> <p>So, now I have my toner but I can’t work out how to print the files. I found <a href="http://www.timbarcz.com/blog/HowToPrintXP...
<p>I have had no problems printing XPS docs from IE. The first thing that comes to mind is what OS are you running, what version of IE, are all service packs installed, etc?</p> <p>Another option would be to copy the XPS files to a thumb drive (or send over the network) and print from another computer that does not h...
<p>Windows XP SP3, IE6, all up to date AFAIK.</p> <p>I use Firefox mostly, so haven't updated IE for ages. Maybe IE7 would be more successful.</p> <p>The point was that XPS is meant to be some kind of PDF-killer, but the difference is that PDF just works, while XPS has been a disaster. I don't mind errors, but I want...
27,952
<p>I am desiging a new website for my company and I am trying to implement switch navigation which is what I have used on all my sites in the past.</p> <pre><code>&lt;?php switch($x) { default: include("inc/main.php"); break; case "products": include("inc/products.php"); break; } ?&gt; </code></pre> <p>For some re...
<p>Yes, your PHP configuration has <strong>correctly</strong> got <code>register_globals</code> turned off, because that's incredibly insecure.</p> <p>Just put:</p> <pre><code>$x = $_REQUEST['x'] </code></pre> <p>at the top of your script.</p> <p>You can also use <code>$_GET</code> if you specifically only want thi...
<p>You can use <a href="http://php.net/manual/es/function.extract.php" rel="nofollow">http://php.net/manual/es/function.extract.php</a> to extract the variables if you want to do it, but keep in mind this lets any user set variables with the content they want in your script, which makes it as insecure as using register...
32,259
<p>How do I retrieve an item at random from the following list?</p> <pre><code>foo = ['a', 'b', 'c', 'd', 'e'] </code></pre>
<p>Use <a href="https://docs.python.org/library/random.html#random.choice" rel="noreferrer"><code>random.choice()</code></a>:</p> <pre><code>import random foo = ['a', 'b', 'c', 'd', 'e'] print(random.choice(foo)) </code></pre> <p>For <a href="https://en.wikipedia.org/wiki/Cryptographically_secure_pseudorandom_number_g...
<p>We can also do this using randint.</p> <pre><code>from random import randint l= ['a','b','c'] def get_rand_element(l): if l: return l[randint(0,len(l)-1)] else: return None get_rand_element(l) </code></pre>
39,410
<p>When I publish my ASP.NET site in RELEASE mode, and set compilation debug="false", will my ASP.NET and System.Diagnostics Tracing still work?</p>
<p>I believe that tracing is set separately from debugging in the configuration, so yes, if properly configured.</p> <pre><code>&lt;configuration&gt; &lt;system.web&gt; &lt;trace enabled="true" requestLimit="40" localOnly="false"/&gt; &lt;/system.web&gt; &lt;/configuration&gt; </code></pre>
<p>Beware that tracing completely breaks any msajax stuff you have going on</p>
40,438
<p>Specifically I have a PHP command-line script that at a certain point requires input from the user. I would like to be able to execute an external editor (such as vi), and wait for the editor to finish execution before resuming the script.</p> <p>My basic idea was to use a temporary file to do the editing in, and t...
<p>You can redirect the editor's output to the terminal: </p> <pre><code>system("vim &gt; `tty`"); </code></pre>
<pre><code>system('vi'); </code></pre> <p><a href="http://www.php.net/system" rel="nofollow noreferrer">http://www.php.net/system</a></p>
15,321
<p>Is it posible to use table view to show just one row of a big amount of elements? What I'm looking for is for some kind of horizontal list, like we have in XCode preferences or Aperture image list.</p> <p>It would behave just like a one columnt table view, but instead of showing the elements vertically, it should b...
<p>If you're okay with Leopard-only, The new NSCollectionView supports horizontal display. Just set the collection view's number of rows to 1 in Interface Builder; it'll even handle the horizontal scroll bar for you. The <a href="http://developer.apple.com/samplecode/IconCollection/index.html" rel="noreferrer">IconCo...
<p>With a table view? No. If I'm understanding correctly what you want, in the past I've created my own NSView subclass for this type of control. Define a data source protocol similar to NSTableView, and in your NSView drawRect method, draw the elements in order one by one from left to right. You can either keep track ...
48,932
<p>When is memory allocated in the .NET compact framework? If there is a difference between value and reference types, please detail. Documentation or steps to confirm are appreciated.</p> <p>In particular, consider this scenario...</p> <pre><code>private MyClass item; // here? public void MyMethod() { item = n...
<p>There are 3 different ways memory is allocated.</p> <p><strong>Static:</strong></p> <p>These are bound and allocated at compile time. Global static variables for example.</p> <p><strong>Stack Dynamic:</strong></p> <p>These are bound during runtime and pushed onto the stack. Such as a local variable in a function...
<p>I highly recommend that you look at the MSDN Webcase on <a href="https://msevents.microsoft.com/cui/WebCastRegistrationConfirmation.aspx?culture=en-US&amp;RegistrationID=1299365950&amp;Validate=false" rel="nofollow noreferrer">Compact Framework Memory Management</a>. It's not exactly the same as how it works on the...
30,794
<p>People also often ask "How can I compile Perl?" while what they really want is to create an executable that can run on machines even if they don't have Perl installed.</p> <p>There are several solutions, I know of:</p> <ol> <li><a href="http://www.indigostar.com/perl2exe.htm" rel="noreferrer">perl2exe</a> of Indig...
<p>In addition to the three tools listed in the question, there's another one called <a href="http://www.cavapackager.com/" rel="nofollow noreferrer">Cava Packager</a> written by Mark Dootson, who has also contributed to <a href="http://par.perl.org" rel="nofollow noreferrer">PAR</a> in the past. It only runs under Win...
<p>You could use the <code>perlcc</code> tool that's shipped with most distributions of Perl. I've also found both <code>perl2exe</code> and Active State's Perl Dev kit useful for shipping Perl applications.</p>
10,284
<p>I have a set of base filenames, for each name 'f' there are exactly two files, 'f.in' and 'f.out'. I want to write a batch file (in Windows XP) which goes through all the filenames, for each one it should:</p> <ul> <li>Display the base name 'f'</li> <li>Perform an action on 'f.in'</li> <li>Perform another action o...
<p>Assuming you have two programs that process the two files, process_in.exe and process_out.exe:</p> <pre><code>for %%f in (*.in) do ( echo %%~nf process_in "%%~nf.in" process_out "%%~nf.out" ) </code></pre> <p>%%~nf is a substitution modifier, that expands %f to a file name only. See other modifiers in ...
<p>Echoing f.in and f.out will seperate the concept of what to loop and what not to loop when used in a for /f loop.</p> <pre><code>::Get the files seperated echo f.in&gt;files_to_pass_through.txt echo f.out&gt;&gt;files_to_pass_through.txt for /F %%a in (files_to_pass_through.txt) do ( for /R %%b in (*.*) do ( if "%...
6,071
<p>The assembly it's trying to find isn't the root assembly - it's a referenced one, but it's in the same folder, and Directory.GetCurrentDirectory() is the folder with all of the files in.</p> <p>I'm stuck - any suggestions?</p>
<p>You can either:</p> <ol> <li>Create a new <code>AppDomain</code> to load the assembly (and set the <code>AppDomain</code>'s base directory to the directory containing all the assemblies).</li> <li>Attach a handler for <code>AppDomain.AssemblyResolve</code> to help the CLR find the assembly's dependencies.</li> <li>...
<p>You could try using something like this</p> <pre><code>string myDll = string.Empty; string location = Assembly.GetExecutingAssembly().Location; if (location != null) { myDll = string.Format(@"{0}\my.assembly.name.dll", location.Substring(0, location.LastIndexOf(@"\"))); } </code></pre> <p>This should get physi...
36,934
<p>In short, I'd like to learn/develop an elegant method to save a binary tree to disk (a general tree, not necessarily a BST). Here is the description of my problem:</p> <p>I'm implementing a game of "20-questions". I've written a binary tree whose internal nodes are questions and leaves are answers. The left chil...
<p>You can store it recursively:</p> <pre><code> void encodeState(OutputStream out,Node n) { if(n==null) { out.write("[null]"); } else { out.write("{"); out.write(n.nodeDetails()); encodeState(out, n.yesNode()); encodeState(out, n.noNode()); ...
<p>I would store the tree like this:</p> <pre><code>&lt;node identifier&gt; node data [&lt;yes child identfier&gt; yes child] [&lt;no child identifier&gt; no child] &lt;end of node identifier&gt; </code></pre> <p>where the child nodes are just recursive instances of the above. The bits in [] are optional and the ...
43,851
<p>I'd much rather code an app using pure C api such as OpenGL, rather that Cocoa Touch. So I'm wondering: is it feasible? Will I be able to maintain the same user experience that you get with Interface Builder?</p>
<p>None of the UI components have OpenGL equivalents. Is it possible? Yes. Is it <em>sensible</em>? No - you would be much better off learning how to use IB and the UIView classes. Coding the UI in OpenGL would be like painting your house with an artist's brush, using hand-made paint instead of Dulux.</p>
<p>Depends on your app. Mine's an "immersive" game, so I'm using openGL instead of CocoaTouch,<br> with a sprinkling of Core Graphics/UIKit calls to generate nice textures.</p> <p>If I had to display any kind of standard, non-trivial widget, I'd use CocoaTouch.</p>
34,255
<p>I would like to match the time (10.00) from a string with the date and time ("21.01.08 10.00"). I'm using the following regular expression:</p> <pre><code>new RegExp("\\b[0-9]{1,2}\\.[0-9]{1,2}\\b" "g"); </code></pre> <p>But this matches 21.01 from 21.01.08 and 10.00.</p> <p>I'm using PCRE as my regualar expressi...
<p>Your original regex didn't work because <code>\b</code> (word boundary) matches at the "." in "21.01.08." You need to code the boundaries more robustly:</p> <pre><code>(?:[^\d:.]|^)(\d\d?[.:]\d\d)(?![.:\d]) </code></pre> <p>This captures the time, in either of the notations you used, while excluding dates. Note th...
<p>try using </p> <pre><code>new RegExp("\\b[0-9]{1,2}\\.[0-9]{1,2}$" "g"); </code></pre> <p>$ indicates end of string</p>
25,666
<p>I'm trying to use Live Search 2.0 but even a simple example doesn't seem to work. Microsoft only has example code for 1.1 and they're not giving out AppIDs for that version.</p> <p>Here's what I'm trying with:</p> <pre><code>&lt;?php $server = new SoapClient('http://soap.search.msn.com/webservices.asmx?wsdl'); cl...
<p>You could begin by using the proper soap api url for 2.0. It's now "<a href="http://api.search.live.net/search.wsdl?AppID=YourAppId" rel="nofollow noreferrer">http://api.search.live.net/search.wsdl?AppID=YourAppId</a>" taken from (<a href="http://msdn.microsoft.com/en-us/library/dd250965.aspx" rel="nofollow noreferr...
<p>The sample code for API 2.0 is on MSDN but we do not have the complete PHP code sample out yet. A first code sample (very similar to the one in the answer you already got) in included in the blog post <a href="http://dev.live.com/blogs/livesearch/archive/2009/01/05/444.aspx" rel="nofollow noreferrer">on the Live Sea...
49,055
<p>My rails app is in a svn repository, but several of the plugins are installed through git and later added to the svn repo. How can I update these plugins? I can't seem to get script/plugin update to do anything. I'd really like to update activemerchant to get rid of the Inflector warnings.</p>
<p>If you haven't made any local changes to the plugin and you don't need to track what changes to it the update will bring, you can just run <code>script/plugin install</code> again, passing in <code>--force</code> if you need to. For example:</p> <pre><code>script/plugin install --force git://github.com/dchelimsky/r...
<p>You should just be able to navigate to the plugin's directory and hit: <code> git pull </code>. I'm pretty sure that <code>script/install plugin</code> just checks the code out from the git repo.</p>
24,259
<p>What is the most efficient way to detect duplicates in a 10 column / 50K row table? I'm using MSSQL 8.0</p>
<p>To show an example of what others have been describing:</p> <pre><code>SELECT Col1, -- All of the columns you want to dedupe on Col2, -- which is not neccesarily all of the columns Col3, -- in the table Col4, Col5, Col6, Col7, Col8, Col9, Col10 FROM MyTable GROUP BY C...
<p>To detect, just group by as Guge said.</p> <pre><code>select fieldA, fieldB, count(*) from table group by fieldA, fieldB having count(*) &gt; 1 </code></pre> <p>If you want to delete dupes... pseudo.... </p> <pre><code>select distinct into a temp table truncate original table select temp table back into original ...
39,461
<p>I need to scale calls into Tomcat and it's been suggested to launch threads internally. Has anyone needed to do this and, if so, what solutions did they come up with?</p>
<p>Creating your own threads inside an application server is generally discouraged because the server should manage threads for better scalability. You can also run into problems if the container makes assumptions about what's available in a thread context, such as security information (e.g., authenticated Subject). Th...
<p>as others asked, you should give more details as to what you're trying to accomplish.</p> <p>Otherwise, tomcat uses thread pools. increase the number of threads in the pool. Use a newer version of tomcat -- 6.x. Use Java 6.0_10. If needed, tune the application using a profiler and fiddle with the JVM settings, if r...
26,072
<p>Is there a way to start another application from within Compact .Net framework 1.0 similar to </p> <pre><code>System.Diagnostics.Process.Start </code></pre> <p>on the Windows side?</p> <p>I need to start a CAB file for installation.</p>
<p>Treat the share as if it were your source control system. Make the share read-only, which will force developers to get local copies in order to make changes. You then have a somewhat stable version to compare against. This would help facilitate being able to do "merges". "Checking" code in would have to consist of s...
<p>Working off of a shared drive is not a good idea, and gets my vote of "no confidence".</p> <p>It would be too easy to overwrite other's changes, you have no change tracking, no way to branch or tag/label, etc.</p>
24,707
<p>I use Visual Studio 2008. I haven't seen this behavior before and, as far as I know, I didn't change anything in the options.</p> <p>When I press Start debugging all the possibly windows (watch 1 - 4), data sources, properties, registers (to be honest I have not even ever seen these windows before) appear in front...
<p>Visual Studio <em>remembers</em> 2 sets of window layouts, normal mode and debugging mode. My solution is to arrange my normal windows exactly like I want them, then start debugging an application and once again arrange all of the windows the way I want, usually making it as similar to my <em>normal</em> layout as ...
<p>I'm experiencing the same thing - whenever the debugger is running, switching focus back to the IDE immediately caused the debug panel to expand.</p> <p>I ended up just pinning the debug panel so that it always appears when debugging, and just changing its height as needed.</p>
8,153
<p>Is there a simple way to sort an iterator in PHP (without just pulling it all into an array and sorting that).</p> <p>The specific example I have is a <a href="http://www.php.net/directoryiterator" rel="noreferrer">DirectoryIterator</a> but it would be nice to have a solution general to any iterator.</p> <pre><cod...
<p>There is no way to do that. An iterator should "iterate" through the list. You have to sort the underlying list to achieve the needed behavior.</p> <p>By the way, the more complete reference to the SPL is here: <a href="http://www.php.net/~helly/php/ext/spl/" rel="noreferrer">http://www.php.net/~helly/php/ext/spl/<...
<p>You'll have to reduce using iterator_to_array() then uasort(). And, in my performance testing, sufficiently fast.</p> <p>To your specific example, the most compact way I know using iterators is below:</p> <pre><code>// get (recursively) files matching a pattern, each file as SplFileInfo object $matches = new Rege...
31,284
<p>I'm looking for some examples or samples of routing for the following sort of scenario:</p> <p>The general example of doing things is: {controller}/{action}/{id}</p> <p>So in the scenario of doing a product search for a store you'd have:</p> <pre><code>public class ProductsController: Controller { public Acti...
<p>I actually found it not even by searching, but by scanning through the ASP .NET forums in <a href="http://forums.asp.net/t/1296928.aspx?PageIndex=1" rel="nofollow noreferrer">this question</a>.</p> <p>Using this you can have the controllers of the same name under any part of the namespace, so long as you qualify wh...
<p>The best way to do this without any compromises would be to implement your own ControllerFactory by inheriting off of IControllerFactory. The CreateController method that you will implement handles creating the controller instance to handle the request by the RouteHandler and the ControllerActionInvoker. The conve...
6,479
<p>We altready have a similar question <a href="https://stackoverflow.com/questions/88950/is-there-any-reason-to-not-ship-the-pdbs-with-your-application">here</a> but the discussion do not cover all the aspect, so I'm asking again:</p> <p><em>What is the best way to distribute a .Net application considering build mode...
<p>Debug builds should not be distributed, they're really for your own private viewing. However, once you build a release build with symbols and generate .pdbs from them, you can keep the pdbs and happily ship the dlls.</p> <p>If you store the .pdbs in a symbol server (see this excellent <a href="http://msdn.microsoft...
<p>Debug builds should not be distributed - you likely do not have the rights to do so. PDBs are most easily distribute using a Symbol Server.</p>
27,871
<p>Is it possible to enumerate all the current errors being displayed through an "Error Provider" without having to access the controls?</p>
<p>There is a summary validator that will give you all of the errors, but it's pretty ugly, and I'm not sure if you can use it without displaying it on the page. Technically, if you are doing things the "right way", all of you error handling should be handled in your midddle teir and then bubbled to the screen that wa...
<p>There is a summary validator that will give you all of the errors, but it's pretty ugly, and I'm not sure if you can use it without displaying it on the page. Technically, if you are doing things the "right way", all of you error handling should be handled in your midddle teir and then bubbled to the screen that wa...
18,925
<p>Large pages are available in <code>Windows Server 2003</code> and <code>Windows Vista</code>. </p> <p>But how do I enable large pages for my application? </p>
<p>Martin's answer is correct on Windows Server 2003:</p> <blockquote> <p>You will have to assign the "Lock pages in memory" privilege to any user that runs your > application. This includes administrators</p> <ol> <li>Select Control Panel -> Administrative Tools -> Local Security Policy</li> <li>Select Loc...
<p>You will have to assign the <code>Lock pages in memory</code> privilege to any user that runs your application. This includes administrators.</p> <ol> <li>Select Control <strong>Panel -> Administrative Tools -> Local Security</strong> Policy </li> <li>Select Local <strong>Policies -> User Rights Assignment</strong...
6,007
<p>I would like to sort a matrix according to a particular column. There is a <code>sort</code> function, but it sorts all columns independently.</p> <p>For example, if my matrix <code>data</code> is:</p> <pre><code> 1 3 5 7 -1 4 </code></pre> <p>Then the desired output (sorting by the first column) wou...
<p>I think the <a href="http://www.mathworks.com/help/matlab/ref/sortrows.html" rel="noreferrer">sortrows</a> function is what you're looking for.</p> <pre><code>&gt;&gt; sortrows(data,1) ans = -1 4 1 3 5 7 </code></pre>
<p>An alternative to <code>sortrows()</code>, which can be applied to broader scenarios.</p> <ol> <li><p>save the sorting indices of the row/column you want to order by:</p> <pre><code>[~,idx]=sort(data(:,1)); </code></pre></li> <li><p>reorder all the rows/columns according to the previous sorted indices</p> <pre><c...
16,310
<p>We have a vxWorks design which requires one task to process both high and low priority messages sent over two message queues.<br> The messages for a given priority have to be processed in FIFO order. </p> <p>For example, process all the high priority messages in the order they were received, then process the low p...
<p>If you use named pipes (pipeDevCreate(), write(), read()) instead of message queues, you can use select() to block until there are messages in either pipe. <br></p> <p>Whenever select() triggers, you process all messages in the high priority pipe. Then you process a single message from the low priority pipe. Then c...
<p>In vxWorks, you can't wait directly on multiple queues. You can however use the OS events (from eventLib) to achieve this result. Here is a simple code snippet:</p> <pre><code> MSG_Q_ID lowQ, hiQ; void Init() { // Task Initialization Code. This should be called from the task that will // be receiving the message...
14,657
<p>I have this function in VB.net "ENCRYPT" (see below)</p> <pre><code>Private key() As Byte = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24} Private iv() As Byte = {65, 110, 68, 26, 69, 178, 200, 219} Public Function Encrypt(ByVal plainText As String) As Byte() ' Declare ...
<p>Simply store in a binary column. (Mostly done from memory, corrections welcome!)</p> <pre><code>CREATE TABLE [Test] ( [Id] NOT NULL IDENTITY(1,1) PRIMARY KEY, [Username] NOT NULL VARCHAR(500), [Password] NOT NULL VARBINARY(500) ) </code></pre> <p>Then insert such:</p> <pre><code>Dim conn As SqlConnec...
<p>Encode the array of byte into a string. 0x00 can be "00" and 0xFF can be "FF." Or you can take at look at <a href="http://en.wikipedia.org/wiki/Base64" rel="nofollow noreferrer">Base64</a>.</p>
17,738
<p>I've implemented an image/video transformation technique called discrete cosine transform. This technique is used in MPEG video encoding. I based my algorithm on the ideas presented at the following URL:</p> <p><a href="http://vsr.informatik.tu-chemnitz.de/~jan/MPEG/HTML/mpeg_tech.html" rel="noreferrer"><a href="...
<p>The result of a DCT is a transformation of the original source into the frequency domain. The top left entry stores the "amplitude" the "base" frequency and frequency increases both along the horizontal and vertical axes. The outcome of the DCT is usually a collection of amplitudes at the more usual lower frequencie...
<p>If I remember correctly, this matrix allows you to save the data to a file with compression.</p> <p>If you read further down, you'll find the zig-zag pattern of data to read from that final matrix. The most important data are in the top left corner, and least important in the bottom right corner. As such, if you st...
2,657
<p>I need an easy way to allow users to upload multiple files at once (ie I need to allow a user to upload a folder). I do not wish to put the burden of zipping on the user. </p> <p><em>I would prefer to avoid Flash or variants if possible.</em> I'm looking for a straight javascript / HTML solution if it is possibl...
<p>You won't be able to do it with just HTML and Javascript. I'd recommend trying <a href="http://digitarald.de/project/fancyupload/" rel="noreferrer">Fancy Upload</a>, a <a href="http://mootools.net/" rel="noreferrer">MooTools</a> plugin for multiple file uploads. It uses a mixture of JavaScript and Flash, but degrade...
<p>This isn't a pure js/html solution. As EndangeredMassa has pointed out, it's not possible. In fact, this idea is an IE/Windows only solution. I don't recommend it, but it can work.</p> <p>So, all disclaimers aside ... </p> <p>Many years and several employers ago, we used to do some client side stuff that instan...
31,709
<p>I have this quiz rails app linked to an IRC bot who asks questions (yes, on IRC), where I have this <code>Question</code> model which contains, well, questions, answers, hints, and a few more things.</p> <p>I started with <code>Quiz</code> model (like, say, the special Halloween or Christmas quiz) with a <code>qui...
<p><strong>Please don't do this.</strong> It's a really, really, really, really, really <em>bad idea</em>.</p> <p>Maybe not as bad as deleting files randomly, if the hard drive runs out of room - but just about as bad.</p>
<p>Mark's code is probably better, but here's mine...</p> <p>If you <strong>really</strong> want to do something like this, I'd use code something like this. Yes, you still have to manually call it, but your idea of indiscriminately retrying ALL excepting methods is a really, really bad idea.</p> <pre><code>public c...
43,552
<p>One of the topics that seems to come up regularly on mailing lists and online discussions is the merits (or lack thereof) of doing a Computer Science Degree. An argument that seems to come up time and again for the negative party is that they have been coding for some number of years and they have never used recursi...
<p>There are a number of good explanations of <a href="http://en.wikipedia.org/wiki/Recursion_%28computer_science%29" rel="noreferrer">recursion</a> in this thread, this answer is about why you shouldn't use it in most languages.* In the majority of major imperative language implementations (i.e. every major implement...
<p>I have created a recursive function to concatenate a list of strings with a separator between them. I use it mostly to create SQL expressions, by passing a list of fields as the '<em>items</em>' and a '<em>comma+space</em>' as the separator. Here's the function (It uses some Borland Builder native data types, but ...
2,515
<p>I want to write a script which cleans the 'run' dialogue automatically every log off. Where is the history stored?</p>
<p>From:</p> <p><a href="http://www.pchell.com/support/editrunmrulistentries.shtml" rel="noreferrer">How to Remove Individual Entries from Run Command History</a></p> <blockquote> <p>Where is the Run MRU (Most Recently Used) List?</p> <p>The RUNMRU list is stored in the Windows Registry in the following ...
<p>Never use registry, just use Win32 SH api to clean it.</p>
20,508
<p>Speaking as a non-C# savvy programmer, I'm curious as to the evaluation semantics of LINQ queries like the following:</p> <pre><code>var people = from p in Person where p.age &lt; 18 select p var otherPeople = from p in people where p.firstName equals "Daniel" ...
<p>They are composable. This is possible because LINQ queries are actually expressions (code as data), which LINQ providers like LINQ-to-SQL can evaluate and generate corresponding SQL.</p> <p>Because LINQ queries are lazily evaluated (e.g. won't get executed until you iterate over the elements), the code you showed w...
<p>Both these queries will be executes when you'll try to access final results. You can try to view original SQL generated from DataContext object properties.</p>
11,477
<p>A J2ME client is sending HTTP POST requests with chunked transfer encoding.</p> <p>When ASP.NET (in both IIS6 and WebDev.exe.server) tries to read the request it sets the Content-Length to 0. I guess this is ok because the Content-length is unknown when the request is loaded.</p> <p>However, when I read the Reques...
<p>Seems to be official: <a href="http://msdn.microsoft.com/en-us/library/ee960144.aspx" rel="nofollow">Cassini does not support <code>Transfer-Encoding: chunked</code> requests.</a></p> <blockquote> <p>By default, the client sends large binary streams by using a chunked HTTP Transfer-Encoding. <strong>Because t...
<p>That url does not work any more, so it's hard to test this directly. I wondered if this would work, and google turned up someone who has experience with it at <a href="http://bytes.com/forum/thread246706.html" rel="nofollow noreferrer">bytes.com</a>. If you put your website up again, I can see if this really works...
9,455
<p>I'm looking for computationally heavy tasks to implement with CUDA and wonder if neural networks or bayesian networks might apply. This is not my question, though, but rather what the relation between the two network types is. They seem very related, especially if you look at bayesian networks with a learning capabi...
<p>Bayesian networks represent independence (and dependence) relationships between variables. Thus, the links represent conditional relationships in the probabilistic sense. Neural networks, generally speaking, have no such direct interpretation, and in fact the intermediate nodes of most neural networks are discover...
<p>Indeed they are. I see a bayesian network as a neural network applying the Baye's Theorem on large scale, but I don't remember details. I know where you can find them and I recommend <a href="https://rads.stackoverflow.com/amzn/click/com/0471056693" rel="nofollow noreferrer" rel="nofollow noreferrer">this</a> book f...
39,255
<p>When I make the same query twice, the second time it does not return new rows form the database (I guess it just uses the cache).</p> <p>This is a Windows Form application, where I create the dataContext when the application starts.</p> <p>How can I force Linq to SQL not to use the cache?</p> <p>Here is a sample ...
<p>The simplest way would be to use a new DataContext - given that most of what the context gives you is caching and identity management, it really sounds like you just want a new context. Why did you want to create just the one and then hold onto it?</p> <p>By the way, for simple queries like yours it's more readable...
<p>It can matter HOW you add an object to the DataContext as to whether or not it will be included in future queries.</p> <p><strong>Will NOT add the new InventoryTransaction to future in memory queries</strong></p> <p>In this example I'm adding an object with an ID and then adding it to the context.</p> <pre><code>...
38,504
<p>I'd like to write a MessageConverter class that can wrap another MessageConverter. This MessageConverter would call the child converter, which is assumed to generate a TextMessage. It would take the payload and GZIP compress it, creating a BytesMessage which is ultimately returned to the sender.</p> <p>The problem ...
<p>So I did, in fact, make one of these:</p> <pre><code> private static class FakeTextMessage implements TextMessage { public FakeTextMessage(Message m) { this.childMessage = m; } private String text; private Message childMessage; public void setText(String t) { this....
<p>So I did, in fact, make one of these:</p> <pre><code> private static class FakeTextMessage implements TextMessage { public FakeTextMessage(Message m) { this.childMessage = m; } private String text; private Message childMessage; public void setText(String t) { this....
29,852
<p>Are there any templates/patterns/guides I can follow for designing a multithreaded server? I can't find anything terribly useful online through my google searches.</p> <p>My program will start a thread to listen for connections using TcpListener. Every client connection will be handled by it's own IClientHandler t...
<p>Oddly enough you may find something on a Computer Science Assignment, <a href="http://homepage.cs.uri.edu/courses/attic/csc512/assn3.html" rel="noreferrer"><strong>CSC 512 Programming Assignment 4: Multi-Threaded Server With Patterns</strong></a>. Altough it's C++ voodoo but the theory is quite understandable for so...
<p>Take a look at this previous question:</p> <p><a href="https://stackoverflow.com/questions/32198/how-do-you-minimize-the-number-of-threads-used-in-a-tcp-server-application">How do you minimize the number of threads used in a tcp server application?</a></p> <p>It's not strictly C# specific, but it has some good adv...
17,978
<p><a href="https://stackoverflow.com/questions/374572/need-help-variable-creation-in-python#374604">That</a> was helpful kgiannakakis. I'm facing a problem as below:</p> <pre><code>a = ['zbc','2.3'] for i in range(0,5): exec('E%d=%s' %(i,a[i])) </code></pre> <p>This results in:</p> <pre> Traceback (most recent ...
<p>It looks like the code you're generating expands to:</p> <pre><code>E0=zbc E1=2.3 </code></pre> <p>At the next iteration through the loop, you'll get an IndexError exception because <code>a</code> is only two elements long.</p> <p>So given the above, you are trying to assign the value of <code>zbc</code> to <code...
<p>Okay. this code is very weird.</p> <p>As a one liner like this, it's not syntactically correct, but I suspect you're missing line breaks for some reason. But then it becomes</p> <pre><code>a = ['zbc','2.3'] for i in range(0,5): exec('E%d=%s' %(i,a[i])) </code></pre> <p>But that will result in an index error...
49,356
<p>Is there a typedef equivalent in C#, or someway to get some sort of similar behaviour? I've done some googling, but everywhere I look seems to be negative. Currently I have a situation similar to the following:</p> <pre><code>class GenericClass&lt;T&gt; { public event EventHandler&lt;EventData&gt; MyEvent; ...
<p>No, there's no true equivalent of typedef. You can use 'using' directives within one file, e.g.</p> <pre><code>using CustomerList = System.Collections.Generic.List&lt;Customer&gt;; </code></pre> <p>but that will only impact that source file. In C and C++, my experience is that <code>typedef</code> is usually used ...
<p>Since the introduction of C# 10.0, we now have the <code>global using</code> directive.</p> <pre><code>global using CustomerList = System.Collections.Generic.List&lt;Customer&gt;; </code></pre> <p>This introduces <code>CustomerList</code> as alias of <code>List&lt;Customer&gt;</code> on a global scope (throughout th...
19,515
<p>I'd like to gain better knowledge of operating system internals. Process management, memory management, and stuff like that. <br> I was thinking of learning by getting to know either linux or BSD kernel.<br> Which one kernel is better for learning purposes?<br> What's the best place to start?<br> Can you recommend a...
<p>In college, I had an operating systems class where we used a <a href="https://rads.stackoverflow.com/amzn/click/com/0003458903" rel="noreferrer" rel="nofollow noreferrer">book by Tanenbaum</a>. In the class, we implemented a device driver in the <a href="http://minix1.woodhull.com/teaching/teach_ver.html" rel="nore...
<p>When I was at uni I spent a semester studying operating systems, and as part of this had an assignment where we had to implement a RAM-based filesystem in Linux.</p> <p>It was a fantastic way to get to understand the internals of the Linux keurnel and to get a grasp on how everything fits together - And a heck of a...
4,431
<p>I'm using the current version of restful_authentication that is found on github and I'm having a bunch of strange session issues. The server seems to be somehow assigning sessions to users it shouldn't be. This only happens when crossing the logged out/logged in barrier.</p> <p>Here's an example. With no sessions a...
<p>I don't know if this is so much of an answer as it is a work around. All I did was switch over to cookie based sessions and everything is working smoothly.</p>
<p>Is this site remote? Are you logging into it onto two separate computers on the same network?</p>
17,502
<p>I'm a little hesitant to post this, as I'm not completely sure what I'm doing. Any help would be wonderful.</p> <p>I'm on a computer with a firewall/filter on it. I can download files without any difficulty. When I try to clone files from Github, though, the computer just hangs. Nothing happens. It creates a git fi...
<p>Github supports cloning using both the git protocol over port 9418 and HTTP over port 80. Using the later is very slow (<a href="http://github.com/blog/92-http-cloning" rel="noreferrer">Reference</a>). You should open port 9418 on your firewall or use HTTP cloning otherwise.</p>
<pre><code>git config --global url."https://".insteadOf git:// </code></pre> <p>Done!</p>
11,410
<p>What are the steps required to enable Hibernate's second-level cache, when using the Java Persistence API (annotated entities)? How do I check that it's working? I'm using JBoss 4.2.2.GA.</p> <p>From the Hibernate documentation, it seems that I need to enable the cache and specify a cache provider in <em>persistenc...
<p>I believe you need to add the cache annotations to tell hibernate how to use the second-level cache (read-only, read-write, etc). This was the case in my app (using spring / traditional hibernate and ehcache, so your mileage may vary). Once the caches were indicated, I started seeing messages that they were in use f...
<p>Follow-up: in the end, after adding annotations, I have it working with EhCache, i.e.</p> <pre><code>&lt;property name="hibernate.cache.provider_class" value="net.sf.ehcache.hibernate.EhCacheProvider" /&gt; </code></pre>
7,707
<p>OK, probably best to give an example here of what I mean.</p> <p>Imagine a web based forum system, where the user authentication is done by some external method, which the system is aware of.</p> <p>Now, say for example, a user enters the URL for a thread that they do not have access to. For this should I return a...
<p>Above everything else, <strong>comply with HTTP spec.</strong> Returning 403 in place of 404 is not a good thing. Returning 404 in place of 403 probably is ok (or not a big blunder), but I would just <strong>let the software tell the truth</strong>. If user only knows the ID of a topic, it's not much anyway. And he ...
<p>Lets say you did return a "page not found" error when you detect that the user does not have the correct access rights. A malicious person with the intent of hacking will soon figure out that you would return this in place of the access denied. </p> <p>But the real users who mistype a url or use a wrong login etc w...
17,792
<p>I have got a simple page with a HtmlInputHidden field. I use Javascript to update that value and, when posting back the page, I want to read the value of that HtmlInputHidden field. The Value property of that HtmlInputHidden field is on postback the default value (the value it had when the page was created, not the ...
<p>Warning, as said <a href="http://www.eggheadcafe.com/software/aspnet/30020406/trouble-getting-logoff-sc.aspx" rel="nofollow noreferrer"><strong>here</strong></a>, <code>gpedit.msc</code> will allow you to configure a logoff script <strong>for <em>all</em> users</strong>.</p> <p>If you need that script only for one ...
<p>If you need something simple and working for a single (or any) user you can make a simple application in C++ or C# for example.</p> <p>The simplest is having a C# in tray (by simply adding the tray component to the form) and register and event handler for the <strong>FormClosing</strong> event. It'd look like this:...
41,987
<p>The client connects to the server using GenuineChannels (we are considering switching to DotNetRemoting). What I mean by find is obtain the IP and port number of a server to connect to.</p> <p>It seems like a brute-force approach would be try every IP on the network try the active ports (not even sure if that's po...
<p>Consider broadcasting a specific UDP packet. When the server or servers see the broadcasted UDP packet they send a reply. The client can collect the replies from all the servers and start connecting to them or based on an election algorithm.</p> <p>See example for client (<strong>untested code</strong>):</p> <hr> ...
<p>Have the server listen for broadcast on a specific port on the network (must use UDP), When client starts have it broadcast some "ping" request on that port. when the server sees a "ping" it send back a message with the TCP address and port required for the client to connect to it.</p>
25,828
<p>What is the reason browsers do not correctly recognize:</p> <pre><code>&lt;script src="foobar.js" /&gt; &lt;!-- self-closing script element --&gt; </code></pre> <p>Only this is recognized:</p> <pre><code>&lt;script src="foobar.js"&gt;&lt;/script&gt; </code></pre> <p>Does this break the concept of XHTML support?<...
<p>The non-normative appendix ‘HTML Compatibility Guidelines’ of the XHTML 1 specification says:</p> <p><a href="http://www.w3.org/TR/xhtml1/#C_3" rel="noreferrer">С.3. Element Minimization and Empty Element Content</a></p> <blockquote> <p>Given an empty instance of an element whose content model is not <code>EMPTY</co...
<p>Difference between 'true XHTML', 'faux XHTML' and 'ordinary HTML' as well as importance of the server-sent MIME type had been <a href="https://stackoverflow.com/a/70288/540955">already described here well</a>.</p> <p>If you want to try it out right now, here is simple editable snippet with live preview including sel...
9,530
<p>I'm having an issue dragging a file from Windows Explorer on to a Windows Forms application. </p> <p>It works fine when I drag text, but for some reason it is not recognizing the file. Here is my test code:</p> <pre><code>namespace WindowsFormsApplication1 { public partial class Form1 : Form { pub...
<p>The problem comes from Vista's <a href="http://en.wikipedia.org/wiki/User_Account_Control" rel="noreferrer">UAC</a>. DevStudio is running as administrator, but explorer is running as a regular user. When you drag a file from explorer and drop it on your DevStudio hosted application, that is the same as a non-privi...
<p>The code you posted <em>should</em> work.</p> <p>Try putting this at the beginning of the DragEnter method</p> <pre><code>string formats = string.Join( "\n", e.Data.GetFormats(false) ); MessageBox.Show( formats ); </code></pre> <p>which will dump data formats associated with the d'n'd operation. Might help us nar...
35,654
<p>I'm asking for a suitable architecture for the following Java web application: </p> <p>The goal is to build several web applications which all operate on the same data. Suppose a banking system in which account data can be accessed by different web applications; it can be accessed by customers (online banking), by ...
<p>B, C, and D are all just different ways to accomplish the same thing.</p> <p>My first thought would be to simply have all consumer code connecting to a common database. This is certainly doable, and would eliminate the code you don't want to place in the middle. The drawback, of course, is that if the schema change...
<p>Apart from the provided responses, if you are considering having multiple applications working with the database at the same time, consider a distributed cache as part of your solution, as well. The beauty of the distributed cache is that it can be accessed by multiple applications at the same time, apart from bein...
43,917
<p>I've been creating CSS/Javascript to style an upcoming site differently on iPhone - mostly to enhance usability. On the desktop app, I use <a href="http://www.digitalia.be/software/slimbox" rel="nofollow noreferrer">slimbox</a> in combination with mootools for an image gallery. This doesn't work on iPhone because it...
<p>You probably already know this - but you can get rid of the address bar with: document.body.onload = function(){setTimeout("window.scrollTo(0,1);",100);};</p> <p>To create the illusion of a native app even more, you can disable scrolling: document.body.ontouchmove = function(e){e.preventDefault();};</p>
<p>There is a meta tag, <a href="http://daringfireball.net/linked/2008/10/03/fullscreen-iphone-web-apps" rel="nofollow noreferrer">apple-mobile-web-app-capable</a>, that you can use to launch mobile safari in fullscreen mode. Keep in mind though that the user needs to add a web bookmark to their home screen in order fo...
46,589
<p>I am not sure whether is it possible to change attribute's parameter during runtime? For example, inside an assembly I have the following class</p> <pre><code>public class UserInfo { [Category("change me!")] public int Age { get; set; } [Category("change me!")] public string ...
<p>Well you learn something new every day, apparently I lied:</p> <blockquote> <p>What isn’t generally realised is that you can change attribute <strong>instance</strong> values fairly easily at runtime. The reason is, of course, that the instances of the attribute classes that are created are perfectly no...
<p>You can change Attribute values at runtime at Class level (not object):</p> <pre><code>var attr = TypeDescriptor.GetProperties(typeof(UserContact))["UserName"].Attributes[typeof(ReadOnlyAttribute)] as ReadOnlyAttribute; attr.GetType().GetField("isReadOnly", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(a...
7,429
<p>I am creating an application in .NET that will serve as a second UI for my already-deployed Django app. For some operations users need to authenticate themselves (as Django users). I used a super-simple way to do this (without encrypting credentials for simplicity):-</p> <p>Step 1. I created a django view that acce...
<p>Looks ok to me. I recommend using Wireshark to see what your restclient is sending in the headers and and see what your app sending in the headers.</p>
<p>It's working now. The HTTP headers were OK, the source of the problem were the following lines: <pre> Dim encoding As New UnicodeEncoding . Dim postBytes As Byte() = encoding.GetBytes(postData)</pre></p> <p>Essentially, this was resulting in a data stream with null bytes between the character bytes. ...
48,869
<p>I am deploying new versions of java servlets with JRun as the host. I am having difficulty finding good sources for information about JRun and tutorials about how to configure and manage it.</p> <p>After installing JRun and opening the launcher it can't start the admin server that it creates by default...so obvious...
<p><a href="http://www.adobe.com/products/jrun/productinfo/faq/eod/" rel="nofollow noreferrer">Jrun development has pretty much stopped</a>. You should look into running another application server. <a href="http://www.jboss.org/" rel="nofollow noreferrer">Jboss</a> or <a href="http://glassfish.java.net/" rel="nofollow ...
<p>This is probably going to be difficult to resolve unless you post either the error message from the log file or the list of steps that you took so far.</p> <p>I have JRun 3.1 configured on my machine so maybe I can duplicate your issue if you give us more information.</p>
5,508
<p>I have a method that I would like to call. However, I'm looking for a clean, simple way to kill it or force it to return if it is taking too long to execute.</p> <p>I'm using Java.</p> <p>to illustrate:</p> <pre><code>logger.info("sequentially executing all batches..."); for (TestExecutor executor : builder.getE...
<p>You should take a look at these classes : <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/FutureTask.html" rel="noreferrer">FutureTask</a>, <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/Callable.html" rel="noreferrer">Callable</a>, <a href="http://java.sun.com/j2se/1.5....
<p>The correct answer is, I believe, to create a Runnable to execute the sub-program, and run this in a separate Thread. THe Runnable may be a FutureTask, which you can run with a timeout ("get" method). If it times out, you'll get a TimeoutException, in which I suggest you</p> <ul> <li>call thread.interrupt() to at...
29,747
<p>I've recently switched to Linux on my work machine and, new to the Linux desktop environment, I'd like to find a decent ERD tool for database design. Booting back into my Windows partition every time I need to create a diagram is going to get unpleasant quickly. I looked at Dia, but didn't see any DB tools - only ...
<p>MySQL just officially released the alpha of "MySQL Workbech for linux":</p> <p>See the announcement here: <a href="http://dev.mysql.com/workbench/?p=153" rel="noreferrer">MySQL Workbench 5.1 Alpha for Linux available</a>.</p>
<p>You can try Base from <a href="https://www.libreoffice.org/features/base/" rel="nofollow">LibreOffice</a>. It can connect to any database and you can easily create, design and write queries using visual wizards and tools.</p>
3,491
<p>I have a WCF service which will be hosted under IIS. Now I have some resources(Connections) that I create within service constructor. I need to free up those resources when IIS which is hosting the service shuts down or resets. These are not the resources that I will be clearing out every time client disconnects but...
<p>Well, I'm out of ideas, but I think that <a href="http://msdn.microsoft.com/en-us/library/bb332338.aspx" rel="nofollow noreferrer">this article</a> contains your answer in the chapter: "Accessing ServiceHost in IIS". It seems you need to build your own HostFactory because out of the box IIS uses the standard HostFac...
<p>The whole point of WCF services and IIS hosting is to achieve scalability and allow easy hosting. Although you could connect to events exposed by the ServiceHostBase class (see <a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.servicehostbase_events.aspx" rel="nofollow noreferrer">here</a>), I wou...
44,008
<p>How would you convert a parapraph to hex notation, and then back again into its original string form?</p> <p>(C#)</p> <p>A side note: would putting the string into hex format shrink it the most w/o getting into hardcore shrinking algo's?</p>
<p>What exactly do you mean by "hex notation"? That usually refers to encoding binary data, not text. You'd need to encode the text somehow (e.g. using UTF-8) and then encode the binary data as text by converting each byte to a pair of characters.</p> <pre><code>using System; using System.Text; public class Hex { ...
<p>While I can't help much on the C# implementation, I would highly recommend <a href="http://en.wikipedia.org/wiki/Lzw" rel="nofollow noreferrer">LZW</a> as a simple-to-implement data compression algorithm for you to use.</p>
27,038
<p>Navision 5.0 includes a feature to export to Word or Excel. Is it possible to make this work with OpenOffice.org Writer or Calc instead? If so, what has to be done to set it up?</p> <p>I have been told by my Navision reseller that the feature works best with Office 2007, and export to Excel 2003 works. No mentio...
<p>I know this is an old question, but I'll add the answer just in case anyone comes here:</p> <p>You can export directly to OpenOffice without customizations. The only thing you need is to go into Tools > Manage Style Sheets... and modify the existing StyleSheets so that they open OpenCalc and OpenWrite instead of Ex...
<p>You should be able to export the documents to word or excel and then use OpenOffice to open the documents. No additional set up required.</p>
7,302
<p>Does using STL increase footprint significantly? Could you guys share your experience regarding this matter? What are the best practices to build a small footprint library?</p>
<p>There's no one answer since STL is a set of templates. Templates, by their very nature, are only compiled in when used. So you can include all of STL and if none of it is actually used, the footprint added by STL will be zero. If you have a very small app that manages to use a lot of different templates with diff...
<p>On an embedded project with a 64kb limit I once did, I couldn't even link the standard C libraries. So it depends on what you need to do</p>
47,930
<p>I'm trying to connect to an MDF. I've even gone to the lengths of re-installing sql server express entirely (it is now the only flavor of SQL installed on my box, where previously I had 05 dev and express). I've verified that the paths are all correct, and thus far my google-fu hasn't helped.</p> <p>The Full exce...
<p>ok, it works now! guess it was a compound problem ... the steps I took to resolve it are as such:</p> <ol> <li>Changed the following property in the connection string (note the subtle difference): <code>AttachDbFilename=|DataDirectory|CustomerDb.mdf;</code></li> <li>Deleted the contents of the following directory: ...
<p>Have you tried to connect to the SQL Server instance by using SQL Management Studio?</p> <p>If this also doesn't allow you to connect then it could be because the SQL service is not starting correctly.</p> <p>Verify that the service is running by checking the services in the control panel.</p>
35,618
<p>I'm developing an operating system and rather than programming the kernel, I'm designing the kernel. This operating system is targeted at the x86 architecture and my target is for modern computers. The estimated number of required RAM is 256Mb or more.</p> <p>What is a good size to make the stack for each thread ru...
<p>Stack size depends on what your threads are doing. My advice:</p> <ul> <li>make the stack size a parameter at thread creation time (different threads will do different things, and hence will need different stack sizes)</li> <li>provide a reasonable default for those who don't want to be bothered with specifying a ...
<p>Why not make the stack size a configurable item, either stored with the program or specified when a process creates another process?</p> <p>There are any number of ways you can make this configurable.</p> <p>There's a guideline that states "0, 1 or n", meaning you should allow zero, one or any number (limited by o...
23,901
<p>I'm running Repetier Host v1.6.1 with Repetier Firmware v0.92.9. My computer is running Windows 7 Pro SP1, 64-bit.</p> <p>If I set a print going via USB then switch to another user (note: I do not log out), then the pinter's display shows that the command buffer drops from 16 to 0 until it stops printing altogethe...
<p>Is it possible that in updating Repetier you inadvertently installed it for a single user rather than for everyone? If so, that might account for its stopping when the user is changed. </p>
<p>I believe what happens here is that Windows suspends the process running the print job, either due to the program not being in focus, because you switch user, or both.</p> <p>You could try to <em>increase the priority of the print process in task manager</em>, and see if that helps.</p> <p><strong>In Windows 7:</s...
297
<p>I have a WPF user control I created that is used to show the state of tasks in my UI. I get the odd report back that the control sometimes has a nasty looking border to the left and I cannot reproduce it.</p> <p>The control looks like this (when working) (grey tick=not run, green=OK,red cross=fail,hourglass=running...
<p>Could it have something to do with <a href="http://msdn.microsoft.com/en-us/library/aa970908.aspx" rel="nofollow noreferrer">pixel snapping</a>?</p>
<p>Are they in a grid? It could be related to <a href="https://stackoverflow.com/questions/267364/wpf-eliminate-transparency-between-grid-cells#267954">WPF: Eliminate transparency between grid cells</a> which we never really resolved.</p>
38,218
<p>I am having an ASP.net page in my page i am having this as my code behind files. on first access the page the page preinit, init, load methods are called. on postbacks the preinit, init, load methods are called.</p> <p>My question is LoadViewstate and control state events (Overridden methods) are not firing after p...
<p>For 2.3 or after:</p> <pre><code>class Enumerate(object): def __init__(self, names): for number, name in enumerate(names.split()): setattr(self, name, number) </code></pre> <p>To use:</p> <pre><code> codes = Enumerate('FOO BAR BAZ') </code></pre> <p><code>codes.BAZ</code> will be 2 and so on. </p> <...
<p>In Python, strings are immutable and so they are better for constants than numbers. The best approach, in my opinion, is to make an object that keeps constants as strings:</p> <pre><code>class Enumeration(object): def __init__(self, possibilities): self.possibilities = set(possibilities.split()) de...
23,925
<p>I had a discussion a few weeks back with some co-workers on refactoring, and I seem to be in a minority that believes "Refactor early, refactor often" is a good approach that keeps code from getting messy and unmaintainable. A number of other people thought that it just belongs in the maintenance phases of a project...
<p>Just like you said: refactor early, refactor often.</p> <p>Refactoring early means the necessary changes are still fresh on my mind. Refactoring often means the changes tend to be smaller.</p> <p>Delaying refactoring only ends up making a big mess which further makes it harder to refactor. Cleaning up as soon as I...
<p>I think you should refactor something when you're currently working on a part of it. Means if you have to enhance function A, then you should refactor it before (and afterwards?). If you don't do anything with this function, then leave it as it is, as long as you have something else to do.</p> <p>Do not refactor a ...
17,004
<p>I need to test a serial port application on Linux, however, my test machine only has one serial port. </p> <p>Is there a way to add a virtual serial port to Linux and test my application by emulating a device through a shell or script?</p> <p>Note: I cannot remap the port, it hard coded on ttys2 and I need to test...
<p>Complementing the @slonik's answer.</p> <p>You can test socat to create Virtual Serial Port doing the following procedure (tested on Ubuntu 12.04):</p> <p><strong>Open a terminal (let's call it Terminal 0) and execute it:</strong></p> <pre><code>socat -d -d pty,raw,echo=0 pty,raw,echo=0 </code></pre> <p><strong>...
<p>Combining all other amazingly useful answers, I found the below command to be VERY useful for testing on different types of Linux distros where there's no guarantee you're <a href="https://unix.stackexchange.com/questions/590302/getting-the-virtual-comport-addr-from-socat-command-with-grep?newreg=03ecb0aa86ea426d84...
7,545
<p>This is something that I have always wondered about, but never bothered to profile.</p> <p>Is it more efficient to assign a value to a temp variable, than to keep using that value. An Example may be clearer:</p> <pre><code>string s = reader.GetItem[0].ToString(); someClass.SomeField = s; someOtherClass.someField ...
<p>The compiler cannot know if the expression on the right-hand-side has side-effects, so it must re-evaluate it if you code it twice. Hence the first is more efficient in the sense that it will not re-do the GetItem &amp; ToString calls.</p> <p>So if you the programmer know that these calls are pure/idempotent, then...
<p>Well assuming that the <code>ToString</code> function not just hands out a reference to some pre-made internal object, it must be pretty clear that the first version, where only one call to it is being made, will be the fastest. However, if this is a performance issue you should care about or not is a completely dif...
29,959
<p>I am completely new to ruby and I inherited a ruby system for a product catalogue. Most of my users are able to view everything as they should but overseas users (specifically Mexico) cannot contact the server once logged in. They are an active user. I'm sorry I cannot be more specific, and the system is private so ...
<p>Speaking as somebody who <em>regularly</em> ends up on your user's side of the fence, the number one culprit for this symptom is "Clueless administrator". There are many, many sites which generically block either large blocks of IP space or which geolocate and carve out big portions of the world. </p> <p>For exam...
<p>If it's working for everyone else then it would appear that the problem is not with Ruby or Rails working, since they are...</p> <p>My first thought would be to check for a network issue: are the Mexican users all behind the same proxy server and/or firewall?</p> <p>Is login handled within the Rails application or...
18,362
<p>Looking for some help with a Labview data collection program. If I could collect 2ms of data at 8kHz (gives 16 data points) per channel (I am collecting data on 4 analog channels with an National Instruments data acquisition board). The DAQ-MX collection task gives a 1D array of 4 waveforms.</p> <p>If I don't disp...
<p>Your overall architecture description sounds solid, but... getting to 30Hz for any non-trivial graph is going to be challenging. Make sure you <em>really need</em> that rate before trying to make it happen. Optimizing to that level might take some time.</p> <p><strong>References that should be helpful:</strong></...
<p>Television updates at about 30 Hz. Any more than that is faster than the human eye can see. 30 Hz should be at the maximum update rate you should consider for a display, not the starting point. Consider an update rate of 5-10 Hz.</p> <p><a href="http://zone.ni.com/reference/en-XX/help/371361B-01/lvconcepts/types_of...
45,005
<p>Can I use JavaScript to check (irrespective of scrollbars) if an HTML element has overflowed its content? For example, a long div with small, fixed size, the overflow property set to visible, and no scrollbars on the element.</p>
<p>Normally, you can compare the <code>client[Height|Width]</code> with <code>scroll[Height|Width]</code> in order to detect this... but the values will be the same when overflow is visible. So, a detection routine must account for this:</p> <pre><code>// Determines if the passed element is overflowing its bounds, // ...
<p>This is a javascript solution (with Mootools) that will reduce the font size to fit the bounds of elHeader. </p> <pre><code>while (elHeader.clientWidth &lt; elHeader.scrollWidth || elHeader.clientHeight &lt; elHeader.scrollHeight) { var f = parseInt(elHeader.getStyle('font-size'), 10); f--; elHeader.setStyle...
17,355
<p>Does anyone know how to show a asp:TreeView always expanded to the leaves? So if I have a 2-level tree, I want it to be expanded at all times. Is there a property on TreeView that does this or could you show the code snippet on how to do this?</p> <p>Thank you very much! Ray.</p>
<p>aspx.cs:</p> <pre><code>protected void Page_Load(object sender, EventArgs e) { TreeView1.ExpandAll(); } </code></pre> <p>if you also want to disable expand-collapse symbols in the tree:</p> <pre><code>&lt;asp:TreeView ID="TreeView1" runat="server" ShowExpandCollapse="false"&gt; &lt;/asp:TreeView&gt; </code></...
<p>And you can use an Integer if you only want to show the roots item per defualt:</p> <pre><code> protected void Page_Load(object sender, EventArgs e) { TreeView1.ExpandDepth = 1; } </code></pre>
47,577
<p>What do I need to install to begin learning Silverlight 2? I know how to build web applications and use c#, I just have very little experience with Silverlight. I used it a little when it first came out and decided to wait until more .net integration took place. In the past I have used Visual Studio 2005 Pro. for ...
<p>See <a href="http://timheuer.com/blog/archive/2008/10/14/silverlight-2-released-officially.aspx" rel="nofollow noreferrer">Silverlight 2 Released: New controls, tools, announcements!</a>:</p> <blockquote> <p>The requirement to install the Silverlight Tools is that you have to have Visual Studio 2008 SP1 installed...
<p>you might want to look at this too:</p> <p><a href="https://stackoverflow.com/questions/203466/good-resource-for-learning-silverlight-2-development">good-resource-for-learning-silverlight-2-development</a></p>
49,017
<p>I'm getting a FileIOPermssion exception thrown when trying to create a folder in Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) on some computers. I've established that there is some form of antivirus running on the computer in question, but I haven't been able to get in contact with their IT d...
<p>I received another answer on a different forum that might be the answer but I've got to verify it first. Basically what they suggested is that the user might have installed the app on a network share instead of directly on the harddrive which would mean the application wouldn't run with full trust. The recommended f...
<p>Vista or XP. Or more importantly, no problems on XP, but problems on Vista? You might be running afoul of UAC which is more stringent about checking the security permissions required for various actions. I ran into a similar problem with a printer set up program I wrote -- works fine on XP, but requires strong-na...
44,100
<p>I am working on a small webapp and I want to use Groovy to write some unit testing for my app. Most of my coding is done on Eclipse and I really want to run all the unit testing with the graphical test runner within Eclipse (I really like the green bar :) )</p> <p>Sadly, after 4 hours of try-and-error, I'm still no...
<p>You might want to give the updated plugin a try, see the <a href="http://blog.springsource.com/2009/07/30/a-groovier-eclipse-experience" rel="nofollow noreferrer">the recent blog post</a> for more details. The theme of this alpha release is <em>providing an optimized edit/save/compile/test experience</em>, which see...
<p>Unfortunately, the Groovy Eclipse plugin is pretty horrible at giving actual helpful information to let you know what is going wrong with your setup. I'm going to assume you already did the verification to make sure the plugin is actually building your Groovy files (i.e. doing a sample with no dependencies, checkin...
3,124
<p>What's the simplest way to convert a Unicode codepoint into a UTF-8 byte sequence in C? The only way that springs to mind is using <code>iconv</code> to map from the UTF-32LE codepage to UTF-8, but that seems like overkill.</p>
<p>Unicode conversion is not a simple task. Using iconv doesn't seem like overkill at all to me. Perhaps there is a library version of iconv you can use to avoid make a system() call, if that's what you want to avoid.</p>
<p>UTF8 works by coding the length of the encoded codepoint into the highest bits of the encoded bytes. see <a href="http://en.wikipedia.org/wiki/UTF-8#Description" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/UTF-8#Description</a></p> <p>I found this small function in C here <a href="http://www.deanlee.cn/p...
29,846
<p>Are there any real world applications written in the <a href="http://clean.cs.ru.nl/" rel="nofollow noreferrer">Clean</a> programming language? Either open source or proprietary.</p>
<p>This is not a direct answer, but when I checked last time (and I find the language very interesting) I didn't find anything ready for real-world.</p> <p>The idealist in myself always wants to try out new languagages, very hot on my list (apart from the aforementioned very cool Clean Language) is currently (random o...
<p><a href="http://clean.cs.ru.nl/Projects" rel="nofollow noreferrer">http://clean.cs.ru.nl/Projects</a> page doesn't look promising :) It looks like just another research project with no real-world use to date.</p>
15,351
<p>Is there an elegant way to create and initialize a <code>const std::vector&lt;const T&gt;</code> like <code>const T a[] = { ... }</code> to a fixed (and small) number of values?<br> I need to call a function frequently which expects a <code>vector&lt;T&gt;</code>, but these values will never change in my case.</p> ...
<p>For C++11:</p> <pre><code>vector&lt;int&gt; luggage_combo = { 1, 2, 3, 4, 5 }; </code></pre> <p><strong>Original answer:</strong></p> <p>You would either have to wait for C++0x or use something like <a href="http://www.boost.org/doc/libs/1_36_0/libs/assign/doc/index.html" rel="nofollow noreferrer">Boost.Assign</a> t...
<p>Not sure if I understood you right. I understand your question like this: you want to initialize a vector to a large number of elements. What's wrong with using <code>push_back()</code> on the vector? :-)</p> <p>If you know the number of elements to be stored (or are sure that it will store less than the next power ...
28,657
<p>What's the best way to store a linked list in a MySQL database so that inserts are simple (i.e. you don't have to re-index a bunch of stuff every time) and such that the list can easily be pulled out in order?</p>
<p>Store an integer column in your table called 'position'. Record a 0 for the first item in your list, a 1 for the second item, etc. Index that column in your database, and when you want to pull your values out, sort by that column.</p> <pre><code> alter table linked_list add column position integer not null defaul...
<p>A list can be stored by having a column contain the offset (list index position) -- an insert in the middle is then incrementing all above the new parent and then doing an insert.</p>
9,098
<p>Given a declaration like this:</p> <pre><code>class A { public: void Foo() const; }; </code></pre> <p>What does it mean?</p> <p>Google turns up this:</p> <blockquote> <p>Member functions should be declared with the const keyword after them if they can operate on a const (this) object. If the function is no...
<p>Consider a variation of your class <code>A</code>.</p> <pre><code>class A { public: void Foo() const; void Moo(); private: int m_nState; // Could add mutable keyword if desired int GetState() const { return m_nState; } void SetState(int val) { m_nState = val; } }; const A *A1 = new A(); A *A...
<p>that will cause the method to not be able to alter any member variables of the object</p>
7,145
<p>What are some good algorithms for automatically labeling text with the city / region or origin? That is, if a blog is about New York, how can I tell programatically. Are there packages / papers that claim to do this with any degree of certainty? </p> <p>I have looked at some tfidf based approaches, proper noun ...
<p>You're looking for a <a href="https://secure.wikimedia.org/wikipedia/en/wiki/Named_entity_recognition" rel="noreferrer">named entity recognition</a> system, or short NER. There are <a href="http://nltk.sourceforge.net/index.php/Main_Page" rel="noreferrer">several</a> <a href="http://opennlp.sourceforge.net/index.htm...
<p><a href="http://en.wikipedia.org/wiki/Latent_semantic_mapping" rel="nofollow noreferrer">Latent Semantic Mapping</a> seems like potentially a good fit. That's just about as naive of an algorithm as you're likely to find.</p>
19,816
<p>I'm using Amazon's tools to build a web app. I'm very happy with them, but I have a security concern.</p> <p>Right now, I'm using multiple EC2 instances, S3, SimpleDB and SQS. In order to authenticate requests to the different services, you include your <a href="https://aws-portal.amazon.com/gp/aws/developer/accoun...
<p>What you can do is have a single, super-locked down 'authentication server'. The secret key only exists on this one server, and all the other servers will need to ask it for permission. You can assign your own keys to the various servers, and lock it down by IP address as well. That way if a server gets compromised,...
<p>AWS offers "Consolidated Billing" which addresses your concern in the second thought.</p> <p><a href="https://aws-portal.amazon.com/gp/aws/developer/account/index.html?ie=UTF8&amp;action=consolidated-billing" rel="nofollow noreferrer">https://aws-portal.amazon.com/gp/aws/developer/account/index.html?ie=UTF8&amp;act...
15,818
<p>I am running NUnit with the project named AssemblyTest.nunit. The test calls another assembly which uses the log4net assembly. This is using nunit version 2.4.3 with the .net 2.0 framework.</p> <p>In TestFixtureSetup I am calling log4net.Config.XmlConfigurator.Configure( ) and am getting the following error:</p> <...
<p>I had the same problem because I forget to add the <em>log4net</em> definition in the <em>configSections</em> element.</p> <p>So, if you want to put <em>log4net</em>-elements into the app.config, you need to include the <em>configSections</em> element (which tells where <em>log4net</em>-elements are defined) at the...
<p>Create a separate config file for log4net with root element log4net.</p> <p>In TestFixtureSetup create a FileInfo object for this config file and give it as argument to log4net.Config.XmlConfigurator.Configure( ).</p>
19,331
<p>I just got burned by the <a href="http://cygwin.com/ml/cygwin-xfree-announce/2008-11/msg00000.html" rel="nofollow noreferrer">Cygwin X11R7.4 update</a> and I find the official mailing lists hostile and clunky. So I thought I'd ask here.</p> <p>If you have survived the upgrade (or at least made progress on fixing t...
<p>I actually found a different sort of solution and now i feel kind of stupid for even asking the question. What I did inside the Service.Outputs.Add() method was really the problem:</p> <pre><code>public void Add(Output output) { OutputCollectionItem oci = new OutputCollectionItem(); oci.item = output; t...
<p>I ran into this same issue, I couldn't come up with an elegant solution. But the only solution I found was to either use "stitching," or to use reflection.</p> <p>Stitching looks something like this.</p> <pre><code>Person existingPerson - DB.GetPerson(1); existingPerson.BirthDate = newPerson.BirthDate; existingPer...
38,948
<p>How does the data go from the MVC to the browser and back again? Does it use Microsoft's own technology like ASMX or WCF or something completely different? </p> <p>This sounds like MVC is using a ASMX Web Service they are using but I can't seem to find any documentation which gives the real answer. </p>
<p>The data from the MVC app &lt;-> browser is just plain ole HTTP request/response data. To see what this raw data is, install <a href="https://addons.mozilla.org/en-US/firefox/addon/1843" rel="nofollow noreferrer" title="FireBug:Firefox addon">Firebug</a> or <a href="https://addons.mozilla.org/en-US/firefox/addon/184...
<p>AJAX requests are performed in the page using normal HTTP request/response. That is, in javascript the client will create a AJAX request object, send it off to a URL and it gets back a string. If that string is json, it can be eval'd and become a live javascript object.</p> <p>The philosophy of MVC is that <em>all</...
37,621
<p>We are using c++ to develop an application that runs in Windows CE 4 on an embedded system.</p> <p>One of our constraint is that all the memory used by the application shall be allocated during <b>startup only</b>. We wrote a lot of containers and algorithms that are using only preallocated memory instead of alloca...
<p>You could write your own allocator for the container, which allocates from a fixed size static buffer. Depending on the usage patterns of the container the allocator could be as simple as incrementing a pointer (e.g. when you only insert stuff into the container once at app startup, and don't continuously add/remove...
<p>Do not use Boost. </p> <p>It is a big library and your basic memory allocation requirements are very different from those of the libraries designers.</p> <p>Even if you can get a current version of Boost to work according to your requirements with custom allocators it may break with a new version of Boost.</p> <p...
20,116
<p>Given the following:</p> <pre><code>declare @a table ( pkid int, value int ) declare @b table ( otherID int, value int ) insert into @a values (1, 1000) insert into @a values (1, 1001) insert into @a values (2, 1000) insert into @a values (2, 1001) insert into @a values (2, 1002) insert into @b ...
<p>Probably not the cheapest way to do it:</p> <pre><code>SELECT a.pkId,b.otherId FROM (SELECT a.pkId,CHECKSUM_AGG(DISTINCT a.value) as 'ValueHash' FROM @a a GROUP BY a.pkId) a INNER JOIN (SELECT b.otherId,CHECKSUM_AGG(DISTINCT b.value) as 'ValueHash' FROM @b b GROUP BY b.otherId) b ON a.ValueHash = b.ValueHas...
<p>As CQ says, a simple inner join is all you need.</p> <pre><code>Select * -- all columns but only from #a from #a inner join #b on #a.value = #b.value -- only return matching rows where #a.pkid = 2 </code></pre>
12,945
<p>Is there a definitive scalable 3D printer? </p> <p>I've seen examples of Chinese companies printing entire houses, and I'm curious as to printers / filaments that are intended (or at least able) be scaled up for (very) large print jobs. </p> <p>Since most hobby printers can take hundreds of hours for something tha...
<p>One big challenge with scaling anything up (or down), is that not all properties or characteristics scale linearly.</p> <p>Consider a trivial case: a small cube. If you double the size, you've quadrupled the surface area and octupled the weight.</p> <p>If you take a desktop-sized 3d printer design, and just double...
<p>As far as I know, right now, all the "3D printers" that can print houses, bridges, etc. are experimental models (and sometimes, vey elaborate art projects) - they just don't exist except as one-off creations designed as a proof-of-concept showing this can be done.</p> <p>Maybe some of those project published their ...
200
<p>how do i get a list of user that have completed or not completed or not responded to a survey. </p> <p>so i have a survey, lets say "survey A". in this survey i have a list of people or groups that must fill the survey. sharepoint already gives us a list of respondents, but i want to make a list of people that have...
<pre><code>bool isSubset = !t2.Except(t1).Any(); </code></pre>
<p>Try this</p> <pre><code>static bool IsSubSet&lt;A&gt;(A[] set, A[] toCheck) { return set.Length == (toCheck.Intersect(set)).Count(); } </code></pre> <p>The idea here is that Intersect will only return the values that are in both Arrays. At this point if the length of the resulting set is the same as the origina...
43,158