Skip to content

Instantly share code, notes, and snippets.

@kenwebb
Created March 14, 2012 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kenwebb/2037928 to your computer and use it in GitHub Desktop.
Save kenwebb/2037928 to your computer and use it in GitHub Desktop.
Pi Day: How 3.14 helps find other planets, and more
<?xml version="1.0" encoding="UTF-8"?>
<!--Xholon Workbook http://www.primordion.com/Xholon/wb/ (C) Ken Webb Wed Mar 14 2012 13:50:20 GMT-0400 (EDT)-->
<XholonWorkbook>
<Notes><![CDATA[
Xholon
------
Title: Pi Day: How 3.14 helps find other planets, and more
Description: A favorite holiday among geeks, March 14 commemorates one of the most fundamental and strange numbers in mathematics.
Url: http://lightyears.blogs.cnn.com/2012/03/13/pi-day-how-3-14-helps-find-other-planets-and-more/
InternalName:
YoutubeId:
Keywords:
My Notes
--------
This is my Xholon workbook for March 14, 2012.
]]></Notes>
<script implName="lang:python:inline:"><![CDATA[
print "Happy Pi Day! pi = " + str(math.pi)
]]></script>
<script implName="lang:javascript:inline:"><![CDATA[
print("Happy Pi Day! pi = " + Math.PI + "\n");
]]></script>
<_-.XholonClass>
<!-- domain objects -->
<PhysicalSystem/>
<Planet/>
<!-- quantities -->
<Radius superClass="Length"/>
</_-.XholonClass>
<xholonClassDetails>
<Planet>
<port name="radius" connector="#xpointer(Radius)"/>
<port name="volume" connector="#xpointer(Volume)"/>
</Planet>
</xholonClassDetails>
<PhysicalSystem>
<!-- The search for new planets -->
<Planet>
<Radius>6378 km</Radius> <!-- this is the radius of the planet Earth, in kilometers (km) -->
<Volume>0.0 km^3</Volume> <!-- the volume (in kilometers cubed) is initially unknown -->
</Planet>
</PhysicalSystem>
<Blockbehavior implName="lang:python:inline:"><![CDATA[
# This works if pasted in as a last child of Block.
#height.incVal(0.02)
#print("Python wants something to do. Height:" + str(height))
]]></Blockbehavior>
<Blockbehavior implName="lang:javascript:inline:"><![CDATA[
// This works if pasted in as a last child of Block.
//height.incVal(0.02);
//print("JavaScript wants something to do. Height:" + height + "\n");
]]></Blockbehavior>
<Planetbehavior implName="lang:webEditionjs:inline:"><![CDATA[
this.bindPorts(this.parent());
// "The volume of a planet is about 4/3 pi times the radius cubed"
this.volume.attr('val', 4 / 3 * Math.PI * (Math.pow(this.radius.attr('val'), 3)));
print("Radius:" + this.radius.attr('val') + this.radius.attr('unit')
+ " Volume:" + this.volume.attr('val') + this.volume.attr('unit') + "\n");
]]></Planetbehavior>
<Blockbehavior implName="lang:bsh:inline:"><![CDATA[
// This works if pasted in as a last child of Block.
//height.incVal(0.02);
//System.out.print("Java/Beanshell wants something to do. Height:" + height + "\n");
]]></Blockbehavior>
<Blockbehavior implName="lang:jruby:inline:"><![CDATA[
#require 'java'
# This works if pasted in as a last child of Block.
#$height.incVal(0.02)
#puts "Ruby wants something to do. Height: #{$height}"
]]></Blockbehavior>
<Blockbehavior implName="lang:groovy:inline:"><![CDATA[
// This works if pasted in as a last child of Block.
//height.incVal(0.02);
//System.out.print("Groovy wants something to do. Height:" + height + "\n");
]]></Blockbehavior>
<SvgClient><Attribute_String roleName="svgUri"><![CDATA[data:image/svg+xml,
<svg width="50" height="50" xmlns="http://www.w3.org/2000/svg">
<g>
<title>Happy π day!</title>
<circle r="20" cy="25" cx="25" fill="#aaffaa" id="pi"/>
<text font-size="24" font-weight="bold" fill="black" id="svg_1" y="31.5" x="16.5">π</text>
</g>
</svg>
]]></Attribute_String><Attribute_String roleName="setup">${MODELNAME_DEFAULT},${SVGURI_DEFAULT}</Attribute_String></SvgClient>
</XholonWorkbook>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment