instruction stringlengths 0 30k ⌀ |
|---|
Best way to extract a timezone from a mail Date header in Java? |
|java|timezone| |
I need to store the timezone an email was sent from. Which is the best way to extract it from the email's 'Date:' header (an RFC822 date)? And what is the recommended format to store it in the database (I'm using hibernate)? |
|java|timezone|jakarta-mail| |
Slightly off-topic, but the #gwt channel on irc is very helpful, in-case you have a persistent problem. |
You ask: What's going on behind the scenes?
A view is a bunch of sql text. When a query uses a view, SQL Server places that sql text into the query. This happens BEFORE optimization. The result is the optimizer can consider the combined code instead of two seperate pieces of code for the best execution plan.
Y... |
Here's a functional example with Google AJAX Libs cache and some jQuery magic
This would be the CSS:
<code>
<style type="text/stylesheet" media="screen">
.inputblank { color:gray; } /* class to use for blank input */
</style>
</code>
This would would be the Javascript:
<code>
... |
I have a command-line tool that could be used for this - it uses the XSLT processor built into Ant (the java build tool) to process input + transform into output. Would be easy to wrap with a batch file for loop.
svn://donie.homeip.net/public/tools |
I'd like to second or third python. Specifically, IronPython (ttp://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython) lets you learn python but also gives you access to the .net framework goodies.
It's quite nice for scripting-related tasks so it'll probably be useful for your day-to-day coding life, and also... |
It looks like the following query will generate a nice table with the values I was looking for that can be exported to Excel. What an awesome tool.
> SELECT METHODS FROM TYPES
> "AE.DataAccess.DBHelper" WHERE
> IsPublic ORDER BY MethodCa DESC |
Thanks for all the quick answers. Based on the answer by amdfan, I put this code together that does the job in C#.
/// <summary>The regular expression parser used to parse the lat/long</summary>
private static Regex Parser = new Regex("^(?<deg>[-+0-9]+)[^0-9]+(?<min>[0-9]+)[^0-9]+(?<sec>[0-9.,]+)[^0-9.,ENSW... |
I NEVER use datasets. They are big heavyweight objects only usable (as someone pointed out here) for "demoware". There are lot's of great alternatives shown here. |
Literals can be used as variables of that type.
eg.
Console.WriteLine(5.ToString());
Console.WriteLine(5M.GetType()); // Returns "System.Decimal"
Console.WriteLine("This is a string!!!".Replace("!!", "!"));
Just a bit of trivia... |
Literals can be used as variables of that type.
eg.
Console.WriteLine(5.ToString());
Console.WriteLine(5M.GetType()); // Returns "System.Decimal"
Console.WriteLine("This is a string!!!".Replace("!!", "!"));
Just a bit of trivia...
There's quite a few things people haven't mentioned, but they have mos... |
public static Regex regex = new Regex("< tab >", RegexOptions.CultureInvariant | RegexOptions.Compiled);
public static string regexReplace = "\t";
string result = regex.Replace(InputText,regexReplace);
|
Whenever a method overrides another method, or a method implements a signature in an interface.
The @Override annotation assures you that you did in fact override something. Without the annotation you risk a misspelling or a difference in parameter types and number. |
Some of the key reasons to use OO are to structure code in a similar way to how we humans like to perceive and relate to things, and exploit the benefits of economy, maintainability, reliability, and scalability.
i.e: Humankind designed the wheel thousands of years ago. We may refine it all the time, but we certain... |
Some of the key reasons to use OO are to structure code in a similar way to how we humans like to perceive and relate to things, and exploit the benefits of economy, maintainability, reliability, and scalability.
i.e: Humankind designed the wheel thousands of years ago. We may refine it all the time, but we certain... |
XML is best used as an interchange format when you need to move data from your application to somewhere else or share information between applications. A database should be the preferred method of storage for almost any size application. |
Java operator overload |
|c++|java|operator|overloading| |
Coming from C++ to Java, the obvious unanswered question is why not operator overload.
On the web some go about: "it's clearly obfuscated and complicate maintenance" but no one really elaborates that further (I completely disagree, actually).
Other people pointed out that some objects do have an overload (like S... |
|java|c++|operator-overloading| |
http://www.allinea.com/index.php?page=48 |
I run a job to script it out to a formal directory structure.
The following is VS2005 code, command line project, called from a batch file, that does the work. app.config keys at end of code.
It is based on other code I found online. Slightly a pain to set up, but works well once you get it working.
Impo... |
Speaking strictly from a Java standpoint, any time you initialize a constructor with illegal values, it should throw an exception. That way it does not get constructed in a bad state. |
To me it's a somewhat philosophical design decision.
It's very nice to have instances which are valid as long as they exist, from ctor time onwards. For many nontrivial cases this may require throwing exceptions from the ctor if a memory/resource allocation can't be made.
Some other approaches are the init() m... |
For this sort of performance testing, there's no such thing as a system that will give you a simple pass/fail result. In real life, changing your system is likely to make some things faster and some other things slower, so it's usually not a choice between "better" and "not better", it's a choice between different kin... |
What's the simplest way to test whether a number is a power of 2 in C++ |
|c++|power|algorithm| |
I need a function like this:
<pre>
// return true iff 'n' is a power of 2, e.g.
// is_power_of_2(2) => true is_power_of_2(3) => false
bool is_power_of_2(int n);
</pre>
Can anyone suggest how I could write this? Can you tell me a good web site where this sort of algorithm can be found? |
What's the simplest way to test whether a number is a power of 2 in C++? |
|c++|algorithm|power| |
I need a function like this:
// return true iff 'n' is a power of 2, e.g.
// is_power_of_2(16) => true is_power_of_2(3) => false
bool is_power_of_2(int n);
Can anyone suggest how I could write this? Can you tell me a good web site where this sort of algorithm can be found? |
How do I get the result of a command in a variable in windows? |
|windows|scripting|batch-file| |
I'm looking to get the result of a command as a variable in a Windows batch script (see [how to get the result of a command in bash](http://stackoverflow.com/questions/58207/using-the-result-of-a-command-as-an-argument-in-bash#58214) for the bash scripting equivalent). A solution that will work in a .bat file is prefe... |
bool is_power_of_2(int i) {
if ( i < 0 ) {
return 0;
}
return ! (i & (i-1));
} |
bool is_power_of_2(int i) {
if ( i <= 0 ) {
return 0;
}
return ! (i & (i-1));
} |
bool is_power_of_2(int i) {
if ( i < 0 ) {
return 0;
}
return ! (i & (i-1));
} |
Sqlite is very much meant to be embedded and is free.
It doesn't directly support isolated storage, however it looks like it would be fairly straightforward to invoke the isolated storage API's yourself, and pass the generated filename to Sqlite as the filename it should use. |
I suspect that SELinux may be the problem. Try temporarily disabling it to see if it works. |
It is my belief you should always compile ASP.NET applications. There are a few instances where my clients requested otherwise. In Visual Studio, when you choose to publish your website, there is an option to have it compiled. Here is Microsoft's MSDN article which offers their information on compiling sites.
[ht... |
/bla/a[contains(@prop, "foo")] |
I understand your question, but you are saying that for future records, NULL (unknown, indeterminate or whatever your semantics are) is acceptable (but if it is left off in an insert, there will be a default), but that for all the existing data, you are going to go ahead and assign it the default.
I would have to lo... |
You can find the specified namespace in this file: *system.web.security.singlesignon.claimtransforms.dll*
But this file isn't normaly available but only installed in the GAC (Global Assembly Cache). You may find it under e.g. *c:\window\assembly\...* and copy the dll to another path. Then you can manual reference it... |
The later a bug is discovered, the costlier it is to fix. So bugs should be discovered as early as possible. This is the motivation behind CI.
A good CI should ensure catching as many bugs as possible. The whole application comprises of code (often in multiple languages), Database schema, deployment files etc. Error... |
For the code above...
//*[contains(@prop,'foo')]
|
I assume something like
(gcnew System::Double(d)).ToString() |
try this:
//a[contains(@prop,'foo')]
that should work for any "a" tags in the document |
To answer my own question in part:
Luabind: once you know how to bind methods and classes via this awkward template syntax, it's pretty straightforward and easy to add new bindings. However, luabind has a significant performance impact and shouldn't be used for realtime applications. About 5-20 times more overhead t... |
Aggregate functions work with "Scope', referring to the paragraph scope in this MSDN article, might help...<br>
<a href="http://msdn.microsoft.com/fr-fr/library/ms252112(VS.80).aspx">http://msdn.microsoft.com/fr-fr/library/ms252112(VS.80).aspx"</a>
From what I understand you may have to define a scope or try =Fir... |
I'm not sure of all the details, but my understanding is that OLE DB and ODBC are two APIs that are available for connecting to various types of databases without having to deal with all the implementation specific details of each. According to [the Wikipedia article on OLE DB][1], OLE DB is Microsoft's successor to OD... |
Some of the key reasons to use **OO** are to structure code in a similar way to how we humans like to perceive and relate to things, and exploit the benefits of **economy**, **maintainability**, **reliability**, and **scalability**.
i.e: Humankind designed the wheel thousands of years ago. We may refine it all the ... |
Boost (www.boost.org, a library I would recommend anyone coding in C++ use) provides a noncopyable base class that does exactly that; you don't need an ugly macro that way. |
Linear congruential (X = AX+C mod M) PRNG's might be a good one to assign for an assembler course as your students will have to deal with carry bits for intermediate AX results over 2^31 and computing a modulus. If you are the student they are fairly straightforward to implement in assembler and may be what the lectur... |
It does allow you (well, the compiler) to catch when you've used the wrong spelling on a method name you are overriding. |
Silverlight app and an iframe co-existing on the same page |
|silverlight|iframe| |
this should be simple...could someone provide me a simple code sample that has an aspx page hosting both a silverlight app (consisting of, say a button) and an iframe (pointing to, say stackoverflow.com). The silverlight app and iframe could be in separate div's, the same div, whatever.
Everything I've tried so far... |
Is it possible to call a JavaScript function from the IMG SRC tag to get an image url?
Like this:
<IMG SRC="GetImage()" />
<script language="javascript">
function GetImage() {return "imageName/imagePath.jpg"}
</script>
This is using .NET 2.0.
|
Which Layout Manager do you use? |
|java|swing|layout| |
What java GUI layout manager does everyone use? Lately, I have been using [MigLayout][1], which has some powerful component controls. Just wanted to see what other developers are using other than the standard JDK ones.
[1]: http://www.miglayout.com/ |
|java|swing|layout| |
In SQL Server 2005, can I do a cascade delete without setting the property on my tables? |
|sql-server|sql-server-2005|cascade| |
I have a database full of customer data. It's so big that it's really cumbersome to operate on, and I'd rather just slim it down to 10% of the customers, which is plenty for development. I have an awful lot of tables and I don't want to alter them all with "ON DELETE CASCADE", especially because this is a one-time de... |
'metaprogramming' is really a bad name for this specific feature, at least when you're discussing more than one language, since this feature is only needed for a narrow slice of languages that are:
- static
- compiled to machine language
- heavyly optimised for performance at compile time
- extensible wit... |
insert data from database into word according to the table format in the word |
|database|word| |
now i need to insert some data from the sqlserver into a word,i know how to use bookmark and the office interop api do that but it's slow to call the word process do that and it's coupling between the bookmark define and the code , is it possible to do this without word process start?if not are there any template e... |
|database|ms-word| |
I would highly recommend chapter 18 of [Code Complete][1].
You could also check this post [What Are Table Driven Methods][2]
[1]: http://cc2e.com/
[2]: http://stackoverflow.com/questions/105311/what-are-table-driven-methods |
I believe it will just suspend all apps wherever they happen to be.
Remember, this happens all the time anyway. Applications are constantly suspended and resumed due to context switching. So, really, the clock could jump between any 2 instructions in your app, though usually not in a noticable/significant way.
... |
The usual contract in OO is that object methods do actually function.
So as a corrolary, to never return a zombie object form a constructor/init.
A zombie is not functional and may be missing internal components. Just a null-pointer exception waiting to happen.
I first made zombies in Objective C, many years a... |
I think this may have been a conscious design choice to force developers to create functions whose names clearly communicate their intentions. In C++ developers would overload operators with functionality that would often have no relation to the commonly accepted nature of the given operator, making it nearly impossibl... |
Mercurial and Bazaar resemble themselves very much on the surface. They both provide basic distributed version control, as in offline commit and merging multiple branches, are both written in python and are both slower than git. There are many differences once you delve into the code, but, for your routine day-to-day t... |
As far as I know it is not possible with a command line, it is just one color... |
Eric Lippert says there are 4 kinds of exceptions.
* Fatal exceptions are not your fault, you cannot prevent them, and you cannot sensibly clean up from them.
* Boneheaded exceptions are your own darn fault, you could have prevented them and therefore they are bugs in your code.
* Vexing exceptions are the result ... |
You could do something like that with [Firebird Embedded][1].
Although it does not natively support Isolated Storage, it should be pretty easy to create a new database for each user.
[1]: http://firebirdsql.org |
ASP.net - How can one differentiate Page-Processing Time from Client-Transmission Time |
|asp.net|page-lifecycle|measurement|transmission| |
The single timing column in the weblog naturally includes client transmission timing. For anamoly analysis, I want to differentiate pages that took excessive construction time from requests that simply had a slow client.
For buffered pages, I've looked at the ASP.NET page lifecycle model and do not see where I can ... |
|asp.net|page-lifecycle|measurement|transmission| |
The single timing column in the weblog naturally includes client transmission timing. For anamoly analysis, I want to differentiate pages that took excessive construction time from requests that simply had a slow client.
For buffered pages, I've looked at the ASP.NET page lifecycle model and do not see where I can ... |
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. |
I don't see the use of encapsulating this, but that may be just me. In any case, returning a reference instead of a pointer makes a lot more sense to me. |
Since none of the code you've written modifies the static field after initialization, there is no need for any locking. Just replacing the string with a new value won't need synchronization either, unless the new value depends on the results of a read of the old value.
Static fields aren't the only things that need... |
> We use Visual C++ 2005 to compile our
> 32 bit application with Cygwin.
I think that's the problem. I like Cygwin a lot, but it is **really** slow when it comes to file I/O. It helps a bit to deactivate the NTFS filesystem feature to keep track of the last file-access.
To get a better speed boost port your bu... |
I found an [install log][1] showing that it was expected to be in
> C:\WINDOWS\ADFS\System.Web.Security.SingleSignon.dll
on Windows Server 2003. You probably need to have active directory installed for it to appear there because I checked one of my 2003 servers without AD and it wasn't there.
Normally I would ... |
The [readLines][1] function will return a zero-length value when it reaches the EOF.
[1]: http://wiki.r-project.org/rwiki/doku.php?id=rdoc:base:readlines |
To get around the preprocessor hackery of the Windows header files, declare it like this:
#undef GetWindowText
String^ GetWindowText()
Note that, if you actually use the Win32 or MFC `GetWindowText()` routines in your code, you'll need to either redefine the macro or call them as `GetWindowTextW()`. |
Reading:
Books - Celko (also read across to some Oracle-biased books)
Blogs - the above mentioned, plus SSWUG
Webinars and Conference - Best way to keep up with vendor-specific stuff like
SSIS/SSRS/SSAS
Practice:
Improving code (mine and others)
Refactoring
Mentoring/training other developers
|
The QuickLaunch (QL) will do security trimming for the default items on the menu. In other words, if a user doesn't have access to what the QL nav item points to, it won't be displayed to her. However, the QL unfortunately does **not** do security trimming on nav items you add manually through the GUI. If you add items... |
AFAICT, C++ tuples basically need to be handled with recursion; there don't seem to be any real ways of packing/unpacking tuples _except_ using the typesystem's only variadic template handling.
|
How can you have SharePoint Link Lists default to opening in a new window? |
|sharepoint|web-parts| |
In SharePoint, it is easy to set up a List webpart consisting of Links to other documents, folders, sites, etc. Unfortunately, when clicking these links, the default behavior is for the page to open in the current browser window. That is, it does NOT open the page in a new instance of the browser. This has proven an... |
Methods (or functions) can be called on object that are not of the type they were designed to work with. This is great to call native (fast) methods on custom objects.
var listNodes = document.getElementsByTagName('a');
listNodes.sort(function(a, b){ ... });
This code crashes because `listNodes` is not a... |