instruction
stringlengths
0
30k
How can you set the SMTP envelope MAIL FROM using System.Net.Mail?
|c#|.net|smtp|
When you send an email using C# and the System.Net.Mail namespace, you can set the "From" and "Sender" properties on the MailMessage object, but neither of these allows you to make the MAIL FROM and the from address that goes into the DATA section different from each other. MAIL FROM gets set to the "From" property va...
If you want to turn it into a public open source project, [Producing Open Source Software][1] is supposed to be a good read (available both online and in print). [1]: http://producingoss.com/
Are you concerned purely about URLs that are the exact same string .. if so there is a lot of good advice in other answers. Or do you also have to worry about canonization? For example: http://google.com and http://go%4fgle.com are the exact same URL, but would be allowed as duplicates by any of the database only t...
Triggers are the best tool for annotating data when a table is changed by insert, update or delete. To automatically set the date column of a new row in the log with the current date, you'd create a trigger that looked something like this: create trigger log_date before insert on log for each row begin ...
When did browsers start supporting multiple classes per tag?
|css|browser|
You can use more than one css class in an HTML tag in current web browsers, e.g.: <div class="style1 style2 style3">foo bar</div> This hasn't always worked; with which versions did the major browsers begin correctly supporting this feature?
How do you find out the ProductCode from a .Net Installer class custom action
|.net|installation|windows-installer|action|
I need to know the application's ProductCode in the Installer.OnCommitted callback. There doesn't seem to be an obvious way of determining this.
Apparently IE 6 doesn't handle these correctly if you have CSS selectors that contain multiple class names: [http://www.ryanbrill.com/archives/multiple-classes-in-ie/][1] [1]: http://www.ryanbrill.com/archives/multiple-classes-in-ie/
I believe Firefox has always supported this, at least since v1.5 anyway. IE only added full support in v7. IE6 does partially support it, but its pretty buggy, so don't count on it working properly.
1. look at the execution plan in query analyzer 2. See what step costs the most 3. Optimize the step 4. Check the execution plan again
1. Look at the execution plan in query analyzer 2. See what step costs the most 3. Optimize the step 4. Check the execution plan again
1. Look at the execution plan in query analyzer 2. See what step costs the most 3. Optimize the step 4. Return to step 1 [thx to Vinko]
According to [blooberry][1], IE4 and Netscape 4.x do not support this. [HTML 4.0 spec][2] says > class = cdata-list [CS] > This attribute > assigns a class name or set of class > names to an element. Any number of > elements may be assigned the same > class name or names. Multiple class > names must be sepa...
|c#|c|string|pointers|language-implementation|
Is there a terminal program that differentiates between input, output, and commands?
|terminal|
Is there a terminal program that shows the difference between input, standard output, error output, the prompt, and user-entered commands? It should also show when standard input is needed vs. running a command. One way would be to highlight each differently. The cursor could change color depending on if it was wa...
Its fugly, and not type safe. But people do it without consequence. I'd prefer using a DOM or, at a minimum, classes designed to write HTML using type safe semantics. Also, its not all that good to mix UI with logic...
Using gnu find, I think this is what you want. It finds all real files and not directories (-type f), and for each one prints the filename (%p), a tab (\t), the size in kilobytes (%k), the suffix " KB", and then a newline (\n). <tt>find . -type f -printf '%p\t%k KB\n'</tt> If the printf command doesn't format th...
I agree with Erik; TRUNCATE TABLE is the way to go. However, if you can't use that for some reason (for example, if you don't *really* want to delete every row in the table), you can try the following options: - Delete the rows in smaller batches (e.g. DELETE FROM bundle_inclusions WHERE id BETWEEN ? and ?) - ...
The ^M is typically caused by the Windows operator newlines, and translated onto Unix looks like a ^M. The command dos2unix should remove them nicely dos2unix [options] [-c convmode] [-o file ...] [-n infile outfile ...]
We use Sybase Ultralite. Before that we were using Codebase to connect to foxpro tables. I'm not a mobile developer but I understand we chose it over SQL Server for performance and memory usage. Also we found they had pretty good support when we found any issues.
The .Net control is a thin wrapper for the common dialog built into windows, and that _is_ a dialog.
Embed a File Chooser in a UserControl / Form
|.net|c#|
I've inherited a desktop application which has a custom .NET file chooser that is embedded in a control, but it has some issues. I'd like to replace it with a non-custom File Chooser (like the OpenFileDialog). However, for a variety of reasons it needs to be embedded in the parent control not a popup dialog. Is there...
|c#|.net|winforms|
I'm inclined to agree with the others; it sounds like one of the parameters you are passing SE.UI.Utilities.GetPermissionList is null which is causing the exception. Your best bet is to fire up the debugger and check was the variables are before that code is called.
You have to select the scope_identity() function. To do this from application code, I normally encapsulate this process in a stored procedure so it still looks like one query to my application.
Try this. It compiles cleanly on gcc 4.1.3: typedef double FourSquare[4][4]; class Parser { private: double matrix_[4][4]; public: Parser() { for(int i=0; i<4; i++) for(int j=0; j<4; j++) matrix_[i][j] = i*j...
It depends on the OS, of cause, but on Windows I would guess the application data directory. I can't remember the path on xp but on vista it's something like this: C:\Users\\ *user name* \AppData\ And then it would probably be here: C:\Users\\ *user name* \AppData\roaming
I think it's called SQL Server Compact now. The advantages are that it's syntax-compatible with full sql server in that any query you write for it is guaranteed to work on an equivalent SQL Server Express/Standard/Enterprise DB. The reverse isn't necessarily true, though.
Scope_identity() is the preferred way, see: [6 Different Ways To Get The Current Identity Value][1] [1]: http://wiki.lessthandot.com/index.php/6_Different_Ways_To_Get_The_Current_Identity_Value
In .Net at least, you can send multiple queries to the server in one go. I do this in my app: command.CommandText = "INSERT INTO [Employee] (Name) VALUES (@Name); SELECT SCOPE_IDENTITY()"; int id = (int)command.ExecuteScalar(); Works like a charm.
How do I perform a simple one-statement SQL search across tables?
|sql|search|
Say I have two tables: users and groups, each of which has a name. I wish to provide a 'simple search', in which the user enters text and results contain both users and groups whose names contain the text. The results must distinguish between the two types.
I do the following: A service layer contains my business objects. It is passed the repository via an Inversion of Control (Castle Windor is my usual choice). The repository is in charge of mapping between the business objects and my entity framework objects. The advantages: You have no problems with object state ...
Yes, it will definitely cause problems. In addition to creating conflicts that have to be manually resolved, when you check in a file that has been reformatted, the VCS will note almost every line as having been changed. This will make it hard for you or a teammate to look back at the history and see what changed whe...
It definitely could cause conflicts. If you want to use this in a multi-user environment then the configuration of Resharper needs to format your code to a set of standards which are enforced in your organization regardless of whether users make use of Resharper or not. That way you are using the tool to ensure y...
Having too many projects within your solution also appears to be a factor when it comes to performance. I have no real evidence of this but from my experience, less projects equates to better performance. If consolidating projects is not an option then create an alternate solution file so you can add only the exist...
As far as merging goes: > I wonder, is there a more efficient > way to have a recursive function that > returns a list of strings without > duplicates? I don't have to use a > Collection, it can be pretty much any > suitable data type. Your function assembles a return value, right? You're splitting the suppl...
function subst($str, $dict){ return preg_replace(array_map(create_function('$a', 'return "/%\\($a\\)s/";'), array_keys($dict)), array_values($dict), $str); } You call it like so: echo subst('The %(site)s site %(adj)s because it %(adj)s', array('site'=>'Stackoverflow', 'adj'=>'rocks'));
The defacto standard for learning Grails is the excellent [Getting Started with Grails][1] by Jason Rudolph. You can debate whether it is an online tutorial or a book since it can be purchased but is available as a free download. There are more "real" books being published and I recommend Beginning Groovy and Grails. ...
i've used yet another solution i found on the net ... this one is under creativecommons and it **checks if the source was included prior to calling the function** ... you can find the file here: [include.js][1] /** include - including .js files from JS - bfults@gmail.com - 2005-02-09 ** Code licensed un...
Hello fellow JDeveloper developer! I have been working with JSPX pages for over two years and I never had any problems with them being JSPX opposed to JSP. The choice for me to go with JSPX was kinda forced since I use JHeadstart to automatically generate ADF Faces pages and by default, JHeadstart generates everythi...
Does this discussion help? (I don't know if it's taboo to link to another programming forum, but I'd rather not just quote the whole discussion =) ) [Sun Discussion on this subject][1] The verdict seems to be that it doesn't make enough of a difference to matter in most cases, though technically the static metho...
I find myself forgetting how to do this every time as well so I just wrap the two one-liners that I need in a little class: public class Utility { /// <summary> /// Takes the full name of a resource and loads it in to a stream. /// </summary> /// <param name="reso...
You could do this: public static Boolean IsEmpty<T>(this IEnumerable<T> source) { if (source == null) return true; // or throw an exception return !source.Any(); }
You could do this: public static Boolean IsEmpty<T>(this IEnumerable<T> source) { if (source == null) return true; // or throw an exception return !source.Any(); } **Edit**: Note that simply using the .Count method will be fast if the underlying source actually has a f...
@Konrad what surprises me is that in my tests, I'm passing the list into a method that accepts `IEnumerable<T>`, so the runtime can't optimize it by calling the Count() extension method for `IList<T>`. I can only assume that the Count() extension method for IEnumerable<T> is doing something like this: public ...
@Konrad what surprises me is that in my tests, I'm passing the list into a method that accepts `IEnumerable<T>`, so the runtime can't optimize it by calling the Count() extension method for `IList<T>`. I can only assume that the Count() extension method for IEnumerable<T> is doing something like this: public ...
Well there's this blog called [High Scalibility][1] that contains a lot of information on this topic. Some useful stuff. [1]: http://highscalability.com/welcome-high-scalability
Often the most effective way to do this is by a well thought through design where scaling is a part of it. Decide what scaling actually means for your project. Is infinite amount of users, is it being able to handle a slashdotting on a website is it development-cycles? Use this to focus your development efforts
I use [EmacsW32][1], it works great. See its [EmacsWiki page][2] for details. To me, the biggest advantage is that: * it has a version of emacsclient that starts the Emacs server if no server is running (open all your files in the same Emacs window) * it includes several useful packages such as Nxml * it has...
I use [EmacsW32][1], it works great. See its [EmacsWiki page][2] for details. To me, the biggest advantage is that: * it has a version of emacsclient that starts the Emacs server if no server is running (open all your files in the same Emacs window) * it includes several useful packages such as Nxml * it has...
If you use "UNION ALL" then the db doesn't try to remove duplicates - you won't have duplicates between the two queries anyway (since the first column is different), so UNION ALL will be faster. (I assume that you don't have duplicates inside each query that you want to remove)
Iterators in C++ (stl) vs Java, is there a conceptual difference?
|java|c++|iteration|iterator|
I'm returning to c++ after being away for a bit and trying to dust off the old melon. In Java Iterator is an interface to a container having methods: hasNext(), next() and remove(). The presence of hasNext() means it **has the concept of a limit** for the container being traversed. //with an Iterator It...
For Unix-like platforms, the usual way to do this is using the [curses][1] library. [1]: http://en.wikipedia.org/wiki/Curses_(programming_library)
Regex. Regex can solve almost everything except for world peace. Well maybe world peace too.
Regex would probably be you bes bet, tried and proven. Plus a regular expression can be compiled.
Just use [printk/syslog](http://linux.die.net/man/2/syslog). It's old-fashioned, but super duper easy.
You probably should have a pluggable system regardless of which type of string parsing you use. So, this system calls upon the right 'plugin' depending on the type of email to parse it.
I've recently tried piping the output of one free obfuscator into the another free obfuscator - namely Dotfuscator CE and the new Babel obfuscator on CodePlex. More details [on my blog][1]. As for serialization, I've moved that code into a different DLL and included that in the project. I reasoned that there weren'...
Try setting the lang attribute on the &lt;html/&gt; element. HTML example: <pre> &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt; &lt;html lang="ja"&gt; </pre> XHTML example: <pre> &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ...
Create an FxCop rule, and add FxCop to your integration build in order to check for this. You'll get warnings, rather than a failing build. Attributes 'run' at reflection time rather than build time. Alternatively (and this is rather nasty) put a compiler directive around the method you don't want to be called...
From a strict runtime performance point of view, the difference is really negligible. The main difference between the two lies down in the fact that the "static" lifecycle is linked to the classloader, whereas for the singleton it's a regular instance lifecycle. Usually it's better to stay away from the ClassLoader bus...
This should be decided on how complicated the design of your website is. The more complicated, graphically or component wise (amount of content divs), will determine how well your website will scale. Generally you will find most graphic designers website will not scale because they are graphically intensive. However in...
If my original post was the correct understanding and the discussion from Sun that was linked to is accurate (which I think it might be), then I think you have to make a trade off between clarity and performance. Ask yourself these questions: 1. Does the Singleton object make what I'm doing more clear? 2. Do I...
Exception analysis tool for C++
|c++|exception|code-analysis|
I've been looking for a tool to extract exception information from a C++ program. The most wanted feature I'm looking for: I want to know all the exceptions that can be thrown from a function (which would include all the function that is called from that function recursively). I've always thought that documenting er...
G'day, Just wanted to expand on the suggestion from Jon to use -prune. It isn't the easiest of find options to use, for example to just search in the current directory the find command looks like: find . \( -type d ! -name . -prune \) -o \( <the bit you want to look for> \) this will stop find from descend...
Loadind Assemblies from the Network
|.net-3.5|dll|assembly|networking|security|
This is related to the [this question][1] and the answer maybe the same but I'll ask anyways. I understand that we can start managed executables from the network from .NET 3.5 SP1 but what about assemblies loaded from inside the executable? Does the same thing apply? [1]: http://stackoverflow.com/questions...
Loading Assemblies from the Network
|security|.net-3.5|assembly|dll|networking|
Although we don't use Maven, we use the Maven directory structure. We've found that it accurately reflects the concepts we need (e.g. separation of deployment code from test code, code from data, installers from code). Also we figure that *if* someday we switched to Maven, most of our process would remain the same.
Good Question! I've given this some thought... and I can't think of a good solution. What I can think of is a horrible horrible hack that just might work. After seeing that no one has posted an answer to this question for nearly a day, I figured a bad, but working answer would be ok. The SAM file is off limits...
First, I agree with the other posters who suggested a resource leak. You really want to rule that out first. Hopefully, the heap manager you are currently using has a way to dump out the actual total free space available in the heap (across all blocks) and also the total number of blocks that it is divided over. If ...
Do you need SQL support? If not, look at a lightweight embeddable DBM-like solution. I've used Tokyo Cabinet for a number of embedded solutions where SQL wasn't necessary and have greatly enjoyed the speed and flexibility it provides. YMMV.
You can use: Request.Params[Control.UniqueId] To get the value of a control BEFORE viewstate is initialized (Control.Text etc will be empty at this point). This is useful for code in Init.
Oops. this is for a winforms app. Not for WPF. I will post this anyway. try this private AxAcroPDFLib.AxAcroPDF axAcroPDF1; this.axAcroPDF1 = new AxAcroPDFLib.AxAcroPDF(); this.axAcroPDF1.Dock = System.Windows.Forms.DockStyle.Fill; ...
Why all the Linq To Entities Hate?
|linq-to-entities|
I've noticed that there seems to be quite a bit of hostility towards Linq To Entities particularly from the Alt.Net folks. I understand the resistance to more "drag and drop" programming, but from my understanding, Linq To Entities doesn't require it. We're currently using Linq to SQL, and we are using the DBML d...
> I thought matrix_ would essentially be the same as a double** In C there are true multi-dimensional arrays, not arrays of pointers to arrays, so a double[4][4] is a contiguous array of four double[4] arrays, equivalent to a double[16], not a (double*)[4]. > There are no conversions to array types, although the...
You can write bad code that fails to scale in any language. .Net is quite capable at scaling to any size of system but, like with any other tech stack, you have to build the system with scaling in mind. The LSE went down on the worst possible day, but whatever the reason I doubt it was the underlying stack that w...
When you send an email using C# and the System.Net.Mail namespace, you can set the "From" and "Sender" properties on the MailMessage object, but neither of these allows you to make the MAIL FROM and the from address that goes into the DATA section different from each other. MAIL FROM gets set to the "From" property va...
When you send an email using C# and the System.Net.Mail namespace, you can set the "From" and "Sender" properties on the MailMessage object, but neither of these allows you to make the MAIL FROM and the from address that goes into the DATA section different from each other. MAIL FROM gets set to the "From" property va...
The key to successful unit testing is **decoupling**. You have to separate your interesting code from its external dependencies, so it can be tested in isolation. (Luckily, Test-Driven Development produces decoupled code.) In this case, your external is the current DateTime. My advice here is to extract the lo...
Not quite. Designing a type as class or struct shouldn't be driven by your need to store it in collections :) You should look at the 'semantics' needed The problem you're seeing is due to value type semantics. Each value type variable/reference is a new instance. When you say Struct obItem = MyList[1]; wha...