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)];
    

Mootools build form

So I am trying to make a custom in place editor in mootools and I want to use a form. Whenever I do try to create a form it just creates <form class="inplaceeditor-form" method="post" action="#"/> How can I make it a form where I can inject other elements?

From stackoverflow
  • You have to create the other input elements to go inside the form. Something like this:

       // create the form element
       var form = new Element('form', {'action' : 'your/action', 'class' : 'inplaceeditor-form'});
      //create the textbox
       var textarea = new Element('textarea', {'name' : 'myTextarea'});
        //create the submit button  
     var button = new Element('input', {'type' : 'submit', 'value' : 'Submit Me!'});
       // this puts the textarea and the button into the form
       form.adopt(textarea,button);
       // put the form inside what ever container you user
        $('myContainer').adopt(form);
    
       // the code above should give you this
       <div id="myContainer">
           <form action="your/action" method="post" class="inplaceeditor-form">
                <textarea name="myTextarea"></textarea>
                <input type="submit" value="Submit Me!" />
          </form>
    

Using USB port from c++

Hello,

i was just wondering if somebody could give me any pointers about how to use USB ports on Ubuntu(and other unix systems) &&/|| (and/or :]) windows. I was trying to googling some stuff up but i failed horribly. Even names of libraries to be used etc would be appriciated.

Thanks, Tomas Herman

From stackoverflow
  • You can use libusb for direct access to USB. http://www.libusb.org/

    If you instead wish to use a USB serial port or other device for which the OS already has drivers, look for other means. E.g. /dev/input/event* or /dev/ttyUSB* devices on Linux.

    Mike DeSimone : One thing to note: libusb 1.0 and later is only supported for some Unixen; Mac OS X and Windows are not supported. libusb 0.1 is cross-platform.
    Arg : thanks for the heads up
  • Two quick links for you:

    http://www.linux-usb.org/ - The Linux USB project

    http://www.libusb.org/ - "...the libusb project. It aims to create a library for use by user level applications to access USB devices regardless of OS."

ActionScript 3 Object to name value string

In a Flex application I am trying to turn an Object into a QueryString such as name1=value1&name2=value2... But I am having trouble getting the names of the Objects children. How do I enumerate the names instead of the values?

Thanks

From stackoverflow
  • I'm guessing you're doing a for each(in) loop. Just do a normal for(in) loop and you'll get the names instead of the values:

    for(var name:String in obj) {
      var value:* = obj[name];
      // do whatever you need
    }
    
    Sophistifunk : If it's a concrete class instead of just an Object, see ObjectUtil.getClassInfo()
    Herms : I believe `for(in)` still works on concrete classes, but it's generally more limited on what it returns. It will only pick up what those classes have set up as visible using the `setPropertyIsEnumerable` method.
  • Ok, first off, if you need that query string to actually query a server, you don't really need to get it yourself as this code will query the server for you

    protected function callSerivce():void
    {
        var o:Object = new Object();
        o.action = "loadBogusData";
        o.val1 = "dsadasd";
        service.send(o);
    }
    
    <mx:HTTPService id="service" url="http://www.somewhere.com/file.php" method="GET" showBusyCursor="true"/>
    

    Will make a call to the server like this: http://www.somewhere.com/file.php?action=loadBogusData&val1=dsadasd

    But in case you really want to analyze the object by hand, try using ObjectUtil.getClassInfo, it returns a lot of information including all the fields (read more on LiveDocs).

How to add to TOP of unordered list with jQuery

Hi All

I've created a Facebook/Twitter like status update and can add the new status to an element. I recently found a great article that explains "How to add items to an unordered list using jquery" but I'm not skilled enough to edit it to make it add to the TOP of my unordered list.

Any help would be greatly appreciated.

From stackoverflow
  • Use the prepend method instead of append.

    st4ck0v3rfl0w : lol, i'll try that, thanks!

Image from dataset in ASP gridview

I receive a certain image name in a boundfield (i have two images in the same folder) and it comes from testing in the codebehind and binding a datatable into this gridview.

example: it comes as "image1.jpg" or "image2.jpg"

I'd like this text not to be displayed, instead, i want these images that are in /folder1/folder2 of my solution (i access images like this, and it works)

either i transform it into html tag...

<img src='/folder1/folder2/image1.jpg' border='0'>

(that's the reason for the first question i've made)

...OR I create an asp image somehow inside the boundfield.

Is there any way to do so ?

From stackoverflow
  • I've used:

    <asp:Literal runat="server" Text="<%#Eval("myField")%>" />
    

    Inside a templatefield

What is gpstate file in ASP.NET

In my project I found a .gpState file in the folder, What is the purpose of gpState file?

From stackoverflow
  • I have never seen such a file in an ASP.NET app. Are you sure it is from ASP.NET?

    Edit: it seems this file comes form the Guidance Automation Toolkit (whatever that is).

    Sauron : I am using WCF service in my application

magento payment methods - enable for admin only

Hi there,

I need to enable the Cheque / Money Order payment method to enable our clients call centre team to create orders in the admin.

However we do not want customers buying online through the website to use this payment method.

Does anybody know how I might be able to do this?

Regards, Fiona

From stackoverflow
  • If you enable it in the global config-view and then disable it for your store/website view does that work? (Don't have a system handy to test...)

    Fiona : Thanks Greg for the suggestion, however unfortunately that didn't work. Just tried it.
  • Just found this, looks like it's what you're after: http://www.magentocommerce.com/boards/viewthread/38765/P15/

SSIS Query Parameters for ADO .NET Source

I am trying to retieve data from a MySQL table and insert into a SQL Server table using ADO .NET connections in SQL Server 2008 SSIS. In my data flow task I have an ADO .NET Source which queries the MySQL table (select all invoices) and an ADO .NET Destination which inserts the data in my SQL Server table. Now, I would like to add a parameter in my data source so that I only select the max(invoiceNumber) retrieved from my SQL Server table. I have performed a similar task using "OLE DB Command" but the problem is that I need to query a MySQL database. Any ideas how I can achieve this?

From stackoverflow
  • Set Data Access Mode in ADO.NET Source to SQL Command and write the query.

    Ali_Abadani : I already do that for my query. Where would I get the parameter from?
    Damir Sudarevic : Variable -- first query your local DB, put result into a variable and pass variable to the second query.
  • You shoudn't have to add a parameter:

    select * 
    from invoices
    where invoiceNumber = (select max(invoiceNumber) from invoices)
    

    The above works in SQL Server. I'm assuming that the same query will work in MySQL

    Ali_Abadani : I think you might have mis-understood me. the select max(invoiceNumber) has to be called against my local SQL Server table. Then, I can use that number to query the MySQL database which is external. So, eveyday the package would get the new invoices from the MySQL database and pushes them to the SQL Server.
  • Ali_Abadani, Did you get the solution for your problem, Even i am looking for the same. please let me know.

  • I have a MAX value in @MAXVal Variable. In Expression for ADO.NEt Source: SQLCommand , need to add value like below..? select *
    from invoices where invoiceNumber = @MaxVal.

    Please let me know.

Drupal 6: Working with Hidden Fields

I am working on an issue i'm having with hooking a field, setting the default value, and making it hidden. The problem is that it is taking the default value, but only submitting the first character of the value to the database.

//Here is how I'm doing it
$form['field_sr_account'] = array( '#type' => 'hidden', '#value' => '45');

I suppose there is something wrong with the way that I have structured my array, but I can't seem to get it. I found a post, http://drupal.org/node/59660 , where someone found a solution to only the first character being submitted

//Here is the format of the solution to the post - but it's not hidden
$form['field_sr_account'][0]['#default_value']['value'] = '45';

How can I add the hidden attribute to this?

From stackoverflow
  • Have you tried using #default_value insted of #value?

    Also if you're trying to pass some data to the submit that will not be changed in the form you should use http://api.drupal.org/api/drupal/developer--topics--forms_api_reference.html#value .

    cinqoTimo : I've used both. I believe #value is the correct parameter...
  • The answer was actually to set the value and the hidden attribute separately, then set the value again in the submit handler using the following format.

    I'm not sure if it's all necessary, I suppose I probably don't need to assign it in the form alter, but it works, so I'm going to leave it alone...

    $form['#field_sr_account'] = $club;
        $form['field_sr_account'] = array( '#type' => 'hidden','#value' => $club);
       }
    }
    
    /*in submit handler, restore the value in the proper format*/
    $form_state['values']['field_sr_account'] = array('0' => array('value' => $form['#field_sr_account']));
    

Sending data to screen

I tried to use a Python program to create input and output screen for a simple GAE app. Importing Tkinter did not work. So I am resorting to html and django but i dont have a solid foundation in these. I simply need to enter text and have something else display in a formatted screen based on the text. For example user enters name and code would display his address in a SEPARATE field (preferrably formatted in a box or something).

From stackoverflow
  • Have a look at, http://code.google.com/appengine/docs/python/overview.html

    They have got good examples for putting together an easy starting app.

  • There's an awesome screencast on Youtube: http://www.youtube.com/watch?v=bfgO-LXGpTM

  • AppEngine is very fundamentally built around the idea of web requests; that's really the only way that you are going to be able to get data into or our of AppEngine. If you don't want to build a web application, you could use AE as the back-end for a desktop application built in Tkinter or wxPython or whatever, but then you will have two separate applications, and the desktop client will still have to use web requests to get at the server.

    It's possible that AppEngine in the not the right solution to your problem. Is there some aspect of the problem that you are trying to solve that wouldn't be answered by Tkinter or wxPython with Sqllite for a database?

Delay task:scheduler first execution in Spring 3

I have a simple application that uses Spring 3 for dependency injection. I have a JFrame for the user to look at and some background tasks for synchronizing with a back-end server and local database maintenance.

This is the relevant part of my application context:

<task:scheduler id="scheduler" pool-size="1"/>
<task:scheduled-tasks scheduler="scheduler">
    <task:scheduled ref="synchronizer" method="incrementalSync" fixed-delay="600000"/>
    ... more tasks ...
</task:scheduled-tasks>

<bean id="mainFrame" class="nl.gdries.myapp.client.ui.MainFrame">
    ... properties and such ...
</bean>

When I start this applicationContext the scheduler immediately starts executing the background tasks even while my UI is loading. Because the first task is a rather heavy one at the start I want it to wait for the UI to fully load and display before it starts execution.

Does anyone know how to tell Spring to delay executing the scheduled tasks until a moment of my choosing?

From stackoverflow
  • This seems to have been left out of the <task:scheduled> bean definition, something I only just noticed last week.

    Remember, though, that the <task:...> definitions are just shortcuts, you can always use the explicit approach, by defining a ScheduledExecutorFactoryBean, with nested ScheduledExecutorTask beans. This gives you much finer control, including initialDelay.

How to create object from String?

I tried the code below:

$dyn = "new ". $className . "(" .$param1 . ", ". $param2 . ");";
$obj = eval($dyn);

It compiles but it's null.

How can you instance object in PHP dynamicaly?

From stackoverflow
  • $class = 'ClassName';
    $obj = new $class($arg1, $arg2);
    
  • If you really want to use eval - which chances are you shouldn't if you're this new to PHP ;) - you'd do something more like...

    $dyn = "new ". $className . "(" .$param1 . ", ". $param2 . ");";
    eval("\$obj = $dyn");
    
  • What are you actually trying to accomplish? eval would work, but its probably not a very good idea.

    What you might want to do is implement a factory for your objects that take a string defining what class to load, and an optional array for the constructors parameters

Asynchronous autocomplete in winforms

Is there a way to get asynchronous auto-complete in a Winforms TextBox or ComboBox? AJAX is so nice, and I would be amazed if the .NET framework doesn't have a thick client equivalent.

From stackoverflow
  • There's no such feature out of the box, but it shouldn't be too hard to implement it yourself... Handle the TextChanged event, send a request asynchronously to get the matching items, and change the AutoCompleteSource when you get the result. You just need to be careful to access UI components on the UI thread, using the Invoke method (or you can use a BackgroundWorker and access the UI in the RunWorkerCompleted event)

    tster : wow, seems like such an oversight.
  • I know that in MFC you can use SHAutoComplete and the shell will do it for you. However I'm not sure the best way to do this in WinForms, but it should be possible.

    See this question and this one for some more info.

help with regular pattern

this pattern will get me all files that begin with a nr and it works perfectly.

glob("path_to_dir/^[0-9]*");

but i want to have a pattern that gets me all files that ends with _thumbnail regardless file extension.

eg.

1.jpg
1_thumbnail.jpg
2.jpg
2_thumbnail.png

will get me

1_thumbnail.jpg
2_thumbnail.png

i have tried:

glob("path_to_dir/(_thumbnail)");

but it didnt work.

would appreciate a little help.

From stackoverflow
  • Will this do it?

    glob('path_to_dir/*_thumbnail.*');
    
    neo : This look like wildcards, not regular expressions...
    weng : it did perfeclty=)

Which Google Maps API key should I use for development?

I got an API key for development using localhost, but I want to be able to hit my server from different machines on my local network so I can test it. When I go via a local 198.162.. IP address on the network Google throws the error saying I need another API key.

What should I be getting for development purposes so a single server instance can be hit from several machines?

From stackoverflow
  • For development purposes, a simple array with all the IPs your server can be called from should do the trick:

    $keys = array("127.0.0.1" => "google key here", "192.168.0.1" => "google key here");
    $key_to_use = $keys[$_SERVER["HTTP_HOST"]];
    

    Note that HTTP_HOST is a value that can be manipulated freely by the client.

    Daniel Vassallo : This is also another option to my answer. You could determine what API key to use dynamically.
  • I suggest setting up an A record on your local DNS server, which would point to your development server.

    Once you do this, then simply generate a Google Maps API key for your local development domain. As a positive side-effect, this will make it easier for you to transfer your development application to another server, since you will not need to notify all your colleagues with the IP change. You would simply change the record from the DNS server.

How to get an outline view in sublime texteditor?

How do I get an outline view in sublime code editor for Windos? http://www.sublimetext.com/

The minimap is helpful but I miss a traditional outline (a klickable list of all the functions in my code in the order they appear for quick navigation and orientation)

Maybe there is a plugin, addon or similar? It would also be nice if you can shortly name which steps are neccesary to make it work.

There is a duplicate of this question here: http://www.sublimetext.com/forum/viewtopic.php?f=3&t=993&p=4308&sid=1a162626960826ab21861f1203f64ec5#p4308

From stackoverflow
  • Hit Ctrl+R for the function list. This works in Sublime Text 1.3 or above.

    : Sounds good. But nothing happens when I press ctrl-r. I have a php file open. Can I locate the command in a menu? Does this work without a plugin? karlthorwald
    : I looked, but there is no ctrl-r in the key binding file (under preferences). Do you have it there? If so, which is the "commmand" for it?
    jskinner : Ctrl+r exists in the current beta version (http://www.sublimetext.com/beta), but not in 1.2
    Cory Petosky : Updated answer with jskinner's addition.

Implementing SFTP in 2.0

I want to write SFTP clients and servers in .NET 2.0. Is that possible? Please give me some suggestions

From stackoverflow
  • Take a look at SharpSSH. It has an open source BSD-style license and supports SCP and SFTP.

  • If you want a commercial package, take a look at edtFTPnet/PRO. It supports multiple connections, directory transfers, and lots of other neat features (I'm one of the developers on the product).

  • The .NET Framework 2.0 does not include any support for SSH/SFTP. You probably have to try one of third party solutions. Our Rebex SFTP for .NET can be worth checking. Check the samples and tutorials to see if it fits your needs.

    Pavel Shved : Hm, why is it marked as spam?
    Tim Post : I don't think @Martin could have been _any_ more clear about his affiliation with the company, the answer is also quite on topic and of possible use to anyone reading this question. @Pavel - people get a little sanctimonious when it comes to pixels on their screen, I suppose.
    Ether : Note to 10k users: this does not constitute spam since 1. Martin discloses his relationship with the company openly, and 2. the answer is relevant to the question.

Remove array values in pgSQL

Is there a way to remove a value from an array in pgSQL? Or to be more precise, to pop the last value? Judging by this list the answer seems to be no. I can get the result I want with an additional index pointer, but it's a bit cumbersome.

From stackoverflow
  • No, I don't think you can. At least not without writing something ugly like:

    SELECT ARRAY (
     SELECT UNNEST(yourarray) LIMIT (
      SELECT array_upper(yourarray, 1) - 1
     )
    )
    
    oggy : Judging from what Google tells me, it seems that I can't. I'll mark this as the accepted answer unless somebody proves you wrong :)
  • I'm not sure about your context, but this should give you something to work with:

    CREATE TABLE test (x INT[]);
    INSERT INTO test VALUES ('{1,2,3,4,5}');
    
    SELECT x AS array_pre_pop,
           x[array_lower(x,1) : array_upper(x,1)-1] AS array_post_pop, 
           x[array_upper(x,1)] AS popped_value 
    FROM test;
    
    
     array_pre_pop | array_post_pop | popped_value 
    ---------------+----------------+--------------
     {1,2,3,4,5}   | {1,2,3,4}      |            5
    
    oggy : Thanks, that would work though I guess slicing isn't exactly an efficient solution?
    Matthew Wood : I think it's your best method considering there's no built-in function for pop(). Without knowing the specifics, I can't give better advice. If you want to loop through the contents for a particular record, then unnest() would probably be better as it would convert into a set of records. However, if you just want to update a table to remove all the "last elements" of the array in multiple records, array slicing would be the way to go.

Reading xlsx file using SmartXLS

Can anybody please tell me how to use SmartXLS to read xlsx file by giving an example?

From stackoverflow
  •     WorkBook workBook = new WorkBook();
        workBook.readXLSX("test.xlsx");
    

What Default Fonts Are Included With iText?

The iText documentation states that it only includes a certain subset of fonts but never says what those are. Does anyone have any ideas what fonts are included by default in iText?

(I've searched online and haven't been able to find this list of fonts anywhere!)

From stackoverflow
  • It is probably referring to the PDF Standard 14 Fonts.

    Ruben : Awesome. This is exactly what I needed. Thanks!!

ASP.NET 2.0 in Virtual Trying to Use SQL State Server

We have IIS 6 running on a W2003 Server. The root web site is running a v1.1 site. Under this site we have a virtual running a v2.0 site (with a separate application pool). The web.config for the root site is using SQL as its state server and has a 1.1 SQL state server database installed. The 2.0 virtual web.config does not need state and its web.config has no reference to a state server. When we attempt to call the virtual we receive this error message. "Unable to use SQL Server because ASP.NET version 2.0 Session State is not installed on the SQL server. Please install ASP.NET Session State SQL Server version 2.0 or above.

This issue is currently only occurring on one web server. The rest are able to run the 2.0 virtual application. I also notice that if we call the 2.0 virtual with the IP address it does not generate the error, however if we call it with the host header name it generates the error (this behavior is only on the 1 web server with the error, all the others can be called with either the ip or host header without error). As an additional note the root and virtual are running with SSL.

My theory is that the virtual 2.0 application is inheriting the 1.1 web.config state server entry from the root and when it looks at the state server it sees it as a 1.1 version and reports the error that it needs a 2.0 state server. I however cannot understand why the other servers are not behaving in this matter. All of the servers are on the same OS service pack as well as the same version of .net framework.

Any ideas? Thanks

From stackoverflow
  • Not sure why it would do that, but in your 2.0 web.config, why don't you just set SessionState back to "InProc"?

  • Although I was unable to determine why the 2.0 project was attempting to use SQL State, I was able to correct the behavior by adding sessionState mode="Off" /> under the system.web section in the web.config of the 2.0 project. Still dont understand why other servers did not need the entry but this was an unacceptable solution for the issue.

How to output messages to the VS output window, from msbuild?

I have tried adding <Message> elements to tasks in a VS project file, in order to debug the build process. However, the elements have no effect on the text that is written to the VS output window.

Is there a way to write messages to the VS output window, by adding markup to the project being built?

From stackoverflow
  • Maybe this can help?

    Under Tools – Options – Projects and Solutions – Build and Run, there’s the MSBuild project build output verbosity combo box. This controls how much info you want to see in the Output window.

    mackenir : Thanks, that did it. Even with Importance="high", Messages don't get written out to the Output window by default.
  • I think this should work (it used to for me): <Message Text="blah" />

    (And of course, from code, System.Diagnostics.Debug.WriteLine("blah");)

    Serge - appTranslator : Debug.WriteLine() outputs to the debug console at *run-time*
    Ariel : That's why I put "from code" above, right? Even more, nothing prevents you from writing a custom msbuild extension and use System.Diagnostics.Debug.WriteLine(), right?

Getting visual representation of a HTML DOM

Hello, I am trying to extract specific content(links, text, images) from an HTML page. Is there some program out there that I can use to produce a visual representation of the DOM model of the page? I know I could I write such a program in Java using an HTML parser, but before I do that, I thought I would see if there already exists such a program.

My main objective is to extract certain links, image URLs, and text; and send these to a Flex applet on the page. Thanks, Vance

From stackoverflow
  • I think your best bet would be jQuery and GreaseMonkey... GreaseMonkey would insert the script, and jQuery can efficiently parse the HTML DOM. Note that this is possibly FireFox only solution, since I THINK GreaseMonkey is a FireFox only utility.

    David Dorward : GreaseMonkey is Friefox only … but the OP was trying to avoid writing his own software for this, and you solution just provides some libraries that a custom program could use.
    Michael Bray : That's not how I took it at all, given that he wanted to send them to another program... To me that implies that he wanted some code to be able to do it. But I guess considering that he accepted the FireBug extension (which is FF only also) that I was mistaken.
  • If you just want to extract a few bits of information (rather than print out the entire page structure say) the you can use the FireBug extension for Firefox.

    Choose the HTML tab then click on the second icon from the left (looks like a cursor pointing at a box) then click on the part of the page you're interested in to go to that part of the DOM.

    JavaMan : Thank-you!! This is exactly what I wanted! I thought this type of program must exist, but I didn't know what it would be called.

Is MySQL JDBC driver compliant with the JDBC spec?

Hi,

I am using Connector/J 5.1.10 as the JDBC driver for my Database application (which uses MySQL).

I have found that although the default ResultSet returned by a Statement is of type TYPE_FORWARD_ONLY, I am still able to safely call the previous() method on the ResultSet.

I also looked at the source code (com.mysql.jdbc.ResultSetImpl), and found out that it too does not do any checks for the type of the ResultSet.

Is Connector/J not fully compliant with the JDBC spec ?

Thanks.

From stackoverflow
  • According to the release notes the driver is compliant with all of the tests that Sun makes publicly available.

    Some parts of the spec are vague, mysql specifically says so in the release notes. Perhaps the spec doesn't say what the vendor should do if you traverse back on a forward_only cursor ... the vendor has a choice whether to throw an exception at you or not.

    The public tests can't test the parts of the spec where a decision is left to the vendor's discretion.

    divesh premdeep : But the spec definitely mentions what should happen if we attempt to call previous() on a result set that can be scrolled only forwards; the javadoc says that an SQLException should be thrown.
  • The API documentation says that ResultSet#previous() should throw an SQLException "if ... the result set type is TYPE_FORWARD_ONLY", so I guess it's safe to assume that J/Connector violates the specification here.

Page Session Countdown Timer

I wrote a PHP code that kills the session after 5 minuets from creation.

I would like to display a timer in the corner of the page that shows the user how many minutes:seconds till the session times out. Are there any good examples out there?

From stackoverflow
  • Something like this? http://keith-wood.name/countdown.html

    There you have a simple example showing how to use it:

    var newYear = new Date(); 
    newYear = new Date(newYear.getFullYear() + 1, 1 - 1, 1); 
    $('#defaultCountdown').countdown({until: newYear}); 
    

    So now what we need is a UNIX timestamp (time when session will end). Then we can modify it like this:

    var endOfSession = new Date(youtitmestamp * 1000); // timestamp is in seconds and we need miliseconds
    $('#defaultCountdown').countdown({until: endOfSession}); 
    

    Hope it helped!

    Mcgo : yes, how can I integrate it with the session time stored in server?
    Balon : If you could create a code which kills the session after 5 minutes from creationg, you could easily calculate time left before end of session.
    Mcgo : I can calculate that, but I don't know how to show that to user in a dynamic way, like your example. please help me, I am new to javascript, but I know PHP well enough.
    Balon : I added an example to my answer ;)