Friday, February 11, 2011

SQL Server Primary file group max size

Hello All!!!

I have a situation, I am trying to run almost 100 update statement on a table say 'XX'

In SQL Server database. But it is giving me an error tat goes something like this...

"Could not allocate space for object 'dbo.XX'.'PK_XX_3489AE06' in database 'MYDATABASE' because the 'PRIMARY' filegroup is full. Create disk space by deleting unneeded files, dropping objects in the filegroup, adding additional files to the filegroup, or setting autogrowth on for existing files in the filegroup."

Please advice me what to do... Thankx in advance

    1. Check to see if your database has auto growth enabled.

    2. Make sure you have available space on disk where your database file is located.

    Rajdeep : @@BOB..it has been set to unrestricted growth and moreover my drive has over 60gb of free space
    Rajdeep : @@BOB my drive has NTFS and not FAT32
    Bob Palmer : Have you tried to manually grow your database? Also, have you checked both data and log file size? And have you run a DBCC to make sure everything is in order? Hope one of these items helps!
    From Bob Palmer

What is the most popular GUI library for Python in Windows ?

What is the most popular GUI library for Python in Windows ?

  • I think PyQt. It's not windows only but I think is one of the most popular out there. Other pretty popular one is WxPython.

  • Last I knew, TkInter was the most popular (cited here as the "de-facto standard GUI package").

    mikerobi : Out of the dozens of Python apps apps I've used over the years, there are less than a handful that used TKinter. TK was the first library, and the only one included in python, but it has been overtaken by better options.
    Nick T : TKinter does win for the "most widely deployed Python GUI package" (like IE is the most widely deployed browser), but that doesn't mean people use it.
  • I've never conducted a survey, but I am reasonably confident that PyGtk and WxPython are the most popular across all platforms.

    What I can say for certainty is that PyGtk, WxPython, PyQt, and at some point in the future PySide, are all mature enough that it would be very unwise to choose one based on popularity.

    From mikerobi
  • How about IronPython + WPF?

    Craig McQueen : Are you saying it's the most popular, or just "How about it, hey"?
    lukas : how about, but WPF is the most popular here :P
    From lukas
  • WXpython is used a lot, this blog has many, many examples to get you quickly started with it:

    http://www.blog.pythonlibrary.org/

    Nick T : wxPython has a giant demo app that is pretty nice http://wxpython.org/download.php
    From relima
  • To quote the BDFL:

    wxPython is the best and most mature cross-platform GUI toolkit, given a number of constraints. The only reason wxPython isn't the standard Python GUI toolkit is that Tkinter was there first.

    -- Guido van Rossum

    From http://www.wxpython.org/quotes.php

    mikerobi : That is a very old quote.
    JasonFruit : And it only answers what one is most popular with Guido.
    From ma3
  • Questions Tagged.. : (Here On SO)

    wxPython - 726

    pyQt - 476

    pyGtk - 371

    Tinkter - 331


    Im not in any way suggesting the above is a measure of popularity. Merely providing some statisics that I thought others may find interesting.

    Bryan Oakley : Of course, one could argue that the more questions there are, the harder, more buggy, or poorly documented the language. If the language is easy to learn, meets all common needs and is stable, no need for questions :-)
    volting : @Bryan: You could argue many points based on those stats, but they would speculative at best without a full analysis of all the questions, that is why I chose to refrain...
    From volting

Visual Studio 2008 and Visual Studio Express Edition 2010 CoExist in the Same Machine?

Hello...I run a Windows 2003 VMWare Machine which has Visual Studio 2008 Professional. Now, I want to play with Visual Studio 2010 Express Edition (primarily, the Visual Web Developer 2010). Can they co-exist.

I have had a look at the following questions, but still posting this because this one is specifically asking about VS2008 Professional Vs Visual Studio 2010 Express?

Other related questions.

Coexisting installation of visual studio 2010 &2008

  • Yes. I have VS2005, VS2008, and VS2010 all living happily side by side on the same development machine.

    Microsoft recommends that you install the multiple versions in order. Start with the lowest version and work your way up. That way the older versions won't overwrite anything they shouldn't.

  • Yes different versions of Visual Studio can co-exist on the same machine. It is a scenario that is explicitly supported and tested for.

    From JaredPar

Shortest route with no set destination in Google Maps V3?

So I'm just learning javascript to mess with the Google Maps API. I was wondering if anyone had an elegant solution to this problem I'm running into.

A Google Maps route request must contain three things (origin, destination, and travelMode). My travelMode will always be DRIVING. The origin will always be wherever the user is located.

The destination though, needs to vary. I have several waypoints and the user will visit, and would like to provide the shortest trip possible depending on what waypoints are selected and where the user is, ending the route at one of the waypoints (eg: ABC or ACB, but always Axx...x).

Is there any possible way to do this other than calculating every possible path and seeing which has the shortest distance (or time, or whatever I'm evaluating on)? It seems like that would be prohibitively costly (O(n!)).

edit: With the suggested optimizeWaypoints flag set to true this becomes a O(n) problem instead of O(n!), but now I have issues with issuing too many requests in too short of a time period.

  • http://en.wikipedia.org/wiki/Travelling_salesman_problem

    From aepryus
  • There is a setting in google directions to provide optimized route (optimizeWaypoints - http://code.google.com/apis/maps/documentation/javascript/services.html#Directions ) you simply set it to true in your directions object

    Crag : I've done that, but I'm still forced to set a destination. I can't just set this to true and feed the request all my waypoints. What I'm working on now though is simple create n routes for n waypoints, feeding the request A as origin, b-n as destinations and all the waypoints minus the destination for each route. This gives me a route I can calculate a distance for, going to do some heavy testing now to see if this works for any decent number of waypoints.
    Crag : Ok the solution I ended up using was based off this answer so it is getting the check mark. What I have now are my waypoints as well as some REALLY far away location. I send all my waypoints in my request, let Google find the optimal route for those waypoints from my start position to the far away destination and then take the newly ordered waypoints out. Then I set the final waypoint as the new destination, and fire off another request with the set of waypoints now containing one less waypoint. This gives me the route I'm after.
    From Michal

Catch pasted input in textarea

with javascript(Jquery).

Searched online, seems like it's not possible. So far I have something like:

$("#textAreaId").bind('paste', function (e) {
        alert('pasting text!!!!');

        var data = $("#taData").val();

        alert(data);



    });

but the data is empty at this stage...is there a way to capture the pasted input after it's been pasted? Seems like there should be a way.

keyup event in Jquery is not triggered when pasting occurs.

Any ideas?

  • Not all browsers support the same copy / paste capabilities. Here is a chart of which browser support which functions:

    http://www.quirksmode.org/dom/events/cutcopypaste.html

    If the browser supports capturing the copy / paste events, jQuery should work fine. I would suggest testing each of your targeted browsers.

    Another approach would be to use the jQuery 'data' property to detect that the input field has changed. Here is an article with example code:

    http://www.mydogboris.com/2009/10/using-jquery-data-feature-to-detect-form-changes/

    from the article:

    var formChanged = false;
    
    $(document).ready(function() {
         $('#my_form input[type=text].editable, #my_form textarea.editable').each(function (i) {
              $(this).data('initial_value', $(this).val());
         });
    
         $('#my_form input[type=text].editable, #my_form textarea.editable').keyup(function() {
              if ($(this).val() != $(this).data('initial_value')) {
                   handleFormChanged();
              }
         });
    
         $('#my_form .editable').bind('change paste', function() {
              handleFormChanged();
         });
    
         $('.navigation_link').bind("click", function () {
              return confirmNavigation();
         });
    });
    
    function handleFormChanged() {
         $('#save_or_update').attr("disabled", false);
         formChanged = true;
    }
    
    function confirmNavigation() {
         if (formChanged) {
              return confirm('Are you sure? Your changes will be lost!');
         } else {
              return true;
         }
    }
    
    gnomixa : Capturing the event works, it's the TEXT pasted that I am wondering how to get. In IE, clipboardData object can be used, but it's not available in FF. And yes, the above code works for both IE and FF so capturing the paste event in NOT the issue.
    gnomixa : So in other words, comparison (or timer) is the only way to go? There is no such thing as postpaste event?
  • I've answered a similar question before: http://stackoverflow.com/questions/3239124/javascript-catch-paste-event-in-textarea/3239609#3239609

    gnomixa : Thanks Tim, I saw this earlier, but the reason I posted this was because I want (rather have) a less cumbersome way to do this. I mean, it should be easy, right? So far it looks like I am going to have to put a timer on a field and start it when paste event has been captured. Seems kind of a backwards way, but looks like there is no alternative.
    Tim Down : I've looked into it and I'm nearly certain there isn't an easier way.
    gnomixa : see my answer for the easier way for what I need to achieve.
    From Tim Down
  • Here is what I have decided to do. Please note that I am merely required to grab the pasted content.

    $(document).ready(function () {         
    
        $("#taData").bind('paste', function (e) {
            setTimeout(function () { DisplayPastedData(); }, 100);
        });    
    
    });
    
    
    
    function DisplayPastedData() {
    
        var data = $("#taData").val();
        alert('input pasted ' + data);
    
    
    }
    

    I have arbitrarily selected 100 milliseconds to wait, which works nicely with my maximum of data pasted.

    Tim Down : Right... so what happens if the user pastes text into a textarea that already contains text?
    gnomixa : that's not something that I am required to cover according to my requirements. The pasting will occur once, pasted input will be parsed out, and used to populate the table, each subsequent pasting will overwrite the previous one. See my original question. There is nothing about covering the pasting when the textarea is not empty.
    Tim Down : Fair enough. In which case, I'd suggest emptying the textarea after you've got the data: `function DisplayPastedData() { var $ta = $("#taData"); data = $ta.val(); alert('input pasted ' + data); $ta.val(""); }`
    From gnomixa

"com.jacob.com.ComFailException: Can't find moniker" Why?

I use jacob last version and jacobgen.

I put all need dll in c:\windows\system32

I generated wrapper about dll by jacobgen.

But I got an exception. Google didn't help. :(

com.jacob.com.ComFailException: Can't find moniker

May be need registy dlls in windows registry?

  • COM objects have to be registered to be found. It does not matter in which folder they reside.

    Call

    regsvr32 mycomdll.dll
    

    on the dll.

    From Daniel
  • Thanks!!! It's helped me!!! :)

    Daniel : TYou should have posted this as an comment to my answer :). And btw. this would be a good time to accept my answer, because then the next question you post has a higher chance to get answered. People tend to ignore questions from users that don't accept answers.
    From Tim

iPhone: Detecting Tap in MKMapView

How do I detect a single tap on an instance of MKMapView? Do I have to subclass MKMapView and then override the touchesEnded method?

Thanks,

-Chris

  • You cant at this time intercept touches on a map view, you can try layering an opaque view on there and see if it picks up touches...

    From Daniel
  • Or depending on what you are trying to do, add an MKAnnotation (push pin, with a callout), so you have something to tap on - and then your map delegate will receive an event eg.

    mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control

    From TimM
  • Hope this will help : How to intercept touches events on a MKMapView or UIWebView objects?

    bentford : This helped, but has issues. But it's better than nothing...
    ChrisJF : Yes, if you read in the comments there is another solution. There is actually a third way of doing this (besides sub-classing MKMapView or layering your own view on top and passing on the touches to MKMapView). Instead of subclassing MKMapView, subclass the main window and pass the touch events to both MKMapView and your view. http://stackoverflow.com/questions/1121889/intercepting-hijacking-iphone-touch-events-for-mkmapview/1298330 Haven't tried this yet but apparently performance is better and pinch to zoom still works.
    From tt.Kilew

Sort array by Alpha?

Code below takes a directory and creates an array of folder names appearing under the directory. How can order the folder names inside the array by alpha?

function get_dirs($dir) {
   $array = array();
   $d = dir($dir);
   while (false !== ($entry = $d->read())) {
       if($entry!='.' && $entry!='..') {
           $entry2 = $dir."/".$entry;
           if(is_dir($entry2)) {
               $array[] = $entry;
           }
       }
   }
   $d->close();
   return $array;
}
  • I believe sort($array); should do the trick: http://us.php.net/manual/en/function.sort.php

    From PureForm
  • You can use sort($array)

    Or rsort() if you want it in descending order.

    PureForm : This will just return the bool value from sort(). You'll have to sort the values then return them.
    Russell Dias : Oops. Good point.

Does changing the innerText of a DOM element result in a new layout caculation/render?

I know that certain changes to the DOM of a web-page (by JavaScript) will result in the rendering engine calculating a new layout for rendering (not sure if my terminology is correct).

I have a process that updates data fairly frequently with comet style long-polling requests. Some of these updates are fairly frequent. I know that a good general rule of thumb is to remove the target DOM element, make the necessary changes, and then put it back into the DOM (so you only get hit twice with the re-render), but I wasn't sure if you only replace the inner text of an element if you incur the same hit. In my case, I am updating the content of some table-cells, that are just text (not wrapped in spans or divs).

  • Any time something changes in the DOM it triggers a Repaint and Reflow. Even if you're just changing text.

  • yes it will be just like you want to be.

    For example: you have a div with id="div" and its html setted to text of 'Lorem'

    var div = document.getElementById('div');
    div.innerHTML = 'Lorem Ipsum Dolor'
    

    then you will see the div's innerHTML to be setted 'Lorem Ipsum Dolor'. this is called document reflowing.

    Lorenzo

    Matt : that's actually what I *didn't* want it to be :) I was trying to figure out if I could speed things up by selectively updating innerText as opposed to rebuilding high-up DOM structures.
    Lorenzo : I could not understand you. If you be more clearly, I want to be help you as well :)
    From Lorenzo

Split multiple lines and input them in separate row in a database

Hi Guys,

I am trying to create a php script that inputs the HTTP links pasted into a textarea into a separated row in a database. More exactly:

First page is where the textarea (name=textarea-linkfield) is, links are going to be pasted here

http://www.stackoverflow.com
http://www.yahoo.com
....
http://google.com

The links are being carried over into the php script with $linkfield=$_POST['textarea-linkfield']; and I would like the links to be inserted into the database, each http link per row. Database name: site, table name plow, columns: id, url, ...

L.E. I tried just as proof of concept:

$linkfield=$_POST['textarea-linkfield'];
$strip=explode("\n",$linkfield);
echo $strip[1];

but I get 500 INTERNAL SERVER ERROR

L.E.2

The answer:

// Split the string into pieces
$pieces = explode("\n", str_replace(array("\n", "\r\n"), "\n", trim($linkfield)));

// Build the top of the INSERT query
$sql = "INSERT INTO `plow`(`url`) VALUES\n";

// Build the rest of the ;INSERT query by re-assembling the
// pieces.
$sql .= "('";
$sql .= implode("'), ('", $pieces);
$sql .= "')"; 
mysql_query($sql) or die ('Error: ' . mysql_error());

mysql_close();

Thanks to all for their help. Chris.

  • use preg_match to find each URL and add it to the database. Example 3 on this page should do the trick: http://php.net/manual/en/function.preg-match.php this way you can enter URLs without having to use a new line. if you're only using URLs, then you could also add a delimeter after each URL i.e. a comma (which isnt used in a URL) to explode them with using the explode() idea in the comment.

    Chris19 : I would like to come up with a script that can work without me adding commas or any other delimiter and the links need to be inputted into the textarea into a new line. Thanks, Chris.
    From InnateDev
  • Depending on your os a newline can be "\n", "\r\n" or "\r".

    Give this a shot:

    $strip=explode("<br>", nl2br($linkfield));
    

    or maybe safer:

    $strip=explode("\n", str_replace(array("\n", "\r\n"), "\n", $linkfield));
    
    Chris19 : Linux environment and is working with the second line of code, now I need to come up with the code to insert it into the database. Thanks PMV.
    PMV : foreach ($strip as $website) { mysql_query("INSERT INTO table (url) VALUES ('$website')"); }
    Chris19 : Thanks PMV. Works like a charm.
    From PMV
  • Here is your question, answered: http://bytes.com/topic/php/answers/850719-extracting-individual-lines-multiline-text-box-processing

    Chris19 : Thanks Ted, indeed that was the answer. I pasted the answer at the bottom of the question for others to use. Thanks all for your help. Good night, Chris.
    From Ted

Searching in SQL Management Studio 2005

Is there a way to search for text within stored procedures? For example I want to find out if a particular table is being referenced by any stored procedure.

  • Use:

    SELECT OBJECT_NAME(m.object_id), m.*
      FROM SYS.SQL_MODULES m
     WHERE m.definition like N'%text_youre_looking_for%'
    

    SYSCOMMENTS and INFORMATION_SCHEMA.routines have NVARCHAR(4000) columns. So if "text_youre_looking_for" is used at position 3998, it won't be found. SYSCOMMENTS does have multiple lines, but INFORMATION_SCHEMA.routines truncates.

    JNK : Thanks for setting me straight.
    OMG Ponies : @JNK: For the record, I didn't downvote you.
    JNK : @OMG - no biggie, I posted a wrong answer :)
    gbn : @JNK: I did but decided to do my answer first beore commenting
    JNK : @gbn: As I said, no biggie it was a wrong answer. that also explains an issue I had with that script in the past.
    Mike Cheel : Don't forget if you just care about references and you have the permissions you can just right click the sproc in Object Explorere and select View Dependencies. And this is in addition to what the others have said so please don't downvote me like some did earlier today on a different post when I was just giving additional information.
    gbn : @Mike Cheel: it's not reliable. Try dropping/recreating a base table used by a view. Dependencies are *not* maintained (though it's getting better)
    From OMG Ponies
  • SELECT
       OBJECT_SCHEMA_NAME(object_id) + '.' + OBJECT_NAME(object_id)
    FROM
       sys.sql_modules
    WHERE
       definition like '%whatever%'
    

    syscomments is legacy and splits the definition into nvarchar 4000 chunks thus risking not finding what you want. The same applies to INFORMATION_SCHEMA.ROUTINES

    KM : +1, `OBJECT_SCHEMA_NAME()` is way better than joining to sys.objects and then sys.schemas!!
    From gbn
  • You can script it out and search the script.

    From Beth
  • My co-worker graciously provided me with this one recently. It does some similar searching as others have noted, but with a little more added in.

    DECLARE
     @chvStringToFind varchar(256), /* String to find */
     @chrObjectType char(2),--=null, /* Only look for objects of this type */
     @intNbCharToExtract int
     --=50 /* Number of characters to extract before and after the string to find */
     --exec DBA_FindStringInDB @chvStringToFind='sp_helpdia', @chrObjectType=null, @intNbCharToExtract=50
     SET @chvStringToFind = 'EnterSearchTextHere'  -- Change this to search
     SET @chrObjectType = NULL
     SET @intNbCharToExtract = 50
    
     SELECT t.Name, t.TypeDescription, t.CreationDate, t.ModificationDate,
     '...' + SUBSTRING
     (
     t.ObjectDefinition,
     CHARINDEX(@chvStringToFind, t.ObjectDefinition) - @intNbCharToExtract,
     LEN(@chvStringToFind) + (@intNbCharToExtract*2)
     ) + '...' AS Extract
     FROM
     (
     SELECT o.name AS Name, 
     o.type_desc AS TypeDescription, 
     o.create_date AS CreationDate, o.modify_date AS ModificationDate,
     OBJECT_DEFINITION(object_id) AS ObjectDefinition
     FROM sys.objects o
     WHERE 
     ((o.type IN ('AF', 'FN', 'IF', 'P', 'TF', 'TT', 'U', 'V', 'X') AND @chrObjectType IS NULL) OR o.type = @chrObjectType)
     AND OBJECT_DEFINITION(o.object_id) LIKE '%' + @chvStringToFind + '%'
     ) AS t
     ORDER BY TypeDescription, Name
    
    From Vinnie
  • Red Gate has a free tool called Sql Search that I rather like. It keeps an index so that after its first search, it is very fast (and even the first one is pretty good...). It can search for text in procs as well as table and view definitions, etc. There are some filtering features to make it a little easier to use. And the search results are displayed in a very useful manner, with the full text of the object and the search text highlighted.

    Prabhu : Great, I knew they had one, but wasn't sure I didn't know it was free.
    marc_s : +1 excellent tool from a great company - highly recommended ! Couldn't live without it anymore.....
    From Ray

How do I choose parent node attribute and its child values using XML and Xquery?

I have this:

<pss>
<ps n="А parent node" m="654564654" t="435,8551" a="2857,2716">
      <sc s="a1" a="25,4220"/>
      <sc s="a2" a="0"/>
      <sc s="a3" a="2395,9945"/>
</ps>
...
</pss>

I need to select "А parent node m attribute and a1-a2 a values in one query. i tried this but it doesnt work:

SELECT ps.value('@m', 'nvarchar(50)') "parent node",
--       sc.value('@a1', 'nvarchar(50)') "название услуги",
--       sc.value('@a2', 'nvarchar(50)') "стоимость услуги",
       ps.value('@a3, 'nvarchar(50)') "b","
FROM   mts.dbo.bill 
OUTER APPLY xCol.nodes('//Report/rp/pss/ps') AS A(ps)
OUTER APPLY xCol.nodes('//Report/rp/pss/ps/sc/.') AS B(sc)

thanx in advance.

  • There are no a1, a2 or a3 attributes in the provided XML document!

    Use:

      /pss/ps/@*[name(.)='n' or name(.)='m']
    |
      /pss/ps/sc/@a
    

    This is the XPath expression that selects the wanted nodes from the provided XML document. I am not sure how it should be combined into an SQL command.

    Kai Osmon : thanx, but ERROR: XQuery [mts.dbo.bill.xCol.nodes()]: There is no function '{http://www.w3.org/2004/07/xpath-functions}:name()'.
    Kai Osmon : "There are no a1, a2 or a3 attributes in the provided XML document!" - this is attribute "s" of node, sorry
    Dimitre Novatchev : @Kai: My answer is in pure XPath 1.0 -- you didn't specify XQuery as a tag!. Now I updated the answer and it will run both in XPath 1.0 and XPath 2.0 (XQuery is a superset of XPath 2.0).
    Kai Osmon : Dimitre. I am quite new to all thу X... stuff. Will you please give me a solution to thу xml at the very top: is the root node and it has several nodes. nodes have nodes. What I need is: Get an attribute of node and all atributes of its nodes (repeats for each node).
    Kai Osmon : I need a query to have the above selected...

Force Flex 4 Spark Hslider snap to certain values?!

I remember using values array on good old mx:HSlider, is there any workaround for s:HSlider?!

Basically I need slider to choose values between 300 and 2500 in following steps 300,500,1000,2000,2500.

<s:HSlider id="franchiser" 
   value="1500" 
   skinClass="components.HorizontalSlider" x="0" y="0" 
   minimum="300" maximum="2500" />

If not with this component, is there any alternative skinable slider out there?!

Thanks in advance!

  • The default HSlider does not have this functionality.

    To accomplish this, you will need to create a class that extends HSlider and adds this functionality.

    You can see an example of how to extend a Flex class here: http://blog.flexexamples.com/2008/09/08/extending-the-linkbutton-control-in-flex/

    zarko.susnjar : OMG, sometimes I really hate Adobe :( Yeah, I kinda had that coming, but hoped that there's some proven solution somewhere in community...
    Alan Geleynse : Yeah, Adobe stated that their position was to add just what was needed and not add convenience methods, so you have to do it yourself unfortunately. Good luck finding another solution, but my guess is you will have to write it yourself.

C# difference between arr[0]++ and ++arr[0]

In C#, is there a difference between the code (all in one statement, not part of a larger one) arr[0]++; and ++arr[0];

I fully understand, that in C / C++ / Objective-C, that this would not do the same thing, first case would get the value at arr's 0th index and increment that value by one, while the second one, increases the pointer value of arr, and does nothing to it's 0th position (same as arr[1]; arr++;).

Thanks to sth, he has reminded me that this is the same in C# and C / C++ / Obj-C.

However, is there a difference between the two statements in C#?

  • If it is a single statement there is no difference.

    Richard J. Ross III : That was fast, thanks!
    From Mark Byers
  • arr[0]++ returns the value of the first element of arr, then increments it.

    ++arr[0] increments the value of the first element of arr, then returns it

    The difference only matters if you're using this as part of a longer instruction. For instance :

    arr[0] = 42;
    int x = arr[0]++; // x is now 42, arr[0] is now 43
    

    Is not the same as:

    arr[0] = 42;
    int x = ++arr[0]; // x is now 43, arr[0] is now 43
    
    Richard J. Ross III : Yes, but that means that there is no difference if it is a singe statement, right?
    Thomas Levesque : @Richard, see my edit
    abatishchev : @Richard: Right
  • ++x increments and then returns while x++ returns the value of x and then increments ! But if there is no one to receive the value, its all the same.

    From mumtaz
  • An optimizing compiler should generate the same code if that statement exists by itself, but when you're using the value you're modifying inline, post-increment can require making a copy (so you can work with the old value), which can be expensive if the array is of a type that has an expensive copy constructor.

    From Chris

Can not locate x:Shared in wpf.

Hi,

Please look into this question.

http://stackoverflow.com/questions/3795737/issue-with-mvvm-view-first-approach

But I'm unable to find "x:Shared" attribute.

Please help.

  • here is the msdn link. it works in 3.5 also see below.

    From the Book WPF Unleased: Assuming the Conventional x Namespace Prefix. x:Shared --> Attribute on any element in a ResourceDictionary, but only works if XAML is compiled!

    //ResourceDictionary
    <ResourceDictionary xmlns:x="http://schema.microsoft.con/winfx/2006/xaml>
    <Image x:Shared="False" x:Key="zoom" Height="21" Source="zoom.png" />
    ...
    
    Anish : I guess, you mention about xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml". But I'm unable to see x:Shared http://social.msdn.microsoft.com/Forums/en-US/vswpfdesigner/thread/15885852-ebeb-4794-95b9-304076a81fae
    blindmeis : what happens if you just type x:Shared=True and then compile? did it not work? what framework do you use? if you have blend what happens there?
    From blindmeis

Auto adjust the UITableViewCell height depend on it's contents in Objective-c

I want to adjust the height of a cell depend on it's contents. I know UITableViewDelegate let you implement the

- (CGFloat) tableView: (UITableView *) tableView 
              heightForRowAtIndexPath: (NSIndexPath *) indexPath {
    return someHeight;
}

but I do not want to hardcode the height. Is there a way to do this dynamically?

  • You have to enter some code into that method that calculates the height of the row content. Exactly what code you need to put depends entirely on what kind of content you're displaying.

    For example, if you're displaying text content that may wrap across multiple lines, you're probably going to end up using one of NSString's sizeWithFont: family of methods.

    Chateaudlf : Thanks! That did the trick.

Custom ListView background problem

I have a LinearLayout layout with a ListView in it. I've made the android:background of the LinearLayout (I've also tried it on the ListView) be an image that I would like for my background.

This works fine enough. However, when I start scrolling through the ListView, the background often disappears and becomes black. If I move it around some more I may be able to get it to appear again. It would seem that Android is drawing over, or perhaps painting what's behind my background onto the items.

Any ideas/solutions?

Rails application runs from terminal but not from Netbeans - missing gem error

Hello! Been trying to get my project up and running on an Ubuntu Virtual Box machine. Everything works fine from the terminal, but when I try to run my application from Netbeans I get the following error:

=> Booting WEBrick
=> Rails 2.3.5 application starting on http://0.0.0.0:3000
/home/soroush/.gem/ruby/1.8/gems/rails-2.3.5/lib/rails/gem_dependency.rb:119:Warning: Gem::Dependency#version_requirements is deprecated and will be removed on or after August 2010.  Use #requirement
Missing these required gems:
  i18n  = 0.3.7

You're running:
  ruby 1.8.7.249 at /usr/bin/ruby1.8
  rubygems 1.3.7 at /home/soroush/.gem/ruby/1.8, /var/lib/gems/1.8

Run `rake gems:install` to install the missing gems.

Running 'gem list' from the terminal shows that i DO have i18n installed. I've searched for answers but haven't really been able to find anything that correlates to my specific error.

Thanks in advance for any help! Regards, Emil

  • What happens if you right-click on your project, choose "Run / Debug Rake Task" and run the gems:install task mentioned above?

    Alternatively you should right-click on the project, choose Properties, choose "Gems" in the sidebar and add the i18n gem there. I had to do that for a project to get debugging working within netbeans, installing the correct gem using bundler from the command-line didn't do anything that NetBeans was picking up.

    Emil : Thanks for your replys prodigitalson and alxp. It turns out the netbeans gem path was a different one than the one that showed up in the terminal. I ran the command, and switched netbeans gem path to GEM HOME to solve the problem. Thanks alot!
    From alxp

Is there a version of JUnit assertThat which uses the Hamcrest 'describeMismatch' functionality?

In every version of JUnit I have tried (up to 4.8.1), a failing assertThat will display an error message that looks like:

expected: [describeTo]
got: [String representation of object]

In other words, it will display the toString() of the object instead of the mismatch description from the Matcher. If I use the assertThat from org.hamcrest.MatcherAssert.assertThat, then it will call 'describeMismatch' and display a more helpful error message.

Am I using Junit incorrectly or is there currently no version of JUnit that will do what I want? Do most people use the Hamcrest assertThat then?

  • Use [the other version][1] assertThat(String, T, Matcher<T>) and in the first argument write your own message that will give you a better description of the failure.

    [1]: http://www.junit.org/apidocs/org/junit/Assert.html#assertThat(java.lang.String, T, org.hamcrest.Matcher)

    Jacob : Thanks, Boris. That is one nice way to create a description. However, I would prefer to use the build-in error message that the Matcher can generate via its "describeMismatch" method.
    Boris Pavlović : You are welcome, Jacob.
  • Short answer: no.

    As far as I can tell, the most recent version of Hamcrest (1.2) has introduced type signatures which are incompatible with version 1.1, which JUnit currently depends on. I am not sure the extent of the damage (so to speak) created by the change in Hamcrest, but it does not appear that the JUnit team are in any hurry to upgrade (see the open issue).

    I am not entirely sure I have solved my issue, but I am planning to use MatcherAssert.assertThat(). This can require a specific release of JUnit (junit-dep-xxx I believe) which will not have classpath conflicts with Hamcrest. Otherwise you may receive NoSuchMethodErrors when assertThat() makes the call to describeMismatch().

Do pre-loaders actually help in Flash?

I have noticed the use of "pre-loaders" on many sites that heavily use Flash. This is supposed to make the user feel as if the site is loading while the app is downloads and initializes. I have a few questions about this practice.

  1. Does this really help? From what I can see, there seems to be a fair amount of graphics in the pre-loader itself many times. This seems to defeat the purpose of having a pre-loader to begin with. Heavy graphics only add to the overall size of the SWF file, which means that it will take longer to download.

  2. How do I determine the right amount of graphics to use in a pre-loader?

    1. Preloaders are solely for user experience. Most sites will experience high bounce rates if users are looking at a blank screen for the first 5 seconds wondering if the site is broken. A preloader simply lets them know that the site is indeed working and how much longer they have to wait.

    2. Most preloaders use vector graphics which are much more efficient than the bitmap images the browser is usually loading in the background.

    1. Yes they do help. Plus they often serve as an extra space for ads.
    2. They're not big. Look at this 4kb large one They have to be small enough to be loaded in the 1st frame
    From poco
  • Preloader shows the progress using the progress bar. Its usually needed since swfs are a little bit bigger and user will experience blank screen even if he is on a fast connection. But the prelaoder must be minimal. You use vector graphics to make them. Also you should show a determinate progress bar. (Means you should show how much percent its loaded, i.e there must be an indication of the progress).

    From jase21
  • Some look graphically "big" but under the hood they can sometimes pull it off at a relatively small filesize by using programmatic approaches to draw their shapes and create motion, just like you can easily create a very light preloader in your SWF file by putting some progress bar code like:

    var thickness:int = 30;
    var sWidth:Number = stage.stageWidth
    var sHeight:Number = stage.stageHeight
    var g:Graphics = root.graphics;
    g.clear();
    g.beginFill(0x0000ff, 1);
    g.drawRect(0, sHeight-thickness, sWidth * yourProgressPercent, thickness);
    g.endFill();
    

    Slip that in an ENTER_FRAME executing while your content is loading, provide the progress percentage variable, and that code shouldn't take any more than a kilobyte for ya (not tested, but assuming :P)

    From bigp