instruction
stringlengths
0
30k
Depending on just how dependency-averse you are, and what kind of text editor you're building, [GtkSourceView][1] adds undo/redo among many other things. Very worth looking at if you want some of the other [features][2] it offers. [1]: http://projects.gnome.org/gtksourceview/ [2]: http://projects.gnome.org/gt...
How to skip sys.exitfunc when unhandled exceptions occur
|python|exception|
As you can see, even after the program should have died it speaks from the grave. Is there a way to "deregister" the exitfunction in case of exceptions? import atexit def helloworld(): print "Hello World!" atexit.register(helloworld) raise Exception("Good bye cruel world!")
This has to be done on the server side. One thing you might look at doing is allowing all the editing to go on client side, and then in the end POST the final image (via AJAX) to the server to allow it to return it to you as the correct MIME type, and correctly packed.
My colleague mentions why we are using RESTeasy for our current project in [RESTful web services in Java EE with RESTeasy (JAX-RS)][1]: > Its reference implementation, Jersey, was not chosen because we had trouble integrating it well with EJB3 and Seam 2.0. > We are using the RESTeasy implementation of JAX-RS, be...
I found the problem. The problem is that you need to set a white background on #page-container. As things stand, it has a transparent background, so the 5pt left margin on navbar-sidebanner is revealing the bg of the page_container ... so change that bg and you're cool.
In defense of the anti-pattern designation, this code lends itself to being used in a few ways: 1. Object x = MyFunction().payload; _(ignoring the return result - very bad)_ 2. int code = MyFunction().result; _(throwing away the payload - may be okay if that's the intended use.)_ 3. FunctionResult<Object> ...
In defense of the anti-pattern designation, this code lends itself to being used in a few ways: 1. Object x = MyFunction().payload; _(ignoring the return result - very bad)_ 2. int code = MyFunction().result; _(throwing away the payload - may be okay if that's the intended use.)_ 3. FunctionResult<Object> ...
Depending on the usage, there are several "correct" answers. The most simple case is: public final class Foo { private static final Foo INSTANCE = new Foo(); private Foo() { if (INSTANCE != null) { throw new IllegalStateException("Already instantiated"); } ...
Have you looked at the HessianC# project ([http://www.hessiancsharp.org/][1])? [1]: http://www.hessiancsharp.org/
Go into Tools > Options > Text Editor > HTML > Miscellaneous and uncheck "Auto ID elements on paste in Source view"
Dreaded iframe horizontal scroll bar can't be removed in IE?
|internet-explorer|iframe|
I have an iframe. The content is wider than the width I am setting so the iframe gets a horizontal scroll bar. I can't increase the width of the iframe so I want to just remove the scroll bar. I tried setting the scroll property to "no" but that kills both scroll bars and I want the vertical one. I tried setting ov...
In SharePoint v.2: - **Max # list items** : 2000 (per folder level) - **Max lists per site** : 2000 is a "reasonable" number - **Effect when we reach the limit** : Exponential degradation of performance. More info: [http://technet.microsoft.com/en-us/library/cc287743.aspx][1] In SharePoint v.3: -...
Who are you trying to convince? Engineers or manager? If you are trying to convince your engineer co-workers I think your best bet is to appeal to their desire to make a high quality piece of software. There are numerous studies that show it finds bugs, and if they care about doing a good job, that should be enough ...
A major part of test-driven development that is often glossed over is the writing of testable code. It seems like some kind of a compromise at first, but you'll discover that testable code is also ultimately modular, maintainable and readable. If you still need help convincing people <a href="http://www.masukomi.org/...
Consider Subversion (http://subversion.tigris.org/) and the Tortoise shell extension (http://tortoisesvn.tigris.org/).
If you can pay for it, [Source Gear Vault][1] is designed to be a drop-in replacement. If you can't pay, Subversion with AnkhSVN works well but is a bit different. [1]: http://www.sourcegear.com/
Depending on the usage, there are several "correct" answers. The most simple case is: public final class Foo { private static final Foo INSTANCE = new Foo(); private Foo() { if (INSTANCE != null) { throw new IllegalStateException("Already instantiated"); } ...
Depending on the usage, there are several "correct" answers. The most simple case is: public final class Foo { private static final Foo INSTANCE = new Foo(); private Foo() { if (INSTANCE != null) { throw new IllegalStateException("Already instantiated"); } ...
You're sort of mixing C and C++ ways of doing things. Why allocate more than the size of a pStruct? Why not just "new pStruct"? If you must do this then it might be clearer to use malloc and free in this case, since then you or other programmers might be a little less likely to make assumptions about the types and s...
You're sort of mixing C and C++ ways of doing things. Why allocate more than the size of a STRUCT? Why not just "new STRUCT"? If you must do this then it might be clearer to use malloc and free in this case, since then you or other programmers might be a little less likely to make assumptions about the types and siz...
It would have to be some kind of a List that you can maintain in sorted order. You would also have to write your own search algorithm that would give you the index of the first element in the list that matches your search pattern. Then iterate from that index until the first element that doesn't match and you have yo...
We use [Standard Time][1] as a Time Tracking tool and it's got a nice quick tasks window that is relatively small and lets you easily click checkboxes to switch between tasks. You can also create projects/customers and pre-set tasks to be loaded for each project (development, unit testing, documentation, etc...) and th...
How to expose a collection property?
|c#|.net|architecture|
Every time I create an object that has a collection property I go back and forth on the best way to do it? 1. public property with a getter that returns a reference to private variable 2. explicit get_ObjList and set_ObjList methods that return and create new or cloned objects every time 3. expli...
Every time I create an object that has a collection property I go back and forth on the best way to do it? 1. public property with a getter that returns a reference to private variable 2. explicit get_ObjList and set_ObjList methods that return and create new or cloned objects every time 3. expli...
What version of Oracle are you using? If its 10g or greater, you should look at using Data Pump instead of import/export anyway. I'm not 100% sure if it can handle this scenario, but I would expect it could.
What version of Oracle are you using? If its 10g or greater, you should look at using Data Pump instead of import/export anyway. I'm not 100% sure if it can handle this scenario, but I would expect it could. [Data Pump][1] is the replacement for exp/imp for 10g and above. It works very similar to exp/imp, except its...
I've done this with bindings, but setting them up programmatically instead of through Interface Builder. This psuedo-snippet should give you the gist of it: NSTableColumn *aColumn = [[NSTableColumn alloc] initWithIdentifier:attr]; [aColumn setWidth:DEFAULTCOLWIDTH]; [aColumn setMinWidth:MINC...
No, as everyone has said, it is not strictly possible. However, you can do [something like this][1] to emulate a mixin in PHP or add methods to a class at runtime, which is about as close as you're going to get. Basically, it's just using design patterns to achieve the same functionality. Zope 3 does something simil...
This is a great question. First, don't escape text on input except to make it safe for storage (such as being put into a database). The reason for this is you want to keep what was input so you can contextually present it in different ways and places. Making changes here can compromise your later presentation. Wh...
You could perhaps override [__call or __callStatic][1] to locate a missing method at runtime, but you'd have to make up your own system for locating and calling the code. For example, you could load a "Delegate" class to handle the method call. [1]: http://uk2.php.net/manual/en/language.oop5.overloading.php
Process raw HTTP request content
|asp.net|http|e-commerce|
I am doing an e-commerce solution in ASP.NET which uses [PayPal's Website Payments Standard](https://www.paypal.com/IntegrationCenter/ic_standard_home.html) service. Together with that I use a service they offer ([Payment Data Transfer](https://www.paypal.com/IntegrationCenter/ic_pdt.html)) that sends you back order in...
|asp.net|https|e-commerce|
|asp.net|http|e-commerce|
HTTP Libraries for Emacs
|http|emacs|
I recently discovered the org-mode in emacs and it works very well for me. I also like www.RememberTheMilk.com. I would like to be able to sync my org-mode file and RTM list. I know that RTM has its API exposed as web services. I am currently looking for a HTTP library that I could use to write my script. I found a cou...
|https|emacs|
|https|emacs|
|http|emacs|
The short answer is you can't. :) (except possibly as root, when it would be more accurate to say you shouldn't.) Unixes only allow a set number of links to directories - ".." from within all its children and "." from within itself. Anything else is potentially a recipe for a very confused directory tree. This is/wa...
Some browsers support the canvas: http://developer.mozilla.org/En/Drawing_Graphics_with_Canvas
This is not exactly what you are searchng for, and it might not be easy to setup, but may be you could have a look at lxr : lxr.linux.no is a browseable kernel tree. In the search box, if you enter a filename, it will give you where it is included. But this is still guessing, and it does not track chained dependenc...
Depending on the usage, there are several "correct" answers. The most simple case is: public final class Foo { private static final Foo INSTANCE = new Foo(); private Foo() { if (INSTANCE != null) { throw new IllegalStateException("Already instantiated"); } ...
Well it really matters! mdb files keep increasing in size each time you manipulate its data, until it reaches unbearable size. But you don't have to supply a compacting method through your interface. You can add the following code in your mdb file to have it compacted each time the file is closed: Application.SetOpt...
It's easy to write out a big list of commands/shortcuts, but it's difficult to remember them all without practice. Focus on one new command at a time. When it becomes automatic, say after using it for a week or two, add another to your repertoire. You'll be taking the long way around to accomplish certain thin...
You could perhaps override [__call or __callStatic][1] to locate a missing method at runtime, but you'd have to make up your own system for locating and calling the code. For example, you could load a "Delegate" class to handle the method call. Here's an example - if you tried to call $foo->bar(), the class would at...
Also, make sure you have an index on the field in your db, or else that query will quickly become sloooow. (It's much better to do this in SQL, otherwise you pull the entire db table into memory just to answer the count.)
You should also look at html5lib for Python as it tries to parse HTML in a way that very much resembles what web browsers do, especially when dealing with invalid HTML (which is more than 90% of today's web).
Comparing two CVS revisions in Eclipse
|eclipse|cvs|
It finally started to annoy me enough to ask this question: how do I do a basic diff between two revisions of a file in CVS? Usually I want to compare the latest revision and some random old one. I'm using the Eclipse CVS plugin. When I use "compare with->Another branch or version..." from the selected file's (latest r...
The ANSWER is... not pretty. But it does precisely what I am after. [Dependency Finder][1]! Not the most modern or active project ever, but if you edit [Dependency Finder]/bin/DependencyFinder.bat, add its path for DEFAULT\_DEPENDENCYFINDER\_HOME, set a JAVA_HOME, you can launch it. Then you click on the 'Extr...
Every time I create an object that has a collection property I go back and forth on the best way to do it? 1. public property with a getter that returns a reference to private variable 2. explicit get_ObjList and set_ObjList methods that return and create new or cloned objects every time 3. expli...
I use [neomem][1] to keep track of things by hand. [1]: http://www.neomem.org/
I use [neomem][1] to keep track of things by hand. This allows me to keep track of more than just time. I often keeps notes associated with the story. This has become a collection of knowledge that I often search. [1]: http://www.neomem.org/
From what I understand, the timeout property doesn't take into account DNS timeouts. It's possible that you could make a DNS lookup separately, then make the request to the server if that works, with the correct timeout value set for the useragent. Is this a DNS problem with the server, or something else? EDIT: I...
How do you whether a string is an Ip or a hostname
|java|
So you have a String that is retrieved from an admin web UI (so it is definitely a String). How can you find out whether this string is an IP address or a hostname in Java?
How do you tell whether a string is an IP or a hostname
So you have a String that is retrieved from an admin web UI (so it is definitely a String). How can you find out whether this string is an IP address or a hostname in Java? Update: I think I didn't make myself clear, I was more asking if there is anything in the Java SDK that I can use to distinguish between IPs and...
In the case where you're automatically generating code that may have margins on it, adding a simple, unstyled `<div>` element wrapping your table might do the trick.
Since Java 1.5 the JDK comes with a new tool: [JConsole][1] wich can show you the CPU and memory usage of any 1.5 or later JVM. It can do charts of these parameters, export to CSV, show the number of classes loaded, the number of instances, deadlocks, threads etc... [1]: http://java.sun.com/developer/technicalAr...
My recommendation is to come up with some simple programs and write them, start to finish, using VI. Odds are, you will be too frustrated at first by the learning curve to force yourself to use them at work or in any time-sensitive environment. I've done this before to get familiar with environments/editors, and ...
My recommendation is to come up with some simple programs and write them, start to finish, using VI. Odds are, you will be too frustrated at first by the learning curve to force yourself to use them at work or in any time-sensitive environment. I've done this before to get familiar with environments/editors, and ...
I wrote a fairly comprehensive guide to this a while back. For a start your equals implementations should be shared (i.e. the overload taking an object should pass through to the one taking a strongly typed object). Additionally you need to consider things such as your object should be immutable because of the need to ...
You can use the Java Sound API. I believe this is part of java 5. This may allow you to do what you want to do. http://java.sun.com/products/java-media/sound/ here are some examples: http://www.jsresources.org/examples/
Are you 100% sure the syntax is correct? I know with HTTP you'll have to an include extra linebreak after the request for it to go through. Without it you'll get nothing back. Not sure how it is with FTP though.
Doesn't really matter, they're both the same. erb is pure ruby, eruby is written in C so it's a bit faster. erubis (a third one) is pure ruby, and faster than both the ones listed above. But I doubt the speed of that is the bottleneck for you, so just use erb. It's part of Ruby Core.
The ANSWER is... not pretty. But it does precisely what I am after. [Dependency Finder][1]! [Download it][2], unzip it. Not the most modern or active project ever, but if you edit [Dependency Finder]/bin/DependencyFinder.bat, add its path for DEFAULT\_DEPENDENCYFINDER\_HOME, set a JAVA_HOME, you can launch it. ...
a first possible answer is... not pretty. But it does begin to do what I am after. (a better solution is [presented below][1]) [Dependency Finder][2]! [Download it][3], unzip it. Not the most modern or active project ever, but if you edit [Dependency Finder]/bin/DependencyFinder.bat, add its path for DEFAULT\_DE...
PGO gives about a 5% speed boost when compiling x264, the project I work on, and we have a built-in system for it (make fprofiled). Its a nice free speed boost in some cases, and probably helps more in applications that, unlike x264, are less made up of handwritten assembly.
Do you have any recommended macros for Microsoft Visual Studio?
|visual-studio|macros|
What are some macros that you have found useful in Visual Studio for code manipulation and automation?
If you type this just above a method or class, intellisense should prompt you with a list of available tags: /// <
C-x b TAB will give you an auto complete with all open buffers. Alternatively, click on the "Buffers" menu item if you are in a windowed version (not sure if there is a terminal equivalent of that). EDIT: Also C-x f will let you open a file, and you can use tab for autocomplete, then tab again to view files/direct...
C-x b TAB will give you an auto complete with all open buffers. Alternatively, click on the "Buffers" menu item if you are in a windowed version (not sure if there is a terminal equivalent of that). EDIT: Also C-x C-f will let you open a file, and you can use tab for autocomplete, then tab again to view files/dire...
The way I look at it is that the controller should reflect the end-user view and translate requests into model operations and reponses while also doing formatting. In your case there are 2 kinds of operations that represent simple operations with a default account/entry, and more complex operations that have user sele...
I think you may just have to brute force that one. I.e. comment out any vbo using lines a few at a time till your program doesn't crash anymore. Then you'll have an idea of which lines to focus your attention on and really scrutinize the parameters you're passing. Also try sprinkling glError() calls liberally arou...
Get Oracle Application Express. It's a browser-based tool that comes free with the database. It allows you to quickly click together reports and specify CSV (or Excel) as output format. (You can also use it to build complete applications). You find tons of documentation, demos etc. here: http://apex.oracle.com ...
They have two rendering pipelines, one using DX9 calls and one using DX10 calls. The APIs are not compatible, though a majority of any game engine can be reused for either. If you want some Open Source examples of how different rendering pipelines are done, look at something like Ogre3d, which supports OpenGL, DX9, and...
Accessing post variables using Java Servlets
|java|servlet|
The title says it all. All I really want is the equivalent of PHP's $_POST[], and after searching the web for an hour, I'm still nowhere closer.
|java|http|servlet|
|java|https|servlets|
|java|http|servlets|
Generating ETags
|language-agnostic|http|etag|header|
How do I generate an ETag HTTP header for a resource file?
HTTP: Generating ETag Header