instruction
stringlengths
0
30k
I came across this recently, up until now I have been happily overriding the equality operator (**==**) and/or **Equals** method in order to see if two references types actually contained the same **data** (i.e. two different instances that look the same). I have been using this even more since I have been getting m...
Are you using the CreateTaskWithContentTypeId activity in your workflow? If you are then you need to ensure that the content types have been added to the Workflow Tasks list. SharePoint will not add them automatically. Oisin
My favourite two features are auto-completion (bound to ⎋ [esc]), and column editing (bound to ⌥ [alt]) both of these things save me quite a lot of time, and are definitely '[robot ninjas](http://www.pragprog.com/titles/textmate/textmate "The Pragmatic Bookshelf | TextMate")'. The book linked above is also a really ...
Have you tried [NHibernate][1]? It's much more matured product than Entity Framework. It's free. [1]: http://www.hibernate.org/343.html
Well, it seems DBSight [doesn't meet the FOSS requirement][1], so unless it is an absolutely stellar solution, it is not an option for me right now... [1]: http://www.dbsight.net/index.php?q=node/42
How do I correctly access static member classes?
|java|
I have two classes, and want to include a static instance of one class inside the other and access the static fields from the second class via the first. This is so I can have non-identical instances with the same name. Class A { public static package1.Foo foo; } Class B ...
The first example isn't thread safe - if two threads call getInstance at the same time, that static is going to be a PITA. Some form of mutex would help.
A few possible explanations: 1. Are you running this script on a multi-core processor or multi-processor machine? If you only have one CPU only one thread can use it at any time. 2. Are there transactions or locks involved with steps 1-6 that would prevent it from being done concurrently? 3. Are you certain y...
How do I detect a user's timezone via javascript?
|javascript|
I want the server to always serve dates in UTC in the html, and have javascript on the client site convert it to the user's local timezone. Bonus if I can output in the user's locale date format.
This will print any commits where the diff contains xyz git log -Sxyz foo.c
Tried. Just works.
Printing a monospaced font at default sizes is (on A4 paper) 80 columns by 66 lines.
I am using the Janus Controls at work. They are extremely buggy as far as disposing of themselves go. I would recommend that you make sure that they are getting disposed of correctly. Also, the binding with them sometimes doesn't release, so you have to manually unbind the object to dispose of the control.
Reflectors can get a high-level version of the MSIL code of your .NET application, but that doesn't mean it's necessarily usable/hackable... A lot of the code won't make sense to casual perusal without the names of private variables & functions along with other things that .NET Reflector cannot access without a PDB fil...
There is no way to produce any actions based on compile-time logic in Java without the use of a separate tool. Technically, it is *possible* to use the C pre-processor on Java, but you would have to be careful of its built-in assumptions about the underlying language. If I were you, I would find a better way to accom...
I'm not sure I see why option 1 wouldn't work for you. Keep in mind that you can't have two different threads trying to use the same FileStream at the same time - doing so will definitely cause you problems. BeginRead/EndRead is meant to let your code continue executing while the potentially expensive IO operation take...
I've had plenty of success with using a form that submits to a php script that uses fpdf and passes in the form fields as get variables (maybe not a great best-practice, but it works). <?php require('fpdf.php'); $pdf=new PDF(); $pdf->AddPage(); $pdf->SetY(30); $pdf->SetX(100); ...
Unfortunately, there is no cut and dried answer. Determining what is fair use involves a very subjective and fact-dependent [four point test][1]. You're never really going to know for sure if a borderline use is permissible or not unless you end up in court and a judge decides. The four factors are: 1. the pur...
Reuse define statement from .h file in C# code
|c#|c++|versioning|preprocessor|header|
I have C++ project (VS2005) which includes header file with version number in #define directive. Now I need to include exactly the same number in twin C# project. What is the best way to do it? I'm thinking about including this file as a resource, then parse it at a runtime with regex to recover version number, but ...
I guess it's OK to show the difference as far as value/reference types are concerned this way. It might be a little bit cleaner to use methods for the console output, though. As you said your "someone" was new to development this might not be too important, but there is a nice list of further differences between cla...
Connect to an existing host but to a port that is blocked by the firewall that simply drops TCP SYN packets. For example, www.google.com:81.
Help needed for extending Asp.Net
|asp.net|
As most of you would know, if I drop a file named app_offline.htm in the root of an asp.net application, it takes the application offline [as detailed here](http://asp-net-whidbey.blogspot.com/2006/04/aspnet-20-features-appofflinehtm.html). You would also know, that while this is great, IIS actually returns a 404 co...
There are a couple of tactics I've used in the past to simulate networking issues; 1. Pull out the network cable 2. Switch off the switch (ideally with the switch that the computer is plugged into still being powered so the machine maintains it's "network connection") between your machine and the "target" machine...
Well it has 32Bits and hence can store 2^32-1 different values. Half of those are negative. Do the maths. That's a simple memory rule if you have a good calculator. :) The solution btw is: +2,147,483,647 and the lowest ist −2,147,483,648 (notice that there is one more negative)
Well it has 32Bits and hence can store 2^32 different values. Half of those are negative. Do the maths. That's a simple memory rule if you have a good calculator. :) The solution btw is: +2,147,483,647 and the lowest ist −2,147,483,648 (notice that there is one more negative)
I came across this recently, up until now I have been happily overriding the equality operator (**==**) and/or **Equals** method in order to see if two references types actually contained the same **data** (i.e. two different instances that look the same). I have been using this even more since I have been getting m...
|.net|comparison|operator-overloading|equality|
I came across this recently, up until now I have been happily overriding the equality operator (**==**) and/or **Equals** method in order to see if two references types actually contained the same **data** (i.e. two different instances that look the same). I have been using this even more since I have been getting m...
How can I get Column number of the cursor in a TextBox in C#?
|c#|
I've got a multiline textBox that I would like to have a label on the form displaying the current line and column position of, as Visual Studio does. I know I can get the line # with GetLineFromCharIndex, but how can I get the column # on that line?
I've got a multiline textBox that I would like to have a label on the form displaying the current line and column position of, as Visual Studio does. I know I can get the line # with GetLineFromCharIndex, but how can I get the column # on that line? (I really want the Cursor Position on that line, not 'column', p...
|c#|windows|user-interface|
I'm just about to start doing Javascript TDD on a new project I am working on. My current plan is to use [qunit][1] to do the unit testing. While developing the tests can be run by simply refreshing the test page in a browser. For continuous integration (and ensuring the tests run in all browsers), I will use [Selen...
I favor Grails over Rails, but learning Rails will give you a more balanced perspective and actually open your eyes to overlooked things that are possible in Grails.
Do the structs themselves need to be in contiguous memory, or can you get away with having a vector of struct*? Vectors make a copy of whatever you add to them, so using vectors of pointers rather than objects is one way to improve performance.
Are iframes a terrible idea?
|javascript|iframe|widget|
I'm building a widget, and I've been using iframes to present content within it. At some point, I might start serving third party HTML and JS, so I thought iframes would be a good idea. It does make the widget javascript a little more complicated, and I'm concerned that this might not be the best implementation. ...
Common Lisp defines a function called [ACONS][1] for exactly this purpose, where (acons key value alist) is equivalent to: (cons (cons key value) alist) This strongly suggests that simply consing onto an alist is idiomatic. Note that this means two things: 1. As searches are usually performed ...
I want the server to always serve dates in UTC in the html, and have javascript on the client site convert it to the user's local timezone. > I'm thinking what I want would be [getTimezoneOffset][]. Then I could just add that my Date object created using the UTC time. Bonus if I can output in the user's locale ...
|javascript|duplicate|
How do I display a date/time in the user's locale format and time offset?
|javascript|
I want the server to always serve dates in UTC in the html, and have javascript on the client site convert it to the user's local timezone. Bonus if I can output in the user's locale date format.
Declare a variable that is the root folder of your operation. Prefix your folders with that variable, including in the copy task. Set the variable based on the OS using a conditional, or pass it as an argument to the Ant script.
This may become more of an issue as the next generation of browsers come out with some flavor of a JavaScript compiler. Code executed via Eval may not perform as well as the rest of your JavaScript against these newer browsers. Someone should do some profiling.
I'm very happy with kdesvn - integrates very well with konqueror, much like trortousesvn with windows explorer, and supports most of the functionality of tortoisesvn. Of course, you'll benefit from this integration, if you use kubunto, and not ubuntu.
Two points come to mind: 1. Security (but as long as you generate the string to be evaluated yourself, this might be a non-issue) 2. Performance: until the code to be executed is unknown, it cannot be optimized. (about javascript and performance, certainly [Steve Yegge's presentation][1]) [1]: http://stev...
In order to avoid writing a full C parser in perl, you're trying to strike a balance. Depending on how much needs changing, I would be inclined to do something like a very restrictive s/// and then anything that still matches /Boolean/ gets written to an exception file for human decision making. That way you're not try...
Absolutely. That's how you don't tie the class to some specific persistence implementation. Sometimes I write mock DAO classes that "persist" to memory structures only, and I inject these when unit testing.
I think google gears have such functionality, maybe you could check how they did that.
Basically I get away with programming to interfaces. I try to encapsulate that which changes through cases to avoid code duplication and to isolate code into managable (for my brain) chunks. Later, if I need, I can then refactor the code quite easily.
Unfortunately, you can't really do this just by seeking to the end. That will set the file length to something huge, but may not actually allocate disk blocks for storage. So when you go to write the file, it will still fail.
Allowing for completely unbounded password length has one major drawback if you accept the password from untrusted sources. The sender could try to give you such a long password that it results in a denial of service for other people. For example, if the password is 1GB of data and you spend all your time accept it...
Information Hiding and Properties
|oop|
Does Information Hiding mean I should minimize the number of properties my classes have? Is that right? Do you tend to make your classes private fields with methods?
Some people say Scheme's greatest strength is as a teaching language. While it is very beneficial to learn functional programming (it's an entirely new way of thinking) another benefit in learning scheme is that it is also "pure". Sure it can't do a ton of stuff like java, but that's also what's great about it, it's a ...
Just 8 char long passwords sound simply wrong. If there ought to be a limit, then atleast 20 char is better idea.
Can the NetBeans code formatter be made to format javadoc comments?
|java|netbeans6.1|javadoc|formatting|
The NetBeans 6.1 editor doesn't seem to like to wrap comments, and the code formatter seems to ignore them. For JavaDoc comments, this behaviour seems inappropriate, as you can end up spending a lot of wasted time manually reflowing paragraphs. I was wondering if there's some magic setting to get the builtin code f...
It looks like you're coding in C#, which has a method called Equals that your class should implement, should you want to compare two objects using some other metric than "are these two pointers (because object handles are just that, pointers) to the same memory address?". I grabbed some sample code from [here][1]: ...
It looks like you're coding in C#, which has a method called Equals that your class should implement, should you want to compare two objects using some other metric than "are these two pointers (because object handles are just that, pointers) to the same memory address?". I grabbed some sample code from [here][1]: ...
Thank you very much for your help. I do mean call forwarding and what I would like to do is to have a simple application, perhaps with only 2 big buttons. When pressed, one should forward the incoming calls to my work phone and the other should forward them to my home phone. Being a (desktop application) developer myse...
What if you loaded the resource (file data or whatever) into memory first and then shared it across threads? Since it is a small db. - you won't have as many issues to deal with.
Also note that main() should return an int: int main(void)
Another disadvantage to doing data validation from the database is that often you dont validate the same way in every case. In fact, it often depends on application logic (user roles), and sometimes you might want to bypass validation altogether (cron jobs and maintenance scripts).
With this method you can pass in an abitrary length. It's set as a default as 6. def generate_random_string(length=6) string = "" chars = ("A".."Z").to_a length.times do string << chars[rand(chars.length-1)] end string end
If you are adding each time then you may need to keep a permanent table to track the relationship between source database primary keys and destination database primary keys (at least for the parent table). If you needed to keep this kind of data out of the destination database, you could get SSIS to store/retrieve it f...
In reading the article by Shawn Wildermuth [WPF Threads: Build More Responsive Apps With The Dispatcher][1]: I came accross the following, Which states you can use the Background Worker just like you could in WindowsForms... Fancy that. > BackgroundWorker Now that you have a sense of how the Dispatcher works, y...
you could use this: select dayname,newdayname = CASE dayname WHEN 'Monday' THEN 'Tuesday' WHEN 'Tuesday' THEN 'Wednesday' WHEN 'Wednesday' THEN 'Thursday' WHEN 'Thursday' THEN 'Friday' WHEN 'Friday' THEN 'Monday' WHEN 'Saturday' THEN 'Monday' WHEN 'Sunday' THEN 'Mo...
Implementing equality in .NET correctly and efficiently is really hard. For instance, you should implement `System.IEquatable<T>` and should implement all the different operations in a consistent and efficient manner without code duplication. Even following the guidelines, I've found that incredibly hard to remember, t...
Implementing equality in .NET correctly and efficiently is really hard. For instance, you should implement `System.IEquatable<T>` and should implement all the different operations in a consistent and efficient manner without code duplication. Even following the guidelines, I've found that incredibly hard to remember, t...
Depending on what firewall software you have installed/available, you should be able to block the outgoing port and depending on how your firewall is setup it should just drop the connection request packet. No connection request, no connection, timeout ensues. This would probably work better if it was implemented at a ...
select top N points from users order by points desc
If the peer address is spoofed, then there is nothing further that you can do. However, to spoof 127.0.0.1 is not easy. You would have to have a TCP/IP stack dumb enough to accept such a packet. There would be no way of the spoofer receiving packets back. On a good TCP/IP stack, it should not be able to guess the se...
svn revert <dir> Or, yes, delete it and grab another copy.
I think you should file a bugreport instead of trying to work around that.
How do you bind in xaml to a dynamic xpath?
|wpf|xaml|xpath|
I have a list box that displays items based on an xpath. This xpath changes depending on user selection elsewhere in the gui. At the moment i use some c# code behind to change the binding of the control to a new xpath expression. I'd like instead to bind in xaml to an xpath and then change the value of that xp...
I have a list box that displays items based on an xpath. This xpath changes depending on user selection elsewhere in the gui. The xpath always refers to the same document. At the moment i use some c# code behind to change the binding of the control to a new xpath expression. I'd like instead to bind in xaml t...
|.net|wpf|xaml|xpath|
None has so far proposed a portable way to get the size of an array when you only have an instance of an array and not its type. (typeof and _countof is not portable so can't be used.) I'd do it the following way: template<int n> struct char_array_wrapper{ char result[n]; }; templat...
56% chance I can't read something, I doubt it. I run a mix of RAID 5 and other goodies and just good backup practices but with Raid 5 and a hot spare I haven't ever had data loss so I'm not sure what all the fuss is about. If you're storing parity information ... well you're creating a RAID system using software, a dis...
Visual Basic 6 and UNC Paths
|vb6|
I'm receiving feedback from a developer that "The only way visual basic (6) can deal with a UNC path is to map it to a drive." Is this accurate? And, if so, what's the underlying issue and are there any alternatives other than a mapped drive?
|vb6|unc|
The various padding/formatting posts prior will work sufficiently enough, but you may be interested in implementing ISerializable. Here's an msdn article about [Object Serialization in .NET][1] [1]: http://msdn.microsoft.com/en-us/library/ms973893.aspx