instruction
stringlengths
0
30k
Dns.GetHostByName(Dns.GetHostName()); will return an array of IP addresses. The first one should be the external IP, the rest will be the ones behind NAT. So: IPHostEntry IPHost = Dns.GetHostByName(Dns.GetHostName()); string externalIP = IPHost.AddressList[0].ToString();
Dns.GetHostEntry(Dns.GetHostName()); will return an array of IP addresses. The first one should be the external IP, the rest will be the ones behind NAT. So: IPHostEntry IPHost = Dns.GetHostEntry(Dns.GetHostName()); string externalIP = IPHost.AddressList[0].ToString(); EDIT: There are reports that ...
If you have installed SharePoint 2007 (without Service Pack 1) then you can follow an example like the following article: [AjaxBasePart: Easy ASP.NET 2.0 AJAX Extensions 1.0 and Office SharePoint Server 2007][1] The reason for this is that there exists a specific problem with mixing doPostback, UpdatePanel and Sh...
In addition to using server side compression, using intelligent coding is the best way to keep bandwidth costs low. you can always use tools like [Dean Edward's Javascript Packer][1], but for css take the time to learn [Css Shorthand][2] background: #fff url(image.gif) no-repeat top left; ...instead of ...
I'm writing a pretty straightforward e-commerce app in asp.net, do i need to use transactions in my stored procedures? Read/Write ratio is about 9:1
I like to pass the parent as an interface (so the class can be contained in any parent implementing that interface) or implement the reference as an event/function pointer/delegate which the parent can hook onto.
If you are doing multiple updations or insertions to your tables from the stored procedure, then surely you would require transactions.
Many people ask - do I need transactions? Why do I need them? When to use them? The answer is simple: use them all the time, unless you have a very good reason not to (for instance, don't use atomic transactions for "long running activities" between businesses). The default should always be yes. You are in doubt? - ...
The answer is, it depends. You do not always need transaction safety. Sometimes it's overkill. Sometimes it's not. I can see that, for example, when you implement a checkout process you only want to finalize it once you gathered all data, etc.. Think about a payment f'up, you can rollback - that's an example when yo...
On the PHP front, I believe for example [phpUnderControl][1] includes metrics through [phpUnit][2] (if I am not mistaken). Keep in mind that metrics are often flawed. For example, a coder who's working on trivial problems will produce more code and there for look better on your graphs, than a coder who's cracking th...
You can use [BindingOperation.SetBinding][1]: Binding newBinding = new Binding(); newBinding.ElementName = "SomeObject"; newBinding.Path = new PropertyPath(SomeObjectType.SomeProperty); BindingOperations.SetBinding(MyGlow, OuterGlowBitmapEffect.GlowSizeProperty, newBinding); I think that sh...
I'm a jQuery believer as well, so pardon my lack of knowledge about the others, but ... What makes jQuery so great is the no-conflict mode, so for example, you would do: $('#foobar').whatever(); With no-conflict mode, you'd do this: var jq = jQuery.noConflict(); jq('#foobar').whatever(); One...
Here's a list: <http://www.oracle.com/podcasts/index.html>
UserControl rendering: write link to current page?
|asp.net|web-applications|custom-server-controls|
I'm implementing a custom control and in this control I need to write a bunch of links to the current page, each one with a different query parameter. I need to keep existing query string intact, and add (or modify the value of ) an extra query item (eg. "page"): "Default.aspx?page=1" "Default.aspx?page=2"...
**Do not trust user input.** Validation of expected data types and formatting is essential to avaoiding SQL injection and Cross-Site Scripting (XSS) attacks.
Because GETs are purely URLs, they can be cached by the web browser and may be better used for things like consistently generated images. (Set an Expiry time) One example from the gravatar page: [http://www.gravatar.com/avatar/4c3be63a4c2f539b013787725dfce802?d=monsterid][1] GET may yeild marginally better perfor...
Microsoft Technet has en excellent article: [Ten Tips for Designing, Building, and Deploying More Secure Web Applications][1] [1]: http://technet.microsoft.com/en-us/library/cc512638.aspx
Microsoft Technet has en excellent article: [Ten Tips for Designing, Building, and Deploying More Secure Web Applications][1] Here are the topics for the tips answered in that article: 1. Never Directly Trust User Input 2. Services Should Have Neither System nor Administrator Access 3. Follow SQL Server B...
I'm afraid I don't know of any built-in method for this, we use this method that takes the querystring and sets parameters /// <summary> /// Set a parameter value in a query string. If the parameter is not found in the passed in query string, /// it is added to the end of the query string ...
As part of my integration strategy, I have a few SQL scripts that run in order to update the database. The first thing all of these scripts do is check to see if they need to run, e.g.: if @version <> @expects begin declare @error varchar(100); set @error = 'Invalid version. Your version is '...
|sql-server|stored-procedures|
How do I concatenate text in a query in sql server?
|sql|sql-server|
SELECT notes + 'SomeText' FROM NotesTable a gives `The data types nvarchar and text are incompatible in the add operator.` as an error.
|sql|sql-server|
SQL Server, nvarchar(MAX) or ntext, image or varbinary?
|t-sql|sql-server|sql-types|
When should I choose one or the other? What are the implications regarding space and (full-text) indexing? BTW: I'm currently using SQL Server 2005 planing to upgrade to 2008 in the following months. Thanks
|sql-server|t-sql|sql-types|
SQL Server 2005 One-way Replication
|replication|sql-server|
In the business I work for we are discussion methods to reduce the read load on our primary database. One option that has been suggested is to have live one-way replication from our primary database to a slave database. Applications would then read from the slave database and write directly to the primary database. ...
|sql-server|replication|
C# WinForms - DataGridView/SQL Compact - Negative integer in primary key column
|c#|winforms|data-binding|sql-server|sql-server-ce|
I'm just getting dirty in WinForms, and I've discovered, through a lovely tutorial, the magic of dragging a database table onto the design view of my main form. So, all is lovely, I've got my DataGridView with all of the columns represented beautifully. BUT... When I run my application against this brand new, emp...
The above posts give you some answers on solving the problem. If just handling the ugly error in the interim is what you're looking for, custom errors are the easiest way to gracefully handle all your "ugly yellow errors" [http://msdn.microsoft.com/en-us/library/aa479319.aspx][1] [http://msdn.microsoft.com/en-us...
Any data you want to keep should be stored in multiple places on multiple formats. While the odds of any one failing may be significant, the odds of all of them failing are pretty small.
You could look into psh here: <http://www.focusresearch.com/gregor/sw/psh/> It's a full on shell (you can use it in replacement of bash for example), but uses perl syntax.. so you can create methods on the fly etc.
Running $ httpd -V will how you lots of useful server information, including where the httpd.conf file can be found.
Running $ httpd -V will show you lots of useful server information, including where the httpd.conf file can be found.
I use the *acts_as_xapian* plugin. I followed this tutorial: [http://locomotivation.com/2008/07/23/simple-ruby-on-rails-full-text-search-using-xapian][1] [1]: http://locomotivation.com/2008/07/23/simple-ruby-on-rails-full-text-search-using-xapian Works very well.
Kind of a pseudo table you can run commands against and get back results, such as sysdate. Also helps you to check if Oracle is up and check sql syntax, etc.
Introspection was introduced with [FxCop in 2004 as an alternative to Reflection][1] : > What's new in FxCop 1.30 is that it > now performs analysis through a > technique called Introspection. The > use of the Introspection engine allows > for much faster analysis and supports > multithreaded analysis. Unlike t...
Based on your level of paranoia, I'd recommend a printer and a safe. More seriously, a RAID array isn't so expensive anymore, and so long as you continue to use and monitor it, a properly set-up array is virtually guaranteed never to lose data.
It's a sort of dummy table with a single record used for selecting when you're not actually interested in the data, but instead want the results of some system function in a select statement: e.g. *select sysdate from dual* See [http://www.adp-gmbh.ch/ora/misc/dual.html][1] [1]: http://www.adp-gmbh.ch/ora/...
C# P/Invoke with Variants
|c#|pinvoke|
I love Yacc, but the discriminating union stack does present a challenge. I don't know whether you are using C or C++. I've modified Yacc to generate C++ for my own purposes, but this solution can be adapted to C. My preferred solution is to pass an interface to the owner down the parse tree, rather than construc...
If the operation is atomic, you _should_ be able to get by just fine. But I wouldn't do that in practice. It is better just to acquire a lock on the object and write the value.
DateTime fields with auto_now are automatically updated upon calling `save()`, so you do not need to update them manually. Django will do this work for you.
They contains the specific settings about project that are tipically assigned to a single developer (like, for example, the starting project and starting page to start when you debug your application). <br/> So it's better not adding them to version control, leaving VS recreate them so that each developer can have th...
Typically, one would expect the performance penalty to lie in the other direction. Recursive calls can lead to the construction of extra stack frames; the penalty for this varies. Also, in some languages like Python (more correctly, in some implementations of some languages...), you can run into stack limits rather e...
In addition to using server side compression, using intelligent coding is the best way to keep bandwidth costs low. you can always use tools like [Dean Edward's Javascript Packer][1], but for css take the time to learn [CSS Shorthand][2] background: #fff url(image.gif) no-repeat top left; ...instead of ...
**You DO need to call Dispose()!** Dispose() is for the developer to call, the Garbage Collector calls Finalize(). If you don't call Dispose() on your objects any unmanaged resources that they used won't be disposed until the garbage collector comes around and calls finalize on them (and who knows when that will hap...
**You DO need to call Dispose()!** Dispose() is for the developer to call, the Garbage Collector calls Finalize(). If you don't call Dispose() on your objects any unmanaged resources that they used won't be disposed until the garbage collector comes around and calls finalize on them (and who knows when that will hap...
Perl 6 is moving along nicely. Perl 6 is a bit unlike previous Perl's in that Perl 6 is actually a language specification not an implementation of it. The reference implementation on top of Parrot that is the main thrust of the Perl 6 project has been renamed Rakudo and is moving along nicely. The best place I've fo...
The problem is it's not normal to want to leave the CPU idle while you have work to do. Normally you set a background task to IDLE priority, and let the OS handle scheduling it all the CPU time that isn't used by interactive tasks. It sound to me like the problem is the watchdog process. If your background task...
Oh and we have this method too that allows you to put in a whole URL string without having to get the querystring out of it public static string SetParameterInUrl(string url, string paramName, object paramValue) { int queryStringIndex = url.IndexOf("?"); string path; string queryS...
what algorithm/pseudo-code is used to create the paging links for stackoverflow
|stackoverflow|algorithm|paging|
Can someome provide code or pseudo-code for how the paging links in stackoverflow are generated? I keep racking my brain but can't think of a decent way to build the dynamic links that always shows the 2 pages around the current, plus the first and last. Example: 1 .. 5 6 7 .. 593
Algorithm / pseudo-code to create paging links?
|algorithm|paging|
**final for instance variables:** Really useful for multi-threading code and it makes it a lot easier to argue about the instance state and correctness. Haven't seen it a lot in industry context and often not thought in java classes. ---------- **static {something;}:** Used to initialize static members (als...
[View formatted source][1] is kinda similar. It uses tree controls rather than pretty colour blocks, though. [1]: https://addons.mozilla.org/en-US/firefox/addon/697
I know you're looking for an entire persistence layer, but NHibernate's hbm2ddl task can do this almost as a one-liner. There is a [NAnt task][1] available to call it which may well be of interest. [1]: http://biasecurities.com/blog/2005/nhibernate-hbm2ddl-nant-task/
Some nice ideas there, thanks. The Visual Studio debugger wasn't showing an exception (and I've wrapped everything in try/catch blocks just in case), but I hadn't thought of trying Windbg...
I use a simple script that dumps the mysql database into a tar.gz file, encrypts it using gpg and sends it to a mail account (Google Mail, but that's irrelevant really) The script is a Python script, which basically runs the following command, and emails the output file. `mysqldump -u theuser -p mypassword thedat...
@Chuck (1921) has a good idea. If the test was created in Flash/Flex, you could force the user to make the application fullscreen in order to start the test (fullscreen mode has to be user-initiated). Then, you can listen for the Flash events dispatched when flash exits fullscreen mode and take whatever appropriate...
If your page is loading files from a non-https URL Firefox should tell you the same thing. Instead of an error the lock symbol at the bottom (in the status bar) should be crossed out. Are you sure that is not the case? If you see the symbol, click on it and check which files are "unsecure".
another way: select * from table a where exists (select 1 from table where column_name=a.column_name and rowid<a.rowid) Works fine (quick enough) when there is index on column_name. And it's better way to delete or update dublicate rows.
access $(this) with href="javascript:..." in JQuery
|jquery|
I am using JQuery. I call a javascript function with next html: <li><span><a href="javascript:uncheckEl('tagVO-$id')">$tagname</a></span></li> I would like to **remove the *li*** element and i thought this would be easy with the **$(this)** object. This is my javascript function: function uncheckEl(i...
It's a good way to outsource a part of your infrastructure. You don't have to worry about lost passwords etc., someone else does it for you. I'm not sure I'd use it exclusively, though. I haven't used openID enough to entirely trust it, and the sign up process needs to be streamlined until > 90% of users have an op...
**Adds critical point to failure to the site** That critical point of failure could be the confirmation email you send out, but the user's mailbox is a) unavailable due to a typo, b) full or c) provider is 'down'. **Takes a user to another sites content and every time they logon to your site** I can see that, ...
You've got two options - Escaping the special characters in your unsafe_variable, or using a parameterized query. Both would protect you from SQL Injection. The parameterized query is considered better practice, but escaping characters in your variable will require fewer changes. We'll do the simpler string escaping...
To solve this one I'd probably create a JSF fragment that only includes your form, then use a <c:import> tag to include it in my JSF page. That solution is probably a little fragile depending on your environment, so another option might be to get ahold of the JSF Context and pull your managed bean out of there fro...
To solve this one I'd probably create a JSF fragment that only includes your form, then use a <c:import> tag to include it in my JSF page. That solution is probably a little fragile depending on your environment though. EDIT: See Chris Hall's answer, FacesContext is not available outside the FacesServlet.
In practice I always find it easier to give the telephone number an identity, even if it isn't strictly necessary in design terms. If it is a strict value object which cannot exist outside the context of the Contact, that indicates that a good user interface may call for the telephone number to be edited within the ...
You may want to take a look at [Unison][1]. I was fairly happy with it as a publishing mechanism for a site where I wanted, effectively, a smart two-way rsync. You could probably tie it to SVN without much difficulty. [1]: http://www.cis.upenn.edu/~bcpierce/unison/
http://www.nessus.org/nessus/ -- Nessus will help suggests ways to make your servers better. It can't really test custom apps by itself, though I think the plugins are relatively easy to create on your own.
From [MSDN][1]: The volatile modifier is usually used for a field that is accessed by multiple threads without using the lock statement to serialize access. Using the volatile modifier ensures that one thread retrieves the most up-to-date value written by another thread. [1]: http://msdn.microsoft.com/en-us/lib...
We don't commit the binary file (*.suo), but we commit the .user file. The .user file contains for example the start options for debugging the project. You can find the start options in the properties of the project in the tab "Debug". We used NUnit in some projects and configured the nunit-gui.exe as the start option ...
Something like: response.setHeader("Set-Cookie", "yourcookiename=yourcookievalue; HTTPOnly"); might work in a Java environment. I am not aware of a JSF-specific way to achieve this... sorry This seems to be not an easy task in Java.
In Visual Studio 2008, is it possible to mix vertical tab groups with horizontal tab groups?
Better to just use http://www.whatismyip.com/automation/n09230945.asp it only outputs the IP just for the automated lookups.
Better to just use http://www.whatismyip.com/automation/n09230945.asp it only outputs the IP just for the automated lookups.<br/><br />If you want something that does not rely on someone else put up your own page http://www.unkwndesign.com/ip.php is just a quick script: <?php echo 'Your Public IP is: ' . $_...
> I'm stuck using WriteString(), I think that's the root of your problem. Can you explain more about your reason you're stuck using WriteString? My gut is you're using the wrong method for what you want to do
You have two options. 1. In JavaScript, you basically have it choose an image based on the day of the week or day of the month if you have more than 7 images. Day of the month modulo by the length of the image array should let you pick the right array element. 2. You need something a bit more stateful to track ...
sql already provides a way to change your schema: the ALTER command. simply have a table that lists the fields that users are not allowed to change, and write a nice interface for ALTER.
Off the top of my head, I think you want the SelectionStart property.
I think what you're looking for is the sql_mode parameter in my.conf. STRICT_ALL_TABLES is the value. I guess it depends what you mean by "fatal". http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html
That depends on how you are rotating them - sequentially, randomly, or what? There are a number of options. You can determine which image you want in PHP, and dynamically change your `<img>` element to point to the correct location. This is best if you are already generating your pages dynamically. You can alwa...
The dojo toolkit has functionality to deal with this in javascript. I don't think there is any good way to handle it in pure PHP. Here is the docs page they have: [http://dojotoolkit.org/book/dojo-book-0-9/part-3-programmatic-dijit-and-dojo/back-button-undo][1] [1]: http://dojotoolkit.org/book/dojo-book-0-9/p...
I tend to use more of the Test::Simple and Test::More functionality. I looked at PerlUnit and it seems to provide much of the functionality which is already built into the standard libraries with the Test::Simple and Test::More libraries.
|visual-studio-2008|multiple-monitors|