instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I work for a small digital marketing company as a programmer, and we are not a Microsoft partner or any sort (Gold/Silver/Bronze). However, we use .NET.</p>
<p>What I am confused about is that the developer before me has left, and he gets subscription DVDs of latest Microsoft tools, delivered to the company (Sql Se... | <p>For the definitive answer read through the <a href="http://msdn.microsoft.com/en-us/subscriptions/aa948864.aspx" rel="noreferrer">MSDN subscription FAQ</a> which includes the license terms.</p>
<p>My understanding is that you can use the software to support development work for your company, but not run production ... | <p>If the subscription was paid for by the company, you should be able to change the named individual to yourself (or someone else in the company). This would allow you to access MSDN using the subscription to download software and submit problem reports. We had a license that we switched one when one of the licensed... | 29,709 |
<p>I've never had a reason to put a label element inside of a legend element (never really thought about it or seen it done). But with the design I'm implementing, it's tempting to do so.</p>
<p>Here's what I'm tempted to do:</p>
<pre><code><fieldset>
<legend><label for="formInfo">I would like infor... | <p>Where is your <code></fieldset></code>?</p>
<p>Semantically, <a href="http://www.w3.org/TR/html401/interact/forms.html#h-17.10" rel="noreferrer"><code>legend</code> describes a <code>fieldset</code></a>, just as <code>label</code> describes a single field.</p>
<p>Fieldsets are supposed to be used to group to... | <p>well, the label element itself seems fine - it's the description of the "formInfo" element, so that's no worries. Semantically, however, what's this saying about the <code>legend</code> element? It's supposed to be a caption for the entire fieldset....</p>
| 29,568 |
<p>I am adapting a little rmi client-server application. I have written several things :</p>
<pre><code>HelloInterface -> A Hello World interface for RMI
Server -> The server app'
Client -> The client app'
</code></pre>
<p>Nothing special, but... I have put my hands in a new RMISecurityManager, which calls a... | <blockquote>
<p>IMHO the meaning of this is that a thread is (implicitly) created and gets the NativeRMISecurityManager as its default SecurityManager.</p>
</blockquote>
<p>This is true, though it is not the cause of your error; the problem has to do with the use of ThreadLocal. The key property of a ThreadLocal is... | <p>Yes ! That's it.</p>
<p>I have thought about that yesterday afternoon, and I went on the same solution. I'll post here my code for those who would be curious of that.
1) The NativeRMISecurityManager
2) The C code (you have to generate the .h with javah</p>
<p>(nb: I won't traduce it in english as there are loads o... | 37,037 |
<p>In order to write better code, is it worth to know deeply what the compiler does? </p>
<p>Just how much would be enough? I'm not a bit scrubber, but I was thinking that knowing how the compiler operates would make me a better programmer. Am I wrong? </p>
<p>If so, what resources would you recommend?</p>
| <p>Probably wouldn't hurt to know how the compiler will optimize your code, but <strong>don't write for the compiler, but write for people to read</strong>.</p>
<p>Writing code in a way that is more optimized for the compiler may make it more difficult for people to read it, and these days the <strong>compiler probabl... | <p>I think that what is really really important is to make an interpreter: it gives you more insight of programming languages, and that's what you use... In scheme it is actually rnot hard at to make an interpeter! But actually I would greatly encourage reading parts of <a href="http://en.wikipedia.org/wiki/Structure_a... | 45,795 |
<p>I'm using shared ASP.NET hosting and I have no remote-desktop access to the web server. I only have the ability to FTP ASP.NET related files to the server.</p>
<p>In this scenario, how would I see how much memory my ASP.NET application is consuming?</p>
| <p>Could you create a page that listed various performance counters in a password-protected part of the site? That would be my suggestion, along with making sure that somewhere on the page, a machine name or IP is listed so that should the site move among various servers, this can be noted somewhere. Another idea wou... | <p>Update: Maybe <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.process.peakvirtualmemorysize64.aspx" rel="nofollow noreferrer">Process.PeakVirtualMemorySize64</a> is more focused on your need. Did not try it myself.</p>
<p>Before update:
This link is about what you need.</p>
<p><a href="https://... | 40,642 |
<p>I'm looking for a way to stream a PDF file from my server to the browser using .NET 2.0 (in binary).</p>
<p>I'm trying to grab an existing PDF file from a server path and push that up as binary to the browser.</p>
| <p>Here you go: <a href="http://support.microsoft.com/kb/306654" rel="noreferrer">How To Write Binary Files to the Browser Using ASP.NET and Visual C# .NET</a></p>
| <p>You can just setup a handler or a page that set's the correct response type and output the pdf to the response output buffer.</p>
| 11,052 |
<p>Even after all the hotfixes and updates that are supposed to fix this, my properties window in Visual Studio 2008 is still SLOW! What happens is a click on a table cell or something similar in the web editor, and regardless of the size of the page I'm working on, it takes a second or two for the properties window t... | <p>I think I figured out the problem I was having - I turned off the startup page, and disabled the startup page refresh option (where it checks for latest content every 60 minutes or whatever), so that now when I load the environment, it just shows a blank page.</p>
<p>I have no idea why this would relate to the amou... | <p>Turn off all animation.</p>
| 16,480 |
<p>We've been running <a href="http://eaccelerator.net/" rel="noreferrer" title="eAccelerator">eAccelerator</a> on each of 3 webservers and are looking to move to a <a href="http://www.danga.com/memcached/" rel="noreferrer" title="memcache">memcache</a> pool across all 3, hopefully reducing by about 2/3 our db lookups.... | <p><a href="http://livebookmark.net/journal/2008/05/21/memcachephp-stats-like-apcphp/" rel="nofollow noreferrer">memcache.php</a> may be what you're looking for.</p>
<blockquote>
<p>memcache.php that you can get stats and dump from multiple memcache servers.</p>
</blockquote>
<p>Can <a href="http://livebookmark.net... | <blockquote>
<p>If all you need to do is to be able to flush the cache from a web-application, you could create a simple php-page and then use the system() call...</p>
</blockquote>
<p>Cache flushing is part of what we're looking for, but also a way to monitor what scripts are currently in there, how much data is in... | 5,749 |
<p>I've used boost serialization but this doesn't appear to allow me to generate xml that conforms to a particular schema -- it seems it's purpose was to just to persist a class's state.</p>
<p>Platform: linux</p>
<p>What do you guys use to generate NOT parse xml?</p>
<p>So far I'm going down Foredecker's route of j... | <p>I recently reviewed a bunch of XML libraries specifically for generating XML code. </p>
<p>Executive summary: I chose to go with <a href="http://code.google.com/p/ticpp/" rel="noreferrer">TinyXML++</a>. </p>
<p>TinyXML++ has decent C++ syntax, is built on the mature <a href="http://www.grinninglizard.com/tinyxml... | <p>Which platform?
MSXML is an option on Windows.
<a href="http://www.firstobject.com" rel="nofollow noreferrer">CMarkup</a> is another good choice.
If .NET is an option, it has excellent XML support.</p>
| 38,977 |
<p>I'm looking for a way to convert a preprocessor token to a string.</p>
<p>Specifically, I've somewhere got:</p>
<pre><code>#define MAX_LEN 16
</code></pre>
<p>and I want to use it to prevent buffer overrun:</p>
<pre><code>char val[MAX_LEN+1]; // room for \0
sscanf(buf, "%"MAX_LEN"s", val);
</code></pre>
<p>I'm ... | <p>see <a href="http://www.decompile.com/cpp/faq/file_and_line_error_string.htm" rel="noreferrer">http://www.decompile.com/cpp/faq/file_and_line_error_string.htm</a>
specifically:</p>
<pre><code>#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
#define AT __FILE__ ":" TOSTRING(__LINE__)
</code></pre>
<p>so you... | <p>While some of the above "work", personally I'd recommend just using a simple string API instead of the dreck that comes in libc. There are a number of portable APIs, some of which are also optimized for ease of inclusion in your project ... and some like <a href="http://www.and.org/ustr/" rel="nofollow noreferrer">u... | 29,752 |
<p>I have the following interface:</p>
<pre><code>internal interface IRelativeTo<T> where T : IObject
{
T getRelativeTo();
void setRelativeTo(T relativeTo);
}
</code></pre>
<p>and a bunch of classes that (should) implement it, such as:</p>
<pre><code>public class AdminRateShift : IObject, IRelativeTo<A... | <p>If I understand the question, then the most common approach would be to declare a non-generic base-interface, i.e.</p>
<pre><code>internal interface IRelativeTo
{
object getRelativeTo(); // or maybe something else non-generic
void setRelativeTo(object relativeTo);
}
internal interface IRelativeTo<T> :... | <p>If all you care about is that IRelativeTo deals with IObjects then you don't need to make it generic:</p>
<pre><code>interface IRelativeTo
{
IObject getRelativeTo();
void setRelativeTo(IObject relativeTo)
}
</code></pre>
<p>The implementing classes may still be generic, however:</p>
<pre><code>abstract cl... | 27,436 |
<p>What's the best framework for writing modules -- <a href="http://search.cpan.org/perldoc/ExtUtils::MakeMaker" rel="noreferrer">ExtUtils::MakeMaker</a> (h2xs) or <a href="http://search.cpan.org/perldoc/Module::Build" rel="noreferrer">Module::Build</a>?</p>
| <p><strong>NOTE</strong> This advice is out of date. <a href="http://www.dagolden.com/index.php/2140/paying-respect-to-modulebuild/" rel="nofollow noreferrer">Module::Build has been removed from the Perl core</a> but lives on as a CPAN module. The pros and cons still stand, and my opinions about MakeMaker still stand... | <p>EU::MM still seems to be the most widely supported and popular one, but Module::Build is catching up. Also, check out <a href="http://search.cpan.org/dist/Module-Starter/" rel="nofollow noreferrer">Module::Starter</a> for a module that will help you get started.</p>
| 9,958 |
<p>I have a static class that I would like to raise an event as part of a try catch block within a static method of that class.</p>
<p>For example in this method I would like to raise a custom event in the catch. </p>
<pre><code>public static void saveMyMessage(String message)
{
try
{
//Do Database s... | <p>Important: be very careful about subscribing to a static event from instances. Static-to-static is fine, but a subscription from a static event to an instance handler is a great (read: very dangerous) way to keep that instance alive forever. GC will see the link, and will not collect the instance unless you unsubscr... | <p>Note: VS2008, C#</p>
<p>Just declare an event as you normally would within the static class, but be sure to mark the event as static:</p>
<pre><code>public static event EventHandler Work;
</code></pre>
<p>Then just subscribe to it as you normally would.</p>
| 36,793 |
<p>Everyone is familiar with this functionality. If you open up the the outlook address book and start typing a name, the list below the searchbox instantly filters to only contain items that match your query. .NET Reflector has a similar feature when you're browsing types ... you start typing, and regardless of how ... | <p><a href="https://stackoverflow.com/questions/296618/what-is-the-most-common-use-of-the-trie-data-structure">What is the most common use of the trie data structure?</a></p>
<p>A Trie is basically a tree-structure for storing a large list of similar strings, which provides fast lookup of strings (like a hashtable) an... | <p>The process is called full text indexing/search.</p>
<p>If you want to play with the algorithms and data structures for this I would recommend you read <a href="http://oreilly.com/catalog/9780596529321/" rel="nofollow noreferrer">Programming Collective Intelligence</a> for a good introduction to the field, if you j... | 39,499 |
<p>What is the best way to handle a big team that has access to a stable but no so pretty code, that is easy to introduce bugs into?</p>
<p>I'm looking for something along the lines of SVN locking the file(s). </p>
| <p>Write unit tests if you don't have them already. Then start refactoring, and keep doing regression tests upon every commit.</p>
| <p>I'm thinking more like refacter, if the code is hard to work with then it needs to be redone, it may take some time but it will likely be better in the long run as you won't cause as many problems.</p>
| 12,467 |
<p>I'm primarily a designer, with a fairly high level of understanding of CSS and HTML. I have an idea for a very simple iPhone app, largely involving a timer, an animated graphic, and some sound. If I get more advanced there could be some simple customization settings </p>
<p>I have no understanding of Objective C, o... | <p>If you have no programming experience, then creating a native iPhone application will be a daunting task. Developing for the iPhone is much like developing for the desktop mac, it's a very complete and mature system.</p>
<p>I'd honestly say, stick with doing a web-app for the iPhone. Mobile Safari makes available s... | <p>If you already understand HTML and CSS, you might want to brush up on your JavaScript instead and use something like <a href="http://www.kendoui.com/mobile.aspx" rel="nofollow">Kendo UI Mobile</a> or <a href="http://jquerymobile.com/" rel="nofollow">jQuery Mobile</a>. You can basically make an HTML5 single-page app ... | 13,471 |
<p>OK, so practically every database based application has to deal with "non-active" records. Either, soft-deletions or marking something as "to be ignored". I'm curious as to whether there are any radical alternatives thoughts on an `active' column (or a status column).</p>
<p>For example, if I had a list of people</... | <p>You partition the table on the active flag, so that active records are in one partition, and inactive records are in the other partition. Then you create an active view for each table which automatically has the active filter on it. The database query engine automatically restricts the query to the partition that ha... | <p>We use active flags quite often. If your database is going to be very large, I could see the value in migrating inactive values to a separate table, though.</p>
<p>You would then only require a union of the tables when someone wants to see all records, active or inactive.</p>
| 12,783 |
<p>Is there a way to specify which monitor a application appears on in Delphi or C++Builder? </p>
<p>I am developing a simple program for a customer, which displays kitchen orders on a secondary monitor, generated by a hospitality system. Currently they need to manually drag the window onto the second monitor after ... | <p>Save the window position before program shutdown and restore them on startup. Multimonitor displays just increase the size of the desktop; other monitor surfaces just have a different section of the same X/Y plane with its origin at the top-left of the primary monitor.</p>
<p>This can be done automatically for you ... | <p>I don't do much with windows systems, so I would suggest a hack like this.</p>
<p>Grab the width of the viewable desktop(both monitors combined), divide it by half and make that your starting position.</p>
<p>You may also look into what api tells you monitor2's dimensions.</p>
| 25,283 |
<p>I am currently using <code>Net::HTTP</code> in a Ruby script to post files to a website via a multipart form post. It works great for small files, but I frequently have to send very large files using this script, and <code>HTTP#post</code> only seems to accept post data as a <code>String</code> object, which means ... | <p>Actually I managed to upload a file using body_stream. The full source code is here:
<a href="http://stanislavvitvitskiy.blogspot.com/2008/12/multipart-post-in-ruby.html" rel="nofollow noreferrer">http://stanislavvitvitskiy.blogspot.com/2008/12/multipart-post-in-ruby.html</a></p>
| <p>Use Net::HTTP#body_stream(input)</p>
<p>Example for <a href="http://trac-git.assembla.com/breakout/browser/lib/trac2assembla.rb#L517" rel="nofollow noreferrer">multipart post without streaming</a>:</p>
| 26,257 |
<p>Given a UTC time string like this:</p>
<pre><code>2005-11-01T00:00:00-04:00
</code></pre>
<p>What is the best way to convert it to a DateTime using a Crystal Reports formula?</p>
<p>My best solution is posted below.</p>
<p>I hope someone out there can blow me away with a one-liner...</p>
| <p>Here you go:</p>
<pre><code>CDateTime(CDate(Split({?UTCDateString}, "T")[1]) , CTime(Split(Split({?UTCDateString}, "T")[2], "-")[1]))
</code></pre>
| <pre><code>StringVar fieldValue;
StringVar datePortion;
StringVar timePortion;
NumberVar yearPortion;
NumberVar monthPortion;
NumberVar dayPortion;
NumberVar hourPortion;
NumberVar minutePortion;
NumberVar secondPortion;
datetimevar dtlimite;
fieldValue := {dtsecretaria.Data_limite};
datePortion := Split (fieldValue,... | 34,091 |
<p>Some projects have properties have miscellaneous settings such as: "AllowPayments", "ShowSideBar", "SectionTitle". Really things that don't necessarily fit in to other objects. </p>
<p>How do you guys store these kinds of values? ApplicationSettings? Flat File? Database table?</p>
<p>How do you access them? Static... | <p>For me it depends on the context the setting is. If it relates to the data and the domain, i store in the database, if it relates the the application i store in the web.config.</p>
| <p>Since you didn't tell which environment you use:
In .NET applications, I use the ApplicationSettings system from Visual Studio. This way you can configure the settings with default values in the designer, and a strongly-typed class to access the values is generated. I usually add a second ApplicationSettings element... | 17,190 |
<p>Is this function declaration in C#:</p>
<pre><code>void foo(string mystring)
</code></pre>
<p>the same as this one in C:</p>
<pre><code>void foo(char *)
</code></pre>
<p>i.e. In C#, does the called function receive a pointer behind the scenes?</p>
| <p>In this specific instance, it is more like:</p>
<pre><code>void foo(const char *);
</code></pre>
<p>.Net strings are immutable and passed by reference. However, in general C# receives a pointer or reference to an object behind the scenes.</p>
| <p>As far as I know, all classes in C# (not sure about the others) are reference types.</p>
| 9,028 |
<p>I am curious to do what happens when you edit a post on this site.</p>
<p>I am using wmd for my markdown editor, of course when I goto edit, I get the HTML it generated not the markdown like on stackoverflow. Now, is there a way I can store both? or is it reliable enough to simply convert the HTML back to markdow... | <p>Look at the <code>optionsExample.html</code> in your WMD distribution. There's an option to send the result to the server as Markdown.</p>
| <p>I have just know <a href="http://milianw.de/projects/markdownify/" rel="nofollow">Markdownify</a> (formerly html2text.php) that "writes texts in Markdown and save them in HTML. You won’t need a copy of the original Markdown input, since Markdownify can convert the saved HTML back to Markdown. And because page impres... | 29,110 |
<p>The 3-argument form of <code>list::splice()</code> moves a single element from one list to the other. <a href="http://techpubs.sgi.com/library/tpl/cgi-bin/init.cgi" rel="noreferrer">SGI's documentation</a> explicitly states that all iterators, <em>including the one pointing to the element being moved</em> remain va... | <p>Ok, this seems to be a defect in the standard, according to <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#250" rel="noreferrer">this</a> and <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#278" rel="noreferrer">this</a> link. It seems that "sticking the head in the sand... | <p>I have an array of lists (equivalence classes of elements), and I'm using splice to move elements between the lists. I have an additional array of iterators which gives me direct access to any element in any of the lists and to move it to another list. None of the lists is searched and modified at the same time. ... | 17,291 |
<p>Apache XMLBeans can be used to generate Java classes and interfaces from XML Schema Definition files (XSD). It also generates Enums based on StringEnumAbstractBase and StringEnumAbstractBase.Table to represent domain values. They are handy for entering only valid values. However, I want to get all those values to ge... | <p>This worked for me:</p>
<pre><code>for (int i = 1; i <= MyEnum.Enum.table.lastInt(); i++)
{
System.out.println(MyEnum.Enum.forInt(i));
}
</code></pre>
| <p>Here is another way to get it :</p>
<pre><code>public static List<String> getEnumValueList(XmlString xmlString){
List<String> values = new ArrayList<String>();
SchemaStringEnumEntry valArr[] = xmlString.schemaType().getStringEnumEntries();
for(SchemaStringEnumEntry val : valArr){
... | 44,705 |
<p>I'm trying to balance a set of currency values using vb.net. The totals for both these values is cast as a double. I'm getting rounding errors in some situations. </p>
<p>What's the best way to avoid this? Is there a type I can use in preference to double? How do I round the resultant value to two decimal places?</... | <p>For financial calculations I believe that the current wisdom is to use Decimals instead of Doubles.</p>
<p>You might be interested in this discussion <a href="https://stackoverflow.com/questions/4/decimal-vs-double">Decimal Vs. Double</a>.</p>
| <p>Try using the Decimal type.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/system.decimal.aspx" rel="nofollow noreferrer">MSDN - Decimal</a></p>
| 22,599 |
<p>I'm working on a web service at the moment and there is the potential that the returned results could be quite large ( > 5mb). </p>
<p>It's perfectly valid for this set of data to be this large and the web service can be called either sync or async, but I'm wondering what people's thoughts are on the following:</p>... | <p>I have seen all three approaches, <strong>paged</strong>, <strong>store and retrieve</strong>, and <strong>massive push</strong>.</p>
<p>I think the solution to your problem depends to some extent on why your result set is so large and how it is generated. Do your results grow over time, are they calculated all at... | <p>I somewhat disagree with secretGeek's comment:</p>
<blockquote>
<p>That's already happening for you -- it's called tcp/ip ;-) Re-implementing that could be overkill.</p>
</blockquote>
<p>There are times when you may want to do just this, but really only from a UI perspective. If you implement some way to either... | 3,291 |
<p>I heard a lot about makefiles and how they simplify the compilation process. I'm using VS2008. Can somebody please suggest some online references or books where I can find out more about how to deal with them?</p>
| <p>The Microsoft Program Maintenance Utility (NMAKE.EXE) is a tool that builds projects based on commands contained in a description file. </p>
<p><a href="http://msdn.microsoft.com/en-us/library/dd9y37ha.aspx" rel="noreferrer">NMAKE Reference</a></p>
| <p>If you are asking about actual command line makefiles then you can export a makefile, or you can call MSBuild on a solution file from the command line. What exactly do you want to do with the makefile?</p>
<p>You can do a search on SO for MSBuild for more details.</p>
| 40,588 |
<p>What follows is a regular expression I have written to match multi-line pre-processor macros in C / C++ code. I'm by no means a regular expressions guru, so I'd welcome any advice on how I can make this better.</p>
<p>Here's the regex:</p>
<pre><code>\s*#define(.*\\\n)+[\S]+(?!\\)
</code></pre>
<p>It should match... | <p>This is a simple test program I knocked up:</p>
<pre><code>#!/usr/bin/env python
TEST1="""
#include "Foo.h"
#define bar foo\\
x
#include "Bar.h"
"""
TEST2="""
#define bar foo
#define x 1 \\
12 \\
2 \\\\ 3
Foobar
"""
TEST3="""
#define foo(x) if(x) \\
doSomething(x)
"""
TEST4="""
#define foo(x) if(x) ... | <pre><code>start = r"^\s*#define\s+"
continuation = r"(?:.*\\\n)+"
lastline = r".*$"
re_multiline_macros = re.compile(start + continuation + lastline,
re.MULTILINE)
</code></pre>
| 8,569 |
<p>How can I access <code>UserId</code> in ASP.NET Membership without using <code>Membership.GetUser(username)</code> in ASP.NET Web Application Project?</p>
<p>Can <code>UserId</code> be included in <code>Profile</code> namespace next to <code>UserName</code> (<code>System.Web.Profile.ProfileBase</code>)?</p>
| <p>Try this:</p>
<pre><code>MembershipUser CurrentUser = Membership.GetUser(User.Identity.Name);
Response.Write("CurrentUser ID :: " + CurrentUser.ProviderUserKey);
</code></pre>
| <p>You have two options here:</p>
<p>1) Use username as the primary key for your user data table
i.e:</p>
<pre><code>select * from [dbo.User] where Username = 'andrew.myhre'
</code></pre>
<p>2) Add UserID to the profile.</p>
<p>There are pros and cons to each method. Personally I prefer the first, because it means ... | 17,683 |
<p>When I'm writing a Spring command line application which parses command line arguments, how do I pass them to Spring? Would I want to have my main() structured so that it first parses the command line args and then inits Spring? Even so, how would it pass the object holding the parsed args to Spring?</p>
| <p>Two possibilities I can think of.</p>
<p>1) Set a static reference. (A static variable, although typically frowned upon, is OK in this case, because there can only be 1 command line invocation). </p>
<pre><code>public class MyApp {
public static String[] ARGS;
public static void main(String[] args) {
ARG... | <p>I'm not sure what you are trying to achieve exactly, maybe you can add some details on what the command and the arguments will look like, and what outcome you expect from your application.</p>
<p>I think this is not what you need, but it might help other readers: Spring supports receiving properties from the comman... | 16,030 |
<p>Is it possible to define an implicit conversion of enums in c#?</p>
<p>something that could achieve this?</p>
<pre><code>public enum MyEnum
{
one = 1, two = 2
}
MyEnum number = MyEnum.one;
long i = number;
</code></pre>
<p>If not, why not?</p>
| <p>There is a solution. Consider the following:</p>
<pre><code>public sealed class AccountStatus
{
public static readonly AccountStatus Open = new AccountStatus(1);
public static readonly AccountStatus Closed = new AccountStatus(2);
public static readonly SortedList<byte, AccountStatus> Values = new... | <p>Introducing implicit conversions for enum types would break type safety, so I'd not recommend to do that. Why would you want to do that? The only use case for this I've seen is when you want to put the enum values into a structure with a pre-defined layout. But even then, you can use the enum type in the structure a... | 32,732 |
<p>My workplace is planning on moving to Team Foundation Server and it's not a moment too soon - anything to get away from the cancer that is Visual SourceSafe.</p>
<p>However, I must ask - is the source control in TFS significantly different (and better) than VSS or is it just a "beefed up" version of the same thing?... | <p>We've been using TFS for the last 18 months, and like many products the first version left a bit to be desired (one of the favourites of TFS 2005 was not to get latest when it said it had, resulting in many build breaks).</p>
<p>However now we're on TFS 2008 SP1 it works exceptionally well. The source control syste... | <p>I don't have first hand experience with TFS, but I've used both source safe and svn. From what I've read, your answers are yes, and yes. You can definitely feel the source safe history, but at the same time it's a modern system with the features you'd expect and then some (it does a lot of project management stuff... | 28,729 |
<p>This is often situation, but here is latest example: </p>
<p>Companies have various contact data (addresses, phone numbers, e-mails...) when they make job ad, they have checkboxes where they choose how they want to be contacted. It is basically descriptive data. User when reading an ad sees something like "You can ... | <p>You've tagged your question as "language-agnostic", and not all languages cleanly support polymorphism, but that's the way I would approach this. </p>
<p>Each option has some type, and different types require different properties to be set. However, every type supports some sort of "render" method that can display ... | <p>Well, if all it is is that you have two options that are special, and then anything else is dealt with in the same way, then store your options as strings, and if either of the two special ones appears in that list, then show the appropriate stuff for that special item.</p>
<p>Just check your list of items for the ... | 42,483 |
<p>We have a bunch of data on S3 (images) but just started reading about Mosso Files (rackspace). Sometime this month they are going to add CDN capabilities so any file you upload is part of the limelight CDN. </p>
<p>Anyone using this service, it's not as well documented or publicized at S3.</p>
| <p>Yes, it's not well documented or publicized as S3. But dude it has CDN support which S3 is lack off (unless you willing to pay extra of course). Bad thing is you can't FTP into Mosso CloudFile, you will either have to upload it through web-based control panel or API. Yet, it's still cheap and worth especially with C... | <p>We use it for all our client sites, from images to podcasts, and it's hand down, the best way to distribute content and make it highly available - especially at this price!</p>
<p>cheers</p>
| 37,658 |
<p>I've been working with a small group of people on a coding project for fun. It's an organized and fairly cohesive group. The people I work with all have various skill sets related to programming, but some of them use older or outright wrong methods, such as excessive global variables, poor naming conventions, and ... | <p>Introduce questions to make them realise that what they are doing is wrong. For example, ask these sort of questions:</p>
<blockquote>
<p>Why did you decide to make that a global variable?</p>
<p>Why did you give it that name?</p>
<p>That's interesting. I usually do mine this way because [Insert reason ... | <p>Probably a bit late after the effect, but that's where an agreed coding standard is a good thing.</p>
| 25,275 |
<p>Is there any library (or even better, web service) available which can convert from a latitude/longitude into a time zone?</p>
| <p>I looked fairly deeply into this question for a project I am working on. GeoNames.org and EarthTools.com are both good options for many situations but with the following serious flaws:</p>
<ul>
<li>GeoNames.org finds the time zone by searching for the nearest point in their database that contains a time zone field... | <p><a href="http://drtengine.com/pages/geo_get_timezone" rel="nofollow">DRT Engine</a> takes a latitude, longitude and local datetime and returns a timezone offset. This can be used to establish the timezone of a particular location at a <em>future</em> date.</p>
| 6,282 |
<p>In your applications, what's a "long time" to keep a transaction open before committing or rolling back? Minutes? Seconds? Hours?</p>
<p>and on which database?</p>
| <p>transactions: minutes.</p>
<p>Cursors: 0seconds maximum, if you use a cursor we fire you. </p>
<p><strong>This is not ridiculous when you consider we are in a high availability web environment, that has to run sql server, and we don't even allow stored procs because of inability to accurately version and maintain ... | <p>Generally I agree with the other answers: Avoid cursors when possible (in most cases) and close them as fast as possible.</p>
<p>However: It all depends on the environment you're working in. </p>
<ul>
<li>If it is a production website environment with lots of users, make sure that the cursor goes away before someo... | 3,190 |
<p>We have IIS6 running on a 64-bit Windows 2003 server with 32Gb physical RAM.
Due to some older 32-bit dependencies within our .NET 3.5 ASP.NET application, we are currently forced to run our IIS worker process in 32-Bit wow64 mode which I understand gives us access to 4Gb of memory for our worker process.</p>
<p>My... | <p>Yes, 4GB limit is per process. Each 32 bit process running on a 64 bit kernel has 4GB private address space limit (which is, by the way, not shared with the kernel as in a 32 bit system). You can access 4x4GB=16GB of memory, however, this 16GB is not available to a single process at once. Each can only directly acce... | <p>The answer to "each worker process access 4Gb of memory each" was answered above - by default you will have 2GB of RAM in user mode unless you use the /3GB switch, which you may or may not be able to use depending on the requirements of your app/server setup. You can wind up starving kernel mode resources. </p>
<p>... | 47,821 |
<p>When I navigate on a website utilizing MasterPages, does the application know what page I am on? If so, does it store it in an object I can access?</p>
<p>The reason I am asking is so I can replace this:</p>
<pre><code>//masterpage
<div id="nav_main">
<ul><asp:ContentPlaceHolder ID="navigation"... | <p>I'd concur with Chris: use a control to handle display of this menu and make it aware of what link should be highlighted. Here's a method I use regularly. It may become more complex if you've got multiple pages that would need the same link styled differently, but you get the idea.</p>
<pre><code>Dim thisURL As Str... | <p>There's also the Request.RawURL</p>
| 22,927 |
<p>I have a PHP script that is called from a cron job every minute. This script takes some info from the database and then calls another PHP script using the System function (passing it some parameters).</p>
<p>That means that I can start up to 10 scripts from this "main" one. And what I would like to do is that I wou... | <p>You may be able to use <a href="http://www.php.net/manual/en/function.proc-open.php" rel="nofollow noreferrer"><code>proc_open()</code></a>, <a href="http://www.php.net/manual/en/function.stream-select.php" rel="nofollow noreferrer"><code>stream_select()</code></a> and <a href="http://www.php.net/manual/en/function.... | <p>use php's version of fork or threads.</p>
| 16,507 |
<p>Why does C#.Net allow the declaration of the string object to be case-insensitive?</p>
<pre><code>String sHello = "Hello";
string sHello = "Hello";
</code></pre>
<p>Both the lower-case and upper-case S of the word String are acceptable and this seems to be the only object that allows this.</p>
<p>Can anyone expla... | <p><strong><code>string</code></strong> is a language keyword while <code>System.String</code> is the type it aliases.</p>
<p>Both compile to exactly the same thing, similarly:</p>
<ul>
<li><strong><code>int</code></strong> is <code>System.Int32</code></li>
<li><strong><code>long</code></strong> is <code>System.Int64... | <p>string is an alias for System.String. They are the same thing.</p>
<p>By convention, though, objects of type (System.String) are generally refered to as the alias - e.g.</p>
<pre><code>string myString = "Hello";
</code></pre>
<p>whereas operations on the class use the uppercase version
e.g.</p>
<pre><code>Strin... | 3,111 |
<p>This is in with <a href="https://3dprinting.stackexchange.com/questions/394/when-building-a-ramps-1-4-based-printer-can-i-safely-plugin-just-some-of-the-co">my other question about components</a> and the <a href="https://3dprinting.stackexchange.com/questions/389/in-the-standard-pc-cable-wire-that-goes-from-the-wall... | <p>To measure amps (current), the meter has to be wired in series with the item to be measured (for this reason, ammeters are designed to have very low resistance). </p>
<p>This has the down-side that you have to disconnect the component to put the meter in line with it. That makes it hard to do the "check a component... | <p>The easiest method is to use a Clamp On amp meter on either the hot or neutral of your power supply. </p>
<p>In most cases clamp on meters only work with AC xor DC power so you would only be able to get the reading on one side of the power supply.</p>
<p>Multiply this number by the voltage and you get the wattage... | 170 |
<p>I would like to know who is locking a file (win32). I know about <a href="http://www.dr-hoiby.com/WhoLockMe/" rel="noreferrer">WhoLockMe</a>, but I would like a <strong>command-line tool</strong> which does more or less the same thing.</p>
<p>I also looked at <a href="https://stackoverflow.com/questions/208283/is-i... | <p><a href="http://technet.microsoft.com/en-us/sysinternals/bb896655.aspx" rel="noreferrer">Handle</a> should do the trick.</p>
<blockquote>
<p>Ever wondered which program has a particular file or directory open?
Now you can find out. Handle is a utility that displays information
about open handles for any proce... | <p>I have used <a href="http://www.majorgeeks.com/files/details/unlocker.html" rel="nofollow noreferrer">Unlocker</a> for years and really like it. It not only will identify programs and offer to unlock the folder\file, it will allow you to kill the processing that has the lock as well. </p>
<p>Additionally, it offers... | 29,851 |
<p>We are changing from vs2003 to vs2005 and use vb as our primary language, I am looking for some of the changes to VB that will be helpful in our ASP.NET development. Can someone point me to a list (maybe from microsoft?) or provide some of their favaorite differences between the two versions?</p>
| <p><a href="http://msdn.microsoft.com/en-us/library/we86c8x2(VS.80).aspx" rel="nofollow noreferrer">What's new in VB 2005 (from MS)</a></p>
<p><a href="http://www.code-magazine.com/Article.aspx?quickid=0505051" rel="nofollow noreferrer">The same topic covered in Code Magazine</a></p>
| <p>I personally find some of the IDE changes to be of the best benefit.</p>
<ul>
<li>The fact that the designer DOESN'T re-format your code as it feels like it</li>
<li>The fact that standard layout is DEFAULT rather than grid layout</li>
<li>Improvements in intellesence</li>
</ul>
<p>In addition to the IDE changes, ... | 26,095 |
<p>I have a symlink to an important directory. I want to get rid of that symlink, while keeping the directory behind it. </p>
<p>I tried <code>rm</code> and get back <code>rm: cannot remove 'foo'</code>.<br>
I tried <code>rmdir</code> and got back <code>rmdir: failed to remove 'foo': Directory not empty</code><br>
I ... | <pre><code># this works:
rm foo
# versus this, which doesn't:
rm foo/
</code></pre>
<p>Basically, you need to tell it to delete a <em>file</em>, not delete a <em>directory</em>. I believe the difference between <code>rm</code> and <code>rmdir</code> exists because of differences in the way the C library treats each.</... | <p>If <code>rm</code> cannot remove a link, perhaps you need to look at the permissions on the directory that contains the link. To remove directory entries, you need write permission on the containing directory.</p>
| 25,789 |
<p>This is something that I have never fully grasped in .NET as to the correct application of the .dispose() method.</p>
<p>Say I have something like</p>
<pre><code>Public Class someClass()
sub someMethod
' do some stuff tying up resources
end sub
End Class
public class mainApp
dim _class as new SomeClass... | <p>I highly recommend reading <a href="http://msdn.microsoft.com/en-us/library/498928w2(VS.80).aspx" rel="nofollow noreferrer">Cleaning Up Unmanaged Resources</a> on MSDN, it has articles touching on when to use Dispose and how to implement IDisposable correctly. Your gut instinct is mostly correct as you rarely have t... | <p>The <code>Dispose()</code> method is used for cleaning up any resources early. Although the garbage collector reclaims any unused memory for you, it's up to you to do deal with things like network/database connections and file handles. Normally, you'd want these things freed up as soon as they're no longer needed, s... | 21,170 |
<p>We have to let go 3 of our software test contractors due to budget constraints, in the middle of a project that had adopted agile development practices. The management attitude is to throw equal number of full time bodies to compensate for this. Does agile development allow for this disruption? I would like to know ... | <p>I was on a project that was going pretty well with 9 developers. For various reasons we had to take 5 people off and add 3 new people in the span of two months. We were following most XP practices (can't say we were 100% XP, but we were close). Our velocity dropped for a time but did not go to zero. </p>
<ul>
<li>T... | <p>What type of agile do you do?</p>
<p>If we speak in general I would say that they are not any problem. You just need to change your team task to continue to do testing. Do not stop testing! You simply need to take time on testing that would have been initially planned to develop. </p>
| 47,686 |
<p>What's a good rule of thumb for naming methods that return properties/attributes/members of an object? If an object has some immutable quality "blarg", should a method that returns that quality be called "blarg()" or "getBlarg()"? The Java API, for example, is inconsistent: most properties are accessed through "ge... | <p>I believe the most often used conventions are:</p>
<pre><code>GetBlarg() or getBlarg()
</code></pre>
<p>It could be argued that the name <code>GetHashCode()</code> is incorrect, since the object doesn't have a field called <code>hashcode</code> and that it's calculated.</p>
<p>These are of course all conventions,... | <p>If it's boolean, the convention is "isBlarg()".</p>
| 37,941 |
<p>In PHP it is easy to pass parameter using <code>$_GET[]</code> and <code>$_POST[]</code>. Is there something like that in JavaScript? I hope I can pass parameters from addresses or forms.</p>
| <p>window.location.href contains the current page's URL. You can append your parameters to a page's URL after a "?" (i.e., a querystring), and have the javascript on that page parse them. Lots more information and examples on googlable pages like <a href="http://www.netlobo.com/url_query_string_javascript.html" rel="no... | <p>You have access to the query string from within javascript as well, so that should help.</p>
| 19,758 |
<p>When and why would somebody do the following:</p>
<pre><code>doSomething( (MyClass) null );
</code></pre>
<p>Have you ever done this? Could you please share your experience?</p>
| <p>If <code>doSomething</code> is overloaded, you need to cast the null explicitly to <code>MyClass</code> so the right overload is chosen:</p>
<pre><code>public void doSomething(MyClass c) {
// ...
}
public void doSomething(MyOtherClass c) {
// ...
}
</code></pre>
<p>A non-contrived situation where you need... | <p>Let's say you have these two functions, and assume that they accept <code>null</code> as a valid value for the second parameters.</p>
<p><code>void ShowMessage(String msg, Control parent);</code><br/>
<code>void ShowMessage(String msg, MyDelegate callBack);</code></p>
<p>These two methods differ only by the type o... | 40,783 |
<p>I'm needing to script my build. I'm using MSBUILD because of it's integration with VS.net. I am trying to copy some files from the build environment to the deployment folder. I'm using the copy task of MSBuild. But instead of copying the directory tree as I would expect. it copies all the contents into a single fol... | <p>When you specify the DestinationFolder for the Copy task, it takes all items from the SourceFiles collection and copies them to the DestinationFolder. This is expected, as there is no way for the Copy task to figure out what part of each item's path needs to be replaced with the DestinationFolder in order to keep th... | <p>I found the example in one of the examples in <a href="http://msdn.microsoft.com/en-us/library/3e54c37h.aspx" rel="nofollow noreferrer">MSDN</a> I don't understand it but will leave an example for my fellow travlers here in stackoverflow. Here is the fixed version of the migrate target from above:</p>
<pre><code>&l... | 33,484 |
<p>I need to display 2d images in opengl using textures.<br>
The image dimensions are not necessarily powers of 2.<br>
I thought of creating a larger texture and restricting the display to the part I was using but the image data will be shared with openCV so I don't want to copy data a pixel at a time into a larger tex... | <p>A couple of GL extensions come to mind. Have a look at <a href="http://www.opengl.org/registry/specs/ARB/texture_rectangle.txt" rel="nofollow noreferrer">GL_ARB_texture_rectangle</a> (if you don't need mipmapping), or <a href="http://www.opengl.org/registry/specs/ARB/texture_non_power_of_two.txt" rel="nofollow nore... | <p>First of all, most modern videocards actually support texture dimensions that are both non-square and non-power-of-two sized. But for maximum compatibility, using only power of two textures is probably recommended.</p>
<p>Start off by determining the closest power of two that is larger for each of the image dimensi... | 41,114 |
<p>We are developing a middleware SDK, both in C++ and Java to be used as a library/DLL by, for example, game developers, animation software developers, Avatar developers to enhance their products.</p>
<p>What I would like to know is this: Are there standard "Best Practices" for the development of these types of API?<... | <p>My two favourite resources on the subject: <a href="http://mollyrocket.com/873" rel="nofollow noreferrer">http://mollyrocket.com/873</a> and <del><a href="http://video.google.com/videoplay?docid=-3733345136856180693" rel="nofollow noreferrer">http://video.google.com/videoplay?docid=-3733345136856180693</a></del></p>... | <p>There are lots of ways to design apis, depending on what you are solving. I think a full answer to this question would be worthy off a whole book, such as the <a href="https://rads.stackoverflow.com/amzn/click/com/0201633612" rel="nofollow noreferrer" rel="nofollow noreferrer">gang of four patterns book</a>. For Jav... | 8,779 |
<p>I have a <code>String</code> representation of a date that I need to create a <code>Date</code> or <code>Calendar</code> object from. I've looked through <code>Date</code> and <code>Calendar</code> APIs but haven't found anything that can do this other than creating my own ugly parse method. I know there must be a w... | <p>In brief:</p>
<pre><code>DateFormat formatter = new SimpleDateFormat("MM/dd/yy");
try {
Date date = formatter.parse("01/29/02");
} catch (ParseException e) {
e.printStackTrace();
}
</code></pre>
<p>See <a href="http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html" rel="noreferrer"><code>Sim... | <p>Try this:</p>
<pre><code>DateFormat.parse(String)
</code></pre>
| 6,538 |
<p>what sql query will i need to show the activated server roles in a specific user?</p>
| <p>EXEC sp_helpuser 'username' should do.</p>
| <p>THIS SHOULD DO IT:</p>
<pre><code>select 'ServerRole' = spv.name, 'MemberName' = lgn.name, 'MemberSID' = lgn.sid
from master.dbo.spt_values spv, master.dbo.sysxlogins lgn
where spv.low = 0 and
spv.type = 'SRV' and
lgn.srvid IS NULL and
spv.number & lgn.xstatus = spv.number
</code></pre>
| 21,362 |
<p>can anyone provide/refer a proper OO type helper class for managing a singleton of the SessionFactory and then also for managing Sessions?</p>
| <p>Check out <a href="http://www.codeproject.com/KB/architecture/NHibernateBestPractices.aspx" rel="nofollow noreferrer">Billy McCafferty's work</a>. His earlier version had some limitations, you'll need to correct the error handling around closing and flushing, and I'm not sure i have it right but I will post how I mo... | <p>You might like to consider making your DAL less concerned with managing NHibernate sessions by leveraging NHibernate.Burrow (or implementing a similar pattern yourself).</p>
<p>"NHibernate.Burrow is a light weight middleware developed to support .Net applications using NHibernate by providing advanced and smart ses... | 40,035 |
<p>I am currently doing the front end for a site with looooads of forms, all styled up and looking pretty in IE, but I've just noticed that in Firefox the file input fields aren't responding to any of my styles, all the other types of input fields are fine. I've checked it in Firebug and its associating the correct sty... | <p>Many of the answers above are quite old. <strong>In 2013 a much simpler solution exists</strong>: nearly all current browsers...</p>
<ul>
<li>Chrome</li>
<li>IE</li>
<li>Safari</li>
<li>Firefox with a few-line fix</li>
</ul>
<p>pass through click events from labels. Try it here: <a href="http://jsfiddle.net/rvCBX/... | <p>Use cheat code ( # ) infront of the attribute of css class
say:</p>
<pre><code>form.CollateralForm input,
form.CollateralForm textarea
{
width:300px; //for firefox
#width:200px; //for IE7
_width:100px; //for IE6
font-size:1em;
border: solid 1px #979797;
font-family: Verdana, Helvetica, Sans... | 45,895 |
<ol>
<li>In WordPress, how do I hide a Page?</li>
<li>How do I then reimplement it as a DIV, let's say, on another Page?</li>
</ol>
<p><strong>Context</strong></p>
<p>I'm trying to get some year-end tax write-offs here for my freelance business, and so I'm donating WordPress sites to churches. Now, unfortunately I'm ... | <p><em>Someone named 'greyhoundcode' in another forum answered me, so I thought I'd post it here.</em></p>
<p><em>His response...</em></p>
<p>If, for example, you have four pages:</p>
<ol>
<li>Home</li>
<li>About</li>
<li>Sidebar</li>
<li>Contact</li>
</ol>
<p>And you deliberately wish to exclude the Sidebar page f... | <p>I think the most logical way is to customize the theme. The theme system is sophisticated and could easily handle such a thing, I believe. At least if I understand the problem.</p>
<p>Be careful with modifying the core system, though. WordPress is known to release new security fixes very often.</p>
| 47,698 |
<p>I've started using Visual Studio 2008 and it keeps asking me to upgrade my 2.0 website project to 3.5 <strong>every time</strong> it opens. </p>
<ul>
<li>What effectively happens when I "upgrade" a website project from 2.0 to 3.5 in Visual Studio? </li>
<li>Does it update my web.config? How exactly does it change m... | <p>(As mentioned elsewhere across the other answers, plus some extras:)</p>
<ul>
<li><p>Converting a VS 2005 solution to VS 2008 will mean that you'll need to maintain duplicates, or others must also be using Visual Studio 2008 (while the project file format (which from your question you're not using anyway) is in the... | <p>If, in the upgrade wizard, you choose not to target your code to 3.5, nothing of your application will change. The main difference is that it will "visual-studify" your Solution and project files so that they potentially can't be opened by an older IDE.</p>
| 14,095 |
<p>I'm trying to use the ASP.NET MVC Ajax.BeginForm helper but don't want to use the existing content insertion options when the call completes. Instead, I want to use a custom JavaScript function as the callback.</p>
<p>This works, but the result I want should be returned as JSON. Unfortunately, the framework just tr... | <p>Try this: </p>
<pre><code>var json_data = content.get_response().get_object();
</code></pre>
<p>this will give you result in JSON format and you can use <code>json_data[0]</code> to get the first record</p>
| <p>Make sure you have included MicrosoftAjax.js and MicrosoftMvcAjax.js. Then use the following calls on the returned context to get a json object out of the return.</p>
<pre><code>var json = context.get_data();
var data = Sys.Serialization.JavaScriptSerializer.deserialize(json);
</code></pre>
| 39,086 |
<p>I'm trying to use SharpZipLib to pull specified files from a zip archive. All of the examples I've seen always expect that you want to unzip the entire zip, and do something along the lines of:</p>
<pre><code> FileStream fileStreamIn = new FileStream (sourcePath, FileMode.Open, FileAccess.Read);
ZipI... | <p>ZipFile.GetEntry should do the trick:</p>
<pre><code>using (var fs = new FileStream(sourcePath, FileMode.Open, FileAccess.Read))
using (var zf = new ZipFile(fs)) {
var ze = zf.GetEntry(fileName);
if (ze == null) {
throw new ArgumentException(fileName, "not found in Zip");
}
using (var s = zf.GetI... | <p>FileStream fileStreamIn = new FileStream(fileNameZipped, FileMode.Open, FileAccess.Read);</p>
<pre><code> ZipInputStream zipInStream = new ZipInputStream(fileStreamIn);
using (var zf = new ZipFile(fileStreamIn))
{
//zf.Password = "123";
va... | 42,543 |
<p>I understand what are lambda functions in Python, but I can't find what is the meaning of "lambda binding" by searching the Python docs.
A link to read about it would be great.
A trivial explained example would be even better.
Thank you.</p>
| <p>First, a general definition:</p>
<blockquote>
<p>When a program or function statement
is executed, the current values of
formal parameters are saved (on the
stack) and within the scope of the
statement, they are bound to the
values of the actual arguments made in
the call. When the statement is
exit... | <p>Where have you seen the phrase used?</p>
<p>"Binding" in Python generally refers to the process by which a variable name ends up pointing to a specific object, whether by assignment or parameter passing or some other means, e.g.:</p>
<pre><code>a = dict(foo="bar", zip="zap", zig="zag") # binds a to a newly-created... | 19,437 |
<p>Is it possible for gcc to link against a library that was created with Visual C++? If so, are there any conflicts/problems that might arise from doing so? </p>
| <p>Some of the comments in the answers here are slightly too generalistic. </p>
<p>Whilst no, in the specific case mentioned gcc binaries won't link with a VC++ library (AFAIK). The actual means of interlinking code/libraries is a question of the ABI standard being used.</p>
<p>An increasingly common standard in the ... | <p>I would guess not. Usually c++ compilers have quite different methods of name-mangling which means that the linkers will fail to find the correct symbols. This is a good thing by the way, because C++ compilers are allowed by the standard to have much greater levels of incompatibility than just this that will cause y... | 6,476 |
<p>Well, heres my scenario.</p>
<p>Client/Server winforms application with SQL Express as the DB. I need to be able to print invoice, packing slips etc..</p>
<p>i would like the customer to be able to modify the invoices. ie. be able to put their logo or change font sizes etc...basically format the display.</p>
<p>T... | <p>After just completing a project with it, I would heartily recommend <a href="http://www.google.com/search?q=itextsharp&sourceid=navclient-ff&ie=UTF-8&rlz=1B3GGGL_enUS216US216" rel="noreferrer">iTextSharp</a> to create your invoices and other forms as PDFs. In addition to creating PDFs from scratch, you c... | <p>you can use Crystal Report for this. But first you need to scan the INVOICE and save it as an image,</p>
<p>Next is, on your crystal report, export the image on to it, and DRAG the fields to where they must print on the invoice (IMAGE SERVES AS YOUR GUIDE). Then after everything has been set-up, DELETE THE IMAGE an... | 38,336 |
<p>We have a current application where user login credentials are stored in a SQL Server DB. These are, basically, stored as a plain text username, a password hash, and an associated salt for this hash.</p>
<p>These were all created by built in functions in ASP.NET's membership/role system. Here's a row for a user n... | <p>It appears python is inserting a byte order marker when you convert a UTF16 string to binary. The .NET byte array contains no BOM, so I did some ghetto python that turns the UTF16 into hex, removes the first 4 characters, then decodes it to binary.</p>
<p>There may be a better way to rip out the BOM, but this work... | <p>Two thoughts as to what could be going wrong.</p>
<p>First the code from the reflection has three paths:</p>
<ul>
<li>If passwordFormat is 0 it returns the password as is.</li>
<li>If passwordFormat is 1 it creates the hash as your python code does.</li>
<li>If passwordFormat is anything other than 0 or 1 it calls... | 33,886 |
<p>I'm trying to decode the result of the Python os.wait() function. This returns, according to the Python docs:</p>
<blockquote>
<p>a tuple containing its pid and exit status indication: a 16-bit number, whose low byte is the signal number that killed the process, and whose high byte is the exit status (if the sign... | <p>This will do what you want:</p>
<pre><code>signum = status & 0xff
exitstatus = (status & 0xff00) >> 8
</code></pre>
| <p>The folks before me've nailed it, but if you really want it on one line, you can do this:</p>
<pre><code>(signum, exitstatus) = (status & 0xFF, (status >> 8) & 0xFF)
</code></pre>
<p>EDIT: Had it backwards.</p>
| 3,138 |
<p>I am planning on porting a PHP application over to Python. The application is mostly about data collection and processing. The main application runs as a stand alone command line application. There is a web interface to the application which is basically a very light weight reporting interface. </p>
<p>I did no... | <p>The command-line Python, IMO, definitely comes first. Get that to work, since that's the core of what you're doing.</p>
<p>The issue is that using a web framework's ORM from a command line application isn't obvious. Django provides specific instructions for using their ORM from a command-line app. Those are anno... | <p>It depends on the way you are going to distribute your application.<br>
If it will only be used internally, go for django. It's a joy to work with it.
However, django really falls short at the distribution-task; django-applications are a pain to set up.</p>
| 16,473 |
<p>Is <a href="http://cpan.uwinnipeg.ca/dist/DBI" rel="noreferrer">CPAN DBI</a> the best database interface to use in Perl for general database use? Are there some better options?</p>
| <p>If you're just looking for low-level database access—you feed it any SQL string (optionally with place-holders and bind values) and it runs your query and gives you back the results—then yes, <a href="http://search.cpan.org/dist/DBI/" rel="nofollow noreferrer">DBI</a> is your best bet, by far.</p>
<p>If... | <p>Basically you should be used to using only DBI firstly.</p>
| 6,435 |
<p>How do you make a field in a sql select statement all upper or lower case?</p>
<p>Example:</p>
<p>select firstname from Person</p>
<p>How do I make firstname always return upper case and likewise always return lower case?</p>
| <pre><code>SELECT UPPER(firstname) FROM Person
SELECT LOWER(firstname) FROM Person
</code></pre>
| <p>You can do:</p>
<pre><code>SELECT lower(FIRST NAME) ABC
FROM PERSON
</code></pre>
<p>NOTE: <code>ABC</code> is used if you want to change the name of the column</p>
| 44,361 |
<p>I read all over the Internet (various sites and blogs) about version control. How great it is and how all developers NEED to use it because it is very useful.</p>
<p>Here is the question: do I really need this? I'm a front-end developer (usually just HTML/CSS/JavaScript) and I NEVER had a problem like "Wow, my file... | <p>Here's a scenario that may illustrate the usefulness of source control even if you work alone.</p>
<blockquote>
<p>Your client asks you to implement an ambitious modification to the website. It'll take you a couple of weeks, and involve edits to many pages. You get to work.</p>
<p>You're 50% done with this... | <p>I think you've made the right decision to use some kind of version control. For simplicity, I'd go with SVN (ignore CVS as SVN is basically a "better" CVS)</p>
<p>SVN can work with "local" repositories right on the filesystem and on lots of platform so you don't have to bite off too much in infrastructure (servers... | 31,245 |
<p>How can I get the MAC Address using only the compact framework?</p>
| <p>1.4 of the OpenNETCF code gets the information from the following P/Invoke call:</p>
<pre><code> [DllImport ("iphlpapi.dll", SetLastError=true)]
public static extern int GetAdaptersInfo( byte[] ip, ref int size );
</code></pre>
<p>The physical address (returned as MAC address) I think is around about index ... | <p>Add a reference to System.Management.dll and use something like:</p>
<pre><code>Dim mc As System.Management.ManagementClass
Dim mo As ManagementObject
mc = New ManagementClass("Win32_NetworkAdapterConfiguration")
Dim moc As ManagementObjectCollection = mc.GetInstances()
For Each mo In moc
If mo.Item("IPEnabled"... | 6,440 |
<p>I can't find any proper way to make a long textField move fluently horizontally across the screen in full screen mode. I tried many ways but it always gets stuck from time to time for a few milliseconds and ruins the whole experience. Please, if someone can help me to find a way to best animate a large dynamic strin... | <p>I know this is quite late, but here's a list of a few things you could try:</p>
<ul>
<li><p>You could try using a tweening engine like <a href="http://code.google.com/p/tweener/" rel="nofollow noreferrer" title="Tweener">Tweener</a>, which does animation frame-independently, so it will help to make the motion appea... | <p>Sounds like your machine can't keep up with all the processes running at the same time. This is a reality on almost all collaborative applications.</p>
<p>To diminish the effect, try reducing your animations framerate. It will be less fluid but the frame duration will be constant and the skip much less noticeable. ... | 41,249 |
<p>My DBA requires all database access to be done through trusted domain account. This can be done if you set the web.config . This requires the user to login or to be on the domain for IE pass the credentials through. I want to impersonate a user by using code. I am using the code found in this knowledgebase arti... | <p>Impersonation occurs at the level of the thread. Impersonation causes the access token of the thread, which is usually inherited from the process, to be replaced with another. The best practice is to revert the effect of impersonation and thus the token as soon as you are done with the operation(s) for which it was ... | <p>The reason you're losing the impersonation context is because each time a new page request ends the impersonation context will go out of scope.</p>
<p>As per the docs <code><alwaysFlowImpersonationPolicy></code> is used to ensure the same impersonation context is maintained across async calls. For example whe... | 15,876 |
<p>What's the fastest way to get a framebuffer and render to in software on the iPhone?</p>
<p>Basically getting into a mode 13h style thing going so I can make some effects? :)</p>
| <p>You need to create a <code>CGImageContext</code>, in a bitmap format that you can directly manipulate. Then, you can draw that image on the screen, use it as a GL texture, or whatever.</p>
<p>Pretty simple stuff - check the Core Graphics documentation. I don't think there's a good way to get actual raw <code>frameB... | <p>As far as I know you have an OpenGL|ES accelerator chip on the IPhone. If you want to push pixels you should check which kind of OpenGL|ES is supported. Write code for it and let the hardware do the job.</p>
<p>Writing OpenGL|ES is not hard btw. I you still know what mode13 is (old fart you are!) you should pick up... | 23,450 |
<p>The following event can possibly get called hundreds of times a frame.</p>
<pre><code>public bool OnCollision(Body body1, Body body2)
{
if(body2.Tag is Dog)
((Dog)body2.Tag).Bark();
}
</code></pre>
<p>I understand that using "is" causes a cast to be made and then when i want to do something with it, cast it... | <pre><code> if(body2.Tag is Dog)
</code></pre>
<p>is actually compiled as</p>
<pre><code>Dog Temp = body2.Tag as Dog;
if (temp != null)
</code></pre>
<p>In your code, you're then doing the cast again. Better would be:</p>
<pre><code>Dog dog = body2.Tag as Dog;
if (dog != null)
{
dog.Bark();
}
</code></pre>
| <p>How about a generic collision method? Then there is no need for inheritance. Just an interface.</p>
<pre><code>public bool OnCollision<TA,TB>(TA a, TB b)
where TA : ICollidable
where TB : ICollidable {
a.Collision(b);
}
</code></pre>
| 49,602 |
<p>So - I have a checkbox</p>
<pre><code><asp:CheckBox ID="chkOrder" runat="server" Visible='<%#IsCheckBoxVisible() %>'
Checked="false"
OnCheckedChanged="chkOrder_CheckedChanged" AutoPostBack="true"
EnableViewState="false"></asp:CheckBox>
</code></pre>
<p>the one above. Now, the che... | <p>Firefox remembers the state of form fields by default. <code>Ctrl+F5</code> will force Firefox to clear this cache.</p>
<p>You can disable this for individual form and input elements:</p>
<pre><code><form autocomplete="off">
<input ... autocomplete="off" />
</code></pre>
| <p>Have you tried to compare the genrated HTML from FF and IE? (with "view html source")</p>
<p>Just to localize the problem a bit more precisely.
It is only a slight chance, but if the HTML is different for both browsers, you have a problem on the serverside with how ASP creates the HTML.</p>
<p>If both are the same... | 25,604 |
<p>Is it possible to use .htaccess to process all six digit URLs by sending them to a script, but handle every other invalid URL as an error 404?</p>
<p>For example:</p>
<pre><code>http://mywebsite.com/132483
</code></pre>
<p>would be sent to:</p>
<pre><code>http://mywebsite.com/scriptname.php?no=132483
</code></pr... | <p>In your htaccess file, put the following</p>
<pre><code>RewriteEngine On
RewriteRule ^([0-9]{6})$ /scriptname.php?no=$1 [L]
</code></pre>
<p>The first line turns the mod_rewrite engine on. The () brackets put the contents into $1 - successive () would populate $2, $3... and so on. The [0-9]{6} says look for a stri... | <p>Yes it's possible with mod_rewrite. There are tons of good mod_rewrite tutorials online a quick Google search should turn up your answer in no time. </p>
<p>Basically what you're going to want to do is ensure that the regular expression you use is just looking for digits and no other characters and to ensure the ... | 9,881 |
<p>I'm currently learning Haskell, Which language (F# or Haskell) do you prefer for programming general purpose applications?</p>
<p>Which do you think is the stronger language?</p>
| <p>I'd go for Haskell. <a href="http://hackage.haskell.org/" rel="noreferrer">HackageDB</a> is a great collection of libraries that are written specifically for the language. In the case of F# you'd have to use mostly libraries that are not written with a functional language in mind so they will not be as 'elegant' t... | <p>I'd say it depends on why you are learning it. If you are doing it for the experience of a pure functional language, go for Haskell. But if you are definitely going to use the language for more than that, F# is might be the better choice.</p>
| 17,267 |
<p>I've decided to attempt using the <a href="https://blog.codinghorror.com/preventing-csrf-and-xsrf-attacks/" rel="nofollow noreferrer">double submitted cookies</a> technique to attempt to prevent XSRF attacks on the site I'm working on. So the way I have it written down here is, all actions that actually DO somethin... | <p>Use the <a href="http://blog.codeville.net/2008/09/01/prevent-cross-site-request-forgery-csrf-using-aspnet-mvcs-antiforgerytoken-helper/" rel="nofollow noreferrer" title="Prevent Cross-Site Request Forgery (CSRF) using ASP.NET MVC’s AntiForgeryToken() helper">built-in support for this in ASP.NET MVC</a>.</p>
| <p>The built in ASP.NET MVC XSRF protection has one downside: it sends down yet another cookie to the client.</p>
<blockquote>
<p>At the same time, <code>Html.AntiForgeryToken()</code> will <strong>give the visitor a cookie called __RequestVerificationToken</strong>, with the same value as the random hidden value sh... | 37,123 |
<p>I would like to have an <code>iframe</code> take as much vertical space as it needs to display its content and not display a scrollbar. Is it at all possible ?</p>
<p>Are there any workarounds?</p>
| <p>This should set the <code>IFRAME</code> height to its content's height:</p>
<pre><code><script type="text/javascript">
the_height = document.getElementById('the_iframe').contentWindow.document.body.scrollHeight;
document.getElementById('the_iframe').height = the_height;
</script>
</code></pre>
<p>You m... | <p>This CSS snippet should remove the vertical scrollbar:</p>
<pre class="lang-css prettyprint-override"><code>body {
overflow-x: hidden;
overflow-y: hidden;
}
</code></pre>
<p>I'm not sure yet about having it take up as much vertical space as it needs, but I'll see if I can't figure it out.</p>
| 5,496 |
<p>We are using a software program at our school to enter IEPs (Individualized Education Programs). When entering goals and objectives for a student, users are provided with a Save and a Close button. Close is meant for users not wishing to save the goal they just chose. However, our users are sometimes wanting to b... | <p>If it's web based, then you're probably just running a webpage in Internet Explorer. If that's the case, I'd recommend <a href="http://samanathon.com/internet-explorer-7s-kiosk-mode/" rel="nofollow noreferrer">IE's kiosk mode</a>.</p>
<p>If you need something a bit more heavyweight, <a href="http://www.teamsoftware... | <p>A lot of browsers have a full-screen mode (F11 in Firefox), where they take up the entire screen real estate, hiding any other UI elements, including the top bar (at least for Windows, dunno about *nix). This is a very simple solution, but afaik there's no way to disable the [x] for windows in general, you'd have to... | 10,342 |
<p>I'm pretty sure I know the answer to this, but short of a virtual Vista installation, is there a way to install IIS 7 on XP? </p>
| <p>No. Which means I'm moving to vista this week as I have to use IIS7.</p>
<p>EDIT: Ha - voted up! I assume it's a sympathy vote. :-)</p>
| <p>Its a completly different model on vista than xp... http.sys and all that type of stuff. I don't believe you can install IIS 6 on XP.</p>
| 13,380 |
<p>My team is working on a project to migrate a .com site into SharePoint. </p>
<p>After all our look and feel assets, master pages, content types, and page layouts are created, we need to actually "move" the actual site pages into SharePoint. </p>
<p>I'm trying to come up with the most effective way to do this. Our ... | <p>If it is just a matter of migrating files, you could actually use the content migration framework. The core classes of this framework are the SPExport and SPImport classes in the Microsoft.SharePoint.Deployment namespace. You can with fairly little code export individual files to disk and import them again to a new ... | <p>Backup and restore the content DB.</p>
| 47,851 |
<p>I have a canvas inside a scrollview. I attached a keydown event handler to the scrollview. For most keys, the handler gets called. </p>
<p>However, for the arrow keys, the handler does not get called. Instead, the scrollview gets scrolled in the appropriate direction.</p>
<p>I also attached a keyup handler to the ... | <p>I found this silly hack to make it work. Setting the scrollview to not be a tabstop keeps it from eating the key events.. but then I had another textbox on the page that all of a sudden ALWAYS had focus because the scrollview didn't anymore. So I fixed that by letting an invisible textbox get focus.</p>
<pre><code>... | <p>"Use the PreviewKeyDown event, I think that's what it's called. It may let you get at the event before it's consumed by the control."</p>
<p>This works. Just set the event arguments "Handled = true" and the ScrollViewer (or ListBox) wont grab onto the event after you've already handled it. I didn't need to use th... | 27,498 |
<p>What is the best way to ascertain the length (in characters) of the longest element in an array?</p>
<p>I need to find the longest element in an array of option values for a select box so that I can set the width dynamically.</p>
| <p>This returns the key of the longest value and can also give you the value itself</p>
<pre><code>function array_longest_value( $array, &$val = null )
{
$val = null;
$result = null;
foreach( array_keys( $array ) as $i )
{
$l = strlen( $array[ $i ] );
if ( $l > $result )
... | <pre><code>$longest_length = 0;
foreach($array as $key => $value
{
if(isset($value[$longest_length + 1]))
{
$longest_length = strlen($value);
}
}
</code></pre>
| 43,783 |
<p>It seems as though the following calls do what you'd expect (close the stream and not allow any further input - anything waiting for input on the stream returns error), but is it guaranteed to be correct across all compilers/platforms?</p>
<pre><code>close(fileno(stdin));
fclose(stdin);
</code></pre>
| <p><code>fclose(stdin)</code> causes any further use of <code>stdin</code> (implicit or explicit) to invoke undefined behavior, which is a <strong>very bad thing</strong>. It does not "inhibit input".</p>
<p><code>close(fileno(stdin))</code> causes any further attempts at input from <code>stdin</code>, after the curre... | <p>Nothing is guaranteed correct across every possible operating system. However, calling fclose(stdin) will work on any POSIX compliant operating system as well as Windows operating systems, so you should hit pretty much anything in general use at the moment.</p>
<p>As stated by the previous answer as well as my comm... | 36,658 |
<p>I have a search form on each of my pages. If I use form helper, it defaults to <code>$_POST</code>. I'd like the search term to show up in the URI:</p>
<pre><code>http://example.com/search/KEYWORD
</code></pre>
<p>I've been on Google for about an hour, but to no avail. I've only found articles on how <code>$_GET</... | <p>There's a better fix if you're dealing with people without JS enabled.</p>
<p><strong>View:</strong></p>
<pre><code><?php echo form_open('ad/pre_search');?>
<input type="text" name="keyword" />
</form>
</code></pre>
<p><strong>Controller</strong> </p>
<pre><code><?php
function pre_... | <p>I don't know much about CodeIgniter, but it's PHP, so shouldn't <code>$_GET</code> still be available to you? You could format your URL the same way Google does: <code>mysite.com/search?q=KEYWORD</code> and pull the data out with <code>$_GET['q']</code>.</p>
<p>Besides, a search form seems like a bad place to use P... | 28,149 |
<p>I'm seeing an ambiguous error in Firebug. I don't think it's particularly related to the script I'm writing, however I don't have enough details to be able to determine that from this one error alone. Has anyone seen something similar and have a suggestion?</p>
<p>error:</p>
<blockquote>
<p>[Exception... "Compon... | <p>I have run across the same error myself, and it is an internal FireFox issue, not an issue with your script at all. It is related to the saving of the FireFox state:</p>
<p>According to: <a href="http://blogs.unbolt.net/index.php/brinley/2008/04/26/0x80040111_nssessionstore" rel="nofollow noreferrer">http://blogs.... | <p>Pasting this here so I can find it later :/</p>
<p>Modify nsSessionStore.js
from: this._writeFile(this._sessionFile, oState.toSource());
to: this._writeFile(this._sessionFile, "(" + this._toJSONString(oState) + ")");</p>
<p>BTW, the error is caused by extensions creating browser elements without disabling the hi... | 18,833 |
<p>I have a problem on how to read text from file and perform operations on it for example</p>
<p>i have this text file that include</p>
<p>//name-//sex---------//birth //m1//m2//m3</p>
<pre><code>fofo, male, 1986, 67, 68, 69
momo, male, 1986, 99, 98, 100
Habs, female, 1988, 99, 100, 87
toto, male, 198... | <p>Try something like this.</p>
<pre><code> var qry = from line in File.ReadAllLines(@"C:\Temp\Text.txt")
let vals = line.Split(new char[] { ',' })
select new
{
Name = vals[0].Trim(),
Sex = vals[1].Trim(),
Birth = vals[2].Trim(),
... | <p>I recommend using the FileHelpers library. Check out example here: <a href="http://www.filehelpers.com/quick_start.html" rel="nofollow noreferrer">Quick start</a></p>
<p>You could calculate the average in a foreach-loop like the one on the page.</p>
| 47,106 |
<p>The HTTP/1.1 specification (<a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html" rel="noreferrer">RFC2616</a>) defines a number of status codes that can be returned by HTTP server to signal certain conditions. Some of those codes can be utilized by web applications (and frameworks). Which of those codes ... | <p>The ones I'm using (that I could find with a quick <code>grep 'Status:'</code> anyway):</p>
<ul>
<li><strong>200</strong> Successfully retrieved a resource without affecting it</li>
<li><strong>201</strong> Sent whenever a form submission puts something significant into the database (forum post, user account, etc.)... | <p>I use webmachine, which automagically generates proper error codes. But there are cases when I need to supply my own. I have found it helpful for development and debugging to return 666 in those cases, so I can easily tell which ones come from my code, and which from webmachine. Besides, I get a chuckle out of it wh... | 43,510 |
<p>Given the following table, how does one calculate the hourly mode, or value with the highest frequency by hour?</p>
<pre><code>CREATE TABLE Values
(
ValueID int NOT NULL,
Value int NOT NULL,
LogTime datetime NOT NULL
)
</code></pre>
<p>So far, I've come up with the following query.</p>
<pre><code>SELE... | <p>The following query may look odd... but it works and it gives you what you want. This query will give you the value that had the highest frequency in a particular "hour" (slice of time).</p>
<p>I am <em>NOT</em> dividing into Year, Month, Day, etc... only hour (as you requested) even though you had those other fiel... | <p>Nest the aggregates...</p>
<pre><code>SELECT
MAX(Frequency) AS [Mode],
[Year],[Month],[Day],[Hour]
FROM
(SELECT
COUNT(*) AS Frequency,
DatePart(yy, LogTime) as [Year],
DatePart(mm, LogTime) as [Month],
DatePart(dd, LogTime) as [Day],
DatePart(hh, LogTime)... | 32,079 |
<p>I've just updated my ruby installation on my gentoo server to ruby 1.8.6 patchlevel 287 and have started getting an error on one of my eRuby apps. The error given in the apache error_log file is:</p>
<pre><code>[error] mod_ruby: /usr/lib/ruby/1.8/cgi.rb:774: superclass mismatch for class Cookie (TypeError)
</code><... | <p>That error shows up when you redeclare a class that’s already been declared, most likely because you’re loading two different copies of cgi.rb. See a <a href="http://209.85.173.104/search?q=cache:wbXLBotEIvUJ:railsforum.com/viewtopic.php%3Fid%3D10993+superclass+mismatch+for&hl=en&ct=clnk&cd=3&gl=us&a... | <p>That error shows up when you redeclare a class that’s already been declared, most likely because you’re loading two different copies of cgi.rb. See a <a href="http://209.85.173.104/search?q=cache:wbXLBotEIvUJ:railsforum.com/viewtopic.php%3Fid%3D10993+superclass+mismatch+for&hl=en&ct=clnk&cd=3&gl=us&a... | 15,636 |
<p>A client using our system has requested that we store the SSNs/SINs of the end users in our database. Currently, we store minimal information about users (name, email address, and optionally, country), so I'm not overly concerned about a security breach - however, I have a suspicion there could be legal issues about... | <p>The baseline recommendation would be to:</p>
<ul>
<li>Inform the user that you are storing their SSN before they use your site/application. <strong>Since the request appears to be to collect the information <em>after the fact</em>, the users should have a way to opt out of your system before they log in or before t... | <p>Way too many organizations in the USA use SSNs as unique identifiers for people, despite the well-documented problems with them. Unless your application actually has something to do with government benefits, there's no good reason for you to store SSns.</p>
<p>Given that so many organizations (mis)use them to ident... | 13,862 |
<p>Is there a way to change the connection string of a DataBase object in Enterprise Library at runtime? I've found <a href="http://blog.benday.com/archive/2005/05/05/357.aspx" rel="nofollow noreferrer">this</a> link but its a little bit outdated (2005)</p>
<p>I've also found <a href="https://stackoverflow.com/questio... | <p>look at this:<a href="https://stackoverflow.com/questions/401339/open-microsoft-practices-enterpriselibrary-database-with-just-a-connection-string">Open Microsoft.practices.EnterpriseLibrary database with just a connection string</a></p>
<p>just use this follow code, you can programming create database at runtime</... | <p>Here's from Yang's Net Zone:</p>
<pre><code>using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Data.Configuration;
DatabaseSettings settings = new DatabaseSettings();
// This maps to <databaseType> element ... | 42,285 |
<p>I want the Perl script to extract a data from a text file and save it as another text file. Each line of the text file contains an URL to a jpg like "<a href="http://pics1.riyaj.com/thumbs/000/082/104//small.jpg" rel="nofollow noreferrer">http://pics1.riyaj.com/thumbs/000/082/104//small.jpg</a>". I want the script t... | <p>What have you tried so far?</p>
<p>Here's a short program that gives you the meat of the problem, and you can add the rest of it:</p>
<pre>
while( )
{
s|http://.*/\d+/(\d+)/(\d+).*?jpg|php?id=$1$2|;
print;
}
</pre>
<p>This is very close to the command-line program the handles the looping and prin... | <p>I didn't know whether to answer according to what you described ("last 6 digits") or just assume that it all fits the pattern you showed. So I decided to answer both ways. </p>
<p>Here is a method that can handle lines more diverse than your examples. </p>
<pre><code>use FileHandle;
my $jpeg_RE = qr{
(.*?) ... | 47,250 |
<p>I would like to create an application that downloads a PDF document from the Internet, and displays it to the user. I would like to re-use the iPhone's builtin PDF viewer that is used throughout the core apps to view a PDF document.</p>
<p>Is there a way to do that?</p>
| <p>You could just use UIWebView class to do that.</p>
| <p>Try this: <a href="https://github.com/vfr/Reader">https://github.com/vfr/Reader</a></p>
| 34,248 |
<p>Has anyone been able to get an NHibernate-based project up and running on a shared web host?</p>
<p>NHibernate does a whole lot of fancy stuff with reflection behind the scenes but the host that I'm using at the moment only allows applications to run in medium trust, which limits what you can do with reflection, an... | <p>I have had no issues with running NHibernate based apps on WebHost4Life, although I don't like them.</p>
<p>Getting NHibernate to run on medium trust is possible. A full description on how this can be done is found here:</p>
<p><a href="http://blechie.com/WPierce/archive/2008/02/17/Lazy-Loading-with-nHibernate-Und... | <p>I'm using a Finnish host called <a href="http://www.nebula.fi" rel="nofollow noreferrer">Nebula</a> that happily runs my NHibernate-leveraging applications. I had an issue once with trust levels; the machine.config on the host was configured to deny reflection but I successfully overrode it in the web.config.</p>
| 8,684 |
<p>Can someone explain to me why my code:</p>
<pre><code>string messageBody = "abc\n" + stringFromDatabaseProcedure;
</code></pre>
<p>where valueFromDatabaseProcedure is not a value from the SQL database entered as </p>
<pre><code>'line1\nline2'
</code></pre>
<p>results in the string:</p>
<pre><code>"abc\nline1\\n... | <p>I just did a quick test on a test NorthwindDb and put in some junk data with a \n in middle. I then queried the data back using straight up ADO.NET and what do you know, it does in fact escape the backslash for you automatically. It has nothing to do with the n it just sees the backslash and escapes it for you. In f... | <p>ASP.NET would use <code><br /></code> to make linebreaks. <code>\n</code> would work with Console Applications or Windows Forms applications. Are you outputting it to a webpage?</p>
<p><strong>Method #1</strong></p>
<pre><code>string value = "line1<br />line2";
string messageBody = "abc<br />" ... | 49,331 |
<p>Implementing a file upload under html is fairly simple, but I just noticed that there is an 'accept' attribute that can be added to the <code><input type="file" ...></code> tag.</p>
<p>Is this attribute useful as a way of limiting file uploads to images, etc? What is the best way to use it?</p>
<p>Alternativ... | <p>The <code>accept</code> attribute is incredibly useful. It is a hint to browsers to only show files that are allowed for the current <code>input</code>. While it can typically be overridden by users, it helps narrow down the results for users by default, so they can get exactly what they're looking for without havin... | <p>Back in 2008 this wasn't important because of the lack of mobile OS'es but now quite important thing. </p>
<p>When you set accepted mime types, then in for example Android user is given system dialog with apps which can provide him the content of mime which file input accepts, what is great because navigating throu... | 21,869 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.