instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I am trying to get pylons to debug in Eclipse under Ubuntu. Specifically. I am not sure what to use for the 'Main Module' on the Run configurations dialog.</p> <p>(<a href="https://stackoverflow.com/questions/147650/debug-pylons-application-through-eclipse">this</a> is a similar question on stackoverflow, but I thi...
<p>I've managed to fix this now.</p> <p>In <code>Window&gt;Preferences&gt;Pydev&gt;Interpreter-Python</code> remove the python interpreter and reload it (select <code>New</code>) after installing pylons.</p> <p>In the Terminal cd into the projects directory. Then type <code>sudo python setup.py develop</code> Not su...
<p>Haven't tried on Eclipse, but I bet the solution I have been using to debug Pylons apps in WingIDE will work here too.</p> <ol> <li><p>Write the following two-liner (name it run_me.py or similarly) and save it in your project directory:</p> <p>from paste.script.serve import ServeCommand</p> <p>ServeCommand("serve...
40,288
<p>I can set data in JTable constructor, and then user can change this data when program is running manually(typing from keyboard).</p> <p>But what method should I use in case I want to change data in some column? To change column header I use TableColumn method setHeaderValue. What should I use to set value in JTable...
<p>If you want to allow users to edit the data, then you need to set a TableCellEditor on the cells that you want people to edit. You probably also want to start using a TableModel instead of hard coding the data in the JTable itself.</p> <p>See <a href="http://java.sun.com/docs/books/tutorial/uiswing/components/tabl...
<p>While creating the JTable you first need to specify that the values of particular column are editable. You can obviously also provide the row basis edit functionality. but all these things you should define while ccreating the table itself. Please reply if you need any help on this.</p>
34,802
<p>What are your favorite ways to encapsulate LINQ to SQL entity classes and data-context classes into business objects?</p> <p>What have you found to work in a given situation?</p> <p>Have you invented or taken to any specific patterns?</p>
<p>I've found a pattern which I think works best--In my case, at least. <br /><br /><br /> I extend entity classes using partial classes. I use partial classes so the signature of the entity does not change (see the <code>DeleteOnSubmit</code> call in the <code>Delete</code> method).</p> <p>I've cooked up a a small ex...
<p>I did some experimentation using Entity Framework and Linq to Entities as a way to further separate my client code from the database, but I found it clumsy to use and was worried about the performance. </p> <p>In my current project I use Linq to SQL as my data layer, but have separate classes where I implement all ...
27,657
<p>Is there a programming language suitable for building web applications, that is compiled, strongly-typed, and isn't ASP.NET?</p> <p>I thought of using Mono (<a href="http://www.mono-project.com/" rel="nofollow noreferrer">http://www.mono-project.com/</a>), but I wonder if there are any other alternatives.</p> <p>(...
<p>Not sure what do you mean by saying "compiled". What about Java ?</p> <p>Java has a lot of frameworks for web development. For example <a href="http://tapestry.apache.org" rel="nofollow noreferrer">Tapestry</a>:</p> <blockquote> <p>Tapestry is an open-source framework for creating dynamic, robust, highly sca...
<p>Maybe you should meant "compiled to machine code"? </p> <p>C# and Java are compiled to an intermediate language which is then interpreted at run time.</p> <p>Most decent interpreters compile this to actual machine code at runtime to speed up (Just In Time compiling).</p> <p>Of course it is not as efficient, but ...
19,493
<p>This is a very complicated question concerning how to serialize data via a web service call, when the data is not-strongly typed. I'll try to lay it out as best possible.</p> <p><strong>Sample Storage Object:</strong></p> <pre><code>[Serializable] public class StorageObject { public string Name { get; set; } ...
<p>This is like dynamic properties for a object. C# is not quite a dynamic language unlike javascript or maybe PHP can parse the object properties on the fly. The following two methods are what I can think of. The second one might fit into your requirements.</p> <p><strong>The KISS Way</strong> </p> <p>The Keep It S...
<p>I'm not sure this would solve your problem (it would in C#, but maybe not in PHP), but try using <code>Dictionary&lt;string,List&lt;string&gt;&gt; OtherInfo</code> instead of <code>List&lt;NameValuePairs&gt;</code>. Then "Hobbies" and "Websites" would be your keys and the values would be the list of hobbies or web ...
31,863
<p>I am trying to write a textbox that will search on 5 DB columns and will return every result of a given search, ex. "Red" would return: red ball, Red Williams, etc. Any examples or similar things people have tried. My example code for the search.</p> <p>Thanks.</p> <pre><code> ItemMasterDataContext db = new...
<p>"q" in your example will be an <code>IQueryable&lt;ITMST&gt;</code>. I don't think the Datasource property of WebControl know what to do with that. try writing that line as:</p> <pre><code> lv.DataSource = q.ToList(); </code></pre>
<p>What you have is generally what people would do using linq. If you wanted to get more complex and use database wild cards then take a look at the SqlMethods class in System.Data.Linq. </p> <p>@ James Curran You can assign the DataSource property q and it will work fine. The only different is when the query gets exe...
45,566
<p>I need to insert 20,000 rows in a single table (SQL Server 2005) using iBatis. What's the fastest way to do it ? I'm already using batch mode, but it didn't help much:</p> <pre><code>try { sqlMap.startTransaction(); sqlMap.startBatch(); // ... execute statements in between sqlMap.commitTransaction(); } fina...
<p>Although this is not specific to your db server, I have previously had success writing the rows out to a local file in csv format and then having the database importing the file. This was considerably faster than insert statements or even a batch insert.</p>
<p>Bulk inserts are best done using the database's own bulk loader tools. For Oracle, it's SQL*Loader, for example. Often these are faster than anything you could ever write.</p>
36,688
<p>I use FTP on a daily basis to work on multiple websites, but when I try to work from home, my darned satellite internet has a latency of about 1000ms. (Its craptastic service, I know, but there are no alternatives where I live.) Thus, I was wondering if there is a way that I can connect to my web server and transfer...
<p>Sounds like a good case for using UDP rather than TCP-based protocols - e.g. <a href="http://uftp-multicast.sourceforge.net" rel="nofollow noreferrer">uftp</a></p> <p>A quote from the linked site: "especially useful for data distribution over a satellite link (with two way communication), where the inherent delay m...
<p>A few options:</p> <ul> <li>Sneaker-net. Use a USB key.</li> <li>SCP. I'm almost positive it'll only authenticate/handshake once.</li> <li>Tunnelling over SSH. The poor man's VPN. You'll be able to tunnel FTP or anything you like over the SSH connection. It'll be as fast as you're going to get and is very secu...
33,574
<p>Is there a built-in method in Python to get an array of all a class' instance variables? For example, if I have this code:</p> <pre><code>class hi: def __init__(self): self.ii = "foo" self.kk = "bar" </code></pre> <p>Is there a way for me to do this:</p> <pre><code>&gt;&gt;&gt; mystery_method(hi) ["ii",...
<p>Every object has a <code>__dict__</code> variable containing all the variables and its values in it.</p> <p>Try this</p> <pre><code>&gt;&gt;&gt; hi_obj = hi() &gt;&gt;&gt; hi_obj.__dict__.keys() </code></pre> <p>Output</p> <pre><code>dict_keys(['ii', 'kk']) </code></pre>
<p>You will need to first, <strong>examine the class</strong>, next, <strong>examine the bytecode for functions</strong>, then, <strong>copy the bytecode</strong>, and finally, <strong>use the <code>__code__.co_varnames</code></strong>. <strong>This is tricky</strong> because <strong>some classes create their methods u...
13,438
<p>I would like to write small console based applications on Windows Mobile. What console applications might I use?</p>
<p>it may be useful to know that when you use printf from a standard windows mobile application, the output will end up in the kernel log of the device.</p> <p>This has several drawbacks: * Access to the kernellog is manufacturer+device dependent. * The length of the string you can print is limited to 255 characters...
<p>There is no command prompt style console on Windows Mobile. If you're really after a command prompt, check out www.pocketdos.com for a high level of dos application compatibility. If you're more interested in writing small applications for Windows Mobile, C# or VB.Net are your best choices. On small mobile devices ...
9,962
<p>I'm struggling with an upgrade I made to my Creality CR-10. I upgraded the extruder to an E3D V6 hotend. The extruder mount and cooling fans are installed and working, however, I'm doing something wrong with installing the bowden tube into the hotend. Inevitably after I print a few layers, the extruder jambs and ...
<p>You may need to secure the pneumatic coupling in the closed position with a small plastic clip (which should be supplied with the hot end).</p> <p><a href="https://i.stack.imgur.com/h3ljP.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/h3ljP.jpg" alt="Pneumatic coupling with retaining clip"></a><...
<p>This sounds more like a problem with heat creep. When you installed the new hotend, did you reuse the old cooling solution? You might need more heatblock insulation and / or cooling power.</p>
1,235
<p>I want to open a folder window, in the appropriate file manager, from within a cross-platform (windows/mac/linux) Python application.</p> <p>On OSX, I can open a window in the finder with</p> <pre><code>os.system('open "%s"' % foldername) </code></pre> <p>and on Windows with</p> <pre><code>os.startfile(foldernam...
<pre><code>os.system('xdg-open "%s"' % foldername) </code></pre> <p><code>xdg-open</code> can be used for files/urls also</p>
<p>this would probably have to be done manually, or have as a config item since there are many file managers that users may want to use. Providing a way for command options as well.</p> <p>There might be an function that launches the defaults for kde or gnome in their respective toolkits but I haven't had reason to lo...
6,338
<p>Not too long ago, I had a problem which required me to <a href="https://stackoverflow.com/questions/186237/program-only-crashes-as-release-build-how-to-debug">set WinDbg.exe as the default post-mortem debugger</a>. Now that I've fixed that and am back doing normal work, it would be really nice if I could set VS to ...
<p>You can re-enable Visual Studio for Just-In-Time debugging from within Visual Studio:</p> <p>Go to the <strong>Tools | Options</strong> | <strong>Debugging | Just-In-Time</strong> dialog. Then make sure all <strong>Native</strong> and <strong>Managed</strong> (if you're debugging a .NET application) are checked. ...
<p>from the <a href="http://support.microsoft.com/kb/121434" rel="noreferrer">Microsoft support page</a>:</p> <pre><code>1. Start Registry Editor and locate the following Registry subkey in the HKEY_LOCAL_MACHINE subtree: \SOFTWARE\MICROSOFT\WINDOWS NT\CURRENTVERSION\AEDEBUG 2. Select the Debugger value. 3. On the...
23,980
<p>When I write code like this in VS 2008:<br><br></p> <pre><code>.h struct Patterns { string ptCreate; string ptDelete; string ptDrop; string ptUpdate; string ptInsert; string ptSelect; }; class QueryValidate { string query; string pattern; static ...
<p>You're trying to create a non-static member (ptCreate) of a static member (pts). This won't work like this.</p> <p>You got two options, either use a struct initializer list for the Patterns class.</p> <pre><code>Patterns QueryValidate::pts = {"CREATE", "DELETE"}; // etc. for every string </code></pre> <p>Or, much...
<p>I'm not real sure what you are trying to do here. It looks kind of like you are trying to declare and initialize each field in pts separately, rather than declare pts once as a single object. I'm really surprised VS lets you do that.</p> <p>What worked for me in gcc was the following:</p> <pre><code>Patterns Query...
34,253
<p>I am attempting to parse a string like the following using a .NET regular expression:</p> <pre><code>H3Y5NC8E-TGA5B6SB-2NVAQ4E0 </code></pre> <p>and return the following using Split: H3Y5NC8E TGA5B6SB 2NVAQ4E0</p> <p>I validate each character against a specific character set (note that the letters 'I'...
<p>I have discovered the answer I was after. Here is my working code:</p> <pre><code> static void Main(string[] args) { string pattern = @"^\s*((?&lt;group&gt;[ABCDEFGHJKLMNPQRSTVXYZ0123456789]{8})-?){3}\s*$"; string input = "H3Y5NC8E-TGA5B6SB-2NVAQ4E0"; Regex re = new Regex(pattern); ...
<p>Why use Regex? If the groups are always split by a -, can't you use Split()?</p>
4,519
<p>I have a collection of collections, all the child collections have the same number of elements. The parent collection does nothing other than hold the child collections.</p> <pre><code>[0] [Child_0] [ID: 1] [0] [Child_0] [Amount: 4] [0] [Child_1] [ID: 2] [0] [Child_1] [Amount: 7] [1] [Child_0] [ID: 1] [1] [Child_0]...
<p>It sounds like a simple selectmany, group and average should do the job; here I'm using anonymous types and arrays purely for convenience of typing...</p> <pre><code> // the data var outer = new[] { new[] { new {ID=1,Amount=4}, // [0] [Child_0] [ID: 1, Amount: 4] ...
<p>you may be able to us this as a guide</p> <pre><code> var items = new[] { new { ID = 1, Amount = 4 }, new { ID = 1, Amount = 5 }, new { ID = 2, Amount = 5 }, new { ID = 2, Amount = 3 }, }; var results = from item in items group item ...
41,172
<p>Visual Studio is such a massively big product that even after years of working with it I sometimes stumble upon a new/better way to do things or things I didn't even know were possible.</p> <p>For instance-</p> <ul> <li><p><kbd>Crtl</kbd> + <kbd>R</kbd>, <kbd>Ctrl</kbd> + <kbd>W</kbd> to show white spaces. Essenti...
<p>Make a selection with ALT pressed - selects a square of text instead of whole lines.</p>
<p>Visual Assist, in general, while a bit OT for this question, is a great app and really helps with the day-to-day running of visual studio. Their open-any-file and find-any-symbol windows are particularly awesome.</p>
12,572
<p>What programming languages support arbitrary precision arithmetic and could you give a short example of how to print an arbitrary number of digits?</p>
<p>Some languages have this support built in. For example, take a look at <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/math/BigDecimal.html" rel="noreferrer">java.math.BigDecimal</a> in Java, or <a href="http://www.python.org/doc/current/lib/module-decimal.html" rel="noreferrer">decimal.Decimal</a> in Python.<...
<p><strong>Haskell</strong> has excellent support for arbitrary-precision arithmetic built in, and using it is the default behavior. At the REPL, with no imports or setup required:</p> <pre><code>Prelude&gt; 2 ^ 2 ^ 12 1044388881413152506691752710716624382579964249047383780384233483283953907971557456848826811934997558...
17,263
<p>I have a simple GUI component written in Java. The class draws an analog clock in a java.awt.canvas.<br> This canvas is then contained in a JFrame - What I want to do is give the canvas a 3d "raised" effect - almost like adding a drop shadow to a photo. Is there a simple way to do this?</p>
<p>If you are using a JFrame, then you have two options:</p> <ol> <li><p>Add your own component to a JPanel first and then add this to the JFrame.</p></li> <li><p>Instead of inheriting from java.awt.Canvas, you can inherit from JComponent. Then you would have to do all your painting in the paintComponent() Method inst...
<p>If you were using a Swing element, you'd use the createRaisedBevelBorder() method of the BorderFactory and set the canvas' border to the resulting border. Canvas is an AWT component, so you'll need to wrap it in a Swing component to which you can set the border.</p>
24,326
<p>I've used both SVN and CVS a little bit, but will need to choose one for a new project I will be starting.</p> <p>Can anyone who has used both extensively please offer some pros and cons and which they think is better? Best learning resources would be appreciated too.</p> <p>This will be for a small project, just...
<p>I've used both. There is no comparison; you want svn. The only reason to use CVS is because you are entering or taking over a legacy system with management that does not want to change the status quo. If you are starting on a new project, it is virtually a logical impossibility to argue that CVS is better than Su...
<p>Subversion is like `a better CVS'. It handles moving files AND directories well. It has branching support, although that is inferior to Distributed VCSs.</p> <p>You may also consider using a distributed VCS one like git, bazaar or mercurial.</p> <p>Edit: Here is a <a href="https://stackoverflow.com/questions/1261/...
30,424
<p>I'm working on a service that needs to detect user states for all user(s) logged on to a single machine. Specifically, I want to check to see whether or not the screen saver is active and whether or not their session is locked.</p> <p>This code will run under a system-level service, and has no visible UI, so that m...
<p>As a serivce you can use the event OnSessionChange to catch all your relevant moments.</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ServiceProcess; using System.Diagnostics; namespace MyCode { class MyService : ServiceBase { publi...
<p>A simpler solution would be to use <a href="http://cassia.googlecode.com/" rel="nofollow noreferrer">Cassia</a>, which wraps the various TS APIs, to check how long users have been idle for:</p> <pre><code>using Cassia; foreach (ITerminalServicesSession session in new TerminalServicesManager().GetSessions()) { ...
30,838
<p>I'm sick and tired of manually tracking my branches and merges across my repository! It's too error prone. In a world where everyone seems to get the idea of reducing duplication and automating everything, subversion branching/merging feels like it's left over from the 80's. What is a good alternative to subversion ...
<p>Have you upgraded to Subversion 1.5? It includes automated merge tracking. This may address your issue. It sounds like you're already familiar with the tool itself and it's free. So, if you upgrade your current solution to 1.5 you'll have almost no learning curve and zero cost - plus you won't have to go through...
<p>git - <a href="http://git.or.cz/" rel="nofollow noreferrer">http://git.or.cz/</a> ( i am quite fond of git, great @ branching and distributed development) - <a href="http://github.com/" rel="nofollow noreferrer">http://github.com/</a> is a great working example.</p>
9,489
<p>What are the popular (ok, popular is relative) web frameworks for the various flavours of LISP?</p>
<p><a href="http://weitz.de/hunchentoot/" rel="noreferrer">Hunchentoot</a> is also quite widespread</p>
<p>This question is a bit old but I thought I'd share my recent discovery: the <a href="http://hop.inria.fr/" rel="nofollow">Hop language</a> which is based on Scheme and is quite complete. </p> <blockquote> <p>HOP is a multi-tier programming language for the Web 2.0 and the so-called diffuse Web. It is designed for...
20,214
<p>If I have a table like this:</p> <pre><code>CREATE TABLE sizes ( name ENUM('small', 'medium', 'large') ); </code></pre> <p>Is MySQL going to store those strings in every row, or internally will it use something smaller like integers to know which enum value to refer to?</p> <p>I want to use an enum in a table...
<p>It converts them to integers on INSERT / UPDATE and back to strings on SELECT so the internal storage is as integers but you don't get exposed to that.</p> <p>You can retrieve the integer like <code>SELECT mycolumn + 0</code>.</p> <p>See <a href="http://dev.mysql.com/doc/refman/5.0/en/enum.html" rel="noreferrer">E...
<p>First, I wouldn't worry about space consumption when deciding whether or not to use an enum. Disk space is both plentiful and cheap. </p> <p>Second, it stores the strings in the column definition and then stores the appropriate enum within each record. According to <a href="http://www.making-the-web.com/2008/03/24/...
32,431
<p>I have a VB6 project in Visual Source Safe 6.0. When I open the project I want to Check Out (Get) all the files in the project so that I can edit them.</p> <p>I have the VSS Options (within VB6) set to act on the Project recursively, but when I check out the project.vbp it only checks out the project file, not all ...
<p><strong>SOLUTION</strong>: Select the <em>Project.vbp</em> and, from the Tool>SourceSafe menu choose Check Out, you get a dialog which lets you choose ALL files (you get a checkbox for each and a button for Select All).</p> <p><strong>Why I had problems</strong></p> <p>For some reason, if you <em>right-click</em> ...
<p>FWIW generally speaking you get more options when choosing 'Check out...' via the Tools menu as compared with choosing 'Check out' from the right click context menu. One of the more useful 'Advanced' options is to check out with out 'getting' (i.e. replacing) your local file.</p>
21,295
<p>Anyone happen to have a sample script for recursing a given directory in a filesystem with Powershell? Ultimately what I'm wanting to do is create a script that will generate NSIS file lists for me given a directory. Something very similar to what was done <a href="http://blogs.oracle.com/duffblog/2006/12/dynamic_fi...
<p>As <a href="https://stackoverflow.com/questions/101783/recursing-the-file-system-with-powershell#106413">halr9000</a> demonstrated, you can use the <code>-recurse</code> switch parameter of the <code>Get-ChildItem</code> cmdlet to retrieve all files and directories under a specified path.</p> <p>It looks like the b...
<p>This is a "paraphrase" port of that bash script.</p> <pre><code>$path = "c:\path\to\program" $installFiles = "installfiles_list.txt" $uninstFiles = "uninstfiles_list.txt" $files = get-childitem -path $path -recurse | where-object { ! $_.psIsContainer } # won't include dirs $filepath = $files | foreach-object { $_.F...
12,727
<p>I'm trying to retrieve data from an SQL Server 2000 server, and place into Excel. Which sounds simple I know. I'm currently Copying, and Pasting into Excel, from Management Studio</p> <p>The problem is one of the columns is an address, and it’s not retaining the newlines. These new lines have to stay in the same ce...
<p>Try running this macro on the worksheet. (Right click the worksheet tab and click "View Code" to summon the VB IDE.)</p> <pre><code>Sub FixNewlines() For Each Cell In UsedRange Cell.FormulaR1C1 = Replace(Cell.FormulaR1C1, Chr(13), "") Next Cell End Sub </code></pre>
<p>For some reason, Excel seems to use those characters the other way around, that is:</p> <pre><code>"a" &amp; Chr(13) + Chr(10) &amp; "b" </code></pre>
47,087
<p>I've found a couple of references (<a href="http://www.javapractices.com/topic/TopicAction.do?Id=23" rel="noreferrer">for example</a>) that suggest using <code>final</code> as much as possible and I'm wondering how important that is. This is mainly in the the context of method parameters and local variables, not fin...
<p>Obsess over:</p> <ul> <li>Final fields - Marking fields as final forces them to be set by end of construction, making that field reference immutable. This allows safe publication of fields and can avoid the need for synchronization on later reads. (Note that for an object reference, only the field reference is im...
<p>First of all, the final keyword is used to make a variable constant. Constant means it does not change. For example: </p> <pre><code>final int CM_PER_INCH = 2.54; </code></pre> <p>You would declare the variable final because a centimeter per inch does not change.</p> <p>If you try to override a final value, the v...
18,650
<p>I have an ASP.NET 3.5 WebForm that leverages the frameworks Page.ClientScript.GetCallbackEventReference() method and I'd like some of the calls to be synchronous. </p> <p>Now, the documentation says that the 5th parameter (see below) controls this. Specifically, when you pass 'false' it's supposed to be a non-asy...
<p><strong>ASPX Page</strong></p> <pre><code>&lt;%@ Page Language="VB" AutoEventWireup="false" CodeFile="How-to-use-GetCallbackEventReference.aspx.vb" Inherits="How_to_use_Callback" %&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &...
<p>For any other poor souls still using the MS AJAX library I found the following post: </p> <p><a href="https://social.msdn.microsoft.com/Forums/vstudio/en-US/f4134c2e-ca04-423a-9da3-c613713a7b52/synchronous-callbacks-with-the-net-20-framework?forum=netfxjscript" rel="nofollow noreferrer">https://social.msdn.microsof...
17,752
<p>For a C# UserControl on Windows Mobile (though please answer if you know it for full Windows...it might work) how do you change what shows up in the Designer Properties window for one of the Control's public Properties. For example:</p> <pre><code>private Color blah = Color.Black; public Color Blah { get { re...
<p><code>DesignerCategory</code> is used to say if the class is a form, component etc.</p> <p>For full windows the attribute you want is:</p> <pre><code>[System.ComponentModel.Category("Custom")] </code></pre> <p>and for the description you can use <code>[System.ComponentModel.Description("This is the description")]...
<p>The article does not suggest that anyone is designing ON the device. However, when you create a Compact Framework project, the compact framework (for your desktop PC) is used to handle design time rendering. If you think about it that is what you expect. The same framework (or nearly so) is used to do the renderi...
3,017
<p>GNU gcc 4.3 partially supports the upcoming c++0x standard: among the implemented features the rvalue reference. By means of the rvalue reference it should be possible to move a non-copyable object or return it from a function. </p> <p>Are std::streams already movable <strong>by means of rvalue reference</strong> o...
<p>In the current g++ svn, rvalue reference support has not yet been added to streams. I suspect adding it will not be too difficult and as ever with open source software, patches are, I'm sure, welcome!</p>
<p>After a quick investigation it comes out that the <strong>rvalue reference</strong> support has not been added yet to streams. </p> <p>To return a non-copyable object from a function indeed it is sufficient to implement the <em>move constructor</em> as follows:</p> <pre><code>struct noncopyable { noncopyable()...
32,806
<p>This is related to <a href="https://stackoverflow.com/questions/43324/can-i-put-an-aspnet-session-id-in-a-hidden-form-field">another question I asked</a>. In summary, I have a special case of a URL where, when a form is POSTed to it, I can't rely on cookies for authentication or to maintain the user's session, but I...
<p>If you hash in a time-stamp along with the user name and password, you can close the window for replay attacks to within a couple of seconds. I don't know if this meets your needs, but it is at least a partial solution.</p>
<p>If you only accept each key once (say, make the key a GUID, and then check when it comes back), that would prevent replays. Of course, if the attacker responds <em>first</em>, then you have a new problem...</p>
6,615
<p>In excel 2007, I have a formula in a cell like the following:</p> <pre><code>=COUNTIFS('2008-10-31'!$C:$C;"&gt;="&amp;'$A7) </code></pre> <p>Now I want to make the name of the sheet ('2008-10-31') be dependent on the value of some cell (say A1). Something like: </p> <pre><code>=COUNTIFS(A1!$C:$C;"&gt;="&amp;'$A7)...
<p>INDIRECT does what you want. Note that if the sheet name has any spaces, you need to put single quotes round it, ie </p> <pre><code>=COUNTIFS(INDIRECT("'" &amp; A1 &amp; "'!$C:$C"); "&gt;=" &amp; $A7) </code></pre>
<p>You are looking for the INDIRECT worksheet function:</p> <pre><code>=INDIRECT("SHEET2!A1") =COUNTIFS(INDIRECT(A1 &amp; "!$C:$C"); "&gt;=" &amp; $A7) </code></pre> <p>The function turns a string into a real cell reference.</p>
32,205
<p>I'm working on a windows forms application (C#) where a user is entering data in a form. At any point while editing the data in the form the user can click one of the buttons on the form to perform certain actions. By default the focus goes to the clicked button so the user has to click back on to the control they...
<p>For a bit of 'simplicity' maybe try.</p> <pre><code>public Form1() { InitializeComponent(); foreach (Control ctrl in Controls) { if (ctrl is TextBox) { ctrl.Enter += delegate(object sender, EventArgs e) { ...
<p>Your implementation looks good enough -- what I do want to know is why you want to do this in the first place? Won't it be preferrable for the focus to cycle back to the first entry? Is the data in the last text box so malleable that once they click the button it is "remembered"? Or do you have some sort of operatio...
5,797
<p>Given the following Flash method:</p> <pre><code>function sendToJava(name:String, ... args) { ExternalInterface.call("sendCommand", name, args); } </code></pre> <p>How do I ensure that ExternalInterface.call() interprets args in its expanded form? Right now, if I pass a list into "args", that list gets interpret...
<p>One small typo. It should be:</p> <pre><code>function sendToJava(name:String, ... args) { // See Array.unshift() args.unshift("sendCommand", name); // See Function.apply() ExternalInterface.call.apply(null, args); } </code></pre> <p>Just change "array" to "apply"</p> <p>Anyways, thanks a ton for posting...
<p>I found an answer on IRC :)</p> <pre><code>function sendToJava(name:String, ... args) { // See Array.unshift() args.unshift("sendCommand", name); // See Function.apply() ExternalInterface.call.array(null, args); } </code></pre>
44,004
<p>EDIT: <strong>I would really like to see some general discussion about the formats, their pros and cons!</strong></p> <p>EDIT2: The 'bounty didn't really help to create the needed discussion, there are a few interesting answers but the comprehensive coverage of the topic is still missing. Six persons marked the que...
<p>There is always <a href="http://toolkit.translatehouse.org/" rel="noreferrer">Translate Toolkit</a> which allow translating between I think <strong>all</strong> mentioned formats, and preferred gettext (po) and XLIFF.</p>
<p>One rather simple approach is to just use a resource file and resource script. Programs like MSVC have no problem editing them. They're also reasonably friendly to other systems (and to text editors) as well. You can just create separate string tables (and bitmap tables) for each language, and mark each such tabl...
35,434
<p>When I generate a default scaffold, the display tags on show.html.erb have</p> <pre><code>&lt;%=h @broker.name %&gt; </code></pre> <p>I know the difference between <code>&lt;%</code> and <code>&lt;%=</code>. What's the "h" do?</p>
<p>html escape. It's a method that converts things like &lt; and > into numerical character references so that rendering won't break your html.</p>
<p>Way late to the party but I'm adding a further explanation to what <code>html_escape</code> is doing to hopefully help other noobs like myself understand what's happening. Rails 3 and later automatically escape all output now and so there are much fewer situations where <code>html_escape</code> aka <code>h()</code>...
37,950
<p>If you (or your organization) aspires to thoroughly unit test your code, how do you measure the success or quality of your efforts? </p> <ul> <li>Do you use code coverage, what percentage do you aim for? </li> <li>Do you find that philosophies like TDD have a better impact than metrics?</li> </ul>
<p>My tip is not a way to determine whether you have good unit tests per se, but it's a way to grow a good test suite over time.</p> <p>Whenever you encounter a bug, either in your development or reported by someone else, fix it twice. You first create a unit test that reproduces the problem. When you've got a failing...
<ul> <li>In addition to TDD, I found myself writing more sane tests since BDD (e.g. <a href="http://rspec.info/" rel="nofollow noreferrer">http://rspec.info/</a>)</li> <li>The everlasting discussion is always to mock or not to mock. Some mocks might become more complex than the code it is testing (which usually points ...
32,892
<p>I'm in need of a functional OleDB data provider for PostgreSQL. It should be similar to the ODBC provider for MySQL. See <a href="http://dev.mysql.com/downloads/connector/odbc/5.1.html" rel="noreferrer">http://dev.mysql.com/downloads/connector/odbc/5.1.html</a></p>
<p>The postgres <a href="http://www.postgresql.org/download/products/2" rel="nofollow noreferrer">software catalog</a> has some providers on there.</p>
<p>If you want to check the last version of ODBC for PosgreSQL : <a href="http://www.postgresql.org/ftp/odbc/versions/" rel="nofollow">http://www.postgresql.org/ftp/odbc/versions/</a></p> <p>Enter in the "msi" folder for the installer. But be careful, when you are using ODBC, there is a 32bits and a 64bits version. So...
43,076
<p>I am trying to work out how to get the value of table cell for each row using jQuery.</p> <p>My table looks like this:</p> <pre><code>&lt;table id="mytable"&gt; &lt;tr&gt; &lt;th&gt;Customer Id&lt;/th&gt; &lt;th&gt;Result&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;123&lt;/td&gt; &lt;td&gt;&l...
<p>If you can, it might be worth using a class attribute on the TD containing the customer ID so you can write:</p> <pre><code>$('#mytable tr').each(function() { var customerId = $(this).find(".customerIDCell").html(); }); </code></pre> <p>Essentially this is the same as the other solutions (possibly because...
<p>try this :</p> <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Untitled&lt;/title&gt; &lt;script type="text/javascript"&gt;&lt;!-- function getVal(e) { var targ; if (!e) var e = window.event; if (e.target) targ = e.target; ...
49,216
<p>I already found this article:</p> <p><a href="http://www.dotnetcurry.com/ShowArticle.aspx?ID=181&amp;AspxAutoDetectCookieSupport=1" rel="nofollow noreferrer">http://www.dotnetcurry.com/ShowArticle.aspx?ID=181&amp;AspxAutoDetectCookieSupport=1</a></p> <p>But I've got a different situation. I am embedding some hidde...
<p>Rather than storing the position information in a hidden field, store it in a cookie. The information is small, so it will have minimal effect on the page load performance.</p>
<p>ok so I got the drag stuff to work, saves in a database and all, brings up cool on my one monitor 1600X1050 all good, fine and dandy! BUT WAIT! I bring up the same page on my other monitor 1366x768 and the panels are all off.</p> <p>The save function saves in pixels, so when you move over to another "resolution" th...
7,906
<p>Upgraded to Flash 10 today and now many flash videos aren't playing on a lot of sites, including a couple i've created. What's the fix?</p> <p><strong>edit</strong> Let me clarify here. this question is intended to find the code change that is needed to allow users of all versions of flash, including the most recen...
<p>Flash APIs only provide the version number in String form, so the probable cause is scripts that pull a single character out of the version string, and see "1" instead of "10". That, or scripts that naively check <code>(version==9)</code> instead of <code>(version&gt;9)</code>.</p> <p>Note: comparisons like <code>...
<p>It is probably due to version checking.</p> <p>Make sure the sites can handle double digit version numbers correctly. Especially when using strings, "9" is larger than "10" in many implementations.</p>
26,357
<p>Yes XML is human readable but so is comma delimited text and properties files.</p> <p>XML is bloated, hard to parse, hard to modify in code, plus a ton of other problems that I can think about with it. </p> <p>My questions is what are XML's most attractive qualities that has made it so popular????</p>
<p>It was the late 90s and the internet was hot hot hot, but companies had systems that couldn't get anywhere near the internet. They had spent countless hours dealing with CORBA and were plotting using Enterprise JavaBeans to get these older systems communicating with their newer systems.</p> <p>Along comes SGML, wh...
<p>It's easier to write a parser for an XML dialect than for an arbitrary one because of tools that are available. </p> <p>Using a DOM parser, for example, is much simpler than lexx and yacc, especially in Java where it was popularized.</p>
14,161
<p>I'm rewriting a PHP+MySQL site that averages 40-50 hits a day using Django. </p> <p>Is SQLite a suitable database to use here? Are there any advantages/disadvantages between them?</p> <p>I'm just using the db to store a blog and the users who can edit it. I am using fulltext search for the blog search, but no comp...
<p>40-50 hits per day is very small and SQLLite can be used without any problem.</p> <p>MySql might be better once you will get more hit because it handles in a better way multiple connexion (lock isn't the same with MySql and SqlLite).</p>
<p>SQLite would be fine for this level of traffic. It actually performs quite well, the only thing that it is lacking is caching of data and queries because it needs to be spun up every time your page is accessed. That said, it is still very quick and it shouldn't be too hard to migrate to MySQL later if need be.</p>
41,503
<p>What are the advantages and disadvantages of turning <strong><code>NOCOUNT</code></strong> off in SQL server queries? ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­</p>
<p>From SQL BOL: </p> <blockquote> <p>SET NOCOUNT ON prevents the sending of DONE_IN_PROC messages to the client for each statement in a stored procedure. For stored procedures that contain several statements that do not return much actual data, <strong>setting SET NOCOUNT to ON can provide a signific...
<p>I personally like to turn <strong>NOCOUNT</strong> on for queries that get run in an manual fashion and use a lot of <code>Print</code> statements to output debugging messages. In this way, your output would look less like:</p> <pre> Updating usernames (287 rows updated) Done Updating passwords (287 rows updated)...
4,611
<p>I was wondering if anyone knew of a macro or keyboard shortcut or anything really that would automate Attaching to a Process within visual studio?</p>
<p><code>System.Diagnostics.Debugger.Break()</code></p> <p>"If no debugger is attached, users are asked if they want to attach a debugger. If yes, the debugger is started. If a debugger is attached, the debugger is signaled with a user breakpoint event, and the debugger suspends execution of the process just as if a d...
<p>You can just record a macro and assign a keyboard shortcut to it in the options dialog. That's what I did. I press CTRL-ALT-SHIFT-Z and it attaches to aspnet_wp.exe for me.</p>
39,028
<p>I'm trying to read variables from a batch file for later use in the batch script, which is a Java launcher. I'd ideally like to have the same format for the settings file on all platforms (Unix, Windows), and also be a valid Java Properties file. That is, it should look like this:</p> <pre><code>setting1=Value1 set...
<p>You can do this in a batch file as follows:</p> <pre><code>setlocal FOR /F "tokens=*" %%i in ('type Settings.txt') do SET %%i java -Dsetting1=%setting1% ... endlocal </code></pre> <p>This reads a text file containing strings like "SETTING1=VALUE1" and calls SET to set them as environment variables.</p> <p>setloca...
<p>You can also access the OS' environment variables from within a Java program:</p> <pre><code>import java.util.Map; public class EnvMap { public static void main (String[] args) { Map&lt;String, String&gt; env = System.getenv(); for (String envName : env.keySet()) { System.out.format...
28,805
<p>Currently I am using a 12 volts, 20 amperes power supply (Model S-240-12) </p> <p><a href="https://i.stack.imgur.com/fraEVm.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fraEVm.jpg" alt="enter image description here"></a></p> <p>The stepper motors and the extruder need 5 amp, and the heated be...
<p>Changing the PSU with one with a higher amperage will <em><strong>not</strong></em> make the bed heat up any faster unless the PSU is underrated for the amperage required and the voltage is dropping as a result of the load. This can be checked by measuring the output voltage with a multimeter (when the PSU is loaded...
<p>May I recommend an alternative approach, which does not require any change of hardware? The time required to heat the bed is not huge, so either via USB from your computer or from the front panel, instruct your printer to heat the bed first, while you're setting everything else up (loading gcode files, changing fi...
891
<p>I have a SVN repository for my project; it keeps code, docs, graphs, etc. Everything related to the project is there and versioned. However, I am trying to get some kind of intelligent stats for my code. The stat program I am using is StatSVN - they seem to be best of breed as far as I can tell. However, I am getti...
<p>I built StatSVN and currently maintain it :) </p> <p>You can use exclude based on filenames and folders. Take a look at our <a href="http://wiki.statsvn.org/User%20Manual.ashx" rel="nofollow noreferrer">wiki</a>!</p>
<p>It may or may not be what you are looking for, but I wrote a web based app that creates a report from the commit messages to SubVersion. It's still pretty light-weight, no real stats or anything like that, but it may help.</p> <p><a href="http://krazyyak.com/svnreport" rel="nofollow noreferrer">http://krazyyak.com/...
23,391
<p>I'm assuming this is an easy question, but I'll be darned if I can find the answer.</p> <p>I have a website in Visual Studio 2008. The paths to the stylesheets (and images) are in the following format /css/stylesheetname.css</p> <p>At the root of the web project in Visual studio the folder exists as does the style...
<p>I think the correct solution is to use relative urls in the style sheet instead of absolute urls as you use now.</p> <p>Do note that relative urls in style sheets are relative to the location of the style sheet, not the current page being view by the browser.</p> <p>If you use ASP.NET Themes, you can put all your ...
<p>it has been ages since I did anything in css, but maybe url(./images/image.jpg) will work?</p> <p>Edit: Or rather ~/format /css/stylesheetname.css or ./format /css/stylesheetname.css as the url to the stylesheet.</p>
47,305
<p>Is it possible to use an <strong>IF</strong> clause within a <strong>WHERE</strong> clause in MS SQL?</p> <p>Example:</p> <pre><code>WHERE IF IsNumeric(@OrderNumber) = 1 OrderNumber = @OrderNumber ELSE OrderNumber LIKE '%' + @OrderNumber + '%' </code></pre>
<p>Use a <a href="http://msdn.microsoft.com/en-us/library/ms181765.aspx" rel="noreferrer">CASE</a> statement<br> <strong>UPDATE:</strong> The previous syntax (as pointed out by a few people) doesn't work. You can use CASE as follows:</p> <pre><code>WHERE OrderNumber LIKE CASE WHEN IsNumeric(@OrderNumber) = 1 THEN ...
<pre><code>If @LstTransDt is Null begin Set @OpenQty=0 end else begin Select @OpenQty=IsNull(Sum(ClosingQty),0) From ProductAndDepotWiseMonitoring Where Pcd=@PCd And PtpCd=@P...
11,343
<p>I need to be able to receive a fax in a java application. I was wondering what are some ways of doing this. Efax? Use a fax to email provider?</p>
<p>I suggest using fax to email. I've been using <a href="http://www.rapidfax.com" rel="nofollow noreferrer">RapidFax</a> for the past year or so, and it is fairly inexpensive and fast. I'm happy with it.</p> <p>Alternatively, there are some Web Service based fax services, like <a href="http://www.interfax.net" rel="n...
<p>This can be done from Java on an API-accessible internet fax service such as Interfax. There are <a href="http://www.interfax.net/en/dev/java" rel="nofollow">Java fax</a> samples available on their site for review and download.</p> <p>Once you've signed up for inbound fax service (free for developers), download the...
22,355
<p>I provide a web service to my organisation. i was wondering would anyone recommeding the use of apache cactus for setting up a testing framework or has anyone worked with any other web service frameworks that may be useful?</p> <p>Thanks Damien</p>
<p>As you are dealing with a web service you would not need to use Jakarta Cactus and could get away with writing plain old JUnit tests.</p> <p>The tests would take two forms:</p> <p><strong>1. Does the underlying functionality work as expected?</strong></p> <p>This has nothing to do with the web service itself but ...
<p>Apache retired Jakarta Cactus on 2011/08/05, so it can't be recommended for any new project.</p>
24,470
<p>I've got a UserControl that contains an UpdatePanel. When I put that on a page, it throws the following error:</p> <blockquote> <p>Cannot unregister UpdatePanel with ID 'ReviewContentUpdatePanel' since it was not registered with the ScriptManager. This might occur if the UpdatePanel was removed from the ...
<p>This error occurs when the Controls collection in which the UpdatePanel is resided is cleared using the <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.controlcollection.clear.aspx" rel="noreferrer">Clear method</a>, or when the specific UpdatePanel is removed using the <a href="http://msdn.microsoft....
<p>Have you tried including a ScriptManagerProxy in the user control?</p>
29,555
<p>When I call this function, everything works, as long as I don't try to recursively call the function again. In other words if I uncomment the line:</p> <pre><code>GetChilds rsData("AcctID"), intLevel + 1 </code></pre> <p>Then the function breaks. </p> <pre><code>&lt;% Function GetChilds(ParentID, intLevel) ...
<p>Look like it fails because your connection is still busy serving the RecordSet from the previous call. </p> <p>One option is to use a fresh connection for each call. The danger there is that you'll quickly run out of connections if you recurse too many times.</p> <p>Another option is to read the contents of each...
<p>try declaring the variables as local using a DIM statement within the function definition:</p> <pre><code>Function GetChilds(ParentID, intLevel) Dim rsData, sSQL Set ... </code></pre> <p>Edit: Ok, I try to be more explicit.</p> <p>My understanding is that since rsData is not declared by DIM, it is not a local var...
38,438
<p>In C/C++, what an <code>unsigned char</code> is used for? How is it different from a regular <code>char</code>?</p>
<p>In C++, there are three <em>distinct</em> character types:</p> <ul> <li><code>char</code></li> <li><code>signed char</code></li> <li><code>unsigned char</code></li> </ul> <p>If you are using character types for <em>text</em>, use the unqualified <code>char</code>:</p> <ul> <li>it is the type of character literals li...
<p>Some googling found <a href="http://bytes.com/forum/thread61480.html" rel="nofollow noreferrer">this</a>, where people had a discussion about this.</p> <p>An unsigned char is basically a single byte. So, you would use this if you need one byte of data (for example, maybe you want to use it to set flags on and off ...
10,082
<p>In MySQL, how do I get a list of all foreign key constraints pointing to a particular table? a particular column? This is the same thing as <a href="https://stackoverflow.com/questions/85978/query-a-tables-foreign-key-relationships">this Oracle question</a>, but for MySQL.</p>
<p><strong>For a Table:</strong></p> <pre><code>SELECT TABLE_NAME,COLUMN_NAME,CONSTRAINT_NAME, REFERENCED_TABLE_NAME,REFERENCED_COLUMN_NAME FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE REFERENCED_TABLE_SCHEMA = '&lt;database&gt;' AND REFERENCED_TABLE_NAME = '&lt;table&gt;'; </code></pre> <p><strong>For a C...
<p>To find all tables <strong>containing a particular foreign key</strong> such as <code>employee_id</code></p> <pre><code>SELECT DISTINCT TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME IN ('employee_id') AND TABLE_SCHEMA='table_name'; </code></pre>
24,624
<p>Let's say I have two arrays:</p> <blockquote> <p>int ArrayA[] = {5, 17, 150, 230, 285};</p> <p>int ArrayB[] = {7, 11, 57, 110, 230, 250};</p> </blockquote> <p>Both arrays are sorted and can be any size. I am looking for an efficient algorithm to find if the arrays contain any duplicated elements between them. I just...
<p>Pretend that you are doing a mergesort, but don't send the results anywhere. If you get to the end of either source, there is no intersection. Each time you compare the next element of each, if they are equal, there is an intersection.</p> <p>For example:</p> <pre><code>counterA = 0; counterB = 0; for(;;) { ...
<p>If the range of values is small, you could build a lookup table for one of them (time cost = O(N)) and then check if the bit is set from the other list (time cost = O(N)). If the range is large, you could do something similar with a hash table.</p> <p>The mergesort trick from Glomek is an even better idea.</p>
30,460
<p>How do I remove a trailing comma from a string in ColdFusion?</p>
<p>To remove a trailing comma (if it exists):</p> <pre><code>REReplace(list, ",$", "") </code></pre> <p>To strip one or more trailing commas:</p> <pre><code>REReplace(list, ",+$", "") </code></pre>
<p>Remove "," from Both Sides, Just the Right Side, or Just the Left Side</p> <pre><code>&lt;cfset theFunnyList = ",!@2ed32,a,b,c,d,%442,d,a"&gt; </code></pre> <p>Replace Funny Characters and Separate with Comma</p> <pre><code>&lt;cfset theList = rereplace(theFunnyList, "[^A-Za-z0-9]+", ",", "all")&gt; &lt;cfset the...
22,049
<p>I have two forms in microsoft access, one called Bill and the other one called Payment. They both have Total amount as a field in both of the forms. I am trying to reference the Bill total amount to the Payment total amount. </p> <p>I have tried in the Payment total amount control source : =Forms!Bill![Total Amount...
<p>Is either of the forms a subform? If so, you need to reference the subform control or the parent property:</p> <pre><code>Me.Parent.[Total order] Me.[Subform Control name Here].form.[Total order] </code></pre> <p>Note that the Subform Control name is not always the same as the form contained.</p> <p>EDIT: Either...
<p>Remou's answer only works in code - however it looks like you are defining the control source of a text box so try this: </p> <pre><code>=Forms("Bill")![Total order] </code></pre>
34,506
<p>Or do you populate your form controls manually by a method?</p> <p>Is either considered a best practice?</p>
<p>It's really about what you trying to achieve</p> <ul> <li><p>Gridview - Limited in design, works like an html table. More in built functionality like edit/update, page, sort. Lots of overhead. </p></li> <li><p>DataGrid - Old version of the Gridview. A gridview is a super datagrid.</p></li> <li><p>Datalist - more cu...
<p>It all comes down to how you want to layout your data.</p> <p>If you need to control the layout (like tables versus CSS versus whatever), when use a Repeater or ListView. Between the two, ListView gives you a lot more events and built-in commands for editing, selecting, inserting. Additionally paging and grouping f...
16,845
<p>I don't know why this bothers me so much, but when I create websites, I always try to do all my styling with CSS. However one thing I always have to remember to do when I'm working with tables is add cellspacing="0" and cellpadding="0"</p> <p>Why is there not a CSS property to override these antiquated HTML 4 attr...
<p><a href="http://www.w3schools.com/Css/pr_tab_border-collapse.asp" rel="noreferrer">Cellspacing</a> :</p> <pre><code>table { border-collapse: collapse; } </code></pre> <p>As for <a href="http://www.w3schools.com/css/css_padding.asp" rel="noreferrer">cellpadding</a>, you can do</p> <pre><code>table tr td, table tr ...
<pre><code>table { border-collapse:collapse; } </code></pre>
44,039
<p>How can I select the good method (I have in the example below show 2 differents way that doesn't work). I was using instead of a variable of type Object with a IF and IS to do the job but I am trying to avoid using Object and boxing/unboxing. So I thought that Generic could do the job but I am stuck here.</p> <p>H...
<p>No, you can't do this. Generics don't work like C++ templates - the generic method is compiled just once. The only information that the compiler can use for overload resolution is the information it knows about within the generic method, regardless of what code uses it.</p> <p>As an example to show this, here's a b...
<p>IIRC you can use the "where" clause to allow this</p> <pre><code>public T execute&lt;T&gt;(T obj) where : /* somthing */ { } </code></pre> <p>I always have to Google that one my self so I'll leave it at that.</p> <p>edit: reading some comments. I would not advise calling type specific code. Rather put that code i...
38,450
<p>Actually, I wanted a custom cell which contains 2 image objects and 1 text object, and I decided to make a container for those objects. </p> <p>So is it possible to hold a image in object and insert that object in any of the collection objects, and later use that object to display inside cell?</p>
<p>NSArray and NSDictionary both hold objects. These are most likely the collections you'll use with a table view.</p> <p>The best way to implement what you are trying to do is to use the UIImage class. UIImages wrap a CGImage and do all the memory management for you (if your app is running low on memory, the image da...
<p>There should be no problem with that. Just make sure you are properly retaining it and what not in your class.</p>
21,901
<p>Ok well I've been trying to convert my model to use LINQ but didn't want to throw away my current DTO's and their interfaces which are scattered through the domain.</p> <p>I managed to find this blog post which has outlined the process quite nicely:</p> <p><a href="http://www.sidarok.com/web/blog/content/2008/10/1...
<p>I guess the problem is in your test method. You created a Repository with a DataContext but you did your submits with another one.</p> <pre><code>[Test] public void AddSelectionShouldAddSelectionToMarket() { Market market = (Market) new Repository().GetMarket(1); Selection selection = new Selection(); ...
<p>I'd suggest sending your code to Sidar Ok. He's a nice guy and will point you in the right direction. Or at least post a comment on his blog pointing him to your question here.</p>
38,156
<p>Are there any free tools available to view the contents of the solution user options file (the .suo file that accompanies solution files)?</p> <p>I know it's basically formatted as a file system within the file, but I'd like to be able to view the contents so that I can figure out which aspects of my solution and c...
<p>The .SUO file is effectively disposable. If it's getting too large, just delete it. Visual Studio will create a fresh one.</p> <p>If you <em>do</em> want to go poking around in it, it looks like an OLE Compound Document File. You should be able to use the StgOpenStorage function to get hold of an IStorage pointer.<...
<p>I don't know any tool, but you can try to access user settings via <a href="http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.shell.interop.ivspersistsolutionopts_members%28VS.80%29.aspx" rel="nofollow noreferrer">IVsPersistSolutionOpts</a> interface</p>
7,766
<p>I've searched around a bit for similar questions, but other than running one command or perhaps a few command with items such as:</p> <pre><code>ssh user@host -t sudo su - </code></pre> <p>However, what if I essentially need to run a script on (let's say) 15 servers at once. Is this doable in bash? In a perfect wo...
<p>You can run a local script as shown by che and Yang, and/or you can use a Here document:</p> <pre><code>ssh root@server /bin/sh &lt;&lt;\EOF wget http://server/warfile # Could use NFS here cp app.war /location command 1 command 2 /etc/init.d/httpd restart EOF </code></pre>
<p>I'm not sure if this method will work for everything that you want, but you can try something like this:</p> <pre><code>$ cat your_script.sh | ssh your_host bash </code></pre> <p>Which will run the script (which resides locally) on the remote server.</p>
30,199
<p>I wish to put some text on a page and hide some data in that text. Does anybody know of any methods / patterns that have been used in the past to solve this problem?</p> <p>Example: I have the following text: "The cat sat on the dog and was happy."</p> <p>I also have the number 123. I want to hide this number in t...
<p>Of course this can be done.</p> <p>What you are describing is in a broad description called <a href="http://en.wikipedia.org/wiki/Steganography" rel="noreferrer">Steganography</a>.</p> <p>For instance, you might encode a number in such a way that you count the number of words until you see the letter B, in which c...
<p>Well, you could try something like <a href="https://www.spammimic.com/" rel="nofollow noreferrer">this</a>...not sure if that's exactly what you're looking for, though.</p>
44,966
<p>Let me start by saying I'm a huge fan of the elegance of this pattern -- I have a group of basic entities that I have implemented builders for (specifically for testing). However I have found (and this may be the caveat) that as my program evolved I kept having to go back and re-work the builders. In the end, it r...
<p>I like using fluent builders for the object under test to express the nature of the object I'm creating. ObjectMothers tend to get unwieldy and tend to (in the implementations I've come across) end up hiding details of the objects creation.</p> <p>Compare:</p> <pre><code>User fred = CreateUser("fred").WithReputati...
<p>If the test data builders become too complex to maintain, I would recommend switching to a <strong>mocking framework</strong>, which makes it more convenient to produce domain test objects with a known state.<br /><br /> Moreover with mocks you could make the test objects be more than simple stubs, and actually part...
22,757
<p>I'm working on a file sharing website, I need a way to take screenshots of the uploaded documents.</p> <p>The site will support several file formarts, from plain text to office documents (doc, xls, ppt, ...), videos (mpeg, avi, ...), images (jpg, gif, png, ...) PDF's, Open Office, etc.</p> <p>Each document need to...
<p>The Windows Thumbnail Viewer is a COM object which implements <a href="http://msdn.microsoft.com/en-us/library/bb761848%28VS.85%29.aspx" rel="nofollow noreferrer">IExtractImage</a>. Out of the box it supports many file types, and applications can add their own. By relying on that interface, you're more likely to get...
<p>For viewing PDF documents you can make use of the ITextSharp library. Here is the link: </p> <p><a href="http://itextsharp.sourceforge.net/" rel="nofollow noreferrer">http://itextsharp.sourceforge.net/</a></p>
21,154
<p>When i do </p> <pre><code>wnd = CreateWindow("EDIT", 0, WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN, x, y, w, h, parentWnd, NULL, NULL, NULL); </code></pre> <p>everything is fine, however if i remove the WS_VSCROLL and WS_HSC...
<p>Some control styles cannot be changed after window creation. The ES_AUTOHSCROLL style (which essentially controls word wrapping) is one of them; this is stated (somewhat indirectly) by the MSDN section on <a href="http://msdn.microsoft.com/en-us/library/bb775464.aspx" rel="noreferrer">Edit Control Styles</a>. You ca...
<p>You can do it with ShowScrollBar() function. You may also find interesting the function EnableScrollBar() if you want to enable/disable scroll bars of a window. Best regards.</p>
36,265
<p>I have a text file in the root of my web app <em><a href="http://localhost/foo.txt" rel="noreferrer">http://localhost/foo.txt</a></em> and I'd like to load it into a variable in javascript.. in groovy I would do this:</p> <pre><code>def fileContents = 'http://localhost/foo.txt'.toURL().text; println fileContents; <...
<p>XMLHttpRequest, i.e. AJAX, without the XML.</p> <p>The precise manner you do this is dependent on what JavaScript framework you're using, but if we disregard interoperability issues, your code will look something like:</p> <pre class="lang-js prettyprint-override"><code>var client = new XMLHttpRequest(); client.open...
<p>When working with jQuery, instead of using <code>jQuery.get</code>, e.g.</p> <pre><code>jQuery.get("foo.txt", undefined, function(data) { alert(data); }, "html").done(function() { alert("second success"); }).fail(function(jqXHR, textStatus) { alert(textStatus); }).always(function() { alert("finished...
23,870
<p>What are the C++ rules for calling the base class constructor from a derived class?</p> <p>For example, I know in Java, you must do it as the first line of the subclass constructor (and if you don't, an implicit call to a no-arg super constructor is assumed - giving you a compile error if that's missing).</p>
<p>Base class constructors are automatically called for you if they have no argument. If you want to call a superclass constructor with an argument, you must use the subclass's constructor initialization list. Unlike Java, C++ supports multiple inheritance (for better or worse), so the base class must be referred to ...
<p>If you simply want to <strong>pass all constructor arguments to the base-class</strong> (=parent), here is a minimal example.</p> <p>This uses templates to forward every constructor call with 1, 2 or 3 arguments to the parent class <code>std::string</code>.</p> <p><strong>Code</strong></p> <p><a href="https://techie...
14,698
<p>I'm currently working on some logging code that supposed to - among other things - print information about the calling function. This should be relatively easy, standard C++ has a <code>type_info</code> class. This contains the name of the typeid'd class/function/etc. but it's mangled. It's not very useful. I.e. <co...
<p>Given the attention this question / answer receives, and the valuable feedback from <a href="https://stackoverflow.com/questions/281818/unmangling-the-result-of-stdtype-infoname/4541470#comment26629807_4541470">GManNickG</a>, I have cleaned up the code a little bit. Two versions are given: one with C++11 features an...
<p>I've always wanted to use type_info, but I'm sure that the result of the name() member function is non-standard and won't necessarily return anything that can be converted to a meaningful result.<br> If you are sticking to one compiler, there maybe a compiler specific function that will do what you want. Check the ...
35,670
<p>There are many tools out there for writing and managing requirements, but are there any good ones for reviewing them? </p> <p>I'm not talking about <strong><em>managing</em></strong> reviews, but automation tools that look for common requirement blunders (such as using negative requirements, or ones that are worde...
<p>I'm working on a console application that takes a xml configuration file like this:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;ReqCheck&gt; &lt;Categories name="Reconsider wording"&gt; &lt;Keyword&gt;may&lt;/Keyword&gt; &lt;Keyword&gt;should&lt;/Keyword&gt; &lt;/Categories&gt; &lt...
<p>You might want to take a look at <a href="http://www.ravenflow.com/" rel="nofollow noreferrer">Ravenflow products</a>. I did not try them myself yet, but their features seem to be very close to what you are looking for...</p> <p><strong>NB:</strong> Ravenflow products are likely to be prohibitively expensive for sm...
26,219
<p>If I get an error code result from a Cocoa function, is there any easy way to figure out what it means (other than by grepping through all the .h files in the framework bundles)?</p>
<p>You should look at the <code>&lt;Framework/FrameworkErrors.h&gt;</code> header for whatever framework the method you're using that's returning an error comes from.</p> <p>For example, an <code>NSError</code> in the Cocoa domain that you get from a method in the Foundation framework will have its <code>code</code> p...
<p>For NSError errors add a line of code:</p> <pre><code>NSError *error; // ... Some code that returns an error // Get the error as a string NSString *s = [error localizedDescription]; // Observe the code for yourself or display to the user. </code></pre>
5,927
<p>I'm pre-compiling a C program containing Pro*C code with Oracle 10.2 and AIX 5.2</p> <p>The Oracle precompiler reads the <code>$ORACLE_HOME/precomp/admin/pcscfg.cfg file</code> which contains the definition of the sys_include variable (set to <code>/usr/include</code>).</p> <p>The Pro*C compiler complains that it ...
<p>From <a href="https://metalink2.oracle.com/metalink/plsql/f?p=130:3:9328216730994661370::::p3_database_id,p3_docid,p3_show_header,p3_show_help,p3_black_frame,p3_font:NOT,102288.1,1,1,1,helvetica" rel="noreferrer">Metalink</a></p> <pre><code>PCC-S-02201, Encountered the symbol "size_t" when expecting one of the fol...
<p>I modified placing /usr/include/linux before everything else. This cleared both the failure to find stddef.h and not knowing what size_t was. Placing it next to /usr/include only fixed the former.</p> <p>Modified pcscfg.cfg:</p> <p>sys_include=(<strong>/usr/include/linux,</strong>$ORACLE_HOME/precomp/public,/usr...
42,205
<p>I am new to php. I made a member registration on login page and adm too. So inside admin I wanted to get the list of the members and delete the members I dont want. So I took the a code from a sample code for phone book from <a href="http://localhost/xamp" rel="nofollow noreferrer">http://localhost/xamp</a> and edi...
<ol> <li>This should be a POST via a FORM not a href link (GET).</li> <li>$TEXT is obviously an array holding the text you want printed.</li> <li>You need to replace <code>&amp;amp;member_1d</code> in the href with a real &amp; and a real i as <code>&amp;member_id</code>.</li> </ol>
<p>An example of a list of members with delete links:</p> <pre><code>$query = mysql_query("SELECT member_id,firstname,lastname,login FROM members ORDER BY lastname"); if(mysql_num_row($query)!= 0){ //only continue if there are members in the database while($row = mysql_fetch_assoc($query)){ //loop through each row in ...
45,398
<p>From what I understand, if you have multiple web servers, then you need some kind of load balancer that will split the traffic amongst your web servers.</p> <p>Does this mean that the load balancer is the main connecting point on the network? ie. the load balancer has the IP address of the domain name?</p> <p>If t...
<p>There are several solutions to this "problem". You could round-robin at the DNS-level. I.e. have www.yourdomain.com point to several IP-addresses (well all your servers).</p> <p>This doesn't give you any intelligence in the load balancing, but the load will be more or less randomly distributed, but you wouldn't be ...
<p>It does (in general). It depends on what server OS and software you are using, but in general, you'll hit the load balancer for each request, and the load balancer will then farm out the work according to the scheme you have in place (round robin, least busy, session controlled, application controlled, etc...)</p>
30,118
<p>I have an array in Perl:</p> <pre><code>my @my_array = ("one","two","three","two","three"); </code></pre> <p>How do I remove the duplicates from the array?</p>
<p>You can do something like this as demonstrated in <a href="http://perldoc.perl.org/perlfaq4.html#How-can-I-remove-duplicate-elements-from-a-list-or-array%3f" rel="noreferrer">perlfaq4</a>:</p> <pre><code>sub uniq { my %seen; grep !$seen{$_}++, @_; } my @array = qw(one two three two three); my @filtered = u...
<p>Try this, seems the uniq function needs a sorted list to work properly.</p> <pre><code>use strict; # Helper function to remove duplicates in a list. sub uniq { my %seen; grep !$seen{$_}++, @_; } my @teststrings = ("one", "two", "three", "one"); my @filtered = uniq @teststrings; print "uniq: @filtered\n"; my ...
2,920
<p>Following the question I asked here: <a href="https://3dprinting.stackexchange.com/questions/8735/replace-x-axis-motor-with-different-model/8738?noredirect=1#comment14916_8738">Replace X axis motor with different model</a></p> <p>I have a problem with my new motor. My X-axis is now moved by a 17HS3401S motor, inste...
<p>The overall torque, and thus the incremental torque is less with your new stepper, this may result in less smooth operation because of moving the weight of the carriage (e.g. when you have a direct extruder mounted on the X carriage). </p> <p>You could be facing skipping steps, resulting in less accurate prints. Ma...
<p>One other possibility is that the printer is "gap-filling". When there is a space between walls that isn't enough for infill or a roof layer, the slicer can be told to fill the gap, and depending on gap size it often does this with a zig-zaggy motion of the extruder. This is normal; if you wish, you can turn it off,...
1,288
<p>I am trying to use Ganymede CDT to index our large codebase. It is painfully slow, can take a whole night to index the C++ files. Same project takes only 5 seconds to index with exuberant ctags 5.7.</p> <p>Is there some way to find what the root of the problem is and to speed it up? Maybe turn on logging in CDT, or...
<p>If you use the "full indexer" this would not surprise me. I'm using the "fast indexer", it is very fast and works pretty well (even with wxWidgets).</p> <p>You can change your indexer settings in Window->Preferences->C/C++->Indexer.</p>
<p>Do you know if this is a regression from 5.0.0? In that case you should definitely open a bugreport. </p> <p>Is all of your code in the same project? That may have an impact.</p>
36,429
<p>I'm wanting to get the full value of a char[] variable in the VC6 watch window, but it only shows a truncated version. I can copy the value from a debug memory window, but that contains mixed lines of hex and string values. Surely there is a better way??</p>
<p>For large strings, you're pretty much stuck with the memory window - the tooltip would truncate eventually. </p> <p>Fortunately, the memory window is easy to get data from - I tend to show it in 8-byte chunks so its easy to manage, find your string data and cut&amp;paste the lot into a blank window, then use alt+dr...
<p>Perhaps, get used to creating logfiles, and write output into the file directly, then bring up in your favorite text editor.</p>
12,958
<p>Does anyone know how I can get rid of the following assembler warning?</p> <p>Code is x86, 32 bit:</p> <pre><code>int test (int x) { int y; // do a bit-rotate by 8 on the lower word. leave upper word intact. asm ("rorw $8, %0\n\t": "=q"(y) :"0"(x)); return y; } </code></pre> <p>If I compile it I get the f...
<p>You can use <code>%w0</code> if I remember right. I just tested it, too. :-)</p> <pre><code>int test(int x) { int y; asm (&quot;rorw $8, %w0&quot; : &quot;=q&quot; (y) : &quot;0&quot; (x)); return y; } </code></pre> <p>Edit: In response to the OP, yes, you can do the following too:</p> <pre><code>int tes...
<p>So apparently there are tricks to do this... but it may not be so efficient. 32-bit x86 processors are generally <b>slow</b> at manipulating 16-bit data in general purpose registers. You ought to benchmark it if performance is important.</p> <p>Unless this is (a) performance critical and (b) proves to be much fas...
14,458
<p>Does the "for…in" loop in Javascript loop through the hashtables/elements in the order they are declared? Is there a browser which doesn't do it in order?<br> The object I wish to use will be declared <em>once</em> and will never be modified.</p> <p>Suppose I have:</p> <pre><code>var myObject = { A: "Hello", B: "W...
<p><a href="http://ejohn.org/blog/javascript-in-chrome/" rel="noreferrer">Quoting John Resig</a>:</p> <blockquote> <p>Currently all major browsers loop over the properties of an object in the order in which they were defined. Chrome does this as well, except for a couple cases. [...] This behavior is explicitly left un...
<p><strong>As of 2022</strong>,</p> <p>I have just found out (to my surprise), that Chrome does not respect the definition order. It rather sorts it alphabetically but <strong>not naturally</strong>. For example key &quot;a12&quot; comes BEFORE &quot;a3&quot;. So be careful.</p>
35,504
<p>I'd like to be able to place all my ASP Classic include files outside of the web root. This assures no include files can be called directly via the URL. </p> <p>What is the best way to accomplish this?</p> <p>I know I can use a <a href="http://msdn.microsoft.com/en-us/library/zwk103ab.aspx" rel="nofollow noreferre...
<p>Although not recommended, you could also enable the 'Enable parent paths' option in IIS, which will allow you to reference files outside the webroot via the include directive, as well as allow access via the filesystemobject. This is generally not recommended though, as it does pose a security risk.</p> <p>For dir...
<p>I was able to check the procedure mentioned in <a href="https://stackoverflow.com/a/272696/87015">Diodeus' answer</a> and it actually worked.</p> <h3>Example Files/Folders Setup:</h3> <pre><code>E:\includes\ \include.asp \another.asp E:\websites\ \business-website.com\ ...
34,278
<p>I have tree control object created using CTreeCtrl MFC class. The tree control needs to support rename. When I left click on any of item in Tree the TVN_SELCHANGED event is called from which I can get the selected item of the tree as below : HTREEITEM h = m_moveListTree.GetSelectedItem(); CString s = m_moveListT...
<p>This behaviour is by design -- right-clicking doesn't move the selection.</p> <p>For what you want, turn on the TVS_EDITLABELS style on the tree view. Then you handle the TVN_BEGINLABELEDIT and TVN_ENDLABELEDIT notifications.</p>
<p>Not sure how you popup the context menu, but you can use HitTest() to get from a point to a tree item. So you might use this in your right click handler.</p> <p>Don't forget that the context menu can also be activated by a key on reasonable modern keyboards. Then you probably want to use the selected item as target...
11,602
<p>I'm developing a website. I'm using a single-page web-app style, so all of the different parts of the site are AJAX'd into index.php. When a user logs in and tells Firefox to remember his username and password, all input boxes on the site get auto-filled with that username and password. This is a problem on the form...
<p>From Mozilla's documentation </p> <pre><code>&lt;form name="form1" id="form1" method="post" autocomplete="off" action="http://www.example.com/form.cgi"&gt; [...] &lt;/form&gt; </code></pre> <p><a href="http://developer.mozilla.org/en/How_to_Turn_Off_Form_Autocompletion" rel="noreferrer">http://developer.mozilla....
<p>are all your input boxes set to type=password? That would do it. One of the things you can do, and I'm not at all sure that this is the best answer is to leave input box as an input type and just use javascript and onkeydown event to place stars in the input box instead of having the browser render it. Firefox won...
7,307
<p>Since I started learning <a href="http://en.wikipedia.org/wiki/F_Sharp_%28programming_language%29" rel="noreferrer">F#</a> and <a href="http://en.wikipedia.org/wiki/Objective_Caml" rel="noreferrer">OCaml</a> last year, I've read a huge number of articles which insist that design patterns (especially in Java) are wor...
<p>The blog post you quoted overstates its claim a bit. FP doesn't <em>eliminate</em> the need for design patterns. The term "design patterns" just isn't widely used to describe the same thing in FP languages. But they exist. Functional languages have plenty of best practice rules of the form "when you encounter proble...
<p>In functional programming, design patterns have a different meaning. In fact, most of <strong>OOP</strong> design patterns are unnecessary in functional programming because of the higher level of abstraction and <strong>HOFs</strong> used as building blocks.</p> <blockquote> <p>The principle of an HOF means that ...
42,515
<p>I already have a deploy.rb that can deploy my app on my production server. </p> <p>My app contains a custom rake task (a .rake file in the lib/tasks directory). </p> <p>I'd like to create a cap task that will remotely run that rake task.</p>
<pre><code>run("cd #{deploy_to}/current &amp;&amp; /usr/bin/env rake `&lt;task_name&gt;` RAILS_ENV=production") </code></pre> <p>Found it with Google -- <a href="http://ananelson.com/said/on/2007/12/30/remote-rake-tasks-with-capistrano/" rel="noreferrer">http://ananelson.com/said/on/2007/12/30/remote-rake-tasks-with-c...
<p>So I have been working on this. it seams to work well. However you need a formater to really take advantage of the code. </p> <p>If you don't want to use a formatter just set the log level to to debug mode. These semas to h</p> <pre><code>SSHKit.config.output_verbosity = Logger::DEBUG </code></pre> <h1>Cap Stuff<...
40,237
<p>Say I have the following methods:</p> <pre><code>def methodA(arg, **kwargs): pass def methodB(arg, *args, **kwargs): pass </code></pre> <p>In methodA I wish to call methodB, passing on the kwargs. However, it seems that if I define <code>methodA</code> as follows, the second argument will be passed on as ...
<p>Put the asterisks before the kwargs variable. This makes Python pass the variable (which is assumed to be a dictionary) as keyword arguments.</p> <pre><code>methodB("argvalue", **kwargs) </code></pre>
<p>Some experimentation and I figured this one out:</p> <p>def methodA(arg, **kwargs): methodB("argvalue", **kwargs)</p> <p>Seems obvious now...</p>
7,446
<p>I recently ran into a problem that I thought boost::lambda or boost::phoenix could help be solve, but I was not able to get the syntax right and so I did it another way. What I wanted to do was remove all the elements in "strings" that were less than a certain length and not in another container.</p> <p>This is my ...
<p>You need boost::labmda::bind to lambda-ify function calls, for example the length &lt; 24 part becomes:</p> <pre><code>bind(&amp;string::length, _1) &lt; 24 </code></pre> <p>EDIT</p> <p>See "Head Geek"'s post for why set::find is tricky. He got it to resolve the correct set::find overload (so I copied that part)...
<p>The main problem, other than the <code>bind</code> calls (Adam Mitz was correct on that part), is that <code>std::set&lt;std::string&gt;::find</code> is an overloaded function, so you can't specify it directly in the <code>bind</code> call. You need to tell the compiler <em>which</em> <code>find</code> to use, like ...
26,302
<p>We use a data acquisition card to take readings from a device that increases its signal to a peak and then falls back to near the original value. To find the peak value we currently search the array for the highest reading and use the index to determine the timing of the peak value which is used in our calculations....
<p>There are lots and lots of classic peak detection methods, any of which might work. You'll have to see what, in particular, bounds the quality of your data. Here are basic descriptions:</p> <ol> <li><p>Between any two points in your data, <code>(x(0), y(0))</code> and <code>(x(n), y(n))</code>, add up <code>y(i +...
<p>You could apply some <a href="http://en.wikipedia.org/wiki/Standard_deviations" rel="nofollow noreferrer">Standard Deviation</a> to your logic and take notice of peaks over x%.</p>
2,544
<p>hi i forgot the code which in a sample class you have to add so that it runs automatically?</p> <p>is it wakeup or something?</p> <p>like so:</p> <pre><code>class something { function automaticxxx_something_which_runs when class is created() { } } $s = new something(); </code></pre> <p>-what do i create in ...
<p>You're after a constructor. In PHP4 the method has the same name as the class</p> <pre><code>class Foobar { function Foobar() { echo "Hello World!\n"; } } new Foobar() </code></pre> <p>In PHP5 the above method still works, but the correct way is to use the __construct() method</p> <pre><code...
<p>You're after a constructor. In PHP4 the method has the same name as the class</p> <pre><code>class Foobar { function Foobar() { echo "Hello World!\n"; } } new Foobar() </code></pre> <p>In PHP5 the above method still works, but the correct way is to use the __construct() method</p> <pre><code...
40,399
<p>When 3D-printing on an 20*20cm, I've heard that the quality of the printings get worse if I fill out the board... Is it true? Should I keep it to small amounts at the time or doesn't it matter?</p>
<p>No, that's not (entirely) true. There might be some loss of quality if you print multiple objects at once, because when the printhead "hops" from one object to another it might leave a mark or ooze out some material. Also, a large number of retractions in a short period of time might lead to inconsistent extrusion.<...
<p>Just to add to the other answers already here, I've also had problems with layer adhesion when filling up the print bed on an extrusion printer. The longer the print head spends working on details around a single layer, the more chance the layer has to cool off before the next layer gets started. I've started to s...
424
<p>I have a class, and I want to inspect its fields and report eventually how many bytes each field takes. I assume all fields are of type Int32, byte, etc.</p> <p>How can I find out easily how many bytes does the field take?</p> <p>I need something like:</p> <pre><code>Int32 a; // int a_size = a.GetSizeInBytes; //...
<p>You can't, basically. It will depend on padding, which may well be based on the CLR version you're using and the processor etc. It's easier to work out the total size of an object, assuming it has no references to other objects: create a big array, use <a href="http://msdn.microsoft.com/en-us/library/system.gc.getto...
<p>You can use method overloading as a trick to determine the field size:</p> <pre><code>public static int FieldSize(int Field) { return sizeof(int); } public static int FieldSize(bool Field) { return sizeof(bool); } public static int FieldSize(SomeStructType Field) { return sizeof(SomeStructType); } </code></pre>
25,437
<p>I have a file in cvs that has Sticky Options set to <code>-kk</code>. This replaces all cvs keywords with just the keyword name to facilitate diffs. For example, <code>$Author: Alex B$</code> becomes <code>$Author$</code>. </p> <p>How do I disable the <code>-kk</code> behavior and get back to "normal" cvs whe...
<pre><code>cvs update -kkv &lt;filename&gt; </code></pre> <p>will reset the sticky options to <code>keyword</code> and <code>value</code></p> <p><strong>Edit:</strong> Corrected <code>checkout</code> to <code>update</code>, thanks to <a href="https://stackoverflow.com/users/6180/alex-b">Alex B</a> for the correction...
<p>Running a cvs status on the file still results in "sticky options" being set, for example:</p> <p><code>Sticky options: -kk</code></p> <p>To remove these completely, edit the CVS/Entries file and remove the '-kk' from the relevent entry.</p>
37,099
<p>I'm writing an intranet application for a client and I want to give them the ability to configure through an admin interface, which users and user groups can access certain areas. What I'd like to know is the best way of storing the reference to the user or group that is assigned to an area of the intranet. </p> <p...
<p>People that claim that you cannot query SharePoint databases because it is not supported are wrong. From reading the documentation, it is fine to query the database as long as you use the 'With(NoLock)' clause. It is clearly not supported to update, delete, or insert records.</p> <p>The below query is supported:<...
<p>MOSS provides many <a href="http://www.infoq.com/articles/swanson-moss-web-services" rel="nofollow noreferrer">webservices</a> out of the box which make life a little easier. They are always worth exploring.</p> <p>For this particular instance, I think the article, <a href="http://sqlblogcasts.com/blogs/drjohn/arc...
26,282
<p>As far as I understand, CouchDB indexes are updated when a view is queried. Assuming there are more reads than writes, isn't this bad for scaling? How would I configure CouchDB to update indexes on writes, or better yet, on a schedule?</p>
<p>CouchDB does regenerate views on update, but only on what has changed since the last read access to the view. Assuming your read volume greatly outweighs your write volume, this shouldn't be a problem.</p> <p>When you're changing large numbers of documents at once this could lead to the possibility of the first rea...
<p>You can't and also, why would you want that?</p> <p>Think about it like that:</p> <ul> <li>When you import data into MySQL you can turn of indizes because it's more expensive to update the index for every row you insert, than it is to update the index for 100 writes (or however many rows you import) in a single ru...
14,875
<p>I was wondering, is there any possibility to create a table without a primary key, but with two foreign keys, where the foreign keys pairs are always different? For example, a <code>STOCK</code> table with <code>item_id</code> and <code>warehouse_id</code> as foreign keys from <code>ITEMS</code> and <code>WAREHOUSES...
<p>You want a <a href="http://en.wikipedia.org/wiki/Combination_Primary_Key" rel="noreferrer">compound primary key</a>.</p>
<p>If you aren't doing any sort of query that needs it, you don't <em>need</em> a primary key. It makes it a tiny bit harder to delete a record unambiguously, though. You might want to put a unique constraint on item_id,warehouse_id if Oracle allows that.</p>
25,601