instruction
stringlengths
0
30k
If your personal project is similar to an existing open source project, you should consider contributing to that project instead. A couple of small contributions (bug fixes etc.) are more valuable than a half finished project.
I find there are lots of limitations to CSS that just seem to hint the specification designers don't make websites for a living. Use HTML tables if you can't do it easy in CSS. Having said that, some of the frameworks do help and it always nicer to do in CSS if you can manage it.
Can you query different databases on the same server using 1 NHibernate Session?
|asp.net|nhibernate|
Does a new SessionFactory and Session object have to be created for each database? I have a data store for my application data, and a seperate data store for my employee security, which is used to validate users. Do I have to create a new SessionFactory ans Session object for calls to the 2 different databases?
Double Quotes in Oracle Column Aliases
|oracle-database|quotes|alias|
Ok, this is bit of an obscure question, but hopefully someone can help me out with it. The system I'm working on builds a dynamic SQL string for execution inside a stored procedure, and part of that dynamic SQL defining column aliases, which themselves are actually values retrieved from another table of user generat...
@Wrestlevania said: > any recommendations for .NET coding > practices, libraries, etc. which might > would be really helpful. I try to maintain a high level of separation while coding in ASP.Net. I find that if I avoid the asp controls and stick as much as possible with basic html elements, I can avoid any situa...
While for most datetime operations I would normally convert to Unixtime and perform addition subtraction etc. on the Unixtime integer, you may want to look at the Zend framework Zend_Date class. This has a lot of the functionality you describe. Although Zend is billed as a "framework" it works exceptionally well as...
maybe this will help for Windows platform only: in the PE header (IMAGE_NT_HEADERS) of your exe there are some records such as: <pre> typedef struct _IMAGE_NT_HEADERS { DWORD Signature; IMAGE_FILE_HEADER FileHeader; IMAGE_OPTIONAL_HEADER32 OptionalHeader; } IMAGE_NT_HEADERS32, *PIMAGE_NT_HEADER...
Old-school SQL DB access versus ORM (NHibernate, EF, et al). Who wins?
|orm|ado.net|
I've been successful with writing my own SQL access code with a combination of stored procedures and parameterized queries and a little wrapper library I've written to minimize the ADO.NET grunge. This has all worked very well for me in the past and I've been pretty productive with it. I'm heading into a new projec...
Check out the [ASP.NET Control Gallery](http://www.asp.net/community/control-gallery/). > "The Control Gallery is a directory of over 900 controls and components to use in your own applications. You will find everything from simple controls to full e-commerce components." Not all of them are free but definite...
Data access layers make a lot of sense when many different parts of your application need to access data the same way. It also makes sense when you need access the same data in many different ways. For example, how word processors can read many different file types and silently convert them into the application's in...
What authentication do you have enabled in IIS? Anonmyous, Basic, Digest, Integrated Windows? Sounds to me like anonymous access is enabled/allowed, and nothing else. This would means that LOGON_USER is not populated. When you access your local IIS, trying using http://127.0.0.1 in particular if you use IE. IE...
Fastest C# Code to Download a Web Page
|c#|
Given a URL, what would be the most efficient code to download the contents of that web page? I am only considering the HTML, not associated images, JS and CSS.
|c#|
Is there an automatic code formatter for C#?
|c#|formatting|build-automation|
In my work I deal mostly with C# code nowadays, with a sprinkle of java from time to time. What I absolutely love about Eclipse (and I know people using it daily love it even more) is a sophisticated code formatter, able to mould code into any coding standard one might imagine. Is there such a tool for C#? Visual Studi...
|php|mysql|
I'm trying to write a page that calls PHP that's stored in a MySQL database. The page that is stored in the MySQL database contains PHP (and HTML) code which I want to run on page load. How could I go about doing this?
You can almost do it like this: static void TestException<E>(string message) where E : Exception, new() { var e = new E(); e.Message = message; throw e; } However, that doesn't compile because Exception.Message is read only. It can only be assigned by passing it to the con...
I believe Steve Steiner is correct. When researching Steve's suggestions, I came across [this thread][1] talking about the "Enable Just My Code" option in Tools|Options|Debugger|General. It is suggested that the debugger will break in certain conditions when non-user code either throws or handles an exception. I'm n...
You can look at the [eval][1] function in PHP. It allows you to run arbitrary PHP code. It can be a huge security risk, though, and is best avoided. [1]: http://php.net/eval
You need to pass the RegexOptions.Singleline flag in to the regular expression, so that "." matches all characters, not just all characters except new lines (which is the default).
How do you mean a pure C/C++ solution? The rest parameter (...) is supported cross platform in the C runtime. http://msdn.microsoft.com/en-us/library/kb57fad8.aspx
Are you using C or C++? The next C++ version, C++0x, will support [variadic templates](http://en.wikipedia.org/wiki/Varargs#Variadic_functions_in_C.2C_Objective-C_and_C.2B.2B) which provide a solution to that problem. Another workaround can be achieved by clever operator overloading to achieve a syntax like this: ...
|c#|asp.net|iis|
Running into a problem where on certain servers we get an error that the directory name is invalid when using Path.GetTempFileName. Further investigation shows that it is trying to write a file to c:\Documents and Setting\computername\aspnet\local settings\temp (found by using Path.GetTempPath). This folder exists so...
The reason you can't extend Enums is because it would lead to problems with polymorphism. Say you have an enum MyEnum with values A, B, and C , and extend it with value D as MyExtEnum. Suppose a method expects a myEnum value somewhere, for instance as a parameter. It should be legal to supply a MyExtEnum value, b...
One aspect of managing technical debt is in convincing non-technical managers that you need time allocated for refactoring and bug fixing. [Here's an article with specific suggestions][1] on how to do that. [1]: http://blog.asmartbear.com/2008/09/quality-mortgage.html
Checking Inheritence with templates in C++
|java|c++|templates|
I have a class which is a wrapper class(serves as a common interface) around another class implementing the functionality required. So my code looks like this. template<typename ImplemenationClass> class WrapperClass { // the code goes here } Now, how do I make sure that ImplementationClass can be d...
I usually put the source into my project, and then I can get better intellisense (and a better understanding of them). I don't tend to customize them at all though. I like to have them stock so I can just distribute the stock binaries anytime I need them.
Page.DataBind() kicks off a round of databind on all child controls. That'll cause Asp.Net to re-evaluate bind expressions on each control. If that's insufficient, you can add whatever logic you want to make sure gets kicked off to an OnDataBinding or OnDataBound override in your usercontrols. If you need to re-execute...
Neither of these answers so far is quite what I'm looking for. To give an example of what I'm aiming at (I don't regard this as a complete answer either), I took the above code and created a couple of extension methods: static public IQueryable<Activity> AddCondition( this IQueryable<Activity> results,...
What we did is made a C++\CLI object that held the string in unmangaed code and would give out manged copies of the item. The conversion code looks very much like what Stan has on his blog (I can't remember it exactly)(If you use his code make sure you update it to use delete[]) but we made sure that the destructor wo...
The easiest method is to use a timestamp, representing the number of seconds since January 1, 2008. With a timestamp type, you can do things like... now = time(); tomorrow = now + 24 * 60 * 60; // 24 hours * 60 minutes * 60 seconds Check out the documentation for [time()][1], [date()][2] and [mktime()][3...
I would suggest using a CMS rather than hardcoding in your textual values to cover localisation.
A cross-join is simply the Cartesian product of two sets. There's no explicit join operator for it. <pre> var combo = from p in people from c in cars select new { p.Name, c.Make, c.Model, c.Colour }...
Or, if you need to do some filtering of the enumerator values, you can loop through Enum.GetValues(typeof(EnumeratorName)) and add the ones you want using: dataGridViewComboBoxColumn.Items.Add(EnumeratorValue) As an aside, rather than using a DataTable, you can set the DataSource of the DataGridView to a Bind...
header("Pragma: public"); header("Expires: 0"); header("Cache-Control: post-check=0, pre-check=0"); header("Content-type: application-download"); header('Content-Length: ' . $filesize); header('Content-Disposition: attachment; filename="' . basename($filename).'"'); header("Content-Transfer-...
if you keep your files in the update directory on example.com, this PHP script should download them for you given the request previously mentioned. (your update would be yourprogram.1.2.4.exe $version = $_GET['version']; $filename = "yourprogram" . $version . ".exe"; $filesize = filesize($file...
PowerShell - how do I do a string replacement in a function?
|string|powershell|function|replace|
How do I convert function input parameters to the right type? I want to return a string that has part of the URL passed into it removed. **This works but uses a hard coded string:** function CleanUrl($input) { $x = "http://google.com".Replace("http://", "") return $x } $Site...
|string|powershell|function|replace|
Best way to convert DateTime to "n Hours Ago" in SQL
|sql|datetime|function|
I wrote a SQL function to convert a datetime value in SQL to a friendlier "n Hours Ago" or "n Days Aog" etc type of message. And I was wondering if there was a better way to do it. (Yes I know "don't do it in SQL" but for design reasons I have to do it this way). Here is the function I've written: CREATE ...
|sql|datetime|function|
How do you pass a function as a parameter in C?
|c|syntax|pointer|function|
I want to create a function that performs a function passed by parameter on a set of data. How do you pass a function as a parameter in C?
|c|syntax|pointers|function|
|c|syntax|pointers|function|
I need to check programmatically (in .NET) whether a given user (domain account) is a member of the built-in Administrators group on a current computer (the one where the application gets executed). Is it possible?
|.net|security|
I made a slight change to [@swilliams](http://stackoverflow.com/questions/52238/how-can-i-highlight-a-table-row-using-prototype#52253) code. $$('#thetable tr:not(#headRow)').each( This lets me have a table with a header row that **doesn't** get highlighted. <tr id="headRow"> <th>Header 1</th> ...
Checking network status or PPP status in a program on linux
|c|linux|networking|internet|ppp|
So I'm running PPP under linux with a cellular modem. The program I'm writing needs to know if the link is active before sending any data. What are my options for seeing if the link is available, and further testing to see if it routes to the internet? C on Linux (custom distribution). -Adam
|c|linux|networking|ppp|
So I'm running PPP under linux with a cellular modem. The program I'm writing needs to know if the link is active before sending any data. What are my options to check - if the link is available - if it routes to a server I control (it doesn't go to the internet as I said earlier) Also, what is the best ...
Checking network status and controlling PPP in a program
tf diff /shelveset:shelveset /format:unified
tf diff /shelveset:shelveset /format:unified **Edit:** This writes to standard output. You can pipe the output to a file.
Here is how to to it in powershell , from [hanselman][1]: $userToFind = $args[0] $administratorsAccount = Get-WmiObject Win32_Group -filter "LocalAccount=True AND SID='S-1-5-32-544'" $administratorQuery = "GroupComponent = `"Win32_Group.Domain='" + $administratorsAccount.Domain + "',NAME='" + $admini...
How to parse relative time?
|time|parsing|language-agnostic|
This question is the other side of the question asking, "[How do I calculate relative time?][1]". Given some human input for a relative time, how can you parse it? By default you would offset from DateTime.Now(), but could optionally offset from another DateTime. (Prefer answers in C#) Example input: - "...
|language-agnostic|parsing|time|
This question is the other side of the question asking, "[How do I calculate relative time?][1]". Given some human input for a relative time, how can you parse it? By default you would offset from DateTime.Now(), but could optionally offset from another DateTime. (Prefer answers in C#) Example input: - "...
In the current state of things, there is no good way other than by comments or a third-party solution. Boost provides a [concept check library][1] for this, and I think gcc also has an implementation. Concepts are on the list of C++0x improvements, but I'm not sure if you can specify subtypes - they are more for "must ...
In the current state of things, there is no good way other than by comments or a third-party solution. Boost provides a [concept check library][1] for this, and I think gcc also has an implementation. Concepts are on the list of C++0x improvements, but I'm not sure if you can specify subtypes - they are more for "must ...
That's building a DSL (Domain specific language) for date handling. I don't know if somebody has done one for .NET but the construction of a DSL is fairly straightforward: 1. Define the language precisely, which input forms you will accept and what will you do with ambiguities 2. Construct the grammar for the lan...
That's building a DSL (Domain specific language) for date handling. I don't know if somebody has done one for .NET but the construction of a DSL is fairly straightforward: 1. Define the language precisely, which input forms you will accept and what will you do with ambiguities 2. Construct the grammar for the lan...
Does IE7 have a "developer mode" or plugin like Firefox/Chrome/Safari?
|html|css|browser|internet-explorer-7|
Firefox has Web Developer plugin and Firebug for troubleshooting html/css/javascript issues. Google Chrome and Safari have a very similar console and right-click options for "Inspect Element". Does IE7 have anything similar for troubleshooting layout/html/css issues?
I'd try to keep complete sentences in the language resource. As you said you might need different words in different contexts. But a bigger problem is that the order of sentences might be different in different languages. So building up strings from words can cause problems. Just store The printer is on ...
[Web Development Helper][1] *Web Development Helper is a free browser extension for Internet Explorer that provides a set of tools and utilities for the Web developer, esp. Ajax and ASP.NET developers. The tool provides features such as a DOM inspector, an HTTP tracing tool, and script diagnostics and immediate wind...
Check out the [IE Developer toolboar][1]. [1]: http://www.microsoft.com/downloadS/details.aspx?familyid=E59C3964-672D-4511-BB3E-2D5E1DB91038&displaylang=en
There's a [toolbar][1] you can get but it still doesn't match up to Firefox, especially for javascript debugging. IE8 will be a huge improvement for development. [1]: http://www.microsoft.com/downloads/details.aspx?FamilyID=e59c3964-672d-4511-bb3e-2d5e1db91038&displaylang=en
If ActiveDirectory couldn't handle multiple domain controllers then it wouldn't be a very good technology. You just need to make sure in your Membership configuration you are pointing to the 'Domain' rather than the 'Server' and then add two or more controllers to your domain.
If ActiveDirectory couldn't handle multiple domain controllers then it wouldn't be a very good technology. You just need to make sure in your Membership configuration you are pointing to the 'Domain' rather than the 'Server' and then add two or more controllers to your domain. Generally if you are referring to th...
I ended up passing the product code as a command line argument to my Installer class using the CustomActionData property in Visual Studio (e.g. /productcode={31E1145F-B833-47c6-8C80-A55F306B8A6C}. I can then access this from any callback within the Installer class using the Context.Parameters StringDictionary s...
As others have mentioned, the inline keyword is only a hint to the compiler. In actual fact, most modern compilers will completely ignore this hint. The compiler has its own heuristics to decide whether to inline a function, and quite frankly doesn't want your advice, thank you very much. If you really, really want ...
The Qt library has a [QFileSystemWatcher][1] class which provides cross platform notifications when a file changes. Even if you are not using Qt, because the source is available you could have a look at it as a sample for your own implementation. Qt has separate implementations for Windows, Linux and Mac. [1]:...
Tools to create maximum velocity in a .NET dev team
|.net|productivity|
If you were to self-fund a software project which tools, frameworks, components would you employ to ensure maximum productivity for the dev team and that the "real" problem is being worked on.
If you were to self-fund a software project which tools, frameworks, components would you employ to ensure maximum productivity for the dev team and that the "real" problem is being worked on. What I'm looking for are low friction tools which get the job done with a minimum of fuss. Tools I'd characterize as such ar...
From what I understand you are not just supposed to use EDM as a "pretty" database designer, in fact EDM does not depend on a specific storage layer. It tries to abstract that part for the developer. There are design schemas (CSDL) and storage schemas (SSDL). Anyway, don't mean to lecture you. ;) There is [EDM Gener...