instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I am having a bit of a problem.</p>
<p>I get a RAW char* buffer from a camera and I need to add this tags before I can save it to disk. Writing the file to disk and reading it back again is not an option, as this will happen thousands of times.</p>
<p>The buffer data I receive from the camera does not contain any ... | <p>Look at this <a href="http://www.exif.org/Exif2-1.PDF" rel="nofollow noreferrer">PDF</a>, on page 20 you have a diagram showing you were to place or modify your exif information. What is the difference with a file on disk ?</p>
<p>Does the JPEG buffer of your camera contain an EXIF section already ?</p>
| <p>What's the difference? Why would doing it to a file on the disk be any different from doing it in memory?</p>
<p>Just do whatever it is you do after you read the file from the disk.. </p>
| 11,611 |
<p>I have a <code>BasePage</code> which inherits from <code>System.Web.UI.Page</code>, and every page that inherits the <code>BasePage</code> will have the same master page.</p>
<p>How do I cast the <code>Page.Master</code> of the <code>BasePage</code> to the specific master page so I can access properties on it?</p>
| <p>Overriden Master can't be done (its not Virtual), and masking it with new causes an issue with the page class not being able to get its master, so the best thing to do is a second property.</p>
<p>Something like:</p>
<pre><code>public CustomMasterPage MasterPage
{
get { return this.Master as CustomMasterPage; ... | <p>In VB.Net</p>
<pre><code>MasterPageVariable = Ctype(page.MasterPage, MasterPageClass)
</code></pre>
| 24,271 |
<p>What are metaclasses? What are they used for?</p>
| <p>A metaclass is the class of a class. A class defines how an instance of the class (i.e. an object) behaves while a metaclass defines how a class behaves. A class is an instance of a metaclass.</p>
<p>While in Python you can use arbitrary callables for metaclasses (like <a href="https://stackoverflow.com/questions/1... | <p>Meta is a Greek word which means 'after' or 'beyond'.
Generally meta referring to self.
Meta represents the additional information.
Meta class is a helper class to explicitly tell about any additional information that has to be mentioned or any additional thing that has to be added about to the super or parent class... | 12,519 |
<p>Using Win32-specific APIs, is there an easy way to start an external application to open a file simply by passing in the path/name of the file?</p>
<p>For example, say I have a file called C:\tmp\image.jpg. Is there a single API that I can call to tell Windows to open the application associated with .jpg files? W... | <p><a href="http://msdn.microsoft.com/en-us/library/bb762153(VS.85).aspx" rel="nofollow noreferrer">ShellExecute</a></p>
<blockquote>
<p>Performs an operation on a specified file.</p>
<h3>Syntax</h3>
<p>C++</p>
<pre><code>HINSTANCE ShellExecute(
_In_opt_ HWND hwnd,
_In_opt_ LPCTSTR lpOperation,
_... | <p>ShellExecute is the function you're looking for. It can handle both executable types and registered file types, <strong>and</strong> perform all sorts of actions (verbs) on the file, depending on what it supports.</p>
<p>The syntax is:</p>
<pre><code>HINSTANCE ShellExecute(
HWND hwnd, // handle to o... | 47,921 |
<p>I'm wondering what strategies people use for reduced sign on with legacy applications and how effective they have found them? </p>
<p>We have an ASP.Net based intranet and own a lot of the legacy applications, but not all. We also have BizTalk and are considering the use of it's SSO engine too.</p>
| <p>A good compromise between effort/rework and the convenience of single sign on is to continue to maintain a list of users, privileges, roles etc in the legacy app. Make the changes necessary to automatically log the user into your application based on their user account (usually their Windows or network account).</p... | <p>We did two things with legacy accounts. (legacy web based apps)</p>
<p>We first mapped the legacy accounts to their system logon accounts (running in a Windows Active Directory). </p>
<p>A facade logon screen then was applied to over the top of the legacy apps (web based), this would request the AD logon, which ... | 7,431 |
<p>I'm dealing with an Oracle DBA at the moment, who has sent me some profiling he's done. One of the terms in his report is 'Buffer Gets', any idea what this actually means? My guess is bytes retrieved from a buffer, but I have no idea really. Here is some sample output:</p>
<pre><code> Buffer Gets Executions Ge... | <p>Oracle storage is arranged into blocks of a given size (e.g. 8k). Tables and indexes are made up of a series of blocks on the disk. When these blocks are in memory they occupy a buffer.</p>
<p>When Oracle requires a block it does a <strong>buffer get</strong>. First it checks to see if it already has the block i... | <p>I want just to make a little consideration.</p>
<p>In first Dave Costa is right, Buffer gets for exec is what really matters.</p>
<p>With that data we can't say if they are too much or not 'cause you don't say how many records your query extract</p>
<p>If you extract 4000 records maybe 4,380 are ok
If you extract... | 37,672 |
<p>I'm loading an image from a file, and I want to know how to validate the image before it is fully read from the file.</p>
<pre><code>string filePath = "image.jpg";
Image newImage = Image.FromFile(filePath);
</code></pre>
<p>The problem occurs when image.jpg isn't really a jpg. For example, if I create an empty te... | <p>JPEG's don't have a formal header definition, but they do have a small amount of metadata you can use.</p>
<ul>
<li>Offset 0 (Two Bytes): JPEG SOI marker (FFD8 hex)</li>
<li>Offset 2 (Two Bytes): Image width in pixels</li>
<li>Offset 4 (Two Bytes): Image height in pixels</li>
<li>Offset 6 (Byte): Number of componen... | <p>in case yo need that data read for other operations and/or for other filetypes (PSD for example), later on, then using the <code>Image.FromStream</code> function is not necessarily a good ideea.</p>
| 25,862 |
<p>I have written this generator code but it returns 'can't convert nil into String' when I call m.directory inside the manifest. Anyone know what had happened?</p>
<pre><code>class AuthGenerator < Rails::Generator::NamedBase
attr_reader :user_class_name
def initialize(runtime_args, runtime_options={})
@use... | <p>Where is it choking? Please post the full error. You can see the source of the <code>directory</code> method <a href="http://api.rubyonrails.org/classes/Rails/Generator/Commands/Create.html#M001866" rel="nofollow noreferrer">here</a>.</p>
<p>Plus, you probably just want </p>
<pre><code>m.directory File.join('app... | <p>Your initialize method needs a call to super.</p>
| 29,389 |
<p>I need to generate buttons initially based on quite a processor and disk intensive search. Each button will represent a selection and trigger a postback. My issue is that the postback does not trigger the command b_Command. I guess because the original buttons have not been re-created. I cannot affort to execute... | <p>The b_Command Event Handler method is not being executed because on post back buttons are not being recreated (since they are dynamically generated). You need to re-create them every time your page gets recreated but in order to do this you need to explicitly cache information somewhere in state. </p>
<p>If this a ... | <p>Does your ASPX have the event handler wired up?</p>
<pre><code><asp:Button id="btnCommand" runat="server" onClick="b_Command" text="Submit" />
</code></pre>
| 34,370 |
<p>I would like something that I can use as follows</p>
<pre><code>var msg = new NonStaticMessageBox();
if(msg.Show("MyMessage", "MyCaption", MessageBoxButtons.OkCancel) == DialogResult.Ok)
{....}
</code></pre>
<p>But specifically non-static (I need to pass a reference to it around) does anyone know if/where such an... | <p>Such an object does not exist in the .net framework. You'll need to roll your own.</p>
| <p>why do you need to pass a reference of it? you could just use MessageBox.Show and that's all? if you really need it you could make your own MessageBox class, something like:</p>
<pre><code>public class MessageBox
{
private Form _messageForm = null;
public void Show(string title,...) {...}
}
</code></pre>
... | 15,686 |
<p>I've done some delving into AppleScript but I'm interested in how difficult and long it would take to make semi-useful Mac apps.</p>
<p>What really good resources besides Apple Documentation?</p>
| <p>"Cocoa Programming For Mac OS X" from Aaron Hillegass. Nice book that gives you an introduction into Objective C and Cocoa programming.</p>
| <p>If you want to make widgets, they are actually little web pages, often with JavaScript.</p>
| 47,832 |
<p>Greetings,</p>
<p>I have data stored on mysql with delimiter "," in 1 table.
I have rows and column stored on database too.
Now i have to output the data using rows and column number stored on database to draw the table.</p>
<p>Rows and column number are user input, so it may varies.</p>
<p>Let say, there is nu... | <p>You can turn the comma separated values from your data column into an array using the explode() function:</p>
<pre><code><?php
$result = mysql_query('SELECT rows, columns, data from table_name where id=1');
$record = mysql_fetch_assoc($result);
$rows = $record['rows'];
$columns = $record['columns'];
... | <p>assuming that user set table size for 2 rows and 3 columns and makes some input fot 6 cells, data which will go to database will be</p>
<blockquote>
<p>2,3,d1,d2,d3,d4,d5,d6</p>
</blockquote>
<p>when you will fetch data from cell and make explode on fetched string you will get 1 dimension array with 8 elements</... | 37,501 |
<p><strong>Please Note:</strong> This question is <em>not</em> about the design. It's about deciding print orientation <em>after the design</em>. </p>
<p>I have a small, but complex piece which I need to print. Here are two images of different orientation for you:</p>
<p><a href="https://i.stack.imgur.com/jpi84.jpg" ... | <p>(Love the question and here is my 2 cents).</p>
<p>Firstly, you want to minimize supports. Even if you have dissolvable supports, you would still want to minimize the usage.</p>
<p>For Example:</p>
<p><a href="https://i.stack.imgur.com/LoQCE.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LoQCE... | <p>First of all, if it were me, I'd split this into two parts at the "obvious" place (where one protrudes from a large flat surface of the other) and connect them after printing, with a push fit and glue (or solvent welding if it works for your material), or holes for threaded fasteners.</p>
<p>With that said, if you ... | 1,418 |
<p>It can be either at compile time or at run-time using a config file. Is there a more elegant way than simple (and many) if statements?</p>
<p>I am targeting especially sets of UI controls that comes for a particular feature.</p>
| <p>Unless your program must squeeze out 100% performance, do it with a config file. It will keep your code cleaner.</p>
<p>If one option changes many parts of code, don't write many conditionals, write one conditional that picks which class you delegate to. For instance if a preference picks TCP versus UDP, have you... | <p>Perhaps I am assuming too much, but:</p>
<pre><code>switch (setting) {
case "development":
dostuff;
break
case "production":
dootherstuff;
break;
default:
dothebeststuff;
break;
}
</code></pre>
| 11,370 |
<p>This is an accident and I don't think there's a solution. But I'm asking anyways.</p>
<p>I introduced SVN to our webshop and I set all the dev pc's htdocs as part of the repository. (my first mistake)</p>
<p>Now, one of my coworkers are working on a project and didn't commit their code to svn (second mistake). His... | <p>You won't find the answer in SVN, but you can use something like this <a href="http://www.altap.cz/salam_en/features/undelete.html" rel="nofollow noreferrer">undelete tool</a>. </p>
<p>A file isn't really gone until the drive is formatted (long).</p>
| <p>If the files were never committed and they're no longer on the hard drive, then I'm afraid they're probably gone, unless your user has manual backups, or some other recovery/undeletion strategy works out.</p>
| 29,567 |
<p>I have an application in which I have to store a couple of millions of integers, I have to store them in a Look up table, obviously I cannot store such amount of data in memory and in my requirements I am very limited I have to store the data in an embebedded system so I am very limited in the space, so I would like... | <p>I'd look at the types of numbers you need to store and pull out the information that's common for many of them. For example, if they're tightly clustered, you can take the mean, store it, and store the offsets. The offsets will have fewer bits than the original numbers. Or, if they're more or less uniformly distr... | <p>I need more detail on the problem. If you cannot store the real value of the integers but instead an approximation, that means you are going to reduce (throw away) some of the data (detail), correct? I think you are looking for a hash, which can be an artform in itself. For example say you have 32 bit values, on... | 43,520 |
<p>I need to be able to schedule a job on the 10th of each month and have it run for a set number of days or until a specified date.</p>
<p>Is there any way to customize sql server agent jobs using some sort of API or something?</p>
<p>Thanks.</p>
| <p>You can accomplish using the SQL Job Schedule properties by using more than one schedule for the job. You can schedule the job to run on the 10th day of the month (with the option for an end date). You can then create multiple schedules, one for the 11th, 12th, etc.</p>
| <p>I still can't find any way of customizing the job schedule, but I have figured a way around it by adding the condition to the job step:</p>
<blockquote>
<p>IF (DAY(GetDate()) >= 10)<br>
EXEC MySP</p>
</blockquote>
<p>And setting the schedule to run every day.</p>
| 29,783 |
<p>A client of mine uses Oracle 9i's utl_smtp to send mails out notifications to managers when their employees have made travel requests and they woul like quite a few changes made to the mailouts done. </p>
<p>We're having a lot of problems getting utl_smtp to talk to any smtp server on our network. We've even tried ... | <p>Looks like the HELO is the problem. Please can we check with a simple testcase...</p>
<pre><code>set serveroutput on
declare
lConnection UTL_SMTP.CONNECTION;
begin
lConnection := UTL_SMTP.OPEN_CONNECTION(your_smtp_server);
DBMS_OUTPUT.PUT_LINE('Opened ok');
UTL_SMTP.HELO(lConnection, your... | <ul>
<li>The OPEN_CONNECTION parameter should be the FQDN or IP address of the server you're connecting to.</li>
<li>The HELO parameter should be the FQDN of the machine you're connecting from.</li>
</ul>
<p>If this doesn't work, do you know which line it errors on?</p>
| 16,801 |
<p>I am trying to implement an "out of proc" COM server written in C#. How do I do this?</p>
<p>I need the C# code to be "out of proc" from my main C++ application, because I cannot load the .NET runtime into my main process space </p>
<p><em>WHY?:</em><br>
My C++ code is in a DLL that is loaded into many different ... | <p>You can create COM+ components using System.EnterpriseServices.ServicedComponent. Consequently, you'll be able to create out-of-proc and in-proc (client) component activation as well as all COM+ benefits of pooling, remoting, run as a windows service etc.</p>
| <p>I cannot recommend this as <em>the way</em>, but you could create a COM-callable wrapper for your C# library, then create a VB6 ActiveX exe project that delegates calls to your C# library.</p>
| 5,053 |
<p>Does Ruby have any tools along the lines of <a href="http://pypi.python.org/pypi/pylint" rel="noreferrer">pylint</a> for analyzing source code for errors and simple coding standards?</p>
<p>It would be nice if it could be integrated with <a href="http://cruisecontrolrb.thoughtworks.com/" rel="noreferrer">cruisecont... | <p>I reviewed a bunch of Ruby tools that are available here</p>
<p><a href="http://devver.wordpress.com/2008/10/03/ruby-tools-roundup/" rel="noreferrer">http://devver.wordpress.com/2008/10/03/ruby-tools-roundup/</a></p>
<p>most of the tools were mentioned by webmat, but if you want more information I go pretty in dep... | <p>I just released Excellent which implements several checks on Ruby code. It combines roodi, reek and flog and also adds some Rails specific checks: </p>
<pre><code>gem sources -a http://gems.github.com
sudo gem install simplabs-excellent
</code></pre>
<p>May be helpful...</p>
| 36,418 |
<p>I'm running zsh as the default shell on a Ubuntu box, and everything works fine using gnome-terminal (which as far as I know emulates xterm). When I login from a windows box via ssh and putty (which also emulates xterm) suddendly the home/end keys no longer work. </p>
<p>I've been able to solve that adding these li... | <p>I found it's a combination:</p>
<p><strong>One</strong></p>
<p>The ZSH developers do not think that ZSH should define the actions of the <kbd>Home</kbd>, <kbd>End</kbd>, <kbd>Del</kbd>, ... keys.</p>
<p>Debian and Ubuntu fix this by defining the normal actions the average user would expect in the global <code>/et... | <p>These bindings simply don't appear to be part of the default bindings set in emacs mode.</p>
<p>executing "where-is beginning-of-line" on my default zsh installation after running "bindkey -e" shows it is only bound to ^a. Perhaps you should ask the zsh developers why :-)</p>
| 19,546 |
<p>I need to setup LookAndFeel Files in JDK 1.6.
I have two files:</p>
<ol>
<li><p>napkinlaf-swingset2.jar</p></li>
<li><p>napkinlaf.jar</p></li>
</ol>
<p>How can I set this up and use it?</p>
<p>I would like a GTK look and feel OR Qt look and feel, Are they available?</p>
| <p>This page explains how the work with Look&Feels:
<a href="http://java.sun.com/docs/books/tutorial/uiswing/lookandfeel/plaf.html" rel="noreferrer">http://java.sun.com/docs/books/tutorial/uiswing/lookandfeel/plaf.html</a></p>
<p>You can do it commandline:</p>
<pre><code>java -Dswing.defaultlaf=com.sun.java.swing... | <p>The Qt look and feel is available from <a href="http://trolltech.com/" rel="nofollow noreferrer">Trolltech</a> as the product Jambi, which IS Qt for Java.</p>
| 17,593 |
<p>In this <a href="http://en.wikipedia.org/wiki/Support_vector_machine#Software" rel="noreferrer">Wikipedia article about SVM</a> there are a number of links to different implementations of MATLAB toolboxes for Support Vector Machines. Could anyone suggest which of these is best in terms of speed, ease of use, etc.?</... | <p>I've used <a href="http://www.csie.ntu.edu.tw/~cjlin/libsvm/" rel="nofollow noreferrer">libSVM</a>. It is pretty fast and easy, and provides some useful tools, too. There are some examples of it in use <a href="http://homepages.cae.wisc.edu/~ece539/matlab/" rel="nofollow noreferrer">here</a>. The other nice thing is... | <p>You can always use MathWorks implementation of SVM in the Bioinformatics Toolbox with the functions: <strong>svmtrain</strong> and <strong>svmclassify</strong>, which as usual have excellent documentation</p>
| 24,737 |
<p>So the following rewrite rules always seem to fire. This has the effect of hiding another domain that I am hosting on the server?</p>
<p>I can't seem to figure out what's wrong and it is time to call in the experts:</p>
<pre><code>RewriteEngine on
RewriteCond %{HTTP_HOST} ^danielhonig.com
RewriteRule ^(.*)$ http:... | <p>Place the rewrite rules inside your <code><VirtualHost></code> directive, then it will not affect your other domain.</p>
| <p>Did you try using <code>%{SERVER_NAME}</code> instead of <code>%{HTTP_HOST}</code>? I've found <code>%{SERVER_NAME}</code> plays nice with sub domains too.</p>
| 40,198 |
<p>What is the best way to load static data files containing game level maps on the iPhone? I have seen some use XML files, but that seems like overkill in my situation as the data files merely determine the layout of the game's level, ie where obstructions will go. Also, what project directory should they be stored ... | <p>If your files are really static, then you'll want to store them in your application bundle (just add them to your project; Xcode will copy them to the .app bundle when it builds your application). If you need to modify and re-save them, probably ~/Documents is your best bet.</p>
<p>Marc is correct, an NSDictionary ... | <p>I would strongly suggest using the existing SQLite functionality that is part of the standard API. </p>
<p>I have found it to be the easiest way to include data during an installation as well as store user generated data.</p>
<p>If you need an example of how to do this check out <a href="http://tetontech.wordpress... | 41,079 |
<p>I am building a small device with its own CPU (AVR Mega8) that is supposed to connect to a PC. Assuming that the physical connection and passing of bytes has been accomplished, what would be the best protocol to use on top of those bytes? The computer needs to be able to set certain voltages on the device, and read ... | <p><a href="http://en.wikipedia.org/wiki/Modbus" rel="noreferrer">Modbus</a> might be what you are looking for. It was designed for exactly the type of problem you have. There is lots of code/tools out there and adherence to a standard could mean easy reuse later. It also support human readable ASCII so it is still eas... | <p><a href="http://en.wikipedia.org/wiki/USB" rel="nofollow noreferrer">USB bus</a> will answer all your requirements. It might be very simple usb device with only control pipe to send request to your device or you can add an interrupt pipe that will allow you to notify host about changes in your device.
There is a n... | 40,057 |
<p>I often encounter the following scenario where I need to offer many different types of permissions. I primarily use ASP.NET / VB.NET with SQL Server 2000.</p>
<p><strong>Scenario</strong></p>
<p>I want to offer a dynamic permission system that can work on different parameters. Let's say that I want to give either a ... | <p>I agree with John Downey.</p>
<p>Personally, I sometimes use a flagged enumeration of permissions. This way you can use AND, OR, NOT and XOR bitwise operations on the enumeration's items.</p>
<pre><code>"[Flags]
public enum Permission
{
VIEWUSERS = 1, // 2^0 // 0000 0001
EDITUSERS = 2, // 2^1 // 0000 00... | <p>An approach I've used in various applications is to have a generic PermissionToken class which has a changeable Value property. Then you query the requested application, it tells you which PermissionTokens are needed in order to use it.</p>
<p>For example, the Shipping application might tell you it needs:</p>
<pr... | 2,382 |
<p>I have a situation where I want to create a signature of a data structure:</p>
<pre><code>my $signature = ds_to_sig(
{ foo => 'bar',
baz => 'bundy',
boing => undef,
number => 1_234_567,
}
);
</code></pre>
<p>The aim should be that if the data structure changes then so should the sig... | <p>I think what you're looking for is a hash function. I would recommend an approach like this:</p>
<pre><code>use Storable;
$Storable::canonical = 1;
sub ds_to_sig {
my $structure = shift;
return hash(freeze $structure);
}
</code></pre>
<p>The function hash can be any hash function, for example the function ... | <p>Can't you use an object instead of a struct? That way you could see if an object is an instance of a type without having to compare hashes, etc.</p>
| 26,887 |
<p>I want to detect and replace malformed UTF-8 characters with blank space using a Perl script while loading the data using SQL*Loader. How can I do this? </p>
| <p>Consider Python. It allows to extend codecs with user-defined error handlers, so you can replace undecodable bytes with anything you want.</p>
<pre><code>import codecs
codecs.register_error('spacer', lambda ex: (u' ', ex.start + 1))
s = 'spam\xb0\xc0eggs\xd0bacon'.decode('utf8', 'spacer')
print s.encode('utf8')
</c... | <p>EDIT: (Removed bit about SQL Loader as it seems to no longer be relevant.)</p>
<p>One problem is going to be working out what counts as the "end" of a malformed UTF-8 character. It's easy to say what's illegal, but it may not be obvious where the next legal character starts.</p>
| 24,988 |
<p>I maintain an application that uses the win32 EnumPorts() function to help determine the set of serial ports installed on the computer. I have seen cases on some computers where the call to get this information fails with a GetLastError() code of 1722 (RPC server is unavailable). I assume that this has something t... | <p>I'm not an expert on EnumPorts, but I strongly advice against relying on registry keys.</p>
<ul>
<li>Key definitions might change in the future.</li>
<li>Key definitions might not be what you think.</li>
<li>There might be ways to "be a serial port" which don't include those keys.</li>
<li>The keys might not reflec... | <p>There are a lot of weird serial ports these days: USB serial cables, Bluetooth, cell phone modems with GPS,... It might be something plugged into the computer and long forgotten since.</p>
<p>To find out which port is causing the problem you could try going into device manager, select "Show hidden devices" in the "... | 22,301 |
<p>I need to make some reflective method calls in Java. Those calls will include methods that have arguments that are primitive types (int, double, etc.). The way to specify such types when looking up the method reflectively is int.class, double.class, etc.</p>
<p>The challenge is that I am accepting input from an out... | <p>The <code>Class</code> instances for the primitive types are obtainable as you said using e.g. <code>int.class</code>, but it is also possible to get the same values using something like <code>Integer.TYPE</code>. Each primitive wrapper class contains a static field, <code>TYPE</code>, which has the corresponding p... | <p>You can use this code :)</p>
<pre><code>/**
* Get an array class of the given class.
*
* @param klass to get an array class of
* @param <C> the targeted class
* @return an array class of the given class
*/
public static <C> Class<C[]> arrayClass(Class<C> klass) {
return (Class<... | 21,728 |
<p>I have a certain application which feeds information into an object, after comparing the new information to the old information.
It goes something like</p>
<pre><code>set
{
oldval=_value;
_value=value;
if (some comparison logic)
raiseEvent();
}
</code></pre>
<p>This all happens on a background ... | <p>Without some meaningful code, we can only guess. In particular, if adding a MessageBox to the start of the Set doesn't appear, then it is likely that the problem is at the calling code (not this).</p>
<p>Some thoughts, though - especially since you have multiple threads:</p>
<ul>
<li>is there a thread race somewhe... | <p>Since event is being raised on background thread all your event handlers are being run on that (background) thread. Is your code handling this correctly?</p>
| 30,018 |
<p>The Add view and the Edit view are often incredibly similar that it is unwarranted to write 2 views. As the app evolves you would be making the same changes to both.</p>
<p>However, there are usually subtle differences. For instance, a field might be read-only once it's been added, and if that field is a DropDownLi... | <p>It's pretty easy really. Let's assume you're editing a blog post.</p>
<p>Here's your 2 actions for new/edit:</p>
<pre><code>public class BlogController : Controller
{
public ActionResult New()
{
var post = new Post();
return View("Edit", post);
}
public ActionResult Edit(int id)
{
... | <p>You can specify a CustomViewData class and pass the parameters here.</p>
<pre><code>
public class MyViewData {
public bool IsReadOnly { get; set; }
public ModelObject MyObject { get; set; }
}
</code></pre>
<p>And both views should implement this ViewData.
As a result you can use provided IsReadOnly propert... | 3,929 |
<p>I just had some basic php questions to further my understanding as I learn, that I could not find easy answers to</p>
<ol>
<li><p>I have a php ajax application that generates a table of mysql rows. I would like to know if there is a way to get php to generate neat html, as it seems neat enough as I echo it out, but... | <h2>Question 1</h2>
<p>You need to separate the PHP code and the HTML output. The easiest thing to do, as a newbie, is :</p>
<ul>
<li><p>Fill a var named $tab with your entries.</p>
</li>
<li><p>Create a file called "<code>my_tab_template.php</code>" including your xHTML code, using very few PHP to unpack $t... | <ol>
<li><p>You could use the <a href="http://de3.php.net/manual/de/intro.tidy.php" rel="nofollow noreferrer">PHP Tidy Addon</a>. Keep in mind, that filtering the HTML with it uses quite some Server CPU. Alternatively you have to print the line breaks yourself (echo "\n";)
However I suggest, that you leave it as it is.... | 42,843 |
<p>(another post here reminded me of this annoyance! this is not a dup!)</p>
<p>I use VS2008 with multiple monitors. I have VS open on one and the app I'm debugging, reference pages, etc.. on the other. </p>
<p>The problem is when I open a find window (Ctrl-F or click on the "Find in Files" icon) the window opens ... | <p>For Visual Studio 2010, there is now a patch that takes care of this and other problems with the find window's size and placement:</p>
<p>VS10-KB2268081-x86</p>
<p><a href="http://code.msdn.microsoft.com/KB2268081/Release/ProjectReleases.aspx?ReleaseId=4766" rel="nofollow">http://code.msdn.microsoft.com/KB2268081/... | <p>Does it open like this every time? Mine remembers the position from the last place it was closed. (Could be UltraMon jumping it, not ruling that out)</p>
<p>You also have the option of docking it somewhere if that suits your preferences.</p>
| 12,729 |
<p>I have:</p>
<pre><code>class MyClass extends MyClass2 implements Serializable {
//...
}
</code></pre>
<p>In MyClass2 is a property that is not serializable. How can I serialize (and de-serialize) this object?</p>
<p>Correction: MyClass2 is, of course, not an interface but a class.</p>
| <p>As someone else noted, chapter 11 of Josh Bloch's <a href="https://rads.stackoverflow.com/amzn/click/com/0321356683" rel="noreferrer" rel="nofollow noreferrer">Effective Java</a> is an indispensible resource on Java Serialization.</p>
<p>A couple points from that chapter pertinent to your question:</p>
<ul>
<li>as... | <p>You can start by looking into the <em>transient</em> keyword, which marks fields as not part of the persistent state of an object.</p>
| 12,079 |
<p>I am wondering how people that use standalone 3D printers (printers that have the ability to print autonomously from SD Card) feed in filament, prime the printhead and/or change filaments without a laptop ?</p>
<p>Do the printers have a menu to arrange all these tasks ?
I often only see the options to preheat the h... | <p>My printer (IdeaWerk 150) is very basic and doesn't have any options for this from the screen.</p>
<p>I wrote a really simple GCODE file that brings the nozzle up to temperature, then runs the extruder for a few seconds, then waits, then extrudes for a bit again. I think it does this 3 or 4 times then stops. I can ... | <p>There are options for tablets. They are running software <strong><a href="http://www.3ders.org/articles/20130408-control-3d-printer-with-pengpod-touch-screen-linux-tablet.html" rel="nofollow noreferrer">(for example)</a></strong> on some device that has internal storage, wifi, USB connection etc.
You can buy a new t... | 180 |
<p>Can anyone explain the difference between the types mentioned above and some sample usage to clearly explain the difference between the two?</p>
<p>Any help would be highly appreciated!
Note: this question is a spin-off from <a href="https://stackoverflow.com/questions/324168/msxml2ixmldomdocument2ptr-getxml-messin... | <p><code>BSTR</code> is the string data type used with COM.</p>
<p><code>_bstr_t</code> is a wrapper class that works like a smart pointer, so it will free the allocated memory when the variable is destroyed or goes out of scope.
<code>_bstr_t</code> also has reference counting, which increases every time you pass the ... | <p>_bstr_t wraps the BSTR type. So, when you instantiate a _bstr_t, you are also creating BSTR. _bstr_t simply wraps everything up for you and acts sort of like a "smart ptr" to the BSTR.</p>
<p>BSTR</p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms221069.aspx" rel="nofollow noreferrer">http://msdn.microsoft... | 44,383 |
<p>I often find myself trying to come up with good names for complementary pairs of variables; where two variables denote opposing concepts, two participants in some sort of duologue, and so on.</p>
<p>This might be better explained by a counter-example - I maintain an app that prints two graphics as part of a print a... | <p>Like with all kinds of code style conventions, <strong>consistency</strong> is what you should strive for.<br/><br/>
I would have the development team agree on "standard" pairs of prefixes for common scenarios like "source/destination" or "from/to" and then stick with them for the whole project. As long as every de... | <p>Yes, I do try to name complementary sets of variables systematically so that the symmetry is clear. It is not always easy; sometimes, not even possible. Well, not possible using the rules I lay down for myself - which means I usually try to have the names the same length. The 'top' and 'lower' example would drive... | 26,510 |
<p>Let's say I have a web page that currently accepts a single ID value via a url parameter:<br>
<a href="http://example.com/mypage.aspx?ID=1234" rel="nofollow noreferrer">http://example.com/mypage.aspx?ID=1234</a></p>
<p>I want to change it to accept a <em>list</em> of ids, like this:<br>
<a href="http://exam... | <p>No offense to those who provided clear answers, but many people seem to be answering your question instead of addressing your problem. You want multiple IDs, so you think you could this this:</p>
<p><a href="http://example.com/mypage.aspx?IDs=1234,4321,6789" rel="noreferrer">http://example.com/mypage.aspx?IDs=1234... | <p>You can use string.Split() to split the values once you have extracted them from the URL.</p>
<pre><code>string[] splitIds = ids.split(',');
</code></pre>
| 8,893 |
<p>Is there any python module for rendering a HTML page with javascript and get back a DOM object?</p>
<p>I want to parse a page which generates almost all of its content using javascript. </p>
| <p>The big complication here is emulating the full browser environment outside of a browser. You can use stand alone javascript interpreters like Rhino and SpiderMonkey to run javascript code but they don't provide a complete browser like environment to full render a web page.</p>
<p>If I needed to solve a problem lik... | <p>You can probably use <a href="http://code.google.com/p/pywebkitgtk/" rel="nofollow noreferrer">python-webkit</a> for it. Requires a running glib and GTK, but that's probably less problematic than wrapping the parts of webkit without glib.</p>
<p>I don't know if it does everything you need, but I guess you should g... | 15,338 |
<p>For a random event generator I'm writing I need a simple algorithm to generate random ranges. </p>
<p>So, for example:</p>
<p>I may say I want 10 random intervals, between 1/1 and 1/7, with no overlap, in the states (1,2,3) where state 1 events add up to 1 day, state 2 events add up to 2 days and state 3 events ad... | <p>First use DateTime.Subtract to determine how many minutes/seconds/whatever between your min and max dates. Then use Math.Random to get a random number of minutes/seconds/whatever in that range. Then use the result of that to construct another TimeSpan instance and add that to your min DateTime.</p>
| <p>Here's an implementation that compiles and works, although it's still somewhat rough. It requires that the input state array properly account for the entire time range of interest (end - start), but it would be trivial to add a bit of code that would make the final state fill up the time not accounted for in the fir... | 32,150 |
<p>I have two files with slight differences. A normal <code>diff</code> will show me the differences between the files. With <code>-c</code> or <code>-u</code> I can add an amount of context to each hunk. What options can I pass to <code>diff</code> to see every unchanged line alongside the changes, and get the diff... | <p>Use the "-y" option for full side by side output</p>
<p>diff -y file1 file2</p>
<p>Will give you output something like</p>
<pre><code>* Lorem ipsum dolor sit amet, consectetuer adipiscing elit. * Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
* Praesent fringilla facilisis pede. ... | <p>You can also override the diff formatting behavior to get your desired behavior without using side-by-side mode:</p>
<pre><code>diff --new-line-format='+%L' --old-line-format='-%L' --unchanged-line-format=' %L' file1 file2
</code></pre>
<p>This command will show you the full file as context and be closest in forma... | 46,186 |
<p>I'm living in nightmares because of this situation, I have a HttpWebRequest.GetResponse that keeps on giving me a ThreadAbortException, that causes the whole app to go down.</p>
<p>How can I avoid that, or at least handle it, would using Thread.ResetAbort() be useful in such a case?</p>
<p>To explain more here is ... | <p>From what you say it seems you are making an outgoing WebRequest to an external resource from within the processing of an incoming request to an ASP.NET application. There are (at least) two timeouts that are relevant here:</p>
<ul>
<li><p>WebRequest.Timeout (default 100000ms = 100s) specifies the timeout for exec... | <p>Our application threw ThreadAbortException's all the time b/c of
Response.Redirect("url") calls. The app never closed, most likely b/c the exception was being caught at some point and remained active.</p>
<p>Incidentally, Response.Redirect("url",false) will prevent the Response from terminating with the exception. ... | 24,671 |
<p>I know there is <a href="https://stackoverflow.com/questions/63546/vs2005-c-programmatically-change-connection-string-contained-in-appconfig">some similar issue</a>.</p>
<p>But, still the question is not answered! I need to <strong>modify</strong> the connection string not add a new one.</p>
| <p>This will help you out!</p>
<pre><code> /// <summary>
/// Add a connection string to the connection
/// strings section and store it in the
/// configuration file.
/// </summary>
/// <param name="csName">The name of the property.</param>
... | <p>This is an oldish question, and I would just like to know what solution eventually worked out for you. If you havent resolved it yet, <a href="https://stackoverflow.com/questions/786315/">this question</a> attempts to answer it.</p>
| 40,504 |
<p>We are creating a Real-Time Process in VxWorks 6.x, and we would like to limit the amount of memory which can be allocated to the heap. How do we do this?</p>
| <p>When creating a RTP via rtpSpawn(), you can specify an environment variable which controls how the heap behaves.<br>
There are 3 environment variables:</p>
<pre>
HEAP_INITIAL_SIZE - How much heap to allocate initially (defaults to 64K)
HEAP_MAX_SIZE - Maximum heap to allocate (defaults to no limit)
HEAP_INCR_... | <p>This can be done through the use of the HEAP_MAX_SIZE environment variable. If it is set, it limits the ability of the heap to grow beyond that size. It does not, however, limit the initial heap size.</p>
<p><a href="http://www.slac.stanford.edu/grp/cd/soft/vxworks/doc/6.6/vxworks_application_api_reference_6.6.pdf"... | 11,530 |
<p>I am setting up a very small MySQL database that stores, first name, last name, email and phone number and am struggling to find the 'perfect' datatype for each field. I know there is no such thing as a perfect answer, but there must be some sort of common convention for commonly used fields such as these. For insta... | <p>Someone's going to post a much better answer than this, but just wanted to make the point that personally I would never store a phone number in any kind of integer field, mainly because:</p>
<ol>
<li>You don't need to do any kind of arithmetic with it, and</li>
<li>Sooner or later someone's going to try to (do some... | <p>I am doing about the same thing, and here's what I did.</p>
<p>I used separate tables for name, address, email, and numbers, each with a NameID column that is a foreign key on everything except the Name table, on which it is the primary clustered key. I used MainName and FirstName instead of LastName and FirstName... | 46,222 |
<p>I have a web page <code>x.php</code> (in a password protected area of my web site) which has a form and a button which uses the <code>POST</code> method to send the form data and opens <code>x.php#abc</code>. This works pretty well.</p>
<p>However, if the users decides to navigate back in Internet Explorer 7, all t... | <p>IE <em>will</em> retain form contents on a back button click automatically, as long as:</p>
<ul>
<li>you haven't broken cacheing with a no-cache pragma or similar</li>
<li>the form fields in question weren't dynamically created by script</li>
</ul>
<p>You seem to have the cacheing in hand, so I'm guessing the latt... | <p>Firefox does this kind of caching. As I understand your question, you want IE7 to behave the way Firefox does. I think that's not possible.</p>
<p>Firefox and IE7 differ on the way they interpret the back button.</p>
<p>Firefox will display the DOM tree of the previous page as it was last displayed before the page... | 32,672 |
<p>I am attempting to write an application that uses libCurl to post soap requests to a secure web service. This Windows application is built against libCurl version 7.19.0 which, in turn, is built against openssl-0.9.8i. The pertinent curl related code follows:</p>
<blockquote>
<pre>
FILE *input_file = fopen(curren... | <p>After further investigation, I found that this error was due to a failure to initialise the openSSL library by calling SSL_library_init(). </p>
| <p>I encountered the same symptom after upgrading to Ubuntu 16.04 as described in <a href="https://stackoverflow.com/a/37295100/363437">this answer</a>. The solution was to Use TLS like so.</p>
<pre><code>curl_easy_setopt(curl_, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2));
</code></pre>
<p>Apparently SSLv3 <a href=... | 20,125 |
<p>What is the best way to convert a fixed length string array to a fixed lengh integer array in C++ ?</p>
| <p>This will copy an array of characters into an array of ints:</p>
<pre><code>#include <algorithm>
char foo[9] = "asdfasdf";
int bar[9];
std::copy(foo, foo+9, bar);
</code></pre>
<p><a href="http://www.cppreference.com/wiki/stl/algorithm/copy" rel="nofollow noreferrer">std::copy</a></p>
<p>This assigns the va... | <p>If you want to use vectors instead of arrays, this might give you some ideas.</p>
<pre><code>#include <iostream>
#include <string>
#include <vector>
#include <iterator>
#include <ostream>
#include <algorithm>
#include <sstream>
using namespace std;
int int_from_string(cons... | 36,025 |
<p>Pretty all in question... I'm looking for batch script, code or library which allows to edit and create <strong>settings</strong> for PPPoE connections in windows <strong>when hardware and infrastructure is already present</strong>. Also I'm looking for script/code to change active connection.</p>
<p>.NET is preffe... | <p>I think you should be looking for code to create/modify DialUp connection or DUN(Dial Up Networking). DialUp doesn't always means the old 56kbps modem, it can also means PPPoE, PPPoA, Cable Modem and all the other possible hardware which mostly requires a login. I don't have the code, but a simple search in google w... | <p>I think PPPOE regards to lower layer connections rather than managed code. some networking devices exposed certain kinds of protocol like http?</p>
| 36,391 |
<p>I've recently inherited an application that makes very heavy use of session, including storing a lot of custom data objects in session. One of my first points of business with this application was to at least move the session data away from InProc, and off load it to either a stateserver or SQL Server.</p>
<p>After... | <p>When you write</p>
<blockquote>
<p>does a lot of object comparisons using GetHashCode()</p>
</blockquote>
<p>i sense there is something horribly wrong with this code. The GetHashCode method does not guarantee, that the returned hash values should be in any way unique given two different objects. As far as GetHas... | <p>Override the GetHashCode method in classes that get called this method and calculate the hash code based on unique object properties (like ID or all object fields).</p>
| 11,220 |
<p>I have a dependency that I need to inject into one of my classes. This dependency will be lifestyle of <code>Transient</code>. It in-turn has a dependency of type <code>Type</code>. This type should be the type of the original class. I was just wondering if anyone has any idea how I might go about conducting this re... | <p>The simplest solution I can see is to change it to</p>
<pre><code>public interface IRegister<TParent> { ... }
public class Register<TParent> : IRegister<TParent>
{
public Register() { ... }
}
public class Customer : ICustomer
{
public Customer(IRegister<Customer> register) { .... }
... | <p>I thought of that but it would mean the parent object would need to know about this little implementation quirk. Hence I would be creating a dependency which i could no longer enforce. Do you see that as an issue? </p>
<p>As far as what I am trying to achieve, the Register needs to have the type of the parent class... | 29,574 |
<p>When I construct my control (which inherits DataGrid), I add specific rows and columns. This works great at design time. Unfortunately, at runtime I add my rows and columns in the same constructor, but then the DataGrid is serialized (after the constructor runs) adding <strong>more</strong> rows and columns.</p>
<p... | <p>What seems to be happening is this:</p>
<ol>
<li>You've designed a custom DataGrid that adds its own rows and columns in the constructor</li>
<li>You've added your custom DataGrid to a form</li>
<li>You've found that the form designer has written code inside the form's InitializeComponent that adds those rows and c... | <p>"Is there a protected method that I can override to know when the control is done serializing?"</p>
<p>No, not a protected method, but there is an interface. If your control implements <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.isupportinitialize.aspx" rel="nofollow noreferrer">ISupportI... | 30,367 |
<p>I am debugging a large, complex web page that has a lot of JavaScript, JQuery, Ajax and so on. Somewhere in that code I am getting a rouge request (I think it is an empty img) that calls the root of the server. I know it is not in the html or the css and am pretty convinced that somewhere in the JavaScript code th... | <p>What about using the step-by-step script debugger in Firebug ?</p>
<p>I also think that could be a very interesting enhancement to Firebug, being able to add a breakpoint on AJAX calls.</p>
| <p>If its a HTTPRequest sent to a web server, I would recommend using TamperData plugin on Firefox. Just install the plugin, start tamper data, and every request sent will be prompted to tamper/continue/abort first.</p>
<p>Visit <a href="https://addons.mozilla.org/en-US/firefox/addon/966" rel="nofollow noreferrer">thi... | 22,541 |
<p>How do I prevent a form that is posted a second time because of a page reload in a browser from being added to my database again with C# Asp.Net.</p>
<p>Thanks,
Steven</p>
| <p>you need some unique value that identifies the form/page - perhaps a generated number in a hidden field - and remember/check that is has been processed</p>
| <p>HTTP provides a mechanism for avoiding accidental resubmissions - use the POST method in your form tag, not the GET method.</p>
<p>I think it's fair to say you <strong>should</strong> use the POST method for a request that updates a resource anyway, because it will prevent other undesireable behaviour too, like boo... | 46,568 |
<p>I am using django 1.0 and I have created my models using the example in the Django book. I am able to perform the basic function of adding data; now I need a way of retrieving that data, loading it into a form (change_form?! or something), <b>EDIT</b> it and save it back to the DB. Secondly how do I <b>DELETE</b> t... | <p>Say you have a model Employee. To edit an entry with primary key emp_id you do:</p>
<pre><code>emp = Employee.objects.get(pk = emp_id)
emp.name = 'Somename'
emp.save()
</code></pre>
<p>to delete it just do:</p>
<pre><code>emp.delete()
</code></pre>
<p>so a full view would be:</p>
<pre><code>def update(request, ... | <p>Read the following: <a href="http://docs.djangoproject.com/en/dev/ref/contrib/admin/#ref-contrib-admin" rel="nofollow noreferrer">The Django admin site</a>. Then revise your question with specific details.</p>
| 40,103 |
<p>Each year at Thanksgiving, my family has drawn names out of a hat to determine who they'll be a "Secret Santa" for the Christmas gift exchange. It's important to our family culture that no one else in the family knows who each other got in order to keep it interesting. The only rule to the selection is that you can'... | <p>Get some paper and some envelopes. Number two of each envelope and two of each paper so that you have 2 "1" envelopes and 2 "1" papers, 2 "2" envelopes and 2 "2" papers, etc. </p>
<p>Have either you or your wife write every couple's names on matching papers, for example: you could put your name on a "1" sheet and... | <p>Why not automatically send everyone an email? You can put the name in a file and zip it as an attachment to avoid peeking eyes.</p>
| 33,727 |
<p>I've written a cheap & cheerful sound board in for my Mac, and I play the various sounds with NSSound like this:</p>
<pre><code>-(void)play:(NSSound *)soundEffect:(BOOL)stopIfPlaying {
BOOL wasPlaying = FALSE;
if([nowPlaying isPlaying]) {
[nowPlaying stop];
wasPlaying = TRUE;
}
... | <p>This is the final version of the method:</p>
<pre><code>-(void)play:(NSSound *)soundEffect:(BOOL)stopIfPlaying {
BOOL wasPlaying = FALSE;
if([nowPlaying isPlaying]) {
struct timespec ts;
ts.tv_sec = 0;
ts.tv_nsec = 25000000;
// If the sound effect is the same, fade it out.... | <p>Something like this perhaps? You probably want a more linear dropoff, but the basic idea is make a loop and sleep the period of time till the next update.</p>
<pre><code>if([nowPlaying isPlaying]) {
for(int i = 1; i < 100; ++i)
{
[nowPlaying setVolume: (1.0 / i)];
Sleep(20);
}
[n... | 36,752 |
<p>I use Thunderbird to receive email using POP3. I have Thurnderbird configured to leave email on the server. Lets say one day I uses POP3 to retrieve (<code>RETR</code>) 10 email messages, then I logout for the night. Overnight 10 more messages are sent to my mailbox. When I fire up Thunderbird the next morning, ... | <p>Thunderbird has a file called <a href="http://kb.mozillazine.org/Popstate.dat" rel="nofollow noreferrer">popstate.dat</a> that contains the UID, an timestamp (epoch), and a flag. The flag indicates the action that Thunderbird is to perform for the associated message.</p>
<p>Evidently, Thunderbird does not actually ... | <p>Which version of server software there is?</p>
<p><a href="http://courier.sourcearchive.com/documentation/0.60.0-2/pop3dserver_8c-source.html" rel="nofollow noreferrer">http://courier.sourcearchive.com/documentation/0.60.0-2/pop3dserver_8c-source.html</a></p>
<blockquote>
<p>00718 ** The UIDL of the message is r... | 41,191 |
<p>I played with one of the early beta versions of PowerShell V1, but haven't used it since it went "gold". What is the best way to get started using PowerShell?</p>
<p>Which version of PowerShell should I be using (V1.0 vs 2.0 CTP's)? What are you using PowerShell for? Are there any tools that make using PowerShell e... | <p>For learning PowerShell, there are a number of great resources</p>
<ol>
<li>Technet Virtual Labs (<a href="https://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?culture=en-US&EventID=1032314395&EventCategory=3" rel="noreferrer">Introduction to Windows PowerShell</a>)</li>
<li>PowerShellCommunity.org - ... | <p>There are <a href="http://www.dnrtv.com" rel="nofollow noreferrer">DNRtv</a>s on PowerShell and PowerGUI. There are also <a href="http://www.dotnetrocks.com" rel="nofollow noreferrer">.NET Rocks!</a> episodes about these tools.</p>
| 5,365 |
<p>I've got an old classic asp/sql server app which is constantly throwing 500 errors/timeouts even though the load is not massive. Some of the DB queries are pretty intensive but nothing that should be causing it to fall over.</p>
<p>Are there any good pieces of software I can install on my server which will show up ... | <p>Some tools you can try:</p>
<ul>
<li>HP (formerly Mercury) <a href="https://h10078.www1.hp.com/cda/hpms/display/main/hpms_content.jsp?zn=bto&cp=1-11-126-17%5E8_4000_100__" rel="nofollow noreferrer">LoadRunner</a> or <a href="https://h10078.www1.hp.com/cda/hpms/display/main/hpms_content.jsp?zn=bto&cp=1-11-12... | <p>Here's how I'd approach it.</p>
<ol>
<li><p>Look at the running tasks on the server. Which is taking up more CPU time - SQL server or IIS? Most of the time, it will be SQL server and it certainly sounds that way based on your post. It's very rare that any ASP application actually does a lot of processing on the ... | 45,917 |
<p>I am writing a simple memory game using ruby + qt (trying to get away from c++ for while...)<br>
In order to allow a X second timeout to view two open pieces, I need either timers or do the work in a background thread.</p>
<p>What is the simplest way of implementing this without reinventing the wheel?<br>
Ruby thre... | <p>The decision to choose QT threads/timers or Ruby ones is probably a personal one, but you should remember that Ruby threads are green. This means that they are implemented by the Ruby interpreter and cannot scale across multiple processor cores. Though, for a simple memory game with a timer I'm guessing you probably... | <p>Thanks.</p>
<p>Solved it using QTimer::singleShot.
Sufficient - in my case, fires a one time timer every time two tiles are displayed.</p>
| 40,435 |
<p>We get these ~50GB data files consisting of 16 byte codes, and I want to find any code that occurs 1/2% of the time or more. Is there any way I can do that in a single pass over the data?</p>
<p>Edit: There are tons of codes - it's possible that every code is different.</p>
<p>EPILOGUE: I've selected Darius Bac... | <p><a href="http://serv2.ist.psu.edu/viewdoc/summary;jsessionid=D1A8C5DCB2A47A473F693E4F996332A2?doi=10.1.1.114.9563" rel="nofollow noreferrer">Metwally et al., Efficient Computation of Frequent and Top-k Elements in Data Streams (2005)</a>. There were some other relevant papers I read for my work at Yahoo that I can't... | <p>That depends on how many different codes exist, and how much memory you have available.</p>
<p>My first idea would be to build a hash table of counters, with the codes as keys. Loop through the entire file, increasing the counter of the respective code, and counting the overall number. Finally, filter all keys wi... | 45,737 |
<p>I want to write a function that accepts a parameter which can be either a sequence or a single value. The type of value is str, int, etc., but I <strong>don't</strong> want it to be restricted to a hardcoded list.
In other words, I want to know if the parameter X is a sequence or something I have to convert to a se... | <p>As of 2.6, use <a href="http://docs.python.org/library/abc.html#module-abc" rel="noreferrer">abstract base classes</a>.</p>
<pre class="lang-none prettyprint-override"><code>>>> import collections
>>> isinstance([], collections.Sequence)
True
>>> isinstance(0, collections.Sequence)
False
... | <p>You could pass your parameter in the built-in len() function and check whether this causes an error. As others said, the string type requires special handling.</p>
<p>According to the documentation the len function can accept a sequence (string, list, tuple) or a dictionary.</p>
<p>You could check that an object i... | 39,271 |
<p>I'm trying to figure out if Haskell uses dynamic or static scoping.
I realize that, for example, if you define:</p>
<pre><code>let x = 10
</code></pre>
<p>then define the function</p>
<pre><code>let square x = x*x
</code></pre>
<p>You have 2 different "x's", and does that mean it is dynamically scoped? If not, ... | <p>Haskell use (broadly speaking) exactly the same lexical scoping as most other languages.</p>
<p>eg.</p>
<pre><code>x = 10
</code></pre>
<p>Results in a value referenced through <code>x</code> in the global scope, whereas </p>
<pre><code>square x = x * x
</code></pre>
<p>will result in <code>x</code> being lexic... | <p>Well, as I think people have said already, Haskell doesn't have any variables as found in most other languages, it only has expressions. In your example <code>let x = 10</code> x is an expression that always evaluates to 10. You can't actually change the value of x later on, though you can use the scoping rules to... | 43,183 |
<p>The XML file I want to parse starts with :</p>
<pre><code><!DOCTYPE plist PUBLIC "-//...//DTD PLIST 1.0//EN" "http://www.....dtd">
</code></pre>
<p>So when I start the SAX praser, it tries to access this DTD online, and I get a java.net.UnknownHostException.</p>
<ol>
<li>I cannot modify the XML file before... | <p>Ok, turns out the <code>parse()</code> method overrides any previously set entity resolvers with the handler passed in to the parse method. The following code should work:</p>
<pre><code>javax.xml.parsers.SAXParserFactory factory = javax.xml.parsers.SAXParserFactory.newInstance();
factory.setValidating(false);
java... | <p>You can implement a custom <code>EntityResolver</code> which is what is used to lookup external entities during XML parsing.</p>
<pre><code>org.xml.sax.EntityResolver customEntityResolver = new DummyEntityResolver();
javax.xml.parsers.SAXParser parser = factory.newSAXParser();
parser.getXMLReader().setEntityResolve... | 37,811 |
<p><a href="https://3dprinting.stackexchange.com/a/2820/5782">In this answer</a> user <a href="https://3dprinting.stackexchange.com/users/4345/barafu-albino">Barafu</a> says,</p>
<blockquote>
<p>Yet I manage to keep my tolerances +- 0.05 mm which is enough for everything but miniature printing.</p>
</blockquote>
<p... | <p>Dimensional accuracy is not as important as dimensional uniformity. I can print with undersized (or oversized) filament, adjusting the flow appropriately, provided the filament has a consistent diameter. When creating filament in-house, without expensive equipment, it is difficult to maintain the same diameter throu... | <p>Put it simply: they say 1.75 mm with a ± error of 0.05 mm. Which means your flow may vary ±2.9 % while you are printing creating blobs and such. </p>
<p>The smaller the filament tolerance, the more expensive the production costs.</p>
| 500 |
<p>I need to grab the <code>base64-encoded</code> representation of the <code>ViewState</code>. Obviously, this would not be available until fairly late in the request lifecycle, which is OK.</p>
<p>For example, if the output of the page includes:</p>
<pre><code><input type="hidden" name="__VIEWSTATE"
id="__VIE... | <p>Rex, I suspect a good place to start looking is solutions that <strong>compress the ViewState</strong> -- they're grabbing ViewState on the server before it's sent down to the client and gzipping it. That's exactly where you want to be.</p>
<ul>
<li><a href="http://www.hanselman.com/blog/CommentView,guid,febce059-7... | <p>See this <a href="http://aspguy.wordpress.com/2008/07/09/reducing-the-page-size-by-storing-viewstate-on-server/" rel="nofollow noreferrer">blog post</a> where the author describes a method for overriding the default behavior for generating the ViewState and instead shows how to save it on the server Session object.<... | 2,341 |
<p>I am very new to VB.net. I have written these objects in VB6 before. I'm just lost in VB.net, but (kicking and screaming) I have to learn how to do this. I've been googling for hours with only minor steps forward. Can anyone post a link that explains start to finish how to do this?</p>
<p>I have managed to write th... | <p>I am going to assume you are not trying to write a COM DLL but rather a complete project that call various sub assemblies like a VB6 EXE call a ActiveX DLL. If you can be more specific about what you are trying to do it would help me better.</p>
<p>Several points about VB.NET versus VB6. </p>
<p>1) For .NET only p... | <p>You want to create what's called a <a href="http://www.codeproject.com/KB/COM/nettocom.aspx" rel="nofollow noreferrer">COM Callable Wrapper</a> (aka CCW) for your .NET component. This basically entails setting up some COM interfaces with some GUIDs and either enabling "Register for COM Interop" in the project proper... | 34,817 |
<p>Why can't Delphi variants hold objects? More importantly, what's the reason behind this limitation? </p>
| <p>You can definitely <em>store</em> an object inside a Variant variable - just cast it into a NativeUInt. An object is just a pointer, anyway.</p>
<pre><code>obj := TObject.Create;
v := NativeUInt(obj);
obj := TSomeObject(NativeUInt(v));
</code></pre>
| <p>I had used Variants to hold objects in the past using the Variant internals, the code is something like this:</p>
<pre><code>var
MyObject: TMyObject;
Value: Variant;
begin
MyObject:= TMyObject.Create;
TVarData(Value).VType:= VarByRef or VarUnknown;
TVarData(Value).VPointer:= MyObject;
</code></pre>
| 47,818 |
<p>I have a Question class:</p>
<pre><code>class Question {
public int QuestionNumber { get; set; }
public string Question { get; set; }
public string Answer { get; set; }
}
</code></pre>
<p>Now I make an ICollection of these available through an ObjectDataSource, and display them using a Repeater bound t... | <p>You have to handle the postback event (button click or whatever) then enumerate the repeater items like this:</p>
<pre><code>foreach(RepeaterItem item in rptQuestions.Items)
{
//pull out question
var question = (Question)item.DataItem;
question.Answer = ((TextBox)item.FindControl("txtAnswer")).Text;
qu... | <p>Then what's the point in the Bind method (as opposed to the Eval method) if I have to bind everything back up manually on postback?</p>
| 7,573 |
<p>Any good recommendations for a platform agnostic (i.e. Javascript) grid control/plugin that will accept pasted Excel data and can emit Excel-compliant clipboard data during a Copy?</p>
<p>I believe Excel data is formatted as CSV during "normal" clipboard operations.</p>
<hr>
<p><a href="http://dhtmlx.com/docs/pro... | <p>I'm currently using <strong>dhtmlxGrid</strong> and we have the Excel copy/paste functionality working. dhtmlXGrid is the most full featured javascript grid package that I've found.</p>
<p>On their website, dhtmlXGrid claims to support <a href="http://dhtmlx.com/docs/products/docsExplorer/index.shtml?node=dhtmlxgr... | <p>I was wrestling with this problem several years ago (2004 I think). We ran into the problem that Firefox doesn't allow scripts to read the clipboard by default (but you can <a href="http://support.mozilla.com/en-US/kb/Granting+JavaScript+access+to+the+clipboard" rel="nofollow noreferrer">grant access to the clipboa... | 2,471 |
<p>I asked <a href="https://stackoverflow.com/questions/168661/javascript-table-manipulation">this question</a> a while back and basically the project almost consists of reproducing excel in the browser. We want people to input data in an excel-like way. The question i have is, what is the best control to use? Shoul... | <p>Option 1: Check out the Silverlight option to develop your application. And it had a good Excel like DataGrid which is rendered at the Browser lever and you can have async calls to server at any point of time you want to persit a change.</p>
<p>Option 2: There are many <a href="https://stackoverflow.com/questions/... | <p>The Farpoint Spread control emulates Excel grids pretty well, you can even code formulas behind it. It does cost money though</p>
| 23,330 |
<p>In Visual Studio 2008 (and others) when creating a .NET or silverlight application if you look at your project properties, it seems like you can only have one assembly name - across all configurations. I would like to compile my application as:</p>
<p>MyAppDebug - in debug mode
and just
MyApp - in release mode</p>
... | <p>I've done this by messing with the .csproj file: either move the attribute into the configuration-specific property groups, or just use Condition. Example:</p>
<pre><code><AssemblyName>MyApp</AssemblyName>
<AssemblyName Condition=" '$(Configuration)' == 'Debug' ">MyAppDebug</AssemblyName>
<... | <p>Sure you can add a post-build event to rename the assembly. This will work if your solution has only one assembly.</p>
<p>But if your solution consists of several projects, you normally have one project referencing the assembly generated by another problem. Imagine your solution has has two projets: the first one c... | 25,521 |
<p>I'm thinking about SEDA. We design at the moment an application (which is running on a server as a service) which must be multithreaded and message / event based.</p>
<p>The SEDA idea is very intresting and should match. But I cannot find articles etc. writing about experiences made with it. </p>
<p>My question(s)... | <p><code>\]</code> is correct, but note that PHP itself ALSO has <code>\</code> as an escape character, so you might have to use <code>\\[</code> (or a different kind of string literal).</p>
| <p>You problem may come from the fact you are using eregi_replace with the first parameter enclosed in simple quotes:</p>
<pre><code> '\['
</code></pre>
<p>In <a href="http://us2.php.net/manual/en/language.types.string.php#language.types.string.syntax.double" rel="nofollow noreferrer">double quotes</a>, though, it co... | 45,436 |
<p>I am using python 2.6 on XP. I have just installed py2exe, and I can successfully create a simple hello.exe from a hello.py. However, when I try using py2exe on my real program, py2exe produces a few information messages but fails to generate anything in the dist folder. </p>
<p>My setup.py looks like this:</p>
<... | <p>I've discovered that py2exe works just fine if I comment out the part of my program that uses wxPython. Also, when I use py2exe on the 'simple' sample that comes with its download (i.e. in Python26\Lib\site-packages\py2exe\samples\simple), I get this error message:</p>
<pre><code>*** finding dlls needed ***
error: ... | <pre><code>import sys
sys.path.append('c:/Program Files/Microsoft Visual Studio 9.0/VC/redist/x86/Microsoft.VC90.CRT')
</code></pre>
| 41,866 |
<p>A couple weeks before, I bought a custom 3D printer that has an Ultimaker 2 motherboard in it. However, the dimensions of the printer is not same with Ultimaker 2 (X and Y same, a bit smaller on Z). The printer had tinkerfirmware installed in it. Today, I tried to print a premade .gcode file (Which was for another 3... | <p>Your printer is an Ultimaker clone or something else? All of the original firmwares located on TinkerGnome's Github are configured for Ultimaker printers so if you are using them on something different you will need to configure it before using it. The easiest option would be editing this print file that changed y... | <p>Firmware <em>is</em> stored in EEPROM, and may contain some default values, but does not affect the <em>calibration</em> values which are stored in EEPROM.</p>
<p>You should be able to reset the calibration to 'factory defaults', this actually means to take the defaults in the firmware and store them in EEPROM.</p>... | 1,020 |
<p>Is there an easier way to step through the code than to start the service through the Windows Service Control Manager and then attaching the debugger to the thread? It's kind of cumbersome and I'm wondering if there is a more straightforward approach.</p>
| <p>If I want to quickly debug the service, I just drop in a <code>Debugger.Break()</code> in there. When that line is reached, it will drop me back to VS. Don't forget to remove that line when you are done.</p>
<p><strong>UPDATE:</strong> As an alternative to <code>#if DEBUG</code> pragmas, you can also use <code>Condi... | <p>You have two options to do the debugging.</p>
<ol>
<li>create a log file : Personally i prefer a separate log file like text file rather using the application log or event log.But this will cost you a lot on behalf of time, because its still hard to figure our where the exact error location is</li>
<li>Convert the ... | 15,318 |
<p>Where can I setup custom errors for directories in my application such as App_Code, App_Browsers, etc.? I already have customErrors configured in the web.config and that works as expected. For example,</p>
<p><a href="http://www.mysite.com/bla.aspx" rel="nofollow noreferrer">http://www.mysite.com/bla.aspx</a> > r... | <p>You are trying to server content from an Protected Folder... ??</p>
<p>I think you might need to allow access to these folders to get the nice errors you are looking for...</p>
<p><a href="http://www.webdavsystem.com/server/documentation/hosting_iis_asp_net/protected_folders" rel="nofollow noreferrer">http://www.w... | <p>One way is to provide a redirect in the global.asax file:</p>
<pre><code> void Application_Error(object sender, EventArgs e)
{
//uncomment this to narrow down 'helpful' microsoft messages
//HttpRequest request = ((HttpApplication)sender).Context.Request;
Exception ex = Server.GetLastError();
//E... | 37,061 |
<p>A friend and I are about to embark on creating a machine that performs some image comparison for sorting. I know about histogram comparison and am generally confident that a small grid of histograms per image precalculated and stored in columns in a database table will generally give us pretty good matches on the f... | <p>Preamble: Herb Sutter has a great article on the subject:</p>
<p><a href="http://herbsutter.wordpress.com/2008/07/25/constructor-exceptions-in-c-c-and-java/" rel="noreferrer">http://herbsutter.wordpress.com/2008/07/25/constructor-exceptions-in-c-c-and-java/</a></p>
<h2>C++ : Yes and No</h2>
<p>While an object destru... | <p>C++ -</p>
<p>Nope. Destructor is not called for partially constructed objects. A Caveat: The destructor will be called for its member objects which are completely constructed. (Includes automatic objects, and native types)</p>
<p>BTW - What you're really looking for is called "Stack Unwinding"</p>
| 22,885 |
<p>What is the best description of <a href="http://www.gertrudandcope.com-a.googlepages.com/thedciarchitecture" rel="nofollow noreferrer">Data, Context and Interaction (DCI)</a> to pitch it to an organization?</p>
<p>It's created by <a href="http://folk.uio.no/trygver/" rel="nofollow noreferrer">Trygve Reenskaug</a>, ... | <p>Trygve makes a presentation of DCI in <a href="https://vimeo.com/8235394" rel="nofollow noreferrer">https://vimeo.com/8235394</a></p>
<p>DCI has been created to solve a problem in object orientation: it's too difficult to review OO code.</p>
<p>The code for one use-case in OO is typicall spread out between lots of... | <p>It totally looks to me as the Policy based design by Andrei Alexandrescu in Modern C++ design, however that work is more low level, DCI looks like an architecture with parts of methodology (use cases drive the design).</p>
| 49,598 |
<p>I just updated from SVN, and one of my files has now disappeared... of course it wasn't committed because I knew I needed to update+merge first. I think maybe the guy renamed the file which means my SVN client deleted my file.</p>
<p>I'm using VC++ 2008 & Visual SVN.</p>
<p>Help... and for reference how is thi... | <p>If you are looking for the file in VS, it is likely that the file still exists in your directory, but is simply no longer referenced in the project (Since VS will only show you files in your project). If the file was renamed, that is likely why you can no longer find it in Visual Studio. I would check the actually... | <p>The answers show you how to restore your file, but more important is your second part of your question: how to avoid such things?</p>
<p>For this you can lock files. This means you want to work undisturbed on this file. SVN will not allow any other user to commit to a locked file. This includes deletion as well.</p... | 39,351 |
<p>I've been trying to get pretty charts to work in GWT on our internal network.</p>
<p>Playing around with <a href="http://gwt-ext.com" rel="noreferrer">GWT-Ext</a>'s charts is nice, but it requires flash and is really messy to control (it seems buggy, in general). </p>
<p>I'd like to hear about something that work... | <p>Googling for "GWT +sparklines" has gotten me to <a href="http://code.google.com/p/gchart/" rel="noreferrer">gchart</a>, which seems like what I need.<br>
From what I understand - it's all client side and requires nothing more than their JAR file.</p>
| <p>Do you want something that has a server side component or entirely client driven? The best ones I have seen are all flash, alas. I have done little tricks with JS and GWT before, but there is only sophisticated I will get before I go hunting for a library to do it for me.</p>
| 2,722 |
<p>I have been considering taking the plunge and installing Linux on my Playstation 3. As C# is my current language of choice, the next logical step would be to install Mono.</p>
<p>I have done a little research and found that <a href="http://psubuntu.com/wiki/InstallationInstructions" rel="nofollow noreferrer">http:... | <p>Just found <a href="http://tirania.org/blog/archive/2008/Feb-26.html" rel="nofollow noreferrer">this posting</a> from Miguel de Icaza's blog. Promising that as recently as Feb 2008 he was looking into this. As he is <a href="https://stackoverflow.com/users/16929/migueldeicaza">a member of the SO community</a> now,... | <p>The PS3 features a PPC general purpose CPU.</p>
<p>You can try to cross compile mono to ppc and go from there.</p>
<p>Mono from svn has received a lot of attention regarding the ppc port, so I would advise using it instead of the 2.0 release.</p>
| 4,680 |
<p>I have a site running in a Windows shared hosting environment. In their control panel for the shared hosting account I have it set to use ASP.NET version 3.0 but it doesn't say 3.5 SP1 specifically.</p>
<p>How can I view the installed version running on the server where my website is hosted in an asp.net page?</p>
| <p>Thanks!</p>
<p>I just dropped <%=Environment.Version%> on a page and got 2.0.50727.3053</p>
| <p>The hint from Brian Boatright by putting the <code><%=Environment.Version%></code> on a page, and save it in DotNetVersion.aspx, upload it, at testing on the right URL, world great.</p>
<p>Sadly it was an too old version for me: 1.1.4322.2443</p>
| 5,814 |
<p>What is the simplest way to get the machine's time zone as a positive or negative UTC offset, preferably using some time of shell command?</p>
| <p>For all Unix-ish operating systems, when using the GNU date command:</p>
<p><code>date +%z</code></p>
<p>Example, for Eastern European Time (my timezone):</p>
<pre>
[moocha@helium ~]$ date +%z
+0200
</pre>
| <p>I figure that if worse comes to worse I can just send a request to an NTP server and take the difference of it and the current local time, but that seems kind of wasteful if the system knows its offset.</p>
| 45,378 |
<p>Can I get user's mobile number (CLI number) in Objective-C on the iPhone from its sim card?</p>
| <p>Not with the official SDK. You could ask the user to point to its own contact entry using the AddressBookUI framework's pickers, or a UI of your own design.</p>
| <p>You can get the user's phone # from NSUserDefaults. And then look up their address book entry.</p>
<p>This method is completely undocumented and liable to break at a moments noticed.</p>
<p>Also it is fragile - user might have a bad address book with the same # used multiple times etc.</p>
| 19,302 |
<p>I have a table named Info of this schema:</p>
<pre><code>int objectId;
int time;
int x, y;
</code></pre>
<p>There is a lot of redundant data in the system - that is, <code>objectId</code> is not UNIQUE. For each <code>objectId</code> there can be multiple entries of <code>time, x, y</code>.</p>
<p>I want to retri... | <p>One way is using a subquery.</p>
<pre><code>select distinct a.objectID, a.time, a.x, a.y
from Info a,
(select objectID, max(time) time from Info group by objectID) b
where a.objectID = b.objectID and a.time = b.time
</code></pre>
<p>EDIT: Added DISTINCT to prevent duplicate rows if one objectId has mult... | <p>For what it's worth, here's another way of getting the desired result. I got into the habit of doing tricks like this in the MySQL 4.0 days, before subqueries were supported.</p>
<pre><code>SELECT a.*
FROM Info AS a
LEFT OUTER JOIN Info AS b ON (a.objectID = b.objectID AND a.time < b.time)
WHERE b.objectID IS... | 29,298 |
<p>I have a large codebase that targetted Flash 7, with a <em>lot</em> of AS2 classes. I'm hoping that I'll be able to use Flex for any new projects, but a lot of new stuff in our roadmap is additions to the old code.</p>
<p>The syntax for AS2 and AS3 is generally the same, so I'm starting to wonder how hard it would... | <p>Some notable problems I saw when attempting to convert a large number of AS2 classes to AS3:</p>
<h3>Package naming</h3>
<pre><code>class your.package.YourClass
{
}
</code></pre>
<p>becomes</p>
<pre><code>package your.package
{
class YourClass
{
}
}
</code></pre>
<h3>Imports are required</h3>
<p>Yo... | <p>Migrating a bigger project like this from as2 will be more than a simple search and replace. The new syntax is fairly similar and simple to adapt (as lilserf mentioned) but if nothing else the fact that as3 is more strict and the new event model will mostly likely cause a lot of problems. You'll probably be better o... | 6,818 |
<p>I have a problem with a sample routing with the preview 5 of asp.net mvc.</p>
<p>In the AccountController I have 2 actions: </p>
<pre><code>public ActionResult Delete()
public ActionResult Delete(string username)
</code></pre>
<p>While trying to look for Account/Delete or Account/Delete?username=davide the Con... | <p>Solution found!</p>
<p>With the introduction of the ActionNameAttribute, it's now necessary to filter manually which method to call depending on the request. This is done by the ActionSelectionAttribute.</p>
<p>Full explanation here: <a href="http://haacked.com/archive/2008/08/29/how-a-method-becomes-an-action.asp... | <p>I can't say for sure why this is happening. But you might want to consider only having the Delete(string username) action and removing the parameter-less overload.</p>
<p>Because string is nullable my understanding is that simply calling Account/Delete will invoke the action with a null username parameter which you... | 6,955 |
<p>Currently we have a java webservice that we are trying to connect to via a .NET client. This is all done over SSL. Are there any well known gotchas as this seems to be a problem that has come up again and again. What are the most well known gotchas I should be looking for?</p>
<p>The java web service is a SOAP/WSDL... | <p>I didn't write the service. Here is the weird thing:
a java client making the same webservice call works perfectly.
However a .NET client making the exact same webservice call breaks.</p>
| <p>Well, if you wrote your service the "right" way, then there shouldn't be any problems, at least not problems of language interop.</p>
| 19,116 |
<p>As a developer, tools that store configuration/options in the registry are the bane of my life. I can't easily track changes to those options, can't easily port them from machine to machine, and it all makes me really yearn for the good old days of .INI files...</p>
<p>When writing my own applications, what - if an... | <ul>
<li>Originally (WIN3) configuration was stored in the WIN.INI file in the windows directory. </li>
<li>Problem: WIN.INI grew too big. </li>
<li>Solution (Win31): individual INI files in the same directory as the program. </li>
<li>Problem: That program may be installed on a network and shared by many people. </l... | <p>Usually, if you don't put settings in registry, you use it mostly to get current Windows settings, change file associations, etc.<br>
Now, if you need to detect if your software is already installed, you can make a minimal entry in registry, that's a location you can find back in any config. Or search a folder of gi... | 33,683 |
<p>What is the difference between a Hash Map and dictionary ADT. And when to prefer one over another. For my programming assignment my instructor has asked to use one of them but I don't see any difference in between both. The program is supposed to work with a huge no. of strings. Any suggestions?</p>
| <p>In terms of Java, both the class <code>HashMap</code> and the class <code>Dictionary</code> are <em>implementations</em> of the "Map" abstract data type. Abstract data types are not specific to any one programming language, and the Map ADT can also be known as a Hash, or a Dictionary, or an Associative Array (other... | <p>Map is an interface for an ADT in Java, <em>the same general language-independent data structure for maintaining <key, value> pairs</em>, and is introduced in Java 1.2.</p>
<p>Dictionary (not an implementation of Map) is an Abstract class for the same purpose introduced earlier in JDK 1.0. The only subclass i... | 33,527 |
<p>How do I generate excel reports with rich formatting including charts with a ASP.Net application?</p>
<p>As per <a href="http://support.microsoft.com/kb/257757" rel="nofollow noreferrer">http://support.microsoft.com/kb/257757</a> server-side automation of office is not advisable and also our admin does not allow in... | <p>You can use for example this <a href="http://www.carlosag.net/Tools/ExcelXmlWriter/" rel="nofollow noreferrer">Excel XML library</a> for rich formatting, but unfortunately there are no charts in there.</p>
<p>Without any third party component and Office automation (which is really not recommended on servers) you ha... | <p>Two options you might consider:</p>
<p>1) The ReportViewer control. You can design your report, including charts, and have it output to excel. You can allow the report to be shown within the control, or bypass that and export it directly to excel. The version it will be open in depends on what the client has ins... | 24,414 |
<p>I have a question regarding the two additional columns (timeCreated, timeLastUpdated) for each record that we see in many solutions. My question: Is there a better alternative?</p>
<p>Scenario: You have a huge DB (in terms of tables, not records), and then the customer comes and asks you to add "timestamping" to 80... | <p>While you're at it, also record the user who made the change. </p>
<p>The flaw with the separate-table design (in addition to the join performance highlighted by others) is that it makes the assumption that <em>every</em> table has an identity column for the key. That's not always true.</p>
<p>If you use SQL Serv... | <p>Philippe,</p>
<p>Don't simply delete those older than 90 days, move them first to a separate DB or write them to text file, do something to preserve them, just move them out of the main production DB.</p>
<p>If ever comes down to it, most often it is a case of "he with the most documentation wins"!</p>
| 18,738 |
<p>I have a working makefile that builds with mingw32. Now i renamed that makefile to Makefile.w32 (source -> <a href="http://pastie.org/319964" rel="nofollow noreferrer">http://pastie.org/319964</a>)</p>
<p>Now i have a Makefile with the following. The problem is, it does not build my source</p>
<pre><code>all:
... | <p>"make Makefile.w32" is looking for a <strong>target</strong> named Makefile.w32, not a make file by that name. To run make and tell it to read the make file "Makefile.w32", use the -f switch:</p>
<pre><code>make -f Makefile.w32
</code></pre>
<p><strong>Edit</strong>: Incidentally, why do you launch a separate inst... | <p>You can use <a href="http://cmake.org/" rel="nofollow noreferrer">cmake</a> to generate makefiles. It should work on most platforms.</p>
| 39,470 |
<p>Whenever I try putting the filament through the nozzle it does not go through. I have searched everywhere online and have found nothing.</p>
| <p>Many printers have a problem with inserting filament into the extruder. Cutting it at an angle is a huge help. It is also very possible that you have a cog or a bad extruder nozzle. </p>
<p>This link could be of some help: <a href="https://www.thingiverse.com/groups/prusa-i3/topic:7469" rel="nofollow noreferrer">Ex... | <p>My first step would be to cut the filament at a bit of an angle. This will help the filament enter the extruder correctly. </p>
<p>If you're still having trouble, you may have a clogged nozzle. This article by Lifewire -<a href="https://www.lifewire.com/3d-printer-extruder-nozzle-clogged-2289" rel="nofollow nore... | 570 |
<p>When I try to programmatically access a Word object model, I get an error saying no document is active. This appears to be because I am loading the document as not visible using Word automation, and I have to keep it invisible.</p>
<p>How would I code the open macro so that it does nothing in this case? </p>
<p>... | <p>Instead of using ActiveDocument you could remember the document that you open (some schematic code):</p>
<pre><code>dim word as new Word.Application
dim doc as Word.Document
doc = word.Documents.Open(fileName)
MsgBox doc.FullName
</code></pre>
| <pre><code>If Documents.Count > 0 Then
</code></pre>
| 48,703 |
<p>I have a control that is basically functioning as a client-side timer countdown control.</p>
<p>I want to fire a server-side event when the count down has reached a certain time.</p>
<p>Does anyone have an idea how this could be done?</p>
<p>So, when timer counts down to 0, a server-side event is fired.</p>
| <p>You would probably want to use AJAX to make your server side call.</p>
| <p>Below is one way to notify the server of an event. You are really firing a client side event but then communicating with the server. This is if you aren't living in an AJAX world though.</p>
<pre><code>function NotifyServer()
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlHttp.onreadystatechange = ... | 33,330 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.