instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>ColdFusion 8 Standard Edition on OS X Leopard.</p>
<p>Developing a new website.</p>
<p>What is the best database to use in conjunction with ColdFusion?</p>
<p>Will be storing simple Credit Card operations, registration information, CRM info for an indie software company</p>
| <p>I would look into MySQL and/or PostgreSQL. </p>
<p>I'm more familiar with MySQL. I rather like it a lot. It is solid, with good administration tools. I've used it on OSX servers (years ago) with PHP, and it delivered performance that was more than adequate for our small operation. Definitely worth looking in t... | <p>If you go with MySQL, check out <strong>MAMP</strong> for your development environment. It will install Apache, MySQL and PHP on your machine. Then you can easily add Coldfusion on top if it. I did that on my Macbook and it works like a charm. I would guess that you could link in PostgreSQL to work as well. </p>... | 26,826 |
<p>I've worked on several PHP projects and always I have problems with organizing my work. Where do you develop your application - on localhost, remote server or maybe production one(!) ?
When I work on my localhost after making some major path I send new files by ftp - but sometimes it happens to forget about one fil... | <p>This is how we manage our commercial site:</p>
<ol>
<li>Develop in a local sand box</li>
<li>Check-in to SVN</li>
<li>Automated build/test from SVN onto internal
dev server</li>
<li>Scripted deploy using rsync to staging
server for QA/UAT</li>
<li>Scripted deploy onto production
servers.</li>
</ol>
<p>Staging and ... | <p>I'm developing on a development machine which has an identical enviroment like the production one - that prevents some different behaviour because of different versions or configs. after finishing i just move all the files on to the production server.</p>
<p><a href="http://www.winmerge.org/" rel="nofollow noreferr... | 31,931 |
<p>I want to generate some formatted output of data retrieved from an MS-Access database and stored in a <em>DataTable</em> object/variable, myDataTable. However, some of the fields in myDataTable cotain <em>dbNull</em> data. So, the following VB.net code snippet will give errors if the value of any of the fields <em>l... | <p>The only way that i know of is to test for it, you can do a combined if though to make it easy.</p>
<pre><code>If NOT IsDbNull(myItem("sID")) AndAlso myItem("sID") = sId Then
'Do success
ELSE
'Failure
End If
</code></pre>
<p>I wrote in VB as that is what it looks like you need, even though you mixed language... | <p><strong>Hello Friends</strong></p>
<p><strong>This is the shortest method to check db Null in DataGrid and convert to string</strong></p>
<ol>
<li>create the cell validating event and write this code</li>
<li>If Convert.ToString(dgv.CurrentCell.Value) = "" Then</li>
<li>CurrentCell.Value = ""</li>
<li>End If </li>... | 27,501 |
<p>is there a way to abort threads created with QueueUserWorkItem?</p>
<p>Or maybe I don't need to? What happens if the main application exits? Are all thread created from it aborted automatically?</p>
| <p>You don't need to abort them. When your application exits, .NET will kill any threads with IsBackground = true. The .NET threadpool has all its threads set to IsBackground = true, so you don't have to worry about it.</p>
<p>Now if you're creating threads by newing up the Thread class, then you'll either need to abo... | <p>yeah, they are background, but f.ex if you have application where you use ThreadPool for some kinda multiple downloading or stuff, and you want to stop them, how do you stop ? my suggestion would be:
exit thread asap, f.ex </p>
<pre><code>bool stop = false;
void doDownloadWork(object s)
{
if (!stop)
{
... | 4,641 |
<p>Does anybody have an implementation of <a href="http://en.wikipedia.org/wiki/Cuckoo_hashing" rel="noreferrer">Cuckoo hashing</a> in C? If there was an Open Source, non GPL version it would be perfect!</p>
<p>Since Adam mentioned it in his comment, anyone knows why it is not much used? Is it just a matter of impleme... | <p><a href="http://www.mpi-inf.mpg.de/~sanders/programs/cuckoo/" rel="noreferrer">http://www.mpi-inf.mpg.de/~sanders/programs/cuckoo/</a></p>
<p>HTH</p>
| <p>The IO language has one, in PHash.c. You can find the <a href="http://github.com/stevedekorte/io" rel="nofollow noreferrer">code for IO</a> on Github. IO is BSD licensed.</p>
| 28,652 |
<p>How would one go about adding a submenu item to the windows explorer context menu (like for example 7-Zip does) for a Java application?</p>
| <p>I am aware of two ways to do it. The fancy way is to write a windows shell extension, which is how powerarchiver, winzip etc do it I believe (this involves running code to determine what the context menu items will be dependent on the file chosen).</p>
<p>The simple way, for simple functionality, is you can add an ... | <p>You could also package the java program in an installer like NSIS and you could use NSIS script to generate explorer context menu</p>
| 48,345 |
<p>I need to do a lot of searches of certain patterns in source files while the user is changing them, so I need to do regexp matching that is efficient in time and memory. The pattern repeats itself so should be compiled once, but I need to be able to retrieve subparts (rather than just confirm a match)</p>
<p>I'm co... | <p>I am not sure there is a huge performance gap in term of the different regexp java engines.</p>
<p>But there sure is a performance issue when constructing a regexp (and that is, if the data is large enough, as <a href="http://blog.codinghorror.com/regex-performance/" rel="nofollow noreferrer">noted by Jeff Atwood</... | <p>As VonC says, you need to know your regexps. It doesn't hurt to compile the Regexes beforehand OTHERWISE, the cost of compiling regex each time can hurt the performance badly.</p>
<p>For some categories, there are alternate libraries : <a href="http://jint.sourceforge.net/jint.html" rel="nofollow noreferrer">http:/... | 23,079 |
<p>Is there a way to monitor processes starting in the system before they start?</p>
<p>Example:<br>
On programs like ZoneAlarm or Antivirus programs, when you run a program it asks you if you allow running this program or not before it runs...<br></p>
| <p>You should check out the <a href="http://code.google.com/p/easyhook-continuing-detours/" rel="noreferrer">easyhook-continuing-detours</a> project, which is a .NET port of the <a href="http://research.microsoft.com/sn/detours/" rel="noreferrer">Microsoft Detours</a> project. It will allow you to hook unmanaged APIs (... | <p>You can find out when processes start via using a real-time ETW consumer - however, to be able to take some action that could possibly <em>cancel</em> the process from starting, you'll have to do something shady / undocumented, like hooking CreateProcess, or using a kernel filter driver to block reads to the EXE.</p... | 37,477 |
<p>I need to write a web application using SQL Server 2005, asp.net, and ado.net. Much of the user data stored in this application must be encrypted (read HIPAA).</p>
<p>In the past for projects that required encryption, I encrypted/decrypted in the application code. However, this was generally for encrypting passwo... | <p>1) Look into using TRY..CATCH in SQL 2005. Unfortunately there is no FINALLY, so you'll have to handle both the success and error cases individually.</p>
<p>2) Not necessary if (1) handles the cleanup.</p>
<p>3) There isn't really a difference between client and server transactions with SQL Server. Connection.Be... | <ol>
<li><p>you can use @@error to see if any errors occured during the call to a sproc in SQL.</p></li>
<li><p>No to complicated.</p></li>
<li><p>You can but I prefer to use transactions in SQL Server itself.</p></li>
</ol>
| 8,468 |
<p>I have a strongly-typed MVC View Control which is responsible for the UI where users can create and edit Client items. I'd like them to be able to define the <code>ClientId</code> on creation, but not edit, and this to be reflected in the UI.</p>
<p>To this end, I have the following line:</p>
<pre><code><%= Ht... | <p>Tough problem... However, if you want to define only the <code>readonly</code> attribute, you can do it like this:</p>
<pre><code><%= Html.TextBox("Client.ClientId", ViewData.Model.ClientId,
ViewData.Model.ClientId != null && ViewData.Model.ClientId.Length > 0
? new { @readonly = "readonly" }... | <p>I tried most of the suggestions above and now I have arrived at the simplest with a single line. Combine 2 anonymous html attributes object by declaring wither one of it as "object" type.</p>
<pre><code>@Html.TextBoxFor(m => m.Email, !isEdit ? new { id = "email_box" } : new { id = "email_box", @readonly = isEdit... | 21,405 |
<pre><code> String fullName = PATH + "." + name;
Class cl= Class.forName(fullName);
if(name.equalsIgnoreCase("MobileSearch")){
if(msearchType==null){
msearchType=(SearchInterface)cl.newInstance();
}
return msearchType;
}
if(name... | <p>Use a Map:</p>
<pre><code>if (!searchInstances.containsKey(name))
{
searchInstances.put(
name,
(SearchInterface)Class.forName(PATH + "." + name).newInstance()
);
}
return searchInstances.get(name);
</code></pre>
| <p>Are you just returning an instance of a SearchInterface? If so why not:</p>
<pre><code>String fullName = PATH + "." + name;
Class cl= Class.forName(fullName);
if(searchType==null){
searchType=(SearchInterface)cl.newInstance();
}
return se... | 46,393 |
<p>Does anyone know what is wrong with this query?</p>
<pre><code> SELECT DISTINCT c.CN as ClaimNumber,
a.ItemDate as BillReceivedDate, c.DTN as
DocTrackNumber
FROM ItemData a,
ItemDataPage b,
KeyGroupData c
WHERE a.ItemTypeNum in (112, 113, 116, 172, 189)
AND a.... | <p>You will need to modify the query as such:</p>
<pre><code>SELECT DISTINCT c.CN as ClaimNumber,
a.ItemDate as BillReceivedDate, c.DTN as
DocTrackNumber, a.DateStored
FROM ItemData a,
ItemDataPage b,
KeyGroupData c
WHERE a.ItemTypeNum in (112, 113, 116, 172, 189)
... | <p>Nevermind, executing in SQL Plus gave me a more informative answer. The DateStored needs to be in the select statement so this works:</p>
<pre><code> SELECT DISTINCT c.CN as ClaimNumber,
a.ItemDate as BillReceivedDate,
c.DTN as DocTrackNumber,
a.DateStored
FROM ItemData a,
ItemDataP... | 30,168 |
<p>Management is thinking of changing out Content Management Systems. What do you use/recommend?</p>
<ol>
<li>What UCM solution is your company using?</li>
<li>How big is your company?</li>
<li>Are you happy with the implementation?</li>
</ol>
<p>Current setup:</p>
<ol>
<li>The company I work for uses <code>Oracle E... | <p>1) CMS: <a href="http://www.bea.com/framework.jsp?CNT=index.htm&FP=/content/products/aqualogic/" rel="nofollow noreferrer">Oracle's BEA Aqualogic</a><br>
2) Size: 10,000+<br>
3) Experience: As an end user with full community and content admin privileges, I find the tool to be outdated and stifling in terms of kn... | <ol>
<li><p>We use the Alterian Content Manager application. It is very robust and suites our needs well.</p></li>
<li><p>20000 staff+</p></li>
<li><p>Very happy. Developers and business team find the application very easy to work with.</p></li>
</ol>
| 3,990 |
<p>I'm writing an HTML form generation library. There's a top-level Form class, and at the bottom there are classes for each type of HTML form input object (Select, Textfield, Radio, etc.). There's a class in between, that holds groupings of 1 or more semantically related input objects.</p>
<p>For example, one type of... | <p>Component, as in the "Login Component" or the "Multivalued Response Component".</p>
<p>FYI. I find <a href="http://thesaurus.reference.com" rel="nofollow noreferrer">http://thesaurus.reference.com</a> very helpful for problems like this.</p>
| <p>Component, as in the "Login Component" or the "Multivalued Response Component".</p>
<p>FYI. I find <a href="http://thesaurus.reference.com" rel="nofollow noreferrer">http://thesaurus.reference.com</a> very helpful for problems like this.</p>
| 41,774 |
<p>There are lot of advices on the web how to paint the 3D printed objects, but generally they are advices for manual painting and this required special skills, especially if the object is small. My guess is that maybe 3D printer can lay the color layers as well? I am especially interested in the layering of enamel pai... | <p>So, there's not really anything like a 3D painting machine/robot like I think you're looking for, but there are printers that do fine detail with actual paint, usually oils, but not on 3D materials.</p>
<p>I found a <a href="https://studioartist.ning.com/forum/topics/paint-printers-do-they-exist" rel="nofollow noref... | <h2>Painting Prints</h2>
<p>Yes, you can paint your models with <a href="https://en.wikipedia.org/wiki/Enamel_paint" rel="nofollow noreferrer">enamel paints</a>. Actually, most paints will work. You might need to roughen the surface with sandpaper a tiny bit. Note that some spray paints might contain solvents that migh... | 1,779 |
<p>Our security manager dynamically inserts a bit of javascript at the top of every html page when a page is requested by the client. It is inserted above the DOCTYPE statement. I think this might be the cause of the layout problems I am having.</p>
<p>Ideas anyone?</p>
| <p>Yes, the DOCTYPE must come first.</p>
<p>The definition is here: <a href="http://www.w3.org/TR/REC-html40/struct/global.html" rel="noreferrer">http://www.w3.org/TR/REC-html40/struct/global.html</a>. Note that it says a document consists of three parts, and the DTD must be first.</p>
| <p>It’s not a tag, but yup. Mainly because that’s the only way to get Internet Explorer (pre-version 8, I think) into standards mode.</p>
| 9,520 |
<p>I'm struggling with my new printer, and I just want to make sure that I have the basic configured correctly. </p>
<p>What motherboard ID in <a href="https://github.com/MarlinFirmware/Marlin/blob/1.1.x/Marlin/Configuration.h" rel="nofollow noreferrer"><code>configuration.h</code></a> is appropriate for MKS BASE V1.5... | <p>Marlin appears to support older versions of the board (and possibly this one) according to this line </p>
<pre><code>#define BOARD_MKS_13 47 // MKS v1.3 or 1.4 (maybe higher)
</code></pre>
<p>in <code>boards.h</code> which can be found <a href="https://github.com/MarlinFirmware/Marlin/blob/RC/Marlin/b... | <p>A more recent version of Marlin Firmware (<em>version 1.1.9 is the last release of this branch, new developments are done in the 2.x branch</em>) nowadays has a separate board constant for the MKS BASE v1.5 board (<code>BOARD_MKS_BASE_15</code>) as can be found in <a href="https://github.com/MarlinFirmware/Marlin/bl... | 583 |
<p>In some languages you can override the "new" keyword to control how types are instantiated. You can't do this directly in .NET. However, I was wondering if there is a way to, say, handle a "Type not found" exception and manually resolve a type before whoever "new"ed up that type blows up?</p>
<p>I'm using a seria... | <p>You can attach an event handler to AppDomain.CurrentDomain.AssemblyResolve to take part in the process.</p>
<p>Your EventHandler should return the assembly that is responsible for the type passed in the ResolveEventArgs.</p>
<p>You can read more about it at <a href="http://msdn.microsoft.com/en-us/library/system.a... | <p>You should check out Reflection and the Activator class. They will allow you to create objects from strings. Granted, the object has to be in one of the assemblies that you have access to.</p>
| 10,246 |
<p>I talked to a friend of mine and he told me that it's possible to create an image in an image editor (gimp/photoshop) and then use it as a button . He said that's the way applications that have great GUIs do it. </p>
<p>He also said that there is a file describing which parts of the image make up the button.</p>
<... | <p>This needs to be clarified with a language of choice, etc. In general, most languages (WinForms, Java AWT/SWT, etc) have an image or background image property that allows you to use images for buttons. There are even skinning frameworks that will let you use images for all controls in an easy-to-define manner.</p>... | <p>Imagemaps I guess.
No seperate file describes the map, it is all part of the html document.</p>
<p><a href="http://www.w3schools.com/TAGS/tag_map.asp" rel="nofollow noreferrer">http://www.w3schools.com/TAGS/tag_map.asp</a></p>
| 9,940 |
<p>So, I've been tasked with making a kiosk for the office for showing statistics about our SCRUM progress, build server status, rentability and so forth. It should ideally run a slideshow with bunch of different pages, some of them showing text, some showing graphs and so on. </p>
<p>What is the best approach for thi... | <p>I would recommend creating it as a series of web-pages, which uses Javascript or the meta refresh tag to cycle though the different pages. Simply full-screen the browser on a spare machine, and connect it to a projector/monitor/big TV.</p>
<p>This has lots of benefits:</p>
<ul>
<li>it's <em>trivial</em> to display... | <p>Thanks. I found jqS5 which did most of what you mentioned.</p>
<p>It requires 1 document where every h2 becomes a new slide.
I can then use the meta-refresh to reload to next page every 10 seconds. When I reach the end of the slides, I pull data from an aggregated RSS feed from all the different systems in order to... | 36,647 |
<p>I have a Windows application written in C++ that occasionally evaporates. I use the word evaporate because there is nothing left behind: no "we're sorry" message from Windows, no crash dump from the Dr. Watson facility...</p>
<p>On the one occasion the crash occurred under the debugger, the debugger did not break-... | <p>You could try using the adplus utility in the <a href="http://www.microsoft.com/whdc/devtools/debugging/default.mspx" rel="noreferrer">windows debugging tool package</a>.</p>
<pre><code>adplus -crash -p yourprocessid
</code></pre>
<p>The auto dump tool provides mini dumps for exceptions and a full dump if the appl... | <p>Have you tried PC Lint etc and run it over your code?
Try compiling with maximum warnings
If this is a .NET app - use FX Cop.</p>
| 49,558 |
<p>Trying to make a <a href="http://en.wikipedia.org/wiki/Web_service" rel="noreferrer">web service</a> call to an <a href="http://en.wikipedia.org/wiki/HTTP_Secure" rel="noreferrer">HTTPS</a> endpoint in my <a href="http://en.wikipedia.org/wiki/Microsoft_Silverlight" rel="noreferrer">Silverlight</a> application result... | <p>You might be able to achieve this in Silverlight by <strong>allowing cross-domain communication</strong> between the web server the hosts the Silverlight application and the remote WCF service.</p>
<p>In that case you need to place a <a href="http://www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html" r... | <p>This does not look like an certificate validation error. It looks like a webservice configuration error. Can you post the config for your endpoint on the server?</p>
<p>WCF services don't support SSL by default, you need to enable transport security by creating a binding configuration and pointing your endpoint ... | 43,921 |
<p>Long story short, I have a substantial Python application that, among other things, does outcalls to "losetup", "mount", etc. on Linux. Essentially consuming system resources that must be released when complete.</p>
<p>If my application crashes, I want to ensure these system resources are properly released.</p>
<... | <p>I like top-level exception handlers in general (regardless of language). They're a great place to cleanup resources that may not be immediately related to resources consumed inside the method that throws the exception.</p>
<p>It's also a fantastic place to <strong>log</strong> those exceptions if you have such a fr... | <p>That seems like a reasonable approach, and more straightforward and reliable than a destructor on a singleton class. You might also look at the "<a href="http://docs.python.org/lib/module-atexit.html" rel="nofollow noreferrer">atexit</a>" module. (Pronounced "at exit", not "a tex it" or something like that. I con... | 12,119 |
<p>What is the added value for learning F# when you are already familiar with LISP?</p>
| <ul>
<li><a href="http://research.microsoft.com/fsharp/manual/quicktour.aspx#QuickTourTypes" rel="noreferrer">Static typing</a> (with type inference)</li>
<li><a href="http://research.microsoft.com/fsharp/manual/quicktour.aspx#QuickTourDiscriminatedUnions" rel="noreferrer">Algebraic data types</a></li>
<li><a href="htt... | <p>I know this thread is old but since I stumbled on this one I just wanted to comment on my reasons. I am learning F# simply for professional opportunities since .NET carries a lot of weight in a category of companies that dominate my field. The functional paradigm has been growing in use among more quantitatively a... | 15,424 |
<p>Can <code>Thread.getContextClassLoader()</code> be null ? The javadoc is not really clear.<br>
Should a library take this case into account ?</p>
<p>Update: the reason I asked is that <code>beansbinding.dev.java.net</code> does <em>not</em> work in this case (and my code does <code>setContextClassLoader(null)</code... | <p>Java threads created from JNI code in a non-java thread have null ContextClassloader unless the creator explicitly sets it. </p>
<p>Also in such context Thread.currentThread() returns null.</p>
| <p>Yes you should, someone could have called <code>Thread.setContextClassLoader(null)</code> and your library IMO should be able to deal with that.</p>
| 27,884 |
<p>I need to get all dlls in my application root directory. What is the best way to do that?</p>
<pre><code>string root = Application.StartupPath;
</code></pre>
<p>Or,</p>
<pre><code>string root = new FileInfo(Assembly.GetExecutingAssembly().Location).FullName;
</code></pre>
<p>And after that,</p>
<pre><code>Direc... | <p><code>AppDomain.CurrentDomain.BaseDirectory</code> is my go to way of doing so.</p>
<p>However:</p>
<p><code>Application.StartupPath</code> gets the directory of your executable</p>
<p><code>AppDomain.BaseDirectory</code> gets the directory used to resolve assemblies</p>
<p>Since they can be different, perhaps y... | <p>I use</p>
<p><code>Path.GetDirectoryName(new Uri(Assembly.GetEntryAssembly().CodeBase).LocalPath)
</code></p>
<p>The Assembly.Location will point to the shadow copy if you use shadow copying, so using CodeBase is a better option, but CodeBase is a Url.</p>
| 47,354 |
<p>I have a project right now where I'd like to be able to pull rows out of an Access database that a 3rd party product uses to store its information. There will likely be a small number of users hitting this database at the same time my "export" process does, so I'm a little concerned about data integrity and concurr... | <p>There should no problem. Problems can occur only on concurrent write operations. The locking from MS Access based on file locks in the ldb file. The locks occur only on pages and not on the completely file. Because the locks are in the ldb file and not in the mdb file that there are no problems with parallel reading... | <p>When you open the database, do not attempt to open in read-only mode (although you might think it makes sense). When you are the first user in, Access opens the mdb file in read-only mode and does not create an ldb, forcing all subsequent users to be in read-only mode as well.</p>
| 16,374 |
<p>While running through the cheat sheet "create a navigation rule" for the <a href="http://www.linuxtopia.org/online_books/eclipse_documentation/eclipse_javaserver_faces_tooling_user_guide/topic/org.eclipse.jst.jsf.doc.user/html/gettingstarted/wpe/eclipse_jsf_user_wpe_getting_started.html" rel="nofollow noreferrer">Ec... | <p>It turns out, in <a href="http://en.wikipedia.org/wiki/Eclipse_%28software%29#Releases" rel="nofollow noreferrer">Ganymede</a> at least, on the right-hand border of the JavaServer Faces configuration editor tab there is a subtle left arrow head. clicking that shows palette.</p>
| <p>Just incase anyone is struggling now to find it I have added a screenshot showing exactly where it is:</p>
<p><a href="http://i.stack.imgur.com/o63WS.png" rel="nofollow">palette image</a></p>
| 23,732 |
<p>The hover "joke" in #505 <a href="http://en.wikipedia.org/wiki/Xkcd" rel="noreferrer">xkcd</a> touts "I call rule 34 on Wolfram's Rule 34".</p>
<p>I know <a href="http://www.urbandictionary.com/define.php?term=Rule%2034" rel="noreferrer">what rule 34 is in Internet terms</a> and I've googled up <a href="http://en.w... | <p>Wolfram has organized the 256 possible 1-D cellular automata based on nearest neighbors in this way:</p>
<pre><code>RULES:
0: 0 0 0
1: 0 0 1
2: 0 1 0
3: 0 1 1
4: 1 0 0
5: 1 0 1
6: 1 ... | <p>Rule 34</p>
<p><a href="http://xkcd.com/305/" rel="nofollow noreferrer">http://xkcd.com/305/</a></p>
| 38,821 |
<p>I have an aspx page with a gridview. In my page load event, I load a datatable with all the data like so:</p>
<pre><code>HistoricalPricing historicalPricing = new HistoricalPricing();
DataTable dtHistoricalPricing = new DataTable();
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPo... | <p>Every time you do a postback you're dealing with a new instance of your page class. That means a new datatable object as well.</p>
<p>If you <em>really</em> want to persist it between postbacks (and make sure you consider the memory implications for that when you may have 1000 people hitting this web server at the... | <p>I think I figured it out, is it because when I click on the ListBox, it does a postback and I am only loading the data on the first load of the Page? If this is correct, I think I answered my own question.</p>
<p>I put the datatable in Session after loading it on the first Page Load and this seemed to solve my pro... | 49,249 |
<p>I have a xsl file that is grabbing variables from xml and they seem to not be able to see each other. I know it is a scope issue, I just do not know what I am doing wrong.</p>
<pre><code><xsl:template match="one">
<xsl:variable name="varOne" select="@count" />
</xsl:template>
<xsl:template ma... | <p>Remembering that xsl variables are immutable...</p>
<pre><code><!-- You may want to use absolute path -->
<xsl:variable name="varOne" select="one/@count" />
<xsl:template match="one">
<!-- // do something -->
</xsl:template>
<xsl:template match="two">
<xsl:if test="$varOne... | <p>I'm fairly certain that variables are scoped and therefore you can't declare a variable in one and then use it in the other. You're going to have to move your variable declaration out of the template so that it's in a higher scope than both of them.</p>
| 17,076 |
<p>I have the following shell script registered in my "Login Items" preferences but it does not seem to have any effect. It is meant to launch the moinmoin wiki but only works when it is run by hand from a terminal window, after which it runs until the machine is next shut down.</p>
<pre><code>#!/bin/bash
cd /Users/st... | <p>launchd is one of the best parts of MacOS X, and it causes me great pain to not be able to find it on other systems.</p>
<p>Edit and place this in <code>/Library/LaunchDaemons</code> as <code>com.you.wiki.plist</code></p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple C... | <p>I don't know much about it, since I don't use login items. Just a suggestion, maybe try with applescript that calls those shell commands, and put that in Login Items.</p>
| 43,578 |
<p>I'd like to know what stored procedures are currently running to diagnose some performance problems. How can I find that out?</p>
| <p>Very useful script for analyzing locks and deadlocks: <a href="http://www.sommarskog.se/sqlutil/aba_lockinfo.html" rel="nofollow noreferrer">http://www.sommarskog.se/sqlutil/aba_lockinfo.html</a></p>
<p>It shows procedure or trigger and current statement.</p>
| <p>Using Enterprise Manager, you can open the Management tree section, and choose Current Activity -> Process Info. Double clicking on a Process ID will show you what that process is running. If it's a stored procedure, it will not show you the parameters. For that it would be better to use Brian Kim's suggestion of... | 15,698 |
<p>I have a site that creates images for some bit of content after the content is created. I'm trying to figure out what to do in between the time the content is created and the image is created. My thought is that I might be able to set a custom image to display on a 404 error on the original image. However, I'm no... | <p>Another alternative on the client side is to do:</p>
<pre><code><img src="/images/generated_image_xyz.png"
onerror="this.src='/images/default_image.png'; this.title='Loading...';" />
</code></pre>
| <p>As I understand your problem: You want to show an intermediate image until the <em>real</em> image has been generated?</p>
<p>You could display a <em>loading image</em> and use AJAX to change that DOM node into the <em>real</em> image when it's been created. You could write it from scratch or use any of the well kn... | 31,391 |
<p>I'm trying to convert some code that uses datasets to LINQ. Some of the code passes column names into other functions as strings.</p>
<p>Is there anyway I can easily rewrite this into LINQ?</p>
<pre><code>string s = getElement(tr, elementName);
private string getElement (tableRow re, string elementName){
if(tr[... | <ol>
<li><p><strong>Simple way</strong> </p>
<p>1.1. <strong>Using IEnumerable</strong> (Linq to Objects or similar)
Change the elementName parameter for a Func and pass lambdas instead (you will get compile time checking as well!)</p>
<p>1.2. <strong>Using IQueryable</strong> (Linq to SQL or similar)
Same, but ... | <p>Why would you convert working and clear code into something using LINQ?</p>
<p>Edit: LINQ is nice, cool stuff. But don't make the same errors as many XML fans did (specially first-adapters), by applying it to everything.</p>
| 39,293 |
<p>What is the best way to sanitize user input for a Python-based web application? Is there a single function to remove HTML characters and any other necessary characters combinations to prevent an <a href="http://en.wikipedia.org/wiki/Cross-site_scripting" rel="noreferrer">XSS</a> or SQL injection attack?</p>
| <p>Here is a snippet that will remove all tags not on the white list, and all tag attributes not on the attribues whitelist (so you can't use <code>onclick</code>).</p>
<p>It is a modified version of <a href="http://www.djangosnippets.org/snippets/205/" rel="noreferrer">http://www.djangosnippets.org/snippets/205/</a>,... | <p>If you are using a framework like <a href="http://www.djangoproject.com/" rel="nofollow noreferrer">django</a>, the framework can easily do this for you using standard filters. In fact, I'm pretty sure django automatically does it unless you tell it not to.</p>
<p>Otherwise, I would recommend using some sort of re... | 3,756 |
<p>I've had a FTP server (Mac OS X, but not the server version) set up for a while where the users are virtual, i.e. they are not actual user accounts in the server's OS, but accounts handled by the FTP server software -- to the OS they all look like the <code>ftp</code> user account. I'd like to retire the FTP server ... | <p>The usual generic Unix answer to this is 'PAM'. If you want plain old OpenSSH SSHD to handle your SFTP, you need something plugged in to SSHD's PAM stack (/etc/pam.d/sshd) that does what you need and leaves out what you don't need. This might be a general-purpose directory server (probably LDAP) that maps all your v... | <p>If you're open to commercial products, VShell Server from Van Dyke Software is available on Unix/Linux/Windows, supports virtual users (multiple backends) with SSH and SFTP protocols:</p>
<p><a href="http://www.vandyke.com/products/vshell/index.html" rel="nofollow">VShell Server</a></p>
| 6,023 |
<p>Can anyone advise on how to crop an image, let's say jpeg, without using any .NET framework constructs, just raw bytes? Since this is the only* way in Silverlight...</p>
<p>Or point to a library?</p>
<p>I'm not concerned with rendering i'm wanting to manipulate a jpg before uploading.</p>
<p>*There are no GDI+(S... | <p><a href="http://www.imagemagick.org/script/index.php" rel="nofollow noreferrer">ImageMagick</a> does a pretty good job. If you're ok with handing off editing tasks to your server...</p>
<p>(Seriously? The recommended way of manipulating images in Silverlight is to work with <em>raw bytes</em>? That's... incredibly ... | <p>where is silverlight executed?
Is there any reason at all to send an complete picture to the client to make the client crop it?
Do it on the server... (if you are not creating an image editor that is..)</p>
| 5,769 |
<p>How to create new PCL file similar to existing MS doc. I have MS doc template and replacing it with actual data. I need to achieve same for PCL format (Create PCL file as template and replacing it with actual value from database and send it to fax).</p>
| <ol>
<li>install a new printer</li>
<li>when asked for a port, create a new port of type "Local Port"</li>
<li>as name of the port, enter some file name, e.g. <code>c:\temp\print.pcl</code></li>
<li>select some PCL-compatible printer, e.g. HP LaserJet 4, or whatever your fax is comptaible with</li>
</ol>
<p>When you p... | <p>I found the simple solution and it works. convert the .doc file tamplete to PCL using tool (available on net). open it in edit plus and study... i relize i can modify it according to my need. if u check it u wil see each charector is with its position Example:
<em>p0Y</em>p796Y*p1582Xn -- means charector n at positi... | 11,576 |
<p>I have an iPhone app that hides the status bar. However, my main view doesn't get any touch events when I tap in the status bar area. Is there something I can do to fix this?</p>
<p>Here are a few details of my app's setup (in case it matters):</p>
<ul>
<li>It's an OpenGL-based application.</li>
<li>The app laun... | <p>Found my own answer (of sorts):</p>
<p>This behavior only happens in the iPhone Simulator. When I run the application on an actual iPhone, it works fine.</p>
<p>I'd still be interested to know if there is a way to make it work on the simulator.</p>
| <p>I haven't had this problem, but then again, I'm not using OpenGL views. When you launch in Landscape mode, are you setting the StatusBarHidden property of the appropriate ViewController?</p>
| 17,608 |
<p>I'm working on a college assignment where I must verify if a certain clause (as a fact or as a rule) exists in the current clause database.</p>
<p>The idea is to use a rule whose head is verify(+name, +arguments). This rule should be true if in the database exists another rule whose head is name(arguments)</p>
<p... | <p>Using <code>call/1</code> is not a good idea because <code>call/1</code> actually calls the goal, but you just want to find out if the fact/rule <em>exists</em>, and you don't want to wait after a long calculation that the call might trigger, and you don't want to have something printed on the screen if the called r... | <p>Are you familiar with the concept of unification? What you have to do is: just call a predicate that looks like the one you're trying to find.</p>
<p>So, say in your database is:</p>
<pre><code>father(abraham,isaac).
</code></pre>
<p>Now you want to call something like:</p>
<pre><code>verify(father,[abraham,isaa... | 41,677 |
<p>Is there any way to make sure that a table and cells it contains have a border only when the cells are not empty?
If all the cells of the table are empty, then no border should be visible.</p>
| <p>See the <a href="http://www.w3.org/TR/CSS2/tables.html#empty-cells" rel="nofollow noreferrer">empty-cells</a> CSS property.</p>
| <p>Give the empty cells one class name and the non-empty ones another. One class specifies a border, the other without.</p>
| 41,650 |
<p>Many examples of macros seem to be about hiding lambdas, e.g. with-open-file in CL. I'm looking for some more exotic uses of macros, particularly in PLT Scheme. I'd like to get a feel for when to consider using a macro vs. using functions.</p>
| <p>I only use Scheme macros (<code>define-syntax</code>) for tiny things like better lambda syntax:</p>
<pre><code>(define-syntax [: x]
(syntax-case x ()
([src-: e es ...]
(syntax-case (datum->syntax-object #'src-: '_) ()
(_ #'(lambda (_) (e es ...)))))))
</code></pre>
<p>Which lets you write</p>... | <p>I use them when procedures do not suffice. </p>
| 30,474 |
<p>I am printing Benchies at high speed, I successfully printed one at 300 mm/s. If I set the speed to 400 mm/s, the Y axis begins shifting around. This is usually accompanied by a banging sound.</p>
<p>In addition, the extruder motor occasionally clicks. When it clicks, the filament shoots back out a little bit.</p>
<... | <p>TL;DR: Don't do that.</p>
<p>Detailed answer: You need motion limit parameters that actually make physical sense, and firmware capable of executing a motion plan according to them. Your jerk and acceleration settings absolutely don't. Marlin's whole implementation of jerk is wacky (note: modern Marlin versions don't... | <p>Ok, so you are having multiple problems, lets break it down:</p>
<p>At the speed you are pushing, it would not be weird to have the Y belt slipping around. Also inertia comes into play, so please, dont do that.</p>
<p>What you are mentioning about the filament going out a bit, also makes sense. You are exceeding the... | 2,028 |
<p>I'm trying to get a PHP site working in IIS on Windows Server with MySQL.</p>
<p>I'm getting this error…</p>
<p>Fatal error: Call to undefined function mysql_connect() in C:\inetpub...\adodb\drivers\adodb-mysql.inc.php on line 363</p>
<hr />
<p>Update…</p>
<p>This link outlines the steps I followed to install PHP on... | <p>Check out phpinfo to see if the mysql functions are compiled with your PHP</p>
<pre><code><?php
phpinfo();
?>
</code></pre>
<p>Since in some versions of php, its not default with the install.</p>
<p><b>Edit for the Update:</b></p>
<p>You should have a full MySQL category in your phpinfo();</p>
<p>See ... | <p>It sounds like the version of PHP you are using has not been compiled with MySQL support, or has not been enabled in the php.ini.</p>
| 18,780 |
<p>I have some decimal data that I am pushing into a SharePoint list where it is to be viewed. I'd like to restrict the number of significant figures displayed in the result data based on my knowledge of the specific calculation. Sometimes it'll be 3, so 12345 will become 12300 and 0.012345 will become 0.0123. Occas... | <p>See: <a href="https://stackoverflow.com/questions/374316/round-a-double-to-x-significant-figures-after-decimal-point/374470#374470">RoundToSignificantFigures</a> by "P Daddy".<br>
I've combined his method with another one I liked. </p>
<p>Rounding to significant figures is a lot easier in TSQL where the rounding ... | <p>As I remember it "significant figures" means the number of digits after the dot separator so 3 significant digits for 0.012345 would be 0.012 and not 0.0123, but that really doesnt matter for the solution.
I also understand that you want to "nullify" the last digits to a certain degree if the number is > 1. You wri... | 19,122 |
<p>I have an application where I have a <code>main.m</code> that returns <code>NSApplicationMain(argc, (const char **) argv);</code>.</p>
<p>I want to run code on <code>-applicationDidFinishLaunching:</code>, but I just dont see how to do it. </p>
<p>Can anyone help or have an example? </p>
<p>Thanks!
-Jason</p>
| <p>The applicationDidFinishLaunching: method of the NSApplication delegate will be called when the app has finished loading. Many of the project templates setup a delegate. If you are using one just add the appropriate method to it.</p>
<p>If your project does not have an app delegate set up you will need to do that y... | <p>Louis' answer is concise and spot-on. However, if the concept of delegate methods is new to you, you'd do well to check out the <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CommunicatingWithObjects/chapter_6_section_4.html" rel="nofollow noreferrer" title="Cocoa Fundamentals ... | 30,442 |
<p>Is it possible to use 2 CSS classes that have the same name for the selectors, etc. in the same HTML file? If so, how do you differentiate between the two when styling elements?</p>
| <p>Yes this is possible, simply include two css files in the HEAD section of the document. Any styles set in the first will be overwritten in the second, so say you have this:<br>
First file:</p>
<pre class="lang-css prettyprint-override"><code> #something{
background-color: #F00;
color: #FFF;
}
</code></pre>
<p... | <p>do you mean 2 definitions for the same class? or 2 class names on an element?</p>
<p>The first case, no.</p>
<pre><code><style>
.foo{
border:1px solid blue;
color:red;
}
.foo{
border:4px solid orange;
}
</style>
<div class="foo">this will have an orange border and red text (no... | 48,711 |
<p>Any free alternative to Robohelp? Prefer open source</p>
<p>Need some sort of online help authoring tool for an open source project.</p>
| <p>Check out this <a href="http://www.thefreecountry.com/programming/helpauthoring.shtml" rel="nofollow noreferrer">list of free help authoring tools</a>, bound to be something useful there.</p>
| <p>If you are trying to build .chm based help, try <a href="http://sourceforge.net/projects/chm-build/" rel="nofollow noreferrer"><strong>chm-build</strong></a></p>
| 11,665 |
<p>How can I show a web page in a transparent window and have the white part of the web page also transparent.</p>
| <p>The solution is as follows.</p>
<p>Use Python module <a href="https://docs.python.org/3/library/zipfile.html" rel="noreferrer">zipfile</a> to create zip archive, but as the file specify <a href="https://docs.python.org/3/library/io.html#io.StringIO" rel="noreferrer">StringIO</a> object (ZipFile constructor requires... | <p>Can't you just write a link to a "zip server" or whatnot? Why does the zip archive itself need to be served from Django? A 90's era CGI script to generate a zip and spit it to stdout is really all that's required here, at least as far as I can see.</p>
| 9,300 |
<p>Is there a way to track which window currently has keyboard focus. I could handle WM_SETFOCUS for every window but I'm wondering if there's an alternative, simpler method (i.e. a single message handler somewhere).</p>
<p>I could use OnIdle() in MFC and call GetFocus() but that seems a little hacky.</p>
| <p>So from the way you worded the question I'm inferring that you want to have an event handler which is invoked whenever focus switches between windows. You want to be notified, rather than having to poll.</p>
<p>I actually don't think calling GetFocus from OnIdle is that much of a hack - sure it's polling, but it's ... | <p>You could monitor messages for the <a href="http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputmessages/wm_activate.asp?frame=true" rel="nofollow noreferrer">WM_ACTIVATE</a> event.</p>
<p><a href="http://blogs.msdn.com/jfoscoding/arch... | 6,595 |
<p>I'm trying to do some async stuff in a webservice method. Let say I have the following API call: <a href="http://www.example.com/api.asmx" rel="nofollow noreferrer">http://www.example.com/api.asmx</a></p>
<p>and the method is called <em>GetProducts()</em>.</p>
<p>I this GetProducts methods, I do some stuff (eg. ge... | <p><code>BackgroundWorker</code> is useful when you need to synchronize back to (for example) a UI* thread, eg for affinity reasons. In this case, it would seem that simply using <code>ThreadPool</code> would be more than adequate (and much simpler). If you have high volumes, then a producer/consumer queue may allow be... | <p>It may torn down because after 20 seconds, that BackgroundWorker instance may be garbage collected because it has no references (gone out of scope).</p>
| 28,312 |
<p>I'm currently planning the migration of a Microsoft Content Management Server (MCMS) website to a SharePoint 2007 publishing site.</p>
<p>The top-level site is a public facing, anonymously-accessible website. It will contain two areas which need to be protected with forms-based authentication - each of which will h... | <p>Don't do MCMS so cannot answer specific to that, see <a href="http://www.andrewconnell.com/blog/" rel="nofollow noreferrer">http://www.andrewconnell.com/blog/</a> for alot of info.</p>
<p>Microsoft has a bunch of different designs for extranets, <a href="http://technet.microsoft.com/en-us/library/cc263513.aspx" rel... | <p>Don't do MCMS so cannot answer specific to that, see <a href="http://www.andrewconnell.com/blog/" rel="nofollow noreferrer">http://www.andrewconnell.com/blog/</a> for alot of info.</p>
<p>Microsoft has a bunch of different designs for extranets, <a href="http://technet.microsoft.com/en-us/library/cc263513.aspx" rel... | 34,930 |
<p>I'm supporting/enhancing a web application written in Classic ASP/VBScript. It has been about 10 years since I have used either in a day to day capacity. I just ran across an issue that I would consider a "gotcha" and was wondering if others had similar things that I should learn to be aware of.</p>
<p>My issue:<... | <p><strong>Repeat after me:</strong> All good VB programmers use <code>Option Explicit</code></p>
<p>It will keep you from accidentally declaring a new variable and using it - thus throwing off whatever you are doing.</p>
<p>Beyond that, it depends on what you're doing.</p>
| <p>Automatic variable allocation is probably one of the biggest gotchas.</p>
<pre><code>Dim varA, varB
varA = varA + varV
</code></pre>
<p>Oops! What's <code>varV</code> you ask? Well.. I just mistyped B for V and everything still works perfectly.. that must be a good thing!</p>
<p>Except why isn't varB gets added ... | 36,552 |
<p>Modern ATL/MFC applications now have access to a new shared pointer class called CAutoPtr, and associated containers (CAutoPtrArray, CAutoPtrList, etc.).</p>
<p>Does the CAutoPtr class implement reference counting?</p>
| <p>Having checked the CAutoPtr source, no, reference counting is not supported. Using boost::shared_ptr instead if this ability is required.</p>
| <p>The documentation for <a href="http://msdn.microsoft.com/en-us/library/txda4x5t(VS.80).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/txda4x5t(VS.80).aspx</a></p>
<p>From reading this it looks like it tries to provides the same functionality as std::auto_ptr <b>i.e.</b> It uses ownership se... | 16,887 |
<p>I have two elements:</p>
<pre><code><input a>
<input b onclick="...">
</code></pre>
<p>When b is clicked, I want to access a and manipulate some of its data. A does not have a globally unique name, so <code>document.getElementsByName</code> is out. Looking into the event object, I thought <code>event.t... | <p>If <code>a</code> and <code>b</code> are next to each other and have the same parent, you can use the <code>prevSibling</code> property of <code>b</code> to find <code>a</code>.</p>
| <p>Leave your plain vanilla JavaScript behind. Get JQuery--it will save you a ton of time.</p>
<p><a href="http://docs.jquery.com/Selectors" rel="nofollow noreferrer">http://docs.jquery.com/Selectors</a></p>
| 7,668 |
<p>Does someone have any tips/advice on database design for a web application? The kind of stuff that can save me a lot of time/effort in the future when/if the application I'm working on takes off and starts having a lot of usage.</p>
<p>To be a bit more specific, the application is a strategy game (browser based, ju... | <p>You have probably touched on a much larger issue of designing for high scalability and performance in general.</p>
<p>Essentially, for your database design I would follow good practices such as adding foreign keys and indexes to data you expect to be used frequently, normalise your data by splitting it into smaller... | <p>Why don't you post the schema you have now? It's too broad a question to answer usefully without some detail of what platform and database you're going to use and the table structure you're proposing...</p>
| 6,975 |
<p>I have problems with how to design some classes. I have three classes. One superclass, and two subclasses. </p>
<p>One subclass (AnimatedCharacter) is made by flash, and is used to display the object on screen. The other (CharacterPhysics) is made by myself to extend the superclass.</p>
<p>The problem is that the ... | <p>I don't quite understand the purpose of this class structure you describe (the class names confuse me), but in general a few things come to mind that might help you:</p>
<p>Almost always the best solution is to try and rethink your class model by evaluating whether you should for example break up the <em>responsibi... | <p>You can interpret a sublass as an instance of a superclass but not vice sersa. Did you state this backwards?</p>
<p>If so, you could use: </p>
<p>vas cp:CharacterPhysics;</p>
<p>...</p>
<p>var ac:AnimatedCharacter = cp As AnimatedCharacter</p>
| 34,120 |
<p>I built a cheap Delta printer with ATMega board and 1.8° motors. The micro stepping is limitied to 1/16. Beside a decent print quality, I observe a moire effect on flat surfaces. The moire is clearly caused by a combination of both, the 1.8° motors steps and the low microstepping. </p>
<p>I thought about using 0.9°... | <p>Delta bots always need all motors to step to maintain a straight level. <a href="https://3dprinting.stackexchange.com/questions/5796/full-steps-mode-for-z-axis-stepper-controller">Microstepping</a>, is not magic, the <strong>incremental torque</strong> decreases per step so that you will be more likely to miss a few... | <p>I am looking at the example print you supplied and trying to understand the defects. Was the object printed vertically, so that the object Z-axis is running from top to bottom in the picture? </p>
<p>If so, then the horizontal defects look like resonance artifacts, which could be caused by the issue you raise of t... | 1,114 |
<p>I have a content management application in the root of my website, and I'm trying to use a different app (a billing application) under a sub-folder. Unfortunately, the web.config of the root site is interfering with the sub-app.</p>
<p>Is there a way to just disable web.config inheritance for a sub-folder?</p>
<p>... | <p>There is an attribute that you can use in the root web.config file to cause it not to have its contents become inherited by child applications.</p>
<p>inheritInChildApplications</p>
<p><a href="http://www.kowitz.net/archive/2007/05/16/stopping-asp.net-web.config-inheritance.aspx" rel="nofollow noreferrer">Blog abo... | <p>I have faced this situation a few times. It seems that the parent poster's instincts are in the ball park. I have found that adding two entries seem to have solved it—both a <code><location></code> entry.</p>
<ol>
<li><p>Find your <code><system.web></code>…<code></system.web></code>. Wrap it with a... | 47,940 |
<p>I've got a timer running in my Delphi MDI application and I'd like to use it to pop up a message if something changes in the background. But I don't want that message to pop up when the the application has a modal dialog in the foreground because the user couldn't do anything about it. </p>
<p>So what I'd like to k... | <p>You could try with this code:</p>
<pre><code>var
ActForm: TCustomForm;
begin
ActForm := Screen.ActiveForm;
if (ActForm = nil) or not (fsModal in ActForm.FormState) then begin
end;
end;
</code></pre>
<p>I tested with Delphi 4, works for me.</p>
<p>[EDIT]: But you should really think about whether popping ... | <p>Today user <a href="https://stackoverflow.com/users/180353/histrio">histrio</a> correctly answered in <a href="https://stackoverflow.com/questions/3306260/delphi-detecting-if-my-app-has-a-modal-dialog-open">another thread</a> that just monitoring modal Delphi forms is not enough; Windows can also have modal dialogs.... | 36,110 |
<p>I'm using Java 6, Tomcat 6, and Metro. I use WebService and WebMethod annotations to expose my web service. I would like to obtain information about the request. I tried the following code, but wsCtxt is always null. What step must I take to <em>not</em> get null for the WebServiceContext.</p>
<p>In other words: ho... | <p>I recommend you either rename your variable from wsCtxt to wsContext or assign the name attribute to the @Resource annotation. The <a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bncjk.html" rel="noreferrer">J2ee tutorial on @Resource</a> indicates that the name of the variable is used as part of the lookup... | <p>Maybe the javax.ws.rs.core.Context annotation is for what you are looking for, instead of Resource?</p>
| 16,154 |
<p>An <a href="https://stackoverflow.com/questions/15241/does-anyone-have-any-real-world-experience-of-csla#15357">answer</a> to a Stack Overflow question stated that a particular framework violated a plain and simple OOP rule: Single Responsibility Principle (SRP).</p>
<p><strong>Is the Single Responsibility Principl... | <p>Very few rules, if any, in software development are without exception. Some people think there are no place for <em>goto</em> but they're wrong. </p>
<p>As far as OOP goes, there isn't a single definition of object-orientedness so depending on who you ask you'll get a different set of hard and soft principles, patt... | <p>SRP is just another expression of ISP :-) . </p>
<p>And the "P" means "principle" , not "rule" :D </p>
| 3,624 |
<p>I'm reading through K&R and came to the small section on register variables, and was wondering if people here have some good examples of this put into practice.</p>
<p>From section 4.7 in K&R:</p>
<blockquote>
<p>The register declaration looks like<br>
register int x;<br>
register char c;<... | <p>There is no good example of register usage when using modern compilers (read: last 15+ years, and note that this answer is from 2008) because it almost never does any good and can do some bad. When you use register, you are telling the compiler "I know how to optimize my code better than you do" which is ... | <p>Well This is a Question that needs multiple answers because there are multiple coding contexes: from the high level language perspective, the mid level and low level (down to assembly) since the C language can call assembly routines.</p>
<p>The reason for using assembly instead of C is exavtly because of performanc... | 40,658 |
<p>So I got started with PHP at version 4, and had to make the switch to 5. Now I understand that version 6 is on the way, and that a lot of things have been re-thought.</p>
<p>The changes may be good ones, but in the future, does anyone know about PHP's roadmap? Does it look like it will flatten out?</p>
| <p>The history of PHP is that they don't implement breaking changes without good reason. I've always seen the benefits of the work I had to do porting to new PHP versions. So, I would actually consider it a good thing that the developers aren't afraid of breaking things when it needs to be done.</p>
| <p>I am really scared with this. I like php and have put a great deal of time in becoming good with php. It's sad and scary to see the developers don't know what the hell they are doing or why they implement this or that in this or that manner. I hope in the future they have a clear vision of php. I do really like php ... | 31,027 |
<p>I get the concept of automatic bed leveling...the printer moves around the bed and uses a sensor to identify high and low spots, then "software compensates for differences". </p>
<p>But what exactly does "compensates" mean? </p>
<p>It is extruding more material in the low spots to build them up and thinning out th... | <p>Last first: use of a raft has nothing to do with bed levelling. It depends only on the features/shape/etc of the object being printed.</p>
<p>Now, as to what the auto-levelling does: the answer is, sadly "it depends." A simple algorithm will just find the Z-height of the four corners and apply a bilinear correcti... | <p>A probe or even manual (e.g. through LCD panel) leveling results in either a reference plane or mesh. This depends on the firmware and the options set in the firmware. Basically, this process maps the geometry of your build plate. Once it knows this geometry, printing an object results in the head following the heig... | 1,017 |
<p>I have 3 points (A, B and X) and a distance (d). I need to make a function that tests if point X is closer than distance d to any point on the line segment AB. </p>
<p>The question is firstly, is my solution correct and then to come up with a better (faster) solution.</p>
<p>My first pass is as follows</p>
<pre><... | <p>If your set of (A,B,d) in fixed, you can calculate a pair of matrices for each to translate the co-ordinate system, so that the line AB becomes the X axis, and the midpoint of AB is the origin.</p>
<p>I <em>think</em> this is a simple way to construct the matrices:</p>
<pre><code>trans = - ((A + B) / 2) // ... | <blockquote>
<p>This code will end up being run for a large set of P's and a large set of A/B/d triplets with the intent of finding all P's that pass for at least one A/B/d so I suspect that there is a way to reduce overall the cost based on that but I haven't looked into that yet.</p>
</blockquote>
<p>In the case w... | 31,812 |
<p>Anticipating the day when multi-touch interfaces become more pervasive, are there libraries in Java that can be used for developing touch applications? I'm looking for interfaces similar to MouseListener / MouseMotionListener / MouseWheelListener.</p>
| <p>The MT4j project has everything you need to develop multitouch applications in java.
All the well known multitouch gestures are already built in and can be accessed as simple
as listening to mouse events (for example: component.addGestureListener(..)).
It also features a hardware accelerated scene graph, similar to ... | <p>I am primarily working in Processing and designing my UI from the ground up. I've been looking for a solution which doesn't prescribe a UI framework which both MT4J and JavaFX appear to do. Furthermore, MT4J appears to be abandoned.</p>
<p>This looks like a promising solution at least for Windows but I'm unsure if ... | 48,233 |
<p>I know the use of server-side controls is a no-no in ASP.NET MVC, however we have a long list of crystal reports that the company has already produced for a previous application that I would like to utilize for our new ASP.NET MVC application.</p>
<p>Is there an appropriate way to use crystal reports in ASP.NET MVC... | <p>It is pretty simple actually. just add following references to your MVC project:</p>
<ul>
<li>CrystalDecisions.CrystalReports.Engine</li>
<li>CrystalDecisions.ReportSource </li>
<li>CrystalDecisions.Shared</li>
</ul>
<p>use Action method like below:</p>
<ul>
<li><p>C# :</p>
<pre><code>using CrystalDecisions.Cr... | <p><strong>Just add this reference : using CrystalDecisions.CrystalReports.Engine;<br>
than do this action :</strong> </p>
<pre><code>using CrystalDecisions.CrystalReports.Engine;
public ActionResult Report()
{
List<Table> table = new List<Table>();
Repor... | 45,382 |
<p>I am trying to have Apache follow a symlink to a raid array server that will contain some large data files. I have tried modifying <code>httpd.conf</code> to have an entry like this</p>
<pre><code><Directory "/Users/imagine/Sites">
Options FollowSymLinks
AllowOverride all
Order allow,deny
Allow from ... | <p>I had the same problem last week and the solution was pretty simple for me.</p>
<p>Run:</p>
<pre><code>sudo -i -u www-data
</code></pre>
<p>And then try navigating the path, directory by directory. You will notice at some point that you don't have access to open the dir.
If you get into the last directory, check ... | <p>This is a permissions problem where the user that your web server is running under does not have read and/or execute permissions to the necessary directories in the symbolic link path. The quick and easy way to check is to <code>su - web-user</code> (where <code>web-user</code> is the user account that the web serv... | 11,161 |
<p>I have a directory full (~10<sup>3</sup>, 10<sup>4</sup>) of XML files from which I need to extract the contents of several fields.
I've tested different xml parsers, and since I don't need to validate the contents (expensive) I was thinking of simply using xml.parsers.expat (the fastest one) to go through the file... | <p>The quickest way would be to match strings (with, e.g., regular expressions) instead of parsing XML - depending on your XMLs this could actually work.</p>
<p>But the most important thing is this: instead of thinking through several options, just implement them and time them on a small set. This will take roughly th... | <p>If you know that the XML files are generated using the ever-same algorithm, it might be more efficient to not do any XML parsing at all. E.g. if you know that the data is in lines 3, 4, and 5, you might read through the file line-by-line, and then use regular expressions.</p>
<p>Of course, that approach would fail ... | 44,818 |
<p>I have an app with the following basic architecture:</p>
<p>A windows service (Service) that registers a .NET type (RemoteObject) for remote access (.NET Remoting). RemoteObject creates non-ThreadPool threads that use the ThreadPool to do IO processing. The size of the ThreadPool must be restricted to a limit for ... | <p>It turns out that the .NET remoting infrastructure uses the .NET ThreadPool (or shares the underlying resource), so remoting calls can hang if all ThreadPool threads are in use by your app.</p>
| <p>A few years ago, I designed and implemented a critical business system that used .NET Remoting. We had a client implemented as a Windows Forms GUI, a server implemented as a Windows Service, and a SQL Server database.</p>
<p>I designed for troubleshooting/debugging/development, so one of my first design criteria w... | 33,885 |
<p>I recently rolled an application that automatically encrypted a file output from another internal system using PGP and then sftp’d to a foreign target server directory where it was to be consumed by a third-party application. I have been trying to trouble shoot the whole process for about a week and was getting no r... | <p>I suppose it would depend on what platform it is on. In Linux case sensitivity is the default so that would bring case sensitivity to the file system calls nessacary to find a file in a directory. But other than that it shouldn't.</p>
| <p>I suppose it would depend on what platform it is on. In Linux case sensitivity is the default so that would bring case sensitivity to the file system calls nessacary to find a file in a directory. But other than that it shouldn't.</p>
| 31,267 |
<p>I have a URI here in which a simple document.cookie query through the console is resulting in three cookies being displayed. I verified this with trivial code such as the following as well:</p>
<pre><code>var cookies = document.cookie.split(';');
console.log(cookies.length);
</code></pre>
<p>The variable cookies ... | <p>The alternative to template style meta-programming is Macro-style that you see in various Lisp implementations. I would suggest downloading <a href="http://www.paulgraham.com/onlisp.html" rel="noreferrer">Paul Graham's <em>On Lisp</em></a> and also taking a look at <a href="http://clojure.org" rel="noreferrer">Cloj... | <p>It does not matter what language you are using -- any of them is able to do Heterogeneous Generative Metaprogramming. <strong>Take any dynamic language</strong> such as Python or Clojure, or Haskell if you are a type-fan, <strong>and write models</strong> in this host language that are <em>able to compile themself i... | 14,216 |
<p>Does anyone have any good links for developing custom field and content types that doesn't involve using VSeWSS? Most of the stuff I have seen on the web requires installing VSeWSS, I would rather build them from scratch with just VS2005.</p>
<p>Thanks</p>
| <p>I understand the idea of doing it by hand first without a tool to help.</p>
<p>But, you will end up creating a lot of xml by hand. It will really hurt and take a long time.</p>
<p>I would recommend <a href="http://www.codeplex.com/stsdev" rel="nofollow noreferrer">STSDev</a> personally. Use it to create the soluti... | <p>Check out rapid tools and SPDeploy:</p>
<p><a href="http://rapid-tools.googlecode.com" rel="nofollow noreferrer">http://rapid-tools.googlecode.com</a></p>
<p>SPDeploy allows you to locally dev a solution using visual studio and deploy a automatically generated wsp remotely.</p>
| 31,280 |
<p>How do you pass "this" to the constructor for ObjectDataProvider in XAML.</p>
<p>Lets say my presenter class is:</p>
<pre><code>public class ApplicationPresenter(IView view){}
</code></pre>
<p>and that my UserControl implements IView.</p>
<p>What do I pass to the ConstructorParameters in the code below so that t... | <p>I'm just starting with Wpf and was under the misapprehension that I should be trying to do everything in XAML. I've just watched a few videos from <a href="http://windowsclient.net/" rel="nofollow noreferrer">WindowsClient.net</a> which are starting to clear some things up. But boy is this a complex technology!!!</p... | <p>i don't know if it works, but you could give your user control a name , e.g.</p>
<pre><code>x:Name="myUserCotrol"
</code></pre>
<p>and then use it in a binding:</p>
<pre><code>... ConstructorParameters="{Binding ElementName=myUserControl}" ...
</code></pre>
<p>this could work</p>
| 30,159 |
<p>I am trying to dynamically load the contents of a div tag with a .cfm page that contains a cfchart in png format. When the user clicks on a link, I am using the load function to put the .cfm page into the div.</p>
<pre><code>$("#bank").bind("click", function(){
$("#chartx").load("bank.cfm");
});
</code></pre>
... | <p>Weirdest thing, but the cfdebug information in the classic style appended on the page is what causes it to break.</p>
| <p>Have you tried jQuery.get? Maybe something like:</p>
<pre><code>$("#bank").bind("click", function(){
$.get("bank.cfm", function(data){
$("#chartx").html(data);
});
});
</code></pre>
<p>It's not as clean but it's more specific. Maybe it will take a different course from whatever is breaking.</p>
| 28,102 |
<p>I have the following xml I'd like to deserialize into a class</p>
<pre><code><?xml version="1.0" encoding="utf-8" ?>
<root>
<element1>String1</element1>
<element2>String2</element2>
</root>
</code></pre>
<p>I am trying to serialize it into the following class:</p>
<pr... | <p>You can't serialise/deserialise internal properties - They have to be public.</p>
| <p>To follow up on my implementation... I ended up abandoning using the XmlSerializer class all together. The classes I was deserializing were pretty complex and contained lists of other objects that needed to be serialized. The amount of attributes I had to add to my classes made the <a href="http://en.wikipedia.org... | 34,043 |
<p>I recently took my Db initiating code out of the __construct of my Page class and placed it just after I initiate the Page class. I removed it from within the Page class because I want to be able to access it from anywhere (other classes for example). It also takes server, username, password and database arguments t... | <p>A global of some sort (Be that global variables, singleton or some other variant) is an improvement over your previous approach, and as such you're on the right track. Generally speaking though, you should try to minimise the scope of program state (For a number of reasons, which I won't get into here). Having a glo... | <p>Global variables do have a use, and this would be one of them. Unless it's likely that you're going to be needing multiple database connections, (or even still), then I don't see a problem with setting up a global $db object.</p>
<p>An alternative way is to have a static "Factory" class which you can use to get the... | 49,343 |
<p>I was reading a post by Brad Wilson (<a href="http://bradwilson.typepad.com/blog/2008/08/partial-renderi.html" rel="nofollow noreferrer">http://bradwilson.typepad.com/blog/2008/08/partial-renderi.html</a>) on the new ViewEngine changes to MVC Preview 5 and thought that it would be great to be able to render a view t... | <p>It's tricky. What you have to do is set the Response.Filter property to a custom stream class that you implement. The MVC Contrib project actually has examples of doing this. I'd poke around in there.</p>
| <p>Moreover testing, it can be useful for components such as HTML to PDF converters.
These components usually uses 2 ways of transformation.</p>
<ul>
<li>Passing a URL to the conversion method</li>
<li>Passing a HTML content (and you can optionally specify the baseUrl to resolve virtual paths)</li>
</ul>
<p>I am usin... | 14,035 |
<p>Is there a method to get all of the .aspx files in my website? Maybe iterate through the site's file structure and add to an array?</p>
| <pre><code>Directory.GetFiles(HttpContext.Current.Server.MapPath(@"/"), "*.aspx", SearchOption.AllDirectories);
</code></pre>
| <p>using Directory.GetFiles("*.aspx"), you can get all the files in the directory. And you can make it recursive to grab any sub directories and their files.</p>
| 23,281 |
<p>How do I generate all the permutations of a list? For example:</p>
<pre><code>permutations([])
[]
permutations([1])
[1]
permutations([1, 2])
[1, 2]
[2, 1]
permutations([1, 2, 3])
[1, 2, 3]
[1, 3, 2]
[2, 1, 3]
[2, 3, 1]
[3, 1, 2]
[3, 2, 1]
</code></pre>
| <p>Use <a href="https://docs.python.org/3/library/itertools.html#itertools.permutations" rel="noreferrer"><code>itertools.permutations</code></a> from the <strong>standard library</strong>:</p>
<pre><code>import itertools
list(itertools.permutations([1, 2, 3]))
</code></pre>
<hr />
<p>Adapted from <a href="http://code.... | <p>for Python we can use itertools and import both permutations and combinations to solve your problem</p>
<pre><code>from itertools import product, permutations
A = ([1,2,3])
print (list(permutations(sorted(A),2)))
</code></pre>
| 13,001 |
<p>I have been trying to parse Java exceptions that appear in a log for some code I'm working with. My question is, do you parse the exception trace from the top down, or the bottom up? It looks something like this:</p>
<pre><code>ERROR [main]</b> Nov/04 11:03:19,440 [localhost].[/BookmarksPortlet].[] - Exceptio... | <p>This stuff is a little hard to explain, but my first step is nearly always starting from the top and skimming down until I see the familiar <code>com.mycompany.myproject</code>.</p>
<p>Given the line number attached to that you have a place to work from in your own code, which is often a good start.</p>
<p><strong... | <p>In your example, it looks like you need to add some Oracle JDBC driver or something to your project's classpath. </p>
<p>But in the spirit of the question, I think it depends. In this example Spring isn't being very helpful on it's own - error creating bean. Gee, thanks for that information. However, it tells you e... | 33,905 |
<p>Someone is trying to sell Lisp to me, as a super powerful language that can do everything ever, and then some.</p>
<p>Is there a <em>practical</em> code example of Lisp's power?<br/>(Preferably alongside equivalent logic coded in a regular language.)</p>
| <p>I like macros.</p>
<p>Here's code to stuff away attributes for people from LDAP. I just happened to have that code lying around and fiigured it'd be useful for others.</p>
<p>Some people are confused over a supposed runtime penalty of macros, so I've added an attempt at clarifying things at the end.</p>
<h1>In T... | <p>John Ousterhout made this interesting observation regarding Lisp in 1994:</p>
<blockquote>
<p>Language designers love to argue about why this language or that language
<strong>must</strong> be better or worse a priori, but none of these arguments really
matter a lot. Ultimately all language issues get settled... | 13,157 |
<p>I'm porting some <a href="http://en.wikipedia.org/wiki/MATLAB" rel="nofollow noreferrer">MATLAB</a> functions to <a href="https://en.wikipedia.org/wiki/Scilab" rel="nofollow noreferrer">Scilab</a>. The cool thing is that there is a <a href="http://ralyx.inria.fr/2004/Raweb/scilab/uid96.html" rel="nofollow noreferrer... | <p>See <a href="http://vnoel.wordpress.com/2008/05/03/bye-matlab-hello-python-thanks-sage/" rel="nofollow noreferrer">Bye MATLAB, hello Python, thanks Sage</a> for a first-hand experience of migrating from <a href="http://en.wikipedia.org/wiki/MATLAB" rel="nofollow noreferrer">MATLAB</a> to Python.</p>
| <p>Not to discourage your project, but if you just want a <em>free</em> and <em>open source</em> alternative to <a href="http://en.wikipedia.org/wiki/MATLAB" rel="nofollow noreferrer">MATLAB</a>, have you looked at the <a href="http://en.wikipedia.org/wiki/GNU_Octave" rel="nofollow noreferrer">Octave</a> project? Contr... | 30,359 |
<p>I just came across <a href="https://stackoverflow.com/questions/139686/should-local-variable-initialisation-be-mandatory#283127">this question</a> about initializing local variables. Many of the answers debated simplicity/readability <em>vs.</em> robustness. As a developer of (remotely deployed) embedded systems, ... | <p>I'm a fan of the techniques described in "<a href="http://www.pragprog.com/the-pragmatic-programmer/extracts/tips" rel="nofollow noreferrer">The Pragmatic Programmer</a>". I also use <a href="http://en.wikipedia.org/wiki/Test-driven_development" rel="nofollow noreferrer">TDD</a>, rather than DBC as I find it more fl... | <p>The systems I write (in C) have high requirements as to performance and reliability. Designing for fail is fine. When it comes to design for safe things become more complicated.</p>
<p>Hardware can always fail and apart from that you have the issue of invalid data entering the system from outside. My solutions in t... | 35,877 |
<p>I've had some discussions recently at work about switching from Subversion to a DVCS like bazaar, and I would like to get other people's opinion.</p>
<p>I've managed to crystallize my reluctance to do so into a simple parallel.</p>
<blockquote>
<p>Version Control can be used well or badly. </p>
</blockquote>
<p... | <p>If there are developers on your team that don't want to share their "one week local hack" then thats the problem, not the source control tool you are using. A better term for the "dark side" you are describing is "the wrong way" of coding for a team. Source control is a tool used to facilitate collaborative work. If... | <p>I believe svn's merging has been somewhat overhauled in the latest release.</p>
| 4,670 |
<p>I am trying to write my first real python function that does something real. What i want to accomplish is searching a given folder, and then open all images and merging them together so they make a filmstrip image. Imagine 5 images stacked on top of eachother in one image.</p>
<p>I have this code now, which should ... | <p>It is not an answer to your question, but It might be helpful:</p>
<pre><code>#!/usr/bin/env python
from PIL import Image
def makefilmstrip(images, mode='RGB', color='white'):
"""Return a combined (filmstripped, each on top of the other) image of the images.
"""
width = m... | <p>I think if you change your <code>try</code> section to this:</p>
<pre><code>filmstripimage.save(filmstrip_url, 'jpg', quality=90, optimize=1)
</code></pre>
| 43,579 |
<p>How can you determine the performance consequences of your PHP code if you are not familiar with the internals? Are there ways to figure out how your code is being executed (besides simply load testing it)? I am looking for things like memory usage, the execution time for algorithms.</p>
<p>Perhaps Joel would say, ... | <p>Use the <a href="http://www.xdebug.org/" rel="nofollow noreferrer">Xdebug</a> extension to profile PHP code.</p>
| <p>Even if you are familiar with the internals, you should still load test your assumptions. I like to use the <a href="http://pear.php.net/package/Benchmark" rel="nofollow noreferrer">PEAR Benchmark</a> package to compare different code.</p>
<p>If you can isolate your code, you can keep your load testing simple. A ty... | 7,385 |
<p>What is the difference between HTML <code><input type='button' /></code> and <code><input type='submit' /></code>?</p>
| <p><code><input type="button" /></code> buttons will not submit a form - they don't do anything by default. They're generally used in conjunction with JavaScript as part of an AJAX application.</p>
<p><code><input type="submit"></code> buttons will submit the form they are in when the us... | <p>IE 8 actually uses the first button it encounters submit or button. Instead of easily indicating which is desired by making it a input type=submit the order on the page is actually significant.</p>
| 36,985 |
<p>Is it possible to clone a virtual machine using VMware Fusion on Mac OS X? I'm trying the 30 day evaluation version but there doesn't appear to be a clone feature. I tried using the Finder to copy a VM's package structure but the copy didn't appear in the Virtual Machine Library.</p>
| <p>Just use File->open to open the copy of the VM. It will probably ask you if you want to change the VM's unique ID. If you plan to run both the original and the clone at the same time, and it's not a Windows OS that needs activation, you should say yes. </p>
| <p>I don't know fusion in detail, but in VMWare Server you can just copy the files somewhere else.</p>
| 13,415 |
<p>I've been wondering what exactly are the principles of how the two properties work. I know the second one is universal and basically doesn't deal with time zones, but can someone explain in detail how they work and which one should be used in what scenario?</p>
| <p><a href="http://msdn.microsoft.com/en-us/library/system.datetime.utcnow.aspx" rel="noreferrer">DateTime.UtcNow</a> tells you the date and time as it would be in Coordinated Universal Time, which is also called the Greenwich Mean Time time zone - basically like it would be if you were in London England, but not durin... | <p>When you need a local time for the machine your application runs at (like CEST for Europe), use Now. If you want a universal time - UtcNow. It's just matter of your preferences - probably making a local website / standalone application you'd want to use the time user has - so affected by his/her timezone setting - D... | 8,751 |
<p>I am starting again with c++ and was thinking about the scope of variables.
If I have a variable inside a function and then I return that variable will the variable not be "dead" when it's returned because the scope it was in has ended?</p>
<p>I have tried this with a function returning a string and it did work.
Ca... | <blockquote>
<p>When the function terminates, the
following steps happen:</p>
<ul>
<li><p>The function’s return value is
copied into the placeholder that was
put on the stack for this purpose.</p></li>
<li><p>Everything after the stack frame
pointer is popped off. This destroys
all local variables ... | <p>The local variable is copied to the return value. Copy constructors are called for non-trivial classes.</p>
<p>If you return a pointer or reference to a local variable you will have trouble---just as your intuition suggested.</p>
| 34,687 |
<p>Has anyone here had any experience with running OpenBD or Railo in production? We have some legacy CF6.1 apps that need to be hosted somewhere and I'm wondering if OpenBD or Railo is stable enough for production use, won't require a great deal effort to migrate to, etc.</p>
| <p>I'll chime in as the 'Adobe' guy and say that yes, both OpenBD and Railo are viable CFML engines. The main hurdles are around CFML compatibility. For the last decade Allaire/Macomedia/Adobe has been driving the CFML standard, but we've formed an open CFML Advisory board made up of various experts in the field to hel... | <p>I think replacedirect.nl recently migrated their webshop to railo.</p>
| 48,618 |
<p>Let's say I have a model like this</p>
<pre><code>class Foo(db.Model):
id = db.StringProperty()
bar = db.StringProperty()
baz = db.StringProperty()
</code></pre>
<p>And I'm going a GqlQuery like this</p>
<pre><code>foos = db.GqlQuery("SELECT * FROM Foo")
</code></pre>
<p><strong>I want to take the re... | <p>Take a look at <a href="http://code.google.com/p/googleappengine/source/browse/trunk/google/appengine/api/datastore.py" rel="nofollow noreferrer">google.appengine.api.datastore</a>. It's the lower level datastore API that google.appengine.ext.db builds on, and it returns Entity objects, which subclass dict. You can ... | <p>You can use web2py on GAE and do:</p>
<pre><code>db.define_table('foo',SQLField('bar'),SQLField('baz'))
rows=db(db.foo.id>0).select()
### rows is a list, rows.response is a list of tuples
for row in rows: print dict(row)
</code></pre>
<p>Runs on Oracle, Postgresql, Mssql, mysql, etc... too.</p>
| 26,071 |
<p>What is the Ruby idiomatic way for retrieving a single character from a string as a one-character string? There is the <code>str[n]</code> method of course, but (as of Ruby 1.8) it returns a character code as a fixnum, not a string. How do you get to a single-character string?</p>
| <p>In Ruby 1.9, it's easy. In Ruby 1.9, Strings are encoding-aware sequences of characters, so you can just index into it and you will get a single-character string out of it:</p>
<pre><code>'µsec'[0] => 'µ'
</code></pre>
<p>However, in Ruby 1.8, Strings are sequences of bytes and thus completely unaware of the en... | <pre><code>'abc'[1].chr # => "b"
</code></pre>
| 48,527 |
<p>I've just started developing a WPF application. This is not my first WPF app, but it will be the first that needs some polish. I know quite a bit about the "plumbing" of WPF such as binding, etc., but very little about how to polish it up. I don't need a snazzy UI. I just need something that looks like a native Wind... | <p>You should be able to put this into the application's OnLoad event to use the Vista theme, for example:</p>
<pre><code>Uri uri = new Uri("PresentationFramework.Aero;V3.0.0.0;31bf3856ad364e35;component\\themes/aero.normalcolor.xaml", UriKind.Relative);
Resources.MergedDictionaries.Add(Application.LoadComponent(uri... | <p>You should be able to put this into the application's OnLoad event to use the Vista theme, for example:</p>
<pre><code>Uri uri = new Uri("PresentationFramework.Aero;V3.0.0.0;31bf3856ad364e35;component\\themes/aero.normalcolor.xaml", UriKind.Relative);
Resources.MergedDictionaries.Add(Application.LoadComponent(uri... | 49,814 |
<p>I wonder if <a href="http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage.aspx" rel="nofollow noreferrer">MailMessage</a> class is protected from <a href="http://en.wikipedia.org/wiki/E-mail_injection" rel="nofollow noreferrer">e-mail injection</a>. For example, should I check values before passing th... | <p>The <code>MailAddress</code> class checks its addresses against the full BNF grammar from RFC822. (See <code>MailBnfHelper</code>).</p>
<p>There is no risk of injection when using <code>MailMessage</code>s. (Except HTML injection in your own content)</p>
| <p>There seems to be only a simple check in the MailAddress class which checks if the address contains an @.</p>
| 38,649 |
<p>I'm using tortoise svn in Windows.</p>
<p>How can I branch in SVN and have it branch my svn:external folders as well?</p>
| <p>You should use <code>svn:externals</code> as <strong>external</strong> references from different repositories. So <code>svn:externals</code> should refer to components, modules, 3rd party tools, etc.</p>
<p>You should <strong>not</strong> use <code>svn:externals</code> to emulate a "symbolic link"-behaviour by usin... | <p>When you create a branch within Subversion you are simply creating a cheap copy of the trunk, branch, or tag that you are branching from. This cheap copy will contain all of the same files and properties as the trunk, branch, or tag that you branched from until you begin to modify the properties or files of the new ... | 30,431 |
<p>I'm experimenting with JavaFX making a small game. </p>
<p>I want to add sound.
How?</p>
<p>I tried <code>MediaPlayer</code> with <code>media</code> defined with relative <code>source</code> attribute like:</p>
<pre><code>attribute media = Media{
source: "{__FILE__}/sound/hormpipe.mp3"
}
attribute pla... | <p>Just a guess, but is that file "hornpipe.mp3" and not "hormpipe.mp3" (with an m)?</p>
| <p>Just a guess, but I think your <code>{__FILE__}</code> will expand to the name of your file. Try replacing it with <code>{__DIR__}</code>.</p>
| 29,887 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.