instruction
stringlengths
0
30k
Database replication. 2 servers, Master database and the 2nd is read-only
|sql-server|replication|
Say you have 2 database servers, one database is the 'master' database where all write operations are performed, it is treated as the 'real/original' database. The other server's database is to be a mirror copy of the master database (slave?), which will be used for read only operations for a certain part of the appli...
Depending on how much of your PHP code is actually executed and how long that execution takes they can be a really big win. It certainly isn't going to hurt, but the gain you see will very much depend on where your time is currently spent. btw mmcache has been rolled into a different project now, I forget the name b...
Looks like what you need is zlibCE from the OpenNETCF foundation. You can get it here: [http://opennetcf.com/FreeSoftware/zlibCE/tabid/245/Default.aspx][1] It's a port of the linux [zlib][2] library to CE. At it's core, it's a native dll, but they now also provide a .NET wrapper, along with all the source code. ...
I recall that there is some feature like using `\\?\` at the start of the path to get around the `MAX_PATH` limit. I'll see if I can find a reference.
I recall that there is some feature like using `\\?\` at the start of the path to get around the `MAX_PATH` limit. Here is a reference on MSDN: <http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx> For remote machines, you would use a path name such as: `\\?\unc\server\share\path\file`. The `\\?\unc\` is...
Generics on ASP.NET page Class
|generics|on|asp.net|
I want to implement Generics in my Page Class like : Public Class MyClass(Of TheClass) Inherits System.Web.UI.Page But for this to work, I need to be able to instantiate the Class (with the correct Generic Class Type) and load the page, instead of a regular Response.Redirect. Is there a way to do this ?
|asp.net|vb.net|generics|
I want to implement Generics in my Page Class like : Public Class MyClass(Of TheClass) Inherits System.Web.UI.Page But for this to work, I need to be able to instantiate the Class (with the correct Generic Class Type) and load the page, instead of a regular Response.Redirect. Is there a way to do this ? ...
Only ever use open() for opening files. file() is actually being removed in 3.0, and it's deprecated at the moment. They've had a sort of strange relationship, but file() is going now, so there's no need to worry anymore. The following is from the Python 2.6 docs. [bracket stuff] added by me. > When opening a fil...
Have you asked the Domain Admins if they have a Group Policy which is re-enabling UAC? It may be that Vista by default has only a few places that can run unrestricted and if you have Visual Studio installed outside those areas, it may be preventing it from running with elevated permissions. Check where it is inst...
According to Mr Van Rossum, although open() is currently an alias for file() you should use open() because this might change in the future.
It looks like you're wanting to display a table, right? So go ahead and use the &lt;table&gt; tag.
Is there a reason to not use tables? If you're displaying tabular data, it's best to use tables - that's what they're designed for. To answer your question, the best way is probably to assign a fixed width to each element, and set float:left. You'll need to have either a dummy element at the end that has clear:both,...
You can use another static object to lock on it. private static Object lockObj = new Object(); and lock this object in the constructor. lock(lockObj){} However, I am not sure if there are situations that should be handled because of compiler optimization in .net like in the case of java
[ICSharpCode.TextEditor][1] is free and pretty stable. As for commercial solution Actipro's [SyntaxEditor][2] might be a best choice [1]: http://www.icsharpcode.net/OpenSource/SD/ [2]: http://www.actiprosoftware.com/Products/DotNet/SyntaxEditor/Default.aspx
Use one of the sort alorithms propose by [Wikipedia][1]. The Swap function should swap array elements using a temporary variable of the same type as the array elements. Use a stable sort if you want entries with the same SortOrder integer value to stay in the order they were in the first place. [1]: http://en.wi...
Unit testing in XCode 3.1 with Objective-C
|xcode|unit|testing|
I read the question on 'The best way to unit text objective-C' and followed the instructions , but no matter what I do, the Unit tests do not run. Actually the entire program does not run, I get the following message. dyld: Library not loaded: @rpath/SenTestingKit.framework/Versions/A/SenTestingKit Referenced from ...
|unit-testing|xcode|
I think if you modify the [Singleton Pattern](http://en.wikipedia.org/wiki/Singleton_pattern#C.23) to include a count (obviously using the thread-safe method), you will be fine :) ###Edit Crap I accidentally deleted! I am not sure if instance constructors _ARE_ thread safe, I remember reading about this in a desig...
@[Rob][1] FYI, This class may not be a singleton, I need access to different instances. They must simply maintain a count. What part of the singleton pattern would you change to perform 'counter' incrementing? Or are you suggesting that I expose a static method for construction blocking access to the code that in...
Visual C++ string functions supporting unicode: <http://msdn.microsoft.com/en-us/library/cc194799.aspx>
Visual C++ string functions supporting unicode: <http://msdn.microsoft.com/en-us/library/cc194799.aspx> the one you are probably looking for is _wcsnicmp
In my opinion, the question: "Do you **use** design pattern?", alone is a little flawed because the answer is universally YES. Let me explain, we, programmers and designers, all use design patterns... we just don't always realise it. I know this sounds cliché, but you don't go to patterns, patterns come to you. You ...
If your parameters change, I would change the function pointer declaration to use the "..." technique to set up a variable number of arguments. It could save you in readability and also having to make a change for each parameter you want to pass to the function. It is definately a lot safer than passing void around. ...
Since I assume you can google, I don't think a link to more sites is what you are looking for. My answer: Choose base on the history of your developers. C# is more JAVA like, and probably C++ like. VB.NET was easier for VB programmers, but I guess that is no really an issue anymore sine there are no new .NET progra...
The linked comparisons are very thorough, but as far as the main differences I would note the following: - C# has anonymous methods - VB supports [implicit late binding][1] - More out-of-the-box code snippets for VB - More out-of-the-box refactoring tools for C# In general the things MS focuses on for ...
Inside your makefile: target: if test -d dir; then echo "hello world!"; else mkdir dir; fi
Either is fine. I use for () myself, and I don't know if there are compile issues. I suspect they both get optimized down to pretty much the same thing.
I prefer the for loop because it also sets the scope of the iterator to just the for loop.
if you're only going to use the iterator once and throw it away, the second form is preferred; otherwise you must use the first form
:noh will do the trick. (short for nohighlight)
Just put this in your .vimrc " <Ctrl-l> redraws the screen and removes any search highlighting. nnoremap <silent> <C-l> :nohl<CR><C-l>
Should selecting by first letter show as many as possible that start with that letter?
|user-interface|
When I am in a list and I press a letter to jump to the first entry that starts with that letter why does it leave that entry on the bottom of the visible entries? It should make the entry the top visable entry so that many entries that start with that letter can be seen. In more concrete terms if I am selecting a s...
The -p option to mkdir prevents the error message if the directory exists. Alternatively, you can use the test command: test -d $(OBJDIR) || mkdir $(OBJDIR)
Why not use the for-each construct? (I haven't used Java in a while, but this exists in C# and I'm pretty sure Java 1.5 has this too): List<String> names = new ArrayList<String>(); names.add("a"); names.add("b"); names.add("c"); for (String name: names) System.out.println(name.charAt(0));
Ruby does this (as well as others). It has nil instead of null and it's an object. I dp hate when functions that are meant to return lists can return null. It's better to return an empty list and let the user decide if they want to check for null (empty) or not.
Altough I haven't tried it myself it seems to be possible by using a combination of DataContext.LoadOptions to make it eager to accept relations and GetCommand(IQueryable) to return a SQLCommand object that preserves relations. See more info on [MSDN Forums][1]. [1]: http://forums.microsoft.com/msdn/ShowPost....
I would agree that the "for" loop is clearer and more appropriate when iterating. The "while" loop is appropriate for polling, or where the number of loops to meet exit condition will change based on activity inside the loop.
There seems to be no way to get a java.io.Console object when running an application through Eclipse. A command-line console window is not opened with the application, as it is run as a background process (background to Eclipse?). Currently, there is no Eclipse plugin to handle this issue, mainly due to the fact that j...
Jeremy Manson, the god when it comes to the Java Memory Model, has a three part blog on this topic - because in essence you are asking the question "Is it safe to access an immutable HashMap" - the answer to that is yes. But you must answer the predicate to that question which is - "Is my HashMap immutable". The answ...
One difference I've found is that the development server handles uploading files differently than IIS does. You can't trap the error if the file being uploaded is bigger than your Max_File_Size setting. The page just dies and returns a 500.
The problem was related to my version of the data access DLL I was adding. I found that if I went to the following: > C:\Program Files\Microsoft Web Client > Software Factory February > 2008\Microsoft Practices Library and imported this specific data access DLL instead of the one I compiled myself from the Ent...
Nothing prevents you for diverting your parser from the "context free" path using PLY. You can pass information to the lexer during parsing, and in this way achieve full flexibility. I'm pretty sure that you can parse anything you want with PLY this way. For a hands-on example, consider http://code.google.com/p/pycp...
Mac OS X Java Swing Buttons are Disabled for no aparent reason
|macos|button|java|swing|
I wrote an application in Java and when it runs on one customer's computer running OS X The Save and Export buttons are disabled. (Everything else works in the application.) Any ideas?
|java|macos|swing|button|
I wrote an application in Java and when it runs on one customer's computer running OS X The Save and Export buttons are disabled. (Everything else works in the application.) Both of these buttons open up a standard save file dialog. Any ideas?
One factor that you might not have thought of is the `Decimal.TryParse` method. Both `Convert.ToDecimal` and `Parse` throw exceptions if they cannot convert the string to the proper decimal format. The TryParse method gives you a nice pattern for input validation. decimal result; if (decimal.TryParse("5.0...
import os os.system("your command") Note that this is dangerous, since the command isn't cleaned. I leave it up to you to google for the relevant docs on the 'os' and 'sys' modules. There are a bunch of functions (exec* , spawn*) that will do similar things.
import os cmd = 'ls -al' os.system(cmd) If you want to return the results of the command you need [os.popen][1]: [1]: http://oreilly.com/catalog/lpython/chapter/ch09.html
On vim.wikia, you will find a category of tips dedicated to snippets and abbreviations expansion [1]. You will also see a list of plugins that ease the definition of complex snippets/templates-files. HTH, [1]: http://vim.wikia.com/wiki/Category:Automated_Text_Insertion
On vim.wikia, you will find a [category of tips][1] dedicated to snippets and abbreviations expansion. You will also see a list of plugins that ease the definition of complex snippets/templates-files. HTH, [1]: http://vim.wikia.com/wiki/Category:Automated_Text_Insertion "Automated Text Insertion category"
C#: Why does Settings PropertyValues have 0 items?
|c#|visual-studio|visual-studio-2005|
Assuming there are 5 items in the settings file (MySetting1 to MySetting5), why does PropertyValues have 0 items while Properties has the correct number? Is there a way to access the current settings values in a loop? This is possible with the Properties.Settings.Default.Properties collection but items have just the de...
Assuming there are 5 items in the settings file (MySetting1 to MySetting5), why does PropertyValues have 0 items while Properties has the correct number? Console.WriteLine( Properties.Settings.Default.PropertyValues.Count ); // Displays 0 Console.WriteLine( Properties.Settings.Default.Properties.Count ); ...
<code>people</code> and <code>otherPeople</code> contain objects of type <code>IQueryable&lt;Person></code>. If you iterate over both, separatly, it will run two queries. If you only iterate over <code>otherPeople</code>, it will run the expected query. If you do <code>.ToList()</code> on <code>people</code> and...
> Edit 4: Sorry, I meant that you could send the XMLHttpRequest to the StackOverflow domain, and then save the result of getAllResponseHeaders() to a string, regex out the cookie, and then post that to an external domain. It appears that Wikipedia and ha.ckers concur with me on this one, but I would love be re-educated...
> Edit 4: Sorry, I meant that you could send the XMLHttpRequest to the StackOverflow domain, and then save the result of getAllResponseHeaders() to a string, regex out the cookie, and then post that to an external domain. It appears that Wikipedia and ha.ckers concur with me on this one, but I would love be re-educated...
Requirements Gathering
|requirements|design-patterns|software-engineering|
How do you go about the requirements gathering phase? Does anyone have a good set of guidelines or tips to follow? What are some good questions to ask the stakeholders? I am currently working on a new project and there are a lot of unknowns. I am in the process of coming up with a list of questions to ask the stake...
|software-engineering|requirements|
Generic IBindingListView Implementations
|.net|data-binding|
Can anyone suggest a good implementation of a generic collection class that implements the IBindingListView & IBindingList interfaces? I see my current options as:<br /> - Using a class that someone else has written and tested - Inheriting from BindingList<T>, and implementing the IBindingListView interfaces...
Can anyone suggest a good implementation of a generic collection class that implements the IBindingListView & IBindingList interfaces and provides Filtering and Searching capabilities? I see my current options as:<br /> - Using a class that someone else has written and tested - Inheriting from BindingList<T>...
I would use a Vector datatype. Just like in Physics, when you want to model an objects movement, you use vectors. Use a [Vector2][1] or [Vector3 class out of the XNA][2] framework or roll your [own Vector3 struct][3] to represent the position. Vector2 is for 2D and Vector3 is 3D. [TimeSpan][4] struct or the [Stop...
First off, **[Konrad][1]** is right to quote the spec, as that is what defines the language and answers your first question. To answer your other questions: > *Are there any other such Javascript browser quirks that I should be wary of?* Oh, too many to list here! Try **[the QuirksMode website][2]** for a good...
Multiple form Delphi applications and dialogs
|delphi|
I have a Delphi application that has two views of a document (e.g. a WYSIWYG HTML edit might have a WYSIWYG view and a source view). They can be opened in separate windows, or docked into tabs in the main window. If I open a dialog from one of the separate forms, the main form is brought to the front, and is shown a...
I have a Delphi 7 application that has two views of a document (e.g. a WYSIWYG HTML edit might have a WYSIWYG view and a source view). They can be opened in separate windows, or docked into tabs in the main window. If I open a modal dialog from one of the separate forms, the main form is brought to the front, and is...
I have a Delphi 7 application that has two views of a document (e.g. a WYSIWYG HTML edit might have a WYSIWYG view and a source view - not my real application). They can be opened in separate windows, or docked into tabs in the main window. If I open a modal dialog from one of the separate forms, the main form is br...
Don't bother with finalizers. Switch to incremental garbage collection. If you want to help the garbage collector, null off references to objects you no longer need. Less path to follow= more explicitly garbage. Don't forget that (non-static) inner class instances keep references to their parent class instan...
Remove duplicates from array
|c#|arrays|
I have been working with a string[] array in c# that gets returned from a function call. I was wondering what the best way to remove duplicates from this array would be? I could possibly cast to a Generic collection, but I was wondering if there was a better way to do it, possibly by using a temp array?
I programmed in Lisp professionally for about a year, and it is definitely worth learning. You will have unparalleled opportunity to remove redundancy from your code, by being able to replace all boilerplate code with functions where possible, and macros where not. You will also be able to access unparalleled flexabi...
I programmed in Lisp professionally for about a year, and it is definitely worth learning. You will have unparalleled opportunity to remove redundancy from your code, by being able to replace all boilerplate code with functions where possible, and macros where not. You will also be able to access unparalleled flexibi...
I programmed in Lisp professionally for about a year, and it is definitely worth learning. You will have unparalleled opportunity to remove redundancy from your code, by being able to replace all boilerplate code with functions where possible, and macros where not. You will also be able to access unparalleled flexibi...
If you needed to sort it, then you could implement a sort that also removes duplicates. Kills two birds with one stone, then.
It looks like Steel Bank Common Lisp (SBCL) also caters to what you want: http://www.sbcl.org/manual/Unix_002dstyle-Command-Line-Protocol.html#Unix_002dstyle-Command-Line-Protocol SBCL is both top rate and open source.
I thought they were - I'm not sure of the point of the lock in your example unless you're also doing something to s_Provider at the same time - then the lock would ensure that these calls happened together. Does that `//Perform initialization` comment cover creating s_Provider? For instance private static voi...
1)The members of a structure are public by default, the members of class are private by default. 2)Default inheritance for Structure from another structure or class is public.Default inheritance for class from another structure or class is private. class A{ public: int i; }; class A2:A{ }; struc...
These are actually both poor practices. Once upon a time, it was considered OK to casually treat None and False as similar. However, since Python 2.2 this is not the best policy. First, when you do an `if x` or `if not x` kind of test, Python has to implicitly convert `x` to boolean. The rules for the `bool` fun...
Determine when application cache item will timeout?
|asp.net-1.1|asp.net|c#|
In ASP.NET, when storing a value in the application cache with absolute expiry is there a method to retrieve the date/time when the item will expire?
|c#|asp.net|asp.net-1.1|
In ASP.NET, when storing a value in the application cache with absolute expiry is there a method to retrieve the date/time when the item will expire? The application cache item will be refreshed if expired based on user requests.