instruction stringlengths 0 30k ⌀ |
|---|
I'm not sure how you do the XOR bit (at least it should be slow; I don't think any of current GPUs accelerate that), but here's my idea:
1. have two input images
2. turn on occlusion query.
3. draw the two images to the screen (i.e. full screen quad with two textures set up), with a fragment shader that computes a... |
Exceptions are not for error handling, IMO. Exceptions are just that; exceptional events that you did not expect. Use with caution I say.
Error codes can be OK, but returning 404 or 200 from a method is bad, IMO. Use enums (.Net) instead, that makes the code more readable and easier to use for other developers. Als... |
Physical Address in JAVA |
|java|macos| |
How do I get the physical addresses of my machine in Java. |
Since you hide the names of the classes, this food for thought on style may or may not apply:
Does it make sense to tell these two objects, MethodA and MethodB, to "get" or "getAsConst"? Would you send "get" or "getAsConst" as messages to either object?
The way I see it, as the sender of the message / invoker of... |
I believe Enum.GetValues() is what you're looking for. |
Try this:
string value = (string)TransactionTypeCode.Shipment; |
I personally just write my own iterator class that inherits from IEnumerator(Of T). It does take sometime to get it right, but I think in the end its better to write it right then try to avoid it. Another method that I have done is to write a recursive method that returns IEnumerable(Of T) and just returns List(Of T)... |
I'm not up on my Java right now, but I would think about the following things.
How you are creating your list? Perhaps you can create it already ordered in a way which cuts down on comparison time.
If you are just doing a straight loop through your collection, you won't see much difference between storing it as ... |
It's definitely not free, but for keeping your T-SQL formatted in a consistent way, Redgate Software's [SQL Prompt][1] is very handy. As long as your proc's syntax is correct, a couple of keystrokes (Ctrl+K,Y) will reformat it all instantly. The options give you a lot of control over how your SQL is formatted.
[... |
For your particular example, sorting the collection would help as you could binarychop to the first item that starts with query and terminate early when you reach the next one that doesn't; you could also produce a table of pointers to collection items sorted by the reverse of each string for the second clause.
In g... |
You'll want to look at smart pointers, such as [boost's smart pointers][1].
Instead of
int main()
{
Object* obj = new Object();
//...
delete obj;
}
boost::shared_ptr will automatically delete:
int main();
{
boost::shared_ptr<Object> obj(new Object... |
You'll want to look at smart pointers, such as [boost's smart pointers][1].
Instead of
int main()
{
Object* obj = new Object();
//...
delete obj;
}
boost::shared_ptr will automatically delete once the reference count is zero:
int main()
{
boost::s... |
You'll want to look at smart pointers, such as [boost's smart pointers][1].
Instead of
int main()
{
Object* obj = new Object();
//...
delete obj;
}
boost::shared_ptr will automatically delete once the reference count is zero:
int main()
{
boost::s... |
Use the static method
java.lang.reflect.Array.newInstance(Class<?> componentType, int length)
A tutorial on its use can be found here:
[http://java.sun.com/docs/books/tutorial/reflect/special/arrayInstance.html][1]
[1]: http://java.sun.com/docs/books/tutorial/reflect/special/arrayInstance.html |
How do I create a "select folder OR file dialog window"? |
|realbasic| |
You can use
SelectFolder() to get a folder
or
GetOpenFolderitem(filter as string) to get files
but can you select either a folder or file? ( or for that matter selecting multiple files )
|
How do I create a "select folder OR file dialog window" in REALbasic? |
Connecting to IMDB |
|web-services| |
Has any one done this before? It would seem to me that there should be a webservice but i can't find one. I am writing an application for personal use that would just show basic info from IMDB. |
|web-services|imdb| |
You could try the CTP(!) of the [Parallel extensions][1] for .NET. These allow you to write something like:
Parallel.Foreach (ListOfStrings, (item) =>
result.add(CalculateSmth(item));
);
Of course result.add would need to be thread safe.
[1]: http://msdn.microsoft.com/en-us/concurrency/def... |
> Also If I use this methodology, do I need to worry about unicode & ASCII clashing?
Your first problem will be your tags clashing with ASCII. Once you get to TAG10, you will clash with 0x0A: line feed. If you ensure that you will never get more than nine tags, you should be safe. Unicode-encoding (or rather: UTF8) ... |
Best practice for application-icon in windows |
|icon|windows| |
So far I had "designed" my app-icon in the Visual-Studio-Editor. 16-Colors, 4kB.
Now someone created a more sophisticated and up-to-date app-icon for me, which results in a filesize of about 250kB.
**Problem:** A user reported, that win2000 is complaining, because it is not able to digest this amount of data for a... |
|icons|windows| |
Chances are high that you miss the runtime libraries of Visual Studio (CRT amongst others), you can either get rid of those dependencies (link statically) or install the VC redist packages on the target computer.
Depending on the Visual C++ version you use, you have to install different packages :
[Visual C++ 200... |
All of the implementations are listed here:
http://www.python.org/dev/implementations/
CPython is the "reference implementation" and developed by Guido and the core developers.
|
DannySmurf said it. You don't have direct "managed" access to these APIs though the .NET framework (I tried this myself a few weeks ago).
I ended up doing something nasty. Created my own UI with GDI+. (Buttons, rounded labels, etc). It looks the same regardless of the Windows version. Win.Forms is really ugly, but t... |
Well, they say you need a key - you need a key, then :-) Exposing an API means you can pull data off the site way easier, it is understandable they want this under control. It is pretty much the same as with other API enabled sites. |
One issue that I've run into is that Visual Studio doesn't allow multiple languages to be mixed in a single project, forcing you to abstract things out into separate DLLs for each language, which isn't necessarily ideal.
I suspect the main reason, however, is the perception that switching back and forth between many... |
What server technology do you use and is there a particular product you use for authentication?
Since the browser is only doing its job, I believe you have to change things on the server side to not return a 401 status code. This could be done using custom authentication forms that simply return the form again when ... |
Look in the enclosing directories. They need to be at least mode 711. (`drwx--x--x`) |
Look in the enclosing directories. They need to be at least mode 711. (`drwx--x--x`)
Also, look in `/var/log/apache2/error_log` (Or whatever the concatenation of `ServerRoot` and `ErrorLog` is from the `httpd.conf`) for a possibly more-detailed error message.
Finally, ensure you restart apache after messing with ... |
> To use the Flickr API you need to have an application key. **We use this to track API usage.**
> Currently, commercial use of the API is allowed only with prior permission. Requests for API keys intended for commercial use are reviewed by staff. If your project is personal, artistic, free or otherwise non-commerci... |
Detect browser connection closed in PHP |
|php|apache|http|mod-php| |
Does anyone know if it is possible to detect whether the browser has closed the connection during the execution of a long PHP script, when using apache and mod_php?
For example, in Java, the HttpOutputStream will throw an exception if one attempts to write to it after the browser has closed it -- Or will respond neg... |
Or like
string hexNum = "0xFFFF";
string hexNumWithoutPrefix = hexNum.Substring(2);
uint i;
bool success = uint.TryParse(hexNumWithoutPrefix, System.Globalization.NumberStyles.HexNumber, null, out i); |
Try
Convert.ToUInt64(hex, 16) |
Try
Convert.ToUInt32(hex, 16) //Using ToUInt32 not ToUInt64, as per OP comment |
Generating account numbers sequentially is a security risk - you should find some other algorithm to do it. |
Best AutoHotKey macros? |
|automation|macros| |
I use AutoHotKey for Windows macros. Most commonly I use it to define hotkeys that start/focus particular apps, and one to send an instant email message into my ToDo list. I also have an emergency one that kills all of my big memory-hogging apps (Outlook, Firefox, etc).
So, does anyone have any good AHK macros to ... |
You might want to look into Typemock Isolator, which can "fake" method calls without forcing you to refactor your code.
I am a dev in that company, but the solution is viable if you would want to choose not to change your design (or forced not to change it for testability)
it's at www.Typemock.com
Roy
blog: ISeri... |
This is pretty easy to do.
Lets assume your queries are named a and b
**a
minus
b**
should give you an empty set. If it does not. then the queries return different sets.
then do
**b
minus
a**
that should give you an empty set. If it does, then the queries do return the same sets.
if it is no... |
Get position data from mobile browser |
|mobile|gps| |
I am developing a web app that will be hit frequently by mobile browsers. I am wondering if there is a way to get any position data (GPS, triangulation) from the browser request. A colleague suggested there some carriers supply a unique identifier in the request header that can be sent to a web service exposed by said ... |
I am developing a web app that will be hit frequently by mobile browsers. I am wondering if there is a way to get any position data (GPS, triangulation) from the browser request. **Not from the request directly, of course.** A colleague suggested there some carriers supply a unique identifier in the request header that... |
I haven't personally implemented this, but I have heard good things about it, and it appears to be a great script:
<http://johndyer.name/post/2007/09/PhotoShop-like-JavaScript-Color-Picker.aspx> |
I think it tried to cover way too many use cases thus becoming a Turing-complete (or so I heard) language. If you try to do any nontrivial transformation, you end up writing complex loops, conditions... in an ugly and verbose language, which is best done with a GPL.
In my view, this complexity makes writing a correc... |
To create a new array of a generic type (which is only known at runtime), you have to create an array of Objects and simply cast it to the generic type and then use it as such. This is a limitation of the generics implementation of Java (erasure).
T[] newArray = (T[]) new Object[X]; // where X is the number of e... |
WPF is a very fresh approach to designing UI. The only problem is that it introduces a large amount of concept, some of those only to hide the verboseness of xaml (xml). It also suffers a little from an architecture astronaut approach to the design but overall I'm pretty happy with it. It makes things that you before w... |
You don't say if your build is run as the currently logged on user. If not, the fact that explorer.exe or other process has the directory shown can cause it to be locked as well. But deleting it in that same explorer.exe process would succeed. Try Unlocker from [http://ccollomb.free.fr/unlocker/][1] to see what process... |
Read and inwardly digest [Transcending CSS][1] by Andy Clarke, Molly E. Holzschlag, Aaron Gustafson, and Mark Boulton.
It gives a set of techniques for dealing with those quirks you can deal with, and advice on making web sites accessible to older or less capable browsers, or those using other technologies, such as ... |
On Windows, Interlocked***Exchange***Add is guaranteed to be atomic. |
Wasn't this supposed to remove namespaces?
XmlNamespaceManager mgr = new XmlNamespaceManager("xmlnametable");
mgr.RemoveNamespace("prefix", "uri");
But anyway on a tangent here, the XElement, XDocument and [XNameSpace][1] classes from System.Xml.Linq namespace (.Net 3.0) are a better lot than the old Xml... |
XSLT is very powerful, but requires a different way of thinking about the problem. It also made life hard for itself by not providing useful data functionality in the early versions. Take for example a ToUpper() style method, you typically implement it with something like:
<xsl:variable name="lcletters">abcdef... |
We had a company come up with a Silverlight upload that could resize the pictures before hand so that the 5MB files didn't have to be uploaded and then resized. The image resizing capability wasn't included with the clr that comes with Silverlight. Occipital came up with their own. You can see it here:
[http://www... |
We also use [Trac][1], but it does not scale very well. Handling Use Cases and Test Cases may also get cumbersome. It really depends on the scope of the project and the size of the development team. I think for teams with less than 10 people Trac does an excellent job, but after that you are hitting the glass ceiling. ... |
If the input is HTML, use the loadHTML method. Be ware that the input has to be valid code, so you might want to pipe it through [html tidy](http://docs.php.net/manual/en/book.tidy.php) first. |
try {
InetAddress addr = InetAddress.getLocalHost();
// Get IP Address
byte[] ipAddr = addr.getAddress();
// Get hostname
String hostname = addr.getHostName();
} catch (UnknownHostException e) {
} |
I know you asked for Windows but thought I'd add this anyway,in Unix/Linux you could do:
cp `ls -t1 | head -1` /somedir/
Which will list all files in the current directory sorted by modification time and then cp the most recent to /somedir/ |
I think this might be what you're looking for, in the Java API for the InetAddress class: http://java.sun.com/javase/6/docs/api/java/net/InetAddress.html
getLocalHost() |
Dependency Injection and Circular reference |
|c#|oop| |
I am just starting out with DI & unit testing and have hit a snag which I am sure is a no brainer for those more experienced devs :
I have a class called MessageManager which receives data and saves it to a db. Within the same assembly (project in Visual Studio) I have created a repository interface with all the met... |
First realize that you're re-inventing the wheel here. There are a number of decent object-relational mapping libraries for database access in just about every language. For C/C++ you might look at:
<http://trac.butterfat.net/public/StactiveRecord><br/>
<http://debea.net/trac>
Ok, with that out of the way, you... |
Check out the latest development version of <a href="http://search.cpan.org/~ferreira/Pod-Perldoc-3.14_07/">Pod::Perldoc</a>. I submitted a patch which lets you do this:
$ perldoc -v '%ENV'
%ENV
$ENV{expr}
The hash %ENV contains your current environment. Setting a value in
"ENV" changes th... |
I believe that this is controlled by the parameter PLSQL_WARNINGS, documented for 10gR2 here: http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/initparams166.htm#REFRN10249 |
[RubyMail][1] is an email handling library for Ruby.
[1]: http://www.rfc20.org/rubymail/ "RubyMail" |
Unfortunately, it sounds like you've got a lot of existing code to tinker with. In that case, I'd just go with (2), assuming it doesn't get too large and unwieldy.
From your description, it sounds like data at the EXE level only needs to be sent once on DLL load.
If (2) is too messy, I'd refactor it a little to ... |
How do I speed up data retrieval from .NET AD within ColdFusion |
|.net|coldfusion|directory|ldap|active| |
How can I optimize the following code, which currently takes over 2 minutes to retrieve and loop through 800+ records from a pool of over 100K records, returning 6 fields per record (adds approximately 20 seconds per additional field):
<cfset dllPath="C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Directory... |
You have confused two different things - identification and authentication. Just because you know who somebody is, it doesn't mean you have to automatically give them permission to do anything. Simon Willison covers this nicely in <a href="http://simonwillison.net/2007/Jan/10/account/">An OpenID is not an account!</a... |
If you're running this script as you, check the %TEMP% environment variable to see if if it differs.
If IIS is executing, check the values in registry for TMP and TEMP under
HKEY_USERS/.DEFAULT/Environment |
Here's a slideshow: [Idiomatic Ruby][1].
Excerpt:
'until' works like 'while not'
x = x * 2 until x > 100
[1]: http://cbcg.net/talks/rubyidioms/
|
If you are using TortoiseSVN right-click on file, select **TortoiseSVN/Add to ignore list**. This will add the file/wildcard to the *svn:ignore* property.
Svn:ignore will be checked when you are checking in files and matching files will be ignored. I have the following ignore list for a Visual Studio .NET project:
... |
I don't mind the unmanaged calls - it's the hack of using a black box to mimic the alpha behaviour and the effect it then has on black element in some components on top that's the problem. |
In **C#** [switch][1] statement [doest not allow fall-through][2]. So [goto][3] is used to transfer control to a specific switch-case label or the [default][4] label.
For example:
switch(value)
{
case 0:
Console.Writeln("In case 0");
goto case 1;
case 1:
Console.W... |
In **C#** [switch][1] statement [doest not allow fall-through][2]. So [goto][3] is used to transfer control to a specific switch-case label or the [default][4] label.
For example:
switch(value)
{
case 0:
Console.Writeln("In case 0");
goto case 1;
case 1:
Console.W... |
Since the question didn't specify .NET, this should work in VBScript or VB6.
Dim objFSO, strFolder
strFolder = "C:\Temp"
Set objFSO = CreateObject("Scripting.FileSystemObject")
If Not objFSO.FolderExists(strFolder) Then
objFSO.CreateFolder(strFolder)
End If |
How do I split a string into a list Python? |
|python|string|list|split|equation| |
Learning to program, trying to do this
I have a string like this
> 2+24*48/32
and I want to split it into a list like this
> ['2', '+', '24', '*', '48', '/', '32']
I have messed around with .split() but that's messy as it returns a list, which means I would now have to iterate over two strings, etc |
Yes, if you're into internal documentation. Or maybe writing a libary that others will use, so that they can tell what happens without consulting the documentation. Throwing or not throwing can be considered part of the API, almost like the return value.
I agree, they are not really useful for enforcing correctnes... |
Here's the raw [reference of PDF 1.7][1], and here's an article [describing the structure of a PDF][2] file. If you use Vim, the [pdftk plugin][3] is a good way to explore the document in an ever-so-slightly less raw form, and the [pdftk][4] utility itself (and its GPL source) is a great way to tease documents apart.
... |
How do you include a JavaScript file from within a SharePoint WebPart? |
|sharepoint|web-parts| |
We have a medium sized .js file that we include in our web framework that I am porting over to SharePoint. However, I'm not sure how to go about this or what the best practice is. This is for a framework solution that will be used by other client projects, so it's best for it to be self contained and deploy-able, rathe... |
http://taggerplugin.sourceforge.net/ |
What are you really going to do with the list? Are you planning to block browsers you don't support? What if the user hacks the User-Agent response?
Like others, I would strongly suggest going with something like Yahoo's "Graded Browsers" and, if possible, leveraging YUI or other libraries so you don't have to do ... |
How do you do performance testing in Ruby webapps? |