iOS 6 Autorotate Solution

When Apple moved from iOS 5 to iOS 6, they changed the way developers must handle autorotation in their apps. 

Basically, it isn't too bad, as it should just work automatically.  But, I ended up struggling for hours without success, until I came upon this helpful website with a small, almost throw-away piece of advice:

In your AppDelegate class, in the application: didFinishLaunchingWithOptions method, you might have a line like this:

[window addSubview:viewController.view];

This is especially likely if you are updating an app from iOS 5 or below.

This line will actually prevent autorotation from working in iOS 6!  Change it to this:

window.rootViewController = tabBarController;
// (or set to whatever navController you might be using)

So, to reiterate, I spent hours and hours pulling my hair out, when it turns out I needed to change one line of code, in an area of the app which seems to have nothing to do with autorotation at all.  Thanks Apple!

FlightPath - Academic advising and degree audit software

The university where I work just officially open-sourced a piece of software which I helped create and currently maintain.  It's called FlightPath-- it's an electronic advising and degree audit system for universities, community colleges, technical colleges, etc.

 fpscreen1-edit_300.jpgAs I said, it's been released as open source, under the GNU GLP license (the same license as many other open source projects).  Programmed in PHP/MySQL, it is designed to let students and advisors track a student's progress through their degree.  The system even lets them try out other majors, to see how their credits would fit in.

If you are interested, there is a live demo of FlightPath available.

So please, give it a try!

Location:  http://getflightpath.com

 

Symlinks in Windows 7/Vista

Did you know you can create a symlink in Windows 7/Vista just like in Linux?  If you don't know what that is, imagine a directory somewhere which is actually displaying the contents of another directory, maybe on an entirely different hard drive.

The command needs to be run from the command line, and looks like this:

MKLINK [options] link target
Example:  MKLINK /J data "C:\Dropbox\MySQL Folder\data"

See this site for more details.

This feature is great because you can "trick" Windows into thinking any folder or file is actually somewhere else.  For example, let's say you have a game which always saves its files to "C:\game\saved".  Let's say you want that to be on another hard drive, or in Dropbox.  Well, with a symlink, that can be the case, and the game is none the wiser.

This feature is also great for server environments. For example, let's say you want to keep multiple installations of MySQL in sync, across multiple computers. Ex: between work and home. (I have this exact problem with projects run through xampp).

What I have learned to do is have the MySQL data directory in my Dropbox, and just create a symlink in my c:\xampp\mysql folder to the Dropbox folder, and presto!  Xampp doesn't know there's anything fishy going on with the servers, yet I can keep my MysQL databases in sync across multiple computers with the help of Dropbox.

Make Any Keyboard a Multi-Media Keyboard

Are you stuck with a boring plain-Jane keyboard, with no volume controls or Prev/Next buttons?  Well, have no fear-- you can redefine some of those F-keys you never use to take on the task.

250px-QWERTY_keyboard.jpgWhat you'll need is a simple program called KeyTweak.  It lets you "remap" one key to any other key.  The program isn't the easiest one to use, but I found it worked well for me.  The only limitation I found was that it can't remap the Pause-Break button.

Here's my personal remapping:

  • F9 = Volume down
  • F10 = Volume up
  • F11 = Previous Track
  • F12 = Next Track
  • Scroll Lock = Play/Pause

There's actually a bunch of options for what you can remap a key to, like starting your web browser, Calc, mail, etc.

Enjoy at your own risk!

psBackup - Super-Simple File and Web Backups

This is going to be slightly shameless self-promotion, but here goes.

Do you need a simple way to backup important files on your computer? 

mainwindow-demo-profile.pngSay you want run a backup every night of your music, documents, dropbox, etc, to an external hard drive.  And, let's say, automatically delete old backups so you only ever keep 30 days worth.

Well, that's exactly what my latest program, psBackup, can do.  It can also download a file from your web server every night too--  I use it with my module Daily Site Backup.

Runs on Windows, Mac, and Linux/Unix.  You can try it out with the trial version, and if you want to buy it, it's only $4.99.  C'mon, support an independent developer ;)

Give it a try and tell me what you think!

Thanks,

Richard

Java Associative Array (Sort Of)

Attached File(s): 

Ever wish that Java had associative arrays (aka assoc arrays) like in PHP?  As in, $x["name"] = "Bill" ?  Well, I created a helper class for Java which comes close to approximating it.  It can even loop through it similar to foreach().

ipad-java.jpgI call the class PseudoAssocArray, because it actually uses a HashMap to do the behind the scenes work. 

Simply include the file attached at the top of the page in your project, then use it like so:

PseudoAssocArray temp = new PseudoAssocArray(1);
temp.put("name", "April");
temp.put("age", "26");
// ...
String n = temp.get("name");

You can even make it be 2 dimensional by supplying a 2 in the constructor.  For example:

PseudoAssocArray temp = new PseudoAssocArray(2);
temp.put(0, "name", "April");
temp.put(1, "name", "Samuel");
// ...
String n = temp.get("1", "name");

Loop through like so:

temp.resetCounter(); //always do this first
while (temp.hasMore()) {
  Object obj = temp.getNext();
  // or: String s = (String) temp.getNext();
}

To loop through and get both key and value, try this:

temp.resetCounter();
while (temp.hasMore()) {
  Map<String, Object> entry = temp.getNextMap();
  String key = (String) entry.get("key");
  String value = (String) entry.get("value");
}

Enjoy!

 


Software License Fine Print

Creative Commons LicenseThis code is licensed as-is, with no warranty or guarantee, under a Creative Commons Attribution 3.0 Unported License.

You may use this code however you want, even in commercial products, but only if you include attribution to me, Richard Peacock, as the original author of this small portion of code, but not in a way that implies I endorse your project.

For example, on a Help/Credits screen:  Portions of this project were based on work freely obtained from these developers: Richard Peacock (http://richardpeacock.com), NAME HERE, etc.  These outside developers neither endorse nor support this software.

If you use this code, feel free to email me to let me know!  I'll include a link to your project here.

Easy to Remember, Yet Unique, Passwords

So we all know we're supposed to have a different password for every site we go to, but of course no one does that.  Instead you end up using the same password for everything because its easier to remember.  The problems occur when your favorite website, knittin-for-kittens.org, gets hacked and your password stolen, and its the same password you use for your bank account.

password.jpgWhat you need is a password scheme that lets you use a different password for every site you go to, so even if one gets stolen, it won't comproise all your other sites.

Here's the system I use:

Chose a random, nonsense "base" with both numbers and letters. Include at least one capital letter.  For example:  zh2Ms
This is just something you will have to dedicate to memory.  If you base it on a phrase, that can help.  Example: zebra have 2 Many stripes = zh2Ms

Next, add on the name of the site or service you are using.  For example...

gmail:         zh2Msgmail
facebook:   zh2Msfacebook
bank:          zh2Msbank

and so on.  Now you have unique passwords for every site you use, but you will always be able to remember them.

PS:  for the best security, you should really be using lastpass!  It's wonderful and free.
 

Amazon.com - The Best Place to Buy Computer Cables, Convertors, Etc

Amazon.com has quickly become my favorite, secret spot to buy things like spare USB extension cables, iPod cables, USB convertors, HDMI cables & convertors, and so on.

amazon_logo1.jpgI used to use sites like Newegg.com, and that's a great site too, but you just can't beat the prices on Amazon.com.  And no, I'm not being paid anything or getting any kind of reward for sending people their way.

I'll give you an example from a recent purchase I made.  This is a DVI to HDMI convertor.  You can use it to connect your PC to a TV, so you can use your nice big TV as a monitor:

dvi_hdmi_convertor.jpg

At BestBuy, a similar convertor costs $30.  At Amazon, it costs less than $3 with free shipping.

Speaking of HDMI, a 3 foot standard HDMI cable costs about $4 on Newegg, with free shipping.  On Amazon it's less than $2, free shipping.  And from a store it can be as much as $20 - $50!

iphone_cable.jpgApple iPhone cables-- at Target they're $20.  At Amazon they're as low as $1, free shipping.

The examples go on and on.  For the most part, any cable or convertor I've ever looked for has been cheaper on Amazon than anywhere else, though, there is a little bit of a secret to the ordering process.

I usually don't just click "add to cart" from the main page.  I usually click on the "XX new from $xx" link at the top of the page, and look at all of the available sellers.

Make sure you order from a seller in the US (or whatever country is closest to you).  Some of the really cheap ones come from Hong Kong, and take literally 18 - 30 days to come in!  I've had this happen to me before. 

So when you order, spend the extra $0.50 and go with a closer seller.

Draw a Box Around a Coordinate In Google Maps Based on Miles or Kilometers

Attached File(s): 

This post explains how, given latitude and longitude coordinates in Google Maps (specifically, in the Static API), how one can draw a bounding box around them, based on a distance in either miles or kilometers.

gmap_bounding.pngLet's say you already know the lat/long of a particular point on the map, and now you want to draw a box around it, or maybe you just need to know the lat/long coordinates of another point, so many km or miles away?  Well, this is the script for you!

Based on a script retrieved from here:
http://www.sitepoint.com/forums/showthread.php?656315-adding-distance-gps-coordinates-get-bounding-box

The trick is that Google Maps wants you to provide it with the lat/long coordinates for each corner of the box.  After several hours of searching, I finally found a script which I was able to modify to give me what I needed.

Simply download the script linked at the top of the page, and then use the following code to create the image you see here. 

Enjoy!


    $lat = -33.872986011907216;
    $lng = 150.90904516601563;

    // Create the static map api image.
    $static_maps_url = "http://maps.googleapis.com/maps/api/staticmap";
    $static_maps_url .= "?center=$lat,$lng";
    $static_maps_url .= "&zoom=15";
    $static_maps_url .= "&size=300x300";
    $static_maps_url .= "&maptype=roadmap";
    $static_maps_url .= "&sensor=false";
    $static_maps_url .= "&markers=color:blue|$lat,$lng";

    // Figure out the corners of a box surrounding our lat/lng.
    $d = 0.3;  // distance
    $path_top_right = bpot_getDueCoords($lat, $lng, 45, $d);
    $path_bottom_right = bpot_getDueCoords($lat, $lng, 135, $d);
    $path_bottom_left = bpot_getDueCoords($lat, $lng, 225, $d);
    $path_top_left = bpot_getDueCoords($lat, $lng, 315, $d);
   
    $static_maps_url .= "&path=color:334433|weight:5|fillcolor:0xFFFF0033|";
    $static_maps_url .= "$path_top_left|$path_top_right|$path_bottom_right|";
    $static_maps_url .= "$path_bottom_left|$path_top_left";
     
    // Now, draw the image from Google Maps API!
    print "<img src='$static_maps_url'>";


 

 


Software License Fine Print

Creative Commons LicenseThis code is licensed as-is, with no warranty or guarantee, under a Creative Commons Attribution 3.0 Unported License.

You may use this code however you want, even in commercial products, but only if you include attribution to me, Richard Peacock, as the original author of this small portion of code, but not in a way that implies I endorse your project.

For example, on a Help/Credits screen:  Portions of this project were based on work freely obtained from these developers: Richard Peacock (http://richardpeacock.com), NAME HERE, etc.  These outside developers neither endorse nor support this software.

If you use this code, feel free to email me to let me know!  I'll include a link to your project here.

Encode Any String to Only Alphanumeric Chars - Better Than URLEncode

Have you ever been faced with a situation where you need to encode a string with all sorts of problem characters into a URL-safe string, but, for whatever reason, urlencode() just won't do the job? 

What you need is a function that will give you nothing but numbers and letters-- no %'s or &'s, spaces, or any other non-alphanumeric character.

Well, look no further that PHP's bin2hex() function, and its pack() function.

It can convert this tricky string:

(!X>4Ob=h/&hN\'

Into this much nicer string, which can easily pass through a URL, MySQL query, XML tags, etc, since it is guaranteed to only ever be letters and numbers:

2821583e344f623d682f26684e5c27

And then decoding is a snap.  Here are the functions you need:

function hex_encode($input) {
  return bin2hex($input);
}

function hex_decode($input) {
  return pack("H*", $input);
}

Enoy!

Syndicate content