instruction stringlengths 0 30k ⌀ |
|---|
It sounds like you're getting z-fighting.
"Z-fighting is a phenomenon in 3D rendering that occurs when two or more primitives have similar values in the z-buffer, and is particularly prevalent with coplanar polygons. The effect causes pseudo-random pixels to be rendered with the color of one polygon or another in a ... |
Now that i think about it, as noted in my last edit, you want to drop the javascript: in the on client click property. It's not needed, because the onclick event is javascript as it is. try that, see if that works. |
Byte level length description |
|c|protocol| |
|c|protocols| |
I have a protocol that requires a length field up to 32-bits, and it must be
generated at runtime to describe how many bytes are in a given packet.
The code below is kind of ugly but I am wondering if this can be refactored to
be slightly more efficient or easily understandable. The problem is that the
code will... |
Are you handling the PageLoad event? If so, try the following
if (!isPostBack)
{
//do something
}
else if (Request.Form["__EVENTTARGET"].ToLower().IndexOf("myevent") >= 0)
{
//call appropriate function.
}
Check if you are getting a call this way, if so then maybe the... |
A data access layer is used to abstract away the storage and retrieval of data from its representation. You can read more about this kind of abstraction in 1994's [Design Patterns](http://www.amazon.com/Design-Patterns-Object-Oriented-Addison-Wesley-Professional/dp/0201633612/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=122125... |
The purpose is to abstract the data storage retrieval mechanism from data usage and manipulation.
Benefits:
- Underlying storage can change (switch from Oracle to MSSQL for example), and you need a way to localize those changes
- Schema changes - see above
- You want a way to run disconnected from your db... |
Are Stored Procedures more efficient, in general, than inline statements on modern RDBMS's? |
|sql|stored-procedures|db| |
Conventional wisdom states that stored procedures are always faster. So, since they're always faster, use them **ALL THE TIME**.
I am pretty sure this is grounded in some historical context where this was once the case. Now, I'm not advocating that Stored Procs are not needed, but I want to know in what cases stored... |
|sql|stored-procedures|db| |
|sql|database|stored-procedures| |
There is no speed difference for stored procedures vs parameterized or prepared queries on most modern databases, because the database will also cache execution plans for those queries.
Note that a parameterized query is not the same as ad hoc sql.
The main reason imo to still favor stored procedures today has ... |
There is no noticeable speed difference for stored procedures vs parameterized or prepared queries on most modern databases, because the database will also cache execution plans for those queries.
Note that a parameterized query is not the same as ad hoc sql.
The main reason imo to still favor stored procedures... |
or even shorter: [ -d / ] && echo "Yes" |
Since it sounds like you are doing a live presentation, where you will be working with real systems and not just charts (PPT, Impress, whatever) make sure it is all working just before you start. It never fails, if I don't try it just before I start talking, it doesn't work how I expected it to. Especially with demos... |
Another C++ one. Optimized for speed (no extra string is made, no superfluous comparisons are made) and size.
<code><pre>bool is_palindrome(const std::string& candidate) {
for(std::string::const_iterator left = candidate.begin(), right = candidate.end(); left < right ; ++left, ++right)
if (*left != *ri... |
Another C++ one. Optimized for speed and size.
<code><pre>bool is_palindrome(const std::string& candidate) {
for(std::string::const_iterator left = candidate.begin(), right = candidate.end(); left < right ; ++left, --right)
if (*left != *right)
return false;
return true;
}</pre></cod... |
Another C++ one. Optimized for speed and size.
<code><pre>bool is_palindrome(const std::string& candidate) {
for(std::string::const_iterator left = candidate.begin(), right = candidate.end(); left < --right ; ++left)
if (*left != *right)
return false;
return true;
}</pre></code> |
Have you tried logging into Linux as your installed Oracle user then
sqlplus "/ as sysdba"
When you log in you'll be able to change your password.
alter user sys identified by <new password>;
Good luck :) |
@iAn and @mats:
I would not "tear down" anything in finally {} that was "set up" within the try {} as a rule. Would be better to pull the stream creation outside of the try {}. If you need to handle an exception on stream create this could be done in a greater scope.
StreamReader stream = new StreamReade... |
You can use Prototype's `addClassName` and `removeClassName` methods.
Create a CSS class "hilight" that you'll apply to the hilighted `<tr>`'s. Then run this code on page load:
var rows = $$('tbody tr');
for (var i = 0; i < rows.length; i++) {
rows[i].onmouseover = function() { $(this).addC... |
[HermesJMS](http://hermesjms.com) seems to be a rather powerful client for interacting with JMS providers. In my opinion, it is pretty unintuitive and hard to set up, though. (At least I'm mostly failing at it...)
Other, more user-friendly clients are often vendor-specific. [Sonic Message Manager](http://queuemanage... |
<table id="mytable">
<tbody>
<tr><td>Foo</td><td>Bar</td></tr>
<tr><td>Bork</td><td>Bork</td></tr>
</tbody>
</table>
<script type="text/javascript">
$$('#mytable tr').each(function(item) {
item.observe('mouseover', function() {
... |
Functions are objects and therefore can have properties.
<pre>
fn = function(x) {
// ...
}
fn.foo = 1;
fn.next = function(y) {
//
}
</pre>
|
How do you resolve .Net namespace conflicts with the 'using' keyword ? |
|.net|namespaces|using| |
Here's the problem, you include multiple assemblies and add 'using namespaceX' at the top of your code file.
Now you want to create a class or use a symbol which is defined in multiple namespaces,
e.g. `System.Windows.Controls.Image` & `System.Drawing.Image`
Now unless you use the fully qualified name, there wi... |
This page has a very good writeup on namespaces and the using-statement:
<http://www.blackwasp.co.uk/Namespaces.aspx>
You want to read the part about "Creating Aliases" that will allow you to make an alias for one or both of the name spaces and reference them with that like this:
using ControlImage = Syste... |
There is a communication aspect to asserts vs exception throwing.
Let's say we have a User class with a Name property and a ToString method.
If ToString is implemented like this:
public string ToString()
{
Debug.Assert(Name != null);
return Name;
}
It says that Name should ... |
There's the [Yahoo Grid CSS][1] which can do all sorts of things. But remember: **CSS IS NOT A RELIGION**. If you save hours by using tables instead of css, do so.
One of the corner cases I could never make my mind up about is forms. I'd love to do it in css, but it's just so much more complicated than tables. You ... |
Use alias
using System.Windows.Controls;
using Drawing = System.Drawing;
...
Image img = ... //System.Windows.Controls.Image
Drawing.Image img2 = ... //System.Drawing.Image
|
|unrelated|answer| |
|regex| |
Let's say I want to represent `\q` (or any other particular "backslash-escaped character"). That is, I want to match `\q` but not `\\q`, since the latter is a backslash-escaped backslash followed by a `q`. Yet `\\\q` would match, since it's a backslash-escaped backslash followed by a backslash-escaped `q`. (Well, it... |
Martin Fowler described this pattern in Patterns of Enterprise Application Architecture together with two other patterns or architectures. These patterns are good for different situations and different amounts of complexity.
If you want to so only simple stuff you can use Transaction Script. This is an architecture ... |
If you are positive you've got the latest version in your directory, then do this:
1. Delete the item from the repository
2. Delete the SVN references from your copy
3. Check your code in as a new copy.
4. Check out the code you just checked in
|
[Now You Have Two Problems](http://www.codinghorror.com/blog/archives/001016.html).
Just write a simple parser. If the regex ties your head up in knots now, just wait a month. |
extern "C" is how you remove decoration - it should work to use:
extern "C" declspec(dllimport) char MyNewVariable;
or
extern "C" {
declspec(dllimport) char MyNewVariable;
} |
extern "C" is how you remove decoration - it should work to use:
extern "C" declspec(dllimport) char MyNewVariable;
or
extern "C" {
declspec(dllimport) char MyNewVariable;
}
And of course, link with the import library generated by the dll doing the export. |
extern "C" is how you remove decoration - it should work to use:
extern "C" declspec(dllimport) char MyNewVariable;
or if you want a header that can be used by C++ or C (with /TC switch)
#ifdef __cplusplus
extern "C" {
#endif
declspec(dllimport) char MyNewVariable;
#ifdef __cplusplus
... |
Do you actively manage technical debt? |
|project-management|technical-debt| |
Do you actively manage [technical debt][1] debt on your software development projects and if so, how do you do it?
[1]: http://forums.construx.com/blogs/stevemcc/archive/2007/11/01/technical-debt-2.aspx |
See this [assignment][1] from the University of Washington CSE department.
Basically, you have a data structure that just has the counts of each letter in a word (an array works for ascii, upgrade to a map if you want unicode support). You can subtract two of these letter sets; if a count is negative, you know one w... |
You can use **Path.GetTempPath()** to find out which directory to which it's trying to write. |
Change it to
appserver.home="C:\\Program Files\\Apache Software Foundation\\Tomcat 6.0" |
On our teams we actively manage technical debt. We do Scrum, so we spawn a technical debt card for either the current iteration or the next iteration depending on the estimate and our remaining sprint capacity and they get prioritized just like features and bug cards do. We also manage larger, cross-team debt items b... |
Could be because [IIS_WPG][1] does not have access to a temp folder. If you think it is a permission issue, run a [Procmon][2] on asp.net worker process and check for AccessDenied errors on the server.
[1]: http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/3648346f-e4f5-474b-86c7-5a86e85... |
Could be because [IIS_WPG][1] does not have access to a temp folder. If you think it is a permission issue, run a [Procmon][2] on asp.net worker process and check for AccessDenied errors.
[1]: http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/3648346f-e4f5-474b-86c7-5a86e85fa1ff.mspx?mfr... |
what do you expect from "Enabled = 'false'" ?
|
Path.GetTempFileName -- Directory name is invalid |
|c#|asp.net| |
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. This folder exists so I'm assuming this must be a permi... |
Use alias
using System.Windows.Controls;
using Drawing = System.Drawing;
...
Image img = ... //System.Windows.Controls.Image
Drawing.Image img2 = ... //System.Drawing.Image
[How to: Use the Namespace Alias Qualifier (C#)][1]
[1]: http://msdn.microsoft.com/en-us/library/c3a... |
Expanding a bit on what Jason W said:
<pre>
I find it easier however (and this works in PHP4) to either just call the
function outside of the string:
<?
echo "foo " . somefunc("bar") . " baz";
?>
</pre>
You can also just embed this function call directly in your html, like:
<pre><?
function ge... |
It doesn't get more simple that using pipes, which are supported on every OS I know of, and can be accessed in pretty much every language.
Check out [this][1] tutorial.
[1]: http://www.utdallas.edu/~kcooper/teaching/3375/Tutorial6a/tutorial6.htm |
It doesn't get more simple than using pipes, which are supported on every OS I know of, and can be accessed in pretty much every language.
Check out [this][1] tutorial.
[1]: http://www.utdallas.edu/~kcooper/teaching/3375/Tutorial6a/tutorial6.htm |
Google's style guide, mentioned in one of these answers, is pretty solid. There's some pointless stuff in it, but it's more good than bad.
Sutter and Alexandrescu wrote a decent book on this subject, called *C++ Coding Standards*.
Here's some general tips from lil' ole me:
1. Your indentation and bracketing s... |
[Mozilla Prism][1] seems ideal for your purposes.
It shares code with Firefox but is designed to run web applications without the usual Browser interface to make them appear more like desktop applications. So no back button or address bar to worry about.
[1]: http://developer.mozilla.org/en/Prism |
[Mozilla Prism][1] seems ideal for your purposes.
It shares code with Firefox but is designed to run web applications without the usual Browser interface to make them appear more like desktop applications. So no back button or address bar to worry about.
**Edit:** [Google Chrome][2] has [Application Shortcuts][3... |
If you install TFS 2008 PowerTools you will get a "Find in Source Control" action in the Team Explorer right click menu.
[TFS2008 Power Tools][1]
[1]: http://www.microsoft.com/downloads/details.aspx?FamilyID=00803636-1D16-4DF1-8A3D-EF1AD4F4BBAB&displaylang=en "TFS2008 Power Tools" |
Have you tried, instead:
static T TestException<Exception>(string message)
{}
because I have a feeling that putting in the generic constraint is not necessary as all throwable exceptions *must* inherit from System.Exception anyway.
Remember that generics do accept inherited types. |
I think seeing as all exceptions should have a parameterless constructor, and have the `Message` property, so the following should work:
static ExType TestException<ExType>(string message) where ExType:Exception
{
ExType ex = new ExType();
ex.Message = message;
return ex;
}
... |
Working with Common/Utility Libraries |
|c#|visual-studio|api| |
At the company I work for we have a "Utility" project that is referenced by pretty much ever application we build. It's got lots of things like NullHelpers, ConfigSettingHelpers, Common ExtensionMethods etc.
The way we work is that when we want to make a new project, we get the latest version of the project from sou... |
How do I execute PHP that is stored in a MySQL database? |
You can [download .NET source code][1] and set break point right in .NET FW source code.
You can use [NetMassDownloader][2] to grab .NET sources quickly.
[1]: http://www.wintellect.com/cs/blogs/jrobbins/archive/2008/01/17/additional-net-framework-source-code-debugging-tricks.aspx
[2]: http://www.codeplex.c... |
According to this article you can download the source code for the .NET framework and then debug it using visual studio:
[http://weblogs.asp.net/scottgu/archive/2007/10/03/releasing-the-source-code][1]
[1]: http://weblogs.asp.net/scottgu/archive/2007/10/03/releasing-the-source-code-for-the-net-framework-libra... |
I use this class when the problem at hand doesn't justify profiling all my code or I get some data from a profiler that I want to verify. What it basically does is sum up the time you spent in a specific block and at the end of the program outputs it to the debug stream (viewable with [DbgView](http://technet.microsoft... |
I believe OS X now has appropriate hooks/callbacks because they were needed for Spotlight indexing.
On linux you'll have the additional trouble that there are multiple file systems commonly used. If you need the functionality for only a limited amount of files/directories, I'd try about actively looking for modific... |
I don't have a copy of VB6 to hand, but I think you need the
Typename()
function... I can see it in Excel VBA, so it's probably in the same runtime. Interestingly, the help seems to suggest that it shouldn't work for a user-defined type, but that's about the only way I ever *do* use it.
Excerpt from the h... |
You can do something to each row, like so:
$('tableId').getElementsBySelector('tr').each(function (row) {
...
});
So, in the body of that function, you have access to each row, one at a time, in the 'row' variable. You can then call Event.observe(row, ...)
So, something like this might work:
... |
I would say boolean logic. AND, OR, XOR, NOT.
I found as programmer we use this more often than the rest of math concepts. |
Miguel had a post about debugging Mono running on linux with remote debugging on Visual Studio. This may be something you want to look into... [Using Visual Studio to debug Mono][1]
[1]: http://tirania.org/blog/archive/2008/Sep-04.html |
Miguel had a post about debugging Mono running on linux with remote debugging on Visual Studio. This may be something you want to look into... [Using Visual Studio to debug Mono][1]. There is also a new project called [CloverLeaf][2] whose goal is enabling debugging Mono on Windows in Visual Studio.
[1]: http... |
Option 3 sounds the simplest and I would have thought Excel is as if not more efficient than Access for storing the data. The trouble with two files is getting the links between them to work even in a different location. |
There is a Win32 API for this you could P/Invoke: [IsUserAnAdmin][1]
The question is more complex on Vista ... see this [blog post][2].
[1]: http://msdn.microsoft.com/en-us/library/bb776463(VS.85).aspx
[2]: http://blogs.msdn.com/cjacks/archive/2006/10/09/How-to-Determine-if-a-User-is-a-Member-of-the-Admini... |
For a little more complete solution try Raxco's PerfectDisk. While it is a commercial product it does a very good job and supports boot time defrag of system files. The first defrag takes longer than say DiskKeeper but its a single pass defragger and supports defragging with very little free space left on the drive. Ov... |
How to check if a given user is a member of the built-in Administrators group? |
|security| |
I believe this is a bug in the Oracle ODBC driver. Basically, the Oracle ODBC driver does not support the `TIMESTAMP WITH (LOCAL) TIME ZONE` data types, only the `TIMESTAMP` data type. As you have discovered, one workaround is in fact to use the `TO_CHAR` method.
In your example you are not actually reading the time... |
Last time I checked, you could use the [module builder][1] to extend the interface. From 5.0 (or maybe 4.x) on, Sugar added all those APIs which should enable you to extend SugarCRM without hacking it in and loosing it with the next upgrade.
Hope that helps!
[1]: http://developers.sugarcrm.com/tutorials/Customi... |
Take a look at [this article on MSDN][1] about "inductive user interfaces". It describes a framework (and provides the code to download) based on UserControls that give you "navigation" within a form. Perfect for designing wizards.
[1]: http://msdn.microsoft.com/en-us/library/ms951103.aspx |
Do you know how to implement transactions in Castle ActiveRecord? |
|activerecord|castle| |
I decided to make a system for a client using [Castle ActiveRecord][1], everything went well until I found that the transactions do not work, for instance;
TransactionScope t = new TransactionScope();
try
{
member.Save();
... |
# Haskell : Functional - Tail Recursive
factorial n = factorial' n 1
factorial' 0 a = a
factorial' n a = factorial' (n-1) (n*a)
|
Take a look at Microsoft SQL Server Compact Edition. I believe you can work with MDF files without having to run a server. All code runs in process. I beleieve it has some limitations but it may work for you and I think it's free. |
Well, I have 2 code snippets. In pseudo code they are looking like (it's a simplified version, I'm using QueryPerformanceFrequency actually)
1st snippet:
Timer timer = new Timer
timer.Start
2nd snippet:
timer.Stop
show elapsed time
A bit of hot-keys kung fu and I can say how muc... |
This article has lots of information about C++ code profiling and also has a free download link to a program/class that will show you a graphic presentation for different code paths/methods:
<http://www.codeproject.com/KB/cpp/profiler.aspx>
|
I almost forgot to mention [Deblector][1] - it's a Reflector plugin, that allows you to debug almost any .net app without source codes :)
[1]: http://www.codeplex.com/deblector |
I would just use the table.
In my experience, using a table for layout will work the same in all browsers and the CSS will not (especially if you're trying to support IE6). It's just not worth the hours and hours of coding to get a layout to work in CSS when it can be done in 10 minutes using a table.
The othe... |
To overcome the issues mentioned with traceroute (ICMP-based, wide area hit) you could consider:
1. traceroute to your public IP (avoids wide-area hit, but still ICMP)
2. Use a non-ICMP utility like ifconfig/ipconfig (portability issues with this though).
3. What seems the best and most portable solution for now i... |
Linux users can use [inotify][1]
> inotify is a Linux kernel subsystem
> that provides file system event
> notification.
[1]: http://en.wikipedia.org/wiki/Inotify |
Linux users can use [inotify][1]
> inotify is a Linux kernel subsystem
> that provides file system event
> notification.
Some goodies for Windows fellows:
- [File Change Notification][2] on MSDN
- "[When Folders Change][3]" article
- [File System Notification on Change][4]
[1]: http://en.wikip... |
Inlining larger functions can make the program larger, resulting in more cache misses and making it slower.
Deciding when a function is small enough that inlining will increase performance is quite tricky. [Google's C++ Style Guide](http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Inline_Functions) rec... |