instruction stringlengths 0 30k ⌀ |
|---|
[Shadowbox][] is a nice script for inline "popups". It can work with any of the usual JS libraries if you use any (jQuery, Prototype, etc) or on its own, has a pretty comprehensive skinning system so you can adapt the looks without having to go into the source code itself.
It is also the only such script (there are... |
How to respond to an alternate URI in a RESTful web service |
|rest|http|language-agnostic| |
I'm building a RESTful web service which has multiple URIs for one of its resources, because there is more than one unique identifier. Should the server respond to a GET request for an alternate URI by returning the resource, or should I send an HTTP 3xx redirect to the canonical URI? Is *HTTP 303 (see also)* the most ... |
|language-agnostic|http|rest| |
I'm building a RESTful web service which has multiple URIs for one of its resources, because there is more than one unique identifier. Should the server respond to a GET request for an alternate URI by returning the resource, or should I send an HTTP 3xx redirect to the canonical URI? Is *HTTP 303 (see also)* the most ... |
|language-agnostic|https|rest| |
|language-agnostic|http|rest| |
How can I confirm a database is Oracle & what version it is using SQL? |
|sql|oracle-database| |
I'm building an installer for an application. The user gets to select a datasource they have configured and nominate what type of database it is. I want to confirm that the database type is indeed Oracle, and if possible, what version of Oracle they are running by sending a SQL statement to the datasource. |
Thanks, that was useful code (+1).
It's more than a little bit messy though, has some bugs (case sensitive checks that shouldn't be, for instance), has a load of UI functionality that I don't need and repeats a lot of code.
I've taken from it the actual discovery mechanism, re-wrote it and almost got it working (... |
jquery is a good choice, it leans towards the 'skinny and speedy' side, and allows for some fantastic DOM manipulation. |
Take a look at [OSflv][1].
[1]: http://www.osflv.com/ |
Since your rectangle is aligned, Liang-Barsky might be a good solution. It is faster than Cohen-Sutherland, if speed is significant here.
[Siggraph explanation][1]
[Another good description][2]
[And of course, Wikipedia][3]
[1]: http://www.siggraph.org/education/materials/HyperGraph/scanline/clipping/c... |
You could accept() the connection anyway then use getInetAddress() to ensure the address is an authorized one. If not, simply close() the socket straight away.
Or you could install your own security manager which will have its checkAccept() method called with the address and port of the remote site. Thet's much ha... |
What I'd love is a property of the exception which would be a string array of all the method signatures leading up to the throw... without having to parse it out of the Exception text. |
Use XMLSlurper to parse the HTML as an XML document and then use the find method with an appropriate closure to select the a tags and then use the list method on GPathResult to get a list of the tags. You should then be able to extract the text as children of the GPathResult. |
Use `NSFileManager`'s `fileExistsAtPath:isDirectory:` method. See Apple's docs [here][1].
[1]: http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/Reference/Reference.html#//apple_ref/occ/instm/NSFileManager/fileExistsAtPath:isDirectory: |
My company uses a variety of Sharepoint and a wiki. Sharepoint for specific documents like requirements, presentations, contracts, etc, while the wiki is used as a help guide a developer repository for tutorials on using internally developed libraries. |
At as deep of a level as possible, how are virtual functions implemented? |
|c++|polymorphism|virtual-functions| |
We all know what virtual functions are in C++, but how are they implemented at a deep level? |
We all know what virtual functions are in C++, but how are they implemented at a deep level?
Can the vtable be modified or even directly accessed at runtime?
Does the vtable exist for all objects, or only those that have at least one virtual function?
Do abstract classes simply have a NULL for the function po... |
We all know what virtual functions are in C++, but how are they implemented at a deep level?
Can the vtable be modified or even directly accessed at runtime?
Does the vtable exist for all classes, or only those that have at least one virtual function?
Do abstract classes simply have a NULL for the function po... |
How do I use owfs to read an iButton temperature logger? |
|python|ubuntu|1wire| |
I've installed [`owfs`][1] and am trying to read the data off a [iButton temperature logger][2].
`owfs` lets me mount the iButton as a fuse filesystem and I can see all the data. I'm having trouble figuring out what is the best way to access the data though. I can get individual readings by `cat`ting the files, e.... |
|python|ubuntu|1wire| |
I've installed [`owfs`][1] and am trying to read the data off a [iButton temperature logger][2].
`owfs` lets me mount the iButton as a fuse filesystem and I can see all the data. I'm having trouble figuring out what is the best way to access the data though. I can get individual readings by `cat`ting the files, e.... |
display:block garauntees that the elements will *not* appear on the same line. Floating for layout is abuse just like tables for layout is abuse (but for the time being, it's necessary abuse). The only way to garauntee that they all appear on the same line is to use a <table> tag. That, or display:inline, and use only ... |
display:block garauntees that the elements will *not* appear on the same line. Floating for layout is abuse just like tables for layout is abuse (but for the time being, it's necessary abuse). The only way to garauntee that they all appear on the same line is to use a table tag. That, or display:inline, and use only &a... |
In addition to ensuring you have the ScriptManager on your page you need to ensure that your web.config is appropriately configured.
When ASP.NET AJAX 1.0 was released (for .NET 2.0) there was a lot of custom web.config settings which added handlers, controls, etc.
You'll find the config info here: http://www.asp... |
Maybe:
((\s*,\s*)|(\s+and\s+))
I'm not a java programmer, so I'm not sure if java regex allows '?' |
Interestingly, a ComboBox with DropDownStyle=Simple has pretty much exactly the behaviour you are looking for, I think. |
Interestingly, a ComboBox with DropDownStyle=Simple has pretty much exactly the behaviour you are looking for, I think.
(If you reduce the height of the control to not show the list - and then by a couple of pixels more - there's no effective difference between the ComboBox and the TextBox.) |
Most encoders, by default (ffmpeg included) put the header atom of the mp4 (the "moov atom") at the end of the video, since they can't place the header until they're done encoding. However, in order for the file to start playback before its done downloading, the moov atom has to be moved to the front.
To do this, y... |
If you use Rails, the performance difference between Haml and erubis is negligible: templates get compiled and cached after the first hit, anyway. Combine this with fragment and page caching and you can rest assured that views are not the performance bottleneck of your application.
The question you should be asking ... |
FindBugs, PMD and Checkstyle are all excellent choices especially if you integrate them into your build process.
At my last company we also used [Fortify][1] to check for potential security problems. We were fortunate to have an enterprise license so I don't know the cost involved.
[1]: http://www.fortify.com |
I don't have a lot to contribute here, but since its gone unanswered, I figured I would throw my two cents in.
Personally, I disable it on dev boxes and when I'm dealing with unimportant things. When I am dealing with anything production, or that requires better security, I leave it on and/or spend the time tweaking... |
Properly scoped transactions in Stored Procs |
|sql-server|stored-procedures|transactions|scope| |
Suppose I have a stored procedure that manages its own transaction
CREATE PROCEDURE theProc
AS
BEGIN
BEGIN TRANSACTION
-- do some stuff
IF @ThereIsAProblem
ROLLBACK TRANSACTION
ELSE
COMMIT TRANSACTION
END
If I call this proc from an ... |
I don't know what's wrong, but I can tell you some things that aren't:
* It's not a scoping issue. If it were then none of the instances of `$in{test}` would work.
* It's not the archaic `&` calling syntax. (It's not "right" but it's harmless in this case.)
`ReadParse` is a nasty bit of code. It munges the symbo... |
You'll need the SQL Server Configuration Manager. Go to Sql Native Client Configuration, Select Client Protocols, Right Click on TCP/IP and set your default port there. |
You may also want to take a look at [OAuth][1], an emerging open protocol for token-based authorization specifically targeting http apis.
It is very similar to the approach taken by [flickr][2] and [remember the milk][3] "rest" apis (not necessarily good examples of restful apis, but good examples of the token-based... |
Ive been looking at this problem for a while.
And buried deep in the Google Performance Tools README
[http://code.google.com/p/google-perftools/source/browse/trunk/README][1]
talks about libunwind
[http://www.nongnu.org/libunwind/][2]
Would love to hear opinions of this library.
The problem with -rdyn... |
You could also treat it as almost-JSON. If the strings really are only letters, like in your example, then this will work:
JSON.parse(yourarray.gsub(/([a-z]+)/,'"\1"'))
If they could have arbitrary characters (other than [ ] , ), you'd need a little more:
JSON.parse("[[this, is],[a, nested],[array]]".g... |
How Does The Debugging Option -g Change the Binary Executable? |
|gcc|debugging|gdb| |
When writing C/C++ code, in order to debug the binary executable the debug option must be enabled on the compiler/linker. In the case of GCC, the option is -g. When the debug option is enabled, how does the affect the binary executable? What additional data is stored in the file that allows the debugger function as ... |
In sql server 2005, how do I change the "schema" of a table without loosing any data? |
|sql-server|database| |
I have a table that got into the "db_owner" schema, and I need it in the "dbo" schema.
Is there a script or command to run to switch it over? |
In a bash script, how do I sanitize user input? |
|bash|shell|user-input|sanitization| |
The difference between Rob Walker's example is called Return Value Optimisation (RVO) if you want to google for it.
Incidentally, if you want to enure your object gets returned in the most efficient manner, create the object on the heap (ie via new) using a shared_ptr and return a shared_ptr<object> instead. The poi... |
No, nothing wrong with iframes. Iframes are probably a better idea if you're going to start serving third party content.
The upcoming HTML5 spec also plans to build more security features into iframes for situations like this, so I would consider it good practice to use them now also. |
Depends what the widget does. Iframes have their place, but they do cause few layout headaches (not to mention making your js more complicated) so most people tend to avoid them unless absolutely necessary.. |
Seconding JSON. I [ported](http://www.olivepeak.com/code/) the [Stringtree JSON reader](http://stringtree.org/stringtree-json.html) to J2ME. It's a single class JSON reader that compiles into a 5KB class file, and directly maps the JSON structure into native CLDC types like Hashtable and Vector. Now I can use the same ... |
I don't think you can. How are you running the query?
I'd say if you need a query that has that many open variables, put it in a vba module or class, and call it, letting it build the string every time. |
To answer the question, "does the static mean only one copy of VAL is created, in case the header is included by more than one source file?"...
**NO**. VAL will always be defined separately in every file that includes the header.
The standards for C and C++ do cause a difference in this case.
> In C, file-s... |
In Addition to the fact that | is a bitwise-operator: || is a short-circuit operator - when one element is false, it will not check the others.
if(something || someotherthing)
if(something | someotherthing)
if something is FALSE, || will not evaluate someotherthing, while | will do. If the variables in... |
In Addition to the fact that | is a bitwise-operator: || is a short-circuit operator - when one element is false, it will not check the others.
if(something || someotherthing)
if(something | someotherthing)
if something is TRUE, || will not evaluate someotherthing, while | will do. If the variables in ... |
Well the obvious answer is that the audio is encoded differently in the second wmv file, so they are not completely identical. You could try forcing it to use a specific audio codec for the 'bad' wmv, and see if that works. Perhaps it's just having trouble picking the right codec? However it seems more likely that the ... |
The thing that always gets me with Java is the date time library. I've never used Joda, just briefly look at it, looks like its a pretty good implementation, and if I understand JSR-130 correctly its taking knowledge from Joda and eventually having it included in JavaSE.
Quite often for past projects I've wrapped t... |
You need a smoothed average, the easiest way is to take the current answer (th etime to draw the last frame) and combine it with the previous answer.
eg. time = time * 0.9 + last_frame * 0.1
By adjusting the 0.9 / 0.1 ratio you can change the 'time constant' - that is how quickly the number responds to changes. A... |
You need a smoothed average, the easiest way is to take the current answer (the time to draw the last frame) and combine it with the previous answer.
eg. time = time * 0.9 + last_frame * 0.1
By adjusting the 0.9 / 0.1 ratio you can change the 'time constant' - that is how quickly the number responds to changes. A... |
If you only want to update the text, simply set the changed SubItem's text directly rather than updating the entire ListViewItem (you've not said how you're doing your updates).
The override you show is equivalent to simply overriding OnPaintBackground, which would be a "more correct" managed way to do that task, an... |
Found another, though it sounds less than ideal:
[ActiveDeveloper][1] - doesn't appear to have active support (last update was in 2006). Mac only.
KDevelop sounds like it only supports Objective C syntax and only through its C support. I'm going to check it out anyway.
Textmate has a couple screencasts for ... |
We all know what virtual functions are in C++, but how are they implemented at a deep level?
Can the vtable be modified or even directly accessed at runtime?
Does the vtable exist for all classes, or only those that have at least one virtual function?
Do abstract classes simply have a NULL for the function po... |
If you are writing a standalone java application you would want to start your own rmiregistry but if you are writing a J2EE app that obviously runs inside a J2EE container then you want to "LocateRegistry" as there is already one running on the app server! |
Zip and Gzip are supported everywhere. If a container is all you need, than those are surely good options. |
Zip is supported everywhere. If a container is all you need, than those are surely good options. |
Use the [Cohen-Sutherland algorithm.][1]
[1]: http://www.cc.gatech.edu/grads/h/Hao-wei.Hsieh/Haowei.Hsieh/mm.html#sec2_3 |
Use the [Cohen-Sutherland algorithm][1].
It's used for clipping but can be slightly tweaked for this task. It divides 2D space up into a tic-tac-toe board with your rectangle as the "center square".
then it checks to see which of the nine regions each of your line's two points are in.
- If both points are lef... |
I would look into the MusicXml format, http://www.recordare.com/xml.html.
Finale should have the ability to export to MusicXml. (I think it is with a plug-in shipped with newer versions of Finale). From there, it should be relatively straightforward, because it is xml, after all. |
I agree with Thomas.
I feel the question you should always ask yourself when refactoring is "What do I gain by doing this vs doing something else with my time?" The answer can be many things, from increasing maintainability to better performance, but it will always come at the expense of something else.
Without ... |
How do I remove duplication in shoulda tests? |
|ruby-on-rails|unit-testing|shoulda| |
Here is what I have:
context "Create ingredient from string" do
context "1 cups butter" do
setup do
@ingredient = Ingredient.create(:ingredient_string => "1 cups butter")
end
should "return unit" do
assert_equal @in... |
are you on a *nix machine? this sort of thing is probably better left to the OS level, using something like [iptables][1]
[1]: http://en.wikipedia.org/wiki/Iptables |
are you on a *nix machine? this sort of thing is probably better left to the OS level, using something like [iptables][1]
[1]: http://en.wikipedia.org/wiki/Iptables
edit:
in response to the comment, yes (sort of). however, the idea is that iptables can work independently. you can set a certain threshold to... |
Using GhostScript from the command line, I've used the following in the past:
on Windows:
`gswin32c -dNOPAUSE -q -g300x300 -sDEVICE=tiffg4 -dBATCH -sOutputFile=output_file_name.tif input_file_name.pdf`
on *nix:
`gs -dNOPAUSE -q -g300x300 -sDEVICE=tiffg4 -dBATCH -sOutputFile=output_file_name.tif input_file_n... |
Another way to illustrate it is in the box model, padding is the inside "margin" of a box margin is the buffer around the box. |
If you are connecting through .Net:
Provider=IBMDA400;Data Source=as400.com;User Id=user;Password=password;Default Collection=yourLibrary;
***Default Collection*** is the parameter that sets the library where your programs should start executing.
And if you are connecting through ODBC from windows (like settin... |
A username will (presumably) need to be quoted on the phone when calling for support so it will be publicised unlike a password. Also, the username field won't be masked out in browsers like password fields are, so it will have much more exposure and get cached/logged in various places, so the 'benefit' of the added se... |
SELinux requires user attention and manual permission granting whenever (oh, well) you don't have a permission for something. Many people such find that it gets in the way and turn it off.
In recent version, SELinux is more user friendly, and there are even talks about removing the possibility to turn it off, or hid... |
I did, three or four years ago when defined policies had many pitfalls and creating policies was too hard and I had 'no time' to learn. This was on not critical machines, of course.
Nowadays with all the work done to ship distros with sensible policies, and the [tools][1] and [tutorials][2] that exist which help you... |
Some tips on smoothing things out.
1) As others have said - try and break down the tasks into smaller chunks. The more obvious way of doing this is to try and break down the technical tasks in greater detail. Where possible I'd encourage you to talk to the product owner and see if you can reduce scope or "thin" the... |
Use what should probably be your course textbook, Randall Hyde's "The Art of Assembly Language":
[http://webster.cs.ucr.edu/AoA/Linux/HTML/AdvancedArithmetica2.html#1007619][1]
[1]: http://webster.cs.ucr.edu/AoA/Linux/HTML/AdvancedArithmetica2.html#1007619 |
Oracle connection problem on Mac OSX: "Status : Failure -Test failed: Io exception: The Network Adapter could not establish the connection" |
|oracle-database|macos| |
I'm trying this with Oracle SQL Developer and am on an Intel MacBook Pro. But I believe this same error happens with other clients. I can ping server hosting the database fine so it appears not to be an actual network problem. |
I'm trying this with Oracle SQL Developer and am on an Intel MacBook Pro. But I believe this same error happens with other clients. I can ping the server hosting the database fine so it appears not to be an actual network problem. |
I'm trying this with Oracle SQL Developer and am on an Intel MacBook Pro. But I believe this same error happens with other clients. I can ping the server hosting the database fine so it appears not to be an actual network problem.
Also, I believe I'm filling in the connection info correctly. It's something like t... |
You need to write your own task. <a href="http://www.atalasoft.com/cs/blogs/jake/archive/2008/05/07/writing-custom-nant-tasks.aspx">This</a> is a nice reference. |
I'm not sure if I understand you correctly, but you may exploit SFINAE to detect function presence at compile-time. Example from my code (tests if class has member function size_t used_memory() const).
template<typename T>
struct HasUsedMemoryMethod
{
template<typename U, size_t (U::*)() const> struct SFI... |
How might I pass variables through to cached content in PHP? |
|php|caching|variables| |