Thursday, May 5, 2011

IE8 issue: div breaks line even though its floated

This looks like IE8 issue. I have two divs that are side by side because I float one of them to left. However, if the content inside of right div gets too big for the window, the right div breaks line and goes under left div. How do I make both divs stay on same level, side by side?

Here is the code:

css:

    <style type="text/css">
    #left_div
    {
        float: left;
        width: 250px;
        height: 400px;
        border: solid 1px red;
    }
    #right_div
    {
        width: 3000px;
        border: solid 1px blue;
    }
</style>

html:

    <div id="left_div">
        text in left_div
    </div>
    <div id="right_div">
        text in right_div
    </div>
From stackoverflow
  • Add float: left to the right_div as well.

    If it is anything similar to the examples shown by Matthew James Taylor and his Perfect 2 Column Left Menu take a look at how he is doing it and maybe copy it!


    IE has in the past also had the issue that it took height and width to mean height-min and width-min, thus still allowing boxes to resize eventhough they had specific limits set. See Webcredible's article, most notably number 2 on their list!

    dev.e.loper : thank you. these are very helpful links!
  • You can also add a left margin of at least 250px (the width of the left_div) to the right_div, that way there will always be space for the left_div next to the right_div.

    dev.e.loper : that is not a problem. the problem is that in ie8, right div breaks line and goes under left div.
    jeroen : Maybe I am missing something here, but is that not normal behaviour for all browsers?
    dev.e.loper : not if you float one element to left.
  • change the doctype: (IE8 needs it to render correctly the webpage)

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd " >
    <html xmlns="h t t p://w w w.w3.org/1999/xhtml" xml:lang="en-GB">

    (I edited the urls with whitespaces so don't forget remove them :) )

Changing target directory for a pre-build command in VS 2005

I'm programming in VB using Visual Studio 2005 Professional.

I have a code munger perl script that generates some of the *.vb files that I want to compile. The script and the associated files are in my project directory, and when I run the script from the OS command prompt, it writes the files in the same directory, which is what I want.

Rather than do this, I want to invoke the perl script as a pre-build event. I've gotten it to work ... almost. The only issue now is that the files are now deposited in TargetDir (/bin/Release e.g.) instead of ProjectDir. I could just change TargetDir to be ProjectDir, but that seems like I'm asking for trouble.

Is there a way to separately specify the target directory for pre-build commands? Or change it to ProjectDir, then change it back after I'm done with the pre-build? Or maybe I just need to write a command that moves the files back where I want?

Thanks in advance!

From stackoverflow
  • You can simply prepend a cd command to your command:

    cd ProjectDir
    do_my_stuff
    

    Your custom build step will be written out as a batch file by Visual Studio and run with cmd.exe, so cd commands will work just fine.

    John at CashCommons : That did exactly what I need. Thank you!

Deitel Live Lessons C# 2008

Hi Everyone,

I've been trying to gain a better understanding of C# through books but I tend to learn things quicker with someone explaining them to me. Has anyone tried any of the Deitel live lessons DVD's, specifically the C# 2008 set? Just wondering if anyone has any opinions on them. Thanks!

Jon

From stackoverflow
  • I can really recommend the DVDs to you, i own them myself and they are really comprehensive and helped me understanding the fundamental principles of C# development when i was switching my preference from Delphi to C#.

  • Where do you get the DVD's? I'm looking on their site and I'm not seeing it.

    Jon : Amazon has the DVD's for a lot less than anywhere else I've seen.
  • I have some AppDev suites. I really like them. Any have both and can comment on the difference?

Memory leak in Eclipse RCP applications

How can the memory leak in Eclipse RCP applications detected?

From stackoverflow
  • You need some kind of profiling tool.

    There is a Memory Analyzer project at eclipse (wiki, blog).

    Also, it looks like TPTP also does profiling.

  • If you're on windows the simplest way is simply to monitor the e.g. eclipse.exe process in Task Manager while using the tool. If your RCP executable has a different name then this is what you'll need to monitor. On Unix you can use an analogous tool (proc maybe?).

    Perform the most intensive tasks available (or if you suspect certain functions cause the problem, use those). IF the amount of memory used by eclipse.exe rises does not eventually decrease after your intensive tasks have completed then you likely have a leak. This will eventually cause an out of memory error.

    You can accelerate an out of memory error by reducing the amount of memory available to the application via the "-Xmx" setting in eclipse.ini (or .ini). E.g. -Xmx256m means a maximum 256 megabytes is available. Obviously this setting still needs to be sufficient to run your app, but a lower setting will force more frequent garbage collection and make leaks more apparent.

  • You need a memory profiler (as others have mentioned.) Once you have a good tool, you can find the problems rather easily.

    We use: http://www.yourkit.com/

    for our testing, it works very well, has floating licenses so devs can use it locally on their machines.

    Basically, you take a snapshot of the actions that you are taking and then look at the items that were allocated and not released.

    Edit: I forgot to add, this tool integrates right into eclipse.

  • You might want try the Memory Leak Detector that comes with JRockit Mission Control together with Eclipse MAT. It's a powerful combination. Both tools are free to use for development.

    With JRockit Mission Control you can inspect the heap online and see the exact number objects of a certain type that are live, without the need to take time consuming snapshots. You can directly see if you got an an Editor, View or listener object left on the heap after you closed the View/Editor. It's usually a framework listener that holds on to your view/editor. Remember, you must go to Windows->Preferences->Memory Leak Detector->Trend and set Lowest Heap Usage to report to 0.0 to se all object instances.

    alt text

    With MAT you can then use the shortest path to thread root to find the chain that is holding on to the leaking object. See below

    alt text

    Modify your code and verify with the Memory Leak Detector that the object is garbage collected when you close the editor/view.

  • The simplest solution comes with Java JDK: Java VisualVM.

    It's located in the bin directory (jvisualvm.exe under Windows) since JDK 6 update 7.

    Also includes a memory profiler, a heap walker and an Eclipse integration.

    https://visualvm.dev.java.net/images/getstarted/vvm-anagram-profiler.png (too bad, I'm not allowed to use image tags)

    See https://visualvm.dev.java.net/

SQL Server: Retrieve auto-incremented ID inside a stored procedure?

My database has a parent table with an auto-incrementing primary key identity 'ID', and a normal 'TIMESTAMP column'. I have child tables with a foreign key that refer to the parent 'ID' column.

I want to write a stored procedure that inserts a new column into both the parent and child databases. How would I set the child 'ID' column to equal the new auto-incremented parent 'ID' column? Does this require a separate:

SELECT TOP 1 * FROM PARENT_TABLE

Or is there another way?

From stackoverflow
  • You can retrieve it from SCOPE_IDENITY(). For example:

    declare @myid int
    INSERT INTO table (field) VALUES ('value')
    SELECT @myid = SCOPE_IDENTITY()
    
  • select scope_identity();

Migrating Delphi App to Java or to Web App

We want to migrate UI rich application from delphi to java or Web Application.

Reason is that we want application to be portable on all Operating Systems.

Current Components and Modules of Application in Delphi :

  • In Delphi we are utilizing TWebBrowser component to display HTML content
  • We are playing mp3 that is extracted from FileStream on clicks in HTML.
  • All resources for HTML are retrieved from Embeded Database Firebird/Ms Access.
  • To sync some content we are doing HTTP post to PHP scripts to centralize the data on webserver.

Deployment: - Application has to be deployed on CD and installed on Desktop computer on Mac OS, Linux, Windows.

I need your help how to approach this migration. Is better to go with Java UI or Web App that will be deployed with WAMP/XAMP and appropriate distributions on Linux and Mac's.

EDIT: I have some specific requirements for audio functionality. Audio files are separate files distributed on CD or USB. Audio files are one solid file compiled from mp3's inside. Application will have to have ability to extract the mp3 based on offset and size of mp3 stored in index file and to play in real time... How this affects idea of Web App using this approach.

From stackoverflow
  • If I had to deploy on a CD, I'd probably go with Adobe's AIR. It is really fulfilling the promise Java made 10 years ago in a reasonable way. It isn't perfect, but it does a pretty good job.

    altCognito : +1 If it simply must be deployed locally, then AIR is really the way to go.
    Irfan Mulic : What do you mean it is not perfect? Look my latest EDIT regarding playing audio files from stream? How to do that in Air?
    Irfan Mulic : The reason for deploying locally is huge amount of audio data about 500 MB? If you wanna do that load from HTTP server locally still make sense but I am still not sure about the future architecture in this case...
    Travis Jensen : I'm not familiar with exactly how Air handles music streaming. Flex does support loading types from streamed data, but I don't know if you can give an offset and such. Perhaps understanding why you need to concatenate all the files into one big file would go further into helping build a solution.
  • I've heard this internet thing is really taking off.

    For all of the reasons that applications have gone online over the past 10 years, there really isn't much discussion to be had.

    While Java is reliable, distributing and rolling out subsequent updates to those applications is heavy and time consuming.

    I did Delphi development for over 9 years. I resisted the idea of distributing real applications over the web for quite some time. Today, I can't believe anyone would choose to continue in this way.

    One nice thing, you can probably reuse some of your Delphi logic on the backend if you get creative. (I would only recommend this for the short term)

    But, this answer doesn't really address your issue as you are saying that you must distribute it via CD.

    Chris Collins : How seamless would a migration from Delphi to Java be. I had the impression most Delphi migration is in the direction of .Net - that would solve the poster's cross-platform requirement but would it be a closer fit to the original source base?
    altCognito : Yeah, if you're looking to keep your original source code, .NET would be a better fit. I like the idea of doing AIR simply because it forces you to think to a day when you are simply running the application online.
    Irfan Mulic : .NET is probably the most easy way to do it but is not an option because of Linux and MAC OS.
  • The Java 6u10 release allows for distributing Java WebStart applications on media instead of from a Webserver, which might be exactly what you are looking for. You can also put the JRE installer for Windows on the CD too, if needed.

    What exactly are your requirements crossplatformwise?

    Irfan Mulic : I don't understand the question, I wanna solve the plaform constraints by moving application from Delphi to Java. Delphi only runs on Windows.
    Thorbjørn Ravn Andersen : Do you need to run a GUI client (difficult) or is it all being delivered through a browser(easier)? For embedded database, look at Apache Derby. For embeddable webserver look at Jetty.
  • If most of the application is HTML-based, why not make it a full web application, using Ajax and Java?

    I recommend NetBeans, and ICEFaces, which is a Java Server Faces implementation with Ajax support, including concurrent updates - if one user edits a record, all other users will see an update in their web page.

    It is possible to package the whole application in a single jar file, including the servlet container (Jetty for example), so a simple java -jar myapp.jar will run the application.

    NetBeans allows visual editing of the ICEFaces web pages, and even visual editing of the page relationships. The tutorials on NetBeans.org are excellent, and with tools like Maven, Hudson and others, code quality and development process can reach a very high level.

    Irfan Mulic : I like this approach. I have some specific requirements for audio part. Audio files are separate files distributed on CD or USB or whatever. Audio files are one solid file compiled from mp3's inside. Application will have to have ability to extract the mp3 based on offset and size of mp3 stored in index file and to play in real time... How this affects idea of Web app using this approach. Thanks.
    altCognito : Errr.... This is a bad reason to not make it a web application.
    mjustin : If it is a multimedia application, Suns new JavaFX client side technolgy might be an option for the user interface: http://en.wikipedia.org/wiki/JavaFX
  • If you have some Delphi application using Datasnap : you can also re use your server made in Delphi with Datasnap in Delphi Prism and make Silverlight application.

    And the same is true for DataAbstract

    Irfan Mulic : This is good idea but we don't wanna be dependent on Delphi platform anymore.
  • Why don't you give FreePascal a try? It uses the same language as Delphi, and can compile to a native application on Windows / Linux / Mac. Since you already have your app in Delphi, converting it shouldn't be too difficult.

    Have a look at the freepascal website

  • I suggest Air

How do I display the result of this query using Joomla pagination?

What can I do to display the result of this query in the fronted using the Joomla pagination?

<?php
  $database =& JFactory::getDBO();
  $sql = 'SELECT * FROM #__no_entreprise';
  $database->setQuery( $sql );
  $rows = $database->loadObjectList();
?
From stackoverflow
  • looking in the first result of google -> here

    Gabriel Sosa : btw, this was my query http://bit.ly/njOfI