input
stringlengths 51
42.3k
| output
stringlengths 18
55k
|
|---|---|
Is there step-by-step tutorial on setting up CruiseControl.NET? <p>What to do automatic nightly build of .NET web application and upload to the test server. </p>
<p>Or, if this tool is overkill, please suggest something else.</p>
|
<p>I have found this great tutorial: <a href="http://weblogs.asp.net/jdanforth/pages/How-to-Hook-Up-a-VS.NET-2005-Solution-With-CruiseControl.NET-in-a-Few-Minutes.aspx">How to Hook Up a VS.NET 2005 Solution With CruiseControl.NET in a Few Minutes</a>.
It's short but uses a real .Net project to illustrate the set up.</p>
<p>After that refine your configuration by reading each relevant section of <a href="http://confluence.public.thoughtworks.org/display/CCNET/Configuring+the+Server">CruiseControl.NET : Configuring the Server</a></p>
<p>And for a really nice and recent tutorial check <a href="http://www.dougrohm.com/blog/post/2006/01/29/Integrating-MSBuild-with-CruiseControlNET.aspx">Integrating MSBuild with CruiseControl.NET</a>. Very good one!</p>
|
Special Characters in URL <p>We're currently replacing all special characters and spaces in our URLs with hypens (-). From an SEO and readability point-of-view this works fine. However, in some cases, we are feeding parts of the URL into a search after stripping the hyphens out. The problem occurs when the search term <em>should</em> have hyphens as it returns no results when they get stripped. We could modify the search algorithm we're using but this will slow it down (especially bad as we're using it with an AJAX-ed search box and this needs to be <em>fast</em>). </p>
<p>The best option to deal with this, as far as we can tell is to replace pre-existing hyphens with pipes (|). I have a feeling that this will have a negative impact on SEO for those terms as the pipe character will be treated as a part of the word and not as a separator. As far as I can tell, the <em>only</em> characters that are considered to be separators are hyphens and forward slashes (/).</p>
<p>So my questions are:</p>
<ol>
<li>Are there alternative characters we can use to represent hyphens?</li>
<li>If we can't use any other characters, how much impact will using a pipe character have on a search engine?</li>
</ol>
<p>Cheers,
Zac</p>
|
<p>Would ~ (<a href="http://en.wikipedia.org/wiki/Tilde" rel="nofollow">tilde</a>) work?</p>
<p>Edit: Google now treats <a href="http://news.cnet.com/8301-10784_3-9748779-7.html" rel="nofollow">underscores and dashes as word separators</a> so you can use dashes as dashes and underscores as spaces.</p>
|
Is it better to have one UpdatePanel around multiple controls or separate UpdatePanels? <p>I have a web form that has multiple ListBoxes, TextBoxes, DropDowns. If I put one UpdatePanel around the whole page, I noticed the page is slower. Is this because, every control is being updated? If I put different UpdatePanels around each control, I noticed the page has a better response. Is it right to assume that this is because I have more control of which parts of the page are updated based on selections from ListBoxes and DropDowns for example?</p>
<p>Thanks,</p>
<p>X</p>
|
<p>each update panel generates a round-trip to the server (i assume you're using a timer or something to cause this)</p>
<p>the general rule would be to group controls in an update panel that <em>must</em> change together, otherwise separate update panels makes more sense</p>
|
Using Lists in C# <p>I am an upper level Software Engineering student currently in a Data Structures and Algorithms class. Our professor wants us to write a program using the List structure found in the C++ STL. I have been trying to use C# more and more, and was wondering if the ArrayList structure in .NET is a good substitute for the STL List implementation. </p>
|
<p>Unless you're stuck with .NET 1.1, use <code>List<T></code> instead of <code>ArrayList</code>. But what are you fundamentally concerned about? Suppose you didn't have List to refer to - what do you need the appropriate data structure to do?</p>
|
What's the best way for a .NET Compact Framework executable to delete itself? <p>I'd like my .NET Compact Framework app to delete itself after it finishes executing. What's the best way to do this?</p>
<p>On a Windows machine it's possible to do this using a .bat file, but that's not an option on mobile devices.</p>
|
<p>In Windows Mobile there is the directory:</p>
<p>\application data\volatile</p>
<p>This directory is kept for as long as the device has power.</p>
<p>So what we do is:</p>
<ol>
<li>copy a exe over to this directory, or a sub-directory (I normally use a sub-directory to make sure we don't clash with another application).</li>
<li>run the exe from this directory.</li>
<li>delete the files you want.</li>
<li>(optional) soft-reset.</li>
</ol>
<p>For compatiblity with all devices you should use the "SHGetSpecialFolderPath" function with CSIDL_APPDATA to get the application data directory and append "\volatile" to it.</p>
|
Why does Hibernate/JDBC/MySQL drop connections after a day or so? <p>I have several server processes that once in a while respond to messages from the clients and perform read-only transactions.</p>
<p>After about a few days that the servers are running, they stop working correctly and when I check it turns out that there's a whole bunch of messages about the connection being closed.</p>
<p>When I checked it out, it turned out that hibernate by default works in some sort of development mode where connections are dropped after a few hours, and I started using c3po for connection pooling. </p>
<p>However, even with c3po, I get that problem about 24 hours or so after the servers are started.</p>
<p>Has anyone encountered that problem and knows how to address it? I'm not familiar enough with the intricacies of configuring hibernate.</p>
|
<p>The MySQL JDBC driver times out after 8 hours of inactivity and drops the connection.</p>
<p>You can set <code>autoReconnect=true</code> in your JDBC URL, and this causes the driver to reconnect if you try to query after it has disconnected. But this has side effects; for instance session state and transactions cannot be maintained over a new connection.</p>
<p>If you use <code>autoReconnect</code>, the JDBC connection is reestablished, but it doesn't automatically re-execute your query that got the exception. So you do need to catch <code>SQLException</code> in your application and retry queries.</p>
<p>Read <a href="http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-configuration-properties.html">http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-configuration-properties.html</a> for more details.</p>
|
SharePoint searching external database <p>We're looking at doing a MOSS 2007 site which will have a fairly dynamic component (an external product catalog). The external produces will be stored in a database (not managed by SharePoint) and all interaction will occur via Web Parts.</p>
<p>Is it possible to configure the SharePoint search to index the textual content <em>and</em> the external database? Or can a custom search provider be written which is also used to query the external database?</p>
|
<p>The Business Data Catalog is intended as the solution in this case.
A BDC solution is crawlable out of the box. </p>
<p>Unfortunately the BDC requires the Enterprise licence for SharePoint, a hefty price increase.</p>
<p>Any other solution will require an html interface to the database either by including the data inside the SharePoint webpages themselves or a custom set of pages.</p>
<p>I have not tried using a custom search provider so I cannot make a comment on doing that.</p>
<p>It is easy enough to include searching on both content sources as OOB SharePoint provides the ability to distinguish between content sources and has the ability to create search scopes that allow rules based on content type or url to be created.</p>
|
PageRequestManager is undefined <p>I am seeing this error intermittently. My app throws PageRequestManager is undefined and so fails to load. Oddly enough this only happens in firefox, ie loads fine. Anyone know what this error means. I've been working on the app for some time and I just started seeing this today.</p>
|
<p>It probably means that there is a javascript error somewhere on the page that hits FF but not IE. Do you have FireBug installed in FF and can you see if there a javascript error that is causing the javascript to fail to be completely parsed?</p>
|
Using Emacs to recursively find and replace in text files not already open <p>As a follow-up to <a href="http://stackoverflow.com/questions/269812/how-to-quickly-get-started-at-using-and-learning-emacs">this question</a>, it's trying to find out how to do something like this which should be easy, that especially stops me from getting more used to using Emacs and instead starting up the editor I'm already familiar with. I use the example here fairly often in editing multiple files.</p>
<p>In Ultraedit I'd do Alt+s then p to display a dialog box with the options: Find (includes using regular expressions across multiple lines), Replace with, In Files/Types, Directory, Match Case, Match Whole Word Only, List Changed Files and Search Sub Directories. Usually I'll first use the mouse to click-drag select the text that I want to replace.</p>
<p>Using only Emacs itself (on Windows XP), without calling any external utility, how to replace all foo\nbar with bar\nbaz in <code>*.c</code> and <code>*.h</code> files in some folder and all folders beneath it. Maybe Emacs is not the best tool to do this with, but how can it be done easily with a minimal command?</p>
|
<ol>
<li><code>M-x find-name-dired</code>: you will be prompted for a root directory and a filename pattern.</li>
<li>Press <code>t</code> to "toggle mark" for all files found.</li>
<li>Press <code>Q</code> for "Query-Replace in Files...": you will be prompted for query/substitution regexps.</li>
<li>Proceed as with <code>query-replace-regexp</code>: <code>SPACE</code> to replace and move to next match, <code>n</code> to skip a match, etc.</li>
</ol>
|
MySQL C API using results <p>I am using the MySQL C API to query the database and I have the results stored in MYSQL_ROW types. I am able to print the results to the console with</p>
<pre><code>printf("%s", row[0]);
</code></pre>
<p>however, according to the MySQL C API documentation, I cannot use them as null-terminated strings.</p>
<p>At the bottom of <a href="http://dev.mysql.com/doc/refman/5.0/en/c-api-function-overview.html" rel="nofollow">the function overview</a>, they say I can "extract" the information with <code>mysql_store_result()</code> or <code>mysql_use_result()</code>. However, I am still confused as to how this is done.</p>
<p>Ideally, I want to use the results as a string so I can do stuff like <code>strcmp</code>, but otherwise I definitely need to use the information somehow with those two functions.</p>
<p>Can somebody show me an example of how to do this?</p>
|
<p>Basically, you call mysql_store_result() or mysql_use_result() to access the result set, the former loads all the rows into memory on the client side, the latter accesses rows one at a time from the server. If you use mysql_use_result(), you need to call mysql_fetch_row() to access each row until the function returns NULL. Each successful call to mysql_fetch_row() will return a MYSQL_ROW which you can use to access the individual field values.</p>
<p>Since the fields are not nul-terminated, you need to use mysql_fetch_lengths() to get the lengths of each of the fields so that you can copy them somewhere else via memcpy, etc.</p>
<p>Since the field values are not nul-terminated you will need to add your own NUL character when you make the copy if you want to use it as a string. Be aware that the field values may contain binary data, so if you do treat it as a string, functions that expect a C string will stop processing data if it encounters a nul-character in the data.</p>
<p>Here is an example from the documentation that should help you put all this together:</p>
<pre><code>MYSQL_ROW row;
unsigned int num_fields;
unsigned int i;
num_fields = mysql_num_fields(result);
while ((row = mysql_fetch_row(result)))
{
unsigned long *lengths;
lengths = mysql_fetch_lengths(result);
for(i = 0; i < num_fields; i++)
{
printf("[%.*s] ", (int) lengths[i],
row[i] ? row[i] : "NULL");
}
printf("\n");
}
</code></pre>
|
LinkedList remove method <p>What is a doubly linked list's remove method?</p>
|
<p>The same algorithm that <a href="http://stackoverflow.com/questions/270950/linkedlist-remove-method#270962">Bill the Lizard</a> said, but in a graphical way :-)</p>
<p><img src="http://www.jaffasoft.co.uk/feature/ll/fig4.gif" alt="Remove From Linked List" /></p>
|
Automate SSH without using public key authentication or expect(1) <p>Is there a way to pass a password to ssh automatically. I would like to automatically ssh to a server <b>without</b> using public key authentication or expect scripts, by somehow getting ssh to read the password from stdin or a file.</p>
<p>The reason it has to be that way is that I would like to backup my files to a server using rsync/ssh running as a cron job. This server mounts my home directory <i>after</i> it authenticates me, so using public key authentication does not work since ~/.ssh isn't available until after the login is successful. expect(1) is out of the question because I would like to run it as a cron job, and since cron jobs don't run under a terminal the combination of expect/ssh just doesn't work. I do not have root access to that server, and it would be difficult to get the admins to make any changes to the way things work there.</p>
|
<blockquote>
<p>expect is out of the question because I would like to run it as a cron job,
and since cron jobs don't run under a terminal the combination of expect/ssh
just doesn't work</p>
</blockquote>
<p>You can run expect scripts from cron, at least you can with expect libraries like "pexpect" for Python. I just tested this to confirm, running a pexpect scp/ssh script from cron and I was able to successfully scp a file from a Python script running in cron. </p>
<p>Example code: </p>
<pre><code>#!/usr/bin/python
import pexpect
FILE="/path/to/file"
REMOTE_FILE=""
USER="user"
HOST="example.com"
PASS="mypass"
COMMAND="scp -oPubKeyAuthentication=no %s %s@%s:%s" % (FILE, USER, HOST, REMOTE_FILE)
child = pexpect.spawn(COMMAND)
child.expect('password:')
child.sendline(PASS)
child.expect(pexpect.EOF)
print child.before
</code></pre>
|
jetty - reload tag file in jar <p>I have my main web project and a common project which houses my tag files. Currently I use jetty in exploded structure and I jar up my common project with my tag files and place into <code>web-inf/lib</code>.</p>
<p>When I make a change to my tag file, I can rejar and place into <code>web-inf/lib</code> again, though jetty is failing.</p>
<pre><code>javax.servlet.ServletException: org.apache.jasper.JasperException: PWC6033: Unable to compile class for JSP
</code></pre>
<p>How can I set up jetty so I can rejar my tag files without restarting the server?</p>
|
<p>A possible reason Jetty is unable to compile the JSP file is because it's running under a JRE instead of a JDK. It needs access to the compiler (which is not part of the JRE just the JDK) to turn JSP source into bytecode (with a Servlet step in between).</p>
|
Ruby on Rails plugin for showing line numbers in log for SQL queries <p>Does anybody know any plugin, that can show line numbers for SQL queries in Rails logs? Something like this:</p>
<pre><code>User Load (0.003154) SELECT * FROM `users` WHERE (`users`.`id` = 1) - (user.rb, line 24)
</code></pre>
<p>Thanks!</p>
|
<p>This plugin puts the stack trace in your logs. As Daniel mentions it would be tricky to determine the line you wanted but I suspect you could work something out, and the trace itself may be good enough.</p>
<p><a href="https://github.com/ruckus/active-record-query-trace" rel="nofollow">https://github.com/ruckus/active-record-query-trace</a></p>
<p>Be careful to set it up so you can turn it on and off. I used this for awhile, and while useful for tracking down specific bugs, it drove me nuts if it was on all the time.</p>
|
How can I make datagrid height is equal to data content in Adobe Flex <p>In adobe Flex datagrid height is equally to fix height . I want to make datagrid height is depend data . </p>
|
<p>You can set each row of the datagrid to fit based on the contents of a particular column of that row by setting the "variableRowHeight" attribute to true on the datagrid and setting the "wordWrap" attribute to true on the dataGridColumn that will contain the variable height content.</p>
|
What is the most useful type of java.awt.image.BufferedImage for off-screen rendering? <p>I am creating a buffered image that is going to be a snapshot of a JComponent (via paint()) and rendered inside an <a href="http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/ImageIcon.html" rel="nofollow">ImageIcon</a>. There are a large amount of types in the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/awt/image/BufferedImage.html#BufferedImage%28int,%20int,%20int%29" rel="nofollow"><code>BufferedImage(int width, int height, int imageType)</code></a> constructor, but which one should I use? </p>
<p>I am sure that any of them would work, but which ones are better than the others? How should I pick one? And Why?</p>
|
<p>See <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/awt/GraphicsConfiguration.html#createCompatibleImage(int,%20int)">GraphicsConfiguration.createCompatibleImage(int, int)</a> for a helper to create a BufferedImage of a "good" type among the many available types.</p>
<p>How to get your hands on a GraphicsConfiguration instance to make this call? It depends on where your code is executing. See the <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/awt/class-use/GraphicsConfiguration.html">many methods</a> for getting your hands on a GraphicsConfiguration via methods like getGraphicsConfiguration() or getDeviceConfiguration().</p>
|
How to configure CruiseControl.NET to build one project on a remote server <p>I have a build server running CruiseControl.NET. It works well for the 7 projects that are configured to run on that server (let's call it server A).</p>
<p>Now I have a new project that I wish to build on a different server (server B), but I want it to appear in the same ccnet dashboard as the existing projects. </p>
<p>How do I configure CCNet for this scenario?</p>
|
<p>In <code>dashboard.config</code> (default location is <code>c:\Program Files\CruiseControl.NET\webdashboard\dashboard.config</code>) take a look at the <a href="http://confluence.public.thoughtworks.org/display/CCNET/Servers+Configuration+Block" rel="nofollow">Servers Configuration Block</a>:</p>
<pre><code> <servers>
<server name="local" url="tcp://localhost:21234/CruiseManager.rem"
allowForceBuild="true" allowStartStopBuild="true" />
</servers>
</code></pre>
<p>It allows you to configure the remote servers you want to report on - just add another <code><server /></code> node.
To force the changes to appear on your CruiseControl.NET dashboard, edit the web.config file in the same folder and save it. Refresh the dashboard web page.</p>
|
GZipStream And DeflateStream will not decompress all bytes <p>I was in need of a way to compress images in .net so i looked into using the .net GZipStream class (or DeflateStream). However i found that decompression was not always successful, sometimes the images would decompress fine and other times i would get a GDI+ error that something is corrupted.</p>
<p>After investigating the issue i found that the decompression was not giving back all the bytes it compressed. So if i compressed 2257974 bytes i would sometimes get back only 2257870 bytes (real numbers).</p>
<p>The most funny thing is that sometimes it would work. So i created this little test method that compresses only 10 bytes and now i don't get back anything at all.</p>
<p>I tried it with both compression classes GZipStream and DeflateStream and i double checked my code for possible errors. I even tried positioning the stream to 0 and flushing all the streams but with no luck.</p>
<p>Here is my code:</p>
<pre><code> public static void TestCompression()
{
byte[] test = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
byte[] result = Decompress(Compress(test));
// This will fail, result.Length is 0
Debug.Assert(result.Length == test.Length);
}
public static byte[] Compress(byte[] data)
{
var compressedStream = new MemoryStream();
var zipStream = new GZipStream(compressedStream, CompressionMode.Compress);
zipStream.Write(data, 0, data.Length);
return compressedStream.ToArray();
}
public static byte[] Decompress(byte[] data)
{
var compressedStream = new MemoryStream(data);
var zipStream = new GZipStream(compressedStream, CompressionMode.Decompress);
var resultStream = new MemoryStream();
var buffer = new byte[4096];
int read;
while ((read = zipStream.Read(buffer, 0, buffer.Length)) > 0) {
resultStream.Write(buffer, 0, read);
}
return resultStream.ToArray();
}
</code></pre>
|
<p>You need to <code>Close()</code> the <code>ZipStream</code> after adding all the data you want to compress; it retains a buffer of unwritten bytes internally (even if you <code>Flush()</code>) that needs to be written.</p>
<p>More generally, <code>Stream</code> is <code>IDisposable</code>, so you should also be <code>using</code> each... (yes, I know that <code>MemoryStream</code> isn't going to lose any data, but if you don't get into this habit, it will bite you with other <code>Stream</code>s).</p>
<pre><code>public static byte[] Compress(byte[] data)
{
using (var compressedStream = new MemoryStream())
using (var zipStream = new GZipStream(compressedStream, CompressionMode.Compress))
{
zipStream.Write(data, 0, data.Length);
zipStream.Close();
return compressedStream.ToArray();
}
}
public static byte[] Decompress(byte[] data)
{
using(var compressedStream = new MemoryStream(data))
using(var zipStream = new GZipStream(compressedStream, CompressionMode.Decompress))
using (var resultStream = new MemoryStream())
{ ... }
}
</code></pre>
<p>[edit : updated re comment]
Re not <code>using</code> things like <code>MemoryStream</code> - this is always a fun one, with lots of votes on either side of the fence: but ultimatey...</p>
<p>(rhetorical - we all know the answer...) How is <code>MemoryStream</code> implemented? is it a byte[] (owned by .NET)? is it a memory-mapped file (owned by the OS)?</p>
<p>The reason you aren't <code>using</code> it is because you are letting knowledge of internal implementation details change how you code against a public API - i.e. you just broke the laws of encapsulation. The public API says: I am <code>IDisposable</code>; you "own" me; therefore, it is your job to <code>Dispose()</code> me when you are through.</p>
|
Can Visual Studio 2008 Standard create a single EXE that does not require .NET framework? <p>This is truly a beginner question, so I apologize in advance.</p>
<p>I have Visual Studio 2008 Standard installed and would like to create a small Windows application that does NOT require any .NET framework when run on computers. Does VS 2008 Standard support such a feature? Any pointers on how to accomplish this would be fantastic.</p>
<p>Thanks in advance.</p>
|
<p>Sure, you can definitely do this. You'll have to write your application in C++, though.</p>
<p>To get started, go to File | New, and under Project Types pick one of the options under Visual C++. For the minimal dependencies, I would suggest one of the Win32 options. Both the "Win32 Console Application" and the "Win32 Project" options appear to take you to the same wizard, which if you click Application Settings on the left lets you pick whether to create a console app or a windows app. A console app will run in a console window like cmd.exe, whereas a windows app will initially have no UI (you'll have to do the UI yourself).</p>
<p>Be aware that even if you don't depend on the .NET runtime, you'll still need to have the CRT dlls available on machines that will be running your program. The redistributables for these live under the Visual Studio install dir, which if you installed in the default location would be C:\Program Files\Microsoft Visual Studio 9.0\VC\redist.</p>
|
How to trigger rendering of JQuery treeview <p>I use Jquery tree plugin (<a href="http://docs.jquery.com/Plugins/Treeview" rel="nofollow">http://docs.jquery.com/Plugins/Treeview</a>) to render hierarchical data. I have coded additional functions which would allow user to interact with this data (like adding/deleting nodes, swapping nodes, etc...)</p>
<p>Currently this plugin supports that whenever you want to add any node, you can call following method,</p>
<p>$("#browser").treeview({
add: branches
});</p>
<p>here "branches" is JQuery object created with the HTML block, which would represent a particular node.</p>
<p>However, for delete and swapping of nodes, I use common JQuery functions like,</p>
<p>for delete,
$("#topnd2").remove();</p>
<p>for swapping,</p>
<p>var next = $("#topnd2").next();
$("#topnd2").insertAfter(next);</p>
<p>"topnd2" is an id of any particular tree node.</p>
<p>The nodes get deleted / swapped properly but the problem is the tree does not get rendered and therefore the tree images (mainly vertical lines denoting branches) are not set properly.</p>
<p>For example, if I delete the last node then that node will be removed from rendered treeview but the remaining sibling node should get L as branch line image but not | .</p>
<p>I tried calling </p>
<p>$("#browser").treeview(); </p>
<p>Please let me know your ideas.</p>
<p>Thanks,
Jatan</p>
|
<p>I found some workaround as given below,</p>
<p>Once the node is swapped up, virtually add its previous node to its child,</p>
<p>$("#browser").treeview({add:$("#topnd2").insertBefore(previous).next()});</p>
<p>If node is swapped down, virtuall add the current node to its next node.</p>
<p>$("#browser").treeview({add:$("#topnd2").insertAfter(next)});</p>
<p>currently it's working fine, will update this post, if I find any problems in this approach. Also please validate this approach if you know.</p>
<p>Regards,
Jatan</p>
|
Dynamic url for dojo combobox source <p>I'm trying to use a dojo combobox with an Ajax data source. What I have is </p>
<pre><code><div dojoType="dojo.data.ItemFileReadStore"
jsId="tags"
url="<%=ResolveClientUrl("~/Tag/TagMatches")%>" >
</div>
<select dojoType="dijit.form.ComboBox"
store="tags"
value=""
name="tagName">
</select>
</code></pre>
<p>Which does work except that I can't restrict the search set on the server side because I don't know how to change the url from which the data is pulled in order to specify a parameter. Any hints? </p>
|
<p>If I understand you correctly, you want the client to load different set of data from the server based on some general condition defined elsewhere.</p>
<p>Basically there is no need to have a <code><div></code> pre-defined. You can also create the <code>ItemFileReadStore</code> directly in JavaScript:</p>
<p>earlier...:</p>
<pre><code>var tagMatchUrlBase = '<%=ResolveClientUrl("~/Tag/TagMatches")%>';
</code></pre>
<p>later...:</p>
<pre><code>var tagMatchUrl = tagMatchUrlBase + "?f=" + escape(somefilterString);
var store = new dojo.data.ItemFileReadStore({url: tagMatchUrl});
tagName.store = store;
// maybe use store.fetch() to pre-select item #1
</code></pre>
|
Image loading icon for flash/flex? <p>You often see those little 'petal' animations while an image or .swf file is loading in a Flash / Flex application.</p>
<p>Do I have to steal this from someone or is there a standard one available from somewhere. i would think there is somethin standard because everyones looks the same!</p>
<p>Ideally I want a flex Image control that displays such an icon when it is loading for more than 1/4 second.</p>
|
<p>You can download that and other icons (as animated gifs) at <a href="http://www.ajaxload.info" rel="nofollow">AjaxLoad</a>.</p>
|
SVN - How to make an older revision the head revision? <p>One of the files in my current head revision got corrupted. I want to make an older revision of that file the head revision as usually people sync to head revsion in my project. How to do that?</p>
|
<p>You should revert all changes since that old reversion. In principle,</p>
<pre><code>svn merge -rHEAD:oldrev filename
svn commit -m "rolled back to oldrev"
</code></pre>
<p>should do. The later revisions are still there, but reverted.</p>
|
Captured variable in a loop in C# <p>I met an interesting issue about C#. I have code like below.</p>
<pre><code>List<Func<int>> actions = new List<Func<int>>();
int variable = 0;
while (variable < 5)
{
actions.Add(() => variable * 2);
++ variable;
}
foreach (var act in actions)
{
Console.WriteLine(act.Invoke());
}
</code></pre>
<p>I expect it to output 0, 2, 4, 6, 8. However, it actually outputs five 10s.</p>
<p>It seems that it is due to all actions referring to one captured variable. As a result, when they get invoked, they all have same output.</p>
<p>Is there a way to work round this limit to have each action instance have its own captured variable?</p>
|
<p>Yes - take a copy of the variable inside the loop:</p>
<pre><code>while (variable < 5)
{
int copy = variable;
actions.Add(() => copy * 2);
++ variable;
}
</code></pre>
<p>You can think of it as if the C# compiler creates a "new" local variable every time it hits the variable declaration. In fact it'll create appropriate new closure objects, and it gets complicated (in terms of implementation) if you refer to variables in multiple scopes, but it works :)</p>
<p>Note that a more common occurrence of this problem is using <code>for</code> or <code>foreach</code>:</p>
<pre><code>for (int i=0; i < 10; i++) // Just one variable
foreach (string x in foo) // And again, despite how it reads out loud
</code></pre>
<p>See section 7.14.4.2 of the C# 3.0 spec for more details of this, and my <a href="http://csharpindepth.com/Articles/Chapter5/Closures.aspx">article on closures</a> has more examples too.</p>
|
What should be included in a C# Programming Standard? <p>I've been tasked to write our department's C# Programming Standard (including guidelines). What sort of standards/guidelines should I include? I've already taken bits from various standards around the net (and pieces from Code Complete), but I'd like hear from developers in the field.</p>
<p>I've already got:
Naming Conventions - General/Variables/Classes/Methods/Interfaces/Controls</p>
<p>General Programming Practices - Documentation (comments etc), [WIP]</p>
<p>OO Programming Practices - Encapsulation, [WIP]</p>
<p>What else would be useful? What shouldn't I include?</p>
|
<p>Have you already suggested that everyone reads the "<a href="http://msdn.microsoft.com/en-us/library/czefa0ke.aspx" rel="nofollow">Design Guidelines for Class Library Developers</a>"? That covers the bulk of it. Other than that, I'd want to hammer home:</p>
<ul>
<li>You should very rarely be creating your own structs. Don't think of them as lightweight classes.</li>
<li>Structs should never be mutable.</li>
<li>Fields should always be private, apart from readonly fields where the type of the field is immutable</li>
<li>Only attempt lock-free programming if you're sure that a simpler solution will be too slow - and have evidence!</li>
<li>Readability is king</li>
<li>Be aware of cultural issues - in particular, read Microsoft's <a href="http://msdn.microsoft.com/en-us/library/ms973919.aspx" rel="nofollow">String Handling Recommendations</a></li>
</ul>
<p>I'll add more as I think of them...</p>
|
Automatic casting to string in C# and VB.NET <p>I could do this in C#..</p>
<pre><code>int number = 2;
string str = "Hello " + number + " world";
</code></pre>
<p>..and str ends up as "Hello 2 world".</p>
<p>In VB.NET i could do this..</p>
<pre><code>Dim number As Integer = 2
Dim str As String = "Hello " + number + " world"
</code></pre>
<p>..but I get an InvalidCastException "Conversion from string "Hello " to type 'Double' is not valid."</p>
<p>I am aware that I should use .ToString() in both cases, but whats going on here with the code as it is?</p>
|
<p>In VB I believe the string concatenation operator is & rather than + so try this:</p>
<pre><code>Dim number As Integer = 2
Dim str As String = "Hello " & number & " world"
</code></pre>
<p>Basically when VB sees + I suspect it tries do numeric addition or use the addition operator defined in a type (or no doubt other more complicated things, based on options...) Note that <code>System.String</code> doesn't define an addition operator - it's all hidden in the compiler by calls to <code>String.Concat</code>. (This allows much more efficient concatenation of multiple strings.)</p>
|
Cross-references and garbage collection <p>There is an application with an extensive object graph. This graph mainly consists of a set of subgraphs which are connected to the rest of the graph through the only reference. But internally each such subgraph has some number of cross-references among objects. Once in a while such a sub graph needs to be thrown away. Would it be enough just to set to null the only referece which points to that subgraph to make it eligible for garbage collection?</p>
<p>My concern is that internal cross-references may "protect" the entire subgraph from garbage collection. In other words, is the garbage collector wise enough to figure out that all references in a subgraph do not leave the boundaries of the subgraph and therefore entire subgraph can be purged.</p>
|
<p>As stated in this <a href="http://stackoverflow.com/questions/176745/circular-references-in-java">SO question</a>, circular reference is well managed.</p>
<p>Java does not do reference counting, it does "mark and sweep" garbage collecting. If follows all the active references to find out what objects are "reachable" and then it cleans up everything else.</p>
<p>References in objects not themselves reachable don't affect reachability so it doesn't matter if they are null or not.</p>
<p>About the only case in which setting a reference to null might, conceivably, have a significant effect is in discarding a very large object in the middle of a long running method. </p>
<p>In that case, setting null to the reference of the graph will help making an <strong>island of isolation</strong> (even for internal circular references) as described in this <a href="http://detailfocused.blogspot.com/2008/03/garbage-collection.html">article</a>.</p>
<p>You will find more details about the unreachable state in <a href="http://java.sun.com/docs/books/performance/1st_edition/html/JPAppGC.fm.html">The Truth About Garbage Collection</a>:</p>
<p><strong>Unreachable</strong></p>
<p>An object enters an unreachable state when no more strong references to it exist.<br />
When an object is unreachable, it is a candidate for collection. </p>
<p>Note the wording:<br />
Just because an object is a candidate for collection doesnât mean it will be immediately
collected. The JVM is free to delay collection until there is an immediate need for thememory being consumed by the object.</p>
<p>Itâs important to note that not just any strong reference will hold an object in memory. These must be references that chain from a garbage collection root. GC roots are a special class of variable that includes:</p>
<ul>
<li>Temporary variables on the stack (of any thread)</li>
<li>Static variables (from any class)</li>
<li>Special references from JNI native code</li>
</ul>
<p><strong>Circular strong references donât necessarily cause memory leaks</strong>.
Consider a code creating two objects, and assigns them references to each other.</p>
<pre><code>public void buidDog() {
Dog newDog = new Dog();
Tail newTail = new Tail();
newDog.tail = newTail;
newTail.dog = newDog;
}
</code></pre>
<p>Before the method returns, there are strong references from the temporary stack variables in the buildDog method pointing to both the Dog and the Tail.</p>
<p>After the buildDog method returns, the Dog and Tail both become unreachable from a root and are candidates for collection (although the VM might not actually collect these objects for an indefinite amount of time).</p>
|
Firefox 3 doesn't allow 'Back' to a form if the form result in a redirect last time <p>Greetings,</p>
<p>Here's the problem I'm having. I have a page which redirects directly to another page the first time it is visited. If the user clicks 'back', though, the page behaves differently and instead displays content (tracking session IDs to make sure this is the second time the page has been loaded). To do this, I tell the user's browser to disable caching for the relevant page. </p>
<p>This works well in IE7, but Firefox 3 won't let me click 'back' to a page that resulted in a redirect. I assume it does this to prevent the typical back-->redirect again loop that frustrates so many users. Any ideas for how I may override this behavior?</p>
<p>Alexey</p>
<p>EDIT: The page which we redirect to is an external site over which we have no control. Server-side redirects won't work because this wouldn't generate a 'back' button for in the browser. </p>
<p>To quote:</p>
<blockquote>
<p>Some people in the thread are talking about server-side redirect, and redirect headers (same thing)... keep in mind that we need client-side redirection which can be done in two ways:</p>
<p>a) A META header - Not recommended, and has some problems
b) Javascript, which can be done in at least three ways ("location", "location.href" and "location.replace()")</p>
<p>The server side redirect won't and shouldn't activate the back button, and can't display the typical "You'll be redirected now" page... so it's no good (it's what we're doing at the moment, actually.. where you're immediately redirected to the "lucky" page).</p>
</blockquote>
|
<p>I think the Mozilla team takes a step into the right direction by breaking this particularly annoying pattern. Finding a way around it somehow defies the purpose, doesn't it?</p>
<p>Instead of redirecting on first encounter, you could simply make your page render differently when a user hits it the first time. Should be easy enough on the server side, since you already have the code that is able to make that distinction.</p>
|
WIX: How can the registry key be changed based on the OS on which the installer is running? <p>I want to set registry keys in following way</p>
<p>if OS is Vista then
HKLM\MyKey1\MyValue=1
else
HKLM\MyKey2\MyValue=1</p>
<p>I know how to set Registry keys in WIX but it seems the condition cannot be set on element. </p>
|
<p>Technically speaking, you should use two different Components to install those Registry keys since they are completely different paths. Then you can Condition the Components with the VersionNT property.</p>
|
Strategy for Offline/Online data synchronization <p>My requirement is I have server J2EE web application and client J2EE web application. Sometimes client can go offline. When client comes online he should be able to synchronize changes to and fro. Also I should be able to control which rows/tables need to be synchronized based on some filters/rules. Is there any existing Java frameworks for doing it? If I need to implement on my own, what are the different strategies that you can suggest?</p>
<p>One solution in my mind is maintaining sql logs and executing same statements at other side during synchronization. Do you see any problems with this strategy?</p>
|
<p>There are a number of Java libraries for data synchronizing/replication. Two that I'm aware of are <a href="http://opensource.replicator.daffodilsw.com/">daffodil</a> and <a href="http://symmetricds.sourceforge.net/">SymmetricDS</a>. In a previous life I foolishly implemented (in Java) my own data replication process. It seems like the sort of thing that should be fairly straightforward, but if the data can be updated in multiple places simultaneously, it's hellishly complicated. I strongly recommend you use one of the aforementioned projects to try and bypass dealing with this complexity yourself.</p>
|
C# in linux environment <p>I am currently working in C/C++ in a Unix environment and am new to Linux environments. I would like to learn about the Linux OS and learn C# as the next level of programming language for my career.</p>
<p>I decided to put Ubuntu Linux on my laptop. But I am not sure whether we can write, compile and run C# programs in Linux environments or not.</p>
<p>The only IDE I know for C# is MS Visual Studio. Is there are any possible way to work in C# in a Linux environment?</p>
<p>If I have no other option, I'll have both operating systems on my laptop - Vista to learn C# and Linux for the other OS.</p>
|
<p>Learn <a href="http://www.mono-project.com/Main_Page">Mono</a>.</p>
<blockquote>
<p>The Mono Project is an open
development initiative sponsored by
Novell to develop an open source, UNIX
version of the Microsoft .NET
development platform. Its objective is
to enable UNIX developers to build and
deploy cross-platform .NET
Applications. The project implements
various technologies developed by
Microsoft that have now been submitted
to the ECMA for standardization.</p>
</blockquote>
<p>You can use the <a href="http://monodevelop.com/Main_Page">MonoDevelop</a> IDE.</p>
<blockquote>
<p>MonoDevelop is a free GNOME IDE
primarily designed for C# and other
.NET languages.</p>
</blockquote>
|
JBoss AS / Wildfly community version corresponding to Red Hat EAP version? <p>As far as i know the EAP editions of JBoss Application Server (AS) are just a bunch of community edition JBoss projects with some sugar.</p>
<p>So, what is the <strong>community edition</strong> of the JBoss Application Server that <strong>JBoss EAP 4.3.0</strong> corresponds to?</p>
|
<p>This response is really late but I came across the unanswered question in a Google search and I wanted to make sure there's a correct response. I work for JBoss support so you can consider this a qualified answer.</p>
<p>JBoss EAP is the only commercially supported version of JBoss. It contains JBoss AS and JBoss Seam. EAP diverged (in terms of the svn branch it's built off) from JBoss AS around version 4.2.1 (not exactly, but close enough). EAP has a 5-year lifetime and is tested and certified rigorously. EAP has paid commercial support and patches (called CPs or cumulative patches) that are designed to maintain ABI/API stability over time while allowing for security issues and bugs to be fixed. It is actually against policy to introduce a feature in a CP, but it happens on occasion.</p>
<p>If you're familiar with how <a href="http://www.redhat.com/rhel/">Red Hat Enterprise Linux</a> differs from <a href="http://fedoraproject.org/">Fedora</a>, you can consider the difference to be quite similar. The JBoss project/product split is much newer, though, so the differences are smaller. Here's the official page describing what I've said.</p>
<p><a href="http://www.jboss.com/products/community-enterprise">http://www.jboss.com/products/community-enterprise</a></p>
<p>Cheers,</p>
<p>Chris</p>
|
Collection<T> versus List<T> what should you use on your interfaces? <p>The code looks like below:</p>
<pre><code>namespace Test
{
public interface IMyClass
{
List<IMyClass> GetList();
}
public class MyClass : IMyClass
{
public List<IMyClass> GetList()
{
return new List<IMyClass>();
}
}
}
</code></pre>
<p>When I Run Code Analysis i get the following recommendation.</p>
<blockquote>
<p>Warning 3 CA1002 : Microsoft.Design : Change 'List' in 'IMyClass.GetList()' to use Collection, ReadOnlyCollection or KeyedCollection</p>
</blockquote>
<p>How should I fix this and what is good practice here?</p>
|
<p>To answer the "why" part of the question as to why not <code>List<T></code>, The reasons are future-proofing and API simplicity.</p>
<p><strong>Future-proofing</strong></p>
<p><code>List<T></code> is not designed to be easily extensible by subclassing it; it is designed to be fast for internal implementations. You'll notice the methods on it are not virtual and so cannot be overridden, and there are no hooks into its <code>Add</code>/<code>Insert</code>/<code>Remove</code> operations. </p>
<p>This means that if you need to alter the behaviour of the collection in the future (e.g. to reject null objects that people try to add, or to perform additional work when this happens such as updating your class state) then you need to change the type of collection you return to one you can subclass, which will be a breaking interface change (of course changing the semantics of things like not allowing null may also be an interface change, but things like updating your internal class state would not be).</p>
<p>So by returning either a class that can be easily subclassed such as <code>Collection<T></code> or an interface such as <code>IList<T></code>, <code>ICollection<T></code> or <code>IEnumerable<T></code> you can change your internal implementation to be a different collection type to meet your needs, without breaking the code of consumers because it can still be returned as the type they are expecting.</p>
<p><strong>API Simplicity</strong></p>
<p><code>List<T></code> contains a lot of useful operations such as <code>BinarySearch</code>, <code>Sort</code> and so on. However if this is a collection you are exposing then it is likely that you control the semantics of the list, and not the consumers. So while your class internally may need these operations it is very unlikely that consumers of your class would want to (or even should) call them.</p>
<p>As such, by offering a simpler collection class or interface, you reduce the number of members that users of your API see, and make it easier for them to use.</p>
|
How to select maximum 3 items per users in MySQL? <p>I run a website where users can post items (e.g. pictures). The items are stored in a MySQL database. </p>
<p>I want to query for the last ten posted items BUT with the constraint of a maximum of 3 items can come from any single user. </p>
<p>What is the best way of doing it? My preferred solution is a constraint that is put on the SQL query requesting the last ten items. But ideas on how to set up the database design is very welcome.</p>
<p>Thanks in advance!</p>
<p>BR</p>
|
<p>It's pretty easy with a correlated sub-query:</p>
<pre><code>SELECT `img`.`id` , `img`.`userid`
FROM `img`
WHERE 3 > (
SELECT count( * )
FROM `img` AS `img1`
WHERE `img`.`userid` = `img1`.`userid`
AND `img`.`id` > `img1`.`id` )
ORDER BY `img`.`id` DESC
LIMIT 10
</code></pre>
<p>The query assumes that larger <code>id</code> means added later</p>
<p>Correlated sub-queries are a powerful tool! :-)</p>
|
Java: Determine receiving address when receiving with MulticastSocket <p>I am using MulticastSocket to receive UDP Multicast packets. How can I determine to which address such a packet was sent? With the methods provided, I am only able to determine the sender address.</p>
<p>Of course, I am the one who sets the To-Address when creating the listening socket, but can I really be sure about this? What about broadcast packets? What about packets that somehow end up here?
I really want to distinguish if the packet was REALLY multicast.</p>
<p>Thank you!</p>
<p>Update: Currently it seems like unicast packets just sent to that port also end up in the multicast sockets receive() :( Binding to devices also gives me no better results</p>
|
<p>I'm a bit fuzzy on the details but a multicast packet will have been sent to the ip/port combo you subscribed to (and this info will be in the packet, somewhere), assuming you managed to have a clear path of intermediary routers that understand multicast. If you want to make sure the multicastsocket is receiving from the right network interface, there's a bunch of functions to bind it to a specific interface.</p>
<p>I don't think you have any way of knowing if the packet was "really" multicast, i.e. someone could always forge one, since there's no real security built in.</p>
|
How to track down tricky memory leak with fastMM? <p>After upgrading a project from Delphi 2007 to Delphi 2009 I'm getting an Unknown memory leak, so far I've been tryin to track it down using fastMM, here is what fastMM stack trace reports:</p>
<pre><code>A memory block has been leaked. The size is: 20
This block was allocated by thread 0x111C, and the stack trace (return addresses)
at the time was:
40339E [System.pas][System][@GetMem][3412] 534873 [crtl][_malloc]
56D1C4 [canex.cpp][MidasLib][DllGetDataSnapClassObject][3918]
56D316 [canex.cpp][MidasLib][DllGetDataSnapClassObject][3961]
56D5EE [canex.cpp][MidasLib][DllGetDataSnapClassObject][4085]
562D48 [DBCommon.pas][DBCommon][TFilterExpr.PutExprNode][1583]
408E46 [System.pas][System][DynArraySetLength][20464]
56D5EE [canex.cpp][MidasLib][DllGetDataSnapClassObject][4085]
408E92 [System.pas][System][@DynArraySetLength][20486]
528C1B [Forms.pas][Forms][TCustomForm.DoCreate][3260]
171A1A [GetRawStackTrace]
The block is currently used for an object of class: Unknown
The allocation number is: 302844
</code></pre>
<p>And sometimes I get this:</p>
<pre><code>A memory block has been leaked. The size is: 20
This block was allocated by thread 0x111C, and the stack trace (return addresses)
at the time was:
40339E [System.pas][System][@GetMem][3412]
534873 [crtl][_malloc]
56D1C4 [canex.cpp][MidasLib][DllGetDataSnapClassObject][3918]
56D316 [canex.cpp][MidasLib][DllGetDataSnapClassObject][3961]
77DC921A [RtlAnsiStringToUnicodeString]
56D5EE [canex.cpp][MidasLib][DllGetDataSnapClassObject][4085]
7726B8F5 [GetProcAddress]
7726B907 [GetProcAddress]
589B1E [ossrv.cpp][MidasLib][DllGetDataSnapClassObject][3163]
56D5EE [canex.cpp][MidasLib][DllGetDataSnapClassObject][4085]
408E92 [System.pas][System][@DynArraySetLength][20486]
The block is currently used for an object of class: Unknown
</code></pre>
<p>Is there some better way to figure out what really is causing the Memory leak?</p>
|
<p>This memory leak was being caused by a Delphi bug, QC <a href="http://qc.embarcadero.com/wc/qcmain.aspx?d=67709">#67709</a></p>
<p>It was fixed by the last Delphi 2009 update, no wonder I wasn't able to fix it.</p>
|
Enabling controls at moment of opening a form in Access <p>I have a form whose controls I want to enable/disable depending on the values in a ComboBox control. This ComboBox control is linked, like all the other controls in the form, to a table. Inside the ComboBox's Change event, I placed the code that enables/disables the other controls.</p>
<p>The problem I have is that when I open the form, the controls are not enabled/disabled. I have to re-choose the ComboBox value to make all other controls enable or disable.</p>
<p>One thing I noticed is that the RecordSet control inside the ComboBox often does not change to the value shown in the value property of the ComboBox.</p>
<p>I tried using <br>
<code>combobox.recordset.filter = "Key = " & combobox.value</code><br>
but I get the error <br>
<code>Operation is not supported for this type of object.</code></p>
<p><hr /></p>
<h2>Update</h2>
<p>I think my problem has to do more in how I'm accessing the values in the combobox.recordset. I was under the impression that combobox.recordset held the value received from the table. But, it seems to hold the first record from the recordsource.</p>
<p>I'm guessing that I will need to search those values I need by using another recordset object.</p>
|
<p>Most Access control events are not triggered by programmatic changes to the control. You may wish to call the code to enable the control(s) from the load event of the form.</p>
<p>You do not mention the version of Access that you are using, but I do not believe that any version has a Recordset property for comboboxes. </p>
<p>Did you wish to set the combobox to a specific value?</p>
|
Signing a desktop application <p>I'd like to know how to have a desktop application signed as a product from my company. I'm not sure of the details.I think the process is I have to purchase a certificate from a company like verisign
Thanks</p>
|
<p>You need to sign the code with an Authenticode certificate.</p>
<p>Full information here: <a href="http://msdn.microsoft.com/en-us/library/ms537359" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms537359</a>(VS.85).aspx</p>
|
Searching for the best PHP nested sets class (PEAR class excluded) <p>I'm looking for a PHP (with MYSQL) nested sets class with all needed functions.
For example:</p>
<p>createLeftNode, createRightNode,createRootNode, createSubNode,deleteNode and <strong>moveTree</strong>. Not only 1 left, 1 right, 1 up and 1 down but also a part of a tree in a nother tree.</p>
<p>Thanks!</p>
|
<p>look at the <a href="http://docs.doctrine-project.org/projects/doctrine1/en/latest/en/manual/behaviors.html#nesting-behaviors" rel="nofollow">nested behavior</a> of Doctrine </p>
|
Shadow Copying, and mixed C# and C++ DLLs loading from arbitrary folders <p>I have a VS 2005 C# project that uses a special Plugin folder to load extra DLLs (for use as nodes in an asset conversion process).</p>
<p>I have a mixture of C# and C++ DLLs in this folder.</p>
<p>The issue I have is that when Shadow Copying is enabled, the C++ DLLs refuse to load using Assembly.LoadFrom. I have attempted to create a custom app domain, and used Load, but this also failed.</p>
<p>Finally, I tried reading the DLL in as byte[] data and using Load on that - again, only the C# DLLs would work this way, with an error "Additional information: Unverifiable code failed policy check. (Exception from HRESULT: 0x80131402)".</p>
<p>An article on the net prompted me to attempt to use /clr:safe when building that particular DLL, but then it simply failed to build due to thousands of errors in Microsoft code... (apparently)</p>
<p>With Shadow Copying disabled, LoadFrom works fine for all DLLs. The app is itself a plugin for Maya, and this used to work with Maya 8.5 but fails with 2008 / 2009 (if Shadow Copying is enabled).</p>
<p>We really would prefer to use Shadow Copying, because it prevents DLL file locks when the app is running (the Plugins folder is stored in a location that Perforce can update while the app is running).</p>
<p>Any ideas as to how I can persuade Shadow Copying to work with a custom folder AND a mix of C# / C++ DLLs without these problems?</p>
|
<p>Sounds like a trust issue. Try getting a Fusion log (see <a href="http://blogs.msdn.com/suzcook/archive/2003/05/29/57120.aspx" rel="nofollow">this blog post</a>). Your C++ DLLs are unverifiable since they weren't compiled with <code>/clr:safe</code>, so they can only be loaded as full trust. Presumably when shadow copying, the download cache location doesn't have full trust.</p>
<p>Running <code>caspol -s</code> may get you up and running if this is a development-only issue.</p>
|
How to put BIDS solutions under source control? <p>I am starting to work with Microsoft BI suite: Analysis services 2005, Business Intelligence Development Studio 2005, stuff like that. Of course my first wish was to set up the same source control/automated testing environment I have for my .NET projects. </p>
<p>But xml files used by Analysiss services (dwproj, cube, dim, ds, dsv) and Integration services (dtsx) are rather source control-unfriendly. Not only they have actual data intermingled with presentation details of e.g. diagram coordinates, but they are also often reformatted on save by Visual Studio. This results in completely useless diffs in TortoiseSVN, where half of the file has changed but you cannot understand where and why. </p>
<p>How do you solve this problem? Are there any specilized systems/plugins suitable for the job?</p>
|
<p>We have a feature in <a href="http://www.codeplex.com/bidshelper">BIDS Helper</a> (a free open source add-in) that does a "smart diff". We can't stop all the reformatting that goes on, but the smart diff feature strips out as much of the presentation details as we can which usually lets you see the important details of any change. I know it works with Source Safe and TFS, I don't know if anyone has tried with SVN yet.</p>
|
SQL: Complex Deletion <p>I basically created some tables to play around with: I have Two main tables, and a Many-Many join table. Here is the DDL: (I am using HSQLDB)</p>
<pre><code>CREATE TABLE PERSON
(
PERSON_ID INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
NAME VARCHAR(50), MAIN_PERSON_ID INTEGER
)
CREATE TABLE JOB
(
JOB_ID INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
NAME VARCHAR(50)
)
CREATE TABLE JOB_PERSON
(
PERSON_ID INTEGER,
JOB_ID INTEGER
)
ALTER TABLE JOB_PERSON ADD
CONSTRAINT FK_PERSON_JOB FOREIGN KEY(PERSON_ID)
REFERENCES PERSON ON DELETE CASCADE ON UPDATE CASCADE
ALTER TABLE JOB_PERSON ADD
CONSTRAINT FK_JOB_PERSON FOREIGN KEY(JOB_ID)
REFERENCES JOB ON DELETE CASCADE ON UPDATE CASCADE
ALTER TABLE PERSON ADD
CONSTRAINT FK_PERSON_PERSON FOREIGN KEY(MAIN_PERSON_ID)
REFERENCES PERSON ON DELETE CASCADE ON UPDATE CASCADE
insert into person values(null,'Arthur', null);
insert into person values(null,'James',0);
insert into job values(null, 'Programmer')
insert into job values(null, 'Manager')
insert into job_person values(0,0);
insert into job_person values(0,1);
insert into job_person values(1,1);
</code></pre>
<p>I want to create a delete statement that deletes orphans from JOB (if there exists only one entry in the join table for a specific job) based on the PERSON.PERSON_ID. </p>
<p>In pseudo language: </p>
<pre><code>delete from job where job_person.job_id=job.job_id
AND count(job_person.job_id)=1 AND job_person.person_id=X
</code></pre>
<p>Where X is some person_id. I have tried a lot of different ways; I think it is the "COUNT" part that is causing problems. I am an SQL rookie, so any help would be much appreciated.</p>
|
<p>I'm not following.</p>
<p>You cannot delete <code>JOB</code> rows which have <code>JOB_PERSON</code> rows (even one) because of your FK contraints. Thus there is no way to delete <code>JOB</code> rows based on <code>PERSON</code> rows.</p>
<p><code>JOB_PERSON</code> rows have to be deleted before either a <code>JOB</code> or <code>PERSON</code> can be deleted.</p>
<p>If you want to delete all <code>JOB</code> rows with no <code>JOB_PERSON</code>, then one way is:</p>
<pre><code>DELETE FROM JOB
WHERE JOB_ID NOT IN (
SELECT JOB_ID
FROM JOB_PERSON
)
</code></pre>
<p>If you want to delete all <code>JOB_PERSON</code> rows for a particular person and then all orphans, do it in two steps:</p>
<pre><code>DELETE FROM JOB_PERSON
WHERE PERSON_ID = X
DELETE FROM JOB
WHERE JOB_ID NOT IN (
SELECT JOB_ID
FROM JOB_PERSON
)
</code></pre>
<p>If you want to delete only the orphan <code>JOB</code>s previously linked to X, you will need to hold those in a temporary table before the first delete.</p>
<pre><code>INSERT INTO TEMP_TABLE
SELECT JOB.JOB_ID
FROM JOB
INNER JOIN JOB_PERSON
ON JOB_PERSON.JOB_ID = JOB.JOB_ID
WHERE JOB_PERSON.PERSON_ID = X
DELETE FROM PERSON
WHERE PERSON_ID = X
-- YOUR CASCADING DELETE DOES THIS:
/*
DELETE FROM JOB_PERSON
WHERE PERSON_ID = X
*/
-- Now clean up (only) new orphans on the other side
DELETE FROM JOB
WHERE JOB_ID NOT IN (
SELECT JOB_ID
FROM JOB_PERSON
)
AND JOB_ID IN (
SELECT JOB_ID
FROM TEMP_TABLE
)
</code></pre>
|
SQL Statement indentation good practice <p>What is the accepted practice for indenting SQL statements? For example, consider the following SQL statement:</p>
<pre><code>SELECT column1, column2
FROM table1
WHERE column3 IN
(
SELECT TOP(1) column4
FROM table2
INNER JOIN table3
ON table2.column1 = table3.column1
)
</code></pre>
<p>How should this be indented? Many thanks.</p>
|
<pre><code>SELECT column1
, column2
FROM table1
WHERE column3 IN
(
SELECT TOP(1) column4
FROM table2
INNER JOIN table3
ON table2.column1 = table3.column1
)
</code></pre>
<p>I like to have all <strong>"," in front</strong>, this way I never search them when an error at line X from the SQL editor.</p>
<p><hr/></p>
<h3>This is an example for those who do not use this type of writting SQL statement. Both contain an error of a missing comma.</h3>
<pre><code>SELECT sdcolumn123
, dscolumn234
, sdcolumn343
, ffcolumn434
, sdcolumn543
, bvcolumn645
vccolumn754
, cccolumn834
, vvcolumn954
, cvcolumn104
FROM table1
WHERE column3 IN
(
...
)
SELECT sdcolumn123, dscolumn234, asdcolumn345, dscolumn456, ascolumn554, gfcolumn645 sdcolumn754, fdcolumn845, sdcolumn954, fdcolumn1054
FROM table1
WHERE column3 IN
(
...
)
</code></pre>
<p>I found easier and more quick at the first example. Hope this example show you more my point of view.</p>
|
How might I update this code <pre><code> <object height="25" width="75" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">
<param value="http://click-here-to-listen.com/players/iaPlay13.swf?x=1058286910FTRZGK" name="movie"/>
<param value="high" name="quality"/>
<param value="#FFFFFF" name="bgcolor"/>
<param value="opaque" name="wmode"/>
<embed height="25" width="75" wmode="opaque" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" bgcolor="#FFFFFF" quality="high" src="http://click-here-to-listen.com/players/iaPlay13.swf?x=1058286910FTRZGK"/>
</object>
</code></pre>
<p>I am having to insert this legacy markup into a new site that I'm building. Problem is its using an <code><embed></code> tag. </p>
<p>Would I just do away with the <code><embed></code> and put some content in as an alternative, for those that do not have flash? Basically I'm just trying to bring this piece of html into the 21st century.</p>
|
<p>You can nest object elements to display alternatives. The W3C explains it <a href="http://www.w3.org/TR/html401/struct/objects.html#h-13.3" rel="nofollow">here</a>. I copied a snippet below:</p>
<blockquote>
<p>One significant consequence of the OBJECT element's design is that it offers a mechanism for specifying alternate object renderings; each embedded OBJECT declaration may specify alternate content types. If a user agent cannot render the outermost OBJECT, it tries to render the contents, which may be another OBJECT element, etc.</p>
<p>In the following example, we embed several OBJECT declarations to illustrate how alternate renderings work. A user agent will attempt to render the first OBJECT element it can, in the following order: (1) an Earth applet written in the Python language, (2) an MPEG animation of the Earth, (3) a GIF image of the Earth, (4) alternate text.</p>
</blockquote>
<pre><code><P> <!-- First, try the Python applet -->
<OBJECT title="The Earth as seen from space"
classid="http://www.observer.mars/TheEarth.py">
<!-- Else, try the MPEG video -->
<OBJECT data="TheEarth.mpeg" type="application/mpeg">
<!-- Else, try the GIF image -->
<OBJECT data="TheEarth.gif" type="image/gif">
<!-- Else render the text -->
The <STRONG>Earth</STRONG> as seen from space.
</OBJECT>
</OBJECT>
</OBJECT>
</code></pre>
|
XMPP Server-to-Server for Gmail.com/Jabber.org <p>I'm in the phase of implementing the server-to-server communication part of a XMPP Server.</p>
<p>I'm testing my implementation with Gmail.com and Jabber.org but both seem to use the dialback protocol. Does anyone know more information about this protocol related to this servers?</p>
<p>The protocol seems to be separated in several federation types, and can't seem to find the one this servers use, and the implications of this (root certificate, self-signed certificate, ...).</p>
|
<p><a href="http://xmpp.org/extensions/xep-0220.html" rel="nofollow">XEP-220</a> specifies the dialback protocol. </p>
<p>Keep in mind in your implementation that you may get asked for dialback on a socket that has already been fully set up and had traffic come across it.</p>
|
Does opacity:0 have exactly the same effect as visibility:hidden <p>If so, does it effectively deprecate the <code>visibility</code> property?</p>
<p>(I realize that Internet Explorer does not yet support this CSS2 property.)
<br/>
<a href="http://en.wikipedia.org/wiki/Comparison_of_layout_engines_(CSS)#Properties">Comparisons of layout engines</a></p>
<p><a href="http://stackoverflow.com/questions/133051/what-is-the-difference-between-visibilityhidden-and-displaynone">See also: What is the difference between visibility:hidden and display:none</a></p>
|
<p>Here is a compilation of verified information from the various answers.</p>
<p>Each of these CSS properties is in fact unique. In addition to rendering an element not visible, they have the following additional effect(s):</p>
<ol>
<li><strong>Collapses</strong> the space that the element would normally occupy</li>
<li>Responds to <strong>events</strong> (e.g., click, keypress)</li>
<li>Participates in the <strong>taborder</strong></li>
</ol>
<pre>
collapse events taborder
opacity: 0 No Yes Yes
visibility: hidden No No No
visibility: collapse * No No
display: none Yes No No
* Yes inside a table element, otherwise No.
</pre>
|
How to add button to other apps window title bar (XP/Vista) <p>I have the handler of an open window which wasn't necessarily open by my process. How can I add a button to that window and make the button call a certain application (.exe) when clicked? The button could be next to the system menu or the minimize button. This should work for both XP and Vista (a different approach for each version is OK).</p>
|
<p>The standard approach is to inject a DLL into the process with SetWindowsHookEx, hooking WH_CALLWNDPROC to monitor the WM_NCPAINT message. That used to work pretty well but no more. Visual Styles and Vista UAC will make you grow a pretty long beard. Common in the Windows 3.x days, I haven't seen this done in quite a while.</p>
|
What's the best static analysis tool for NetBeans 6.1? <p>I'm finding a couple for Java in general but no plugins for netbeans that I can see.</p>
<p>Thanks</p>
|
<p>I've used the <a href="http://sourceforge.net/project/showfiles.php?group_id=56262&package_id=63621" rel="nofollow">PMD NetBeans plugin</a>, and <a href="http://pmd.sourceforge.net/integrations.html#netbeans" rel="nofollow">here</a> are the installation instructions (may be a little outdated, due to the speed of NetBeans development, but I got them to work).</p>
<p>Here's a list of <a href="http://en.wikipedia.org/wiki/List_of_tools_for_static_code_analysis#Java_2" rel="nofollow">tools for static analyisis</a>. Maybe you can cross-check for others that offer NetBeans support.</p>
<p><strong>EDIT:</strong> Those instruction are a little bit old, so I put a more up-to-date set <a href="http://www.billthelizard.com/2008/11/netbeans-pmd-plugin.html" rel="nofollow">here</a> (links to my blog).</p>
|
NullReferenceException when hosting WPF in a System.AddIn <p>We are developing a WPF application that uses the System.AddIn framework to host add-ins that display additional WPF content. Everything seems to be working fine, but overnight, the application threw the following NullReferenceException:</p>
<pre>
Message: Error : Object reference not set to an instance of an object.
StackTrace : at System.Windows.Interop.HwndSource.CriticalTranslateAccelerator(MSG& msg, ModifierKeys modifiers)
at System.AddIn.Pipeline.AddInHwndSourceWrapper.TranslateAccelerator(MSG msg, ModifierKeys modifiers)
at MS.Internal.Controls.AddInHost.System.Windows.Interop.IKeyboardInputSink.TranslateAccelerator(MSG& msg, ModifierKeys modifiers)
at System.Windows.Interop.HwndHost.OnKeyUp(KeyEventArgs e)
at System.Windows.UIElement.OnKeyUpThunk(Object sender, KeyEventArgs e)
at System.Windows.Input.KeyEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
at System.Windows.Interop.HwndKeyboardInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawKeyboardActions actions, Int32 scanCode, Boolean isExtendedKey, Boolean isSystemKey, Int32 virtualKey)
at System.Windows.Interop.HwndKeyboardInputProvider.ProcessKeyAction(MSG& msg, Boolean& handled)
at System.Windows.Interop.HwndSource.CriticalTranslateAccelerator(MSG& msg, ModifierKeys modifiers)
at System.Windows.Interop.HwndSource.OnPreprocessMessage(Object param)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
at System.Windows.Interop.HwndSource.OnPreprocessMessageThunk(MSG& msg, Boolean& handled)
at System.Windows.Interop.HwndSource.WeakEventPreprocessMessage.OnPreprocessMessage(MSG& msg, Boolean& handled)
at System.Windows.Interop.ThreadMessageEventHandler.Invoke(MSG& msg, Boolean& handled)
at System.Windows.Interop.ComponentDispatcherThread.RaiseThreadMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
</pre>
<p>As you can see, none of our code is in the stack trace, so I have no place to fix anything. Anybody have any ideas about possible workarounds?</p>
<p>Thanks for the help!</p>
|
<p>In addition the above answer by Steve Massing it will likely help to disable the "Just My Code" option, enable the "Enable source server support" option and setup your debugging symbols in order to break into and debug the framework code,</p>
<p>It's easier than it sounds, follow these 3 step directions</p>
<p>Red line Unchecked, Green line Checked and setup symbols like below</p>
<p><img src="http://www.gangleri.net/content/binary/debugOptions1.gif" alt="alt text" />
<img src="http://www.gangleri.net/content/binary/debugOptions2.gif" alt="alt text" /></p>
|
WCF javascript proxy not found when endpoint address is not blank <p>I am trying to setup a WCF service with multiple endpoints with one of the endpoints using the enableWebScript endpoint behavior so that a Javascript proxy will be created on the client (jsdebug/js).</p>
<p>When adding the Service Reference to my AJAX ScriptManager, the jsdebug file is not found unless the address of the endpoint is blank. The ScriptManager proxy seems to always generate a path of "MyService.svc/jsdebug" to look for the file even though my service has an address of "ajax". The proxy should generate the path as "MyService.svc/ajax/jsdebug".</p>
<p>Is there a setting to get the Proxy generated with the right path? My service is at the root of my website.</p>
<p>works:</p>
<pre><code><endpoint address=""
behaviorConfiguration="ajaxBehavior"
binding="webHttpBinding"
bindingConfiguration="webBinding"
contract="MyTest.Web.ICustomerService" />
</code></pre>
<p>want this (doesn't work):</p>
<pre><code><endpoint address="ajax"
behaviorConfiguration="ajaxBehavior"
binding="webHttpBinding"
bindingConfiguration="webBinding"
contract="MyTest.Web.ICustomerService" />
</code></pre>
|
<p><code><enableWebScript /></code> also known as AJAX-enabled endpoints essentially hard-codes everything to do with address so you can generate the client-side code.</p>
<p>The way it's hard-coded is that everything is directly relative to the .svc file.</p>
<p>See <a href="http://msdn.microsoft.com/en-us/library/bb628467.aspx" rel="nofollow">How to: Use Configuration to Add an ASP.NET AJAX Endpoint</a></p>
<blockquote>
<p>The endpoint is configured at an empty
address relative to the .svc file, so
the service is now available and can
be invoked by sending requests to
<code>service.svc/<operation></code> - for example,
<code>service.svc/Add</code> for the <code>Add</code> operation.</p>
</blockquote>
<p>For this reason, you can't mix <code><enableWebScript /></code> with <code>UriTemplate</code>, which takes away half the fun out of WCF in my opinion. See <a href="http://blogs.msdn.com/justinjsmith/archive/2008/02/15/enablewebscript-uritemplate-and-http-methods.aspx" rel="nofollow">enableWebScript, UriTemplate, and HTTP methods</a>.</p>
<p>Personally, I like to configure my URI and serve both POX and JSON, as well as SOAP. See <a href="http://www.codemeit.com/wcf/wcf-restful-pox-json-and-soap-coexist.html" rel="nofollow">WCF RESTful POX, JSON and SOAP Coexist</a>.</p>
|
How to move documents from SharePoint 2003 to SharePoint 2007 with versioning? <p>I'm desperately searching for a tool allowing me to copy documents with their old versions from a SharePoint 2003 to a SharePoint 2007 site.<br />
Do you know about any simple (and preferably free) tool which does this?<br /></p>
|
<p>This may be too late for you, but I needed to migrate from a SharePoint 2003 site to a SharePoint 2007 site and keep not only versions, but also the file metadata from all of the document libraries. The official methods of migrating or upgrading failed, so I ended up writing a tool that must run on the destination SharePoint 2007 server, but can copy from the 2003 server all lists and document libraries with metadata and version intact. It's available with source at <a href="http://sourceforge.net/projects/splistcp">http://sourceforge.net/projects/splistcp</a> so feel free to use and improve it.</p>
|
Do I have to learn Objective-C for professional Mac Development? <p>Do I really have to learn Objective-C to develop solid Mac Apps?</p>
<p>As Mac users tend to use only applications that have a nice (native) GUI, i don't think that Mono and GTK+ or any Java GUI (Swing) will fit their needs.</p>
<p>There are projects like Cocoa#, PyObjC and RubyCocoa, but are they ready for primetime?</p>
<p>So do I really have to learn Objective-C ?
I would prefer a dynamic language.</p>
|
<p>Objective-C <em>is</em> a dynamic language, as far as the Objective-C parts go. Here's a little summary article: <a href="http://www.macdevcenter.com/pub/a/mac/2003/04/28/objective-c.html">http://www.macdevcenter.com/pub/a/mac/2003/04/28/objective-c.html</a></p>
<p>The syntax is scary at first, but it grows on you. I suggest biting the bullet and slogging through it.</p>
<p>If you want to work at a "real job" doing Mac programming with other people, you're going to need to know Objective-C (in my opinion, anyway).</p>
|
SQL Server Profiler - How to filter trace to only display events from one database? <p>How do I limit a SQL Server Profiler trace to a specific database? I can't see how to filter the trace to not see events for all databases on the instance I connect to.</p>
|
<p>Under Trace properties > Events Selection tab > select show all columns. Now under column filters, you should see the database name. Enter the database name for the Like section and you should see traces only for that database.</p>
|
Kill a blocked Boost::Thread <p>I am writing an application which blocks on input from two <code>istreams</code>.</p>
<p>Reading from either <code>istream</code> is a synchronous (blocking) call, so, I decided to create two <code>Boost::thread</code>s to do the reading.</p>
<p>Either one of these threads can get to the "end" (based on some input received), and once the "end" is reached, both input streams stop receiving. Unfortunately, I cannot know which will do so.</p>
<p>Thus, I cannot <code>join()</code> on both threads, because only one thread (cannot be predetermined which one) will actually return (unblock).</p>
<p>I must somehow force the other to exit, but it is blocked waiting for input, so it cannot itself decide it is time to return (condition variables or what not).</p>
<p>Is their a way to either:</p>
<ul>
<li>Send a signal a boost::thread, or</li>
<li>Force an <code>istream</code> to "fail", or</li>
<li>Kill a Boost::thread?</li>
</ul>
<p>Note:</p>
<ul>
<li>One of the <code>istreams</code> is <code>cin</code></li>
<li>I am trying to restart the process, so I cannot close the input streams in a way that prohibits reseting them.</li>
</ul>
<p>Edit:</p>
<ul>
<li>I do know when the "end" is reached, and I do know which thread has successfully finished, and which needs to be killed. Its the killing I need to figure out (or a different strategy for reading from an istream).</li>
<li>I need both threads to exit and cleanup properly :(</li>
</ul>
<p>Thanks!</p>
|
<p>I don't think there is a way to do it cross platform, but pthread_cancel should be what you are looking for. With a boost thread you can get the <a href="http://www.boost.org/doc/libs/1_37_0/doc/html/thread/thread_management.html#thread.thread_management.thread.nativehandle" rel="nofollow">native_handle</a> from a thread, and call pthread_cancel on it.</p>
<p>In addition a better way might be to use the boost <a href="http://www.boost.org/doc/libs/1_36_0/doc/html/boost_asio.html" rel="nofollow">asio</a> equivalent of a select call on multiple files. That way one thread will be blocked waiting for the input, but it could come from either input stream. I don't know how easy it is to do something like this with iostreams though.</p>
|
Migrating content from OpenWiki to ScrewTurn Wiki <p>We have a large OpenWiki powered wiki. OpenWiki appears to be a dead project, and ScrewTurn the next best option.</p>
<p>Is anyone aware of a data migration route to move our content from the OpenWiki SQL Server format to the ScrewTurn wiki SQL Server format?</p>
<p>We may end up creating our own (and sharing it) but we'd rather not re-invent the wheel.</p>
<p>Regards,</p>
<p>Mike</p>
|
<p>Are you sure about the "dead" status?</p>
<p><a href="http://www.facebook.com/pages/OpenWiki-The-Post-It-Note-of-the-Web/145492998806288" rel="nofollow">http://www.facebook.com/pages/OpenWiki-The-Post-It-Note-of-the-Web/145492998806288</a></p>
|
Does the brand name matter for a SSL EV certificate? <p>Do end users really care if a SSL EV certificate is from VeriSign, Thwate, DigiCert, or etc.? A certificate from VeriSign can cost up to 3x the cost from DigiCert for the same basic features. VeriSign is probably the most recognizable brand name though.</p>
<p>I've had many discussions with people about this topic, but I've never seen any real data (from studies, surveys, etc.) to support the idea that end users will feel more secure using your site when they see the VeriSign seal vs. the DigiCert seal.</p>
<p>Does anyone have any real data to back up this idea?</p>
|
<p>No. The reason Verisign can charge more is that as one of the very first CAs they are recognised by more legacy and obscure browsers.</p>
|
Undefined reference to static class member <p>Can anyone explain why following code won't compile? At least on g++ 4.2.4.</p>
<p>And more interesting, why it will compile when I cast MEMBER to int?</p>
<pre><code>#include <vector>
class Foo {
public:
static const int MEMBER = 1;
};
int main(){
vector<int> v;
v.push_back( Foo::MEMBER ); // undefined reference to `Foo::MEMBER'
v.push_back( (int) Foo::MEMBER ); // OK
return 0;
}
</code></pre>
|
<p>You need to actually define the static member somewhere (after the class definition). Try this:</p>
<pre><code>class Foo { /* ... */ };
const int Foo::MEMBER;
int main() { /* ... */ }
</code></pre>
<p>That should get rid of the undefined reference.</p>
|
In Java when does a URL connection close? <p>When does java let go of a connections to a URL? I don't see a close() method on either URL or URLConnection so does it free up the connection as soon as the request finishes? I'm mainly asking to see if I need to do any clean up in an exception handler.</p>
<pre><code>try {
URL url = new URL("http://foo.bar");
URLConnection conn = url.openConnection();
// use the connection
}
catch (Exception e) {
// any clean up here?
}
</code></pre>
|
<p>It depends on the specific protocol specified in the protocol. Some maintain persistent connections, other close their connections when your call close in the input or outputstream given by the connection. But other than remembering to closing the streams you opened from the URLConnection, there is nothing else you can do.</p>
<p>From the javadoc for java.net.URLConnection</p>
<blockquote>
<p>Invoking the close() methods on the
InputStream or OutputStream of an
URLConnection after a request may free
network resources associated with this
instance, unless particular protocol
specifications specify different
behaviours for it.</p>
</blockquote>
|
What's "in" and "out" of OpenGL-ES? (Porting from OpenGL) <p>It seems that all of the documentation I can find about OpenGL-ES says something to the effect of "OpenGL-ES is just like OpenGL, but without a lot of stuff. For example, there's no glBegin or glEnd."</p>
<p>Ok, that's great. So, what ELSE isn't there any of? Or is there a list of what's <em>in</em>? Or maybe a porting guide?</p>
<p>(Specifically, I'm trying to move an existing GL app to the iPhone, although I don't want to necessarily limit my Q to the iPhone.)</p>
|
<p>Part of the problem in answering your question is there are many things missing and often it's a set of rarely used or non-applicable bit flags. The best document describing the differences is actually the implementation headers.</p>
<p>For the framework I'm working on I decided to make it completely cross platform between desktop and iPhone. The approach I take in figuring it out is write code in OpenGL, and see where it breaks. Then look in </p>
<p><code>/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.sdk/
System/Library/Frameworks/OpenGLES.framework/Headers/ES1/gl.h</code></p>
<p>and compare it to </p>
<p><code>/Developer/SDKs/MacOSX10.5.sdk/
System/Library/Frameworks/OpenGL.framework/Versions/A/Headers/gl.h</code></p>
<p>These headers are very straightforward and easy to follow.</p>
<p>The main difference I've discovered so far is there is no GLdouble (anything using GLdouble such as glOrtho and glFrustum has a GLfloat version glOrthof and glFrustumf). Also there is no gluPerspective or gluPerspectivef for some reason. </p>
<p>Here is a drop in replacement:</p>
<pre><code>void gluPerspective( GLfloat fovy, GLfloat aspect, GLfloat zNear, GLfloat zFar )
{
GLfloat xmin, xmax, ymin, ymax;
ymax = zNear * tan(fovy * M_PI / 360.0);
ymin = -ymax;
xmin = ymin * aspect;
xmax = ymax * aspect;
glFrustumf( xmin, xmax, ymin, ymax, zNear, zFar );
}
</code></pre>
<p>Since you have no glBegin and glEnd, you have to do everything through glDrawArray or glDrawElements (preferred). A quick and dirty example:</p>
<pre><code>void draw( short x, short y, short w, short h )
{
const GLshort t[8] = { 0, 0, 1, 0, 1, 1, 0, 1 };
const GLshort v[8] = { x, y, x+w, y, x+w, y+h, x, y+h };
glVertexPointer( 2, GL_SHORT, 0, v );
glEnableClientState( GL_VERTEX_ARRAY );
glTexCoordPointer( 2, GL_SHORT, 0, t );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
glDrawArrays( GL_TRIANGLE_FAN, 0, 4 );
}
</code></pre>
<p>Check out Apple's Technical Note <a href="http://developer.apple.com/iphone/library/technotes/tn2008/tn2230.html">TN2230 "Optimizing OpenGL ES for iPhone OS"</a> for some other hints that could be useful in porting.</p>
<p>Porting so far has been fairly pain free for me, and unless your app does some pretty advanced OGL stuff or uses completely unsupported functionality you'll find your problems by hitting the build button and a simple fix will be apparent by digging a little in the gl.h files. In fact, porting to ES kind of forces you to write good optimized rendering code.</p>
|
Testing Web Services Consumer <p>Here are some tools that I have found to test web services consumers:</p>
<p><a href="http://www.soapui.org/" rel="nofollow">http://www.soapui.org/</a>
https://wsunit.dev.java.net/</p>
<p>Are there any others? I would prefer testing frameworks that are written in Java or Python.</p>
|
<p>I have used soapui by a maven plugin. It can create junit-linke reports to be run and analysed like unit tests. This can be easily integrated in continious build, also with the free distribution of soapui.</p>
|
UPS Worldship Integration and .net <p>Are there any UPS WorldShip integration APIS or Libraries out there for .net? I've been tasked with integrating our Sample Order application (A VB.Net/SQL Server app) with UPS, and having it write .xml files for the auto import feature though serialization has gotten my foot in the door- but some of the more advanced shipment options such as international customs options are completely undocumented. </p>
<p>How did you get UPS integration up and running? Did you have any 3rd party help doing it? Is there a better location for documentation I'm just missing?</p>
<p><strong>EDIT</strong>: What I'm trying to do is create new shipments based on order data in my database and then update those orders with the tracking number the shipment received from UPS. The orders have the shipping method designated, 2nd Day Air, Ground, or International. About 50% of the orders are international. </p>
|
<p>Check here:<br />
<a href="http://www.ups.com/content/us/en/bussol/offering/technology/alliances/technology_tools.html" rel="nofollow">http://www.ups.com/content/us/en/bussol/offering/technology/alliances/technology_tools.html</a></p>
<p>Look at the NexxStatus and ShipRush products at the bottom. Hopefully between those you'll be able to find something.</p>
|
WPF TreeView Binding <p>I've got a class with Parent and Children properties.</p>
<p><img src="http://img148.imageshack.us/img148/6802/edmxxe8.gif" alt="ADO.NET Entity Framework Hierarchical Page Class" /></p>
<p>I want to display this hierarchy in a WPF treeview.</p>
<p>Here's my XAML...</p>
<pre><code><TreeView Margin="12" Name="TreeViewPages" ItemsSource="{Binding}">
<TreeView.Resources>
<HierarchicalDataTemplate DataType="{x:Type Page}" ItemsSource="{Binding Children}">
<TextBlock Text="{Binding Path=ShortTitle}" />
</HierarchicalDataTemplate>
</TreeView.Resources>
</TreeView>
</code></pre>
<p>And my VB code...</p>
<pre>
Dim db As New PageEntities
Dim t = From p In db.Page.Include("Children") _
Where p.Parent Is Nothing _
Select p
TreeViewPages.ItemsSource = t
</pre>
<p>But I get a tree with one, non-templated item:</p>
<pre>
PageManager.Page
</pre>
<p>What do I need to do to get this working?</p>
|
<p>You need to define an xmlns mapping to your Page class in the XAML file and use that in your Type declaration. The reason why you aren't getting a compile error is that the Page class is already defined in WPF.</p>
<p>So, if your Page class was defined in the Zack namespace, in the TreeViewBinding assembly, you would need to add the following declaration to the parent container (most likely Window):</p>
<pre><code>xmlns:local="clr-namespace:Zack;assembly=TreeViewBinding"
</code></pre>
<p>And then modify your DataTemplate to the following:</p>
<pre><code><HierarchicalDataTemplate DataType="{x:Type local:Page}" ItemsSource="{Binding Children}">
</code></pre>
<p>I will clarify my post for your original question.</p>
|
Help with using LD_PRELOAD <p>I want to create a library with a modified version of printf and then call LD_PRELOAD so when my program calls printf it uses my version. Can someone explain to me how to use LD_PRELOAD and if there is a something special I need to do in my code or my library? </p>
|
<p>You just set the environment variable <code>LD_PRELOAD</code> to the full path to the replacement library. Since all programs you launch after that point will attempt to use this library, you may want to make a wrapper script that sets <code>LD_PRELOAD</code> then calls the program you want to run.</p>
|
iPhone and HTML5 Cache Manifest <p>I am trying to build an iPhone web application using ASP.NET. The page is dynamically rendered once for each visitor. At this point the page can be bookmarked and it will never change again for that visitor. For this reason it should be cached locally from that point on so the application will run if referenced from the bookmark even if no network connection is available. No matter what I try the phone continues to request the page from the server forcing a re-render or it fails if the phone is offline. </p>
<p><a href="http://stackoverflow.com/users/30506/louis-gerbarg">Louis Gerbarg</a> suggested in <a href="http://stackoverflow.com/questions/264367/iphone-web-app-cache-persistence">this</a> post that I use HTML5 Cache Manifest to get this working however following the <a href="http://www.w3.org/TR/offline-webapps/#offline" rel="nofollow">w3.org docs</a> does not appear to work for the iPhone. Does anyone have a good example where application cache is working?</p>
|
<p>The cache manifest file has to be served with a 'text/cache-manifest' mime-type. This is absolutely critical, it will not work without it. If you navigate to the url of your manifest file, it should trigger a download...</p>
<p>Also, I've found that putting the manifest location in the tag as an absolute location, as well as all the entries in the manifest file to be more effective.</p>
|
Sharepoint: Is it possible to make subgroups in top navigation menu? <p>I need to make subgroups in the top navigation menu, like: </p>
<p>Home
-Group
--Subgroup</p>
<p></p>
<p>Is it possible? I can not make more than two levels!</p>
|
<p>See this <a href="http://www.heathersolomon.com/blog/archive/2007/05/15/SharePoint-Tip--How-to-Activate-the-Drop-Down-Menu.aspx" rel="nofollow">blog entry</a> by Heather Solomon.</p>
<p>You need to modify your Master Page to set your <strong>MaximumDynamicDisplayLevels</strong> property of the <strong>SharePoint:AspMenu</strong> tag from 1 to the level you need. </p>
<p>And you will get this as result : </p>
<p><img src="http://www.heathersolomon.com/images/postimages/sampledropnav2levels.gif" alt="sub sites" /></p>
|
How many dimensions in my array or get the last one <p>How can I find out the number of dimensions in an array in Classic ASP ( VBScript ) .</p>
<p>I am being passed an Array with multiple dimensions but I only want to look at the last. Seems easy in other languages.</p>
|
<pre><code>Ubound(MySingleDimensionalArray, 2) ' Number of Array Elements
Ubound(MyMultiDimensionalArray, 1) ' Number of Columns
Ubound(MyMultiDimensionalArray, 2) ' Number of Rows
</code></pre>
|
iPhone: Detecting user inactivity/idle time since last screen touch <p>Has anybody implemented a feature where if the user has not touched the screen for a certain time period, you take a certain action? I'm trying to figure out the best way to do that.</p>
<p>There's this somewhat-related method in UIApplication:</p>
<pre><code>[UIApplication sharedApplication].idleTimerDisabled;
</code></pre>
<p>It'd be nice if you instead had something like this:</p>
<pre><code>NSTimeInterval timeElapsed = [UIApplication sharedApplication].idleTimeElapsed;
</code></pre>
<p>Then I could set up a timer and periodically check this value, and take some action when it exceeds a threshold.</p>
<p>Hopefully that explains what I'm looking for. Has anyone tackled this issue already, or have any thoughts on how you would do it? Thanks.</p>
|
<p>Here's the answer I had been looking for:</p>
<p>Have your application delegate subclass UIApplication. In the implementation file, override the sendEvent: method like so:</p>
<pre><code>- (void)sendEvent:(UIEvent *)event {
[super sendEvent:event];
// Only want to reset the timer on a Began touch or an Ended touch, to reduce the number of timer resets.
NSSet *allTouches = [event allTouches];
if ([allTouches count] > 0) {
// allTouches count only ever seems to be 1, so anyObject works here.
UITouchPhase phase = ((UITouch *)[allTouches anyObject]).phase;
if (phase == UITouchPhaseBegan || phase == UITouchPhaseEnded)
[self resetIdleTimer];
}
}
- (void)resetIdleTimer {
if (idleTimer) {
[idleTimer invalidate];
[idleTimer release];
}
idleTimer = [[NSTimer scheduledTimerWithTimeInterval:maxIdleTime target:self selector:@selector(idleTimerExceeded) userInfo:nil repeats:NO] retain];
}
- (void)idleTimerExceeded {
NSLog(@"idle time exceeded");
}
</code></pre>
<p>where maxIdleTime and idleTimer are instance variables.</p>
<p>In order for this to work, you also need to modify your main.m to tell UIApplicationMain to use your delegate class (in this example, AppDelegate) as the principal class:</p>
<pre><code>int retVal = UIApplicationMain(argc, argv, @"AppDelegate", @"AppDelegate");
</code></pre>
|
Designing a Wiki, design considerations and feedback <p>When designing a wiki application, what things should I take into consideration?</p>
<p>So far I have:</p>
<ol>
<li>revisions</li>
<li>parsing some sort of markup text</li>
<li>keeping track of links in wikis, and pages that link to other pages.</li>
<li>related wikis i.e. wikis are related to others.</li>
</ol>
<p>What else goes into building a Wiki?</p>
|
<p>If it's helpful, here is the database schema for Wikipedia (actually MediaWiki, the engine behind Wikipedia):</p>
<p><img src="http://upload.wikimedia.org/wikipedia/commons/4/41/Mediawiki-database-schema.png?" alt="alt text" /></p>
<p><a href="http://upload.wikimedia.org/wikipedia/commons/4/41/Mediawiki-database-schema.png?">http://upload.wikimedia.org/wikipedia/commons/4/41/Mediawiki-database-schema.png?</a></p>
|
Java image library to deskew and crop images <p>Does anybody have a suggestion for a java library that performs automatic cropping and deskewing of images (like those retrieved from a flatbed scanner)?</p>
|
<p><a href="http://www.imagemagick.org" rel="nofollow">ImageMagick</a> can do that; you can use the <a href="http://sourceforge.net/projects/jmagick/" rel="nofollow">ImageMagick Java bindings</a>. The <a href="http://www.imagemagick.org/Usage/crop/#trim" rel="nofollow">auto-crop</a> operator is probably what you're looking for. Automatic deskewing is a much harder problem and involves some significant image processing; I'm not sure if ImageMagick can handle that. If you can figure out the skewing parameters using something else, ImageMagick can definitely unskew it for you.</p>
|
Decoding a PRF file <p>Is there any way to decode a PICS Rules File?
Contains settings and preferences used by the Windows operating system.</p>
<p>The file is given by:</p>
<p>Q:F]9y3n5|dp:n4hU)qbs;!&-bzh</p>
|
<p>The <a href="http://www.w3.org/TR/REC-PICSRules" rel="nofollow">PICSRules spec</a> defines what PICS rules should look like. I don't think your file is one of those.</p>
<p>Is that the <em>entire</em> file contents above?</p>
<p>Are you sure that it's definitely a PICS rules file? There are many file types which use the .prf extension, perhaps it's one of those.</p>
|
C# 4.0 Feedback <p>Does anyone know the official method for submitting feedback on C# 4.0 so that Anders and his team will get the feedback and be able to respond to the submission?</p>
|
<p>Probably the forums <a href="http://social.msdn.microsoft.com/Forums/en-US/vs2010ctpvbcs/threads/" rel="nofollow">here</a>, or (for bugs) <a href="https://connect.microsoft.com/VisualStudio/Feedback" rel="nofollow">connect</a> (they've added options for .NET 4.0 CTP and VS2010 CTP)</p>
|
If I use explicit constructor, do I need to put the keyword in both .h and .cpp files? <p>Actually my question is all in the title.<br>
Anyway:<br>
I have a class and I use explicit constructor:
<br>.h<br></p>
<pre><code>class MyClass
{
public:
explicit MyClass(const string& s): query(s) {}
private:
string query;
}
</code></pre>
<p>Is it obligatory or not to put <b>explicit</b> keyword in implementation(.cpp) file?</p>
|
<p>No, it is not. The <code>explicit</code> keyword is only permitted in the header. My gcc says:</p>
<pre><code>test.cpp:6: error: only declarations of constructors can be 'explicit'
</code></pre>
<p>for the following code:</p>
<pre><code>class foo {
public:
explicit foo(int);
};
explicit foo::foo(int) {}
</code></pre>
|
designing a distributed (over many servers) error logging feature, WCF or? <p>I am designing a error logging feature so our servers (each donig different things) can have a central data store for logging errors.</p>
<p>Would it be a good idea to have the various applications writing to the error log file using a WCF service, or is that a bad idea?</p>
<p>they <em>can</em> do it just by ADO.NET to the database, which I think is the simpler route.</p>
|
<p>I'd say just log to your local data store. The advantages are :</p>
<ol>
<li>Speed - it's pretty rapid to just
dump your chosen error report to an
existing data connection.</li>
<li>Tracability - What happens if you
have an error in your service? You
lose all ability to chase down
errors on all servers. </li>
<li>Simplicity - If you change the
endpoint for your errors service,
you have to update every other
application that uses the error
service.</li>
<li>Reporting - Do you really want to
trawl through error reports from
tens / hundreds of applications in
one place when you could easily find
them in the data store local to the
app?</li>
</ol>
<p>Of course, any of these points could be viewed from the other side, these are just my opinions.</p>
|
Singleton Destructors <p>Should Singleton objects that don't use instance/reference counters be considered memory leaks in C++?</p>
<p>Without a counter that calls for explicit deletion of the singleton instance when the count is zero, how does the object get deleted? Is it cleaned up by the OS when the application is terminated? What if that Singleton had allocated memory on the heap?</p>
<p>In a nutshell, do I have to call a Singelton's destructor or can I rely on it getting cleaned up when the application terminates?</p>
|
<p>As so often, "it depends". In any operating system worthy of the name, when your process exits, all memory and other resources used locally within the process WILL be released. You simply don't need to worry about that.</p>
<p>However, if your singleton is allocating resources with a lifetime outside it's own process (maybe a file, a named mutex, or something similar) then you do need to consider the appropriate cleanup.</p>
<p>RAII will help you here. If you have a scenario like this:</p>
<pre><code>class Tempfile
{
Tempfile() {}; // creates a temporary file
virtual ~Tempfile(); // close AND DELETE the temporary file
};
Tempfile &singleton()
{
static Tempfile t;
return t;
}
</code></pre>
<p>...then you can be reassured that your temporary file WILL be closed and deleted however your application exits. <a href="http://stackoverflow.com/questions/246564/what-is-the-lifetime-of-a-static-variable-in-a-c-function#246594">However, this is NOT thread-safe, and the order of object deletion may not be what you expect or require.</a></p>
<p>however, if your singleton is implemented like THIS</p>
<pre><code>Tempfile &singleton()
{
static Tempfile *t = NULL;
if (t == NULL)
t = new Tempfile();
return *t;
}
</code></pre>
<p>... then you have a different situation. The memory used by your tempfile will be reclaimed, but the file will NOT be deleted because the destructor will not be invoked.</p>
|
HTTP status for functional redirect <p>Right now we've got web pages that show UI elements, and web pages that just process form submissions, and then redirect back to the UI pages. They do this using PHP's header() function:</p>
<pre><code>header("Location: /other_page.php");
</code></pre>
<p>This causes a 302 Found response to be sent; according to the HTTP 1.1 spec, 302 is for cases where "The requested resource resides temporarily under a different URI." <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.3" rel="nofollow">[HTTP 1.1 spec]</a></p>
<p>Functionally, this is fine, but it doens't seem like this is the proper status code for what we're doing. It looks like 303 ("See Other") is the appropriate status here, so I'm wondering if there's any reason not to use it. We'd have to be more explicit in our use of header(), since we'd have to specify that status line rather than just a Location: field. Thoughts?</p>
|
<p>You can use either, but the proper statuscode to use for redirect-after-post is 303.</p>
<p>The confusion has a historical explanation. Originally, 302 specified that the browser mustn't change the method of the redirected request. This makes it unfit for redirect-after-post, where you want the browser to issue a GET request. However, all browsers seems to misinterpret the specs and always issue a GET request. In order to clear up the ambiguity HTTP/1.1 specified two new codes: 303 and 307. 303 essentially specifies the de-facto interpretation of 302, while 307 specifies the original specification of 302. So in practice 302 and 303 are interchangeable, and in theory 302 and 307 are.</p>
<p>If you <em>really</em> care about compatibility, 302 is a safer bet than 303, since HTTP/1.0 agents may not understand 303, but all modern browsers speak HTTP/1.1, so it isn't a real issue. I would recommend using 303, since that's the most correct thing to do.</p>
<p>On a side-note; The <code>Location</code> field should be a full URL. In practice it doesn't matter - browsers are forgiving - but if you care about the specs, that's the proper thing to do.</p>
|
Crystal Reports 8.5 grouping <p>I am grouping using a formula fCity which goes like this
If {X.MailingCity} > "" Then
{X.MailingCity}
Else
{X.City}
I have two different fields in my view (Home City and Mailing City)</p>
<p>Now, these fields contain many rural communities and in my report I want to have these smaller rural communities included with the major city it is located near. I created another group (Specified Order) and created the major cities and was attempting to include the rural cities into these groups. IN the end I ended up with many of the communities in "OTHER" category. It was only picking up rural communities from the X.MailingCity field and not X.City or from my formula fCity.</p>
<p>Have I just confused you. If there is someone who understands what I am doing please respond.</p>
|
<p>You need to relate rural cities and major cities somehow, then you can just group by major cities (or by formula, returning major city for rural one).</p>
|
Where do I start designing when using O/R mapping? Objects or database tables? <p>I'm starting a new database application and I wonder if it would be better to start the design at the objects (with UML) and build the database schema accordingly, or start at the design of the database (with ER) and create the objects accordingly.</p>
<p>What are the pros and cons of either approach?</p>
<p>(I dont think it matters but just in case: I'm planning to use Java and Hibernate)</p>
|
<p>Depends on whether your application is designed to meet user needs, or to meet the needs of developers.</p>
<p>Start with the user stories, and get the OOP Classes straight. And your users will love you.</p>
<p>Otherwise you end up with an application that turns users into data entry clerks. (You'll have lots of company.)</p>
|
Does Castle-Windsor support ForwardedTypes via XML configuration <p>I have a class that implements multiple interfaces.
I would like to register these interfaces via XML.
All I've found is documentation for the new Fluent Interface.
Is this option supported via XML?
What would be involved in adding this feature?</p>
|
<p>[<strong>Update</strong>] This is now possible in Windsor 2.1 or newer. See the documentation for syntax <a href="http://stw.castleproject.org/Windsor.Registering-components.ashx?NoRedirect=1#Component_with_multiple_services_forwarded_types_5" rel="nofollow">here</a>.</p>
<hr>
<p>This feature has not been implemented in the XML interpreter as of yet.. however it is not difficult to add support for it via a facility (obviously this technique is also useful when wanting to add other features absent from the existing configuration parser).</p>
<p>So first off we add a facility which will detect when a handler is created for a type, and at the same time will register any of the forwarded services so they point to the existing handler:</p>
<pre><code>public class HandlerForwardingFacility : AbstractFacility
{
IConversionManager conversionManager;
protected override void Init()
{
conversionManager = (IConversionManager)Kernel.GetSubSystem(SubSystemConstants.ConversionManagerKey);
Kernel.HandlerRegistered += new HandlerDelegate(Kernel_HandlerRegistered);
}
void Kernel_HandlerRegistered(IHandler handler, ref bool stateChanged)
{
if (handler is ForwardingHandler) return;
var model = handler.ComponentModel;
if (model.Configuration == null) return;
var forward = model.Configuration.Children["forward"];
if (forward == null) return;
foreach (var service in forward.Children)
{
Type forwardedType = (Type)conversionManager.PerformConversion(service, typeof (Type));
Kernel.RegisterHandlerForwarding(forwardedType, model.Name);
}
}
}
</code></pre>
<p>And then of course we need to make use of this in code, for this example I'm going to have a mutant duck/dog component that supports two separate services - IDuck and IDog:</p>
<pre><code>public interface IDog
{
void Bark();
}
public interface IDuck
{
void Quack();
}
public class Mutant : IDog, IDuck
{
public void Bark()
{
Console.WriteLine("Bark");
}
public void Quack()
{
Console.WriteLine("Quack");
}
}
</code></pre>
<p>Now to actually configure the container:</p>
<pre><code> <castle>
<facilities>
<facility id="facility.handlerForwarding" type="Example.Facilities.HandlerForwardingFacility, Example" />
</facilities>
<components>
<component id="mutant" service="Example.IDog, Example" type="Example.Mutant, Example">
<forward>
<service>Example.IDuck, Example</service>
</forward>
</component>
</components>
</castle>
</code></pre>
<p>And now we can happily execute a test like this:</p>
<pre><code> WindsorContainer container = new WindsorContainer(new XmlInterpreter());
var dog = container.Resolve<IDog>();
var duck = container.Resolve<IDuck>();
Assert.AreSame(dog, duck);
</code></pre>
<p>Hope this helps.</p>
|
What are the best free software products that improve productivity? <p>What are the best free software products that improve productivity?</p>
|
<p>One of the best compilation of productivity tools for developers -- at least for Windows -- is</p>
<p><a href="http://www.hanselman.com/tools" rel="nofollow">
Scott Hanselman's Ultimate Developer and Power Users Tool List for Windows</a></p>
<p>Many, but not all of them, are free.</p>
|
Any big sites using Client Side XSLT? <p>Lately, I've been pondering the somewhat non-mainstream architecture of building raw XML on the server side, and then using an XSLT stylesheet on the client to transform the XML into the full UI. Of course, a fallback mechanism would have to exist if the client was not capable of client side XSLT, in which case we'd just transform it for them on the server side.</p>
<p>I'm already intimately familiar with XSLT, and this approach seems to be a clean separation of presentation and content, completely forcing the data into XML, and using XSLT for presentation.</p>
<p>I'm also aware that this does add an extra layer of complexity to the application, which is just another moving part that can fail.</p>
<p>My question is: are there any big name or big traffic sites using this approach, and if so: what limitations/lessons learned did you take away from it?</p>
<p>Thanks Internet,
Zach</p>
|
<p>Like other people have mentioned, Blizzard has many sites that are client side xsl. I would recommend avoiding client side xsl. It is a really cool idea, but there are many unusual bugs that you need to work around.</p>
<p>In Firefox, any javascript that uses document.write will destroy the DOM. Also, the noscript plug-in for firefox stops client side xsl. In both cases, the user will see nothing. There doesn't seem to be a way to detect this kind of error, so a fall back will not work.</p>
<p>In IE, if you have anything that does a 30x redirect to something of a different origin (going from http to https or crossing sub domains), you will get an error for violating the <a href="http://en.wikipedia.org/wiki/Same%5Forigin%5Fpolicy">same origin policy</a>. You did not really violate the same origin policy, but IE acts like you did. For example, if you go to <a href="http://foo.example.com/login">http://foo.example.com/login</a> and that does a 302 redirect to https://bar.example.com/login.xml, IE will treat the xsl as if it came from bar.example.com and it will treat the xml as if it came from foo.example.com. So you will need to revert to something like a meta refresh for your redirects.</p>
<p>These are the things that I came up with off the top of my head. It is a neat idea, but be aware of these issues.</p>
|
Checking if an instance's class implements an interface? <p>Given a class instance, is it possible to determine if it implements a particular interface? As far as I know, there isn't a built-in function to do this directly. What options do I have (if any)?</p>
|
<pre><code>interface IInterface
{
}
class TheClass implements IInterface
{
}
$cls = new TheClass();
if ($cls instanceof IInterface)
echo "yes"
</code></pre>
<p>You can use the "instanceof" operator. To use it, the left operand is a class instance and the right operand is an interface. It returns true if the object implements a particular interface.</p>
|
OpenGL background transparency? <p>I'm using QT's QGLFramebufferObject for off-screen rendering.<br />
After rendering to the buffer I read the result using glReadPixels()<br />
The problem is that sometimes the background color I read is just 0 (transparent black) and sometimes it is 0xFF000000 (opaque black)<br />
This seem to be related to the time the buffer is initialized. If the buffer is a member of the class inherited from QGLWidget then it is 0. If it is initialized anywhere else it's 0xFF000000. </p>
<p>Does anybody have any idea what's going on here? What is the good expected result of this read?</p>
|
<p>Do you set up the correct clear color (glClearColor) and actually do a clear (glClear)? Are you making sure that your color write (glColorMask) mask is fully enabled (it also affects clears). Next you can check if QT sets up some weird pixel copy transfer (other than the default, see glPixelStore, glPixelTransfer and glPixelMap). Are you sure you are getting (and reading into) an RGBA buffer in both cases, not just RGB? Lastly, it is very well possible that the framebuffer object extension is buggy on your particular graphics card/driver combination, more so if there is no primary visible window. At least check cards from both vendors. And of course always check glGetError after all potentially failing operations.
After re-reading your question, do you get any other valid rendering in the non QGLWidget case at all? Does clear to say green, return green? Because it might very well be that you just did not initialize any valid OpenGL context to begin with in that case. Framebuffer objects, unlike pbuffers need an external context. </p>
|
Creating a DLNA server/service in VB.NET <p>I would like to create a DLNA server in VB.NET.
Since a lot of multimedia devices start supporting DLNA, i would like to see what is possible. Not only streaming video/audio and pictures but see what else can be done.</p>
<h2>Anybody any starting points? protocol info, some basic code to get started?</h2>
<p>DLNA is based on UPnP so i geuss that is the direction i have to start looking. </p>
|
<p><a href="http://www.mperfect.net/whsUpnp360/">UPnP MediaServer using Intels SDK for Windows Home Server and Xbox 360</a> is written in C# and does not have all the functionallity required but it is a start.</p>
<p>I'd like to see an open source implementation of DLNA in .NET</p>
|
Parallel quicksort: recursion using Boost Bind? <p>I am working on making quicksort parallel, threads being the first attempt. The non threaded version sorts correctly but the threaded doesn't (no surprise there). What I found interesting was when I removed the threads but kept the boost::bind calls it still doesn't work. If boost::bind isn't what I want please offer a suggestion. Bind seemed to be the easiest (or only) way to make my function work with boost threads.</p>
<pre><code>void Quicksort( fVec &Array, const int Left, const int Right )
{
if( Right <= Left )
return;
int pivot = Left;
const int pivotNewIndex = Partition( Array, Left, Right, pivot );
// These function calls make it work fine
//Quicksort( Array, Left, pivotNewIndex - 1 );
//Quicksort( Array, pivotNewIndex + 1, Right );
// boost::bind calls only swaps one element, doesn't actually sort
boost::bind( &Quicksort, Array, Left, pivotNewIndex - 1 )();
boost::bind( &Quicksort, Array, pivotNewIndex + 1, Right )();
// threaded version that doesn't work, same as above
//boost::thread threadA( boost::bind( &Quicksort, Array, Left, pivotNewIndex - 1 ) );
//threadA.join();
//boost::thread threadB( boost::bind( &Quicksort, Array, pivotNewIndex + 1, Right ) );
//threadB.join();
}
</code></pre>
|
<p>Boost bind more or less creates a functor that when called, will call the function you want with the arguments you want. In this case you are creating the functor but never calling it. Try:</p>
<pre><code>boost::bind( &Quicksort, Array, Left, pivotNewIndex - 1 )();
boost::bind( &Quicksort, Array, pivotNewIndex + 1, Right )();
</code></pre>
<p>Im guessing the first argument is what is messing it up. I think bind requires arguments to be copyable, and references aren't really, it is probably creating a copy and passing the reference to that, which is why nothing is changing. Try:</p>
<pre><code>boost::bind( &Quicksort, boost::ref(Array), Left, pivotNewIndex - 1 )();
boost::bind( &Quicksort, boost::ref(Array), pivotNewIndex + 1, Right )();
</code></pre>
<p>It would help to know what fVec is and why you aren't passing a pointer to the array of whatever you are sorting.</p>
<p>Also note that this method of threading is likely to not give very much speedup because as you get to very small sorts the overhead of starting and scheduling a new thread is much larger than the benefit (plus you will be creating massive numbers of threads which is bad). What you really want is a threadpool that operates on some optimum size chunk or larger and has a fixed number of threads. When sizes smaller than the limit are reached, it does everything serially (and for smaller still you would obviously want to change from quicksort to insertion sort).</p>
<p>Also note that the order you are joining leads to serial execution anyways... you want to join both threads after you start both threads.</p>
|
How to publish our Webservices <p>I have created an web service I need to publish this service. I need to host and authenticated users need to access my services using ASP.net 2.0</p>
|
<p>I'm not sure if you are asking for an alternative, but I've been experimenting with <a href="http://www.codeproject.com/KB/WCF/generic_wcf_host.aspx" rel="nofollow">this code</a> that seems to work well on codeproject.com (CP).
<br><br>
If your question is on security, perhaps <a href="http://www.codeproject.com/KB/WCF/wcfcertificates.aspx" rel="nofollow">this article</a> on CP is a useful start.</p>
|
How do you test a public/private DSA keypair? <p>Is there an easy way to verify that a given private key matches a given public key? I have a few *.pub, and a few *.key files, and I need to check which go with which.</p>
<p>Again, these are pub/key files, DSA.</p>
<p>I would really prefer a one-liner of some sort...</p>
|
<p>I found a way that seems to work better for me:</p>
<pre><code>ssh-keygen -y -f <private key file>
</code></pre>
<p>that command will output the public key for the given private key, so then just compare the output to each *.pub file.</p>
|
System Calls: UNIX, Linux, BSD and Solaris variations <h3>Are there differences between the amount of syscalls in the major *NIX variants ?</h3>
<h3>Which syscalls would be supported universally ?</h3>
|
<p>Anything that is not a posix standard may be an additional system call, or it maybe additional library functionality above the system call layer. If your goal is to write portable code stick to posix, and use the c library (as opposed to direct system calls) as much as possible.</p>
<p>If you are just curious, they vary quite widely. You do not need to support much in the way of system calls in order to be posix compliant. It specifies interfaces you need to support, but whether you do that through calling into the kernel or jumping into a shared library is pretty much up to you.</p>
<p>Mac OS X does not even guarantee binary compatibility for system calls between releases, they consider them private interfaces between the the system libraries and the OS. What most people consider to be system calls are actually small stubs in a dynamic library that call through to the kernel, and if you make the system calls directly instead of linking to that dynamic library and calling the stub functions then your code may break between OS releases.</p>
<p>That flexibility means a number of OSes implement system calls that are completely different from what they need to support posix, then deal with the differences in their libraries. For example, Linux's threading implementation is based around a system call called clone(), and they deal with much of the bookkeeping to make the pthreads interface work in their libraries.</p>
<p>So if your goal is to implement a standard library the does not link against anything else and works on multiple unixes, you may find things a bit tricky in some cases. If your goal is to write something that links against the standard libraries on various Unixes you can get a generally uniform interface.</p>
|
Session is lost with login control in Internet Explorer 7 <p>After logging in using the Login control the browser loses the session. This only occurs in Internet Explorer 7. Has anyone else run into this problem? If so, do you know a work around?</p>
|
<p>I would suggest downloading a tool like <a href="http://www.blunck.se/iehttpheaders/download.html" rel="nofollow">ieHTTPHeaders</a> to trace the request/respnonse headers in IE and seeing at what point either IE stops sending the cookie or the server clears it. </p>
<p>You should see a POST to your login page and the server should respond with a Set-Cookie:, and that cookie should be in every subsequent request.</p>
|
How can I call Perl from Java? <p>I have a Perl module that I would like to use from Java. Is there a way to call this code using either ActiveState Perl on Windows or the generic Perl that comes with Linux? I have found references to JPL but it doesnât appear to be maintained anymore.</p>
|
<p><a href="http://search.cpan.org/~patl/Inline-Java-0.52/Java.pod">Inline-Java</a> is the usual library to call java from Perl, and this <a href="http://www.piersharding.com/blog/archives/2004/04/calling_perl_fr.html">post propose a <strong>org.perl.java</strong></a> module which should allow calling Perl from Java, as asked.</p>
<p>However, because of the unpredictability of the JNI implementations for different
JVMs it is difficult to say what combinations of JVM and Perl will work. Typically, what is required is Perl with MULTIPLICITY, and threads compiled in. That means he uses a custom built Perl.</p>
<p>Otherwise, <strong><a href="http://linux.wareseeker.com/Programming/inline-java-callback-0.52.zip/326355">Inline::Java::Callback</a></strong> allows you to call Perl functions from Java. To do this you need to create an <code><strong>org.perl.inline.java.InlinePerlCaller</strong></code> object. Here is a example of a typical use:</p>
<pre><code>use Inline Java => <<END ;
import java.util.* ;
import org.perl.inline.java.* ;
class Pod_regexp extends InlineJavaPerlCaller {
public Pod_regexp() throws InlineJavaException {
}
public boolean match(String target, String pattern)
throws InlineJavaException {
try {
String m = (String)CallPerlSub("main::regexp",
new Object [] {target, pattern}) ;
if (m.equals("1")){
return true ;
}
}
catch (InlineJavaPerlException pe){
// $@ is in pe.GetObject()
}
return false ;
}
}
END
my $re = new Pod_regexp() ;
my $match = $re->match("Inline::Java", "^Inline") ;
print($match . "n") ; # prints 1
sub regexp {
my $target = shift ;
my $pattern = shift ;
return ($target =~ /$pattern/) ;
}
</code></pre>
|
Style for web application grid <p>I'm working on a small bugtracking system which shows a list of bugs. For the overview I want to use a grid - now I only need a style. </p>
<p>Of course I won't copy the whole style from anyone else, but I just want to know which type of styles you like. Do you have any other great style?</p>
<p>What do you think about the styles on <a href="http://mattberseth.com/blog/2008/06/4_new_grouping_grid_skins_vist.html" rel="nofollow">this site</a>.
Do you like the <a href="http://www.componentart.com/webui/demos/demos_control-specific/grid/design/default/WebForm1.aspx" rel="nofollow">Component art grid styles</a>?
What about the <a href="http://demos.telerik.com/aspnet-ajax/grid/examples/overview/defaultcs.aspx" rel="nofollow">styles from telerik</a>?</p>
<p>Thanks for your help</p>
|
<p><a href="http://icant.co.uk/csstablegallery/" rel="nofollow">CSS table gallery</a> can be a great source of inspiration.</p>
<p>The CSS Table Gallery is a showcase of how CSS and data tables can work together to create usable and pretty results. </p>
|
Wheel Reinvention Avoidance for Web Rating Feature <p>I have a need to implement a rating feature and would like to do it the mouse-over stars way similar to netflix.</p>
<p>What is my best approach? Here are some that come to mind.</p>
<ul>
<li>code it up by hand in HTML and
javascript</li>
<li>use flash or a java applet</li>
<li>use <a href="http://www.nickstakenburg.com/projects/starbox/" rel="nofollow">Starbox</a> (if you have used Starbox, then feel free to comment on it)</li>
<li>use another java script library (please specify)</li>
</ul>
|
<p>I really like <a href="http://www.fyneworks.com/jquery/star-rating/" rel="nofollow">jQuery Star Rating Plugin</a>, non-obstrusive, will work even if JavaScript is disabled, its based on a set of radio input boxes, and its very easy to use.</p>
|
Accessing the value of a session variable of a specific session <p>I'm trying to integrate a public message board service into an existing web site. </p>
<p>The handshaking between the apps goes like this:</p>
<p>1) File on my web site loads a flash file. The Flash reads a local variable that is the Session ID, or some other GUID unique to the user session.</p>
<p>2) Flash app connects with the remote service, passing the SessionID to the service.</p>
<p>3) The service issues a GET request back to the originating web site, asking for additional information about the user.</p>
<p>4) The originating web site (my site) validates that the session ID is for a valid session, and if yes, passes back the other requested information. </p>
<p>I'd like to be able to use the intrinsic ASP SessionID but I'm not sure how in Classic ASP to retrieve session variables for a <strong>specific</strong> ASP Session, ie, I want the value of Session("FirstName") where SessionID=1234 and not Session("FirstName") for any other session ID. I haven't been able to find any syntax that would allow me to do this.</p>
<p>The alternative is to create a new GUID for every session, but that's adding a lot of overhead.</p>
<p>Any ideas?</p>
|
<p>I'm not aware of any way to retrieve Session details for a particular instance or ID.
However, you could utilise the Application object to store the information you need using the Session.SessionID value:</p>
<p>Application(Session.SessionID & tag) = myTagValue</p>
<p>This way you are not creating a new GUID, but utilising the already existing one for session that both client and server are using in your example.</p>
|
Java: How do I know which jar file to use given a class name? <p>Given a class, <a href="http://help.eclipse.org/stable/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/org/eclipse/ui/views/navigator/ResourceNavigator.html">org.eclipse.ui.views.navigator.ResourceNavigator</a> for example, how do I find out which jar file to use? I know it's in org.eclipse.ui.ide, but how would I find that out?</p>
<p><strong>Edit</strong>: Thank you to all of you who answered. Like many things, there seems to be several ways to skin this cat. I wish javadoc contained this info. So far here are the different methods:</p>
<ol>
<li><p>Without Internet, Eclipse or NetBeans:</p>
<pre><code>for f in `find . -name '*.jar'`; do echo $f && jar tvf $f | grep -i $1; done
</code></pre></li>
<li><p>If you want to find out locally using Eclipse:</p>
<ul>
<li><a href="http://www.alphaworks.ibm.com/tech/jarclassfinder">JAR Class Finder Plug-in</a></li>
<li><a href="http://classlocator.sourceforge.net/">Class Locator Plug-in</a></li>
</ul></li>
<li><p>If you want to find out from Internet or you do not have the jar yet:</p>
<ul>
<li><a href="http://www.jarfinder.com/">jarFinder</a></li>
</ul></li>
</ol>
|
<p>If you have the jar in your class path / project path hit CTRL-SHIFT-T and type the name ... the jar will be displayed at the bottom.</p>
<p>If you haven't the class in your build path
a) put together a dummy project containing all the jars
b) I think there is a plugin to find jars from IBM Alphaworks (but that might be kind of outdated)</p>
|
Shutterfly Order API . <p>I found this site</p>
<p><a href="http://www.shutterfly.com/documentation/api_OrderImage.sfly" rel="nofollow">http://www.shutterfly.com/documentation/api_OrderImage.sfly</a></p>
<p>but there are no examples of actually walking through the whole process. Does anyone have any good documentation on using this API to take a local photo and allow someone to order a print via shutterfly?</p>
|
<p>I went through these steps:</p>
<ul>
<li><a href="https://www.shutterfly.com/signup/viewSignup.sfly">Sign up for an account</a></li>
<li><a href="https://www.shutterfly.com/developer/apps.sfly">Sign up as a developer</a></li>
</ul>
<p>Create an application (I called mine Test). Note the generated <strong>Application Id</strong> and <strong>Shared Secret</strong></p>
<p>The <a href="http://www.shutterfly.com/documentation/start.sfly">Shutterfly API page</a> has a list of references for various Domain-specific APIs:</p>
<ul>
<li><a href="http://www.shutterfly.com/documentation/api%5FAddressBook.sfly">Address Book</a></li>
<li><a href="http://www.shutterfly.com/documentation/api%5FAlbum.sfly">Album Data</a></li>
<li><a href="http://www.shutterfly.com/documentation/api%5FFolder.sfly">Folder Data</a></li>
<li><a href="http://www.shutterfly.com/documentation/api%5FImageUpload.sfly">Go To Shutterfly UE</a></li>
<li><a href="http://www.shutterfly.com/documentation/IsiSetup.sfly">Image Upload</a></li>
<li><a href="http://www.shutterfly.com/documentation/api%5FProctaserv.sfly">Interactive Sign-in</a></li>
<li><a href="http://www.shutterfly.com/documentation/api%5FOrder.sfly">Image Request</a></li>
<li><a href="http://www.shutterfly.com/documentation/api%5FOrder.sfly">Order</a></li>
<li><a href="http://www.shutterfly.com/documentation/api%5FPricing.sfly">Pricing</a></li>
<li><a href="http://www.shutterfly.com/documentation/SsiSetup.sfly">Seamless Sign-in</a></li>
<li><a href="http://www.shutterfly.com/documentation/api%5FUser.sfly">User Data</a></li>
<li><a href="http://www.shutterfly.com/documentation/api%5FUserAuth.sfly">User Authentication</a></li>
</ul>
<p>Each uses RESTful principles. The documentation looks pretty comprehensive to me, if you need some background, here's links for <a href="http://www.xfront.com/REST-Web-Services.html">RESTful</a> APIs and <a href="http://www.xml.com/pub/a/2006/02/22/rome-parse-publish-rss-atom-feeds-java.html">ROME</a> you may find useful</p>
<p>There is also an <strong>API Explorer</strong> section on the same page that allows you to test the methods via a form on their site. For example this form for <a href="https://www.shutterfly.com/documentation/api%5FExplorerAlbum.sfly">CRUD operations on the album data</a>.</p>
<p>Based on your comment, for your requirements, you would:</p>
<ul>
<li>Use the <a href="http://www.shutterfly.com/documentation/api%5FAlbum.sfly#GET">Album GET</a> to list albums, then get the data for a specific album.</li>
<li>Use the <a href="http://www.shutterfly.com/documentation/api%5FProctaserv.sfly#GET">Image Get</a> request to retrieve the image data, so your friend can verify the image(s) they want to purchase.</li>
<li><a href="http://www.shutterfly.com/documentation/AuthAuth.sfly">Authenticate the user</a></li>
<li>Use the <a href="http://www.shutterfly.com/documentation/api%5FPricing.sfly#POST">Pricing POST</a> request to get the estimated pricing for the image.</li>
<li>User the <a href="http://www.shutterfly.com/documentation/api%5FOrder.sfly#POST">Order POST</a> to submit the order over https</li>
</ul>
<p><hr /></p>
<p>Update: Found a page <a href="http://quasistoic.org/ts/archives/2005/06/22/flickr-shutterfly/">describing</a> using a Greasemonkey script which adds Shutterfly print ordering capability to Flickr. This might provide the basis for a solution.</p>
|
XHTML and & (Ampersand) encoding <p>My website is XHTML Transitional compliant <strong>except for one thing</strong>: the & (ampersand) in the URL are written as it is, instead of <code>&amp;</code></p>
<p>That is, all the urls in my pages are usually like this:</p>
<pre><code><a href="http://www.foo.com/page.aspx?x=1&y=2">Foo</a>
</code></pre>
<p>But <a href="http://validator.w3.org/">XHTML validator</a> generates this error:</p>
<blockquote>
<p>cannot generate system identifier for general entity "y"</p>
</blockquote>
<p>... and it wants the url to be written like this:</p>
<pre><code><a href="http://www.foo.com/page.aspx?x=1&amp;y=2">Foo</a>
</code></pre>
<p>The problem is that IE and Firefox don't handle the URL correctly and ignore the y parameter. <strong>How can I make this link work and validate correctly?</strong></p>
<p>It seems to me that it is impossible to write XHTML pages if the browsers don't work with strict encoded XHTML URLs.</p>
<p>Do you want to see in action? See the difference between these two links (copy and paste them as they are): </p>
<pre><code>http://stackoverflow.com/search?q=ff&sort=newest
</code></pre>
<p>and</p>
<pre><code>http://stackoverflow.com/search?q=ff&amp;sort=newest
</code></pre>
|
<p>I have just tried this. What you attempted to do is correct. In HTML if you are writing a link the <code>&</code> characters should be encoded as <code>&amp;</code> You would only encode the <code>&</code> as <code>%26</code> if you wanted a parameter value to contain an ampersand. I just wrote a simple HTML page that contained a link: <code><a href="Default2.aspx?param1=63&amp;param2=hel">Click me</a></code>
and it worked fine: <code>default2.aspx</code> received the parameters intended and the source passed validation.</p>
<p>The encoding of <code>&</code> as <code>&amp;</code> is required in HTML, not in the link. When the browser sees the <code>&amp;</code> in the HTML source for a link it will interpret it as an ampersand and the link target will be as intended. If you paste a URL into your browser address bar it does not expect it to be HTML and does not try to interpret any HTML encoding that it may contain. This is why your example links that you suggest we should copy/paste into a browser don't work and why we wouldn't expect them to work.</p>
<p>If you post a bit more of your actual code we might be able to see what you have done wrong, but you appear to be heading the right direction by using <code>&amp;</code> in your anchor tags.</p>
|
Regex for names <p>Just starting to explore the 'wonders' of regex. Being someone who learns from trial and error, I'm really struggling because my trials are throwing up a disproportionate amount of errors... My experiments are in PHP using ereg().</p>
<p>Anyway. I work with first and last names separately but for now using the same regex. So far I have:</p>
<pre><code>^[A-Z][a-zA-Z]+$
</code></pre>
<p>Any length string that starts with a capital and has only letters (capital or not) for the rest. But where I fall apart is dealing with the special situations that can pretty much occur anywhere.</p>
<ul>
<li>Hyphenated Names (Worthington-Smythe) </li>
<li>Names with Apostophies (D'Angelo) </li>
<li>Names with Spaces (Van der Humpton) - capitals in the middle which may or may not be required is way beyond my interest at this stage.</li>
<li>Joint Names (Ben & Jerry)</li>
</ul>
<p>Maybe there's some other way a name can be that I'm no thinking of, but I suspect if I can get my head around this, I can add to it. I'm pretty sure there will be instances where more than one of these situations comes up in one name.</p>
<p>So, I think the bottom line is to have my regex also accept a space, hyphens, ampersands and apostrophes - but not at the start or end of the name to be technically correct.</p>
|
<p>This regex is perfect for me.</p>
<pre><code>^([ \u00c0-\u01ffa-zA-Z'\-])+$
</code></pre>
<p>It works fine in php environments using preg_match(), but doesn't work everywhere.</p>
<p>It matches <code>Jérémie O'Co-nor</code> so I think it matches all UTF-8 names.</p>
|
Excel / Quickbooks data to c# <p>I know how to use the OleDbConnection class to open an excel file and select from it, but is there a simple method to read the data from an excel file that has been read into a Stream? And is there also a similar method for QuickBooks?</p>
|
<p>Stream? No, Excel files are a complicated mess. Quickbooks, yeah. I found this <a href="http://www.synergration.com/accessbooksrt/" rel="nofollow">ODBC driver</a>, it should support OdbcDataAdapter.</p>
|
How can I increase the stack size with runhaskell? <p>I'm writing some disposable Haskell scripts to solve some of the <a href="http://projecteuler.net">Project Euler</a> problems. I don't really want to have to compile them because of the number of changes I'm constantly having to make, but in a few cases I've found that I've run out of stack space.</p>
<p>The documentation for <code>runhaskell</code> says that the following syntax should increase the stack space:</p>
<pre><code>runhaskell +RTS -K5M -RTS Script.hs
</code></pre>
<p>This never, ever works (in any permutation I've tried). The stack size always remains 8,388,608. This is maddening, and I haven't found much help on Google.</p>
<p>Any suggestions? What am I doing wrong?</p>
|
<p>I'm guessing you're using GHC. Chapter 4 of the User's Guide of the newly released 6.10.1 says: </p>
<blockquote>
<p>The only runghc flag currently is -f
/path/to/ghc, which tells runghc which
GHC to use to run the program.</p>
</blockquote>
<p>I don't see a bug logged at <a href="http://hackage.haskell.org/trac/ghc">http://hackage.haskell.org/trac/ghc</a> . Seems pretty lame to me. I'd suggest asking on irc #ghc, or the cvs-ghc mailing list.</p>
<p>Of the other Haskell compilers/interpreters, only nhc98 seems allow you to set the max stack size. Depending on your OS, nhc98 could be an option. </p>
|
Best practices for project organization with ASP.NET MVC <p>I recently downloaded Rob Conery's excellent <a href="http://blog.wekeroad.com/mvc-storefront/">ASP.NET Storefront reference application</a> and am finding it incredibly instructive. One question that comes to mind is where one should place the Model classes (and the Data classes upon which they depend). The MVC project template creates a Model folder. But it seems to me that I would be better served breaking the model out into a separate project assembly so that it can be re-used by other potential applications (e.g. management tools related to the website's application domain)?</p>
<p>I'm curious to get people's opinions.</p>
|
<p>It really depends on the size of the project. There's no inherent value in having a separate "models" assembly, as you can unit test a Web Application project (including MVC projects).</p>
|
Top-level .mak file for Visual Studio? <p>I've inherited a body of Visual C++ source that consists of about a dozen sub-projects. One of these is an empty "MakeAll" project that depends on all the others, so I can build the entire project by setting the MakeAll project active and selecting "Build All."</p>
<p>I'd like to automate this process, and coming from a linux environment, my instinct was to generate a Makefile and build from the command line. The IDE will generate <code>.mak</code> files for each of the sub-projects, but not for the top-level MakeAll. (I'm assuming this is because it contains nothing but dependencies.)</p>
<p>The linux answer would be a Makefile that simply descends into each of the sub-projects and executes <code>make</code> in each one. But a quick look at the <code>.mak</code> files showed that each wants to be told which of several configurations to use -- and apparently some use Debug, some use Release, and some use configurations concocted by a previous developer.</p>
<p>What's the accepted way to build a set of projects like this from the command line?</p>
<p>Thank you!</p>
|
<p>You don't have to use make - if you have everything as solution files (.sln) then you can automate the build by using <a href="http://msdn.microsoft.com/en-us/library/0k6kkbsd.aspx" rel="nofollow">the msbuild tool</a>:</p>
<pre><code>msbuild solution.sln
</code></pre>
<p>Also, why do you have a "MakeAll" project? Visual Studio doesn't require this kind of hackery, just do a "build all" and it will build everything satisfying dependancies just like a typical "make all" rule would.</p>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.