instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I would like to know how to get the name of the property that a method parameter value came from. The code snippet below shows what I want to do:</p>
<pre><code>Person peep = new Person();
Dictionary<object, string> mapping = new Dictionary<object, string>();
mapping[peep.FirstName] = "Name";
Dictionary... | <p>You are not able to do so in this way, since the way it works is that C# evaluates the value of FirstName property by calling its get accessor and passes the value of that to the indexer of the dictionary. Therefore, the way you found out FirstName value is completely lost. Just like the way you evaluate 2 + 2.
If y... | <p>I don't know much about C#, but I suppose <em>peep</em> is an enum? As for Java, you could do:</p>
<pre><code>String propertyName = kvp.key.toString()
</code></pre>
<p>Maybe there's something similar in C#?</p>
<p>And even if peep isn't a enum: I see no reason why the key should be an arbitrary object? So maybe t... | 37,368 |
<p>How do I set the column which has the header sort glyph, and its direction, in a .NET 2.0 WinForms ListView?</p>
<h2>Bump</h2>
<p>The listview is .net is not a managed control, it is a very thin wrapper around the Win32 ListView common control. It's not even a very good wrapper - it doesn't expose all the features... | <p>In case someone needs a quick solution (it draws up/down arrow at the beginning of column header text):</p>
<p><strong>ListViewExtensions.cs:</strong></p>
<pre><code>public static class ListViewExtensions
{
public static void DrawSortArrow(this ListView listView, SortOrder sortOrder, int colIndex)
{
... | <p>I use unicode arrow characters in the title of the column and make the header a linkbutton.</p>
| 9,901 |
<p>hey, I'm very new to all this so please excuse stupidity :)</p>
<pre><code>import os
import MySQLdb
import time
db = MySQLdb.connect(host="localhost", user="root", passwd="********", db="workspace")
cursor = db.cursor()
tailoutputfile = os.popen('tail -f syslog.log')
while 1:
x = tailoutputfile.readline()... | <p>As pointed out, you're failing to copy the Python variable values into the query, only their names, which mean nothing to MySQL.</p>
<p>However the direct string concatenation option:</p>
<pre><code>cursor.execute("INSERT INTO releases (date, cat, name) VALUES ('%s', '%s', '%s')" % (timestring, y[4], y[7]))
</code... | <p>never use "direct string concatenation" with SQL, because it's not secure, more correct variant:</p>
<pre><code>cursor.execute('INSERT INTO releases (date, cat, name) VALUES (%s, %s, %s)', (timestring, y[4], y[7]))
</code></pre>
<p>it automatically escaping forbidden symbols in values (such as ", ' etc)</p>
| 32,138 |
<p>We're looking at moving from a check-out/edit/check-in style of version control system to Subversion, and during the evaluation we discovered that when you perform an Update action in TortoiseSVN (and presumably in any Subversion client?), if changes in the repository that need to be applied to files that you've bee... | <p>The best way around this is to educate the developers.
After you do an update in TortoiseSVN it shows you a list of affected files. Simply double clicking each file will give you the diff between them. Then you'll be able to see what changed between your version and the latest repository version.</p>
| <p>This is why automated (unit) testing is a fundamental part of distributed software development. In the example you give, at least one unit test should fail on svn update and alert you to the error.</p>
<p>Remember what Subversion is: a version control system, not a perfectly-working-code-merging-tool.</p>
| 7,735 |
<p>Is there an easy way to tell Windows not to display popups on a headless server machine?</p>
<p>Currently occasional application popups are causing my app to freeze because no one is available to press 'Okay' on the console. Just logging to the eventlog would be more than sufficient.</p>
| <p>Depending on precisely what popups need to be handled, there are a couple of approaches.</p>
<ol>
<li>For hard error popup handling, <a href="http://support.microsoft.com/kb/128642" rel="nofollow noreferrer" title="HOWTO: How To Change Hard Error Popup Handling in Windows NT">HOWTO: How To Change Hard Error Popup H... | <p>It all depends on the kind of popup, from system's message box to custom dialog. So I don't think there is a generic solution to this.</p>
<p>Should I have the problem, I would use a macro language, like AutoHotkey (or AutoIt), to detect the activation of the popup and automate the click on the discard button.</p>
... | 25,997 |
<p>I have just started using silverlight 2 beta and cannot find how to or if it is possible to render a canvas to an bitmap image and then upload it to my web server?</p>
<p>Is this possible and if so how would I complete this task?</p>
<hr>
<p><strong>Update:</strong> This is now possible under silverlight 3 using ... | <p>You can't render a canvas to a bitmap in Silverlight 2, but if you could generate a XAML version of your Canvas, you could pass it to the server and do something like this server side:</p>
<p><a href="http://www.thedatafarm.com/blog/2008/01/31/ConvertingSilverlightInkPresenterImagesToAPNGFile.aspx" rel="nofollow no... | <p>The only option you have now (if you want it done in the Silverlight CLR on the client side) is to start with fjcore</p>
<p><a href="http://code.google.com/p/fjcore/" rel="nofollow noreferrer">http://code.google.com/p/fjcore/</a></p>
<p>It's only a starting point, you will have to write a lot of code -- it mainly ... | 17,876 |
<p>The navigation on the left menu in the below site uses CSS for mouseover links.<br /><a href="http://www.pvh.com/" rel="nofollow noreferrer">PVH</a></p>
<p>When I take the code of the navigation and make it separate page. Then the mouseover links are not working. What could be the reason?<br />
<a href="http://shiv... | <p>Probably...</p>
<pre><code><script src="menu_1b.js" type="text/javascript">
</script>
<script src="menu_com.js" type="text/javascript">
</code></pre>
<p>have something to say on the matter. EDIT: A function called function CreateMenuStructureAgain() kind of gives it away.</p>
| <p>As mentioned, you needed to take the scripts too. I was going to take a look at a solution for you but then I opened the JS code you were attempting to use. You could do a lot better with a lot less code. Try looking at <a href="http://htmldog.com/articles/suckerfish/dropdowns/example/vertical.html" rel="nofollow... | 41,020 |
<p>In the C# example of polymorphism, there is a Cat class which inherits a class called AnimalBase and an interface called IAnimal.</p>
<p>The link in question is: <a href="http://en.wikipedia.org/wiki/Polymorphism_in_object-oriented_programming" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Polymorphism_in_... | <p>The statement that "inheriting from a base class allows you to inherit BEHAVIOR, whereas implementing an interface only lets you specify INTERACTION" is absolutely true.</p>
<p>But more importantly, interfaces allow statically typed languages to continue to support polymorphism. An Object Oriented purist would ins... | <p>Base classes and interfaces really have mostly unrelated purposes. The main purpose of the base class is for your inheriting class to be able to import some common functionality. The main purpose of the interface is for <em>other</em> classes to be able to ask the question, "does this object support interface X"?<... | 49,687 |
<p>I've been given a requirement for an internal web application to send documents to a printer transparently. The idea would be that the user can select their nearest printer, and the web application would send their print jobs to the printer they selected.</p>
<p>The first printer we have to roll out against are Ca... | <p>The key phrase in that question is 'web application'. </p>
<p>In a normal web app using only HTML+Javascript over HTTP, you <em>can't</em> just send a document directly to a printer. That's one of the reasons web browsers exist, and without that functionality everyone's printer would collect the same kind of junk... | <p>This code works perfectly
It uses Adobe reader itself to print</p>
<p>Hints to use
1- don't forget to provide your own install path to adobe reader
2- Get printer name from Properties of the Printer you want to print with</p>
<p>use the class like this:</p>
<pre><code>PdfFilePrinter p = new PdfFilePrinter();
p.... | 26,891 |
<p>When writing production-quality VC++ code, is the use of recursion acceptable? Why or why not?</p>
| <blockquote>
<p>Is there a way to determine at what point I would encounter a stack overflow?</p>
</blockquote>
<p>Not really. A stack overflow happens when you exhaust the stack space - however...</p>
<ul>
<li>The initial stack size can be changed programatically and may default to different amounts depending on y... | <p>Sure - e.g. if you want to traverse a tree structure what else would you use ? </p>
<p>Maybe you would like to have something like a maximum depth to be sure you're not writing an infinite loop. (if this makes sense in your example)</p>
| 5,822 |
<p>I have an instance of a general purpose class that will be executed both under
ASP.NET and a stand alone program. This code is sensative to the process where it
is being run - that is, there are certin methods that should not called if
running under ASP.NET. How do you determine if the code is executing in an ASP.NE... | <p>HttpContext.Current can also be null within ASP.NET if you're using asynchronous methods, as the asynchronous task happens in a new thread that doesn't share the HttpContext of the original thread. This may or may not be what you want, but if not then I believe that HttpRuntime.AppDomainAppId will be non-null anywhe... | <p>This is my answer to the question.</p>
<p>First, make sure your project references System.Web and that your code file is "using System.Web;".</p>
<pre><code>public class SomeClass {
public bool RunningUnderAspNet { get; private set; }
public SomeClass()
//
// constructor
//
{
try {
... | 25,755 |
<p>I am looking for the best way to customize my Rails log entries (I want to add the user ID in there). I am using Rails 2.1.2. The only way I've found so far is to override method "add" of class BufferedLogger (as defined in active_support/lib/active_support). </p>
<p>But it ain't pretty: I have to copy all the code... | <p>Have you seen the <a href="http://github.com/ffmike/user_event_logger/tree/master" rel="nofollow noreferrer">user_event_logger</a> plugin?</p>
| <p>What are you trying to capture, every action each user does, or just a specific sub-set of actions? If a sub-set one quick and dirty way would be to simply use a logger call to dump the user-id to the log for the actions you want to track.</p>
| 33,028 |
<p>I've been scanning through all the popular js libraries, but I can't find one that has a width function for a DOM element that actually accounts for quirks mode in Internet Explorer. The issue is that padding and borders don't get counted in the the width when quirks mode is engaged. As far as I can tell this happen... | <p>@1</p>
<pre><code>document.compatMode
</code></pre>
<p>"CSS1Compat" means "<em>standards mode</em>" and "BackCompat" means "<em>quirks mode</em>".</p>
<p>@2</p>
<p>offsetWidth property of a HTML elements gives its width on screen, in pixels.</p>
<pre><code><div id="mydiv" style="width: 250px; padding-left: 1... | <p>The library is probably telling the true. The problem is not that the readings are incorect but that the acutal display is incorect. As an example try:</p>
<pre><code><div id="mydiv" style="width: 100px; border-left: 100px black solid;">&nbsp;</div>
</code></pre>
<p>then try to change the text insi... | 27,267 |
<p>I am setting the <code>.Content</code> value of a Label to a string that contains underscores; the first underscore is being interpreted as an accelerator key.</p>
<p>Without changing the underlying string (by replacing all <code>_</code> with <code>__</code>), is there a way to disable the accelerator for Labels?<... | <p>If you use a TextBlock as the Content of the Label, its Text will not absorb underscores.</p>
| <p>Why not like this?</p>
<pre><code>public partial class LabelEx : Label
{
public bool PreventAccessKey { get; set; } = true;
public LabelEx()
{
InitializeComponent();
}
public new object Content
{
get
{
var cont... | 6,200 |
<p>I am trying to run some Perl CGI scripts under IIS. I get the following message :</p>
<pre>
<code>
CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:
perl: warning: Setting locale failed.
perl: warning: Please check that your locale se... | <p>The LANG and LC_ALL environment variables are set for your shell, but they aren't set for IIS. I'm not an IIS person, but the docs say that IIS is a service and you have to set those ahead of time then reboot.</p>
<p>Alternatively, you can set these variables as soon your script starts to compile (and before you l... | <p>It seems your Perl application is sending it's errors to the browser, and an error happens before a header is sent.</p>
<p>If you are using the CGI module, the first may be caused by <code>use CGI::CARP qw(fatalsToBrowser)</code>.</p>
<p>In this case <code>fatalsToBrowser</code> does more harm than it is of use, s... | 45,572 |
<p>In Eclipse (Ganymede) I'm debugging some code that uses Apache Commons HttpClient and would like to step into the HttpClient code. I've downloaded the source code and tried to attach it in the normal fashion (CTRL-click on the method name and use the Attach Source button). I've tried to attach both as external file ... | <p>Try pointing it at a directory containing the top level package directly, "D:/Data/Download/commons-httpclient-3.1/src/java" for you. What worked for me was creating a new src zip file containing the "org" folder and everything beneath it.</p>
<p>Here's my .classpath entry, (which works for me) in case it helps:</... | <p>Attaching sources is not all that is required to step into a library on the classpath; that library must also be compiled with debug symbols. This usually isn't a problem, since most Java libraries are compiled and distributed in such a fashion, but as you have found, some of them are not.</p>
<p>It is interesting... | 23,329 |
<p>I've been reading about Ocaml's consistent speed, rapid prototyping ability, and excellent memory management, and decided to take it up.</p>
<p>As I've already got Ruby, *lisp, Haskell, and Erlang under my belt, I'm interested specifically in what KISS-violating features I should look out for in Ocaml.</p>
<p>If y... | <p>I found an excellent resource on Ocaml and its relation to most other languages: <a href="http://www.soton.ac.uk/~fangohr/software/ocamltutorial/lecture1.html" rel="nofollow noreferrer">http://www.soton.ac.uk/~fangohr/software/ocamltutorial/lecture1.html</a></p>
<p>Not only does it explain the why, it also explains... | <p>There is a book about Ocaml "Practical Ocaml" it's not a really good book, but at least for getting started it's good enough. It's a quite practical language, which unfortunatly a "strange" syntax. If you like to see some "real" Ocaml then just look at the Shootout pages. </p>
<p>Regards
Friedrich</p>
| 23,499 |
<p>If given the choice, which path would you take?</p>
<blockquote>
<p>ASP.NET Webforms + ASP.NET AJAX</p>
</blockquote>
<p><strong>or</strong></p>
<blockquote>
<p>ASP.NET MVC + JavaScript Framework of your Choice</p>
</blockquote>
<p>Are there any limitations that ASP.NET Webforms / ASP.NET AJAX has vis-a-vis ... | <p>I've done both lately, I would take MVC nine times out of ten.</p>
<ul>
<li>I really dislike the implementation of the asp.net ajax controls, I've run into a lot of issues with timing, events, and debugging postback issues. I learned a lot from <a href="http://encosia.com/2007/07/11/why-aspnet-ajax-updatepanels-ar... | <p>I've used asp.net winforms with ajax.net as well as prototype/ext/jquery. I guess something to consider is the goal of the site.. MVC is a popular pattern. I can't say anything against ASP MVC because I haven't had a chance to use it, but I want to make sure you know you are not limited to just ajax.net if you cho... | 12,433 |
<p>Is there a collection (BCL or other) that has the following characteristics:</p>
<p>Sends event if collection is changed AND sends event if any of the elements in the collection sends a <code>PropertyChanged</code> event. Sort of an <code>ObservableCollection<T></code> where <code>T: INotifyPropertyChanged</c... | <p>Made a quick implementation myself:</p>
<pre><code>public class ObservableCollectionEx<T> : ObservableCollection<T> where T : INotifyPropertyChanged
{
protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
{
Unsubscribe(e.OldItems);
Subscribe(e.NewItems);... | <p>Check out the <a href="http://www.itu.dk/research/c5" rel="nofollow noreferrer">C5 Generic Collection Library</a>. All of its collections contain events that you can use to attach callbacks for when items are added, removed, inserted, cleared, or when the collection changes.</p>
<p>I am working for some extensions... | 33,788 |
<p>I want the following layout to appear on the screen:</p>
<pre><code>FieldName 1 [Field input 1]
FieldName 2 is longer [Field input 2]
. .
. .
FieldName N [Field input N]
</code></pre>
<p>Requirements:</p>
<ul>
<li>Field names and fi... | <p>I wouldn't, I would use a table. This is a classic example of a tabular layout - exactly the sort of thing tables are <em>supposed</em> to be used for.</p>
| <p>FieldName objects should be contained in SPANs with style attributes of float: left and a width that is wide enough for your labels.</p>
<p>Inputs should be contained within a span styled to float: left. Place a <code><div style="clear: both"/></code> or <code><br/></code> after each field input to brea... | 13,485 |
<p>I'm currently building a Java app that could end up being run on many different platforms, but primarily variants of Solaris, Linux and Windows.</p>
<p>Has anyone been able to successfully extract information such as the current disk space used, CPU utilisation and memory used in the underlying OS? What about just ... | <p>You can get some limited memory information from the Runtime class. It really isn't exactly what you are looking for, but I thought I would provide it for the sake of completeness. Here is a small example. Edit: You can also get disk usage information from the java.io.File class. The disk space usage stuff requires ... | <p>Not exactly what you asked for, but I'd recommend checking out <a href="https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/ArchUtils.html" rel="nofollow noreferrer">ArchUtils</a> and <a href="https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/SystemUtils.html... | 4,518 |
<p>I have a curious question about efficiency. Say I have a field on a database that is just a numeric digit that represents something else. Like, a value of 1 means the term is 30 days.</p>
<p>Would it be better (more efficient) to code a SELECT statement like this...</p>
<pre><code>SELECT
CASE TermId
... | <p>Efficiency probably wouldn't matter here - code maintainability does though.
Ask yourself - will these values change? What if they do? What would I need to do after 2 years of use if these values change?
If it becomes evident that scripting them in SQL would mean better maintainability (easier to change), then do ... | <p>For a number of reasons, I would process the translation in the grid view.</p>
<p>Reason #1: SQL resource is shared. Grid is distributed. Better scalability.</p>
<p>Reason #2: Lower bandwidth to transmit a couple integers vs. strings.</p>
<p>Reason #3: Code can be localized for other languages without affecting t... | 18,006 |
<p>I have the ISO week and year but how do I correctly convert that into two dates representing the start and end of that week?</p>
| <p><code>ffmpeg</code> is a general purpose (de)muxer/transcoder. <code>MP4Box</code> is a (de)muxer/transcoder from <a href="http://gpac.wp.institut-telecom.fr/mp4box/" rel="nofollow noreferrer">GPAC</a>, a package dedicated to MP4 related software tech. Right now it seems wiser to use MP4Box because it writes the moo... | <p>Just use any mp4-Muxer like Yamb to create an <code>mp4</code>-file with only the <code>aac</code> audio track in it, then change the file extension to <code>m4a</code>.</p>
| 9,592 |
<p>How do I determine if a <code>Nullable(of Enum)</code> is indeed an <code>Enum</code> by means of reflection?</p>
<p>I'm working with a method that dynamically populates an object of type <code>T</code> with an <code>IDataReader</code> retrieved from a database call. At its essence, it loops through the datareader... | <p>It's a bit cumbersome:</p>
<ul>
<li>Get type from <code>PropertyInfo.PropertyType</code></li>
<li>Test for <code>IsGenericType</code></li>
<li>If it is, get the generic type with <code>GetGenericTypeDefinition()</code></li>
<li>If that type equals <code>typeof(Nullable<>)</code>, you have a Nullable</li>
<li>... | <p>Your question is unclear. You can use <code>.HasValue</code> to find if the Nullable has an Enum or it's null but that doesn't seem to be the purpose of your question. Are you using reflection to get the type of a variable and casting the IDataReader's data from Object to that type?</p>
| 23,407 |
<p><strong>A big shout out to all of us for a successful graduation into private beta.
Let's make it a success now, and make sure we graduate into a full-fledged site.
So, this is one post which every user of a private beta site should read and act accordingly.</strong></p>
<p>This is a reproduction of a moderator's... | <p><strong>Yes!</strong></p>
<p>Absolutely. We need to reward good answers, and raise rep levels so suers can get moderation privileges when they rise to the normal public beta levels.</p>
<p>However, I think we should also downvote poor questions and answers. I haven't yet done so, partly because I've focused on rew... | <p>There are other considerations, as have already been noted on <a href="https://3dprinting.meta.stackexchange.com/questions/264/what-does-it-take-to-get-out-of-beta-stage">What does it take to get out of Beta stage?</a></p>
<p>On fully graduated sites, we need:</p>
<ul>
<li><strong><em>users with > 10k</em></strong... | 9 |
<p>I want my WPF application to be skinnable, by applying a certain XAML template, and the changes to be application wide, even for dynamic controls or controls that aren't even in the visual/logical tree. </p>
<p>What can I use to accomplish this type of functionality? Are there any good resources or tutorials that s... | <p>The basic approach to take is using resources all through your application and dynamically replacing the resources at runtime. </p>
<p>See <a href="http://www.nablasoft.com/alkampfer/index.php/2008/05/22/simple-skinnable-and-theme-management-in-wpf-user-interface/" rel="noreferrer">http://www.nablasoft.com/alkampfe... | <p>The replacing of resource will work but I found "structural skinning" to be more powerfull! Read more about it on CodeProject...</p>
<p><a href="http://www.codeproject.com/KB/WPF/podder1.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/WPF/podder1.aspx</a></p>
| 14,705 |
<p>I was writing some try-catch blocks for various methods today, and thought to myself it would be good to have utility method which would automatically call the method again for a number of times specified in a parameter, at a certain time.</p>
<p>However, I thought to myself, the method/property etc which will cau... | <p><strong>Please don't do this.</strong> It's a really, really, really, really, really <em>bad idea</em>.</p>
<p>Maybe not as bad as deleting files randomly, if the hard drive runs out of room - but just about as bad.</p>
| <p>Mark's code is probably better, but here's mine...</p>
<p>If you <strong>really</strong> want to do something like this, I'd use code something like this. Yes, you still have to manually call it, but your idea of indiscriminately retrying ALL excepting methods is a really, really bad idea.</p>
<pre><code>public c... | 43,551 |
<p>The IT lady just gave me a laptop to keep! </p>
<p>I've always wanted to have Linux install to play with so the first thing I did is search stackoverflow for Linux Distro suggestions and found it <a href="https://stackoverflow.com/questions/659/what-is-your-preferred-linux-distribution#6730">here</a>. However the... | <p>Many distros, Ubuntu included, have a "live" mode. You download the .iso image, burn the CD, and then boot from the CD. The OS will run directly off the CD without installing anything. It will run slowly, because it's reading from the CD, but it should give you the opportunity to test your hardware.</p>
| <p>I would look in (at least) these two places:</p>
<p><a href="http://www.linuxcompatible.org/compatibility.html" rel="nofollow noreferrer">http://www.linuxcompatible.org/compatibility.html</a></p>
<p><a href="http://www.linux-drivers.org/" rel="nofollow noreferrer">http://www.linux-drivers.org/</a></p>
| 8,424 |
<p>Is there a way when executing a stored procedure in Management Studio to get the data types of the result sets coming back? I'm looking for something like functionality of when you pass a table name to sp_help</p>
| <p>You do get to look at the types though, if you call the stored procedure via ADO, ADO.NET, ODBC or the likes: The resulting recordsets have the type information you are looking for. Are you really restricted to Management Studio?</p>
| <p>You could always use an actual table that is garrenteed to be unique. It's a kludge, but it's an option. This will not work inside a stored proc though.</p>
<pre><code>if exists (select * from sys.tables where name = 'tmp_TableName')
drop table tmp_TableName
go
select * into tmp_TableName from MyTable
--do s... | 5,317 |
<p>I've recently inherited a internationalized and text-heavy Struts 1.1 web application. Many of the JSP files look like:</p>
<pre class="lang-jsp prettyprint-override"><code><p>
<bean:message key="alert" />
</p>
</code></pre>
<p>and the properties files look like:</p>
<pre><code>messages.prop... | <blockquote>
<p>Avoid creating links within long
blocks of text. Prefer shorter text
that can act as a logically complete
and independent link.</p>
</blockquote>
<p>Generally, it will lead to fewer problems. Sometimes you have to compromise your UI design to accommodate localization; sometimes you need to comp... | <p>Perhaps:</p>
<pre><code>#
alert=Please update your {0}address{1} and {2}contact information{3}.
</code></pre>
| 3,423 |
<p>I just watched the Windows Azure intro video and it left me feeling like it was a front end shell for hosted IIS instances. Can anyone who know more (possibily that was part of the beta) shed on why you would use this vs. EC2.</p>
<p>it seemed easy enough but really didnt give specifics on how it works, why it work... | <p>According to the vision (and I can only talk about the vision here since the product isn't really out yet), here's a couple of reasons you might consider Azure over EC2.</p>
<p>Azure includes built-in load balancing abilities. If you want to do that in Amazon, you have to roll your own solution or buy a third-part... | <p>Well it's more than just web services. It will also allow you to host other types of connected applications. Plus it provides integrated access to other MS software on the cloud; i.e. SharePoint, Exchange, CRM, SQL data sevices, and will allow you to fully customize and extend those offerings in the same way that yo... | 29,796 |
<p>Suppose you have the canonical Customer domain object. You have three different screens on which Customer is displayed: External Admin, Internal Admin, and Update Account.</p>
<p>Suppose further that each screen displays only a subset of all of the data contained in the Customer object. </p>
<p>The problem is: whe... | <p>Is this a web app? Load the customer object from the repo, update it from the DTO, save it back. That doesn't seem like a kludge to me. :)</p>
<p>UPDATE: As per your updates (the A, B, C, D example)</p>
<p>So what I was thinking is that when you load the entity, it has A, B, C, and D filled in. If DTO#1 only up... | <p>I missed the point of this question at first because it is predicated on a few things that I don't think make sense from a design perspective.</p>
<ol>
<li><p>Hydrating an entity from repository and then converting it to a DTO is a waste of effort. I assume that your DAL passes a DTO to your repository which then c... | 28,669 |
<p>I am getting this warning:</p>
<pre><code>Use of uninitialized value in eval \"string\" at myscript.pl line 57.
</code></pre>
<p>When I run this code:</p>
<pre><code>eval;
{
`$client -f $confFile -i $inputFile -o $outputFile`;
};
if( $@ )
{
# error handling here ...
}
</code></pre>
<p>What is ca... | <p>There is a semicolon after <code>eval</code>.</p>
| <p>There is a semicolon after <code>eval</code>.</p>
| 39,041 |
<p>I have multiple logos of various companies in various formats that needs to be added to other PDFs. The format of these logos is not specified at the moment but it could be locked down to only certain formats if it causes issues.</p>
<p>These other PDFs will be mostly posters and will be printed off by the user. </... | <p>See at my answer to a <a href="https://stackoverflow.com/questions/204860/best-server-side-net-pdf-editing-library">similar question</a>. In short, I've used <a href="http://itextsharp.sourceforge.net/" rel="nofollow noreferrer">itextsharp</a> to add watermark(s) to an existing PDF.</p>
| <p><a href="http://www.pdfsharp.com/PDFsharp/" rel="nofollow noreferrer">PDFSharp</a> is a free library that can do this. <a href="http://www.pdfsharp.com/PDFsharp/index.php?option=com_content&task=view&id=40&Itemid=51" rel="nofollow noreferrer">These watermarking examples</a> should help you get started.<... | 29,663 |
<p>I'm looking to use a VBScript variable within a reference to a DOM element for a web-app I'm building. Here's a brief excerpt of the affected area of code:</p>
<pre><code>dim num
num = CInt(document.myform.i.value)
dim x
x = 0
dim orders(num)
For x = 0 To num
orders(x) = document.getElementById("order" & x... | <p>I was able to get this working. Thanks to both of you for your time and input. Here is what solved it for me:</p>
<p>Rather than using</p>
<pre><code>document.getElementById("order" & x).value
</code></pre>
<p>I set the entire ID as a variable:</p>
<pre><code>temp = "order" & x
document.getElementById(... | <p>I can only assume that this is client side VBScript as document.getElementById() isn't accessible from the server.</p>
<p>try objFile.writeLine("order" & x), then check the source to make sure all the elements are in the document.</p>
<p>[As I can't put code in comments...]
That is strange. It looks to me like... | 16,336 |
<p>I've created an implementation of the <code>QAbstractListModel</code> class in Qt Jambi 4.4 and am finding that using the model with a <code>QListView</code> results in nothing being displayed, however using the model with a <code>QTableView</code> displays the data correctly.</p>
<p>Below is my implementation of <... | <p><a href="http://everything2.com/index.pl?node_id=477013" rel="noreferrer">This illustration</a> is in English, rather than an actual programming language, but is useful for explaining the process in a non-technical way:</p>
<pre>
A child couldn't sleep, so her mother told a story about a little frog,
who couldn't... | <p>Translate a spreadsheet column index to a column name. </p>
<p>It's trickier than it sounds, because spreadsheet columns don't handle the '0' digit properly. For example, if you take A-Z as digits when you increment from Z to AA it would be like going from 9 to 11 or 9 to 00 instead of 10 (depending on whether A ... | 15,420 |
<p>PHP provides a mechanism to register a shutdown function:</p>
<pre><code>register_shutdown_function('shutdown_func');
</code></pre>
<p>The problem is that in the recent versions of PHP, this function is still executed DURING the request. </p>
<p>I have a platform (in Zend Framework if that matters) where any pie... | <p>If you're really concerned about the insert times of MySQL, you're probably addressing the symptoms and not the cause.</p>
<p>For instance, if your PHP/Apache process is executing after the user gets their HTML, your PHP/Apache process is still locked into that request. Since it's busy, if another request comes alo... | <p>The comments on <a href="http://www.brandonchecketts.com/archives/performing-post-output-script-processing-in-php" rel="nofollow noreferrer">this random guy's blog</a> sound similar to what you want. If that header trick doesn't work, one of the comments on that blog suggests <code>exec()</code>ing to a separate PHP... | 37,447 |
<p>I am working on a winforms application using LINQ to SQL - and am building the app using a SQL Express instance on my workstation. The final installation of the project will be on a proper SQL Server 2005. </p>
<p>The database has the same name, and all tables are identical but the hostname is different. </p>
<p>... | <p>If I understand your problem correctly, you simply change the database's connection string in your app.config / web.config.</p>
<p><strong>Edit</strong>, post clarification: You have the connection strings stored somewhere. They might be in the app.config of your server. Still, you get them from somewhere and that ... | <p>I believe you can store the connection information in an app.config file and retrieve it from there. <a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3716857&SiteID=1" rel="nofollow noreferrer">Here</a> is a post about doing that with LINQ to SQL. Once you deploy it to a production server, you ca... | 7,175 |
<p>I'm looking at introducing multi-lingual support to a mature CGI application written in Perl. I had originally considered rolling my own solution using a Perl hash (stored on disk) for translation files but then I came across a CPAN module which appears to do just what I want (<a href="http://search.cpan.org/~audre... | <p>There is a <a href="http://search.cpan.org/perldoc?Locale::Maketext::TPJ13" rel="noreferrer">Perl Journal article</a> on software localisation. It will provide you with a good idea of what you can expect when adding multi-lingual support. It's beautifully written and humourous.</p>
<p>Specifically, the article is... | <p>If you have the time then do take a look at the way the I18N is done in the <a href="http://search.cpan.org/dist/Jifty/" rel="nofollow noreferrer">Jifty</a> framework - although initially quite confusing it is very elegant and usable.</p>
<p>They overload <code>_</code> so that you can use <code>_("text to translat... | 19,936 |
<p>We're considering writing the next version of out project in using .Net 3, but are wondering if we can take the hit on forcing end users to install the .net framework version 3.</p>
| <p>If you want to ensure you are only using .NET 2.0 compatible functionality then you should only use .NET 2.0 assemblies. Then you know your safe and sound.</p>
| <p><a href="http://evain.net/blog/articles/2008/09/14/c-3-and-linq-on-net-2" rel="nofollow noreferrer">This article from Jean-Baptiste Evain</a> explains how you can use C# 3.0 and LINQ and targeting machines on which there is only .NET 2.0 runtime installed.</p>
<p>The idea is to use System.Core <a href="http://www.m... | 16,755 |
<p>Is there a command, or a set of tables I can look at to determine which tables, stored procedures and views in SQL Server server 2005 have a certain user defined data type?</p>
| <p>Tables are relatively easy, sys.columns and sys.types allow you to link columns to types. The query below will get this out.</p>
<pre><code>select s.name
,o.name
,c.name
,t.name
from sys.schemas s
join sys.objects o
on o.schema_id = s.schema_id
join sys.columns c
on c.object_id = o.... | <p>Tables are relatively easy, sys.columns and sys.types allow you to link columns to types. The query below will get this out.</p>
<pre><code>select s.name
,o.name
,c.name
,t.name
from sys.schemas s
join sys.objects o
on o.schema_id = s.schema_id
join sys.columns c
on c.object_id = o.... | 40,663 |
<p>Here's the deal. I have a big class hierarchy and I have this one method that is extended all the way through. The method always has to look at one or two more variable at each new level and these variable depend on the actual class in the hierarchy. What I want to do is check those two extra variables then call the... | <p>Can't you use a hash map?</p>
| <p>Sounds like you want to want to use something like a sorted binary tree. Both lookup and iteration are fast and the tree won't care about the spacing of the entries.</p>
<p>If your multiple axes are independent, you could create one for each axis.</p>
| 45,324 |
<p>How can styles be applied to CheckBoxList ListItems. Unlike other controls, such as the Repeater where you can specify <code><ItemStyle></code>, you can't seem to specify a style for each individual control.</p>
<p>Is there some sort of work around?</p>
| <p>You can add Attributes to ListItems programmatically as follows.</p>
<p>Say you've got a CheckBoxList and you are adding ListItems. You can add Attributes along the way.</p>
<pre><code>ListItem li = new ListItem("Richard Byrd", "11");
li.Selected = false;
li.Attributes.Add("Style", "color: red;");
CheckBoxList1.I... | <pre><code>public bool Repeater_Bind()
{
RadioButtonList objRadioButton = (RadioButtonList)eventArgs.Item.FindControl("rbList");
if (curQuestionInfo.CorrectAnswer != -1) {
objRadioButton.Items[curQuestionInfo.CorrectAnswer].Attributes.Add("Style", "color: #b4fbb1;");
}
}
</code></pre>
| 13,005 |
<p>I'm a Engineering student and I'm attending a Database and Information Systems class this semester. It's required that I produce a website/application that uses a database, using PHP/PGSQL. My questions are:</p>
<ul>
<li>which IDE would you recommend?</li>
<li>does anyone have good tips and advices for a new develo... | <ul>
<li>which IDE would you recommend?</li>
</ul>
<p>Anything that supports remote debugging. You will save yourselves hours and hours and learn so much quicker if you can actually step through your code. It always amazes me that more people don't use good debugging tools for PHP. The tools are there, not using them ... | <ul>
<li>IDE: <a href="http://quanta.kdewebdev.org/" rel="nofollow noreferrer">Quanta+</a></li>
<li>tip: don't use a template library over a template language (PHP)</li>
<li>tip: MVC is a design and mentality issue, not a library</li>
</ul>
| 19,019 |
<p>I'm not exactly sure how to ask this question really, and I'm no where close to finding an answer, so I hope someone can help me. </p>
<p>I'm writing a Python app that connects to a remote host and receives back byte data, which I unpack using Python's built-in struct module. My problem is with the strings, as they... | <p>There's no built-in functionality for decoding a string like this, since it is really its own custom codec. You simply need to split up the string on those control characters and decode it accordingly.</p>
<p>Here's a (very slow) example of such a function that handles latin1 and shift-JIS:</p>
<pre><code>latin1 ... | <p>I don't suppose you have any way of convincing the person who hosts the other machine to switch to unicode?</p>
<p>This is one of the reasons Unicode was invented, after all.</p>
| 24,068 |
<p>For example I have two tables. The first table is student while the second table are the courses that the a student is taking. How can I use a select statement so that I can see two columns student and courses so that the courses are separated by commas.</p>
<p>Thanks.</p>
| <p>Assuming you're using SQL Server 2005:</p>
<p>This should do what you're after - obviously replace fields as you need:</p>
<p>For demo purposes, consider the following two table structures:</p>
<pre><code>Students(
STU_PKEY Int Identity(1,1) Constraint PK_Students_StuPKey Primary Key,
STU_NAME nvarchar(64)
)
... | <p>It depends on which server you're using. SQL Server? MySQL? Other?</p>
| 48,105 |
<p>I was listening to the steve yegge podcast (#29, around 21:29), and in part of it, they were talking about "how to tell if the person you're talking to is smart", and they said that one way was to talk about "smart people things" (I'm paraphrasing), like "piano numbers" and "lambda calculus".<br>
I'm secure enough t... | <p>Being Smart and having a certain knowledge base is not the same thing.</p>
<p>I'd be wary of listening to anyone that is equating the two.</p>
<p>And in true SO fashion, I'm going to roll up the other answers. Most likely they meant Peano:</p>
<p><a href="http://en.wikipedia.org/wiki/Peano_axioms" rel="noreferre... | <p>For those interested in a precise definition of Peano's Numbers, check out this explanation <a href="http://cs.calstatela.edu/wiki/index.php/Courses/CS_332L/Peano_arithmetic" rel="nofollow">here</a>. In short, Peano came up with a recursive way to generate the Natural Numbers using successor functions. A number in t... | 45,534 |
<p>Today I changed the application pool identity of our ASP.NET application from "Network Service" to a domain user.</p>
<p>I added the user to the local group "IIS_WPG", done a iisreset just in case, and
everything works fine with IE6 and Firefox 3.0</p>
<p>But when I go to the website with IE7, an authentication p... | <p>Typically, if you see an issue with authentication where it works in IE 6 but not IE 7, I'd check to make sure Kerberos is configured correctly.</p>
<p>Running as Network Service, your Kerberos SPNs should attached to the machine account. As a domain account, the SPN's need to be on that account.</p>
<p>As to why... | <p>You can try to disable "Enable integrated authentication" in Options, Advanced Settings.
But I don't know if there isn't some side effects.</p>
| 27,873 |
<p>This is something simple I came up with for <a href="https://stackoverflow.com/questions/146795/how-to-read-config-file-entries-from-an-ini-file">this question</a>. I'm not entirely happy with it and I saw it as a chance to help improve my use of STL and streams based programming.</p>
<pre><code>std::wifstream file... | <blockquote>
<p>// what if the name = value does not have white space?<br>
// what if the value is enclosed in quotes?</p>
</blockquote>
<p>I would use boost::regex to match for every different type of element, something like:</p>
<pre><code>boost::smatch matches;
boost::regex name_value("(\S+)\s*=\s*(\S+)");
if(... | <p>This:</p>
<pre><code>for (size_t i=1; i<line.length(); i++)
{
if (line[i]!=L']')
header.push_back(line[i]);
else
break;
}
</code></pre>
<p>should be simplified by a call to wstrchr, wcschr, WSTRCHR, or something else, depending on what platform you are... | 17,692 |
<p>I find myself to be a visual person and sometimes it's easier to learn something if I can draw diagram/pictures out of it. My question is which tool do I use if I want to map a programming framework (for example .net) visually and see the relationship between all entities (such as classes and members).</p>
| <p>You might try <a href="http://www.ndepend.com/" rel="nofollow noreferrer">NDepend</a>. The great <a href="http://www.hanselman.com/blog/ExitingTheZoneOfPainStaticAnalysisWithNDepend.aspx" rel="nofollow noreferrer">Scott Hanselman discusses it more here.</a> Tons of visual dependency formats too. It sounds like it... | <p>A decent first-cut might be to write a simple PERL script to parse out dependencies and then pipe that data to <a href="http://www.graphviz.org/" rel="nofollow noreferrer" title="Graphviz">Graphviz</a> for visualization.</p>
| 6,837 |
<p>I am able to create the same SVN branch twice. I would hope that SVN would not allow me to create same branch again. Please help me to fix this issue.</p>
| <p>From <a href="http://svnbook.red-bean.com/en/1.5/svn-book.html#svn.branchmerge.using.concepts" rel="nofollow noreferrer">SVN RedBook</a>:</p>
<blockquote>
<p>Subversion has no internal concept of a branch—it knows only how to make copies. When you copy a directory, the resultant directory is only a “branch” because ... | <p>In SVN, branches (and tags too) are only copies.</p>
<p>SVN has no idea of what a branch is, it only knows about copies. SVN users give to those copies the meaning of branches, but it's only a convention followed by the people, not by SVN.</p>
| 43,271 |
<p>Can anybody recommend a treeview component for ASP.NET that supports drag & drop (between it's own nodes - it's for a content management system to rearrage the pages). Don't mind if it's open source or commercial (can't quite stretch to the <a href="http://demos.telerik.com/ASPNET/Prometheus/Treeview/Examples/Fu... | <p>If you could stretch to including jQuery (free) then there is a client side tree that does drag drop <a href="http://jstree.com/jsTree/examples/_opers/moving.html" rel="nofollow noreferrer">jstree</a>. You would just need to implement ajax hooks to handle the database updates for the tree structure.</p>
| <p><a href="http://www.obout.com/t2/edraganddrop.aspx" rel="nofollow noreferrer">Obout.com's treeview looks slick</a>. I've never used it, but I've thought about it many a time...</p>
| 38,216 |
<p>Google maps in some region can serve traffic information showing the blocked roads and so on. I was wondering if there is any code example demonstrating how can I serve traffice information for my own region. </p>
| <p>"Google Maps Hacks" has a hack, <a href="http://safari.oreilly.com/0596101619/googlemapshks-CHP-4-SECT-3" rel="nofollow noreferrer">"Hack 30. Stay Out of Traffic Jams"</a>, on that.</p>
<p>You can also find out how to get U.S. traffic info from John Resig's <a href="http://ejohn.org/blog/traffic-conditions-data/" r... | <p>Google is mum on what source they use for their traffic data. You might contact them directly to see if they want to implement something for you, but my guess is that they'd simply refer you to their provider if they really wanted your data.</p>
<p>Keep in mind that traffic data is available for more than just the... | 9,258 |
<p>(<strong>Updated a little</strong>)</p>
<p>I'm not very experienced with internationalization using PHP, it must be said, and a deal of searching didn't really provide the answers I was looking for.</p>
<p>I'm in need of working out a reliable way to convert only 'relevant' text to Unicode to send in an SMS messag... | <p>To deal with it conceptually before getting into mechanisms, and apologies if any of this is obvious, a string can be defined as a sequence of Unicode characters, Unicode being a database that gives an id number known as a code point to every character you might need to work with. GSM-338 contains a subset of the Un... | <p>PHP6 will have better unicode support but there are a few functions you can use.</p>
<p>My first thought was <a href="http://php.net/manual/en/function.mb-convert-encoding.php" rel="nofollow noreferrer"><code>mb_convert_encoding</code></a> but as you said this will shorten messages to 70 chars - so perhaps you can ... | 4,723 |
<p>Anyone know how to get the position of a node using XPath?</p>
<p>Say I have the following xml:</p>
<pre><code><a>
<b>zyx</b>
<b>wvu</b>
<b>tsr</b>
<b>qpo</b>
</a>
</code></pre>
<p>I can use the following xpath query to select the third <... | <p>Try:</p>
<pre><code>count(a/b[.='tsr']/preceding-sibling::*)+1.
</code></pre>
| <p>The problem is that the position of the node doesn't mean much without a context.</p>
<p>The following code will give you the location of the node in its parent child nodes</p>
<pre><code>using System;
using System.Xml;
public class XpathFinder
{
public static void Main(string[] args)
{
XmlDocumen... | 27,993 |
<p>We’ve found that the unit tests we’ve written for our C#/C++ code have really paid off.
But we still have thousands of lines of business logic in stored procedures, which only really get tested in anger when our product is rolled out to a large number of users. </p>
<p>What makes this worse is that some of these s... | <p>I ran into this same issue a while back and found that if I created a simple abstract base class for data access that allowed me to inject a connection and transaction, I could unit test my sprocs to see if they did the work in SQL that I asked them to do and then rollback so none of the test data is left in the db.... | <p>LINQ will simplify this only if you remove the logic from your stored procedures and reimplement it as linq queries. Which would be much more robust and easier to test, definitely. However, it sounds like your requirements would preclude this.</p>
<p>TL;DR: Your design has issues. </p>
| 3,343 |
<p>Working with dates in ruby and rails on windows, I'm having problems with pre-epoch dates (before 1970) throwing out of range exceptions. I tried using both <a href="http://ruby-doc.org/core-2.2.0/Time.html" rel="nofollow noreferrer"><code>Time</code></a> and <a href="http://ruby-doc.org/stdlib-1.9.3/libdoc/date/rdo... | <p>If you only need dates (no times), the <a href="http://ruby-doc.org/stdlib-2.2.3/libdoc/date/rdoc/Date.html" rel="nofollow noreferrer"><code>Date</code></a> class in ruby should handle dates before 1970. But it has only a resolution of days. I don't know if there are solutions, if you also need times before 1970
<a ... | <p>You can also check out the section on dates on <a href="http://ruby-doc.org/stdlib/libdoc/date/rdoc/index.html" rel="nofollow noreferrer">ruby-doc.org</a>. I'm still learning Ruby but it sounds like you could use either the <a href="http://ruby-doc.org/stdlib/libdoc/date/rdoc/index.html" rel="nofollow noreferrer">C... | 4,770 |
<p>I have a list of Date objects, and a target Date. I want to find the date in the list that's nearest to the target date, but only dates that are before the target date.</p>
<p>Example:
2008-10-1
2008-10-2
2008-10-4</p>
<p>With a target date of 2008-10-3, I want to get 2008-10-2</p>
<p>What is the best way to do i... | <p>Sietse de Kaper solution assumes a <em>reverse</em> sorted list, definitely not the most natural thing to have around</p>
<p>The natural sort order in java is following the ascending natural ordering. (see Collection.sort <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Collections.html#sort(java.util.Lis... | <p>Have you looked at the JodaTime API? I seem to recall a feature like this being available.</p>
| 22,539 |
<p>I was asked to do a code review and report on the feasibility of adding a new feature to one of our new products, one that I haven't personally worked on until now. I know it's easy to nitpick someone else's code, but I'd say it's in bad shape (while trying to be as objective as possible). Some highlights from my co... | <p>To actually scrap and start over?</p>
<p>When the current code doesn't do what you would like it to do, and would be cost prohibitive to change.</p>
<p>I'm sure someone will now link Joel's article about Netscape throwing their code away and how it's oh-so-terrible and a huge mistake. I don't want to talk about i... | <p>If it requires more time to read and understand the code (if that is even possible) than it would to rewrite the entire application, I say scrap it and start over. </p>
| 17,456 |
<p>Consider the following Haskell code:</p>
<pre><code>module Expr where
-- Variables are named by strings, assumed to be identifiers:
type Variable = String
-- Representation of expressions:
data Expr = Const Integer
| Var Variable
| Plus Expr Expr
| Minus Expr Expr
... | <p>Rather than call your function toString, it might be preferable to use the <a href="http://www.haskell.org/tutorial/stdclasses.html" rel="nofollow noreferrer">Show type class</a>. Then your data type can be used anywhere that an instance of Show can be used. Show is the standard Haskell way of converting "things" ... | <p>Here is everything you need to know for this: <a href="http://augustss.blogspot.com/2007/04/overloading-haskell-numbers-part-1.html" rel="nofollow noreferrer">http://augustss.blogspot.com/2007/04/overloading-haskell-numbers-part-1.html</a></p>
| 41,657 |
<p>I created an app for a small business. Some of the employees in the office can not see the form correctly. The reason is they have their DPI setting set to above 96dpi. Does anybody know of a way to control this?</p>
<p>For all of you who have experience with winforms apps, how do you control your form layout so ... | <p>Assuming you do not try to honor the user's UI font choice (SystemFonts.IconTitleFont), and hard-code your forms for one font size only (e.g. Tahoma 8pt, Microsoft Sans Serif 8.25pt), you can set your form's <code>AutoScaleMode</code> to <code>ScaleMode.Dpi</code>.</p>
<p>This will scale the size of the form and <e... | <p>I know it's somewhat drastic, but consider to rewrite your app in WPF. WPF applications have the same look on every DPI setting.</p>
| 22,478 |
<p>In C# is there any real difference (other than syntax) under the hood between:</p>
<pre><code>myButton.Click += new EventHandler(myMemberMethod);
</code></pre>
<p>and</p>
<pre><code>myButton.Click += myMemberMethod;
</code></pre>
<p>?</p>
| <p>The second method is a shortcut to the first one, it was introduced in C# 2.0</p>
<p>See also <a href="https://stackoverflow.com/questions/119160/what-is-the-difference-between-events-with-delegate-handlers-and-those-without">this thread</a>.</p>
| <p>They are exactly the same, its called syntax sugar.</p>
<p>There are a lot of things that arent needed, to get a better idea of them while programming you should try something like <a href="http://www.jetbrains.com/resharper/" rel="noreferrer">Resharper</a>. It will color the unnecessary code in Grey. Not to mentio... | 26,346 |
<p>In <a href="http://channel9.msdn.com/posts/Dan/Countdown-to-PDC2008-By-Developers-for-Developers-Don-Box-and-Chris-Anderson/" rel="nofollow noreferrer">today's channel9.msdn.com video</a>, the PDC guys posted a challenge to decipher this code:</p>
<pre><code>2973853263233233753482843823642933243283
6434928432937228... | <p>Well, based on the 332 pattern you pointed out and the fact that the number of numbers is divisible by 3, and that several of the first 3 digit groups have matches... it might be that each 3 digits represent a character. Get a distribution of the number matches for all the 3 digit groups, then see if that distribut... | <p>I wrote some C# code to scan the cipher and give me some stats back. Here are some interesting results:</p>
<p>With a chunk size of 3, </p>
<ul>
<li><p>There are 236 chunks.</p></li>
<li><p>There are 172 duplicates.</p></li>
<li><p>The 323 code shows up a whopping
total of 29 times!</p></li>
<li><p>The 333 code sh... | 5,695 |
<p>Is there a way to have XAML properties scale along with the size of the uielements they belong to?</p>
<p>In essence, I have a control template that I have created too large for it's use/ mainly because I want to use the same control with different sizes. The problem is that I can set the control size to Auto (in t... | <p>You could try to bind the width and height of the control inside the template to the width and height respectively of the templated control at runtime. Something like:</p>
<pre><code><Button>
<Button.Template>
<ControlTemplate TargetType={x:Type Button}>
<Border Width="{... | <p>Too bad you can't create a control template for a StackPanel, DockPanel, Grid, or any other container.</p>
| 24,493 |
<p>While browsing with Chrome, I noticed that it responds extremely fast (in comparison with IE and Firefox on my laptop) in terms of rendering pages, including JavaScript heavy sites like gmail.</p>
<p>This is what googlebook on Chrome has to say </p>
<ol>
<li>tabs are hosted in process rather than thread.</li>
<li>... | <p>Chrome's approach is difficult to write, and requires forethought from the developers. IE and Firefox are both attempting to move to a process-per-tab model, but due to backwards compatibility are not able to transition quickly. Chrome, being an entirely new browser build on a clean rendering engine (WebKit), was ea... | <p>You have to keep in mind that Microsoft primary business is Rich environement (GUI) Application. Web tool is a threat to them as it is platform independant (not promoting they main product).</p>
<p>Of course the IE team probably had figured something like that but... Microsoft definetly won't invest a lot of money ... | 6,452 |
<p>I have an ASP.Net web user control that contains a TextBox and a calendar from the Ajax Control Toolkit.</p>
<p>When I include this user control on my page I would like it to participate in input validation (there is a required filed validator set on the TextBox inside the UC), ie. when the page is validated the co... | <p>Create a property on your new user control that sets the validation group on the contained validator. Then from your markup, all you need to do is just set the ValidationGroup property on the control, and that'll roll to the validators contained in the user control. You likely don't need the interface or inheritin... | <p>If you are planning to add lots of validation in the future it may pay off to check out Peter Blum's <a href="http://www.peterblum.com/Home.aspx" rel="nofollow noreferrer">DES</a> (Data Entry Suite) - it has numerous enhanced controls for data entry and validation including conditional validation scenarios and the o... | 46,882 |
<p>in Web 2.0 applications many users usually want to stay logged in ('remember me' flag) and on the other hand their cookie can give access to very private data. Is there a way to prevent that somebody who steals the cookie - directly from the computer or via sniffing - can use the cookie to get access to the user's d... | <p>Bernd -- the trouble with anything done over standard HTTP is that it's plaintext; anyone can fake anything. IP Spoofing is a bit more challenging to do than just plain cookie stealing, so tying to the IP tends to be what people do. Like you said, that does not work very well with highly dynamic environments.</p>
... | <p>Bernd - you say connecting the IP address to the cookie is not an option, I'm assuming that's b/c the user could be connected via DHCP, and thus could come in under a different IP each time. Have you considered tying the cookie to the DNS host name? You could encrypt the cookie using a private key, and store it on... | 39,576 |
<p>I'm still new to ROR, so pardon the simplicity of the question...</p>
<p>So <a href="http://www.example.com/controller/:id" rel="nofollow noreferrer">http://www.example.com/controller/:id</a> displays a record in my table, with :id being a number (1,2,3 etc.).</p>
<p>Is there a way I can have :id in the URL be the... | <p>The cleanest way is to add a new find method in your model (or simply use the find_by_fieldname Rails gives you in your control). Then you'll have your controller use that method instead of the regular find(params[:id]) to pull your model record.</p>
<p>Check out Ryan B's screencast on this <a href="http://railsca... | <p>I use the excellent rails plugin named friendly_id.</p>
<p><a href="http://github.com/norman/friendly_id/tree/master" rel="nofollow noreferrer">http://github.com/norman/friendly_id/tree/master</a></p>
<p>That should sort you out nicely. It is well documented too.</p>
<p>Take care around fields that might have mod... | 37,450 |
<p>Suppose I have a directory <code>/dir</code> inside which there are 3 symlinks to other directories
<code>/dir/dir11</code>, <code>/dir/dir12</code>, and <code>/dir/dir13</code>. I want to list all the files in <code>dir</code> including the ones in <code>dir11</code>, <code>dir12</code> and <code>dir13</code>.</p>... | <p>The <code>-L</code> option to <code>ls</code> will accomplish what you want. It dereferences symbolic links.</p>
<p>So your command would be:</p>
<pre><code>ls -LR
</code></pre>
<p>You can also accomplish this with</p>
<pre><code>find -follow
</code></pre>
<p>The <code>-follow</code> option directs find to foll... | <p>in case you would like to print all file <strong>contents</strong>:
<code>find . -type f -exec cat {} +</code></p>
| 13,077 |
<p>Is there a way to change the encoding used by the String(byte[]) constructor ?</p>
<p>In my own code I use String(byte[],String) to specify the encoding but I am using an external library that I cannot change.</p>
<pre><code>String src = "with accents: é à";
byte[] bytes = src.getBytes("UTF-8");
System.out.println... | <p>You need to change the locale before launching the JVM; see:</p>
<p><a href="http://bugs.sun.com/bugdatabase/view_bug.do;jsessionid=6f932817e77b249681417c21bfaf?bug_id=4163515" rel="noreferrer">Java, bug ID 4163515</a></p>
<p>Some places seem to imply you can do this by setting the file.encoding variable when laun... | <p>Quoted from <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/nio/charset/Charset.html" rel="nofollow noreferrer">defaultCharset()</a></p>
<blockquote>
<p>The default charset is determined
during virtual-machine startup and
typically depends upon the locale and
charset of the underlying operating
syst... | 10,695 |
<p>Is there a way to create an instance of a class based on the fact I know the name of the class at runtime. Basically I would have the name of the class in a string.</p>
| <p>Take a look at the <a href="http://msdn.microsoft.com/en-us/library/system.activator.createinstance.aspx" rel="noreferrer">Activator.CreateInstance</a> method.</p>
| <pre><code>ReportClass report = (ReportClass)Activator.CreateInstance(Type.GetType(reportClass));
</code></pre>
<p>why do u want to write a code like this? If you have a class 'ReportClass' is available, you can instantiate it directly as shown below.</p>
<pre><code>ReportClass report = new ReportClass();
</code></pr... | 27,661 |
<p>YAML seems like a great format for configuration files & data binding persistent objects in human-readable form...</p>
<p>Is there a C++ library that handles YAML? Does <code>Boost::Serialization</code> have plans for a YAML option?</p>
<p><strong>EDIT: I would prefer an OO library.</strong></p>
| <p>A quick search gave me this: <a href="https://github.com/jbeder/yaml-cpp" rel="noreferrer">yaml-cpp</a></p>
| <p>I found this, please if you use it let me know how it did it for you and post some example if possible,</p>
<p><a href="https://code.google.com/p/google-summer-of-code-2008-boost/downloads/list" rel="nofollow noreferrer">https://code.google.com/p/google-summer-of-code-2008-boost/downloads/list</a></p>
<p>UPDATED l... | 30,358 |
<p>I'd like to offer my users correct links to an upgraded version of my program based on what platform they're running on, so I need to know whether I'm currently running on an x86 OS or an x64 OS.</p>
<p>The best I've found is using <code>Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE")</code>, but I wou... | <p><a href="http://msdn.microsoft.com/en-us/library/system.environment.is64bitoperatingsystem(VS.100).aspx" rel="noreferrer">Environment.Is64BitOperatingSystem </a> and <a href="http://msdn.microsoft.com/en-us/library/system.environment.is64bitprocess(VS.100).aspx" rel="noreferrer">Environment.Is64BitProcess</a> are be... | <p>Check just <code>IntPtr.Size</code> . You need to have target platform as AnyCPU.</p>
<p><a href="http://channel9.msdn.com/forums/TechOff/410567-C-Detect-32-bit-or-64-bit-OS/" rel="nofollow noreferrer">from here</a></p>
| 11,616 |
<p>When using IF statements in Python, you have to do the following to make the "cascade" work correctly.</p>
<pre><code>if job == "mechanic" or job == "tech":
print "awesome"
elif job == "tool" or job == "rock":
print "dolt"
</code></pre>
<p>Is there a way to make Python accept multiple values when c... | <pre><code>if job in ("mechanic", "tech"):
print "awesome"
elif job in ("tool", "rock"):
print "dolt"
</code></pre>
<p>The values in parentheses are a tuple. The <code>in</code> operator checks to see whether the left hand side item occurs somewhere inside the right handle tuple.</p>
<p>Note that when Python ... | <p>In other languages I'd use a switch/select statement to get the job done. <a href="http://simonwillison.net/2004/May/7/switch/" rel="nofollow noreferrer">You can do that in python too</a>.</p>
| 17,834 |
<p>Specifically, is the following legal C++?</p>
<pre>class A{};
void foo(A*);
void bar(const A&);
int main(void)
{
foo(&A()); // 1
bar(A()); // 2
}</pre>
<p>It appears to work correctly, but that doesn't mean it's necessarily legal. Is it?</p>
<p><i>Edit - changed <code>A&</code> to <code>const A&a... | <p>1: Taking the address of a temporary is not allowed. Visual C++ allows it as a language extension (language extensions are on by default).</p>
<p>2: This is perfectly legal.</p>
| <p>Perfectly legal.</p>
<p>The object will exist on the stack during the function call, just like any other local variable as well. </p>
| 11,002 |
<p>At one point I had looked at implementing a class/template in C++ that would support an Enum that would behave like it does in Ada. It has been some time since I thought about this problem and I was wondering if anyone has ever solved this problem?</p>
<p>EDIT:</p>
<p>My apologies, I should clarify what functional... | <p>One of my colleagues has implemented a tool to generate classes that do most (if not all) of what you want:</p>
<p><a href="http://code.google.com/p/enumgen/" rel="nofollow noreferrer">http://code.google.com/p/enumgen/</a></p>
<p>The current implementation is in Lisp, but do not hold that against him :-)</p>
| <p><a href="http://www.edm2.com/0405/enumeration.html" rel="nofollow noreferrer">This article</a> shows you how to generate the string version of an enumerated value, although it requires that you write the code to do so yourself. It also provides a preprocessor macro to very easily permit incrementing and decrementin... | 38,537 |
<p>In our web-app we use PHP5.2.6 + PDO to connect to a SQL Server 2005 database and store Russian texts.</p>
<p>Database collation is <code>Cyrillic_General_CI_AS</code>, table collation is <code>Cyrillic_General_CI_AS</code>, column type is <code>NVARCHAR(MAX)</code>.</p>
<p>We tried connecting to a database using ... | <p>Try executing <code>SET NAMES "charset"</code> after you connect.</p>
<p>I don't know what the charset to match <code>Cyrillic_General_CI_AS</code> is, but try "Cyrillic"?</p>
| <p>I've always had the best luck using utf8_general_ci across the board - for connections, collations - everything.</p>
<p>However, I only have that experience with MySQL and PostgreSql - not with SQL Server.</p>
<p>As to your DSN question - I'm not sure.</p>
<p>Good Luck!</p>
| 21,516 |
<p>For one and a half years, I have been keeping my eyes on the git community in hopes of making the switch away from SVN. One particular issue holding me back is the inability to lock binary files. Throughout the past year I have yet to see developments on this issue. I understand that locking files goes against the... | <p>Subversion has locks, and they aren't just advisory. They can be enforced using the <code>svn:needs-lock</code> attribute (but can also be deliberately broken if necessary). It's the right solution for managing non-mergeable files. The company I work for stores just about everything in Subversion, and uses <code>svn... | <p>Git is not providing any command to lock files but I've fund a way to achieve that function using git hooks.
An auxiliary server is needed to store the lock informations. We can use a pre-commit hook to check if any of the committed files is locked. And if anyone locks a file, a program should tell the auxiliary ser... | 14,528 |
<p>I have created a "check Box " window with a button, when the button is clicked, It should open a "Edit" window, How can I do?</p>
<p>thanks </p>
| <p>It depends completely on the windowing system you are using, or the graphics library. ¿Are you using .NET? ¿MFC?</p>
<p>In any case, your button object will have a way to associate a function to its click event. Just write a function that does what you need (in this case, open the "Edit" window), associate this f... | <p>You could instanciate a new window and show it on the click event</p>
| 49,486 |
<p>A "static" query is one that remains the same at all times. For example, the "Tags" button on Stackoverflow, or the "7 days" button on Digg. In short, they always map to a specific database query, so you can create them at design time. </p>
<p>But I am trying to figure out how to do "dynamic" queries where the user... | <p>The first rule is that users are allowed to specify <em>values</em> in SQL expressions, but not SQL <em>syntax</em>. All query syntax should be literally specified by your code, not user input. The values that the user specifies can be provided to the SQL as query parameters. This is the most effective way to lim... | <p>Well the options have to map to something.</p>
<p>A SQL query string <code>CONCAT</code> isn't a problem if you still use parameters for the options.</p>
| 35,185 |
<p>Currently, I'm using a strategy found on many blog posts. Basically, the URL contains the page number (e.g. /Users/List/5 will give you the users on page 5 of your paged list of users). However, I'm not running into a situation where one page must list two separate paged lists. How do I go about doing this using ... | <p>Ignoring routes for just a minute, you'll just keep the state of the 2 different pages in the URL as querystring parameters.</p>
<p>mysite.com/foo?list1page=2&list2page=8</p>
<p>Then you build the data/pagers accordingly. The pager links will just update the url.</p>
<p>You can get creative with routes to cr... | <p><a href="https://www.nuget.org/packages/PagedList.Mvc" rel="nofollow">PagedList.Mvc</a> is a really easy to use plugin, and is available via <code>Nuget</code> too.</p>
| 37,239 |
<p>Given the following class</p>
<pre><code>public class Foo
{
public int FooId { get; set; }
public string FooName { get; set; }
public override bool Equals(object obj)
{
Foo fooItem = obj as Foo;
if (fooItem == null)
{
return false;
}
return fooI... | <p>Yes, it is important if your item will be used as a key in a dictionary, or <code>HashSet<T></code>, etc - since this is used (in the absence of a custom <code>IEqualityComparer<T></code>) to group items into buckets. If the hash-code for two items does not match, they may <em>never</em> be considered eq... | <p>Below using reflection seems to me a better option considering public properties as with this you don't have have to worry about addition / removal of properties (although not so common scenario). This I found to be performing better also.(Compared time using Diagonistics stop watch).</p>
<pre><code> public int ... | 48,525 |
<p>I have a blank test app created in VS 2005 as ASP.NET application. <a href="http://msdn.microsoft.com/en-us/library/ms998351.aspx" rel="nofollow noreferrer">MSDN says</a> that </p>
<blockquote>
<p>By default, ASP.NET does not use impersonation, and your code runs using the ASP.NET application's process identity.<... | <p>I think I understand your problem here.</p>
<p>Things to know before moving further,</p>
<ol>
<li><p>There are different security context while an application is running. Like <code>System.Security.Principal.WindowsIdentity.GetCurrent().Name</code>, and the one you mentioned above, i.e. <code>System.Threading.Thre... | <p>Seems odd, A few things to try:</p>
<ul>
<li>While in on a breakpoint in Debug type $user in a watch window, that will show you the process and thread identities.</li>
<li><p>Your use of impersonate is incorrect, try this code:</p>
<pre><code>// Declare the logon types as constants
const long LOGON32_LOGON_INTERAC... | 30,750 |
<p>I have a (varchar) field Foo which can only be specified if (bit) Bar is <em>not</em> true. I would like the textbox in which Foo is displayed to be <em>disabled</em> when Bar is true -- essentially, <code>FooBox.Enabled = !isBar</code>. I'm trying to do something like</p>
<pre><code>FooBox.DataBindings.Add(new B... | <p>As far as I can tell, Databind uses reflection to find the member passed as the 3rd string argument. You cannot pass an expression there, just the member name.</p>
| <p>if isBar is a property of the source class (otherwise you need a property of a class to do the binding) this should work:</p>
<pre><code>FooBox.DataBindings.Add("Enabled", source, "isBar");
</code></pre>
<p>but remember that source.isBar must exist and be a boolean.</p>
| 44,919 |
<p>Many times I saw logging of errors like these:</p>
<pre><code>System.out.println("Method aMethod with parameters a:"+a+" b: "+b);
print("Error in line 88");
</code></pre>
<p>so.. What are the best practices to log an error?</p>
<p><strong>EDIT:</strong></p>
<p>This is java but could be C/C++, basic, etc.</p>
| <p>Logging directly to the console is horrendous and frankly, the mark of an inexperienced developer. The only reason to do this sort of thing is 1) he or she is unaware of other approaches, and/or 2) the developer has not thought one bit about what will happen when his/her code is deployed to a production site, and ho... | <p>There really is no best practice for logging an error. It basically just needs to follow a consistent pattern (within the software/company/etc) that provides enough information to track the problem down. For Example, you might want to keep track of the time, the method, parameters, calling method, etc.</p>
<p>So ... | 37,873 |
<p>Ok, after seeing <a href="https://stackoverflow.com/questions/315911/git-for-beginners-the-definitive-practical-guide/2678236#2678236">this post by PJ Hyett</a>, I have decided to skip to the end and go with <a href="http://en.wikipedia.org/wiki/Git_(software)" rel="nofollow noreferrer">Git</a>.</p>
<p>So what I ne... | <h1>How do you create a new project/repository?</h1>
<p>A git repository is simply a directory containing a special <code>.git</code> directory.</p>
<p>This is different from "centralised" version-control systems (like subversion), where a "repository" is hosted on a remote server, which you <code>c... | <p>Very good post on merging with conflicts - <a href="http://www.gitguys.com/topics/merging-with-a-conflict-conflicts-and-resolutions/" rel="nofollow">GitGuys: Merging With a Conflict - Conflicts And Resolutions</a></p>
<p>The blog is really great - illustrative, clean examples and understandable. Definitely worth ch... | 40,789 |
<p>My team has a command parsing library for console apps. Each team around us has their own as well. There isn't anything in the BCL so I suppose this is natural.</p>
<p>I've looked at the the module in Mono, which seems solid, and the one on CodePlex looks fine as well. There are probably others out there that will ... | <p>Well to be honest, you <strong>can't</strong> make everyone settle on one solution. You can suggest a solution and point out it's benefits, but eventually the advantages would have to be greater than the inertia that they have built up with their present library.</p>
<p>To make them settle on one library you would ... | <p>EBGreen, good point, I should have mentioned <em>why</em> I am looking to do this. Our teams frequently read and edit code from the surrounding teams. And I mean feature teams, not just dev/test/pm divisions. </p>
<p>This is just one of those little things that slow everybody down. Working on Team C's code? Got to ... | 7,867 |
<p>Here's a coding problem for those that like this kind of thing. Let's see your implementations (in your language of choice, of course) of a function which returns a human readable String representation of a specified Integer. For example:</p>
<ul>
<li>humanReadable(1) returns "one".
<li>humanReadable(53) returns "f... | <p>There was already a question about this:
<a href="https://stackoverflow.com/questions/3213/c-convert-integers-into-written-numbers">Convert integers to written numbers</a></p>
<p>The answer is for C#, but I think you can figure it out.</p>
| <p>There's one huge problem about this function implementation. It is it's future localization. That function, written by english native speaker, most probably wouldn't work right for any other language than english. It is nearly impossible to write general easy localizable function for any human language dialect in a ... | 3,253 |
<p>I have a table with two fields of interest for this particular exercise: a CHAR(3) ID and a DATETIME. The ID identifies the submitter of the data - several thousand rows. The DATETIME is not necessarily unique, either. (The primary keys are other fields of the table.)</p>
<p>Data for this table is submitted ever... | <p>From your description, I wouldn't worry about the efficiency of the query since apparently it only needs to run twice a year!</p>
<p>There are a few ways to do this, which one is 'best' depends on the data that you have. The datediff (on max/min date values) you suggested should work, another option is to just count... | <p>From your description, I wouldn't worry about the efficiency of the query since apparently it only needs to run twice a year!</p>
<p>There are a few ways to do this, which one is 'best' depends on the data that you have. The datediff (on max/min date values) you suggested should work, another option is to just count... | 23,867 |
<p>What language(s) have comments with side effects? In essence, comments which are <strong>not</strong> comments....</p>
| <p>I can think of several places where comments aren't really comments.</p>
<ul>
<li>HTML and script tags (providing support for browsers that don't allow or support scripts).</li>
</ul>
<p>And then, considerably more obscurely:</p>
<ul>
<li>IBM Informix 4GL (I4GL) and 4J's Genero (successor to Informix Dynamic 4GL,... | <p>CSS for clever cross-browser hacks. Of course, I wouldn't really call CSS a language.</p>
| 48,326 |
<p>I noticed when a file is executed on Windows (.exe or .dll), it is locked and cannot be deleted, moved or modified.</p>
<p>Linux, on the other hand, does not lock executing files and you <em>can</em> delete, move, or modify them.</p>
<p>Why does Windows lock when Linux does not? Is there an advantage to locking?</... | <p>Linux has a reference-count mechanism, so you can delete the file while it is executing, and it will continue to exist as long as some process (Which previously opened it) has an open handle for it. The directory entry for the file is removed when you delete it, so it cannot be opened any more, but processes already... | <p>NT variants have the </p>
<p>openfiles </p>
<p>command, which will show which processes have handles on which files. It does, however, require enabling the system global flag 'maintain objects list' </p>
<p>openfiles /local /? </p>
<p>tells you how to do this, and also that a performance penalty is incurred by d... | 23,928 |
<p>I have video durations stored in HH:MM:SS format. I'd like to display it as HH hours, MM minutes, SS seconds. It shouldn't display hours if it's less than 1.</p>
<p>What would be the best approach?</p>
| <p>try using split </p>
<pre><code>list($hh,$mm,$ss)= split(':',$duration);
</code></pre>
| <p>explode() is for pansies. This is a job for <a href="http://regular-expressions.info" rel="nofollow noreferrer">regular expressions</a>!</p>
<pre><code><?php
preg_match('/^(\d\d):(\d\d):(\d\d)$/', $video_duration, $parts);
if ($parts[1] !== '00') {
echo("{$parts[1]} hours, {$parts[2]} minutes, {$parts[3]} se... | 10,578 |
<p>I'm writing an image bank with Django, and I want to add a button to get a hi-res version of an image (the low-res is shown in the details page). If I put just an <code><a></code> link, the browser will open the image instead of downloading it. Adding an HTTP header like:</p>
<pre><code>Content-Disposition... | <p>If your django app is proxied by nginx you can use <a href="http://blog.kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/" rel="nofollow noreferrer">x-accell-redirect</a>. You need to pass a special header in your response, nginx will intercepet this and start serving the file, you can also pass Content-Dispo... | <p>What i'm doing now is to use a different URL for download than for 'views', and add the filename as an URL arg:</p>
<p>usual media link: <code>http://xx.com/media/images/lores/f_123123.jpg</code>
download link: <code>http://xx.com/downs/hires/f_12323?beach008.jpg</code></p>
<p>and nginx has a config like this:</p>... | 32,939 |
<p>I'm developing an application which has a lot of text and also different modules which can be included or not in every build.</p>
<p>For each saved project we generate automatically a report with all the details (i.e. description of algorithms used in that project and so on). Currently we embed all text as strings ... | <p>I think all text which may change between different versions of the code should be kept in separate property files. You can build a mechanism which maps message ids to the proper string from a property file, say map id 15 to "search" or to "busca" in the English and Spanish property files respectively. So a property... | <p>From personal experience with using different languages I found the special textfile for each country the best solution. You have to be careful with the differences in length for the same concept in different languages. You can also print the textfile and give it to a translator way before you install the software. ... | 32,729 |
<p>When designing a REST API or service are there any established best practices for dealing with security (Authentication, Authorization, Identity Management) ?</p>
<p>When building a SOAP API you have WS-Security as a guide and much literature exists on the topic. I have found less information about securing REST en... | <p>As tweakt said, Amazon S3 is a good model to work with. Their request signatures do have some features (such as incorporating a timestamp) that help guard against both accidental and malicious request replaying.</p>
<p>The nice thing about HTTP Basic is that virtually all HTTP libraries support it. You will, of cou... | <p>REST itself offers no security standards, but things like OAuth and SAML are rapidly becoming the standards in this space. However, authentication and authorization are only a small part of what you need to consider. Many of the known vulnerabilities relating to web applications apply very much to REST apis. You ... | 2,910 |
<p>We have an Excel 2002/XP based application that interacts with SQL 2000/5 to process fairly complex actuarial calculations. The application performs its function well, but it's difficult to manage.</p>
<p>We're trying to create a "controller" application or service that can manage and monitor these various instance... | <p>Don't do it!</p>
<p>We tried for weeks to get something like that to work and it simply does not behave as advertised. Don't even start - give up immediately!</p>
<p>The only options that you really have is a heavy server-side MOSS based implementation - Excel (Web) services (they call it something like that). Wi... | <p>You might want to take a look at this product: <a href="http://www.spreadsheetgear.com/products/spreadsheetgear.net.aspx" rel="nofollow noreferrer">http://www.spreadsheetgear.com/products/spreadsheetgear.net.aspx</a></p>
<p>It's all managed code and direct .NET libraries. No InterOp headaches. I haven't used it mys... | 11,314 |
<p>We have a simple registration form for our website users where we only require an e-mail address and a password (both repeated twice to make sure they are correct). We require that the user confirm their e-mail accounts by clicking a link in an e-mail.</p>
<p>We see that a lot of users don't bother following the li... | <p>I don't have any stats to help you, but have you gathered stats on how many people try to log in to inactive accounts?</p>
| <p>I don't have any stats to help you, but have you gathered stats on how many people try to log in to inactive accounts?</p>
| 27,888 |
<p>Anyone can point me to any info regarding physics of a snooker game, if possible more about the ball collisions? I would like to make a game and I need some help about the physics.</p>
| <p>There's a book online about this,</p>
<p>"<a href="http://web.cecs.pdx.edu/~howe/poolphysics.pdf" rel="noreferrer">Amateur Physics for the Amateur Pool Player</a>" by Ron Shepard (PDF Link)</p>
<p>I haven't read it but I've heard it's good for game developers.</p>
| <p>Carom3D is a great one, they seem to have mastered the physics. See these links for more info:</p>
<p><a href="http://www.jimloy.com/billiard/phys.htm" rel="nofollow noreferrer">http://www.jimloy.com/billiard/phys.htm</a>
<a href="http://archive.ncsa.uiuc.edu/Classes/MATH198/townsend/math.html" rel="nofollow noref... | 11,857 |
<p>I can, on some of my systems, get my IP address (192.68.m.n format) by doing this:</p>
<pre><code>addr = IPSocket::getAddress(Socket.gethostname())
</code></pre>
<p>...the trouble is that this only works if the name the local machine uses for itself is the name the DNS server associates with it.</p>
<p>How *&... | <p>See <a href="https://stackoverflow.com/questions/42566/getting-the-hostname-or-ip-in-ruby-on-rails">this question</a>. Also <code>see Socket.getaddrinfo()</code></p>
| <p>How about this</p>
<pre><code>require 'socket'
ipaddr = UDPSocket.open {|s| s.connect('65.59.196.211'); s.addr.last }
</code></pre>
<p>the IP address can be anything that is real (this is the I got for stackoverflow.com), but it should be an IP address reachable on the interface you want to get the IP address for.... | 49,722 |
<p>I had a discussion with some colleagues mentioning that there are not too many projects that we do which make use of WPF for creating UI for a windows application (we almost always use Windows Forms instead).</p>
<ul>
<li>Are your experiences the same - i.e. there is not too much adoption of this technology?</li>
<... | <p>Have a look at this <a href="http://www.componentfactory.com/blog/?p=322" rel="nofollow noreferrer">survey</a> it was done by a Windows Forms Contol Vendor in Australia.
Personally I have worked on two commercial projects in the last year that were using WPF to varying degrees.</p>
<p>The adoption of WPF is on the r... | <p>Though WPF was introduced few years ago it was too raw to use it in the real world apps. Major problem that stops WPF from wide adoption is a lack of RAD tools and out-of-box components. Currently we have Blend, more or less working Cider, but usable versions of these tools came not so long ago. Another reason is ... | 5,879 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.