instruction
stringlengths 21
27.8k
| chosen
stringlengths 18
28.2k
| rejected
stringlengths 18
33.6k
| __index_level_0__
int64 0
50k
|
|---|---|---|---|
<p>We are looking to implement a rich-text box in an ASP.NET application and our requirements are specific to using the "Track Changes" features of Microsoft Word. The closest thing we found in the RadEditor by Telerik. This is a nice control that has a "Track Changes" button and will give you the ability to track the changes from the text in the box to now. It does not let you track your changes from the two previous versions. </p>
<p>We have used CVSWeb in the past and the display was not great but it did have the ability (in a web page) to diff two different versions of text (source code in this case). </p>
<p>Does anyone have any experience or know of any web-based diff tools that work nicely with a rich-text editor in the web?</p>
|
<p>I was going to suggest Telerik, but obviously you've seen that. Another nice one (at least in terms of a slick UI) is ComponnentOne.</p>
<p><a href="http://www.componentone.com/SuperProducts/WebEditorASPNET/" rel="nofollow noreferrer">http://www.componentone.com/SuperProducts/WebEditorASPNET/</a></p>
|
<p>You might be able to hack something like <a href="http://freetextbox.com/" rel="nofollow noreferrer">FreeTextBox</a> onto a wiki backend. That would provide somewhat equivalent functionality.</p>
| 36,197
|
<p>In a web application I am developing, I wish to implement wiki-style edits (where each and every edit is saved, can be compared, and users can rollback edits easily).</p>
<p>What is a good way of implementing this without re-inventing the wheel too much?</p>
<p>Thank you in advance.</p>
|
<p>I believe you're really seeking a <em>Content Management System</em> (CMS), of which a Wiki is a specialization (IMHO).</p>
<p>Googling '<a href="http://www.google.com/search?rlz=1C1GGLS_en-USUS292&aq=f&sourceid=chrome&ie=UTF-8&q=cms+open+source" rel="nofollow noreferrer">CMS Open Source</a>' brings as its top hit:</p>
<p><a href="http://www.opensourcecms.com/" rel="nofollow noreferrer">Open Source CMS</a>, try before you install</p>
<ul>
<li>Joomla</li>
<li>Drupal</li>
<li>Wordpress</li>
</ul>
<p>And a <em>lot</em> of other information.</p>
<p>Commercially, I really like Atlassian's <a href="http://www.atlassian.com/software/confluence/" rel="nofollow noreferrer">Confluence</a>. Wiki like markup, editing history, easily attach documents and now supporting editing in Word, Excel & Powerpoint.</p>
|
<p>use a cms like tikiwiki which is very close to what you plan todo.. :D</p>
| 31,919
|
<p>I'm build an UserControl and I'm not sure how to handle exceptions, the Control itself is not very complicated, the User chose an image from disk so they can authorize it, I don't know exactly how the control will be used so if I use a MessageBox I might block the application, and if I just re-throw it I might crash it.</p>
<p>thanks in advance.</p>
<p>Juan Zamudio</p>
|
<p>this is a common problem facing developers who build libraries. Try to weed out bugs and decide for the remaining error cases if it's an expected error (your control should not throw an exception but rather gracefully handle the error) or an unexpected exceptional condition (your control must throw an exception as soon as possible).</p>
<p>You might also have a look at <a href="http://www.google.com/search?q=Design+By+Contract" rel="nofollow noreferrer">Design By Contract</a>, a methodology to declare required preconditions and guaranteed postconditions. This may sound academic, but it leads to more robust code.</p>
<p>UPDATE:
A good introduction is <a href="http://se.ethz.ch/~meyer/publications/computer/contract.pdf" rel="nofollow noreferrer">http://se.ethz.ch/~meyer/publications/computer/contract.pdf</a></p>
<p>Regards,
tamberg</p>
|
<p>unhandled exceptions should definitely be thrown so that the people using your control can see what's wrong.</p>
| 36,578
|
<p>Is it different from any other certificate I can generate via makecert or buy from some authority?</p>
|
<p>As mentioned by <em>Mile L</em> and <em>Boot to the Head</em> the Extended Key Usage is what determines the purpose that the key can be used for.</p>
<p>Most commercial certificate authorities (Verisign et al) issue certificates for single purposes, or for as few as possible.</p>
<p>They use this narrowing of the puropse to carve out different markets for the certificates and then price them accordingly.</p>
<p>You see them selling different Object Signing certs for Windows Assemblies / Java / Office / Adobe Air etc when (in most cases) the resulting certificate is the same.</p>
<p>For example the <a href="https://secure.comodo.net/products/frontpage?ap=Multisigner&area=CodeSigning&product=8" rel="noreferrer">Comodo codesigning</a> cert issued here can sign Java applets, WebStart applications, Firefox extensions and even Windows assemblies.</p>
|
<p>I'd also add that a .NET assembly has to be strongly named (which requires it to be signed) in order to be added to the GAC.</p>
<p>There are different types of certs... from the CA that is bundled in Win 2003 server, you can request:</p>
<ul>
<li>Client authentication</li>
<li>Email protection</li>
<li>Server authentication</li>
<li>Code signing</li>
<li>Time stamp signing</li>
<li>IPSec</li>
<li>Other</li>
</ul>
| 25,024
|
<p>I try <code>Request.Form.Set(k, v)</code> but it's throwing exception </p>
<blockquote>
<p>Collection is read-only</p>
</blockquote>
|
<p>This is exactly the same as modifying <code>Request.Querystring</code>. Both are internally complicated by private properties and what could be deemed a bug, however there are two possible solutions I'm aware of (I'll dismiss the response.redirect plan out of hand - that's terrible).</p>
<p>Method one is to use reflection to modify the collection directly:</p>
<pre><code>NameValueCollection oQuery = Request.QueryString;
oQuery = (NameValueCollection)Request.GetType().GetField("_queryString",BindingFlags.NonPublic | BindingFlags.Instance).GetValue(Request);
PropertyInfo oReadable = oQuery .GetType().GetProperty("IsReadOnly", BindingFlags.NonPublic | BindingFlags.Instance);
oReadable.SetValue(oQuery, false, null);
oQuery["foo"] = "bar";
oReadable.SetValue(oQuery, true, null);
</code></pre>
<p>Plan B, which I think lends itself better to unit testing is to avoid dealing with the collection directly and instead pass it as a <code>NameValueCollection</code> to any method you want to handle it, shallow copying whatever you need out of it. I've used this myself to mock web requests.</p>
<p>Edit: Marc Gravell gave more eloquent reasons for plan B</p>
|
<p>The form is a representation of what the client sent in the request. What is it you want to do? Personally, I would try to separate the "read the form" code from the "do something with the values" code - that way, you can do any pre-processing early on (when reading from the form), and none of the later code needs to know about what was <em>actually</em> sent - it just takes the values given to it (i.e. it never talks to the request directly).</p>
<p>It also means you can test your logic without the need for a form, or even an http-request at all.</p>
<p>Actually, ASP.NET MVC will do a lot of this (the above paragraph) for you...</p>
<p>Note that you can update the .Items collection - but this is a bit more vague (i.e. it doesn't relate specifically to the form).</p>
| 41,839
|
<p><a href="http://www.python.org/dev/peps/pep-0008/" rel="noreferrer">PEP 8</a> states:</p>
<blockquote>
<p>Imports are always put at the top of the file, just after any module comments and docstrings, and before module globals and constants.</p>
</blockquote>
<p>However if the class/method/function that I am importing is only used in rare cases, surely it is more efficient to do the import when it is needed?</p>
<p>Isn't this:</p>
<pre><code>class SomeClass(object):
def not_often_called(self)
from datetime import datetime
self.datetime = datetime.now()
</code></pre>
<p>more efficient than this?</p>
<pre><code>from datetime import datetime
class SomeClass(object):
def not_often_called(self)
self.datetime = datetime.now()
</code></pre>
|
<p>Module importing is quite fast, but not instant. This means that:</p>
<ul>
<li>Putting the imports at the top of the module is fine, because it's a trivial cost that's only paid once.</li>
<li>Putting the imports within a function will cause calls to that function to take longer.</li>
</ul>
<p>So if you care about efficiency, put the imports at the top. Only move them into a function if your profiling shows that would help (you <strong>did</strong> profile to see where best to improve performance, right??)</p>
<hr>
<p>The best reasons I've seen to perform lazy imports are:</p>
<ul>
<li>Optional library support. If your code has multiple paths that use different libraries, don't break if an optional library is not installed.</li>
<li>In the <code>__init__.py</code> of a plugin, which might be imported but not actually used. Examples are Bazaar plugins, which use <code>bzrlib</code>'s lazy-loading framework.</li>
</ul>
|
<p>I would like to mention a usecase of mine, very similar to those mentioned by @John Millikin and @V.K.:</p>
<h1>Optional Imports</h1>
<p>I do data analysis with Jupyter Notebook, and I use the same IPython notebook as a template for all analyses. In some occasions, I need to import Tensorflow to do some quick model runs, but sometimes I work in places where tensorflow isn't set up / is slow to import. In those cases, I encapsulate my Tensorflow-dependent operations in a helper function, import tensorflow inside that function, and bind it to a button.</p>
<p>This way, I could do "restart-and-run-all" without having to wait for the import, or having to resume the rest of the cells when it fails.</p>
| 15,633
|
<p>What is the benefit of Connectedness as defined by Resource Oriented Architecture (ROA)? The way I understand it, the crux of Connectedness is the ability to crawl the entire application state using only the root URIs.</p>
<p>But how useful is that really?</p>
<p>For example, imagine that HTTP GET <a href="http://example.com/users/joe" rel="nofollow noreferrer">http://example.com/users/joe</a> returns a link to <a href="http://examples.com/uses/joe/bookmarks" rel="nofollow noreferrer">http://examples.com/uses/joe/bookmarks</a>.</p>
<p>Unless you're writing a dumb web crawler (and even then I wonder), you still need to teach the client what each link means at compile-time. That is, the client needs to know that the "bookmarks URI" returns a URI to Bookmark resources, and then pass control over to special Bookmark-handling algorithms. You can't just pass links blindly to some general client method. Since you need this logic anyway:</p>
<ol>
<li><p>What's the difference between the client figuring out the URI at runtime versus providing it at compile-time (making <a href="http://example.com/users/bookmarks" rel="nofollow noreferrer">http://example.com/users/bookmarks</a> a root URI)?</p></li>
<li><p>Why is linking using <code><a href="http://example.com/users/joe/bookmarks/2" rel="nofollow noreferrer">http://example.com/users/joe/bookmarks/2</a></code> preferred to <code>id="2"</code>?</p></li>
</ol>
<p>The only benefit I can think of is the ability to change the path of non-root URIs over time, but this breaks cached links so it's not really desirable anyway. What am I missing?</p>
|
<p>You are right that changing Uris is not desirable but it does happen and using complete Uris instead of constructing them makes change easier to deal with.</p>
<p>One other benefit is that your client application can easily retrieve resources from multiple hosts. If you allowed your client to build the URI's the client would need to know on which host certain resources reside. This is not a big deal when all of the resources live on a single host but it becomes more tricky when you are aggregating data from multiple hosts. </p>
<p>My last thought is that maybe you are oversimplifying the notion of connectedness by looking at it as a static network of links. Sure the client needs to know about the possible existence of certain links within a resource but it does not necessarily need to know exactly what are the consequences of following that link. </p>
<p>Let me try an give an example: A user is placing an order for some items and they are ready to submit their cart. The submit link may actually go to two different places depending on whether the order will be delivered locally or internationally. Maybe orders over a certain value need to go through an extra step. The client just knows that it has to follow the submit link, but it does not have compiled in knowledge of where to go next. Sure you could build a common "next step" type of resource so the client could have this knowledge explicitly but by having the server deliver the link dynamically you introduce a lot less client-server coupling.</p>
<p>I think of the links in resources as placeholders for what the user could choose to do. Who will do the work and how it will be done is determined by what uri the server attaches to that link.</p>
|
<p>Its easier to extend, and you could write small apps and scripts to work along with the core application fairly easily.</p>
<p>Added: Well the whole point starts with the idea that you don't specify at compile-time how to convert URIs to uids in a hardcoded fashion, instead you might use dictionaries or parsing to do that, giving you a much more flexible system.</p>
<p>Then later on say someone else decides to change the URI syntax, that person could write a small script that translates URIs without ever touching your core Application. Another benefit is if your URIs are logical other users, even within a corporate scenario, can easily write Mash-ups to make use of your system, without touching your original App or even recompiling it.</p>
<p>Of course the counter side to the whole argument is that it'll take you longer to implement a URI based system over a simple UID system. But if your App will be used by others in a regular fashion, that initial time investment will greatly payback (it could be said to have a good extensibility based ROI).</p>
<p>Added: And another point which is a mater of tastes to some degree is the URI itself will be a better Name, because it conveys a logical and defined meaning</p>
| 24,906
|
<p>I am writing a Clone method using reflection. How do I detect that a property is an indexed property using reflection? For example:</p>
<pre><code>public string[] Items
{
get;
set;
}
</code></pre>
<p>My method so far:</p>
<pre><code>public static T Clone<T>(T from, List<string> propertiesToIgnore) where T : new()
{
T to = new T();
Type myType = from.GetType();
PropertyInfo[] myProperties = myType.GetProperties();
for (int i = 0; i < myProperties.Length; i++)
{
if (myProperties[i].CanWrite && !propertiesToIgnore.Contains(myProperties[i].Name))
{
myProperties[i].SetValue(to,myProperties[i].GetValue(from,null),null);
}
}
return to;
}
</code></pre>
|
<pre><code>if (propertyInfo.GetIndexParameters().Length > 0)
{
// Property is an indexer
}
</code></pre>
|
<p>Here is some code that worked for me:</p>
<pre>
foreach (PropertyInfo property in obj.GetType().GetProperties())
{
object value = property.GetValue(obj, null);
if (value is object[])
{
....
}
}
</pre>
<p>P.S. <code>.GetIndexParameters().Length > 0)</code> works for the case described in this article: <a href="http://msdn.microsoft.com/en-us/library/b05d59ty.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/b05d59ty.aspx</a>
So if you care about the property named Chars for a value of type string, use that, but it does not work for most of the arrays I was interested in, including, I am pretty sure, a string array from the original question.</p>
| 37,158
|
<p>What's the best way (or tool) on the Windows (Vista) command line to get size and modification time for a file on a remote webserver, without downloading it?</p>
|
<p>There is a <a href="http://gnuwin32.sourceforge.net/packages/wget.htm" rel="nofollow noreferrer">Win32 port of wget</a> that works decently.</p>
<p>PowerShell's <code>Invoke-WebRequest -Method Head</code> would work as well.</p>
|
<p>I'd download <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html" rel="nofollow noreferrer">PuTTY</a> and run a telnet session on port 80 to the webserver you want</p>
<pre><code>HEAD /resource HTTP/1.1
Host: www.example.com
</code></pre>
<p>You could alternatively download <a href="http://strawberryperl.com" rel="nofollow noreferrer">Perl</a> and try LWP's HEAD command. Or write your own script.</p>
| 26,800
|
<p>Basically I need to insert a bunch of data to an Excel file. Creating an OleDB connection appears to be the fastest way but I've seen to have run into memory issues. The memory used by the process seems to keep growing as I execute INSERT queries. I've narrowed them down to only happen when I output to the Excel file (the memory holds steady without the output to Excel). I close and reopen the connection in between each worksheet, but this doesn't seem to have an effect on the memory usage (as so does Dispose()). The data is written successfully as I can verify with relatively small data sets. If anyone has insight, it would be appreciated.</p>
<p><em>initializeADOConn()</em> is called in the constructor</p>
<p><em>initADOConnInsertComm()</em> creates the insert parameterized insert query</p>
<p><em>writeRecord()</em> is called whenever a new record is written. New worksheets are created as needed.</p>
<pre><code>public bool initializeADOConn()
{
/* Set up the connection string and connect.*/
string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + this.destination + ";Extended Properties=\"Excel 8.0;HDR=YES;\"";
//DbProviderFactory factory =
//DbProviderFactories.GetFactory("System.Data.OleDb");
conn = new OleDbConnection(connectionString);
conn.ConnectionString = connectionString;
conn.Open();
/* Intialize the insert command. */
initADOConnInsertComm();
return true;
}
public override bool writeRecord(FileListerFileInfo file)
{
/* If all available sheets are full, make a new one. */
if (numWritten % EXCEL_MAX_ROWS == 0)
{
conn.Close();
conn.Open();
createNextSheet();
}
/* Count this record as written. */
numWritten++;
/* Get all of the properties of the FileListerFileInfo record and add
* them to the parameters of the insert query. */
PropertyInfo[] properties = typeof(FileListerFileInfo).GetProperties();
for (int i = 0; i < insertComm.Parameters.Count; i++)
insertComm.Parameters[i].Value = properties[i].GetValue(file, null);
/* Add the record. */
insertComm.ExecuteNonQuery();
return true;
}
</code></pre>
<p>EDIT:</p>
<p>No, I do not use Excel at all. I'm intentionally avoiding Interop.Excel due to its poor performance (at least from my dabbles with it).</p>
|
<p>The answer is <strong>Yes</strong>, the formula you describe <em>does</em> equal a bad time.</p>
<p>If you have a database handy (SQL Server or Access are good for this), you can do all of your inserts into a database table, and then export the table all at once into an Excel spreadsheet.</p>
<p>Generally speaking, databases are good at handling lots of inserts, while spreadsheets aren't.</p>
|
<p>Instead of writing one record at a time, can you find a way to insert in a Bulk capacity? I try not to use crazy DataSet stuff, but isn't there a way to make all your inserts happen local first and then make them go up in one fell swoop?
Does this processes open up Excel in the background? Do these processes die afterwards?</p>
| 35,402
|
<p>I am looking for an addon that can say characters vocally. It is for non-commercial use, and it would be nice if it can vocalize more languages, like asian, english etc...
I have googled it, but can't seem to find anything for free use.</p>
<p>Update: This is for web use</p>
|
<p>You could try <a href="http://espeak.sourceforge.net/" rel="nofollow noreferrer">http://espeak.sourceforge.net/</a> and make an mp3 of the word, then stream it to a flash application (you could use darwin for the streaming).</p>
|
<p>What yo uare searching for ist <a href="http://cmusphinx.sourceforge.net/html/cmusphinx.php" rel="nofollow noreferrer">Sphinx4</a>. Some free speech models for other languages can be found <a href="http://www.voxforge.org/home/downloads" rel="nofollow noreferrer">here</a>.</p>
| 20,209
|
<p>Is there anyway to upgrade the installed JRE in the system? We are having 1.5.0_08 installed in out HP Unix system.We have to upgrade this to 1.5.0_15.Is there a way to patch up the existing JRE and upgrade to a newer version.Or can this only be achieved by installing the newer JRE and set this in the system PATH.</p>
|
<p>What's usually done is to have multiple JRE installed in separate directories (JRE_1_5_10, JRE_1_5_16, JRE_1_6_3, ...) and use some symlinks as references as JRE_1_5 that will point to the latest version of JRE 1.5, same for JRE_1_6, and eventually, JRE that will point to the latest version of the JRE.</p>
<p>Doing so, you just need to update the symlinks when you choose to use a newer version and always refer to the symlinks for systems that are "upgradable".</p>
|
<p>I'd always just upgrade and change the one in the path. But if it was only class library changes you needed, and not JVM you could replace the contents of the lib directory. But this is asking for disaster.</p>
| 20,964
|
<p>I understand that programming to interfaces helps with loose coupling. However, is there a guideline that explains when its most effective?</p>
<p>For example, I have a simple web application that collects data on employees, their training plans, expenses and computes their expense for the year etc. This is a fairly simple application and I can of course use an interface but wonder if there would be any use. I will be using it for the sake of using it.</p>
<p>It can always be argued that as the application grows in complexity and I pass around objects it would make more sense to pass the type (interface) than an implementation. So, should I wait for the application to become complex or use it right away? I'm wondering the best practice might turn out to be "this guy is over doing things".</p>
|
<p>The reason to program to an interface is to insulate higher-level classes from changes in lower-level classes. If you don't anticipate a lower-level class to change at all, then it's reasonable <em>not</em> to program to an interface in that case. This <a href="http://www.objectmentor.com/resources/articles/dip.pdf" rel="nofollow noreferrer">article (PDF)</a> elaborates on the idea, coining the term the Dependency-Inversion Principle.</p>
|
<p>You have to see an interface as a contract. This contract defines the set of rules and operations that need to be fulfilled by those who signed this contract, no matter how it gets done.</p>
| 44,261
|
<p>In some instances, I prefer working with custom objects instead of strongly typed datasets and data rows. However, it seems like Microsoft Reporting (included with VS2005) requires strongly typed datasets.</p>
<p>Is there a way to use my custom objects to design and populate reports?</p>
|
<p>I found the answer. Yes, it's possible. You just have to add a custom object as a datasource in visual studio.</p>
<p><a href="http://www.gotreportviewer.com/objectdatasources/index.html" rel="noreferrer">http://www.gotreportviewer.com/objectdatasources/index.html</a></p>
|
<p>I believe you can set up SSRS to read data values from a more or less arbitrary object. <a href="http://msdn.microsoft.com/en-us/library/microsoft.reportingservices.dataprocessing.idatareaderfieldproperties_members(SQL.90).aspx" rel="nofollow noreferrer">This Link</a> describes the IDataReaderFieldProperties object in the API which (IIRC) allows you to specify the getter method to invoke to get a value. </p>
| 15,434
|
<p>I'm watching Stephen A Bohlen's excellent <a href="http://www.summerofnhibernate.com/" rel="nofollow noreferrer">Summer of NHibernate</a> series, and have been watching him interact with CodeRush. I've recently installed ReSharper (I'm a ReSharper newbie), and I'm trying to find some of the ReSharper productivity equivalents that Stephen is demonstrating (tangentially) with CodeRush.</p>
<p>As an example, he demonstrates highlighting a code block that looks like this:</p>
<pre><code>ISession session = GetSession();
session.xxx
</code></pre>
<p>and then turning it into </p>
<pre><code>using (ISession session = GetSession())
{
session.xxx
}
</code></pre>
<p>He does this by highlighting the block he wants to <em>surround</em> with the using statement and then invoking some CodeRush template. I've been unable to figure out how to do the equivalent thing with ReSharper. I found the ReSharper Surround command (within the Code command), but when you select the <strong>using</strong> statement, it does surround your highlighted code block, but it does not seem <em>smart</em> enough to put the first line within the using clause. That is, it results in:</p>
<pre><code>using ()
{
ISession session = GetSession();
session.xxx
}
</code></pre>
<p>which requires me to move the first line into the using clause. Am I missing an easier way?</p>
|
<p>Resharper offers this capability. If your class implements IDisposable, just hit Alt-Enter:</p>
<p><em>(removed image dead link "Before")</em><br>
<em>(removed image dead link "After")</em></p>
<p>You also have to have your cursor on variable name. Like this: <a href="http://img204.imageshack.us/img204/3872/sshot1dd8.jpg" rel="nofollow noreferrer">SShot1</a> <a href="http://img99.imageshack.us/img99/9543/sshot2dn0.jpg" rel="nofollow noreferrer">SShot2</a> <a href="http://img220.imageshack.us/img220/9697/sshot3hd5.jpg" rel="nofollow noreferrer">SShot3</a></p>
|
<p>I wonder if something is wrong with my ReSharper setup. When my cursor is on the</p>
<pre><code>Class1 c = new Class1();
</code></pre>
<p>line in the code sample, below, ReSharper only suggests, <strong>Use 'var'</strong>. If offers NEITHER <strong>Split declaration and assignment</strong> NOR <strong>Put into using construct</strong>??</p>
<p>(Mindaugas -- Your comment is of course correct about DirectoryInfo. My bad. Hopefully, this example more clearly illustrates what I'm seeing).</p>
<pre><code>using System;
namespace DataAccessLayerTest {
public class Class1 : IDisposable {
public void Moo()
{
Console.Out.WriteLine("Moo");
}
public void Dispose()
{
}
}
public class Class2 {
public void m()
{
Class1 c = new Class1();
c.Moo();
}
}
}
</code></pre>
| 42,290
|
<p><strong>Problem:</strong> </p>
<p>I have two spreadsheets that each serve different purposes but contain one particular piece of data that needs to be the same in both spreadsheets. This piece of data (one of the columns) gets updated in spreadsheet A but needs to also be updated in spreadsheet B.</p>
<p><strong>Goal:</strong></p>
<p>A solution that would somehow link these two spreadsheets together (keep in mind that they exist on two separate LAN shares on the network) so that when A is updated, B is automatically updated for the corresponding record.</p>
<p>*Note that I understand fully that a database would probably be a better plan for tasks such as these but unfortunately I have no say in that matter.</p>
<p>**Note also that this needs to work for Office 2003 and Office 2007</p>
|
<p>So you mean that AD743 on spreadsheet B must be equal to AD743 on spreadsheet A? Try this:</p>
<ul>
<li>Open both spreadsheets on the same
machine.</li>
<li>Go to AD743 on spreadsheet B.</li>
<li>Type =.</li>
<li>Go to spreadsheed A and click on
AD743.</li>
<li>Press enter.</li>
</ul>
<p>You'll notice that the formula is something like '<em>[path-to-file+file-name].worksheet-name!AD743</em>'.</p>
<p>The value on spreadsheet B will be updated when you open it. In fact, it will ask you if you want to update. Of course, your connection must be up and running for it to update. Also, you can't change the name or the path of spreadsheet A.</p>
|
<p>I can't say if this is overkill without knowing the details of your usage case, but consider creating a spreadsheet C to hold all data held in common between the two. Links can become dizzyingly complex as spreadsheets age, and having a shared data source might help clear up the confusion.</p>
<p>Perhaps even more "enterprise-y" is the concept of just pasting in all data that otherwise would be shared. That is the official best practice in my company, because external links have caused so much trouble with maintainability. It may seem cumbersome at first, but I've found it may just be the best way to promote maintainability in addition to ease of use, assuming you don't mind the manual intervention.</p>
| 2,518
|
<p>Suppose you have a program which reads from a socket. How do you keep the download rate below a certain given threshold?</p>
|
<p>At the application layer (using a Berkeley socket style API) you just watch the clock, and read or write data at the rate you want to limit at.</p>
<p>If you only read 10kbps on average, but the source is sending more than that, then eventually all the buffers between it and you will fill up. TCP/IP allows for this, and the protocol will arrange for the sender to slow down (at the application layer, probably all you need to know is that at the other end, blocking write calls will block, nonblocking writes will fail, and asynchronous writes won't complete, until you've read enough data to allow it).</p>
<p>At the application layer you can only be approximate - you can't guarantee hard limits such as "no more than 10 kb will pass a given point in the network in any one second". But if you keep track of what you've received, you can get the average right in the long run.</p>
|
<p>wget seems to manage it with the --limit-rate option. Here's from the man page:</p>
<blockquote>
<p>Note that Wget implements the limiting
by sleeping the appropriate amount of
time after a network read that took
less time than specified by the
rate. Eventually this strategy causes
the TCP transfer to slow down to
approximately the specified rate.
However, it may take some time for
this balance to be achieved, so don't
be surprised if limiting the rate
doesn't work well with very small
files.</p>
</blockquote>
| 12,059
|
<p>If there are many return records from DB. It will get stackoverflow problem.
<code>User</code> is a class, which has a one to many relationship (to 3 other classes). When I print out the SQL, i found that the system runs the same query many time to get the data from DB. Does anyone know what the problem is?</p>
<pre><code>result.addAll(getCurrentSession().createCriteria(User.class)
.add(Restrictions.ilike("name", "tom", MatchMode.ANYWHERE))
.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY)
.list());
</code></pre>
|
<p>Edited after reading Frans Bouma's answer, since my answer has been accepted and therefore moved to the top. Thanks, Frans.</p>
<p>GUIDs do make a good unique value, however due to their complex nature they're not really human-readable, which can make support difficult. If you're going to use GUIDs you might want to consider doing some performance analysis on bulk data operations before you make your choice. Take into account that if your primary key is "clustered" then GUIDs are not appropriate.</p>
<p>This is because a clustered index causes the rows to be physically re-ordered in the table on inserts/updates. Since GUIDs are random, every insert would require actual rows in the table to be moved to make way for the new row.</p>
<p>Personally I like to have two "keys" on my data:</p>
<p><strong>1) Primary key<br></strong>
Unique, numeric values with a clustered primary key. This is my system's <em>internal</em> ID for each row, and is used to uniquely identify a row and in foreign keys.</p>
<p>Identity can cause trouble if you're using database replication (SQL Server will add a "rowguid" column automatically for merge-replicated tables) because the identity seed is maintained per server instance, and you'd get duplicates.</p>
<p><strong>2) External Key/External ID/Business ID<br></strong>
Often it is also preferable to have the additional concept of an "external ID". This is often a character field with a unique constraint (possibly including another column e.g. customer identifier).</p>
<p>This would be the value used by external interfaces and would be exposed to customers (who do not recognise your internal values). This "business ID" allows customers to refer to your data using values that mean something to them.</p>
|
<p>I used to not like GUID at all, but I've grown to love it. I love it because it is relatively uniform and adopted, and I end up writing less code by using it, and maintaining that code, than I would normally write and maintain.</p>
<p>It is especially useful for storage of files, where you need to guarantee that a filename is unique, in a directory with a potentially large number of files, including pre-existing files.</p>
| 47,277
|
<p>Has anyone used ADO.NET Data Services as a data source for Adobe Flex applications? If so, any success stories or tragedies to avoid? If you did use it, how did you handle security?</p>
|
<p>I use WebORB for .NET to do Flex remoting and then use DLINQ on the server. One tricky thing about using LINQ with WebORB is that WebORB uses Reflection to automatically retrieve all the relationships of the object(s) you return to Flex. This causes severe time penalties as LINQ uses lazy loading to load relationships. To prevent this from happening, I do something like the following:</p>
<p>Override your DataContext's constructor and add the following code:</p>
<pre><code>this.DeferredLoadingEnabled = false;
DataLoadOptions dlo = new DataLoadOptions();
dlo.LoadWith<Order>(q => q.Payments);
dlo.LoadWith<Order>(q => q.Customer);
this.LoadOptions = dlo;
</code></pre>
<p>This tells the DataContext to disable deferred loading of relationships and specifically instructs it to load just the relationships you want, without lazy loading. That way, WebORB isn't causing any lazy loading to happen through Reflection and the number of relationships being transferred to Flex is kept at a minimum.</p>
<p>Hope this helps you in some way. It's definitely one of those little "gotchas" when working with Flex/WebORB and LINQ.</p>
|
<p>He Asked about ADO.NET Data Services not web service</p>
| 6,660
|
<p>I am trying to create a rather simple effect on a set of images. When an image doesn't have the mouse over it, I'd like it to have a simple, gray border. When it does have an image over it, I'd like it to have a different, "selected", border.</p>
<p>The following CSS works great in Firefox:</p>
<pre class="lang-css prettyprint-override"><code>.myImage a img
{
border: 1px solid grey;
padding: 3px;
}
.myImage a:hover img
{
border: 3px solid blue;
padding: 1px;
}
</code></pre>
<p>However, in IE, borders do not appear when the mouse isn't hovered over the image. My Google-fu tells me there is a bug in IE that is causing this problem. Unfortunately, I can't seem to locate a way to fix that bug.</p>
|
<p>Try using a different colour. I'm not sure IE understands 'grey' (instead, use 'gray').</p>
|
<p>IE has problems with the :hover pseudo-class on anything other than anchor elements so you need to change the element the hover is affecting to the anchor itself. So, if you added a class like "image" to your anchor and altered your markup to something like this:</p>
<pre><code><div class="myImage"><a href="..." class="image"><img .../></a></div>
</code></pre>
<p>You could then alter your CSS to look like this:</p>
<pre class="lang-css prettyprint-override"><code>.myImage a.image
{
border: 1px solid grey;
padding: 3px;
}
.myImage a.image:hover
{
border: 3px solid blue;
padding: 1px;
}
</code></pre>
<p>Which should mimic the desired effect by placing the border on the anchor instead of the image. Just as a note, you may need something like the following in your CSS to eliminate the image's default border:</p>
<pre class="lang-css prettyprint-override"><code>.myImage a img {
border: none;
}
</code></pre>
| 8,933
|
<p>The code below shows a sample that I've used recently to explain the different behaviour of structs and classes to someone brand new to development. Is there a better way of doing so? (Yes - the code uses public fields - that's purely for brevity)</p>
<pre><code>namespace StructsVsClasses
{
class Program
{
static void Main(string[] args)
{
sampleStruct struct1 = new sampleStruct();
struct1.IntegerValue = 3;
Console.WriteLine("struct1.IntegerValue: {0}", struct1.IntegerValue);
sampleStruct struct2 = struct1;
Console.WriteLine();
Console.WriteLine("struct1.IntegerValue: {0}", struct1.IntegerValue);
Console.WriteLine("struct2.IntegerValue: {0}", struct2.IntegerValue);
struct1.IntegerValue = 5;
Console.WriteLine();
Console.WriteLine("struct1.IntegerValue: {0}", struct1.IntegerValue);
Console.WriteLine("struct2.IntegerValue: {0}", struct2.IntegerValue);
sampleClass class1 = new sampleClass();
class1.IntegerValue = 3;
Console.WriteLine();
Console.WriteLine("class1.IntegerValue: {0}", class1.IntegerValue);
sampleClass class2 = class1;
Console.WriteLine();
Console.WriteLine("class1.IntegerValue: {0}", class1.IntegerValue);
Console.WriteLine("class2.IntegerValue: {0}", class2.IntegerValue);
class1.IntegerValue = 5;
Console.WriteLine();
Console.WriteLine("class1.IntegerValue: {0}", class1.IntegerValue);
Console.WriteLine("class2.IntegerValue: {0}", class2.IntegerValue);
Console.ReadKey();
}
}
struct sampleStruct
{
public int IntegerValue;
}
class sampleClass
{
public int IntegerValue;
}
}
</code></pre>
|
<p>Well, your <em>explanation</em> isn't an explanation at all, it's an observation of behavior, which is different.</p>
<p>If you want an explanation of what the difference is, then you need a piece of text <em>explaining</em> it. And the behavior explained can be ed with the code.</p>
<p>The page linked to by Grimtron is good for detailing all the individual differences between a class and a struct, and pieces of it would serve as a <em>overview explanation</em>, in particular read the following items:</p>
<ul>
<li>Exists on stack or heap?</li>
<li>Inheritance differences?</li>
</ul>
<p>But I wouldn't link to that page as an <em>explanation</em> for what the differences are. It's like trying to describe what a car is, and just listing up all the parts that make up a car. You still need to understand the big picture to understand what a car is, and such a list would not be able to give you that.</p>
<p>In my mind, an explanation is something that tells you how something works, and then all the details follow naturally from that.</p>
<p>For instance, if you understand the basic underlying principles behind a value type vs. a reference type, a lot of the details on that page makes sense, <em>if you think about it</em>.</p>
<p>For instance, a value type (struct) is allocated where it is declared, inline, so to speak. It takes up stack space, or makes a class bigger in memory. A reference type, however, is a pointer, which has a fixed size, to <em>somewhere else in memory where the actual object is stored</em>.</p>
<p>With the above explanation, the following details makes sense:</p>
<ul>
<li>A struct variable cannot be null (ie. it always takes up the necessary space)</li>
<li>An object reference can be null (ie. the pointer can point to nothing)</li>
<li>A struct does not add pressure to garbage collection (garbage collection works with the heap, which is where objects live in that <em>somewhere else</em> space)</li>
<li>Always have a default constructor. Since you can declare any value-type variable (which is basically a kind of struct), without giving it a value, there must be some underlying magic that clears up that space (remember I said it took up space anyhow)</li>
</ul>
<p>Other things, like all the things related to inheritance, needs their own part in the explanation.</p>
<p>And so on...</p>
|
<ol>
<li><p>I don't see what you're trying to show with your sample. </p></li>
<li><p>The way I explain it to people is "A structure <em>holds</em> stuff. A class <em>does</em> something with it".</p></li>
</ol>
| 12,612
|
<p>I required to write a small web application that allow customer to select predefined layout template in html and be able to modify it. The application need to allow customer to add block text to pre defined area and images. The block texts need to be able to reorder based on customer need. eg. move up , move down or move to sidebar. THe complete layout will be able to convert to table layout and inline css due to email program doesn't like div & css. I don't know where should I looking for the information to make this happen, could anyone show me how to do this. </p>
<p>Thank you</p>
|
<p>Of course, I may be misunderstanding you. You might consider using a standard content management system such as:</p>
<p>linux based</p>
<ul>
<li><a href="http://www.joomla.org/" rel="nofollow noreferrer">joomla</a></li>
<li><a href="http://mamboserver.com" rel="nofollow noreferrer">Mambo</a></li>
</ul>
<p>Windows based</p>
<ul>
<li><a href="http://www.dotnetnuke.com/" rel="nofollow noreferrer">DotNetNuke</a></li>
<li><a href="http://www.microsoft.com/Sharepoint/default.mspx" rel="nofollow noreferrer">Sharepoint</a></li>
</ul>
<p>Those systems have the functionality you described built in with the added benefit that most of them are free and open source.</p>
|
<p>I'm not sure why someone downvoted you, but check out a javascript framework like <a href="http://script.aculo.us/" rel="nofollow noreferrer">script.aculo.us</a> or <a href="http://developer.yahoo.com/yui/" rel="nofollow noreferrer">Yahoo's YUI</a></p>
<p>Those will go a long way towards creating the interface you need. Also they have a lot of examples.</p>
<p>The Yahoo framework has an inplace html editor (I think that is what you are asking for). Another editing is the <a href="http://www.fckeditor.net/" rel="nofollow noreferrer">fckeditor</a>.</p>
| 29,980
|
<p>I've never done it myself, and I've never subscribed to a feed, but it seems that I'm going to have to create one, so I'm wondering. The only way that seems apparent to me is that when the system is updated with a new item (blog post, news item, whatever), a new element should be written to the rss file. Or alternatively have a script that checks for updates to the system a few times a day and writes to the rss file is there is. There's probably a better way of doing it though.</p>
<p>And also, should old elements be removed as new ones are added? </p>
<p><strong>Edit</strong>: I should have mentioned, I'm working in PHP, specifically using CodeIgniter, with a mySQL database.</p>
|
<p>For PHP I use feedcreator
<a href="http://feedcreator.org/" rel="nofollow noreferrer">http://feedcreator.org/</a></p>
<pre><code><?php define ('CONFIG_SYSTEM_URL','http://www.domain.tld/');
require_once('feedcreator/feedcreator.class.php');
$feedformat='RSS2.0';
header('Content-type: application/xml');
$rss = new UniversalFeedCreator();
$rss->useCached();
$rss->title = "Item List";
$rss->cssStyleSheet='';
$rss->description = 'this feed';
$rss->link = CONFIG_SYSTEM_URL;
$rss->syndicationURL = CONFIG_SYSTEM_URL.'feed.php';
$articles=new itemList(); // list of stuff
foreach ($articles as $i) {
$item = new FeedItem();
$item->title = sprintf('%s',$i->title);
$item->link = CONFIG_SYSTEM_URL.'item.php?id='.$i->dbId;
$item->description = $i->Subject;
$item->date = $i->ModifyDate;
$item->source = CONFIG_SYSTEM_URL;
$item->author = $i->User;
$rss->addItem($item);
}
print $rss->createFeed($feedformat);
</code></pre>
|
<p>Here's a simple ASP.NET 2 based RSS feed I use as a live bookmark for my localhost dev sites. Might help you get started:</p>
<pre><code><%@ Page Language="C#" EnableViewState="false" %>
<%@ OutputCache Duration="300" VaryByParam="none" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Configuration" %>
<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Web.Security" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Text" %>
<%@ Import Namespace="System.DirectoryServices" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
System.Collections.Specialized.StringCollection HideSites = new StringCollection();
System.Collections.Generic.List<string> Sites = new System.Collections.Generic.List<string>();
HideSites.Add(@"IISHelp");
HideSites.Add(@"MSMQ");
HideSites.Add(@"Printers");
DirectoryEntry entry = new DirectoryEntry("IIS://LocalHost/W3SVC/1/ROOT");
foreach (DirectoryEntry site in entry.Children)
{
if (site.SchemaClassName == "IIsWebVirtualDir" && !HideSites.Contains(site.Name))
{
Sites.Add(site.Name);
}
}
Sites.Sort();
Response.Clear();
Response.ContentType = "text/xml";
XmlTextWriter RSS = new XmlTextWriter(Response.OutputStream, Encoding.UTF8);
RSS.WriteStartDocument();
RSS.WriteStartElement("rss");
RSS.WriteAttributeString("version","2.0");
RSS.WriteStartElement("channel");
RSS.WriteElementString("title", "Localhost Websites");
RSS.WriteElementString("link","http://localhost/sitelist.aspx");
RSS.WriteElementString("description","localhost websites");
foreach (string s in Sites)
{
RSS.WriteStartElement("item");
RSS.WriteElementString("title", s);
RSS.WriteElementString("link", "http://localhost/" + s);
RSS.WriteEndElement();
}
RSS.WriteEndElement();
RSS.WriteEndElement();
RSS.WriteEndDocument();
RSS.Flush();
RSS.Close();
Response.End();
}
</script>
</code></pre>
| 32,110
|
<p>Has anybody used or seen a website that uses <a href="http://www.flapjax-lang.org/" rel="nofollow noreferrer">FlapJax</a> to function, rather than just as a demo? I'm curious to see how they operate / how difficult they were to write.</p>
<p>List one example per answer.</p>
|
<p>I'm going to ignore the one app per answer request:</p>
<p><a href="http://continue2.cs.brown.edu/" rel="nofollow noreferrer">http://continue2.cs.brown.edu/</a></p>
<p><a href="http://resumedemo.cs.brown.edu/" rel="nofollow noreferrer">http://resumedemo.cs.brown.edu/</a></p>
<p>Keep in mind though that these were made by the developers of Flapjax.</p>
|
<p>I've been using it for a page internal to my employer that is largely a very fancy clock. Just using the library directly (skipping the compiler, which they plan to deprecate) has worked great. Event streams are very convenient when you've got a whole lot of different components, coming and going, that have to be synchronized.<br/>
So, sorry, can't show you anything, but I've been very pleased with it.</p>
| 35,437
|
<p>I mostly develop on Linux and meld is indispensable for me. However, when I'm on the road I use a MacBook (leopard) and I want to use the same set of tools as on my main development box, meld being one of them.</p>
<p>Although you shoud be able to install meld, I could not succeed with it. So... are there any alternatives that are as good (or better) as meld?</p>
<p>One thing to point out, I use subversion and I just love the 'meld .' command that diffs my working directory to the BASE revision...</p>
<p>Johan</p>
|
<p>There's FileMerge.app, which comes with XCode.</p>
<p>It can be run as a separate standalone application :</p>
<p><img src="https://i.stack.imgur.com/qwzlk.png" alt="enter image description here"></p>
|
<p><a href="http://barebones.com/products/bbedit/" rel="nofollow noreferrer">BBEdit</a> has a good diff viewer in it.</p>
| 28,362
|
<p>I've computed the mean & variance of a set of values, and I want to pass along the value that represents the # of std deviations away from mean for each number in the set. Is there a better term for this, or should I just call it num_of_std_devs_from_mean ...</p>
|
<p>Some suggestions here:
<a href="http://en.wikipedia.org/wiki/Standard_score" rel="noreferrer">Standard score</a> (z-value, z-score, normal score)</p>
<p>but "sigma" or "stdev_distance" would probably be clearer</p>
|
<p>I've always heard it as number of standard deviations</p>
| 10,486
|
<p>Do all php include files have to be in an include directory, or is that just an organizational convenience?
Can I include files from any directory using the path to that directory?
Do html files that contain php includes have to have a php extension?
If so, I guess that would mean all of my html docs would be php if they all have the menus I am planning to "include". Is that acceptable protocol to have every file on your site be a php file?</p>
<p>A bow in humble reverence...</p>
<p>p.s. is there a good bible on this topic!?</p>
|
<p>You don't need to have your php includes anywhere particular, or have any file extension...</p>
<p>Calling include('/path/to/your/file/with/any/extension.extension'); should include it as a php file</p>
<p>Normally safer to call files with php code in with a php extension tho. </p>
|
<p>James Musser:</p>
<p>I think you are referring to Apache SSI includes now
(see <a href="http://httpd.apache.org/docs/2.2/howto/ssi.html#standard-footer" rel="nofollow noreferrer">http://httpd.apache.org/docs/2.2/howto/ssi.html#standard-footer</a>)</p>
<p>Not knowing the answer, I tried it, and here are my results</p>
<pre><code>Extension Call method PHP runs
.html browser no
.html Apache #include no
.html PHP include() yes
.php browser yes
.php Apache #include yes
.php PHP include() yes
</code></pre>
<p>(Testing done with WinXP, Apache 2.2.3, PHP 5.2.26 and CentOS 5.2, Apache 2.2.3, PHP 5.1.16)</p>
<p>So your answer is YES - if you wish to call a PHP script through an Apache SSI #include, the script must have a .php extension (or some other extension, ie .php4 .php5 etc, which is registered with Apache as being a PHP script), otherwise it will NOT run.</p>
| 40,604
|
<p>I'm looking at the SOAP output from a web service I'm developing, and I noticed something curious:</p>
<pre><code><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<ns1:CreateEntityTypesResponse xmlns:ns1="http://somedomain.com/wsinterface">
<newKeys>
<value>1234</value>
</newKeys>
<newKeys>
<value>2345</value>
</newKeys>
<newKeys>
<value>3456</value>
</newKeys>
<newKeys xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<newKeys xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<errors>Error1</errors>
<errors>Error2</errors>
</ns1:CreateEntityTypesResponse>
</soapenv:Body>
</soapenv:Envelope>
</code></pre>
<p>I have two newKeys elements that are nil, and both elements insert a namespace reference for xsi. I'd like to include that namespace in the soapenv:Envelope element so that the namespace reference is only sent once.</p>
<p>I am using WSDL2Java to generate the service skeleton, so I don't directly have access to the Axis2 API.</p>
|
<h3>Using WSDL2Java</h3>
<p>If you have used the Axis2 WSDL2Java tool you're kind of stuck with what it generates for you. However you can try to change the skeleton in this section:</p>
<pre><code> // create SOAP envelope with that payload
org.apache.axiom.soap.SOAPEnvelope env = null;
env = toEnvelope(
getFactory(_operationClient.getOptions().getSoapVersionURI()),
methodName,
optimizeContent(new javax.xml.namespace.QName
("http://tempuri.org/","methodName")));
//adding SOAP soap_headers
_serviceClient.addHeadersToEnvelope(env);
</code></pre>
<p>To add the namespace to the envelope add these lines somewhere in there:</p>
<pre><code>OMNamespace xsi = getFactory(_operationClient.getOptions().getSoapVersionURI()).
createOMNamespace("http://www.w3.org/2001/XMLSchema-instance", "xsi");
env.declareNamespace(xsi);
</code></pre>
<h3>Hand-coded</h3>
<p>If you are "hand-coding" the service you might do something like this:</p>
<pre><code>SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
SOAPEnvelope envelope = fac.getDefaultEnvelope();
OMNamespace xsi = fac.createOMNamespace("http://www.w3.org/2001/XMLSchema-instance", "xsi");
envelope.declareNamespace(xsi);
OMNamespace methodNs = fac.createOMNamespace("http://somedomain.com/wsinterface", "ns1");
OMElement method = fac.createOMElement("CreateEntityTypesResponse", methodNs);
//add the newkeys and errors as OMElements here...
</code></pre>
<h3>Exposing service in aar</h3>
<p>If you are creating a service inside an aar you may be able to influence the SOAP message produced by using the target namespace or schema namespace properties (see <a href="http://wso2.org/library/2060" rel="noreferrer">this article</a>).</p>
<p>Hope that helps.</p>
|
<p>Other option is that the variable MY_QNAME has the prefix empty.</p>
<pre><code>public static final QName MY_QNAME = new QName("http://www.hello.com/Service/",
"tagname",
"prefix");
</code></pre>
<p>So, if you fill it, then it works.</p>
| 10,059
|
<p>How can I find out whether a specific RedHat release (RHEL4, RHEL5...) contains a certain package (or a certain version of a package)? For Debian and Ubuntu, there's packages.debian.org and packages.ubuntu.com; is there a similar web site for RedHat?</p>
<p>Note: I don't want to have to install all the releases just to check some package version :-)</p>
|
<p>The best you can do, as it seems, is to check the FTP directories of the source packages:</p>
<ul>
<li><a href="http://web.archive.org/web/20190807022012/http://ftp.redhat.com/pub/redhat/linux/enterprise/4/en/os/i386/SRPMS/" rel="nofollow noreferrer">RHEL4</a></li>
<li><a href="ftp://ftp.redhat.com/pub/redhat/linux/enterprise/5Server/en/os/SRPMS/" rel="nofollow noreferrer">RHEL5</a></li>
<li><a href="ftp://ftp.redhat.com/pub/redhat/linux/enterprise/6Server/en/os/SRPMS/" rel="nofollow noreferrer">RHEL6</a></li>
<li><a href="ftp://ftp.redhat.com/pub/redhat/linux/enterprise/7Server/en/os/SRPMS/" rel="nofollow noreferrer">RHEL7</a></li>
</ul>
<p>Keep in mind that RedHat has the habit of patching software to hell and back, so the version number might not have to much in common with the actual release, especially for the kernel.</p>
|
<p>If you have your yum repositories set, you can use "yum search " to see if it exists, or "yum list" to see all available packages.</p>
| 16,885
|
<p>I'm working on a C#/ASP.NET web application, and I have a number of situations where I need to do locking. Ideally, I want the locks to act independently, since they have nothing to do with each other. I've been considering <code>[MethodImpl(MethodImplOptions.Synchronized)]</code> and a few ways of using <code>lock()</code>, but I have a few questions/concerns. </p>
<p>It seems like MethodImplOptions.Synchronized<code>will essentially do</code>lock(this)`. If that's the case, it seems like a thread entering any synchronized method would block <em>all other</em> threads from entering <em>any</em> synchronized method. Is that right? If so, this isn't granular enough. At that point, it seems like I may as well use Application.Lock. (But please correct me if I'm wrong.)</p>
<p>Concerning <code>lock()</code>, I'm trying to figure out what I should pass in. Should I create a set of objects solely for this purpose, and use each one for a different lock? Is there a better way?</p>
<p>Thanks in advance!</p>
|
<p>My preference is to create an object specifically for the lock. </p>
<pre><code>private object lockForSomeResource = new object();
</code></pre>
<p>in the class that is managing the contentious resource.
Jeff Richter posted an <a href="http://msdn.microsoft.com/en-us/magazine/cc188793.aspx" rel="nofollow noreferrer">article</a> I read some time ago that recommended this.</p>
<p>You need to think carefully about designing these as a hierarchy if there is any code within a lock that needs another lock. Make sure you always request them in the same order.</p>
|
<p>You can expose some static reference or a singleton, and lock() that.</p>
<p>Maybe you can care to explain why you need such locking and what you will use it for?</p>
| 15,268
|
<p>What I'm trying to do is run the same SQL select on many Oracle databases (at least a dozen), and display the output in a Gridview.</p>
<p>I've hacked together something that works but unfortunately it's very slow. I think its exacerbated by the fact that at least 1 of the dozen databases will invariably be unreachable or otherwise in an error state.</p>
<p>As well as being slow I can't help thinking it's not the best way of doing it, nor very '.NET' like.</p>
<p>I've written something similar in the past as a simple loop in PHP that just connects to each db in turn, runs the sql and writes another <code><tr></code>, and it works at least twice as fast, for a given query. But I'm not really happy with that, I'd like to improve my knowledge!</p>
<p>I'm learning C# and ASP.NET so please excuse the horrible code :)</p>
<pre><code>public void BindData(string mySQL)
{
OracleConnection myConnection;
OracleDataAdapter TempDataAdapter;
DataSet MainDataSet = new DataSet();
DataTable MainDataTable = new DataTable();
DataSet TempDataSet;
DataTable TempDataTable;
string connectionString = "";
Label1.Visible = false;
Label1.Text = "";
foreach (ListItem li in CheckBoxList1.Items)
{
if (li.Selected)
{
connectionString = "Data Source=" + li.Text + "";
connectionString += ";Persist Security Info=True;User ID=user;Password=pass;Unicode=True";
myConnection = new OracleConnection(connectionString);
try
{
TempDataAdapter = new OracleDataAdapter(mySQL, myConnection);
TempDataSet = new DataSet();
TempDataTable = new DataTable();
TempDataAdapter.Fill(TempDataSet);
TempDataTable = TempDataSet.Tables[0].Copy();
/* If the main dataset is empty, create a table by cloning from temp dataset, otherwise
copy all rows to existing table.*/
if (MainDataSet.Tables.Count == 0)
{
MainDataSet.Tables.Add(TempDataTable);
MainDataTable = MainDataSet.Tables[0];
}
else
{
foreach (DataRow dr in TempDataTable.Rows)
{
MainDataTable.ImportRow(dr);
}
}
}
catch (OracleException e)
{
Label1.Visible = true;
Label1.Text = Label1.Text + e.Message + " on " + li.Text + "<br>";
}
finally
{
if (myConnection != null)
{
myConnection.Close();
myConnection = null;
}
TempDataSet = null;
TempDataAdapter = null;
TempDataTable = null;
}
}
}
GridView1.DataSourceID = String.Empty;
if (MainDataSet.Tables.Count != 0)
{
GridView1.DataSource = MainDataSet;
if (GridView1.DataSource != null)
{
GridView1.DataBind();
}
}
}
protected void Button1_Click(object sender, EventArgs e)
{
BindData(TextBox1.Text);
}
</code></pre>
<p>Thanks!</p>
<p>UPDATE: The SQL code varies, for testing I have used very simple queries such as <code>select sysdate from dual</code> or <code>select name from v$database</code>. In eventual use, it will be much more complicated, the idea is that I should be able to run pretty much anything, hence the <code>BindData(TextBox1.Text)</code></p>
<p>UPDATE: The reason for connecting to many databases from the ASP.NET code rather than a stored proc on one or all dbs, or replicating to one db, is twofold. Firstly, the dbs in question are frequently updated replicas of several similar production environments (typically development, testing and support for each client), so anything done to the actual dbs would have to be updated or redone regularly as they are reloaded anyway. Secondly, I don't know in advance what kind of query might be run, this form lets me just type e.g. <code>select count (name) from dbusers</code> against a dozen databases without having to first think about replicating the dbusers table to a master db.</p>
|
<p>If you run the DataAdapter.Fill method on a DataTable object the table will be updated with the results from the query. So instead of creating new DataTable and DataSet objects and then copying the DataRows manually you can just add rows to the same table.</p>
<p>Try something like this (in untested C# code):</p>
<pre><code>public void BindData(string mySQL)
{
OracleConnection myConnection;
// Empty connection string for now
OracleDataAdapter MainDataAdapter = new OracleDataAdapter(mySQL, "");
DataTable MainDataTable = new DataTable();
string connectionString = "";
Label1.Visible = false;
Label1.Text = "";
foreach (ListItem li in CheckBoxList1.Items)
{
if (li.Selected)
{
connectionString = "Data Source=" + li.Text + "";
connectionString += ";Persist Security Info=True;User ID=user;Password=pass;Unicode=True";
MainDataAdapter.SelectCommand.Connection.ConnectionString = connectionString
try
{
MainDataAdapter.Fill(MainDataTable);
}
catch (OracleException e)
{
Label1.Visible = true;
Label1.Text = Label1.Text + e.Message + " on " + li.Text + "<br>";
}
}
}
GridView1.DataSourceID = String.Empty;
GridView1.DataSource = MainDataTable;
GridView1.DataBind();
}
</code></pre>
<p>I did the following changes:</p>
<ul>
<li>Created one data adapter and assigned it a select command using your mySQL query</li>
<li>Gave the connection an empty connection string</li>
<li>Created a data table object and removed the data sets (you only need them if your query returns several rows)</li>
<li>Changed you loop to just set the connection string of the SelectCommand (you may have to change this to replacing the SelectCommand with a new one)</li>
<li>Removed the connection.Close() calls. The DataAdapter does this automatically.</li>
</ul>
<p>And thats it. If your databases are offline you will still experience slowdowns, but at least the code is simpler and faster since you don't have to copy all the rows between your tables. </p>
<p>One more thing. You can probably set a timeout for the connection in the connection string. Try to lower this one.</p>
|
<p>It sounds like you may be more interested in getting an answer to this more generic question: <strong>How can I execute a long running task without hanging the UI</strong> (ASP or WinForms)?</p>
<p>The answer to that question is to use multiple <a href="http://msdn.microsoft.com/en-us/library/system.threading.thread.aspx" rel="nofollow noreferrer">Threads</a>. I would perform a long running task like this on a separate thread and show the user a page with the current results (either refreshing automatically or with ajax, etc). You can even get fancy and create tasks for each available processor to get the most out of your machine (using something like the <a href="http://blogs.msdn.com/pfxteam/" rel="nofollow noreferrer">Parallel Extensions</a>); however this increases the complexity significantly and can be hard to get right.</p>
<p>If you haven't worked with Threads in .Net a great tutorial can be found <a href="http://www.yoda.arachsys.com/csharp/threads/" rel="nofollow noreferrer">here</a> (by the one and only <a href="https://stackoverflow.com/users/22656/jon-skeet">Jon Skeet</a>)</p>
| 39,280
|
<p>The Python docs say:</p>
<blockquote>
<p>re.MULTILINE: When specified, the pattern character '^' matches at the beginning of the string and at the beginning of each line (immediately following each newline)... By default, '^' matches only at the beginning of the string...</p>
</blockquote>
<p>So what's going on when I get the following unexpected result?</p>
<pre><code>>>> import re
>>> s = """// The quick brown fox.
... // Jumped over the lazy dog."""
>>> re.sub('^//', '', s, re.MULTILINE)
' The quick brown fox.\n// Jumped over the lazy dog.'
</code></pre>
|
<p>Look at the definition of <a href="http://docs.python.org/library/re.html#re.sub" rel="noreferrer"><code>re.sub</code></a>:</p>
<pre><code>re.sub(pattern, repl, string[, count, flags])
</code></pre>
<p>The 4th argument is the count, you are using <code>re.MULTILINE</code> (which is 8) as the count, not as a flag.</p>
<p>Either use a named argument:</p>
<pre><code>re.sub('^//', '', s, flags=re.MULTILINE)
</code></pre>
<p>Or compile the regex first:</p>
<pre><code>re.sub(re.compile('^//', re.MULTILINE), '', s)
</code></pre>
|
<p>The full definition of <a href="http://docs.python.org/library/re.html#re.sub" rel="noreferrer"><code>re.sub</code></a> is:</p>
<pre><code>re.sub(pattern, repl, string[, count, flags])
</code></pre>
<p>Which means that if you tell Python what the parameters are, then you can pass <code>flags</code> without passing <code>count</code>:</p>
<pre><code>re.sub('^//', '', s, flags=re.MULTILINE)
</code></pre>
<p>or, more concisely:</p>
<pre><code>re.sub('^//', '', s, flags=re.M)
</code></pre>
| 6,413
|
<p>When i open some website, can i as a end-user make the Text printed in the IE title bar at top disappear(make it blank or change it to my own text).
e.g. While typing this question my IE title bar says </p>
<p><strong>Ask a Question - Stack Overflow - Windows Internet Explorer</strong></p>
<p>I want to make that blank without at my browser end by way of some IE settings/Windows settings/registry settings etc. Is it possible?</p>
<p>Also is it possible to make the text on IE windows Tab to go blank/customize the text in similar ways??</p>
<p>Just want to keep my SO browsing sessions at work, unnoticed as far as possible!!</p>
<p>-AD</p>
|
<p>Press F11. This will make the titlebar go away. With my settings also the tabs disappear (autohide or something), so that solves everything for you.</p>
<p>As a side-effect the browser will fill your whole screen.</p>
|
<p>You cannot remove "Windows Internet Explorer" from the title bar of Internet Explorer except through the registry. There is no javascript that can do this.</p>
| 27,911
|
<p>There are thousands of <code>vi</code> tutorials on the web, most of them generically listing all the commands. There are even videos on youtube which show basic functionality.</p>
<p>But does anyone know of a vi tutorial which focuses on the <strong>needs of programmers</strong>? </p>
<p>For example when I program in <strong>Perl</strong> with <code>vi</code>, moving to the "next paragraph" is meaningless.</p>
<p>I want to know which commands seasoned vi users combine to e.g:</p>
<ul>
<li>copy everything inside of parentheses</li>
<li>copy a function</li>
<li>copy and paste a variable (e.g. 2yw)</li>
<li>etc.</li>
</ul>
<p>I am sure there are lots of functions using multiple-file capability, and the maps, macros, reading in of files for template code, regular expression search, jumping to functions, perhaps minimal code completion, or other features that emulate what programmers have gotten used to in Visual Studio and Eclipse, etc. </p>
|
<p>A nice collection of <a href="http://rayninfo.co.uk/vimtips.html" rel="noreferrer">vimtips</a>.</p>
<p>And the best Vim <a href="http://www.cheat-sheets.org/saved-copy/vimqrc.pdf" rel="noreferrer">cheatsheet</a> around.</p>
|
<p>I just ended up reading the vim manual a few times, over the years, picking up useful features on each iteration.</p>
<p>One thing that really made vim work for me as a perl IDE was starting to use tags, as explained here: <a href="http://www.vim.org/tips/tip.php?tip_id=94" rel="nofollow noreferrer">http://www.vim.org/tips/tip.php?tip_id=94</a>. Using the pltags script that ships with vim, you can jump around between modules to find your functions, methods, etc.</p>
| 6,935
|
<p>I want to extend the basic <code>ControlCollection</code> in VB.NET so I can just add images and text to a self-made control, and then automaticly convert them to pictureboxes and lables.</p>
<p>So I made a class that inherits from ControlCollection, overrided the add method, and added the functionality.</p>
<p>But when I run the example, it gives a <code>NullReferenceException</code>.</p>
<p>Here is the code:</p>
<pre><code> Shadows Sub add(ByVal text As String)
Dim LB As New Label
LB.AutoSize = True
LB.Text = text
MyBase.Add(LB) 'Here it gives the exception.
End Sub
</code></pre>
<p>I searched on Google, and someone said that the <code>CreateControlsInstance</code> method needs to be overriden. So I did that, but then it gives <code>InvalidOperationException</code> with an <code>innerException</code> message of <code>NullReferenceException</code>.</p>
<p>How do I to implement this?</p>
|
<p>Why not inherit from <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.usercontrol.aspx" rel="nofollow noreferrer">UserControl</a> to define a custom control that has properties like Text and Image?</p>
|
<p>You are probably better off using just a generic collection anyways. Bieng Control Collection doesnt really do anything special for it.</p>
<pre><code>puclic class MyCollection : Collection<Control>
</code></pre>
| 13,904
|
<p>I have the following code that I wrote but it the SQLBindCol does not seem to work correctly (of course I could have screwed up the whole program too!.) The connection works, it creates the table in the DB, addes the record fine and they all look good in SQL Enterprise Manager. So what I need help with is after the comment "Part 3 & 4: Searchs based on criteria." Perhaps I should have done this assignment completely different or is this an acceptable method?</p>
<pre><code>#include <iostream>
#include <cstdio>
#include <string>
#include <windows.h>
#include <sql.h>
#include <sqlext.h>
#include <sqltypes.h>
using namespace std; // to save us having to type std::
const int MAX_CHAR = 1024;
int main ( )
{
SQLCHAR SQLStmt[MAX_CHAR];
char strSQL[MAX_CHAR];
char chrTemp;
SQLVARCHAR rtnFirstName[50];
SQLVARCHAR rtnLastName[50];
SQLVARCHAR rtnAddress[30];
SQLVARCHAR rtnCity[30];
SQLVARCHAR rtnState[3];
SQLDOUBLE rtnSalary;
SQLVARCHAR rtnGender[1];
SQLINTEGER rtnAge;
// Get a handle to the database
SQLHENV EnvironmentHandle;
RETCODE retcode = SQLAllocHandle( SQL_HANDLE_ENV, SQL_NULL_HANDLE, &EnvironmentHandle );
// Set the SQL environment flags
retcode = SQLSetEnvAttr( EnvironmentHandle, SQL_ATTR_ODBC_VERSION, (SQLPOINTER) SQL_OV_ODBC3, SQL_IS_INTEGER );
// create handle to the SQL database
SQLHDBC ConnHandle;
retcode = SQLAllocHandle( SQL_HANDLE_DBC, EnvironmentHandle, &ConnHandle );
// Open the database using a System DSN
retcode = SQLDriverConnect(ConnHandle,
NULL,
(SQLCHAR*)"DSN=PRG411;UID=myUser;PWD=myPass;",
SQL_NTS,
NULL,
SQL_NTS,
NULL,
SQL_DRIVER_NOPROMPT);
if (!retcode)
{
cout << "SQLConnect() Failed";
}
else
{
// create a SQL Statement variable
SQLHSTMT StatementHandle;
retcode = SQLAllocHandle(SQL_HANDLE_STMT, ConnHandle, &StatementHandle);
// Part 1: Create the Employee table (Database)
do
{
cout << "Create the new table? ";
cin >> chrTemp;
} while (cin.fail());
if (chrTemp == 'y' || chrTemp == 'Y')
{
strcpy((char *) SQLStmt, "CREATE TABLE [dbo].[Employee]([pkEmployeeID] [int] IDENTITY(1,1) NOT NULL,[FirstName] [varchar](50) NOT NULL,[LastName] [varchar](50) NOT NULL,[Address] [varchar](30) NOT NULL,[City] [varchar](30) NOT NULL,[State] [varchar](3) NOT NULL, [Salary] [double] NOT NULL,[Gender] [varchar](1) NOT NULL, [Age] [int] NOT NULL, CONSTRAINT [PK_Employee] PRIMARY KEY CLUSTERED ([pkEmployeeID] ASC)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]) ON [PRIMARY]");
retcode = SQLExecDirect(StatementHandle, SQLStmt, SQL_NTS);
}
// Part 2: Hardcode records into the table
do
{
cout << "Add records to the table? ";
cin >> chrTemp;
} while (cin.fail());
if (chrTemp == 'y' || chrTemp == 'Y')
{
strcpy((char *) SQLStmt, "INSERT INTO employee([FirstName], [LastName], [Address], [City], [State], [Salary], [Gender],[Age]) VALUES ('Mike','Slentz','123 Torrey Dr.','North Clairmont','CA', 48000.00 ,'M',34)");
retcode = SQLExecDirect(StatementHandle, SQLStmt, SQL_NTS);
strcpy((char *) SQLStmt, "INSERT INTO employee([FirstName], [LastName], [Address], [City], [State], [Salary], [Gender],[Age]) VALUES ('Sue','Vander Hayden','46 East West St.','San Diego','CA', 36000.00 ,'F',28)");
retcode = SQLExecDirect(StatementHandle, SQLStmt, SQL_NTS);
strcpy((char *) SQLStmt, "INSERT INTO employee([FirstName], [LastName], [Address], [City], [State], [Salary], [Gender],[Age]) VALUES ('Sharon','Stonewall','756 West Olive Garden Way','Plymouth','MA', 56000.00 ,'F',58)");
retcode = SQLExecDirect(StatementHandle, SQLStmt, SQL_NTS);
strcpy((char *) SQLStmt, "INSERT INTO employee([FirstName], [LastName], [Address], [City], [State], [Salary], [Gender],[Age]) VALUES ('James','Bartholemew','777 Praying Way','Falls Church','VA', 51000.00 ,'M',45)");
retcode = SQLExecDirect(StatementHandle, SQLStmt, SQL_NTS);
strcpy((char *) SQLStmt, "INSERT INTO employee([FirstName], [LastName], [Address], [City], [State], [Salary], [Gender],[Age]) VALUES ('Joe','Smith','111 North 43rd Ave','Peoria','AZ', 44000.00 ,'M', 40)");
retcode = SQLExecDirect(StatementHandle, SQLStmt, SQL_NTS);
strcpy((char *) SQLStmt, "INSERT INTO employee([FirstName], [LastName], [Address], [City], [State], [Salary], [Gender],[Age]) VALUES ('Michael','Smith','20344 North Swan Park','Phoenix','AZ', 24000.00 ,'M', 40)");
retcode = SQLExecDirect(StatementHandle, SQLStmt, SQL_NTS);
strcpy((char *) SQLStmt, "INSERT INTO employee([FirstName], [LastName], [Address], [City], [State], [Salary], [Gender],[Age]) VALUES ('Jennifer','Jones','123 West North Ave','Flagstaff','AZ', 40000.00 ,'F', 40)");
retcode = SQLExecDirect(StatementHandle, SQLStmt, SQL_NTS);
strcpy((char *) SQLStmt, "INSERT INTO employee([FirstName], [LastName], [Address], [City], [State], [Salary], [Gender],[Age]) VALUES ('Cora','York','33rd Park Way Drive','Mayville','MI', 30000.00 ,'F', 61)");
retcode = SQLExecDirect(StatementHandle, SQLStmt, SQL_NTS);
strcpy((char *) SQLStmt, "INSERT INTO employee([FirstName], [LastName], [Address], [City], [State], [Salary], [Gender],[Age]) VALUES ('Tom','Jefferson','234 Friendship Way','Battle Creek','MI', 41000.00 ,'M', 31)");
retcode = SQLExecDirect(StatementHandle, SQLStmt, SQL_NTS);
}
// Part 3 & 4: Searchs based on criteria
do
{
cout << "1. Display all records in the database" << endl;
cout << "2. Display all records with age greater than 40" << endl;
cout << "3. Display all records with salary over $30K" << endl;
cout << "4. Exit" << endl << endl;
do
{
cout << "Please enter a selection: ";
cin >> chrTemp;
} while (cin.fail());
if (chrTemp == '1')
{
strcpy((char *) SQLStmt, "SELECT [FirstName], [LastName], [Address], [City], [State], [Salary], [Gender],[Age] FROM EMPLOYEE");
}
else if (chrTemp == '2')
{
strcpy((char *) SQLStmt, "SELECT [FirstName], [LastName], [Address], [City], [State], [Salary], [Gender],[Age] FROM EMPLOYEE WHERE [AGE] > 40");
}
else if (chrTemp == '3')
{
strcpy((char *) SQLStmt, "SELECT [FirstName], [LastName], [Address], [City], [State], [Salary], [Gender],[Age] FROM EMPLOYEE WHERE [Salary] > 30000");
}
if (chrTemp == '1' || chrTemp == '2' || chrTemp == '3')
{
retcode = SQLExecDirect(StatementHandle, SQLStmt, SQL_NTS);
SQLBindCol(StatementHandle, 1, SQL_C_CHAR, &rtnFirstName, sizeof(rtnFirstName), NULL );
SQLBindCol(StatementHandle, 2, SQL_C_CHAR, &rtnLastName, sizeof(rtnLastName), NULL );
SQLBindCol(StatementHandle, 3, SQL_C_CHAR, &rtnAddress, sizeof(rtnAddress), NULL );
SQLBindCol(StatementHandle, 4, SQL_C_CHAR, &rtnCity, sizeof(rtnCity), NULL );
SQLBindCol(StatementHandle, 5, SQL_C_CHAR, &rtnState, sizeof(rtnState), NULL );
SQLBindCol(StatementHandle, 6, SQL_C_DOUBLE, &rtnSalary, sizeof(rtnSalary), NULL );
SQLBindCol(StatementHandle, 7, SQL_C_CHAR, &rtnGender, sizeof(rtnGender), NULL );
SQLBindCol(StatementHandle, 8, SQL_C_NUMERIC, &rtnAge, sizeof(rtnAge), NULL );
for(;;)
{
retcode = SQLFetch(StatementHandle);
if (retcode == SQL_NO_DATA_FOUND) break;
cout << rtnFirstName << " " << rtnLastName << " " << rtnAddress << " " << rtnCity << " " << rtnState << " " << rtnSalary << " " << rtnGender << "" << rtnAge << endl;
}
}
} while (chrTemp != '4');
SQLFreeStmt(StatementHandle, SQL_CLOSE );
SQLFreeConnect(ConnHandle);
SQLFreeEnv(EnvironmentHandle);
printf( "Done.\n" );
}
return 0;
}
</code></pre>
|
<p>You can get enough diagnostic out of SQL that you may be able to isolate and resolve the issue.</p>
<p>You can get the statement handle to tell you what has gone wrong with it by calling when SQLExecDirect returns something other than <code>SQL_SUCCESS</code> or <code>SQL_SUCCESS_WITH_INFO</code></p>
<p><code>SQLGetDiagRec( SQL_HANDLE_STMT, StatementHandle, req, state, &error, (SQLCHAR*) buffer, (SQLINTEGER) MAX_CHAR, (SQLSMALLINT*) &output_length );</code></p>
<p>You'll have to allocate the variables you see here of course... I suggest you put a throw away line after the <code>SQLGetDiagRec</code> call and assign a breakpoint to it. When it breaks there, you can look at <code>state</code>'s value: that will align with the "Diagnostics" section here:
<a href="http://msdn.microsoft.com/en-us/library/ms713611(VS.85).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms713611(VS.85).aspx</a></p>
|
<p>You said you were getting errors with:</p>
<p>string sqlString = "Select * From Customers Where Customers.Employee = '" +id+ "'";</p>
<p>It should be obvious, sorry, lol. The id is integer, sure. But when you evaluate the string, it comes up like so:</p>
<p>string sqlString = "Select * From Customers Where Customers.Employee = '100'";</p>
<p>Notice what's wrong? You have single quotes around it. So no matter what data type you are using, the single quotes makes the SQL treat it as a string. So just take them out like so:</p>
<p>string sqlString = "Select * From Customers Where Customers.Employee = " + id + "";
. . . . . . . Or,
string sqlString = "Select * From Customers Where Customers.Employee = " + id;</p>
<hr>
<p>My question is this... Can you explain how looping through records in C++ works? For example, the user inputs a user name to strUName, and you wanna see if that user name is in the database table Users. The SQL is easy enough (select * from Users where [UName] = '" + strUName + "'; But How do you actually execute it in C++ and figure it out?</p>
<p>I see the SQLStmt, I see it being executed using Direct. I then see some SQLBindCol junk and then an infinite loop until break evals. But I don't quite get what's happening (This is easy for any other language for me, but I'm new to C++.</p>
| 18,506
|
<p>Yes, I know. The existence of a running copy of <code>SQL Server 6.5</code> in 2008 is absurd.</p>
<p>That stipulated, what is the best way to migrate from <code>6.5</code> to <code>2005</code>? Is there any direct path? Most of the documentation I've found deals with upgrading <code>6.5</code> to <code>7</code>.</p>
<p>Should I forget about the native <code>SQL Server</code> upgrade utilities, script out all of the objects and data, and try to recreate from scratch?</p>
<p>I was going to attempt the upgrade this weekend, but server issues pushed it back till next. So, any ideas would be welcomed during the course of the week.</p>
<p><em>Update. This is how I ended up doing it:</em></p>
<ul>
<li>Back up the database in question and Master on <code>6.5</code>.</li>
<li>Execute <code>SQL Server 2000</code>'s <code>instcat.sql</code> against <code>6.5</code>'s Master. This allows <code>SQL Server 2000</code>'s OLEDB provider to connect to <code>6.5</code>.</li>
<li>Use <code>SQL Server 2000</code>'s standalone <code>"Import and Export Data"</code> to create a DTS package, using <code>OLEDB</code> to connect to 6.5. This successfully copied all <code>6.5</code>'s tables to a new <code>2005</code> database (also using <code>OLEDB</code>).</li>
<li>Use <code>6.5</code>'s Enterprise Manager to script out all of the database's indexes and triggers to a .sql file.</li>
<li>Execute that .sql file against the new copy of the database, in 2005's Management Studio.</li>
<li>Use 6.5's Enterprise Manager to script out all of the stored procedures.</li>
<li>Execute that <code>.sql</code> file against the <code>2005</code> database. Several dozen sprocs had issues making them incompatible with <code>2005</code>. Mainly <code>non-ANSI joins</code> and <code>quoted identifier issues</code>.</li>
<li>Corrected all of those issues and re-executed the <code>.sql</code> file.</li>
<li>Recreated the <code>6.5</code>'s logins in <code>2005</code> and gave them appropriate permissions.</li>
</ul>
<p>There was a bit of rinse/repeat when correcting the stored procedures (there were hundreds of them to correct), but the upgrade went great otherwise.</p>
<p>Being able to use Management Studio instead of <code>Query Analyzer</code> and <code>Enterprise Manager 6.5</code> is such an amazing difference. A few report queries that took 20-30 seconds on the <code>6.5 database</code> are now running in 1-2 seconds, without any modification, new indexes, or anything. I didn't expect that kind of immediate improvement.</p>
|
<p>Hey, I'm still stuck in that camp too. The third party application we have to support is FINALLY going to 2K5, so we're almost out of the wood. But I feel your pain 8^D</p>
<p>That said, from everything I heard from our DBA, the key is to convert the database to 8.0 format first, and then go to 2005. I believe they used the built in migration/upgrade tools for this. There are some big steps between 6.5 and 8.0 that are better solved there than going from 6.5 to 2005 directly.</p>
<p>Your BIGGEST pain, if you didn't know already, is that DTS is gone in favor of SSIS. There is a shell type module that will run your existing DTS packages, but you're going to want to manually recreate them all in SSIS. Ease of this will depend on the complexity of the packages themselves, but I've done a few at work so far and they've been pretty smooth.</p>
|
<p>I am by no means authoritative, but I believe the only supported path is from 6.5 to 7. Certainly that would be the most sane route, then I believe you can migrate from 7 directly to 2005 pretty painlessly.</p>
<p>As for scripting out all the objects - I would advise against it as you will inevitably miss something (unless your database is truly trivial).</p>
| 2,270
|
<p>Coming from a Ruby background, I'm used to writing all my code using classes with methods and such. I do know javascript quite well, but I'm new to jQuery and its best practices.</p>
<p>Obviously there are a million ways to simulate classes in javascript. But, what is the actual jQuery community REALLY using in the real world?</p>
<p>Specific examples would be ideal. Or links to real production code. Links to fictional ideal code would also be helpful.</p>
<p>Thanks!</p>
|
<p>I'd start here for inspiration:</p>
<p><a href="http://errtheblog.com/posts/73-the-jskinny-on-jquery" rel="nofollow noreferrer">http://errtheblog.com/posts/73-the-jskinny-on-jquery</a></p>
|
<p>I am struggling with same problem using jQuery in my current project and I am feeling same about jQuery. It is like big cryptic method chains. And when it is getting bigger it takes more time to understand what I wrote earlier.</p>
<p>The only way I found to make more maintainable jQuery code is <a href="http://www.yuiblog.com/blog/2007/06/12/module-pattern/" rel="nofollow noreferrer">Module Pattern</a>.Maybe it can be useful.Also you can look at Ajaxian <a href="http://ajaxian.com/archives/jquery-vs-prototype-oo-javascript-with-or-without-training-wheels" rel="nofollow noreferrer">jQuery vs. Prototype: OO JavaScript with or without training wheels</a> article about same problem.</p>
| 26,033
|
<p>I have inherited a application framework from the previous developer where I now work. This framework utilizes multiple parent/child relationships. In many instances parent/parent/child occur. I asked why he WASN'T using MDI and he stated that years ago, when he had started, MDI had major shortcomings concerning the previously stated relationship scenarios. Particularly with the multiple Parents.</p>
<p>My actual questions are; Does MDI still have these shortcomings? & Those of you who have worked with MDI, what problems did you have and how did you overcome them?</p>
<p>Thank You!</p>
|
<p>One problem with MDI interfaces is that you can't register unlimited Window's within your MDI Containers anyway (see <a href="http://support.microsoft.com/kb/126962" rel="nofollow noreferrer">This Microsoft KB item</a>). Thought i posted that up because i've seen many MDI applications hit that error when its heavily used.</p>
<p>I generally like an SDI Interface and make it share the same controls and windows over multiple instances of 'something' instead of spawning a new Window for each instance of 'something'. </p>
<p>I dont know the specifics of the programs interface but i've yet to find something that couldnt be reworked to an SDI interface and some modal dialogs (if really needed).</p>
|
<p>I have certainly seen some glitches in MDI at times, but to be honest I would probably suggest looking at WPF instead of winforms if you want something complex.</p>
| 48,707
|
<p>I want to create a license key, which cryptography algorithm would you recommend?</p>
<p>Basically the inputs would be:</p>
<blockquote>
<p>company name<br/>
major version number<br/>
date created<br/>
expirey date<br/>
has feature1:<br/>
has feature2:<br/>
has feature3:</p>
</blockquote>
<p>e.g. Acme Inc 5.0 20081102 20081102 0 1 0</p>
<p>Related: <a href="https://stackoverflow.com/questions/258721/which-built-in-net-crypotgraphy-algorithm-is-the-most-secure">Which built-in .NET cryptography algorithm is the most secure?</a></p>
|
<p>I would recommend: Don't spend too much time on securing your keys.
With byte compiled languages it is very easy to decompile and just make the application skip the validation step. No matter how secure your keys are, they don't matter when your validation function always return true. Serial keys are there to keep honest people honest.</p>
|
<p>If you would like to see an example of Triple DES encryption, you can take a look at <a href="http://www.wrightin.gs/2008/11/how-to-encryptdecrypt-sensitive-column-contents-in-nhibernateactive-record-video.html" rel="nofollow noreferrer">my blog post</a> on encrypting data in a database. </p>
<p>The blog post contains a video and the source code. </p>
<p>Although it focuses on encrypting string columns in the database, you can definitely modify it to work with licensing fields.</p>
<p>The source code is written in C# and uses Triple DES algorithms.</p>
| 32,341
|
<p>Backgrounder:</p>
<p>The <a href="http://en.wikipedia.org/wiki/Opaque_pointer" rel="noreferrer">PIMPL Idiom</a> (Pointer to IMPLementation) is a technique for implementation hiding in which a public class wraps a structure or class that cannot be seen outside the library the public class is part of.</p>
<p>This hides internal implementation details and data from the user of the library.</p>
<p>When implementing this idiom why would you place the public methods on the pimpl class and not the public class since the public classes method implementations would be compiled into the library and the user only has the header file?</p>
<p>To illustrate, this code puts the <code>Purr()</code> implementation on the impl class and wraps it as well.</p>
<p><strong>Why not implement Purr directly on the public class?</strong></p>
<pre class="lang-c++ prettyprint-override"><code>// header file:
class Cat {
private:
class CatImpl; // Not defined here
CatImpl *cat_; // Handle
public:
Cat(); // Constructor
~Cat(); // Destructor
// Other operations...
Purr();
};
// CPP file:
#include "cat.h"
class Cat::CatImpl {
Purr();
... // The actual implementation can be anything
};
Cat::Cat() {
cat_ = new CatImpl;
}
Cat::~Cat() {
delete cat_;
}
Cat::Purr(){ cat_->Purr(); }
CatImpl::Purr(){
printf("purrrrrr");
}
</code></pre>
|
<p>I think most people refer to this as the <em>Handle Body</em> idiom. See James Coplien's book <em><a href="https://rads.stackoverflow.com/amzn/click/com/0201548550" rel="noreferrer" rel="nofollow noreferrer">Advanced C++ Programming Styles and Idioms</a></em>. It's also known as the <a href="http://en.wikipedia.org/wiki/Cheshire_Cat" rel="noreferrer">Cheshire Cat</a> because of <a href="https://en.wikipedia.org/wiki/Lewis_Carroll" rel="noreferrer">Lewis Caroll's</a> character that fades away until only the grin remains.</p>
<p>The example code should be distributed across two sets of source files. Then only <em>Cat.h</em> is the file that is shipped with the product.</p>
<p><em>CatImpl.h</em> is included by <em>Cat.cpp</em> and <em>CatImpl.cpp</em> contains the implementation for <em>CatImpl::Purr()</em>. This won't be visible to the public using your product.</p>
<p>Basically the idea is to hide as much as possible of the implementation from prying eyes.</p>
<p>This is most useful where you have a commercial product that is shipped as a series of libraries that are accessed via an API that the customer's code is compiled against and linked to.</p>
<p>We did this with the rewrite of <a href="https://en.wikipedia.org/wiki/IONA_Technologies" rel="noreferrer">IONA's</a> <a href="https://en.wikipedia.org/wiki/Orbix_(software)" rel="noreferrer">Orbix</a> 3.3 product in 2000.</p>
<p>As mentioned by others, using his technique completely decouples the implementation from the interface of the object. Then you won't have to recompile everything that uses <em>Cat</em> if you just want to change the implementation of <em>Purr()</em>.</p>
<p>This technique is used in a methodology called <a href="http://en.wikipedia.org/wiki/Design_by_contract" rel="noreferrer">design by contract</a>.</p>
|
<p>I don't know if this is a difference worth mentioning but...</p>
<p>Would it be possible to have the implementation in its own namespace and have a public wrapper / library namespace for the code the user sees:</p>
<pre><code>catlib::Cat::Purr(){ cat_->Purr(); }
cat::Cat::Purr(){
printf("purrrrrr");
}
</code></pre>
<p>This way all library code can make use of the cat namespace and as the need to expose a class to the user arises a wrapper could be created in the catlib namespace.</p>
| 8,548
|
<p>The following code</p>
<pre><code>number=1
if [[ $number =~ [0-9] ]]
then
echo matched
fi
</code></pre>
<p>works. If I try to use quotes in the regex, however, it stops:</p>
<pre><code>number=1
if [[ $number =~ "[0-9]" ]]
then
echo matched
fi
</code></pre>
<p>I tried <code>"\[0-9\]"</code>, too. What am I missing?</p>
<p>Funnily enough, <a href="http://www.tldp.org/LDP/abs/html/abs-guide.html#REGEXMATCHREF" rel="noreferrer">bash advanced scripting guide</a> suggests this should work.</p>
<p>Bash version 3.2.39.</p>
|
<p>It was changed <a href="http://tiswww.case.edu/php/chet/bash/NEWS" rel="noreferrer">between 3.1 and 3.2</a>. Guess the advanced guide needs an update.</p>
<blockquote>
<p>This is a terse description of the new
features added to bash-3.2 since the
release of bash-3.1. As always, the
manual page (doc/bash.1) is the place
to look for complete descriptions.</p>
<ol>
<li>New Features in Bash</li>
</ol>
<p>snip</p>
<p>f. Quoting the string argument to the
[[ command's =~ operator now forces
string matching, as with the other pattern-matching operators.</p>
</blockquote>
<p>Sadly this'll break existing quote using scripts unless you had the insight to store patterns in variables and use them instead of the regexes directly. Example below.</p>
<pre><code>$ bash --version
GNU bash, version 3.2.39(1)-release (i486-pc-linux-gnu)
Copyright (C) 2007 Free Software Foundation, Inc.
$ number=2
$ if [[ $number =~ "[0-9]" ]]; then echo match; fi
$ if [[ $number =~ [0-9] ]]; then echo match; fi
match
$ re="[0-9]"
$ if [[ $number =~ $re ]]; then echo MATCH; fi
MATCH
$ bash --version
GNU bash, version 3.00.0(1)-release (i586-suse-linux)
Copyright (C) 2004 Free Software Foundation, Inc.
$ number=2
$ if [[ $number =~ "[0-9]" ]]; then echo match; fi
match
$ if [[ "$number" =~ [0-9] ]]; then echo match; fi
match
</code></pre>
|
<p>Using a local variable has slightly better performance than using command substitution.</p>
<p>For larger scripts, or collections of scripts, it might make sense to use a utility to prevent unwanted local variables polluting the code, and to reduce verbosity. This seems to work well:</p>
<pre class="lang-bash prettyprint-override"><code># Bash's built-in regular expression matching requires the regular expression
# to be unqouted (see https://stackoverflow.com/q/218156), which makes it harder
# to use some special characters, e.g., the dollar sign.
# This wrapper works around the issue by using a local variable, which means the
# quotes are not passed on to the regex engine.
regex_match() {
local string regex
string="${1?}"
regex="${2?}"
# shellcheck disable=SC2046 `regex` is deliberately unquoted, see above.
[[ "${string}" =~ ${regex} ]]
}
</code></pre>
<p>Example usage:</p>
<pre class="lang-bash prettyprint-override"><code>if regex_match "${number}" '[0-9]'; then
echo matched
fi
</code></pre>
| 26,839
|
<p>I have a simple question. Is there a way ( using reflections I suppose ) to iterate all the static values of a class?</p>
<p>For instance </p>
<pre><code>class Any {
static int one = 1;
static int two = 2;
static int three = 3;
public static void main( String [] args ) {
for( int i : magicMethod( Any.class ) ){
System.out.println( i );
}
}
}
</code></pre>
<p>Output</p>
<pre><code> 1
2
3
</code></pre>
<p>Thanks.</p>
|
<pre><code>import java.util.*;
import java.lang.reflect.*;
class Any {
static int one = 1;
static int two = 2;
static int three = 3;
public static void main( String [] args ) {
for( int i : magicMethod( Any.class ) ){
System.out.println( i );
}
}
public static Integer[] magicMethod(Class<Any> c) {
List<Integer> list = new ArrayList<Integer>();
Field[] fields = c.getDeclaredFields();
for (Field field : fields) {
try {
if (field.getType().equals(int.class) && Modifier.isStatic(field.getModifiers())) {
list.add(field.getInt(null));
}
}
catch (IllegalAccessException e) {
// Handle exception here
}
}
return list.toArray(new Integer[list.size()]);
}
}
</code></pre>
|
<p>As an alternative, use an enum and get rid of the class variables entirely (to be precise, the enum is a class variable as well :-)):</p>
<pre><code>class Any {
enum Number {
ONE(1),
TWO(2),
THREE(3);
Number(int number) {
this.number = number;
}
int number;
};
public static void main(String [] args) {
for (Number value : Number.values()) {
System.out.println(value.number);
}
}
}
</code></pre>
| 34,089
|
<p>I have a SQL table which has a number of fields</p>
<p>ID | Value | Type</p>
<p>A typical record may be :-
1000,10,[int]</p>
<p>a second row may be:-</p>
<p>1001,foo,[string]</p>
<p>a third row may be:-</p>
<p>1002,10/12/2008,[DateTime]</p>
<p>I have been asked to look at this as at the moment, each time we wish to select from this table we have to cast the value to the type specified. I am able to do a database redesign on this and am wondering the best route to go to optimise this. (SQL 2000).</p>
|
<p>Horrors! This is the dreaded <a href="http://tonyandrews.blogspot.com/2004/10/otlt-and-eav-two-big-design-mistakes.html" rel="nofollow noreferrer">Entity-Attribute-Value (EAV)</a> model! Run away!</p>
<p>But seriously, assuming there is some reason for needing this kind of model, maybe create a properly typed column for each data type?</p>
<pre><code>ID Type StringValue DateValue NumberValue
1001 String Foo
1002 Date 10/12/2008
1003 Number 123.46
</code></pre>
|
<p>Generally when designing tables you want to know what is actually going to be in them. Do you have a distinct number of data types which you need to support? Do you need to cover decimals? One possible solution would be something like this:</p>
<pre><code>CREATE TABLE dbo.My_Table (
id INT NOT NULL,
data_type VARCHAR(10) NOT NULL,
string_value VARCHAR(100) NULL,
int_value INT NULL,
date_value DATETIME NULL,
CONSTRAINT CK_My_Table_data_type CHECK data_type IN ('int', 'string', 'datetime'),
CONSTRAINT PK_My_Table PRIMARY KEY CLUSTERED (id)
)
GO
</code></pre>
<p>You can then use the data type to decide on which column you want to select or insert/update. Keep in mind though that you might have problems with using:</p>
<pre><code>SELECT
id,
CASE data_type
WHEN 'string' THEN string_value
WHEN 'int' THEN int_value
WHEN 'datetime' THEN date_value
ELSE NULL
END
</code></pre>
<p>SQL Server requires that the data types all match for a column being returned. If you are only ever selecting one at a time it might work ok, but if you ever want to select sets of data then you'll likely need to do some casting anyway or select only rows where the data_type values are equal. I haven't done testing on all of the scenarios though, so you should play around with it to see what works and what doesn't work.</p>
<p>I'll just say again though, you should look at the design of your application again. It's certainly possible that you have a requirement for this kind of functionality, but often times when I see this design pattern what the front-end REALLY wants is a string that will be displayed in the application. That string just happens to look like a number or a date at times. If you're going to actually be performing data type specific functions on the data then it's likely that a less "flexible" design is called for, but without knowing all of your requirements I can't say. This is just from my experience in the past.</p>
<p>EDIT: Looks like I type too slowly and Tony beat me to it. :)</p>
| 41,451
|
<p>Wifi support on Vista is fine, but <a href="http://msdn.microsoft.com/en-us/library/bb204766.aspx" rel="nofollow noreferrer">Native Wifi on XP</a> is half baked. <a href="http://msdn.microsoft.com/en-us/library/aa504121.aspx" rel="nofollow noreferrer">NDIS 802.11 Wireless LAN Miniport Drivers</a> only gets you part of the way there (e.g. network scanning). From what I've read (and tried), the 802.11 NDIS drivers on XP will <em>not</em> allow you to configure a wireless connection. You have to use the Native Wifi API in order to do this. (Please, correct me if I'm wrong here.) Applications like <a href="http://www.metageek.net/products/inssider" rel="nofollow noreferrer">InSSIDer</a> have helped me to understand the APIs, but InSSIDer is just a scanner and is not designed to configure Wifi networks.</p>
<p>So, the question is: where can I find some code examples (C# or C++) that deal with the configuration of Wifi networks on XP -- e.g. profile creation and connection management?</p>
<p>I should note that this is a XP Embedded application on a closed system where we can't use the built-in Wireless Zero Configuration (WZC). We have to build all Wifi management functionality into our .NET application.</p>
<p>Yes, I've Googled myself blue. It seems that someone should have a solution to this problem, but I can't find it. That's why I'm asking here.</p>
<p>Thanks.</p>
|
<p>You kind of have to get a "feel" for what programmers had to do back in the day. The vast majority of the code I work with is older than I am and ran on machines that were "new" when my parents were in high school.</p>
<p>Common FORTRAN-isms I deal with, that hurt readability are:</p>
<ul>
<li>Common blocks</li>
<li>Implicit variables</li>
<li>Two or three DO loops with shared CONTINUE statements</li>
<li>GOTO's in place of DO loops</li>
<li>Arithmetic IF statements</li>
<li>Computed GOTO's</li>
<li>Equivalence REAL/INTEGER/other in some common block</li>
</ul>
<p>Strategies for solving these involve:</p>
<ol>
<li>Get <a href="http://www.polyhedron.com/spag0html" rel="noreferrer">Spag / plusFORT</a>, worth the money, it solves a lot of them automatically and Bug Free(tm)</li>
<li>Move to Fortran 90 if at all possible, if not move to free-format Fortran 77</li>
<li>Add IMPLICIT NONE to each subroutine and then fix every compile error, time consuming but ultimately necessary, some programs can do this for you automatically (or you can script it)</li>
<li>Moving all COMMON blocks to MODULEs, low hanging fruit, worth it</li>
<li>Convert arithmetic IF statements to IF..ELSEIF..ELSE blocks</li>
<li>Convert computed GOTOs to SELECT CASE blocks</li>
<li><p>Convert all DO loops to the newer F90 syntax</p>
<pre><code>myloop: do ii = 1, nloops
! do something
enddo myloop
</code></pre></li>
<li><p>Convert equivalenced common block members to either ALLOCATABLE memory allocated in a module, or to their true character routines if it is Hollerith being stored in a REAL</p></li>
</ol>
<p>If you had more specific questions as to how to accomplish some readability tasks, I can give advice. I have a code base of a few hundred thousand lines of Fortran which was written over the span of 40 years that I am in some way responsible for, so I've probably run across any "problems" you may have found.</p>
|
<p>Here's another one that has bit me from time to time. When you are working on FORTRAN code make sure you skip all six initial columns. Every once and a while, I'll only get the code indented five spaces and nothing works. At first glance everything seems okay and then I finally realize that all the lines are starting in column 6 instead of column 7.</p>
<p>For anyone not familiar with FORTRAN, the first 5 columns are for line numbers (=labels), the 6th column is for a continuation character in case you have a line longer than 80 characters (just put something here and the compiler knows that this line is actually part of the one before it) and code always starts in column 7.</p>
| 5,161
|
<p>(under asp.net enviro)</p>
<p>I will be sending data to a central server via a web service, and I want to hash the data to ensure that it didn't get corrupted during transfer.</p>
<p>Which hash method should I use?
Can I hash when the web service is passing objects?</p>
|
<p>Preferably use <a href="http://en.wikipedia.org/wiki/Sha1" rel="nofollow noreferrer">SHA1</a>. You can also use <a href="http://en.wikipedia.org/wiki/MD5" rel="nofollow noreferrer">MD5</a>.</p>
|
<p>I'd recommend just calling GetHashcode() on the byte array of your data. Send this value as part of the webservice call and verify that they match on the other side.</p>
| 25,566
|
<p><code>GWT</code> gets locale from either the locale property or the locale query string. If neither is specified, it uses the "default" (ie <code>en_US</code>) locale.</p>
<p>Why doesn't it get it from the browser settings?</p>
<p>It seems the only solution to this is to replace your static html launch page with something like a JSP that reads the browser locales and sets the locale or redirects using the query string. There has to be a better solution than this or simply hard-coding a locale, surely?</p>
|
<p>You can also put this switch in your *.gwt.xml</p>
<pre><code><set-configuration-property name="locale.useragent" value="Y"/>
</code></pre>
<p>this will add language selecting based on language selected in browser. You can also control search order for locale by setting</p>
<pre><code> <set-configuration-property name="locale.searchorder" value="queryparam,cookie,meta,useragent"/>
</code></pre>
<p>But beware that in IE this doesn't work - you should develop server-side language pick based on 'Accept-Language' header send by the IE.</p>
|
<p>If your entry page is a JSP you can inspect the request's <code>Accept-Language</code> header to dynamically set the locale.</p>
| 18,920
|
<p>Can anyone tell me if there are RDBMSs that allow me to create a separate database for every user so that there is full separation of users' data?
Are there any?</p>
<p>I know I can add UID to every table but this solution has its own problems (for example per user database schema changes are impossible).</p>
|
<p>Doesnt MySQL, PostgreSQL, Oracle and so on and so on allow you to do that?. There's the grant statements to control ACLs</p>
|
<p>MS SQLServer2005 is one which can be used for multiple users.An instance can be created
if you have any, run the previlegs and use one user per instance</p>
| 20,888
|
<p>I have a custom login component in Flex that is a simple form that dispatches a custom LoginEvent when a user click the login button:</p>
<pre><code>
<?xml version="1.0" encoding="utf-8"?>
<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml" defaultButton="{btnLogin}">
<mx:Metadata>
[Event(name="login",tpye="events.LoginEvent")]
</mx:Metadata>
<mx:Script>
import events.LoginEvent;
private function _loginEventTrigger():void {
var t:LoginEvent = new LoginEvent(
LoginEvent.LOGIN,
txtUsername.text,
txtPassword.text);
dispatchEvent(t);
}
</mx:Script>
<mx:FormItem label="username:">
<mx:TextInput id="txtUsername" color="black" />
</mx:FormItem>
<mx:FormItem label="password:">
<mx:TextInput id="txtPassword" displayAsPassword="true" />
</mx:FormItem>
<mx:FormItem>
<mx:Button id="btnLogin"
label="login"
cornerRadius="0"
click="_loginEventTrigger()" />
</mx:FormItem>
</mx:Form>
</code></pre>
<p>I then have a main.mxml file that contains the flex application, I add my component to the application without any problem:</p>
<pre><code>
<custom:login_form id="cLogin" />
</code>
</pre>
<p>I then try to wire up my event in actionscript:</p>
<pre>
<code>
import events.LoginEvent;
cLogin.addEventListener(LoginEvent.LOGIN,_handler);
private function _handler(event:LoginEvent):void {
mx.controls.Alert.show("logging in...");
}
</code>
</pre>
<p>Everything looks good to me, but when I compile I get an "error of undefined property cLogin...clearly I have my control with the id "cLogin" but I can't seem to get a"handle to it"...what am I doing wrong?</p>
<p>Thanks.</p>
|
<p>ah! I figured it out...it was a big oversight on mine...it's just one of those days...</p>
<p>I couldn't get the handle on my component because it was not yet created...I fixed this by simply waiting for the component's creationComplete event to fire and then add the event listener.</p>
|
<p>You can also do something like this I believe:</p>
<pre><code><custom:login_form id='cLogin' login='_handler' />
</code></pre>
| 16,223
|
<p>What rules apply to the name that ends up in the exports section of an PE (Portable Executable)?
Roughly, I see names starting with an '_' underscore, a '?' question mark or an '@' at-sign. What do those mean, and what about the rest of the name?</p>
<p>Also - How can I reverse the naming convention into something more usable?</p>
|
<p>I think you are refering to "dll name mangling"</p>
<p><a href="http://cplus.about.com/gi/dynamic/offsite.htm?zi=1/XJ&sdn=cplus&cdn=compute&tm=4&gps=352_1578_1062_840&f=00&su=p284.9.336.ip_p504.1.336.ip_&tt=2&bt=1&bts=0&zu=http%3A//theory.uwinnipeg.ca/gnu/gcc/gxxint_15.html" rel="nofollow noreferrer">name mangling</a></p>
<p>It's used to make sure exports names are unique</p>
<p>You can specify a .def file which will make it easier to use afterwards</p>
<p>Simply put, a .def file is just a text file containing the following structure</p>
<pre><code>LIBRARY "MyDll"
EXPORTS
exportFunction1
</code></pre>
|
<p>I should have looked a little longer before asking this - as I just found an answer to this:</p>
<p>It's called 'name mangling', and here's a link explaning a bit about it : <a href="http://en.wikipedia.org/wiki/Name_mangling" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Name_mangling</a></p>
<p>My apologies for bothering you; Cheers!</p>
| 39,511
|
<p>What's the difference between the list methods <code>append()</code> and <code>extend()</code>?</p>
|
<p><a href="https://docs.python.org/3/library/stdtypes.html#mutable-sequence-types" rel="noreferrer"><code>append</code></a> appends a specified object at the end of the list:</p>
<pre><code>>>> x = [1, 2, 3]
>>> x.append([4, 5])
>>> print(x)
[1, 2, 3, [4, 5]]
</code></pre>
<p><a href="https://docs.python.org/3/library/stdtypes.html#mutable-sequence-types" rel="noreferrer"><code>extend</code></a> extends the list by appending elements from the specified iterable:</p>
<pre><code>>>> x = [1, 2, 3]
>>> x.extend([4, 5])
>>> print(x)
[1, 2, 3, 4, 5]
</code></pre>
|
<p><code>append</code> "extends" the list (in place) by <strong>only one item</strong>, the single object passed (as argument).</p>
<p><code>extend</code> "extends" the list (in place) by <strong>as many items as</strong> the object passed (as argument) contains.</p>
<p>This may be slightly confusing for <code>str</code> objects.</p>
<ol>
<li>If you pass a string as argument:
<code>append</code> will add a single string item at the end but
<code>extend</code> will add as many "single" 'str' items as the length of that string.</li>
<li>If you pass a list of strings as argument:
<code>append</code> will still add a single 'list' item at the end and
<code>extend</code> will add as many 'list' items as the length of the passed list.</li>
</ol>
<blockquote>
<pre><code>def append_o(a_list, element):
a_list.append(element)
print('append:', end = ' ')
for item in a_list:
print(item, end = ',')
print()
def extend_o(a_list, element):
a_list.extend(element)
print('extend:', end = ' ')
for item in a_list:
print(item, end = ',')
print()
append_o(['ab'],'cd')
extend_o(['ab'],'cd')
append_o(['ab'],['cd', 'ef'])
extend_o(['ab'],['cd', 'ef'])
append_o(['ab'],['cd'])
extend_o(['ab'],['cd'])
</code></pre>
</blockquote>
<p>produces:</p>
<pre><code>append: ab,cd,
extend: ab,c,d,
append: ab,['cd', 'ef'],
extend: ab,cd,ef,
append: ab,['cd'],
extend: ab,cd,
</code></pre>
| 31,486
|
<p>I would like to call an ejb3 at runtime. The name of the ejb and the method name will only be available at runtime, so I cannot include any remote interfaces at compile time.</p>
<pre><code>String bean = 'some/Bean';
String meth = 'doStuff';
//lookup the bean
Object remoteInterface = (Object) new InitialContext().lookup(bean);
//search the method ..
// foreach (methods)
// if method == meth, method.invoke(bean);
</code></pre>
<p>the beans should be distributed accross multiple application servers, and all beans are to be called remotely.</p>
<p>Any hints? specifically i do <strong>not</strong> want:</p>
<ol>
<li>dependency injection</li>
<li>inclusion of appliation specific ejb interfaces in the dispatcher (above)</li>
<li>webservices, thats like throwing out processing power for nothing, all the xml crap</li>
</ol>
<p>Is it possible to load an ejb3 remote interface over the network (if yes, how?), so I could cache the interface in some hashmap or something.</p>
<p>I have a solution with a remote dispatcher bean, which I can include in the above main dispatcher, which does essentially the same, but just relays the call to a local ejb (which I can lookup how? naming lookup fails). Given the remote dispatcher bean, I can use dependency injection.</p>
<p>thanks for any help</p>
<p>(netbeans and glassfish btw)</p>
|
<p>ejb3 calls use RMI. RMI supports remote class loading, so i'd suggest looking into that.</p>
<p>also, JMX mbeans support fully untyped, remote invocations. so, if you could use mbeans instead of session beans, that could work. (JBoss, for instance, supports ejb3-like mbeans with some custom annotations).</p>
<p>lastly, many app servers support CORBA invocations, and CORBA supports untyped method invocations.</p>
|
<p>You might be able to use java.rmi.server.RMIClassLoader for the remote class loading. You'll also need to load any classes that the remote service returns or throws.</p>
| 34,729
|
<p>When I place a control on a tabpage in Silverlight the control is placed ~10 pixels down and ~10 pixels right. For example, the following xaml:</p>
<pre><code><System_Windows_Controls:TabControl x:Name=TabControlMain Canvas.Left="0" Canvas.Top="75" Width="800" Height="525" Background="Red" HorizontalContentAlignment="Left" VerticalContentAlignment="Top" Padding="0" Margin="0">
<System_Windows_Controls:TabItem Header="Test" VerticalContentAlignment="Top" BorderThickness="0" Margin="0" Padding="0" HorizontalContentAlignment="Left">
<ContentControl>
<Grid Width="400" Height="200" Background="White"/>
</ContentControl>
</System_Windows_Controls:TabItem>
</System_Windows_Controls:TabControl>
</code></pre>
<p>will produce:</p>
<p><img src="https://i.stack.imgur.com/y5LuN.jpg" alt="alt text"></p>
<p>How do I position the content at 0,0?</p>
|
<p>Check the control template of your TabItem , it might have some default Margin of 10. Just a guess</p>
|
<p>After spending a couple hours fooling around with this problem. Brian is totally right. The current version of VS does not allow changing the TabControl's template, but it can be done using Blend, and there is a margin on the template. The main drawback of doing this is that the XAML file will no longer be previewable from Visual Studio.</p>
| 13,484
|
<p>I'm a total newbie to SVN and haven't been able to find an answer for the following situation.</p>
<p>I have an ASP .NET 2.0 web app that I am developing. I am using my local IIS as the development web server (i.e. not the Visual Studio web development server). My development environment is VS2005, Vista, IIS7, TortoiseSVN / AnkhSVN. VisualSVN is installed on the server. </p>
<p>My .sln files and class libraries, etc. are located in the **C:\Localsource\Projects\ProjectName** folder, and my .aspx files are in my **C:\inetpub\wwwroot\ProjectName** folder. </p>
<p>I can set up the repository for **C:\Localsource\Projects\ProjectName** fine, but can't think of a way to set it up for the IIS folder as well in the same repository. </p>
<p>What's the best way for dealing with this development environment in SVN?</p>
<p>Many thanks,</p>
<p>Ant </p>
|
<p>In a solution in Visual Studio you can have a class library project which is usually in a directory underneath the .sln file.</p>
<p>In this case he also has a web project within the solution but NOT underneath the .sln file in the file directory structure. </p>
<p>He will be attaching to this project via HTTP not via local file path.</p>
<p>IIS will manage this as <a href="http://localhost/webapp" rel="nofollow noreferrer">http://localhost/webapp</a> and by default will place it in c:\inetpub\wwwroot\webapp. The files in webapp folder will not be in the repo as they arent in the hierachy of the solution and the class library. This is his question how to sort it out.</p>
<p>My answer is to move <a href="http://localhost/webapp" rel="nofollow noreferrer">http://localhost/webapp</a> to point to a folder that is underneath the .sln file and adjacent to the class library directory then it can all go in the repo.</p>
<p>Seperating the class library and the the webapp is best practice to aide code re-use and decoupling the logic from the web site.</p>
|
<p>Hmmm - Good point. It was set up like this when I got here, and Visual Studio always creates websites in the wwwroot folder, so I assumed wwwroot was just where they had to go. </p>
<p>Maybe I'll have to think about doing a little rearranging...</p>
<p>Thanks!</p>
| 45,971
|
<p>How can I use/display characters like ♥, ♦, ♣, or ♠ in Java/Eclipse?</p>
<p>When I try to use them directly, e.g. in the source code, Eclipse cannot save the file.</p>
<p>What can I do?</p>
<p>Edit: How can I find the unicode escape sequence?</p>
|
<p>The problem is that the characters you are using cannot be represented in the encoding you have the file set to (Cp1252). The way I see it, you essentially have two options:</p>
<p>Option 1. <strong>Change the encoding.</strong> <a href="http://publib.boulder.ibm.com/infocenter/eruinf/v2r1m1/index.jsp?topic=/com.ibm.iru.doc/concepts/cirerwp.htm" rel="noreferrer">According to IBM</a>, you should set the encoding to UTF-8. I believe this would solve your problem.</p>
<blockquote>
<ul>
<li>Set the global text file encoding preference Workbench > Editors to "UTF-8".</li>
<li>If an encoding other than UTF-8 is required, set the encoding on the individual file rather than using the global preference setting. To do this use the File > Properties > Info menu selection to set the encoding on an individual file.</li>
</ul>
</blockquote>
<p>Option 2. <strong>Remove the characters which are not supported by the "Cp1252" character encoding.</strong> You can replace the unsupported characters with <a href="http://en.wikibooks.org/wiki/Java_Programming/Syntax/Unicode_Escape_Sequences" rel="noreferrer">Unicode escape sequences</a> (\uxxxx). While this would allow you to save your file, it is not necessarily the best solution.</p>
<p>For the characters you specified in your question here are the Unicode escape sequences:</p>
<pre><code>♥ \u2665
♦ \u2666
♣ \u2663
♠ \u2660
</code></pre>
|
<p>Windows Menu –> Preferences –> General (expand it) –> Workspace (click on it).
Look for a box “Text File Encoding”. Default will be “Cp1252″.
Change radio to select other and select “UTF-8″ from combo box.</p>
| 24,491
|
<p>For scripting languages, what is the most effective way to utilize a console when developing? Are there ways to be more productive with a console than a "compile and run" only language?</p>
<p>Added clarification: I am thinking more along the lines of Ruby, Python, Boo, etc. Languages that are used for full blown apps, but also have a way to run small snippets of code in a console.</p>
|
<blockquote>
<p>I am thinking more along the lines of Ruby, ...</p>
</blockquote>
<p>Well for Ruby the <code>irb</code> interactive prompt is a great tool for "practicing" something simple. Here are the things I'll mention about the irb to give you an idea of effective use:</p>
<ul>
<li><p><em>Automation</em>. You are allowed a <code>.irbrc</code> file that will be automatically executed when launching irb. That means you can load your favorite libraries or do <em>whatever</em> you want in full Ruby automatically. To see what I mean check out some of the ones at <a href="https://web.archive.org/web/20110824004021/http://dotfiles.org:80/.irbrc" rel="nofollow noreferrer">dotfiles.org</a>.</p></li>
<li><p><em>Autocompletion</em>. That even makes writing code easier. Can't remember that string method to remove newlines? <code>"".ch<tab></code> produces chop and chomp. <em>NOTE: you have to enable autocompletion for irb yourself</em></p></li>
<li><p><em>Divide and Conquer</em>. irb makes the small things really easy. If you're writing a function to manipulate strings, the ability to test the code interactively right in the prompt saves a lot of time! For instance you can just open up irb and start running functions on an example string and have working and tested code already ready for your library/program. </p></li>
<li><p><em>Learning, Experimenting, and Hacking</em>. Something like this would take a very long time to test in C/C++, even Java. If you tried testing them all at once you might seg-fault and have to start over.</p>
<p>Here I'm just learning how the <code>String#[]</code> function works.</p>
<pre><code>joe[~]$ irb
>> "12341:asdf"[/\d+/]
# => "12341"
>> "12341:asdf"[/\d*/]
# => "12341"
>> "12341:asdf"[0..5]
# => "12341:"
>> "12341:asdf"[0...5]
# => "12341"
>> "12341:asdf"[0, ':']
TypeError: can't convert String into Integer
from (irb):5:in `[]'
from (irb):5
>> "12341:asdf"[0, 5]
# => "12341"
</code></pre></li>
<li><p><em>Testing and Benchmarking</em>. Now they are nice and easy to perform. <a href="http://ozmm.org/posts/time_in_irb.html" rel="nofollow noreferrer">Here</a> is someone's idea to emulate the Unix <code>time</code> function for quick benchmarking. Just add it to your <code>.irbrc</code> file and its always there!</p></li>
<li><p><em>Debugging</em> - I haven't used this much myself but there is always the ability to debug code <a href="https://web.archive.org/web/20080912141043/http://www.rubycentral.com:80/pickaxe/trouble.html" rel="nofollow noreferrer">like this</a>. Or pull out some code and run it in the irb to see what its actually doing.</p></li>
</ul>
<p>I'm sure I'm missing some things but I hit on my favorite points. You really have zero limitation in shells so you're limited only by what you can think of doing. I almost always have a few shells running. Bash, Javascript, and Ruby's irb to name a few. I use them for a lot of things!</p>
|
<p>I've added a shortcut to my Control-Shift-C key combination to bring up my Visual Studio 2008 Console. This alone has saved me countless seconds when needing to register a dll or do any other command. I imagine if you leverage this with another command tool and you may have some massive productivity increases.</p>
| 5,248
|
<p>I'm about to implement a feature in our application that allows the user to 'upload' a PDF or Microsoft PowerPoint document, which the application will then make available to other users in a viewer (so they don't get to 'download' it in the 'Save as..' sense).</p>
<p>I already know how to save and retrieve arbitrary binary information in database columns, but as this will be a commonly used feature of our application I fear that solution would lead to enormously large database tables (as we know one of our customers will want to put video in PowerPoint documents).</p>
<p>I know there's a way to create a 'directory' object in Oracle, but is there a way to use this feature to store and retrieve binary files saved elsewhere on the Database Server?</p>
<p>Or am I being overly paranoid about the database size?</p>
<p>(for completeness our application is .Net WinForms using <a href="http://www.devart.com/oranet/" rel="nofollow noreferrer">CoreLab / DevArt OraDirect.Net drivers</a> to Oracle 10g)</p>
|
<p>Couple of options: You could put the BLOB column in its own tablespace, with its own storage characteristics; you could store the BLOBs in their own table, linked to the other table by an ID column. In either case as you suggested you could define the column as a BFILE which means the actual file is stored externally from the database in a directory. What might be a concern there is that BFILE LOBs do not participate in transactions and are not recoverable with the rest of the database.</p>
<p>This is all discussed in the Oracle 10gR2 SQL reference, chapter 2, starting on page 23.</p>
|
<p>I guess it depends what you consider enormously large.</p>
<p>It really does depend on the use case. If the documents are only being accessed rarely then putting it in the database would be fine (with the advantage of getting "free" backups, eg, with the database).</p>
<p>If these are files which are going to be hit over and over again, you might be better to put them directly on disk and just store the location, or even (if its really high bandwidth) look into something like <a href="http://en.wikipedia.org/wiki/MogileFS" rel="nofollow noreferrer">MogileFS</a></p>
<p>No one is going to be able to give you a Yes or no answer for this.</p>
| 8,837
|
<p>I remember watching a webcast from Mark Russinovich showing the sequence of keyboard keys for a user initiated kernel dump. Can somebody refresh my memory on the exact order of the keys.</p>
<p>Please note this is for XP.</p>
|
<p><a href="http://psacake.com/web/jr.asp" rel="nofollow noreferrer">http://psacake.com/web/jr.asp</a> contains full instructions, and here's an excerpt:</p>
<pre>
While it may seem odd to think about purposefully causing a Blue Screen Of Death (BSOD), Microsoft includes such a provision in Windows XP. This might come in handy for testing and troubleshooting your Startup And Recovery settings, Event logging, and for demonstration purposes.
Here's how to create a BSOD:
Launch the Registry Editor (Regedit.exe).
Go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\i8042prt\Parameters.
Go to Edit, select New | DWORD Value and name the new value CrashOnCtrlScroll.
Double-click the CrashOnCtrlScroll DWORD Value, type 1 in the Value Data textbox, and click OK.
Close the Registry Editor and restart Windows XP.
When you want to cause a BSOD, press and hold down the [Ctrl] key on the right side of your keyboard, and then tap the [ScrollLock] key twice. Now you should see the BSOD.
If your system reboots instead of displaying the BSOD, you'll have to disable the Automatically
Restart setting in the System Properties dialog box. To do so, follow these steps:
Press [Windows]-Break.
Select the Advanced tab.
Click the Settings button in the Startup And Recovery panel.
Clear the Automatically Restart check box in the System Failure panel.
Click OK twice.
Here's how you remove the BSOD configuration:
Launch the Registry Editor (Regedit.exe).
Go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\i8042prt\Parameters.
Select the CrashOnCtrlScroll value, pull down the Edit menu, and select the Delete command.
Close the Registry Editor and restart Windows XP.
Note: Editing the registry is risky, so make sure you have a verified backup before making any changes.
</pre>
<p>And I may be wrong in assuming you want BSOD, so this is a Microsoft Page showing how to capture kernel dumps:
<a href="https://web.archive.org/web/20151014034039/https://support.microsoft.com/fr-ma/kb/316450" rel="nofollow noreferrer">https://web.archive.org/web/20151014034039/https://support.microsoft.com/fr-ma/kb/316450</a></p>
|
<p>I don't know of any keyboard short cuts, but are you looking for like in task manager, when you right click on a process and select "Create Dump"?</p>
| 8,388
|
<p>I'm using a deploy project to deploy my ASP.net web application.
When I build the deploy project, all the .compiled files are re-created.</p>
<p>Do I need to FTP them to the production web server?<br>
If I do a small change do I need to copy all the web site again?</p>
|
<p>From my own research, the .compiled files must be copied to the production server, but not needed to copied every time</p>
<p>from <a href="http://www.west-wind.com/" rel="noreferrer">Rick Strahl</a> excellent blog:</p>
<blockquote>
<p>The output from the merge utilitity
can combine all markup and CodeBeside
code into a single assembly, but you
will still end up with the .compiled
files which are required for ASP.NET
to associate the page requests with a
specific class contained in the
assembly. However, because the file
names generated are fixed you don’t
need to update these files unless you
add or remove pages. In effect this
means that in most situations you can
simply update the single assembly to
update your Web.<br>
<a href="http://www.west-wind.com/presentations/AspNetCompilation/AspNetCompilation.asp" rel="noreferrer">Source</a></p>
</blockquote>
|
<p>There's nothing special about .compiled files: it's just the actual file with a .compiled extension on the end so that nothing happens if you accidentally double click it. </p>
<p>But if you're seeing .compiled files, you're publishing your app in such a way that it expects to be formally installed- it's not enough to just copy things to production. You have to run the installer program too. If this is an app you know is already deployed, that seems a bit unnecessary.</p>
| 8,371
|
<p>I want to print a object that looks like a flat board with a set of matchbox-like lumps on top of it.</p>
<p>I have written a script that outputs an STL file. To keep the script simple, it creates an object that includes non-manifold edges. To be precise, the board and the boxes are a single model, but each has 6 faces made from 2 triangles. The underside of each matchbox rests on the top of the larger flat board.</p>
<p>If I understand correctly, the top face of the board should be broken up into many smaller triangles to take into account the position of the matchboxes, but coding this by hand (although it might be an interesting Exercise For The Reader) would not be a good use of time. Well-written code that already does this is built into FOSS applications like Blender.</p>
<p>However, Blender cannot merge or fuse shapes that are part of the same object. My current understanding is that I will need to:</p>
<ol>
<li>Provide Blender with multiple objects</li>
<li>Select all the objects</li>
<li>Use Ctrl-J to merge them</li>
<li>Export the world in STL format</li>
</ol>
<p>Is this a valid approach?</p>
<p>If so, my key question is: how do I format the STL file so that Blender will recognize that it contains multiple separate objects?</p>
<p>(I have found references to STL files containing multiple objects, but I have seen nothing in any of the STL files that I have examined that tells me: here is the end of one object and the beginning of another.)</p>
<p>Or should I just be clunky and export two STL files — one for the board and one for all the matchboxes — and then import both into Blender?</p>
<hr>
<p>NOTE: I know that there are free services like <a href="https://service.netfabb.com/login.php" rel="noreferrer">Netfabb</a> that will correct my simple files for me, but I would prefer not to include that in my workflow if possible.</p>
|
<p>Blender imports all STL files as if they are a single object. If you have multiple meshes in the object that you want to be separated, you can press tab to enter edit mode, select the parts that need to be separated, then hit P and separate by selected.</p>
<p>If you want to print those pieces as one part you have to get rid of any internal faces. The easiest way to do that is to select an object and then use the boolean modifier in union mode. Once you have the object that you want to fuse selected and in place, apply the modifier, that should leave you with an object without internal faces.</p>
|
<p>I think there's an easier way to do this - <em>if</em> you're not committed to using Blender, and it sounds as if you're not.</p>
<p>Take a look at <a href="http://www.openscad.org/" rel="nofollow noreferrer">http://www.openscad.org/</a> (which should run anywhere that Blender does). It's very easy to write code to produce your desired shape (in this case it would be a union of cuboids) in OpenSCAD's description language, and then you can use OpenSCAD itself to render that to STL. (It's even possible to automate this from the command line.)</p>
| 736
|
<p>Given the case I made <strong>two independent changes</strong> in <em>one</em> file: eg. added a new method and changed another method.</p>
<p>I often don't want to commit both changes as <strong>one</strong> commit, but as <strong>two</strong> independent commits.</p>
<p>On a git repository I would use the <strong>Interactive Mode</strong> of <a href="http://linux.die.net/man/1/git-add" rel="noreferrer">git-add(1)</a> to split the <em>hunk</em> into smaller ones:</p>
<pre><code> git add --patch
</code></pre>
<p>What's the easiest way to do this with Subversion? (Maybe even using an Eclipse plug-in)</p>
<p><strong>Update:</strong><br/>
In <a href="http://tomayko.com/writings/the-thing-about-git" rel="noreferrer">The Thing About Git</a>, Ryan calls it: <em>“The Tangled Working Copy Problem.”</em></p>
|
<p>With git-svn you can make a local GIT repository of the remote SVN repository, work with it using the full GIT feature set (including partial commits) and then push it all back to the SVN repository.</p>
<p><a href="http://schacon.github.com/git/git-svn.html" rel="noreferrer">git-svn (1)</a></p>
|
<p>I think an easier option than generating diff files, reverting, etc, would be to have two copies of the repository checked out, and use a visual diff tool like DeltaWalker to copy hunks from one to the other.</p>
<p>The first copy would be the one you actually work off of, and the second would just be for this purpose. Once you've made a ton of changes to the first, you can copy one section over to the second, commit it, copy another section, commit it, etc.</p>
| 10,148
|
<p>What I am trying to do is so simple but I am having a hard time making it work. I saw some posts along the same lines but I still have questions.</p>
<p>I have a MenuItem object called mnuA. All I want is set the icon property programatically in C#. I have tried the following</p>
<p>a) <code>mnuA.Icon = new BitmapImage{UriSource = new Uri(@"c:\icons\A.png")};</code>
Results: Instead of showing the actual icon, I get the class name (<code>System.Windows.Media.Imaging.BitmapImage</code>)</p>
<p>b) <code>mnuA.Icon = new BitmapImage(new Uri(@"c:\icons\A.png"));</code>
Results: Instead of showing the actual icon, I get the path of the image (<code>file:///c:/icons/A.png</code>)</p>
<p>What am I doing wrong? Do I really need a converter class for something simple like this?</p>
|
<p>Try this:</p>
<pre><code>Image img = new Image();
img.Source = new BitmapImage(new Uri(@"c:\icons\A.png"));
mnuA.Icon = img;
</code></pre>
|
<p>Might be a long shot, but try something like:</p>
<blockquote>
<p>Uri u = new Uri(...); mnuA.Icon = new
BitmapImage(u);</p>
</blockquote>
<p>What it seems its happening is that your icon is getting converted to a string.</p>
| 46,211
|
<p>Is there a way to statically/globally request a copy of the ApplicationContext in a Spring application?</p>
<p>Assuming the main class starts up and initializes the application context, does it need to pass that down through the call stack to any classes that need it, or is there a way for a class to ask for the previously created context? (Which I assume has to be a singleton?)</p>
|
<p>If the object that needs access to the container is a bean in the container, just implement the <a href="http://static.springframework.org/spring/docs/2.5.x/reference/beans.html#beans-factory-aware-beanfactoryaware" rel="noreferrer">BeanFactoryAware</a> or <a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/context/ApplicationContextAware.html" rel="noreferrer">ApplicationContextAware</a> interfaces.</p>
<p>If an object outside the container needs access to the container, I've used a <a href="http://en.wikipedia.org/wiki/Singleton_pattern#Java" rel="noreferrer">standard GoF singleton pattern</a> for the spring container. That way, you only have one singleton in your application, the rest are all singleton beans in the container.</p>
|
<p>I know this question is answered, but I would like to share the Kotlin code I did to retrieve the Spring Context. </p>
<p>I am not a specialist, so I am open to critics, reviews and advices:</p>
<p><a href="https://gist.github.com/edpichler/9e22309a86b97dbd4cb1ffe011aa69dd" rel="nofollow noreferrer">https://gist.github.com/edpichler/9e22309a86b97dbd4cb1ffe011aa69dd</a></p>
<pre><code>package com.company.web.spring
import com.company.jpa.spring.MyBusinessAppConfig
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.ApplicationContext
import org.springframework.context.annotation.AnnotationConfigApplicationContext
import org.springframework.context.annotation.ComponentScan
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.Import
import org.springframework.stereotype.Component
import org.springframework.web.context.ContextLoader
import org.springframework.web.context.WebApplicationContext
import org.springframework.web.context.support.WebApplicationContextUtils
import javax.servlet.http.HttpServlet
@Configuration
@Import(value = [MyBusinessAppConfig::class])
@ComponentScan(basePackageClasses = [SpringUtils::class])
open class WebAppConfig {
}
/**
*
* Singleton object to create (only if necessary), return and reuse a Spring Application Context.
*
* When you instantiates a class by yourself, spring context does not autowire its properties, but you can wire by yourself.
* This class helps to find a context or create a new one, so you can wire properties inside objects that are not
* created by Spring (e.g.: Servlets, usually created by the web server).
*
* Sometimes a SpringContext is created inside jUnit tests, or in the application server, or just manually. Independent
* where it was created, I recommend you to configure your spring configuration to scan this SpringUtils package, so the 'springAppContext'
* property will be used and autowired at the SpringUtils object the start of your spring context, and you will have just one instance of spring context public available.
*
*Ps: Even if your spring configuration doesn't include the SpringUtils @Component, it will works tto, but it will create a second Spring Context o your application.
*/
@Component
object SpringUtils {
var springAppContext: ApplicationContext? = null
@Autowired
set(value) {
field = value
}
/**
* Tries to find and reuse the Application Spring Context. If none found, creates one and save for reuse.
* @return returns a Spring Context.
*/
fun ctx(): ApplicationContext {
if (springAppContext!= null) {
println("achou")
return springAppContext as ApplicationContext;
}
//springcontext not autowired. Trying to find on the thread...
val webContext = ContextLoader.getCurrentWebApplicationContext()
if (webContext != null) {
springAppContext = webContext;
println("achou no servidor")
return springAppContext as WebApplicationContext;
}
println("nao achou, vai criar")
//None spring context found. Start creating a new one...
val applicationContext = AnnotationConfigApplicationContext ( WebAppConfig::class.java )
//saving the context for reusing next time
springAppContext = applicationContext
return applicationContext
}
/**
* @return a Spring context of the WebApplication.
* @param createNewWhenNotFound when true, creates a new Spring Context to return, when no one found in the ServletContext.
* @param httpServlet the @WebServlet.
*/
fun ctx(httpServlet: HttpServlet, createNewWhenNotFound: Boolean): ApplicationContext {
try {
val webContext = WebApplicationContextUtils.findWebApplicationContext(httpServlet.servletContext)
if (webContext != null) {
return webContext
}
if (createNewWhenNotFound) {
//creates a new one
return ctx()
} else {
throw NullPointerException("Cannot found a Spring Application Context.");
}
}catch (er: IllegalStateException){
if (createNewWhenNotFound) {
//creates a new one
return ctx()
}
throw er;
}
}
}
</code></pre>
<p>Now, a spring context is publicly available, being able to call the same method independent of the context (junit tests, beans, manually instantiated classes) like on this Java Servlet:</p>
<pre><code>@WebServlet(name = "MyWebHook", value = "/WebHook")
public class MyWebServlet extends HttpServlet {
private MyBean byBean
= SpringUtils.INSTANCE.ctx(this, true).getBean(MyBean.class);
public MyWebServlet() {
}
}
</code></pre>
| 15,708
|
<p>In the Application_Error method in Global.asax I am trying to retrieve a value from session state.</p>
<p>I am able to access session state as long as I throw the exception. EG: </p>
<pre><code>thow new Exception("Test exception");
</code></pre>
<p>However if it is an unhandled exception, i get the following error when trying to access session state: "Session state is not available in this context.".</p>
<p>Why the differences in behavior, is there a work around? </p>
<p>Thanks.</p>
|
<p>I hate ASP.NET sometimes... </p>
<p>So generating an error using:</p>
<pre><code>Response.Redirect("thispagedoesnotexist.aspx", false);
</code></pre>
<p>The above line will redirect to Application_Error with session state not available</p>
<p>However</p>
<pre><code>throw new Exception("test");
</code></pre>
<p>The above line will redirect to Application_Error with session state AVAILABLE</p>
<p>So instead of doing this all in Application_Error, in one spot, I will have to use try/catches through out my code to catch errors. Then gather data from session, log and email error details, then finally redirect to friendly error page. Lots of extra code..</p>
<p>Conclusion: Application_Error is worthless.</p>
|
<p>I think you are trying to access the session through HttpContext.Current.Session. I believe the difference in behavior is that in the unhanded exception handler, the request has gone into "Failsafe" mode and the page lifecycle (including loading and disposing the session) has finished.</p>
<p>Check out this page on the <a href="http://msdn.microsoft.com/en-us/library/ms178473.aspx" rel="nofollow noreferrer">lifecycle</a> for more info</p>
| 38,461
|
<p>I'm struggling with bed adhesion for nylon on a glass bed (122 °C measured) in an enclosed chamber (45 °C near the front, likely more on top of the print bed). I used a glue stick to enhance adhesion, but after around 20 minutes the print comes off the bed.</p>
<p>I tried a <a href="https://www.123-3d.nl/123inkt-lijmstift-medium-21-grams-i1326-t7445.html" rel="nofollow noreferrer">no-brand glue stick</a> and a <a href="https://www.123-3d.nl/Pritt-stick-medium-22-gram-i1329-t7445.html" rel="nofollow noreferrer">Pritt glue stick</a>.</p>
<p>Now I wonder whether they are suitable for the purpose, because nylon should really be printable in these conditions. Maybe the glue cannot hold those 100+ °C temperatures.</p>
<p>How to find out whether a glue stick is PVA-based and suitable for nylon (or polycarbonate, ABS) printing?</p>
|
<p>Not all glue sticks work! The working ingredient of a glue stick is <a href="http://en.wikipedia.org/wiki/Polyvinylpyrrolidone" rel="nofollow noreferrer">Polyvinylpyrrolidone</a>; a more elaborate answer is found <a href="https://3dprinting.stackexchange.com/a/11183/">here</a> on question: <a href="https://3dprinting.stackexchange.com/questions/11182/why-does-hairspray-work-as-an-adhesive-for-abs/">"Why does hairspray work as an adhesive for ABS?"</a>.</p>
<p>There are very good alternatives to glue sticks and hair spray nowadays. Specific adhesion sprays exist for several years now (e.g. Dimafix, 3DLAC, Magigoo for PA, Plasticz, PrintaFix, Dr.Mat, etc.; my personal experience is with the first 2 mentioned, both work for nylon: Dimafix has more tack at higher temperatures > 80 °C, up to 80 °C 3DLAC works perfect).</p>
<p>E.g. Dimafix has a higher temperature application range than e.g. 3DLAC. From the <a href="http://www.dima3d.com/en/home/dimafix/" rel="nofollow noreferrer">manufacturer</a> can be seen that:</p>
<p><a href="https://i.stack.imgur.com/ZBZny.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZBZny.png" alt="enter image description here" /></a>
<em>Source: <a href="http://www.dima3d.com/en/home/dimafix/" rel="nofollow noreferrer">http://www.dima3d.com/en/home/dimafix/</a></em></p>
<p>This image shows that the spray has its maximum tack/adhesion at about 120 °C and holds this adhesion level at least up to about 145 °C according to the image.</p>
<p>However, not all glues get stronger with temperature! PVA (also called PVAc) glues soften very quickly, making them good only at low temperature. See "<a href="https://bioresources.cnr.ncsu.edu/resources/influence-of-temperature-on-the-strength-of-bonded-joints/" rel="nofollow noreferrer">Influence of temperature on the strength of bonded joints</a>" which discloses this graph for PVAc Rhenocoll 3W, 4B Plus:</p>
<p><a href="https://i.stack.imgur.com/KB1lM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KB1lM.png" alt="enter image description here" /></a></p>
|
<p>Not all glue sticks work! The working ingredient of a glue stick is <a href="http://en.wikipedia.org/wiki/Polyvinylpyrrolidone" rel="nofollow noreferrer">Polyvinylpyrrolidone</a>; a more elaborate answer is found <a href="https://3dprinting.stackexchange.com/a/11183/">here</a> on question: <a href="https://3dprinting.stackexchange.com/questions/11182/why-does-hairspray-work-as-an-adhesive-for-abs/">"Why does hairspray work as an adhesive for ABS?"</a>.</p>
<p>There are very good alternatives to glue sticks and hair spray nowadays. Specific adhesion sprays exist for several years now (e.g. Dimafix, 3DLAC, Magigoo for PA, Plasticz, PrintaFix, Dr.Mat, etc.; my personal experience is with the first 2 mentioned, both work for nylon: Dimafix has more tack at higher temperatures > 80 °C, up to 80 °C 3DLAC works perfect).</p>
<p>E.g. Dimafix has a higher temperature application range than e.g. 3DLAC. From the <a href="http://www.dima3d.com/en/home/dimafix/" rel="nofollow noreferrer">manufacturer</a> can be seen that:</p>
<p><a href="https://i.stack.imgur.com/ZBZny.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZBZny.png" alt="enter image description here" /></a>
<em>Source: <a href="http://www.dima3d.com/en/home/dimafix/" rel="nofollow noreferrer">http://www.dima3d.com/en/home/dimafix/</a></em></p>
<p>This image shows that the spray has its maximum tack/adhesion at about 120 °C and holds this adhesion level at least up to about 145 °C according to the image.</p>
<p>However, not all glues get stronger with temperature! PVA (also called PVAc) glues soften very quickly, making them good only at low temperature. See "<a href="https://bioresources.cnr.ncsu.edu/resources/influence-of-temperature-on-the-strength-of-bonded-joints/" rel="nofollow noreferrer">Influence of temperature on the strength of bonded joints</a>" which discloses this graph for PVAc Rhenocoll 3W, 4B Plus:</p>
<p><a href="https://i.stack.imgur.com/KB1lM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KB1lM.png" alt="enter image description here" /></a></p>
| 1,826
|
<p>I have some shapefile (demographic/heat map data in the USA, such as crime in New York) data imported into a sql server 2008 database, field data type: <em>Geography</em>.</p>
<p>How can i get this data, from a <em>select</em> query, in a format which i can then display on google maps or microsoft virtual earth?</p>
<p>thanks!</p>
<p>Edit 1: So far, the best solution has been to use a (free) 3rd Party dll (<a href="http://www.codeplex.com/SharpMap" rel="nofollow noreferrer">SharpMap</a>). I'm hoping someone might suggest some sql tricks in sql2008 to return it in a compatible format ...</p>
|
<p>Geri Langlois's Sharpmap link is to 0.9 If you want bleeding edge, the repository is here:
<a href="http://sharpmapv2.googlecode.com/svn" rel="nofollow noreferrer">http://sharpmapv2.googlecode.com/svn</a></p>
<p>Also, you have to make sure your data is Lat/Long WGS84 and not something else before you start placing coordinate info into your KML. I don't know of a way to do that in SQLServer2008 (might need to use <a href="http://www.gdal.org" rel="nofollow noreferrer">ogr2ogr</a>).</p>
<p>using STX and STY, you can probably generate some coordinate tags for the KML</p>
<pre><code>select SHAPE.STX as X
,SHAPE.STY as Y
,SHAPE.STAsText() as WKT
,SHAPE.AsGml() as GML
from dpu.SW_SERVICE_LOCATIONS
</code></pre>
<p>maybe something like:</p>
<pre><code>SELECT '<coordinates>'+convert(varchar,convert(decimal(20,6), SHAPE.STX),1)+
','+ convert(varchar,convert(decimal(20,6), SHAPE.STY),1)
+ '</coordinates>'
FROM sw_service_locations;
</code></pre>
|
<p>The easiest way to do this is to select to XML and then transform the data into GeoRSS or KML. Virtual Earth and Google Maps both have support for KML so that would probably be the easiest way to do it.</p>
<p>There are considerations though. If you have many many vertices in your data you probably want to implement some sort of AJAX method to retrieve only the data in the map view. You can generalize data in SQL 2008 to make a fewer amount of vertices depending on your zoom level. If you are zoomed out to a country level you don't need nearly as much detail as zoomed into a town.</p>
<p><a href="http://www.mapdotnet.com/Pages2.0/Index.aspx" rel="nofollow noreferrer">MapDotNet</a> has a lot of features for getting your data in a Virtual Earth map more easily. It is relatively easy to perfrom a select query and display the data as you desire. I'm sure there are other similar products for Google maps but I haven't personally used them. It has support for polygons as well as heat maps and gives you a lot more functionality than just using Virtual Earth. Virtual Earth is powerful but there are a lot of GIS tools someone from a mapping background would expect that you have to program in yoursef.</p>
| 35,808
|
<p>I need to make some commits using Git but I would like the timestamp in git-log to be in the future.</p>
<p>How can I do a commit in git that causes a future timestamp to register in the git-log?</p>
|
<p>You should wait a bit.</p>
<p>Or you can do this:</p>
<pre><code>/tmp/x 604% env GIT_AUTHOR_DATE='Wed Dec 19 15:14:05 2029 -0800' git commit -m 'future!'
[master]: created 6348548: "Future!"
1 files changed, 1 insertions(+), 0 deletions(-)
/tmp/x 605% git log
Author: Dustin Sallings <dustin@spy.net>
Date: Wed Dec 19 15:14:05 2029 -0800
Future!
</code></pre>
<p><strong>Note</strong> that there's both an author date and a committer date, so be sure to set the right one (or both).</p>
|
<p>May I ask why you would want to do this? </p>
<p>If you don't want to change your clock, I would suggest creating a script to do the commit and use the Windows Scheduler (or whatever equivalent for your OS) to run the script at the time you want the commit to be.</p>
| 47,936
|
<p>No doubt I'm missing something really simple here but I just can't see the problem with this query which is producing the following error:</p>
<pre><code>SQL query:
INSERT INTO ads(
ad_id, author, ad_date, category, title,
description, condition, price, fullname,
telephone, email, status, photo, photothumb
)
VALUES (
NULL , 'justal', '1225790938', 'Windsurf Boards',
'test', 'test', 'Excellent', '12', 'test',
'test', 'test', '', '', ''
);
MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check
the manual that corresponds to your MySQL server version
for the right syntax to use near ''ad_id', 'author',
'ad_date', 'category', 'title', 'description',
'condition', '' at line 1
</code></pre>
<p>Can someone with a fresh pair of eyes spot the problem?</p>
<p>Thanks,
Al. </p>
|
<p>Shouldn't you use back ticks instead of single quotes in column names?</p>
<pre><code>INSERT INTO ads( `ad_id`, `author`, `ad_date`, `category`, `title`, `description`, `condition`, `price`, `fullname`, `telephone`, `email`, `status`, `photo`, `photothumb` )
VALUES (
NULL , 'justal', '1225790938', 'Windsurf Boards', 'test', 'test', 'Excellent', '12', 'test', 'test', 'test', '', '', ''
);
</code></pre>
|
<p>Single quotes are used for string literals. In MySQL, by default, double quotes are also used for string literals although this is incompatible with standard SQL and you should stick to single quotes in your code.</p>
<p>For column names, you normally wouldn't quote them at all. If you need to - and you don't for any of yours - then quote them with a backquote (`), or set it to strict ANSI compatible mode (ANSI_QUOTES) and use double quotes.</p>
| 32,676
|
<p>In the iPhone is there a way I can use JavaScript to close the browser and return to the home screen? After the last page a wizard I am calling out to another iPhone app (ex: maps) and I do NOT what the user to come back to the browser screen when they are done. My backup plan is to have a "Complete" page but that is not the best experience for the client.</p>
|
<p>I have confirmed with apple this is not possible in iPhone OS 2.2 and before.</p>
<p>I have tried each of these good suggestions but, they will not close the browser on the iPhone.</p>
|
<p>Knowing Apple, this may not be possible with JavaScript. Have you tried anything yet? If not, try one of these guys out:</p>
<pre><code>javascript:self.close();
window.close();
</code></pre>
<p>EDIT: I found this thru google, this may bypass the confirmation box, but I don't think it works with the modern browsers anymore:</p>
<pre><code>window.opener='x';
window.close();
</code></pre>
<p>I just checked, doesn't look like it will work (IE7 box pops up, FF3 does nothing, Opera 9.61 doesnt have a prompt box at all).</p>
| 32,820
|
<p>I want to be able to capture my iPhone's screen as a video, but I'm not sure the best way to do this.</p>
<p>Can anyone help guide me on how to best do this <em>without jailbreak?</em></p>
|
<p>Here's my solution in a nutshell:</p>
<p>In recent years, when needing to produce moving visual content from the interface of an iOS app, I would require the developer provide a compiling of the app designed for the Simulator, (must be separately compiled because the apps are, by default compiled to run on the iPhone's ARM processor, whereas the Simulator runs on the Mac's Intel processor). This would then be screen captured on the Mac with something like Snapz Pro, Screenflow or something similar.</p>
<p>Beyond that, typical solutions required jailbreaking the device and installing a screen capture application sourced from the Cydia Store.</p>
<p>With the introduction of the iPad 2, Apple enabled full interface mirrored video output via either an authorized dock connector to HDMI dongle, or a dock connector to VGA dongle. (Note: Apple's composite and component options do not port mirrored content.) While the typical intent for these output mechanisms are to display the interface content to an external projector or High Definition Television, it is possible to record this mirrored content with a device capable of recording or transcoding content from such an incoming source. This option was also made possible with the introduction of the iPhone 4S. Quite often, recording this video content is done with HDMI capture cards installed on the capturing computer, such as those produced by Black Magic or AJA, among others. This is, or course limited to using computers that are capable of having such a capture card installed. Other options may include some HDMI record-enabled DVR devices (though many detect and disable such options) or firewire-based transcoding devices (like the Grass Valley ADVC-HD50, which I use).</p>
<p>Since getting the iPad 2 earlier this year, I have been using the Grass Valley ADVC HD50 to capture iOS screen motion from dock connected HDMI to a HDV compatible video capture application on my Mac. It has thus far worked flawlessly.</p>
<p>Here is an example from a video I recorded showing such captured content from both the iPHone 4S and the iPad 2.</p>
<p><a href="http://youtu.be/k7jlPx8NAmw" rel="noreferrer">http://youtu.be/k7jlPx8NAmw</a></p>
<p>However, now that Apple has enabled wireless iOS mirroring via Airplay in iOS 5, I find it is now much more convenient to connect an Apple TV device to the Grass Vally ADVC HD50, and capture the iOS interface screen recording wirelessly.</p>
<p>Here is a recent short video example in which the iPhone 4S interface was captured wirelessly via Airplay mirroring.</p>
<p><a href="http://youtu.be/UKsixjcCXdI" rel="noreferrer">http://youtu.be/UKsixjcCXdI</a></p>
<p>I hope this helps.</p>
|
<p>I dont believe this is possible.
Your best bet is to get something like iShowU and capture from the simulator.</p>
| 24,393
|
<p>Does MS Access 2007 support internal foreign keys within the same table?</p>
|
<p>Yes. Create the table with the hierarchy.</p>
<p>id - autonumber - primary key<br>
parent_id - number<br>
value</p>
<p>Go to the relationships screen. Add the hierarchy table twice. Connect the id and the parent_id fields. Enforce referential integrity.</p>
|
<p>Yes it does.</p>
<p>Under database tools and relationships you need to show 2 copies of the self-referencing table. It will name the second copy Table_1. Then you setup a relationship between the primary key in "table" and the foreign key column(s) in "Table_1".</p>
| 19,751
|
<p>Having a vector containing pointers to objects then using the clear function doesn't call the destructors for the objects in the vector. I made a function to do this manually but I don't know how to make this a generic function for any kind of objects that might be in the vector.</p>
<pre><code>void buttonVectorCleanup(vector<Button *> dVector){
Button* tmpClass;
for(int i = 0; i < (int)dVector.size(); i++){
tmpClass = dVector[i];
delete tmpClass;
}
}
</code></pre>
<p>This is the function I have that works fine for a specific type of object in the vector but I'd like a single function that could take any kind of vector with object pointers.</p>
|
<p>The best thing to do is use smart pointers, such as from <a href="http://www.boost.org/doc/libs/1_36_0/libs/smart_ptr/smart_ptr.htm" rel="nofollow noreferrer">Boost</a>. Then the objects will be deleted automatically.</p>
<p>Or you can make a template function</p>
<pre><code>template <class T>
void vectorCleanup(vector<T *>& dVector){
T* tmpClass;
for(vector<T*>::size_type i = 0; i < dVector.size(); i++){
tmpClass = dVector[i];
delete tmpClass;
}
</code></pre>
<p>}</p>
|
<p>A couple of other points - you probably want to pass a reference to the vector, not a copy. tmpClass is not needed - you can delete the pointer directly. You should either resize the vector to 0 or replace the pointers with NULL after deleting - otherwise you could access unallocated memory in the calling function.</p>
| 30,453
|
<p>Is it possible to obfuscate a .NET web application? I tried to use the Dotofuscator tool that comes with Visual Studio 2005 and I was able to obfuscate the dlls of a precompiled web site, but when I deployed the soultion to an IIS server, I could not the pages of the application.</p>
<p>So the question would be: was any of you able to obfuscate a complete .NET web application?</p>
<p>Thanks for your answers</p>
<p>EDIT: I obfuscated all the dlls on the bin folder. The site is built without allowing updates of the aspx files. After that when I go to <a href="http://serveradress/main.aspx" rel="nofollow noreferrer">http://serveradress/main.aspx</a>, I get an error saying that main.aspx does not exists</p>
<p>PD: I need to obfuscate the code because the application does some license chcecking and I want to make it harder to remove the license checking code</p>
|
<p>Just bear in mind that is you obfuscate an application that uses reflection, it can cause issues.</p>
<p>I personally don't see the need to obfuscate, as <strong>people who <em>really</em> want to see your code, will get their hands on it with effort, regardless if you obfuscate it or not</strong>.</p>
|
<p>Make sure you use the library setting with your obfuscation software. If you don't all your classes and methods will be renamed.</p>
| 46,509
|
<p>I am looking for a drop-down JavaScript menu.</p>
<p>It should be the simplest and most elegant accessible menu that works in IE6 and Firefox 2 also.
It would be fine if it worked on an unnumbered list (<code>ul</code>) so the user can use the page without JavaScript support.</p>
<p>Which one do you recommend and where can I find the code to such a menu?</p>
|
<p>I think the jquery superfish menu is fantastic and easy to use:</p>
<p><a href="http://users.tpg.com.au/j_birch/plugins/superfish/" rel="noreferrer">http://users.tpg.com.au/j_birch/plugins/superfish/</a></p>
<p>Javascript is <strong>not required</strong>, and it is based on simple valid ul unorder lists. </p>
|
<p>I like stickman's <a href="http://www.stickmanlabs.com/accordion/" rel="nofollow noreferrer">accordion</a>, which depending on how you want it to behave can be a nice effect.</p>
| 12,701
|
<p>I would like to know what's the best technique to do single sign-on in web sites. It means that if you enter in more than one website, you will be authenticated in a "transparent" way. I'm using php + curl to set the cookies for the different sites, but i really would like to know if does exist a standard way to do it.</p>
|
<p>For a standard secure way you need :</p>
<ul>
<li>an authentication server</li>
<li>an authentication filter on each site that need SSO</li>
</ul>
<p>The mechanism is a little bit complex, it involves http redirects and secure authentication tickets. You will find detailled explanation on the <a href="http://www.ja-sig.org/products/cas/" rel="noreferrer">CAS website</a> (a popular java SSO server).<br>
I recommend to read this page "<a href="http://www.ja-sig.org/wiki/display/CASC/CAS+Java+Client+Gateway+Example" rel="noreferrer">CAS Java Client Gateway Example</a>", especially the sequence diagram at the bottom of the page.</p>
|
<p>The best way is to use Image tags which pull an image stream from your external sites.</p>
<p>So if you're at www.some-site.com and you want to also be signed into www.some-partner-site.com you have this displayed after logging in:
</p>
<p>Because you're using an Image it forces the browser to "pull in" the contents of that URL.</p>
<p>I've recently built a solution which does it with ASP.NET but we also have a php-based partner site.</p>
<p>What image displayed is irrelivant, really you should not display any image at all (hence the 1x1 size)</p>
| 12,577
|
<p>Can I write a plug in for Microsoft SQL Enterprise Manager which changes the query window background if the query window points to a production database?</p>
|
<p>No, Enterprise Manager doesn't have a plug-in framework for you to hook in to.</p>
|
<p>I see this has already been answered but I'm going to add this in case it helps future readers. The Enterprise Manager has been replaced by SQL Management Studio. Management Studio does have support for add-ins. Also, when you register a server in the properties window you can associate a custom color with the connection. Whenever you open a query window, the status bar along the bottom of the window will be this color. We have an Access database that contains information about the systems we support, including SQL Server and database names. I wrote a SQL Powershell script that registers all of the servers and sets their custom color to Green, Yellow, and Red for Development, Acceptance, and Production. It doesn't change the entire query window color but it might be useful to you.</p>
| 8,951
|
<p>I will elaborate somewhat. Jsf is kind-of extremely painful for working with from designer's perspective, somewhat in the range of trying to draw a picture while having hands tied at your back, but it is good for chewing up forms and listing lots of data. So sites we are making in my company are jsf admin pages and jsp user pages. Problem occurs when user pages have some complicated forms and stuff and jsf starts kickin' in. </p>
<p>Here is the question: I'm on pure jsp page. I need to access some jsf page that uses session bean. How can I initialize that bean? If I was on jsf page, I could have some commandLink which would prepare data. Only thing I can come up with is having dummy jsf page that will do the work and redirect me to needed jsf page, but that's kind of ugly, and I don't want to end up with 50 dummy pages. I would rather find some mechanism to reinitialize bean that is already in session with some wanted parameters.</p>
<p>Edit: some more details. In this specific situation, I have a tests that are either full or filtered. It's a same test with same logic and everything, except if test is filtered, it should eliminate some questions depending on answers. Upon a clicking a link, it should start a requested test in one of the two modes. Links are parts of main menu-tree and are visible on many sibling jsp pages. My task is to have 4 links: testA full, testA filtered, testB full, testB filtered, that all lead on same jsf page and TestFormBean should be reinitialized accordingly.</p>
<p>Edit: I've researched facelets a bit, and while it won't help me now, I'll definitely keep that in mind for next project.</p>
|
<p>have you looked into using facelets? It lets you get rid of the whole JSF / JSP differences (it's an alternate and superior view controller).</p>
<p>It also supports great design-time semantics with the jsfc tag...</p>
<pre><code><input type="text" jsfc="#{SomeBean.property}" class="foo" />
</code></pre>
<p>gets translated internally to the correct JSF stuff, so you can work with your existing tools.</p>
|
<p>Create a custom JSP tag handler. You can then retrieve the bean from session scope and then initialize it on the fly. See this <a href="http://java.sun.com/products/jsp/tutorial/TagLibrariesTOC.html" rel="nofollow noreferrer">tutorial</a> for more details.</p>
| 6,443
|
<p>I guess this is a multi-part question.</p>
<p>I can import a 3D model into my WPF application but how do I apply an ambient occlusion shader effect to it?
I know with .NET 3.5 SP1 you can do custom effects but that's limited to pixel shaders and doesn't include vertex shaders.</p>
<p>I think i can do this with an XNA application but Im not familiar with XNA so the second question is:
How much different is WPF and XNA? I don't seem to have any notion of XAML in XNA. How much ramp up would moving from WPF to XNA take?</p>
<p>Thanks,
Chris</p>
|
<p>To answer your second question:</p>
<p>WPF and XNA are completely different. They do share the following:</p>
<ul>
<li>Built upon .net</li>
<li>Use DirectX</li>
<li>Can access hardware acceleration of the video card</li>
</ul>
<p>XNA does not have any GUI support built in and is really aimed at games (for PC and XBOX-360) whilst WPF is usable in business style applications. As you've discovered XNA does not have any XAML support, indeed it is mainly an abstract .net wrapper for DirectX.</p>
|
<p>To answer your second question:</p>
<p>WPF and XNA are completely different. They do share the following:</p>
<ul>
<li>Built upon .net</li>
<li>Use DirectX</li>
<li>Can access hardware acceleration of the video card</li>
</ul>
<p>XNA does not have any GUI support built in and is really aimed at games (for PC and XBOX-360) whilst WPF is usable in business style applications. As you've discovered XNA does not have any XAML support, indeed it is mainly an abstract .net wrapper for DirectX.</p>
| 32,362
|
<p>I just installed visio, and the installer almost seemed like it was built in flash.
The buttons kinda glowed when I hovered over them, and when I clicked on 'continue' the form phased out in a cool way.</p>
<p>I'm assuming it was built in WPF.</p>
<p>Anyhow, so are WPF more flash-like (visually speaking).
Do they have new properties where you can make forms phase out nicely/smoothly compared to winforms?</p>
|
<p><strong>Disclaimer</strong>: I work for Microsoft. However, I don't work on Visio, WPF, CLR or Silverlight team. So, the following is my personal take on these technologies. If you want to quote me, don't do it implying it's the official Microsoft position. :-))</p>
<p><strong>Update</strong>: Anything I say below about Flash/Flex/AIR might be wrong, as I have not worked with these technologies and what I know about them is based on what I read on the intertubes. :-) If you notice anything wrong, just shout in the comment and I'll correct it.</p>
<p>To the best of my knowledge, the Visio installer is not built with WPF. It's all unmanaged code; it's just people took a lot of care to make it really polished.</p>
<p>WPF is the new UI platform for building standalone applications for the Windows OS. It supports a declarative UI language - XAML, and related CLR types to program against. WPF is a different platform than WinForms, although it is possible to build applications that mix UI built with both. WPF supports a lot of things that WinForms does not, like bitmap effects, animations, control styling and so on and exposes them both in XAML or through code. Also, WPF relies heavily on vector graphics, as opposed to the pixel graphics in WinForms. In short, WPF is quite powerfull and allows building very snazzy UI. (Don't take my word for it, though, as I am biased; go check around for what people are saying about it or buiding with it. :-))</p>
<p>WPF and WinForms do not compete with Flash/Flex. WPF and WinForms are both UI frameworks for building standalone client applications. As far as I know, Flash/Flex are frameworks for building rich internet applications - RIA (though lately people started interpreting this abbreviation as rich interactive applications).</p>
<p>Adobe did come up with AIR about half a year (or maybe a year) ago, which allows building standalone client applications, so you could say that Adobe is trying to position Flash/Flex/AIR to compete with WPF. Of course, that's my take on it and I doubt Adobe's official positiong is anything like that.</p>
<p>If you want to compare particular MS technnologies with Flash/Flex, take a look at Silverlight - it's the MS RIA platform.</p>
<p>Silverlight is related to WPF in the sense that they share XAML and the corresponding CLR types. Silverlight supports only a subset of what WPF offers, though, as it is not targeting Windows OS only and thus is limited by the fact that it has to be portable.</p>
<p><strong>Quick update to reflect the changes in the year since I've written the answer :-)</strong></p>
<p>With Silverlight 3 shipped, SL and WPF are getting even closer and sharing bigger set of supported features. In addition, most of the new XAML controls are built for platform at the same time. Thus, SL/WPF are getting to a point of singularity...</p>
<p>Also, SL 3 supports out-of-browser applications. In that sense, SL is not only starting to compete with Flash/Flex, but it is also encroaching on AIR's turf.</p>
<p>And no, I still don't work on the WPF or Silverlight team. :-)</p>
|
<p>The way I see it: WPF is to Flash as WinForms is to Flex. WPF has more emphasis on vectors and states than on programming.</p>
| 23,459
|
<p>What's the best javascript framework for drawing (lines, curves whatnot) on images?</p>
|
<p>jQuery has several plugins available for doing graphics. Raphael is a plugin that uses SVG (for Firefox and other browsers that support SVG), and VML for the IE products. In addition, jQuery provides a great architecture for javascript projects with plenty of support and plug-ins.</p>
<p>Raphael is available here: <a href="http://raphaeljs.com/index.html" rel="nofollow noreferrer">http://raphaeljs.com/index.html</a></p>
<p>jQuery is available here: <a href="http://jquery.com/" rel="nofollow noreferrer">http://jquery.com/</a></p>
|
<p>You can create "images" using javascript's flot library.</p>
<p>It's on <a href="http://code.google.com/p/flot/" rel="nofollow noreferrer">google code: flot</a><br />
And requires <a href="http://www.jquery.com/" rel="nofollow noreferrer">jQuery</a></p>
<p>Here's an example, how a <a href="http://people.iola.dk/olau/flot/examples/graph-types.html" rel="nofollow noreferrer">graph might look like</a></p>
| 13,443
|
<p>I would like to use open source tools if possible.</p>
<p>here are 2 links I found but haven't tried them - </p>
<ul>
<li><a href="http://pivots.pivotallabs.com/users/chad/blog/articles/471-continuous-integration-in-a-box-exploring-tsttcpw" rel="nofollow noreferrer">http://pivots.pivotallabs.com/users/chad/blog/articles/471-continuous-integration-in-a-box-exploring-tsttcpw</a></li>
<li><a href="http://laurentbois.com/category/continuous-integration/" rel="nofollow noreferrer">http://laurentbois.com/category/continuous-integration/</a></li>
</ul>
|
<p>Try this CruiseControl.rb</p>
<p><a href="http://cruisecontrolrb.thoughtworks.com/" rel="nofollow noreferrer">http://cruisecontrolrb.thoughtworks.com/</a></p>
<p>CruiseControl.rb is written in Ruby and designed for ruby.</p>
<p>Another one is Hudson, it is built in Java, but it has a plugin for ruby</p>
<p><a href="https://hudson.dev.java.net/" rel="nofollow noreferrer">https://hudson.dev.java.net/</a></p>
|
<p>Give Cinabox a try (I'm the author). It is intended to make this as simple as possible, and uses cruisecontrol.rb. There is a screencast and readme. If you have problems, open a ticket using the LightHouse link in the readme.</p>
<p>Good Luck!</p>
| 20,455
|
<p>I try to get rounded corners on a UIImage, what I read so far, the easiest way is to use a mask images. For this I used code from TheElements iPhone Example and some image resize code I found. My problem is that resizedImage is always nil and I don't find the error...</p>
<pre><code>- (UIImage *)imageByScalingProportionallyToSize:(CGSize)targetSize
{
CGSize imageSize = [self size];
float width = imageSize.width;
float height = imageSize.height;
// scaleFactor will be the fraction that we'll
// use to adjust the size. For example, if we shrink
// an image by half, scaleFactor will be 0.5. the
// scaledWidth and scaledHeight will be the original,
// multiplied by the scaleFactor.
//
// IMPORTANT: the "targetHeight" is the size of the space
// we're drawing into. The "scaledHeight" is the height that
// the image actually is drawn at, once we take into
// account the ideal of maintaining proportions
float scaleFactor = 0.0;
float scaledWidth = targetSize.width;
float scaledHeight = targetSize.height;
CGPoint thumbnailPoint = CGPointMake(0,0);
// since not all images are square, we want to scale
// proportionately. To do this, we find the longest
// edge and use that as a guide.
if ( CGSizeEqualToSize(imageSize, targetSize) == NO )
{
// use the longeset edge as a guide. if the
// image is wider than tall, we'll figure out
// the scale factor by dividing it by the
// intended width. Otherwise, we'll use the
// height.
float widthFactor = targetSize.width / width;
float heightFactor = targetSize.height / height;
if ( widthFactor < heightFactor )
scaleFactor = widthFactor;
else
scaleFactor = heightFactor;
// ex: 500 * 0.5 = 250 (newWidth)
scaledWidth = width * scaleFactor;
scaledHeight = height * scaleFactor;
// center the thumbnail in the frame. if
// wider than tall, we need to adjust the
// vertical drawing point (y axis)
if ( widthFactor < heightFactor )
thumbnailPoint.y = (targetSize.height - scaledHeight) * 0.5;
else if ( widthFactor > heightFactor )
thumbnailPoint.x = (targetSize.width - scaledWidth) * 0.5;
}
CGContextRef mainViewContentContext;
CGColorSpaceRef colorSpace;
colorSpace = CGColorSpaceCreateDeviceRGB();
// create a bitmap graphics context the size of the image
mainViewContentContext = CGBitmapContextCreate (NULL, targetSize.width, targetSize.height, 8, 0, colorSpace, kCGImageAlphaPremultipliedLast);
// free the rgb colorspace
CGColorSpaceRelease(colorSpace);
if (mainViewContentContext==NULL)
return NULL;
//CGContextSetFillColorWithColor(mainViewContentContext, [[UIColor whiteColor] CGColor]);
//CGContextFillRect(mainViewContentContext, CGRectMake(0, 0, targetSize.width, targetSize.height));
CGContextDrawImage(mainViewContentContext, CGRectMake(thumbnailPoint.x, thumbnailPoint.y, scaledWidth, scaledHeight), self.CGImage);
// Create CGImageRef of the main view bitmap content, and then
// release that bitmap context
CGImageRef mainViewContentBitmapContext = CGBitmapContextCreateImage(mainViewContentContext);
CGContextRelease(mainViewContentContext);
CGImageRef maskImage = [[UIImage imageNamed:@"Mask.png"] CGImage];
CGImageRef resizedImage = CGImageCreateWithMask(mainViewContentBitmapContext, maskImage);
CGImageRelease(mainViewContentBitmapContext);
// convert the finished resized image to a UIImage
UIImage *theImage = [UIImage imageWithCGImage:resizedImage];
// image is retained by the property setting above, so we can
// release the original
CGImageRelease(resizedImage);
// return the image
return theImage;
}
</code></pre>
|
<p>If you are using a UIImageView to display the image you can simply do the following:</p>
<pre><code>imageView.layer.cornerRadius = 5.0;
imageView.layer.masksToBounds = YES;
</code></pre>
<p>And to add a border:</p>
<pre><code>imageView.layer.borderColor = [UIColor lightGrayColor].CGColor;
imageView.layer.borderWidth = 1.0;
</code></pre>
<p>I believe that you'll have to import <code><QuartzCore/QuartzCore.h></code> and link against it for the above code to work.</p>
|
<p><a href="https://stackoverflow.com/questions/205431/rounded-corners-on-uiimage#205643">See here...</a>
IMO unless you absolutely need to do it in code, just overlay an image on top.</p>
<p>Something along the lines of...</p>
<pre><code>- (void)drawRect:(CGRect)rect
{
// Drawing code
[backgroundImage drawInRect:rect];
[buttonOverlay drawInRect:rect];
}
</code></pre>
| 32,800
|
<p>What is the best practice for storing keys, and or passwords for a website. These keys are for various 3rd party web services. Is it best to have them in the Web.config file, or in the database, or encrypted somehow? </p>
|
<p>Assuming your database isn't accessible from the outside world or that you have it properly locked down that would be the preferred way to store the keys. This allows all of your applications to pull from the same store of keys/passwords making changes very quick and easy.</p>
|
<p>You can store the encrypted values in the .config file, and ASP.NET 2.0 will decrypt them on the fly.</p>
<p>Your configuration would look something like:</p>
<pre><code><configSections>
<section
name="sampleSection"
type="System.Configuration.SingleTagSectionHandler"
/>
</configSections>
<MySecrets
FavoriteMusic="Disco"
FavoriteLanguage="COBOL"
DreamJob="Dancing in the opening ceremonies of the Olympics"
/>
</code></pre>
<p>and then you run the following from a command line, in the same directory as your config file:</p>
<pre><code>aspnet_regiis -pef MySecrets .
</code></pre>
<p>From K. Scott Allen:</p>
<p><a href="http://odetocode.com/Blogs/scott/archive/2006/01/08/2707.aspx" rel="nofollow noreferrer">http://odetocode.com/Blogs/scott/archive/2006/01/08/2707.aspx</a></p>
| 24,228
|
<p>I once read about an open source database for postal codes with geolocation data but now I can't remember its name. Can someone help?</p>
|
<p>My guess is that your lost friend is <a href="http://www.geonames.org/" rel="noreferrer">GeoNames</a>.</p>
|
<p>Yes Geonames is the place. To be more specific as slacy said</p>
<p><a href="https://download.geonames.org/export/zip/" rel="nofollow noreferrer">https://download.geonames.org/export/zip/</a></p>
<p>It has a list of countries' postal codes and it has an allCountries zip file.</p>
<p>And the data is updated daily.</p>
| 39,660
|
<p>I want to be able to generate PDF output from my (native) C++ Windows application. Are there any free/open source libraries available to do this?</p>
<p>I looked at the answers to <a href="https://stackoverflow.com/questions/177/how-do-i-programmatically-create-a-pdf-in-my-net-application">this question</a>, but they mostly relate to .Net.</p>
|
<p><a href="https://github.com/libharu/libharu" rel="noreferrer">LibHaru</a></p>
<blockquote>
<p>Haru is a free, cross platform,
open-sourced software library for
generating PDF written in ANSI-C. It
can work as both a static-library (.a,
.lib) and a shared-library (.so,
.dll).</p>
</blockquote>
<p>Didn't try it myself, but maybe it can help you</p>
|
<p><a href="http://wxcode.sourceforge.net/docs/wxpdfdoc/" rel="nofollow">http://wxcode.sourceforge.net/docs/wxpdfdoc/</a></p>
<p>Works with the wxWidgets library.</p>
| 8,315
|
<p>I work at a company that has some very non-standardized SQL conventions (They were written by Delphi Developers years ago). Where is the best place that I can find SQL industry standard convention definitions that are most commonly used?</p>
|
<p>In his book "<a href="https://rads.stackoverflow.com/amzn/click/com/0120887975" rel="noreferrer" rel="nofollow noreferrer">SQL Programming Style</a>," Joe Celko suggests a number of conventions, for example that a collection (e.g. a table) should be named in the plural, while a scalar data element (e.g. a column) should be named in the singular.</p>
<p>He cites <a href="http://en.wikipedia.org/wiki/ISO/IEC_11179" rel="noreferrer">ISO-11179-4</a> as a standard for metadata naming, which supports this guideline.</p>
|
<p><a href="http://www.ssw.com.au/ssw/standards/Default.aspx" rel="nofollow noreferrer">Here you can find a lot of Rules to better SQL /SQL Server.</a><br>
Yes, it's the company that I am working for, but they are good!
And these rules come from experience with client projects.</p>
<p>Have a look and take what you like!</p>
| 49,669
|
<p>Running VISTA 32bit.</p>
<p>I am trying to install c# Visual Express 2008 - but it requires .NET 3.5. One of the prerequisites during the install is .NET 3.5 ... it attempts to install it but fails, with no real error message.</p>
<p>So I downloaded .NET 3.5 standalone from MS website and tried that.Again it fails with the error </p>
<blockquote>
<p>[10/17/08,23:17:07] WapUI: [2] DepCheck indicates Microsoft .NET Framework 3.0SP1 (CBS) is not installed.
[10/17/08,23:50:55] Microsoft .NET Framework 3.0SP1 (CBS): [2] Error: Installation failed for component Microsoft .NET Framework 3.0SP1 (CBS). MSI returned error code 34</p>
</blockquote>
<p>I currently have c# Express edition 2005 installed. But everything I read says that I can have these two applications installed together. I believe that 2005 runs Framework 2.0. 2005 express edition works fine. - its just the 2008 edition im having problems installed the .NET 3.5 with ....</p>
<p>any ideas ? thanks</p>
|
<p>.NET Framework 3.0 is a component that is released together with Windows Vista. In order to get SP1 of .NET Framework 3.0, you have to install <strong>Windows Vista SP1</strong>. The stand-alone SP1 installer for .NET Framework 3.0 is meant for operating systems that do not have it natively.</p>
|
<p>Have you ever installed any of the pre-release versions of 3.0 or 3.5? I had a lot of trouble installing 3.5 until I realized that I had installed a CTP of WPF. Go through all of your Microsoft and .NET installs in Add/Remove programs and make sure that you don't have any pre-release versions.</p>
| 26,322
|
<p>I know that here at SE I cant ask recommendation of products and so. I have a printer that I wanna buy and I want to know if it's good. Where should I post this question in order to get some smart people to take a look?</p>
|
<p>Great question! 3DPrinting SE attracts a lot of new Stack Exchange network users, which unfortunately can come with questions that don't always meet the Q&A style for the network that this site tries to uphold.</p>
<p>Questions like this are probably best asked in the <a href="http://chat.stackexchange.com/rooms/34216/the-hotbed-3d-printing">Chat</a> room. Currently, it's not very active, but hopefully if we have a few people interested in these more "off-topic" questions the activity will pick up. Pings are going to be a very useful tool if we're going to try and utilize the chat window more. Pinging some of the highly active users may help get quality answers to those off-topic questions.</p>
|
<p>Some of your question could be acceptable. What you want to avoid is "questions which are too broad, unclear, incomplete or primarily opinion-based". That still leaves lots of other acceptable questions to ask like what printers have a specific feature or whether a specific printer has a specific feature. Note the word "specific".</p>
<p>There is also a <a href="https://hardwarerecs.stackexchange.com/">Hardware Recommendations</a> SE Beta that may work for you.</p>
| 39
|
<p>I would like to understand the way git works from a architects point of view. How are files stored, how are versions kept and how do changes happen (branches, merges, etc.)?</p>
<p>I am not searching for information how to use it. (I already found a lot of pages with tutorials.) But I did not find any "behind the scenes" details, that would make me understand.</p>
|
<p><a href="http://eagain.net/articles/git-for-computer-scientists/" rel="noreferrer">http://eagain.net/articles/git-for-computer-scientists/</a></p>
<p><a href="http://www.loria.fr/~molli/pmwiki/uploads/Main/gitmanual.pdf" rel="noreferrer">http://www.loria.fr/~molli/pmwiki/uploads/Main/gitmanual.pdf</a>
Chap 7</p>
<p><a href="http://ftp.newartisans.com/pub/git.from.bottom.up.pdf" rel="noreferrer" title="Git From the Bottom Up">Git From the Bottom Up</a></p>
|
<p><a href="http://en.wikipedia.org/wiki/Git_(software)#Implementation" rel="nofollow noreferrer">Wikipedia</a> might get you started. </p>
<p>I do remember encountering some documents describing some of the internal architecture, so I know that they are out there. I just can't remember where they were...</p>
| 32,712
|
<p>I'm doing a tech review and looking at AMF integration with various backends (Rails, Python, Grails etc).</p>
<p>Lots of options are out there, question is, what do the Adobe products do (BlazeDS etc) that something like RubyAMF / pyAMF don't?</p>
|
<p>Other than NIO (RTMP) channels, LCDS include also the "data management" features. </p>
<p>Using this feature, you basically implement, in an ActionScript class, a CRUD-like interface defined by LCDS, and you get:</p>
<ul>
<li>automatic progressive list loading (large lists/datagrids loads while scrolling)</li>
<li>automatic crud management (you get object locally in flash, modify it, send it back and DB will get updated automatically)</li>
<li>feature for conflict resolution (if multiple user try to updated the same record at the same time)</li>
<li>if I remember well, also some improved integration with the LiveCycle ES workflow engine</li>
</ul>
<p>IMO, it can be very fast to develop this way, but only if you have only basic requirements and a simple architecture (forget SOA, that otherwise works so well with Flex). I'm fine with BlazeDS.</p>
|
<p>Good question. I'm not a ruby guy (i use java with flex), but what I believe differentiates blazeds vs commercial livecycle ds is</p>
<ol>
<li>Streaming protocol support (rtmp) - competition for comet and such, delivering video</li>
<li>Some advanced stuff for hibernate detached objects and large resultset caching that I don't fully understand or need
<ol start="3">
<li>support?
Might be others but those are the ones I know off the top of my head.</li>
</ol></li>
</ol>
| 10,278
|
<p>I've got a really odd error message that only occurs when I add the following line to my project:</p>
<pre><code>std::list<CRect> myVar;
</code></pre>
<p>It's worth noting that it doesn't have to be a std::list, it can be std::vector or any other STL container I assume.</p>
<p>Here is the error message:</p>
<blockquote>
<p>Error 1 error LNK2005: "public:
__thiscall std::list</p>
<blockquote>
<p>::list >(void)"
(??0?$list@VCRect@@V?$allocator@VCRect@@@std@@@std@@QAE@XZ)
already defined in
SomeLowLevelLibrary.lib</p>
</blockquote>
</blockquote>
<p>The low level library that's referenced in the error message has no idea about the project I am building, it only has core low level functionality and doesn't deal with high level MFC GUIs.</p>
<p>I can get the linker error to go away if I change the line of code to:</p>
<pre><code>std::list<CRect*> myVar;
</code></pre>
<p>But I don't want to hack it for the sake of it.</p>
<p>Also, it doesn't matter if I create the variable on the stack or the heap, I still get the same error.</p>
<p>Does anyone have any ideas whatsoever about this?
I'm using Microsoft Visual Studio 2008 SP1 on Vista Enterprise.</p>
<p><strong>Edit:</strong> The linker error above is for the std::list<> constructor, I also get an error for the destructor, _Nextnode and clear functions.</p>
<p><strong>Edit:</strong> In other files in the project, std::vector won't link, in other files it might be std::list. I can't work out why some containers work, and some don't. MFC linkage is static across both libraries. In the low level library we have 1 class that inherits from std::list.</p>
<p><strong>Edit:</strong> The low level library doesn't have any classes that inherit from CRect, but it does make use of STL.</p>
|
<p>You should be looking at the linker settings, but I can't immediately say which. It's normal for STL instantiations to be done in multiple files. The linker should pick one. They're all identical (assuming you <em>do</em> have consistent compiler settings).</p>
|
<p>This doesn't sound like the exact symptom, but to be sure you should check that your main project and all your included libraries use the same "Runtime Library" setting under "C++:Code Generation". Mixing these settings can create runtime library link errors. (What confuses me in your case is that you can make it go away by changing the code, but it's worth checking if you haven't already.)</p>
| 17,854
|
<p>What things have to be done before I can honestly tell myself my web application is accessible by anyone? Or even better, convince Joe Clark. I don't have any video or audio to worry about, so I know I won't need transcripts. What else do I have to check?</p>
|
<p>Your question is very vague, but in short, you need to ensure that your site meets one of the three levels (A, AA, or AAA) of the <a href="http://www.w3.org/TR/WCAG10/" rel="nofollow noreferrer">Web Content Accessibility Guidelines</a>.</p>
<p>FWIW, in my experience, if you are providing anything other than a purely static HTML site, aim for AA. Trying to follow the WCAG guidelines stringently to triple-A standard for a dynamic website is the road to hair loss IMO. This may change with WCAG 2.0.</p>
<p>Good luck!</p>
<p><strong>EDIT:</strong> @Blowdart suggests running your site through online checkers. This is fine so long as you realise that many of the WCAG guidelines (especially towards the higher end) are so arbitrary, they can only be validated with a human eye.</p>
<p>Do not trust the output of these online checkers and blindly stick a AAA badge on your site. If you are called on it, you may be in trouble.</p>
<p>+1 Blowdart for suggesting HTML and CSS validation, and Chris Pederick's add-on is <em>great</em>!</p>
|
<p>Run it through a bunch of checkers. Check the HTML is valid. Try to use it with script disabled. Try to use it with CSS disabled. You can do all of this with the <a href="https://addons.mozilla.org/en-US/firefox/addon/60" rel="nofollow noreferrer">web developer addon</a> for Firefox</p>
| 11,650
|
<p>I have the following C# code:</p>
<pre><code>byte rule = 0;
...
rule = rule | 0x80;
</code></pre>
<p>which produces the error: </p>
<blockquote>
<p><em>Cannot implicitly convert type 'int' to 'byte'. An explicit conversion exists (are you missing a cast?)</em></p>
</blockquote>
<p>[Update: first version of the question was wrong ... I misread the compiler output]</p>
<p>Adding the cast <strong>doesn't</strong> fix the problem:</p>
<pre><code>rule = rule | (byte) 0x80;
</code></pre>
<p>I need to write it as:</p>
<pre><code>rule |= 0x80;
</code></pre>
<p>Which just seems weird. Why is the <code>|=</code> operator any different to the <code>|</code> operator?</p>
<p>Is there any other way of telling the compiler to treat the constant as a byte?</p>
<hr>
<p><strong>@ Giovanni Galbo</strong> : yes and no. The code is dealing with the programming of the flash memory in an external device, and logically represents a single byte of memory. I could cast it later, but this seemed more obvious. I guess my C heritage is showing through too much!</p>
<p><strong>@ Jonathon Holland</strong> : the 'as' syntax looks neater but unfortunately doesn't appear to work ... it produces:</p>
<blockquote>
<p><em>The as operator must be used with a reference type or nullable type ('byte' is a non-nullable value type)</em> </p>
</blockquote>
|
<p>C# does not have a literal suffix for byte. u = uint, l = long, ul = ulong, f = float, m = decimal, but no byte. You have to cast it.</p>
|
<p>Unfortunately, your only recourse is to do it just the way you have. There is no suffix to mark the literal as a byte. The | operator does not provide for implicit conversion as an assignment (i.e. initialization) would.</p>
| 6,468
|
<p>I'm trying to write a 2d array into an output file, it's all working fine except in creating the .getline function to draw the array back out of the file. My issue is putting the string length. My current code for the line is;</p>
<p>inputFile.getline(myArray, [10][10], '\n');</p>
<p>but it doesn't like having the string length in square brackets it seems, what should I do?</p>
<p>thanks in advance</p>
|
<p>For that to compile, <code>myArray</code> must be an array of <code>char</code>, or a <code>char*</code>. In particular, it is a <em>one-dimensional</em> array. To read multiple dimensions, you'll need to read each row separately. The second parameter to <a href="http://en.cppreference.com/w/cpp/io/basic_istream/getline" rel="nofollow noreferrer"><code>std::istream::getline</code></a> is the maximum number of <code>char</code>s to read and store in the array, minus one.</p>
<p>To begin reading something from a file, you should start by knowing how the file was written to in the first place. <em>You</em> know how the file was created, I hope, but you haven't described that in your question. Knowing how the file was written is essential for knowing how to read from it. Show some code, please.</p>
|
<p>With all due respect to <em>Rob Kennedy</em>, he's misrepresenting how C/C++ handle multidimensional arrays.</p>
<p>Consider int foo[10][10] and int foo[100]. In both cases foo is a pointer to a block of memory containing sizeof(int)*100 bytes.</p>
<p>There <strong>are</strong> subtle differences between int *pointer and int foo[10][10]. Especially with respect to sizeof() and certain compiler-specific error checking. But, when desired, we can treat them interchangeably.</p>
<hr>
<p>That said, <em>leachrode</em> can't pass argument 2 of <em>getline()</em> as <em>"[10][10]"</em>. He can pass <em>"10*10*sizeof(foo)"</em>, where foo is <em>myArray</em>'s type. He could also pass <em>sizeof(myArray)</em>, if it's actually declared as an array.</p>
<p>The variable <em>myArray</em> does NOT necessarily need to be of type <em>char</em>. However, none of the bytes in the myArray data block can have the value '\n' if that <em>getline()</em> invocation is going to work.</p>
<p>Personally, I'd go with binary storage. E.g.: (Assuming <em>inputFile</em> is an iostream object.)</p>
<pre><code> inputFile.write( (const char *)myArray, sizeof(myArray) );
inputFile.read( (char *)myArray, sizeof(myArray) );
</code></pre>
<p><strong>*HOWEVER*</strong>, that does assume that you are reading and writing on binary-compatible systems. We are making assumptions about how your compiler stored that array in memory. Different compilers may do things differently. Padding and alignment issues can create cross-platform nightmares.</p>
<p>It would be better, from a portability & future maintenance perspective, to <strong>read/write each array element in/out individually!</strong> Codewise it's not much more complicated. Speed wise, iostreams are buffered and you're bound by disk io anyway...</p>
<p>Reference: <a href="http://www.cplusplus.com/reference/iostream/" rel="nofollow noreferrer">http://www.cplusplus.com/reference/iostream/</a></p>
<p><strong><em>Afterthought:</em></strong> - <strong>IF</strong> myArray in not an elementary type (int[], double[]), but instead represents an array of objects (with virtual members) or pointers, you'll need a means of serializing. Pointers won't point to valid memory when they are read back in.</p>
| 46,613
|
<p>I have a need to evaluate user-defined logical expressions of arbitrary complexity on some PHP pages. Assuming that form fields are the primary variables, it would need to:</p>
<ul>
<li>substitute"varibles" for form
fields values;</li>
<li>handle comparison operators,
minimally ==, <, <=, >= and > by
symbol, name (eg eq, lt, le, ge, gt
respectively);</li>
<li>handle boolean operators not, and, or and
possibly xor by name, symbol (eg !,
&&, || and ^^ respectively);</li>
<li>handle literal values for strings
and numbers;</li>
<li>be plaintext not XML (eg "firstname
== '' or lastname == ''); and</li>
<li>be reasonably performant.</li>
</ul>
<p>Now in years gone by I've written recursive descent parsers that could build an expression tree and do this kind of thing but thats not a task I'm relishing in PHP so I'm hoping there are things out there that will at least get me some of the way there.</p>
<p>Suggestions?</p>
|
<p>Much time has gone by since this question was asked, and I happened to be looking for an expression parser for php. I chose to use the <a href="http://symfony.com/blog/new-in-symfony-2-4-the-expressionlanguage-component" rel="noreferrer">ExpressionLanguage</a> component from Symfony 2.4. It can be installed with no dependencies from composer via <a href="https://packagist.org/packages/symfony/expression-language" rel="noreferrer">packagist</a>.</p>
<p><code>composer require symfony/expression-language</code></p>
|
<p>Take a look at <a href="http://www.guge.net/?p=3#more-3" rel="nofollow noreferrer">my infix to postfix example</a> I think you could port it to PHP with relative ease. It only uses an array and some switches. No trees. A stack is only needed to run the postfix result.</p>
| 42,375
|
<p>I'm writing an implementation of a virtual machine in C#, and I need to implement the VM's stack, which can contain two types of entry - return entries or backtrack entries. What is the best way of implementing this?</p>
<p>I'm currently using a base type, as follows:</p>
<pre><code>class StackEntry { }
class Return : StackEntry { uint pc; }
class Backtrack : StackEntry { uint pc; object backtrack; }
Stack<StackEntry> stack;
</code></pre>
<p>This works OK, but the resulting type testing and downcasting feels clumsy.</p>
<p>Is there a better way of handling this type of construction?</p>
|
<p>I'm having a hard time imagining how you're going to use this, but the basic answer is that you use a single type with a default operation for post-pop processing</p>
<pre><code>StackEntry { protected virtual void PostPop(); }
Return : StackEntry { protected override void PostPop(); }
Backtrack : StackEntry { protected override void PostPop(); }
</code></pre>
<p>Does that make sense?</p>
|
<p>It depends on the level of abstraction that you expect. The base class method is quite nice. Only when benchmarks reveal that too much performance is lost this way, I would try to drill deeper, perhaps using a custom-tailored structure with explicit memory layout that acts similar to a C <code>union</code>.</p>
<p>How does your code affect usability in a negative way?</p>
| 33,005
|
<p>I have recently been web-researching quantum computing. </p>
<p>Will we see these in our lifetimes (ever?) (The error correction issue, for example, seems intractable to me).</p>
|
<p>Just looking at the results from one website, I'd say it's not that impossible:</p>
<p><a href="http://arstechnica.com/journals/science.ars/2008/03/28/encoding-more-than-one-bit-in-a-photon" rel="nofollow noreferrer">http://arstechnica.com/journals/science.ars/2008/03/28/encoding-more-than-one-bit-in-a-photon</a><br>
<a href="http://arstechnica.com/journals/science.ars/2008/10/28/scalable-quantum-computing-in-the-next-5-years" rel="nofollow noreferrer">http://arstechnica.com/journals/science.ars/2008/10/28/scalable-quantum-computing-in-the-next-5-years</a><br>
<a href="http://arstechnica.com/news.ars/post/20080729-finding-lost-qubits.html" rel="nofollow noreferrer">http://arstechnica.com/news.ars/post/20080729-finding-lost-qubits.html</a><br>
<a href="http://arstechnica.com/news.ars/post/20080509-new-quantum-dot-logic-gates-a-step-towards-quantum-computers.html" rel="nofollow noreferrer">http://arstechnica.com/news.ars/post/20080509-new-quantum-dot-logic-gates-a-step-towards-quantum-computers.html</a><br>
<a href="http://arstechnica.com/news.ars/post/20080626-three-dimensional-qubits-on-the-way.html" rel="nofollow noreferrer">http://arstechnica.com/news.ars/post/20080626-three-dimensional-qubits-on-the-way.html</a><br>
<a href="http://arstechnica.com/news.ars/post/20080527-molecular-magnets-in-soap-bubbles-could-lead-to-quantum-ram.html" rel="nofollow noreferrer">http://arstechnica.com/news.ars/post/20080527-molecular-magnets-in-soap-bubbles-could-lead-to-quantum-ram.html</a> </p>
<p>For a more technical overview of why it's not as hard as it used to be, there's a four-part series on self-correcting quantum computers:<br>
<a href="http://scienceblogs.com/pontiff/2008/08/selfcorrecting_quantum_compute.php" rel="nofollow noreferrer">http://scienceblogs.com/pontiff/2008/08/selfcorrecting_quantum_compute.php</a></p>
|
<p>Quantum computing is a tool; it's just a tool too raw to have any sort of useful application as of this moment, but who knows.</p>
| 39,416
|
<p>I'm using the WorldPay payment gateway on a website I'm working on. It handles all the credit card authorisation, and then calls a PHP file on my server with information about the transaction. It grabs the output from my script and displays it in the WorldPay chrome.</p>
<p>I don't know the inner workings, but I imagine that they'd be using something similar to cURL to post the transaction details to my script and to then retrieve the output.</p>
<p>My script writes the necessary information into an XML file, sends an email and then thanks the customer for shopping with us.</p>
<p>My problem is that when I test my file by calling it directly (by turning off the security checks and visiting <code>http://example.com/mysite/myscript.php</code> in my browser), everything works as planned, however when I go through the payment system (so I assumed my script is being called via cURL), it fails on this line:</p>
<pre><code>$xml = simplexml_load_file('./info.xml');
</code></pre>
<p>Any ideas??</p>
<p><em>Clarification: that line returns <strong>false</strong>, which breaks the following lines.</em></p>
|
<p>This might be a stretch, but check one of php's number one confusions with relative path resolution. </p>
<pre><code>'./'
</code></pre>
<p>is relative to wherever Entrypoint is, not the script, which is why I use </p>
<pre><code>dirname(__FILE__).'/'
</code></pre>
<p>everywhere instead. </p>
|
<p>Are you sure the path to <code>info.xml</code> is correct? That gets me sometimes when I am including a file from a subdirectory.</p>
| 39,136
|
<p>I seem to remember reading something about how it is bad for structs to implement interfaces in CLR via C#, but I can't seem to find anything about it. Is it bad? Are there unintended consequences of doing so?</p>
<pre><code>public interface Foo { Bar GetBar(); }
public struct Fubar : Foo { public Bar GetBar() { return new Bar(); } }
</code></pre>
|
<p>Since no one else explicitly provided this answer I will add the following:</p>
<p><strong>Implementing</strong> an interface on a struct has no negative consequences whatsoever.</p>
<p>Any <em>variable</em> of the interface type used to hold a struct will result in a boxed value of that struct being used. If the struct is immutable (a good thing) then this is at worst a performance issue unless you are:</p>
<ul>
<li>using the resulting object for locking purposes (an immensely bad idea any way)</li>
<li>using reference equality semantics and expecting it to work for two boxed values from the same struct.</li>
</ul>
<p>Both of these would be unlikely, instead you are likely to be doing one of the following:</p>
<h3>Generics</h3>
<p>Perhaps many reasonable reasons for structs implementing interfaces is so that they can be used within a <strong>generic</strong> context with <em><a href="http://msdn.microsoft.com/en-us/library/d5x73970.aspx" rel="noreferrer">constraints</a></em>. When used in this fashion the variable like so:</p>
<pre><code>class Foo<T> : IEquatable<Foo<T>> where T : IEquatable<T>
{
private readonly T a;
public bool Equals(Foo<T> other)
{
return this.a.Equals(other.a);
}
}
</code></pre>
<ol>
<li>Enable the use of the struct as a type parameter
<ul>
<li>so long as no other constraint like <code>new()</code> or <code>class</code> is used.</li>
</ul></li>
<li>Allow the avoidance of boxing on structs used in this way.</li>
</ol>
<p>Then this.a is NOT an interface reference thus it does not cause a box of whatever is placed into it. Further when the c# compiler compiles the generic classes and needs to insert invocations of the instance methods defined on instances of the Type parameter T it can use the <a href="http://msdn.microsoft.com/en-us/library/system.reflection.emit.opcodes.constrained.aspx" rel="noreferrer">constrained</a> opcode:</p>
<blockquote>
<p>If thisType is a value type and thisType implements method then ptr is passed unmodified as the 'this' pointer to a call method instruction, for the implementation of method by thisType.</p>
</blockquote>
<p>This avoids the boxing and since the value type is implementing the interface is <em>must</em> implement the method, thus no boxing will occur. In the above example the <code>Equals()</code> invocation is done with no box on this.a<sup>1</sup>.</p>
<h3>Low friction APIs</h3>
<p>Most structs should have primitive-like semantics where bitwise identical values are considered equal<sup>2</sup>. The runtime will supply such behaviour in the implicit <code>Equals()</code> but this can be slow. Also this implicit equality is <em>not</em> exposed as an implementation of <code>IEquatable<T></code> and thus prevents structs being used easily as keys for Dictionaries unless they explicitly implement it themselves. It is therefore common for many public struct types to declare that they implement <code>IEquatable<T></code> (where <code>T</code> is them self) to make this easier and better performing as well as consistent with the behaviour of many existing value types within the CLR BCL.</p>
<p>All the primitives in the BCL implement at a minimum: </p>
<ul>
<li><code>IComparable</code></li>
<li><code>IConvertible</code></li>
<li><code>IComparable<T></code></li>
<li><code>IEquatable<T></code> (And thus <code>IEquatable</code>)</li>
</ul>
<p>Many also implement <code>IFormattable</code>, further many of the System defined value types like DateTime, TimeSpan and Guid implement many or all of these as well. If you are implementing a similarly 'widely useful' type like a complex number struct or some fixed width textual values then implementing many of these common interfaces (correctly) will make your struct more useful and usable.</p>
<h2>Exclusions</h2>
<p>Obviously if the interface strongly implies <em>mutability</em> (such as <code>ICollection</code>) then implementing it is a bad idea as it would mean tat you either made the struct mutable (leading to the sorts of errors described already where the modifications occur on the boxed value rather than the original) or you confuse users by ignoring the implications of the methods like <code>Add()</code> or throwing exceptions.</p>
<p>Many interfaces do NOT imply mutability (such as <code>IFormattable</code>) and serve as the idiomatic way to expose certain functionality in a consistent fashion. Often the user of the struct will not care about any boxing overhead for such behaviour.</p>
<h2>Summary</h2>
<p>When done sensibly, on immutable value types, implementation of useful interfaces is a good idea</p>
<hr>
<h3>Notes:</h3>
<p>1: Note that the compiler may use this when invoking virtual methods on variables which are <em>known</em> to be of a specific struct type but in which it is required to invoke a virtual method. For example:</p>
<pre><code>List<int> l = new List<int>();
foreach(var x in l)
;//no-op
</code></pre>
<p>The enumerator returned by the List is a struct, an optimization to avoid an allocation when enumerating the list (With some interesting <a href="http://www.eggheadcafe.com/software/aspnet/31702392/c-compiler-challenge--s.aspx" rel="noreferrer">consequences</a>). However the semantics of foreach specify that if the enumerator implements <code>IDisposable</code> then <code>Dispose()</code> will be called once the iteration is completed. Obviously having this occur through a boxed call would eliminate any benefit of the enumerator being a struct (in fact it would be worse). Worse, if dispose call modifies the state of the enumerator in some way then this would happen on the boxed instance and many subtle bugs might be introduced in complex cases. Therefore the IL emitted in this sort of situation is:</p>
<pre>
IL_0001: newobj System.Collections.Generic.List..ctor
IL_0006: stloc.0
IL_0007: nop
IL_0008: ldloc.0
IL_0009: callvirt System.Collections.Generic.List.GetEnumerator
IL_000E: stloc.2
IL_000F: br.s IL_0019
IL_0011: ldloca.s 02
IL_0013: call System.Collections.Generic.List.get_Current
IL_0018: stloc.1
IL_0019: ldloca.s 02
IL_001B: call System.Collections.Generic.List.MoveNext
IL_0020: stloc.3
IL_0021: ldloc.3
IL_0022: brtrue.s IL_0011
IL_0024: leave.s IL_0035
IL_0026: ldloca.s 02
IL_0028: constrained. System.Collections.Generic.List.Enumerator
IL_002E: callvirt System.IDisposable.Dispose
IL_0033: nop
IL_0034: endfinally
</pre>
<p>Thus the implementation of IDisposable does not cause any performance issues and the (regrettable) mutable aspect of the enumerator is preserved should the Dispose method actually do anything! </p>
<p>2: double and float are exceptions to this rule where NaN values are not considered equal.</p>
|
<p>Structs are just like classes that live in the stack. I see no reason why they should be "unsafe".</p>
| 8,906
|
<p>For what I can read, it is used to dispatch a new thread in a swing app to perform some "background" work, but what's the benefit from using this rather than a "normal" thread?</p>
<p>Is not the same using a new Thread and when it finish invoke some GUI method using SwingUtilities.invokeLater?... </p>
<p>What am I missing here?</p>
<p><a href="http://en.wikipedia.org/wiki/SwingWorker" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/SwingWorker</a></p>
<p><a href="http://java.sun.com/products/jfc/tsc/articles/threads/threads2.html" rel="nofollow noreferrer">http://java.sun.com/products/jfc/tsc/articles/threads/threads2.html</a></p>
|
<p>Yes, you can accomplish what a SwingWorker does with vanilla threads + invokeLater. SwingWorker provides a predictable, integrated way to accomplish tasks on a background thread and report result on the EDT. SwingWorker additionally adds support for intermediate results. Again, you can do all of this yourself but sometimes it's easy to use the integrated and predictable solution especially when it comes to concurrency. </p>
|
<p><code>SwingWorker</code> makes trivial example code much more concise. However it creates a ball of mud. Communications to and from the GUI and executed logic are all welded together. So, I'd not like to see it used in real production code.</p>
| 35,675
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.