instruction stringlengths 0 30k ⌀ |
|---|
XML to Excel (2007) Ideas using Windows XP, and C#.Net |
|c#|.net|xml|excel| |
I have a dataset that I have modified into an xml document and then used a xsl sheet to transform into an Excel xml format in order to allow the data to be opened programatically from my application. I have run into two problems with this:
1. Excel is not the default Windows application to open Excel files, theref... |
I have a dataset that I have modified into an xml document and then used a xsl sheet to transform into an Excel xml format in order to allow the data to be opened programatically from my application. I have run into two problems with this:
1. Excel is not the default Windows application to open Excel files, theref... |
Clean implementation of the strategy pattern in Perl |
|perl|design-patterns|strategy| |
How do I write a clean implementation of the strategy pattern in Perl? I want to do it in a way that leverages Perl's features. |
Volatile means that we have to go to memory to get or set this value. If you don't set volatile, the compiled code might store the data in a register for a long time.
What this means is that you should mark variables that you share between threads as volatile so that you don't have situations where one thread start... |
The class you're looking for is java.text.MessageFormat; specifically, calling
MessageFormat.format("{0} This {1} a test", new Object[] {"Yes!!!", "is"});
will return
"Yes!!! This is a test"
[Unfortunately, I can't help with the Struts connection, although [this][1] looks relevant.]
[1]: http... |
The short answer is, you're not missing anything. The Android SDK doesn't provide a direct method to change the indicator of a TabHost after it's been created. The TabSpec is only used to build the tab, so changing the TabSpec after the fact will have no effect.
I think there's a workaround, though. Call mTabs.ge... |
I found this resource to be very helpful
http://blog.eworldui.net/post/2008/05/ASPNET-MVC---Localization.aspx
Its a wrapper round the **HttpContext.Current.GetGlobalResourceString** and **HttpContext.Current.GetLocalResourceString** that allows you to call the resources like this...
// default global resourc... |
If you aren't using a javascript framework, I strongly suggest it. I use MooTools, but there are many others that are very solid (Prototype, YUI, jQuery, etc). These include methods for attaching functionality to the DomReady event. The problem with:
window.onload = function(){...};
is that you can only ever ... |
Switching from C# to C++. Any must-reads? |
|c#|c++| |
Forget lazy initialization, it's too problematic. This is the simplest solution:
public class A {
private static A singleton = new A();
private A() {}
public static A getInstance() {
return singleton;
}
} |
I agree with Jon, but assuming you still have need for a separate damage counter class, you can do:
class IDamageable {
virtual DamageCounter* damage_counter() = 0;
};
class DamageCounter {
...
};
Each damageable class then needs to provide their own damage_counter() member functi... |
I think you can use
> `freopen`
for this . |
Create two pipes with pipe(...), one for stdin, one for stdout.
fork(...) the process.
in the child process (the one where fork(...) returns 0) dup
(...) the pipes to stdin/stdout.
exec[v][e] the to be started programm file in the child process.
In the parent process (the one where fork) returns the PID of... |
Precedence and associativity both specify how and in which order a term should be split into subterms. In other words does it specifies the rules where brackets are to be set implicitly if not specified explicitly.
If you've got a term without brackets, you start with operators with lowest precedence and enclose it ... |
Nothing. Indentation and other coding standards are a matter of preference. |
What is the license for unlicensed material? |
|licensing| |
Rails Binary Stream support |
I'm going to be starting a project soon that requires support for large-ish binary files. I'd like to use Ruby on Rails for the webapp, but I'm concerned with the BLOB support. In my experience with other languages, frameworks, and databases, BLOBs are often overlooked and thus have poor, difficult, and/or buggy functi... |
If using Gmail you can configure GMAIL to pick up mail from other accounts. |
How can I make a ListView's columns auto-resize programmatically? |
|.net|windows|user-interface|controls| |
I've found some examples using the Win32 api or simulating the ^+ button combination (ctrl-+) [using SendKeys][1], but at least with the SendKeys method the listview grabs the cursor and sets it to an hourglass until I hit the start button on my keyboard. What is the cleanest way to do this?
[1]: http://www.cod... |
With the ScktComp classes, you need to use a ThreadBlocking server rather than an a NonBlocking server type. Use the OnGetThread event to hand off the ClientSocket param to a new thread of your devising. Once you've instantiated an inherited instance of TServerClientThread you'll create a instance of TWinSocketStream (... |
Manually detaching an event can be important to prevent memory leaks: the object that connects to an event fired by another object, will not be garbage collected until the object that fires the event is garbage collected. In other words, an "event-raiser" has a strong reference to all the "event-listeners" connected to... |
I'm trying to find a least-resistance path from C# to C++, and while I feel I handle C# pretty well after two solid years, I'm still not sure I've gotten the "groove" of C++, despite numerous attempts.
Are there any particular books or websites that might be suitable for this transition? |
The rule I follow is it should be a new app if I want to reuse the functionality in a different project.
If it needs deep understanding of the models in your project, it's probably more cohesive to stick it with the models. |
Another idea would be to put the actual rating mechanism at the bottom of each child window. So the answer is actually attached to the picture on their child windows instead of having the answers in their own area. |
SVN with TortiseSVN (on Windows) is superb. I highly recommend it. |
Use a HwndHost to host the outside window in your application. |
If you're dealing with similar (well, exactly the same), configurations, the answer is Microsoft Sysprep & Norton/Symantec Ghost.
What you're essentially looking for is taking settings for a particular computer and cloning them to different hardware. nLite and unattended installs are great and fantastic for getting... |
To deal with it conceptually before getting into mechanisms, and apologies if any of this is obvious, a string can be defined as a sequence of Unicode characters, Unicode being a database that gives an id number known as a code point to every character you might need to work with. GSM-338 contains a subset of the Unico... |
Either current($array) or array_shift($array) will work, the former will leave the array intact. |
I don't know if my answer's related to the question but:
Be **very** careful about inline virtual methods! Some buggy compilers (previous versions of Visual C++ for example) would generate inline code for virtual methods where the standard behaviour was to do nothing but go down the inheritance tree and call the app... |
Multiple languages in an ASP.NET MVC application? |
|asp.net|asp.netmvc|language|multilingual|internationalization| |
What is the best way to support multiple languages for the interface in an ASP.NET MVC application. I've seen people use resource files for other applications. Is this still the best way? |
|asp.net|mvc|language|internationalization|multilingual| |
|asp.net|mvc|language|internationalization|multilingual| |
|asp.net-mvc|language|internationalization|multilingual| |
|asp.net-mvc|mvc|language|internationalization|multilingual| |
Is it bad to load many managed DLL's without using any types in them? |
|c#|.net|dll|inversion-of-control|spring.net| |
Background: At my company we are developing a bunch applications that are using the same core dll's. These dll's are using Spring.net's IoC-container to wire things up (auto-wiring). All applications are using the same spring configuration file, and this configuration file points to many classes in many different dll's... |
It is perhaps a good idea not to use tabs at all.
:set expandtab
If you want to replace all the tabs in your file to spaces (given tabstop=3)
%s/^I/ /
(where ^I is the TAB character) |
It is perhaps a good idea not to use tabs at all.
:set expandtab
If you want to replace all the tabs in your file to spaces (given tabstop=3)
%s/^I/ /
(where ^I is the TAB character)
From the VIM online help:
'tabstop' 'ts' number (default 8)
local to buffer
Number of spaces that a <Tab> ... |
Filestream blob storage is the biggest bonus to me |
Others have suggested some pretty good ideas using output pins, so I won't suggest that, although it can be a very good solution, and is very cost effective. If your budget and target processor support it, a hardware trace system, (either an old fashioned emulator, or a fancy BDM with bus snooping trace support) can be... |
The [Ziggurat algorithm][1] is pretty efficient for this, although the [Box-Muller transform][2] is easier to implement from scratch (and not crazy slow).
[1]: http://en.wikipedia.org/wiki/Ziggurat_algorithm
[2]: http://en.wikipedia.org/wiki/Box-Muller_transform |
Is there a better deterministic disposal pattern than nested "using"s in C#? |
|c#|c++|using|raii| |
In C#, if I want to deterministically clean up non-managed resources, I can use the "using" keyword. But for multiple dependent objects, this ends up nesting further and further:
using (FileStream fs = new FileStream("c:\file.txt", FileMode.Open))
{
using (BufferedStream bs = new BufferedStream(fs... |
If you connect directly to the DB with no middle layer, you should consider using a DB user for each real user, because otherwise you can't really secure the access of the application.
If you connect to Oracle with ORa*Net the user password is automatically encrypted (since Oracle 8) however it might fall back to u... |
Usually the camera is displayed as a removable drive when attached.
So for a Winforms application just let the user select the drive and the picture you want to upload. You can do any processing once you have the FileStream of the picture.
In ASP.net you are going to need a FileUpload Control where again the user... |
This depends on your camera.
Many cameras will simply mount as USB mass storage devices. If this is the case, then you can just copy the file from the visible file system like you would any other file on an external disk.
If the camera doesn't make its contents available in this way, you'll need to look at the ca... |
You can also make use of *xargs*. Just pipe the output of *ls* through *xargs*.
ls | xargs
If that doesn't work and the *find* examples above aren't working, try piping them to *xargs* as it can help the memory usage that might be causing your problems. |
tv_grab_dvb can do this. See the [subversion repository][1] for sources.
tv_grab_dvb is made to work with the stream grabbed from the DVB-T card using [dvbtools][2] on Linux, but it may be portable to other platforms - I think it just works with the raw data from the stream.
[1]: http://www.darkskiez.co.uk/svn/... |
You can use the XmlDocument.ImportNode method to copy a node from a XmlDocument to another. |
This should give you the real path that you can use to extract / edit files.
[Javadoc Link][1]
We're doing something similar in a context listener.
public class MyServlet extends HttpServlet {
public void init(final ServletConfig config) {
final String context = config.getServletContext().get... |
If I understand your problem correctly, you simply change the database's connection string in your app.config / web.config. |
If I understand your problem correctly, you simply change the database's connection string in your app.config / web.config.
**Edit**, post clarification: You have the connection strings stored somewhere. They might be in the app.config of your server. Still, you get them from somewhere and that somewhere may be in a... |
I find that dynamically attaching/detaching event handlers is only of use where you have a long-lived object exposes events that are consumed by many short-lived objects. For most other cases the two objects are disposed around the same time and the CLR does a sufficient job of cleaning up on its own
|
How to calculate age in TSQL with Years, Months, and Days |
|t-sql|datediff|age| |
What would be the best way to calculate someone's age in years, months, and days in TSQL (SQLServer 2000)?
The datediff function doesn't handle year boundaries well, plus getting the months and days separate will be a bear. I know I can do it on the client side relatively easily, but I'd like to have it done in my ... |
There's no way to override the ClickOnce installation location. As you said, it's runtime generated, and resides within the user ClickOnce App Cache within the individual users directory. Have you considered having having the admins whitelisting this specific folder?
I guess the only other way to handle it would be ... |
You might be interested in <http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.importnode.aspx>. But take a close look at the "The following table describes the specific behavior for each XmlNodeType."-part of that document. |
"NMEA" is the keyword to be searching for when looking for this stuff. While I haven't done anything with this in a long, long time, here is a good source for some boards and other hardware:
http://www.sparkfun.com/commerce/categories.php?c=4 |
Volatile means that we have to go to memory to get or set this value. If you don't set volatile, the compiled code might store the data in a register for a long time.
What this means is that you should mark variables that you share between threads as volatile so that you don't have situations where one thread start... |
In short: don't do this by hand, link/use existing software. And sain_grocen's answer is incorrect. :(
These are all tests for significance of parameter estimates that are typically used in Multivariate response Multiple Regressions. These would not be simple things to do outside of a statistical programming envi... |
Sounds like you're looking for linux realtime filesystems. Be sure to search Google et al for that.
XFS has a realtime option, though I haven't played with it.
hdparm might let you turn off the caching altogether.
Tuning the filesystem options (turn off all the extra unneeded file attributes) might reduce wh... |
I'll throw out some suggestions, advice is cheap.
- make sure you are using a lower level API for writing to the disk, don't use user-mode caching functions like <code>fopen, fread, fwrite</code> use the lower level functions <code>open, read, write</code>.
- pass the <code>O_SYNC</code> flag when you open th... |
I'm a Subversion fan but there are a lot of good open and closed source choices. I'd avoid CVS as it really doesn't stack up as a modern SCM (no atomic commits and such).
Someone will probably suggest SourceSafe. Avoid it like the plague. SourceSafe silently destroys history and causes no end of grief. A little goog... |
A portable and robust solution is to use [iconv](http://www.gnu.org/software/libiconv/), with the understanding that you have to know what encoding your system `wchar_t` uses (UTF-16 on Windows, UTF-32 on many Unix systems, for example).
If you want to minimise your dependency on third-party code, you can also hand-... |
A portable and robust solution is to use [iconv](http://www.gnu.org/software/libiconv/), with the understanding that you have to know what encoding your system `wchar_t` uses (UTF-16 on Windows, UTF-32 on many Unix systems, for example).
If you want to minimise your dependency on third-party code, you can also hand-... |
Passing data between a parent app and a virtual directory |
|c#|asp.net|iis| |
I have an application that runs as a child application in a virtual directory.
I want to pass a value from the parent application, but I believe that Session is keyed per application, and won't work.
To further complicate things, the parent application is WebForms, while the child is NVelocity MVC.
Does anyone... |
I have an application that runs as a child application in a virtual directory.
I want to pass a value from the parent application, but I believe that Session is keyed per application, and won't work.
To further complicate things, the parent application is WebForms, while the child is NVelocity MVC.
Does anyone... |
Not using widths & padding/margins on the same element? |
|html|css| |
I've seen numerous people mentions that you shouldn't use widths and padding or margins on the same element with CSS. Why is that? |
Match it against a regular expression.
c.f. http://forums.mysql.com/read.php?60,1907,38488#msg-38488 as quoted below:
<pre>
Re: IsNumeric() clause in MySQL??
Posted by: kevinclark ()
Date: August 08, 2005 01:01PM
I agree. Here is a function I created for MySQL 5:
CREATE FUNCTION IsNumeric (sIn varchar(1... |
It will depend on the brand of camera. Here is a link to start with for [Canon](http://www.usa.canon.com/consumer/controller?act=SDKHomePageAct&keycode=Sdk_Lic&fcategoryid=314&modelid=7474&id=3464). |
The using statement is syntactic sugar that converts to:
try
{
obj declaration
...
}
finally
{
obj.Dispose();
}
You can explicitly call Dispose on your objects, but it won't be as safe, since if one of them throws an exception, ... |
In .Net 2 the BackgroundWorker was introduced, this makes running async operations really easy:
BackgroundWorker bw = new BackgroundWorker { WorkerReportsProgress = true };
bw.DoWork += (sender, e) =>
{
//what happens here must not touch the form
//as it's in a different t... |
Use expression language:
<pre><code lang="jsp">
<wf:my-tag obj="${myObject}" />
</code></pre>
|
Conditional operator assignment with nullable<value> types? |
|c#|conditional|operator|nullable|int| |
EmployeeNumber =
string.IsNullOrEmpty(employeeNumberTextBox.Text)
? null
: Convert.ToInt32(employeeNumberTextBox.Text),
I often find myself wanting to do things like this (EmployeeNumber is a nullable<int> as it's a property on a LINQ-to-SQL dbml object where the column allows NULL val... |
Suppose I've found a “text” somewhere in open access (say, on public network share). I have no means to contact the author, I even don't know who is the author.
What can I legally do with such “text”? |
Suppose I've found a “text” somewhere in open access (say, on public network share). I have no means to contact the author, I even don't know who is the author.
What can I legally do with such “text”?
**Update:** I am not going to publish that “text”, but rather learn from it m... |
Suppose I've found a “text” somewhere in open access (say, on public network share). I have no means to contact the author, I even don't know who is the author.
What can I legally do with such “text”?
**Update:** I am not going to publish that “text”, but rather learn from it m... |
Personal Preference I would have thought? I guess it has the code block in one vertical line so possibly easier to work out at a glance? Personally I prefer the brace to start directly under the previous line |
Its just another style--people code how they like to code, and that is one accepted style (though not my preferred). I don't think it has much of a disadvantage or advantage over the more common style in which brackets are not indented but the code within them is. Perhaps one could justify it by saying that it more c... |