instruction
stringlengths
0
30k
The following should work. (See link to [Variadic macros][1]) (Example below shows a fixed and variable arguments.) # define DBGPRINTF(fmt,...) \ do { \ printf(fmt, __VA_ARGS__); \ } while(0) [1]: http://msdn.microsoft.com/en-us/library/ms177415(VS.80).aspx
GotAPI is a fantastic resource http://www.gotapi.com
Although I think the first mistake was choosing an implementation language without ensuring a suitable deployment environment, there's nothing that can be done about that now. I would think the Mono way would be better. Having to rewrite code would only increase the cost of the project, especially if you already have a...
Spend a couple hours at the vi lover's site http://nereida.deioc.ull.es/html/vilovers.html - loads of tutorials, links, etc. with enthusiastic fans of vi.
You are after a native SQL query. If you are using JPA the syntax is: Query q = em.createNativeQuery("select foo.* from Foo foo " + "where f.x = max(f.x) over " + "(partition by f.y)", Foo.class); If you need to return multiple types, ...
You may be able to have multiple form tags, but note that they cannot be nested. You'll run into all kinds of weirdness in that scenario (e.g., I've seen cases where the opening tag for the nested form apparently gets ignored and then its closing tag winds up closing the "parent" form out).
I use SQL Explorer. It comes as an Eclipse plugin or standalone. http://eclipsesql.sourceforge.net/
[WURFL][1] is the best open resource for handling device-specific browser properties, including CSS. [1]: http://wurfl.sourceforge.net
Here's a little clarification of the direction I hoped the responses would take: * pros/cons of various of frameworks * compatibility/install base of frameworks * suitability for internal (local) vs. external (CPAN) releases * *not* bare "use X" answers [Dave's answer](http://stackoverflow.com/questions/73889/...
It seems it can't be done that way. It will only provide meta information about the method and it's parameters. Not the actual value at the time of the callstack. Some suggest deriving your classes from [ContextBoundObject][1] and use [IMessageSink][2] to be notified off all method calls and the values of the param...
On a linux box I use the ssh-agent and sshfs. You need to setup the sshd to accept connections with key pairs. Then you use ssh-add to add you key to the ssh-agent so you don't have type your password everytime. Be sure to use -t seconds, so the key doesn't stay loaded forever. <br /> ssh-add -t 3600 /home/user/.ssh/s...
If a class has a Dispose method the best practice is to call it. the reason behind that is that Dispose runs when called, whereas setting the object to null simply adds a entry to the Finalize queue in GC, and we cannot determine when GC will run. There is no performance benefit in implementing the Dispose method...
([1-9]|1\d|2[0-8]) would match the numbers 1 to 28 but woudn't allow leading zeros for single digits (0?[1-9]|1\d|2[0-8]) would match the numbers 1 to 28 and would allow 01, 02,... 09 (where \d matches any digit, use [0-9] if your regex engine doesn't support it.)
([1-9]|1\d|2[0-8]) // matches 1 to 28 but woudn't allow leading zeros for single digits (0?[1-9]|1\d|2[0-8]) // matches 1 to 28 and would allow 01, 02,... 09 (where \d matches any digit, use [0-9] if your regex engine doesn't support it.) See also the question [What is the regex pattern for datetime (2...
The purpose of a dispose method is to release all resources associated with your class, and the parent's class by calling the base class dispose method. Have a read of this link, it should make things a little clearer: http://msdn.microsoft.com/en-us/library/fs2xkftw.aspx
what do you mean by "large object"? You should at least call Dispose() on any member implementing IDisposable, though.
**Original Question** I am currently engaged in teaching my brother to program. He is a total beginner, but very smart. (And he actually wants to learn). I've noticed that some of our sessions have gotten bogged down in minor details, and I don't feel I've been very organized. (*But the answers to this post have h...
**Original Question** I am currently engaged in teaching my brother to program. He is a total beginner, but very smart. (And he actually wants to learn). I've noticed that some of our sessions have gotten bogged down in minor details, and I don't feel I've been very organized. (*But the answers to this post have h...
I used a local automatic proxy configuration script for years with great success. The trick was identifying from the URL or IP address where I was. /Allan
Let's tackle this systematically, because there is a lot to learn and there is a lot of information out there. You may want to start with Microsoft's resources first, as they are highly reviewed, and all in one place, and we're working hard to create a lot of them to produce a smooth on-ramp. Then, when you are comfort...
`[0-9][0-9][0-9]`, `[0-9]{3}` or `\d{3}` don't work because they also match "1234". So it depends on what the delimiter is. If it's in a variable, then you can do `^/[0-9]{3}/$`. If it's delimited by whitespace you could do `\w+[0-9]{3}\w+`
OK, I found the problem. The packaging task uses reflection for some reason or another. When it finds that your class inherits from a class in another domain, it tries to load it using reflection. However, reflection doesn't do binding policy, so that domain isn't loaded. The authors of the packaging program could s...
In a **PostScript** file called so.ps will cause execstackoverflow %!PS /increase {1 add} def 1 increase (so.ps) run
If you're using a web framework such as [Spring][1] then you can delegate in your web.xml to a page and then use the controller to send the email. For example: In web.xml: <error-page> <error-code>500</error-code> <location>/error/500.htm</location> </error-page> Then define /error/500.h...
as a general rule of thumb, if i have to set the value of the string more than once, or if there are any appends to the string, then it needs to be a string builder. I have seen applications that I have written in the past before learning about string builders that have had a huge memory foot print that just seems to k...
I assume you don't mean *any* Exception but rather any *uncaught* Exception. If this is the case [this article on the Sun Website][1] has some ideas. You need to wrap your top level method in a `try-catch` block and also do some extra work to handle other Threads. [1]: http://java.sun.com/developer/JDCTechTi...
I encountered this for the first time a few weeks ago. I found it was down to invalid HTML. I had to cut out sections of content and paste it back in a little at a time to track down the problem.
Do you have any code in page load that is by chance re-defaulting the value to the first value? When the page reloads do you see the new value?
Usually this sort of behavior is caused by invalid code. It may only be invalid HTML causing it which would still allow the program to be compiled. For example, if tags are mismatched like this the IDE cannot reformat it. <div><h1>My Title</div></h1 Check your warnings to see if there are any entries poin...
Also you should note, that name resolution happens before overload resolution. So if there is something with the same name in your current scope then it will stop looking for other names and try to use them. void bar() {}; class foo { void bar(int) {}; void foobar() { bar(); } // won't com...
Preventing stuff like that is the whole point. If it's your code that's supposed to run in the chroot, have it set a flag on startup. If you're hacking, hack: check for several common things in known locations, count the files in /etc, something in /dev.
Multicolor cursor in X
|cursors|x|
X has the method XCreatePixmapCursor to create a cursor from a pixmap with a color depth of 1. The foreground and background colors can be other than black and white, but there are only two colors. Is there a way to create a multicolored cursor in X?
Corey, my answer of using FxCop had assumed you were interested in removing unused private members, however to solve the problem with other cases you can try using [NDepend][1]. With some CQL to remove them: // <Name>Potentially unused methods</Name> WARN IF Count > 0 IN SELECT METHODS WHERE MethodCa ...
Corey, my answer of using FxCop had assumed you were interested in removing unused private members, however to solve the problem with other cases you can try using [NDepend][1]. Here is some CQL to detect unused public members (adapted from an article listed below): // <Name>Potentially unused methods</Name> ...
Remember that obfuscation is only a barrier to the casual examiner of your code. If someone is serious about figuring out what you wrote, you will have a very hard time stopping them. If you have secrets in your code (like passwords), you're doing it wrong. If you worried someone might produce your own software ...
**Original Question** I am currently engaged in teaching my brother to program. He is a total beginner, but very smart. (And he actually wants to learn). I've noticed that some of our sessions have gotten bogged down in minor details, and I don't feel I've been very organized. (*But the answers to this post have h...
**Original Question** I am currently engaged in teaching my brother to program. He is a total beginner, but very smart. (And he actually wants to learn). I've noticed that some of our sessions have gotten bogged down in minor details, and I don't feel I've been very organized. (*But the answers to this post have h...
unpatented one-way encryption algorithm
|encryption|hash|
I am looking for a simple unpatented one-way encryption algorithm, preferably in c. I would like to use it to validate passwords.
it will be cool to have autocompletion in flash CS3 like the one that comes with eclipse for java (with hints, hierarchies , implementation, autoimports for clases etc . .), i dont know why everyone wants to separate the code from graphical editor , when thats the best part of flash , anyway i always recommend to stay...
just use the crypt(3) function here's the [background][1] [1]: http://en.wikipedia.org/wiki/Crypt_(Unix)
MD5 has suited me fine so far.
You should use this: "^\d{3}$"
Are you looking for something more like this? (untested, just typed it up in the reply box) var cookies = new HttpCookieCollection(); controller.ControllerContext = new FakeControllerContext(controller, cookies); var result = controller.TestCookie() as ViewResult; Assert.AreEqual("somevaluethatsh...
Are you looking for something more like this? (untested, just typed it up in the reply box) var cookies = new HttpCookieCollection(); controller.ControllerContext = new FakeControllerContext(controller, cookies); var result = controller.TestCookie() as ViewResult; Assert.AreEqual("somevaluethatsh...
If the functionality is the GetValue() returns each array element in succession then you should be able to set up multiple expectations eg using(_mocks.Record()) { Expect.Call(mocked_class.GetValue()).Return(3); Expect.Call(mocked_class.GetValue()).Return(6); Expect.Call(mocked_class.GetVa...
*Disclaimer: Non-informed person speaking* Its a tradeoff between openness/standards and performance.. Maybe you're using something like SOAP that adds a lot of protocol overhead bytes to the data packet. If size is a vital constraint, try sending it across as a pure binary stream... the actual syntax maybe someone ...
Don't do this with Regex. Dates are formatted differently in different countries. Use the DateTime.TryParse routine instead: DateTime parsedDate; if ( DateTime.TryParse( dateString, out parsedDate) && parsedDate.Day <= 28 ) { // logic goes here. } Regex is nearly the <a href="http:...
Don't do this with Regex. Dates are formatted differently in different countries. Use the DateTime.TryParse routine instead: DateTime parsedDate; if ( DateTime.TryParse( dateString, out parsedDate) && parsedDate.Day <= 28 ) { // logic goes here. } Regex is nearly the <a href="http:...
Perhaps this answer should be in a different thread, but in Java: list = new ArrayList<T>(new HashSet<T>(list)) If you really wanted to mutate the original list: List<T> noDupes = new ArrayList<T>(new HashSet<T>(list)); list.clear(); list.addAll(noDupes);
In Java (I assume C# is more or less identical): list = new ArrayList<T>(new HashSet<T>(list)) If you really wanted to mutate the original list: List<T> noDupes = new ArrayList<T>(new HashSet<T>(list)); list.clear(); list.addAll(noDupes); To preserve order, simply replace HashSet with Link...
Not usually. The garbage collector looks for rooted objects, and circular dependencies don't prevent collection if neither object is rooted. There is a caveat: if object A has a reference to object B, and object B is being disposed, you may want to clean up that relationship or else you could end up with a leak. ...
> not sure that it matters which database UNION and UNION ALL should work on all sql servers. You should avoid of unnecessary UNIONs they are huge performance leak. As a rule of thumb use UNION ALL if you are not sure which to use.
how to remove black border around hyperlinked image?
|html|css|
When I turn an image (<img>) into a hyperlink (by wrapping it in <a>), Firefox adds a black border around the image. Safari does not display the same border. What CSS directive would be best to eliminate the border?
> Bounds checking This means runtime checks of array accesses. Contrary to C's laissez-faire approach to memory accesses and pointer arithmetic, other languages like Java or C# actually check whether or not a given array has the element one is trying to access.
a img { border-width: 0px; }
Well, it depends on what's most important... if a tripple map is too tedious to use, then is implementing other data structures not worth the effort? If you want to get around the uglyness of the tripple map solution, just wrap it up in another container class with an access function with three parameter, and hide a...
To me it seems you're missing a ; between the two statements: nsert into ps_tl_compleave_tbl values('2626899', 0, TO_DATE('01/01/2002', 'MM/DD/YYYY'), 'LTKN', 'LTKN', '52', TO_DATE('01/01/2002', 'MM/DD/YYYY'), 16.000000, 24.000)<br/><b>;</b><br>insert into ps_tl_compleave_tbl values('4327142', 0, TO_DATE('03/23/2002',...
Column Info only Returned with FMTONLY set to OFF
|sql-server|
I have a query that is dynamically built after looking up a field list and table name. I execute this dynamic query inside a stored proc. The query is built without a where clause when the two proc parameters are zero, and built with a where clause when not. When I execute the proc with SET FMTONLY ON e...
You could use reflection to get all the properties of an object, than loop through it, and get the value of the property where the name (of the property) matches the passed in parameter.
Well had a bit of look. *of course* you can't use any Type information. Also, the name of a local variable is not available at runtime because their names are not compiled into the assembly's metadata.
<a href="http://www.multieditsoftware.com">MultiEdit</a> Extremely powerfull (and extensible on emacs level) text editor with many IDE features (integration with compilers/debuggers etc). Beats all other suggested editors on every aspect. Much easier to learn and use than editors with UNIX/terminal roots like vi...
I'm going to go with youphoric on this one. For very large files SAX (or any other streaming parser) will be a great help in processing. Using DOM you can collect just top level nodes, but you still have to parse the entire document to do it...using a streaming parser and event-based processing lets you "skip" the node...
**Original Question** I am currently engaged in teaching my brother to program. He is a total beginner, but very smart. (And he actually wants to learn). I've noticed that some of our sessions have gotten bogged down in minor details, and I don't feel I've been very organized. (*But the answers to this post have h...
**Original Question** I am currently engaged in teaching my brother to program. He is a total beginner, but very smart. (And he actually wants to learn). I've noticed that some of our sessions have gotten bogged down in minor details, and I don't feel I've been very organized. (*But the answers to this post have h...
Here is an option I came up with, it may help: public static class Container<E> { private Class<E> clazz; public Container(Class<E> clazz) { this.clazz = clazz; } public E createContents() throws Exception { return clazz.newInstance(); } ...
It's this way in SQL (as a logic language) because null means unknown/undefined. However, in programming languages (like say, C++ or C#), a null pointer/reference is a specific value with a specific meaning -- nothing. Two nothings are equivilent, but two unknowns are not. The confusion comes from the fact that ...
What real-world language implement academic features from functional programming?
|lisp|haskell|ml|functional-programming|enterprise|
Lisp developed a set of interesting language features quite early on in the academic world, but most of them never caught on in production environments. Some languages, like JavaScript, adapted basic features like garbage collection and lexical closures, but all the stuff that might actually change how you write pro...
What real-world languages implement academic features from functional programming?
|functional-programming|lisp|haskell|enterprise|ml|
As someone else pointed out, it is recommended not to expose List<T> publicly, and FxCop will whinge if you do so. This includes inheriting from List<T> as in: public MyTypeCollection : List<MyType> In most cases public APIs will expose IList<T> (or ICollection<T> or IEnumerable<T>) as appropriate. In cas...
It can't find basic system headers. Either your include path is seriously messed up, or the headers are not installed.
Google might be your best bet. I know the msdn site search has time and again pointed me in the wrong direction, but a quick switch to Google ("GetLongPathName site:msdn.microsoft.com") never steers me wrong.
As others point out, you need to match more than just the three digits. Before the digits you have to have either a line-start or something that is not a digit. If emacs supports \D, use it. Otherwise use the set [^0-9]. In a nutshell: (^|\D)\d{3}(\D|$)
Take a screenshot via a python script. [Linux]
|python|linux|screenshot|
I want to take a screenshot via a python script and unobtrusively save it. I'm only interested in the Linux solution, and should support any X based environment.
SVN and renaming the server it's running on
|svn|tortoisesvn|visualsvn|
I'm running VisualSVN as my SVN server and using TortoiseSVN as the client. I've just renamed the server from mach1 to mach2 and now can't use SVN because it's looking for the repositories at http://mach1:81/ instead of the new name http://mach2:81/ Any idea how to fix this?
SHA-1 seems like a good suggestion, or, if you believe that SHA-1 is close to being cracked, one of the SHA-2 family. You may feel that MD5 isn't "safe" enough.
If you're debugging at the instruction level rather than the source level, it's an awful lot for you easier to map unoptimized instructions back to the source. Also, compilers are occasionally buggy in their optimizers. In the Windows division at Microsoft, all release binaries are built with debugging symbols and f...
JPEG is a compression technology, and it is expected that it will expand greatly once you read it in. This is the nature of the file format. Try to find a way to send the original JPEG file without reading it as an image first.
Create a .Bat file which uses svcutil, for proxygeneration, that has the settings that is right for your project. It's fairly easy. Clicking on the batfile, to generate new proxyfiles whenever the interface have been changed is easy. The batch can then later be used in automated builds. Then you only need to set up...
Workarount is to programmatically add <script> blocks to head DOM element in JavaScript at Callback function or call eval() method. It's only way you can make this work in IE 6.
Is there a reason you can't override the base class's `execute` function directly? class Base(object): def execute(self): ... class Derived(Base): def execute(self): """Docstring for derived class""" Base.execute(self) ...stuff specific...
No, but whenever you find yourself doing extremely complex things like this, you might want to re-think your solution. Remember that code should be easier to read than it was to write.
Are you expecting/requiring exact matches? These might be hard to enforce with doubles. For example, if you have processed (1.0, 1.0, 1.0) and you then receive (0.9999999999999, 1.0, 1.0) would you consider it the same? If so, you will need to either apply some kind of approximation or else define error bounds. Howe...
System.Environment.StackTrace will give you a string that includes the current call stack. You could parse that to get the information, which includes the variable names for each call.
How to run TAP::Harness tests written in Guile?
|guile|unit-testing|