instruction
stringlengths
0
30k
Simply multiply the RGB values by the amount you want to modify the level by. If one of the colors is already at the max value, then you can't make it any brighter (using HSV math anyway.) This gives the exact same result with a lot less math as switching to HSV and then modifying V. This gives the same result as ...
I work on support staff for a large uni that uses Blackboard. All the support people are students working part time, so salary can be pretty low per hour. You'll want to have someone on permanent staff as an administrator, who could also be the developer/deployment guy. Perhaps only part time if your institution is sma...
Using an ASP.NET SiteMap for a Page with multiple paths
|asp.net|vb.net|.net-2.0|
I have a certain page (we'll call it MyPage) that can be accessed from three different pages. In the Web.sitemap file, I tried to stuff the XML for this page under the three separate nodes like this: < Page 1 ><br> &nbsp;&nbsp;< MyPage / ><br> &nbsp;&nbsp;...<br> < /Page 1 ><br><br> < Page 2 ><br> &nbsp;&...
I prefer to use [Microsoft Visual C++][1] express on windows. Though the 2008 ide is fine, the 2005 express has better support for many of the open projects which you might want to participate in. It's a pain to compile Firefox or a half life 2 mod on 2008. Also as a general tip when looking for software, I like to ...
The C++ 0x spec defines lambdas without garbage collection. In short, the spec allows non-deterministic behavior in cases where the lambda closure contains references which are no longer valid. For example (pseudo-syntax): (int)=>int create_lambda(int a) { return { (int x) => x + a } } ...
Using Merb for Facebook Application
|ruby-on-rails|facebook|merb|
Since Rails is not multithreaded (yet), it seems like a threaded web framework would be a better choice for a Facebook application. (reason being is cuz each Rails process can only handle one request at a time, and facebook actions tend to be slow, because there is a lot of network communication between your app and f...
JRockit resolved this for me as well; however, I noticed that servlet restart times were much worse, so while it was better in production, it was kind of a drag in developemnt.
I just constructed a command that helped me find my lost stash commit: for ref in `find .git/objects | sed -e 's#.git/objects/##' | grep / | tr -d /`; do if [ `git cat-file -t $ref` = "commit" ]; then git show --summary $ref; fi; done | less This lists all the objects in the .git/objects tree, locates the one...
It's "unspecified behavior", but in practice with the way the C call stack is specified it almost always guarantees that you will see it as 0, 0 and never 1, 0. As someone noted, the assembler output by VC pushes the right most parameter on the stack first. This is how C function calls are implemented in assembler. ...
That depends. If you get the stack trace, it is clear what class threw the exception. This usually leads to making sure your environment will give you stack traces when there are unhanded exceptions.
If you've got jQuery handy, attach a click() event that disables the button after the initial submission - $('input[type="submit"]').click(function(e){ event.preventDefault(); this.click(null); }); that sort of thing.
Have you seen the PEAR package XML_Serializer? http://pear.php.net/package/XML_Serializer
Scheme was used by NASA to program some of the Mars rovers. It's usage in the marketplace is pretty specific, but like I'm sure your teachers are telling you, the things you learn in Scheme will carry over to programming in general.
I don't know about the older .mus files, but the newer .eft files are partially described here: [http://www.lilypond.org/web/devel/misc/etfformat][1]. [1]: http://www.lilypond.org/web/devel/misc/etfformat
How about having the first option starting with the letter you pressed be in the *middle* of the ones that are seen? To extend your example, if you press "N" in the State dropdown, the choices you see might be: * Missouri * Montana * Nebraska <-- First "N" choice * Nevada * New Hampshire Now you can ...
I just trialled adding another selenium function, `windowFocus()`: // force new window to open at this point - so we can select it later selenium().getEval("this.browserbot.getCurrentWindow().open('', 'enquiryPopup')"); selenium().click("//input[@value='Submit']"); selenium().windowFocus("enquiryP...
Microsoft was already aware of this issue, its KB is located [here][1]. You can solve the problem by installing Cumulative Update 1 (build 3161), which can be requested for download through the following Microsoft [page][2] If you can wait a little while more I think the fix will come out with SQL Server 2005 SP3...
I would have the following models Tshirt TshirtBox has_many TshirtItems TshirtBoxItems (This is basically a join table with an id tshirt_box_id and tshirt_id) belongs_to TshirtBox TshirtBoxItems is a way to link a Tshirt with a box and potentially other things in the future.
Web application to user instant messaging
|messaging|
What options are available for receiving instant alerts from web applications? I have a time sensitive web application I need to tend to (approving expediated purchase order requests). I have thought of being notified by e-mail and SMS. Are there any programs to let my website send a popup window directly to my...
It seemed that this was Microsoft's way to evolve the event model over time. It also seems that they are also allowing another way to do it with the "new" Action delegate and it's variations.
If 3rd-party extensions are allowed, then [C5][1] and [Microsoft CCR][2] (see [this blog post][3] for a quick introduction) are a must-know. C5 complements .Net's somewhat lacking collections library (not Set???), and CCR makes concurrent programming easier (I hear it's due to be merged with Parallel Extensions). ...
In C++, why use static_cast<int>(x) instead of int(x)?
|c++|casting|
I've heard that, in C++, the static_cast function should be preferred to C-style or simple function-style casting. Is this true? Why?
|c++|casting|duplicate|
In C++, why use static_cast<int>(x) instead of (int)x?
|c++|casting|
Unfortunately, no. If the crash is due to missing imports from the .bpl files required by your application, there is no way (short of rewriting the Delphi RTL and linker themselves) to check for those packages from within the crashing executable itself. PatrickvL's solution is probably the best for your situation. N...
To answer the asked question: at the finest-grained level, the pointer to the member function will perform better. To address the unasked question: what does "better" mean here? In most cases I would expect the difference to be negligible. Depending on what the class it doing, however, the difference may be signif...
I like this piece of the `bind` source: template<class R, class F, class L> class bind_t { public: typedef bind_t this_type; bind_t(F f, L const & l): f_(f), l_(l) {} #define BOOST_BIND_RETURN return #include <boost/bind/bind_template.hpp> #undef BOOST...
I like this piece of the `bind` source: template<class R, class F, class L> class bind_t { public: typedef bind_t this_type; bind_t(F f, L const & l): f_(f), l_(l) {} #define BOOST_BIND_RETURN return #include <boost/bind/bind_template.hpp> #undef BOOST...
Named formatting, % -formatting takes a hash (also applies %i/%s etc. validation). >>> print "The %(foo)s is %(bar)i." % {'foo': 'answer', 'bar':42} The answer is 42. >>> foo, bar = 'question', 123 >>> print "The %(foo)s is %(bar)i." % locals() The question is 123. And since lo...
You can also take a look at [aggiorno express for IE8 Compat][1], it is a free tool that automates the tagging of your site with the meta tag Jon points to, it will also remove the flag once u have got ur pages to render correctly under the standards mode. The tool supports both a GUI and command line so it is easy ...
Another tiny feature - convert an FixNum into any base up to 36: >> 1234567890.to_s(2) => "1001001100101100000001011010010" >> 1234567890.to_s(8) => "11145401322" >> 1234567890.to_s(16) => "499602d2" >> 1234567890.to_s(24) => "6b1230i" >> 1234567890.to_s(36) =...
Another tiny feature - convert a `Fixnum` into any base up to 36: >> 1234567890.to_s(2) => "1001001100101100000001011010010" >> 1234567890.to_s(8) => "11145401322" >> 1234567890.to_s(16) => "499602d2" >> 1234567890.to_s(24) => "6b1230i" >> 1234567890.to_s(36) ...
You can use both MinGW and VC++ Express (free, no need to buy it). See: 2. http://eli.thegreenplace.net/2008/06/28/compiling-python-extensions-with-distutils-and-mingw/ 3. http://eli.thegreenplace.net/2008/06/27/creating-python-extension-modules-in-c/
###Global variables Every variable in Javascript is a named attribute of an object. For example:- var x = 1; x is added to the global object. The global object is provided by the script context and may already have a set of attributes. For example in a browser the global object is window. An equivalent...
Dynamic typed variables just have type **Universal**, such that every other type is a subtype of **Universal**. Any language where all types inherit from such a universal type (such as Java modulo unboxed values) already have this capability. As for usefulness - depends on what you're doing. I prefer a fully static ...
It's quite easy to generate English sounding words using a Markov chain. Going backwards is mroe of a challenge, however. What's the acceptible margin of error for the results? You could always have a list of common letter pairs, triples, etc, and grade them based on that.
It's quite easy to generate English sounding words using a Markov chain. Going backwards is more of a challenge, however. What's the acceptable margin of error for the results? You could always have a list of common letter pairs, triples, etc, and grade them based on that.
Yes, it would be beneficial, but not for the example you are showing. I think something like this would be better public void f(var o) { o.method(); } and I could call f with any object with a method called method() without needing to introduce an interface. It's nice for places where ther...
[SimpleXML][1] works great for your use. [1]: http://php.net/simplexml
You can `#define` constants on the compiler command line using the `-D` or `/D` option. This is often useful when cross-compiling the same software for multiple platforms because you can have your makefiles control what constants are defined for each platform.
A quick Google search popped up a page with C++ code for testing the intersection. Basically it tests the intersection between the line, and every border or the rectangle. <a href="http://nuttybar.drama.uga.edu/pipermail/dir3d-l/2003-October/004323.html">Rectangle and line intersection code</a>
Easiest way to use them in my opinion without getting into a mess is to write down little CRC cards in your file headers like this: /////////////////////// //* CRC CARD //* Class: UISliderEvent //* Responsability: Event that holds the value and id of a Slider's movement //* Collaborators: ...
this might be useful, but i think it clutters the code - presumably when the code is working you would want to remove the 'trace' keywords; perhaps some form of metadata would be more appropriate then there's always print statements...
In my experience, iframes are either hacks or time-savers - make sure that if you're using them they're neccesary for those reasons. If you have control over the content (or can gain control through mirroring or scraping) you should consider using AJAX or server-side includes to pull external data onto and push it off ...
Unfortunately, `BOOLEAN` semantics are highly database-specific. I'm *guessing* that the Oracle driver is going to translate boolean values to a `VARCHAR` field into "`true`" and "`false`", rather than `0` and `1`, but you should verify this yourself.
cvs co MyWebApp/Trunk/www In general, you have to get the MyWebApp/Trunk directories, but they will be empty except for www. You can also set up modules in the repository, which will let you check out just www as if it were a top-level directory, but you have to do it for every such directory.
[Oops, deleted some wrong crap.] yeah, co -d www is what you want. You can also set up modules in the repository, which will let you check out just www as if it were a top-level directory, but you have to do it for every such directory.
`git fsck --unreachable | grep commit` should show the sha1, although the list it returns might be quite large. `git show <sha1>` will show if it is the commit you want.
`git fsck --unreachable | grep commit` should show the sha1, although the list it returns might be quite large. `git show <sha1>` will show if it is the commit you want. `git cherry-pick -m 1 <sha1>` will merge the commit onto the current branch.
Assuming that you have separate validation and persist (i.e. save to database) code, I would do the following: 1. The UI should perform validation. Don't throw exceptions here. You can alert the user to errors and prevent the record from being saved. 2. Your database save code should throw invalid argument except...
<a href="http://blog.abakas.com">Abakas</a>. It's written by my boss, but I'd recommend it even if that weren't the case.
O(n), and simple. Thanks to Matthew for the suggestion. y = {} for item in x: y[x] = "" y.keys()
O(n), and simple, fixed. Thanks to Matthew for the suggestion. def unique(x): output = [] y = {} for item in x: y[item] = "" for item in x: if item in y: output.append(item) return output
O(n) if dict is hash, O(nlogn) if dict is tree, and simple, fixed. Thanks to Matthew for the suggestion. Sorry I don't know the underlying types. def unique(x): output = [] y = {} for item in x: y[item] = "" for item in x: if item in y: output.appe...
Reference app relative virtual paths in .css file
|asp.net|css|dynamic-css|
Setuptools and distutils don't come with gcc, but they use the same compiler Python was built with. The difference is mostly that on the typical UNIX system that compiler is 'gcc' and you have it installed. In order to compile extension modules on Windows, you need a compiler for Windows. MSVS will do, even the Expr...
* Ensure the DB is setup on your production server * Set up capistrano to deploy your app properly * Run a capistrano dry-run * Ensure Rails is packed into your vendor/rails folder * Ensure all gems are frozen in your app or installed on your prod server * Run your tests on the production machine
Building Python C extension modules for Windows
|python|windows|
I have a C extension module and it would be nice to distribute built binaries. Setuptools makes it easy to build extensions modules on OS X and GNU/Linux, since they come with GCC, but I don't know how to do it in Windows. Would I need to buy a copy of Visual Studio, or does Visual Studio Express work? Can I just us...
|python|windows|
I have a C extension module and it would be nice to distribute built binaries. Setuptools makes it easy to build extensions modules on OS X and GNU/Linux, since those OSs come with GCC, but I don't know how to do it in Windows. Would I need to buy a copy of Visual Studio, or does Visual Studio Express work? Can I ju...
AMD 64 bit Dual Core Optimization
|amd|64-bit|graphics|opengl|cpu|
We have a graphics intensive application that seems to be experiencing problems on AMD 64 bit Dual Core platforms that are not apparent on Intel platforms. Running the application causes the CPU to run at 100%, in particular when using code for shadows and lighting (Open GL). Does anyone know of specific issues w...
|graphics|opengl|64-bit|cpu|amd|
We have a graphics intensive application that seems to be experiencing problems on AMD 64 bit Dual Core platforms that are not apparent on Intel platforms. Running the application causes the CPU to run at 100%, in particular when using code for shadows and lighting (Open GL). Does anyone know of specific issues w...
Using PostSharp to intercept calls to Silverlight objects?
|c#|postsharp|
I'm working with PostSharp to intercept method calls to objects I don't own, but my aspect code doesn't appear to be getting called. The documentation seems pretty lax in the Silverlight area, so I'd appreciate any help you guys can offer :) I have an attribute that looks like: public class LogAttribute : OnMeth...
VB.NET 2005 problems with Designer not being able to process a code line.
|vb.net|crystal-reports|2005|designer|
I have a problem in my project with the .designer which as everyone know is autogenerated and I ahvent changed at all. One day I was working fine, I did a back up and next day boom! the project suddenly stops working and sends a message that the designer cant procees a code line... and due to this I get more errores (2...
|vb.net|crystal-reports|visual-studio-2005|designer|
Using flash will give the highest productivity for the graphical artist (well - if he knows flash). You may want to have a look at gameswf. It's a bit dated but seems like a perfect match for your problem. http://tulrich.com/geekstuff/gameswf.html Another option would be to just do the entire UI in your 3D co...
The below seems to work. The enter event handles the tabbing to the control and the MouseDown works when the control is clicked. private void textBox1_Enter(object sender, EventArgs e) { textBox1.SelectAll(); } private void textBox1_MouseDown(object sender, MouseEve...
The 404 page really is your only option if you can't map the requests. I've seen several blog packages that do this to enable magic URLs like .../archive/YYYY/MM/DD and such - there's no such page, so it hits the 404 page and the 404 page does the redirection.
If you are going to keep using a switch, which is perfectly fine, then you probably should put the logic in a helper method and call if from the constructor. Alternatively, this is a classic case of the [Strategy Pattern][1]. You could create an interface (or abstract class) named IFoo which has one method with Foo's...
The "++" bit of "test++" gets executed after the call to foo. So you pass in (0,0) to foo, not (1,0) Here is the assembler output from Visual Studio 2002: mov ecx, DWORD PTR _i$[ebp] push ecx mov edx, DWORD PTR tv66[ebp] push edx call _foo add esp, 8 mov eax, DWORD PTR _i$[ebp] add eax, 1 mov DWO...
The "++" bit of "test++" gets executed after the call to foo. So you pass in (0,0) to foo, not (1,0) Here is the assembler output from Visual Studio 2002: mov ecx, DWORD PTR _i$[ebp] push ecx mov edx, DWORD PTR tv66[ebp] push edx call _foo add esp, 8 mov eax, DWORD PTR _i$[ebp] add eax, 1 mov DWO...
Everything I said originally is WRONG! The point in time at which the side-affect is calculated **is** unspecified. Visual C++ will perform the increment after the call to foo() if test is a local variable, but if test is declared as static or global it will be incremented before the call to foo() and produce different...
Everything I said originally is WRONG! The point in time at which the side-affect is calculated **is** unspecified. Visual C++ will perform the increment after the call to foo() if test is a local variable, but if test is declared as static or global it will be incremented before the call to foo() and produce different...
Further to DanWoolston's answer, Microsoft Outlook 2003 was the first Outlook version to offer full Unicode support, so depending on your definition of 'Office' (seeing as there are so many different editions), your answer might be Microsoft Office 2003. URL: http://office.microsoft.com/en-us/ork2003/HA011402611033....
It basically means "maps to". Read it that way or as "is transformed into" or something like that. So, from the [F# in 20 minutes][1] tutorial, > List.map (fun x -> x % 2 = 0) [1 .. 10];; val it : bool list = [false; true; false; true; false; true; false; true; false; true] > The code (fun i -> i...
What's the right way to dynamically choose menu items for a context menu in WinForms?o
|.net|winforms|menu|
What's the right way to dynamically choose menu items for a context menu in WinForms?
I'm trying to make a context menu for a control that is "linked" to a main menu item. There are two fixed menu items that are always there and an arbitrary number of additional menu items that might need to be on the menu. I've tried solving the problem by keeping a class-level reference to the fixed menu items and...
I'm writing a Telnet client of sorts in C# and part of what I have to parse are ANSI/VT100 escape sequences, specifically, just those used for colour and formatting (detailed [here](http://www.termsys.demon.co.uk/vtansi.htm#colors)). One method I have is one to find all the codes and remove them, so I can render the...
I'm writing a Telnet client of sorts in C# and part of what I have to parse are ANSI/VT100 escape sequences, specifically, just those used for colour and formatting (detailed [here](http://www.termsys.demon.co.uk/vtansi.htm#colors)). One method I have is one to find all the codes and remove them, so I can render the...