instruction
stringlengths
0
30k
|c|compiler-construction|gcc|
I have a library I created, mylib.c: #include <mylib.h> int testlib() { printf("Hello world\n"); return (0); } mylib.h: #include <stdio.h> extern int testlib(); In my program, I've attempted to call this library function: myprogram.c: #include <mylib.h> int main (int argc, char *argv[]) { testlib(); return (0); } When I attempt to compile this program I get the following error: In file included from myprogram.c:1 mylib.h:2 warning: function declaration isn't a prototype I'm using: gcc (GCC) 3.4.5 20051201 (Red Hat 3.4.5-2) My question is, what is the proper way to declare a function prototype?
C++ Compiler Error C2371 - Redefinition of WCHAR
|c++|compiler-construction|
I am getting C++ Compiler error C2371 when I include a header file that itself includes odbcss.h. My project is set to MBCS. C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\odbcss.h(430) : error C2371: 'WCHAR' : redefinition; different basic types 1> C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\winnt.h(289) : see declaration of 'WCHAR' I don't see any defines in odbcss.h that I could set to avoid this. Has anyone else seen this?
Can you use the 3.5 framework? Linq to XML is fantastic, and simple.
Try: extern int testlib(void);
Math is your friend: import static java.lang.Long.toString; import static java.lang.Math.round; import static java.lang.Math.random; import static java.lang.Math.pow; import static java.lang.Math.abs; import static java.lang.Math.min; public class RandomAlphaNum() { public static String gen(int length) { StringBuffer sb = new StringBuffer(); for (int i = length; i > 0; i -= 12) sb.append(toString(round(random() * pow(36, min(12, abs(i)))), 36)); return sb.toString(); } }
Math is your friend: import static java.lang.Math.round; import static java.lang.Math.random; import static java.lang.Math.pow; import static java.lang.Math.abs; import static java.lang.Math.min; public class RandomAlphaNum { public static String gen(int length) { StringBuffer sb = new StringBuffer(); for (int i = length; i > 0; i -= 12) sb.append(Long.toString(round(random() * pow(36, min(12, abs(i)))), 36)); return sb.toString(); } } Here's a sample run: scala> RandomAlphaNum.gen(42) res3: java.lang.String = uja6snx21bswt89s3ubxssu8g6qlu16ffzqaxxoy
import static java.lang.Math.round; import static java.lang.Math.random; import static java.lang.Math.pow; import static java.lang.Math.abs; import static java.lang.Math.min; import static org.apache.commons.lang.StringUtils.leftPad public class RandomAlphaNum { public static String gen(int length) { StringBuffer sb = new StringBuffer(); for (int i = length; i > 0; i -= 12) { int n = min(12, abs(i)); sb.append(leftPad(Long.toString(round(random() * pow(36, n)), 36), n, '0')); } return sb.toString(); } } Here's a sample run: scala> RandomAlphaNum.gen(42) res3: java.lang.String = uja6snx21bswf9t89s00bxssu8g6qlu16ffzqaxxoy
Is there a reason that you want it in Flash? If a plain, old PNG will work, try the [Google Chart API](http://code.google.com/apis/chart/).
Epoch is pretty large and available in US and EU: [http://www.epoch.com/en/index.html][1] I have no idea about their conditions though. [1]: http://www.epoch.com/en/index.html
I have worked for a company that developed a system for distributing media content to dedicated "players". It was web based and used ASP.NET technology and have tried almost every possible media format you can think of and your choice really comes down to asking yourself: does it needs to play directly out of the box, or can I make sure that the components required to play the videos can be installed beforehand? If your answer is that it needs to play out of the box then really your only option is flash (I know that it is not installed by default, but most will already have it installed) If it is not a big issue that extra components are needed then you can go with formats that are supported by windows media player The reason why windows media player falls into the second option is because for some browsers and some formats extra components must be installed. We had the luxury that the "players" were provided by us, so we could go for the second option, however even we tried to [convert as much as possible][1] back to flash because it handles way better than windows media player [1]: http://ffmpeg.mplayerhq.hu/
I'd have to go with paypal. I've used it in the past, and its really quite painless. All you need to do is create an account, and it's automatically available to you.
<http://www.authorize.net/> works well. This type of solution would allow your customer to enter his/her credit card directly.
<http://teethgrinder.co.uk/open-flash-chart/> seems really sweet. I suggest you give it a look.
I can vouch that I've had good experiences with [PHP/SWF charts][1] (and by extension, the XML/SWF charts too). It's easy to create really subtle chart effects. Pie charts fading in one slice at a time looks fairly professional without being annoying. [1]: http://www.maani.us/charts/index.php
I can vouch that I've had good experiences with [PHP/SWF charts][1] (and by extension, the XML/SWF charts too). It's easy to create really subtle chart effects. Pie charts fading in one slice at a time looks fairly professional without being annoying. Edit: Scratch that, [Open-Flash-Chart][2] looks WAY better. I recede my suggestion. [1]: http://www.maani.us/charts/index.php [2]: http://teethgrinder.co.uk/open-flash-chart/
Appropriate pagefile size for SQL Server
|windows|sql-server|
Does any know a good rule of thumb for the appropriate pagefile size for a Windows 2003 server running SQL Server?
I'm no expert on Agile development, but I would imagine that integrating some basic automated pen-test software into your build cycle would be a good start. I have seen several software packages out there that will do basic testing and are well suited for automation.
You can use a file system watcher to check when the file has been changed. It only becomes "changed" after whichever program had the file previously closes the file. I know you asked for C#, but my VB.Net is much better. Hope you or someone else can translate. It tries to open the file, if it isn't available, it adds a watcher, and waits for the file to be changed. After the file is changed, it tries to open again. It throws an exception if it waits more than 120 seconds, because you may get caught in a situation where the file is never released. Also, I decided to add a timeout of waiting for the file change of 5 seconds, in case of the small possibility that the file was closed prior to the actual file watcher being created. Public Sub WriteToFile(ByVal FilePath As String, ByVal FileName As String, ByVal Data() As Byte) Dim FileOpen As Boolean Dim File As System.IO.FileStream = Nothing Dim StartTime As DateTime Dim MaxWaitSeconds As Integer = 120 StartTime = DateTime.Now FileOpen = False Do Try File = New System.IO.FileStream(FilePath & FileName, IO.FileMode.Append) FileOpen = True Catch ex As Exception If DateTime.Now.Subtract(StartTime).TotalSeconds > MaxWaitSeconds Then Throw New Exception("Waited more than " & MaxWaitSeconds & " To Open File.") Else Dim FileWatch As System.IO.FileSystemWatcher FileWatch = New System.IO.FileSystemWatcher(FilePath, FileName) FileWatch.WaitForChanged(IO.WatcherChangeTypes.Changed,5000) End If FileOpen = False End Try Loop While Not FileOpen If FileOpen Then File.Write(Data, 0, Data.Length) File.Close() End If End Sub
**Python** uses pass-by-value, but since all such values are object references, the net effect is something akin to pass-by-reference. However, Python programmers think more about whether an object type is *mutable* or *immutable*. Mutable objects can be changed in-place (e.g., dictionaries, lists, user-defined objects), whereas immutable objects can't (e.g., integers, strings, tuples). The following example shows a function that is passed two arguments, an immutable string, and a mutable list. >>> def do_something(a, b): ... a = "Red" ... b.append("Blue") ... >>> a = "Yellow" >>> b = ["Black", "Burgundy"] >>> do_something(a, b) >>> print a, b Yellow ['Black', 'Burgundy', 'Blue'] Because the `a` parameter in `do_something()` is a reference to an immutable string object, the line `a = "Red"` merely creates a local name, `a`, for the string value `"Red"` and has no effect on the passed-in argument. The `b` parameter is a reference to a mutable list object, and the `.append()` method performs an in-place extension of the list, tacking on the new `"Blue"` string value. (Because string objects are immutable, they don't have any methods that support in-place modifications.) Once the function returns, the re-assignment of `a` has had no effect, while the extension of `b` clearly shows pass-by-reference style call semantics. Note that even if the argument for `a` is a mutable type, the re-assignment within the function is not an in-place operation, and so there would be no change to the passed argument's value: >>> a = ["Purple", "Violet"] >>> do_something(a, b) >>> print a, b ['Purple', 'Violet'] ['Black', 'Burgundy', 'Blue', 'Blue'] If you did't want your list modified by the called function, you would instead use the immutable tuple type (identified by the parentheses in the literal form, rather than square brackets), which does not support the in-place `.append()` method: >>> a = "Yellow" >>> b = ("Black", "Burgundy") >>> do_something(a, b) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 3, in do_something AttributeError: 'tuple' object has no attribute 'append'
Here it is in Java: import static java.lang.Math.round; import static java.lang.Math.random; import static java.lang.Math.pow; import static java.lang.Math.abs; import static java.lang.Math.min; import static org.apache.commons.lang.StringUtils.leftPad public class RandomAlphaNum { public static String gen(int length) { StringBuffer sb = new StringBuffer(); for (int i = length; i > 0; i -= 12) { int n = min(12, abs(i)); sb.append(leftPad(Long.toString(round(random() * pow(36, n)), 36), n, '0')); } return sb.toString(); } } Here's a sample run: scala> RandomAlphaNum.gen(42) res3: java.lang.String = uja6snx21bswf9t89s00bxssu8g6qlu16ffzqaxxoy
This error happens when you redeclare a variable of the same name as a variable that has already been declared. Have you looked to see if odbcss.h has declared a variable you already have?
You can use Reflection to set <code>myClassImpl</code> by calling <code>instantiateMyClass()</code> again. You can look at [this answer][1] to see example patterns for playing around with private methods and variables. [1]: http://stackoverflow.com/questions/34571/whats-the-best-way-of-unit-testing-private-methods#34658
You can use Reflection to set <code>myClassImpl</code> by calling <code>instantiateMyClass()</code> again. Take a look at [this answer][1] to see example patterns for playing around with private methods and variables. [1]: http://stackoverflow.com/questions/34571/whats-the-best-way-of-unit-testing-private-methods#34658
right now i don't have crystal reports installed on my machine but if i remember correctly you can select as the source of your report an xml file. i believe that you can also select the xsd with the data definition for your xml file. in my case, since i was working with a dataset i would run my application and save the xml representation of the dataset with dataset.writexml(true) so that i would end up with an xml file that include the data definition
What are the best ways to determine what port an application is using?
|sql-server|port|msde|
This is an adapted version of a question from someone in my office. She's trying to determine how to tell what ports MSDE is running on for an application we have in the field. Answers to that narrower question would be greatly appreciated. I'm also interested in a broader answer that could be applied to any networked applications.
Download currports from [here][1]. It will show you which ports are open and which processes are associated with each port. Scroll down to: Download CurrPorts [1]: http://www.nirsoft.net/utils/cports.html
If you use an XmlTextReader class it will technically be faster than using an XmlDocument, which parses the entire file and builds a DOM for you. But you must also consider that fact that with an XmlTextReader, you are just reading one node at a time, so there is the additional overhead of making sense of the data as you read it. If you are going to end up storing everything yourself anyway, using XmlDocument might end up being more efficient.
**Python** uses pass-by-value, but since all such values are object references, the net effect is something akin to pass-by-reference. However, Python programmers think more about whether an object type is *mutable* or *immutable*. Mutable objects can be changed in-place (e.g., dictionaries, lists, user-defined objects), whereas immutable objects can't (e.g., integers, strings, tuples). The following example shows a function that is passed two arguments, an immutable string, and a mutable list. >>> def do_something(a, b): ... a = "Red" ... b.append("Blue") ... >>> a = "Yellow" >>> b = ["Black", "Burgundy"] >>> do_something(a, b) >>> print a, b Yellow ['Black', 'Burgundy', 'Blue'] The line `a = "Red"` merely creates a local name, `a`, for the string value `"Red"` and has no effect on the passed-in argument (which is now hidden, as `a` must refer to the local name from then on). Assignment is not an in-place operation, regardless of whether the argument is mutable or immutable. The `b` parameter is a reference to a mutable list object, and the `.append()` method performs an in-place extension of the list, tacking on the new `"Blue"` string value. (Because string objects are immutable, they don't have any methods that support in-place modifications.) Once the function returns, the re-assignment of `a` has had no effect, while the extension of `b` clearly shows pass-by-reference style call semantics. As mentioned before, even if the argument for `a` is a mutable type, the re-assignment within the function is not an in-place operation, and so there would be no change to the passed argument's value: >>> a = ["Purple", "Violet"] >>> do_something(a, b) >>> print a, b ['Purple', 'Violet'] ['Black', 'Burgundy', 'Blue', 'Blue'] If you didn't want your list modified by the called function, you would instead use the immutable tuple type (identified by the parentheses in the literal form, rather than square brackets), which does not support the in-place `.append()` method: >>> a = "Yellow" >>> b = ("Black", "Burgundy") >>> do_something(a, b) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 3, in do_something AttributeError: 'tuple' object has no attribute 'append'
How to make junior programmers write tests?
|testing|bestpractices|unittesting|
We have a junior programmer that simply doesn't write enough tests. I have to nag him every two hours, "have you written tests?". We've tried: - Showing that the design becomes simpler - Showing it prevents defects - Making it an ego thing saying only bad programmers don't - This weekend 2 team members had to come to work because his code had a NULL reference and he didn't test it My work requires top quality stable code, and usually everyone 'get it' and there's no need to push tests through. We know we can make him write tests, but we all know the useful tests are those written when you're into it. Do you know of more motivations?
|unittesting|bestpractices|testing|
We have a junior programmer that simply doesn't write enough tests. I have to nag him every two hours, "have you written tests?". We've tried: - Showing that the design becomes simpler - Showing it prevents defects - Making it an ego thing saying only bad programmers don't - This weekend 2 team members had to come to work because his code had a NULL reference and he didn't test it My work requires top quality stable code, and usually everyone 'gets it' and there's no need to push tests through. We know we can make him write tests, but we all know the useful tests are those written when you're into it. Do you know of more motivations?
Does the parent div have a defined width either pixel or percentage? Not 100% sure but I think in IE7, the parent div needs a defined width for child percentage divs to work correctly.
`Math.Floor` rounds down, `Math.Ceiling` rounds up, and `Math.Truncate` rounds towards zero. Thus, `Math.Truncate` is like `Math.Floor` for positive numbers, and like `Math.Ceiling` for negative numbers. Here's the [reference](http://msdn.microsoft.com/en-us/library/system.math.truncate.aspx). For completeness, `Math.Round` rounds to the nearest integer. If the number is exactly midway between two integers, then it rounds towards the even one. [Reference.](http://msdn.microsoft.com/en-us/library/system.math.round.aspx)
Unloading a ByteArray in Actionscript 3.
|apache-flex|actionscript-3|
Does anyone know how to forcefully unload a ByteArray from memory in AS3? I have tried (without success): <pre><code> byteArray.length = 0; byteArray = new ByteArray(); and for ( var i:int=0; i&lt;byteArray.length; i++ ) { byteArray[i] = null; } </code></pre> Any ideas?
Consider using a [ManualResetEvent][1] to block the main thread at the end of its processing, and call Reset() on it once the timer's processing has finished. If this is something that needs to run constantly, consider moving this into a service process instead of a console app. [1]: http://msdn.microsoft.com/en-us/library/system.threading.manualresetevent.aspx "MSDN Reference"
Here is one hack that might work. Isn't clean, but it looks like it might work: http://www.brokenbuild.com/blog/2006/08/15/mysql-triggers-how-do-you-abort-an-insert-update-or-delete-with-a-trigger/ Essentially you just try to update a column that doesn't exist.
Why don't you want to use triggers. They are a good thing if you use them correctly. If you use them as a way to enforce referential integrity that is when they go from good to bad. But if you use them for monitoring, they are not really considered taboo.
Have a look at this article <http://www.gskinner.com/blog/archives/2006/06/as3_resource_ma.html> IANA actionscript programmer, however the feeling I'm getting is that, because the garbage collector might not run when you want it to. Hence <http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/> So I'd recommend trying out their collection code and see if it helps private var gcCount:int; private function startGCCycle():void{ gcCount = 0; addEventListener(Event.ENTER_FRAME, doGC); } private function doGC(evt:Event):void{ flash.system.System.gc(); if(++gcCount > 1){ removeEventListener(Event.ENTER_FRAME, doGC); setTimeout(lastGC, 40); } } private function lastGC():void{ flash.system.System.gc(); }
(I'm not positive about this, but...) AS3 uses a non-deterministic garbage collection. Which means that unreferenced memory will be freed up whenever the runtime feels like it (typically not unless there's a reason to run, since it's an expensive operation to execute). This is the same approach used by most modern garbage collected languages (like C# and Java as well). Assuming there are no other references to the memory pointed to by byteArray or the items within the array itself, the memory will be freed at some point after you exit the scope where byteArray is declared. You can force a garbage collection, though you really shouldn't. If you do, do it only for testing...if you do it in production, you'll hurt performance much more than help me. To force a GC, try (yes, twice): flash.system.System.gc(); flash.system.System.gc(); You can read more at: http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/
You can do it Asynchronously using .NET Ajax PageMethods. See [here](http://www.singingeels.com/Articles/Using_Page_Methods_in_ASPNET_AJAX.aspx) or [here](http://weblogs.asp.net/sohailsayed/archive/2008/02/23/calling-methods-in-a-codebehind-function-pagemethods-from-client-side-using-ajax-net.aspx).
Toad for SQL Server does this nicely, if you're considering a commercial product.
I'm not at work so this is off the top of my head, but: If you get a reference to the Site, can you try to create a new SPSite with the SYSTEM-UserToken? SPUserToken sut = thisSite.RootWeb.AllUsers["SHAREPOINT\SYSTEM"].UserToken; using (SPSite syssite = new SPSite(thisSite.Url,sut){ // Do what you have to do }
I agree with [Leac][1]. I actually play with [Scratch][2] sometimes if I'm bored. It's a pretty fun visual way of looking at code. How it works is, they give you a bunch of "blocks" (these look like legos) which you can stack. And by stacking these blocks, and interacting with the canvas (where you put your sprites, graphics), you can create games, movies, slideshows... it's really interesting. When it's complete you can upload it right to the Scratch websites, which is a youtube-ish portal for Scratch applications. Not only that, but you can download any submission on the website, and learn from or extend other Scratch applications. [1]: #3135 [2]: http://scratch.mit.edu/
Can you access the windows registry from Adobe Air?
|air|apache-flex|actionscript-3|
(y/N)
|apache-flex|actionscript-3|air|
(y/N) Edit: Read-only access is fine.
Check out the open source project [LMMS][1]. It's a music studio for Linux that includes the ability to use MIDI keyboards with software instruments. If you dig around in [source files][2] with 'midi' in the name, you'll probably find what you're looking for. [1]: http://lmms.sourceforge.net/ [2]: http://lmms.sourceforge.net/wiki/index.php?title=Accessing_SVN
The [Microsoft AJAX library][1] will accomplish this. You could also create your own solution that involves using AJAX to call your own aspx (as basically) script files to run .NET functions. I suggest the Microsoft AJAX library. Once installed and referenced, you just add a line in your page load or init: Ajax.Utility.RegisterTypeForAjax(GetType(YOURPAGECLASSNAME)) Then you can do things like: <Ajax.AjaxMethod()> _ Public Function Get5() AS Integer Return 5 End Function Then, you can call it on your page as: var myVar = PageClassName.Get5(javascriptCallbackFunction); The last parameter of your function call must be the javascript callback function that will be executed when the AJAX request is returned. [1]: http://www.asp.net/ajax/
I would personally store the large data outside of the database. Pros: Stores everything in one please, easy access to data files, easy baskup Cons: Decreases database performance, many page splits, possible database coruption
Choosing a new development machine
|cpu|
I'm not sure how this question will be recieved here but lets give it a shot... It's time for me to get a new dev PC. What's the best choice these days? I typically have 2-3 Visual Studios open along with mail and all that stuff. Ideally I would imagine 2+ GB of RAM would be nice as my current XP box is dying. =) I hopped on the Dell site (my days of building PC's are behind me. I just need something that gets the job done.) and started browsing around only to be confused from all the processor choices. What does a typical dev box need these days? Duo? Quad? Is it worth going to 64 bit Vista as well? It's been a while since I got a new machine so I'm just looking for some guidance. Thanks
echo $'\002\003' > ./myfile
Ctrl-V escapes the next keystoke. That's how you can get a Ctrl-C out: Ctrl-V Ctrl-C
People are probably going to yell at me...but I've found that Vista 64 is mostly worth it. The main reason for me though is that I'm always maxing out my memory and having a 64bit OS allows me to go past the <4GB limit of 32bit. But even if you don't get 64bit, just buy 2 2GB RAM cards anyways....you will be able to use most of it (my system shows 3.5GB on 32bit) and then you've got it for if you upgrade later and (if your system has 4 slots) you'll have room to expand to 8GB later on....
There are some additional questions that would make our answers more complete. - Are you going to want to travel with it? - How important is screen real estate to you? - Will you be doing interpreted or compiled? - Is it web based development, or client based? I've seen some great deals on 17" HP laptops lately - one at Best Buy that had 4GB of RAM and a monster hard drive along with a 2.4+ Ghz Core 2 Duo for roughly $800 after tax.
I'm not expecting anything like this to exist. The tool would have to first implement everything that the SQL parser in your database implements, and then it would have to do a data model analysis to predict "bad" queries. Your best bet might be to write a plugin for a text editor that did some basic checking for suspicious patterns and highlighted them differently than the standard .sql mode. But even that would be quite difficult. I would be happy with a tool that set off alarm bells whenever I typed in an update statement without a where clause. And perhaps administered a mild electric shock, since it's usually about 1 in the morning after a long day when mistakes like that happen.
Not looking to travel. I'd rather get a powerful desktop for my dollar. I have a nice big panel here so problem with that. The majority of my development is ASP.NET stuff with some winforms projects.
I think that like many events in VB, it can't be switched off. Just set a boolean flag as you've suggested.
1. You should translate your requirements into a Product Backlog. This backlog is what you use to decide what Sprint Backlog items are chosen for each Sprint iteration. Management decides what is on the Product Backlog, but the team needs to agree to what they can produce in the Sprint (this is a negotiation that occurs at every sprint). 2. Your Product Owner (usually a product manager) drives the creation of the stories. The Stories are simple (as a system admin, I need to be able to add a user). If your product management does not understand your product, you are in trouble. 3. Agile is about designing as required. The design is never in the story. The spec can be per story, or per feature. You could design all your CRUD inside of one spec, which covers multiple stories. 4. The Product Owner gets a product demo at the end of every Sprint. So value is demonstrated at every cycle. So your VP would get reports on a monthly basis (ususally 3 weeks of dev + 1 week to prepare for the Sprint demo).
6/2002/2003/2005/2008, I believe, can all coexist. Though just this weekend I purged 'em all except 2008 as it went totally mad and stopped showing the build output. Plus my splash screen wasn't right. Now it is.
Setting an attribute on an object won't give a compile-time or a run-time error, it will just do nothing useful if the object doesn't access it (i.e. "`node.noSuchAttr = 'bar'`" would also not give an error). Unless you need a specific feature of `minidom`, I would look at `ElementTree`: import sys from xml.etree.cElementTree import Element, ElementTree def make_xml(): node = Element('foo') node.text = 'bar' doc = ElementTree(node) return doc if __name__ == '__main__': make_xml().write(sys.stdout)
The ability to express real-world scenarios in code. foreach(House house in location.Houses) { foreach(Deliverable mail in new Mailbag(new Deliverable[] { GetLetters(), GetPackages(), GetAdvertisingJunk() }) { if(mail.AddressedTo(house)) { house.Deliver(mail); } } } - foreach(Deliverable myMail in GetMail()) { IReadable readable = myMail as IReadable; if ( readable != null ) { Console.WriteLine(readable.Text); } } To achieve this you need: * **Pointers/References** to ensure that this == this and this != that. * **Classes** to point to (e.g. Arm) that store data (int hairyness) and operations (Throw(IThrowable)) * **Polymorphism (Inheritance and/or Interfaces)** to treat specific objects in a generic fashion so you can read books as well as graffiti on the wall (both implement IReadable) * **Encapsulation** because an apple doesn't expose an Atoms[] property
**Archetype** The ability to express real-world scenarios in code. foreach(House house in location.Houses) { foreach(Deliverable mail in new Mailbag(new Deliverable[] { GetLetters(), GetPackages(), GetAdvertisingJunk() }) { if(mail.AddressedTo(house)) { house.Deliver(mail); } } } - foreach(Deliverable myMail in GetMail()) { IReadable readable = myMail as IReadable; if ( readable != null ) { Console.WriteLine(readable.Text); } } **Why?** To help us understand this shit more easily. It makes better sense in our heads and if implemented correctly makes the code more efficient, re-usable and reduces repetition. To achieve this you need: * **Pointers/References** to ensure that this == this and this != that. * **Classes** to point to (e.g. Arm) that store data (int hairyness) and operations (Throw(IThrowable)) * **Polymorphism (Inheritance and/or Interfaces)** to treat specific objects in a generic fashion so you can read books as well as graffiti on the wall (both implement IReadable) * **Encapsulation** because an apple doesn't expose an Atoms[] property
I ultimately ended up finding the <a href="http://groups.google.com/group/borland.public.delphi.winapi/browse_frm/thread/36b3d5a199be91f4/7de8dab437f6aa1e?lnk=st&q=delphi+main+form+modal+dialog+z-order#7de8dab437f6aa1e">answer</a> using Google Groups. In a nutshell, all the modal dialogs need to have the following added to them: <blockquote><pre><code> procedure TDialogForm.CreateParams(var Params: TCreateParams); begin inherited; Params.Style := Params.Style or WS_POPUP; Params.WndParent := (Owner as TWinControl).Handle; end; </code></pre></blockquote> I'm guessing this does the equivalent of Lars' and Marius' answers in Delphi 7.
I did it this way (ZF 1.5): $name = new Zend_Form_Element_Text('name'); $name->setLabel('Full Name: ') ->setRequired(true) ->addFilter('StripTags') ->addFilter('StringTrim') ->addValidator($MyNotEmpty); so, the addValidator() is the interesting part. The Message is set in an "Errormessage File" (to bundle all custom messages in one file): $MyNotEmpty = new Zend_Validate_NotEmpty(); $MyNotEmpty->setMessage($trans->translate('err.IS_EMPTY'),Zend_Validate_NotEmpty::IS_EMPTY); hope this helps...
> Is it better to go all the way and log everything across multiple attempts/days, or log only what you need to (given hdd is cheap). The fact harddrives are cheap really isn't a good reason to verbosely log everything possible, for a few reasons.. For one, with a very busy application, you really don't want to slow it down and tie up disc-writes writing logs (harddrives are pretty slow). The second point, and the more important one - there's really very little to gain from terabytes worth of logs.. For development, they can are useful, but you don't need to keep more than a few minutes of them.. Some logging is of course useful, having different levels is about the only way to go about it - for example debug() info() only get logged if requested (in a config, or command line flag), then maybe warning() and error() get sent to a log file For most of the things I've written (smallish scripts) I generally just have a debug() function, that checks if --verbose is set, and prints the message.. That way I can shove debug("some value: %s" % (avar)) when needed, and not have to worry about going back and removing debugging print() statements everwhere. For web applications, I generally just use the web-server logs for statistics, and the error log. I use things like mod_rewrite's log when needed, but it would be idiotic to leave this enabled beyond development (as it creates many many lines on each page request) I suppose it depends on the application itself, but generally, for big applications use multiple levels of logs that can be activated when needed. For smaller things, a --verbose flag or equivalent, for web applications, log errors and (to a point) log hits. Basically, in "production" log only the information you can use, in development log everything you could possible need to fix problems.
Even if you create a voronoi diagram, that still means you need to compare your x, y coordinates to all 15 thousand created areas. To make that easier, the first thing that popped into my mind though was to create some sort of grid over the possible values, so that you can easily place and x/y coordinate into one of the boxes in a grid, if the same is done for the list of areas you should quickly shrink the possible candidates for comparison (because the grid would be more rectangular, it's possible for an area to be in multiple grid positions).
Do webtests need VS tester edition on the build server?
|tfs|build-process|
I have some webtests I'd like to run as part of a build. Can webtests be run on the TFS build server without VS 2008 team system tester edition installed?
I have some webtests I'd like to run as part of a build. Can webtests be run on the TFS build server without VS 2008 team system tester edition installed? Webtests can only be recorded using the tester edtion of visual studio. Here's a [post][1] from Jeff while he was at Vertigo. My question is in order to run these tests on the build server does Tester edition of visual studio need to be installed? [1]: http://blogs.vertigosoftware.com/teamsystem/archive/2006/03/09/Simple_Web_Testing_with_Team_Test_Edition.aspx
Give your submit buttons same name like this: <input type="submit" name="submitButton" value="Previous Page" /> <input type="submit" name="submitButton" value="Next Page" /> When the user presses enter and the *Request* goes to server, you can check the value for **submitButton** on your server-side code which contains a collection of form name/value pairs. For example in classic ASP: If Request.Form("submitButton") = "Previous Page" Then ' Code for Previous Page ElseIf Request.Form("submitButton") = "Next Page" Then ' Code for Next Page End If Reference: [Using multiple submit buttons on a single form][1] [1]: http://www.chami.com/tips/internet/042599I.html
Would it be possible for you to change the previous button type int a button like this: <input type="button" name="prev" value="Previous Page" /> Now the Next button would be the default, plus you could also add the default attribute to it so that your browser will highlight it like so: <input type="submit" name="next" value="Next Page" default /> Hope that helps, Wally
Unfortunately when it comes to memory management in Flash/actionscript there isn't a whole lot you can do. ActionScript was designed to be easy to use (so they didn't want people to have to worry about memory management) The following is a workaround, instead of creating a ByteArray variable try this. var byteObject:Object = new Object(); byteObject.byteArray = new ByteArray(); ... //Then when you are finished delete the variable from byteObject delete byteObject.byteArray; Where byteArray is a dynamic property of byteObject, you can free the memory that was allocated for it.
This is the method I am currently using on one of my websites. This only returns a relative day, hour, time. And then the user has to slap on "ago" in the output. public static string ToLongString(this TimeSpan time) { string output = String.Empty; if (time.Days > 0) output += time.Days + " days "; if ((time.Days == 0 || time.Days == 1) && time.Hours > 0) output += time.Hours + " hr "; if (time.Days == 0 && time.Minutes > 0) output += time.Minutes + " min "; if (output.Length == 0) output += time.Seconds + " sec"; return output.Trim(); }
@jeff IMHO yours seems a little long. However it does seem a little more robust with support for "yesterday" and "years". But in my experience when this is used the person is most likely to view the content in the first 30 days. It is only the really hardcore people that come after that. So that is why I usually elect to keep this short and simple. This is the method I am currently using on one of my websites. This only returns a relative day, hour, time. And then the user has to slap on "ago" in the output. public static string ToLongString(this TimeSpan time) { string output = String.Empty; if (time.Days > 0) output += time.Days + " days "; if ((time.Days == 0 || time.Days == 1) && time.Hours > 0) output += time.Hours + " hr "; if (time.Days == 0 && time.Minutes > 0) output += time.Minutes + " min "; if (output.Length == 0) output += time.Seconds + " sec"; return output.Trim(); }
According to Mark Russo (http://introducinglinq.com/blogs/marcorusso/archive/2008/07/20/use-of-distinct-and-orderby-in-linq.aspx) > "The problem is that the Distinct > operator does not grant that it will > maintain the original order of > values." So your query will need to work like this var names = (from DataRow dr in dataTable.Rows select (string)dr["Name"]).Distinct().OrderBy( name => name );
|bestpractices|unittesting|testing|
We have a junior programmer that simply doesn't write enough tests. I have to nag him every two hours, "have you written tests?" We've tried: - Showing that the design becomes simpler - Showing it prevents defects - Making it an ego thing saying only bad programmers don't - This weekend 2 team members had to come to work because his code had a NULL reference and he didn't test it My work requires top quality stable code, and usually everyone 'gets it' and there's no need to push tests through. We know we can make him write tests, but we all know the useful tests are those written when you're into it. Do you know of more motivations?
|unit-testing|testing|
IE 7+ Favorites
|internet-explorer|bookmarks|favorites|
Is it possible to develop a plug-in for Internet Explorer that can replace the existing favorites functionality?
If you are looking for a good text on F# [Expert F#][1] is co-written by Don Syme. Creator of F#. He worked on generics in .NET specifically so he could create F#. F# is modeled after OCaml so any OCaml text would help you learn F# as well. [1]: http://www.apress.com/book/view/9781590598504
Is UML practical ?
|uml|project-management|diagram|bestpractices|