Thursday, April 21, 2011

reflection java ? extends

Is there any difference between :

Class<?> and Class<? extends Object> ?

Thanks

From stackoverflow
  • It is effectively the same

  • Nope. They are equivalent.

  • the same, 'cos every class extends Object.

    it's analogous to saying

    class MyClass

    and

    class MyClass extends Object

    are the same thing.

jQuery slider problem reaching min and max values

I have a jQuery slider initialized and then dynamically set min max values depeding on the contents of a json-request. Steps av even 100, min a max are recalculated to even hundred, most of the case somewhere between 300 and 4800.

The slider values and settings are fine, but when I move the handle I can't get it all the way out to the ends, it stops a few steps from min/max values. Why is that?

I've tried all sorts of things, nothing works. I ended up adding 200 at the top value and subtracting 200 in the lower and to compensate, but that's is a hack and not a solution.

From stackoverflow

Comet JavaScript libraries that support multiple windows

Are there any free Comet JavaScript libraries that allow multiple windows/tabs to reuse the same connection? In other words, when you open a second window, it detects that you have another window open under the same domain. Rather than open a new connection, it starts listening to the other window's connection. That way it can stay within the browser's per-domain connection limit.

Lightstreamer seems to handle this well, but I'd prefer something open-source.

From stackoverflow
  • I think the closest thing you're going to find in the Open Source world is going to be the functionality build into Dojo.

    I'm sure in the future, you'll see more Open Source support for that kind of functionality...but for now you might have to hack something together.

  • You can't do that directly, because different browser windows/tabs don't know what connections are open in other browsers/tabs. The best you can do is either 1) wildcard a bunch of subdomains (the per-domain limit is per-subdomain too) or 2) use a cookie or some other form of persistent storage and fall back to short-polling, which is what the dojo framework does.

Chrome : make textareas which are not resizable

By default, Chrome makes my textareas resizable. I wish to control this and either make them only vertically resizable, or not at all.

How can I achieve this ?

From stackoverflow
  • Set max-width to make them only vertically resizable, or set max-height and max-width to stop all resizing.

    However, be aware that breaking user expectations about how their browser treats controls tends to create a lot of user frustration.

  • you can set the column and rows like

    <%= text_area :object, :attribute, :rows => '10', :cols => '100' %> 
    #=> <textarea cols="100" rows="10" id="object_attribute" name="object[attribute]">
    #      #{@object.attribute}
    #   </textarea>
    

    or specify the size like

    <%= text_area :object, :attribute, :size => "10x100" %> 
    #=> <textarea cols="10" rows="100" id="object_attribute" name="object[attribute]">
    #      #{@object.attribute}
    #   </textarea>
    
  • Rails generate standard textarea tag, but Safari/Chrome (Webkit) display all (not only Rails :) textareas as resizable.

    It's apperance may be disabled by CSS

    textarea {
        resize: none;
        }
    

    Or, if need only vertical resize:

    textarea {
         resize: vertical;
         }
    

Netbeans: PhpDoc formatting

How to automatically format PhpDoc comments in Netbeans?

I'd like to have comments aligned like this:

 * @author      Author Name <example@example.com>
 * @package     Doctrine
 * @subpackage  Table
 * @license     http://www.opensource.org/licenses/lgpl-license.php LGPL
 * @version     $Revision: 67999 $
 * @link        www.phpdoctrine.org
 * @since       1.0

When I type /**[Enter] in Netbeans, it automatically imports all parameters as @param from the method definition. But then, when the comment is already generated I add a new variable to the definition. What now? How to trigger comment reparse and add newly added parameter?

From stackoverflow
  • Not possible in current version. I just use TAB to align the docs.

Multiple UILabel or just one?

I have a text which looks like the following,


the url of the page is http://www.myurl.com, and the phone # is (999)999-9999, blah blah blah...

And I want to show it in a way such that the URL and the phone # are both in different color and bolded. Can I do it using just one UILabel control, or I need to parse them out and put them onto separate UILabel controls. (Note that the text itself could span multiple lines.) How can I do it?

From stackoverflow

iPhone SDK: set animated loading (gear) image to UIBarButtonItem

Is there any way to set an animated image like the Apple spinning gear to an UIBarButtonItem?

I have tried this line of code but the animated gif image wont play:

myButton.image = [UIImage imageNamed:@"spinningGear.gif"];

Solution found here: How to use a custom UIBarButtonItem to display a UIActivityIndicatorView

From stackoverflow
  • Try creating a UIActivityIndicatorView and assigning it to your button with -[UIBarButtonItem initWithCustomView:].

    Adam : That doesn't work. I don't know where you tried it - doesn't work in iOS 3, and doesn't seem to work in iOS 4 either
  • I don't think that's possible with UIBarButtonItem.

    You might want to use customView for that (the property or initWithCustomView) and use UIImageView as that view. That still won't animate gif's "out of the box" (just checked).

    If you do so you have two options:

    • use animatedImages from UIImageView class and use separate images for every frame (writing out of head - code might have some errors):

    NSMutableArray * imgs = [NSMutableArray array];
    for(int i = 0; i < NUMBER_OF_FRAMES; i++) {
        [imgs addObject: [UIImage imageNamed: [NSString stingWithFormat: @"anim%d.png", i]]];
    }
    UIImageView * imgview = [[UIImageView alloc] init];
    imgview.animatedImages = imgs;
    [imgview startAnimating];
    

  • I found that this line was incorrect:

    [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0, 0, 20, 20)];
    

    ...the actual size of the default Refresh button from Apple is a little different. If you have other items doing auto-layout on that toolbar, you need to get the size right.

    Unfortunately, Apple provides no API for finding out the size. By trial and error, it seems this is correct:

    [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0, 0, 28, 28)];