Thursday, May 9, 2013

Paleo twaddle


Menu:

2 Poached eggs
Baby spinach
Bacon
Mushrooms
Tomato
Avocado.
+
Regular coffee.

How much of this is really part of a Paleo diet?  From wikipedia: "The Paleolithic..., is a prehistoric period of human history distinguished by the development of the most primitive stone tools discovered... and covers roughly 99% of human technological prehistory. It extends from the earliest known use of stone tools, probably by hominins such asaustralopithecines, 2.6 million years ago, to the end of the Pleistocene around 10,000 BP"

So; 10,000 years ago what parts of these menu items would a paleo eater have to eat?

Poached eggs?  Nope, chickens were domesticated in southeast asia only a few thousand BCE.  And chickens are native to southeast Asia, so no way they could have been eaten on the African savanna.

Spinach?  Dunno.  Seems to have been from Persia, so maybe.

Bacon?  Same situation as chickens.  Another southeast asian native.

Mushrooms? Very probably.

Tomato?  A native plant of south America, so no, not available.

Avocado.  Ummm. The avocado (Persea americana) is a tree native to Central Mexico. FAIL.

Coffee; it was only harvested in Ethiopian highlands in the last few thousand years.

Yumm, a big plate of mushrooms is what you need to keep authentic paleo.

Saturday, March 2, 2013

dojox charting tooltip function



Want to have a custom tool tip on your dojox chart?  The easiest thing to do is to use a custom function when creating the Tooltip object.

First: Add the require for the tool tip.

dojo.require( 'dojox.charting.action2d.Tooltip' );

Second: define the function to be used when a tooltip is required.


new dojox.charting.action2d.Tooltip(chart1, "default", {
text : function(o) {
return ( o.run.name +'<br>' + o.y ); 
} );

As you can see the tool tip function is passed the o object.  This object describes the chart, series and plots you'll need to make a nice tool tip.  What you need is the o.run.name, which is the name of the series and o.y, which is the value of the data point on the y axis.  Combined with <br> you'll get a two line tool tip.

Well, this is a three liner, but it looks much the same.  That's because I used a more complicated tool tip function that uses the label function to add the x axis label to the tool tip. 

Sunday, February 3, 2013

ArcGIS quakes example unexpected token < error

I have been playing with one of the example ArcGIS samples from the 'Building Web Applications Using the ArcGIS API for JavaScript' and kept getting an annoying error:


esri.request failed: SyntaxError: Unexpected token < quakes.js:164

  1.  

Which stops the quakes layer loading.

The esri.request method requires a web server running hosting the example and a proxy page to call the quakes XML service:


function requestQuakes(){
esri.config.defaults.io.proxyUrl = "proxy.php"; //relative - if proxy.php is in the same application as the web page

var requestHandle = esri.request({
 url: "http://earthquake.usgs.gov/earthquakes/feed/geojson/1.0/week",
 load: requestSucceeded,
 error: requestFailed
}, {
 useProxy: true // changed from True
});
}



When I run it under the EasyPHP server that error came up. 

I chased the error down to the proxy.php script echoing out error messages due to uninitialized variables and missing keys from arrays.  Once I had eliminated those errors the page loaded correctly.  It seems the error messages were getting returned with the usgs earthquakes JSON and messing up the dojo JSON parser.

The new proxy.php

Tuesday, October 23, 2012

Simple x y dojo chart example

This is a very simple x, y, chart using Dojo and sourcing the js and css from Google.  Copy the next part and save as a html file.


<!DOCTYPE html>
<html >
<head>
<script 
type="text/javascript" 
src="http://ajax.googleapis.com/ajax/libs/dojo/1.8.0/dojo/dojo.js" 
dojoConfig = "{parseOnLoad: true}"></script>
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/dojo/1.8/dijit/themes/claro/claro.css"/>

<script type="text/javascript" >
dojo.require( "dojox.charting.Chart" );
dojo.require( "dojox.charting.axis2d.Default" );
dojo.require( "dojox.charting.plot2d.Lines" );

  dojo.ready(function(){
    var chart1 = new dojox.charting.Chart("simplechart",{title: "Basic XY chart" });
    chart1.addPlot("default", {type: dojox.charting.plot2d.Lines});
    chart1.addAxis("x", {title: "X axis", titleOrientation: "away"});
    chart1.addAxis("y", {vertical: true, title: "Y axis"});
    chart1.addSeries("Series 1", [1, 2, 2, 3, 4, 5, 5, 7]);
    chart1.render();
  });
</script>
</head>
<body class="claro">
    <div id="simplechart" style="float:left; width: 350px; height: 350px; margin: 5px auto 0px auto;"></div>
</body>
</html>












   




   



Tuesday, August 7, 2012

Issues in Beginning RhoMobile


Here I'm listing a few mistakes/typos in the book Rhomobile Beginner's Guide.


Chapter 4


Code for cancel button on the filter_employee_form.erb, chapter 4, incorrectly takes you to the index of employees, when It should take you back to the home page. Replace :

<a class="cancel" href="<%= url_for :action => :index %>">Cancel</a>

With

<a class="cancel" href="<%= Rho::RhoConfig.start_path %>">Cancel</a>

Also latest ruby practice is to use link_to instead of <a href style.

Creating a RhoSync application.


Should say where to run the rhosync application. Also rhosync is now replaced by rhoconnect. So starting rhosync with rake is now starting rhoconnect with rake.

Installing the Rhodes translator gem


You must run gem install from the ruby folder or it won't work.

Thursday, April 19, 2012

Fixing RhoMobile build problems to android device.

Android SDK location.

Make sure you don't install it with any spaces.

Version of Android SDK

I had to install 2.3 before it would compile without complaining about missing getNumberOfCameras()

And delete xlargeScreen

Wednesday, April 18, 2012

Connectify connecting problems using android phone

I changed my laptop and installed Connectify onto it. Then I tried to connect with my Atrix to the WiFi. It saw the hotspot but whenever I tried to connect the phone would say 'obtaining ip address' for about 2 minutes, then abort the connection. Another laptop could connect to the Connectify hotspot so the issue was on the phone.

Solved the issue by going into the WiFi settings on android, pressing the menu button, choosing 'Advanced' and selecting 'Enable Auto IP'. Then it connected! Hooray!