instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>How would you go about creating a random alpha-numeric string that matches a certain regular expression?</p>
<p>This is specifically for creating initial passwords that fulfill regular password requirements.</p>
| <p>Welp, just musing, but the general question of generating random inputs that match a regex sounds doable to me for a sufficiently relaxed definition of random and a sufficiently tight definition of regex. I'm thinking of the classical formal definition, which allows only ()|* and alphabet characters. </p>
<p>Regu... | <p>Presuming you have both a minimum length and 3-of-4* (or similar) requirement, I'd just be inclined to use a decent password generator.</p>
<p>I've built a couple in the past (both web-based and command-line), and have never had to skip more than one generated string to pass the 3-of-4 rule.</p>
<ul>
<li>3-of-4: m... | 25,166 |
<p>Here's a link to Windows <a href="http://msdn.microsoft.com/en-us/library/ms683218(VS.85).aspx" rel="nofollow noreferrer">documentation</a>.</p>
<p>Basically I would like to get similar data, but on Linux. If not all is possible, then at least some parts.</p>
| <p>If you enable <code>CONFIG\_TASK\_IO\_ACCOUNTING</code>, you will have the information available in /proc/<pid>/io. This is available since kernel 2.6.20, but not normally enabled by default (However, in Ubuntu 8.04 it seems like it is enabled).</p>
<p>You can read about the various data items in <a href="htt... | <p>Look at the pseudo-files under <code>/proc/<PID>/</code>. Maybe you can find what you need there.</p>
<hr>
<p>Look at <code>man 5 proc</code>, or failing that the kernel documentation. However, I don't see much that looks promising. Sorry.</p>
| 20,302 |
<p>I am creating an ZIP file with <code>ZipFile</code> in Python 2.5, it works OK so far:</p>
<pre><code>import zipfile, os
locfile = "test.txt"
loczip = os.path.splitext (locfile)[0] + ".zip"
zip = zipfile.ZipFile (loczip, "w")
zip.write (locfile)
zip.close()
</code></pre>
<p>But I could... | <p>I created a simple library to create a password encrypted zip file in python. - <a href="https://github.com/smihica/pyminizip" rel="noreferrer"><strong>here</strong></a></p>
<pre><code>import pyminizip
compression_level = 5 # 1-9
pyminizip.compress("src.txt", "dst.zip", "password", compression_level)
</code></pre>... | <p>You can use the <a href="http://www.chilkatsoft.com/python.asp" rel="nofollow noreferrer">Chilkat</a> library. It's commercial, but has a free evaluation and seems pretty nice.</p>
<p>Here's an example I got from <a href="http://www.example-code.com/python/zip.asp" rel="nofollow noreferrer">here</a>:</p>
<pre><co... | 3,794 |
<p>In a previous question, I asked about various ORM libraries. It turns out Kohana looks very clean yet functional for the purposes of ORM. I already have an MVC framework that I am working in though. If I don't want to run it as a framework, what is the right fileset to include to just give me the DB and ORM base cla... | <p>Why not just have a </p>
<pre><code>class ORM extends ORM_Core {}
</code></pre>
<p>somewhere in your code? This removes the need to use any of the loader code.</p>
<p>You'll also need Kohana_Exception, the Database library (and appropraite driver), Kohana::config(), Kohana::auto_load(), Kohana::log() methods (se... | <p><a href="http://obando.com.ve/2009/04/29/modelado-orm-rapido-y-facil/" rel="nofollow noreferrer">http://obando.com.ve/2009/04/29/modelado-orm-rapido-y-facil/</a></p>
<p>That is all your need!! </p>
| 27,637 |
<p>I would like to add a method to a built-in type (e.g. Double), so that I can use an <code>infix</code> operator. Is that possible?</p>
| <p>Yes and no. Yes, you can make it <em>seem</em> like you have added a method to <code>double</code>. For example:</p>
<pre><code>class MyRichDouble(d: Double) {
def <>(other: Double) = d != other
}
implicit def doubleToSyntax(d: Double) = new MyRichDouble(d)
</code></pre>
<p>This code adds the previously... | <p>This feature came in handy to implement a class performing error estimation:</p>
<pre><code>object errorEstimation {
class Estimate(val x: Double, val e: Double) {
def + (that: Estimate) =
new Estimate(this.x + that.x, this.e + that.e)
def - (that: Estimate) =
new Estimate(this.x - that.x, thi... | 38,151 |
<p>We have Core2 machines (Dell T5400) with XP64.</p>
<p>We observe that when running 32-bit processes,
the performance of memcpy is on the order of
1.2GByte/s; however memcpy in a 64-bit process
achieves about 2.2GByte/s (or 2.4GByte/s
with the Intel compiler CRT's memcpy). While the
initial reaction might be to jus... | <p>I think the following can explain it:</p>
<p>To copy data from memory to a register and back to memory, you do</p>
<pre><code>mov eax, [address]
mov [address2], eax
</code></pre>
<p>This moves 32 bit (4 byte) from address to address2. The same goes with 64 bit in 64 bit mode</p>
<pre><code>mov rax, [address]
mov... | <p>I don't have a reference in front of me, so I'm not absolutely positive on the timings/instructions, but I can still give the theory. If you're doing a memory move under 32-bit mode, you'll do something like a "rep movsd" which moves a single 32-bit value every clock cycle. Under 64-bit mode, you can do a "rep mov... | 33,841 |
<p>I have a directory with PDF files that I need to create an index for. It is a PHP page with a list of links:</p>
<pre><code><A HREF="path to file">filename</A>
</code></pre>
<p>The filenames can be complicated:</p>
<pre><code>LVD 2-1133 - Ändring av dumpningslina (1984-11-20).pdf
</code></pre>
<p>Wha... | <p>You can use <a href="http://php.net/manual/en/function.rawurlencode.php" rel="nofollow noreferrer">rawurlencode()</a> to convert a string according to the RFC 1738 spec.
This function replaces all non-alphanumeric characters by their associated code.</p>
<p>The difference with <a href="http://php.net/manual/en/func... | <p><a href="http://se.php.net/manual/en/function.urlencode.php" rel="nofollow noreferrer">urlencode()</a> should probably do what you want.</p>
<p><strong>Edit</strong>: urlencode() works fine on swedish characters.</p>
<pre><code>
<?php
echo urlencode("åäö");
?>
</code></pre>
<p>converts to... | 5,547 |
<p>When creating web parts for Sharepoint, is it better to create an actual web part, or is using and ASP.NET User Control (.ascx) just as good?</p>
<p>I already know how to create the user controls that I need, so it seems like the extra effort of creating a web part is just unnecessary leg work.</p>
<p>What are the... | <p>I am a big fan of user controls except for the simplest web parts. I create a webpart that instantiates and loads the user control. There are other tools out there that you can use to expose your user control, like smartpart, but I would suggest you wrap it up yourself, as it is a good learning experience. Once y... | <p>A bare ASP.NET ascx control would have to be added to a custom layout page. This limits the utility of the control a little as it cannot be added "just anywhere".</p>
<p>Having a webpart gives the flexibility of the control being added to the site multiple times in different locations or even multiple times on the ... | 28,679 |
<p>I have a layered application in Java which has a multi thread data access layer which is invoked from different points. A single call to this layer is likely to spawn several threads to parallelize requests to the DB. </p>
<p>What I'm looking for is a logging tool that would allow me to define "activities" that are... | <p>You should also have a look at the <a href="http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/NDC.html" rel="noreferrer">nested diagnostic context</a> feature of log4j. Pushing different contexts to the logger for different callers might do the trick for you.</p>
| <p>In Java5 (and later) you can call </p>
<pre><code>StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
</code></pre>
<p>Inspect the stack trace to whatever depth you want and log accordingly.</p>
<p>In Java 1.4 you can get the same info with </p>
<pre><code>StackTraceElement[] stackTrace = ne... | 10,882 |
<p>Among the known limitations of Joe Celko's nested sets (modified pre-order traversal) is marked degredation in performance as the tree grows to a large size.</p>
<p>Vadim Tropashko proposed nested intervals, and provides examples and theory explanation in this paper: <a href="http://arxiv.org/html/cs.DB/0401014" re... | <p><a href="http://www.sitepoint.com/article/hierarchical-data-database/" rel="noreferrer">While I've seen examples for nested sets</a>, I haven't seen much for nested intervals, although in theory it shouldn't be difficult to convert from one to the other. Instead of doing pre-order traversal to label the nodes, do a ... | <p>I have written a gem that abstracts away all the computations of nested intervals to be used with Rails's ActiveRecord <a href="https://github.com/clyfe/acts_as_nested_interval/" rel="nofollow">https://github.com/clyfe/acts_as_nested_interval/</a> used in production on several systems.</p>
| 47,076 |
<p>I have a 12 V/30 A power supply. Will a RAMPS 1.4 shield burn if I use that power supply with it?</p>
| <p>Voltage and current behave differently and it is important to remember two essential points:</p>
<ul>
<li>PSU voltage specifications <em><strong>should never be exceeded</strong></em>, else the circuit will (most likely) be damaged, and;</li>
<li>PSU current specifications <em><strong>can be exceeded</strong></em>, ... | <p>No, it won't burn if you use a power supply that put out 12 Volts and tolerates up to 30 Amps.</p>
| 2,113 |
<p>I've created a custom search page with some defined options in my search scope.</p>
<p>I have a metadata mapped <code>jobtitle</code>, and added the search option to my custom search.</p>
<pre><code><Property name="JobTitle"
ManagedName="title"
ProfileURI="urn:schemas-microsoft-com:sharepo... | <p>It is a little difficult to know exactly what you're problem is since you are using a custom search page.</p>
<p>I am assuming you created a new Managed property and mapped it to something. Then you added it to the advanced search webpart via editing the <code>xsl/xml</code> (directions <a href="http://www.sharepo... | <p>Changes to the managed properties will not appear in the search results until the data is re-crawled. I suggest you reset the search index and do a full crawl.</p>
| 27,270 |
<p>How do I read text from the (windows) clipboard with python?</p>
| <p>You can use the module called <a href="http://docs.activestate.com/activepython/2.5/pywin32/win32clipboard.html" rel="noreferrer">win32clipboard</a>, which is part of <a href="https://github.com/mhammond/pywin32" rel="noreferrer">pywin32</a>.</p>
<p>Here is an example that first sets the clipboard data then gets it... | <p>For users of Anaconda: distributions don't come with pyperclip, but they do come with pandas which redistributes pyperclip:</p>
<pre class="lang-py prettyprint-override"><code>>>> from pandas.io.clipboard import clipboard_get, clipboard_set
>>> clipboard_get()
'from pandas.io.clipboard import clipb... | 12,649 |
<p>In languages like Java and C#, strings are immutable and it can be computationally expensive to build a string one character at a time. In said languages, there are library classes to reduce this cost such as C# <code>System.Text.StringBuilder</code> and Java <code>java.lang.StringBuilder</code>.</p>
<p>Does php (... | <p>No, there is no type of stringbuilder class in PHP, since strings are mutable.</p>
<p>That being said, there are different ways of building a string, depending on what you're doing.</p>
<p>echo, for example, will accept comma-separated tokens for output.</p>
<pre><code>// This...
echo 'one', 'two';
// Is the sam... | <p>no such limitation in php,
php can concatenate strng with the dot(.) operator</p>
<pre><code>$a="hello ";
$b="world";
echo $a.$b;
</code></pre>
<p>outputs "hello world"</p>
| 15,090 |
<p>I'm developing a game coded in Flash AS3 and need to read/write info to an SQL server.
Currently, for testing purposes, I use <a href="http://asql.mooska.pl/" rel="nofollow noreferrer">ASQL</a> which is very simple and robust, but it needs a direct connection from the client machine to the SQL server (port 3306 open... | <p>You can use HTTP(S) with authentication with e.g. PHP. Don't make the script a wrapper to the SQL connection, as this'd ruin the point of the script (essencially); have custom commands as the protocol (e.g. add/update high scores).</p>
| <p>You can use HTTP(S) with authentication with e.g. PHP. Don't make the script a wrapper to the SQL connection, as this'd ruin the point of the script (essencially); have custom commands as the protocol (e.g. add/update high scores).</p>
| 43,492 |
<p>Using the svnmerge.py tool it is possible to merge between branches, up and down. It is hard to find the details for doing this. Hopefully, v1.5 will have a neat method for doing this without using svnmerge.py - details requested!</p>
| <p>It looks like you're asking about 1.5 merge tracking. Here's a quick overview for doing merges to/from trunk (or another branch): <a href="http://blog.red-bean.com/sussman/?p=92" rel="nofollow noreferrer">http://blog.red-bean.com/sussman/?p=92</a></p>
| <p>With svnmerge.py, you initialize both branches (when going in one direction, you only need to initialize one of the branches). Then merge using the -b (For bidirectional flag). Here is a summary starting from branch one to branch two. $REPO is the protocol and path to your repository.</p>
<blockquote>
<p>svn c... | 9,393 |
<p>I'm doing .NET 3.5 programming in VB for a class. I have a .mdb database with 3 related tables, and a table adapter with some queries on it that look like this:</p>
<pre><code>SELECT PropertyID, Street, Unit, City, Zip, Type, Bedrooms, Bathrooms, Area, MonthlyRent
FROM tblProperties
</code></pre>
<p>Th... | <p><a href="http://oss.oetiker.ch/mrtg/" rel="nofollow noreferrer">MRTG</a> is probably the easiest to setup. If your router has SNMP (as you mention), to setup it's a single command:</p>
<pre><code>cfgmaker --output=mrtg_myrouter.cfg public@1.2.3.4
</code></pre>
<p>MRTG is good for high-bandwidth routers and the lik... | <p>Also consider <a href="http://cactiez.cactiusers.org/" rel="nofollow">CactiEZ</a> on a VM or small server, it is a baremetal CentOS 6 based system.</p>
| 32,220 |
<p>I'm having a hard time understanding and therefore managing arrays and indexes manually in C. These are my two classic approaches but they doesn't seem to work as they keep looping when the condition is reached: </p>
<pre><code>#include<stdio.h>
#define MAX 255
int main(){
int arr[MAX]={0};
int idx=... | <pre><code>arr[idx] <= MAX
</code></pre>
<p>should be</p>
<pre><code>idx <= MAX
</code></pre>
| <p>C arrays begin counting from 0. </p>
<p>If you allocate an array of size MAX, accessing the element at MAX would be an error.
Change the loop to;</p>
<pre><code>int arr[MAX];
for ( .... && idx < MAX )
</code></pre>
| 13,763 |
<p>I want to download a lot of urls in a script but I do not want to save the ones that lead to HTTP errors.</p>
<p>As far as I can tell from the man pages, neither <code>curl</code> or <code>wget</code> provide such functionality.
Does anyone know about another downloader who does?</p>
| <p>I think the <code>-f</code> option to <code>curl</code> does what you want:</p>
<blockquote>
<p><code>-f</code>, <code>--fail</code></p>
<p>(HTTP) Fail silently (no output at all) on server errors. This is mostly done to better
enable scripts etc to better deal with failed attempts. In norma... | <p>You can download the file without saving using <code>"-O -"</code> option as </p>
<pre><code>wget -O - http://jagor.srce.hr/
</code></pre>
<p>You can get mor information at <a href="http://www.gnu.org/software/wget/manual/wget.html#Advanced-Usage" rel="nofollow">http://www.gnu.org/software/wget/manual/wget.html#Ad... | 11,540 |
<p>Suppose I have a class where I want the user to be able to have a reference to one of my members. Which is preferred?</p>
<pre><code>class Member;
class ClassWithWeakPtr
{
private:
boost::shared_ptr<Member> _member;
public:
boost::weak_ptr<Member> GetMember();
};
</code></pre>
<p>or</p>
<pre><c... | <p>Why not return a <code>shared_ptr<></code>? Thatway the client gets to use what's returned for as long as he needs it, but there is no problem if the 'server' class goes away.</p>
<p>There are not too many situations where the semantics of <code>weak_ptr<></code> make a lot of sense (caches and ???). ... | <p>Depending on the context, either one could be fine. The main problem with returning a 'live' link to a member (if you have to expose one in the first place) is that whoever uses the exposed member is that your client might hold onto it longer than the containing object exists. And if your client accesses said member... | 26,474 |
<p>I used a class which derives from <code>CListBox</code>, and create it with following:</p>
<pre><code>style:WS_CHILD|WS_VISIBLE |LBS_OWNERDRAWFIXED | WS_VSCROLL | WS_HSCROLL
</code></pre>
<p>I expect the ListBox's item to be have a fixed size, not affected by the size of the list box. So I override the MeasureItem... | <p>What's not mentioned in the reference is that <code>WM_MEASUREITEM</code> is called <em>every time</em> the <code>*_OWNERDRAWFIXED</code> control is resized.</p>
<p>I don't know however, how official this behavior is and whether it should be relied on, but it has been verified at <a href="http://www.codeguru.com/Cp... | <p>If you look at the <code>MSDN</code> entry for <a href="http://msdn.microsoft.com/en-us/library/t7tccyw7(VS.80).aspx" rel="nofollow noreferrer"><code>CListBox::MeasureItem</code></a> you'll see that it's only called once unless the <code>LBS_OWNERDRAWVARIABLE</code> (not <code>LBS_OWNERDRAWFIXED</code>) style is set... | 31,533 |
<p>I have a legacy VB6 executable that runs on Vista. This executable shells out another legacy MFC C++ executable.</p>
<p>In our early Vista testing, this call would display the typical UAC message to get the user's permission before running the second executable. This wasn't perfect, but acceptable. However, it no... | <p>If UAC is disabled on the machine, and the call would have required elevated privileges, then the call to CreateProcess will fail. make sure UAC is enabled.</p>
<p>Additionally, follow the guidelines <a href="https://stackoverflow.com/questions/90702/how-does-a-program-ask-for-administrator-privileges#90718">here f... | <p>This works well for us under Vista</p>
<pre><code>Private Declare Function CreateProcess Lib "kernel32" Alias "CreateProcessA" (ByVal lpApplicationName As String, ByVal lpCommandLine As String, lpProcessAttributes As Any, lpThreadAttributes As Any, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, lpEnv... | 14,493 |
<p>I have a product idea that requires integration into the Microsoft Office suite.</p>
<p>Are there any licensing/limitation issues to be aware of for me to proceed?</p>
| <p>Depends...</p>
<p>If your product uses their published APIs and you don't ship any components of theirs "in your box" then you are (probably) just a value added supplier on top of their platform. You would be telling your customers to have the appropriate MS products in place and then install your App over the top... | <p>I realised I have a technical answer for you too. About 10 years ago I wrote a plug-in for Excel which leveraged their spreadsheet to surface data from my provider. It was very successful and lived for about 8 years as a viable revenue generating product. It was a key differentiator for the BI company I worked fo... | 29,215 |
<p>I am currently working on a project that will store specific financial information about our clients in a MS SQL database. Later, our users need to be able to query the database to return data from the clients based on certain criteria (eg. clients bigger then a certain size, clients in a certain geographical locati... | <p>Interestingly, the data warehouse folks do this all the time. They often use the simplest possible SQL (SELECT SUM/COUNT... GROUP BY...) and do the work <em>outside</em> the database in report-writing tools.</p>
<p>I think you should get a copy of The Data Warehouse Toolkit and see how this can be done in a way th... | <p>You can do any calculation in stored procedure and return data. Interest calculation like stored procedure need lot of calculations. </p>
<p>Any way you have to calculate data with other table data's. </p>
<p>SUM we can do in SP,</p>
<pre><code>Declare @SUMAmount decimal(12,3)
</code></pre>
<p>-- also declare @... | 21,117 |
<p>I've been beating myself over the head with this app migration for a few days now. What I have is an old MSSQL Server 2000-backed application that is being upgraded to a Windows 2003 Server running SMSQL Server 2005. I know little about SQL Server but obviously not enough.</p>
<p>I tried backing up the database on ... | <p>The backup file has the "hard" location of the data files stored in it. You just need to update them:</p>
<p>When you restore in 2005, before you click the final "ok" to restore (after you have selected the .bak file), go to the options tab. This will have the mdf and ldf locations that were in the backup file. C... | <p>Create a backup of SQL2000's database to file. Create new database on SQL2005 with same name and restore backup file into new database with option "force restore over existing database" and set copliant level of new database to "SQL2000 (8.0)".</p>
| 18,682 |
<p>I'd like to have my Eclipse plugin cause a URL to be opened by the users' default browser. This seems like pretty standard behavior, but I haven't been able to find any docs on how to do this.</p>
<p>Can anyone help?</p>
| <p>You are looking for:</p>
<pre><code>final IWebBrowser browser = PlatformUI.getWorkbench().getBrowserSupport().createBrowser( ... );
browser.openURL(url);
</code></pre>
| <p>Do you mean launch an external windows (IE, FireFox, ...) outside eclipse, or opening an internal "<a href="http://kickjava.com/src/org/eclipse/swt/browser/Browser.java.htm" rel="nofollow noreferrer">Browser</a>" composite ?</p>
<p>Because on the internal side, the <a href="http://kickjava.com/src/org/eclipse/help/... | 38,425 |
<p>What is the best technique for catching ALL exceptions thrown within JavaScript?</p>
<p>Obviously, the best technique is to use try...catch. But with ansynchronous callbacks and so forth, that can get tricky.</p>
<p>I know IE and Gecko browsers support window.onerror, but what about Opera and Safari?</p>
<p>Here... | <p>If you use a library like <a href="http://jquery.com/" rel="noreferrer">jQuery</a> for assigning all your event handlers, you can use a combination of <code>window.onerror</code> and wrapping the jQuery event handler code and on ready function with an error handling function (see: <a href="http://blogs.cozi.com/tech... | <p>I was also looking for error handling and stacktrace and logging for user actions this is what i found hope this also helps you
<a href="https://github.com/jefferyto/glitchjs" rel="nofollow">https://github.com/jefferyto/glitchjs</a></p>
| 25,198 |
<p>There are so many Linux distributions to choose from! What is the "best" linux flavor for a web hosting environment running primarily:
Apache HTTP, Tomcat or JBoss, MySQL and Alfresco (not necessarily all in the same instance).</p>
<p>Are there any significant differences in terms of ease of administration and con... | <p>They all use similar tools to administer things like webmin, and sshd.</p>
<p>What are you more familiar with. Red Hat based systems(fedora, mandriva) or Debian based systems(Ubuntu). This family divide will determine a few things. First rpm packaging vs deb packaging.</p>
<p>You also want to look at the level of ... | <p>You mentioned Linux and Java. You did <em>not</em> mention other things like an Appserver, LDAP server, DB Server. </p>
<p>With those things considered, you would be best off with Redhat, Fedora, CentOS and SUSE/OpenSUSE. Ubuntu will not hurt since they have a relationship with Sun but since JBoss has become part o... | 16,656 |
<p>Is there a way in C# to play audio (for example, MP3) direcly from a <a href="http://msdn.microsoft.com/en-us/library/system.io.stream%28v=vs.110%29.aspx" rel="noreferrer">System.IO.Stream</a> that for instance was returend from a WebRequest without saving the data temporarily to the disk?</p>
<hr>
<h3>Solution wi... | <p><strong>Edit: Answer updated to reflect changes in recent versions of NAudio</strong></p>
<p>It's possible using the <a href="https://github.com/naudio/NAudio" rel="noreferrer">NAudio</a> open source .NET audio library I have written. It looks for an ACM codec on your PC to do the conversion. The Mp3FileReader supp... | <p>I've always used FMOD for things like this because it's free for non-commercial use and works well.</p>
<p>That said, I'd gladly switch to something that's smaller (FMOD is ~300k) and open-source. Super bonus points if it's fully managed so that I can compile / merge it with my .exe and not have to take extra care ... | 22,336 |
<p>I have 1 table called urltracker that holds information about the number of times a specific url has been clicked. The table is structured into 4 columns id, urlclicked, referrer and timestamp. The urltracker creates another entry in the table every time a url has been clicked.</p>
<p>What i would like to do is dis... | <p>One thing to consider is using two tables - one table that holds the unique urls and another that stores the click information (and either using a unique sequence number to join them, or the url (since it is unique))</p>
<p>But to answer your query question - yes I would have one query to display URLs and a second ... | <p>You should be able to do something like this to get the totals for each URL:</p>
<pre><code>SELECT urlclicked, COUNT(urlclicked) AS total
FROM urltracker
GROUP BY urlclicked
</code></pre>
<p>Is this what you were after?</p>
| 49,443 |
<p>I have a web app that is heavily loaded in javascript and css. First time users log in it takes some time to load once it is downloading js etc. Then the caching will make everything faster.</p>
<p>I want my users to be aware of this loading time. How can I add some code to "show" some loading information while js ... | <p>You could show an overlay saying "loading..." and hide this the moment the downloads are complete.</p>
<pre><code><html>
<head>
... a bunch of CSS and JS files ...
<script type="text/javascript" src="clear-load.js"></script>
</head>
<body>
<... | <p>Sweet mother of mercy, Ricardo, how much Javascript and CSS are involved with this application?</p>
<p>You could, I guess, do something where you load the JS and CSS using an AJAX request and do nothing with them. This will load your JS and CSS files into the cache. You could do all of this on a "Loading" page, a... | 38,724 |
<p>Before anyone suggests scrapping the table tags altogether, I'm just modifying this part of a very large system, so it really wouldn't be wise for me to revise the table structure (the app is filled with similar tables).</p>
<p>This is a webapp in C# .NET - data comes in from a webservice and is displayed onscreen ... | <p>When you build the row in the databinding event, you can add in a unique identifier using say the id of the data field or something else that you use to make it unique.</p>
<p>Then you could use a client side method to expand collapse if you want to fill it with data in the beginning, toggling the style.display set... | <p><strike>just wrap the contents of the item template in an asp:Panel, then you have you have a unique id.</strike> Then throw in <a href="http://www.learningjquery.com/2007/03/accordion-madness" rel="nofollow noreferrer">some jquery</a> for some spice ;)</p>
<p><strong>edit</strong>: just noticed that you are using ... | 10,267 |
<p>I always wondered what different methods Google Desktop Search is using so that it uses least CPU and memory while indexing a computer containing more 100,000 files on an average.</p>
<p>In just few hours it has indexed the whole system and I did not see it eating up my CPU, memory etc.</p>
<p>If any of you have d... | <p>The trick is simple: It starts to work then very soon stops and just sits there in in memory, doing nothing. Of course it's then totally useless but at least, it keeps light and fast. Sorry, couldn't resist :-) I Switched to Windows Search 4.0 and I'm much happier about it.</p>
| <p>It doesn't...</p>
<p>I installed it on one computer, and quickly removed it because it was intrusive (although this can be probably configured) and hungry (particularly on a low end PC).</p>
<p>It is installed on a laptop near me right now, and if I compare it to a couple of small utilities I run permanently (Slic... | 24,487 |
<p>I've been attempting move a directory structure from one location to another in Subversion, but I get an <code>Item '*' is out of date</code> commit error. </p>
<p>I have the latest version checked out (so far as I can tell). <code>svn st -u</code> turns up no differences other than the mv commands.</p>
| <p>I sometimes get this with TortoiseSVN on windows. The solution for me is to <code>svn update</code> the directory, even though there are no revisions to download or update. It does something to the metadata, which magically fixes it.</p>
| <p>is more isyly make this:</p>
<p>1)i copy my modify code in a notepad.
2) next , update the file.
3) copy the code of notepad in a file updated.
4) commit in svn.</p>
| 11,359 |
<p>I am trying to get the <code>Edit with Vim</code> context menu to open files in a new tab of the previously opened Gvim instance (if any).</p>
<p>Currently, using <code>Regedit</code> I have modified this key:</p>
<pre><code>\HKEY-LOCAL-MACHINE\SOFTWARE\Vim\Gvim\path = "C:\Programs\Vim\vim72\gvim.exe" -p --remote-... | <p>Try setting it to: "C:\Programs\Vim \vim72\gvim.exe" -p --remote-tab-silent "%1" "%*"</p>
<p>See: <a href="http://www.vim.org/tips/tip.php?tip_id=1314" rel="noreferrer">http://www.vim.org/tips/tip.php?tip_id=1314</a></p>
<p>EDIT: As pointed out by Thomas, vim.org tips moved to: <a href="http://vim.wikia.com/" rel=... | <p>I would recommend trying <a href="http://cream.sourceforge.net/index.html" rel="nofollow noreferrer">Cream</a>.</p>
<p> Cream is a set of scripts and add-ons that sit on top of gVim. Cream doesn't change the appearance of gVim, but it does change the way it behaves.</p>
<p>One of those behaviours is a tabbed docum... | 9,306 |
<p>I recently had to solve this problem and find I've needed this info many times in the past so I thought I would post it. Assuming the following table def, how would you write a query to find all differences between the two?</p>
<p>table def:</p>
<pre><code>CREATE TABLE feed_tbl
(
code varchar(15),
name varchar(40... | <p>UNION will remove duplicates, so just UNION the two together, then search for anything with more than one entry. Given "code" as a primary key, you can say:</p>
<p><em>edit 0: modified to include differences in the PK field itself</em></p>
<p><em>edit 1: if you use this in real life, be sure to list the actual co... | <p>I would use a minor variation in the second <code>union</code>:</p>
<pre><code>where (ISNULL(feed_tbl.name, 'NONAME') <> ISNULL(data_tbl.name, 'NONAME')) OR
(ISNULL(data_tbl.status, 'NOSTATUS') <> ISNULL(feed_tbl.status, 'NOSTATUS')) OR
(ISNULL(data_tbl.update, '12/31/2039') <> ISNULL(feed_tbl.upd... | 5,084 |
<p>This has got to be something simple: I set up a frames page with two possible sources for the target frame based on a form with two options. I used the OnClick event to trap the user's click to show the appropriate page. It works fine in Internet Explorer 7, swapping the two source pages. FireFox 3 and Chrome sh... | <p>You are using getElementByID, but you aren't specifying IDs for your inputs. Perhaps consider this instead:</p>
<pre><code>function SwapInlineFrameSource(rdoButton)
{
rsiFrame = document.getElementById("RatesFrame");
rsiFrame.src = rdoButton.value;
}
<input type="radio" value="SantaCruzRates.htm" checked="c... | <p>I don't believe that getElementById works on frames in firefox. I have always used the frames["frameID"], which seems to work more consistently.</p>
| 35,008 |
<p>I am trying to pass a dataString to to an ajax call using JQuery. In the call, I construct the get parameters and then send them to the php page on the receiving end. The trouble is that the data string has ampersands in them and the HTML strict validator is chocking on it.</p>
<p>Here is the code:</p>
<pre><cod... | <p>Try putting your javascript inside a CDATA block like this:</p>
<pre><code><script type="text/javascript">
<![CDATA[
// content of your Javascript goes here
]]>
</script>
</code></pre>
<p>which should make it pass validation. To be extra safe you can add Javascript comments around the CDATA tag... | <p>i would try:</p>
<pre><code>var dataString = "email="+username+"&amp;password="+password+"&amp;remember="+remember;
</code></pre>
| 46,270 |
<p>As a novice in practicing test-driven development, I often end up in a quandary as to how to unit test persistence to a database.</p>
<p>I know that technically this would be an integration test (not a unit test), but I want to find out the best strategies for the following:</p>
<ol>
<li>Testing queries. </li>
<li... | <p>Look into DB Unit. It is a Java library, but there must be a C# equivalent. It lets you prepare the database with a set of data so that you know what is in the database, then you can interface with DB Unit to see what is in the database. It can run against many database systems, so you can use your actual databas... | <p>I would also mock the database, and check that the queries are what you expected. There is the risk that the test checks the wrong sql, but this would be detected in the integration tests</p>
| 2,426 |
<p>Yes we all get a <b>warm and fuzzy</b> feeling when we read about project specifications, and how they help keep a project <b>on time</b> and <b>within scope</b> etc etc.</p>
<p>Who here actually works for a company that keeps and up-to-date specification?</p>
<p>If you do, what are the reasons for this? Is the p... | <p>Cor.. <strong>What's a project spec?</strong></p>
<p>We tend to start out with an idea that has well defined timelines etc. then the sales team talk to the customer and promise the Earth. Our project spec then goes out the window!</p>
<p>So, we do not maintain a project spec mainly because:</p>
<ul>
<li>Sales pro... | <p>The best way to do this is to extract out the relevant bits of the func. / design spec. and then include them as "headers" in the actual code.</p>
<p>These headers can then be extracted using Javadoc or some such.</p>
<p>That way developers can update the "header" when they update the code and it keeps the whole p... | 45,652 |
<p>Sorry, that title just hurts. I'm wondering if there is a Linq to collections extension method that collapses the following code segment into a single line:</p>
<pre><code>public IEnumerable<Child> GetAllChildren(IEnumerable<Parent> parents){
var result = new List<Child>();
foreach(Parent p... | <p>Here's the obligatory method form.</p>
<pre><code>return parents
.SelectMany(p => p.Children);
</code></pre>
<p>And for two levels:</p>
<pre><code>return oldies
.SelectMany(grand => grand.Children)
.SelectMany(parent => parent.Children);
</code></pre>
| <p>This will work:</p>
<pre><code>public IEnumerable<Child> GetAllChildren(IEnumerable<Parent> parents)
{
return from parent in parents
from child in parent.Children
select child;
}
</code></pre>
<p>and then this:</p>
<pre><code>public IEnumerable<Child> GetAllChildren(IEn... | 25,131 |
<p>Assume you have some objects which have several fields they can be compared by:</p>
<pre><code>public class Person {
private String firstName;
private String lastName;
private String age;
/* Constructors */
/* Methods */
}
</code></pre>
<p>So in this example, when you ask if:</p>
<pre><cod... | <p>With Java 8: </p>
<pre><code>Comparator.comparing((Person p)->p.firstName)
.thenComparing(p->p.lastName)
.thenComparingInt(p->p.age);
</code></pre>
<p>If you have accessor methods:</p>
<pre><code>Comparator.comparing(Person::getFirstName)
.thenComparing(Person::getLastName)
... | <p>Its easy to do using <a href="http://code.google.com/p/guava-libraries/wiki/CommonObjectUtilitiesExplained#equals" rel="nofollow noreferrer">Google's Guava library</a>.</p>
<p>e.g. <code>Objects.equal(name, name2) && Objects.equal(age, age2) && ...</code></p>
<p>More examples:</p>
<ul>
<li><a href... | 48,263 |
<p>I believe it's the <code>File</code> class but I heard that is very expensive in memory.</p>
<p>Is there a better way to work with file paths?</p>
| <p>It's hard to say without knowing what you want to do, but please do not prematurely optimize. I doubt the memory use of a File object will be at all noticeable in your application.</p>
| <p>The only time I know where File uses a lot of memory is when you use File.list()...</p>
<p>See these for some solutions:</p>
<p><a href="https://stackoverflow.com/questions/354703/is-there-a-workaround-for-javas-poor-performance-on-walking-huge-directories">Is there a workaround for Java’s poor performance on walk... | 48,133 |
<p>I can select all the distinct values in a column in the following ways:</p>
<ul>
<li><code>SELECT DISTINCT column_name FROM table_name;</code></li>
<li><code>SELECT column_name FROM table_name GROUP BY column_name;</code></li>
</ul>
<p>But how do I get the row count from that query? Is a subquery required?</p>
| <p>You can use the <code>DISTINCT</code> keyword within the <a href="http://technet.microsoft.com/en-us/library/ms175997%28v=sql.90%29.aspx" rel="noreferrer"><code>COUNT</code></a> aggregate function:</p>
<pre><code>SELECT COUNT(DISTINCT column_name) AS some_alias FROM table_name
</code></pre>
<p>This will count only... | <p>Count(distinct({fieldname})) is redundant</p>
<p>Simply Count({fieldname}) gives you all the distinct values in that table. It will not (as many presume) just give you the Count of the table [i.e. NOT the same as Count(*) from table]</p>
| 17,109 |
<p>Is there a native c++ variable type that's "bigger" than a double?<br>
float is 7<br>
double is 15 (of course depending on the compiler)<br>
Is there anything bigger that's native, or even non-native?</p>
| <p>C++ has <code>long double</code>, but there is no guarantee that it's any more precise than a plain <code>double</code>. On an x86 platform, usually <code>double</code> is 64 bits, and <code>long double</code> is either 64 or 80 bits (which gives you 19 significant figures, if I remember right).</p>
<p>Your mileage... | <p>Boost 1.53 or higher has multiprecision.</p>
<p><a href="http://www.boost.org/doc/libs/1_54_0/libs/multiprecision/doc/html/index.html" rel="nofollow">http://www.boost.org/doc/libs/1_54_0/libs/multiprecision/doc/html/index.html</a></p>
| 32,113 |
<p>I have a tree representation of pages in a CMS application. I understand how to persist the tree in the database. However, I don't have a good way to:</p>
<p>A) Reorder subpages under a particular parent page.<br>
B) Provide a UI implementation that allows the user to change the order.</p>
<p>Any suggestions?</p>
| <p><a href="http://www.javaworld.com/javaworld/jw-12-2004/jw-1220-toolbox.html" rel="nofollow noreferrer">Write custom appenders for log4j</a></p>
| <p>May I suggest that you leverage the existing SyslogAppender?</p>
| 6,934 |
<p>I'm programming a class that implements the observable pattern (not the interface) and I'm thinking about whether or not the copy constructor should also copy the listeners.</p>
<p>On the one hand the copy constructor should create an instance that is as close as possible to the original instance so that it can be ... | <p>Don't copy. The listeners are not aware of the new object and are not expecting to receive messages related to it.</p>
| <p>Don't copy.</p>
| 39,400 |
<p>(using the IMAP commands, not with the assistance of any other mail package)</p>
| <p>I'm not sure how well-versed you are in imap-speak, but basically after login, "SELECT" the source mailbox, "COPY" the messages, and "EXPUNGE" the messages (or "DELETE" the old mailbox if it is empty now :-).</p>
<pre><code>a login a s
b select source
c copy 1 othermbox
d store 1 +flags (\Deleted)
e expunge
</code>... | <p>I guess you COPY the message to the new folder and then delete (EXPUNGE) it in the old one.</p>
<p><a href="http://www.networksorcery.com/enp/rfc/rfc3501.txt" rel="nofollow noreferrer">RFC3501</a></p>
<p><strong>HINT</strong> There's no DELETE command that does what you mean, you have to flag the message as delete... | 14,868 |
<p>Is it currently possible with pre release of ironruby to run rubygems? It seems as if I have to set an environment variable to find them? </p>
| <p>You've been able to run rubygems under IronRuby for quite a while now. Simply download and install the latest <a href="http://www.codeplex.com/Wikipage?ProjectName=ironruby" rel="noreferrer">IronRuby from codeplex</a>, and run <code>igem</code> on the command line</p>
<hr />
<blockquote>
<p><strong>Original Answer:<... | <p>if you set ENV['GEM_PATH'] correctly before using rubygems, then gems will work <em>sometimes</em> under IronRuby. I'm actually looking at fixing this right now.</p>
<p>Also, this kind of question is probably better suited for the <a href="http://rubyforge.org/mail/?group_id=4359" rel="nofollow noreferrer">IronRub... | 6,676 |
<p>I'm using a <code>std::map</code> (VC++ implementation) and it's a little slow for lookups via the map's find method. </p>
<p>The key type is <code>std::string</code>.</p>
<p>Can I increase the performance of this <code>std::map</code> lookup via a custom key compare override for the map? For example, maybe <code>... | <p>First, turn off all the profiling and DEBUG switches. These can slow down STL immensely.</p>
<p>If that's not it, part of the problem may be that your strings are identical for the first 80-90% of the string. This isn't bad for map, necessarily, but it is for string comparisons. If this is the case, your search ... | <p><code>hash_map</code> is not standard, try using <code>unordered_map</code> available in tr1 (which is available in boost if your tool chain doesn't already have it).</p>
<p>For small numbers of strings you might be better using <code>vector</code>, as <code>map</code> is typically implemented as a tree.</p>
| 31,950 |
<p>I'm looking for an explanation or good free online resources about the organization of memory and memory management in Windows systems.</p>
| <p>You can buy this (old) book, (the actual Windows architecture hasn't really changed much in 10 years) for a penny (used):</p>
<p><a href="https://rads.stackoverflow.com/amzn/click/com/1572316772" rel="noreferrer" rel="nofollow noreferrer">Inside Windows NT</a></p>
<p>Here's the up-to-date version:</p>
<p><a href=... | <p>In MSDN, some information is located here: <a href="http://msdn.microsoft.com/en-us/library/aa366525(VS.85).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/aa366525(VS.85).aspx</a></p>
| 43,280 |
<p>I've been asked to create a Delphi compatible dll in C++ to do simple 64bit memory management.</p>
<p>The background is that the system in Delphi needs to allocate a lots of chunks of memory that would go well outside 32bit addressable space. The Delphi developer explained to me that he could not allocate memory wi... | <p>Only 64 bit processes can address 64 bit memory. A 64 bit process can only load 64 bit dlls and 32 bits processes can only load 32 bits dlls. Delphi's compiler can only make 32 bits binaries.</p>
<p>So a 32 bits Delphi exe can not load your 64 bit c++ dll. It could load a 32 bit c++ dll, but then that dll wouldn't ... | <p>You might also want to add a way to pin and unpin that 64-bit pointer to a 32-bit memory address. Since this is Delphi, I'm pretty sure it's Windows specific, so you might as well use <a href="http://msdn.microsoft.com/en-us/library/aa366527(VS.85).aspx" rel="nofollow noreferrer">Address Windowing Extensions</a>. Th... | 5,448 |
<p>Can anyone give me an example of what the Artifact paths setting defined for a build configuration could look like if I want to create two artifacts dist and source where I am using the sln 2008 build runner and building my projects using the default bin/Release?</p>
<pre>
**/Source/Code/MyProject/bin/Release/*.* =... | <p>So you'll just need:</p>
<pre><code>Source\Code\MyProject\bin\Release\* => dist
Source\**\* => source
</code></pre>
<p>This will put all the files in release into a artifact folder called dist and everything in Source into a artifact folder called source.</p>
<p>If you have subfolders in Release try:</p>
<... | <p>According to TeamCity documentation; it should be like this:</p>
<pre><code>file_name|directory_name|Ant-like wildcard [ => target_directory ]
</code></pre>
<p>So.. </p>
<pre><code>Source\Code\MyProject\bin\Release|**\* => dist (| not \)
</code></pre>
| 21,997 |
<p>What is the clearest explanation of what computer scientists mean by "the naive implementation"? I need a good clear example which will illustrate — ideally, even to non-technical people — that the naive implementation may <em>technically</em> be a functioning solution to the problem, but <em>practically</em> be ut... | <p>I'd try to keep it away from computers altogether. Ask your audience how they find an entry in a dictionary. (A normal dictionary of word definitions.)</p>
<p>The naive implementation is to start at the very beginning, and look at the first word. Oh, that's not the word we're looking for - look at the next one, etc... | <p>A O(n!) algorithm.</p>
<pre><code>foreach(object o in set1)
{
foreach(object p in set1)
{
// codez
}
}
</code></pre>
<p>This will perform fine with small sets and then exponentially worse with larger ones.</p>
<p>Another might be a naive Singleton that doesn't account for threading.</p>
<pre>... | 32,108 |
<p>I can't figure out a use case for being able to annotate interfaces in Java. </p>
<p>Maybe someone could give me an example?</p>
| <p>I've used it in Spring to annotate interfaces where the annotation should apply to all subclasses. For example, say you have a Service interface and you might have multiple implementations of the interface but you want a security annotation to apply regardless of the annotation. In that case, it makes the most sen... | <p>You could use it for contract style programming - go one step further than just defining the interface (types and method names) and also define some semantics (contents of the types, preconditions, postconditions).</p>
<p>I'd have to check up on how annotations work in Java though, but this stuff could easily be do... | 17,634 |
<p>Is there a javascript function I can use to detect whether a specific silverlight version is installed in the current browser?</p>
<p>I'm particularly interested in the Silverlight 2 Beta 2 version. I don't want to use the default method of having an image behind the silverlight control which is just shown if the S... | <p>Include Silverlight.js (from Silverlight SDK)</p>
<p><code>Silverlight.isInstalled("4.0")</code></p>
<hr>
<p><strong>Resource:</strong></p>
<p><a href="http://msdn.microsoft.com/en-us/library/cc265155(vs.95).aspx" rel="nofollow noreferrer"><a href="http://msdn.microsoft.com/en-us/library/cc265155(vs.95).aspx" re... | <pre><code>var hasSilverlight = Boolean(window.Silverlight);
var hasSilverlight2 = hasSilverlight && Silverlight.isInstalled('2.0');
</code></pre>
<p>Etc....</p>
| 14,590 |
<p>Here is my code: </p>
<pre><code>ThreadStart threadStart = controller.OpenFile;
Thread thread = new Thread(threadStart);
thread.Start();
</code></pre>
<p>In the OpenFile function, my code looks like:</p>
<pre><code>System.Console.Error.WriteLine("Launching");
</code></pre>
<p>The code in OpenFile doesn't get exe... | <p>As others pointed out - first try to produce a test program which demonstrates the behavior.</p>
<p>If you can't, try to troubleshoot by:
1. Call the method directly, not in thread, and see how it behaves.
2. Comment out the rest of the code besides the System.Error.WriteLine line</p>
<p>If you still see the the d... | <p>My first step would be to build a test version of the app that calls the OpenFile function the normal way (without using threads), and see if you still get the delay.</p>
| 35,213 |
<p>How do you do your Hibernate session management in a Java Desktop Swing application? Do you use a single session? Multiple sessions?</p>
<p>Here are a few references on the subject:</p>
<ul>
<li><a href="http://www.hibernate.org/333.html" rel="noreferrer">http://www.hibernate.org/333.html</a></li>
<li><a href="htt... | <p>Single session. Start transaction when you need to do a set of operations (like update data after dialog box OK button), commit the tx at the end. The connection though is constantly open (since it's the same session), and thus all opportunities for caching can be used by both Hib and RDBMS.</p>
<p>It may also be a... | <p>Use one session per thread (<a href="http://www.hibernate.org/42.html#A6" rel="nofollow noreferrer">doc</a>) and a version or timestamp column to allow optimistic concurrency and thereby avoiding session-to-instance conflicts. Attach instances to session when needed unless you need long running transactions or a res... | 33,720 |
<p>Probably the question sounds a little strange; however, I am looking for a filament which is breakable and not so steady and reliable as PLA. I want to print parts similar to the following gears for instance (They are from Lego, a children's toy). <a href="https://i.stack.imgur.com/dsvt3.png" rel="nofollow noreferre... | <h2>deliberate/planned obsolescence is the term you look for</h2>
<p>If you design parts that break after some time, you plan their obsolescence. That you do by a deliberate choice of material and working conditions. Designing a part that will break after a certain time can be done by choosing the correct stresses that... | <p>This metod will be difficult with gears but doable. Print cold and slightly under extruded. This will cause part to fail in layers. You may need to print the part on side to ensure a non functioning gear. Use PLA or PETG. Breaking TPU is next to impossible.</p>
| 1,197 |
<p>What are the main differences when using ABS over PLA and vice versa?</p>
| <p>Paraphrasing <a href="http://www.protoparadigm.com/news-updates/the-difference-between-abs-and-pla-for-3d-printing/">this</a> site. Feel free to add suggestions in the form of comments and I will try to incorporate them.</p>
<p>Summary</p>
<ul>
<li>ABS: Stronger, machinable, more flexible, and more temperature
res... | <p>PLA (polylactic acid) melts at a lower temp and does not warp AS BADLY when cooled. It is non-toxic (in USA it comes from cornstarch, beets in some countries, or tapioca root)
It is less flexible than ABS, could rip or crumble.</p>
<p>ABS (Acrylonitrile Butadiene Styrene) is a harder and more sturdy plastic. (What ... | 86 |
<p>Is there any clear documentation on the binary formats used to serialize the various MFC data structures? I've been able to view some of my own classes in a hex editor and use Java's ByteBuffer class to read them in (with automatic endianness conversions, etc).</p>
<p>However, I am currently running into issues wh... | <p>Since MFC ships with source code I would create a test MFC application that serializes a CObArray and step through the serialization code. This should give you all the information you need.</p>
| <p>I agree with jmatthias: use the MFC source code.</p>
<p>There's also <a href="http://msdn.microsoft.com/en-us/library/32wxt301%28VS.71%29.aspx" rel="nofollow noreferrer">this page</a> on MSDN that may be useful.</p>
| 7,911 |
<p>What's the regex to match a square bracket? I'm using <code>\\]</code> in a pattern in <code>eregi_replace</code>, but it doesn't seem to be able to find a <code>]</code>...</p>
| <p><code>\]</code> is correct, but note that PHP itself ALSO has <code>\</code> as an escape character, so you might have to use <code>\\[</code> (or a different kind of string literal).</p>
| <p>You problem may come from the fact you are using eregi_replace with the first parameter enclosed in simple quotes:</p>
<pre><code> '\['
</code></pre>
<p>In <a href="http://us2.php.net/manual/en/language.types.string.php#language.types.string.syntax.double" rel="nofollow noreferrer">double quotes</a>, though, it co... | 45,435 |
<p>As I've only ever used Visual Studio for .NET development, I would like to expand my horizons and see what else there is on offer as an alternative to it. So what in your opinion is the best alternative to Visual Studio? Is there a viable alternative?</p>
| <p>If you're into C# and VB.Net and don't mind open source then you could use <a href="http://www.icsharpcode.net/OpenSource/SD/" rel="noreferrer">SharpDevelop</a>. It does a pretty good job!</p>
| <p>For .NET development, VS2008 is the best but if you want to check for another best IDE, <strong><a href="http://www.eclipse.org/downloads/" rel="nofollow noreferrer">Eclipse</a></strong> probably the best after VS if you are rating it among the IDEs, ofcourse you cant do .NET development in Eclipse though</p>
| 40,044 |
<p>WSPBuilder</p>
<p>Version: 0.9.8.0830
Created by Carsten Keutmann
GPL License 2007</p>
<p>Install and deploying [MYDLL]
Unable to deploy solution
Inner exception(1): This solution contains one or more assemblies targeted for the global assembly cache. You should use a strong name for any assembly that will be in t... | <p>I had the same issues but what worked for me was to delete all the files in the bin and obj folder and then rebuild the WSP.</p>
| <p>I'm experiencing the same issue, one solution, multiple projects, the one failing to compile is using an object from another project.</p>
<p>I've tried clearing the bin & obj folder, as well as restarting the server. I think I'll copy the files dll to the gac using gacutil instead.</p>
| 48,507 |
<p>Which is better? Or use and OR mapper with SP's? If you have a system with SP's already, is an OR mapper worth it? </p>
| <p>I like ORM's because you don't have to reinvent the wheel. That being said, it completely depends on your application needs, development style and that of the team.</p>
<p>This question has already been covered <a href="https://stackoverflow.com/questions/50346/why-is-parameterized-sql-generated-by-nhibernate-just-... | <p>I personally have found that SP's tend to be faster performance wise, at least for the large data items that I execute on a regular basis. But I know many people that swear by OR tools and wouldn't do ANYTHING else.</p>
| 10,856 |
<p>I'm new to this JSF world, please bear with me if I'm asking some silly thing</p>
<p>i'm using UI tags for my application and I have a scenario that I need to generate a calendar control to make the user to select the date I followed the ui tags documentation and wrote the code like this:</p>
<pre><code> <tabl... | <p>I got the solution by myself - the issue is with the javascript code. it reads the javascript from themes.jar, which i placed in web-inf/lib folder still it was unable to access that. so I extracted the same and placed it in web-inf and it's working fine</p>
| <p>The component is coming from which JSF library?
In others words, what do you have at the beginning of your XHTML file?</p>
<p>The only library I know is coming from <a href="https://facelets.dev.java.net/" rel="nofollow noreferrer">Facelets</a>, and it does not provide any component!</p>
<p>In addition, if calD... | 43,187 |
<p>How can I <strong>pre pend</strong> (insert at beginning of file) a file to all files of a type in folder and sub-folders using <code>Powershell</code>?</p>
<p>I need to add a standard header file to all <code>.cs</code> and was trying to use <code>Powershell</code> to do so, but while I was able to append it in a ... | <p>Here is a very simple example to show you one of the ways it could be done.</p>
<pre><code>$Content = "This is your content`n"
Get-ChildItem *.cs | foreach-object {
$FileContents = Get-Content -Path $_
Set-Content -Path $_ -Value ($Content + $FileContents)
}
</code></pre>
| <p>Have no idea, but if you have the code to append just do it the other way round. Something like</p>
<ol>
<li>rename existing file,</li>
<li>create an empty file named the same as above </li>
<li>append header to new empty file,</li>
<li>append renamed file to previous,</li>
<li>delete renamed file</li>
</ol>
| 9,959 |
<p>I'm using Zend Studio 6.1 for Eclipse, which comes bundled with the Subversive plug-in.</p>
<p>My repo layout is:</p>
<pre><code>/trunk/
/branches/
/tags/
</code></pre>
<p>My application code is in:</p>
<pre><code>/trunk/application
</code></pre>
<p>I'm trying to add some view templates in:</p>
<pre><code>/tru... | <p>It's actually fine to say "Yes" to this warning.</p>
<p>A common layout for version control is to have 3 root folders:</p>
<blockquote>
<pre><code>/trunk
/tags
/branches
</code></pre>
</blockquote>
<p>Once a trunk build has been released, the current contents of trunk are copied into a folder (e.g. "April 2008 ve... | <p>The <strong>trunk</strong> should usually represent the current working copy of your application, <strong>branches</strong> are there to support working on a previous version of an application (like they do with Firefox for example, they still release bug fixes to version 2.0 while the last version is in the trunk. ... | 49,031 |
<p>I'm trying to write an app using Ruby on Rails and I'm trying to achieve the following:</p>
<blockquote>
<p>The app needs to receive UDP messages coming in on a specific port (possibly 1 or more per second) and store them in the database so that the rest of my Rails app can access it. </p>
</blockquote>
<p>I wa... | <p>You definitely don't want to load the Rails stack for each incoming request -- that would be way too slow; you'll want to use something lower-level to handle the incoming connections. You might look at the internals of Webrick to see a simple server daemon coded in ruby -- or, if you want something more performant, ... | <p>I have an application that does something similar to this, i.e receiving lots of messages on a port and persisting them to the database. We addressed a number of issues when evolving the design of our database, including the fact that we must not lose messages even if the database was unavailable for some reason.</p... | 15,214 |
<p>For my application, I want a <a href="http://java.sun.com/docs/books/tutorial/uiswing/components/combobox.html" rel="nofollow noreferrer">Combo Box</a> that displays its elements when dropped down as a <a href="http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html" rel="nofollow noreferrer">Tree</a>. ... | <p>I think I would implement this as a JTree component in a JViewPort, followed by an expansion button. When collapsed, it would look like a combo box. When you click the expansion button, the viewport would expand, allowing you to scroll and select a node in the JTree. When you selected the node, the view port woul... | <p>Override the getListCellRendererComponent methode and create the components in level order.
For every tree level move the painted string 3 spaces to right.</p>
<p>Example:</p>
<p>1</p>
<p>. a</p>
<p>. b</p>
<p>2</p>
<p>. c</p>
<p>The original implementation you can look from</p>
<pre><code>public Compo... | 46,648 |
<p>I'm concerned that this might be working on an NP-Complete problem. I'm hoping someone can give me an answer as to whether it is or not. And I'm looking for more of an answer than just yes or no. I'd like to know why. If you can say,"This is basically this problem 'x' which is/is not NP-Complete. (wikipedia link)"</... | <p>Your description seems to indicate that you are just interested in whether two nodes are connected, not finding the shortest path.</p>
<p>Finding if two nodes are connected is relatively easy:</p>
<pre><code>Create two sets of nodes: toDoSet and doneSet
Add the source node to the toDoSet
while (toDoSet is not em... | <p>Any graph shortest path algorithm will be overkill if all you need is to find if a node is connected to another. A good Java library that accomplishes that is <a href="http://jgrapht.org/" rel="nofollow noreferrer">JGraphT</a>. It's usage is quite simple, here's an example of an Integer graph:</p>
<pre><code>public... | 46,159 |
<p>I have a table that represents a series of matches between ids from another table as follows:</p>
<pre><code>CREATE TABLE #matches (
asid1 int,
asid2 int
)
insert into #matches values (1,2)
insert into #matches values (1,3)
insert into #matches values (3,1)
insert into #matches values (3,4)
insert into #matche... | <p>It appears that a <a href="http://en.wikipedia.org/wiki/Disjoint-set_data_structure" rel="nofollow noreferrer">Disjoint-set</a> is what you need to solve this. Here is a <a href="http://www.emilstefanov.net/Programming/DisjointSets.aspx" rel="nofollow noreferrer">listing</a> of a C# and C++ implementation.</p>
| <p>If this can be done at all within SQL, it's going to be insanely difficult. You should analyze that table in whatever programming language you're using.</p>
| 49,955 |
<p>An interesting problem that no doubt someone here has come across before. </p>
<p>I'm reading a CSV file that contains some values wrapped in quotes, I came across a problem today were my app couldn't read the file as the value was wrapped in cury quotation marks and not square quotation marks. Is this an encoding... | <p>I suspect the data was copied and pasted from a document created using Word.</p>
<p>By default Word 2003 will convert "straight quotes" to what it calls “smart quotes”. You can override this behavior using Tools/AutoCorrect Options/AutoFormat as you type.</p>
| <p>I suspect the data was copied and pasted from a document created using Word.</p>
<p>By default Word 2003 will convert "straight quotes" to what it calls “smart quotes”. You can override this behavior using Tools/AutoCorrect Options/AutoFormat as you type.</p>
| 43,317 |
<p>I am redesigning a command line application and am looking for a way to make its use more intuitive. Are there any conventions for the format of parameters passed into a command line application? Or any other method that people have found useful?</p>
| <p>I see a lot of Windows command line specifics, but if your program is intended for Linux, I find the <a href="http://www.gnu.org/prep/standards/html_node/Command_002dLine-Interfaces.html" rel="noreferrer">GNU command line standard</a> to be the most intuitive. Basically, it uses double hyphens for the long form of a... | <p>-operation [parameters] -command [your command] -anotherthings [otherparams]....</p>
<p>For example,</p>
<pre><code>YourApp.exe -file %YourProject.prj% -Secure true
</code></pre>
| 13,407 |
<p>There seems to be lots of different ways to register assemblies with the GAC, as in, they 'work'. However, what's the "proper" way of doing it?</p>
<p>In response to Lou Franco (and gacutil):</p>
<p>I'm using Gacutil for development, but it seems to me to be not the proper way to install it, since gacutil isn't i... | <p>With Wix I would do something like this:</p>
<pre>
<DirectoryRef Id="MyDirectory" >
<Component Id="MyComponent" Guid="PUT-GUID-HERE" DiskId="1">
<File Id="MyAssembly" Name="MyAssembly.dll" Assembly=".net" KeyPath="yes" Source="MyAssembly.dll" />
</Component>
</DirectoryRe... | <p>copy directly to %WINDIR%\Assembly.</p>
<p>Advantage: Straightforward.</p>
<p>Disadvantage: AFAIK, %WINDIR%\Assembly just <em>happens</em> to be where it is right now, and it's location is subject to change. This would make it break in future versions of windows or if that folder's behavior chaneges. This proba... | 25,139 |
<p>I am trying to encode/decode MIME headers in Ruby.</p>
| <p>Ruby has Base64 methods in core, just do</p>
<pre><code>require "base64"
</code></pre>
<p>and use <code>Base64.decode64</code> and <code>Base64.encode64</code>. For quoted-printable, you could use the following code <a href="http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/133587" rel="nofollow norefer... | <p>If the mime content is related to emails you might also want to check out TMAil...</p>
<p><a href="http://tmail.rubyforge.org/" rel="nofollow noreferrer">http://tmail.rubyforge.org/</a></p>
<p>It has a nice approach to parsing out email attachments and multi-part messages and what not.</p>
| 48,793 |
<p>ToolStrip with MenuStrip or RibbonBar? </p>
<hr>
<p>It combines both of the controls. It also have a TabPages navigation, contextual tabs, etc. However the RibbonBar is a very complex control and when you open a new document in for example Word2007 the half of the screen you see a Ribbon Bar. It is not cool. When ... | <p>Ribbon Bar</p>
| <p>It boils down to what you're trying to navigate and how complex do you want the Navigation to work.</p>
<p>I prefer to use simple existing applications to base my programs.</p>
<p>Thus for the most part I use either the MenuStrip + X ToolStrips or just a simple ToolStrip if a menu is more involved than is required... | 24,028 |
<p>What won't plugins wont work with vb c# studio express?</p>
| <p>The Express editions do not support Visual Studio Addins.</p>
| <p>Students qualify for <a href="https://downloads.channel8.msdn.com/" rel="nofollow noreferrer">free Microsoft software</a>, which include Visual Studio Pro.</p>
| 15,235 |
<p>The Python <a href="http://www.python.org/doc/2.5.2/lib/datetime-datetime.html" rel="noreferrer"><code>datetime.isocalendar()</code></a> method returns a tuple <code>(ISO_year, ISO_week_number, ISO_weekday)</code> for the given <code>datetime</code> object. Is there a corresponding inverse function? If not, is the... | <p>Python 3.8 added the <a href="https://docs.python.org/3/library/datetime.html#datetime.date.fromisocalendar" rel="noreferrer">fromisocalendar()</a> method:</p>
<pre><code>>>> datetime.fromisocalendar(2011, 22, 1)
datetime.datetime(2011, 5, 30, 0, 0)
</code></pre>
<p>Python 3.6 added the <a href="https://d... | <p><em>EDIT: ignore this, the edge cases are a pain. Go with Ben's solution.</em></p>
<p>Ok, on closer inspection I noticed that <code>strptime</code> has <code>%W</code> and <code>%w</code> parameters, so the following works:</p>
<pre><code>def fromisocalendar(y,w,d):
return datetime.strptime( "%04dW%02d-%d"%(y,w... | 39,090 |
<p>I have a command that runs fine if I ssh to a machine and run it, but fails when I try to run it using a remote ssh command like : </p>
<pre><code>ssh user@IP <command>
</code></pre>
<p>Comparing the output of "env" using both methods resutls in different environments. When I manually login to the machine an... | <p>There are different types of shells. The SSH command execution shell is a non-interactive shell, whereas your normal shell is either a login shell or an interactive shell. Description follows, from man bash:</p>
<pre>
A login shell is one whose first character of argument
zero is a -, or one start... | <p>I found an easy resolution for this issue was to add
source /etc/profile
to the top of the script.sh file I was trying to run on the target system.
On the systems here, this caused the environmental variables which were needed by script.sh to be configured as if running from a login shell.</p>
<p>In one of the pr... | 26,582 |
<p>I would like to add the following MIME type to a site run by <code>Apache</code>:</p>
<pre><code><mime-mapping>
<extension>jnlp</extension>
<mime-type>application/x-java-jnlp-file</mime-type>
</mime-mapping>
</code></pre>
<p><strong>That is the Tomcat format.</strong></p>
<... | <pre><code>AddType application/x-java-jnlp-file .jnlp
</code></pre>
<p>Note that you might not actually be allowed to do that.</p>
<p>See also the <a href="http://HTTPd.Apache.Org/docs/trunk/mod/mod_mime.html#addtype" rel="noreferrer" title="mod_mime - AddType">documentation of the AddType directive</a> and the <a hr... | <p>You should be able to just add this line:</p>
<pre><code>AddType application/x-java-jnlp-file .jnlp
</code></pre>
| 5,384 |
<p>Often I want to add a value to a table or update the value if its key already exists. This can be accomplished in several ways, assuming a primary or unique key is set on the 'user_id' and 'pref_key' columns in the example:</p>
<p><strong>1. Blind insert, update if receiving a duplicate key error:</strong></p>
<pr... | <p>have a look at the ON DUPLICATE KEY syntax in <a href="http://dev.mysql.com/doc/refman/5.0/en/insert-select.html" rel="nofollow noreferrer">http://dev.mysql.com/doc/refman/5.0/en/insert-select.html</a></p>
<pre><code>INSERT [LOW_PRIORITY | HIGH_PRIORITY] [IGNORE]
[INTO] tbl_name [(col_name,...)]
SELECT ...
[ ON DUP... | <p>The first way is the preferred way as far as I know.</p>
| 18,048 |
<p>In Flex I'm using the following code to allow sorting in a DataGrid (the data is paged and sorted serverside).</p>
<pre>
private function headerReleaseHandler(event:DataGridEvent):void
{
var column:DataGridColumn = DataGridColumn(event.currentTarget.columns[event.columnIndex]);
... | <p>There is an example here if this is what you are looking for:
<a href="http://blog.flexexamples.com/2008/02/28/displaying-the-sort-arrow-in-a-flex-datagrid-control-without-having-to-click-a-column/" rel="noreferrer">http://blog.flexexamples.com/2008/02/28/displaying-the-sort-arrow-in-a-flex-datagrid-control-without-... | <p>in the above code what does "this" refer to is it the datagrid because I am confused by this.query.SortField , I am assuming 'this' and "query' are your own custom objects. and why are you checking for count. what count is that.</p>
<p>Regards
-Mohan</p>
| 41,821 |
<p>Jeff mentioned the concept of 'Progressive Enhancement' when talking about using JQuery to write stackoverflow.</p>
<p>After a quick Google, I found a couple of high-level discussions about it.</p>
<p>Can anyone recommend a good place to start as a programmer.</p>
<p>Specifically, I have been writing web apps in ... | <p>As you've said</p>
<blockquote>
<p>To me, that seems a bit overkill, since viewing the site without Javascript will probably break most of it.</p>
</blockquote>
<p>This isn't progressive enhancement. Progressive enhancement is when the site works perfectly without JavaScript or CSS, and <em>then</em> adding (lay... | <p>Going at it from the other direction is sometimes referred to as graceful degradation. This is usually needed when the site is built first with the enhanced functionality afforded by the various technologies then modified to degrade gracefully for browsers with those technologies are not available.</p>
<p>It is al... | 2,459 |
<p>Wanted to convert</p>
<pre><code><br/>
<br/>
<br/>
<br/>
<br/>
</code></pre>
<p>into</p>
<pre><code><br/>
</code></pre>
| <p>You can do this with a regular expression:</p>
<pre><code>preg_replace("/(<br\s*\/?>\s*)+/", "<br/>", $input);
</code></pre>
<p>This if you pass in your source HTML, this will return a string with a single <br/> replacing every run of them.</p>
| <p>You probably want to use a Regular Expression. I haven't tested the following, but I believe it's right. </p>
<pre><code>$text = preg_replace( "/(<br\s?\/?>)+/i","<br />", $text );
</code></pre>
| 16,168 |
<p>Kind of a basic question but I'm having troubles thinking of a solution so I need a push in the right direction.</p>
<p>I have an input file that I'm pulling in, and I have to put it into one string variable. The problem is I need to split this string up into different things. There will be 3 strings and 1 int. ... | <p>I usually use something like this:</p>
<pre><code>void split(const std::string &s, char delim, std::vector<std::string> &elems) {
std::stringstream ss(s);
std::string item;
while(std::getline(ss, item, delim)) {
elems.push_back(item);
}
}
</code></pre>
<p>you can use it like t... | <p>A comfortable solution that I found is not uncommon is the following prototype:</p>
<pre><code>string SplitToken(string & body, char separator)
</code></pre>
<p>which returnsd everything up to the first occurence of separator, and removes that part including the separator. </p>
<p>"My" MFC - CString-based imp... | 42,066 |
<pre><code>abstract class Foo
{
private List<Object> container;
private bool update;
Foo Foo()
{
container = new List<object>();
update = false;
}
public abstract Bar CreateBar();
public void BeginUpdate()
{
if (!update)
{
Thread... | <p>Your code does not do what you think it does. This method</p>
<pre><code>public List<Object> Objects
{
get
{
lock (container)
{
return this.container;
}
}
}
</code></pre>
<p>Does not hold the lock after it has returned the value. So your loop is not locked.</p>... | <p>krosenvald is correct, the lock on the Objects accessor is released as soon as the property returns the pointer to the container object... </p>
<p>In you code</p>
<pre><code>List<Objects> objects = foo_instance.Objects;
foreach (Object o in objects)
{
Thread.Sleep(31173);
}
</code></pre>
<p>The lock... | 42,276 |
<p>I have a class which constructor takes a <a href="http://commons.apache.org/lang/api-2.3/org/apache/commons/lang/enums/Enum.html" rel="nofollow noreferrer">Jakarta enums</a>. I'm trying to find how I can easily inject it via an <a href="http://www.springframework.org/" rel="nofollow noreferrer">Spring</a> XML aplica... | <p>Check out the <code><util:constant></code> tag in Spring. It will require you to add the schema to your xml definition. So you would wind up with the following:</p>
<pre><code><bean id="myService" class="MyService">
<constructor-arg index="0">
<util:constant static-field="MyEnum.MY_FIRST... | <p>I voted-up Spencer's answer but found that this will work as well. In this example, you just need to specify the <strong>index, type</strong>, and <strong>name</strong> in the constructor-arg.</p>
<pre><code><bean id="myService" class="MyService">
<constructor-arg index="0" type="com.package.MyEnum" value... | 40,610 |
<p>I want to get the size of a drive (or UNC path pointing to a partition would be nice, but not required), as well as free space for said drive (or UNC path). This doesn't need to work cross platform; only in Windows.</p>
<p>I know it's easy to do in Java 6, but that's not an option; I'm stuck with Java 5.</p>
<p>I... | <p>One way to do it would be to use fsutil on the command line. It returns something like this:</p>
<pre><code>D:\>fsutil fsinfo ntfsinfo c:
NTFS Volume Serial Number : 0xd49cf9cf9cf9ac5c
Version : 3.1
Number Sectors : 0x0000000004a813ff
Total Clusters : ... | <p>You could use the <a href="http://support.hyperic.com/display/SIGAR/Home" rel="nofollow noreferrer">SIGAR</a> library, which gives you native access on many platforms.</p>
| 31,294 |
<p>Which C#/.NET Dependency Injection frameworks are worth looking into?
And what can you say about their complexity and speed.</p>
| <p><strong>edit</strong> (not by the author): There is a comprehensive list of IoC frameworks available at <a href="https://github.com/quozd/awesome-dotnet/blob/master/README.md#ioc" rel="nofollow noreferrer">https://github.com/quozd/awesome-dotnet/blob/master/README.md#ioc</a>:</p>
<ul>
<li><a href="https://github.com... | <p>I've used <a href="http://www.springframework.net/" rel="nofollow noreferrer">Spring.NET</a> in the past and had great success with it. I never noticed any substantial overhead with it, though the project we used it on was fairly heavy on its own. It only took a little time reading through the <a href="http://www.sp... | 4,152 |
<p>By "code snippet execution", I mean the ability to write a few lines of code, run and test it without having to fire up an IDE and create a dummy project.</p>
<p>It's incredibly useful for helping people with a small code sample without creating a project, compiling everything cleanly, sending them the code snippet... | <p>For C, the in-browser <a href="http://codepad.org/" rel="nofollow noreferrer">http://codepad.org/</a> is truly excellent. Executes code and everything.</p>
| <p>In Ruby you can use the <a href="http://en.wikipedia.org/wiki/Interactive_Ruby_Shell" rel="nofollow noreferrer">Interactive Ruby Shell</a>.</p>
<p>It also looks like the guru's at the mono project have gone and made a <a href="http://www.mono-project.com/CsharpRepl" rel="nofollow noreferrer">C# interactive</a>. YAY... | 33,066 |
<p>Is there a better/simpler way to find the number of images in a directory and output them to a variable?</p>
<pre><code>function dirCount($dir) {
$x = 0;
while (($file = readdir($dir)) !== false) {
if (isImage($file)) {$x = $x + 1}
}
return $x;
}
</code></pre>
<p>This seems like such a long way of doin... | <p>Check out the Standard PHP Library (aka SPL) for DirectoryIterator:</p>
<pre><code>$dir = new DirectoryIterator('/path/to/dir');
foreach($dir as $file ){
$x += (isImage($file)) ? 1 : 0;
}
</code></pre>
<p>(FYI there is an undocumented function called iterator_count() but probably best not to rely on it for now I... | <p>Your answer seems about as simple as you can get it. I can't think of a shorter way to it in either PHP or Perl.</p>
<p>You might be able to a system / exec command involving ls, wc, and grep if you are using Linux depending how complex isImage() is.</p>
<p>Regardless, I think what you have is quite sufficient. ... | 27,721 |
<p>I need to get the "td" element of a table. I do not have the ability to add a mouseover or onclick event to the "td" element, so I need to add them with JQUERY.</p>
<p>I need JQUERY to add the mouseover and onclick event to the all "td" elements in the table.</p>
<p>Thats what I need, maybe someone can help me ou... | <pre><code>$(function() {
$("table#mytable td").mouseover(function() {
//The onmouseover code
}).click(function() {
//The onclick code
});
});
</code></pre>
| <p>Work off of the following code to get you started. It should do just what you need. </p>
<pre><code>$("td").hover(function(){
$(this).css("background","#0000ff");
},
function(){
$(this).css("background","#ffffff");
});
</code></pre>
<p>You can use <a href="http://www.ibm.com/developerworks/web/library/wa-jqu... | 19,409 |
<p>I find that most books concerning C++ templates don't tell anything about whether it's possible or not to use initialization list in constructor of a template class.</p>
<p>For example, I have code like this:</p>
<pre><code>template <class T>
class Stack {
T* data;
std::size_t count;
std::size_t ... | <p>Yes. Did the compiler tell you otherwise?</p>
| <p>I've just tried and VS2008 says that it's OK, but it seems a little bit strange because some great authors don't do that (Eckel, for example, in his "Thinking in C++").</p>
| 28,568 |
<p>My application dynamically loads assemblies at runtime from specific subfolders. These assemblies are compiled with dependencies to other assemblies. The runtime trys to load these from the application directory. But I want to put them into the modules directory.</p>
<p>Is there a way to tell the runtime that the d... | <p>One nice approach I've used lately is to add an event handler for the AppDomain's AssemblyResolve event.</p>
<pre><code>AppDomain currentDomain = AppDomain.CurrentDomain;
currentDomain.AssemblyResolve += new ResolveEventHandler(MyResolveEventHandler);
</code></pre>
<p>Then in the event handler method you can load ... | <p>You can use the <code><codeBase></code> element found in the application configuration file. More information on "<a href="http://msdn.microsoft.com/en-us/library/15hyw9x3.aspx" rel="nofollow noreferrer">Locating the Assembly through Codebases or Probing</a>".</p>
<blockquote>
<p>Well, the loaded assembly d... | 4,205 |
<p>I just ran into an issue with Python's imaplib and Gmail's authentication mechanism:</p>
<pre><code>>>> import imaplib
>>> imap = imaplib.IMAP4_SSL('imap.gmail.com', 993)
>>> imap.authenticate('bobdole@gmail.com', 'Bob Dole likes your style!')
Traceback (most recent call last):
...
imap... | <p>Instead of</p>
<pre><code>>>> imap.authenticate('bobdole@gmail.com', 'Bob Dole likes your style!')
</code></pre>
<p>use</p>
<pre><code>>>> imap.login('bobdole@gmail.com', 'Bob Dole likes your style!')
</code></pre>
| <p>I found the solution on <a href="http://codeclimber.blogspot.com/2008/06/using-ruby-for-imap-with-gmail.html" rel="nofollow noreferrer">this helpful blog post</a>. Although Gmail doesn't support AUTHENTICATE, it does support the LOGIN capability, like so:</p>
<pre><code>>>> imap.login('bobdole@gmail.com', ... | 45,826 |
<p><a href="https://medifacd.relayhealth.com/Pharmacies/MediFacD_Pharmacies_PayerSheet_E1December2006.htm#Examples" rel="nofollow noreferrer" title="Medicare Eligibility EDI Example Responses">Medicare Eligibility EDI Example Responses</a> is what I'm trying to match.</p>
<p>I have a string that looks like this:</p>
... | <p>I think what you want is positive lookahead, not negative, so that you find the key-colon combo ahead of the current position, but you don't consume it. This appears to work for your test example:</p>
<pre><code>([\w]{2})\:(.+?)(?=[\w]{2}\:|$)
</code></pre>
<p>Yielding:</p>
<pre>
LN: SMITHbbbbbbbb
FN: SAMANTHAbb
... | <p>This works in JavaScript (I always fire up the Error Console in Firefox to play around with regular expressions) but it should also work fine in .NET:</p>
<pre>([^:]{2}):((?:[^:](?!(?:[^:]:)))+)</pre>
<p>It uses negative lookahead:</p>
<pre>
( -> start capturing first token (the label)
[^:]{2} -> two non-colo... | 48,622 |
<p>Although I'm doubtful, I'm curious as to whether it's possible to extract primitive-type template parameters from an existing type, perhaps using RTTI.</p>
<p>For example:</p>
<pre><code>typedef std::bitset<16> WordSet;
</code></pre>
<p>Would it be possible to extract the number 16 in the above code without... | <p>It's not possible in general to pick arbitrary template parameters.</p>
<p>However, the usual way you do it is this:</p>
<pre><code>template<int N>
struct foo {
static const int value = N;
};
</code></pre>
<p>and for types</p>
<pre><code>template<typename T>
struct foo {
typedef T type;
};
</code... | <p>In the case of <code>std::bitset</code>, you can just use the <code>size()</code> member function:</p>
<pre><code>size_t sz = oh_my_word.size(); // sz is now 16
</code></pre>
<p>In the general case, you can define a member function which returns the size in a similar manner:</p>
<pre><code>template <int N>... | 38,628 |
<p>I would like to know how .NET teams out there are handling assembly reference paths when not everybody can immediately upgrade to a x64 operating system. The key issue right now is x64 versions of Windows will plant 32-bit installations into C:\Program Files (x86)\ instead of the regular C:\Program Files. This means... | <p>Either install the assemblies in the GAC on each machine, or have a special LIB folder under your solution root that contains all your 3rd party assemblies. The LIB folder is what I've used for the last few years myself. I even put the assemblies in source control so other/new developers get them without having to t... | <p>This is more of a follow-on question than an answer, but I thought this group might know.</p>
<p>What do we do if we have some devs working on 64 bit machines and some on 32 bit machines, but we need to reference unmanaged assemblies that need to be in x86 for half the team and x64 for the other half? Is there a so... | 30,475 |
<p>I would like to store data persistently for my application, but I don't really need a full blown relational database. I really could get by with a basic "cache"-like <em>persistent</em> storage where the structure is just a (key, value) pair.</p>
<p>In lieu of a database what are my best, scalable options?</p>
| <p>There's always <a href="http://www.sqlite.org/" rel="noreferrer">SQLite</a>, a database that's stored in a file. SQLite already has built-in concurrency, so you don't have to worry about things like file locking, and it's really fast for reads.</p>
<p>If, however, you are doing lots of database changes, it's best t... | <p>If you want something really scalable, I wouldn't opt for a flat or XML file. As your data grows, it could kill your performance.</p>
<p>If you will have a lot of data <em>at some stage</em>, I would still opt for a database - I would take a look at something like <a href="http://www.sqlite.org/" rel="nofollow nore... | 42,262 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.