instruction
stringlengths
0
30k
I don't think renaming or moving the log file will work while the database is online. Easiest thing to do, IMO, is to open the properties for the database and switch it ti Simple logging mode. then shrink the database and then go back and set the DB to Full logging (or whatever logging you need). Changing the ...
They're two parts of the same whole. Introspection refers to the ability of a class to look 'inside' itself and see, for example, what parameters a method takes, what the names of its members are, etc. Reflection is the specific name for how .NET implements introspection. Other languages may call it something di...
string[] splitStrings = myCsv.Split(",".ToCharArray());
Perhaps a hybrid approach. Python and C++ make a good combination (see, for example, PyGame).
Personally, I've never had a problem with the built-in javadoc browsing tools offered by my IDE. Currently, I use IntelliJ Idea -- Ctl-Q brings up the javadoc for the method under the cursor, with the hyperlinks to other parts of the documentation functional. I would imagine NetBeans and Eclipse offer similar fu...
MVC is fantastic for an individual widget, however it gets a little unruly when you have "pages" and "forms" with lots of widgets. One thing that might be worth looking into (and I'm not endorsing it, I haven't actually used it, just implemented something very similar for myself) is the [Beans Binding Framework (JSR...
yyp - remember it with "yippee!" Multiple lines with a number in between: y7yp
You could also set a cookie using javascript on unload. I think the advantage ajax has over cookies is that you have the data available to you for reporting and the user (if logged in) can utilise the data across different machines. The disadvantage of using ajax is that it might slow down the actual closing of the ...
I use [http://www.teria.com/~koseki/tools/gm/javadoc_isearch/][1] for FF. Lets me easily browse other libraries as well. [1]: http://www.teria.com/~koseki/tools/gm/javadoc_isearch/ "javadoc incremental search plugin"
One difference is that an anonymous delegate can omit parameters while a lambda must match the exact signature. Given: public delegate string TestDelegate(int i); public void test(TestDelegate d) {} you can call it in the following four ways (note that the second line has an anonymous delegate that ...
Also, Cocoa's NSError is meant to be displayable to the end user. If you just log it, it should be readable. If you're talking about Carbon's OSStatus and such, MacErrors.h.
You might want to check out [buildr][1] as well. It's a higher-level build-tool built on rake. IMHO it takes a lot of the good features from maven, and throws away the bad-ones. I haven't used it in anything big myself but I know people who have and are quite happy with it. [1]: http://incubator.apache.org/build...
The solution posted by Stu Thompson is valid in Java5.0 and later. But I would prefer not to use it because I think it is error prone. It's easy to forget the volatile statement and difficult to understand why it is necessary. Then this code would not be thread safe anymore due to the double-checked locking antipatt...
The solution posted by Stu Thompson is valid in Java5.0 and later. But I would prefer not to use it because I think it is error prone. It's easy to forget the volatile statement and difficult to understand why it is necessary. Without the volatile this code would not be thread safe anymore due to the double-checked ...
It is possible to reference them, but as paulbetts said, its not recommended as they could change. Also consider if what you are doing is truely 'correct'. Can you edit your question to explain why you need to do this exactly?
There is a [jQuery plugin][1] for the general case of scrolling to a DOM element, but if performance is an issue (and when is it not?), I would suggest doing it manually. This involves two steps: 1. Finding the position of the element you are scrolling to. 2. Scrolling to that position. [quirksmode][2] gives a g...
I'm not an expert with .NET by any means but Localization is never just as simple as "swapping out String values" or "changing date formats". There is much more to be taken into consideration such as layout, proper text placement. Take Chinese for example. The way you read is top to bottom not left to right. If p...
Just look in the msdn database for (T) delegate. Here you got a direct link: [List of delegates][1] That should get you started. [1]: http://social.msdn.microsoft.com/Search/en-us/?Query=(T)%20delegate
from the results of the search the third item was pretty much what I pointed in right direction. [Jow Wirtley's Blog][1] All I had to do was update the bindings in the app.config of the client app and it all works now. [1]: http://joewirtley.blogspot.com/2007/08/maximum-string-content-length-and.html
from the results of the search the third item was pretty much what I pointed in right direction. [Jow Wirtley's Blog][1] **All I had to do was update the bindings in the app.config of the client app and it all works now.** [1]: http://joewirtley.blogspot.com/2007/08/maximum-string-content-length-and.html
The classic recipe is: design the app with no native language but a localization facility, and develop an initialization into one language (e.g., English). So you build the app and localize it into English every night; without the localization step it would not be usable. Do that well, and the resources for the initi...
Best for what? Language design is always about tradeoffs. The advantage of return codes is that they don't require any runtime support beyond regular function calls; the disadvantages are 1) you always have to check them 2) the return type has to have a failure value that isn't a valid result of the function call. T...
Homework? You'd read it into a `char*` using the `fread()` function, and then store how many bytes were read in a separate variable. Then use a `for` loop to iterate through the buffer and count how many of each byte are present.
I'm not down with the specifics for jQuery, but a general answer that doesn't involve polling wold be: Use a variation of the [forever frame][1] technique. Basically, create a hidden iframe, and set the src of it to be 'getresults.php'. Inside getresults you "stream" back script blocks, which are calls to a javascrpt f...
I use Oracle SQL Developer - the latest version also has support for CVS and Subversion. It has the bonus of supporting other database providers, too. I have used this tool for 2 years and it has now settled down to be reliable.
If a method is unused and public FxCop assumes that you have made it public for external things to access. If unused public methods lead to FxCop warnings writing APIs and the like would be a pain - you'd get loads of FxCop warnings for methods you intend others to use. If you don't need anything external to acce...
Other answers cover the probable mechanics (all guesses as compiler not specified). The issue that you have is that your compiler and linker have not been set to enable every possible error and warning. For any new project there is (virtually) no excuse for not doing so. *for legacy projects more excuse - but shou...
Also, never forget that and ID is unique. Once used, the ID value may not appear again anywhere in the document. You may have many ID's, but all must have a unique value. On the other hand, there is the class-element. Just like ID, it can appear many times, but the value may be used over and over again.
You can use [nekohtml][1] to parse your html document. You will get a DOM document. You may use XPATH to retrieve data you need. [1]: http://sourceforge.net/projects/nekohtml
[MSDN][1]: A hash function must have the following properties: * If two objects compare as equal, the GetHashCode method for each object must return the same value. However, if two objects do not compare as equal, the GetHashCode methods for the two object do not have to return different values. * The G...
What (good) Java RADIUS server libraries are out there?
|java|hammer|radius|
I've only been able to find two thus far, namely <a href="http://tinyradius.sourceforge.net/">TinyRadius</a>, which itself discourages production use and <a href="http://www.axlradius.com/">AXL</a>, which is pay-only. <a href="http://coova.org/wiki/index.php/JRadius">JRadius</a> seems tied to <a href="http://freerad...
[Guidance Explorer](http://www.codeplex.com/guidanceExplorer) Guidance packages integrate into VS as Snippets, projects, and project templates. They provide a way to collect and reuse patterns, code, and How To answers. You can create guidance for your team and you can download the guidance packages coming out of th...
A quick google search [found this][1]. Useful for all kinds of plugins. [1]: http://www.oreillynet.com//cs/user/view/cs_msg/9920
I'd model Role as an association class between Users and Roles, thus, class User(models.Model): ... class Event(models.Model): ... class Role(models.Model): user = models.ForeignKey(User) event = models.ForeignKey(Event) And enforce the one role per user p...
Get Last Friday of Month in Java
|java|calendar|date|
I am working on a project where the requirement is to have a date calculated as being the last Friday of a given month. I think I have a solution that only uses standard Java, but I was wondering if anyone knew of anything more concise or efficient. Below is what I tested with for this year: for (int month ...
You may need them for static (or 'global') attribute you want your subclasses or classes from same package (if it is about java) to benefit from. Those static final attributes representing some kind of 'constant value' have seldom a getter function, so a protected static final attribute might make sense in that case...
I don't use protected attributes in Java because they are only package protected there. But in C++, I'll use them in abstract classes, allowing the inheriting class to inherit them directly.
I should be called when either the application ends or the DLL is unloaded, whichever comes first. Note that this is somewhat dependent on the actual runtime you're compiling against. Also, beware non-trivial destructors as there are both timing and ordering issues. Your DLL may be unloaded **after** a DLL your d...
Alternatively if you know the time-out length then you could add a bit of javascript to the page which redirects the user to an alternative page if there has been no activity on the page after a preset period of time. You can then extend this to warn the customer that their session / page is about to expire and provide...
You probably will have to pay. If you check with your current registrar and with your target registar and see what needs to be done with them and what the costs are. It is diferent for every registar, even though the actual process is the same.
I like the way COM can handle both exception and non-exception capable callers. The example below show how a HRESULT is tested and an exception is thrown in case of failure. (usually autogenerated in tli files) inline _bstr_t IMyClass::GetName ( ) { BSTR _result; HRESULT _hr = get_name(&_result...
I am running a Windows O/S and use perl2exe from IndigoSTAR. The resulting .EXE file will be unlikely to be changed on-site. As others have said, "how do I obfuscate it" is the wrong question. "How do I stop the customer from changing the code" is the right one.
they charge you to transfer (like 6.99?), but godaddy will then renew it for a year. You usually need to contact your current hosting and have them release it for transfer, then follow godaddy's procedure for transferring a new domain in.
If you want robust CSV handling, check out [FileHelpers][1] [1]: http://www.filehelpers.com/
One of the timeout fields in the SOA is a "negative timeout". It is usually set to a short time, such as 30 or 60 seconds. So, yes, but for a shorter time than a "positive" response.
Don't use the API ;-) Seriously, if your JOIN are complex, you should see significant performance increases by dropping down in to SQL rather than by using the API. And this doesn't mean you need to get dirty dirty SQL all over your beautiful Python code; just make a custom manager to handle the JOINs and then have t...
I wrote some code a while ago that merges two records. Is not entirely dynamic, but whith macros you could easily use it for several records. It works like this: The merge/2 function takes two records and converts them to lists together with the empty record for reference (the record type is defined at compile time,...
Spelling Alternatives based on a Database?
|php|mysql|
I'm looking for an efficient way (using PHP with a Mysql Database) to suggest alternative spelling for a query. I know I can use services such as [Yahoo's Spelling Suggestion][1] but I want the suggestions to be based on what is currently available in the database. For example: The user has to fill a form with a...
[MSDN][1]: A hash function must have the following properties: * If two objects compare as equal, the GetHashCode method for each object must return the same value. However, if two objects do not compare as equal, the GetHashCode methods for the two object do not have to return diffe...
[MSDN][1]: A hash function must have the following properties: * If two objects compare as equal, the GetHashCode method for each object must return the same value. However, if two objects do not compare as equal, the GetHashCode methods for the two object do not have to return diffe...
Tiles can be a pain. Vast improvement over what came before (i.e. nothing), but rather limiting. [Wicket][1] might be more what you're looking for, unless you've settled on JSP. [1]: http://wicket.apache.org/
If I understand your structure correctly, I think you are going to have many duplicates in your dev tree related to "tools" and "lib". Most likely these are external tools and libraries that might be shared by different projects. Something that works well for us is:<br /> <code> solutionfile.sln<br /> -src<br /> ...
Java Applet crashes .NET Webbrowsercontrol
|java|browser|applet|controls|
in our application we have a Java applet running inside a .NET browser control. It is a know issue from Sun that running an applet this way may crash the control. Has anyone come across the same problem and solved it? Atm we are running the applet in a Webbrowser but we need to run it in a browser control. Thx...
That is odd as the ViewState is stored as a string in the webpage itself. So I do not see how an extended period of time would cause that error. Perhaps one or more objects on the page have been garbage collected or the application reset, so the viewstate is referencing old controls instead of the controls created wh...
import operator to sort the list of dictionaries by key='name' : list_of_dicts.sort(key=operator.itemgetter('name')) to sort the list of dictionaries by key='age' list_of_dicts.sort(key=operator.itemgetter('age'))
There isn't a simple way to do this well, if you want to account for quoted elements with embedded commas, especially if they are mixed with non-quoted fields. You will also probably want to convert the lines to a dictionary, keyed by the column name. My code to do this is several hundred lines long. I think t...
What's the best way to tell if a method is a property from within Policy Injection?
|c#|enterprise-library|policy-injection|
I've got a custom handler applied to a class (using the Policy Injection Application Block in entlib 4) and I would like to know whether the input method is a property when Invoke is called. Following is what my handler looks like. [ConfigurationElementType(typeof(MyCustomHandlerData))] public class MyCust...
You can still use Outer.class to get the class of the outer class object (which will return the same Class object as Outer.this.getClass() but is more efficient) If you want to access statics in the enclosing class, you can use Outer.name where name is the static field or method.
How can I highlight the current cell in a DataGridView when SelectionMode=FullRowSelect
|.net|winforms|datagridview|
I have an editable DataGridView with SelectionMode set to FullRowSelect (so the whole row is highlighted when the user clicks on any cell). However I would like the cell that currently has focus to be highlighted with a different back color (so the user can clearly see what cell they are about to edit). How can I do th...
There are two approaches: using an Internet service and using some kind of local list (perhaps wrapped in a library). What you want will depend on what you are building. For services: - [http://www.hostip.info/use.html][1] (as mentioned by [Mark][2]) - [http://www.team-cymru.org/Services/ip-to-asn.html][3] ...
Just avoid using an interface: public interface MyConstants { String CONSTANT_ONE = "foo"; } public class NeddsConstant implements MyConstants { } It is tempting, but violates encapsulation and blurs the distinction of class definitions.
To take it a step further, you can place globally used constants in an interface so they can be used system wide. E.g. public interface MyGlobalConstants { public static final int TIMEOUT_IN_SECS = 25; } But don't then implement it. Just refer to them directly in code via the fully qualified c...
For unusual perspective on exception handling, see Haskell's [`Control.Exception` monad](http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Exception.html)
My experience is that every time that I have bothered to look it has been in document order. However, I believe that I read somewhere it is not guaranteed to be in document order. I can't find where I read that right now, so take it as hearsay. I think your best bet if you **must** have them in document order would be ...
Any DVCS (BitKeeper, git, Bazaar, Mercurial, etc) because being distributed will cut down the load on the central 'canonical' SCM server.
Any DVCS (BitKeeper, git, Bazaar, Mercurial, etc) because being distributed will cut down the load on the central 'canonical' SCM server. The caveat is that they're fairly new technology and not many people will be familiar with their use. If you want to stick to the older, centralized model, I'd recommend Perforce...
Really, I think the answer is 'how you run the project'. All of your examples matter, yes, but the key things are how the interaction between developers is managed, how patches etc are handled/accepted, who's 'in charge' and how they handle that responsibility, and so on and so forth. Compare and contrast (the hi...
[Google Notebook][1] is very convenient tool. You can clip and save any parts of web pages without leaving your browser tab. The Notebook plug-in automatically saves them as separate notes in your notebooks and keep the links back to the original web pages. You can organize your clippings later by moving them between y...
I was just reading tonight an excellent post on the usability aspect of successful vs unsuccessful open source projects. Excerpt: > A lot of bandwidth has been wasted arguing over the lack of usability in open-source software/free software (henceforth “OSS”). The debate continues at this moment on blogs, forums...
I've been using Visual Assist X for nearly two years now, and I find it so useful I can honestly say that if my employer didn't provide it, I'd have to pay for it myself. I also use Cool Commands and SlickEdit (the free version), whose File Explorer and Command Spy tools are quite useful.
One of the only examples about allocating and destroying in different places is thread creation (the parameter you pass). But even in this case is easy. Here is the function/method creating a thread: struct myparams { int x; std::vector<double> z; } std::auto_ptr<myparams> param(new mypar...
Once you removed the file from your HEAD revision, it doesn't slow you down on operation speed as ony deltas between revisions are handled. (Repository backups must of course handle the load).
It should be called when either the application ends or the DLL is unloaded, whichever comes first. Note that this is somewhat dependent on the actual runtime you're compiling against. Also, beware non-trivial destructors as there are both timing and ordering issues. Your DLL may be unloaded **after** a DLL your ...
How do I set the HttpOnly flag on JSF/Richfaces
|security|jsf|richfaces|
I'd like to add the HttpOnly flag to my cookies to up the level of security on my web app. Any ideas?
|security|jsf|richfaces|java|
|java|security|jsf|richfaces|
I'd like to add the HttpOnly flag to JSF/richfaces cookies, especially the session cookie, to up the level of security on my web app. Any ideas?
C#: I use protected for abstract or virtual methods that I want base classes to override. I also make a method protected if it may be called by base classes, but I don't want it called outside the class hierarchy.
If you already have MS Access installed, then yes the mdb is probably your quickest way to get started. Also you will want to just started with a quick ADO.NET tutorial. There are hundreds of these (well almost hundreds, I haven't counted).
What milliseconds? You are providing only minutes information in the first example, whereas your second example grabs current date from the system with milliseconds, what is it you're looking for? String date = "06-04-2007 07:05:00:999"; SimpleDateFormat fmt = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss:S"); ...
What milliseconds? You are providing only minutes information in the first example, whereas your second example grabs current date from the system with milliseconds, what is it you're looking for? String date = "06-04-2007 07:05:00:999"; SimpleDateFormat fmt = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss:S"); ...
What milliseconds? You are providing only minutes information in the first example, whereas your second example grabs current date from the system with milliseconds, what is it you're looking for? String date = "06-04-2007 07:05:00.999"; SimpleDateFormat fmt = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss.S"); ...
There are never any good reasons to have protected attributes. A base class must be able to depend on state, which means restricting access to data through accessor methods. You can't give anyone access to your private data, even children.
At the very least, a simple pass/fail for each TestFixture run would allow the output to be sucked into other TAP results for aggregating results/reports. Maybe it's as simple as a xslt to transform the xml report into TAP
Look at the functools.wraps() decorator; it does all of this, but I don't know offhand if you can get it to run in the right context
How do I encode arbitrary data to XML using Java 1.4 and SAX?