instruction stringlengths 0 30k ⌀ |
|---|
What's your opinion on using UUIDs as database row identifiers, particularly in web apps? |
|uuid|database|web-applications| |
I've always preferred to use long integers as primary keys in databases, for simplicity and (assumed) speed. But when using a [REST][1] or Rails-like URL scheme for object instances, I'd then end up with URLs like this:
http://example.com/user/783
And then the assumption is that there are also users with IDs ... |
I've always preferred to use long integers as primary keys in databases, for simplicity and (assumed) speed. But when using a [REST][1] or Rails-like URL scheme for object instances, I'd then end up with URLs like this:
http://example.com/user/783
And then the assumption is that there are also users with IDs ... |
It depends on whether the code will only be read by a compiler or also by a human. In addition, it matters whether the code is supposed to be super-fast or whether readability is important. When in doubt, put in the extra effort to generate readable code. |
Structs are implemented as value types and classes are reference types. If you have a variable of type Foo, and you store an instance of Fubar in it, it will "Box it" up into a reference type, thus defeating the advantage of using a struct in the first place.
The only reason I see to use a struct instead of a class... |
With some heavy pair programming a colleague of mine and I came up with this, feel free to refactor:
private void copyToolStripMenuItem_Click_1(object sender, EventArgs e)
{
Form f = this.ActiveMdiChild;
// Find the control that has focus
Control focusedContr... |
With some heavy pair programming a colleague of mine and I came up with this, feel free to refactor:
/// <summary>
/// Recursively traverse a tree of controls to find the control that has focus, if any
/// </summary>
/// <param name="c">The control to search, might be a control con... |
|javascript|css|performance| |
I am trying to improve the performance of a web application. I have metrics that I can use to optimise the time taken to return the main HTML page, but I'm concerned about the external CSS and Javascript files that are included from these HTML pages. These are served statically, with HTTP Expires headers, but are sha... |
I believe [YSlow](http://developer.yahoo.com/yslow/) does, but be aware that unless all requests are over a loopback connection you shouldn't worry. The HTTP overhead of split-up files will impact performance *far* more than parsing, unless your CSS/JS files exceed several megabytes. |
Thanks everyone for your answers!
There are some discussions regarding this on dotnetnuke.com forums, but I had the wrong date criteria in my search so the reason I didn't see any responses previously and thought I would ask here.
I think I found what I am looking for from a dotnetnuke perspective its a module th... |
My company uses WordPress and MediaWiki internally and we use HTTP_AUTH access control to create a "single sign on". As we add more applications, we simply integrate them into the HTTP_AUTH system where practical. For security, you can run HTTP_AUTH over SSL. The basic steps are:
Configure the .htaccess to specif... |
Some of the more advanced java bytecode obfuscators do much more than just class name mangling. [Zelix KlassMaster](http://www.zelix.com/), for example can also scramble your code flow in a way that makes it really hard to follow and works as an excellent code optimizer...
Also many of the obfuscators are also ab... |
Some of the more advanced java bytecode obfuscators do much more than just class name mangling. [Zelix KlassMaster](http://www.zelix.com/), for example can also scramble your code flow in a way that makes it really hard to follow and works as an excellent code optimizer...
Also many of the obfuscators are also able... |
You'll need a GSM library. There appear to be a few of these.
e.g. http://www.wirelessdevstudio.com/eng/
|
Is Bouncy Castle API Thread Safe ? |
|java|cryptography|bouncycastle| |
Is Bouncy Castle API (http://bouncycastle.org/java.html) Thread Safe ? Especially,
org.bouncycastle.crypto.paddings.PaddedBufferedBlockCipher
org.bouncycastle.crypto.paddings.PKCS7Padding
org.bouncycastle.crypto.engines.AESFastEngine
org.bouncycastle.crypto.modes.CBCBlockCipher
I am planning to write a singlet... |
setOpaque(false)
It'll pass off painting the background to its parent, which may draw its own background.
You can do a screen capture and then use that to paint the background of the panel.
|
ctrl-shift-r and its buddy, ctrl-shift-t, to open a resource or type, respectively. Resources includes all files in your open projects (including non-java files), and types includes java types either in your projects, or in a library included in the projects. |
As a ASP.NET programmer, do I need to be concern about email injection attacks ? |
|asp.net|security|email| |
There are lots of PHP articles about the subject so is this a PHP only problem. |
|security|email|asp.net| |
There are lots of PHP articles about the subject so is this a PHP only problem.
I am sending emails using System.Net.Mail after some regular expression checks of course.
Similar to http://weblogs.asp.net/scottgu/archive/2005/12/10/432854.aspx |
As a ASP.NET programmer, do I need to be concerned about email injection attacks ? |
|asp.net|security|email| |
This seems like a huge, vague question...
But I will throw in Reflection, as it has allowed me to do some incredibly powerful things like pluggable DALs and such. |
HttpModules. The architecture is crazy elegant. Maybe not a hidden feature, but cool none the less. |
This article seems to have some handy info on how to create shaped and transparent windows in Java:
[http://today.java.net/pub/a/today/2008/03/18/translucent-and-shaped-swing-windows.html][1]
[1]: http://today.java.net/pub/a/today/2008/03/18/translucent-and-shaped-swing-windows.html |
[@peacedog][0]:
Correct; Alison's method is perfectly acceptable.
The trick with the database roundtrips: they are not free, obviously, but web servers tend to be very "close" (fast, low-latency connection) to the database, while your users are probably "far" (slow, high-latency connection).
Because of that,... |
Not an answer, but just some more info for you.
We are running 3.4.5 20051201 (Red Hat 3.4.5-2) at my day job.
We have also noticed some of our code (which I can't post here) stops working when
we add the -O1 flag. Our solution was to remove the flag for now :(
|
With the aid of some heavy pair programming a colleague of mine and I came up with this, feel free to refactor.
The code is placed in the main form. The copyToolStripMenuItem_Click method handles the Click event on the Copy menu item in the Edit menu.
/// <summary>
/// Recursively traverse a tree... |
That's a really good question.
I think it's nuanced but definitely answerable:
Macros are not stuck in s-expressions. See the LOOP macro for a very complex language written using keywords (symbols). So, while you may start and end the loop with parentheses, inside it has its own syntax.
Example:
(loop... |
If you can find an old "dumb" hub, you can run the node NIC's through it, or if your switch is managable you can set the ports up so that they do not remember the MAC address to IP address mappings.
I will say that I have had horrible experience with WLBS (the 2003+ version of NLB) in regards to port flooding. We h... |
I hate to give you the answer you probably already know, but yeah this is a video card driver software thing and if the ATI software crashes then it's either corrupted or buggy or your Windows install has gone rotten.
I've done this before on my NVidia-based cards without issue. I've never owned an ATI card. |
I asked a [similar question][1] and got a better answer, the problem is related to C#'s support for covariance and contravariance. See that discussion for a little more information.
[1]: http://stackoverflow.com/questions/46933/why-doesnt-inheritance-work-the-way-i-think-it-should-work |
> Custom (hand-written) storage engine / Potentially very high performance in required uses cases
<http://hdf.ncsa.uiuc.edu/>
If you have enormous data sets, instead of rolling your own, you might use HDF, the Hierarchical Data Format.
<http://en.wikipedia.org/wiki/Hierarchical_Data_Format>:
> HDF supports... |
I know this is going to sound negative, but don't do it! :-)
The idea behind the setup method is that it executes something required by *every* test, which means that it doesn't matter which test is being executed, so you don't need to know the name of the method.
If you are after different data used in initialis... |
IRotate: <http://www.entechtaiwan.net/util/irotate.shtm>.
Have not used it but heard good things.
Same people that make Powerstrip <http://www.entechtaiwan.net/util/ps.shtm>.
Which gets rave reviews from the HTPC crowd.
Was looking at these recently while researching stuff for an HTPC.
Both are try ... |
As long as it's a hash function, be it String.hashCode(), MD5 or SHA1, collision is unavoidable unless you have a fixed limit on the string's length. It is mathematically impossible to have one-to-one mapping from an infinite group to a finite group.
Stepping back, is collision avoidance *absolutely* necessary? |
Iterating - @ScArcher2 has asnwered that perfectly.
Order of iteration - if you are just using `Map`, then stritly speaking, there are **no ordering gauruntees**. However, the [`SortedMap`][1] interface extends `Map` and provides exactly this.
[1]: http://java.sun.com/javase/6/docs/api/java/util/SortedMap.ht... |
This is a two part question:
*How to iterate over the entries of a Map* - @ScArcher2 has asnwered that perfectly.
*What is the order of iteration* - if you are just using `Map`, then strictly speaking, there are **no ordering guarantees**. So you shouldn't really rely on the ordering given by any implementation.... |
Is it possible that we are in a panic and are getting confused between unit tests and performance tests? Is it that your application works fine with few users, but starts throwing errors when under heavier load? If so, unit tests are not the answer. Unit tests != Load tests.
If unit tests are in fact the answer, ... |
split is the first thing that comes to mind, but that returns an array, not a List<int>;
you could try something like:
<pre><code>
List<int> intList = new List<int>;
foreach (string tempString in ids.split(',')
{
intList.add (convert.int32(tempString));
}
|
split is the first thing that comes to mind, but that returns an array, not a List<int>;
you could try something like:
<pre><code>
List<int> intList = new List<int>;
foreach (string tempString in ids.split(',')
{
intList.add (convert.int32(tempString));
}
</code></pre> |
If you do go with Attributes, I'm fairly certain you'll have to [roll your own logic][1] to deduce what they mean and what to do about them. Whatever is using your custom class objects will have to have a way of performing these attribute actions/checks, preferably at instantiation.
Otherwise, you're looking at usi... |
VS2005 C# Programmatically change connection string contained in app.config |
|c#|windowsapplication| |
Would like to programmically change the connecton string for a database which utilizes the membership provider of asp.net within a windows application. The system.configuration namespace allows changes to the user settings, however, we would like to adjust a application setting? Does one need to write a class with util... |
|c#|.net|winforms| |
|c#|.net|winforms|configuration| |
Would like to programmically change the connecton string for a database which utilizes the membership provider of asp.net within a windows application. The system.configuration namespace allows changes to the user settings, however, we would like to adjust a application setting? Does one need to write a class with util... |
|database|web-applications|uuid| |
I've always preferred to use long integers as primary keys in databases, for simplicity and (assumed) speed. But when using a [REST][1] or Rails-like URL scheme for object instances, I'd then end up with URLs like this:
http://example.com/user/783
And then the assumption is that there are also users with IDs ... |
I use this to parse strings, not sure if it helps here; but with some minor modifications perhaps?
function getstringbetween($string, $start, $end){
$string = " ".$string;
$ini = strpos($string,$start);
if ($ini == 0) return "";
$ini += strlen($start);
$len = strpo... |
Take a look at the CHECKSUM command:
SELECT CHECKSUM_AGG(BINARY_CHECKSUM(*)) FROM sample_table WITH (NOLOCK);
That will return the same number each time it's run as long as the table contents haven't changed. See my post on this for more information:
[http://msdn.microsoft.com/en-us/library/aa258245(SQL.80).as... |
Take a look at the CHECKSUM command:
SELECT CHECKSUM_AGG(BINARY_CHECKSUM(*)) FROM sample_table WITH (NOLOCK);
That will return the same number each time it's run as long as the table contents haven't changed. See my post on this for more information:
[http://msdn.microsoft.com/en-us/library/aa258245(SQL.80).as... |
First, are you sure that NetCDF is the right choice? If you want to interact with other programs that need to read in large amounts of data and they already support NetCDF, then it's probably a great choice. There aren't that many standard and well-supported file formats that support large multidimensional arrays. B... |
I think the new preferred way might be to use IDataErrorInfo
Read more [here][1]
[1]: http://blogs.msdn.com/wpfsdk/archive/2007/10/02/data-validation-in-3-5.aspx |
Easy way to create a form to email in SharePoint without using infopath. |
|sharepoint| |
Does anyone know a good way to do this? I need to have simple forms that submit to email without writing a lot of code. These forms will be hosted in content-viewer web parts or similar in MOSS 2007. I'd like to avoid using InfoPath. |
Is there a way to "diff" two XMLs element-wise? |
|xml|comparison|diff|dtd|element| |
I'm needing to check the differences between two XMLs but not "blindly", Given that both use the same DTD, I'm actually interested in verifying wether they have the same amount of elements or if there's differences. |
There are several things going on in this question...
It is possible for a struct to implement an interface, but there are concerns that come about with casting, mutability, and performance. See this post for more details: http://blogs.msdn.com/abhinaba/archive/2005/10/05/477238.aspx
In general, structs should be... |
|firefox|proxy|authentication|passwords|plugins| |
Suppose someone worked for a company that put up an HTTP proxy preventing internet access without password authentication (NTLM, I think). Also suppose that this password rotated on a daily basis, which added very little security, but mostly served to annoy the employees. How would one get started writing a Firefox add... |
|firefox|authentication|plugins|proxy|passwords| |
Suppose someone worked for a company that put up an HTTP proxy preventing internet access without password authentication (NTLM, I think). Also suppose that this password rotated on a daily basis, which added very little security, but mostly served to annoy the employees. How would one get started writing a Firefox add... |
The basic intrinsic types (e.g. `byte`, `int`, `string`, and arrays) will be serialized automatically by WCF. Custom classes, like your UploadedFile, won't be.
So, a silly question (but I have to ask it...): is UploadedFile marked as a `[DataContract]`? If not, you'll need to make sure that it is, and that each of ... |
That's a lot of data to be streaming into a browser. Flash or Flex charts is probably the only solution that will be memory efficient. Javascript charting tends to break-down for large data sets. |
The other option is generating the waveforms on the server-side with GD or RMagick. But good luck getting RubyGD to compile. |
I believe that WPF has amazing potential as a tool to make UIs more creative and better suited to the actual data that is being displayed, BUT..............
Just the mere act of **using** WPF isn't going to make great UIs appear out of nowhere.
A great carpenter may use the best wood working tools, but th... |
I believe that WPF has amazing potential as a tool to make UIs more creative and better suited to the actual data that is being displayed, BUT..............
Just the mere act of **using** WPF isn't going to make great UIs appear out of nowhere.
A great carpenter may use the best wood working tools, but th... |
In the C# IDE, type 'exception' and hit TAB. This will expand to get you started in writing a new exception type. There are comments withs links to some discussion of exception practices.
Personally, I'm a big fan of creating lots of small classes, at that extends to exception types. For example, in writing the F... |
How do I know when to use state based testing versus mock testing? |
|unit-testing| |
Which scenarios, areas of an application/system, etc. are best suited for 'classic' state based testing versus using mock objects? |
[Thread.dumpStack();][1]
[1]: http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html#dumpStack() |
You should be using mocks for dependencies. I don't think that its an either-or; Usually you will create mocks for dependencies, set expectations (whether it is calls or state) on them, then run the unit under test. Then you would check its state, and verify the expectations on the mocks, afterwards.
|
use insertAfter():
$("<div id='xxx'></div>").insertAfter("#somediv > ul").append($("#someotherdiv").clone()) |
This is another aproach to parse the the process list from the command "**ps -e**":
try {
String line;
Process p = Runtime.getRuntime().exec("ps -e");
BufferedReader input =
new BufferedReader(new InputStreamReader(p.getInputStream()));
... |
Count Xpaths in XmlSpy |
|xml|xpath|xmlspy| |
I am using XmlSpy to analyze an xml file, and I want to get a quick count of the number of nodes that match a given xpath. I know how to enter the xpath and get the list of nodes, but I am really just interested in the count. Is it possible to get this?
I'm using XmlSpy Professional Edition version 2007 sp2, if it... |
What is a prepared statement? |
|postgresql| |
I see a bunch of lines in the .log files in the postgres pg_log directory that say something like:
> ERROR: prepared statement "pdo_pgsql_stmt_09e097f4" does not exist
What are prepared statements, and what kinds of things can cause these error messages to be displayed? |
I think what you mean is a character per node... sort of like a simple hash tree scheme for keyword lookup. Assuming this or even another kind of tree... imagine doing something like this (in pseudo-LISP):
(defun buildtree (wordlist) ...code to build tree recursively returns the tree...)
(define lookup (tr... |
C# .NET + PostgreSQL |
|c#|.net|postgresql| |
I'm looking at working on a project which uses C#.NET (sitting on a windows box) as the primary language and PostgreSQL as the backend database (backend is sitting on a linux box). I've heard that ODBC.NET allows for easy integration of these two components.
Has anyone had experience actually setting C# and Postg... |
FYI, you can also use `map.keySet()` and `map.values()` if you're only interested in keys/values of the map and not the other. |
[iRotate][1] worked great, and it is free for personal use. Very quick and painless install. Thanks [seanb][2]. My only complaint is it binds hot keys to CTRL+ALT+[arrows], so I have to close it after I rotate. It seems to stay rotated, but I guess I will see what happens when I reboot.
[1]: http://www.ente... |
Determining the last changelist synced to in Perforce |
|perforce| |
A question that occasionally arises is what is the best way to determine the changelist that you last synced to in Perforce. This is often needed for things like injecting the changelist number into the revision info by the automatic build system.
|