instruction
stringlengths
0
30k
Can't you simply write your boolean expression in a separate static function which you call from your lambda - passing p.Ingredients as a parameter... private static bool IsIngredientPresent(IngredientBag i, string ingredientType, string ingredient) { return i != null && i.Contains(ingredientType) ...
One thing to check, make sure alpha test is off with AlphaTestEnable = false If that is on (along with something like AlphaFunction = Greater and ReferenceAlpha = 0), clear pixels could be thrown away regardless of the AlphaBlendEnable setting.
The most annoying issue with EclipseME for me was the "broken" debugger, which just wouldn't start. This is covered in docs, but it took me about an hour to find this tip when I first installed EclipseME, and another hour when I returned to JavaME development a year later, so I decided to share this piece of knowledge ...
Well, your sample code is not PHP, but yes, if you return a reference to a protected variable, you can use that reference to modify the data outside of the class's scope. Here's an example: <?php class foo { protected $bar; public function __construct() { $this->bar = arr...
How to add uninstall option in .NET Setup Project?
|.net|installation|uninstallation|
The .NET Setup project seems to have a lot of options, but I don't see an "Uninstall" option. I'd prefer if people could "uninstall" from the standard "start menu" folder rather than send them to the control panel to uninstall my app, so can someone please tell me how to do this? Also, I am aware of non Microso...
How do I get my Java application to shutdown nicely in windows?
|java|windows|shutdown|
I have a Java application which I want to shutdown 'nicely' when the user selects Start->Shutdown. I've tried using JVM shutdown listeners via Runtime.addShutdownHook(...) but this doesn't work as I can't use any UI elements from it. I've also tried using the exit handler on my main application UI window but it has ...
Well, building on what Niall Ryan started, if performance is an issue, you can take this one step further by optimizing the math and encapsulating this into a class. So we'll start with a bit of math. Recall that 800 can be written in powers of 2 as: 800 = 512 + 256 + 32 = 2^5 + 2^8 + 2^9 So we can write o...
As far as I know you need to start using JNI to set up a message handler for the Windows [WM_QUERYENDSESSION](http://msdn.microsoft.com/en-us/library/aa376890.aspx) message. To do this (if you're new to Windows programming like me) you'll need to create a new class of window with a new message handling function (as ...
AJAX or plugin are your only chances.
You can make shortcut to: msiexec /uninstall [path to msi or product code]
What exactly do you want to do that System.DateTime and System.Timespan can't handle?
OK, if you want definitive guide, here it is: [Configuring Visual Studio to Debug .NET Framework Source Code][1] If you want some help, go ahead and tell use which steps did you perform? [1]: http://blogs.msdn.com/sburke/archive/2008/01/16/configuring-visual-studio-to-debug-net-framework-source-code.aspx
Full-text databases, which can be queried with proximity operators such as "within 10 words of," etc. Relational databases are an ideal business tool for many purposes - easy enough to understand and design, fast enough, adequate even when they aren't designed and optimized by a genius who could "use the full power,...
I agree with [Tyler][1] - what you are describing is a variant of the [Subset Sum][2] problem which is known to be [NP-Complete][3]. In this case you are a bit lucky as you are working with a limited set of values so you can use [dynamic programming][4] techniques here to optimize the problem a bit. In terms of some ge...
There's three pretty good blog posts about Singletons by <a href="http://misko.hevery.com/about/">Miško Hevery</a> in the Google Testing blog. <ol> <li><a href="http://googletesting.blogspot.com/2008/08/by-miko-hevery-so-you-join-new-project.html">Singletons are Pathological Liars</a></li> <li><a href="http://go...
I don't know about GCJ, but my company uses Excelsior JET with success. We haven't done it with a webapp (yet) but it should be able to handle anything that the Sun JRE can. In fact JET is a Sun-certified Java implementation.
I'm not familiar with DB2, but have you tried COALESCE? ie: <pre><code> SELECT Product.ID, COALESCE(product.Name, "Internal") AS ProductName FROM Product </code></pre>
Especially in CFCs, proper scoping is important. The extra 'verbosity' is worth the clarity. Having variables slip out of their indended scope will cause severe problems and very hard to diagnose. Verbosity isn't always a bad thing. We name our functions and methods in descriptive manners like getAuthenticatedUser...
This is implementation dependent, as the C standard does NOT define the signed-ness of "char". Depending on the platform, char may be signed or unsigned, so you need to explicitly asked for "signed char" or "unsigned char" if you want them that way. The difference between signed char and unsigned char is as you'd e...
This is implementation dependent, as the C standard does NOT define the signed-ness of "char". Depending on the platform, char may be signed or unsigned, so you need to explicitly ask for "signed char" or "unsigned char" if your implementation depends on it. The difference between signed char and unsigned char is a...
This is implementation dependent, as the C standard does NOT define the signed-ness of "char". Depending on the platform, char may be signed or unsigned, so you need to explicitly ask for "signed char" or "unsigned char" if your implementation depends on it. Just use "char" if you intend to represent characters from ...
<p>A little Google search gave me the following OSS:</p> <dl> <dt>RLib</dt> <dd><a href="http://rlib.sicompos.com/">http://rlib.sicompos.com/</a></dd> <dt>PM Report</dt> <dd><a href="http://www.hotscripts.com/Detailed/48187.html">http://www.hotscripts.com/Detailed/48187.html</a> </dl> <br /> <p>I don't ...
<p>A little Google search gave me the following OSS:</p> >RLib >> [http://rlib.sicompos.com/](http://rlib.sicompos.com/) > >PM Report >>[http://www.hotscripts.com/Detailed/48187.html](http://www.hotscripts.com/Detailed/48187.html) <br /> <p>I don't have any information on them, sorry.</p>
Just to be technical... PostGIS isn't a project of the Postgres community... it's a stand-alone project that is built on top of Postgres. If you want help or support with PostGIS, you'll want to go to it's community instead of Postgres.
If it looks bad you can use CSS to change the appearance of selected sections.
The official word on what is supported looks like this: ![alt text][1] The reality is that we do run on **a lot** of browsers, but things change might quickly in these here parts. [1]: http://www.jesseliberty.com/sl/browsers.jpg
If you *have* to delve down into the C APIs, you might tackle the limitation to 32-bit builds by moving the QuickTime specific code into a separate, 32-bit process. We do this on Windows and it works quite well ...
MySQL, Asterisk Dialplans and call forwarding
|mysql|asterisk|
How do I get Asterisk to forward incoming calls based on matching the incoming call number with a number to forward to? Both numbers are stored in a MySQL database.
1. You need to read original image stream using FileStream and then pass it to the Serializer using MemoryStream. 2. If you can only use Image class the try to specify output format of byte array you're receiving.
Contrary to Patrick's answer, C++ has no `^^` operator for performing a short-circuiting exclusive or. If you think about it for a second, having a `^^` operator wouldn't make sense anyway: with exclusive or, the result always depends on both operands. However, Patrick's warning about non-`bool` "Boolean" types holds e...
I try to understand the intent of .NET NetworkStream designers, and they must design it this way. After Write, the data to send are no longer handled by .NET. Therefore, it is reasonable that Write returns immediately (and the data will be sent out from NIC some time soon). So in your application design, you should ...
Use the "relocate" option provided by Tortoise SVN. Just right click on the upper-most checked out folder, select relocate, and then enter the new URL.
The community standard workhorses are Test::Simple (for getting started with testing) and Test::More (for once you want more than Test::Simple can do for you). Both are built around the concept of expected versus actual output, and both will show you differences when they occur. The perldoc for these modules will get y...
Take a look at Ant [macros][1]. They allow you to define reusable "routines" for Ant builds. You can find an example [here][2] (item 15). [1]: http://ant.apache.org/manual/CoreTasks/macrodef.html [2]: http://blog.uncommons.org/2007/10/25/15-tips-for-better-ant-builds/
Flash hyperlinks spacing error
|flash|actionscript-3|
I have a weird bug involving Flash text and hyperlinks, htmlText in a TextField with `<a>` tags seem to truncate surrounding space: ![output][1] Once I place my cursor over the text, it "fixes" itself: ![output with mouseover][2] Here is the HTML in the textField: <p>The speeches at both the <a href=...
I'm with [Mendelt Siebenga][1] on the fact that you should use the Command Pattern. The pattern you used was the Memento Pattern, which can and will become very wasteful over time. Since you're working on a memory-intensive application, you should be able to specify either how much memory the undo engine is allowed ...
"End Process" on the Processes-Tab calls TerminateProcess which is the most ultimate way windows knows to kill a process. If it doesn't go away, it's currently locked waiting on some kernel resource (probably a buggy driver) and there is nothing (short of a reboot) you could do to make the process go away. Have a...
It isn't necessary as others have pointed out, but it is good practice and helps with debugging. Once an object has finished with a pointer it is using then setting it to null helps prevent reuse of that object later (you'll get an null reference exception). The same logic applies to setting member pointers to nu...
Many programmers don't use templates much because of the poor compiler support up until recently. However, while templates have had a lot of issues in the pas, newer compilers have much better support. I write code that has to work with GCC on Mac and Linux as well as Microsoft Visual C++ and it's only with GCC 4 and ...
on error resume next - is kinda close but its been a while. you might want to look up any caveats
As you may already know, the long-term solution for this is supposed to be the ZODB BLOB support. [Ticket 6805](http://dev.plone.org/plone/ticket/6805) is probably the most authorative source on this. Unfortunately, the milestone is set to 4.0, and running it in production on an older release is perhaps not a good solu...
The [quickcheck manual][1] says "no": > Properties must have monomorphic types. `Polymorphic' properties, such as the one above, must be restricted to a particular type to be used for testing. It is convenient to do so by stating the types of one or more arguments in a > where types = (x1 :: t1, x2 :: t2, ...) ...
Since you're testing legacy code I'm assuming you can't refactor said code to have less dependencies (e.g. by using the <a href="http://www.gotw.ca/gotw/028.htm">pimpl idiom</a>) That leaves you with little options I'm afraid. Every header that was included for a type or function will need a mock object for that typ...
An unsigned char uses the bit that is reserved for the sign of a regular char as another number. This changes the range to [0 - 255] as opposed to [-128 - 127]. Generally unsigned chars are used when you don't want a sign. This will make a difference when doing things like shifting bits (shift extends the sign) and...
MySQL has a null-safe equality operator, <=>, which returns true if both sides are equal or both sides are null. See [MySQL Docs][1]. [1]: http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#operator_equal-to
Not strictly speaking of error_reporting, I'd **strongly** suggest using any IDE that automatically shows parsing errors and common glitches (eg, assignment in condition). Zend Studio for Eclipse has this feature enabled by default, and since I started using it, it has been helping me **a lot** at catching errors be...
Depending on what you mean by 'class': callable( obj ) and not inspect.isclass( obj ) or: callable( obj ) and not isinstance( obj, types.ClassType ) For example, results are different for 'dict': >>> callable( dict ) and not inspect.isclass( dict ) False >>> callable( dict ) and not...
FacesContext facesContext = FacesContext.getCurrentInstance().getFacesContext(); HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse(); response.addHeader("Set-Cookie", "yourcookiename=yourcookievalue; HTTPOnly");
I fixed the issue that I had with the connection. The problem was on my application. The cause of the issue was that a connection string to the development (instead of the production) database, was hardcoded by one of the dialogs that generates the datasets. This dialog placed the connection string both on the web.conf...
How global do your hotkeys need to be? Is it enough for them to be global for a X session? In that case you should be able to just open an Xlib connection and listen for key press events.
How global do your hotkeys need to be? Is it enough for them to be global for a X session? In that case you should be able to open an Xlib connection and listen for the events you need. Ordinarily keyboard events in X are delivered to the window that currently has the focus, and propagated up the hierarchy until t...
I use this on my macbook: " configure expanding of tabs for various file types au BufRead,BufNewFile *.py set expandtab au BufRead,BufNewFile *.c set noexpandtab au BufRead,BufNewFile *.h set noexpandtab au BufRead,BufNewFile Makefile* set noexpandtab " --------------------------------...
The SQL command is: ALTER TABLE <tablename> ADD CONSTRAINT <constraintname> UNIQUE NONCLUSTERED ( <columnname> ) See the full syntax [here][1]. If you want to do it from a Database Diagram: - right-click on the table and select 'Indexes/Keys' - cl...
In addition to adding the frameborder attribut you might wan't to consider setting the scrolling attribute to "no" to prevent scrollbars from appearing. <IFRAME src="myURL" width=300" height="300" frameborder="0" scrolling="no">Browser not compatible. </IFRAME>
Ok, I guess the jury is out on this one. @leddt, I already knew that the 'crap' was the containers surrounding it, but I thought maybe Microsoft would have left a backdoor to leave the ID alone. Regenerating CSS files on every use by including ClientIDs would be a horrible idea. I'm either left with using class...
Only you can really answer that question. Your customers' experience of your site will be mediated by their browser. The first place to look for browser information is at a listing of the user-agents that are being used to access your website. Hopefully you have a good log analyzer such as Analog, Weblog, Google Analyt...
NHibernate and shared web hosting
|security|nhibernate|web-hosting|
Has anyone been able to get an NHibernate-based project up and running on a shared web host? NHibernate does a whole lot of fancy stuff with reflection behind the scenes but the host that I'm using at the moment only allows applications to run in medium trust, which limits what you can do with reflection, and it's t...
Has anyone been able to get an NHibernate-based project up and running on a shared web host? NHibernate does a whole lot of fancy stuff with reflection behind the scenes but the host that I'm using at the moment only allows applications to run in medium trust, which limits what you can do with reflection, and it's t...
I might create a single dimension array of 800*800. It is probably more efficient to use a single allocation like this, rather than allocating 800 separate vectors. int *ary=new int[800*800]; Then, probably encapsulate that in a class that acted like a 2D array. class _2DArray { public: ...
I might create a single dimension array of 800*800. It is probably more efficient to use a single allocation like this, rather than allocating 800 separate vectors. int *ary=new int[800*800]; Then, probably encapsulate that in a class that acted like a 2D array. class _2DArray { public: ...
@marcio - My own server-side app shells out to ffmpeg to do encoding. I'm 98.42% sure ffmpeg does snapshots, too. (It is an all singing, all dancing ***beast*** of a program. The command line options alone could fill a book.) Check it out: [ffmpeg.mplayerhq.hu][1] [1]: http://ffmpeg.mplayerhq.hu/
Back it up in SQL Server 2000 and then use the `RESTORE WITH MOVE` command into 2005 Express.
We address this - or at least a similar problem to this - as follows: 1. The schema has a version number - this is represented by a table which has one row per version which, as well as the version number, carries boring things like a date/time stamp for when that version came into existence. 2. By having the sch...
Get process explorer from sysinternal (now Microsoft) [http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx][1] [1]: http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx
Get process explorer from sysinternals (now Microsoft) [http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx][1] [1]: http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx
I would use one of the DateTime.TryParse techniques in conjunction with a [CustomValidator][1] [1]: http://msdn.microsoft.com/en-us/library/f5db6z8k.aspx
What are some good SharePoint security resources?
|security|sharepoint|
I've got a SharePoint application and I'm sad to say that in my SharePoint-induced excitement, I ignored a lot of the security concerns I should have been paying more attention to. Though we didn't before, now we actually *need* granular security, so I need to get educated. I'm mostly interested in how to best create...
For this particular issue, the reason is because javascript generated by ASP.NET 2.0 has some IE only notation: event.srcElement is not availabe in FireFox (use event.target instead): function WebForm_FireDefaultButton(event, target) { if (!__defaultFired && event.keyCode == 13 && !(event.srcElement && ...
I understand that the people you call functional people are acting as Product Owners, right? > I think part of the problem is that there are no specs or User Stories as such. Personally I think they need to be writing down some sort of requirements - what sort of things should they be writing down and to what comple...
To answer the original question - there are various ways to do this, but the following would be the simplest. If you already have a handle to the child node that you want to remove, i.e. you have a JavaScript variable that holds a reference to it: myChildNode.parentNode.removeChild(myChildNode); Obviously,...
To answer the original question - there are various ways to do this, but the following would be the simplest. If you already have a handle to the child node that you want to remove, i.e. you have a JavaScript variable that holds a reference to it: myChildNode.parentNode.removeChild(myChildNode); Obviously,...
I don't think there is a web-app that allows you to write an instance document based on an uploaded schema (as yet.. mebbe I should write one? :) ). [Altova XMLSpy][1] is pretty much the best of the editors I have used, but very expensive. [1]: http://www.altova.com/products/xmlspy/xml_editor.html
compile, next-error, and previous-error are all pretty important commands for C++ development in Emacs (works great on grep output too). Etags, visit-tags-table, and find-tag are important as well. completion.el is one of the great unsung hacks of the 20th century, and can speed up your C++ hacking by an order of mag...
I attempted to define SOA in [one of my blog posts][1]. Here's an excerpt... > For years it's been standard practice to separate functionality into functions, classes, and modules. The idea has always been that these smaller, highly specialized components are easier to share and maintain than monolithic blocks of c...
If you extend ArrayObject, or implement ArrayAccess then you can do what you want. [http://uk2.php.net/arrayobject][1] [http://www.php.net/~helly/php/ext/spl/interfaceArrayAccess.html][2] [1]: http://uk2.php.net/arrayobject [2]: http://www.php.net/~helly/php/ext/spl/interfaceArrayAccess.html
It looks like qemu-img from [qemu](http://bellard.org/qemu/) can do this, at least looking at its commandline help on a Ubuntu 8.04 machine where it claims support for, amont others, the "parallels" and the "vpc" format. Have not tried myself, though. Hope this helps.
It looks like qemu-img from [qemu](http://bellard.org/qemu/) can do this, at least looking at its commandline help on a Ubuntu 8.04 machine where it claims support for, among others, the "parallels" and the "vpc" format. Have not tried myself, though. Hope this helps.
@Matt Dawdy: There are some great uses for IDs in CSS, primarily when you want to style an element that you know only appears once in either the website or a page, such as a logout button or masthead.
Possible solutions aside, direct translations of programs written in one language to a different language is generally considered a Bad Idea&trade; -- especially if this translation is done in some automated fashion. Even when done by a "real" programmer, translating an application line by line often results in a less...
[Hotwire][1] could be a good candidate, but it's not doing that out of the box, AFAIK [1]: http://hotwire-shell.org/
The problem with having a servlet implement MessageListener is that servlets are synchronous and MessageListeners are asynchronous. Instead you should create some other object to act as the MessageListener and update some state somewhere (possibly a database or a JMX MBean or a Stateful Session EJB) when messages come...
If it is already split up, and you can be sure that the routine to split the data is sound, then I would split up the table as granular as possible. You can always parse it back together in your middle tier. If space is not an issue, you could always store it twice. One, split up into the relevant fields, and anothe...
How to make embedded servlet engine instantiate servlets eagerly?
|java|servlets|jetty|
The problem is simple, but I'm struggling a bit already. Server server = new Server(8080); Context context = new Context(server, "/", Context.NO_SESSIONS); context.addServlet(MainPageView.class, "/"); context.addServlet(UserView.class, "/signup"); server.start(); That's a pretty stan...
You could use Javascript: <input name="Query" type="text" class="searchField" id="Query" value="Search" size="15" onfocus="if(this.value == 'Search') { this.value = ''; }" onblur="if(this.value == '') { this.value = 'Search'; }" onkeydown="var event = event || window.event; var key = event.which || event.keyCode...
Is it possible that you have items copied throughout your datasource for the drop down list?
WPF enables you to do some amazing things, and I LOVE it... but I always feel obligated to qualify my recommendations, whenever developers ask me whether I think they should be moving to the new technology. Are your developers willing (preferrably, EAGER) to spend the time it takes to learn to use WPF effectively? ...