instruction
stringlengths
0
30k
|c++|reference|pointers|
|c++|pointers|reference|
I know references are syntactic sugar, so easier code to read and write :) But what are the differences? Summary from answers and links below: 1. A pointer can be re-assigned any number of times while a reference can not be reassigned after initialization. 2. A pointer can point to NULL while reference can...
> What about late-binding? As in loading > it with LoadLibrary() and > GetProcAddress() ? I'm used being able > to load the library at run time and it > would be great if you could do that > here. So there are two ways to load the DLL. The first is to reference one or more symbols from the DLL (your classname, ...
@Matthew- ADF! The application I'm presently working on has 90% of the presentation layer generated by mod PL/SQL. I started working on a few new screens and wanted to investigate other options that might fit into our architecture, without being to much of a learning burden (increasing the complexity of the system/c...
Generating an object model in Ruby from an XML DTD
|ruby|xml|dtd|
I have an XML document with a DTD, and would love to be able to access the XML model, something like this: title = Thing.Items[0].Title Is there a way, in Ruby, to generate this kind of object model based on a DTD? Or am I stuck using REXML? Thanks!
Visual Studio 2005 has the Script Explorer (under the Debug > Windows menu). It shows a tree of all the scripted stuff that's currently debuggable. Previousy I was breaking into the debugger via IE's View > Script Debugger menu, but I'm finding the Script Explorer is a quicker way to get to what I want.
Visual Studio 2005 has the Script Explorer (under the Debug > Windows menu). It shows a tree of all the scripted stuff that's currently debuggable. Previously I was breaking into the debugger via IE's View > Script Debugger menu, but I'm finding the Script Explorer is a quicker way to get to what I want.
I'd suggest using the XmlHttp class in your ASP code. Assuming you have an ASMX web service similar to this, in MyService.asmx: [WebMethod] public string HelloWorld() { return "Hello World"; } You could call it in ASP something like this: Dim xhr Set xhr = server.CreateO...
With or without the OnClientClick event it still doesn't work. The _doPostBack event is the auto generated javascript that .NET produces. function __doPostBack(eventTarget, eventArgument) { if (!theForm.onsubmit || (theForm.onsubmit() != false)) { theForm.__EVENTTARGET.value ...
You can't inherit from/extend an enum, you can use [attributes][1] to [declare a description][2]. If you're looking for an integer value, that's built-in. [1]: http://msdn.microsoft.com/en-us/library/system.componentmodel.descriptionattribute.aspx [2]: http://blog.waynehartman.com/articles/84.aspx
Hmmm - as far as I know, this can't be done - enumerations are written at design-time and are used as a convenience to the programmer. I'm pretty sure that when the code is compiled, the equivalent values will be substituted for the names in your enumeration, thereby removing the concept of an enumeration and (there...
Well, the main thing is that it is pure managed code - for what that is worth; it works not only on your typical Windows machines running .NET, but works wherever you run the Compact Framework and even works on [**Mono**][1]. Here are some noteworthy bullet points from their homepage: - Small < 1 MB footprint trul...
Adding enums is a fairly common thing to do if you go back to the source code and edit, any other way (inheritance or reflection, if either is possible) is likely to come back and hit you when you get an upgrade of the library and they have introduced the same enum name _or_ the same enum value - I have seen plenty of ...
I haven't found a simple solution either. There are examples using CreateObject and the WinNT ADSI provider. But eventually they all bump into <a href="http://support.microsoft.com/kb/218497"> User authentication issues with the Active Directory Service Interfaces WinNT provider</a>. I'm not 100% sure but I <i>guess</...
The Best Way to shred XML data into SQL Server database columns
|sql-server|xml|
What is the best way to shred XML data into various database columns? So far I have mainly been using the nodes and value functions like so: INSERT INTO some_table (column1, column2, column3) SELECT Rows.n.value('(@column1)[1]', 'varchar(20)'), Rows.n.value('(@column2)[1]', 'nvarchar(100)'), ...
0xff will be seen as an integer constant, with the value of 255. You should always pay attention to these kind of comparison between different types. If you want to be sure that the compiler will generate the right code, you should use the typecast: <pre> if( *p == (signed char)0xFF ) break; </pre> Anyway, <b>b...
Viruses embedded in image files are unlikely to be a major problem for your application. What will be a problem is JAR files. Image files with JAR trailers can be loaded from any page on the Internet as a Java applet, with same-origin bindings (cookies) pointing into your application and your server. The best way to...
Centralizing/controlling arbitrary builds of .NET projects and solutions.
|.net|visual-studio|build-automation|
Over the years I have created and tweaked a set of NAnt scripts to perform complete project builds. The main script takes a single application end point (a web application project for example) and does a complete, from source control, build of it. The scripts are preconfigured with the necessary information regarding...
|.net|visual-studio|build-automation|projects-and-solutions|
ant build.xml windows white space in path
|windows|ant|white|build.xml|space|
I'm using Windows and I'm trying to get ANT to work. When I do an ant build from the command line, I get: C:\dev\Projects\springapp\${%ANT_HOME%}\lib not found. I look into the build.xml file and I find: appserver.home=${user.home}/apache-tomcat-6.0.14 (which I just copied and pasted straight from a tutorial) ...
Common Files in Visual Studio Solution
|visual-studio|
Many times I have seen Visual Studio solutions which have multiple projects that share source files. These common source files are usually out in a common directory and in the solution explorer their icon shows up with a link arrow in the bottom left. However, any time I try to add a source file to the project that...
|visual-studio|projects-and-solutions|
this might seem elemental, but did you verify that your firefox settings aren't set to interfere with the postback? Sometimes I encounter similar problems due to a odd browser configuration I had from a debugging session.
Integer literals have signed int type. Since 0xFF is a signed int, the compiler converts *p to a signed int and then does the comparison. When *p is -1, which is then converted to a signed int, it is still -1 which has a representation of 0xFFFFFFFF, which is not equal to 0xFF.
Integer literals have signed int type. Since 0xFF is a signed int, the compiler converts *p to a signed int and then does the comparison. When *p is -1, which is then converted from a signed char to a signed int, it is still -1 which has a representation of 0xFFFFFFFF, which is not equal to 0xFF.
Great tools and frameworks are essential, but the other essential is great project leadership.
Try setting the credentials property of the WebClient object WebClient ww = new WebClient(); ww.Credentials = CredentialCache.DefaultCredentials; string html = ww.DownloadString("Internal.aspx");
Try setting the credentials property of the WebClient object WebClient ww = new WebClient(); ww.Credentials = CredentialCache.DefaultCredentials; ww.DownloadString("Login.aspx?UserName=&Password="); string html = ww.DownloadString("Internal.aspx");
I use explicit checks that throw exceptions on _public_ and _protected_ methods and assertions on private methods. Usually, the explicit checks guard the private methods from seeing incorrect values anyway. So really, the assert is checking for a condition that should be impossible. If an assert does fire, it tells ...
I'd definitely recommend Coderush+Refactor or Resharper (Coderush being my personal favourite), these tools dramatically reduce the time to go from code in your head to code on the page. For quick development the UI component sets from the likes of Telerik/DevExpress/Infragistics can be good, but in my experience ca...
I would add Resharper to the list and Ndepend. Most likely Rhino mocks too.
Free, WYSIWYG HTML editor that is Django template compatible
|html|django|
I'm interested to get a free, WYSIWYG HTML editor that is compatible with Django template. Any ideas?
Mid or maybe Senior: WinForms and WPF InterOp.
I would say mimic the diagnostics that .NET itself uses (Trace and Debug). Create a "output" class that can have different classes that adhere to a text output interface. You report to the output class, it autotmatically sends the output given to the classes you have added (ConsoleOutput, TextFileOutput, WhateverOut...
FWIW, most systems will scale most effectively by ignoring this until it's a problem- Moore's law is still holding, and unless your traffic is growing faster than Moore's law does, it's usually cheaper to just buy a bigger box (at $2 or $3K a pop) than to pay developers. That said, the most important place to focus ...
Checking if a list is empty with LINQ
|.net|c#|linq|
What's the "best" (taking both speed and readability into account) way to determine if a list is empty? Even if the list is of type `IEnumerable<T>` and doesn't have a Count property. Right now I'm tossing up between this: if (myList.Count() == 0) { ... } and this: if (!myList.Any()) { ... } My g...
What's the "best" (taking both speed and readability into account) way to determine if a list is empty? Even if the list is of type `IEnumerable<T>` and doesn't have a Count property. Right now I'm tossing up between this: if (myList.Count() == 0) { ... } and this: if (!myList.Any()) { ... } My g...
|c#|.net|linq|
What's the "best" (taking both speed and readability into account) way to determine if a list is empty? Even if the list is of type `IEnumerable<T>` and doesn't have a Count property. Right now I'm tossing up between this: if (myList.Count() == 0) { ... } and this: if (!myList.Any()) { ... } My g...
If you're learning scala, I'd take a good look at the [Seq][1] trait. It provides the basis for much of scala's functional goodness. [1]: http://www.scala-lang.org/docu/files/api/scala/Seq.html
I'm not sure who downmodded botismarius, because he's right. The reason is the .lib generated is the import library that makes it easy to simply declare the external variable/function with `__declspec(dllimport)` and just use it. The import library simply automates the necessary `LoadLibrary()` and `GetProcAddress()`...
Depending on the view engine you're going to use. yes. But you can easilly check this by looking at the page-source for stack-overflow. It's not zen-garden but it's pretty clean.
Depending on the view engine you're going to use. yes. But you can easilly check this by looking at the page-source for stack-overflow. It's not zen-garden but it's pretty clean. Some more clarification: The rendering of the pages is done by the view engine. You can use the standard view engine or existing one...
No code so far, therefore I copy-paste a testing part from [my answer][1] to the original question. // ... int main() { typedef std::map<std::pair<size_t, Deck::value_type>, size_t> Map; Map freqs; Deck d; const size_t ntests = 100000; // compute fr...
No code so far, therefore I copy-paste a testing part from [my answer][1] to the original question. // ... int main() { typedef std::map<std::pair<size_t, Deck::value_type>, size_t> Map; Map freqs; Deck d; const size_t ntests = 100000; // compute fr...
Display solution/file path in Visual Studio IDE
|visual-studio|
I frequently work with multiple instances of Visual Studio, often working on different branches of the same solution. VC6 used to display the full path of the current source file in its title bar, but Visual Studio 2005 doesn't appear to do this. This makes it slightly more awkward than it should be to work out whic...
|visual-studio|projects-and-solutions|
1) Ctrl-. (control period - this will bring up the Quick Nav) 2) Start typing the name of the Type, Variable, etc. 3) Hit Enter to select when the target shows in the top of the list If the scope is not already set to "Solution" (you can tell via the drop-down on the right of the Quick Nav), you can hit Alt-S...
Response.AddHeader "Set-Cookie", "mycookie=yo; HttpOnly" Other options like `expires`, `path` and `secure` can be also added in this way. I don't know of any magical way to change your whole cookies collection, but I could be wrong about that.
You can use .NET reflection to retrieve the labels and values from an existing enum at run-time (`Enum.GetNames()` and `Enum.GetValues()` are the two specific methods you would use) and then use code injection to create a new one with those elements plus some new ones. This seems somewhat analagous to "inheriting from ...
There's nothing wrong with using a command line utility to do what you want. If you put a nice wrapper around the service, you can implement the internals however you want! For example: class Whois(object): _whois_by_query_cache = {} def __init__(self, query): """Initializes the ...
There's nothing wrong with using a command line utility to do what you want. If you put a nice wrapper around the service, you can implement the internals however you want! For example: class Whois(object): _whois_by_query_cache = {} def __init__(self, query): """Initializes the ...
I would say mimic the diagnostics that .NET itself uses (Trace and Debug). Create a "output" class that can have different classes that adhere to a text output interface. You report to the output class, it automatically sends the output given to the classes you have added (ConsoleOutput, TextFileOutput, WhateverOutp...
Good source control should probably be your number 1 priority. I've mentioed them before, but [CVSDude][1] are an excellent managed source control provider. I'm using a SVN package and it's brilliant. Saves a lot of hassle setting up your own server etc. [1]: http://cvsdude.com/
Kyle, in order for PDO/Sqlite to work you need write permission to directory where your database resides. Also, I see you perform multiple selects in loop. This may be ok if you are building something small and not heavy loaded. Otherwise I'd suggest building single query that returns multiple rows and process them ...
> A simple alternative is to “go back in time” to the antics of C and C++: declaration before definition. Try the following: > > Func<int, int> fact = null; > fact = x => (x == 0) ? 1 : x * fact(x - 1); > Works like a charm. Yes, that does work, with one little caveat. C# has mutable reverences. So make...
Rather than suggest a specific language, I would recommend you pick any language or languages that offer the following 4 features: 1. Automatic Memory Management 2. Reflection/Introspection 3. Declarative/Functional constructs(e.g. lambda functions) 4. Duck Typing The idea here is to expand your programmin...
As a side bonus, Silverlight is based on WPF and starting with either lets you gain the know how for working with the other. If things continue to go web based, having prior knowledge (and a library of existing code) to transfer easily to the browser (or Windows Live Mesh) might help give your software an extra lease o...
[http://www.fckeditor.net/][1] ? EDIT: Just found this: [http://blog.newt.cz/blog/integration-fckeditor-django/][2] [1]: http://www.fckeditor.net/ [2]: http://blog.newt.cz/blog/integration-fckeditor-django/
How to provide next page of updated content?
CakePHP's built-in ACL system is really powerful, but poorly documented in terms of actual implementation details. A system that we've used with some success in a number of CakePHP-based projects is as follows. It's a modification of some group-level access systems that have been [documented elsewhere][1]. Our syste...
If you look at the IL using ILDasm, you'll find that they both compile down to Nullable<<bool>>.
They're both right. The fact that the error message describes `__imp_?MyNewVariable@@3PADA` means that it's looking for the decorated name, so the extern "C" is necessary. However, linking with the import library is **also** necessary or you'll just get a different link error.
There might be instances where you need to store objects of unknown types, or objects of multiple different types, but if you do indeed know the type of the objects that you want to store then I cannot see a reason not to use the generic version.
There might be instances where you need to store objects of unknown types, or objects of multiple different types, but if you do indeed know the type of the objects that you want to store then I cannot see a reason not to use the generic version. Edit: As commented you can just use `List<Object>` - doh!
Do a fresh checkout into a different folder, then use a diff program to create a patch. apply the patch to your new working copy.
activerecord as model, is this a good idea?
|php|model-view-controller|activerecord|
Recently thanks to rails' popularity, many people start using activerecord as model. however, before I heard of rails (my peer group was not a fan of open source stuff, we were taught in a .NET school...) and while I was doing my final year project, i found this definition for a model > The model represents enterpri...
I would agree with @Martin and @Pilif's answer, but add; Consider allowing your end-users to decide if they want to actually install the update there and then, or delay the installation of the update until they've finished using the program. I don't know the purpose/function of your app but many applications are...
Opening a PDF in WPF Application
|wpf|
Any ideas how to open a PDF file in a WPF Windows Application?
|wpf|pdf|
|winforms|wpf|pdf|
Since MFC ships with source code I would create a test MFC application that serializes a CObArray and step through the serialization code. This should give you all the information you need.
/<input type="hidden" name="fooId" value="([\d-]+)" \/>/
PDO is the standard, it's what most developers will expect to use. mysqli was essentially a bespoke solution to a particular problem, but it has all the problems of the other DBMS-specific libraries. PDO is where all the hard work and clever thinking will go.
Parsing is one of those areas where you really don't want to roll your own if you can avoid it, as you'll be chasing down the edge-cases and bugs for years go come I'd recommend using [BeautifulSoup](http://www.crummy.com/software/BeautifulSoup/). It has a very good reputation and looks from the docs like it's prett...
Have you successfully used a GPGPU?
|c|gpgpu|hpc|
I am interested to know whether anyone has written an application that takes advantage of a [GPGPU][1] by using, for example, [nVidia CUDA][2]. If so, what issues did you find and what performance gains did you achieve compared with a standard CPU? [1]: http://en.wikipedia.org/wiki/GPGPU [2]: http://www.nvid...
import re reg = re.compile('<input type="hidden" name="([^"]*)" value="<id>" />') value = reg.search(inputHTML).group(1) print 'Value is', value