instruction stringlengths 0 30k ⌀ |
|---|
I've been doing some work with the JAX-RS reference implementation (Jersey).
I know of at least two other frameworks (Restlet & Apache CXF).
My question is: Has anyone did some comparison between those frameworks and if so, which framework do you recommend and why? |
|java|rest|jax-rs| |
|java|frameworks|rest|jax-rs|roa| |
Wich is the best wat yo paginate results in php |
|php|pagination|results| |
I need to display many pages of news in a site.<br>
Should i do the pagination in the db query using limit or do it in my php script after getting all the results? |
Wich is the best way to paginate results in php |
What is the best way to paginate results in php |
In addition, you should use [Valgrind][1] to test it all and get real useful reports about memory behavior of your program
[1]: http://valgrind.org |
Personally, I would use the query to do it. Obviously, that can change if your dealing with AJAX and such, but just doing a basic limit in the query and outputting the results is simple and efficient. |
Use limit in SQL! Every time!
Otherwise you're throwing around considerably more data than you need to, which makes your scripts unnecessarily slow, and will lead to scalability problems as the amount of data in your tables increases.
Limit is your friend! |
The specifics of the content of a log can be discussed, but it is my experience that the level of verbosity will quickly determined during **[stress test][1]**.
If the system can not function properly, it is because you just:
- get either too verbose with your logs, or
- did log too often (actually, I believe [J... |
You'll want to use the .SelectionFont property of the RichTextBox and assign it a Font object with the desired styles.
Example - this code would be in the event handler for the button:
Dim bfont As New Font(RichTextBoxFoo.Font, FontStyle.Bold)
RichTextBoxFoo.SelectionFont = bfont |
Two possible solutions:
1. Try to use a proxy model (a subclass of QAbstractProxyModel) which accesses row headers as columns in a single row. Not trivial because the proxy model displays as data what the original model considers to be header.
2. Display a second 2D view of your model, but hide everything exce... |
What does autoboxing/unboxing have to do with generics? This is just a type-safety issue. With a non-generic collection, you are required to explicitly cast back to an object's actual type. With generics, you can skip this step. I don't think there is a performance difference one way or the other. |
Myself, I am a firm believer in the following:
alert('Some message/variables'); |
I don't know of an add-on (I use [Remember The Milk][1] externally), but I think you are onto a good idea there.
[1]: http://www.rememberthemilk.com/ |
My old company actually considered this problem. The approach we took was: if it's easy to refactor, do it; if not (i.e. it will touch too many classes), leave it for a later time. It really depends on whether or not you have the time to do it, or whether there are more important items to be coding (i.e. features you s... |
Generics, whether Java or .NET, should be used for design and type safety, not for performance. Autoboxing is different from generics (essentially implicit object to primitive conversions), and as you mentioned, you should NOT use them in place of a primitive if there is to be a lot of arithmetic or other operations w... |
You need to use a UDF
first:
CREATE VIEW vRandNumber
AS
SELECT RAND() as RandNumber
second:
CREATE FUNCTION RandNumber()
RETURNS float
AS
BEGIN
RETURN (SELECT RandNumber FROM vRandNumber)
END
test:
SELECT dbo.RandNumber(), *
FROM <table>
Abo... |
see [here][1].
[1]: http://avinashv.net/2008/05/pythons-range-and-xrange/ |
The best-known library is <a href="http://effbot.org/zone/pil-index.htm">PIL</a>. However if you are simply doing basic manipulation, you are probably better off with the Python bindings for <a href="http://wiki.python.org/moin/ImageMagick">ImageMagick</a>, which will be a good deal more efficient than writing the tra... |
xrange returns an iterator and only keeps one number in memory at a time. range keeps the entire list of numbers in memory. |
select top 10 username, max(score) from usertable group by username order by max(score) desc |
How do you priortize multiple triggers of a table? |
|sql|t-sql|sql-server-2005|triggers| |
I have a couple of triggers on a table that I want to keep ***separate*** and would like to priortize them.
I could have just one trigger and do the logic there, but I was wondering if there was an easier/logical way of accomplishing this of having it in a pre-defined order. |
|java|sorting|list| |
Let's say that I have two arrays (in Java),
int[] numbers; and int[] colors;
Each ith element of numbers corresponds to its ith element in colors.
Ex, numbers = {4,2,1}
colors = {0x11, 0x24, 0x01}; Means that number 4 is color 0x11, number 2 is 0x24, etc.
I want to sort the numbers array, but then still... |
Let's say that I have two arrays (in Java),
int[] numbers; and int[] colors;
Each ith element of numbers corresponds to its ith element in colors.
Ex, numbers = {4,2,1}
colors = {0x11, 0x24, 0x01}; Means that number 4 is color 0x11, number 2 is 0x24, etc.
I want to sort the numbers array, but then still... |
You could use sort() with a custom comparator if you kept a third array with the index, and sorted on that, leaving the data intact.
|
I think if I can impart something useful, like "Hey this is an interface, don't count on specific behaviour" right there, as in IEnumerable, I oughtta do it. Comment can clutter things up much more than just a one or two character symbol. |
I've always thought that a prefix or two in the right place wouldn't hurt. I think if I can impart something useful, like "Hey this is an interface, don't count on specific behaviour" right there, as in IEnumerable, I oughtta do it. Comment can clutter things up much more than just a one or two character symbol. |
How about adding a new table to store this replicated value (and a primary key to link each record to the main table). Then you simply add a record for every replicated item, and delete records to remove the replicated flag. (Or maybe the other way around - a record for every non-replicated record, depending on which i... |
How to auto-focus RTE editor inside firefox? |
|javascript|firefox|iframe|focus|editmode| |
Instance constructor sets a static member, is it thread safe? |
|.net|thread-safety| |
I am refactoring some code and am wondering about the use of a 'lock' in the instance constructor.
private static Int32 counter = 0;
private Int32 myCount;
public MyClass()
{
lock(this)
{
counter++;
myCount = counter;
}
}
Please confirm
... |
|.net|multithreading|c#| |
|.net|thread-safety| |
I am refactoring some code and am wondering about the use of a 'lock' in the instance constructor.
public class MyClass
{
private static Int32 counter = 0;
private Int32 myCount;
public MyClass()
{
lock(this)
{
counter++;
... |
|.net|c#|multithreading| |
|c#|.net|multithreading| |
I am refactoring some code and am wondering about the use of a 'lock' in the instance constructor.
public class MyClass
{
private static Int32 counter = 0;
private Int32 myCount;
public MyClass()
{
lock(this)
{
counter++;
... |
@ajmastrean
I am not saying you should use the singleton pattern itself, but adopt its method of encapsulating the instantiation process.
i.e.
* Make the constructor private.
* Create a static instance method that returns the type.
* In the static instance method, use the lock keyword before instantiating.
... |
If you want only work with a DBMS that support this than do it on the DBMS. If you want support other DBMS in the future then ad a layer between that can handle depending on the current DBMS. |
An alternative to freespace's answer would be to generate a random maze, then assign each cell a value representing the number of moves to reach the end of the maze (you can do both at once if you decide that you're starting at the 'end'). Then pick a distance (perhaps the highest one with n points at that distance?) a... |
I know this is not a VS add-in but [SSMS one][1] anyway could be useful for anyone working with MSSQL.
Just for the case you wanna see more like this one check [this post][2]. Actually from ssmstoolspack creator.
[1]: http://www.ssmstoolspack.com/
[2]: http://weblogs.sqlteam.com/mladenp/archive/2007/11/20... |
If you happen to be using Java, the built-in method Integer.bitCount will do that. |
Programmatically updating FILEVERSION in a MFC app w/SVN revision number |
|fileversion|mfc|svn| |
How do I go about programmatically updating the FILEVERSION string in an MFC app? I have a build process that I use to generate a header file which contains the SVN rev for a given release. I'm using SvnRev from http://www.compuphase.com/svnrev.htm to update a header file which I use to set the caption bar of my MFC ap... |
|windows|svn|mfc|fileversion| |
The instructions you got mentioned SBCL explicitely, so it's expected that they'll work better using SBCL, I suppose. Some other Lisps don't come with ASDF or don't hook it up to CL:REQUIRE. In the former case, you'll have load ASDF yourself beforehand. In the latter case, you'll need to call (asdf:oos 'asdf:load-op <w... |
Even though I had been programming rofessionally for years, Rocky Lhotka's "Business Objects" series about his CSLA framework was the book that opened my eyes.
<br/><br/>
His ideas he got me excited about software development patterns and theory again. It set me on the path of a new interest in learning how to be a ... |
Console editors, such as [emacs][1] and [vi][2], are more lightweight than their GUI counterparts, and (at least those two are) just as capable as any other IDE (syntax highlighting, mouse support, ctags, autocompletion ... all the way to gdb integration). The learning curve might be somewhat steep, and you might have ... |
I would look into creating XML data islands which emulate the structure of the objects you will eventually bind the UI to. This way your designer can bind the root element of the page (or user control, etc.) to the top level of your fake XML data island and all the relative paths will stay the same when you swap that d... |
range creates a list, so if you do range(1, 10000000) it creates a list in memory with 10000000 elements.
xrange is a generator, so it evaluates lazily. |
What is the cost of a function call? |
|memory|optimization|architecture| |
Compared to
* Simple memory access
* Disk access
* Memory access on another computer(on the same network)
* Disk access on another computer(on the same network)
in C++ on windows.
|
|c++|optimization|architecture|memory| |
Consistency and practice. Four things that improved my typing dramatically:
1. Find a comfortable keyboard that
fits your hands very well. It's less
about ergonomics or split keyboards,
but more about finding one with perfect finger reach. And this means using the keyboard for a couple weeks to see i... |
range generates the entire list and returns it. xrange does not -- it generates the numbers in the list on demand. |
xrange uses an iterator (generates values on the fly), range returns a list. |
How to automate the test running process using TestComplete? |
|automated-tests|finalbuilder|testcomplete|dailybuilds|build-automation| |
We are trying to integrate tests in our daily builds using TestComplete, so far we have a machine dedicated for testing and our build script copies to this machine everything TestComplete needs for its tests (Application, Database, Test script project and source files, etc).
Basically we can open the TestComplete pr... |
We have a RTE editor based on htmlarea which consists of content with editmode enabled inside an iframe. The question is how to automatically bring the focus into the editor. |
How do I overlap widgets with the pack geometry manager in Python/Tkinter? |
|python|geometry|tkinter|manager| |
I want to put a canvas with an image in my window, but then I want to pack() widgets over top of it so the canvas acts as a background. Is it possible to have two states for the pack() manager, one for one set of widgets and another for another set?
|
I think the whole thing of **the aesthetical aspect is over-hyped**. If that was the most important thing, we would not call ourselves **developers**, but graphic **designers**.
One important part, I think, is that you decribe what your objects role is, not what it is. You don't call yourself HumanDustman, becuase i... |
Like Heath Borders said, SWT doesn't support L&Fs, so you have to use Swing for that. Aerith however does not base on a look and feel, but on custom painting on the components with a lot of gradients.
If you are looking for a Swing GUI Editor that is (nearly) as easy to use as VB, try the Matisse GUI Builder in [Net... |
Where the `id` of the `IFRAME` is `myRTE`:
var iframe = document.getElementById("myRTE");
if ( iframe && iframe.contentWindow )
iframe.contentWindow.focus();
|
Go here for a discussion of the mathematical basis to Shamir's secret sharing and brief discussion of the type of practical applications that it has. Scroll down the page to the lecture notes on Polynomials and Secret Sharing. It's probably a v. basic overview of the area, but should be quite interesting for you.
[Dis... |
There are several ways to do this. Here's one option, using the [IO::CaptureOutput](http://search.cpan.org/perldoc?IO::CaptureOutput) module:
use IO::CaptureOutput qw/capture/;
my ($stdout, $stderr);
my $exit = capture sub { system( @cmd ); return $? >> 8 }, \$stdout, \$stderr;
The exit value i... |
`I say GCC for simple things because for a more complicated project the build process isn't so easy`
True, but I don't think understanding the build process of a large project is orthogonal to understanding the project itself. My last job I worked at, they had a huge project that needed to build for the target plat... |
I can't address best practice in Objective-C, but in C++ it's fine for a constructor to throw an exception. Especially as there's no other way to ensure that an exceptional condition encountered at construction is reported without resorting to invoking an isOK() method.
The function try block feature was designed sp... |
Just programming in BASIC, the commands are right there on those rubbery keys. Now if only PC's could have key-legends with while, case, switch etc. on them :-) |
If you're using user controls for the edits, I think you could do it with <a href="http://www.orangoo.com/labs/GreyBox/">Greybox</a>. Pass the user control name (and other parameters) to the page you show in greybox, then dynamically load the user control that does the edit. |
The standard C/C++ specification for outputting to the command line doesn't specify any capabilities for changing the color of the console window. That said, there are many functions in Win32 for doing such a thing.
The easiest way to change the color of the Win32 console is through the system command in iostream.h.... |
You can do it technically, you branch is not dead nor disabled, but it is not recommended to merge from branch to trunk after reintegration.
You can find a full discussion about the reason for that, here: [Subversion merge reintegrate][1]
Basically, it says, that it is possible to merge your changes again to the ... |
It sounds to me as though you've done everything right.
I'm sure you are but have you made sure you are using 'DOMAIN\user' as the user account and not just 'user'?
|
Converting audio to code and vice-versa |
|audio| |
Having just witnessed [Sound Load technology][1] on the Nintendo DS game [Bangai-O Spritis][2]. I was curious as to how this technology works? Does anyone have any links, documentation or sample code on implementing such a feature, that would allow the state of an application to be saved and loaded via audio?
[1... |
[RAWK][1] I have used to get performance reports emailed to me at regular intervals. It works by analyzing the rails production logs and has always done well for me.
I recently learned about [Scout][2] from their article about [rails monitoring][3], but I haven't had a chance to try it out yet, looks promising!
... |
Replacing strings inside SWF |
|flash| |
We've got dozens of versions of an SWF modified for different customers of a big Flash project, and now would have to replace some strings embedded in scripts in each copy. The FLA file for some of these is very difficult to locate or even missing (I inherited this mess and refactoring it is currently not an option).
... |
If you're not too bothered about efficiency, you can simply write:
var lineCount = File.ReadAllLines(@"C:\file.txt").Length;
For a more efficient method you could do:
var lineCount = 0;
using (var reader = File.OpenText(@"C:\file.txt"))
{
while (reader.ReadLine() != null)
{
... |
Also consider the build-in functions of your compilers.
On the GNU compiler for example you can just use:
int __builtin_popcount (unsigned int x);
In the worst case the compiler will generate a call to a function. In the best case the compiler will emit a cpu instruction to do the same job faster.
The... |
Master one discipline then move to the next one.
I am also at the very infancy of learning business application development. The very step I took was to study database. Majority of the applications in the real world is data-centric. It is good to start with desktop application. Do some drag-and-drop then study the ... |
This is a really religious question - just choose the one you like. Every editor has it's pros/cons and you need to decide which set suits best to you. There are many IDEs out there that can use various editors like [Pida](http://pida.co.uk/). |
What you really need is a tool which takes the format strings in printf() statements and converts them into equivalent QString based function calls.
Does anyone want to spend his Free Software Donation Time on developing such a tool?
*Placeholder for URL to a Free Software hosting service holding the source code ... |
Short answer: no.
You could create an application which will run on both Windows and Linux.
But there are platform-specific features and right now Mono could not automatically 'translate' those for you. A Windows Service is a good example of that. |
We're working with EJB here and it works quite well with JBoss Seam and JSF, Faclets and MyFaces Trinidad. Good UI, Templating, AJAX and stable production 24/7 running on JBoss 4.2.
It's a good stack for business processes, workflows, messageing, webservices and ui control. Fast delivery of features, easy programmin... |
Is there a .NET OS abstraction layer to make OS calls work cross-platform? |