instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I'm using BlogEngine.NET (a fine, fine tool) and I was playing with the TinyMCE editor and noticed that there's a place for me to create a list of external links, but it has to be a javascript file:</p> <p><code>external_link_list_url : "example_link_list.js"</code></p> <p>this is great, of course, but the list of...
<p>I would create an HTTPHandler that responds with the desired data read from the db. Just associate the HTTPHandler with the particular filename 'example_link_list.js' in your web-config. Make sure you set </p> <pre><code>context.Response.ContentType = "text/javascript"; </code></pre> <p>then just context.Response....
<p>If you can't change the file extension (and just return plain text, the caller shouldn't care about the file extension, js is plain text) then you can set up a handler on IIS (assuming it's IIS) to handle javascript files.</p> <p>See this link - <a href="http://msdn.microsoft.com/en-us/library/bb515343.aspx" rel="n...
9,357
<p>Can I have multiple primary keys in a single table?</p>
<p>A Table can have a <strong>Composite Primary Key</strong> which is a primary key made from two or more columns. For example:</p> <pre><code>CREATE TABLE userdata ( userid INT, userdataid INT, info char(200), primary key (userid, userdataid) ); </code></pre> <p><strong>Update:</strong> <a href="http://weblo...
<p>Yes, Its possible in SQL, but we can't set more than one primary keys in MsAccess. Then, I don't know about the other databases.</p> <pre><code>CREATE TABLE CHAPTER ( BOOK_ISBN VARCHAR(50) NOT NULL, IDX INT NOT NULL, TITLE VARCHAR(100) NOT NULL, NUM_OF_PAGES INT, PRIMARY KEY (BOOK_ISBN, IDX) ); ...
26,798
<p>I'm trying to consolidate some build information by using a common makefile. My problem is that I want to use that makefile from different subdirectory levels, which makes the working directory value (<code>pwd</code>) unpredictable. For example:</p> <pre><code># Makefile.common TOP := $(shell pwd) COMPONENT_DIR :=...
<p>You should be able to use the <a href="http://www.gnu.org/software/make/manual/html_node/Special-Variables.html#Special-Variables" rel="noreferrer">MAKEFILE_LIST variable</a>, like this:</p> <pre><code># This must be the first line in Makefile.common TOP := $(dir $(firstword $(MAKEFILE_LIST))) </code></pre> <p>Fro...
<p>Have you tried doing:</p> <pre><code># Makefile.common TOP ?= $(shell pwd) COMPONENT_DIR := $(TOP)/component COMPONENT_INC := $(COMPONENT_DIR)/include COMPONENT_LIB := $(COMPONENT_DIR)/libcomponent.a # other_component/Makefile TOP ?= .. include ../Makefile.common </code></pre> <p>Using the ?= construct will keep ...
41,796
<p>For a science project, I'm 3D-printing some custom pipes and tubes to regulate the flow of gas (a combination of ethyl alcohol and water vapor) through an apparatus. They need to be pretty small, as the entire experiment is designed on a small scale. I'd also like the use a little filament as possible.</p> <p>How t...
<p>The thinnest wall your printer can print is determined by its nozzle size, and will be a little thicker than that nozzle size.</p> <p>A great challenge when dealing with thin, hollow cylinders is that the cross-section has very little surface area and it can delaminate easily, especially if the tube is long.</p> <...
<p>This is difficult to give a definitive answer, but I have some thoughts.</p> <p>For a vertical wall, the minimum thickness is determined by your nozzle size, typically 0.4mm. If you are able to print entirely in a vertical orientation (a pipe standing on end), you may consider using "vase mode" with no top or botto...
135
<p>I've got a WCF service that uses a LinqToSql DataContext to fetch some information out of a database. The return type of the operation is IEnumerable<code>&lt;DomainObject</code>>, and I have a helper method that converts from the Table-derived LINQ object to a WCF data contract like so:</p> <pre><code>[OperationCo...
<p>WCF does seem, at least in my experience, to do some magic with exceptions. I'm really not sure what it does with exceptions but I've found that if the FaultContract attribute is used to specify exceptions that the contract could throw, it'll at least give a bit more information to the client about the why the error...
<p>Did you configure your "<a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.description.servicedebugbehavior.includeexceptiondetailinfaults.aspx" rel="nofollow noreferrer">IncludeExceptionDetailInFaults</a>" settings? (it defaults to 'false' for security purposes).</p>
32,707
<p>I am trying to create a DLL for authentication using Java and JNI.</p> <p>To create the DLL, I have created a Win32 application whose Character Set and Runtime Library information are Multi-Byte String and Multi-threaded (/MT) respectively.</p> <p>I have tested the DLL on WinXP with valid and invalid user credenti...
<p>It is useful when you want to have access to some members of the base class, but without exposing them in your class interface. Private inheritance can also be seen as some kind of composition: the <a href="http://www.parashift.com/c++-faq-lite/private-inheritance.html" rel="noreferrer">C++ faq-lite</a> gives the fo...
<p>I once implemented these data structures as classes:</p> <ul> <li>Linked list</li> <li>Generic array (abstract)</li> <li>Simple array (inherits from generic array)</li> <li>Big array (inherits from generic array)</li> </ul> <p>The big array's interface would make it look like an array, however, it was actually a l...
48,961
<p>I've got an array of <code>char*</code> in a file. The company I work for stores data in flat files.. Sometimes the data is sorted, but sometimes it's not. I'd like to sort the data in the files.</p> <p>Now I could write the code to do this, from scratch. Is there an easier way? </p> <p>Of course an in-place so...
<pre><code>template&lt;size_t length&gt; int less(const char* left, const char* right) { return memcmp(left, right, length) &lt; 0; } std::sort(array, array + array_length, less&lt;buffer_length&gt;); </code></pre>
<p>The canonical way to sort an array of character strings in C, and therefore an available but not necessarily recommended way to do so in C++, uses a level of indirection to <code>strcmp()</code>:</p> <pre><code>static int qsort_strcmp(const void *v1, const void *v2) { const char *s1 = *(char * const *)v1; c...
40,579
<p>I am working with an existing code base made up of some COM interfaces written in C++ with a C# front end. There is some new functionality that needs to be added, so I'm having to modify the COM portions. In one particular case, I need to pass an array (allocated from C#) to the component to be filled.</p> <p>What I...
<p>Hmmm... I've found some information that gets me closer...</p> <p><a href="http://msdn.microsoft.com/en-us/library/ek1fb3c6.aspx#cpconeditingmicrosoftintermediatelanguagemsilanchor1" rel="nofollow noreferrer">Marshaling Changes - Conformant C-Style Arrays</a></p> <p>This IDL declaration (C++)</p> <pre><code>HRESU...
<p>I don't know much about C# COM operability, but have you tried using SAFEARRAY(INT_PTR) or something similar?</p>
24,339
<p>Is a string actually a character array (is-a), or does it have a character array as an internal store (has-a), or is it's own object which can expose itself as a with an array of characters?</p> <p>I am more inclined to say it is it's own object, but then why are we so inclined to always say "A string is an array o...
<p>the .NET string is not just an array of characters. It contains an array of characters, so strictly speaking, it's has-a.</p> <p>Moreover, there are a lot of Unicode-related subtleties where it doesn't behave <em>anything</em> like an array. Concatenating a character may do a lot more than just increase the string ...
<p>In an abstract way (and I guess, when laid out in memory) - it is an array of characters.</p> <p>Correct me, if I am wrong in thinking that.</p>
46,595
<p>Is it safe to have 2 or more threads call the Win32 API's SetEvent on the same event handler not being protected by a critical section?</p>
<p>It's safe, but remember that if one thread Sets it, and another thread Sets it at the same time, you're not going to get two notifications, just one; since the 2nd one changed it from True to...True. If you're worried about this, use Semaphores instead.</p>
<p>Assuming you have multiple threads waiting on the same event, running the same code. </p> <ol> <li>If your code doesnt clear the event until its done processing, you effectively have a CS. Since the event remains signaled until it is cleared(aka not autoreset), having multiple threads signal the does nothing excep...
33,206
<p>I uploaded a 3D object for <a href="https://lerdagiovanni.wixsite.com/kauda/stl-files" rel="nofollow noreferrer">this project</a> to Fusion 360 and printed it out straightforward:</p> <p><a href="https://i.stack.imgur.com/BLeFU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BLeFU.png" alt="enter ...
<p>Besides offsetting the <strong>clearances</strong> you want into models, you can and should also calibrate your printer to <strong>compensate for included holes</strong> - because often inner holes are solved to be smaller than actually designed out of necessity.</p> <p>However, the option can <em>also</em> be used ...
<p>This seems like a tolerance press fit problem and similar to what you will find if you try the same using normal machining operations on a lathe or milling machine.</p> <p>I print 3 mm clearance fit holes on my Prusa MK3S, meant to fit on 3.00 mm (measured with a digital caliper) stainless steel shafts. The printed ...
1,890
<p>I want to be able to read from an unsorted source text file (one record in each line), and insert the line/record into a destination text file by specifying the line number where it should be inserted.</p> <p>Where to insert the line/record into the destination file will be determined by comparing the incoming line...
<p>The basic problem is that under common OSs, files are just streams of bytes. There is no concept of lines at the filesystem level. Those semantics have to be added as an additional layer on top of the OS provided facilities. Although I have never used it, I believe that VMS has a record oriented filesystem that wo...
<p>I think the question is more about implementation rather than specific algorithms, specifically, handling very large datasets.</p> <p>Suppose the source file has 2^32 lines of data. What would be an efficent way to sort the data.</p> <p>Here's how I'd do it:</p> <ol> <li><p>Parse the source file and extract the f...
39,342
<p>I'm building an application that is used by several different customers. Each customer has a fair amount of custom business logic, which I have cleverly refactored out into an assembly that gets loaded at runtime. The name of that assembly, along with a number of other customer-specific settings, are stored in the...
<p>A couple of people suggested using multiple VS configurations, which I think would have worked, except that it would require me to rebuild the solution every time I switched between configurations.</p> <p>What I did instead seemed a little stupid while I was doing it, but I've been using it for nearly a year now an...
<p>You may opt to define multiple Visual Studio solution configurations, one for each customer, and have customised MSBuild targets for your Windows app project.</p> <p>I have documented the steps of how I handled this here. <a href="http://icelava.net/forums/thread/2920.aspx" rel="nofollow noreferrer">Multiple app.co...
21,209
<p>I want to give Windows Server 2008 a try as a .NET developer and a database environment.</p> <p>I was wondering which configuration would be the most appropriate for the server in terms of:</p> <ul> <li><p><strong>Services:</strong> Which ones are unnecessary and can be turned off to increase performance?</p></li>...
<p>Actually a default install of Windows Server 2008 doesn't have many services running to start with. Just add the roles you need to test your projects.</p> <p>If you want to minimize the number of running services then you don't want to tweak the server into a workstation.</p>
<p>Don't activate Superfetch. It will load you disk with work for many long minutes each time the system starts.</p> <p>Don't add "Widows Resource Manager" feature, which sounds attractive from its description. It will bring permanent CPU load in the range of 8-12%.</p>
43,149
<p>I'm trying to use the giveio.sys driver which requires a "file" to be opened before you can access protected memory. I'm looking at a C example from WinAVR/AVRdude that uses the syntax:</p> <pre class="lang-c prettyprint-override"><code> #define DRIVERNAME "\\\\.\\giveio" HANDLE h = CreateFile(DRIVERNAME, ...
<p>Solution: in python you have to use win32file.CreateFile() instead of open(). Thanks everyone for telling me what I was trying to do, it helped me find the answer!</p>
<p>There are 2 ways to do this.</p> <p>The first way is using the win32 python bindings</p> <pre><code>h = win32file.CreateFile </code></pre> <p>Or using ctypes</p>
26,144
<p>I need to develop a small-medium sized desktop GUI application, preferably with Python as a language of choice because of time constraints.</p> <p>What GUI library choices do I have which allow me to redistribute my application standalone, assuming that the users don't have a working Python installation and obvious...
<p><a href="http://wiki.wxpython.org/CreatingStandaloneExecutables" rel="noreferrer">http://wiki.wxpython.org/CreatingStandaloneExecutables</a></p> <p>It shouldn't be that large unless you have managed to include the debug build of wx. I seem to rememebr about 4Mb for the python.dll and similair for wx.</p>
<p>I've used py2Exe myself - it's really easy (at least for small apps).</p>
18,599
<p>Let's say I'm writing a Library application for a publishing company who already has a People application.</p> <p>So in my Library application I have</p> <pre><code>class Person &lt; ActiveResource::Base self.site = "http://api.people.mypublisher.com/" end </code></pre> <p>and now I want to store <code>Article<...
<p>I suppose one possibility for #1, assuming I can get any of it working, is to do this:</p> <pre><code>class Person &lt; ActiveResource::Base self.site = "http://api.people.mypublisher.com/" def articles Article.find(:all, :conditions =&gt; { :person_id =&gt; self.id }) end def add_article(article) ...
<p>I think a better solution would be making a method that returns a scope.</p> <pre><code>class Person &lt; ActiveResource::Base self.site = .. . def articles Article.for_person(self.id) end end class Article &lt; ActiveRecord::Base named_scope :for_person, lambda { |pid| { :conditions =&gt; { :person_i...
22,203
<p>Today I had a discussion with a colleague about nested functions in Javascript:</p> <pre><code>function a() { function b() { alert('boo') } var c = 'Bound to local call object.' d = 'Bound to global object.' } </code></pre> <p>In this example, trials point out that b is not reachable outside the ...
<p>This is static scoping. Statements within a function are scoped within that function.</p> <p>Javascript has a quirky behavior, however, which is that without the <strong>var</strong> keyword, you've implied a <strong>global variable</strong>. That's what you're seeing in your test. Your &quot;d&quot; variable is ...
<p>...</p> <pre><code>function a() { function b() { alert('boo') } var c = 'Bound to local call object.' d = 'Bound to global object.' } </code></pre> <p>without being preceded by <em>var</em>, d is global. Do this to made d private:</p> <pre><code>function a() { function b() { alert('boo'...
29,132
<p>I am a member of all the roles (Browser, Content Manager, My Reports, Publisher, Report Builder). If I login with a Local Administrator account, I can see and use it fine. Any ideas?</p>
<p>The first thing I would check is to make sure that your normal login is mapped to a role with the correct system-level permissions. The item-level role definitions don't make a difference for the "Report Builder" button.</p> <p>From the browser-based report manager interface:</p> <ul> <li>Click "site settings"</l...
<p>Tried to do as was stated in the answer above. But didn't find "Configure system-level role definitions" as mentioned in the second bullet. Perhaps the interface has changed a little in the past 5 years.</p> <p>Assuming you already have a browser window open where you see the report manager without the [Report Buil...
6,154
<p>How are the java API thread priorities (1-10) gets translated to the OS level priorities since most OS don't have thread priority levels (in terms of number) which match this.</p> <p>So keeping in mind , can there be a scenario when two or more threads with different priorities eventually get the same priority at O...
<p>Indeed, some priority levels can map to the same "native" priority level. Here's the list (based on the Hotspot code in OpenJDK 6):</p> <h2>Solaris</h2> <ul> <li>1 ⇒ 0</li> <li>2 ⇒ 32</li> <li>3 ⇒ 64</li> <li>4 ⇒ 96</li> <li>5 – 10 ⇒ 127</li> </ul> <p>Of note is that on Solaris, you can't raise the thread priorit...
<p>Since we're talking about threads, I think that this never reaches the OS directly. The priority is probably a hint to the JRE on how to schedule CPU time each thread. To deal with your example, there needs to be some sort of 'tie-breaking' algorithm. </p> <p>Basically, this is going to be on-top of OS process prio...
38,111
<p>I am looking at starting a hosted CMS-like service for customers.</p> <p>As it would, it would require the customer to input text which would be served up to anyone that comes to visit their site. I am planning on using Markdown, possibly in combination with WMD (the live markdown preview that SO uses) for the big ...
<p>Why <strong>wouldn't</strong> you sanitize the input? </p> <p>If you don't, you're inviting calamity - to either your customer or yourself or both.</p>
<p>At least parse their entry an only allow a certain "safe" subset of HTML tags.</p>
21,226
<p>I have a problem creating a regular expression for the following task:</p> <p>Suppose we have HTML-like text of the kind:</p> <pre><code>&lt;x&gt;...&lt;y&gt;a&lt;/y&gt;...&lt;y&gt;b&lt;/y&gt;...&lt;/x&gt; </code></pre> <p>I want to get a collection of values inside <code>&lt;y&gt;&lt;/y&gt;</code> tags located i...
<p>This is a job for an <a href="http://htmlparsing.icenine.ca/" rel="nofollow noreferrer">HTML/XML parser</a>. You <em>could</em> do it with regular expressions, but it would be very messy. There are examples in the page I linked to.</p>
<p>It would help if we knew what language or tool you're using; there's a great deal of variation in syntax, semantics, and capabilities. Here's one way to do it in Java:</p> <pre><code>String str = "&lt;y&gt;c&lt;/y&gt;...&lt;x&gt;...&lt;y&gt;a&lt;/y&gt;...&lt;y&gt;b&lt;/y&gt;...&lt;/x&gt;...&lt;y&gt;d&lt;/y&gt;"; S...
44,247
<p>Scenario: You have an ASP.Net webpage that should display the next image in a series of images. If 1.jpg is currently loaded, the refresh should load 2.jpg.<br> Assuming I would use this code, where do you get the current images name.</p> <pre><code>string currImage = MainPic.ImageUrl.Replace(".jpg", ""); currIma...
<pre><code>int num = 1; if(Session["ImageNumber"] != null) { num = Convert.ToInt32(Session["ImageNumber"]) + 1; } Session["ImageNumber"] = num; </code></pre>
<p>You'll have to hide the last value in a HiddenField or ViewState or somewhere like that...</p>
6,655
<p>Why can't I pass the table name to a prepared PDO statement?</p> <pre><code>$stmt = $dbh-&gt;prepare('SELECT * FROM :table WHERE 1'); if ($stmt-&gt;execute(array(':table' =&gt; 'users'))) { var_dump($stmt-&gt;fetchAll()); } </code></pre> <p>Is there another safe way to insert a table name into a SQL query? Wit...
<p><strong>Table and Column names CANNOT be replaced by parameters in PDO.</strong></p> <p>In that case you will simply want to filter and sanitize the data manually. One way to do this is to pass in shorthand parameters to the function that will execute the query dynamically and then use a <code>switch()</code> state...
<p>Short answer is NO you cannot use dynamic table name, field names, etc in the Prepared execute statement with PDO because it adds quotes to them which will break the query. But if you can sanitize them, then you can safely plop them right in the query itself just like you would with MySQLi anyway.</p> <p>The corre...
22,030
<p>What do you think is a good IDE for learning SmallTalk? I'll only be using it as a hobby, so it has to be free.</p>
<p>I think <a href="http://www.squeak.org/" rel="noreferrer">Squeak</a> is the way to go. It has an entire smalltalk environment and is constantly updated. Its what I used for learning and is actually even a cool app in itself.</p>
<p><a href="http://www.exept.de/en/products/smalltalk-x/stx-overview" rel="nofollow noreferrer">Smalltalk/X</a> came up on Reddit the other day. It looked pretty good.</p>
16,272
<p>I've managed to get a memory 'leak' in a java application I'm developing. When running my JUnit test suite I randomly get out of memory exceptions (java.lang.OutOfMemoryError).</p> <p>What tools can I use to examine the heap of my java application to see what's using up all my heap so that I can work out what's kee...
<p>VisualVM is included in the most recent releases of Java. You can use this to create a heap dump, and look at the objects in it.</p> <p>Alternatively, you can also create a heapdump commandine using jmap (in your jdk/bin dir):</p> <pre><code>jmap -dump:format=b,file=heap.bin &lt;pid&gt; </code></pre> <p>You can e...
<p>If you're using a system which supports GTK you could try using <a href="http://www.khelekore.org/jmp/" rel="nofollow noreferrer">JMP</a>.</p>
17,590
<p>I'm new to 3D printing. I modeled an empty bird in Blender (the stl file of model is presented). I tested the model in Blender (using 3D printing tool) and also the Netfabb software. They don't show any error. However, when I load this model in Ultimaker Cura for printing, as shown in the last image, the result is o...
<p>You have modeled your bird. So far so good, but you likely only modeled a single surface and not a closed surface body. The crucial step was forgotten, as your pictures 1 and 2 show: you have designed a single surface for most of the object, not a body. To turn the bird into a printable object needs it not to be a s...
<p>Slicers don't do well with &quot;empty&quot; (hollow) bodies, or bodies with secret holes in it. You need to supply a filled body<sup>1</sup>, the slicer will make it mostly empty anyways (depending on the infill percentage). Also, you need to have infill, else the top cannot be printed as it does not have any suppo...
1,386
<p>What is the easiest way to find out how much memory an object uses in .NET?</p> <p>Preferably without having to resort to a third party tool. Marshal.SizeOf or the sizeof operator look useful but only work with a restricted range of types.</p> <p>Some related posts:</p> <ul> <li><a href="https://stackoverflow.co...
<p>Asked and answered here: <a href="https://stackoverflow.com/questions/51540/determine-how-much-memory-a-class-uses#51895">Determine how much memory a class uses?</a></p> <p>The quick summary is that if you don't want to use a tool, you need to use the <a href="http://msdn.microsoft.com/en-us/library/ms404386.aspx" ...
<p>Because of .NET's garbage-collected nature, it's somewhat difficult to measure how much memory is really being used. If you want to measure the size of a class instance, for example, does it include the memory used by instances that your instance points to?</p> <p><strong>If the answer is no</strong>, add up the s...
18,741
<p>What is the difference between </p> <ol> <li>a parameter passed by reference</li> <li>a parameter passed by value?</li> </ol> <p>Could you give me some examples, please?</p>
<p>First and foremost, <strong>the &quot;pass by value vs. pass by reference&quot; distinction as defined in the CS theory is now obsolete</strong> because <strong>the technique originally defined as &quot;pass by reference&quot; has since fallen out of favor</strong> and is seldom used now.<sup>1</sup></p> <p><strong...
<p> Here is an example that demonstrates the differences between <strong>pass by value - pointer value - reference</strong>:</p> <pre class="lang-cpp prettyprint-override"><code>void swap_by_value(int a, int b){ int temp; temp = a; a = b; b = temp; } void swap_by_pointer(int *a, int *b){ int te...
48,840
<p>I am trying to create a custom accordion for my page to that display my posts. I have it in list format using HTML and I am trying to create an effect when you click each header to expand to show more information.</p> <p>But I don't want to have say six blocks of code for six of the <code>&lt;li&gt;</code> elements...
<p>Did you take a look at <a href="http://roshanbh.com.np/2008/03/expandable-collapsible-toggle-pane-jquery.html" rel="nofollow noreferrer">this tutorial</a> ?</p> <p>Because, as this <a href="http://roshanbh.com.np/examples/exapandable-panel/" rel="nofollow noreferrer">example illustrates</a>, one does not need multi...
<p>Check this also pretty simple Demo : <a href="http://demos.pankaj.pro/jquery-tutorial-guide-to-build-a-simple-accordion/" rel="nofollow">http://demos.pankaj.pro/jquery-tutorial-guide-to-build-a-simple-accordion/</a></p> <p>code <a href="http://time2hack.com/2013/01/jquery-tutorial-guide-to-build-a-custom-and-simple...
40,203
<p>I have a website (ASP.NET) and some winforms(.Net 2.0) for a project (written in C#). I use the webservice (IIS6) for task that both require like sending email inside the business. </p> <p>I think Webservice is nice but I would like <strong>from your experience</strong> what should and what should not be in a webse...
<p>In My Opinion:</p> <p>Web services should be reserved for code that</p> <ol> <li>You either can't or don't want to distribute; or,</li> <li>code that needs to seriously scale up.</li> </ol> <p>One example is custom business logic that multiple applications need access to. </p> <p>Code you don't want to put into...
<p>It seems like the new trend for web services/SOA is to more or less expose a light-weight middle tier that your host application can use. Instead of having individual method calls exposed through a service (as in your example), SOA-oriented applications have extensive Data/Operation contracts that act as the "tradit...
15,088
<p>Can VBA code instantiate and use .NET objects? The specific class I'm interested in is System.IO.Compression.GZipStream.</p> <p><strong>For Info</strong> GAC is the .NET Global Assembly Cache</p>
<p>I think Andy nailed this answer, but I'm not certain that the aspect regarding the CLR loading rules is exactly right. </p> <p>The .NET Assembly that holds the class acting as the wrapper for GZipStream would be exposed to COM and registered just like any other COM project library and class. In this regard, VBA wou...
<p>VBA can make use of any .NET objects that are exposed to COM. I don't know if GZipStream is or not, but I would guess that it would be easier for you to create a separate .NET object that is a wrapper around the functionality of GZipStream that you want to use. You can then expose your object to COM, and then VBA sh...
21,640
<p>How do I declare "as any" in VB.NET, or what is the equivalent?</p>
<p>The closest you can get is:</p> <p><code>Dim var as Object</code></p> <p>It's not exactly the same as VB6's as Any (which stores values in a Variant) but you can store variables of any type as Object, albeit boxed.</p>
<p><a href="http://en.wikipedia.org/wiki/Visual_Basic_.NET" rel="nofollow noreferrer">VB.NET</a> doesn't support the "As Any" keyword. You'll need to explicitly specify the type.</p>
9,559
<p>I have a select element in a form, and I want to display something only if the dropdown is not visible. Things I have tried:</p> <ul> <li>Watching for click events, where odd clicks mean the dropdown is visible and even clicks mean the dropdown isn't. Misses other ways the dropdown could disappear (pressing escap...
<p>Conditional-content, which is what you're asking about, isn't that difficult. The in the following example, I'll use <a href="http://www.jquery.com" rel="nofollow noreferrer">jQuery</a> to accomplish our goal:</p> <pre><code>&lt;select id="theSelectId"&gt; &lt;option value="dogs"&gt;Dogs&lt;/option&gt; &lt;opti...
<p>Keep track of the state using a JavaScript varialbe. We'll call it "openX".</p> <p>onfocus="openX=true" onblur="openX=false" onchange="openX=false"</p>
17,093
<p>I'm running MySQL 5 on a linux server on my local network. Running windows XP for my desktop. Had a look at the <a href="http://dev.mysql.com/downloads/gui-tools/5.0.html" rel="nofollow noreferrer">MySQL GUI Tools</a> but I dont think they help. I cannot install apache on the remote server &amp; use something like...
<p>I use <a href="http://www.webyog.com/" rel="nofollow noreferrer">SQLyog</a> on my Windows system which has a free Community Edition and has an option to import from CSV.</p> <p>I've never used this option myself so I can't tell you how good it is. However, SQLyog has been great for all the other things I've used i...
<p>Write a simple Python script that parses the CSV and inserts it into the table.</p> <p>Look at the <b>csv</b> and <b>mysqldb</b> module.</p>
18,998
<p>I want to add all the files in the current directory to git:</p> <pre><code>git add . error: open(".mysql_history"): Permission denied fatal: unable to index file .mysql_history </code></pre> <p>That's fine. That file happens to be in this directory and owned by root. I want to add all <em>other</em> files. Is th...
<p>Use <code>git add --ignore-errors .</code></p> <p>This will still give an error for the unreadable file(s), but not a fatal one. The other files will be added.</p>
<p>Restarting system (Windows) solving my problem.</p>
46,454
<p>Is there any way to list all the files that have changed between two tags in CVS?</p> <p>Every time we do a release we apply a tag to all the files in that release. I want to find all the files that changed between releases.</p> <p>It would also work if I could find all files that had changed between two dates.</p...
<p>I suppose this command would help:</p> <pre><code>cvs diff -N -c -r RELEASE_1_0 -r RELEASE_1_1 &gt; diffs </code></pre> <p>where <code>RELEASE_1_0</code> and <code>RELEASE_1_1</code> are the names of your tags.</p> <p>You can find a little more information on cvs diff command <a href="http://www.network-theory.co...
<p>The best tool I've found for this is a perl script called <a href="http://www.red-bean.com/cvs2cl/" rel="nofollow noreferrer">cvs2cl.pl</a>. This can generate a change list in several different formats. It has many different options, but I've used the tag-to-tag options like this:</p> <pre><code>cvs2cl.pl --delt...
16,904
<p>just wondering if anyone knows of a truly restful Put/delete implementation asp.net mvc preview 5 preferably.</p>
<p>Check out the mvccontrib project at <a href="http://www.mvccontrib.org" rel="nofollow noreferrer">http://www.mvccontrib.org</a>. In the source code a restful implementation has been added and it is current up to Preview 5. Check out the source code here - <a href="http://mvccontrib.googlecode.com/svn/trunk/src/MVCC...
<p>I don't know of one off the top of my head, but you might look into the way that Rails handles it if you don't find anything else, and try porting it over. Rails utilizes POST, GET, PUT, and DELETE, but it apparently has to do some fakery for PUT. Could be worth looking into if you come up dry here.</p>
6,881
<p>If you have a site which sends out emails to the customer, and you want to save a copy of the mail, what is an effective strategy?</p> <p>If you save it to a table in your database (e.g. create a table called Mail), it gets very large very quickly.</p> <p>Some strategies I've seen are:</p> <ol> <li>Save it to the...
<p>I don't agree that gmail is an effective backup for business data.</p> <p>Why trust your business information to a provider who makes no guarantees of service, or over who you have no control whatsoever?</p> <p>Makes no sense to me.</p> <p>Depending on how frequently you need to access this information, I'd say g...
<p>We save the email to a database table. It really doesn't get that big that quickly. We've a table with 32,000 emails in it (they're biggish emails too @ 50kb per email) and with compression, the file only uses 16MB. </p> <p>If you're sending a shed load of email, then know that GMail(free) currently only allows 7GB...
7,462
<p>I have a solution of mixed VB.NET and C++ projects. When using Visual Studio 2005 you can set the "Tools->Option->Projects and Solutions->VC++ Directories" to help the compiler find your include files. When building the same solution with MSBuild I don't see how to pass these settings. The C++ won't compile without ...
<p>To set the include directories, you can add them into your INCLUDE environment variable. You use the same format as in PATH env. variable - you separate paths with semicolons.</p> <p>To set the library directories - you can do it in similar way, by putting them into your LIB environment variable.</p> <p>To set env...
<p>...and also you may like to append %INCLUDE% and %LIB% to your variables to avoid overwriting of them</p> <pre><code>set INCLUDE=C:\Libraries\LibA\Include;%INCLUDE% set LIB=C:\Libraries\LibA\Lib\x86;%LIB% </code></pre>
43,177
<p>I have a bit of code where I am looping through all the select boxes on a page and binding a <code>.hover</code> event to them to do a bit of twiddling with their width on <code>mouse on/off</code>.</p> <p>This happens on page ready and works just fine.</p> <p>The problem I have is that any select boxes I add via ...
<p><strong>As of jQuery 1.7</strong> you should use <a href="https://api.jquery.com/on/#on-events-selector-data-handler" rel="noreferrer"><code>jQuery.fn.on</code></a> with the selector parameter filled:</p> <pre><code>$(staticAncestors).on(eventName, dynamicChild, function() {}); </code></pre> <p><em>Explanation:</em>...
<p>I was looking a solution to get <code>$.bind</code> and <code>$.unbind</code> working without problems in dynamically added elements. </p> <p>As <a href="http://api.jquery.com/on/" rel="nofollow noreferrer">on()</a> makes the trick to attach events, in order to create a fake unbind on those I came to:</p> <pre><c...
24,859
<p>I want to test ASP.NET applications to get the feel for the MVC extension and compare that to what I can do today with Grails or Rails. The trouble is that being in a corporate environment, I can't install IIS on my workstation, neither on my DEV server. And - you guessed it - Visual Studio is not to be considered a...
<p><a href="http://en.wikipedia.org/wiki/UltiDev_Cassini_Web_Server" rel="nofollow noreferrer">UltiDev Cassini Web Server</a></p>
<p>UltiDev recently started shipping test builds of the Cassini replacement - <a href="http://ultidev.com/Forums/yaf_postsm2726_Welcome-to-UltiDev-Web-Server-Pro.aspx" rel="nofollow">UltiDev Web Server Pro</a>. It requires elevated/admin privileges to be installed, but it can be downloaded for free. It's quite advanced...
14,563
<p>Object-relational mapping has been well discussed, including on here. I have experience with a few approaches and the pitfalls and compromises. True resolution seems like it requires changes to the OO or relational models themselves.</p> <p>If using a functional language, does the same problem present itself? It...
<p>The hard problems of extending the relational database are extended transactions, data-type mismatches, automated query translation and things like <a href="http://ayende.com/Blog/archive/2006/05/02/CombatingTheSelectN1ProblemInNHibernate.aspx" rel="noreferrer">N+1 Select</a> that are fundamental problems of leaving...
<p>Being functional and being OO are two orthogonal concepts. The issue of mapping flat tables to trees of objects is orthogonal to Functional vs Imperative.</p> <p>However, functional vs imperative does solve <em>one particular mismatch</em>, namely the mismatch between imperative updates and MVCC. In imperative progr...
26,846
<p>I'm working on an embedded linux system in C, I'm looking for the source code to the equivalet of SendARP in Windows. Any pointers?</p>
<p>Take a look at <a href="http://freshmeat.net/projects/arping/" rel="nofollow noreferrer">arping</a>. The quick and dirty way of sending an arp would be to do:</p> <pre><code> foo = system("/somepath/arping somehost"); </code></pre> <p>But a look through the arping source should be able to give you a better solutio...
<p>This may be of interest: <a href="http://cvs.linux-ha.org/viewcvs/viewcvs.cgi/linux-ha/resources/heartbeat/SendArp.in?rev=1.4" rel="nofollow noreferrer">http://cvs.linux-ha.org/viewcvs/viewcvs.cgi/linux-ha/resources/heartbeat/SendArp.in?rev=1.4</a></p> <p>It is an implmenetation in a Bourne Shell script.</p>
16,512
<p>Having some Geometry data and a Transform how can the transform be applied to the Geometry to get a new Geometry with it's data transformed ?</p> <p>Ex: I Have a Path object that has it's Path.Data set to a PathGeometry object, I want to tranform <strong>the points</strong> of the PathGeometry object <strong>in pla...
<p>You could try and use Geometry.Combine. It applies a transform during the combine. One catch is that Combine only works if your Geometry has area, so single lines will not work.</p> <p>Here is a sample that worked for me.</p> <pre><code>PathGeometry geometry = new PathGeometry(); geometry.Figures.Add(new PathFigur...
<p>There are two things you have to consider:</p> <ol> <li>Geometry inherits from Freezable, you can't modify the geometry object in-place if it's frozen.</li> <li>You can scan the PathGeometry list of figures and segments and transform all the points in them but some types, like ArcSegment includes sizes and angles, ...
31,093
<p>I have problems with layer widths and uneven outer walls on my 3D prints. Sometimes layers are squeezed and sometimes pushed outside. I noticed that these problems happen when there are retractions on layers. I don't have problems with round and simple objects without changes on layers or where all layers are identi...
<p>You can do this provided the part releases consistently after cooling. Your filament choice may cause problems, though. ABS is prone to warping and a fan constantly blowing on the part would make it worse. The second thing to consider would be the release agent. I assume you are using gluestick or something similar ...
<p>In theory you could knock the item off the build plate and into a bin by positioning the print head behind the part and then pushing.</p> <p>However your build plate would need to have a smooth front edge, so no clips in the way.</p> <p>You'd also want to have some delay to let the bed cool down before attempting th...
2,027
<p>I know that I can insert multiple rows using a single statement, if I use the syntax in <a href="https://stackoverflow.com/questions/39576/best-way-to-do-multi-row-insert-in-oracle#39602">this answer</a>. </p> <p>However, one of the values I am inserting is taken from a sequence, i.e. </p> <pre><code>insert into T...
<p>This works:</p> <pre><code>insert into TABLE_NAME (COL1,COL2) select my_seq.nextval, a from (SELECT 'SOME VALUE' as a FROM DUAL UNION ALL SELECT 'ANOTHER VALUE' FROM DUAL) </code></pre>
<p>this works and there is no need to use union all.</p> <pre><code>Insert into BARCODECHANGEHISTORY (IDENTIFIER,MESSAGETYPE,FORMERBARCODE,NEWBARCODE,REPLACEMENTDATETIME,OPERATORID,REASON) select SEQ_BARCODECHANGEHISTORY.nextval, MESSAGETYPE, FORMERBARCODE, NEWBARCODE, REPLACEMENTDATETIME, OPERATORID, REASON from ( ...
28,244
<p>Maybe I'm just thinking about this too hard, but I'm having a problem figuring out what escaping to use on a string in some JavaScript code inside a link's onClick handler. Example:</p> <pre><code>&lt;a href="#" onclick="SelectSurveyItem('&lt;%itemid%&gt;', '&lt;%itemname%&gt;'); return false;"&gt;Select&lt;/a&gt; ...
<p>In JavaScript you can encode single quotes as "\x27" and double quotes as "\x22". Therefore, with this method you can, once you're inside the (double or single) quotes of a JavaScript string literal, use the \x27 \x22 with impunity without fear of any embedded quotes "breaking out" of your string. </p> <p>\xXX is f...
<p>Is the answers here that you can't escape quotes using JavaScript and that you need to start with escaped strings.</p> <p>Therefore. There's no way of JavaScript being able to handle the string 'Marge said "I'd look that was" to Peter' and you need your data be cleaned before offering it to the script?</p>
12,307
<p>Unless I am missing an obvious built-in method, what is the quickest way to get the <em>n</em>th occurrence of a string within a string?</p> <p>I realize that I could loop the <a href="https://msdn.microsoft.com/en-us/library/k8b1470s(v=vs.110).aspx" rel="noreferrer">IndexOf</a> method by updating its start index o...
<p>That's basically what you need to do - or at least, it's the easiest solution. All you'd be "wasting" is the cost of n method invocations - you won't actually be checking any case twice, if you think about it. (IndexOf will return as soon as it finds the match, and you'll keep going from where it left off.)</p>
<p>This might do it:</p> <pre><code>Console.WriteLine(str.IndexOf((@"\")+2)+1); </code></pre>
22,594
<p>Does there exist a parser that generates an AST/parse tree at runtime? Kind of like a library that would accept a string of EBNF grammar or something analogous and spit out a data structure? </p> <ul> <li>I'm aware of antlr, jlex and their ilk. They generate source code which could do this. (like to skip the compil...
<p>Take a look at <a href="http://en.wikipedia.org/wiki/Parser_Combinator" rel="noreferrer">parser combinators</a> which i think may help you. It is possible to make parsers at runtime using this technique. One popular parser combinator is <a href="http://legacy.cs.uu.nl/daan/parsec.html" rel="noreferrer">Parsec</a> wh...
<p><a href="http://www.jflex.de" rel="nofollow noreferrer">JFlex</a>, the JLex Java extension, lets you do run time compilation, but it is pretty hairy stuff.</p>
22,449
<p>I have no clue about trigonometry, despite learning it in school way back when, and I figure this should be pretty straightforward, but trawling through tons of trig stuff on the web makes my head hurt :) So maybe someone could help me...</p> <p>The title explains exactly what I want to do, I have a line: x1,y1 an...
<p>construct a normal to the vector (x1,y1)->(x2,y2). place it at the midpoint ((x1+x2)/2,(y1+y2)/2) and go out a distance h.</p> <p>the normal will look like (-(y2-y1),x2-x1). make this a unit vector (<a href="http://en.wikipedia.org/wiki/Unit_vector" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Unit_vector...
<p>Al I can remember is that an isosceles triangle will have sides of equal length, and equal angles at the base. If you have the height, then you have the final coordinate because this will be the point of intersection, right?</p>
45,312
<p>I would prefer that a console app would default to </p> <p>multithreaded debug. warning level 4. build browse information. no resource folder.</p> <p>Does anyone know of any technique that would allow me to create a console app, with my desired options, without manually setting it.</p>
<p>Yes, you can do that. What you want is to create your own project template. You can then select that template from the New Project wizard. I wasn't able to location documentation on how to create a project template in Visual Studio 6, but <a href="http://msdn.microsoft.com/en-us/library/ms247120(VS.80).aspx" rel="no...
<p>I have concluded this is impossible.</p> <p>The is support for custom appwizards for windows projects, but not console projectcs.</p> <p>This is where I did research.</p> <p><a href="http://www.codeproject.com/KB/cpp/genwiz.aspx?fid=15478&amp;df=90&amp;mpp=25&amp;noise=3&amp;" rel="nofollow noreferrer">http://www...
13,200
<p>I have an winforms application that was built using MVC. The controller is subscribing to all of the events from the view (button clicks, etc) and connects multiple views with the model. </p> <p>The problem is that the controller is now about 3000 lines of (hard to unit test) code.</p> <p>What is the best practic...
<p>One obvious thing to point out might be that one controller does not have to be implemented as one class. The MVC design pattern simply states that M, V and C are separate components, but not that each must be one, and only one, class.</p>
<p>Depends on the situation, but assuming you are not at a point where a new controller should be created there are several approaches.</p> <p>Much depends on your setup. One common approach is to have a service layer or service agent which would do work for the controllers that is not specific. The use of interface...
42,456
<p>I'm currently working on a web business application that has many entities (people,organizations) with lots of contact information ie. multiple postal addresses, email addresses, phone numbers etc. </p> <p>At the moment the database schema is such that persons table has postal address columns, phone number columns ...
<p>It is starting to sound like you have a perfectly good hammer (i.e your SQL database) and you are trying to make another hammer with it (a meta-language to define SQL schemas).</p> <p>Before you go down this path, there are many products on the market that aim to store customer details in an SQL database. It might ...
<p>This is not a very informative post; have you had a look at how the vCard people handle the same issues? Also, be careful of overengineering, you might end up with <a href="http://en.wikipedia.org/wiki/Notation_3" rel="nofollow noreferrer" title="N3">N3</a>.</p>
10,647
<p>Visual Studio 2008's XAML editor (SP1) cannot reformat the XML into a consistent style.</p> <p>Which tools can I use to get a nicely formatted XAML file? Studio integration preferred.</p>
<p>While browsing through the options, I found that I had to set "Position each attribute on a separate line" and "Position first attribute on same line as start tag" under "Tools > Options ... > Text-Editor > XAML > Formatting > Spacing" and reset the Keyboard mappings under "Tools > Options ... > Environment > Keyboa...
<p>I just did a post on this. This is a very versatile way to format XAML.</p> <p><a href="http://blogs.msdn.com/b/brunoterkaly/archive/2013/01/09/how-to-format-xaml-easily-and-effectively-windows-8-wpf-silverlight.aspx" rel="nofollow">http://blogs.msdn.com/b/brunoterkaly/archive/2013/01/09/how-to-format-xaml-easily-a...
6,994
<p>I have been trying to remove the text before and after a particular character in each line of a text. It would be very hard to do manually since it contain 5000 lines and I need to remove text before that keyword in each line. Any software that could do it, would be great or any Perl scripts that could run on Window...
<p>You don't need software, you can make this part of your existing script. Multiline <strong>regex</strong> replace along the lines of /a(b)c/ then you can backref b in the replacer with $1. Without knowing more about the text you're working with it's hard to guess what the actual pattern would be.</p>
<p>Assuming you want to remove all text to the left of <code>keyword1</code> and all text to the right of <code>keyword2</code>:</p> <pre><code>while (&lt;&gt;) { s/.*(keyword1)/$1/; s/(keyword2).*/$1/; print; } </code></pre> <p>Put this into a perl script and run it like this:</p> <pre><code>fix.pl original.t...
47,315
<p>Why prefer composition over inheritance? What trade-offs are there for each approach? When should you choose inheritance over composition?</p>
<p><em>Prefer composition over inheritance as it is more malleable / easy to modify later, but do not use a compose-always approach.</em> With composition, it's easy to change behavior on the fly with Dependency Injection / Setters. Inheritance is more rigid as most languages do not allow you to derive from more than o...
<p>What do you want to force yourself (or another programmer) to adhere to and when do you want to allow yourself (or another programmer) more freedom. It has been argued that inheritance is helpful when you want to force someone into a way of dealing with/solving a particular problem so they can't head off in the wron...
7,143
<p>I have a link on a long HTML page. When I click it, I wish a <code>div</code> on another part of the page to be visible in the window by scrolling into view.</p> <p>A bit like <code>EnsureVisible</code> in other languages.</p> <p>I've checked out <code>scrollTop</code> and <code>scrollTo</code> but they seem like...
<p>old question, but if anyone finds this through google (as I did) and who does not want to use anchors or jquery; there's a builtin javascriptfunction to 'jump' to an element;</p> <pre><code>document.getElementById('youridhere').scrollIntoView(); </code></pre> <p>and what's even better; according to the great compa...
<p>Correct me if I'm wrong but I'm reading the question again and again and still think that Angus McCoteup was asking how to set an element to be position: fixed. </p> <p>Angus McCoteup, check out <a href="http://www.cssplay.co.uk/layouts/fixed.html" rel="nofollow noreferrer">http://www.cssplay.co.uk/layouts/fixed.ht...
9,368
<p>I am trying to display a live word count in the vim statusline. I do this by setting my status line in my .vimrc and inserting a function into it. The idea of this function is to return the number of words in the current buffer. This number is then displayed on the status line. This should work nicely as the statusl...
<p>Here's a usable version of Rodrigo Queiro's idea. It doesn't change the status bar, and it restores the statusmsg variable.</p> <pre><code>function WordCount() let s:old_status = v:statusmsg exe "silent normal g\&lt;c-g&gt;" let s:word_count = str2nr(split(v:statusmsg)[11]) let v:statusmsg = s:old_status ...
<p>Using the method in the answer provided by Steve Moyer I was able to produce the following solution. It is a rather inelegant hack I'm afraid and I feel that there must be a neater solution, but it works, and is much faster than simply counting all of the words in a buffer every time the status line is updated. I sh...
13,974
<p>I've deployed some Managed Beans on WebSphere 6.1 and I've managed to invoke them through a standalone client, but when I try to use the application "jconsole" distributed with the standard JDK can can't make it works.</p> <p>Has anyone achieved to connect the jconsole with WAS 6.1?</p> <p>IBM WebSphere 6.1 it's s...
<p>WebSphere's support for JMX is crap. Particularly, if you need to connect to any secured JMX beans. Here's an interesting tidbit, their own implementation of jConsole will not connect to their own JVM. I have had a PMR open with IBM for over a year to fix this issue, and have gotten nothing but the runaround. Th...
<p>I have successfully connected to ActiveMQ and ServiceMix using the JConsole. Does WAS 6.1 use Java Management Extension (JMX) technology? JMX is required for JConsole.</p> <p>If your path is set correctly it should work fine. On windows you go to System Properties -> Advanced Tab -> Environment Variables. Have your...
4,722
<p>Basic requests are:</p> <ul> <li>human readable / text format (for easy version control)</li> <li>online (for collaboration)</li> <li>easy formatting (markdown ok, html is too much)</li> <li>strict formatting (so authors don't invent new types of titles, bullets etc.)</li> <li>exportable to PDF, HTML </li> <li>easy...
<p>Although it may not answer all your requests, <a href="http://www.dokuwiki.org/dokuwiki" rel="noreferrer">DokuWiki</a> may be worth taking a look at.</p> <p>As with other wikis, it has a <a href="http://www.dokuwiki.org/syntax" rel="noreferrer">simple syntax</a>, and has version control to <a href="http://www.dokuw...
<p>try <a href="http://wiki.developer.mindtouch.com/" rel="nofollow noreferrer">Dikiwiki</a></p>
40,516
<p>I'm designing a few mechanisms with OpenSCAD, and one of the parameters that need adjustment between printers/filaments is allowances between pieces that need to be assembled together (for example, if I want a "5&nbsp;mm diameter pin" to fasten two pieces together, how much larger than 5&nbsp;mm will the holes / how...
<p>It helps to understand the different aspects of dimensions, so you can use the terminology correctly. This will help you define your variables in OpenSCAD with correct names. (Tolerance is the wrong term to use.) And once you have correct names, you'll understand how to specify the dimensions in OpenSCAD.</p> <u...
<p>Well, the tolerances will depend on material to be used for fabrication of the required part and also where the part will go and fit. Remember the all parts need some clearance to fit properly.</p> <p>Few years ago (10 years) I was working as Quality Engineer and some Design Engineers were complaining about a Dupon...
769
<p>Is there any way to use a constant as a hash key?</p> <p>For example:</p> <pre><code>use constant X =&gt; 1; my %x = (X =&gt; 'X'); </code></pre> <p>The above code will create a hash with "X" as key and not 1 as key. Whereas, I want to use the value of constant X as key.</p>
<p><code>use constant</code> actually makes constant subroutines.</p> <p>To do what you want, you need to explicitly call the sub:</p> <pre><code>use constant X =&gt; 1; my %x = ( &amp;X =&gt; 'X'); </code></pre> <p>or</p> <pre><code>use constant X =&gt; 1; my %x = ( X() =&gt; 'X'); </code></pre>
<p>Comment @shelfoo (reputation not high enough to add comment directly there yet!)</p> <p>Totally agree about Perl Best Practices by Damian Conway... its highly recommended reading.</p> <p>However please read <a href="http://www.perlfoundation.org/perl5/index.cgi?pbp_module_recommendation_commentary" rel="nofollow n...
12,236
<p>I have a query that I'm executing from a .NET application to a SQL Server database and it seems to take quite a while to complete (5+ Minutes). I created a test app in c# to try to see what was talking so long (the query should return quickly). </p> <p>As I was reconstructing the query by adding in elements to se...
<p>I suspect that this is a procedure cache issue. One benefit of stored procedures is that the plan is stored for you, which speeds things up. Unfortunately, it's possible to get a bad plan in the cache (even when using dynamic queries).</p> <p>Just for fun, I checked my procedure cache, ran an adhoc query, checked...
<p>firstly, are you 100% sure its the query that is going wrong? Check the trace profile in sql server to see how long its taking in the DB.</p> <p>Secondly, are you getting the same number of results back. The capitalisation should not matter by default in sql server, but it could have been set up differently.</p>
18,074
<p>Its a little tricky to search for 'var:*' because most search engines wont find it.</p> <p>I'm not clear exactly what var:* means, compared to say var:Object</p> <p>I thought it would let me set arbitrary properties on an object like :</p> <pre><code>var x:* = myObject; x.nonExistantProperty = "123"; </code></pr...
<p>Expanding on the other answers, declaring something with type asterisk is <em>exactly</em> the same as leaving it untyped.</p> <pre><code>var x:* = {}; var y = {}; // equivalent </code></pre> <p>However, the question of whether you are allowed to assign non-existant properties to objects has nothing to do with the...
<p>As they said before, it's untyped, so it may hold any kind of data. However, you cannot treat it as such in operations. For example, this is valid code:</p> <pre><code>var untyped:* = functionThatReturnsSomeValue(); </code></pre> <p>But if you go one step farther, you have to watch out or you might get bitten:</p>...
25,421
<p>On a small embedded system project we have some code which we would like to run in a thread so we are electing to build in top of an embedded RTOS (eCos). </p> <p>Previously, we have used a cyclic executive in main() that drove tasks each implemented as a state machine. For some tasks we encountered problems where ...
<p>This is a perfectly valid design.<br> In one of our product, we used a similar design, where the asynchronous I/O channels (TCP/IP, 2 serial streams) were in their own tasks and we had a "main" task which would be responsible for multiple areas of functionality.</p> <p>Think of tasks as simply a partitioning mechan...
<p>It is a valid design, but I think I missed the reason for having the OS at all.</p> <p>What facilities of the OS are you planning to use?</p> <p>From the information available it seems that you will end up moving the complexity of the tasks to your new main loop.</p>
14,060
<p>Anyone know a simple way using Java calendar to subtract X days from a date?</p> <p>I have not been able to find any function which allows me to directly subtract X days from a date in Java. Can someone point me to the right direction?</p>
<p>Taken from <a href="http://docs.oracle.com/javase/7/docs/api/java/util/Calendar.html#add%28int,%20int%29" rel="noreferrer">the docs here</a>: </p> <blockquote> <p>Adds or subtracts the specified amount of time to the given calendar field, based on the calendar's rules. For example, to subtract 5 days from the cur...
<p>Eli Courtwright second solution is wrong, it should be:</p> <pre><code>Calendar c = Calendar.getInstance(); c.setTime(date); c.add(Calendar.DATE, -days); date.setTime(c.getTime().getTime()); </code></pre>
26,097
<p>Rails is now making <a href="http://guides.rubyonrails.org/2_2_release_notes.html#_thread_safety" rel="nofollow noreferrer">multi-threaded</a> applications possible, but it doesn't sound like it applies in every situation (for instance, if you're using Mongrel, it doesn't sound like this affects you at all).</p> <p...
<p>I would steer well clear of multithreaded applications in Ruby unless you're using JRuby. Ruby threads are not native threads, and in my experience they work very badly indeed. Also, Ruby's memory manager leaves a lot to be desired, so segregating by process rather than by thread turns out to be a much more produc...
<p>As a rule of thumb, if you are planning to use Threads, most likely your approach is not the better one. Try first to elaborate more on why you need threads, and if you still need them, use them with care :)</p>
34,959
<p>I'm trying to write a macro that would allow me to do something like: <code>FORMAT(a &lt;&lt; "b" &lt;&lt; c &lt;&lt; d)</code>, and the result would be a string -- the same as creating an ostringstream, inserting <code>a...d</code>, and returning <code>.str()</code>. Something like:</p> <pre><code>string f(){ o...
<p>You've all pretty much nailed this already. But it's a little challenging to follow. So let me take a stab at summarizing what you've said...</p> <hr> <p>That difficulties here are that:</p> <ul> <li><p>We are playing with a temporary <code>ostringstream</code> object, so taking addresses is contra-indicated.</...
<p>Why not just use a function instead of a macro?</p>
39,003
<p>Is it possible to check a bash script syntax without executing it?</p> <p>Using Perl, I can run <code>perl -c 'script name'</code>. Is there any equivalent command for bash scripts?</p>
<pre><code>bash -n scriptname </code></pre> <p>Perhaps an obvious caveat: this validates syntax but won't check if your bash script tries to execute a command that isn't in your path, like <code>ech hello</code> instead of <code>echo hello</code>.</p>
<p>If you need in a variable the validity of all the files in a directory (git pre-commit hook, build lint script), you can catch the stderr output of the "sh -n" or "bash -n" commands (see other answers) in a variable, and have a "if/else" based on that</p> <pre><code>bashErrLines=$(find bin/ -type f -name '*.sh' -ex...
20,728
<p>Whats the best/easiest GUI library out there for Ruby?</p> <p>I would prefer a cross-platform GUI library, but currently I'm only concerned about Windows (Win32). I am having difficulting finding any that seem to be easy to use. Are there any?</p>
<p>Ruby <a href="http://shoesrb.com/" rel="noreferrer">Shoes</a> (by why) is intended to be a <em>really</em> simple GUI framework. I don't know how fully featured it is, though.</p> <p>Some good code samples can be found in the <a href="http://shoesrb.com/tutorials/" rel="noreferrer">tutorials</a>.</p> <p>Also, I th...
<p>Try <a href="http://shoesrb.com/" rel="nofollow noreferrer">shoes</a>. Unfortunately, I have not had a chance to work with it yet, but I have an upcoming project where I plan to use it. It is cross-platform. Also the API looks very Rubyish so I would give it a try.</p>
32,621
<p>I want to detect whether adobe reader is installed using VB6. Also if detected that it's not installed, what would be the best solution?</p>
<p>There are crude ways (checking for files on Program files directory), but I'd recommend you declare full-registry functions (not getSetting from vb) as in <a href="http://www.windowsdevcenter.com/pub/a/windows/2004/06/15/VB_Registry_Keys.html" rel="nofollow noreferrer">http://www.windowsdevcenter.com/pub/a/windows/2...
<p>I would check in the </p> <pre><code>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\ </code></pre> <p>Going through that list will give you all the programs installed. Looking for Application Specific Registry Entries typically will work, but occasionally when uninstalling an application, ...
32,689
<p>What are the fast solvers for <a href="http://en.wikipedia.org/wiki/Finite_element_method" rel="nofollow noreferrer">FEM</a> equations? I would prefer open source implementation, but if there is a commercial implementation, then I won't mind paying for it. </p>
<p>How about <a href="http://www.ce.berkeley.edu/~rlt/feap/" rel="nofollow noreferrer">FEAP</a>. It has full source code available when you purchase it. It is pretty big project, maybe its too much for your needs, but check it out.</p> <blockquote> <p>FEAP is a general purpose finite element analysis program which...
<p>Oops, that's kind of a brad question.</p> <p>Solving differential equations usually starts with analyzing equation itself. Some equations are notoriously difficult to solve efficiently, e.g. indifinite boundary problems. So if you have something else than an elliptic problem, you'll might better prepare for hard ti...
47,986
<p>What do I need to allow Visual Studio 2005 to add WCF service reference to a project? </p> <p>I know I should just use Visual Studio 2008, but I'm preparing for a "what-if" situation where the client does not have VS2008 just yet.</p>
<p>If you want visual studio 2005 integration they have to have at least .net 3.0 installed. The client can then use svcutil.exe to generate the proxy.</p> <p>Take a look here on how to use WCF in VS 2005 using the orcas extensions:<br> <a href="http://www.15seconds.com/issue/061130.htm" rel="noreferrer">http://www.15...
<p>The following is a post that will walk you through all the necessary to create a WCF service in Visual Studio 2005 including how to add necessary references:</p> <p><a href="http://tyblog.in/" rel="nofollow noreferrer">http://tyblog.in/</a></p>
45,064
<p>I like Tinkercad so far for it's very simple UI. (I'm new to 3D modeling and very confused by Blender and the like.) However, I'm not using it to do 3D printing just yet. For I'd like to be able to be to slap textures on the models I make and get images of that. What is the easiest beginner way to do that (for Linux...
<p>For your purposes, consider that Meshmixer (free) can open .OBJ files and display them in any position you desire.</p> <p>I use Meshmixer quite a bit for model editing, but have not used it for .OBJ files with textures. I searched my drive and found quite a few .OBJ files, but was not able to present or add texture...
<p>Consider using Clara.io (100% free):</p> <ul> <li>Export your Tinkercad project as OBJ.</li> <li>Import in Clara.io</li> <li>Texture and render.</li> </ul> <p>Clara.io is 100% web based. It is simple to learn if you have prior experience with other 3D renderers. If you don't, the learning curve might be steep thou...
1,113
<p>I would like to convert the following string into an array/nested array: </p> <pre><code>str = "[[this, is],[a, nested],[array]]" newarray = # this is what I need help with! newarray.inspect # =&gt; [['this','is'],['a','nested'],['array']] </code></pre>
<p>You'll get what you want with YAML.</p> <p>But there is a little problem with your string. YAML expects that there's a space behind the comma. So we need this</p> <pre><code>str = "[[this, is], [a, nested], [array]]" </code></pre> <p>Code:</p> <pre><code>require 'yaml' str = "[[this, is],[a, nested],[array]]" ##...
<p>Looks like a basic parsing task. Generally the approach you are going to want to take is to create a recursive function with the following general algorithm</p> <pre><code>base case (input doesn't begin with '[') return the input recursive case: split the input on ',' (you will need to find commas only at this ...
5,931
<p>I have a List containing several keywords. I foreach through them building my linq query with them like so (boiled down to remove the code noise):</p> <pre><code>List&lt;string&gt; keys = FillKeys() foreach (string key in keys){ q = q.Where(c =&gt; c.Company.Name.Contains(key)); } </code></pre> <p>When I now m...
<p>You're reusing the same variable (<code>key</code>) in your lambda expression.</p> <p>See my article on <a href="http://pobox.com/~skeet/csharp/csharp2/delegates.html#anonymous.methods" rel="nofollow noreferrer">anonymous methods</a> for more details, and there are a number of related SO questions too:</p> <ul> <l...
<p>it’s been fixed in C# 5.0, and the example above in C# 5.0 works but fails in earlier versions of C#. </p> <p>But be careful, it does not concern a for loop</p> <pre><code> static void Main() { IEnumerable&lt;char&gt; query = "aaa bbb ccc"; string lettersToRemove = "ab"; ...
37,779
<p>I am in the position of having to make a technology choice early in a project which is targetted at mobile phones. I saw that there is a python derivative for S60 and wondered whether anyone could share experiences, good and bad, and suggest appropriate IDE's and emulators.</p> <p>Please don't tell me that I shoul...
<h2>PyS60 -- its cool :)</h2> <p>I worked quite a lot on PyS60 ver 1.3 FP2. It is a great language to port your apps on Symbian Mobiles and Powerful too. I did my Major project in PyS60, which was a <a href="http://sourceforge.net/projects/gsmlocator" rel="nofollow noreferrer">GSM locator</a>(its not the latest versi...
<p>I've written a calculator, that I'd like to have, and made a simple game. I wrote it right on the phone. I was writing in text editor then switched to Python and ran a script. It is not very comfortable, but it's ok. Moreover, I was writing all this when I hadn't PC nearby.</p> <p>It was a great experience!</p>
20,901
<p>How to get the last selected item in a .Net Forms multiselect ListBox? Apparently if I select an item in the listbox and then select another 10 the selected item is the first one.</p> <p>I would like to obtain the last element that I selected/deselected.</p>
<p>I would take this general approach:</p> <p>Listen for the <code>SelectedIndexChanged</code> event and scan through the <code>SelectedIndices</code> collection every time. </p> <p>Keep a separate list of all selected indices, appending ones that have not been in the list, removing those that have been de-selected.<...
<p>This is way I've done it in VB.</p> <p>When you refresh the list box you have to re-dimension the array.</p> <pre><code> Dim SelectedAry(-1) As Integer Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged Dim LastOne As Integer = -1 '...
39,307
<p>We are using SSRS 2005 SP1 and the lastest Reportviewer controls.<br> We are having situations where certain reporting infrastructure exceptions are not being exposed to any of the exception handling routines.</p> <p>A specific example is when the SQL Server Reporting Services Windows service was unexpectantly stop...
<p>Thanks for your response Bob. It's surprising and a disappointment that SSRS is eating those exceptions. We will probably stay away from hacking the dll and try to figure out a way to monitor and alert from the SSRS internal logs.</p>
<p>I saw something similar to this in reporting services 2008 where I was trying to catch certain types of exceptions. <a href="https://stackoverflow.com/questions/188373/custom-error-pages-in-reporting-services-2008">No one else replied to my question either.</a></p> <p>What I did learn after asking this question how...
39,365
<p>I want a data structure that will allow querying <em>how many items in last <strong>X</strong> minutes</em>. An item may just be a simple identifier or a more complex data structure, preferably the timestamp of the item will be in the item, rather than stored outside (as a hash or similar, wouldn't want to have prob...
<p>A simple linked list can be used for this.</p> <p>Basically you add new items to the end, and remove too old items from the start, it is a cheap data structure.</p> <p>example-code:</p> <pre><code>list.push_end(new_data) while list.head.age &gt;= age_limit: list.pop_head() </code></pre> <p>If the list will b...
<p>I think that an important consideration will be the frequency of querying vs. adding/removing. If you will do frequent querying (especially if you'll have a large collection) a B-tree may be the way to go:</p> <p><a href="http://en.wikipedia.org/wiki/B-tree" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/B...
3,609
<p>I am looking for a more elegant way of concatenating strings in Ruby.</p> <p>I have the following line:</p> <pre><code>source = "#{ROOT_DIR}/" &lt;&lt; project &lt;&lt; "/App.config" </code></pre> <p>Is there a nicer way of doing this?</p> <p>And for that matter what is the difference between <code>&lt;&lt;</cod...
<p>You can do that in several ways:</p> <ol> <li>As you shown with <code>&lt;&lt;</code> but that is not the <em>usual</em> way</li> <li><p>With string interpolation</p> <pre><code>source = "#{ROOT_DIR}/#{project}/App.config" </code></pre></li> <li><p>with <code>+</code></p> <pre><code>source = "#{ROOT_DIR}/" + proj...
<p>For your particular case you could also use <code>Array#join</code> when constructing file path type of string:</p> <pre><code>string = [ROOT_DIR, project, 'App.config'].join('/')] </code></pre> <p>This has a pleasant side effect of automatically converting different types to string:</p> <pre><code>['foo', :bar, ...
49,472
<p>I have code like this:</p> <pre><code>var newMsg = new Msg { Var1 = var1, Var2 = var2 }; using (AppDataContext appDataContext = new AppDataContext(ConnectionString)) { appDataContext.CClass.InsertOnSubmit(newMsg); appDataContext.SubmitChanges(); } </code></pre> <p>After reading <a href="https://st...
<p>The second answer in the post you're referencing says it:</p> <blockquote> <p>LINQ to SQL uses <em>execute_sql</em> with parameters.</p> </blockquote> <p>It does not concatenate property values into a one big INSERT ... VALUES('...', '...')</p>
<p>No, but you should be validating user data anyhow.</p>
23,838
<p>I am having an issue with linq updating in linqtosql</p> <p>from the code below</p> <pre><code>Dim lqPatientTable As New lqHospitalDataContext Dim strPatientId As String strPatientId = Me.ucboPatientInfo.SelectedRow.Cells(5).Value Dim lqPatientName = (From lqp In lqPatientTable.Patients _ ...
<p>When you select just individual fields you are creating an anonymous type on the fly that is no longer part of the ORM's change tracking/update mechanism.</p> <p>You will need to change the select part to be "Select lqp" for this to work.</p>
<p>When you created the dbml file for your data context, did it create the LastName property as a readonly field? Open the dbml find the field and check the property to see if it's set to readonly...</p>
49,240
<p>I've been a .NET developer for several years now and this is still one of those things I don't know how to do properly. It's easy to hide a window from the taskbar via a property in both Windows Forms and WPF, but as far as I can tell, this doesn't guarantee (or necessarily even affect) it being hidden from the <kbd...
<p><strong>Update:</strong></p> <p>According to @donovan, modern days WPF supports this natively, through setting <code>ShowInTaskbar=&quot;False&quot;</code> and <code>Visibility=&quot;Hidden&quot;</code> in the XAML. (I haven't tested this yet, but nevertheless decided to bump the comment visibility)</p> <p><strong>O...
<p>Personally as far as I know this is not possible without hooking into windows in some fashion, I'm not even sure how that would be done or if it is possible.</p> <p>Depending on your needs, developing your application context as a NotifyIcon (system tray) application will allow it to be running without showing in A...
46,565
<p>I want to write out a text file.</p> <p>Instead of the default UTF-8, I want to write it encoded as ISO-8859-1 which is code page 28591. I have no idea how to do this...</p> <p>I'm writing out my file with the following very simple code:</p> <pre><code>using (StreamWriter sw = File.CreateText(myfilename)) { s...
<pre><code>using System.IO; using System.Text; using (StreamWriter sw = new StreamWriter(File.Open(myfilename, FileMode.Create), Encoding.WhateverYouWant)) { sw.WriteLine("my text..."); } </code></pre> <p>An alternate way of getting your encoding:</p> <pre><code>using System.IO; using System.Text; usin...
<p>Change the Encoding of the stream writer. It's a property.</p> <p><a href="http://msdn.microsoft.com/en-us/library/system.io.streamwriter.encoding.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/system.io.streamwriter.encoding.aspx</a></p> <p>So:</p> <pre><code>sw.Encoding = Encoding.GetE...
48,831
<p>Since AspectJ LoadTime-Weaving needs to load the JVM with an agent/it's own classloader - is there a way to load/make changes in the user's JVM from my applet? or maybe just before loading the applet (with a parent applet?)</p>
<p>It might be possible to add a weaving agent after the JVM is started, see: <a href="https://stackoverflow.com/questions/4817670/how-can-i-add-a-javaagent-to-a-jvm-without-stopping-the-jvm">How can I add a Javaagent to a JVM without stopping the JVM?</a></p>
<p>I'm afraid you'll be completely out of luck there. According to the <a href="http://java.sun.com/sfaq/#appletCL" rel="nofollow noreferrer">Sun docs on applet classloaders</a>, a "web browser uses only one class loader, which is established at start-up. Thereafter, the system class loader cannot be extended, overloa...
14,504
<p>I'm writing an interactive function that I'd like to have remember the last argument the user supplied and use it as the default. </p> <pre><code>(defun run-rake (param) (interactive "sTask: ") (shell-command (format "rake %s" task))) </code></pre> <p>The first time the function is invoked I want it to rememb...
<p>You can see how the <code>compile</code> command does this. Bring up the help text for the compile command with <code>C-h f compile</code>, move the cursor over the name of the file that contains the function, then hit <code>RETURN</code>. This will bring up the source file for <code>compile</code>.</p> <p>Basica...
<p>I figured out how to do this manually using a defvar (global), but this feels like the kind of thing that should already be provided by the core library (kind of like scheme's make-parameter). This just seems like more code, and more manual than it should be:</p> <pre><code>(defvar *editconf-ruby-run-rake-last-rak...
17,597
<p>&lt;rant-mode&gt; Have you ever seen a programming language that does not allow to add comments to the code? Welcome to the world of RTML (may it burn in hell)! &lt;/rant-mode&gt;</p> <h2>Question</h2> <blockquote> <p>What is the best technique (if any) you've adopted to comment your RTML code?</p> </blockquote>...
<p>To create a comment in RTML, click on your template, then <code>New</code>, and in the textbox that says Simple, type (in quotes) your comment.</p> <pre><code>"**************** My comment and stuff ******************" </code></pre> <p>If you want to comment out a piece of code, insert your code after a <code>MULTI...
<p>I just had a look at RTML,I wouldn't like working with it directly (it's very ugly).</p> <p>It seems that the best way would be to have source files, and a preprocessor that strips comments and probably includes shortcuts and new features, then automatically uploads the RTML (maybe even a wasabi for RTML).</p> <p>...
37,089
<p>I'm writing a Python application that takes a command as an argument, for example:</p> <pre><code>$ python myapp.py command1 </code></pre> <p>I want the application to be extensible, that is, to be able to add new modules that implement new commands without having to change the main application source. The tree look...
<p>With Python older than 2.7/3.1, that's pretty much how you do it.</p> <p>For newer versions, see <code>importlib.import_module</code> for <a href="https://docs.python.org/2/library/importlib.html#importlib.import_module" rel="noreferrer">Python 2</a> and <a href="https://docs.python.org/3/library/importlib.html#impo...
<p>The following worked for me:</p> <pre><code>import sys, glob sys.path.append('/home/marc/python/importtest/modus') fl = glob.glob('modus/*.py') modulist = [] adapters=[] for i in range(len(fl)): fl[i] = fl[i].split('/')[1] fl[i] = fl[i][0:(len(fl[i])-3)] modulist.append(getattr(__import__(fl[i]),fl[i]))...
38,616
<p>I've been facing this issue where, the hibernate objects on serialization produces unexpect xmls containing all the instrumented code from Hibernate.</p> <p>We did some cleaning of the object before serializing the object.</p> <p>But, is there a standard option available to serialize the object directly?</p>
<p>I've not used XStream before, but I have serialized Hibernate-managed entities. It isn't fun.</p> <p>There are two big issues:</p> <ul> <li>Lazy loading;</li> <li>One-to-many relationships.</li> </ul> <p>The former is obvious - you need the actual data to serialize. The latter is less so - any one-to-many relatio...
<p>There is some info on this (and sample code) over at the Codehaus JIRA:</p> <p><a href="http://jira.codehaus.org/browse/XSTR-226" rel="nofollow noreferrer">http://jira.codehaus.org/browse/XSTR-226</a></p> <p>We wrote some tools to work around this sort of issue for a bunch of other remoting implementations (Axis 1...
42,608
<p>Effectively I want to give numeric scores to alphabetic grades and sum them. In Excel, putting the <code>LOOKUP</code> function into an array formula works:</p> <pre><code>{=SUM(LOOKUP(grades, scoringarray))} </code></pre> <p>With the <code>VLOOKUP</code> function this does not work (only gets the score for the fi...
<p>I'm afraid I think the answer is no. From the help text on <a href="http://docs.google.com/support/spreadsheets/bin/answer.py?answer=71291&amp;query=arrayformula&amp;topic=&amp;type=" rel="nofollow noreferrer">http://docs.google.com/support/spreadsheets/bin/answer.py?answer=71291&amp;query=arrayformula&amp;topic=&am...
<p>I know this thread is quite old, but I'd been struggling with this same problem for some time. I finally came across a solution (well, Frankenstiened one together). It's only slightly more elegant, but should be able to work with large data sets without trouble.</p> <p>The solution uses the following:</p> <pre><...
4,744
<p>There are two Databases, Database A has a table A with columns of id, group and flag. Database B has a table B with columns of ID and flag. Table B is essentially a subset of table A <code>where the group == 'B'</code>. </p> <p>They are updated/created in odd ways that are outside my understanding at this time, ...
<p>Assuming that ID is a unique key, and that you can use linked servers or some such to run a query across servers, this SQL statement should work (it works for two tables on the same server).</p> <pre><code>UPDATE Table_B SET Table_B.Flag = Table_A.Flag FROM Table_A inner join Table_B on Table_A.id = Table_B.id </co...
<p>Create an update trigger on table A that pushes the necessary changes to B as A is modified.</p> <p>Basically (syntax may not be correct, I can't check it right now). I seem to recall that the inserted table contains all of the updated rows on an update, but you may want to check this to make sure. I think the t...
26,359
<p>I am working on a windows service that polls for a connection to a network enabled devices every 15 seconds. If the service is not able to connect to a device, it throws an exception and tries again in 15 seconds. All of this works great.</p> <p>But, lets say one of the devices is down for a day or more. I am fi...
<p>One good way to achieve what you need is to employ the Circuit Breaker design pattern.</p> <p>I first read about this in the book "Release It! Design and Deploy Production Ready Software" by Michael T. Nygard, from the Pragmatic Press, p104-107.</p> <p>The idea of the circuit breaker is that it sits in the path of...
<p>What about...</p> <pre><code> int count = 0; while (true) { try { AttemptStuff() } catch (Exception ex) { if(count &lt; 10) { EventLog.WriteEntry("my service", ex.ToString(), EventLogEntryType.Error); count++; ...
30,882
<p>Is there a way to bypass the following IE popup box:</p> <blockquote> <p>The webapge you are viewing is trying to close the window. Do you want to close this window? Yes|No</p> </blockquote> <p>This is occurring when I add window.close() to the onclick event of an asp.net button control.</p>
<p>Your JavaScript code can only close a window without confirmation that was previously opened by window.open(). This is an intentional security precaution because a script running on a webpage does not own the window, and by closing it discards the browsing history in that window.</p> <p>The workaround is to either ...
<p>There is a hack for this.</p> <p>for IE call:</p> <pre><code>window.open('close.html', '_self'); </code></pre> <p>then in close.html all you need is:</p> <pre><code>&lt;script&gt;window.close();&lt;/script&gt; </code></pre> <p>Since this essentially opens a popup, in the same named window, when the "new' window...
46,601
<p>When I run indent with various options I want against my source, it does what I want but also messes with the placement of *s in pointer types:</p> <pre><code> -int send_pkt(tpkt_t* pkt, void* opt_data); -void dump(tpkt_t* bp); +int send_pkt(tpkt_t * pkt, void *opt_data); +void dump(tpkt * bp); </code></pre>...
<p><strong>Uncrustify</strong> </p> <p>Uncrustify has several options on how to indent your files. </p> <p>From the config file: </p> <pre>indent_with_tabs How to use tabs when indenting code 0=spaces only 1=indent with tabs, align with spaces 2=indent and align with tabs<...
<p>Hack around and change its behavior editing the code. It's GNU after all. ;-)</p> <p>As it's probably not the answer you wanted, here's another link: <a href="http://www.fnal.gov/docs/working-groups/c++wg/indenting.html" rel="nofollow noreferrer">http://www.fnal.gov/docs/working-groups/c++wg/indenting.html</a>.</p>...
12,731
<p>Is there any way of determining whether or not a specific temp table has been created in a session without referencing the tempdb database that it was created on? Users are allocated to a specific tempdb when they log in, so I don't know which tempdb they'll be using.</p> <p>I don't need to specify a tempdb to sele...
<p>You can check for the existence of a temporary object using the object_id:</p> <pre><code>SELECT object_id('#tmpTable') </code></pre> <p>You can specify which tempdb you are using if you want, but you don't have to:</p> <pre><code>SELECT object_id('tempdb..#tmpTable') </code></pre> <p>It's worth noting that this...
<p>It seems to me that you shouldn't be using temporary tables here... these seem more like regular tables (perhaps with a user identifier). What is the scenario here?</p> <p>Note that using temporary tables in this way can play havoc with the optimiser/query cache - it will have to do lots of recompiles, as the meani...
23,013
<p>I am creating a GUI frontend for the Eve Online API in Python.</p> <p>I have successfully pulled the XML data from their server.</p> <p>I am trying to grab the value from a node called "name":</p> <pre><code>from xml.dom.minidom import parse dom = parse("C:\\eve.xml") name = dom.getElementsByTagName('name') print...
<p>It should just be</p> <pre><code>name[0].firstChild.nodeValue </code></pre>
<p>I had a similar case, what worked for me was:</p> <p>name.firstChild.childNodes[0].data</p> <p>XML is supposed to be simple and it really is and I don't know why python's minidom did it so complicated... but it's how it's made</p>
41,001
<p>My record sheet app has a menu option for creating a new, blank record sheet. When I open a sheet window, I can open new windows without a problem, using subprocess.Popen() to do it.</p> <p>However, under Windows (I haven't tested it on other OSes yet), if I open a new window then use the "open file" dialog to popu...
<p>From the error message, it looks like you need to pass the full path of "foo.py" to your Popen call. Normally just having "foo.py" will search in your current working directory, but this can be a bit unpredictable on Windows, I have found. Yours seems to be jumping around with the open file dialog.</p> <p>Secondly,...
<p>The suggested answer seems to have fixed the problem. I also realized that I needed to use <strong>os.name</strong> to determine which OS is being used, then I can use the correct path format for loading the external Python file.</p>
35,927
<p>I have set up transactional replication between two SQL Servers on different ends of a relatively slow VPN connection. The setup is your standard "load snapshot immediately" kind of thing where the first thing it does after initializing the subscription is to drop and recreate all tables on the subscriber side and ...
<p>Yes. You can apply the <a href="http://msdn.microsoft.com/en-us/library/aa237138(SQL.80).aspx" rel="nofollow noreferrer">initial snapshot manually</a>.</p> <p>It's been a while for me, but the link (into BOL) has alternatives to setting up the subscriber.</p> <p>Edit: From BOL How-tos, <a href="http://msdn.microso...
<p>In SQL 2005, you have a "compact snapshot" option, that allow you to reduce the total size of the snapshot. When applied over a network, snapshot items "travel" compacted to the suscriber, where they are then expanded.</p> <p>I think you can easily figure the potential speed gain by comparing sizes of standard and ...
44,834