instruction stringlengths 0 30k β |
|---|
|nhibernate| |
I've got two tables in my database: Articles and Tags
The Tags tables consist of ArticleID (foreign key) and a Tag (varchar).
Now I need to map an articles tags into a readonly collection on Article entity, either using IList<string> Tags or ReadOnlyCollection<string> Tags.
I've consulted the NHibernate refere... |
@Gareth Jenkins
The page will execute all of the queries before returning even the first update panel, so he won't save any time there.
The trick to do this is to move each of your complex gridviews into a user control, in the user control, get rid of the Object DataSource crap, and do your binding in the code be... |
I stand by Jim McKeeth's comment.
Also, indexing and full table scans are faster if your table has only CHAR columns. Basically the optimizer will be able to predict how big each record is if it only has CHAR columns, while it needs to check the size value of every VARCHAR column.
Besides if you update a VARCHAR ... |
I stand by Jim McKeeth's comment.
Also, indexing and full table scans are faster if your table has only CHAR columns. Basically the optimizer will be able to predict how big each record is if it only has CHAR columns, while it needs to check the size value of every VARCHAR column.
Besides if you update a VARCHAR ... |
You can create a hidden textbox with a value of 0. Put the onLoad() code in a if block that checks to make sure the hidden text box value is 0. if it is execute the code and set the textbox value to 1. |
Finding network alias in .net |
|networking|.net-2.0|alias| |
Is there a way in .net 2.0 to discover the network alias for the machine that my code is running on? Specifically, if my workgroup sees my machine as //jekkedev01, how do I retrieve that name programmatically? |
If your working with me and your working with Oracle I would probably make you use varchar in almost every circumstance. The assumption that char uses less processing power than varchar may be true...for now...but database engines get better over time and this sort of general rule has the making of a future "myth".
... |
Postbacks are caused by a FORM submission. You need to initiate them from the client.
|
If you can edit the code, you should just re-write it to use a custom API that does what you want. Failing that, use Maximilian's technique, but be warned that it is a maintenance horror.
If you cannot edit the code, you can patch the import tables to redirect calls to your own code. A description of this technique ... |
You could do it with an Ajax request. You'd have to have the page polling the server. There isn't any way for the server to push information out to the browser without requesting it. But having some Javascript that runs in the background and polls the server every 5 seconds (or more, depending on your needs) would p... |
You could do it with an Ajax request. You'd have to have the page polling the server. There isn't any way for the server to push information out to the browser without requesting it. But having some Javascript that runs in the background and polls the server every 5 seconds (or more, depending on your needs) would p... |
Well, it sort of depends upon what the logic has to deal with...
Often, it makes sense to push more things into your models, leaving controllers small. This ensures that this logic can easily be used from anywhere you need to access the data that your model represents. Views should contain almost no logic. So reall... |
There's [testoob](http://testoob.sourceforge.net/) which is pretty complete suite of test.Also xUnit-ie, and has a nice reporting option |
In a normal situation, variables are bound by scoping rule: Local variables work only within the defined function. Closure is a way of breaking this rule temporarily for convenience.
def n_times(a_thing)
return lambda{|n| a_thing * n}
end
in the above code, `lambda(|n| a_thing * n}` is the closure... |
There is also [PyUnit](http://pyunit.sourceforge.net/) which might be what you're looking for. |
@Greg: PyUnit is included in the standard library as `unittest` |
When you parse the data use nl2br() to convert \n/\r\n into <br /> |
Best Way to ReUse Code When Using Visual Studio? |
|visual-studio|.net| |
I've tried 2 different methods of reusing code. I have a solution full of just class library projects with generic code that I reuse in almost every project I work on. When I get to work on a new project, I will reuse code from this code library in one of 2 ways. I have tried bringing the projects I need from this code... |
Best Way to Reuse Code When Using Visual Studio? |
|visual-studio|.net|productivity| |
|.net|visual-studio|productivity| |
use the <pre> tag, that will use a monospaced font (for your art) and keep all the whitespace
<pre>
text goes here and here
and here and here Some out here
β βββ ββ β
βββββ ββββββ βββββββ ββ βββββββββββββββββ
ββ ββ βββββ ββ β ββ... |
use the <pre> tag (pre formatted), that will use a mono spaced font (for your art) and keep all the white space
<pre>
text goes here and here
and here and here Some out here
β βββ ββ β
βββββ ββββββ βββββββ ββ βββββββββββββββββ
ββ ... |
Conferences and training for architects, best practices, |
|architecture|education| |
It's getting close to the time when I need to submit training and travel requests. I'm looking for conferences and classes in the coming 12 months that are geared toward improving coding and software development, best practices, system architecture, etc. They need to be in the US or Canada since I'll never get approval... |
Many JDBC drivers, early versions of Oracle in particular, have problems while inserting LOBs. Did you make sure that the query Hibernate fires, with the same parameters bound works successfully in your JDBC driver? |
The API CreateJobObject() almost does what I need... but doesn't seem to close everything unless my software manages to call TerminateJobObject() before crashing. |
The Windows API supports objects called "Job Objects". The following code will create a "job" that is configured to shut down all processes when the main application ends (when its handles are cleaned up). This code should only be run once.:
HANDLE ghJob = CreateJobObject( NULL, NULL); // GLOBAL
if( ghJob == NULL... |
The Windows API supports objects called "Job Objects". The following code will create a "job" that is configured to shut down all processes when the main application ends (when its handles are cleaned up). This code should only be run once.:
HANDLE ghJob = CreateJobObject( NULL, NULL); // GLOBAL
if( ghJob == NULL... |
Variables declared with static/global scope are always initialized under VC++ at least.
Under some circumstances there can actually be a difference in behaviour between:
int x=0;
int main() { ... }
and
int x;
int main() { ... }
If you are using shared data segments then VC++... |
I love Red Gate's SQL Compare and Data Compare too but it won't meet his requirements for the changing primary keys as far as I can tell.
If cross database queries/linked servers are an option you could do this with a stored procedure that copies the records from parent/child in DB A into temporary tables on DB B ... |
Is it possible to display the entity ⇓ in IE6 |
|internet-explorer-6| |
is it possible to display ⇓ entity in ie6? It is being display in every browser but not IE 6.I am writing markup such as:
<span>⇓\;</span> // Not that the ; is escaped to show the entity
|
is it possible to display ⇓ entity in ie6? It is being display in every browser but not IE 6.I am writing markup such as:
<span>⇓</span>
|
No. As explained [here](http://msdn.microsoft.com/en-us/library/aa365141%28VS.85%29.aspx), anonymous pipes do not support asynchronous I/O. You need to use a named pipe. There's example code to do this on MSDN [here](http://msdn.microsoft.com/en-us/library/aa365603%28VS.85%29.aspx) and [here](http://msdn.microsoft.com/... |
make sure you indent properly |
Checkbox in listview control |
|c#|user-interface| |
Can you have a multicolumn listview control where one of the columns is a checkbox? Example code or links would be greatly appreciated. |
improve my python regex! |
|python|regex| |
What follows is a regular expression I have written to match multi-line pre-processor macros in C / C++ code. I'm by no means a regular expressions guru, so I'd welcome any advice on how I can make this better.
Here's the regex:
<pre>^\s*#define(.*\\\n)+[\S]+(?!\\)</pre>
It should match all of this:
<pre>
... |
Php function argument error suppression, empty() isset() emulation |
I'm pretty sure the answer to this question is no, but in case there's some PHP guru
is it possible to write a function in a way where invalid arguments or non existent variables can be passed in and php will not error without the use of '@'
Much like empty and isset do. You can pass in a variable you just made u... |
I'm pretty sure the answer to this question is no, but in case there's some PHP guru
is it possible to write a function in a way where invalid arguments or non existent variables can be passed in and php will not error without the use of '@'
Much like empty and isset do. You can pass in a variable you just made u... |
I'm pretty sure the answer to this question is no, but in case there's some PHP guru
is it possible to write a function in a way where invalid arguments or non existent variables can be passed in and php will not error without the use of '@'
Much like empty and isset do. You can pass in a variable you just made u... |
> Or is it initialized when doSomething() is first called?
Yes, it is. This, among other things, lets you initialize globally-accessed data structures when it is appropriate, for example inside try/catch blocks. E.g. instead of
int foo = init(); // bad if init() throws something
int main() {
try {
...
... |
There are multiple ways of doing it, though some will only work in certain browsers. One that I know off the top of my head is to embed a tiny near-invisible iframe on the page. When the user hits the back button the iframe is navigated back which you can detect and then update your page. [Here][1] is another soluti... |
Why not use a compression library that supports password-protected files? I've used a password-protected zip file containing XML content in the past :} |
The suggestions for abstraction of an engine are good, assuming that you know what you are doing. It's difficult to write a good abstraction layer for graphics without having done it already.
I would suggest that you just pick one. You will pick up the concepts from either easily enough -- enough so that you can p... |
I'm afraid I can't tell you why you're not getting an exception, but I can postulate as to why it chose CATEGORIES' version of the column over PARTS' version.
> As far as I understood, in the case of left joins, the "main" table in the query (PARTS) has precedence in ambiguity
It's not clear whether by "main" you... |
Coding Dojo with IE and SSL |
|javascript|ssl|internet-explorer|dojo| |
My application is using Dojo 1.1.1 on an SSL-only website. It is currently taking advantage of dijit.ProgressBar and a dijit.form.DateTextBox.
Everything works fabulous in Firefox 2&3, but as soon as I try the same scripts in IE7 the results are an annoying Security Information dialog:
> This page contains bo... |
Recover corrupt zip or gzip files? |
|zip|recovery|gzip|corrupt| |
The most common method for corrupting compressed files is to inadvertently do an ASCII-mode FTP transfer, which causes a many-to-one trashing of CR and/or LF characters.
Obviously, there is information loss, and the best way to fix this problem is to transfer again, in FTP binary mode.
However, if the original is... |
The type of collection to use in your mapping depends on how you want to represent the collection in code. The settings map like so:
- The `<list>` maps directly to an
IList.
- The `<map>` maps directly to an IDictionary.
- The `<bag>` maps to an IList. A <bag> does not completely comply
with the... |
Store the libraries! The repository should be a snapshot of what is required to build a project at any moment in time. As the project requires different version of external libraries you will want to update / check in the newer versions of these libraries. That way you will be able to get all the right version to go w... |
Solution:
public ActionResult TestAction(string paramName)
{
if (!String.IsNullOrEmpty(Request["paramName"]))
{
return RedirectToAction("TestAction", new { paramName = paramName});
}
/* ... */
} |
Solution:
public ActionResult TestAction(string paramName)
{
if (!String.IsNullOrEmpty(Request["paramName"]))
{
return RedirectToAction("TestAction", new { paramName = Request["paramName"]});
}
/* ... */
} |
ASP.NET MVC Preview 4 - Stop Url.RouteUrl() etc. using existing parameters |
|c#|asp.net-mvc|forms|routes| |
I have an action like this:
/* Inside TestController, route to this action is 'test-route' */
public ActionResult TestAction(String param)
{
/* ... */
}
The URL that leads to this action looks like this:
TestController.mvc/TestAction/param
In the view this action redirects to... |
** Rewritten for clarity **
I have an action like this:
public class News : System.Web.Mvc.Controller
{
public ActionResult Archive(int year)
{
/* ... */
}
}
With a route like this:
routes.MapRoute(
"News-Archive", ... |
There is a script you can use that will [create an automatic TOC for your wiki][1] page though and this will probably solve your problem.
[1]: http://support.fogcreek.com/default.asp?fogbugz.4.27712.2 |
Limiting CPU speed for profiling |
|c++|profiling|cpu| |
I'm trying to optimize several bottlenecks on an application which is supposed to run on a really wide range of CPUs and architectures (some of them very close to embeded devices).
The results of my profiler, however, aren't really significant because of the speed of my CPU. Is there any way (preferably under Window... |
I think you are looking for xbuild:
http://www.mono-project.com/Microsoft.Build
|
I found a workaround. I thought I'd let the next person with this problem know about.
Basically. Instead of setting the inputVerifier on the ComboBox you set it to it's "Editor Component".
JComboBox combo = new JComboBox();
JTextField tf = (JTextField)(combo.getEditor().getEditorComponent());
tf.s... |
You should probably throw ArgumentException, as that is what the base library classes do. |
Why do I get this error "[DBNETLIB][ConnectionRead (recv()).]General network error" with ASP pages |
|networking|classicasp| |
Occasionally, on a ASP (classic) site users will get this error:
[DBNETLIB][ConnectionRead (recv()).]General network error.
Seems to be random and not connected to any particular page. The SQL server is seperate from the web server and my guess is that every once and a while the "link" goes down between the tw... |
|networking|asp-classic| |
Do you know which version of MS Office you are targeting? These PIAs are very specific to the version of Office. I remember when we were building a smart client application, we used to have Build VM machines, each one targeting a specific version of Outlook.
Another hurdle was not being able to specify these PIAs as... |
Well, if you really want an collection with unique items, you might want to take a look at the [HashSet object][1] (available in C# 3.0).
Otherwise, there are two approaches that you can take:
- Create a custom exception for your operation, just as you had stated
- Implement an Add() method that returns a bo... |
I was also wondering how to do this, when I found grom's answer. Thanks for the code.
I struggled with understanding how the code was supposed to be used. (I don't use a version control system.) In summary, you include the timestamp (ts) when you call the stylesheet. You're not planning on changing the styleshee... |
- Use and enforce a common coding style and guidelines. *Rationale:* Every developer on the team or in the firm is able to read the code without distractions that may occur due to different brace styles or similar.
- Regularly do a full rebuild of your entire source base (i.e. do daily builds or builds after each ... |
According to [this page](http://www.ackadia.com/web-design/character-code/character-code-symbols.php), that symbol doesn't show in IE6 at all.
Symbol Character Numeric Description
β ⇓ ⇓ Down double arrow - - * Doesn't show with MS IE6
If you really need that particular symbol, you m... |
According to [this page](http://www.ackadia.com/web-design/character-code/character-code-symbols.php), that symbol doesn't show in IE6 at all.
Symbol Character Numeric Description
β ⇓ ⇓ Down double arrow - - * Doesn't show with MS IE6
If you really need that particular symbol, you... |
Yes, it is possible... But you'll need to explicitly tell IE which font to find it in. For instance:
<span style="font-family:Arial Unicode MS"> ⇓ </span>
should produce <span style="font-family:Arial Unicode MS"> ⇓ </span> in most browsers.
|
The MVC pattern is really only concerned with UI and nothing else. You shouldn't put any complex business logic in the controller as it controls the view but not the logic. The Controller should concern itself with selecting the proper view and delegate more complex stuff to the domain model (Model) or the business lay... |
So, if CAPTCHA's on the way out, what comes next? |
|captcha| |
With text-recognition improving and CAPTCHA-breakers using Mechanical Turks to break otherwise unbreakable keys, what's the next technology to keep scripts from spam-botting a site that relies on user input? |
Use the [System.Environment][1] class. It has a property for retrieving the machine name, which is retrieved from the NetBios. Unless I am misunderstanding your question.
[1]: http://msdn.microsoft.com/en-us/library/system.environment.aspx |
Lots of options here.
For a pure JS solution, have your page submit to itself, but with additional URL parameter (mypage.html?postback=true) - you can then get the page url with window.location.href, and parse that using a split or regex to look for your variable.
The much easier one, assuming you sending back to... |
I am a fan of limiting logins by using a credit card or cell phone SMS (like Craigslist and Gmail). These methods don't cost much (<$1), but can be highly effective in keeping spam accounts under control.
However, this is tricky on a site like SO because one of the founding goals is to have minimum friction and a... |
If it's an active code base, you might still want to upgrade the code base. Of course, performing the changes manually isn't feasible but I believe that this problem could be solved once and for all by one single `sed` command. I haven't tried it, though, so take the following with a grain of salt.
find . -exec ... |
I always used Select Case statements to short circuit logic in VB. Something like..
Select Case True
Case isNull(Rs("myField"))
myField = 0
Case (myField <> 0)
myField = -1
Case Else
myField = Rs("myField")
End Select
... |
I always used Select Case statements to short circuit logic in VB. Something like..
Select Case True
Case isNull(Rs("myField"))
myField = 0
Case (Rs("myField") <> 0)
myField = Rs("myField")
Case Else
myField = -1
End S... |