Sunday, January 29, 2017

How to Restart Web Server After Google App Engine Launcher Crash

  1. Open a terminal window.
  2. Copy and paste this: sudo lsof -i -n -P | grep TCP
  3. Take note of the process id (PID) currently listening on the port your app was running on (look for something that looks like: TCP 127.0.0.1:8080 (LISTEN)).
  4. Open Activity Monitor.
  5. Sort the processes list by PID.
  6. Kill the process matching the PID you noted in step 3.
  7. Restart your server from Google App Engine Launcher.
Thanks to irs8925 for providing the answer on Stack Overflow.

Saturday, March 08, 2014

Installing Phonegap plugins

Putting this example of installing Phonegap plugins here for myself as reference...

Example using Plugman (for Native workflow; entered from anywhere):
plugman install --platform ios --project ./Phonegap/ios/beepwatch2/platforms/ios --plugin org.apache.cordova.splashscreen

Example using Cordova (for Global workflow; entered from project folder):
cordova plugin add org.apache.cordova.inappbrowser

Saturday, August 24, 2013

Force Phoegap app to maintain focus and not go into background

This one actually took me a second to research and find the answer to. I was putting together a beeping stopwatch app for myself and wanted the app to remain in the foreground but, after about 60 seconds, the app kept going into the background.

Finally, I stumbled on a stackoverflow conversation. Without further ado...

Add the following line to your didFinishLaunchingWithOptions in AppDelegate:
[UIApplication sharedApplication].idleTimerDisabled = YES;


Wednesday, February 06, 2013

Add iAd to PhoneGap Application

This post derives from the SiteKickr Blog post "PhoneGap/Cordova and iAd integration." I got stuck in a couple of spots and decided to attempt to lend a little clarity for anyone else seeking a solution. I've also taken a couple of the comments from that post and integrated here.

1. Click on the "Project Navigator" icon in the left most panel in XCode.



2. Click on the top-most item in your hierarchy. 



3. Click on the Build Phases tab. 



4. Expand "Link Binary with Libraries."



5. Click the + icon to add the iAd.framework to your project.



6. In your App -> Classes folder, open up MainViewController.h, and drop in the following code after any existing #import statements but before @end:

 #import <iAd/iAd.h>
 @interface MainViewController : CDVViewController {  
   ADBannerView *adView;  
 }   



7. Open up MainViewController.m


8. In your viewDidUnload method, which should already exist, add:

 [adView release];   



9. In your webViewDidFinishLoad method, add the following just before: 
"return [super webViewDidFinishLoad:theWebView];"

   adView = [[ADBannerView alloc] initWithFrame:CGRectZero];  
   CGRect adFrame = adView.frame;  
   if([UIApplication sharedApplication].statusBarOrientation  
     == UIInterfaceOrientationPortrait  
     || [UIApplication sharedApplication].statusBarOrientation  
     == UIInterfaceOrientationPortraitUpsideDown) {  
     adView.currentContentSizeIdentifier =  
       ADBannerContentSizeIdentifierPortrait;  
     adFrame.origin.y = self.view.frame.size.height-adView.frame.size.height;  
   } else {  
     adView.currentContentSizeIdentifier =  
       ADBannerContentSizeIdentifierLandscape;  
     adFrame.size.width = adView.frame.size.width;  
     adFrame.origin.y = self.view.frame.size.width-adView.frame.size.height;  
   }  
   adView.frame = adFrame;  
   [self.view addSubview:adView];  


10. If you don't already have a willAnimateRotationToInterfaceOrientation method, add it, and drop in the following code:

   BOOL hide = (newInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || newInterfaceOrientation == UIInterfaceOrientationLandscapeRight);  
   [[UIApplication sharedApplication] setStatusBarHidden:hide withAnimation:UIStatusBarAnimationNone];  
   CGRect mainFrame = [[UIScreen mainScreen] applicationFrame];  
   [self.view setFrame:mainFrame];  
   if (newInterfaceOrientation != UIInterfaceOrientationLandscapeLeft && newInterfaceOrientation != UIInterfaceOrientationLandscapeRight) {  
     adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;  
     [self.view bringSubviewToFront:adView];  
     adView.frame = CGRectMake(0.0, self.view.frame.size.height - adView.frame.size.height, adView.frame.size.width, adView.frame.size.height);  
   }  
   else {  
     adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierLandscape;  
     [self.view bringSubviewToFront:adView];  
     adView.frame = CGRectMake(0.0, self.view.frame.size.width - adView.frame.size.height, adView.frame.size.width, adView.frame.size.height);  
   }  


A couple of points of note regarding ad placement:
- iAd is not like Adwords or Admob. Ad placement is not done in your HTML and does not use your javascript or CSS.

- By default, the ad will be placed on the bottom of your app's UI. To change the position of the ad, you'll need to edit all instances of the value of adFrame.origin.y to equal 0 (adFrame.origin.y=0).

- After you're done and ready to deploy, you'll need to enable iAd in your application through iConnect. Keep in mind you can only do this AFTER you upload your app.

  1. Log in to iTunes Connect
  2. Click on "Manage Your Applications"
  3. Click on the App you want to enable iAd on.
  4. Click on the blue "Set Up iAd Network" button.
  5. Follow the instructions.

That's it! Good luck.

UPDATE 03.06.2013: Check out this great response at StackOverflow regarding not showing the ad placeholder if an ad is not delivered: http://stackoverflow.com/a/14764349/2037540

UPDATE 04.17.2013: Brandon Hawkins has come up with a great solution to deal with the issue of the ad frame setting on top of the webview. Check it out here: http://hawkinbj.wordpress.com/2013/04/16/implement-iad-banner-ads-without-covering-uiwebview-in-phonegap/

Tuesday, November 27, 2012

Installing PIL on a Mac

After much torment, and many failures, PIL is now installed. And, it is embarrassing just how simple it ended up being. I'm leaving this here so when I move to my next dev box, I don't spend three days figuring out again.

At the time of this writing, I was running OSX 10.8.2 but I'm sure this will work on earlier versions and probably subsequent versions for some time.

1. Open Terminal
2. Type: sudo easy_install pip
3. Type: sudo pip install PIL

Thanks to klobucar at StackOverflow for his answer regarding installing PIP.


Saturday, November 03, 2012

Updates Posted to the Classic ASP VBScript OAuth Library

There's been a bit of drama over at the Classic ASP VBScript OAuth board regarding twitter's recent API URL changes.  All is well now as the project has been updated and a new example project zip uploaded.

Essentially, it boils down to some Constant URL changes in one of the files. You can read more about it and download the latest version at the Classic ASP VBScript OAuth site.

Tuesday, April 10, 2012

Delete all pyc files

Scenario: You've just pushed a slew of compiled python files 
Solution:
1. Terminal into your project directory
2. Enter: 'find . -type f -name "*.pyc" -delete;' (without the quotes)
3. Add a .gitignore file to the root of your project with '*.pyc' as its content
4. Re-push the project

Thursday, September 22, 2011

Google App Engine Localhost from Parallels


This post is for developers using a MAC, developing on the Google App Engine platform, attempting to connect to their development environment from Windows on Parallels to test browser compatibility.

NOTE: This post was updated on March 25th, 2013 to accommodate changes made to the GAE Python Development Server.

Again, you are:
1. Developing on a MAC.
2. Atop of Google App Engine
3. Using Parallels for browser testing

Setup:
1. On your MAC, open Google App Engine's Launcher application
2. Double click on the project you're attempting to connect to
3. In the "Extra Flags" field, enter "--host=0.0.0.0" (without the quotes) and hit the "Update" button.
4. Make sure the Windows firewall is OFF in your Parallels Windows instance.

That's it, open a browser in your Parallels Windows instance and hit the local network IP address of your MAC using the port delegation from Google App Engine launcher. For instance, if your MAC's IP address is 192.168.0.2, and your project's Google App Engine port is 8101, the address you put in your Parallels browser may be http://192.168.0.2:8101.

Voila.

Tuesday, August 23, 2011

Unsync/Remove Gmail Contacts from iPhone

Somehow you managed to get every single person you've ever emailed jammed into your iPhone right?

This solution assumes you have a Mac & an iPhone:
1. On your Mac, open "address book"
2. Click on File -> New Smart Group...
3. In Smart Group Name, type "iPhone Tmp"
4. In the first drop-down menu, select "Phone"
5. In the second drop-down menu, select "is set"
6. Click "OK"
7. Click File -> New Group
8. Name the group "iPhone Contacts"
9. Click on the "iPhone Tmp" group and drag all of the contacts from that group into "iPhone Contacts"
10. Plug your iPhone into your Mac and open iTunes.
11. Click on your phone listed in "Devices"
12. Click on the "Info" tab/button.
13. Check the "Sync Address Book Contacts" checkbox.
14. Check "Selected groups"
15. Check "iPhone Contacts"
16. Make sure nothing else on the page is checked.
17. Sync.
18. Be happy.

Saturday, July 10, 2010

Another transaction by user ... is already in progress for this app and major version.

Gotta love it when your app deployment tells you there was on error on your last attempt to deploy... 24 hours ago. WHAT!? Thanks for the heads up Google.

Recently got hit with "Another transaction by user ... is already in progress for this app and major version." during what I thought was going to be a quick update.

Thanks to John Ballinger for posting instructions.

1. Start -> Run -> cmd
2. cd into your application directory. For me, this is cd /Sites/appengine_myapp
3. appcfg.py --no_cookies --email=YOUR_EMAIL_HERE@gmail.com --passin rollback ./
4. You should be prompted for your password.

Nice.

Wednesday, June 23, 2010

Web SIte Performance: Optimal Page Structure Vs. Reality

Recently, I had the opportunity to talk about Steve Souders' web site performance work with some old friends. While attempting to hammer home the importance of the Souders' performance techniques, I failed to mention one VERY IMPORTANT thing...

It's NOT an all or nothing proposition.

Along with the ideal, there are two VERY important points that need to be conveyed:

1. Not ALL of the techniques need to be deployed at the same time in order to have an impact. Implementing just a few can have a dramatic effect. The more the merrier BUT, all or nothing is DEFINITELY NOT the goal.

2. The techniques are not biblical in stature. There are times when the ideal is simply incongruent with the required solution. For instance, the recipe for optimum performance and IDEAL page structure is:


  • 1 static HTML file

  • 1 css resource

  • 1 image resource

  • 1 js resource


Ideal Page Structure:

<html>
    <head>
        <!-- 1 css resource -->
        <link rel="stylesheet" href="[EXTERNAL_PATH]">
    </head>
    <body>
        <div id="container">
            <!-- begin content -->

            <!-- 1 image resource (to be used as sprite) -->
            <img src="[EXTERNAL_PATH]">

            <!-- end content -->
        </div>

        <!-- 1 js resource -->
        <script src="[EXTERNAL_PATH]"></script>

        <!-- embedded js if required -->
        <script language="javascript">
            your.thing = new your.constructor({
                name1: value1,
                name1: value2
            });
        </script>
    </body>
</html>



HOWEVER, while this may be the ideal, sometimes, you simply can't get down to a single resource request because of solution requirements. Case in point - if you need to add Google Analytics to your page, you're NOT going to hit the ideal - you're going to have more than 1 js resource.

So, in closing, the idea should always be to strive for the ideal and get as close as possible. Very simply put, taking 10 js requests down to 8 is a GREAT start. Don't skip it because you can't get 10 down to 1.

Monday, June 14, 2010

Apple likes my wife.

To date, I've built 3 iPhone Web Apps. None of them would be considered functionally unique or powerful by any stretch, HOWEVER... and it's a big HOWEVER... so far... ready for this?

Two out of the three have earned "Staff Pick" awards from Apple!

As much as I would like to take credit for being an absolute genius, it would appear that Apple has a thing... for my wife.

The two awarded iPhone Apps are "Mila's Tools", a simple Unit Conversion Calculator and "VeganMunch Kombucha Calculator" a simple Kombucha recipe calculator. Both are basically products of my wife, Mila.

The other App - Scott's Pinger, a simple web site monitor, of which I am very proud - got nothin'. Nada. Zilch. Zippo.

I guess I'll be asking Mila for more App ideas.

In the meantime, while waiting for Mila to tell me what App to build next, I decided to put a Mini-App of sorts together as a portal to all of my apps. The idea being, as I deploy new iPhone apps, they'll be listed in the portal app.

Check it out from your iPhone here: Scott's iPhone Web Apps. Don't forget to add it to your Home screen.

Back to the grind. Uhm... eh ehm... Mila? What am I building next?

Cannot Process Command: Internal Error.

*Knock, knock. knock.*

Apple? Hello? Apple?

Apple!

Is there anyone even home over at the Apple iPhone Web Apps site?

For the love of Pete already. After all of the hubub from Jobs about HTML 5, Safari 5, Web Apps, iPhone 4 and all of the other greatness spewing from the pores of Apple, you'd think maybe they'd have someone over there keeping an eye on the Web Apps site.

Intermittently, THE VAST MAJORITY of the web app links point to this lovely page:

Cannot Process Command: Internal Error.Cannot Process Command: Internal Error. I'm now having nightmares about this page! How many e-mails do I have to send!? How many forums need to be screaming!?

PLEASE... someone at APPLE... FIX THE DAMN LEAK. Oh... wait... wrong rant... Nevertheless!!! FIX IT ALREADY!

K. I feel better. Love you Apple. :)

If you're experiencing the same issue at Apple.com, please leave a comment below. A few more voices couldn't hurt.

Sunday, May 23, 2010

Add a mute button to your system tray

So you're working... jammmin' to some Zeppelin... and the phone rings. You then proceed to fumble around your systray with your volume control attempting to open it to mute. I'm not one to critique another UI engineer's flow but... DUDE! REALLY!? WHERE THE HELL IS THE DAMN MUTE BUTTON IN THE SYSTRAY!?

Get ready to go around your ass to get to your elbow. Ready?

1. Download NirCmd
2. Download BeTrayed!
3. Assuming you installed NirCmd in your Program Files directory, create a shortcut on your desktop to: "C:\Program Files\nircmd\nircmd.exe" mutesysvolume 2
4. Create a new txt document with the following as the body:

  C:
  cd C:\Program Files\JohnnyFoster.com\BeTrayed!
  start BeTrayed "C:\Program Files\nircmd\nircmd.exe" mutesysvolume 2
  Y:
  exit
  cls

5. Save the file as MUTE_SYSTRAY.cmd
6. Create a shortcut to MUTE_SYSTRAY.cmd in your Start -> All Programs -> Startup folder

Double click to toggle your sound.

Nice.

TODO: Find volume control UI designer. Yell.

Saturday, May 22, 2010

"Mila's Tools" on the Apple Web Apps homepage

Let me tell you something... if you've built yourself a simple iPhone Web App... and you'd like to get a few hundred users REAL QUICK... SUBMIT YOUR APP TO THE APPLE WEB APPS DIRECTORY. Run. Don't walk. Run to the Apple Web Apps site and do it now.

I about fell out of my chair after submitting my app late one night only to wake up to 100s of new users. Upon checking the directory, there it was... right on the Apple Web Apps home page as a "Staff Pick" - "Mila's Tools", my new iPhone Unit Conversion App.

Pure awesomeness, drenched in awesome juice.



Thursday, May 20, 2010

Error Number: 1413 (0x80070585)

PROBLEM: Immediately after installing Zend server, upon testing you are faced with:


FastCGI Error

The FastCGI Handler was unable to process the request.
Error Details:

Could not find entry for "php" on site 1 in [Types] section.
Error Number: 1413 (0x80070585).
Error Description: Invalid index.
HTTP Error 500 - Server Error.
Internet Information Services (IIS)


SOLUTION: Add the following to the end of C:\WINDOWS\system32\inetsrv\fcgiext.ini


[Types]
php=PHP

[PHP]
ExePath=C:\Program Files\Zend\ZendServer\bin\php-cgi.exe

EnvironmentVars=PHP_FCGI_MAX_REQUESTS:1000
IdleTimeout=1500
ActivityTimeout=3000
RequestTimeout=1500


Tuesday, May 18, 2010

REFACTORING: A day in the life

I put this video up months ago and just realized I never blogged about it! How'd that happen!? If you're an engineer, this butting-my-head-up-against-the-wall moment is for you.

So, without further ado... I bring to you... "Refactoring: A day in the life." [dat-do-do]



P.S. Turn up the volume. [Really. Turn it up.]

 

Sunday, May 16, 2010

iPhone Unit Conversion Calculator

So, I dove into jQuery and jQTouch development for the iPhone and all I know is, I can't wait to do it again.

Wow, wow, wow... talk about easy-peasy-Japanese. I could not have been more impressed. The functionality of the unit conversion calculator in-and-of-itself is nothing to write home about BUT, that which comes with employing jQuery + jQTouch most certainly is.

Wowsers. Yep. That's all I got. Wowsers.

The iPhone app includes four conversion calculators - a length converter, liquid converter, temperature converter, and time converter. From your iPhone, check out the converter here: iPhone Unit Conversion Calculator.

Don't forget to add it as a full screen app by hitting the + sign. :)

 

Sunday, May 02, 2010

Amazon API "Tags" Response Group

PROBLEM: Amazon API is not returning "Tags" even when "Tags" response group is specified in the request URL.

SOLUTION: Add the "Version" parameter to your request.

EXAMPLE: http://webservices.amazon.com/onca/xml?AWSAccessKeyId=...&Version=2009-10-01

For valid "Version" values, keep your eyes on the API's release notes.

NOTE: By default, the API will return the top 5 tags. To have more returned or to page through tags, check out the TagPage and TagsPerPage parameters in the ItemLookup documentation.