instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I started a print on my Monoprice Select v2 and let it run. I'm printing with Dikale PLA at 200&nbsp;&deg;C extruder and 60&nbsp;&deg;C build plate temperatures. My initial layer speed is 30mm/s then 60mm/s after that. Although the Monoprice comes with an aluminum build plate, I put on a <a href="https://rads.stack...
<p>You have more than one problem going on. As for the print lifting up, that could be for a multitude of reasons. Clearly better bed adhesion is required. It also appears the printer stopped printing at one layer. Now for the charred part, I think it could've been caused by the nozzle staying in one area for too long ...
<p>1) You have a layer shift. I guess the shift is caused by an <em>overheating</em> stepper driver, because it started relatively late, but could be also a mechanical issue.</p> <p>2) Print bed adhesion is a minor problem. Just test your printer with a simpler shape (large ground area).</p> <p>3) After carbonization...
1,151
<p>I have the following arrays:</p> <pre><code>$artist = array("the roots", "michael jackson", "billy idol", "more", "and more", "and_YET_MORE"); $count = array(5, 3, 9, 1, 1, 3); </code></pre> <p>I want to generate a tag cloud that will have artists with a higher number in <code>$count</code> enclosed in <code>h6</c...
<p>You will want to add a logarithmic function to it too. (taken from tagadelic, my Drupal module to create tag clouds <a href="http://drupal.org/project/tagadelic" rel="noreferrer">http://drupal.org/project/tagadelic</a>):</p> <pre><code>db_query('SELECT COUNT(*) AS count, id, name FROM ... ORDER BY count DESC'); $s...
<p>As a helper in Rails:</p> <pre><code>def tag_cloud (strings, counts) max = counts.max strings.map { |a| "&lt;span style='font-size:#{((counts[strings.index(a)] * 4.0)/max).ceil}em'&gt;#{a}&lt;/span&gt; " } end </code></pre> <p>Call this from the view:</p> <pre><code>&lt;%= tag_cloud($artists, $counts) %&...
2,271
<p>I have been trying to find information on how to retrieve attachments from a gmail account in either python or PHP, I'm hoping that someone here can be of some help, thanks.</p> <p>Related:</p> <ul> <li><a href="https://stackoverflow.com/questions/348630/how-can-i-download-all-emails-with-attachments-from-gmail">H...
<p>You will have to enable IMAP access to your GMail account (Settings → Forwarding and POP/IMAP), and then use <code>imaplib.IMAP4_SSL</code> to access it. </p> <p>Use the raw text of every message as an argument to <code>email.message_from_string</code> in order to process any attachments.</p>
<p>The php docs for imap_open explain connecting to gmail in the comments (e.g. 31-Oct-2007 07:50):</p> <p><code>$mbox = imap_open("{imap.gmail.com:993/imap/ssl}INBOX", "username@gmail.com", "password") or die("can't connect: " . imap_last_error());</code></p> <p>Where, obviously, you have to fill in the actual usern...
40,246
<p>Every time I need to work with date and/or timstamps in Java I always feel like I'm doing something wrong and spend endless hours trying to find a better way of working with the APIs without having to code my own Date and Time utility classes. Here's a couple of annoying things I just ran into:</p> <ul> <li><p>0-b...
<p><a href="http://mike-java.blogspot.com/2008/02/java-date-time-api-vs-joda.html" rel="nofollow noreferrer">This post</a> has a good discussion on comparing the Java Date/Time API vs JODA.</p> <p>I personally just use <a href="http://docs.oracle.com/javase/8/docs/api/java/util/GregorianCalendar.html" rel="nofollow no...
<p>Date APIs are very difficult to design, especially if they have to deal with localization. Try to roll your own and see, it's worth doing at least once. The fact that Joda was able to do such a good job is a real credit to its developers. To answer your question, I've heard nothing but good things about that libr...
11,322
<p>I am working on creating a daemon in Ruby using the daemons gem. I want to add output from the daemon into a log file. I am wondering what is the easiest way to redirect <code>puts</code> from the console to a log file.</p>
<p>I should recommend to use ruby logger, it is better than puts, you can have multiple log levels that you can turn on/off: debug, warn, info,error, etc.</p> <pre><code> logger = Logger.new(STDOUT) logger = Logger.new("/var/log/my-daemon.log") </code></pre> <p>I use runit package to manage ruby services, it has svl...
<p>Or you can redefine the <code>puts</code> command? Works probably only in a single file/class</p> <pre><code>def puts(message) #write message to file end </code></pre>
27,743
<p>My questions is simple!</p> <ol> <li>Would you start learning Smalltalk if you had the time? Why? Why not?</li> <li>Do you already know Smalltalk? Why would you recommend Smalltalk? Why not?</li> </ol> <p>Personally I'm a Ruby on Rails programmer and I really like it. However, I'm thinking about Smalltalk because ...
<p>If you like Ruby you'll probably like Smalltalk. IIRC Seaside has been ported to the <a href="http://seaside.gemstone.com/" rel="noreferrer">Gemstone VM,</a> which is part of their Gemstone/S OODBMS. This has much better thread support than Ruby, so it is a better back-end for a high-volume system. This might be ...
<p>Yes, I'm interested in it. Tried to start once already, but couldn't find a Smalltalk development environment that didn't cost both arms and a leg.</p>
17,962
<p>I chmod'ed the directory to 777, same with the directory contents. Still, I get a "permission denied" error. Does PHP throw this error if apache is not the group/owner, regardless of the file permissions? Here's the call that's failing:</p> <pre><code>rename('/correct/path/to/dir/1', '/correct/path/to/dir/2'); </co...
<p>You're editing the higher level directory, so the PHP user needs to have write access to that directory.</p>
<p>Try running the following script:</p> <pre><code>print_r(posix_getpwuid(getmyuid())); print_r(pathinfo($YOUR_PATH)); </code></pre> <p>And see what that returns.</p>
23,832
<p>Alright, this might be a bit of a long shot, but I have having problems getting AnkhSVN to connect from Visual Studio 2005 to an external SVN server. There is a network proxy in the way, but I can't seem to find a way in AnkhSVN to configure the proxy and doesn't seem to be detecting the Internet Explorer proxy conf...
<p><a href="http://en.wikipedia.org/wiki/Printf#printf_format_placeholders" rel="noreferrer">http://en.wikipedia.org/wiki/Printf#printf_format_placeholders</a> is Wikipedia's reference for format placeholders in printf. <a href="http://www.cplusplus.com/reference/clibrary/cstdio/printf.html" rel="noreferrer">http://www...
<p>One issue that hasn't been raised by others is whether <strong>double</strong> is the same as a <strong>float</strong>. On some systems a different format specifier was needed for a double compared to a float. Not least because the parameters passed could be of different sizes. <PRE> %f - float %lf - double %g ...
3,861
<p>In .net, is there a way using reflection to determine if a parameter on a method is marked with the "params" keyword?</p>
<p>Test to see whether the final <a href="http://msdn.microsoft.com/en-us/library/system.reflection.parameterinfo.aspx" rel="noreferrer">ParameterInfo</a> has <a href="http://msdn.microsoft.com/en-us/library/system.paramarrayattribute.aspx" rel="noreferrer">ParamArrayAttribute</a> applied to it.</p>
<p>Test to see whether the final <a href="http://msdn.microsoft.com/en-us/library/system.reflection.parameterinfo.aspx" rel="noreferrer">ParameterInfo</a> has <a href="http://msdn.microsoft.com/en-us/library/system.paramarrayattribute.aspx" rel="noreferrer">ParamArrayAttribute</a> applied to it.</p>
25,003
<p>I have this marked as PHP but only because I'll be using PHP code to show my problem.</p> <p>So I have some code like this for the controller:</p> <pre><code>switch ($page) { case "home": require "views/home.php"; break; case "search": require "views/search.php"; break; } </...
<p>The controller should just set up the data for the view and choose which view to display. The view should be responsible for the layout of the page, including shared pages. I like your first sample over the second.</p>
<p>If you are using straight PHP pages as your templates, you could essentially set a global/session variable to hold the page you want. You would have a "main template" php page which includes the header and footer elements, then calls a include for the $page. Something like this in the controller:</p> <pre><code>$_S...
42,716
<p>I have an UP! mini and I am using the UP Studio and ABS 1.75 mm.</p> <p>My prints are always stuck to the rafts and are impossible to remove without destroying the print.</p> <p>I've had a look at the settings on the Up Studio but I don't know which ones to change to improve the situation.</p>
<p>The OpenSCAD <code>surface</code> function will do this. You can feed it a greyscale image or a textfile containing a matrix. Documentation and examples can be found at <a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features#Surface" rel="nofollow noreferrer">https://en.wikibooks.org/wi...
<p>FreeCAD can import JPG (and IIRC TIFF and PNG as well) image files and produce a lithophane type height-map based on the brightness of each pixel. I'd be rather surprised if other 3D CAD software aimed at the 3D printing user base couldn't do the same. Most of the common free-to-use 3D CAD packages have Linux vers...
1,955
<p>I have both Fruityloops and Propellerheads Reason software synths on my Windows PC.</p> <p>Any way I can get at and script these from either Visual Basic or Python? Or at least send Midi messages to the synths from code?</p> <p>Update : attempts to use something like a "midi-mapper" (thanks for link MusiGenesis) d...
<p>I think both FL Studio and Reason can be configured as the default MIDI playback device. To send MIDI messages to either from VB.NET, you'll need to PInvoke the midiOutOpen, midiOutShortMsg and midiOutClose API calls. Here's a link to code samples:</p> <p><a href="http://www.answers.com/topic/midioutopen" rel="no...
<p>When it comes to Reason, you can do with it to much because of it's closed architecture - you can use VST plugins (or any other type like DirectX ones) - your only option is to use MIDI.</p> <p>Regarding Fruity Loops, you could write a VST plugin that can take an input from a scripting language (VB, Python or whate...
33,566
<p>If you have a statically allocated array, the Visual Studio debugger can easily display all of the array elements. However, if you have an array allocated dynamically and pointed to by a pointer, it will only display the first element of the array when you click the + to expand it. Is there an easy way to tell the...
<p>Yes, simple. say you have</p> <pre><code>char *a = new char[10]; </code></pre> <p>writing in the debugger:</p> <pre><code>a,10 </code></pre> <p>would show you the content as if it were an array.</p>
<p>I haven't found a way to use this with a multidimensional array. But you can at least (if you know the index of your desired entry) add a watch to a specific value. Simply use the index-operator.</p> <p>For an Array named current, which has an Array named Attribs inside, which has an Array named Attrib inside, it s...
10,079
<p>I have a site that will ultimately support 4 languages and 2 countries (US &amp; Canada, English and Spanish)</p> <p>I'm wondering what's the best way to set up the directory structure?</p> <p>Right now, I have a root site called site.com: </p> <p>This will take you to a page where you choose your country and lan...
<p>Well, they want the Url to be different for each site.</p> <p>Essentially it is actually one site (for maintenance reasons) and we're using globalization to determine which connection string to use (different databases, identical structures in each one)</p> <p>Each time we publish I'll publish to four locations. ...
<p>generally accepted nomenclature for localization is ll-CC for language code hyphen country-code. example: en-US, though en-US would probably be the default with en-GB or en-CA as fallbacks... es-MX etc are also worthy. It may be better to use subdomains though, which would allow for the breakup of resources withou...
48,789
<p>I'm writing a MFC app that uses the MS Mappoint OCX. I need to display the locations of people and vehicles on the map and the best of doing this appears to be with Pushpin objects. I have no problem displaying a stock pushpin icon with some text but want to change the icon to a custom designed one. From the limited...
<p>I found the solution to this one myself. The following code works ..</p> <pre><code>CSymbols symbols; CSymbol symbol; symbols=map.get_Symbols(); symbol=symbols.Add("c:/temp/myicon.ico"); pushpin.put_Symbol(symbol.get_ID()); </code></pre> <p>Where map is the Mappoint control.</p>
<p>So it looks like your error was that the symbols collection had not been created: so yes of course it will throw an exception.</p> <p>As you have found, the symbols collection can be accessed using the Symbols property on your MapPoint.Map object.</p> <p>All this is in the MapPoint reference, but it is primarily i...
25,971
<p>I'm working on a project that will be distributed with GNU autoconf/automake, and I have a set of bash scripts which call awk scripts. I would like the bash scripts to end up in the $PATH, but not the awk scripts. How should I insert these into the project? Should they be put in with other binaries?</p> <p>Also,...
<p>Add something like this to Makefile.am</p> <pre><code>scriptsdir = $(prefix)/bin scripts_DATA = awkscript1 awkscript2 </code></pre> <p>In this case it will install awkscript in $(prefix)/bin (you can also use $(bindir)).</p> <p>Note: Dont forget that the first should be named name + dir (scripts -> scriptsdir) an...
<p>If the awk scripts won't go into the main bin directory (prefix/bin), then you need to place them in an appropriate sub-directory - probably of lib but possibly libexec or share (since the awk scripts are probably platform neutral).</p> <p>Correct: software won't necessarily end up in /usr/local/bin; on my machine,...
11,982
<p>How is the salt generated in HashProvider in Microsoft Enterprise Library when we set SaltEnabled?</p> <p>Is it random to new machines? Is it some magic number?</p> <p>(I know what is a salt, the question is what's the actual value of a/the salt in Enterprise Library HashProvider)</p>
<p>Edit:</p> <p>See Microsoft.Practices.EnterpriseLibrary.Security.Cryptography.HashAlgorithmProvider for an example implementation. Hashing steps are:</p> <ol> <li>If SaltEnabled, generate random bytes for the salt length using RNGCryptoServiceProvider.</li> <li>Append the salt to the plaintext.</li> <li>Hash the sa...
<p>Slightly offtopic : </p> <p>This salt is used to prevent Rainbow attacks. A rainbow attack is a type of attempt to find out what was the string for which this hash has been computed based on a very large (exhaustive / several gigabytes usually) dictionary of precomputed hashes.</p> <p><a href="http://www.codinghor...
15,341
<p>Is there any Visual Studio Express plug ins for source versioning? I am starting a project on my own and only have the Express version of Visual Studio 2008.</p>
<p>Short answer: No.</p> <p>The Express editions support neither the Add-Ins nor Source Control providers (SCC plug-ins). While there are ways to make this work, they are undocumented, violate the license and <a href="http://weblogs.asp.net/nunitaddin/archive/2007/05/31/microsoft-vs-testdriven-net-31-may-2007.aspx" re...
<p>I don't think there are any plugins for Express versions of VS. Googling 'Jamie Cansdale' is the canonical reference for this issue.</p>
5,069
<p>I trying to learn swt, and I use maven for all my builds and eclipse for my IDE. When getting the swt jars out of the maven repository, I get:</p> <pre><code>Exception in thread "main" java.lang.UnsatisfiedLinkError: no swt-pi-gtk-3034 in java.library.path at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1...
<p>Sounds like Maven is pulling in an old version of SWT. As of v3.4 (and higher), the swt.jar is <em>all</em> you need. SWT will automatically extract the <code>.so</code>s, <code>.jnilib</code>s or <code>.dll</code>s as necessary. The only tricky thing you need to worry about is to ensure that you get the right sw...
<p>I did a little more research on this and found that the swt jar is in a couple different places in the maven repository. I was using jars put out by the swt group, but after looking around a bit, I found the jars put out by the org.eclipse.swt.gtk.linux group for linux (org.eclipse.swt.win32.win32 for Windows). This...
37,326
<p>What are the various charting tools that are available for displaying charts on a web page using ASP.NET?</p> <p>I know about commercial tools such as Dundas and Infragistics.</p> <p>I could have "googled" this but I want to know the various tools that SO participants have used? Any free charting tools that are av...
<p>I like <a href="http://code.google.com/apis/chart/" rel="nofollow noreferrer">google charts</a>, but check the license before using.</p>
<p>If you use SQL Server, then SQL Server reporting services is not bad. It includes a free version of Dundas chart controls which allows you to do basic charting. There are are couple of issues with presentation and making it Firefox friendly but it's a pretty simple solution. - If you've SQL Server of course!</p>
10,803
<p>Without using plpgsql, I'm trying to urlencode a given text within a pgsql SELECT statement.</p> <p>The problem with this approach:</p> <pre><code>select regexp_replace('héllo there','([^A-Za-z0-9])','%' || encode(E'\\1','hex'),'g') </code></pre> <p>...is that the encode function is not passed the regexp paramete...
<pre><code>select regexp_replace(encode('héllo there','hex'),'(..)',E'%\\1','g'); </code></pre> <p>This doesn't leave the alphanumeric characters human-readable, though.</p>
<p>You can use CLR and import the namespace or use the function shown in this link , this creates a T-SQL function that does the encoding.</p> <p><a href="http://www.sqljunkies.com/WebLog/peter_debetta/archive/2007/03/09/28987.aspx" rel="nofollow noreferrer">http://www.sqljunkies.com/WebLog/peter_debetta/archive/2007/...
44,317
<p>Is DirectSound the best audio abstraction layer for Windows? Switching my app from a very bad sound implementation, built to a specific chipset, to an abstration layer.</p> <p>App is native Winform, .net 3.5. DirectX/DirectSound is the likely choice, but a little concerned about the overhead. Any other options? ...
<p>DirectSound is not getting the same love from Microsoft today as it got in the past. As far as DirectX is concerned, you may try XAudio2 or XACT instead. Some people love those, others hate them. XAudio2 is more low-level, while XACT is rather high-level. Both are accessible from Microsoft XNA, which is like Managed...
<p><a href="http://code.google.com/p/sharpdx/" rel="nofollow">SharpDX</a> looks interesting. I'm planning on trying it as a replacement for Managed DirectX because of the x86 limitations of the latter.</p>
19,137
<p>What is the best way to deal with storing and indexing URL's in SQL Server 2005? </p> <p>I have a WebPage table that stores metadata and content about Web Pages. I also have many other tables related to the WebPage table. They all use URL as a key. </p> <p>The problem is URL's can be very large, and using them as ...
<p>I'd use a normal identity column as the primary key. You say:</p> <blockquote> <p>This keeps all the associated indexes smaller and more efficient but it makes importing data a bit of a pain. Each import for the associated tables has to first lookup what the id of a url is before inserting data in the tabl...
<p>I totally agree with Dylan. Use an IDENTITY column or a GUID column as surrogate key in your WebPage table. Thats a clean solution. The lookup of the id while importing isn't that painful i think.</p> <p>Using a big varchar column as key column is wasting much space and affects insert and query performance.</p>
20,751
<p>I'm am building my asp.net web application using MVC (Preview 5), and am also using the Master pages concept. </p> <p>My PageA and PageB are both content pages. I'm doing a form submit in a method via JavaScript from PageA to PageB. PageB has its PreviousPageType attribute set to PageA, but when I access the Pre...
<p>You can iterate over both lists at the same time like this:</p> <pre><code># Get the max index of the smallest list set maxIndex = $#correctList if ( $#wrongList &lt; $#correctList ) then set maxIndex = $#wrongList endif set index = 1 while ($index &lt;= $maxIndex) printf "%-20s %s\n" "$correctList[$index]" "$...
<p>try getting rid of the \n</p>
33,525
<p>Using Windows Server 2003 in a multi-user environment (via Remote Desktop, using it as an application server), how to mount a (preferably encrypted) volume in a way, that won't show up on any other user's desktop?</p> <p>Tried, and failed approaches:</p> <ul> <li><p>tweaking user rights -display of mounted volume ...
<p>You're going to be hard-pressed to find a solution for your exact problem. Drive mount points aren't stored on the user level (afaik). There are a couple of workarounds that you can use that aren't guaranteed to be secure:</p> <ol> <li>hide access to certain drive letters based on group policy. Not very secure, ...
<p>There's a key in the Registry that's used to hide mapped drives.</p> <p>If you want to stop any combination of drives appearing in My Computer</p> <p>Add the Binary Value of 'NoDrives' in the registry at </p> <blockquote> <p>"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer"</p> </b...
11,481
<p>I'm looking for a way to serialize <strong>generic</strong> Python objects between a CherryPy-based server and a Python client running on a Symbian phone.. Since pyS60 doesn't implement the pickle module, how would you do it?</p> <p>I know about <a href="http://home.gna.org/oomadness/en/cerealizer" rel="nofollow no...
<p>What's wrong with using the pickle module?</p>
<p>There is a json module someone wrote for PyS60. I'd simply grab that, serialize things into json and use that as the transfer method between the web/client app. </p> <p>For the json lib and a decent book on PyS60: <a href="http://www.mobilepythonbook.org/" rel="nofollow noreferrer">http://www.mobilepythonbook.org/<...
47,311
<p>I have an array of shorts (short[]) that I need to write out to a file. What's the quickest way to do this?</p>
<p>Use the BinaryWriter</p> <pre><code> static void WriteShorts(short[] values, string path) { using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write)) { using (BinaryWriter bw = new BinaryWriter(fs)) { foreach (short value in ...
<p><strong>BinaryFormatter</strong> is in fact about <strong>10 times faster</strong> both for reads and writes when used with arrays of primitive types (obj.GetType().IsPrimitive), i.e. not for Decimal and String (which are not primitive) and certainly not for any other struct or class where it instead is horribly slo...
27,702
<p>Does anybody have experience working with PHP accelerators such as <a href="http://turck-mmcache.sourceforge.net/" rel="noreferrer">MMCache</a> or <a href="http://www.zend.com/en/" rel="noreferrer">Zend Accelerator</a>? I'd like to know if using either of these makes PHP comparable to <em>faster</em> web-technologi...
<p>Note that Zend Optimizer and MMCache (or similar applications) are totally different things. While Zend Optimizer tries to optimize the program opcode MMCache will cache the scripts in memory and reuse the precompiled code.</p> <p>I did some benchmarks some time ago and you can find the <a href="http://blogs.interd...
<p>Have you checked out Phalanger? It compiles PHP to .NET code. Here are <a href="http://web.archive.org/web/20101126094453/http://php-compiler.net/doku.php?id=core%3abenchmarks" rel="nofollow noreferrer">some benchmarks</a> which show that it can dramatically improve performance.</p>
3,402
<p>If any of you have worked with a cool tool for viewing/querying the SQL Transaction logs, please let me know. This should show all the transactional sql statements which are committed or rolled back.</p> <p>For Database files, if it has some additional graphical capabilities like showing the internal Binary Tree st...
<p>This is only relevant if you're talking SQL Server 2000 but RedGate produced a free tool called <a href="http://www.red-gate.com/products/SQL_Log_Rescue/index.htm" rel="noreferrer">SQL Log Rescue</a>. Otherwise, for SQL Server 2005 <a href="http://www.apexsql.com/sql_tools_log.asp" rel="noreferrer">ApexSQLLog</a> fr...
<p>There are some companies that produce log readers like Lumigent and Red Gate. However they do not work with SQL server versions greater than 2000 because of meta data changes in the underlying system tables and data types, they might work if you do not use any new functionality but if you use varchar(max) XML datat...
7,274
<p>After I <a href="https://stackoverflow.com/questions/121922/automatic-casts">messed up the description of my previous post</a> on this I have sat down and tried to convey my exact intent.</p> <p>I have a class called P which performs some distinct purpose. I also have PW which perform some distinct purpose on P. PW...
<p>You could try overriding operator* and operator-> to return access to the embedded p. Something like this might do the trick :</p> <pre><code>class P { public: void a( ) { std::cout &lt;&lt; "a" &lt;&lt; std::endl; } }; class PW { public: PW(P&amp; p) : p(p) { } void b( ) { std::cout &lt;&lt; "b" ...
<p>I think you need to think through what kind of relationship exists between PW and P.</p> <p>Is it an is-a relationship? Are instances of PW instances of P? Then it would make sense to have PW inherit from P.</p> <p>Is it a has-a relationship? Then you should stick with containment, and put up with the syntactic...
15,361
<p>When running FindBugs on my project, I got a few instances of the error described above.</p> <p>Namely, my overriding versions of equals cast the RHS object into the same type as the object in which the overriding version is defined.</p> <p>However, I'm not sure whether a better design is possible, since AFAIK Jav...
<p>Typically, when implementing equals you can check to see whether the class of the argument is equal (or compatible) to the implementing class before casting it. Something like this:</p> <pre><code>if (getClass() != obj.getClass()) return false; MyObj myObj = (MyObj) obj; </code></pre> <p>Doing it this way wil...
<p>I start my equals(Object) implementations like this:</p> <pre><code>if ((object == null) || !(object instaceof ThisClass)) { return false; } </code></pre> <p>This will also prevent the FindBugs warning but will not automatically return <code>false</code> when a subclass of ThisClass is being handed in. It migh...
47,578
<p>When using the .NET WebBrowser control how do you open a link in a new window using the the same session (ie.. do not start a new ASP.NET session on the server), or how do you capture the new window event to open the URL in the same WebBrowser control?</p>
<p>I just spent an hour looking for the answer, so I though I would post the results here. You can use the SHDocVwCtl.WebBrowser_V1 object to capture the NewWindow event.</p> <p>NOTE: Code from <a href="http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_21484555.html#discussion" rel="noreferrer">http...
<p>After adding the reference to shdocvw.dll to your project if you are not adding the actuasl object to your toolbox (shwos as &quot;Microsoft Browser&quot;) then define the object at the top of your code with:</p> <p>Dim WithEvents Web_V1 As SHDocVw.WebBrowser_V1</p>
21,182
<p>In a server-side application running on Tomcat, I am generating full HTML pages (with header) based on random user-requested sites pulled down from the Internet. The client-side application uses asynchronous callbacks for requesting processing of a particular web page. Since processing can take a while, I want to in...
<p>Let us assume the database character set is UTF-8, which is the recommended setting in recent versions of Oracle. In this case, some characters take more than 1 byte to store in the database.</p> <p>If you define the field as <code>VARCHAR2(11 BYTE)</code>, Oracle can use up to 11 bytes for storage, but you may not...
<p>In simple words when you write <code>NAME VARCHAR2(11 BYTE)</code> then only 11 Byte can be accommodated in that variable.</p> <p>No matter which characters set you are using, for example, if you are using Unicode (UTF-16) then only half of the size of Name can be accommodated in <code>NAME</code>.</p> <p>On the oth...
10,711
<p>What's the best way to trim a DateTime object to a specific precision? For instance, if I have a DateTime with a value of '2008-09-29 09:41:43', but I only want it's precision to be to the minute, is there any better way to do it than this?</p> <pre><code>private static DateTime TrimDateToMinute(DateTime date) { ...
<pre><code>static class Program { //using extension method: static DateTime Trim(this DateTime date, long roundTicks) { return new DateTime(date.Ticks - date.Ticks % roundTicks, date.Kind); } //sample usage: static void Main(string[] args) { Console.WriteLine(DateTime.Now); ...
<pre><code>DateTime dt = new DateTime() dt = dt.AddSeconds(-dt.Second) </code></pre> <p>Above code will trim seconds.</p>
18,434
<p>I'm developing a site-specific Firefox extension. The official hosting/updating mechanism at addons.mozilla.org forces my users to login to download my plugin (until it get approved for public status), which isn't good for me, especially as my plugin is unlikely to be deemed useful to the web at large and will be st...
<p>I recommend <a href="http://github.com/briancarper/cow-blog" rel="noreferrer">cow-blog</a> by Brian Carper. According to the author it was written with your purpose in mind.</p>
<p>Clojure is still too young and a moving target to have medium sized applications with available source code yet.</p>
42,666
<p>Can you program/configure Visual Studio to produce custom intellisense for your own server controls.</p> <p>eg can you get it to do this:</p> <p><a href="http://www.yart.com.au/test/vs.gif" rel="nofollow noreferrer">alt text http://www.yart.com.au/test/vs.gif</a></p> <p>for a tag of your own like:</p> <pre><code...
<p>You should be getting this for free (default behavior of control). Are the references all in place while you are typing the custom control?</p> <p>There is an attribute to hide properties from intellisense:</p> <pre><code>[EditorBrowsableAttribute (EditorBrowsableState.Never)] </code></pre> <p>Use the descriptio...
<p>Bluevision have a nice plugin for Visual Studio to do this for you. Last time I looked, it was free. (yep, it's still free!)</p> <ul> <li><p>IntellisenseAttribute class allows you to specify members for which intellisense symbols will be generated.</p></li> <li><p>Ability to generate default intellisense symbols fo...
39,582
<p>On one of the nozzles on my printer, the filament comes out at a 45 degree angle. It seems that this causes problems with adhesion to the bed and overall quality.</p> <ul> <li>What caused this problem? </li> <li>How do I fix it? </li> <li>How do I prevent it from happening in the future?</li> </ul>
<p>I've personally had this happen when I had a minor clog in my nozzle. </p> <p>My first steps to fix this would be:</p> <ol> <li>Make sure the exterior of your nozzle is clean. I've had bits of plastic pull at the extruding filament and change it's direction.</li> <li>Attempt a "cold pull" or "<a href="http://suppo...
<p>You very likely have partial clog in your hotend (the side which is clogged is the angle the extruding filament bends to) or have some plastic somehow stuck on the nozzle surface which the extruding plastic almost sticks to, like two droplets of water merging into one.</p> <p>If its the latter, clean the hotend. It...
165
<p>I'm exporting data programatically from Excel to SQL Server 2005 using SqlBulkCopy. It works great, the only problem I have is that it doesn't preserve the row sequence i have in Excel file. I don't have a column to order by, I just want the records to be inserted in the same order they appear in the Excel Spreadshe...
<p>I don't think that row ordering is specified or guaranteed by SQL unless you use an "ORDER BY " clause.</p> <p>From a post by Bill Vaughn (<a href="http://betav.com/blog/billva/2008/08/sql_server_indexing_tips_and_t.html" rel="nofollow noreferrer">http://betav.com/blog/billva/2008/08/sql_server_indexing_tips_and_t....
<p>If you can save the excel spreadsheet as a CSV it is very easy to generate a list of INSERT statements with any scripting language which will be executed in the exact same order as the spreadsheet. Here's a quick example in Groovy but any scripting language will do it just as easily if not easier:</p> <pre><code>d...
23,012
<p>When using <a href="http://jquery.com/" rel="nofollow noreferrer">jQuery</a>'s <a href="http://docs.jquery.com/Ajax/jQuery.ajax#options" rel="nofollow noreferrer">ajax method</a> to submit form data, what is the best way to handle errors? This is an example of what a call might look like:</p> <pre><code>$.ajax({ ...
<blockquote> <p>Should I be throwing the errors in the ashx, or should I be returning a status code as part of the data returned by the call to userCreation.ashx, then using this to decide what action to take? How do you handle these situations?</p> </blockquote> <p>Personally, if possible, I would prefe...
<p>Now I have a problem as to which answer to accept.</p> <p>Further thought on the problem brings me to the conclusion that I was incorrectly throwing exceptions. Duplicate user names, email addresses etc are expected issues during a sign up process and are therefore not exceptions, but simply errors. In which case I...
4,813
<p>Is there an existing solution to create a regular expressions dynamically out of a given date-time format pattern? The supported date-time format pattern does not matter (Joda <code>DateTimeFormat</code>, <code>java.text.SimpleDateTimeFormat</code> or others).</p> <p>As a specific example, for a given date-time form...
<p>I guess you have a limited alphabet that your time formats can be constructed of. That means, <code>"HH"</code> would always be "hours" on the 24-hour clock, <code>"dd"</code> always the day with leading zero, and so on.</p> <p>Because of the sequential nature of a time format, you could try to tokenize a format st...
<p><code>SimpleDateFormat</code> already does this with the <code>parse()</code> method.</p> <p>If you need to parse multiple dates from a single string, start with a regex (even if it matches too leniently), and use <code>parse()</code> on all the potential matches found by the regex.</p>
7,528
<p>I have never done huge amounts of RTF processing, I always used a library to read or generate one and that was a long time ago. Now I need to get more intimate with the format again, and eventually convert it to XML.</p> <p>Can you recommend a good path to do it so that I have a lot of control on how RTF chunks are...
<p><a href="http://rtf2xml.sourceforge.net/docs/index.html" rel="nofollow noreferrer">RTF Manual</a>? Seriously though, a quick google turns up all sorts of tools and libraries. Why reinvent the wheel?</p>
<p>ScroogeXHTML, a library for RTF to HTML / XHTML conversion, is available for the Java(tm) platform and Delphi. A demo version and online documentation of the API are available on this page:</p> <p><a href="http://www.mikejustin.com/" rel="nofollow noreferrer">http://www.mikejustin.com/</a></p> <p>or</p> <p><a hre...
24,454
<p>What's the best way to unit test protected and private methods in Ruby, using the standard Ruby <code>Test::Unit</code> framework?</p> <p>I'm sure somebody will pipe up and dogmatically assert that "you should only unit test public methods; if it needs unit testing, it shouldn't be a protected or private method", b...
<p>You can bypass encapsulation with the send method:</p> <pre class="lang-ruby prettyprint-override"><code>myobject.send(:method_name, args) </code></pre> <p>This is a 'feature' of Ruby. :)</p> <p>There was internal debate during Ruby 1.9 development which considered having <code>send</code> respect privacy and <co...
<p>I know I'm late to the party, but don't test private methods....I can't think of a reason to do this. A publicly accessible method is using that private method somewhere, test the public method and the variety of scenarios that would cause that private method to be used. Something goes in, something comes out. Testi...
33,516
<p>I have a number of custom controls that I am trying to enable designer support for. The signature looks something like the following:</p> <pre><code>[ToolboxData("&lt;{0}:MyDropDownList runat=\"server\" CustomProp="123"&gt;&lt;/{0}:MyDropDownList&gt;")] public class MyDropDownList: DropDownList { ... code here }...
<p>It looks something like this:</p> <pre><code>[assembly:TagPrefix("MyControls","RequiredTextBox")] </code></pre> <p>and <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.tagprefixattribute.tagprefixattribute.aspx" rel="noreferrer">here's</a> some more info about it.</p>
<p>FYI, the TagPrefix attribute is only a <em>suggestion</em> to Visual Studio and other designer tools. If the user already has your namespace registered to a different tag prefix then it is free to use that tag prefix. Also, if your suggested tag prefix is already in use and points to a different namespace, the Visua...
28,899
<p>I would find out the <em>floppy inserted state</em>:</p> <ul> <li>no floppy inserted</li> <li>unformatted floppy inserted</li> <li>formatted floppy inserted</li> </ul> <p>Can this determined using "WMI" in the System.Management namespace?</p> <p>If so, can I generate events when the <em>floppy inserted state</em>...
<p>This comes from <a href="http://msdn.microsoft.com/en-us/library/aa394592(VS.85).aspx" rel="nofollow noreferrer">Scripting Center @ MSDN</a>:</p> <pre><code>strComputer = "." Set objWMIService = GetObject( _ "winmgmts:\\" &amp; strComputer &amp; "\root\cimv2") Set colItems = objWMIService.ExecQuery _ ("Sele...
<p>This comes from <a href="http://msdn.microsoft.com/en-us/library/aa394592(VS.85).aspx" rel="nofollow noreferrer">Scripting Center @ MSDN</a>:</p> <pre><code>strComputer = "." Set objWMIService = GetObject( _ "winmgmts:\\" &amp; strComputer &amp; "\root\cimv2") Set colItems = objWMIService.ExecQuery _ ("Sele...
18,717
<p>I am designing a error logging feature so our servers (each donig different things) can have a central data store for logging errors.</p> <p>Would it be a good idea to have the various applications writing to the error log file using a WCF service, or is that a bad idea?</p> <p>they <em>can</em> do it just by ADO....
<p>I'd say just log to your local data store. The advantages are :</p> <ol> <li>Speed - it's pretty rapid to just dump your chosen error report to an existing data connection.</li> <li>Tracability - What happens if you have an error in your service? You lose all ability to chase down errors on all servers. </li> ...
<p>We're looking at a similar approach, except for audit logging as well as error handling.</p> <p>Looking at using WCF over netTcp, also looking at using the event log, but that seems to require high trust settings, and maybe performance issues.</p> <p>Not convinced by ZombieSheep's objections:</p> <ol> <li><p>It's...
34,478
<p>How do you organize installing different programs if these programs use the same DLLs which <strong>require registration</strong>. </p> <p>The problem: if the user uninstalls the program that is installed later the other program will stop working as the registry entries now point to the missing DLLs. </p> <p>One p...
<p>It is usually handled as you already described: placing the DLLs into a common folder below common files in the program files folder.</p> <p>I mostly create a merge module containing such DLLs and include that when creating a setup for different programs. That way, the DLLs remain installed until the last program u...
<p>Use the new XP deployment model of side by side assemblies. It supports isolated COM components.</p> <p><a href="http://msdn.microsoft.com/en-us/library/aa369732(VS.85).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/aa369732(VS.85).aspx</a></p>
30,078
<p>What would be the bast way to change the orientation of the WPF treeview. I would like to work the expand-collapse-functionality to work left to right instead of top to down. I.e. when I click on on the expand button of a treenode I would its subnode to appear right of the parent and the indent should work top-down ...
<p>Here is a great article by <a href="http://www.codeproject.com/KB/WPF/CustomTreeViewLayout.aspx" rel="noreferrer">Josh Smith on CodeProject</a> detaling exactly how to do this kind of thing.</p>
<p>To expand on <a href="http://www.codeproject.com/KB/WPF/CustomTreeViewLayout.aspx" rel="nofollow noreferrer">John Smith's CodeProject article</a>, if you want to have horizontal layout on only a particular level in the tree (instead of on all levels like his article shows), then just set the <code>ItemsPanel</code> ...
47,530
<p>How are the UDP and TCP protocols used in MMORPG client/server communication?</p> <p>For example:</p> <p>Does the client broadcast (player position, etc) via UDP to the server? or vice versa?</p> <p>Or is it more like using TCP where the Client requests that the server move the player. The server receives the re...
<p>A lot of games use UDP for movement related activities--so, like, when you are walking, chances are, a bunch of UDP requests are being sent. The server still ultimately controls whether that's valid, but you don't necessarily care whether every single packet gets to the server. This is why a lot of game clients also...
<p>I don't know any details other than observations as a player, but most game most definitely do not wait for a server reply to move a character, that would kill the user experience unless it was turn-based. What looks like happens is the movement is done client-side and sent to the server which then sends those mess...
26,216
<p>I have a property defined in my HBM file like this:</p> <pre><code>&lt;property name="OwnerId" column="OwnerID" type="System.Int32" not-null="false" /&gt; </code></pre> <p>It is defined as a nullable field in the database also. If a record in the DB has the OwnerID column set to an integer, this object is correct...
<p>Assuming that you are using the jQuery <a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/" rel="nofollow noreferrer">validation plugin</a>, you could set/clear the class of each of the controls in the required/not required sections based on the checkbox that was clicked. </p> <pre><code>$(docum...
<p>Assuming that you are using the jQuery <a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/" rel="nofollow noreferrer">validation plugin</a>, you could set/clear the class of each of the controls in the required/not required sections based on the checkbox that was clicked. </p> <pre><code>$(docum...
38,079
<p>Delphi 2009, among some cool stuff, has also just got Anonymous methods. I've seen the examples, and the blog posts regarding anonymous methods, but I don't get them yet. Can someone explain why I should be excited?</p>
<p>Just think of typical callback code where you need to have data available to the callback. Often this data is needed for the callback <strong>only</strong>, yet you have to jump through a number of hoops to get it there without having to resign to un-OOP-friendly practices like global variables. With anonymous metho...
<p>I guess (I don't know Delphi) this implies that you can create functions as a kind of data object now. This means that you can, for example, pass functions as parameters to other functions. Example: A sort function might take a comparison function as a parameter, thus being much more versatile.</p>
31,961
<p>I have a cron job on an Ubuntu Hardy VPS that only half works and I can't work out why. The job is a Ruby script that uses mysqldump to back up a MySQL database used by a Rails application, which is then gzipped and uploaded to a remote server using SFTP.</p> <p>The gzip file is created and copied successfully but ...
<p>Are you sure the temporary file is being created correctly when running as a cron job? The working directory for your script will either be specified in the HOME environment variable, or the /etc/passwd entry for the user that installed the cron job. If deploy does not have write permissions for the directory in whi...
<p>Is cron sending emails with logs?</p> <p>If not, pipe the output of cron to a log file.</p> <p>Make sure to redirect STDERR to the log.</p>
3,419
<p>I'm getting a <code>ConnectException: Connection timed out</code> with some frequency from my code. The URL I am trying to hit is up. The same code works for some users, but not others. It seems like once one user starts to get this exception they continue to get the exception.</p> <p>Here is the stack trace:</p...
<p>Connection timeouts (assuming a local network and several client machines) typically result from</p> <p>a) some kind of firewall on the way that simply eats the packets without telling the sender things like "No Route to host"</p> <p>b) packet loss due to wrong network configuration or line overload</p> <p>c) too...
<p>There is a possibility that your IP/host are blocked by the remote host, especially if it thinks you are hitting it too hard.</p>
11,235
<p>I am looking for a free WYSIWYG editor control to be used in a Winform application. The applications primary language is VB but using C# is also an option. To clarify I need a rich text editor control that has a formatting bar. I have looked all over the web and the only options I can find are expensive control pack...
<p>Actually it's very easy to write your own based on the RichTextBox control.</p> <p>I would go that way for sure. Your biggest problem will be the icons for the edit bar.</p> <p>Check <a href="http://www.workaholic.hu/temp/RTFEditor.zip" rel="nofollow noreferrer">this one</a> for starter.</p>
<p>Actually it's very easy to write your own based on the RichTextBox control.</p> <p>I would go that way for sure. Your biggest problem will be the icons for the edit bar.</p> <p>Check <a href="http://www.workaholic.hu/temp/RTFEditor.zip" rel="nofollow noreferrer">this one</a> for starter.</p>
32,328
<p>I JOIN 2 tables </p> <p>for example</p> <pre> table_A +---------+-----------+-----------+ | user_id | ticket_id | user_name | +---------+-----------+-----------+ table_B +-----------+-------------+ | ticket_id | ticket_name | +-----------+-------------+ </pre> <p>If I run the following query:</p> <pre> SELECT ...
<p>There are a similar issues with MS SQLServer where version 2000 is accepting some ambiguous queries and the 2005 would throw an error. Basically the newer versions seem to be more strict.</p> <p>As a general rule you should use the same DB version both on Test server and on Production server to avoid this type of b...
<p>I think Tomalak is right - there is a strict mode in the MySQL Administrative settings that may resolve your issue on the issue.</p> <p>I recall you select it during db creation, but you can adjust it from the Admin GUI.</p> <p>There are some significant bugs in MySQL right now, you may want to consider moving to ...
43,728
<p>This is a simplification of the issue (there are lots of ways of doing things), but among applications that need to talk to a database I have usually seen one of two patterns:</p> <ol> <li>Object-Relational Mapping (ORM), where (usually) each table in the database has a corresponding "row wrapper" class with public...
<p>Datatable will certainly be conceptually more straight forward in working with data. And its devoid of sometimes unnatural idioms that you find in ORM. (querying a record into local memory, before updating it; joins are pointers; the key value itself is a pointer, hence, adding a record requires loading the parent ...
<p>I used to just use a datareader to read fields onto my object using GetString, GetInt etc. but i've moved on now to a much more OO and testable approach using a Gateway to return a datatable from a query, this is then passed into a Service class which parses the table onto an object. </p> <p>I never really liked OR...
34,194
<p>I have 2 wav files that I want to concatenate into one file with the two sound tracks. </p> <p>Is there any api for that task or some built in commands in .NET that can I can use in some genius way to make this task possible?</p> <p>Many thanks for the help. :)</p>
<p>If I'm not mistaken, you can just append the bytes from the second file to the end of the first. If there is any header data, you'll want to exclude that (see <a href="http://filext.com/file-extension/WAV" rel="nofollow noreferrer">here</a>)</p> <p>Be advised that you may hear a click or pop between the two clips, ...
<p>The straightforward way would be to interpret the wav file headers, extract the samples and interleave the samples from both files into a new sample stream which you write to a new wav file. You could also add the sample values of both source wav files sample by sample to 'mix' both files into a single track. The wa...
44,265
<p>I have the following equation</p> <blockquote> <p>1 - ((.5 * 0.83333333333333) ^ 2 + (.5 * 0.83333333333333) ^ 2 + (.5 * (1 - 0.83333333333333)) ^ 2 + (.5 * (1 - 0.83333333333333)) ^ 2) </p> </blockquote> <p>In Php5, this results in an answer of 1 as opposed to .63 (on two machines, OSx and Centos). Should I be...
<p>I think maybe you should be using <a href="http://www.php.net/pow" rel="noreferrer">pow()</a> instead of the <a href="http://www.php.net/manual/en/language.operators.bitwise.php" rel="noreferrer">xor operator (^)</a> :)</p>
<p>Not really an equation, but thats semantics. also, I doubt you mean xor, so I'll assume that isn't what you want. Anyway, can you use rational arithmetic?</p> <p>0.83333 can be converted to a fraction (assuming the 3 is a repeating decimal):</p> <pre><code> 83.3333333 = 100x 8.3333333 = 10x ----------------- ...
36,142
<p>I've heard a lot of people touting success using Linux based proxies to handle routing for high availability of web applications, but what are others doing with web services? I have a bank of WCF services that need to be moved to a high availability (failover) model, meaning that if a particular server hosting the W...
<p>The <a href="http://mjsarfatti.com/sandbox/nestedSortable/" rel="noreferrer">nestedSortable jQuery plugin</a> is probably a good place to start. Below is an example of using form fields in each draggable and nest-able <code>&lt;li&gt;</code>. Then it's just a matter of implementing something to handle indenting by k...
<p>The most difficult part will be enabling the keyboard to control the collapsing and expanding. The same functionality using only mouse events is pretty easy and you should find examples <a href="http://www.google.es/search?q=jquery+outliner" rel="nofollow noreferrer">googling</a></p>
32,092
<p>I'm looking for an example of how to load an image from file and print it on a page using WPF. I'm having a hard time finding good information about WPF printing.</p>
<pre><code>var bi = new BitmapImage(); bi.BeginInit(); bi.CacheOption = BitmapCacheOption.OnLoad; bi.UriSource = new Uri(""); bi.EndInit(); var vis = new DrawingVisual(); using (var dc = vis.RenderOpen()) { dc.DrawImage(bi, new Rect { Width = bi.Width, Height = bi.Height }); } var pdialog = new PrintDialog(); if ...
<p>Just load the image and apply it to a visual. Then use the PrintDialog to do the work.</p> <pre><code>... PrintDialog printer = new PrintDialog(); if (printer.ShowDialog()) { printer.PrintVisual(myVisual, "A Page Title"); } </code></pre>
33,210
<p>I have been using <a href="http://en.wikipedia.org/wiki/Inversion_of_control" rel="nofollow noreferrer">IoC</a> for a little while now and I am curious if I should use Microsoft's <a href="http://msdn.microsoft.com/en-us/library/dd203101.aspx" rel="nofollow noreferrer">Unity</a> framework (official name "Unity Appli...
<p>I am using Unity with no real problems. I know a few ALT.NET type people warn against Unity but I really think that is just because of the history the MS P&amp;P team have of writing bloatware. Unity is not yet bloated IMO and works well.</p>
<p>I've played with CompositeWPF (aka Prism) - successor of Composite app block. From my experience Unity works much better as compared with previous version of ObjectBuilder. However it's up to you to evaluate IoC frameworks and choose one suited for your needs.</p> <p><a href="http://www.pnpguidance.net/Category/Uni...
13,252
<p>I'd like to know if there's an easier way to insert a record if it doesn't already exist in a table. I'm still trying to build my LINQ to SQL skills. </p> <p>Here's what I've got, but it seems like there should be an easier way.</p> <pre><code>public static TEntity InsertIfNotExists&lt;TEntity&gt; ( DataContex...
<pre><code>public static void InsertIfNotExists&lt;TEntity&gt; (this Table&lt;TEntity&gt; table, TEntity entity, Expression&lt;Func&lt;TEntity,bool&gt;&gt; predicate) where TEntity : class { if (!table.Any(predicate)) { table.InsertOnSu...
<p>Small modification for Mark's answer:</p> <p>If you only care about checking if the entity exists by its primary key, Marke's answer can be used like this:</p> <pre><code>public static void InsertIfNotExists&lt;TEntity&gt; (this Table&lt;TEntity&gt; table , TEntity entity ...
12,526
<p><strong>UPDATE:</strong> i updated the code and problem description to reflect my changes. </p> <p>I know now that i'm trying a Socket operation on nonsocket. or that my fd_set is not valid since:</p> <p><code>select</code> returns -1 and <code>WSAGetLastError()</code>returns 10038. </p> <p>But i can't seem to ...
<p>You have some data ready to be read, but you are not actually reading anything. When you poll the descriptor next time, the data will still be there. Drain the pipe before you continue to poll.</p>
<p>The first argument to select needs to be the highest-numbered file descriptor in any of the three sets, plus 1:</p> <pre><code> int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); </code></pre> <p>Also:</p> <pre><code> if(FD_ISSET(filePointer,&am...
18,435
<p>I have seen this macro defined before but never really knew its purpose. Can anyone shed light on this?</p>
<p>This is a compiler intrinsic used for optimization, typically seen in embedded programming. The only time I have seen it used is in the "default" for a switch statement to assert that the variable has a limited range (for better optimization). Example:</p> <pre><code> /* Get DTMF index */ switch(dtmf) { case...
<p>I've seen things like that before as part of testing. If it <em>is</em> executed, then you know that you have a bug.</p>
25,549
<p>I have this XML in a column in my table:</p> <pre><code>&lt;keywords&gt; &lt;keyword name="First Name" value="|FIRSTNAME|" display="Jack" /&gt; &lt;keyword name="Last Name" value="|LASTNAME|" display="Jones" /&gt; &lt;keyword name="City" value="|CITY|" display="Anytown" /&gt; &lt;keyword name="State" value=...
<p>Here is a sample code:</p> <p>To read keywords we need to call <em>Elements("<strong>keyword</strong>")</em> not <em>Elements("<strong>keywords</strong>")</em> since <em>keywords</em> is a root node. </p> <pre><code>// IEnumerable sequence with keywords data var keywords = from kw in ga.ArticleKeywords.Elements("k...
<p>I would think something like this would work</p> <pre><code>var keywordData = from k in ga.ArticleKeywords.Elements("Keywords") select new { Value = k.Attributes["value"].Value, Display = k.Attributes["display"].Value}; </code></pre> <p>This would give you an IEnume...
25,383
<p>I'm trying to do a basic "OR" on three fields using a hibernate criteria query.</p> <p>Example</p> <pre><code>class Whatever{ string name; string address; string phoneNumber; } </code></pre> <p>I'd like to build a criteria query where my search string could match "name" or "address" or "phoneNumber".</p>
<p>You want to use <code>Restrictions.disjuntion()</code>. Like so</p> <pre><code>session.createCriteria(Whatever.class) .add(Restrictions.disjunction() .add(Restrictions.eq("name", queryString)) .add(Restrictions.eq("address", queryString)) .add(Restrictions.eq("phoneNumber", queryString))...
<p>The conditions can be applied using the or / and in different levels of the query using disjunction</p> <pre><code>Criteria query = getCriteria("ENTITY_NAME"); query.add(Restrictions.ne("column Name", current _value)); Disjunction disjunction = Restrictions.disjunction(); if (param_1 != null) disjunction.add(...
8,173
<p>My understanding of the Git pack file format is something like: <img src="https://content.screencast.com/users/aggieben/folders/Jing/media/dc42fabf-6fd6-47f3-9244-446b9ec04494/2008-09-16_1424.png" alt="alt text"></p> <p>Where the table is 32-bits wide, and the first three 32-bit words are the pack file header. The...
<p>My reading of the <a href="http://repo.or.cz/w/git.git?a=blob;f=Documentation/technical/pack-format.txt;h=1803e64e465fa4f8f0fe520fc0fd95d0c9def5bd;hb=HEAD" rel="noreferrer">pack file documentation</a> indicates that the last byte of the size (offset 15 in your example) would have the MSB set to 0.</p>
<p>There is also some graphical documentation explaining some of the format <a href="http://shafiulazam.com/gitbook/7_the_packfile.html" rel="nofollow noreferrer">here</a>. This section is no longer present in Community book, but still available it the location above.</p>
10,165
<p>We have built a custom socket server in ruby and packaged it as a gem. Since this is an internal project we can not simply publish it to RubyForge or GitHub. I tried to setup our own gem server but gem would not authenticate over https. Our other deployment is all for standard rails applications that use capistran...
<p>Start </p> <pre><code>gem server #That will serve all your local installed gems. gem install YourLocalPkg1.X.X.gem </code></pre> <p>#on YourHost</p> <p>use </p> <pre><code>gem sources --add localhost:8808 gem install YourGem </code></pre> <p>on client machine develop something</p> <pre><code>rake gem gem inst...
<p>gem install --local path_to_gem/filename.gem will help. Or you can get a trusted certificate on your web server.</p> <p>You might be able to install from the server with gem install -P NoSecurity or -P LowSecurity, but I haven't tried that.</p> <p><a href="http://www.rubygems.org/read/chapter/21" rel="nofollow nor...
37,461
<p>I have a vector with 1000 "nodes"</p> <pre><code> if(count + 1 &gt; m_listItems.capacity()) m_listItems.reserve(count + 100); </code></pre> <p>The problem is I also clear it out when I'm about to refill it. </p> <pre><code>m_listItems.clear(); </code></pre> <p>The capacity doesn't change. I've used the res...
<pre><code>vector&lt;Item&gt;(m_listItems).swap(m_listItems); </code></pre> <p>will shrink <code>m_listItems</code> again: <a href="http://www.gotw.ca/gotw/054.htm" rel="noreferrer">http://www.gotw.ca/gotw/054.htm</a> (Herb Sutter)</p> <p>If you want to clear it anyway, swap with an empty vector:</p> <pre><code>vect...
<p>You could try this technique from <a href="http://www.gamedev.net/community/forums/topic.asp?topic_id=397748" rel="nofollow noreferrer">here</a></p> <pre><code>std::vector&lt; int &gt; v; // ... fill v with stuff... std::vector&lt; int &gt;().swap( v ); </code></pre>
41,278
<p>Hi I want to generate running time graphs on my java program. Is there any program which makes it?</p>
<p>So, if the X-axis is time, what do want on the Y-axis?</p> <p>If its memory, then you could use something <a href="http://java.sun.com/javase/6/docs/technotes/tools/index.html#monitor" rel="nofollow noreferrer">jconsole or jvisualvm </a></p>
<p>Have a look at the <a href="http://www.jfree.org/jfreechart/" rel="nofollow noreferrer">jfreechart</a> library.</p>
41,923
<p>A Google search for "site:example.com" will tell you the number of pages of example.com that are currently in Google's index. Is it possible to find out how this number has changed over time?</p>
<p><a href="http://www.hubspot.com/" rel="nofollow noreferrer">HubSpot</a> does this for you. It costs money but they do a lot of useful things like this.</p>
<p>I was going to suggest Google Webmaster Tools, but it doesn't appear to have this information. How irritating.</p> <p><br/> Anyway, to follow on from UltimateBrent's answer, this regular expression will extract the value from a google search:</p> <pre><code>\d+(?=&lt;/b&gt; from &lt;b&gt;domain\.net&lt;/b&gt;) </c...
12,346
<p>Is anyone aware of a good resource <strong><em>online</em></strong> for detailed information on the use of ole excel objects(embeded workbooks, worksheets, etc...) in VB6? I'm maintaining an application that makes heavy use of these conrols and I'm having a lot of trouble getting them to work properly for the user's...
<p>I'm not sure this is helpful for <em>embedding</em> Excel, but assuming that the Excel engine is at the core of the embedded controls, you can look <a href="http://msdn.microsoft.com/en-us/library/aa272310(office.11).aspx" rel="nofollow noreferrer">here</a> for an alphabetized reference of the objects available for ...
<p>Any book on Excel VBA should help as you can copy and paste code from VBA to VB6. I would start there. </p> <p>Also trying to do what you want to do in Excel with VBA then putting it into your VB6 project will also help. Then you'll have access to all the VBA help in Excel (if you installed it.. it doesn't always i...
45,483
<p>I'm trying to create an algorithm in C# which produces the following output strings:</p> <pre><code>AAAA AAAB AAAC ...and so on... ZZZX ZZZY ZZZZ </code></pre> <p>What is the best way to accomplish this?</p> <pre><code>public static IEnumerable&lt;string&gt; GetWords() { //Perform algorithm yield return w...
<p>well, if the length is a constant 4, then this would handle it:</p> <pre><code>public static IEnumerable&lt;String&gt; GetWords() { for (Char c1 = 'A'; c1 &lt;= 'Z'; c1++) { for (Char c2 = 'A'; c2 &lt;= 'Z'; c2++) { for (Char c3 = 'A'; c3 &lt;= 'Z'; c3++) { ...
<p>javascript!</p> <pre><code>var chars = 4, abc = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", top = 1, fact = []; for (i = 0; i &lt; chars; i++) { fact.unshift(top); top *= abc.length; } for (i = 0; i &lt; top; i++) { for (j = 0; j &lt; chars; j++) document.write(abc[Math.floor(i/fact[j]) % abc.length]); document....
40,305
<p>I'm writing some Javascript to resize the large image to fit into the user's browser window. (I don't control the size of the source images unfortunately.)</p> <p>So something like this would be in the HTML:</p> <pre><code>&lt;img id="photo" src="a_really_big_file.jpg" alt="this is some alt text" t...
<p>Either add an event listener, or have the image announce itself with onload. Then figure out the dimensions from there.</p> <pre><code>&lt;img id="photo" onload='loaded(this.id)' src="a_really_big_file.jpg" alt="this is some alt text" title="this is some title text" /&gt; </code></pre>
<p>We developed a page where it loaded a number of images and then performed other functions only after the image was loaded. It was a busy site that generated a lot of traffic. It seems that the following simple script worked on practically all browsers:</p> <pre><code>$(elem).onload = function() { doSomething();...
32,970
<p>I want to avoid the duplication of stylesheet link tags in the output html when a user control is dropped onto an aspx page. However if you omit the stylesheet link tag you don't get design time support for the stylesheet.</p> <p>Anybody know a way around this problem?</p>
<p>I suggest seeing this thread:</p> <p><a href="https://stackoverflow.com/questions/34390/how-to-make-user-controls-know-about-css-classes-in-aspnet">How to make user controls know about CSS classes in ASP.NET.</a></p>
<p>While that will impact the size of the HTML. I don't see it affecting the overall performance of your webpage. The browser will cache the CSS client side, so it should only be downloaded once.</p>
28,445
<p>I really need to see some honest, thoughtful debate on the merits of the currently accepted <strong><em>enterprise application</em></strong> design paradigm.</p> <p>I am not convinced that entity objects should exist.</p> <p>By entity objects I mean the typical things we tend to build for our applications, like "P...
<p>I think it comes down to how complicated the "logic" of the application is, and where you have implemented it. If all your logic is in stored procedures, and all your application does is call those procedures and display the results, then developing entity objects is indeed a waste of time. But for an application ...
<p>I think that you are just used to writing a specific kind of application, and solving a certain kind of problem. You seem to be attacking this from a "database first" perspective. There are lots of developers out there where data is persisted to a DB but performance is not a top priority. In lots of cases putting...
3,918
<p>I'm going to be working on some iPhone apps so I've been given a golden ticket to buy a Mac. However the golden ticket isn't worth that much, and I'm thinking iMac. Now, Macs are great, I love 'em and use 'em at home, but I know that the iMac is geared more towards the average consumer than the professional. Is an i...
<p>Any modern Mac will be fine. I work on a two year old MacBook (2GHz) with 2Gb of memory and its perfectly usable. The biggest constraint I find it screen real-estate. I am <em>way</em> more productive on my 22" external screen. Go big if you get an iMac or consider adding an external monitor to the base model.</p>
<p>As with all development, screen size is paramount so I would suggest the 24" iMac if your golden ticket stretches that far or a mac mini with a large (probably non-Apple) monitor if it doesn't.</p>
4,250
<p>I am converting a linux script from <a href="http://www.perlmonks.org/index.pl?node_id=217166" rel="nofollow noreferrer">http://www.perlmonks.org/index.pl?node_id=217166</a> specifically this:</p> <pre><code>#!/usr/bin/perl -w use strict; use Getopt::Std; use File::Find; @ARGV &gt; 0 and getopts('a:', \my %opt) or...
<p>From this <a href="http://perl.active-venture.com/lib/File/Find.html" rel="nofollow noreferrer">documentation</a></p> <blockquote> <p>postprocess</p> <p>The value should be a code reference. <b>It is invoked just before leaving the currently processed directory</b>. It is called in void context with no...
<p>Thanks for all your replies. My final script looks like this:</p> <pre><code>#!/usr/bin/perl -w use strict; use warnings; use Getopt::Std; use File::Find; use Win32::OLE; @ARGV &gt; 0 and getopts('a:', \my %opt) or die &lt;&lt; "USAGE"; Deletes any old files from the directory tree(s) given and removes empty direc...
45,544
<p>I am making a DIY 3D printer based on the prusa mini. So, I doubt is if RAMPS can only control 4 stepper motors as it has slots for 5 stepper motor slots and one will not be used in my case, if I can in what order should I connect the drivers and also ho will Marlin figure out which slot the extruder is connected? S...
<p>Generally, a timing belt is a complicated device and many things depend on its internal construction and materials (it may be damaged when bound in wrong direction, or when cut, and when overtighten of course, etc.). There is also physics and math applicable, based on <a href="https://en.wikipedia.org/wiki/Mersenne%...
<p>Mine came from the factory tight enough that it doesn't sag at all, but not so tight that it feels hard or stiff or difficult to deflect a bit with gentle pressure. With the bed pushed all the way to the back, I can push the y-axis belt to the side about 1/8&quot; with gentle pressure, and it feels like that's about...
1,823
<p>The backup and restore process of a large database or collection of databases on sql server is very important for disaster &amp; recovery purposes. However, I have not found a robust solution that will guarantee the whole process is as efficient as possible, 100% reliable and easily maintainable and configurable ac...
<p>I've used a similar step to keep dev/test/QA databases 'zero-stepped' on a nightly basis for developers and QA folks to use. </p> <p>Documentation is the key - if you want to remove what Scott Hanselman calls 'bus factor' (i.e. the danger that the creator of the system will get hit by a bus and everything starts to...
<p>I am doing precisely the same thing and have various issues semi regularly even with this process.</p> <p>How do you handle the spacing between copying the file from Server A to Server B and restoring the transactional backup on Server B.</p> <p>Every once in a while the transaction backup is larger than normal an...
10,296
<p>What format do I use for Date/Time when writing to an XML file using .NET? Do I simply use <code>DateTime.ToString()</code>, or do I have to use a specific format?</p>
<p>I always use the <a href="http://en.wikipedia.org/wiki/ISO_8601" rel="noreferrer">ISO 8601</a> format (e.g. <code>2008-10-31T15:07:38.6875000-05:00</code>) -- <code>date.ToString("o")</code>. It is the <a href="http://www.w3.org/TR/xmlschema-2/#isoformats" rel="noreferrer">XSD date format</a> as well. That is the pr...
<p>The <code>XmlConvert</code> class provides these kinds of facilities. About DateTimes, in particular, be careful about obsolete methods. See also: <a href="https://stackoverflow.com/a/7457718/1288109">https://stackoverflow.com/a/7457718/1288109</a></p>
31,783
<p>I have an XML file that starts like this:</p> <pre><code>&lt;Elements name="Entities" xmlns="XS-GenerationToolElements"&gt; </code></pre> <p>I'll have to open a lot of these files. Each of these have a different namespace but will only have one namespace at a time (I'll never find two namespaces defined in one xml...
<p>There are a few techniques that you might try; which you use will depend on exactly what information you need to get out of the document, how rigorous you want to be, and how conformant the XPath implementation you're using is.</p> <p>One way to get the namespace URI associated with a particular prefix is using the...
<p>Unfortunately, XPath doesn't have any concept of "default namespace". You need to register namespaces with prefixes with the XPath context, and then use those prefixes in your XPath expressions. It means for very verbose xpath, but it's a basic shortcoming of XPath 1. Apparently XPath 2 will address this, but tha...
14,898
<p>I am trying to learn some of the basic and advanced features of visual studio, Anyone find sites that have this type of information ?</p> <p>I see this:</p> <p><a href="https://stackoverflow.com/questions/86355/best-way-to-learn-visual-studio-power-features">https://stackoverflow.com/questions/86355/best-way-to-le...
<p>To set up the environment variables, do this</p> <ol> <li>Fire up the start menu</li> <li><strong>Right-Click</strong> on <code>Computer</code> and select <code>Properties</code></li> <li>Click <code>Advanced system settings</code> in the left-hand bar, and confirm the UAC prompt</li> <li>Select the <code>Advanced<...
<p>Add your ruby bin directory to your PATH environment variable, go to Control Panel -> System -> Advanced system settings, then go to the Advanced tab, Environment Variables, then edit your PATH variable and append the path to the ruby binaries install i.e. <strong>;C:\ruby\bin</strong></p>
21,844
<p>On Linux, how can I (programmatically) retrieve the following counters <em>on a per-interface basis</em>:</p> <ul> <li>Sent/received ethernet frames,</li> <li>Sent/received IPv4 packets,</li> <li>Sent/received IPv6 packets.</li> </ul>
<p>On my system, there are files under <code>/sys/class/net/eth0/statistics</code>, which gives various stats about network interfaces.</p> <p>This is assuming a vaguely recent Linux which has <code>/sys</code> (sysfs) mounted.</p>
<p>You can easily do that in C# in monodevelop:</p> <pre><code>using System.Net.NetworkInformation; foreach (NetworkInterface ni in interfaces) { // perform your calculations } </code></pre>
45,481
<p>Right now, I keep all of my projects on my laptop. I'm thinking that I shouldn't do this, but instead use a version control system and check them in/out from an external hosting repository (Google Code, SourceForge, etc). I see several benefits here - first, I don't have to worry about losing my code if my computer ...
<p><strong><a href="http://www.assembla.com/" rel="nofollow noreferrer">Assembla</a></strong> is <em>awesome.</em></p> <hr> <p>EDIT: Yes, this is a good idea - I used to use a personal copy of <a href="http://www.sourcegear.com/vault/" rel="nofollow noreferrer">Vault</a> and found it was more than I cared to manage (...
<p>Online backup is cheap and easy. Why would you not?</p>
5,361
<p>What choices do I have for creating stateful dynamic content in an ASP.Net web site?</p> <p>Here's my scenario. I have a site that has multiple, nested content regions. The top level are actions tied to a functional area <code>Catalog</code>, <code>Subscriptions</code>, <code>Settings</code>.</p> <p>When you cli...
<p>Controls that are added dynamically do not persist in viewstate, and this is the reason that it doesn't matter if you use AJAX or iframes or whatever.</p> <p>One possible work-around is to re-populate controls on postback. The problem with this, is the page life-cycle (simplified) is:</p> <ol> <li>Initialize <ul>...
<p>you've got a number of different options, and yes, IFrames were a bad design choice. </p> <p>The first option is the AJAX solution. And with that there's not really a viewstate scenario, it's just you're passing data back and forth with the webserver, building the UI on the fly as needed.</p> <p>The next option is...
15,180
<p>As a newbie I'm trying to implement a sorting function in C++, using the list-class. However, running the code I get the error that the list iterator is not incrementable... However it seems very unlikely as it should be incrementable!</p> <p>code: </p> <pre><code>void shuffle (list&lt;int&gt; &amp;list1) { l...
<p>Your call to list1.pop_front() removes the element which the iterator is pointing to initially, invalidating it. And an invalid iterator can not be incremented. :)</p> <p>It took a few minutes to find with the debugger. Just keep an eye on the value of 'it' as you step through the program. I don't know if you know ...
<p>I was also able to compile the posted code with VS2008 after I commented out the calls to print() and added the following to the beginning:</p> <pre><code>#include &lt;list&gt; using namespace std; </code></pre>
43,459
<p>What are good ways to handle user input concurrency?</p> <p>As the answers to <a href="https://stackoverflow.com/questions/225625/locking-to-handle-concurrency-a-good-idea">this question</a> already rule out database locking, how do you handle concurrent user inputs in general?</p> <p>Is locking always a bad idea,...
<p>Best strategy depends on what <em>should</em> happen from (business) process perspective - also important questions are what users would normally expect and what would surprise them least, and, of course, whether it is feasible to implement what they expect.</p> <p>Your example of editing a file <strong>over web</s...
<p>Look for how to handle "transactions" in whatever language/database API you are using. If you design these correctly it will handle it for you.</p> <p>And to understand the theory, I'd recommend <a href="http://www.amazon.co.uk/Distributed-Systems-Concepts-International-Computer/dp/0321263545/ref=sr_1_1?ie=UTF8&amp...
39,718
<p>In a .NET project, say you have a configuration setting - like a connection string - stored in a app.config file, which is different for each developer on your team (they may be using a local SQL Server, or a specific server instance, or using a remote server, etc). </p> <p>How can you structure your solution so th...
<p>AppSettings can be overridden with a local file:</p> <pre><code>&lt;appSettings file="localoveride.config"/&gt; </code></pre> <p>This allows for each developer to keep their own local settings.</p> <p>As far as the connection string, in a perfect world all developers should connect to a test DB, not run SQL Serve...
<p>I always make templates for my config files. </p> <p>As an example I use NAnt for the building of my projects. I have a file checked in called local.properties.xml.template. My NAnt build will warn the developer if local.properties.xml does not exist. Inside that file will be workstation specific settings. The temp...
3,980
<p>I am building a small website for fun/learning using a fairly standard Web/Service/Data Access layered design.</p> <p>To save me from constantly having to create instances of my service layer/data access layer classes, I have made the methods in them all static. I shouldn't get concurrency issues as they use local ...
<p>Disadvantages:</p> <ul> <li>You will be unable to write unit tests as you will be unable to write mock data access/business logic objects to test against.</li> <li>You will have concurrency problems as different threads try to access the static code at the same time - or if you use synchronized static methods you w...
<p>I would think that you will have concurrency issues with all static methods with multiple users. The web layer will thread out concurrent users. Can all your static methods handle this? Perhaps, but won't they constantly be locked in queuing the requests in single file? I'm not sure, never tried your idea.</p>
14,948
<p>I have a rather complex page that dynamically builds user controls inside of a repeater. This repeater must be bound during the Init page event before <code>ViewState</code> is initialized or the dynamically created user controls will not retain their state.</p> <p>This creates an interesting Catch-22 because the o...
<p>The LoadViewState method on the page is definitely the answer. Here's the general idea:</p> <pre><code>protected override void LoadViewState( object savedState ) { var savedStateArray = (object[])savedState; // Get repeaterData from view state before the normal view state restoration occurs. repeaterData = s...
<p>1) there's probably a way to get it to work... you just have to make sure to add your controls to the tree at the right moment. Too soon and you don't get ViewState. Too late and you don't get ViewState.</p> <p>2) If you can't figure it out, maybe you can turn off viewstate for the hole page and then rely only...
6,699
<p>As anyone with an iPhone knows, some applications launch quickly, while others take several seconds.</p> <p>What are the best techniques for ensuring an iPhone app launches and becomes usable in a snappy manner?</p>
<p>Apple recommends you "lazy load" every view. I.e. only load the first page on start up, and other pages only when they are navigated to.</p> <p>In terms of graphics, use PNGs wherever possible as the device is heavily optimized for this format. </p> <p>Also include the startup screenshot so the user knows the appl...
<p>This is one of those things where there is no sure-fire path to success. Use Apple's excellent Instruments tool to monitor your application's launch. You then need to delve into the results to figure out ways to optimise the launch process.</p>
40,949
<p>I am developing an Asp.net mvc application, everything works fine in ASP.net development server but when I am trying to host it on IIS 7. I am getting problem related to URL resolution. I have used relative paths in Javascript to give the image. The script file is in ~/Scripts/ folder and image files are in ~/Conten...
<p>If how I'm reading this is correct, you're now running the WebApp from the domain root of IIS7 now instead of WebApp1 from your development environment?</p> <p>So, if my assumption is correct, then <strong><em>~/</em></strong> should now resolve to <strong><em><a href="http://localhost/" rel="nofollow noreferrer">h...
<p>I have had this issue in the past, try using tilde</p> <blockquote> <p>~/controller1/action1/</p> </blockquote>
44,506
<p>I have a shell script which copies a few files to the current directory, compresses them, and streams the compressed file to stdout.</p> <p>On the client side I use plink to execute the script and stream stdin to a file.</p> <p>This almost works.</p> <p>It seems that the cp command outputs the file name being cop...
<p>It's not cp, it's tar. You are passing it -v, which makes it print the names of the files.</p>
<p>As others pointed out, the -v (verbose) option to tar is kicking out the file names to STDERR. You can also make your script more efficient by having tar write the compressed file stream to STDOUT:</p> <pre><code>tar zcf - file1 file2 file3 </code></pre> <p>In this example, the "-" option passed as the filename m...
34,064
<p>Here is a simple scenario with table characters:</p> <pre><code>CharacterName GameTime Gold Live Foo 10 100 3 Foo 20 100 2 Foo 30 95 2 </code></pre> <p>How do I get this output for the query <code>SELECT Gold, Live FROM characters WHERE name = 'Foo' ORDER BY GameTime</code>:</p> <pre><code>Gold Live 100 3 0 -1 ...
<p>Do you have an ID on your Table.</p> <pre><code>GameID CharacterName GameTime Gold Live ----------- ------------- ----------- ----------- ----------- 1 Foo 10 100 3 2 Foo 20 100 2 3 Foo 30 95 ...
<p>Do you have an ID on your Table.</p> <pre><code>GameID CharacterName GameTime Gold Live ----------- ------------- ----------- ----------- ----------- 1 Foo 10 100 3 2 Foo 20 100 2 3 Foo 30 95 ...
32,093
<p>I have only just found out about DB2 Express. I had a quick look and was unable to find a load of information about it but would be interested in hearing how people have found it compared to SQL Server Express (particularly 2008) in terms of</p> <ol> <li>Ease of deployment </li> <li>Ease of use and development too...
<p>I assume that you are talking about the Express-C edition of DB2 (which is not the samme as DB2 Express).</p> <p>1,2: If you are generally working on a Windows platform (dev tools, backend+frontend, ...), you will find MSSQL easier to deploy and use. And in general, MSSQL is probably a bit easier to deploy than DB2...
<p>I assume that you are talking about the Express-C edition of DB2 (which is not the samme as DB2 Express).</p> <p>1,2: If you are generally working on a Windows platform (dev tools, backend+frontend, ...), you will find MSSQL easier to deploy and use. And in general, MSSQL is probably a bit easier to deploy than DB2...
40,820
<p>I use a non-default Windows colour scheme on most of my machines, and have a laptop with a 124 DPI screen, which Windows is set to.</p> <p>A lot of programs I tested or even use daily seem to have problems with that, showing for example non-standard sizes of controls, cut-off UI elements, unreadable text and so on....
<p>I definitely don't. It costs time that I prefer spending on improving the experience of many rather than the few who use non-standard windows settings. A few things I usually do, which should still fix some of these issues:</p> <ul> <li>use clWindows etc. because that's the standard for Delphi controls anyway, so w...
<p>I occasionally test it myself for large fonts, because my Vista laptop is set to Large Fonts. Colors, not so much, but I rarely specify colors on controls.</p> <p>However, proper resizing is pretty hard. I usually set Forms scale to false, so as that they won't resize wrong.</p> <p>There are a few tools for auto-r...
37,215
<p>Is the F# is the future of programming languages? Is it right time to learn F# ? Any other languages in the market which is equivalent to F#?</p>
<p>F# is a general-purpose, object-oriented <em>functional</em> language and there isn't anything about it that's specifically designed for domain-specific languages, although you can probably easily create a DSL within F#. </p> <p>If you're really interested in learning something like F#, then now is the right time. ...
<p>As F# is basically "Functional Programming for .Net" there are a number of similar (and possibly more mature languages) such as:</p> <ul> <li><a href="http://www.scala-lang.org/" rel="nofollow noreferrer">Scala</a>: Functional programming on the JVM.</li> <li><a href="http://www.haskell.org/" rel="nofollow noreferr...
24,385
<p>I have an datetime object that I want to remove one hour to display the corect time in a different time zone. I am using datetime.addhours(-1) with the -1 being a config value. This works in most cases except when I set the time to 12:59 AM today it displays 11:59 AM today. When it should display 11:59 PM. Is it p...
<p>How about using the Subtract function:</p> <pre><code>DateTime.Now.Subtract(new TimeSpan(1, 0, 0)); </code></pre>
<p>I notice you didn't specify which framework version you are using. If you are using 2.0 SP1, 3.0 SP1, or 3.5 SP1 you might want to use the <a href="http://msdn.microsoft.com/en-us/library/system.datetimeoffset.aspx" rel="nofollow noreferrer">DateTimeOffset</a> structure instead. Then you would simply specify the T...
49,174
<p>My junk mail folder has been filling up with messages composed in what appears to be the Cyrillic alphabet. If a message body or a message subject is in Cyrillic, I want to permanently delete it.</p> <p>On my screen I see Cyrillic characters, but when I iterate through the messages in VBA within Outlook, the "Subje...
<p>The <code>String</code> datatype in VB/VBA can handle Unicode characters, but the IDE itself has trouble displaying them (hence the question marks). </p> <p>I wrote an <code>IsCyrillic</code> function that might help you out. The function takes a single <code>String</code> argument and returns <code>True</code> if ...
<blockquote> <p>the "Subject" property of the message returns a bunch of question marks.</p> </blockquote> <p>A classic string encoding problem. Sounds like that property is returning ASCII but you want UTF-8 or Unicode.</p>
25,323
<p>I have a logging table which has three columns. One column is a unique identifier, One Column is called "Name" and the other is "Status".<br> Values in the Name column can repeat so that you might see Name "Joe" in multiple rows. Name "Joe" might have a row with a status "open", another row with a status "closed",...
<p>I would create a second table named something like "Status_Precedence", with rows like:</p> <pre><code>Status | Order --------------- Closed | 1 Hold | 2 Waiting | 3 Open | 4 </code></pre> <p>In your query of the other table, do a join to this table (on <code>Status_Precedence.Status</code>) and then y...
<p>I ended up using matt b's solution and using this final query to filter out the lower ranked (lower bing higher numbered).</p> <pre><code>SELECT * from [TABLE] tb LEFT JOIN Status_Precedence sp ON tb.Status = sp.Status WHERE sp.Rank = (SELECT MIN(sp2.rank) FROM[Table] tb2 LEFT JOIN Statu...
45,531