|
Which is a better way to force GC on ThreadLocal instance?
Answer Snippets (Read the full thread at stackoverflow):
With exit!
The simple and ugly answer:
System.gc();
This does not guarantee garbage collection of a specific object, but it will... .
Well, in fact you can.
Some may posts tricks but all in all you simply can't .
Simple answer: you can't force the GC in java.
|
|
The () seems silly. is there a better way?
For example:
ExternalId.IfNotNullDo(()=>ExternalId=ExternalId.Trim());
Started by brendanjerwin on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
For a lambda....
Whether there ever will be one or not is a different matter .
I know that the C# team feels your pain, and have tried to find an alternative .
Lambda expressions are optimised (in terms of syntax) for the single parameter case .
No, there isn't.
|
|
Is there a better way to develop Java Swing applications?
SWIXML? JavaFX? Anything else that developers out here have liked and recommend?
Started by tellme on
, 6 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
better way" is through the use of a better Layout Manager:
MigLayout :
an extremely flexible and easy.
|
Ask your Facebook Friends
|
Is there a better way to profile code then:
$start1 = microtime(TRUE); for($i=0;$i<count($array);$i++) { //do something } $time1 = microtime(TRUE) - $start1;
Started by Unkwntech on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Http://www.xdebug.org/
http://www.zend.com/en/community....
Their profiler will time everything for you without any modification of your code .
Try this: http://www.xdebug.org/docs/profiler
Xdebug or Zend Debugger if you have some difficulty to install Xdebug .
|
|
Here's my code:
$quizId = ''; foreach ($module['QuizListing'] as $quizListing) { if ($quizListing['id']) { $quizId = $quizListing['id']; break; } }
Is there a better way of doing this?
Started by baker on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
If you want the first quiz listing then do this:
$listing = reset($module[... .
I assume from your question that one of both of these is not true .
What you're doing is reasonable assuming that:
multiple quiz listings appear; and not all of them have an ID .
|
|
Quick one, but thought I'd ask.
Is there a better way of getting the column values from a model's column than something like this?
Item.count(:all, :group => 'status').reject! { |i, e| i.blank? }.collect { |i,e| i}
Started by The Pied Pipes on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Status is blank? count is blank?
Item.find(:all, :select....
But then could you please specify more criteria you want? i.e .
Maybe not ..
Is it the same thing as the following code?
Item.count(:all, :group => "status", :conditions => "status != ''"}
. .
|
|
What is the better way of getting the IP address in PHP:
getenv('REMOTE_ADDR');
or,
$_SERVER['REMOTE_ADDR'];
please tell me the difference, if any, between the two.
Started by Sachindra on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
The common approach is to use....
Getenv() can be used to access any environment variables (PHP simply registers REMOTE_ADDR as an environment variable for the script), while with $_SERVER you obviously only access the contents of the $_SERVER superglobal .
|
|
Is there a better way to do this jQuery selection:
$("p.DynFieldWrapper :input:not(:text):not(textarea)").focus(HideDynamicFormError).click(HideDynamicFormError); $("p.DynFieldWrapper :text,p.DynFieldWrapper textarea").blur(HideDynamicFormError);
I am...
Started by Ronnie Overby on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
I'd be tempted to do this:
$("p.DynFieldWrapper :input").each(function() { if ($(this).is(":text") || $(this).is("textarea"))... .
The first one can be a little simpler:
$("p.DynFieldWrapper :input:not(:text,textarea)")
Other than that, you're doing fine .
|
|
This is related to my question asked here today on SO. Is there a better way to build a packet to send over serial rather than doing this:
unsigned char buff[255]; buff[0] = 0x02 buff[1] = 0x01 buff[2] = 0x03 WriteFile(.., buff,3, &dwBytesWrite,..);
Note...
Started by Changeling on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
There is a much better way, which is using structs to set.
:-)
Is there a better way to build a packet than concerns like this can help reuse.
This is left as an exercise for the reader.
|
|
On a PHP file, I receives more than 20 variables coming from the client(submitted via a web form) and I have to apply mysql_real_escape_string() more than 20 times, it is quite troublesome, is there a better way to do this job?
Started by Steven on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
They're a little bit wordy.
);
is there a better way to do this job?
Certainly: parameterised queries .
|