Sunday, February 8, 2015

A New URL

Hey all - I have been able to reacquire one of my domains that were so viciously stolen from me by domain squatters some time ago. So, you can now visit the site using www.joshwieder.net. Keep in mind that all links to joshwieder.blogspot.com will continue to work.

Wednesday, February 4, 2015

Google Maps Javascript API Tutorial is Rubbish

I am working on creating a Google-maps based project. As such, I was using the Google Maps Javascript API Tutorial to activate an API key and create a 'Hello World' style test script.

I continuously received one of the following errors:

Google has disabled use of the Maps API for this application. The provided key is not a valid Google API Key, or it is not authorized for the Google Maps Javascript API v3 on this site. If you are the owner of this application, you can learn about obtaining a valid key here: https://developers.google.com/maps/documentation/javascript/tutorial#api_key

Google has disabled use of the Maps API for this application. See the Terms of Service for more information: http://www.google.com/intl/en-US_US/help/terms_maps.html.

Having not used the API to make a single call, the notion that I had somehow violated the Google TOS was particularly infuriating, as was the notion that I had not enabled the Google Maps API, which I had done, as outlined in the API Tutorial:


The issue, at least in my case, turned out to be the sample code that Google provides in the same tutorial. The sample is as follows:


<html>
<head>
<style type="text/css">
html, body, #map-canvas { height: 100%; margin: 0; padding: 0;}
</style>
<script src="https://maps.googleapis.com/maps/api/js?key=API_KEY" type="text/javascript">
</script>
<script type="text/javascript">
function initialize() {
var mapOptions = {
center: { lat: -34.397, lng: 150.644},
zoom: 8
};
var map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map-canvas">
</div>
</body>
</html>

In the script above, the developer is prompted to replace API_KEY with their actual API Key. However, this will cause a TOS violation if you have followed the Tutorial. To resolve the issue, add the following to your API Key:

&sensor=false
So the entire line of script, with an actual API Key, would look something like this:

<script src="https://maps.googleapis.com/maps/api/js?key=21a300d4a9a2cf55e4ffac1750acbc01
&sensor=false" type="text/javascript">
This will allow the map to render as described in the tutorial.

Sunday, February 1, 2015

BootChess: The Tiniest Chess Program in Town

Coding hyper-efficient chess programs has been something like a running contest among big time Smarty Pantses with too much time on their hands. For the last 33 years, the record for the smallest version of chess was held by the fabled 1K ZX Chess for the Sinclair ZX81. First published in 1982, 1K ZX had all of the basic chess rules and a opponent loaded into a now-hard-to-imagine 672 bytes of memory. Its publisher, David Horne, would go on to publish the code for the program in a three art Computer Magazine series (the first part of which you can see embedded below:


This is the super-rad David Horne:

david horne joshua wieder bootchess

1K ZX's 33 year reign has just been challenged. The challenger is a program called BootChess, which includes all of the features of 1K ZX with a stunning memory allocation of only 512 bytes. The program was written by Olivier Poudade and Peter Ferrie.

BootChess, Josh Wieder, DOSBox
It was never a very graphic-intensive game, anyway
This is a photo of Peter Ferrie:
Joshua Wieder Peter Ferrie

A photo of Olivier Poudade was not immediately available however this artist's rendition is accurate:

Joshua Wieder Olivier Poudade
Olivier is not, in fact an evil genius. I can't prove it. Yet.
That 512 byte number might be familiar to some readers; it is the exact size of an x86 bootloader (You can take a closer look at the source, in assembler below). There is still a bit of a controversy surrounding the release, as there appears to be a few bugs with BootChess. I personally haven't had a chance to give it a complete test run yet (but I look forward to). Let me know what you think.

The Latest Not-So-Subtle Threat to Tech Companies Using Encryption

This time the kneecap-breaker is Stewart Baker, former counsel general of the NSA and assistant secretary for the Department of Homeland Security (currently counsel with Steptoe & Johnson LLP).

Baker claims that Blackberry (AKA RIM) should blame its use of strong encryption for its poor market performance. Specifically:
He claimed that by encrypting user data Blackberry had limited its business in countries that demand oversight of communication data, such as India and the UAE and got a bad reception in China and Russia. “They restricted their own ability to sell. We have a tendency to think that once the cyberwar is won in the US that that is the end of it - but that is the easiest war to swim.”
Of course, Baker makes no mention of the iPhone snatching up corporate mobile market-share, or tiny changes in the phone market like, I dunno, the implementation of the Android OS. But who cares about little fish like that when the United Arab Emirates is at stake?

Baker's statements are not competent when viewed as economic analysis. It might seem like Baker is carrying water for the intelligence community, but maybe its as simple as having an atrophied thinking cap from a lifetime in "government service"?

Uploading HTML forms to Amazon S3 using PHP

Dynamically uploading information to S3 can be a bit challenging to do initially, particularly in PHP where a lot of the documentation is either really new or really old.

Amazon has a PHP SDK, which is available as either a .phar file or can be installed using Composer. That's cool for building a new project, but what if you have a pre-existing project or form and just want to be able to dump the text output to S3?

I've put together some code at Github that will take care of that issue. The only requirement is PHP and an Amazon S3 account.

Download or clone the files here: https://github.com/jwieder/s3-http-php-form

Your Amazon access keys and other configuration are stored in a single configuration file. Just fill out your login info into the configuration file and include the php form where you need it as outlined in the README.md file and you should be all set!