instruction
stringlengths
0
30k
This is one of the things that having a preprocessor is useful for. You could define a macro that swallows exceptions, then with a quick script add that macro to all lines. So, if this were C++, you could do something like this: #define ATTEMPT(x) try { x; } catch (...) { } // ... ATTEMPT(WidgetMak...
One place to be careful is Objects that *look* small to GC but are not... In the SharePoint API for example, the SPWeb object has a small footprint as far as the GC is concerned and so will have low priority for collection, but it has really grabbed a bunch of memory (in the heap I believe) that the GC doesn't know abo...
Make one or both of the terms a floating point number, like so: 4.0/100.0 Alternatively, turn on the feature that will be default in Python 3.0, 'true division', that does what you want. At the top of your module or script, do: from __future__ import division
I'd use the [Commons Http Client][1]. There is a contrib class in the project that allows you to use ssl. We're using it and it's working well. [1]: http://hc.apache.org/httpclient-3.x/
I'd use the [Commons Http Client][1]. There is a contrib class in the project that allows you to use ssl. We're using it and it's working well. Edit: Here's the [SSL Guide][2] [1]: http://hc.apache.org/httpclient-3.x/ [2]: http://hc.apache.org/httpclient-3.x/sslguide.html
How do you reset ASP.Net AJAX cascading dropdown control (client side)
Managing a large backlog in an aggressive manner is almost always wasteful. By the time you get to the middle of a prioritized pile things have more often than not changed. I'd recommend adopting something like what Corey Ladas calls a priority filter: [http://leansoftwareengineering.com/2008/08/19/priority-filter/]...
The short answer is to use a PL/SQL function. For more details, have a look in [this][1] post. [1]: http://stackoverflow.com/questions/102317/how-to-get-multiple-records-against-one-record-based-on-relation
There's no easy way of doing what you're suggesting, as all types in C# are strong-typed, even the anonymous ones like you're using. However it's not impossible to pull it off. To do it you would have to utilize reflection and emit your own assembly in memory, adding a new module and type that contains the specific p...
How can I get a hardware-based screen capture?
|flash|video|video-capture|
In the past, some of my projects have required me to create a movie version of a fullscreen Flash application. The easiest way to do this has been to get a screen capture. However, capturing anything over 1024x768 has resulted in choppy video, which is unacceptable. I understand that there are hardware based solutions ...
RSpec and similar framewroks are tooling designed to aid in Behavior Driven Development. They're not just a prettier way to write tests, though they do help with that. There is plenty of information on BDD here: [http://behaviour-driven.org/][1] And wikipedia: [http://en.wikipedia.org/wiki/Behavior_Driven_Developm...
You can try XPanel from Farata Systems. This is a native Windows UI that can show log messages using the Flex 3 Logging API even for Flex applications running in a browser. Unfortunately they have redesigned their site and I can't find it anymore... Maybe Google will help you. We did something different using JavaSc...
Do you have to have the same environment for development and staging? I would really recommend against it. Even if you have them on the same server, I think you should have them at least in separate virtual directories. Assuming you have then done that, it is simple to keep the '.' directories hidden, you simply `ex...
You can hide the .svn folders in DNN but you'll have to modify the core. Probably an easier solution is to exclude the folder Portals/[PortalID] from your repository, but that depends on what you're developing. Do you need the Portal's files in your repository?
There is a class of stable in-place merge algorithms, although they are complicated and linear with a rather high constant hidden in the O(n). To learn more, have a look at [this article, and its bibliography](http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.45.5606). Edit: the merge phase is linear, thus the...
If you use MySQL 5.x you can use triggers for these kinds of constraints. Another (suboptimal) option would be to use a "type" column in the parent table to silently ignore duplication, and to be able to choose the correct "extension table".
You could just add a foreign key from one primary key to the other primary key. Because PK's have to be unique, you automaticly get a one-to-one relation.
There are 2 mains solutions : The pure HTML one : <input type="text" id="Textbox" name="Textbox" maxlength="10" /> The javascript one (attach it to a onKey Event) : function limitText(limitField, limitNum) { if (limitField.value.length > limitNum) { limitField.value = limitFiel...
Agree with dmeister's answer. And for that matter there's a good implementation of the "Effective Java"'s hashcode() and equals() logic in Apache Commons Lang. Checkout [HashCodeBuilder][1] and [EqualsBuilder][2]. [1]: http://commons.apache.org/lang/api/org/apache/commons/lang/builder/HashCodeBuilder.html [2]...
SVN Externals are what you want to do. The SVN book explains it in great detail [here][1]. That's one thing I love about SVN, the wonderful documentation. [1]: http://svnbook.red-bean.com/en/1.0/ch07s03.html
This is what svn "Externals" are for.
Just do normal long multiplication, as if you were multiplying a pair of 2-digit numbers, except each "digit" is really a 32-bit integer. If you're multiplying two numbers at addresses X and Y and storing the result in Z, then what you want to do (in pseudocode) is: <pre>Z[0..3] = X[0..3] * Y[0..3] Z[4..7] = X[0.....
I'm a big fan of [UnitTest++][1], it's very lightweight, but does the job. You can run single tests there easily. [1]: http://unittest-cpp.sourceforge.net/
Using DateAdd in umbraco xslt to display next year's date
|xslt|umbraco|
I'm trying to display the date for a year from now in an xslt file using umbraco like so: <xsl:variable name="now" select="umbraco.library:CurrentDate()"/> <xsl:value-of select="umbraco.library:DateAdd($now, 'year', 1)"/> The value-of tag outputs today's date. How can I get the DateAdd to add a year to ...
How best to make the selected date of an ASP.Net Calendar control available to javascript?
|asp.net|javascript|calendar|
Like the title says. Most controls are pretty simple, but the calendar requires more than just a simple _document.getElementById().value_.
Yes, have a look at [SVN Externals][1]. [1]: http://svnbook.red-bean.com/en/1.0/ch07s03.html
There is something out there, context aware resizing, don't know if you will be able to use it, but it's worth looking at, that's for sure A nice video demo (Enlarging appears towards the middle) <http://www.youtube.com/watch?v=vIFCV2spKtg> Here there could be some code. <http://www.semanticmetadata.net/2007/...
Eclipse/JUnit is a solid package for java, and there are C++ extensions/equivalents for both. It can do what you're talking about. Of course, you'd have to change IDEs...
Tim's suggestion didn't solve my problem on my development PC, but it did convince me to try again from a different PC. When using a different PC's SQL to logged into the development PC's database and trying exactly what Tim describes, I'm having the same behavior Tim describes. I was also able to re-replicate the ...
You could use partial classes and partial methods. I'm not sure why you'd do this though... [Partial Classes and Methods - MSDN][1] [1]: http://msdn.microsoft.com/en-us/library/wa80x488.aspx
Essentially the real limitations are only through of the platform, being the browser. If you have to account for all browsers in current use that can be a pain due to varying degrees of standards in each of them. If have control of the which browser to use, that is everyone is on computers that you control on sit...
The IDE will show you exactly that inline when you have an instance followed by the "." like myBadlyNamedObject. (or "ClassName."), and the beauty is that you have it at your fingertips when working with the object and not when you decide to open up the object definition to see what it might be
That's a wrong approach. C# isn't C++. **Forget about header files**. If you want the class summary, just open the **Object Browser** in Visual Studio. It will give you the signature of all the methods within your classes.
I don't think you can do header files like you can in C++. Check out the partial keyword for both classes and methods. I just learned about them yesterday, so I haven't really used them, but they might help you accomplish what you're trying to do.
It completely depends on the requirements of your project. For the most part, there isn't much web applications cannot do these days. Admittedly, certain applications do belong on the desktop as browsers (while currently advancing, and rapidly), still are not quite there yet. From the advent of applications such as [Go...
As far as I know that's not possible. You can however make things a little bit better by using partial classes where you put different parts of a class in different files. You can for example put all public methods in one file and all private in one to make it easier to get an overview of which methods are available fo...
In [Joel Spolsky's Making Wrong Code Look Wrong](http://www.joelonsoftware.com/articles/Wrong.html) he explains that what everybody thinks of as Hungarian Notation (which he calls Systems Hungarian) is not what was it was really intended to be (what he calls Apps Hungarian). Scroll down to the **I’m Hungary** heading ...
while IFS= read -r line; do echo "$line" done < somefile.txt This is a good way to process a file line by line. Clearing IFS is needed to get whitespace characters at the front or end of the line. The "-r" is needed to get all raw characters, including backslashes.
Online-only games like World of Warcraft (WoW) have it made, everyone has to connect to the server every time and thus accounts can be constantly verified. No other method works for beans.
Shoot you wrote exactly what i was going to post. I was just getting some code ready :/ Its a little convoluted but anyways: ClientCollection coll = new ClientCollection(); var results = coll.Select(c => { Dictionary<string, object> objlist = new Dictionary<string, object>(); foreach (Pr...
[Phillips dvdr3575h][1] and other set-top boxes may be the simplest. However, I don't believe they support the resolution you are looking for. [1]: http://www.google.com/products/catalog?rlz=1C1GGLS_enUS291&sourceid=chrome&ie=UTF-8&q=dvd+recoreder+hdd&um=1&cid=9245182892068372171&sa=X&oi=product_catalog_result&...
There are several methods, such as using the processor ID to generate an "activation key." The bottom line is that if someone wants it bad enough -- they'll reverse engineer any protection you have. The most failsafe methods are to use online verification at runtime or a hardware hasp. Good luck!
How about something like this... select * from books where title like "%text%" or description like "%text%" order by case when instr(title,"text") > 0 then 1 else 0 end desc, date
How about something like this... select * from books where title like "%text%" or description like "%text%" order by case when title like "%text%" then 1 else 0 end desc, date
How do you protect your software from illegal distribution?
|licensing|software-distribution|protection|security|
I am curious about how do you protect your software against cracking, hacking etc. Do you employ some kind of serial number check? Hardware keys? Do you use any third-party solutions? How do you go about solving licensing issues? (e.g. managing floating licenses)
|security|licensing|protection|software-distribution|
I am curious about how do you protect your software against cracking, hacking etc. Do you employ some kind of serial number check? Hardware keys? Do you use any third-party solutions? How do you go about solving licensing issues? (e.g. managing floating licenses) EDIT: I'm not talking any open source, but ...
You could use linq: string [] strings = contactList.Select(c => c.Name).ToArray(); string csv = string.Join(strings, ","); Obviously that could all be done in one line, but its a bit clearer on two.
And the correct answer iiiiis... RewriteRule ^(a|bunch|of|old|directories).* - [NC,L] # all other requests will be forwarded to Cake RewriteRule ^$ app/webroot/ [L] RewriteRule (.*) app/webroot/$1 [L] I still don't get why the index.php file in the root directory was called initiall...
CSV string handling
|csv|c#|
Typical way of creating a csv string (psudokode): 1. create a csv container object (like a StringBuilder in C#) 2. Loop through the strings you want to add appending a comma after each one 3. After the loop, remove that last superfluous comma. Code sample: public string ReturnAsCSV(ContactList contac...
|c#|csv|
Typical way of creating a csv string (psudokode): 1. create a csv container object (like a StringBuilder in C#) 2. Loop through the strings you want to add appending a comma after each one 3. After the loop, remove that last superfluous comma. Code sample: public string ReturnAsCSV(ContactList contac...
>I like the idea of adding the comma by checking if the container is empty, but doesn't that mean more processing as it needs to check the length of the string on each occurrence? You're prematurely optimizing, the performance hit would be negligible.
If you are looking to find out which dll's your target machine is missing then use depends.exe which used to come with MSDev, but can also be found [here][1]. Testing this on a few target machines should tell you which dll's you need to package with your application. [1]: http://dependencywalker.com/
//a[contains(@prop,'Foo')] Works if I use this XML to get results back. <bla> <a prop="Foo1">a</a> <a prop="Foo2">b</a> <a prop="3Foo">c</a> <a prop="Bar">a</a> </bla> This site is great for testing this kind of thing http://www.xmlme.com/XpathTool.aspx
//a[contains(@prop,'Foo')] Works if I use this XML to get results back. <bla> <a prop="Foo1">a</a> <a prop="Foo2">b</a> <a prop="3Foo">c</a> <a prop="Bar">a</a> </bla> This site is great for testing this kind of thing http://www.xmlme.com/XpathTool.aspx Edit: Anothe...
Class library with support for several persistence strategies
|c++|design-patterns|persistence|
I am developing a C++ class library containing domain model classes, and I would like to add support for instantiating these classes from various persistence mechanisms, i.e. databases and file. The user of the class library should be given an interface(?) against which to program a class that can transfer the data fro...
I do not understand what you mean with "independence form [...] installed software". You ever need at least the DBMS installed as well as one client or user interface. I recommend using MS Access. It is easy and cheap for simple, single user tasks and rapid prototyping development. Only development version have to b...
Example: svn switch --relocate \ http://svn.example.com/path/to/repository/path/within/repository \ http://svnnew.example.com/new/repository/path/within/repository One thing which is to remember, lets assume you checked out the project "path/within/repository" then you have to go to the **ro...
You might want to use the Java Advanced Imaging (JAI) API. An example of how to scale an image using JAI can be found [here][1]. [1]: http://archives.java.sun.com/cgi-bin/wa?A2=ind9908&L=jai-interest&P=R14150
If you got rid of *product-dvd-id* and *product-cd-id*, and used the *product-id* as the primary key for all three tables, you could at least make sure that no two DVD or no two CD use the same *product-id*. Plus there would be less ids to keep track of. And you maybe need some kind of *type* column in the products...
Tim's suggestion didn't solve my problem on my development PC, but it did convince me to try again from a different PC. When using a different PC's SSMS to log into the development PC's database and trying exactly what Tim describes, I'm having the same behavior Tim describes. I was also able to re-replicate the ar...
You could also use the `<exec>` task.
Yes, this mechanism is called "externals". See [the book](http://svnbook.red-bean.com/en/1.1/ch07s04.html).
I think no design pattern can solve this issue in itself. Good database design, good store procedure programming and especially learning how to keep your transactions short will ease most of the problems. There is no 100% guaranteed method of not having problems though. In basically every case I've seen in my caree...
We decided to try and detect the plugin - if the browser doesn't have the plug-in we give the user a message saying that they will need to instal the relevant plugin if they wish to view the file in the browser, although we give them the option to continue. As ddaa mentions not all the scenarios can be accurately c...
Well, certainly frames / sec = 1 / (sec / frame) But, as you point out, there's a lot of variation in the time it takes to render a single frame, and from a UI perspective updating the fps value at the frame rate is not usable at all (unless the number is very stable). What you want is probably a moving a...
Web applications delegate processing to a remote machine. Depending on the amount of processing, this can be a con. Consider a photo editor that's a web app. Web applications also can't deal with a whole lot of data going back and forth to and from a client. You can watch video online.. when it's compressed. It ...
Why shouldn't I use "Hungarian Notation"?
|hungarian|naming-conventions|language-agnostic|
I know what Hungarian refers to - giving information about a variable or parameter as a prefix to its name. Everyone seems to be rabidly against it, even though in some cases it seems to be a good idea. If I feel that useful information is being imparted, why shouldn't I put it right there where it's available?
I know what Hungarian refers to - giving information about a variable, parameter, or type as a prefix to its name. Everyone seems to be rabidly against it, even though in some cases it seems to be a good idea. If I feel that useful information is being imparted, why shouldn't I put it right there where it's available?
|language-agnostic|naming-conventions|hungarian|
I know what Hungarian refers to - giving information about a variable, parameter, or type as a prefix to its name. Everyone seems to be rabidly against it, even though in some cases it seems to be a good idea. If I feel that useful information is being imparted, why shouldn't I put it right there where it's available? ...
The Hungarian notation was abused, particularly by Microsoft, leading to prefixes longer than the variable name, and showing it is quite rigid, particularly when you change the types (the infamous lparam/wparam, of different type/size in Win16, identical in Win32). Thus, both due to this abuse, and its use by M$, it...
|asp.net|ajax|cascading|drop-down-menu|
The cascading dropdown control works great except that I am unable to figure out a way to reset the dropdown client-side (in Javascript) My set up is something like this DD1 DD2 DD3 DD4 each DD is dependent on the previous DD and uses webservice to load them. On change of DD3 I need to reset DD4 but the...
|asp.net|asp.net-ajax|drop-down-menu|
For quick updates I just run `svn update` from the server. Sometimes for really really quick updates I edit the files using vim and commit them from the server. It's not very proper, but quick and quite reliable.
As others have said, using is your friend. I wrote [this blog entry][1] about how to implement IDisposable in a fairly straightforward way that is less error-prone by factoring out the parts that are the most important. [1]: http://www.atalasoft.com/cs/blogs/stevehawley/archive/2006/09/21/10887.aspx
icewm has done me good for several years. I don't need most of the crap that the big-time desktops offer, but i do like a clock and CPU usage monitor running in the bar along the bottom - icewm does have these. It is noticeably lighter in feel than the popular desktops. No weirdness such as tiled windows or anti-mo...
It appears [the official word is no](http://social.msdn.microsoft.com/forums/en-US/wpf/thread/84299fec-94a1-49a1-b3bc-ec48b8bdf04f/). Still, happy to hear if anyone has any non-wpf alternatives for simple bitmap operations like `DrawLine` and friends.
On Linux, <a href="http://manpages.ubuntu.com/manpages/hardy/en/man3/daemon.html">daemon()</a> is what you're looking for, if I understand you correctly.
From the Terminal, I can run open -n -a appName.app Then from Applescript, I can run tell application "Terminal" activaate do script "open -n -a appName.app" end tell Then from Java, I can execute that script. Then, I can stuff that Java code into an Action. Then, stuff that ac...
Best way to fix CSS/JS drop-down problem in IE7 when page includes Google Map
|css|ie6|ie|ie7|js|
I have a page using < ul > lists for navigation (Javascript changes the styling to display or not on mouseover). This is working fine for me _except_ in IE6 and IE7 when I have a Google Map on the page. In this case the drop-down simply does not work. However, the page continues to work in FireFox 2. I have do...
With a bit of luck your graphic adapter already has a analog video output. You could hook up a dvd recorder and just digitze the video signal on a stand alone hardware box. That won't give you 1920x1080 though. If you really need to get captures higher than dvd resolution you need professional (and *incredible* ...