Dropbox install on Fedora 14

I started using Dropbox and couldn’t get it installed on my 64 bit fedora 14 machine.  I found the solution and am just reposting here to hopefully guide someone to it quicker than I was able to find it.

Here is the dropbox forum page with the information and description of the issue (the answer that worked for me is the last post, by P K.)

Here is the solution in case you have dropbox installed, it is not working, and you don’t want to go through the forum post:

execstack -c ~/.dropbox-dist/_ctypes.so

If you haven’t installed it yet, here’s how I did it:

  1. I downloaded the fedora rpm file from the dropbox site.  Get it here.
  2. I installed it using yum localinstall <packagename>.rpm.  This gave me “missing public key” error.  The solution here was to edit (as superuser) the /etc/yum.conf file and temporarily disable gpgcheck (ie, change gpgcheck=1 to gpgcheck=0).  Edit the file with something like sudo gedit /etc/yum.conf
  3. You can skip this step, unless you want to see the problem.   Once installed, run dropbox — either from the command line or the from the Application Launcher, under the Internet folder.  This says you have to run a daemon, press OK.  It says it is downloading and unpacking… and never finishes.
  4. Don’t forget to go back into /etc/yum.conf and reset gpgcheck=1
  5. In the terminal, type execstack -c ~/.dropbox-dist/_ctypes.so <enter>
  6. Now, run dropbox from either from the command line or the from the Application Launcher, under the Internet folder.
That’s it.  It is working for me.  I was using the Dolphin file explorer but dropbox installs into the Nautilus file explorer… so i’m using that now.  Dolphin crashed often for me anyway, so i was never really attached to it.

Great video and post on persisting

This is not a post on database persistence…

I really believe in learning from failing and persisting through problems to find solutions, whether it is fixing my house or making an HTML5 canvas scrollable.  I think it is one of my major strengths and the best way I learn.

Here are two links to articles I just read/watched this morning that I really enjoyed.  Hope you enjoy them, the video is 5 minutes.  Summary: Whatever you do, just do it.  Keep doing it and don’t stop.  You’ll keep getting better at it.

Ira Glass talks about how he started, and Seth Godin covers the topic of writer’s block.


Set up PhoneGap with Xcode 4(.0.2)

I had to set up PhoneGap on Xcode 4 yesterday and found many confusing, wrong, or just outdated pages describing how to do it.  I think they fixed some things in PhoneGap 1.0.0, so the install is much simpler than what these pages were saying.  So here is my version which worked for me:

  1. Download and install PhoneGap 1.0.0 on your mac.  Get it here.  This downloads a ZIP file.  Open it up and run the DMG file installation in the iOS directory.  The instructions I saw said to have Xcode closed at this point, which I did.
  2. Open Xcode and create your new PhoneGap project.  This will set up everything except the www directory.

    New Phonegap Project in Xcode

    New Phonegap Project in Xcode

  3. In Finder, navigate to your project (mine is in my home directory under ‘Xcode projects’).  Copy the www directory from <Macintosh HD>/Users/Shared/PhoneGap/Frameworks/PhoneGap.framework/ and paste it into your project in the same directory as the *.xcodeproj file (i.e., your project’s root directory)
  4. In Xcode, right click on the top-most project header (the blue-ish project header block that contains the entire project) and select “Add Files to <your project name>”.  Find and select the www directory that you just placed in your project, and make sure to change the “Folders” radio button to “Create folder references for any added folders”.  Press Add.  Your project should look like this:

    Final Project in Xcode

    Final Project in Xcode

That’s it.  Select the correct simlulator or iOS device scheme at the top of the project window (next to the RUN/STOP buttons), press RUN and the project should build and start up with the “PhoneGap works!” message.  Now you can continue doing whatever you were planning in the www directory.
UPDATE: there is a specific page for this on phone gap that I had not seen… go to it here.  There are still a lot of pages out there that have bad Xcode 4 info on them though!

Having one iframe watch for other iframes to load.

This is an issue that I thought was going to be straight forward using the jQuery ready function, but i could not get it to work.

The problem is simple: I want to watch a couple of iframes load and then do something once they are all done.

The “when they are all done” part is simple with jQuery Deferred objects.  A really good, quick tutorial on those is here.  Basically, I can pass however many Deferred objects I want to the jQuery.when( ... )  command.  When all of them “resolve” (i.e., when the are done doing whatever they need to do), the when command will continue with some “success” function or functions.  There are also options for when one or more Deferred objects fail, etc.  Read the tutorial… it’s good.  I created a javascript object that encapsulates the Deferred object and my method of resolving the object.  So I just needed to create one per frame I wanted to watch and feed them into the jQuery.when() function.

So for the “watch a couple of iframes” part I want to resolve my Deferred objects, instantiated in iframe A, based on iframes B, C, and D finishing loading.  I assumed this was a simple something like:

jQuery(top.B.document).ready( function() { ... resolve my deferred object ... } );

however, this did not work!  It did not matter that I put top.B.document (this is a path from top down to the frame, and then referencing the frames document), the call seemed to work on my local iframe’s document (iframe A in this example). I couldn’t find any information on this online, so if anyone knows more about it i’d love to hear it.

The solution:

I could have gone into each iframe and placed a document ready function that set a flag, and then read that flag from the iframe that is watching, but I wanted to keep this functionality clean and encapsulated in my object that was also handling the Deferred object.  I wanted to write it once — not X number of times.  Also, I know someone will mention “why are you using iframes at all?  use Ajax and blah blah blah”  I know, but you have to work with what you’re given sometimes… so i’m using iframes.

The solution I came up with is this (most of the Deferred object stuff is left out):

// Constructor
function MyIframeWatcherObject( contextPath ) {
...
// Get the path to the iframe we're watching.
this.contextPathToUse = contextPath || null;
...
{

MyIframeWatcherObject.prototype.resolveOnDOMloaded = function( ) {
	// Re-eval contextDocument each time because it is lost when page reloads.
	var contextDocument = document; //default
	try {
            if ( this.contextPathToUse )
		contextDocument = eval(this.contextPathToUse + '.document');
	} catch ( err ) {
		// Do nothing, use default as contextDocument as fallback for now..
                // Add error handling...
	}
	if ( contextDocument.readyState === 'complete' ) {
            deferredObject.resolve();
        } else {
            var self = this;
            setTimeout( MyIframeWatcherObject.prototype.resolveOnDOMloaded.call( self ), 100 );
        }

}

First, I resolve the contextPath that was passed in to get its document.  I do this each time because if I resolve it in the constructor and store it, I lose it if the page begins to reload again (it becomes undefined).  Then I check the readyState on the document and determine if I should resolve the Deferred object now, or set up another timer.  The setTimeout function is best here so that I am only setting up one more trigger each time and don’t have to worry about tracking it like I would with setInterval.  John Resig has a great tutorial on timers here – definitely a good read if you are not aware of how they function.

I’m not completely thrilled with this solution, but it works.  Please offer another way of doing it if you know one!

UPDATE: just an additional note. The document.readyState property looked like it was a cross-browser solution based on my quick google search — otherwise I would not have considered it. If you know differently, or know of bugs with this method, please let me know. Also, the opposite state of document.readyState == 'complete' is document.readyState == 'loading'.


Nice, simple tutorial on REST

I found a nice tutorial on REST by Dr. M Elkstein so i wanted to post it here:  http://rest.elkstein.org/


Follow

Get every new post delivered to your Inbox.