instruction
stringlengths
0
30k
When learning a new programming language, one of the possible roadblocks you might encounter is the question whether the language is, by default, *pass-by-value or pass-by-reference* So here is my question to all of you, in your favorite language, *how* is it actually done? and what are the *possible pitfalls*? y...
One interesting way is to maintain a stack, and only merge if the list on the stack has the same number of elements, and otherwise push the list, until you run out of elements in the incoming list, and then merge up the stack.
Fair enough. You probably know more than I do about Windows Mobile. :) I just started programming for it. But in regular WinForms, you can override the OnXxx event handler methods all you want. A quick look in Reflector with the CF shows that Control, TextBoxBase and TextBox don't prevent you from overriding the OnMous...
Try this. <asp:Button id="myButton" runat="server" style="display:none" Text="Click Me" /> <script type="text/javascript"> function ShowButton() { var buttonID = '<%= myButton.ClientID %>'; var button = document.getElementById(buttonID); if(button) { button...
Try this. <asp:Button id="myButton" runat="server" style="display:none" Text="Click Me" /> <script type="text/javascript"> function ShowButton() { var buttonID = '<%= myButton.ClientID %>'; var button = document.getElementById(buttonID); if(button) { button...
IE8 overflow:auto with max-height
|internet-explorer-8|beta|
First of all, I know IE8 is still testing. But I'd *like* to have my site look the same even in testing version... so: I have an element which may contain very big amounts of data, but I don't want it to ruin the page layout, so I set `max-height: 100px` and `overflow:auto`, hoping for scrollbars to appear when the ...
|beta|internet-explorer-8|
Please see the following for an example which shows the declaration and potential usage: namespace Flags { class Program { [FlagsAttribute] public enum MyFlags : short { Foo = 0x1, Bar = 0x2, Ba...
The ElementName property on a Binding is not supported in Silverlight. You will notice, if you go into the code behind or inspect the Binding object in class explorer, it doesn't have a property named ElementName.
You can also do this [Flags] public enum MyEnum { None = 0, First = 1, Second = 1 << 1, Third = 1 << 2, Fourth = 1 << 3 } I find the bit-shifting easier than typing 4,8,16,32 and so on. It has no impact on your code because it's all done at compile time
If you make use of WPF commands, each custom command could then log the Action taken. You can also log the way the command was initiated.
I haven't used MSVC6 in years, but I remember the debugger basically being a flaky piece of crap. Things like this would regularly happen for no apparent reason because it just didn't like your code that day. In addition to the debugger being a flaky piece of crap, the rest of it was too. It's STL implementation ...
Someone also suggest the Raphael Javascript library, which apparently lets you draw on the client in all popular browsers: http://dmitry.baranovskiy.com/raphael/ .. but that wouldn't exactly work with my `<noscript>` case, now would it ? :)
What you are asking for is handled at the OS level. Once the data is in your program, it is liable to be paged out. For accessing the memory, a motivated individual can attach a hardware debugger.
Be sure it isn't something [google can answer][1] though. which also shows an issue with that --order of operations! [1]: http://www.google.com/search?q=what+is+7+minus+3+times+2%3F
The flags attribute should be used only when bitwise operations (and, or, exclusive or, not) is to be used on the enum. One example is myProperties.AllowedColors = MyColor.Red | MyColor.Green | MyColor.Blue; This will render the posibility to retrieve these three distinct values from your property *AllowedCol...
You mean it isn't already? ;) Obviously a lot of currently-popular applications would need to offer it and make it obvious that it was a good alternative. If Google and Facebook made it an obvious option, that would help. Ultimately, user education will really be the thing that does it. I doubt most people wo...
Try monitoring the Visual Studio process using a tool like [Process Monitor][1] and get more info. It could be because of some weird file access issues. [1]: http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx
I Believe the best you can do is pass a container object as an argument to a function and change the values of some properties in that object: function swap(aValuesContainer:Object):void { var tempValue:int = aValuesContainer["a"]; aValuesContainer["a"] = aValuesContainer["b"]; aV...
I Believe the best you can do is pass a container object as an argument to a function and change the values of some properties in that object: function swapAB(aValuesContainer:Object):void { if (!(aValuesContainer.hasOwnProperty("a") && aValuesContainer.hasOwnProperty("b"))) throw new ...
It would certainly help if more OpenID consumers were also OpenID providers. As a developer, I'm comfortable going through a few contortions to figure out that I can create a new ID on openid.org, but the more mainstream consumer could easily be put off by the process.
Yes, you can add a bat file to svn (on the installed server) so that anytime you update a particular branch, that change get mimicked.. I believe its called hooks... I hope this is what you meant.
There's a control code you can pass to [DeviceIoControl][1] to get the physical disk geometry. [1]: http://msdn.microsoft.com/en-us/library/aa365171(VS.85).aspx
I finally got this working with danb's help above. This is my resource bundle class and resource bundle control class. I used this code from danb. ResourceBundle bundle = ResourceBundle.getBundle("AwesomeBundle", locale, DbResourceBundle.getMyControl()); javax.servlet.jsp.jstl.core.Config.set(actionBe...
This functionality isn't part of the default PostgreSQL install, but you can add it in. It's called [dblink][1]. I've never used it, but it is maintained and distributed with the rest of PostgreSQL. If you're using the version of PostgreSQL that came with your Linux distro, you might need to install a package called...
I agree most important is not what style one uses but it being consistent. With that said, the new MS/.NET styling for private fields tends to be _fooVar (underscore followed by a camelCased name)
In the options, you can specify how much you want to grow by. By default i believe it's 10%, so given a 200MB database, when you fill your last page, it will allocate another 20MB of page space. At 7GB it would allocate 700MB. I don't know exactly where you can modify it after you create a db, but i know it has it w...
WebBrowserControl Scroll to Bottom
|.net|user-controls|wysiwyg|
I am working on a simple chat application using a System.Windows.Forms.WebBrowser Control to display the messages between the user and the recipient. How do I get the control to automatically scroll to the bottom every time I update the DocumentText of the control?
At least one resource points to this as an alternative to XmlNodeWriter: [http://msdn.microsoft.com/en-us/library/5x8bxy86.aspx][1]. Otherwise, you could write MS using that form they have on the new MSDN Code Library replacement for GotDotNet looking for XmlNodeWriter. [1]: http://msdn.microsoft.com/en-us/libra...
I have found that if you do not take care to backup your transistion log file (the LDF) you will get something like this behavior. I can not stress enough the importance of having good backup "hygiene". Not only will it save your bacon if something goes wrong but I will also help maintain a nice tight database.
I would use the AutoScrollOffset property and set it the the bottom left of the WebBrowser control, so something like: webCtrl.AutoScrollOffset = new Point(webCtrl.Height, 0);
Thanks to all of you that helped to point me in the right direction. I made a change to only clear/add the menu when the form is loaded, so I shouldn't see this error again when the form is painting.
Doesn't **ShowDialog()** have different window behavior than just **Show()**? What if you tried: msgFrm.Show(); msgFrm.BringToFront(); msgFrm.Focus();
> I don't do many physical deletes what about updates of the table, what is the fragmentation level. run DBCC SHOWCONTIG, then rebuild the index if it is highly fragmented. After that do a BACKUP LOG <name> WITH TRUNCATE_ONLY followed by a SHRINK command
First of all, I know IE8 is still testing. But I'd *like* to have my site look the same even in testing version... so: I have an element which may contain very big amounts of data, but I don't want it to ruin the page layout, so I set `max-height: 100px` and `overflow:auto`, hoping for scrollbars to appear when the ...
I was just testing you guys. Here's the answer: object cell = myDataGrid[row, col]; Actually a colleague provided the answer. Thanks, Mike
I was just testing you guys. Here's the answer: object cell = myDataGrid[row, col]; Actually a colleague provided the answer. Thanks, Mike
I find that [Patrick Steele](http://weblogs.asp.net/psteele/default.aspx) answered this question best on his blog: [Avoiding IsNothing()](http://weblogs.asp.net/psteele/archive/2005/06/03/410336.aspx) I did not copy any of his answer here, to ensure Patrick Steele get's credit for his post. But I do think if you're ...
Continuing with what **Dave Ward** said: - You can't set the *Visible* property to false because the control will not be rendered. - You should use the *Style* property to set it's *display* to *none*. --- **Page/Control design** <asp:Label runat="server" ID="Label1" Style="display: none;" /> ...
LinqBridge looks like a pretty nice place to start since I have VS2008, I just need to compile and deploy to a .net 2.0 server. I've looked at SubSonic and it's also an interesting alternative, but linqbridge seems to provide a much closer fit so I'm not going to have to go and learn a new ORM / query syntax.
|language-agnostic|oo|byvalue|byreference|parameters|article|
When learning a new programming language, one of the possible roadblocks you might encounter is the question whether the language is, by default, *pass-by-value or pass-by-reference* So here is my question to all of you, in your favorite language, *how* is it actually done? and what are the *possible pitfalls*? y...
|language-agnostic|object-oriented|parameters|pass-by-reference|pass-by-value|
|language-agnostic|oop|parameters|pass-by-reference|pass-by-value|
How would you access Object properties from within an object method?
|oo|java|php|theory|
What is the "purist" or "correct" way to access an object's properties from within an object method that is not a getter/setter method? I know that from outside of the object you should use a getter/setter, but from within would you just do: Java: String property = this.property; PHP: $property = $this->prop...
What is the "purist" or "correct" way to access an object's properties from within an object method that is not a getter/setter method? I know that from outside of the object you should use a getter/setter, but from within would you just do: Java: String property = this.property; PHP: $property = $this->prop...
|java|php|object-oriented|theory|
|java|php|oop|theory|
Anders gives a good summary, and here's an example of a JUnit annotation @Test(expected=IOException.class) public void flatfileMissing() throws IOException { readFlatFile("testfiles"+separator+"flatfile_doesnotexist.dat"); } Here the @Test annotation is telling JUnit that the ...
It would be equal to b. The comma operator has a lower precedence than assignment.
Be especially careful with strings. Strings often have escape sequences which you also have to respect while you're finding the end of them. So e.g. `"This is \"a test\""`. You cannot blindly look for a double-quote to terminate. Also beware of ``"This is \\"`, which shows that you cannot just say "unless double-...
Also see the most recent F# release - it has static measurement domain/dimension analysis.
It depends entirely on how the site works. I'm in agreement with most that a sitemap is usually the best way to do it. However, if you're using a CMS, then you might need to keep it in the database. If you have a taxonomy-centric site, then use the taxonomy to build the menu. There's no "best way" to do navigation, on...
b's value will be assigned to a. Nothing will happen to c
One upside I can think of is being able to specify GET parameters in the direct URL to the SWF, which will then be available in the Flash app (via `Application.application.parameters` in Flex, not sure how you'd access them in Flash CS3). This can of course be achieved by other means as well if you have an HTML wrapper...
Why do you want to use the ASP.NET AJAX Toolkit with PHP / Python? Have you considered other non ASP.NET specific AJAX libraries like jQuery, Dojo, MooTools, YUI? ASP.NET AJAX and the ASP.NET AJAX Toolkit is ASP.NET centric, you'll gain more flexibility using other AJAX libraries with PHP / Python.
You can use `System.Threading.Thread.CurrentPrincipal`.
Note that if the user pushes a button, focus on the textbox will be lost and there will be no caret position!
loop over all you input fields... finding the one that has focus.. then once you have your text area... you should be able to do something like... myTextArea.value = 'text to insert in the text area goes here';
I'm not sure if you can capture the caret position, but if you can, you can avoid Jason Cohen's concern by capturing the location (in relation to the string) using the text box's `onblur` event.
We've got a similar feature. The application menu is loaded on the master page from the database, because visible menu options depend on the user's permissions. A couple of conventions and clever structure on the database ensure that the menu loading code is generic and automagically navigates to the proper scree...
Take care to notice that the comma operator may be overloaded in C++. The actual behaviour may thus be very different from the one expected. As an example, [Boost.Spirit](http://spirit.sourceforge.net/) uses the comma operator quite cleverly to implement list initializers for symbol tables. Thus, it makes the follow...
If I'm not mistaken, GetHashCode is consistent given the same value, but it is NOT guaranteed to be consistent across different versions of the framework. From the MSDN docs on String.GetHashCode(): > The behavior of GetHashCode is dependent on its implementation, which might change from one version of the common...
Your question is a little large, the answer vary a lot - If you are using Just In Time compilation (JIT) or not - When you are using,, if your process is executed for a long time or not All recent JVM use JIT, but on old JVM the java code is several time slower that native code. If you have a server that ...
You could try to argue your point with a timed example, run a sql select against an indexed table and then run a loop to find exactly the same item in the same set but this time in code. The code will be much slower. Let the database do what it was designed to do, select sets and subsets of data :) I think realistic...
You can use the sp_depends stored procedure to do this: `USE AdventureWorks GO EXEC sp_depends @objname = N'Sales.Customer' ;` [http://msdn.microsoft.com/en-us/library/ms189487(SQL.90).aspx][1] [1]: http://msdn.microsoft.com/en-us/library/ms189487(SQL.90).aspx
Google will use meta tags, but the description, to better summarize your site. They won't help to increase your page rank. See: [http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=79812][1] [1]: http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=79812
Another option is to use an object with public static properties. I used to use $GLOBALS but most editors don't auto complete $GLOBALS. Also, un-instantiated classes are available everywhere (because you can instatiate everywhere without telling PHP you are going to use the class). Example: <?php clas...
To confirm if you're using the provided PDB, CorporateComponent.pdb, during debugging within the Visual Studio IDE review the output window and locate the line indicating that the CorporateComponent.dll is loaded and followed by the string <code>Symbols loaded</code>. To illustrate from a project of mine: The...
I finally got this working with danb's help above. This is my resource bundle class and resource bundle control class. I used this code from @[danb]'s. ResourceBundle bundle = ResourceBundle.getBundle("AwesomeBundle", locale, DbResourceBundle.getMyControl()); javax.servlet.jsp.jstl.core.Config.set(act...
The Perl documentation comes with a nice collection of FAQs. Your question is frequently asked: % perldoc -q duplicate The answer, copy and pasted from the output of the command above, appears below: <pre>Found in /usr/local/lib/perl5/5.10.0/pods/perlfaq4.pod How can I remove duplicate elements from a l...
The Perl documentation comes with a nice collection of FAQs. Your question is frequently asked: % perldoc -q duplicate The answer, copy and pasted from the output of the command above, appears below: <pre>Found in /usr/local/lib/perl5/5.10.0/pods/perlfaq4.pod How can I remove duplicate elements from a l...
Delete Amazon S3 buckets?
|amazon-s3|buckets|
I've been interacting with Amazon S3 through [S3Fox][1] and I can't seem to delete my buckets. I select a bucket, hit delete, confirm the delete in a popup, and... nothing happens. Is there another tool that I should use? [1]: https://addons.mozilla.org/en-US/firefox/addon/3247
|amazon|amazon-s3|buckets|
My first suggestion would be to use a drop-in logging tool like log4net, which will make formatting much more automatic. If you are going to go the route of two files (and I agree with Craig that a database is probably a better choice,) you can probably save yourself a lot of heartache by having one file that is as ...
Have you installed Visual Studio 2005 Service Pack 1?
Its true the hardware load balancer could be set to sticky sessions to solve the issue, but in a perfect world, I would like the feature turned off.
The fact that big sites will accept OpenID isn't, on it's own, enough to make it mainstream. The closest I've seen so far was having LiveJournal both accept and provide OpenID authentication (which I believe it has been doing for quite some time). But I think that just accepting OpenID isn't enough. What we real...
What version of TinyMCE will work in Drupal 5 with google chrome?
|drupal|tinymce|
My drupal site (internal) will not display the TinyMCE editor when using Google Chrome browser. Has anyone gotten TinyMCE to work with Chrome in Drupal 5?
This was the answer I gave on a [related question][1]: /// <summary> /// Blocks until the file is not locked any more. /// </summary> /// <param name="fullPath"></param> bool WaitForFile(string fullPath) { int numTries = 0; while (true)...
Multi-Paradigm Languages
|php|object-oriented|paradigms|procedural|
In a language such as (since I'm working in it now) PHP, which supports procedural and object-oriented paradigms, is there a good rule of thumb for determining which paradigm best suits a new project? If not, how can you make the decision?
|php|oop|paradigms|procedural|
Use [CreateFile][1] in a loop with OPEN_ EXISTING flag and FILE_ ALL_ ACCESS (or you might need only a subset, see http://msdn.microsoft.com/en-us/library/aa364399(VS.85).aspx Examine the handle returned against -1 (INVALID_ HANDLE_ VALUE) for failure. It's still polling, but this will save the cost of an exception...
In a sufficiently complex system there are some places where some UML is considered useful. The useful diagrams for a system, vary by applicability, but the most widely used ones are State Diagrams, Activity Diagrams and Sequence Diagram. There are many enterprises who swear by them and many who outright reject them...
In a sufficiently complex system there are some places where some UML is considered useful. The useful diagrams for a system, vary by applicability. But the most widely used ones are State Diagrams, Activity Diagrams and Sequence Diagram. There are many enterprises who swear by them and many who outright reject ...
HTML differences between browsers
|html|browsers|
Do you know of any differences in handling HTML tags/properties in different browsers? For example, I once saw a page with a input tag with a maxlength field set to "2o". Firefox and Opera ignore the "o", and set the max length to 2, while Internet Explorer ignores the field altogether. Do you know of any more? (Not...