Using adb to play a game for you on an Android device.

May 17th, 2012 by joey | No Comments | Filed in Uncategorized

I recently flashed my Kindle Fire with the latest CyanogenMod 9 image using the awesome Kindle Fire Utility.  This put Android Ice Cream Sandwhich on my Kindle Fire.

I play a game “Defender II” which is a lot of fun.  But, you have to play it ALOT to level up and upgrade all your weapons.  (Which takes a LONG time).

I knew about Androids Debug Bridge which you use to root most android devices.  And so I did a quick google search to see if you could simulate touches on the screen with it.

YOU CAN!  So, I wrote a little php page that uses some javascript, jQuery, and ajax to send the right inputs to my kindle fire to play the game for me.  It doesn’t do any reading from the device, just screen touches, so it obviously doesn’t play the game very well.  But, it provides me with Defender II cash, and experience points every time it plays for me.  So, if I let it run for a few days, I should be able to get the next 75000 point Multi Arrow upgrade!



While somewhat of a useless excercise I did learn alot about the adb  and a little more bout Android.

The code to do this yourself is below:

(send_input.php)

<?php
if (!empty($_GET['action'])) {
    $commands = array();
    if ($_GET['action'] == 'click') {
        //Up
        $commands[] = "sendevent /dev/input/event1 3 48 0";
        $commands[] = "sendevent /dev/input/event1 0 2 0";
        $commands[] = "sendevent /dev/input/event1 0 0 0";

        //Down
        $commands[] = "sendevent /dev/input/event1 3 57 0";
        $commands[] = "sendevent /dev/input/event1 3 53 " . $_GET['y'];
        $commands[] = "sendevent /dev/input/event1 3 54 " . $_GET['x'];
        $commands[] = "sendevent /dev/input/event1 3 48 1";
        $commands[] = "sendevent /dev/input/event1 0 2 0";
        $commands[] = "sendevent /dev/input/event1 0 0 0";

        //Up
        $commands[] = "sendevent /dev/input/event1 3 48 0";
        $commands[] = "sendevent /dev/input/event1 0 2 0";
        $commands[] = "sendevent /dev/input/event1 0 0 0";
    } elseif ($_GET['action'] == 'move') {
        $commands[] = "sendevent /dev/input/event1 3 57 0";
        $commands[] = "sendevent /dev/input/event1 3 53 " . $_GET['y'];
        $commands[] = "sendevent /dev/input/event1 3 54 " . $_GET['x'];
        $commands[] = "sendevent /dev/input/event1 3 48 1";
        $commands[] = "sendevent /dev/input/event1 0 2 0";
        $commands[] = "sendevent /dev/input/event1 0 0 0";
    } elseif ($_GET['action'] == 'up') {
        $commands[] = "sendevent /dev/input/event1 3 48 0";
        $commands[] = "sendevent /dev/input/event1 0 2 0";
        $commands[] = "sendevent /dev/input/event1 0 0 0";
    }

    system('adb shell ' . implode(";", $commands) . ";");
} else {

    ?>
<link rel="stylesheet" type="text/css"
      href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/themes/base/jquery-ui.css">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.js"></script>
<script>
    jQuery(function () {
        jQuery('[x]').click(function () {
            var $this = jQuery(this);
            jQuery('[name=x]').val($this.attr('x'));
            jQuery('[name=y]').val($this.attr('y'));
            jQuery('[name=action]').val(jQuery(this).attr('name'));
        });

        jQuery('[type=button]').click(function () {
            jQuery('[name=action]').val(jQuery(this).attr('name'));
            jQuery('form').submit();
        });

        jQuery('form').submit(
            function () {
                var $this = jQuery(this);
                jQuery.ajax('send_input.php?' + $this.serialize(), {async: false});
                return false;
            }
        )    ;



    });

    function play(){
        jQuery('[value=Top]').click();
        jQuery('[value=Top]').click();
        jQuery('[value=MiddleTop]').click();
        jQuery('[value=Middle]').click();
        jQuery('[value=MiddleBottom]').click();
        jQuery('[value=MiddleBottom]').click();
        jQuery('[value=Top]').click();
        jQuery('[value=Top]').click();
        jQuery('[value=MiddleTop]').click();
        jQuery('[value=Middle]').click();
        jQuery('[value=MiddleBottom]').click();
        jQuery('[value=MiddleBottom]').click();
        jQuery('[name=up]').click();
        jQuery('[value=AdClose]').click();
        jQuery('[value=ContinueButton]').click();
        setTimeout(play, 1000);
    }

</script>
<form method="get">
    X: <input type="text" name="x" value="<?=!empty($_GET['x']) ? $_GET['x'] : 0 ?>">
    <br/>
    Y: <input type="text" name="y" value="<?=!empty($_GET['y']) ? $_GET['y'] : 0 ?>">
    <br/>
    Action: <input type="text" name="action" value="<?=!empty($_GET['action']) ? $_GET['action'] : '' ?>">
    <br/>

    <input type="button" name="click" value="Down">
    <input type="button" name="move" value="Move">
    <input type="button" name="up" value="Up">
    <br/>
    <input type="button" name="move" value="Top" x="3500" y="2100">
    <input type="button" name="move" value="MiddleTop" x="3500" y="1575">
    <input type="button" name="move" value="Middle" x="3500" y="1050">
    <input type="button" name="move" value="MiddleBottom" x="3500" y="525">

    <input type="button" name="move" value="Bottom" x="3500" y="0">
    <br/>
    <input type="button" name="click" value="ContinueButton" x="3500" y="2100">
    <input type="button" name="click" value="AdClose" x="3500" y="1000">
</form>
    <input type="button" name="start" value="Auto Play" onclick="play();"/>
<?

}
?>

North Korea – The Silent Country and it’s Citizens

May 2nd, 2012 by joey | 1 Comment | Filed in Politics

My wife and I frequently watch documentaries.  Some of them are boring, some exciting, and some are extremely informative.

One such informative documentary we viewed is “National Geographic: Inside North Korea”.

North Korea is a country we know little about.  The film provides a rare glimpse inside the lives of North Korean Citizens.  What spoke to me loudest is the absolute lack of freedoms, and the tight grasp the government maintains on it’s citizens through fear and intimidation.  One story portrayed in the documentary is that of a rare North Korean defector.  Like drug cartell’s and ruthless gangs, the government maintains absolute control by punishing not just those who cross them but punishing their family and friends as well.

Like Nazi Germany, North Korea has many “Work Camps” where “political prisoners” are held and worked to death.

The film also evidences the god-like reverence the people hold for their leader (at the time Kim Jong Il)

I believe the key to change is not the top-down approaches of regime change, and military action; Rather I believe the key is a balanced approach that includes motivating the people people to change.  One way is to provide a clear vision of what they want.   How can someone desire something they haven’t tasted.  Freedom is as foreign to them as beautiful warm sunny days on a beach in the pacific are to Eskimos.  If the average North Korean doesn’t know what life is like free from tyranical oppression how can anyone expect them to be ill-content with their current conditions and desire a change.  Allowing them to import telecommunications equipment could provide them with a much needed taste of the freedoms much of the world enjoys and they do not.

Another is to proliferate the same taste of freedom through print.  Easily concealable pamphlets that contain the greatest freedom inspiring words ever written could be scattered across the country.  As well as subtle thought provoking questions about their current leadership.

Conditions in North Korea will likely not improve overnight without some dire intervention; However we can begin to plant the seeds of change in the hearts of the people now.

 

 

 

Ideas That Became Big Business

May 1st, 2012 by joey | 1 Comment | Filed in Business

I’m an entrepreneur.  I’ve operated several small / micro businesses so far in my life (lawn mowing, contract software development, a computer repair company).  I started Novak Solutions, LLC about a year ago.

Over the last few years I have slowly been reading a book called “Ideas That Became Big Business“.  It is a GREAT read.  It is a compilation of one to two page histories of big businesses.  Taking you from the idea through to the businesses current state (atleast current at the time of writing which was in the 50′s).

I read this book looking for the secrets of success of these big businesses.  I discovered a few characteristics that were common among all the companies (in order of importance I think).

  • Persistence
  • Hard Work
  • A Good Idea

Occasionally luck also played a part.  Specifically in the case of “Cream of Wheat”.  The story goes that one of three partners in a struggling flour business decided to try a new product.  The company had no extra capital so the used existing plates to print the logo on the box (the African American chef), some recycled crates to put the boxes in and included it in their next shipment of flour.  A few days later they received a telegram from the customer that said “Forget the flour!  Send us more of that new Cream of Wheat!”

Another good story is the creation of John Deere.  A farmer was in an area where the mud was such that it would stick to the plow and make it almost impossible to plow a field.  He tinkered some and formed a new plow shape that the mud wouldn’t stick to.  After a few years sales sored and through acquisitions John Deere became what it is today.

Many company founders struggle for over a decade (that’s right, over a decade) before their ideas took off.  Notably the first commercial manufacturer of zippers (The Talon Zipper Company) founded by Whitcomb L Judson, He invented the precursor of the modern zipper in 1891, but it wasn’t until the zipper was redesigned and he partnered with Gideon Sundback to design equipment that would automatically manufacture them that the company began to turn a profit.  Sales were still very Meager until 1923 when the zipper appeared on Galoshes which were marketed by B.F. Goodrich Co. A whopping 30 years after the initial invention.

So, if you are interested in business.  I highly recommend this book.

And, if you own a business that isn’t performing like you want, hang in there and don’t give up.

 

Catch All Email Server for Testing

April 17th, 2012 by joey | No Comments | Filed in Software

While at Infusionsoft I took Eric Daugherty’s Java Email Server and modified it so that it would deliver any email sent to it to a single mailbox.  This tool proved invaluable and I suspect is still frequently used.  When I left Infusionsoft I left all my code as well.  I didn’t take anything with me.  I wanted to make 100% sure I was following the rules.

Today, I finally re-created the tool.  And am happy to announce that it is available for anyone to use.

You can download it here: http://code.google.com/p/test-catchall-email-server/

The tool is a fork of JES 2.1.3

I also added a feature to the tool that allows you to test smtp error handling.  If you send a message to error400@(anything), or error500@(anything) you will get a 400 or 500 smtp error after the RCPT TO:  This allows you to easily simulate delivery failures easily.

XBMC Awesomeness!

March 29th, 2012 by joey | 1 Comment | Filed in Fun

I wash the dishes in our house most of the time, and I get bored.  Usually I’ll setup my iPhone, or Kindle in the cabinet above the sink and put on a talk, or music or something.  But it’s quiet…  I have a laptop in the kitchen that runs ZoneMinder already so I thought I would see if there was some web controllable music player thing I could put on it, so when I do the dishes I could use my iPhone to tell the laptop to play something.

After searching for a few minutes I found XBMC.  I installed it, and it is AWESOME!  It has surprised me more then once already with cool neato features.  And today was the best yet.

My friend was over showing me a youtube video on his iPad and the airplay icon came up (which neither of us had ever seen before…). He pushed it, and my xbmc computer came up in the list.  I told him to push it, and VIOLA!  The YouTube video was playing on the projector and speakers connected to the xbmc computer.  Too cool!

 

Awkward Turtles

March 29th, 2012 by joey | No Comments | Filed in Book Reviews

I have a good friend, Jacob Allred, who is undoubtedly one of the smartest people I know (not to mention luckiest, seriously).  We served our missions together and later his family moved to the same city I was living in.  He went to work with me at Affinity 4 where he shined and eventually became their Director of Development.

He self published a choose your own adventure book called “Awkward Turtles”.  He wrote his book while he was dating his GF now Wife Rebecca.  I haven’t read it myself but I am looking forward to it.  You can view his blog post about it here: http://www.jacoballred.com/goals/awkward-turtles-finally-in-print-and-3-copies-sold/

It’s available on Amazon here: http://www.amazon.com/gp/reader/0982066805?ie=UTF8&p=S001#reader-link

 

rule.fm RULES!!!

March 23rd, 2012 by joey | No Comments | Filed in Exceptional Businesses

I was looking into project management software for my software company.  I needed it badly.  At first I tried Trac.  That reminded me just how important a nice friendly UI is to productivity.

I looked at some agile project management software but found them to be too rigid with too many extra features I didn’t need for my plethora of smaller one week projects.

I tried out a few, and signed up for rule.fm.  I’ve seen ads for rule.fm before, but I always thought it was an online radio like pandora or spotify.

I signed up for the trial, loved it and purchased it.  Then I had my first interaction with their support staff, and it was amazing…  See the screenshot below of our conversation…

Bottom line, I love rule.fm.  So do my contractors.  They are WELL worth the monthly cost.  I suspect in a year or two we will be up to the pro $99 / mo plan but for now, the $19 / mo plan should get us by.

Thanks Jerome!  Awesome Customer Service.

Infusionsoft Spring Release – Thoughts on my first 10 Minutes- GAME CHANGING

March 22nd, 2012 by joey | No Comments | Filed in Infusionsoft

So, this morning my Infusionsoft Application was upgraded (I’m part of the Alpha Group).  I logged in, and at first I was pretty disappointed that I couldn’t even find my webforms… Which are easy to find once you discover that the nav bar changes depending upon what “area” of the app you are in (Marketing, ECommerce, CRM, Admin).  Then I saw their new super cool totally AWESOME ******** tool (sorry, they won’t let me say what it is till after Infusion Con).  And I was astonished  I usually don’t jump onto cool aid band wagons, but this new tool is GAME CHANGING.  Look out aweber, constant contact,  ComF5, Sales Force, and the rest of you.  Infusionsoft is about to hit their stride.

Testing My Latest Car (#14) As If It Were Software

March 22nd, 2012 by joey | No Comments | Filed in Life

I make my living by providing custom software solutions to small businesses.  To stay sane  in this industry one thing you have to learn to do is test, test, test, test, test…  It is much easier to fix a bug before something gets delivered to a customer then after.  And nothing is worse then waking up to an angry customer who just found that bug that YOU didn’t.  So I test my software hard.  I go through every edge case, I test dirty input, I test on multiple browsers.  I click as fast as I can through things.  I go slowly, I click around.  I try huge uploads.  I try weird combinations of data.  I write extra code so that I can quickly test things.  The list goes on…  Because of this, when I deploy something to production I feel good about it.  I don’t have the dread in back of my head that I missed something and it will break.

Well, I like to feel the same way about the car I drive.  That’s easy with my scooter.  It’s so simple it just works.  (And it’s a Honda).  But this new car I got (1996 Geo Prizm / Toyota Corolla I bought from a friend who had some problems with it for $450. ) I’m not sure about yet.

I’ve made a few repairs on it, and I need to test it.  I want to KNOW that it isn’t going to over heat the first time I take the scouts on a camp-out in the mou.  I want to KNOW it will JUST WORK.  So, what is the equivalent of beating on software for a car?  Several things.  First, a trip to the car wash to clean the engine.  If you can’t blast the engine compartment with water without the car dieing, you probably don’t want to drive it in the rain.  I cleaned it really good, and one of the cylinders started miss-firing.  This wasn’t wholly unexpected as it’s pretty common when you get the ignition system wet. I just drove it long enough for the water to evaporate and everything was great.  Next stop, the highway. Shifting the transmission manually I ran at 75mph near red-line for about 10 minutes.   WARNING: Don’t do this unless your car is made in Japan.  Seriously, we don’t have anything on the Japanese when it comes to building bullet-proof 4 cylinder gasoline engines.  At this point I was impressed.  No burning oil, no over heating, no weird sounds.  In fact, this is one of the smoothest running cars I’ve ever owned.  Next test, handling…  A few speedy left and right turns, no squealing, no wheel noises, no excessive under steer, very nice.  Everything seems good.  To test the suspension a little I head home (still manually shifting and keeping the engine screaming near red-line) to the speed bumps and drainage dips on the way.  Unlike our other car (A Classic Prius) the Corolla glides over the bumps, and through the dips without bottoming out.  No odd noises either, the struts and springs seem to be in good shape. When I get home, I check on my repairs and am happy to see they are still working just fine.

Overall I was extremely impressed.  Now before you get in a tizzy about me abusing the car, you have to understand that for several reasons I was confident this car should be able to take this kind of treatment.  One is that Kiplinger rates it as the #2 car that JUST WON’T DIE.  I also ran a compression check before hand and was AMAZED that with almost 200k miles it was still pushing 195psi across all four cylinders (many new cars won’t test that high).  Add to that my previous experience with Toyota vehicles, as well as the many you tube videos of people trying to destroy old Toyotas and having a hard time doing it.

Now, I am as confident as I can be without a complete tear-down that this car won’t leave me stranded anytime soon.

It’s PI Day!!!

March 14th, 2012 by joey | No Comments | Filed in Life

Once a year a day with the best Christmas Dessert’s but without the stress of traveling and extended family comes along.

PI DAY!!!!

So, go out and celebrate.  Buy yourself your favorite Pi and Chow down!