instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I'm going to build a <strong>Classic Music</strong> website and the client already has several podcasts for about 3 min each, and I want to know if <strong>should I just add as QT / WMP file</strong> to listen and a ZIP to download, <strong>or should I use a web podcast hosting</strong> solution and just add the lin...
<p>I'd recommend 3rd party hosting for the podcasts (mp3 files are the standard), and on the pages use a flash mp3 player on each podcast post, with a download link as well. Don't forget your RSS and iTunes either, subscriptions are a huge part of podcasting!</p>
<p>If you are expecting many downloads then hosting the files on your own site could run down your bandwidth pretty quickly. A third party host could solve this.</p>
25,320
<p>How do I determine how much an individual print costs?</p> <p>I'd like an answer including support material, failed prints, and (ideally) wear and tear / printer maintenance costs.</p> <p>To clarify, I'm not asking how to <em>predict</em> the cost before printing, but rather how to calculate the actual cost after ...
<p>For <a href="http://3dprintingfromscratch.com/common/types-of-3d-printers-or-3d-printing-technologies-overview/#fdm" rel="nofollow noreferrer">FDM</a> printing: </p> <p>Both Cura and Makerbot Desktop (and perhaps others I'm not as familiar with) will give you a preview of both the length and weight of your print, i...
<p>I recently faced the problem of calculating the cost of my printed 3D models. I wanted to know what their real value had to be counted in Excel. It was really inconvenient. Then I found a program for counting, it turned out really great, even takes into account the electricity. This is not an advertisement just thr...
129
<p>The C# project I'm working on uses nHibernate and the connection string is in the web.config as a property of a Hibernate element. I need to read the connection string in the installer to get a connection manually without using Hibernate. I know I can use configManager.connectionStrings, but as the connection stri...
<p>You could put the connection string in the &lt;connectionStrings /&gt; section of the web.config and then have NHibernate get it from there. In the NHibernate settings, remove the &lt;connection.connection_string&gt; property and replace it with &lt;connection.connection_string_name&gt; supplying the name from the ...
<pre><code>&lt;hibernate&gt; &lt;add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/&gt; &lt;add key="hibernate.dialect" value="NHibernate.Dialect.MsSql2000Dialect"/&gt; &lt;add key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver"/&gt;...
32,996
<p>I'm looking for a profiler in order to find the bottleneck in my C++ code. I'd like to find a free, non-intrusive, and good profiling tool. I'm a game developer, and I use PIX for Xbox&nbsp;360 and found it very good, but it's not free. I know the Intel <a href="https://en.wikipedia.org/wiki/VTune" rel="noreferrer">...
<p><a href="https://gpuopen.com/archived/legacy-codexl/" rel="nofollow noreferrer">CodeXL</a> has now superseded the End Of Line'd <a href="https://web.archive.org/web/20120607044224/http://developer.amd.com/tools/CodeAnalyst/Pages/default.aspx" rel="nofollow noreferrer">AMD Code Analyst</a> and both are free, but not ...
<p>I've used "TrueTime - part of Compuware's DevPartner suite for years. There's a [free version](you could try Compuware DevPartner Performance Analysis Community Edition.) available.</p>
9,308
<p>I'm trying to create a custom transition, to serve as a replacement for a default transition you would get here, for example:</p> <pre><code>[self.navigationController pushViewController:someController animated:YES]; </code></pre> <p>I have prepared an OpenGL-based view that performs an effect on some static textu...
<p>While I cannot completely answer your question without doing some more research of my own, I can help a bit:</p> <p>-In order to get the view of a UINavigationController, you need to take a screenshot. The easiest way to do this is by grabbing it into a UIImage:</p> <pre><code>UIGraphicsBeginImageContext(self.view...
<p>I recently write some transitioning animation betweeen view controllers like you. If you want to get any extra info from the invisible view, you can try delaying the transition like this :</p> <pre><code>- (void)animationFromModalView:(UIView *)modalView toMasterView:(UIView *)masterView { [masterView setNeedsLayo...
39,924
<p>I'm reading through the <a href="http://framework.zend.com/manual/en/coding-standard.coding-style.html" rel="nofollow noreferrer">Zend Framework coding standards</a>, where they state that curly brace after a Class definitions should be on the next line, the "one true brace form".</p> <pre><code>class MyClass { ...
<p>Personal preference is really the only real "reason".</p>
<p>The real reason is to have uniform looking code throughout the codebase. Both styles have their advantages, which style is "better" depends on personal preference and what has been used "traditionally" in the language and the project. </p> <p>If a style of braces is prescribed, use that, else use what was being use...
31,010
<p>I store different items (notes, articles, pictures, files) in a single table (there are many metadata in common for all the item types - for example, categories, tags, rating, statistics etc.).</p> <p>My first design was like this: table <strong>Items</strong>, plus another "detail" table for each of the item types...
<p>If programmers are sensible enough to query only required columns from the table instead of "SELECT *", first design approach looks okay.</p> <p>Need to take care of indexing, referential constraints etc. for the second design.</p>
<p>If the database doesn't need to know what's in those items (won't be indexing or searching on them) then option 1 seems the best option (assuming you just have one 'Item' column as a BLOB) - you can just read out the items as binary data and deal with them yourself as appropriate - thus avoiding that inner join.</p>...
43,216
<p>I need to exclude files with the following pattern:</p> <p>ProjectFoo.Data[0-9]{14}.lgp</p> <p>How can I use RegEx for (Visual)SVN ignore list?</p>
<p>The subversion ignore list doesn't support regular expressions. They are implemented as glob/file patterns.</p> <p>These patterns don't support the {14} repeat construct.</p> <p>The pattern</p> <pre><code>ProjectFoo.Data[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].lgp </code></pre> <p>shoul...
<p>Some basic advice for how to use the other answers on this page with TortoiseSVN backed by VisualSVN Server. You can manually add an svn:ignore property to the folder. Bert's glob/file advice for the patterns works well there (I went with the "good enough" [0-9]* myself). <a href="http://tortoisesvn.net/docs/release...
46,781
<p>I need to play .vox files on my web page. Does anyone have any tips on how to play .vox files using the Silverlight Mediaplayer control?</p>
<p>Silverlight will only play VC-1 encoded content right now. You can see the supported formats/containers here: <a href="http://msdn.microsoft.com/en-us/library/cc189080(VS.95).aspx" rel="nofollow noreferrer">Supported Audio and Video Formats</a>.</p>
<p>It won't play VOX files. Convert it to MP3 and it should play.</p>
38,299
<p>we're currently planning a larger WPF LoB application and i wonder what others think being the best practice for storing lots of UI settings e.g.</p> <ul> <li>Expander States</li> <li>Menu orders</li> <li>Sizing Properties</li> <li>etc...</li> </ul> <p>i don't like the idea of having dozens of stored values using ...
<p>We store the preferences file here:</p> <pre><code>Environment.SpecialFolder.ApplicationData </code></pre> <p>Store it as xml "preferences" file so it's not so hard to get to and change if it ever gets corrupted.</p> <p>So far this has worked much better than the registry for us, it's cleaner and easier to blow o...
<p>Seems to be losing popularity for some reason; but the registry has always been an appropriate place for these kinds of settings.</p>
30,646
<p>I am new to developing for Office Forms Server / MOSS 2007. I have to choose between designing my web-based forms and writing code for them in Visual Studio Tools for Applications (aka VSTA) or Visual Studio Tools for Office (aka VSTO). VSTA is included free as part of the license for InfoPath 2007; VSTO, also fre...
<p>This explains it better than I can: <a href="http://blogs.msdn.com/andreww/archive/2006/02/21/536179.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/andreww/archive/2006/02/21/536179.aspx</a></p> <p>Given the fact that the license for VSTA comes with InfoPath, I'd probably run with that.</p>
<p>To add to Bennor's answer I would avoid writing code "behind" InfoPath forms entirely. This is a desperate attempt to make 'dumb XML' as much as possible instead of "smart" XML that is entangled with code. Failing this, my next choice is VSTA because historically these solutions (at least the ones I have written) ha...
10,430
<p>We’re developing a web-based application that allows administrators to upload plug-ins. All plug-ins are stored in a special folder outside the app root (say, C:\Plugins) and are dynamically loaded via Assembly.LoadFrom(). This works just fine for the most part: WebControls in the plug-ins are instantiated and loade...
<p>Assembly.LoadFrom is dynamic (late bound) which means the type is not included during compilation time therefore references to its contained classes are invalid. You need to specifically reference the assembly so its included as part of the compilation of the *.aspx class.</p> <p>You may find some of the source co...
<p>Have you tried fully-qualifying the namespace for the helper class? Is it public? Is it in the same assembly? Perhaps it's in another assembly that has to be loaded as well.</p> <p>Try stepping into the code and examining the type of InternalHelperClass. The newer "website" methods of compilation often add name...
19,754
<p>I love TortoiseSVN, as I'm sure many do.</p> <p>we've fairly recently moved to TFS at work, and I find myself wanting Tortoise for TFS.</p> <p>I tried the TFS Power Toys ( I'm running under Windows Server 2003) but no icons turned up).</p> <p>Is it a vista only thing?</p> <p>Is there a way to get TFS to expose S...
<p>In the latest TFS power tools there was shell integration but it requires the following:</p> <ul> <li>Custom selection during the install (it's not part of the standard install)</li> <li>You must be logged into the windows machine using the same accound credentials that you would use to connect to your TFS instance...
<p>You said that SVNBridge doesn't work for you, but I would recommend giving it a second look and trying to figure out what is not working. I use it here and have no major problems except browsing the repository is slow.</p> <p>Here are snippets from a doc I wrote for our office on getting it up and running. It might...
43,524
<p>I need to extract and decode barcodes and text from images. Is there any open source library available that helps to accomplish that task? If not, do you know a good commercial product?</p>
<p>Disclaimer: I work for Atalasoft.</p> <p>DotImage + the <a href="http://www.atalasoft.com/products/dotimage/barcode/" rel="nofollow noreferrer">Barcode Reader addon</a> from Atalasoft offers a Runtime Royalty-Free option that does not use any COM.</p>
<p>I am a fan of Pegasus Imaging's Barcode Xpress<br> www.jpg.com</p>
12,271
<p>This is a <a href="https://stackoverflow.com/questions/319199/why-is-java-able-to-store-0xff000000-as-an-int">follow up question</a>. So, Java store's integers in <a href="http://en.wikipedia.org/wiki/Two%27s_complement" rel="nofollow noreferrer">two's-complements</a> and you can do the following:</p> <pre><code>in...
<p>C# (rather, .NET) also uses the two's complement, but it supports both signed and unsigned types (which Java doesn't). A bit mask is more naturally an unsigned thing - why should one bit be different than all the other bits?</p> <p>In this specific case, it is safe to use an unchecked cast:</p> <pre><code>int ALPH...
<p>And just to add insult to injury, this will work too:</p> <pre><code>-0x7F000000 </code></pre>
41,384
<p>The image below I indicated where the point where the tip of my extruder returns after changing the layer height, I don't know if I am right to call this point &quot;Start Point&quot; ...</p> <p><a href="https://i.stack.imgur.com/mZmgC.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mZmgC.jpg" alt...
<p>Photo interpretation: I understand that the image on the right presents the actual error: it happens on many layers, following the red &quot;Starting Point&quot; line (so above it on the photo). Interesting issue. Btw. which side of the print is the bottom (zero layer)? - I believe the left side, and the right side ...
<p>Photo interpretation: I understand that the image on the right presents the actual error: it happens on many layers, following the red &quot;Starting Point&quot; line (so above it on the photo). Interesting issue. Btw. which side of the print is the bottom (zero layer)? - I believe the left side, and the right side ...
1,819
<p>One thing that always been a pain is to log SQL (JDBC) errors when you have a PreparedStatement instead of the query itself.</p> <p>You always end up with messages like:</p> <pre><code>2008-10-20 09:19:48,114 ERROR LoggingQueueConsumer-52 [Logger.error:168] Error executing SQL: [INSERT INTO private_rooms_bans (ro...
<p>I tried <a href="http://code.google.com/p/log4jdbc/" rel="nofollow noreferrer">log4jdbc</a> and it did the job for me.</p> <p><em>SECURITY NOTE: As of today August 2011, the logged results of a log4jdbc prepared statement are NOT SAFE to execute. They can be used for analysis, but should NEVER be fed back into a D...
<ol> <li><p>If you are using MySQL, MySQL Connector's PreparedStatement.toString() <a href="http://bugs.mysql.com/bug.php?id=5133" rel="nofollow noreferrer">does include the bound parameters</a>. Though third-party connection pools may break this.</p></li> <li><p>Sub-class PreparedStatement to build up the query string...
26,830
<p>Updating an old ASP/Access site for a client - I need SQL to add a column to an existing table and set a default value. Doesn't work - any ideas?</p> <p>This works fine</p> <pre><code>ALTER TABLE documents ADD COLUMN membersOnly NUMBER </code></pre> <p>I want this to work:</p> <pre><code>ALTER TABLE documents AD...
<p>Tools -&gt; Options -&gt; Tables/Queries -&gt; (At the bottom right:) Sql Server Compatible Syntax - turn option on for this database.</p> <p>then you can execute your query:</p> <pre><code>ALTER TABLE documents ADD COLUMN membersOnly NUMBER DEFAULT 0 </code></pre>
<p>Tools -> Options -> Tables/Queries -> (At the bottom right:) Sql Server Compatible Syntax - turn option on for this database.</p> <p>is not found on MS Access 2010</p>
6,981
<p>I would like to get a general consensus for the minimal/boilerplate professional PHP team development environment. I can not find this information anywhere on the web. In the open-source world there are so many choices and so many ways to do things but I've yet to find any common best-practice for the infrastructu...
<p>I'll start. <strong>feel free to edit and improve this</strong></p> <p>This is for a ficticious product called: dundermifflin.com</p> <ol> <li><p>Setup a development virtual machine running the same software you plan on using in production: e.g. Ubuntu with PostgreSQL, Apache and PHP5.</p></li> <li><p>Each develop...
<p>For continuous integration, linked with your version control system, and automated unit testing I find this article very interesting:</p> <p><a href="http://nohn.net/blog/view/id/cruisecontrol_ant_and_phpunit" rel="nofollow noreferrer">Continuous builds with CruiseControl, Ant and PHPUnit</a></p>
25,871
<p>We have a number of web servers, each running one version of ColdFusion. The cluster has a load balancer on front of it. </p> <p>Obviously each of these servers has its own CF application running and this implements query caching at the CF application level. However, since all of these servers service the one web a...
<p>You might consider giving <a href="http://www.flexablecoder.com/blog/index.cfm/2007/12/11/external-caching-for-coldfusion-with-memcached" rel="nofollow noreferrer">memcached</a> a try.</p>
<p>you can cluster across and have the application scope shared across the servers, but you must be using the enterprise version of ColdFusion. More information here: <a href="http://livedocs.adobe.com/coldfusion/7/htmldocs/00001774.htm" rel="nofollow noreferrer">http://livedocs.adobe.com/coldfusion/7/htmldocs/0000177...
48,114
<p>On a PHP-based web site, I want to send users a download package after they have filled out a short form. The site-initiated download should be similar to sites like download.com, which say "your download will begin in a moment."</p> <p>A couple of <strong>possible approaches</strong> I know about, and browser comp...
<p>You can also do a meta refresh, which most browsers support. Download.com places one in a noscript tag.</p> <pre><code>&lt;meta http-equiv="refresh" content="5;url=/download.php?doc=123.zip"/&gt; </code></pre>
<p>How about changing the location to point to the new file? (e.g. by changing window.location)</p>
8,551
<p>I'm trying to understand the event system of Kohana. The only thing i don't understand is, where to place the Event::add code. </p> <p>It should be in a place where it is executed before any events are fired. Or am I missing something? </p> <p>What i want to achieve is to construct a class that is available everyw...
<p>Try adding in a <a href="http://docs.kohanaphp.com/general/hooks" rel="nofollow noreferrer">hook</a> with your Event::Add code.</p> <p>From the documentation:</p> <blockquote> <p>The power of hooks mainly comes from the Events class. Hooks are loaded before any of the events are started so you can attach a hook ...
<p>Usually Event::add() and Event::replace() are placed in the Hook constructor. Hooks are loaded before the first event of system ('system.ready') so you can add your callback to every system or custom event.</p>
45,883
<p>I know it is a good idea to store configuration data in app.config (e.g. database connection strings) instead of hardcoing it, even if I am writing an application just for myself. But is there a way to update the configuration data stored in app.config from the program that is using it?</p>
<p>If you use the Settings for the project, you can mark each setting as either application or user.</p> <p>If they're set as user, they will be stored per-user and when you call the Save method it will be updated in the config for that user.</p> <p>Code project has a really detailed <a href="http://www.codeproject.c...
<p>app.config isn't what you want to use for user-tweakable data, as it'll be stored somewhere in Program Files (which the user shouldn't have write permissions to). Instead, settings marked with <code>a UserScopedSettingAttribute</code> will end up in a user-scoped .config file somewhere in %LocalAppData%.</p> <p>I f...
5,698
<p>There is a number of commercial products out there, that give you a windows based installers for configuring your app and the back end SQL Server DB. Typically it will ask if you want to connect to the DB with Windows or SQL Server authentication. Most of them make a recommendation to use Windows Auth and then confi...
<p>Using NETWORK SERVICE as a db_owner is probably OK for a lot of environments.</p> <p>If you want to have a higher degree of security, simply create a separate Windows Account, grant it the minimum access it needs in SQL Server, and then change the application to run under the context of this new account.</p> <p>Th...
<p>Yes, the application (and any user of it) can potentially execute anything that dbo can execute against the database. DROP TABLE, SELECT * FROM PASSWORDS, etc. </p> <p>If you setup preventative measures against SQL Injection and have written your application with the appropriate application layer security, then thi...
37,842
<p>I need a robust and simple way to remove illegal path and file characters from a simple string. I've used the below code but it doesn't seem to do anything, what am I missing?</p> <pre><code>using System; using System.IO; namespace ConsoleApplication1 { class Program { static void Main(string[] arg...
<p>Try something like this instead;</p> <pre><code>string illegal = "\"M\"\\a/ry/ h**ad:&gt;&gt; a\\/:*?\"| li*tt|le|| la\"mb.?"; string invalid = new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars()); foreach (char c in invalid) { illegal = illegal.Replace(c.ToString(), ""); } </co...
<p>Or you can just do</p> <pre><code>[YOUR STRING].Replace('\\', ' ').Replace('/', ' ').Replace('"', ' ').Replace('*', ' ').Replace(':', ' ').Replace('?', ' ').Replace('&lt;', ' ').Replace('&gt;', ' ').Replace('|', ' ').Trim(); </code></pre>
17,603
<p>I need to generate some passwords, I want to avoid characters that can be confused for each other. Is there a definitive list of characters I should avoid? my current list is</p> <p>il10o8B3Evu![]{}</p> <p>Are there any other pairs of characters that are easy to confuse? for special characters I was going to limit...
<p>Here are the character sets that Steve Gibson uses for his <a href="https://www.grc.com/ppp.htm" rel="noreferrer">"Perfect Paper Password"</a> system. They are "characters to allow" rather than "characters to avoid", but they seem pretty reasonable for what you want:</p> <p>A standard set of 64 characters</p> <pre...
<p>I don't love the wordlist approach. For example, in /usr/share/dict/words on OSX, there are 5110 4-character words. Using two of them with a seperator character produces ~600M combinations. But if you used the character set directly with a strong random number generator, you'd have 88^9 possible passwords, 3.16e+17 ...
7,935
<p>I am using a DBGrid component in Delphi. I wonder how I can set the format of a column. I have real values that I want to be displayed as currency in the grid. </p> <p>Someone knows how?</p>
<ol> <li>You can set the <code>DisplayFormat</code> of the <code>Field</code></li> <li>You can handle <code>OnGetText</code> event. This approach allows to do more complex operations with the value. </li> </ol>
<p>The first port of call is the DisplayFormat of the data field in the database itself.</p>
25,605
<p>Is there an official convention for naming private fields in VB.NET? For example, if I have a property called 'Foo', I normally call the private field '_Foo'. This seems to be frowned upon in the <a href="http://msdn.microsoft.com/en-us/library/ms229012.aspx" rel="noreferrer">Offical Guidelines</a>:</p> <p>"Do no...
<p>I still use the _ prefix in VB for private fields, so I'll have _foo as the private field and Foo as the property. I do this for c# as well and pretty much any code I write. Generally I wouldn't get too caught up in "what is the right way to do it" because there isn't really a "right" way (altho there are some very ...
<p>I agree with @lomaxx, it's more important to be consistent throughout the team than to have the <em>right</em> convention.</p> <p>Still, here are several good places to get ideas and guidance for coding conventions:</p> <ol> <li><a href="http://www.dotnet2themax.com/PracticalGuidelines.aspx" rel="nofollow noreferr...
2,919
<p>Is it possible to set the DataContext property of a usercontrol after the user control has been loaded, and force the usercontrol to rebind?</p>
<p>I'm pretty sure that if you just set the datacontext again, it will rebind</p>
<p>Setting the DataContext property should cause the rebind.</p>
48,311
<p>I have <a href="http://laconi.ca/trac/" rel="nofollow noreferrer">Laconica</a> (self hosted <a href="http://twitter.com/home" rel="nofollow noreferrer">twitter</a>) configured on my local intranet and would like to integrate the public stream into SharePoint site with a web part. How can I do this?</p>
<p>You can point an RSS Viewer web part at the laconi.ca public stream RSS feed and use this XSLT to ensure attractive output.</p> <p><strong>Result screen shot:</strong></p> <p><a href="https://i.stack.imgur.com/dMlja.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dMlja.jpg" alt="Screenshot of Laco...
<p>I like the RSS idea. Another option would be to create a Laconica plugin and hook the EndNoticeSave event to push notices to SharePoint.</p>
13,325
<p>I would like to create an XML-based website. I want to use XML files as datasources since it is a kind of online directory site. Can someone please give me a starting point? Are there any good online resources that I can refer to? I am pretty comfortable with ASP and JavaScript.</p>
<p>If you cannot or don't wish to store your data in XHTML format, then XSLT is definitely the way you want to go. By its very definition, it is a transformation language designed to transform data from one format to another. Because this is it's focus, it provides power, speed and flexibility you won't find in many ot...
<p>jQuery, AJAX, and PHP are your friends - for static content, a few nested loops in PHP can easily prase XML into XHTML (kudos to the person who pointed out that well-formed xhtml is xml), and with jQuery you can AJAX in additional content as needed.</p> <p>Also - did I mention that they're all free?</p>
13,294
<p>Wanted to see peoples thoughts on best way to organize directory and project structure on a project / solution for a winforms C# app. </p> <p>Most people agree its best to seperate view, business logic, data objects, interfaces but wanted to see how different people tackle this. In addition, isolate third party d...
<p>For me it depends on the model I'm following. If I'm using MVC it would be</p> <pre><code>Project -Models -Controllers -Views </code></pre> <p>Or for MVP it would be</p> <pre><code>Project -Models -Presenters -Views </code></pre> <p>Under the views I seperate them into namespaces relevant to the controllers, i.e...
<p>We usually keep SourceSafe projects, project names, namespaces and directory structures in sync. </p> <p>For example, given our company name as XCENT the SourceSafe structure and the corresponding directory structure for App1 looks like:</p> <pre><code>\XCENT \XCENT\App1 \XCENT\App1\UI \XCENT\App1\UI\Test //test h...
21,715
<p>Our Flex app would like to work with requests and responses as object graphs (nothing unusual there) e.g. response becomes the model of some view, and would be a structure with several layers of nesting.</p> <p>** Now, ideally we would like to use the same client (and server) side objects for different message form...
<p>Regarding the Xml serialization I can give you a starting point (as biased as it may be, though :D). </p> <p>I am working on a project that allows for automatic conversion of AS3 objects to and from xml. It basically uses annotations on the model objects you use for communication in order to construct the xml struc...
<p>There's a library including JSON available from Adobe, too. And since ActionScript is a superset of JavaScript ... and JSON is increasingly supported cross-framework ...</p>
33,938
<p>Well, after a long time writing .net programs in C# I started to feel angry and frustrated about all that syntactic trash that comes with statically typed languages. Now I want to change to dynamically typed languages, that takes advantage of CLI. So I searched a bit around and I didn't like of what I saw. I first l...
<p>I'd still use <a href="http://boo.codehaus.org/" rel="nofollow noreferrer"><strong>Boo</strong></a>. I'm not sure why you believe Boo has been halted. Development sometimes seems slow, but there are multiple people currently working on bug fixes as demonstrated by <a href="http://jira.codehaus.org/sr/jira.issuevie...
<p>Take a look at <a href="http://clojure.org/" rel="nofollow noreferrer">Clojure</a>. The CLR version is still in the early stages, but you could probably get the java version working in .Net via <a href="http://www.ikvm.net/" rel="nofollow noreferrer">IKVM</a></p>
20,818
<p>My win32 C++ application frequently checks a file that normally resides on a network share [in our corporate network]. But if the computer isn't connected to a network, the application freezes for several minutes and the user usually has to end the process. How can I check if the file is accessible before I open it?...
<p>I think a thread is your best option.</p> <p>There does not appear to be a way to invoke the CreateFile API asynchronously. Once a file handle is open you can do asynchronous I/O on it, but the act of opening it is still synchronous.</p> <p>You will have to manage the synchronization with the thread yourself sinc...
<p>It seems to me this method in a separate thread would be your best bet.</p> <p><a href="http://msdn.microsoft.com/en-us/library/system.io.file.exists(VS.71).aspx" rel="nofollow noreferrer">File.Exists</a></p>
14,795
<p>I'm trying to do the following without too much special case code to deal with invalidated POSITIONs etc:</p> <p>What's the best way to fill in the blanks?</p> <pre><code>void DeleteUnreferencedRecords(CAtlMap&lt;Record&gt;&amp; records) { for(____;____;____) { if( NotReferencedElsewhere(record) ) ...
<p>According to this:</p> <p><a href="http://msdn.microsoft.com/en-us/library/0h4c3zkw(VS.80).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/0h4c3zkw(VS.80).aspx</a></p> <p>RemoveAtPos has these semantics</p> <blockquote> <p>Removes the key/value pair stored at the specified position. The ...
<p>My first thoughts would be the save the current POSITION before calling <code>GetNext</code>, then, if you delete the element you can reset it. However, perhaps the safest way would be to create a new map containing the elements you want to keep, else you could be relying on how the internal implementation of POSIT...
23,967
<p>Imagine that you want to develop a non-trivial end-user desktop (not web) application in Python. What is the best way to structure the project's folder hierarchy?</p> <p>Desirable features are ease of maintenance, IDE-friendliness, suitability for source control branching/merging, and easy generation of install pac...
<p>Doesn't too much matter. Whatever makes you happy will work. There aren't a lot of silly rules because Python projects can be simple.</p> <ul> <li><code>/scripts</code> or <code>/bin</code> for that kind of command-line interface stuff</li> <li><code>/tests</code> for your tests</li> <li><code>/lib</code> for you...
<p>Non-python data is best bundled inside your Python modules using the <code>package_data</code> support in <A HREF="http://peak.telecommunity.com/DevCenter/setuptools" rel="nofollow noreferrer">setuptools</A>. One thing I strongly recommend is using namespace packages to create shared namespaces which multiple projec...
23,482
<p>I'm looking for a way to create Outlook Task Request from ASP.NET. I'm using Exchange Server 2003 for email server. Basically, user of my ASP.NET application will do something that will create Outlook Task based on some logic. Is this natively supported in .NET or must I use third party component?</p>
<p>You can use WebDav for Exchange. <a href="http://blog.downtownsoftwarehouse.com/2006/10/26/using-net-and-webdav-to-access-an-exchange-server/" rel="nofollow noreferrer">Here</a> is an example how to do this.</p>
<p>Are you using Outlook with an Exchange Server? If so, you can use Exchange Web Services.</p> <p>Exchange Web Services are an easy way of doing pretty much anything within an Exchange mailbox, so if you're going to be doing more than just Outlook Tasks, then it may be worth looking at. Otherwise, AFAIK, there are no...
39,698
<p>I'm using the Repeater control on my site to display data from the database. I need to do pagination ("now displaying page 1 of 10", 10 items per page, etc) but I'm not sure I'm going about it the best way possible.</p> <p>I know the Repeater control doesn't have any built-in pagination, so I'll have to make my own...
<p>This isn't a way to page the data, but have you looked into the <a href="http://msdn.microsoft.com/en-us/library/bb398790.aspx" rel="nofollow noreferrer">ListView</a> control? It gives the flexibility of repeater / data list but with built in paging like the grid view.</p> <p>And for paging in sql, you would want t...
<p>This was answered <a href="https://stackoverflow.com/questions/2840/paging-sql-server-2005-results">here</a>.</p>
4,298
<p>While there are 100 ways to solve the conversion problem, I am focusing on performance.</p> <p>Give that the string only contains binary data, what is the fastest method, in terms of performance, of converting that data to a byte[] (not char[]) under C#?</p> <p>Clarification: This is not ASCII data, rather binary...
<p>I'm not sure ASCIIEncoding.GetBytes is going to do it, because it only supports the <a href="https://learn.microsoft.com/en-us/dotnet/api/system.text.asciiencoding" rel="nofollow noreferrer">range 0x0000 to 0x007F</a>. </p> <p>You tell the string contains only bytes. But a .NET string is an array of chars, and 1 ch...
<p>There is <em>no such thing</em> as an ASCII string in C#! Strings <em>always</em> contain UTF-16. Not realizing this leads to a lot of problems. That said, the methods mentioned before work because they consider the string as UTF-16 encoded and transform the characters to ASCII symbols.</p> <p>/EDIT in response to ...
9,779
<p>I am using the ReportViewer control from Visual Studio 2008 in Local Mode with objects as the data source. My classes are mapped to data tables in my database. In the objects, it loads related objects as needed. So it leaves the reference null until you try to use the property, then it tries to load it from the data...
<p>I've found the solution. You specify System.Security.Policy.Evidence of you executing assembly (or one that has sufficient rights) to the LocalReport for use during execution.</p> <pre><code>reportViewer.LocalReport.ExecuteReportInCurrentAppDomain(System.Reflection.Assembly.GetExecutingAssembly().Evidence); </code...
<p>One quick thought, although this isn't an error I've seen, make sure that your Assert is in the same method as the code that is setting the resource data source:</p> <pre><code>System.Data.SqlClient.SqlClientPermission mPermission = new SqlClientPermission(System.Security.Permissions.PermissionState.Unrestricted); ...
33,002
<p>Right, initially ran:</p> <pre><code>c:\regsvr32 Amazing.dll </code></pre> <p>then, (accidentally - I might add) I must have run it again, and (indeed) again when new versions of 'Amazing.dll' were released. Yes - I know <em>now</em> I should've run:</p> <pre><code>c:\regsvr32 /u Amazing.dll </code></pre> <p>bef...
<p>Your object's GUID's should not be changing. In other words, once you register the COM object, re-registering shouldn't be adding anything additional to the registry.</p> <p>Unless you added additional COM interfaces or objects to the project.</p> <p>In any case, if this is a one time deal (and it sounds like it i...
<p>I've got myself into a horrible mess with COM before. I had to pick my way though the registry deleting each reference, unfortunately.</p>
4,010
<p>Let's say I have 3 point clouds: first that has 3 points {x1,y1,z1}, {x2,y2,z2}, {x3,y3,z3} and second point cloud that has same points as {xx1, yy1, zz1}, {xx2,yy2,zz2}, {xx3,yy3,zz3}... I assume to align second point cloud to first I have to multiply second one's points by T[3x3matrix]. </p> <p>1) So how do I fin...
<p>The transformation matrix T1 that takes the unit vectors {1, 0, 0}, {0, 1, 0}, and {0, 0, 1} to {x1, y1, z1}, {x2, y2, z2}, {x3, y3, z3} is simply</p> <pre> | x1 x2 x3 | T1 = | y1 y2 y3 | | z1 z2 z3 |</pre> <p>And likewise the transformation T2 that takes those 3 unit vectors to the second set of points ...
<p>Here is an <a href="http://casoilresource.lawr.ucdavis.edu/drupal/node/532" rel="nofollow noreferrer">example</a> of computing least-squares estimates of the parameters of a 2D affine transformation in R.</p>
46,757
<p>How can I assert my <a href="http://en.wikipedia.org/wiki/Ajax_%28programming%29" rel="noreferrer">Ajax</a> request and test the JSON output from Ruby on Rails functional tests?</p>
<h2>In Rails &gt;= 5</h2> <p>Use <a href="https://www.apidock.com/rails/v6.0.0/ActionDispatch/TestResponse/parsed_body" rel="noreferrer"><code>ActionDispatch::TestResponse#parsed_body</code></a>.</p> <p>Example:</p> <pre><code>user = @response.parsed_body assert_equal &quot;Mike&quot;, user['name'] </code></pre> <h2>In...
<p>You can use the <a href="https://github.com/xing/assert_json" rel="nofollow" title="AssertJson gem">AssertJson gem</a> for a nice DSL which allows you to check for keys and values which should exist in your JSON response.</p> <p>Add the gem to your <code>Gemfile</code>:</p> <pre><code>group :test do gem 'assert_...
43,678
<p>I know that there are a few (automatic) ways to create a data access layer to manipulate an existing database (LINQ to SQL, Hibernate, etc...). But I'm getting kind of tired (and I believe that there should be a better way of doing things) of stuff like:</p> <ol> <li>Creating/altering tables in Visio</li> <li>Using...
<p>Check out <a href="http://wiki.dataobjects.net" rel="nofollow noreferrer">DataObjects.Net</a> - is is designed to support exactly this case. Code only, and nothing else. Its <a href="http://wiki.dataobjects.net/index.php?title=Schema_upgrade" rel="nofollow noreferrer">schema upgrade layer</a> is probably the most fe...
<p>Some of the really big dogs, such as <a href="http://ca.com/us/products/product.aspx?id=260" rel="nofollow noreferrer">ERwin Data Modeler</a>, will go object to DB. You need to have the big bucks to afford the product though.</p>
4,883
<p>I'm looking for a QR-Code library for C/C++, not Java or .Net please. Anyone knows of one?</p> <p>Note: There was a <a href="https://stackoverflow.com/questions/231741/qr-code-2d-barcode-coding-and-decoding-algorithms">similar question</a> a while back however but it didn't get answered properly.</p>
<p>How is this one?</p> <p><a href="http://megaui.net/fukuchi/works/qrencode/index.en.html" rel="noreferrer">http://megaui.net/fukuchi/works/qrencode/index.en.html</a></p>
<p>check out my widely cross platform C port of Psytec QR Image generator <a href="https://github.com/swex/QR-Image-embedded" rel="nofollow">https://github.com/swex/QR-Image-embedded</a></p>
39,138
<p>I have a class <code>Page</code> that creates an instance of <code>DB</code>, which is named <code>$db</code>.</p> <p>In the <code>__construct()</code> of <code>Page</code>, I create the new <code>$db</code> object and I pull a bunch of config data from a file.</p> <p>Now the DB class has a method <code>_connectTo...
<p>I find that it's often easier to initialise all the "important" objects close to whatever variables they need to know. You could try it this way:</p> <pre><code>/* Code to get config variables here */ $DB = new DB($config); /* You might want to delete the database password from $config here */ $Page = new Page($con...
<p>You can pass the child a reference to the parent. For example:</p> <pre><code>class Parent { function __construct() { $this-&gt;myChild = new Child($this); } public function doSomething() {} } class Child { function __construct(Parent $parent) { $parent-&gt;doSomething() } } </code></pre> <p>You...
43,598
<p>I have form area in my view. If I click button <kbd>A</kbd>, I want to submit to <code>/Books/1</code> and if I click button <kbd>B</kbd>, I want to submit to <code>/Books/2</code></p> <p>How do I achieve this with MVC?</p>
<p>It sounds like what you want to do is call the Books Controller, with, say, the Search action. So for instance you might want to call /Books/Search/&lt;search expression&gt;/1, or /Books/Search/&lt;search expression&gt;/2, etc. (There's a few different ways you could be formatting these URLs, but it's mostly a matte...
<p>I have never seen the ability to have a form field attached to two forms, seems like it wouldn't work. What you can do is put a hidden field in the second form which, on submission, grabs the information from the textbox in the first form. </p>
30,454
<ol> <li>What are the patterns you use to determine the frequent queries? </li> <li>How do you select the optimization factors?</li> <li>What are the types of changes one can make?</li> </ol>
<p>This is a nice question, if rather broad (and none the worse for that).<br /> If I understand you, then you're asking how to attack the problem of optimisation starting from scratch.</p> <p>The first question to ask is: &quot;<em>is there a performance problem?</em>&quot;<br /> If there is no problem, then you're d...
<ol> <li>For MySQL there is a feature called <a href="http://dev.mysql.com/doc/refman/5.0/en/slow-query-log.html" rel="nofollow noreferrer">log slow queries</a></li> </ol> <p>The rest is based on what kind of data you have and how it is setup.</p>
16,597
<p>Whenever I restore a backup of my database in SQL Server I am presented with the following error:</p> <pre><code>Msg 3101, Level 16, State 1, Line 1 Exclusive access could not be obtained because the database is in use. Msg 3013, Level 16, State 1, Line 1 RESTORE DATABASE is terminating abnormally. </code></pre> <...
<p>You can force the database offline and drop connections with:</p> <pre><code>EXEC sp_dboption N'yourDatabase', N'offline', N'true' </code></pre> <p>Or you can</p> <pre><code>ALTER DATABASE [yourDatabase] SET OFFLINE WITH ROLLBACK AFTER 60 SECONDS </code></pre> <p>Rollback specifies if anything is executing. Afte...
<p>I'd suggest talking to your co-worker, and asking him to leave the database. (And make him aware of the problem, because he might lose changes he's made when you restore.)</p> <p>That's far better than dropping his connections, or setting exclusive access which might cause him some inconvenience.</p>
22,213
<p>In 3D printing firmware and slicers, jerk settings are expressed in units if mm/s. This is contrary the physical definition of jerk, which is in units of mm/s³, being the second derivative of speed with respect to time (or the third derivative of position). What is the reason for this discrepancy and how does one in...
<p>The jerk setting in 3D printing G-code and firmware represents a concept similar to, but distinct from, the physical definition of jerk. Rather, it's a [limit on] instantaneous change of speed.</p> <p>Mathematically, one way to make sense of this is to think that, rather than being the second derivative of speed wit...
<p>The units for jerk should be meters per second cubed or m/s<sup>3</sup>. </p> <p>Meters are the basic unit for <em>distance</em>. The first derivative is speed, or <em>velocity</em>, m/s. The second derivative is <em>acceleration</em>, m/s<sup>2</sup>. The third derivative is <em>jerk</em>, m/s<sup>3</sup>.</p> <p...
1,376
<p>Are 3D printed gears applicable for industrial use? </p> <p>I want to print some gears with ABS. </p> <ul> <li>What will their lifespan be? How long will they last if I use them, for example, every day? </li> </ul>
<p>Well, to determine the time life of the gears you will need to do a test called ALT (Accelerated Life Time) but the parts should be last for a long time (not years) however this can be determined by thickness. </p> <p>The torque required is not than much like a tuning up the radio volume, so if you are going to cre...
<p>Well, to determine the time life of the gears you will need to do a test called ALT (Accelerated Life Time) but the parts should be last for a long time (not years) however this can be determined by thickness. </p> <p>The torque required is not than much like a tuning up the radio volume, so if you are going to cre...
766
<p>I have written an AIR Application that downloads videos and documents from a server. The videos play inside of the application, but I would like the user to be able to open the documents in their native applications.</p> <p>I am looking for a way to prompt the user to Open / Save As on a local file stored in the Ap...
<p>You can use the new <code>openWithDefaultApplication();</code> function that's available on the File class (I believe it's only available in AIR 2)</p> <p>eg:</p> <pre><code>var file:File = File.desktopDirectory.resolvePath(fileLocation); file.openWithDefaultApplication(); </code></pre>
<p>Currently adobe is not supporting opening files in there default applications. Passing it off to the browser seems to be the only way to make it work.</p> <p>You could however use a FileStream and write a small html file with some javascript that sets the location of an iframe to the file, then after 100ms or so ca...
2,699
<p>I've changed SD cards, printed from USB connection, upgraded/reloaded firmware and attempted using different software packages. Nothing has worked yet. When connected via USB, I get a &quot;disconnected&quot; error after a few minutes into the print. Also, the LED lights now either don't work at all or will rando...
<p>I recently had this problem and narrowed it down to the part cooling fan (on the side of the extruder head). I diagnosed the problem by noticing that the printer would reboot shortly after the second layer started, only on PLA prints. Of course, the part cooling fan is not usually started until after the first lay...
<p>I had a similar problem with my Ender 3 that started after relocating the power supply to a (3D printed) bracket to give additional clearance from the edge of the bed (it was touching the magnetic build sheet, potentially causing prints to lift or warp at +X +Y corner).</p> <p>What I found was that the brackets I ha...
2,030
<p>I have a console app that needs to display the state of items, but rather than having text scroll by like mad I'd rather see the current status keep showing up on the same lines. For the sake of example:</p> <blockquote> <p><code>Running... nn% complete</code><br> <code>Buffer size: bbbb bytes</code></p> </bl...
<p>You can use <a href="http://msdn.microsoft.com/en-us/library/ms686025.aspx" rel="noreferrer">SetConsoleCursorPosition</a>. You'll need to call <a href="http://msdn.microsoft.com/en-us/library/ms683231.aspx" rel="noreferrer">GetStdHandle</a> to get a handle to the output buffer.</p>
<p>In Linux, you can accomplish this by printing \b and/or \r to stderr. You might need to experiment to find the right combination of things in Windows.</p>
6,713
<p>A person uses their cell phone multiple times per day, and the length of their calls vary. I am tracking the length of the calls in a table:</p> <pre><code>Calls [callID, memberID, startTime, duration] </code></pre> <p>I need to a query to return the average call length for users <strong>per day</strong>. Per day ...
<p>You need to convert the DATETIME to something you can make "per day" groups on, so this would produce "yy/mm/dd".</p> <pre><code>SELECT memberId, CONVERT(VARCHAR, startTime, 102) Day, AVG(Duration) AvgDuration FROM Calls WHERE CONVERT(VARCHAR, startTime, 102) = ( SELECT CONVERT(VARCHAR, MAX(...
<pre><code>select average(duration) from calls group by date(startTime); </code></pre>
26,094
<p>I am trying to build a function grapher,</p> <p>The user enters xmin, xmax, ymin, ymax, function. I got the x, y for all points.</p> <p>Now i want to translate this initial referential to a Canvas starting at 0,0 up to 250,250.</p> <p>Is there a short way or should i just check </p> <pre><code>if x &lt; 0 new ...
<p>Instead of iterating over x in the original coordinates, iterate over the canvas and then transform back to the original coordinates:</p> <pre><code>for (int xcanvas = 0; xcanvas &lt;= 250; i++) { double x = ((xmax - xmin) * xcanvas / 250.0) + xmin; double y = f(x); int ycanvas = 250 * (y - ymin) / (ym...
<ol> <li>You can estimate the derivative (if you have one). </li> <li>You can use bidirectional (dichotomic) approach: estimate the difference and split the segment if necessary.</li> </ol>
44,675
<p>Can someone show me how to get the <code>top</code> &amp; <code>left</code> position of a <code>div</code> or <code>span</code> element when one is not specified?</p> <p>ie:</p> <pre><code>&lt;span id='11a' style='top:55px;' onmouseover=&quot;GetPos(this);&quot;&gt;stuff&lt;/span&gt; &lt;span id='12a' onmouseover=&q...
<p>This function will tell you the x,y position of the element relative to the page. Basically you have to loop up through all the element's parents and add their offsets together.</p> <pre><code>function getPos(el) { // yay readability for (var lx=0, ly=0; el != null; lx += el.offsetLeft, ly...
<p>I realize this is an old thread, but @alex 's answer needs to be marked as the correct answer</p> <p><code>element.getBoundingClientRect()</code> is an exact match to jQuery's <code>$(element).offset()</code></p> <p>And it's compatible with IE4+ ... <a href="https://developer.mozilla.org/en-US/docs/Web/API/Element...
36,755
<p>I have the following code in Visual Studio 2005.</p> <pre><code> Dim OutFile As System.IO.StreamWriter Try OutFile = New System.IO.StreamWriter(Filename) // Do stuff with OutFile Catch Ex As Exception // Handle Exception Finally If OutFile IsNot Nothing Then OutFile.Close...
<pre><code>Dim OutFile As System.IO.StreamWriter OutFile = Nothing Try OutFile = New System.IO.StreamWriter(Filename) // Do stuff with OutFile Catch Ex As Exception // Handle Exception Finally If OutFile IsNot Nothing Then OutFile.Close() End Try </code></pre> <p><strong>Similar to <a href="https://stacko...
<p>The accepted answer is correct, of course, but it doesn't explain why or when explicit initialization may matter.</p> <p>VB.NET <em>usually</em> assigns a default value (<code>0</code> or <code>Nothing</code>) when a variable is declared, but there are corner cases where it doesn't.</p> <p>Consider this simple con...
41,887
<p>At various times in my career I have encouraged staff I worked with and/or managed to track defects in artifacts of the development process other than source code (i.e. requirements, tests, design). Each time the request has been met with astonishment, confusion and resistance. It seems so obvious to me that I'm alw...
<p>Yes, track them all. </p> <p>Documentation, design docs, requirements, etc.</p> <p>I am also as astonished as you when I hear "arguments" against it.<br> At the very least the tracking system should be able to identify where the defect was found and what part of the process it was injected.</p>
<p>Normally bug tracking systems have an assumption that they're a list of things that are to be fixed or implemented. Tracking bugs in requirements or other documentation (e.g. task lists) doesn't seem like it's the same thing. It's more a matter of keeping records so you can trend problems and evaluate if you're ma...
48,242
<p>I've met a really strange problem.</p> <p>The code is as follow:</p> <pre><code>::boost::shared_ptr&lt;CQImageFileInfo&gt; pInfo=CQUserViewDataManager::GetInstance()-&gt;GetImageFileInfo(nIndex); Image* pImage=pInfo-&gt;m_pThumbnail; if(pImage==NULL) pImage=m_pStretchedDefaultThumbImage; else { // int...
<p><code>0xfeeefeee</code> is a fill pattern that the debug version of the Windows heap (not the C runtime heap) uses for uninitialized memory. <code>0xfeeefef2</code> is <code>0xfeeefeee+4</code>. It sounds like you're dereferencing an uninitialized pointer located in (or copied from) a block of memory allocated from ...
<p>What happens if <code>pImage == NULL</code> on the third line you pasted? In that case, <code>rcShowImage</code> is not assigned a value.</p>
33,557
<p>Would you recommend extreme programming practices implemented in organizations where team composition changes often? If in an extreme programming scenario, the team <strong>becomes</strong> volatile midway, what would you recommend? Thanks.</p>
<p>I would suggest that the issue of team volatility is addressed first. No process is going to work very well if you've got a revolving door in your office in the first place and I'd say that using a process that relies more heavily on an individual's performance and contribution than one intended to be used with "rep...
<p>What process is going to work when the team composition is volatile? At least with XP, using pair programming, you have some hope that more than one team member has some familiarity with all parts of the code. FWIW, I don't practice XP, I just don't see how the issue is exacerbated by using XP.</p>
37,373
<p>Our network admins have disabled IMAP and POP for our exchange server, but do have RDP over HTTP enabled. Does Mac Mail only use IMAP to communicate with exchange servers, or does it also know how to use RDP over HTTP?</p>
<p>A very good introduction to the semantic web in comparison to object-oriented languages is this document from W3C: <a href="http://www.w3.org/TR/sw-oosd-primer/" rel="noreferrer">A Semantic Web Primer for Object-Oriented Software Developers</a>. It helped me clarify a lot of things from the beginning.</p>
<p>I've found the linkeddatatools tutorial is easy to understand the basics.</p> <p><a href="http://www.linkeddatatools.com/semantic-web-basics" rel="nofollow">http://www.linkeddatatools.com/semantic-web-basics</a></p>
18,824
<p>I've started figuring out drupal, and so far most of the results are just ugly. May be I need to learn it in something similar to a real-life project. I thought — to reproduce this site's functionality might be a good learning project. But I need help. :)</p> <p>Without assuming this site is based on drupal (it mos...
<p>Firstly, Drupal is by no means a slow system, actually it works quite well.</p> <p>Secondly, this has been already asked and answered <a href="https://stackoverflow.com/questions/32638/which-cms-or-other-framework-to-develop-a-stackoverflow-like-site#32652">here</a>.</p> <p>By the way Drupal has a medium learning ...
<p>-Is there a way to build something similar [to stackoverflow] in functionality with existing drupal modules and schemes (or with minimal tweaking)?</p> <p>It's a good idea to try and learn a new technology by trying to make a real-world project. But if you're intention is to actually learn drupal, then trying to so...
12,063
<p>I have searched but apparently my google foo is weak. What I need is a way to prompt for user input in the console and have the request time out after a period of time and continue executing the script if no input comes in. As near as I can tell, Read-Host does not provide this functionality. Neither does $host.UI.P...
<p>Found something <a href="http://huddledmasses.org/powershell-xmpp-jabber-snapin/" rel="noreferrer">here</a>:</p> <pre><code>$counter = 0 while(!$Host.UI.RawUI.KeyAvailable -and ($counter++ -lt 600)) { [Threading.Thread]::Sleep( 1000 ) } </code></pre>
<pre><code>function ReadKeyWithDefault($prompt, $defaultKey, [int]$timeoutInSecond = 5 ) { $counter = $timeoutInSecond * 10 do{ $remainingSeconds = [math]::floor($counter / 10) Write-Host &quot;`r$prompt (default $defaultKey in $remainingSeconds seconds): &quot; -NoNewline if($Host.UI...
18,096
<p>Has anyone ever integrated an external web application with Siebel On-Premise CRM? Note that I'm not talking about Siebel On-Demand SaaS, but their behind-the-firewall product. Specifically, I'm trying to achieve two-way synchronization of CRM objects (contacts, accounts, sales opportunities) between my web appli...
<p>Siebel On-Premise offers a wealth of integration options. Start with Siebel Bookshelf and specifically Integration Platform Technologies: Siebel Enterprise Application Integration.</p> <p>For your more static data, have a look at MDM. In this case refer to Siebel Master Data Applications Reference for Industry Appl...
<p>Worked on a couple of Siebel projects for my sins. Standard ways to interface include: - Web Services (which I think MoMo was referring to) - you'll need to check with the Siebel app team to see if this is / can be turned on; also, the vanilla services might need to be modified to reflect any modifications to the Si...
9,723
<p>How would I get the last item (or any specific item for that matter) in a simplexml object? Assume you don't know how many nodes there will be.</p> <p>ex.</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;?xml-stylesheet type="text/xsl" href="/xsl.xml"?&gt; &lt;obj href="http://xml.foo.com/" di...
<p>Use XPath's <code>last()</code> function, which solves this very problem:</p> <pre><code>&lt;?php $xml = simplexml_load_file('HistoryRecord.xml'); $xml-&gt;registerXPathNamespace('o', 'http://obix.org/ns/schema/1.0'); $xpath = "/o:obj/o:list/o:obj[last()]/o:int[@name = 'energy_in_kwh']"; $last_kwh = $xml-&gt;xpa...
<p>I think SimpleXML loads the whole XML anyway and (if I remember correctly) you can use the SimpleXML nodes as if they were arrays, so you could just use array functions to get the last node. It's a while since I used PHP but you should be able to get the length and then get the item at length-1...</p> <p><strong>Ed...
37,698
<p>Can I use comments inside a <a href="https://en.wikipedia.org/wiki/JSON" rel="noreferrer">JSON</a> file? If so, how?</p>
<p>No.</p> <p>JSON is data-only. If you include a comment, then it must be data too.</p> <p>You could have a designated data element called <code>&quot;_comment&quot;</code> (or something) that should be ignored by apps that use the JSON data.</p> <p>You would probably be better having the comment in the processes that...
<p>Yes, you can, but your parse will probably fail (there is no standard).</p> <p>To parse it you should remove those comments, or by hand, or using a regular expression:</p> <p>It replaces any comments, like:</p> <pre><code>/**** * Hey */ /\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/ </code></pre> <p>It replace...
30,356
<p>Does anyone have any tips or gotcha moments to look out for when trying to migrate MySQL tables from the the default case-insenstive swedish or ascii charsets to utf-8? Some of the projects that I'm involved in are striving for better internationalization and the database is going to be a significant part of this ch...
<p>Some hints:</p> <ul> <li>Your <code>CHAR</code> and <code>VARCHAR</code> columns will use up to 3 times more disk space. (You probably won't get much disk space grow for Swedish words.)</li> <li>Use <code>SET NAMES utf8</code> before reading or writing to the database. If you don't this then you will get partiall...
<blockquote> <p>Your <code>CHAR</code> and <code>VARCHAR</code> columns will use up to 3 times more disk space.</p> </blockquote> <p>Only if they're stuffed full of latin-1 with ordinals > 128. Otherwise, the increased space use of UTF-8 is minimal.</p>
6,919
<pre><code>struct foo { unsigned x:1; } f; printf("%d\n", (int)sizeof(f.x = 1)); </code></pre> <p>What is the expected output and why? Taking the size of a bitfield lvalue directly isn't allowed. But by using the assignment operator, it seems we can still take the size of a bitfield type.</p> <p>What is the "size of...
<p>You are right, integer promotions aren't applied to the operand of <code>sizeof</code>:</p> <blockquote> <p>The integer promotions are applied only: as part of the usual arithmetic conversions, to certain argument expressions, to the operands of the unary +, -, and ~ operators, and to both operands of the shift o...
<p>Wouldn't</p> <pre><code>(f.x = 1) </code></pre> <p>be an expression evaluating to true (technically in evaluates to result of the assignment, which is 1/true in this case), and thus,</p> <pre><code>sizeof( f.x = 1) </code></pre> <p>is asking for the size of true in terms of how many chars it would take to store ...
10,691
<p>I would like to know if there is an easy way to detect if the text on the clipboard is in ISO 8859 or UTF-8 ?</p> <p>Here is my current code:</p> <pre><code> COleDataObject obj; if (obj.AttachClipboard()) { if (obj.IsDataAvailable(CF_TEXT)) { HGLOBAL hmem = obj.GetGlobalDat...
<p>Check out the definition of CF_LOCALE at <a href="http://msdn.microsoft.com/en-us/library/ms649013(VS.85).aspx" rel="nofollow noreferrer">this Microsoft page</a>. It tells you the locale of the text in the clipboard. Better yet, if you use CF_UNICODETEXT instead, Windows will convert to UTF-16 for you.</p>
<p>You could check to see obj.IsDataAvailable(CF_UNICODETEXT) to see if a unicode version of what's on the clipboard is available. </p> <p>-Adam</p>
19,997
<p>I have headers in <code>&lt;h1&gt;</code> through <code>&lt;h6&gt;</code> tags. Is there a way that I can use JavaScript to generate a table of contents for the contents that serves as anchor tags as well?</p> <p>I would like the output to be something like:</p> <pre><code>&lt;ol&gt; &lt;li&gt;Header 1&lt;/li&...
<p>I couldn't resist putting together a quick implementation.</p> <p>Add the following script anywhere on your page:</p> <pre><code>window.onload = function () { var toc = ""; var level = 0; document.getElementById("contents").innerHTML = document.getElementById("contents").innerHTML.replace( ...
<p>after page load, cycle through the DOM and look for the elements that interest you. build a nice list of anchors and add it to the document at the place of your desire.</p>
22,731
<p>I have a binary field in my database that is hard to describe in a UI using a single "Is XXXX?"-type checkbox. I'd rather use a pair of radio buttons (e.g. "Do it the Foo way" and "Do it the Bar way"), but right now all the other fields on my form are data-bound to a business object. I'd like to data-bind the pair...
<ol> <li>Bind the <code>RadioButton</code> that is directly linked to your boolean value (ie is checked when the value is <code>true</code>).</li> <li><p>Add an event handler to the <code>CheckedChanged</code> event on this <code>RadioButton</code> that looks like the following :</p> <pre><code>private void radioButto...
<p>You should only have to bind one of the controls as long as you make sure they are in the same group.</p> <p>You could also consider a DropDown.</p>
44,878
<p><strong>Given the emissions that 3d printing gives off (ABS = styrene and other chemicals, PLA give some off, etc), what options are there to filter the air in the enclosure other than venting the air out of a window?</strong></p> <p>More information on the chemicals 3d printing emit:</p> <ul> <li><a href="http://bu...
<p>My residential materials expert referred me to these links (<a href="http://www.bofaamericas.com/3D-printing-fume-extraction.asp" rel="noreferrer">3D Printing Fume Extraction Solutions</a>, and <a href="http://www.3dprintfilemarket.com/140629194058.html" rel="noreferrer">ABS 3d Printer Nanoparticle and Chemical Exha...
<p>Anybody consider using a Grow Box Fan and filter inside an enclosure. They come cheap with 180 cfm fan and / carbon filters.</p> <p><a href="https://i.stack.imgur.com/16XP7.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/16XP7.jpg" alt="https://www.amazon.com/iPower-Inline-Variable-Controller-Ven...
188
<p>Is it possible to specify my own default object instead of it being null? I would like to define my own default properties on certain objects.</p> <p>For example, if I have an object foo with properties bar and baz, instead of default returing null, I'd like it to be an instance of foo with bar set to "abc" and ba...
<p>You have to use a constructor to get that functionality. So, you can't use default.</p> <p>But if your goal is to ensure a certain state of the passed type in a generic class, there may still be hope. If you want to ensure the passed type is instanti-able, use a generic constraint. The new() constraint. This en...
<p>No you cant. Sorry.</p>
49,661
<p>How do I select all the columns in a table that only contain NULL values for all the rows? I'm using <strong>MS SQL Server 2005</strong>. I'm trying to find out which columns are not used in the table so I can delete them.</p>
<p>Here is the sql 2005 or later version: Replace ADDR_Address with your tablename.</p> <pre><code>declare @col varchar(255), @cmd varchar(max) DECLARE getinfo cursor for SELECT c.name FROM sys.tables t JOIN sys.columns c ON t.Object_ID = c.Object_ID WHERE t.Name = 'ADDR_Address' OPEN getinfo FETCH NEXT FROM getin...
<p>You might need to clarify a bit. What are you really trying to accomplish? If you really want to find out the column names that only contain null values, then you will have to loop through the scheama and do a dynamic query based on that.</p> <p>I don't know which DBMS you are using, so I'll put some pseudo-code ...
8,879
<p>I have a .NET web app that uses CR 2008 for reports. The server it's deployed on is saddled with McAfee, and we want to tell CR to use a temp directory other than the Windows temp dir.</p> <p>Google found me the following registry key:</p> <p>SOFTWARE\Business Objects\Suite 12.0\Report Application Server\InprocSe...
<p>The other temp directory than C:/windows/temp should be located in your web site's virtual directory. Just add that temp folder in your web site's directory and when you make its virtual path to host it on IIS , it automatically gets included. If you want to make it at some other place like at D:/CrystalTEmp, you ne...
<p>“Operation not yet implemented” change "Font" type from - right click on text area. - format setting. - change font </p>
8,107
<p>In a <a href="https://3dprinting.stackexchange.com/questions/5604/how-to-re-program-prusa-firmware-to-accept-a-taller-z-axis">previous question</a>, I have modified the Z-axis-height of my Prusa Mk3 from 250 mm to 350 mm.</p> <p>Prior to the MMU2 upgrade, I changed the code in my printer to accept the new height the...
<p>Basically, the <a href="/a/5606/5740">answer</a> on your <a href="/questions/5604/how-to-re-program-prusa-firmware-to-accept-a-taller-z-axis">previous question</a> is still valid, but your specific questions will be addressed below.</p> <h2>To answer where the setting has gone by answering:</h2> <blockquote> <p>...
<p>Latest firmware: Prusa-Firmware-3.5.0\Prusa-Firmware-3.5.0 Arduino 1.6.9, RepRap Arduino-compatible Mother Board RAMBo by Ultimachine latest version 1.0.1, Arduino AVR Boards Built-in by Arduino latest version v.1.6.23.</p> <p>Copy the 1_75mm_MK3-EINSy10a-E3Dv6full file from Prusa-Firmware-3.5.0\Prusa-Firmware-3.5....
1,096
<p>I have been asked to audit any/all changes in a MySQL table. Does anyone know of any tools out there to help me do this or do I need to write my own solution?</p> <p>If I write my own audting, my initial thought it to make a separate table and build a string of changes in the PHP code. Something like "fieldname1 ->...
<p>The only sure-fire way to capture all changes to a DB table is to use triggers on the Server. The risk of modifing your own code to audit the changes is that changes from another application/user etc will not be captured.</p> <p>Having said that, I'm not sure that MySQL 4 had trigger support.</p>
<p>SoftTree DB Audit has MySQL support, might do what you're after:</p> <p><a href="http://www.softtreetech.com/idbaudit.htm" rel="nofollow noreferrer">http://www.softtreetech.com/idbaudit.htm</a></p>
26,912
<p>In <a href="https://stackoverflow.com/questions/161368/pitfalls-for-converting-a-net-20-solution-to-net-35">this question</a> superwiren asks about the pitfalls for converting a .net 2.0 solution to .net 3.5. </p> <p>What about .net 1.1 to .net 2.0? </p> <p>Is 2.0 fully backwards compatible with 1.1?</p>
<p>I think its depends on your code, the best option is to perform a trial run and see what errors it will generate. I dont think .NET 2.0 is fully backwards compatible, though they claim it is. </p> <p><a href="http://msdn.microsoft.com/en-us/library/aa479312.aspx#issue11" rel="nofollow noreferrer">Common conversio...
<p>I've worked on a couple of ASP.NET 1.1 to 2.0 conversions (medium-sized websites), and we found that the Visual Studio conversion wizard made things pretty easy. We didn't run into any incompatibility issues, and the only things we really changed involved replacing deprecated api calls with new functions. I'd sugg...
45,273
<p>As part of another question that did involve programming (I assure you), someone suggested I ask a community wiki question as to why your forum software of choice was the 'best' one for you.</p> <p>I'm looking into providing forum software as part of an install of a web server and web application tailored for a med...
<p>How about <a href="http://www.phpbb.com/" rel="nofollow noreferrer">PHPBB</a> ? Immensely easy to setup and configure, and does automatic imports from previous pbpbb versions (like from v2 to v3)</p> <p>PHPBB 3 has also a very good captcha system, unlike the v2 one. In phpbb2, using a captcha when registering, we ...
<p><a href="http://jforum.net" rel="nofollow noreferrer">JForum</a> - Ease of use, maintainability and easy integration with other webapps.</p>
48,949
<p>I think that java executables (jar files) are trivial to decompile and get the source code.</p> <p>What about other languages? .net and all?</p> <p>Which all languages can compile only to a decompile-able code?</p>
<p>In general, languages like Java, C#, and VB.NET are relatively easy to decompile because they are compiled to an intermediary language, not pure machine language. In their IL form, they retain more metadata than C code does when compiled to machine language. </p> <p>Technically you aren't getting the original sourc...
<p>Most languages can be decompiled but some are easier to decompile than others. .Net and Java put more information about the original program in the executables (method names, variable names etc.) so you get more of your original information back. </p> <p>C++ for example will translate variables and functions etc. ...
6,526
<p>Can anyone recommend any good <strong>add-ons</strong> or <strong>plugins</strong> for <code>Microsoft Visual Studio</code>?<br> Freebies are preferred, but if it is worth the cost then that's fine.</p>
<p><a href="http://weblogs.asp.net/alex_papadimoulis/archive/2004/05/25/Smart-Paster-1.1-Add-In---StringBuilder-and-Better-C_2300_-Handling.aspx" rel="noreferrer">SmartPaster</a> - (FREE) Copy/Paste code generator for strings</p> <p><a href="http://ankhsvn.open.collab.net/" rel="noreferrer">AnkhSvn</a> - (FREE) SVN So...
<ul> <li>Resharper (Agree it sucks you have to pay extra to get this, but well work the money)</li> <li><p>GhostDoc (Takes away any excuse for not having comments in your code)</p></li> <li><p>PowerCommands for VS 2008 (Forgot I even had this installed because it just adds a the little things that should have been ther...
2,487
<p>What is the best C++ IDE or editor for using on Windows? I use Notepad++, but am missing IntelliSense from Visual Studio.</p>
<p>Um, that's because Visual Studio is the best IDE. Come back to the darkside.</p>
<p>Dev C++ is also a nice IDE. It's not so user friendly, but it's usefull.</p>
11,486
<p>Windows API ::FindWindow function fails when called from Service application. GetLastError() also returns 0 (success?). Is this some privilege\access right problem? Do you think it's design problem and I should use another IPC method? </p>
<p>leppie's right, Windows services are usually denied in interaction with desktop. You can bypass that in XP and earlier versions but won't be able to do in Vista and above. You'd better delegate desktop and user interactions to a GUI application. See this <a href="http://www.microsoft.com/whdc/system/vista/services.m...
<p>Services run in Session 0. On XP and earlier, the first user to log in also runs in Session 0, and subsequent users run in Sessions 1 and higher. If the service is set to "Interact with the Desktop", then it can access any user windows running in Session 0. However, starting with Vista, users never run in Session...
44,177
<p>A common technique for storing a lot of files/blobs in a filesystem is to use a hash function to determine the filepath; eg hash(identifier) -> "o238455789" -> o23/8455/789 (there is often a hash-collision strategy too)</p> <p>Does this technique have a name (is it a 'pattern'?) so that I may find it with a search ...
<p>I think this is what microsoft has done in SQL Server 2008 with FILESTREAM storage. It allows storage of BLOB data inside of SQL Server, but allows you to access the files directly off the disk, which gives you kick-ass performance.</p> <p>Microsoft released a whitepaper on <a href="http://www.microsoft.com/sqlser...
<p>This sort of sounds like <a href="http://en.wikipedia.org/wiki/Shard_(database_architecture)" rel="nofollow noreferrer">sharding</a>, but I am probably missing the subtleties.</p> <p>And equally I don't see many articles on it - <a href="http://highscalability.com/tags/shard" rel="nofollow noreferrer">a few on high...
44,146
<p>What are some ways that I can query the local machine's specifications (a range of things from CPU specs, OS version, graphics card specs and drivers, etc.) through a programmatic interface? We're writing a simple app in C# to test compatibility of our main app and want to have it dump out some system metrics, but ...
<p>For this type of information <a href="http://msdn.microsoft.com/en-us/library/aa394582(VS.85).aspx" rel="nofollow noreferrer">WMI</a> is your friend. Fortunately dealing with WMI in .NET is much easier than in the unmanaged world. There are quite a lot of articles out there to get started with, like <a href="http:...
<p>For the odd case that you would be developing for linux, you could find awesome stuff inside the <code>/proc</code> pseudofilesystem.</p>
24,736
<p>Is there any way to export data (not necessarily schema) to an access database via asp.net?</p> <p>The server has no office components installed and the process must occur via a webpage (like an excel export).</p>
<p>You have to do it programatically.</p> <ol> <li>Open the source table</li> <li>Create a new AccessDB using ADO Extensions (as shown above)</li> <li>Create the table in the AccessDB by reading the source schema (CREATE TABLE X ...)</li> <li>Iterate thought the source table inserting the records in the Access table</...
<p>Here is a very detailed article. It is something I stumbled upon, not an approach I am familiar with:</p> <p><a href="http://www.stardeveloper.com/articles/display.html?article=2003031201&amp;page=1" rel="nofollow noreferrer">File Uploading to Access Database using ASP.NET by Faisal Khan.</a></p>
30,552
<p>I recently had a print failure/crash, where the print stuck to the nozzle and forced molten filament back into the print head, fans, and heater block.</p> <p>I changed the nozzle for a new 0.4mm same as existing. I shortened the bowden tube by ~8mm to remove some crispiness, and the push-lock connector on top of th...
<p>I'm a fan of OpenSCAD and have used the method suggested in the first answer. For non-OpenSCAD users, another option exists, which I've also used.</p> <p>PrusaSlicer is a free 3D printer slicing program. One can configure layer heights as desired for the material thickness, even though it's not likely one will find ...
<p>With OpenSCAD, you can <code>import</code> the STL file and apply <code>projection</code> with <code>cut=true</code> at successive Z-axis <code>translate</code> operations, and write out the result as SVG. This can all be automated from the command line to product a series of SVG files for your layers to &quot;2D pr...
2,151
<p>Which is a better format to store graphic assets for a Flex application, SWF or SWC?</p> <p>Are there any real differences, and if so what are they?</p>
<p>Assets in a seperate SWF are loaded and included at runtime.</p> <p>Assets in a SWC are loaded and included / compiled at compile time.</p> <p>You can also directly embed assets within the main app SWF at compile time (check out the Embed meta data).</p> <p>Of course, you can also load individual assets (such as ...
<p>A SWC is simply a SWF and some metadata wrapped into a zip file. Other than the fact that runtime loading of SWC isn't supported, I don't think there are any major differences between using the two formats.</p>
19,844
<p>Every now and then I get an error when I set up states in an MXML file. The error I get says that mx:states could not be resolved to a component implementation.</p> <p>I read, at the following url, that this issue is caused by extending components - that somehow throws off the compiler's ability to resolve mx:stat...
<p>If you have a custom component, you'll probably have it in a namespace other than <em>mx</em>. You're on the right track by removing the namespace, but you don't have to do that. Consider the following example</p> <pre><code>&lt;example:MyComponent xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:example="com.ex...
<pre><code>&lt;mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" backgroundColor="#f7f7f7" xmlns:common="com.americanexpress.voice.view.component.common.*"&gt; &lt;mx:states name="edit"&gt; </code></pre> <p>Why does this fail? I have also found that ...
48,204
<p>How do I find a stored procedure in a Sybase database given a text string that appears somewhere in the proc? I want to see if any other proc in the db has similar logic to the one I'm looking at, and I think I have a pretty unique search string (literal)</p> <p>Edit:</p> <p>I'm using Sybase version 11.2</p>
<p>Two variations on Graeme's answer (So this also won't work on 11.2):</p> <p>This lists the name of the sproc too, but will return multiple rows for each sproc if the text appears several times:</p> <pre><code>select object_name(id),* from syscomments where texttype = 0 and text like '%whatever%' </code></pre> ...
<p>Multiple rows are used to store text for database objects the value might be accross two rows. So the more accurate answer is:</p> <pre><code>select distinct object_name(sc1.id) from syscomments sc1 left join syscomments sc2 on (sc2.id = sc1.id and sc2.number = sc1.number and sc2.colid2 = sc1.colid2 + ((sc1.colid...
31,221
<p>I try to open and excel reference in LabVIEW and then close it after sometime. But the LabVIEW keeps holding the reference and does not release it unless I close the VI. Why is this happening? Is there anyway to force it to release the Reference?</p> <p>I am checking the error out for any errors. But it is not thro...
<p>The first solution you describe is the best if you want to maintain data integrity, and if you have relatively few product types and seldom add new product types. This is the design I'd choose in your situation. Reporting is complex only if your reports need the product-specific attributes. If your reports need o...
<p>Chris and AJ: Thanks for your responses. The product line may change, but I would not term it "volatile". </p> <p>The reason I dislike the third option is that it comes at the cost of metadata for the product attribute values. It essentially turns columns into rows, losing most of the advantages of the database...
14,704
<p>I want to have a TextBox which does accept the TAB key (and places a TAB, ASCII 0x09, \t accordingly into the textbox) instead of jumping to the next control. The TextBox has a property AcceptsTab, which I have set to true but this does not give the desired result. It turns out the AcceptsTab property only works the...
<p>Here's what you do. Create your own class that inherits from TextBox. In the constructor, set multiline to true, and AcceptsTab to true. Then, override WndProc and use this code:</p> <pre><code> protected override void WndProc(ref Message m) { if (m.Msg == (int)0x102 &amp;&amp; m.WParam.T...
<p>Sel multilines to true and set the line size to 1. you will get the desired result.</p>
48,978
<p>How do I solve the error:</p> <blockquote> <p>Unable to read WSDL from URL: <a href="https://workflowtest.site.edu/_vti_bin/Lists.asmx?WSDL" rel="nofollow noreferrer">https://workflowtest.site.edu/_vti_bin/Lists.asmx?WSDL</a>.<br> Error: 401 Unauthorized.</p> </blockquote> <p>I can successfully view the WSDL f...
<p>CFInvoke can only pass basic authentication, not windows integrated authentication. </p> <p>Sharepoint won't be able to downgrade to basic authentication since sharepoint needs to know who is calling the services to check authentication and authorization of the data being requested.</p> <p>Your best bet here is t...
<p>I had the same problem.</p> <p>Open your IIS, and change the LoginType to Basic. (in my german Windows it is: "Verzeichnissicherheit" -> "Steuerung des Anonymen Zugriffs und der Authentifizierung" -> "Bearbeiten" -> Set the checkbox for "Standardauthentifizierung" )</p> <p>-Kevin</p>
20,343
<p>I feel that using GetEnumerator() and casting IEnumerator.Current is expensive. Any better suggestions?<br/><br/> I'm open to using a different data structure if it offers similiar capabilities with better performance.</p> <p><strong>After thought:</strong><br/> Would a generic stack be a better idea so that the ca...
<p>Have you done any benchmarks, or are they just gut feelings?</p> <p>If you think that the majority of the processing time is spent looping through stacks you should benchmark it and make sure that that is the case. If it is, you have a few options.</p> <ol> <li>Redesign the code so that the looping isn't necessary...
<p>An alternative to creating an enumerator is to use the ToArray method, and then iterate over the array. The stack iterator causes some slight overhead for checking whether the stack has been modified, whereas iteration over the array would be fast. However, there is of course the overhead of creating the array in th...
31,516
<p>I am trying to fetch an RTSP stream over HTTP using a proxy. The behavior of the Real client seems to be a bit hectic: it tries all the possible ports, methods and protocols at once. The only thing that should work is HTTP GET over port 80. Such a request is indeed issued, and is received on the server. Here's how t...
<p>First, you might want to read this:</p> <p><a href="http://developer.apple.com/quicktime/icefloe/dispatch028.html" rel="nofollow noreferrer">http://developer.apple.com/quicktime/icefloe/dispatch028.html</a></p> <p>Second, the HTTP requests (both GET and POST) need to be formatted so that they get proxied properly....
<ol> <li>See whether issuing the same request but bypassing the proxy (e.g., replay the request you posted above using Netcat) results in more than four bytes streamed in the response body.</li> <li>See what TCP packets the proxy is receiving, for example, by eavesdropping on the TCP traffic on the machine that's runn...
32,353
<p>I've just completed a Silverlight project and it's time to have a little clean up. I'd like to take my core files and put them into a separate project which I will reference from my main Silverlight app. Some of these classes are compatible with WPF and I would quite like to be able to have Silverlight / WPF code al...
<p>I haven't tried it myself (still trying to find the time to play with Silverlight), but couldn't you have one solution with two projects, one targetting Silverlight and the other targetting .NET 3.5, and add the common class files to each project as Links (right-click the project, Add Existing Item..., Add as Link)?...
<p>You should check out "patterns &amp; practices: Composite WPF and Silverlight"</p> <p><a href="http://www.codeplex.com/CompositeWPF/Wiki/View.aspx?title=Home" rel="nofollow noreferrer">http://www.codeplex.com/CompositeWPF/Wiki/View.aspx?title=Home</a> </p> <p>It has quick starts with WPF/Silvelight versions of the...
25,529
<p>Is it possible, in Java, to enforce that a class have a specific set of subclasses and no others? For example:</p> <pre><code>public abstract class A {} public final class B extends A {} public final class C extends A {} public final class D extends A {} </code></pre> <p>Can I somehow enforce that no other subclas...
<p>Give class <strong><code>A</code></strong> a constructor with package-level accessibility (and no other constructors).</p> <p><sup>Thanks, Dave L., for the bit about no other constructors.</sup></p>
<p>You could put class A,B,C,D in a seperate package and make class A not public.</p>
20,480
<p>I'm try to extract info from a MySQL DB into a MS SQL DB. The DB is a mess and the developer is no longer available.</p> <p>All dates are in char fields, and I use </p> <pre><code>SELECT concat( mid(DueDate, 7, 4), mid(DueDate, 4, 2), mid(DueDate, 1, 2)) as DueDate FROM TableName </code></pre> <p>to get the date ...
<p>In MySQL you can convert a string to a date using the <a href="http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_str-to-date" rel="nofollow noreferrer">STR_TO_DATE</a> function.</p> <p>An example usage is:</p> <pre><code>mysql&gt; SELECT STR_TO_DATE('04/31/2004', '%m/%d/%Y'); -&g...
<p>MySQL equivalent to getdate() is CURDATE()</p> <pre> mysql&gt; select IF(CURDATE()&lt;NOW(), 1, 0); +---------------------------+ | IF(CURDATE()&lt;NOW(), 1, 0) | +---------------------------+ | 1 | +---------------------------+ 1 row in set (0.00 sec) mysql&gt; select IF(CURDATE()=NOW(),...
39,918