Cow Tipping Updates

I decided to put a few hours into my very first Android app, Cow Tipping, over the weekend (originally released 8/1/2011).  If you haven't seen it before, the gameplay consists of tapping on cows repeatedly to make them tip over, trying to tip as many as you can in 20 seconds.  It was a pretty fun first-timer project for me, and since pushing out a bug-patched version 2 last fall, it has now gone untouched for 13 months. After getting familiar with my old code again (which included a lot of "huhs" and "why in the worlds"... n00b mistakes), I started getting pretty excited again.  Believe it or not, Cow Tipping has averaged about 1000 downloads a month since its release, totaling nearly 14,000 total downloads today.   While the app itself doesn't provide much value to anyone, really, and only sits at about 1700 active installs, I started to imagine the possibilities if I invested some time into adding new modes of gameplay or some system of levels.

Screen Shot 2012-10-16 at 9.00.47 AM

Screen Shot 2012-10-16 at 9.00.47 AM

I decided to give it a test run by adding a "Frenzy Mode" in addition to the classic gameplay.  In frenzy mode, cows tip over with a single click, as opposed to the variable number of clicks in the original release (random number between 2 and 5).  Took me about 5 hours to clean things up, add the new gameplay mode, update the high scores screen, and add a Twitter share.  I pushed out the update Monday night at about 7 PM and noticed it live at 9 PM. If it goes well then maybe it'll be worth adding more levels.

Get Cow Tipping on Google Play!

Defending Google

A friend recently posted an article to the Information System forum community that makes the claim that Google Search is only 18.5% Search, citing the following screenshot. See full article.

serp2

To which I respond that I'm going to side with Google here.  For one, that article seems to imply that the remaining 81.5% of the page is filled with irrelevant ad-related content for Google.  Classic example of using favorable "statistics" to prove a point, right?  Quite a bit of the page is taken by white space, menus, and links relating to other google services.  I agree that the author has a point, but to accurately compare the two it seems like search results real estate vs. ad real estate should be compared, not total screen space.  His screen shot also only shows the view from a single monitor.  On my 16:9 screen (I'm guessing his is 4:3) there is much more empty, negative space that makes the page feel balanced and keeps the ads from dominating.  Seems very relative.

My personal opinion is that if you don't like the way a free service supports its business (e.g. ads, soliciting donations, other), then don't use the service.   I feel like free, ad-supported services are a great business model in certain markets and tend to roll my eyes internally when I hear rants about Facebook ads, wikipedia donation requests, and even the less-obtrusive google Adwords.  My brother worked on the bing digital advertising team at Microsoft for a few years, so maybe he rubbed off on me, but I have no problem with a few ads in my search results.  These companies work long and hard to serve up relevant ads that are at best something helpful you could use or are interested in and at worst something you can easily skip over.

The iPhone 5 - What's Missing?

iphone-5-white-black-back-featured-360x360.jpeg

The iPhone 5 looks awesome.  Some very exciting enhancements. My wife got hers the first day they shipped and loves it.  But for me, I have to admit I feel like it's more of the same.  The new screen size is exciting, and I'm really glad they decided go bigger, but aside from that just about everything was "expected."  Don't get me wrong, I don't think they need to go and reinvent the best-selling product in the world every year, and I really don't mean to disrespect the iPhone, because I am convinced it will be an enormous success, but personally I'm not yet convinced that this is my new phone.  Not that I buy into the Android argument that this and that feature have been on Android for months or years, because I do think Apple does a fantastic job of taking existing technology and integrating it in ways that are much more intuitive and user friendly.  Maybe it's just the buzz surrounding the iPhone is wearing off for me.  In any case I'm looking forward to all the new phones coming out this fall. Particularly hoping to test out the Lumia 920, HTC 8X, and hopefully a new Google branded Nexus device in the next 2 months.

Back Online

success_kid2.png

The good news is I was able to restore 99% of my content thanks to Webhosting Pad's automated backup service.  After getting infected with malware many moons ago I thought all hope was lost for a time.  

Webhosting Pad came to my rescue by delivering to me a very recent database backup from the time of the attack and by wiping everything out so I could start clean again.  Some phpMyAdmin magic and a little TLC later and voila, we're back.  It looks like all my old images are now deadlinked, but hey, it could be worse.

Tidy JSON Formatting with TextWrangler

This script can be used to format JSON. Place the script in your TextWrangler Text Filters folder. For me the path was /Library/Application Support/TextWrangler/Text Filters. You can name the script whatever you want, just make sure to give it a .py extension. I called mine TidyJSON.py.

#!/usr/bin/python

import fileinput
import json

if name == "main":
jsonStr = ''
for aline in fileinput.input():
jsonStr = jsonStr + ' ' + aline.strip()
jsonObj = json.loads(jsonStr)
print json.dumps(jsonObj, sort_keys=True, indent=2)

After saving the file, restart TextWrangler and go to Text -> Apply Text Filter -> TidyJSON. Your garbage-looking JSON will look like a million bucks!

Twitter Share - Android

Been working on a twitter share using the ACTION_SEND intent rather than the more cumbersome Twitter APIs. [css]

// Call find twitter client to get the twitter clients to post to 
Intent shareIntent = findTwitterClient();
shareIntent.putExtra(Intent.EXTRA_TEXT, "test");
startActivity(Intent.createChooser(shareIntent, "Share"));

findTwitterClient will call this method, which will search the phone for various Twitter clients, and launch the tweet through the first client it successfully matches:

public Intent findTwitterClient() {
final String[] twitterApps = {
// package // name - nb installs (thousands)
"com.twitter.android", // official - 10 000
"com.twidroid", // twidroid - 5 000
"com.handmark.tweetcaster", // Tweecaster - 5 000
"com.thedeck.android" }; // TweetDeck - 5 000 };
Intent tweetIntent = new Intent();
tweetIntent.setType("text/plain");
final PackageManager packageManager = getPackageManager();
List<ResolveInfo> list = packageManager.queryIntentActivities(
tweetIntent, PackageManager.MATCH_DEFAULT_ONLY);

for (int i = 0; i < twitterApps.length; i++) {
for (ResolveInfo resolveInfo : list) {
String p = resolveInfo.activityInfo.packageName;
if (p != null && p.startsWith(twitterApps[i])) {
tweetIntent.setPackage(p);
return tweetIntent;
}
}
}
return null;
}

Changing the default page when you open a new tab in Firefox

I've been super frustrated with firefox lately because somehow my default page when you open a new tab got changed from blank to a bing search.  Can't tell you how annoying this is when I'm used to a quick ctrl+t, ctrl+v to get where I want to go.  And the worst part is there's nowhere to change it when you go to the firefox options! It turns out the perpetrator is Microsoft (of COURSE) and that I somehow installed an extension that was doing it.  I'm still mad at firefox.

To disable the madness you need to restart firefox in safe mode: Firefox -> Help -> Restart Firefox with Add-ons Disabled.  Wait for it to restart, then select Disable all add-ons and whatever else you want to select.

Hit Make Changes and Restart and you should be all set.  No more pesky bing search stealing the cursor location.

Use LogCat to Debug for Android

To use LogCat you need to import the Log library in the java code import android.util.Log;

Then, where you would normally print something, replace “System.out.println(“HERE”);” with:

Log.d(“LOGCAT”, “HERE”);

Now when you run your app on the emulator or a device it'll print out to logcat, which can be viewed right in Eclipse (might need to go to Tools and click LogCat or something similar) or in the terminal in the directory where the android sdk has been installed, in the <sdk>/platform-tools/ folder.

Run adb logcat from that directory location to view the logs.

This prints out a log of everything that's happening, so if it's on the phone there's probably going to be a lot of stuff going on continuously, which is why it's helpful to use good tags so you can just browse or search for "LOGCAT" and you'll find what you're looking for.

Geotagging

  I read an article this week titled Could Geotagging Pose a Threat to Your Security.  I felt like it was a relevant topic to data communications and general tech because geotagging is essentially using a smartphone's GPS features to tag the latitude and longitude of the pictures that are taken.  This significant advancement in data communications is an incredible tool and creates a wide array of creative possibilities with the geologically tagged images.  However, it also poses some serious security threats.

The article contains comments from several officials that explains why geotags can be so dangerous.   "Geotagging can be dangerous when you don't intend to share that information with someone else, when someone else has a vested interest in knowing what that location is of the picture you took," says Jeremiah Johnson of the National White Collar Crime Center.  This poses a major threat, because predators can potentially analyze your photos off your blog, website, or social network and use the embedded geotag to identify the exact locations of some of your most routine daily tasks.  And worse yet, your children's common locations.  The article concludes by referring to a video on several ways to disable geotags on your smart phone.

I see the ability to geographically tag my images as a wonderful tool that, as with all technology, with proper use within well-established boundaries, can be a great way to manage and collect your digital media.  My personal decision (and recommendation) is to use geotagging in all cases on my phone, but from here on out the change I will make is that I will remove the geotag information before posting any potentially "private" images on the Internet.

I feel like there are too many advantages of this technology to do something drastic like shut it off completely.  I loved being able to see all my photos by location on a map on my iPhone.  Without geotagging that wouldn't be possible.

Years down the road, I'd like to be able to take a look at my personal history by looking at a map and seeing collections of pictures in all the locations I’ve lived or traveled.  What amazing technology!  Sure, you could manually specify the location of each photo, but if we're talking hundreds or thousands of pictures, the geotag is such a innovative (and creative) feature that enables wonderful creativity.

As with any technology, we must make sure we understand the technology and approach it correctly.  Similar skepticism at the risks of new technologies occurred with AOL instant messenger and other messaging clients that came out 10-15 years ago.  Look at the widespread use of these technologies today... where would we be without them!  Geotagging must be handled safely and responsibly, and it can be an incredible tool that takes advantage of years of technological innovation in computer hardware and data communications!

Using PHP and LDAP to Authenticate Against BYU's Servers

Been working on a BYU project at the law school where I only want to let BYU students post on a message board.  I needed an authentication solution and decided to give LDAP a try since I've heard it's relatively simple.  Here's the two step process: 1) Create a form that accepts a username and password as follows.

<form action=login.php method=post name=Auth>

Please log in using your NetID and password:<p>

<table cellspacing=3 cellpadding=3> <tr> <td>Username: </td> <td><input type=text name=username size=16 maxlength=15></td> </tr> <tr> <td>Password: </td> <td><input type=password name=password size=16 maxlength=15></td> </tr> <tr> <td colspan=2><input type=submit value=Authenticate style='width:100'></td> </tr> </table> </form>

 2) Create a login.php file.  This file accepts the username and password from the form, then connects to BYU's LDAP server (ldap://ldap.byu.edu - port 389).  After connecting, it binds the connection using the username (NetID) and if successful returns true.  Below, the authenticate function is called and if successful sets the 'loggedin' session variable to 'true' (not a boolean).  It then redirects back to the previous page, which, in this example is the message board I'm working on.

<head> <?php session_start(); ?> </head>

<?php

echo "test"; echo "</br>";

// get username and password from form $username = $_POST['username']; $password = $_POST['password'];

/* * checks the credentials against the LDAP server * $user - RouteY * $pass - password */ function authenticate($user,$pass){

echo "</br>"; echo "Authenticating..." . $user;

// prevents guest account access if($pass == ""){ return false; }

try{

$Yldap_location = "ldap://ldap.byu.edu"; $ldap_port = 389;

// call the ldap connect function $Ydatabase = ldap_connect($Yldap_location, $ldap_port);

// bind the connection $good = @ldap_bind($Ydatabase, "uid=".$user.",ou=People,o=BYU.edu", $pass);

if($good){ // valid credentials return true; } else{ // invalid credentials return false; }

} catch(Exception $e){ return false; } }

// call authenticate function if(authenticate($username,$password)){

// authenticate successful echo "</br>"; echo "SUCCESS";

// set session $_SESSION['loggedin'] = 'true';

// redirect echo $_SESSION['loggedin']; $url = "http://www.law2.byu.edu/page/messageboard.php"; //$url = "http://www.law2.byu.edu/page/messageboard.php"; header("Location: ".$url); } else{

// authenticate fails echo "</br>"; echo "FAIL";

// redirect to login header("Location: http://www.law2.byu.edu/page/messageboard.php"); } ?>

java.util.Date to java.sql.Date conversion error

For a database project (building a full retail store system) I've tried passing a java.util.Date to a Java prepared statement.  The problem is that the prepared statement expects java.sql.date, and converting it isn't working for me.  Here's the errant code: ps.setDate(2, emp.getDate()); which results in this error: no suitable constructor found for Date(java.util.Date) constructor java.sql.Date.Date(long) is not applicable (actual argument java.util.Date cannot be converted to long by method invocation conversion) constructor java.sql.Date.Date(int,int,int) is not applicable (actual and formal argument lists differ in length) The fix is to create an SQL Date using the java.util.Date as follows: java.sql.Date sqlDate = new java.sql.Date(emp.getDate().getTime()); Then, the prepared statement accepts the date. ps.setDate(2, sqlDate);

Super Wi-Fi - The Dawn of a New Era

Vocab Lesson to start - SUPER WI-FI - Super Wi-Fi is essentially Wi-Fi as we already know it, but on a new, unused block of unlicensed spectrum (thanks FCC!).  This spectrum ranges from 50 MHz to 700 MHz and is at a much lower frequency than Wi-Fi is now, which will allow for better travel of data signals. I recently read on article on Super Wi-Fi.  The article makes some great points about Super Wi-Fi, which is supposedly the direction we're all heading.  Should it pan out, Americans will have the ability to get Wi-Fi access all across town, or campus, or park, or whatever it may be.  This makes me think of two futuristic possibilities: (1) the possibility of every human being having some kind of ever-connected bracelet, or ring, or even chip in them and (2) the fall of cell phone providers.

The article begins by shedding light on the first "Super Wi-Fi" network in Wilmington, North Carolina. With the first efforts relatively successful, are we ready to move everyone over to "Super Wi-Fi"? Not so fast, the article argues. "New Hanover County IT Director Leslie Chaney says that the network is being used primarily as backhaul technology for the time being and won't be available for residential subscribers in the county for at least a year."

The article goes on to describe some of the problems that Super Wi-Fi will still need to overcome. Some of the problems include establishing network standards that have yet to be worked out and mass-producing chipsets that will work on the spectrum. Overall though, Super Wi-Fi is impressive. Having taken advantage of unused TV frequencies, Super Wi-Fi is at an overall lower frequency, which means less interference from rain and walls. The county estimates that the networks will be ready for Super Wi-Fi in a year, and the country will be ready in 2-3 years.

The first impact mentioned has to do with monitoring human life.  I was telling my wife last week that I thought embedded heart-rate, temperature, and other health/performance measuring sensors in the everyday wedding ring will be an amazing technology in the future (and that we should build it).  With Wi-Fi access anywhere, and data-to-Wi-Fi transmitting chips embedded on small items such as a camera's SD card, I have to wonder when this technology will become an every day part of human life for health monitoring.  Sure, there's still years of technology and scores of legal issues to get through, but we're moving that direction.

The second, and more pressing issue is what to do with cell-phone carriers once Wi-Fi becomes commonplace.  Think of the impact nationwide Wi-Fi (are we really that far away from it?) will have.  I've already thought of ditching my phone's phone plan, data plan, and text messaging plan and using a free service like google voice, skype, heytell, facebook messenger or some combination of those as my replacement for AT&T.  What will happen when we realize that we don't need to pay AT&T for their text messaging data (thank you WiFi), "data" data (thank you WiFi), and even cellular phone data.  With Google being one of the first to venture into providing these services, I see a whole need business model with google creeping in, charging 10 bucks a month for all the above, and the whole U.S. flocking to Google Voice.  Because seriously, why I am pay $100/month for AT&T when I can get the same data using my home/school/work Wi-Fi and soon enough... Super Wi-Fi.

For these, and many other reasons, I think Super Wi-Fi will have an enormous impact on the world.

Protest SOPA on your Website (JavaScript)

Join hundreds of thousands in protesting SOPA and PIPA by writing to your congressmen, telling them how you feel about these bills.  To take it a step further and join in the #blackoutSOPA cause, paste this handy javascript into the <head> tags of your webpage or blog.  It will 'blackout' your website for January 18th only, redirecting users to sopastrike.com

<script type="text/javascript"> var a=new Date,b=a.getUTCHours(); if(0==a.getUTCMonth()&&2012==a.getUTCFullYear()&&((18==a.getUTCDate()&&13<=b)||(19==a.getUTCDate()&&0>=b)))window.location="http://sopastrike.com/strike"; </script>

Stop SOPA & PIPA

To my congressman, Jason Chaffetz, representing Utah's Third District, I oppose SOPA and PIPA. Please do not support these misguided proposals for combating online piracy. I am a web developer and mobile app developer and businesses like the one I started will be severely threatened by SOPA and PIPA. This is not freedom and liberty, it is an unjust proposal to a web-related problem. This issue must be reassessed and readdressed with greater sensitivity to freedom of speech, due process of law, and business and technological innovation.

Kyle Clegg

Android Thoughts

Recently a friend decided to upgrade from an Android device to an iPhone 4s. I commented on her facebook post:

You're crossing to the dark side??

Kyle youll be back to the dark side iphone is taking over the world!!!! and i want to be on team apple when that happens.

Touche. can't argue. iphone is by far the best. Android is decent but given iOS and apple hardware as an alternative it's almost a no brainer. unless windows phone 8 makes a splash...

Someone else chimes in:

Almost a no-brainer... but not quite. Compared to budget Android devices, the iPhone is definitely superior. But there is literally no hardware spec on the iPhone that isn't matched or beaten by higher end Androids. If you favor features over price point, it comes down to preference, not superiority. The user experience on Android 4.0 is absolutely amazing, and the open source nature of Android puts it light years ahead of iOS in terms of development opportunities.

Again, it's about preference. iOS is clean, simple, and beautiful. Android is powerful, customizable, and versatile. It's all about what you're looking for in a phone. But let us be wary of granting to Apple some of these unearned superlatives.

My latest thoughts on Android:

I haven't used Android 4.0, but given the improvements between 2.2, 2.3, 3.0, and similarly positive and 'groundbreaking' reviews for 4.0, I can't imagine it being something I get too excited about. I switched from an iPhone 4 to Android (dual core Motorola Atrix) for many of the reasons listed but have ultimately been let down.

Google delivers power, customizability, and a sense of freedom on Android devices, however I find the power comes with some catches - weak battery life, unexpected FCs, laggy display (WHY?? the Atrix's processor should kill the iphone 4). The customization options are confusing and inconsistent across different hardware makers. Even having developed two Android apps, I haven't seen (or maybe just haven't utilized) any features that I feel are compelling. Lastly, the freedom I feel due to the open source nature of Android is refreshing, but honestly, I'd be fine giving up this flexibility for a superior WP7 or iOS device.

To me, bottom line is the Android ecosystem is discombobulated and inconsistent. It's a decent OS and beats any feature phone on the market, but having seen both Android and iOS up close and personal, I'm ready to switch back to iOS or try something new in WP7/WP8.