<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3158873714071458599</id><updated>2024-08-30T10:00:32.688-05:00</updated><category term="Hello World"/><category term="Insertion sort"/><category term="algorithm"/><category term="sorting"/><category term="productivity"/><category term="C++"/><category term="Java"/><category term="Python"/><category term="golang"/><category term="google go"/><category term="scala"/><category term="47906Proxy"/><category term="BCH"/><category term="Back Test"/><category term="Backtesting"/><category term="Bitcoin"/><category term="ETC"/><category term="Entrepreneur"/><category term="Gson"/><category term="Java.regex"/><category term="Regex"/><category term="Regular Expressions"/><category term="RoundTable"/><category term="Software"/><category term="TypeAdapter"/><category term="bluehost"/><category term="codejam codewithgoogle flyswatter java mathjax"/><category term="dock freeze"/><category term="eclipse"/><category term="gvim"/><category term="java 13"/><category term="java on mac"/><category term="killall"/><category term="libexec"/><category term="mountain lion"/><category term="multi line"/><category term="multiple jvms on mac"/><category term="netbeans"/><category term="network sniffer"/><category term="notes bookmarks"/><category term="osx"/><category term="perl"/><category term="port forwarding"/><category term="prductivity"/><category term="project search and replace"/><category term="protocol analysis"/><category term="subversion"/><category term="svn"/><category term="tradingbot"/><category term="vi tags"/><title type='text'>ECOCRYPT</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blog.ecocrypt.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://blog.ecocrypt.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Q. B.</name><uri>http://www.blogger.com/profile/08502256579896627307</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9e-xzbIV9ABn9OHlgiNbVBplXewci_K0F0yYD52TW8scrP1IbQfmHRVQKv9uy5wULo5xDNj8aPq51gJ4O84pgc3K3HFXWP1rYGbQMXPdcXeuEyzvl9lGkIWrLVbghNjY/s220/JetCloud.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>27</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3158873714071458599.post-8986907503679069229</id><published>2023-06-17T09:31:00.002-05:00</published><updated>2023-06-17T09:31:32.813-05:00</updated><title type='text'>King&#39;s View of the Battle</title><content type='html'>&lt;p&gt;&amp;nbsp;Open GL model of a chess board.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.ecocrypt.com/feeds/8986907503679069229/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.ecocrypt.com/2023/06/kings-view-of-battle.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/8986907503679069229'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/8986907503679069229'/><link rel='alternate' type='text/html' href='http://blog.ecocrypt.com/2023/06/kings-view-of-battle.html' title='King&#39;s View of the Battle'/><author><name>Q. B.</name><uri>http://www.blogger.com/profile/08502256579896627307</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9e-xzbIV9ABn9OHlgiNbVBplXewci_K0F0yYD52TW8scrP1IbQfmHRVQKv9uy5wULo5xDNj8aPq51gJ4O84pgc3K3HFXWP1rYGbQMXPdcXeuEyzvl9lGkIWrLVbghNjY/s220/JetCloud.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3158873714071458599.post-2758418638957009546</id><published>2020-02-09T21:45:00.000-06:00</published><updated>2020-02-09T21:45:05.452-06:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Back Test"/><category scheme="http://www.blogger.com/atom/ns#" term="Backtesting"/><category scheme="http://www.blogger.com/atom/ns#" term="BCH"/><category scheme="http://www.blogger.com/atom/ns#" term="Bitcoin"/><category scheme="http://www.blogger.com/atom/ns#" term="ETC"/><category scheme="http://www.blogger.com/atom/ns#" term="Gson"/><category scheme="http://www.blogger.com/atom/ns#" term="tradingbot"/><category scheme="http://www.blogger.com/atom/ns#" term="TypeAdapter"/><title type='text'>Bitcoin Trading Algorithm Back Testing Project Historical Data Setup</title><content type='html'>I have the desire to create a bitcoin algorithmic trader which will work autonomously without supervision.&amp;nbsp; However, it might be a wise idea to initially test this trader out with a backtesting solution first.&amp;nbsp; Once the back testing proves profitable, I can then think about the actual autonomous side of the trading.&lt;br /&gt;
&lt;br /&gt;
That said, I have access to historical trade data from the Coinbase Pro (formerly GDAX) exchange.&amp;nbsp; The data is not the full order book, but a very simplified view which shows the &quot;Ticker&quot; after each &quot;Match&quot;.&amp;nbsp; For my backtesting application this should be adequate, and the trading strategy that I intend to employ will only need the ticker information.&lt;br /&gt;
&lt;br /&gt;
Goal of this phase:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Organize the Ticker data I have into a usable Backtesting structure&lt;/li&gt;
&lt;li&gt;Create an API that will allow a Backtesting Application to request the next Tick, or skip an entire day of Ticks if the daily high or daily low is tighter (narrower) than the autonomous trader is quoting.&lt;/li&gt;
&lt;li&gt;Develop unit tests and check the overall performance of the system&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
Thinking backwards from the end solution, will allow for a usable design.&amp;nbsp; In the end API, it would be nice to be able have:&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;An autonomous Trader;&amp;nbsp; A &quot;Tick Provider&quot;; and a &quot;Quote Handler&quot; -&amp;gt;&amp;nbsp; Produce a List of Trades and a Profit and Loss Report&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The current task at hand is to develop the &quot;Tick Provider&quot;.&amp;nbsp; So taking a quick look at the data, it comes in &quot;Daily Files&quot; as:&lt;/div&gt;
&lt;style type=&quot;text/css&quot;&gt;
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000}
span.s1 {font-variant-ligatures: no-common-ligatures}
span.Apple-tab-span {white-space:pre}
&lt;/style&gt;


&lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;Ticker_20190928.gz&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;Ticker_20191204.gz&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;Ticker_20190929.gz&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;Ticker_20191205.gz&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;Ticker_20190930.gz&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;Ticker_20191206.gz&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;Ticker_20191001.gz&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;Ticker_20191207.gz&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;Ticker_20191002.gz&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;Ticker_20191208.gz&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;Ticker_20191003.gz&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;Ticker_20191209.gz&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;Ticker_20191004.gz&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;Ticker_20191210.gz&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;Ticker_20191005.gz&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;Ticker_20191211.gz&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;
Each file is a compressed set of &quot;JSON&quot; data with many different &quot;Products&quot; in it. An example of a few rows of json are shown below:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;{
  &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;&quot;gdaxv&quot;&lt;/span&gt;: &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;tpid&quot;&lt;/span&gt;,
  &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;&quot;type&quot;&lt;/span&gt;: &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;ticker&quot;&lt;/span&gt;,
  &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;&quot;trade_id&quot;&lt;/span&gt;: &lt;span style=&quot;color: blue;&quot;&gt;2577287&lt;/span&gt;,
  &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;&quot;sequence&quot;&lt;/span&gt;: &lt;span style=&quot;color: blue;&quot;&gt;488009902&lt;/span&gt;,
  &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;&quot;time&quot;&lt;/span&gt;: &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;2019-09-28T05:21:19.586000Z&quot;&lt;/span&gt;,
  &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;&quot;product_id&quot;&lt;/span&gt;: &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;ETC-USD&quot;&lt;/span&gt;,
  &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;&quot;price&quot;&lt;/span&gt;: &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;4.73&quot;&lt;/span&gt;,
  &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;&quot;side&quot;&lt;/span&gt;: &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;sell&quot;&lt;/span&gt;,
  &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;&quot;last_size&quot;&lt;/span&gt;: &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;2551.79500000&quot;&lt;/span&gt;,
  &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;&quot;best_bid&quot;&lt;/span&gt;: &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;4.728&quot;&lt;/span&gt;,
  &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;&quot;best_ask&quot;&lt;/span&gt;: &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;4.731&quot;&lt;/span&gt;}
{
  &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;&quot;gdaxv&quot;&lt;/span&gt;: &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;tpid&quot;&lt;/span&gt;,
  &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;&quot;type&quot;&lt;/span&gt;: &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;ticker&quot;&lt;/span&gt;,
  &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;&quot;trade_id&quot;&lt;/span&gt;: &lt;span style=&quot;color: blue;&quot;&gt;75022004&lt;/span&gt;,
  &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;&quot;sequence&quot;&lt;/span&gt;: &lt;span style=&quot;color: blue;&quot;&gt;10913413268&lt;/span&gt;,
  &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;&quot;time&quot;&lt;/span&gt;: &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;2019-09-28T05:22:14.457000Z&quot;&lt;/span&gt;,
  &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;&quot;product_id&quot;&lt;/span&gt;: &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;BTC-USD&quot;&lt;/span&gt;,
  &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;&quot;price&quot;&lt;/span&gt;: &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;8165.28&quot;&lt;/span&gt;,
  &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;&quot;side&quot;&lt;/span&gt;: &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;buy&quot;&lt;/span&gt;,
  &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;&quot;last_size&quot;&lt;/span&gt;: &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;0.00585052&quot;&lt;/span&gt;,
  &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;&quot;best_bid&quot;&lt;/span&gt;: &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;8165.27&quot;&lt;/span&gt;,
  &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;&quot;best_ask&quot;&lt;/span&gt;: &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;8165.28&quot;&lt;/span&gt;}&lt;/pre&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;
The goal for this segment of the overall project will be the following:&lt;/div&gt;
&lt;div&gt;
&lt;ol&gt;
&lt;li&gt;Identify if a daily summary and extraction exists for the desired product/day.&amp;nbsp;&amp;nbsp;&lt;/li&gt;
&lt;ol&gt;
&lt;li&gt;If Not Create the daily summary&lt;/li&gt;
&lt;li&gt;Use the existing daily summary&lt;/li&gt;
&lt;/ol&gt;
&lt;li&gt;Provided a request based feed of the price ticks for the requested product.&lt;/li&gt;
&lt;li&gt;Allow for an entire day of data to be skipped if the Max or Min price are tighter that required by the client using the data (in this case the autonomous trader may choose to list trade bounds)&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
The basic API will work a follows:&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;Initialize the Exchange via the constructor and then calling the init() method.&amp;nbsp; I separated out the init method because it could raise an exception and does disk io work like looking for files and making sure that your cache is pre-built.&amp;nbsp; The idea here is that you will want to run a series of tests against the same product data and same time range.&amp;nbsp; The first setup might take a bit, but then after that the data will get processed faster.&lt;br /&gt;&lt;br /&gt;A sample header will look like this:&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;{
  &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;&quot;day&quot;&lt;/span&gt;: &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;20190929&quot;&lt;/span&gt;,
  &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;&quot;product&quot;&lt;/span&gt;: &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;BCH-USD&quot;&lt;/span&gt;,
  &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;&quot;open&quot;&lt;/span&gt;: &lt;span style=&quot;color: blue;&quot;&gt;227.63&lt;/span&gt;,
  &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;&quot;close&quot;&lt;/span&gt;: &lt;span style=&quot;color: blue;&quot;&gt;218.17&lt;/span&gt;,
  &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;&quot;high&quot;&lt;/span&gt;: &lt;span style=&quot;color: blue;&quot;&gt;228.11&lt;/span&gt;,
  &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;&quot;low&quot;&lt;/span&gt;: &lt;span style=&quot;color: blue;&quot;&gt;212.0&lt;/span&gt;}&lt;/pre&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;Followed by all the trades that match the given product.&lt;/li&gt;
&lt;li&gt;After init() is called, then Exchange.next() can be called repeatedly until a NULL is returned indicating the last trade in the set for analysis.&lt;/li&gt;
&lt;li&gt;This can be used by an autonomous trader to calculate a position or re-quote.&amp;nbsp; Currently it would be too much work to make this back tester behave exactly as an really exchange API&amp;nbsp; But this will be good enough for simple tests.&lt;/li&gt;
&lt;/ul&gt;
The EXCHANGE CODE:&lt;/div&gt;
&lt;div&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt;/*&lt;/span&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt;* Copyright (c) 2020. Ecocrypt.com&lt;/span&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt;* Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);&lt;/span&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt;* you may not use this file except in compliance with the License.&lt;/span&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt;* You may obtain a copy of the License at&lt;/span&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt;*     http://www.apache.org/licenses/LICENSE-2.0&lt;/span&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt;* Unless required by applicable law or agreed to in writing, software&lt;/span&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt;* distributed under the License is distributed on an &quot;AS IS&quot; BASIS,&lt;/span&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt;* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.&lt;/span&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt;* See the License for the specific language governing permissions and&lt;/span&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt;* limitations under the License.&lt;/span&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt;*/&lt;/span&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt;
&lt;/span&gt;&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;package &lt;/span&gt;com.ecocrypt.backtesting.exchange;

&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;import &lt;/span&gt;com.google.gson.Gson;

&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;import &lt;/span&gt;java.io.*;
&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;import &lt;/span&gt;java.text.ParseException;
&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;import &lt;/span&gt;java.text.SimpleDateFormat;
&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;import &lt;/span&gt;java.util.*;
&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;import &lt;/span&gt;java.util.concurrent.atomic.AtomicBoolean;
&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;import &lt;/span&gt;java.util.logging.Logger;
&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;import &lt;/span&gt;java.util.zip.GZIPInputStream;
&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;import &lt;/span&gt;java.util.zip.GZIPOutputStream;

&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;public class &lt;/span&gt;ExchangeFeed {

    &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;private static final &lt;/span&gt;Logger &lt;span style=&quot;color: #660e7a; font-style: italic; font-weight: bold;&quot;&gt;LOGGER &lt;/span&gt;= Logger.&lt;span style=&quot;font-style: italic;&quot;&gt;getLogger&lt;/span&gt;(ExchangeFeed.&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;class&lt;/span&gt;.getName());


    &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;private final &lt;/span&gt;Date &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;startDate&lt;/span&gt;;
    &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;private final &lt;/span&gt;Date &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;endDate&lt;/span&gt;;
    &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;private final &lt;/span&gt;List&amp;lt;String&amp;gt; &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;fileDateStrings &lt;/span&gt;= &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new &lt;/span&gt;ArrayList&amp;lt;&amp;gt;();
    &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;private final &lt;/span&gt;Calendar &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;calendar&lt;/span&gt;;
    &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;private final &lt;/span&gt;String &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;cacheDir&lt;/span&gt;;
    &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;private final &lt;/span&gt;String &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;dataDir&lt;/span&gt;;
    &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;private final &lt;/span&gt;String &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;product&lt;/span&gt;;
    &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;private final &lt;/span&gt;AtomicBoolean &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;isReady &lt;/span&gt;= &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new &lt;/span&gt;AtomicBoolean(&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;false&lt;/span&gt;);

    &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;private &lt;/span&gt;Gson &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;gson &lt;/span&gt;= Util.&lt;span style=&quot;font-style: italic;&quot;&gt;gson&lt;/span&gt;();
    &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;private &lt;/span&gt;Queue&amp;lt;String&amp;gt; &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;cacheQueue &lt;/span&gt;= &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new &lt;/span&gt;LinkedList&amp;lt;&amp;gt;();
    &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;private &lt;/span&gt;BufferedReader &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;currentFileReader &lt;/span&gt;= &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;null&lt;/span&gt;;


    &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;public &lt;/span&gt;ExchangeFeed(String pStart, String pEnd,String pDataDir, String pCacheDir, String pProduct){

        &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;cacheDir&lt;/span&gt;=pCacheDir;
        &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;dataDir&lt;/span&gt;=pDataDir;
        &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;product&lt;/span&gt;=pProduct;
        SimpleDateFormat sdf = &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new &lt;/span&gt;SimpleDateFormat(&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;yyyy-MM-dd&quot;&lt;/span&gt;);
        Date tStartDate = &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new &lt;/span&gt;Date();
        Date tEndDate = &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new &lt;/span&gt;Date();

        &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;try &lt;/span&gt;{
            tStartDate = sdf.parse(pStart);
            tEndDate = sdf.parse(pEnd);

        } &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;catch &lt;/span&gt;(ParseException e) {

            e.printStackTrace();
        }
        &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;startDate &lt;/span&gt;= tStartDate;
        &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;endDate&lt;/span&gt;=tEndDate;
        &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;calendar &lt;/span&gt;= &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new &lt;/span&gt;GregorianCalendar();
        &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;calendar&lt;/span&gt;.setTime(&lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;startDate&lt;/span&gt;);


        &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;while &lt;/span&gt;(&lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;calendar&lt;/span&gt;.getTimeInMillis()&amp;lt;=&lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;endDate&lt;/span&gt;.getTime()){
            &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;fileDateStrings&lt;/span&gt;.add(Util.&lt;span style=&quot;font-style: italic;&quot;&gt;yyyyMMdd&lt;/span&gt;(&lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;calendar&lt;/span&gt;));
            &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;calendar&lt;/span&gt;.add(Calendar.&lt;span style=&quot;color: #660e7a; font-style: italic; font-weight: bold;&quot;&gt;DATE&lt;/span&gt;, &lt;span style=&quot;color: blue;&quot;&gt;1&lt;/span&gt;);
        }
    }

    &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;public void &lt;/span&gt;init() &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;throws &lt;/span&gt;IOException {
        checkCache();
        &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;cacheQueue&lt;/span&gt;.addAll(&lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;fileDateStrings&lt;/span&gt;);
        progressReaderToNextFile();
        &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;isReady&lt;/span&gt;.set(&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;true&lt;/span&gt;);
    }

    &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;public &lt;/span&gt;Ticker next(){
        String result = &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;null&lt;/span&gt;;
        &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;if&lt;/span&gt;(&lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;isReady&lt;/span&gt;.get()){
            &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;if&lt;/span&gt;(&lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;currentFileReader&lt;/span&gt;!=&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;null&lt;/span&gt;){
                &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;try &lt;/span&gt;{
                    result = &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;currentFileReader&lt;/span&gt;.readLine();
                } &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;catch &lt;/span&gt;(IOException e) {
                    e.printStackTrace();
                }
                &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;if&lt;/span&gt;(result==&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;null&lt;/span&gt;){
                    &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;try &lt;/span&gt;{
                        progressReaderToNextFile();
                        &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;if&lt;/span&gt;(&lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;currentFileReader&lt;/span&gt;!=&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;null&lt;/span&gt;) {
                            result = &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;currentFileReader&lt;/span&gt;.readLine();
                        }
                    } &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;catch &lt;/span&gt;(IOException e) {
                        e.printStackTrace();
                    }
                }
            }
        }&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;else&lt;/span&gt;{
            &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;throw new &lt;/span&gt;IllegalStateException(&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot; Call initialize before for first use...&quot;&lt;/span&gt;);
        }
        Ticker resultTicker = &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;null&lt;/span&gt;;
        &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;if&lt;/span&gt;(result!=&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;null&lt;/span&gt;){
            resultTicker = &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;gson&lt;/span&gt;.fromJson(result, Ticker.&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;class&lt;/span&gt;);
        }
        &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;return &lt;/span&gt;resultTicker;
    }



    &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;void &lt;/span&gt;printFileDateStrings(){
        &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;fileDateStrings&lt;/span&gt;.stream().forEach(System.&lt;span style=&quot;color: #660e7a; font-style: italic; font-weight: bold;&quot;&gt;out&lt;/span&gt;::println);
    }

    &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;void &lt;/span&gt;checkCache(){
        &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;fileDateStrings&lt;/span&gt;.stream().forEach(s -&amp;gt; {
            File cacheFile = &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new &lt;/span&gt;File(&lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;cacheDir&lt;/span&gt;+ File.&lt;span style=&quot;color: #660e7a; font-style: italic; font-weight: bold;&quot;&gt;separator&lt;/span&gt;+&lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;product&lt;/span&gt;+&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;_&quot;&lt;/span&gt;+s+&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;.gz&quot;&lt;/span&gt;);
            &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;if&lt;/span&gt;(cacheFile.exists()){
                System.&lt;span style=&quot;color: #660e7a; font-style: italic; font-weight: bold;&quot;&gt;out&lt;/span&gt;.println(&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;Using Cache Data &quot;&lt;/span&gt;+ cacheFile.getAbsoluteFile());
            }&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;else&lt;/span&gt;{
                File rawFile = &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new &lt;/span&gt;File(&lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;dataDir&lt;/span&gt;+File.&lt;span style=&quot;color: #660e7a; font-style: italic; font-weight: bold;&quot;&gt;separator&lt;/span&gt;+&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;Ticker_&quot;&lt;/span&gt;+s+&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;.gz&quot;&lt;/span&gt;);
                &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;if&lt;/span&gt;(rawFile.exists()) {
                    System.&lt;span style=&quot;color: #660e7a; font-style: italic; font-weight: bold;&quot;&gt;out&lt;/span&gt;.println(&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;Processing &quot; &lt;/span&gt;+ rawFile
                            .getAbsoluteFile() +&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;\n\t&lt;/span&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt; INTO Cache -&amp;gt; &quot; &lt;/span&gt;+ cacheFile.getAbsoluteFile());
                    &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;if&lt;/span&gt;(processRawFile(rawFile,cacheFile,s)!=&lt;span style=&quot;color: blue;&quot;&gt;0&lt;/span&gt;){
                        &lt;span style=&quot;color: grey; font-style: italic;&quot;&gt;// Error processing Data.&lt;/span&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt;
&lt;/span&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt;                    &lt;/span&gt;}
                }&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;else&lt;/span&gt;{
                    System.&lt;span style=&quot;color: #660e7a; font-style: italic; font-weight: bold;&quot;&gt;out&lt;/span&gt;.println(&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;RAW DATA FILE MISSING &quot; &lt;/span&gt;+ rawFile.getAbsoluteFile());

                }
            }
        });
    }

    &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;private void &lt;/span&gt;progressReaderToNextFile() &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;throws &lt;/span&gt;IOException {
        String nextDate = &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;cacheQueue&lt;/span&gt;.poll();
        &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;if&lt;/span&gt;(nextDate!=&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;null&lt;/span&gt;){
            &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;currentFileReader &lt;/span&gt;= &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new &lt;/span&gt;BufferedReader(&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new &lt;/span&gt;InputStreamReader(&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new &lt;/span&gt;GZIPInputStream(&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new &lt;/span&gt;FileInputStream(&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new &lt;/span&gt;File(&lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;cacheDir&lt;/span&gt;+File.&lt;span style=&quot;color: #660e7a; font-style: italic; font-weight: bold;&quot;&gt;separator&lt;/span&gt;+&lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;product&lt;/span&gt;+&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;_&quot;&lt;/span&gt;+nextDate+&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;.gz&quot;&lt;/span&gt;)))));
            String header = &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;currentFileReader&lt;/span&gt;.readLine();
            System.&lt;span style=&quot;color: #660e7a; font-style: italic; font-weight: bold;&quot;&gt;out&lt;/span&gt;.println(&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;Header: &quot; &lt;/span&gt;+ header);
        }&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;else&lt;/span&gt;{
            &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;currentFileReader &lt;/span&gt;=&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;null&lt;/span&gt;;
        }
    }



    &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;private int &lt;/span&gt;processRawFile(File rawFile, File cacheFile, String s) {
        &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;int &lt;/span&gt;result = -&lt;span style=&quot;color: blue;&quot;&gt;1&lt;/span&gt;;

        String tempFile = &lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;cacheDir&lt;/span&gt;+File.&lt;span style=&quot;color: #660e7a; font-style: italic; font-weight: bold;&quot;&gt;separator&lt;/span&gt;+&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;temp_&quot;&lt;/span&gt;+&lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;product&lt;/span&gt;+&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;_&quot;&lt;/span&gt;+s+&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;.gz&quot;&lt;/span&gt;;
        OCHLDailyStat stats = &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new &lt;/span&gt;OCHLDailyStat();
        stats.setProduct(&lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;product&lt;/span&gt;);
        stats.setDay(s);
        Gson g = Util.&lt;span style=&quot;font-style: italic;&quot;&gt;gson&lt;/span&gt;();
        AtomicBoolean firstTrade = &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new &lt;/span&gt;AtomicBoolean(&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;false&lt;/span&gt;);
        &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;try &lt;/span&gt;(GZIPInputStream inputStream = &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new &lt;/span&gt;GZIPInputStream(&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new &lt;/span&gt;FileInputStream(rawFile));
            BufferedReader reader = &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new &lt;/span&gt;BufferedReader(&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new &lt;/span&gt;InputStreamReader(inputStream));
            GZIPOutputStream os = &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new &lt;/span&gt;GZIPOutputStream(&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new &lt;/span&gt;FileOutputStream(tempFile));
            BufferedWriter bw = &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new &lt;/span&gt;BufferedWriter(&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new &lt;/span&gt;OutputStreamWriter(os))) {


            String line = reader.readLine();

            &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;while&lt;/span&gt;(line!=&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;null&lt;/span&gt;){
                Ticker t = g.fromJson(line, Ticker.&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;class&lt;/span&gt;);

                &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;if&lt;/span&gt;(&lt;span style=&quot;color: #660e7a; font-weight: bold;&quot;&gt;product&lt;/span&gt;.equalsIgnoreCase(t.getProduct())){
                    &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;if&lt;/span&gt;(firstTrade.compareAndSet(&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;false&lt;/span&gt;, &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;true&lt;/span&gt;)){
                        stats.setOpen(t.getPrice());
                        stats.setHigh(t.getPrice());
                        stats.setLow(t.getPrice());
                    }
                    bw.write(line);
                    bw.newLine();
                    &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;if&lt;/span&gt;(t.getPrice()&amp;lt;stats.getLow()){
                        stats.setLow(t.getPrice());
                    }
                    &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;if&lt;/span&gt;(t.getPrice()&amp;gt;stats.getHigh()){
                        stats.setHigh(t.getPrice());
                    }
                    stats.setClose(t.getPrice());
                }
                line = reader.readLine();
            }

            bw.flush();
        } &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;catch &lt;/span&gt;(IOException e) {
            e.printStackTrace();
        }
        &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;try&lt;/span&gt;(BufferedOutputStream bos = &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new &lt;/span&gt;BufferedOutputStream(&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new &lt;/span&gt;GZIPOutputStream(&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new &lt;/span&gt;FileOutputStream(cacheFile)));
        BufferedInputStream bis = &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new &lt;/span&gt;BufferedInputStream(&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new &lt;/span&gt;GZIPInputStream(&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new &lt;/span&gt;FileInputStream(tempFile)))){

            String statsAsString = g.toJson(stats);
            statsAsString +=&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;&lt;/span&gt;;
            bos.write(statsAsString.getBytes());
            &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;byte&lt;/span&gt;[] buf = &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new byte&lt;/span&gt;[&lt;span style=&quot;color: blue;&quot;&gt;1024&lt;/span&gt;];
            &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;int &lt;/span&gt;b = -&lt;span style=&quot;color: blue;&quot;&gt;1&lt;/span&gt;;

            &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;while&lt;/span&gt;((b = bis.read(buf)) &amp;gt;-&lt;span style=&quot;color: blue;&quot;&gt;1&lt;/span&gt;){
                bos.write(buf,&lt;span style=&quot;color: blue;&quot;&gt;0&lt;/span&gt;,b);
            }
            bos.flush();
            result =&lt;span style=&quot;color: blue;&quot;&gt;0&lt;/span&gt;;

        }&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;catch &lt;/span&gt;(IOException e){
            e.printStackTrace();
        }
        File f = &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new &lt;/span&gt;File(tempFile);
        f.delete();

        &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;return &lt;/span&gt;result;
    }
}&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
One of the key tricks here was using a TypeAdapter for the Gson Json Parser the type that needed to be serialized and de-serialized was an ENUM called SIDE.&amp;nbsp; This has 2 valid options either BUY or SELL.&amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt;/*&lt;/span&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt;* Copyright (c) 2020. Ecocrypt.com&lt;/span&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt;* Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);&lt;/span&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt;* you may not use this file except in compliance with the License.&lt;/span&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt;* You may obtain a copy of the License at&lt;/span&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt;*     http://www.apache.org/licenses/LICENSE-2.0&lt;/span&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt;* Unless required by applicable law or agreed to in writing, software&lt;/span&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt;* distributed under the License is distributed on an &quot;AS IS&quot; BASIS,&lt;/span&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt;* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.&lt;/span&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt;* See the License for the specific language governing permissions and&lt;/span&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt;* limitations under the License.&lt;/span&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;*/&lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;package &lt;/span&gt;com.ecocrypt.backtesting.exchange;

&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;import &lt;/span&gt;com.google.gson.*;

&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;import &lt;/span&gt;java.lang.reflect.Type;

&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;public class &lt;/span&gt;SIDETypeAdapter &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;implements &lt;/span&gt;JsonSerializer&amp;lt;SIDE&amp;gt;,
        JsonDeserializer&amp;lt;SIDE&amp;gt; {


        &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;public &lt;/span&gt;SIDETypeAdapter() {
        }


    &lt;span style=&quot;color: olive;&quot;&gt;@Override&lt;/span&gt;&lt;span style=&quot;color: olive;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;public &lt;/span&gt;SIDE deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;throws &lt;/span&gt;JsonParseException {
        &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;return &lt;/span&gt;SIDE.&lt;span style=&quot;font-style: italic;&quot;&gt;get&lt;/span&gt;(jsonElement.getAsString());
    }

    &lt;span style=&quot;color: olive;&quot;&gt;@Override&lt;/span&gt;&lt;span style=&quot;color: olive;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;public &lt;/span&gt;JsonElement serialize(SIDE side, Type type, JsonSerializationContext jsonSerializationContext) {
        &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;return new &lt;/span&gt;JsonPrimitive(side.toString());
    }
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
Then using the Gson TypeAdapter is done in the GsonBuilder as follows:&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: navy; font-family: menlo; font-size: 9pt; font-weight: bold;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: navy; font-family: menlo; font-size: 9pt; font-weight: bold;&quot;&gt;package &lt;/span&gt;&lt;span style=&quot;background-color: white; font-family: menlo; font-size: 9pt;&quot;&gt;com.ecocrypt.backtesting.exchange;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;import &lt;/span&gt;com.google.gson.Gson;
&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;import &lt;/span&gt;com.google.gson.GsonBuilder;

&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;import &lt;/span&gt;java.text.SimpleDateFormat;
&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;import &lt;/span&gt;java.util.Calendar;
&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;import &lt;/span&gt;java.util.Date;

&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;public class &lt;/span&gt;Util {

    &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;public static &lt;/span&gt;Gson gson(){
        Gson g = &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new &lt;/span&gt;GsonBuilder()
                .setDateFormat(&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;yyyy-MM-dd&#39;T&#39;HH:mm:ss.SSSZ&quot;&lt;/span&gt;)
                .registerTypeAdapter(SIDE.&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;class&lt;/span&gt;, &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new &lt;/span&gt;SIDETypeAdapter())
                .create();
        &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;return &lt;/span&gt;g;
    }

    &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;public static &lt;/span&gt;String yyyyMMdd(Calendar c){
        &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;return &lt;/span&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;yyyyMMdd&lt;/span&gt;(c.getTime());
    }

    &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;private static &lt;/span&gt;String yyyyMMdd(Date time) {

        SimpleDateFormat sdf = &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new &lt;/span&gt;SimpleDateFormat(&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;yyyyMMdd&quot;&lt;/span&gt;);
        &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;return &lt;/span&gt;sdf.format(time);

    }
    &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;private static &lt;/span&gt;String yyyyMMdd(&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;long &lt;/span&gt;l){
        &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;return &lt;/span&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;yyyyMMdd&lt;/span&gt;(&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new &lt;/span&gt;Date(l));
    }
}&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The SIDE enum is show for completeness:&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: navy; font-family: menlo; font-size: 9pt; font-weight: bold;&quot;&gt;package &lt;/span&gt;&lt;span style=&quot;background-color: white; font-family: menlo; font-size: 9pt;&quot;&gt;com.ecocrypt.backtesting.exchange;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;public enum &lt;/span&gt;SIDE {
    &lt;span style=&quot;color: #660e7a; font-style: italic; font-weight: bold;&quot;&gt;BUY &lt;/span&gt;{
        &lt;span style=&quot;color: olive;&quot;&gt;@Override&lt;/span&gt;&lt;span style=&quot;color: olive;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;public &lt;/span&gt;String toString() {
            &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;return &lt;/span&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;BUY&quot;&lt;/span&gt;;
        }
    },
    &lt;span style=&quot;color: #660e7a; font-style: italic; font-weight: bold;&quot;&gt;SELL&lt;/span&gt;{
        &lt;span style=&quot;color: olive;&quot;&gt;@Override&lt;/span&gt;&lt;span style=&quot;color: olive;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;public &lt;/span&gt;String toString() {
            &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;return &lt;/span&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;SELL&quot;&lt;/span&gt;;
        }
    };
    &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;public static &lt;/span&gt;SIDE get(String s){
        &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;if&lt;/span&gt;(s.equalsIgnoreCase(&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;BUY&quot;&lt;/span&gt;)){
            &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;return &lt;/span&gt;&lt;span style=&quot;color: #660e7a; font-style: italic; font-weight: bold;&quot;&gt;BUY&lt;/span&gt;;
        }&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;else&lt;/span&gt;{
            &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;return &lt;/span&gt;&lt;span style=&quot;color: #660e7a; font-style: italic; font-weight: bold;&quot;&gt;SELL&lt;/span&gt;;
        }
    }
}&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://blog.ecocrypt.com/feeds/2758418638957009546/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.ecocrypt.com/2020/02/bitcoin-trading-algorithm-back-testing.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/2758418638957009546'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/2758418638957009546'/><link rel='alternate' type='text/html' href='http://blog.ecocrypt.com/2020/02/bitcoin-trading-algorithm-back-testing.html' title='Bitcoin Trading Algorithm Back Testing Project Historical Data Setup'/><author><name>Q. B.</name><uri>http://www.blogger.com/profile/08502256579896627307</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9e-xzbIV9ABn9OHlgiNbVBplXewci_K0F0yYD52TW8scrP1IbQfmHRVQKv9uy5wULo5xDNj8aPq51gJ4O84pgc3K3HFXWP1rYGbQMXPdcXeuEyzvl9lGkIWrLVbghNjY/s220/JetCloud.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3158873714071458599.post-8739154919533150543</id><published>2020-02-06T21:34:00.002-06:00</published><updated>2020-02-07T14:35:57.413-06:00</updated><title type='text'>Classic Visitor Pattern in Java</title><content type='html'>First let&#39;s take a quick look at the classic visitor pattern.&lt;br /&gt;
When do you want to use the visitor:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;A fixed number of objects that you want to be able to apply operations on.&lt;/li&gt;
&lt;li&gt;These objects don&#39;t currently have the ability to perform the operations needed.&lt;/li&gt;
&lt;li&gt;Limited ability access or change the behavior of the objects.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0hOyL5hWZzM6XRMzqMeBKp3cnPtPL1eSljayyhecOaaRYn-DC-BI4HBG1Wu_UNViMikQUNUthy4nxnZ49kYSyQFAbpxsuZ3r12DK5RL2RAZnY3Slz09YMDWS_Lt52_a30XrAuDbBm4FA/s1600/ClassicVisitor.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;529&quot; data-original-width=&quot;680&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0hOyL5hWZzM6XRMzqMeBKp3cnPtPL1eSljayyhecOaaRYn-DC-BI4HBG1Wu_UNViMikQUNUthy4nxnZ49kYSyQFAbpxsuZ3r12DK5RL2RAZnY3Slz09YMDWS_Lt52_a30XrAuDbBm4FA/s1600/ClassicVisitor.png&quot; /&gt;&lt;/a&gt;The basic idea of the visitor pattern is this: Starting with a group of related objects say, Shapes, where these shapes may be squares and circles etc.. which do not know how to calculate their perimeters and you either don&#39;t have access to or don&#39;t want to code the logic in the shape.&amp;nbsp; Therefore we need a mechanism to calculate the perimeter (or area or other feature) without modifying the original code.&amp;nbsp; However, we do have the good fortune of having each Shape implement an &quot;accept&quot; method which accepts a visitor.&lt;br /&gt;
&lt;br /&gt;
So we develop a concrete &quot;PerimeterShapeVisitor&quot; which knows how to calculate the perimeter for all known shapes.&amp;nbsp; This class does not know how to do anything else.&amp;nbsp; Also this class must implement the special &quot;ShapeVisitor&quot; interface.&amp;nbsp; This allows polymorphism of the java language to select which shape logic needs to be invoked.&amp;nbsp; Key code samples are discussed below.&amp;nbsp; The running code can be found at&amp;nbsp;&lt;a href=&quot;https://gist.github.com/qboiler/da9c3dbb4ad6b34c74199b970cafc9c3&quot; target=&quot;_blank&quot;&gt;GIST Classic Visitor&lt;/a&gt;&lt;br /&gt;
------------------------------------------------------------------------------------------------&lt;br /&gt;
&lt;b&gt;Classic Visitor Code&lt;/b&gt;&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Each shape must implement the Shape interface to &quot;accept&quot; a visitor e.g.&lt;br /&gt;&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;public interface &lt;/span&gt;Shape {
    &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;void &lt;/span&gt;accept(ShapeVisitor v);
}

&lt;/pre&gt;
&lt;pre style=&quot;caret-color: rgb(0, 0, 0); overflow-wrap: break-word; text-size-adjust: auto; white-space: pre-wrap;&quot;&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Each ShapeVisitor (e.g. the PerimeterVisitor) must implement the ShapeVisitor&lt;br /&gt;&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;public interface &lt;/span&gt;ShapeVisitor {
    &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;void &lt;/span&gt;visit(Square s);
    &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;void &lt;/span&gt;visit(Circle c);
    &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;void &lt;/span&gt;visit(IsoscelesTriangle t);
}

&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;And the Concrete Perimeter Visitor Looks like this:&lt;br /&gt;&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;public class &lt;/span&gt;PerimeterVisitor &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;implements &lt;/span&gt;ShapeVisitor{

    &lt;span style=&quot;color: olive;&quot;&gt;@Override&lt;/span&gt;&lt;span style=&quot;color: olive;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;public void &lt;/span&gt;visit(Square s) {
        &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;double &lt;/span&gt;p = s.side()*&lt;span style=&quot;color: blue;&quot;&gt;4&lt;/span&gt;;
        System.&lt;span style=&quot;color: #660e7a; font-style: italic; font-weight: bold;&quot;&gt;out&lt;/span&gt;.println(&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;Square perimeter: &quot; &lt;/span&gt;+ p);
    }

    &lt;span style=&quot;color: olive;&quot;&gt;@Override&lt;/span&gt;&lt;span style=&quot;color: olive;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;public void &lt;/span&gt;visit(Circle c) {
        &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;double &lt;/span&gt;radius = c.radius();
        &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;double &lt;/span&gt;p = Math.&lt;span style=&quot;color: #660e7a; font-style: italic; font-weight: bold;&quot;&gt;PI&lt;/span&gt;*&lt;span style=&quot;color: blue;&quot;&gt;2&lt;/span&gt;*radius;
        System.&lt;span style=&quot;color: #660e7a; font-style: italic; font-weight: bold;&quot;&gt;out&lt;/span&gt;.println(&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;Circle perimeter: &quot; &lt;/span&gt;+ p);

    }

    &lt;span style=&quot;color: olive;&quot;&gt;@Override&lt;/span&gt;&lt;span style=&quot;color: olive;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;public void &lt;/span&gt;visit(IsoscelesTriangle t) {
        &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;double &lt;/span&gt;base = t.base();
        &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;double &lt;/span&gt;height = t.height();
        &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;double &lt;/span&gt;p = base+Math.&lt;span style=&quot;font-style: italic;&quot;&gt;sqrt&lt;/span&gt;(base*base + &lt;span style=&quot;color: blue;&quot;&gt;4&lt;/span&gt;*height*height);
        System.&lt;span style=&quot;color: #660e7a; font-style: italic; font-weight: bold;&quot;&gt;out&lt;/span&gt;.println(&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&quot;Isosolese Triangle perimeter: &quot; &lt;/span&gt;+ p);
    }
}&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
Running the Visitor Test:&lt;br /&gt;
&lt;pre style=&quot;background-color: white; font-size: 9pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;public static void &lt;/span&gt;main(String[] args){
    List&amp;lt;Shape&amp;gt; shapeList;
    shapeList = &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new &lt;/span&gt;ArrayList&amp;lt;&amp;gt;();

    shapeList.add(&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new &lt;/span&gt;Circle(&lt;span style=&quot;color: blue;&quot;&gt;1&lt;/span&gt;));
    shapeList.add(&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new &lt;/span&gt;Square(&lt;span style=&quot;color: blue;&quot;&gt;1&lt;/span&gt;));
    shapeList.add(&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new &lt;/span&gt;IsoscelesTriangle(&lt;span style=&quot;color: blue;&quot;&gt;1&lt;/span&gt;, &lt;span style=&quot;color: blue;&quot;&gt;1&lt;/span&gt;));
    PerimeterVisitor v = &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new &lt;/span&gt;PerimeterVisitor();
    &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;for &lt;/span&gt;(Shape s:shapeList) {
        s.accept(v);
    }

}&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;menlo&amp;quot;;&quot;&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
Produces the following output:&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;Circle perimeter: 6.283185307179586&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;Square perimeter: 4.0&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;Isosceles Triangle perimeter: 3.23606797749979&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
SEQUENCE OF EVENTS IN THE VISITOR:&lt;/div&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;&amp;nbsp;A Shape invokes the accept(v) method passing a visitor associated with whatever operation it would like to perform.&lt;/li&gt;
&lt;li&gt;Since Shape is an interface, polymorphism of the language will dynamically bind the &quot;accept(v)&quot; method associated with the concrete shape, e.g. for a Circle, the Circle&#39;s accept method will be invoked.&amp;nbsp; This decision is made at run time&lt;/li&gt;
&lt;li&gt;The accept method will the invoke the &quot;visit&quot; method of the PerimeterShapeVisitor Class, and the method selected will be the Calculate&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;&lt;/pre&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://blog.ecocrypt.com/feeds/8739154919533150543/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.ecocrypt.com/2020/02/classic-visitor-pattern-in-java.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/8739154919533150543'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/8739154919533150543'/><link rel='alternate' type='text/html' href='http://blog.ecocrypt.com/2020/02/classic-visitor-pattern-in-java.html' title='Classic Visitor Pattern in Java'/><author><name>Q. B.</name><uri>http://www.blogger.com/profile/08502256579896627307</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9e-xzbIV9ABn9OHlgiNbVBplXewci_K0F0yYD52TW8scrP1IbQfmHRVQKv9uy5wULo5xDNj8aPq51gJ4O84pgc3K3HFXWP1rYGbQMXPdcXeuEyzvl9lGkIWrLVbghNjY/s220/JetCloud.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0hOyL5hWZzM6XRMzqMeBKp3cnPtPL1eSljayyhecOaaRYn-DC-BI4HBG1Wu_UNViMikQUNUthy4nxnZ49kYSyQFAbpxsuZ3r12DK5RL2RAZnY3Slz09YMDWS_Lt52_a30XrAuDbBm4FA/s72-c/ClassicVisitor.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3158873714071458599.post-1531243818328254369</id><published>2020-02-05T14:39:00.000-06:00</published><updated>2020-02-05T14:47:43.999-06:00</updated><title type='text'>Performance of the parallelSort method introduced in Java SE 8.</title><content type='html'>Taking a quick look at a feature added to java in SE8.&amp;nbsp; This is a parallel Array sort, and it takes advantage of multiple processors to sort arrays more quickly.&amp;nbsp; The feature is really easy to use, simply invoke&amp;nbsp;&lt;span style=&quot;background-color: white; font-family: &amp;quot;menlo&amp;quot;; font-size: 9pt;&quot;&gt;Arrays.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;menlo&amp;quot;; font-size: 9pt; font-style: italic;&quot;&gt;parallelSort&lt;/span&gt;&lt;span style=&quot;background-color: white; font-family: &amp;quot;menlo&amp;quot;; font-size: 9pt;&quot;&gt;(input);&lt;/span&gt;. instead of the old&amp;nbsp;&lt;span style=&quot;background-color: white; font-family: &amp;quot;menlo&amp;quot;; font-size: 9pt;&quot;&gt;Arrays.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;menlo&amp;quot;; font-size: 9pt; font-style: italic;&quot;&gt;sort&lt;/span&gt;&lt;span style=&quot;background-color: white; font-family: &amp;quot;menlo&amp;quot;; font-size: 9pt;&quot;&gt;(input);&lt;/span&gt;.&amp;nbsp; That is it.&amp;nbsp; Lets look at a simple performance test with results:&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: white; font-size: 9pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;b&gt;            size %Faster               serial ns      parallel ns
              10 -83.5% Faster -&amp;gt;          1,908            3,502
             100 17.0%  Faster -&amp;gt;          5,496            4,560
            1000 65.3%  Faster -&amp;gt;        149,033           51,768
           10000 5.1%   Faster -&amp;gt;        488,044          463,089
          100000 57.7%  Faster -&amp;gt;      6,153,690        2,601,578
         1000000 56.2%  Faster -&amp;gt;     72,704,992       31,827,891
        10000000 58.2%  Faster -&amp;gt;    855,719,416      357,283,539&lt;/b&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; font-size: 9pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;b&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;&lt;/pre&gt;
Some Notes about this test:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;The sort and parallel sort are tested on the exact same Array.&amp;nbsp; An array is generated using the syntactic sugar of $\lambda$ expressions and then duplicated with a System.arrayCopy(...).&amp;nbsp; as&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;span style=&quot;color: navy; font-family: menlo; font-size: 9pt; font-weight: bold;&quot;&gt;private double&lt;/span&gt;&lt;span style=&quot;background-color: white; font-family: menlo; font-size: 9pt;&quot;&gt;[] randomArray(&lt;/span&gt;&lt;span style=&quot;color: navy; font-family: menlo; font-size: 9pt; font-weight: bold;&quot;&gt;int &lt;/span&gt;&lt;span style=&quot;background-color: white; font-family: menlo; font-size: 9pt;&quot;&gt;size) {&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;    &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;double&lt;/span&gt;[] result = &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new double&lt;/span&gt;[size];
    Random randGen = &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;new &lt;/span&gt;Random();

    &lt;span style=&quot;color: grey; font-style: italic;&quot;&gt;// Use the parallel Set All function to generate this random number quickly.&lt;/span&gt;&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt;    &lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; font-family: Menlo; font-size: 9pt;&quot;&gt;    Arrays.&lt;span style=&quot;font-style: italic;&quot;&gt;parallelSetAll&lt;/span&gt;(result, value -&amp;gt; {
        &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;return &lt;/span&gt;&lt;span style=&quot;color: #660e7a;&quot;&gt;randGen&lt;/span&gt;.nextDouble() * &lt;span style=&quot;color: blue;&quot;&gt;10000&lt;/span&gt;;
    });
    &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;return &lt;/span&gt;result;
}&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;The test is run 9 times without recording the result.&amp;nbsp; This is to make sure that the JVM as &quot;warmed up&quot; and the hotspot will not experience a compile pause.&lt;/li&gt;
&lt;li&gt;Prior to each sort a System.gc() is invoked to give the JVM a chance to clean up any garbage.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
Looking at the results on a 4 core iMac:&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;Hardware Overview:&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot;, courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot;, courier, monospace; font-size: x-small;&quot;&gt;Model Name:&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot;, courier, monospace; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot;, courier, monospace; font-size: x-small;&quot;&gt;iMac&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;b&gt;Processor Name:&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;Quad-Core Intel Core i5&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &lt;/span&gt;Processor Speed:&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;3.2 GHz&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &lt;/span&gt;Number of Processors:&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;1&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;b&gt;Total Number of Cores:&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;4&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &lt;/span&gt;L2 Cache (per Core):&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;256 KB&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &lt;/span&gt;L3 Cache:&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;6 MB&lt;/span&gt;&lt;/div&gt;
&lt;style type=&quot;text/css&quot;&gt;
p.p1 {margin: 0.0px 0.0px 0.0px 140.9px; text-indent: -141.0px; font: 11.0px &#39;Helvetica Neue&#39;; color: #000000}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; color: #000000; min-height: 14.0px}
span.Apple-tab-span {white-space:pre}
&lt;/style&gt;












&lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;Memory:&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;32 GB&lt;/span&gt;&lt;/div&gt;
Based on the above results it is clear that an array must be at least 100 elements in size to overcome the cost of using multiple threads for the sorting, however at 100,000 a consistent cost savings of 50%+ exists.&lt;br /&gt;
The gist for this is:&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/qboiler/5e6e1d8cb983c092648917722d0b532e.js&quot;&gt;&lt;/script&gt;

</content><link rel='replies' type='application/atom+xml' href='http://blog.ecocrypt.com/feeds/1531243818328254369/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.ecocrypt.com/2020/02/performance-of-parallelsort-method.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/1531243818328254369'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/1531243818328254369'/><link rel='alternate' type='text/html' href='http://blog.ecocrypt.com/2020/02/performance-of-parallelsort-method.html' title='Performance of the parallelSort method introduced in Java SE 8.'/><author><name>Q. B.</name><uri>http://www.blogger.com/profile/08502256579896627307</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9e-xzbIV9ABn9OHlgiNbVBplXewci_K0F0yYD52TW8scrP1IbQfmHRVQKv9uy5wULo5xDNj8aPq51gJ4O84pgc3K3HFXWP1rYGbQMXPdcXeuEyzvl9lGkIWrLVbghNjY/s220/JetCloud.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3158873714071458599.post-6823500193524926744</id><published>2020-02-04T21:17:00.003-06:00</published><updated>2020-02-04T21:20:30.505-06:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="java 13"/><category scheme="http://www.blogger.com/atom/ns#" term="java on mac"/><category scheme="http://www.blogger.com/atom/ns#" term="libexec"/><category scheme="http://www.blogger.com/atom/ns#" term="multiple jvms on mac"/><title type='text'>Installing Multiple JVMs on a Mac Manually and Switching Manually with latest Default</title><content type='html'>This blog will show you now to install multiple version of java manually on a Mac, and switch between them manually.&amp;nbsp; It will also show how to set and maintain the default java to the &quot;latest&quot; version.&lt;br /&gt;
&lt;br /&gt;
First, Check if there are any version of java installed.&amp;nbsp; I just bought a 2013 iMac on Ebay, and set it up tabula rosa.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;iMac:~ $ &lt;b&gt;/usr/libexec/java_home -V&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;Unable to find any JVMs matching version &quot;(null)&quot;.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;Matching Java Virtual Machines (0):&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small; font-variant-ligatures: no-common-ligatures;&quot;&gt;Default Java Virtual Machines (0):&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small; font-variant-ligatures: no-common-ligatures;&quot;&gt;No Java runtime present, try --request to install.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
Mac OS looks for java in the /Library/Java/JavaVirtualMachines/ directory.&amp;nbsp; Therefore if we download a valid Java JDK, and &quot;copy&quot; the un-archived structure over to that directory, we will see that it works.&amp;nbsp; This is done as follows.&lt;br /&gt;
&lt;br /&gt;
Java 13 is available from&amp;nbsp;&lt;a href=&quot;https://jdk.java.net/13/&quot; target=&quot;_blank&quot;&gt;Java 13 link - &amp;gt; https://jdk.java.net/13/&lt;/a&gt;&amp;nbsp;or it can obtained via wget with:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;iMac:java $ &lt;b&gt;wget https://download.java.net/java/GA/jdk13.0.2/d4173c853231432d94f001e99d882ca7/8/GPL/openjdk-13.0.2_osx-x64_bin.tar.gz&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;--2020-02-04 19:01:16--&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &lt;/span&gt;https://download.java.net/java/GA/jdk13.0.2/d4173c853231432d94f001e99d882ca7/8/GPL/openjdk-13.0.2_osx-x64_bin.tar.gz&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;Resolving download.java.net (download.java.net)... 104.87.12.11&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;Connecting to download.java.net (download.java.net)|104.87.12.11|:443... connected.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;HTTP request sent, awaiting response... 200 OK&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;Length: 189969691 (181M) [application/x-gzip]&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;Saving to: ‘openjdk-13.0.2_osx-x64_bin.tar.gz’&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small; font-variant-ligatures: no-common-ligatures;&quot;&gt;openjdk-13.0.2_osx-x64_bin.tar.gz&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small; font-variant-ligatures: no-common-ligatures;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small; font-variant-ligatures: no-common-ligatures;&quot;&gt;7%[====&amp;gt; &lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small; font-variant-ligatures: no-common-ligatures;&quot;&gt;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small; font-variant-ligatures: no-common-ligatures;&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small; font-variant-ligatures: no-common-ligatures;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small; font-variant-ligatures: no-common-ligatures;&quot;&gt;13.50M &lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small; font-variant-ligatures: no-common-ligatures;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small; font-variant-ligatures: no-common-ligatures;&quot;&gt;254KB/s&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small; font-variant-ligatures: no-common-ligatures;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small; font-variant-ligatures: no-common-ligatures;&quot;&gt;eta 9m 8s &lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small; font-variant-ligatures: no-common-ligatures;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
Once this has been downloaded:&amp;nbsp; it can be extracted and copied or move to the /Library/Java/JavaVirtualMachines/ directory.&lt;br /&gt;
&lt;br /&gt;
Extract with the &quot;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;b&gt;tar -xvzf openjdk-13.0.2_osx-x64_bin.tar.gz&lt;/b&gt;&lt;/span&gt;&quot; which says eXtract Verbose Compressed(z) Filesystem.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;$ tar -xvzf openjdk-13.0.2_osx-x64_bin.tar.gz&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;$ mv jdk-13.0.1.jdk/ /Library/Java/JavaVirtualMachines/&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Re-running the /usr/libexec/java_home -V command gives:&lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;$ &lt;b&gt;/usr/libexec/java_home -V&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;Matching Java Virtual Machines (1):&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;13.0.1, x86_64:&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;&quot;OpenJDK 13.0.1&quot;&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;/Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small; font-variant-ligatures: no-common-ligatures;&quot;&gt;/Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
And &#39;java -version&#39; on the command line gives:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;$ &lt;b&gt;java -version&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;openjdk version &quot;13.0.1&quot; 2019-10-15&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;OpenJDK Runtime Environment (build 13.0.1+9)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;style type=&quot;text/css&quot;&gt;
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000}
span.s1 {font-variant-ligatures: no-common-ligatures}
&lt;/style&gt;





&lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;OpenJDK 64-Bit Server VM (build 13.0.1+9, mixed mode, sharing)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
After downloading and installing several different version of java (which included creating an oracle account, and getting one of the &quot;legacy/archived&quot; version of java from the oracle website) my lib execute for java home looked like this:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;$ &lt;b&gt;/usr/libexec/java_home -V&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;Matching Java Virtual Machines (4):&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;13.0.1, x86_64:&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;&quot;OpenJDK 13.0.1&quot;&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;/Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;11.0.6, x86_64:&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;&quot;Java SE 11.0.6&quot;&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;/Library/Java/JavaVirtualMachines/jdk-11.0.6.jdk/Contents/Home&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;1.8.0_241, x86_64:&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;&quot;Java SE 8&quot;&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;1.7.0_80, x86_64:&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;&quot;Java SE 7&quot;&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;/Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;style type=&quot;text/css&quot;&gt;
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; min-height: 13.0px}
span.s1 {font-variant-ligatures: no-common-ligatures}
span.Apple-tab-span {white-space:pre}
&lt;/style&gt;









&lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;/Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
Now it might make sense to just add some convenience methods to the environment files.&amp;nbsp; Basically this is the step to make it very easy to switch to different version of java on the command line:&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;PLACE THIS IN YOUR ~/.bash_profile or other startup environment script directory&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;export&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &lt;/span&gt;JAVA_HOME_7=$(/usr/libexec/java_home -v1.7)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;export&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &lt;/span&gt;JAVA_HOME_8=$(/usr/libexec/java_home -v1.8)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;#export JAVA_HOME_9=$(/usr/libexec/java_home -v9)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;#export JAVA_HOME_10=$(/usr/libexec/java_home -v10)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;export&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &lt;/span&gt;JAVA_HOME_11=$(/usr/libexec/java_home -v11)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;export&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &lt;/span&gt;JAVA_HOME_13=$(/usr/libexec/java_home -v13)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;alias java7=&#39;export JAVA_HOME=$JAVA_HOME_7&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;alias java8=&#39;export JAVA_HOME=$JAVA_HOME_8&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;#alias java9=&#39;export JAVA_HOME=$JAVA_HOME_9&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;#alias java10=&#39;export JAVA_HOME=$JAVA_HOME_10&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;alias java11=&#39;export JAVA_HOME=$JAVA_HOME_11&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;#alias java12=&#39;export JAVA_HOME=$JAVA_HOME_12&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;alias java13=&#39;export JAVA_HOME=$JAVA_HOME_13&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;#default&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;style type=&quot;text/css&quot;&gt;
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; min-height: 13.0px}
span.s1 {font-variant-ligatures: no-common-ligatures}
&lt;/style&gt;


















&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;java13&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
Source your newly modified .bash_profile (this only needs to be done once, and not after a login logout...)&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;$ &lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;source ~/.bash_profile&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
Now switching from java13 to java7 is as easy as typing $ java7 at the command line E.G.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;iMac:~ $ &lt;b&gt;java7&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;iMac:~ $ &lt;b&gt;java -version&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;java version &quot;1.7.0_80&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;Java(TM) SE Runtime Environment (build 1.7.0_80-b15)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;iMac:~ $ &lt;b&gt;java8&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;iMac:~ $ &lt;b&gt;java -version&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;java version &quot;1.8.0_241&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;Java(TM) SE Runtime Environment (build 1.8.0_241-b07)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;Java HotSpot(TM) 64-Bit Server VM (build 25.241-b07, mixed mode)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;iMac:~ $ &lt;b&gt;java11&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;iMac:~ $ &lt;b&gt;java -version&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;java version &quot;11.0.6&quot; 2020-01-14 LTS&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;Java(TM) SE Runtime Environment 18.9 (build 11.0.6+8-LTS)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.6+8-LTS, mixed mode)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;iMac:~ $ &lt;b&gt;java13&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;iMac:~ $ &lt;b&gt;java -version&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;openjdk version &quot;13.0.1&quot; 2019-10-15&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;OpenJDK Runtime Environment (build 13.0.1+9)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;style type=&quot;text/css&quot;&gt;
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000}
span.s1 {font-variant-ligatures: no-common-ligatures}
&lt;/style&gt;





















&lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;OpenJDK 64-Bit Server VM (build 13.0.1+9, mixed mode, sharing)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;style type=&quot;text/css&quot;&gt;
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; min-height: 13.0px}
span.s1 {font-variant-ligatures: no-common-ligatures}
&lt;/style&gt;&lt;style type=&quot;text/css&quot;&gt;
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; min-height: 13.0px}
span.s1 {font-variant-ligatures: no-common-ligatures}
&lt;/style&gt;&lt;style type=&quot;text/css&quot;&gt;
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; min-height: 13.0px}
span.s1 {font-variant-ligatures: no-common-ligatures}
span.Apple-tab-span {white-space:pre}
&lt;/style&gt;&lt;style type=&quot;text/css&quot;&gt;
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; min-height: 13.0px}
span.s1 {font-variant-ligatures: no-common-ligatures}
&lt;/style&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.ecocrypt.com/feeds/6823500193524926744/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.ecocrypt.com/2020/02/installing-multiple-jvms-on-mac.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/6823500193524926744'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/6823500193524926744'/><link rel='alternate' type='text/html' href='http://blog.ecocrypt.com/2020/02/installing-multiple-jvms-on-mac.html' title='Installing Multiple JVMs on a Mac Manually and Switching Manually with latest Default'/><author><name>Q. B.</name><uri>http://www.blogger.com/profile/08502256579896627307</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9e-xzbIV9ABn9OHlgiNbVBplXewci_K0F0yYD52TW8scrP1IbQfmHRVQKv9uy5wULo5xDNj8aPq51gJ4O84pgc3K3HFXWP1rYGbQMXPdcXeuEyzvl9lGkIWrLVbghNjY/s220/JetCloud.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3158873714071458599.post-8184999736652319401</id><published>2020-02-03T00:11:00.000-06:00</published><updated>2020-02-03T00:12:15.163-06:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="codejam codewithgoogle flyswatter java mathjax"/><title type='text'>Fly Swatter Problem Google Code Jam 2008 Qualifying Round Problem 3</title><content type='html'>The Fly Swatter problem was quite challenging.&lt;br /&gt;
This solution uses an &quot;Exact&quot; closed form solution.&lt;br /&gt;
&lt;br /&gt;
Basic problem summary: calculate the probability of hitting a fly with a tennis racket.&lt;br /&gt;
CodeJam&#39;s Detailed statement:&amp;nbsp;&amp;nbsp;&lt;a href=&quot;https://code.google.com/codejam/contest/32013/dashboard#s=p2&amp;amp;a=2&quot;&gt;Code Jam 2008 Qualifying Round P3&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
The basic idea is the following:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Divided the Tennis racket into 4 symmetric quadrants&lt;/li&gt;
&lt;li&gt;Calculate the area where the fly would be able to safely fly through&lt;/li&gt;
&lt;li&gt;Calculate the total Area&lt;/li&gt;
&lt;li&gt;Solution 1-safeArea/totalArea is the solution.&amp;nbsp; format and maintain 6 sig figs.&lt;/li&gt;
&lt;/ul&gt;
Prior to really diving into this problem there is a bit of Trigonometry that must be programmed. Specifically, we will be required to calculate the area of a &quot;chord&quot; of a circle.&amp;nbsp; For the most part equations of this assume that $Area = f(\theta,r) \stackrel{\bullet}{\equiv} \theta&amp;nbsp; $.&amp;nbsp; However, we will need this in the form $Area = f(x_{1},x_{2},r) \space where \space x_{1} ,&amp;nbsp; x_{2}&amp;nbsp; $ are the x-coordinates of the 2 points of the chord.&amp;nbsp; So the Area of the chord in a usable format for this problem becomes: $$ { 1 \over {2}} r^2 ( 2 \arcsin{{l}\over{2r}}) - \sin{(2 \arcsin{l\over{2r}})}$$ where $ l $ is the length of the chord.&lt;br /&gt;
Or In Code Calculate the Area of a Chord:&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/qboiler/2f18ac923354d8842e1cdba751b30116.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;span style=&quot;text-align: center;&quot;&gt;The North-East Case:&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;div style=&quot;text-align: start;&quot;&gt;
$$Area = gap^{2}&amp;nbsp; -&amp;nbsp; {1 \over 2} (xTwo -&amp;nbsp; X_{RIM \space yTwo} ) * (yTwo - X_{RIM \space xTwo}) + ChordArea (X_{RIM \space yTwo},X_{RIM \space xTwo})$$,&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiR8qKzfMrnJrnWMg34oqLggYKsk_J7CPrNlCkZx-yldVe9-D6yJkyZt3EWHbHPAACzwAx2h_B-pv4auT5H3jfyBjEeA4lcZL49ETcq06q9Z_QHPDM_UYBbAyiEmcEd5ywAtoUJhS3U1r4/s1600/FlySwatterNECase.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1079&quot; data-original-width=&quot;1600&quot; height=&quot;215&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiR8qKzfMrnJrnWMg34oqLggYKsk_J7CPrNlCkZx-yldVe9-D6yJkyZt3EWHbHPAACzwAx2h_B-pv4auT5H3jfyBjEeA4lcZL49ETcq06q9Z_QHPDM_UYBbAyiEmcEd5ywAtoUJhS3U1r4/s320/FlySwatterNECase.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;
West East Case:&lt;br /&gt;
$$ Area = gap*(yOne - RIM_{y \space xTwo}) + {{1 \over 2} (RIM_{y \space xOne} - RIM_{y \space xTwo})} +  ChordArea (X_{RIM \space xTwo},X_{RIM \space xOne})$$&lt;br /&gt;
OR IN CODE In Code Area Calc for West-East Case:&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/qboiler/b5af5500d2442185a95645856d9c4f12.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrKaOtPQBXaopxTRbwKzesq0BqoJY0uBrn-3t8FPHwuWIE-4cyXGme0EoMigMFMdj02p3__fbwMhu68rlCTrRfUGVDK5eGUIjMVoqOEdP5mUFMCh3o60MhIg8AOF0jwiWjHRxy8xgGCB8/s1600/FlySwatterWECase.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1095&quot; data-original-width=&quot;1343&quot; height=&quot;260&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrKaOtPQBXaopxTRbwKzesq0BqoJY0uBrn-3t8FPHwuWIE-4cyXGme0EoMigMFMdj02p3__fbwMhu68rlCTrRfUGVDK5eGUIjMVoqOEdP5mUFMCh3o60MhIg8AOF0jwiWjHRxy8xgGCB8/s320/FlySwatterWECase.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;br /&gt;
For The North South And West South Cases: the code with picture is self explanatory, see the code at the bottom of the blog or on Git HUB&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiivDRl5UYjAGZWA-M94zWq4gOSbJi68a_kbyKctK8Ozoil29DUxrUQGuQuYVwXzpF6WOFXg0mkkq_vIw8Ci0z_Nn40Pg6ZuVYAcPWN7-bH-DtTxb4oj8sfSeAZT8sb6A6UYdxDRHuywWs/s1600/FlySwatterNSCase.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;753&quot; data-original-width=&quot;1600&quot; height=&quot;150&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiivDRl5UYjAGZWA-M94zWq4gOSbJi68a_kbyKctK8Ozoil29DUxrUQGuQuYVwXzpF6WOFXg0mkkq_vIw8Ci0z_Nn40Pg6ZuVYAcPWN7-bH-DtTxb4oj8sfSeAZT8sb6A6UYdxDRHuywWs/s320/FlySwatterNSCase.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtdmLmsSm1304l8syuR_kL96BPwJlPuBFwtxGYrXz-scwUJGdfClOWpBH32B_fiYYJUoDOPyEjbdD6fGvDTeEv7DIcsBT82UZYN2u_KC8clmih6XPYK0fJatkZp-fdlTX-E0h6O5TnLbA/s1600/FlySwatterWSCase.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1112&quot; data-original-width=&quot;1304&quot; height=&quot;272&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtdmLmsSm1304l8syuR_kL96BPwJlPuBFwtxGYrXz-scwUJGdfClOWpBH32B_fiYYJUoDOPyEjbdD6fGvDTeEv7DIcsBT82UZYN2u_KC8clmih6XPYK0fJatkZp-fdlTX-E0h6O5TnLbA/s320/FlySwatterWSCase.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/qboiler/20764ddc79bc6308367316912a932124.js&quot;&gt;&lt;/script&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://blog.ecocrypt.com/feeds/8184999736652319401/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.ecocrypt.com/2020/02/fly-swatter-problem-google-code-jam.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/8184999736652319401'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/8184999736652319401'/><link rel='alternate' type='text/html' href='http://blog.ecocrypt.com/2020/02/fly-swatter-problem-google-code-jam.html' title='Fly Swatter Problem Google Code Jam 2008 Qualifying Round Problem 3'/><author><name>Q. B.</name><uri>http://www.blogger.com/profile/08502256579896627307</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9e-xzbIV9ABn9OHlgiNbVBplXewci_K0F0yYD52TW8scrP1IbQfmHRVQKv9uy5wULo5xDNj8aPq51gJ4O84pgc3K3HFXWP1rYGbQMXPdcXeuEyzvl9lGkIWrLVbghNjY/s220/JetCloud.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiR8qKzfMrnJrnWMg34oqLggYKsk_J7CPrNlCkZx-yldVe9-D6yJkyZt3EWHbHPAACzwAx2h_B-pv4auT5H3jfyBjEeA4lcZL49ETcq06q9Z_QHPDM_UYBbAyiEmcEd5ywAtoUJhS3U1r4/s72-c/FlySwatterNECase.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3158873714071458599.post-651011804216758682</id><published>2012-10-21T22:00:00.000-05:00</published><updated>2012-10-21T22:00:02.672-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="dock freeze"/><category scheme="http://www.blogger.com/atom/ns#" term="killall"/><category scheme="http://www.blogger.com/atom/ns#" term="mountain lion"/><category scheme="http://www.blogger.com/atom/ns#" term="osx"/><title type='text'>Mountain Lion Dock Freeze.</title><content type='html'>This is quite frustrating,  the Mountain Lion Dock Freezes.  WAY to often.
What do you do when this happens?&lt;br /&gt;
&lt;br /&gt;
SOME OPTIONS: &lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;&amp;nbsp;HARD REBOOT ( not fun...)&lt;/li&gt;
&lt;li&gt;killall Dock (reqires access to a terminal)&lt;/li&gt;
&lt;/ol&gt;
Because this happens often, a habit has formed to make sure to keep a terminal is always open.&amp;nbsp; Then just switch via the apple in the upper left, and invoke&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;&quot;&gt;PROMPT $ killall Dock&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
Shortest blog post I ever wrote... Just trying to get the word out...</content><link rel='replies' type='application/atom+xml' href='http://blog.ecocrypt.com/feeds/651011804216758682/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.ecocrypt.com/2012/10/mountain-lion-dock-freeze.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/651011804216758682'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/651011804216758682'/><link rel='alternate' type='text/html' href='http://blog.ecocrypt.com/2012/10/mountain-lion-dock-freeze.html' title='Mountain Lion Dock Freeze.'/><author><name>Q. B.</name><uri>http://www.blogger.com/profile/08502256579896627307</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9e-xzbIV9ABn9OHlgiNbVBplXewci_K0F0yYD52TW8scrP1IbQfmHRVQKv9uy5wULo5xDNj8aPq51gJ4O84pgc3K3HFXWP1rYGbQMXPdcXeuEyzvl9lGkIWrLVbghNjY/s220/JetCloud.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3158873714071458599.post-4214779436831895402</id><published>2012-08-29T17:31:00.001-05:00</published><updated>2012-08-29T17:57:15.717-05:00</updated><title type='text'>Unique Static Content and Eclipse Non-Consume Regex Glitch</title><content type='html'>I discovered a technique to allow infinite cache expire time for images and static content on websites. This technique is highly desirable because image requests and 304 requests consume time and make the user experience poor. &amp;nbsp;The technique is to include a version as follows:&lt;br /&gt;
&lt;div&gt;
&lt;pre class=&quot;brush: html&quot;&gt; 

&lt;img ref=&quot;/some/random/link.jpg&quot; /&gt;

-
 &lt;img ref=&quot;/some/random/link.jpg?Version=1.1.a&quot; /&gt;
&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;
In Fact, in the above example you could be even more sophisticated and include the MD5-checksum or other very unique identifier. &lt;br /&gt;
So I cracked open Eclipse to make the REGEX search and replace. &amp;nbsp;The expression I came up with was:&lt;br /&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;
#Search RegEx
# This looks for .jpg, and then does a 
# NON-Consuming match on a word boundary where there is NOT a ?
# For example .jpg&quot; and .jpg&#39; would match, but .jpg?version2 will not
\.jpg(?\b)(?[^\?])
#Replacement
\.jpg?STATIC_CONTENT_VERSION
&lt;/pre&gt;

&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2fiUh4MBxHeiKinr4Vbku21szHqCAuf18Yi0berfNsjlfdxTWpwQ1Su6vFYX_nlHs2MtryLHCfHVNkF1Yc3oIoWAn34sU8TChh_2ph7myUfoC5BSc9V_-HFOVTBJdXZBJWHjkPSZGbys/s1600/eclipse-regex-bug1.jpg.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;186&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2fiUh4MBxHeiKinr4Vbku21szHqCAuf18Yi0berfNsjlfdxTWpwQ1Su6vFYX_nlHs2MtryLHCfHVNkF1Yc3oIoWAn34sU8TChh_2ph7myUfoC5BSc9V_-HFOVTBJdXZBJWHjkPSZGbys/s320/eclipse-regex-bug1.jpg.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
I proceeded to do the simple search and replace.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi71-bpecJj4u8QakzkEpMTGP7IKIPGg9wSHgHPbrMjTRsoK3qkUCEAVY3MwHlMBu8WUExQ0WKEpZMaqLZqLW1cfOOj5ch5BvpBo7Ljq4_u_Nd_kH1U15ZlZdmbf-ZO5FQ8og621hEAzPQ/s1600/eclipse-regex-bug2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;248&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi71-bpecJj4u8QakzkEpMTGP7IKIPGg9wSHgHPbrMjTRsoK3qkUCEAVY3MwHlMBu8WUExQ0WKEpZMaqLZqLW1cfOOj5ch5BvpBo7Ljq4_u_Nd_kH1U15ZlZdmbf-ZO5FQ8og621hEAzPQ/s320/eclipse-regex-bug2.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
To my&amp;nbsp;chagrin, I received the infamous Error:&lt;br /&gt;
, &quot;&lt;b&gt;Match string has changed in the file&quot;&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
Why is this? &amp;nbsp;Well I googled it. &amp;nbsp;It is a know bug with Eclipse and regexes...&lt;br /&gt;
&lt;a href=&quot;https://bugs.eclipse.org/bugs/show_bug.cgi?id=109481&quot;&gt;Eclipse Bug.&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Workaround: &amp;nbsp;well we could use Netbeans, but I choose to go more primitive and use perl. &amp;nbsp;This post will include the generic perl script developed to solve the simple issue and how it was used:&lt;br /&gt;
&lt;br /&gt;
To use, simple type perl findreplace.pl regexSearch regexReplace [0|1]&lt;br /&gt;
The 0 is a dryrun, the 1 will really do the replace.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: pl&quot;&gt;use File::Find;
use File::Basename;

# The inputs:
# directory to start in, findRegex, replacement, dryrun indicator
@DIRS = $ARGV[0];
$patternFind = $ARGV[1];
$patternReplace = $ARGV[2];
$dryrun = $ARGV[3];

#  process a single file (this sub is called from below)
sub processFile{

    $baseN=&quot;&quot;;
    $dirN=&quot;&quot;;
    $extN=&quot;&quot;;
    $linesProcessed = 0;
    $currentFile = $File::Find::name;
    ($baseN,$dirN,$extN) = fileparse($currentFile,&#39;\..*&#39;);
    if ($extN eq &quot;.java&quot; || 
        $extN eq &quot;.jsp&quot;  ||
        $extN eq &quot;.properties&quot; ||
        $extN eq &quot;.js&quot; ||
        $extN eq &quot;.css&quot; ){
        # This represents a file that we want to do a search and replace on.
        # print &quot;found java $currentFile :$extN:$baseN:$dirN:\n&quot;;
    }else{
        # print &quot;\nRETURNING: $currentFile\n\n&quot;;
        return;
    }

    $currentBaseName = $_;

    # OPEN THE FILE READ ONLY.
    open FILE, $currentBaseName;
    $modify= 0;
    # DETERMINE IF THE FILE CONTAINS A MATCH
    while($line =&lt;file&gt;){
        if($line =~ /$patternFind/){
            $modify++
        }
    }
    close FILE;
    if($modify==0){
        # THERE WAS NO REGEX MATCH, SO EXIT.
        return;
    }

    # NO IT&#39;s not the evil number, 
    # it means set to global read/write in unix.
    # required for TFS integration.
    chmod 0666, $currentBaseName;

    open (FILE, &quot;+&amp;lt; $currentBaseName&quot;)  or die &quot;can&#39;t read $currentFile $!&quot;;
    $out = &#39;&#39;;
    while(&lt;file&gt;){
        if($_ =~ /$patternFind/){
            $linesProcessed++;
        print &quot;\tReplace: $_\n&quot;;
            s/$patternFind/$patternReplace/eg;
        print &quot;\tWith: $_\n&quot;;
        }

        $out .=$_;
    }

    if($dryrun==1){

        seek(FILE,0,0) or die &quot;can&#39;t seek to start of $currentFile $!&quot;;
        print FILE $out or die &quot;cant&#39;t print $currentFile $!&quot;;
        truncate(FILE, tell(FILE))  or die &quot;can&#39;t truncate $currentFile: $!&quot;;
        close (FILE)         or die &quot;can&#39;t close $currentFile: $!&quot;;

    }

    print &quot;File:$baseN$extN :From -&amp;gt;:$dirN\n&quot;;
    print &quot;Lines Changed: $linesProcessed\n&quot;;
    print &quot;___________________________________________________\n&quot;;
}
find (\&amp;amp;processFile, @DIRS);
&lt;/pre&gt;
&lt;br /&gt;
hope you find this useful!</content><link rel='replies' type='application/atom+xml' href='http://blog.ecocrypt.com/feeds/4214779436831895402/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.ecocrypt.com/2012/08/unique-static-content-and-eclipse-non.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/4214779436831895402'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/4214779436831895402'/><link rel='alternate' type='text/html' href='http://blog.ecocrypt.com/2012/08/unique-static-content-and-eclipse-non.html' title='Unique Static Content and Eclipse Non-Consume Regex Glitch'/><author><name>Q. B.</name><uri>http://www.blogger.com/profile/08502256579896627307</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9e-xzbIV9ABn9OHlgiNbVBplXewci_K0F0yYD52TW8scrP1IbQfmHRVQKv9uy5wULo5xDNj8aPq51gJ4O84pgc3K3HFXWP1rYGbQMXPdcXeuEyzvl9lGkIWrLVbghNjY/s220/JetCloud.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2fiUh4MBxHeiKinr4Vbku21szHqCAuf18Yi0berfNsjlfdxTWpwQ1Su6vFYX_nlHs2MtryLHCfHVNkF1Yc3oIoWAn34sU8TChh_2ph7myUfoC5BSc9V_-HFOVTBJdXZBJWHjkPSZGbys/s72-c/eclipse-regex-bug1.jpg.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3158873714071458599.post-3757932292550905539</id><published>2012-06-01T13:16:00.000-05:00</published><updated>2012-06-01T13:23:26.888-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="eclipse"/><category scheme="http://www.blogger.com/atom/ns#" term="multi line"/><category scheme="http://www.blogger.com/atom/ns#" term="netbeans"/><category scheme="http://www.blogger.com/atom/ns#" term="productivity"/><category scheme="http://www.blogger.com/atom/ns#" term="project search and replace"/><category scheme="http://www.blogger.com/atom/ns#" term="regex"/><title type='text'>Eclipse/NetBeans Multi Line Search and Replace Across Files</title><content type='html'>We all know System.out.println statements are not good for performance and clutter logs. &amp;nbsp;We should use a logger instead. &amp;nbsp;Loggers allow for the control of logging levels. &amp;nbsp;How do you replace these System.outs in a large project? &amp;nbsp;Here are the steps used recently:&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Come up with a good REGular EXspresion (REGEX), for matching your desired code.&lt;/li&gt;
&lt;li&gt;Come up with your replacement regex and capture user.&lt;/li&gt;
&lt;li&gt;Ensure that your code compiles and inspect your changes.&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
In this case we want to replace the following:&lt;/div&gt;
&lt;pre class=&quot;brush: java&quot;&gt;package com.ecokrypt...

public class ToManySystemOuts {

    System.out.println(&quot;Single Line System.out.println&quot;);


    System.out.println(&quot;Rare multiline &quot; +
           &quot; System.out.println &quot;);

}
&lt;/pre&gt;
We need to find a REGEX that will match both of these cases. &amp;nbsp;There are several ways to do any REGEX, but a solution that is easy &amp;nbsp;to understand that will work is:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: shell&quot;&gt;   (?s)System.out.println(\(([^;]+?)\));
&lt;/pre&gt;
&lt;br /&gt;
We have to dissect what this is saying to understand a couple of subtleties:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;(?s) - indicates that we search past line feeds. &amp;nbsp;Without this we will not match the second case because the line feed would cause the REGEX to not match at all.&lt;/li&gt;
&lt;li&gt;System.out.println - matches the exact phrase&lt;/li&gt;
&lt;li&gt;(\(([^;]+?)\)) - is very complicated, and will take time before you can read this. &amp;nbsp;A technique that typically works is to read it inside out. &amp;nbsp;Trying that out:&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;[^;]+ - look for anything that is NOT a &#39;;&#39; (semicolon). &amp;nbsp;the + is saying that you have to match at least 1, and there is no limit to how many characters you can match.&lt;/li&gt;
&lt;li&gt;([^;]+?) - Has a real subtlety to it, Regexes have an ability to be greedy, or lazy. &amp;nbsp;A greedy regex will match the largest region it can. &amp;nbsp;A lazy regex will match the smallest area it can. &amp;nbsp;It will take time to figure out when to use which, but the basic advice given here is ALWAYS try to use lazy. &amp;nbsp;Only use greedy if you really need it. &amp;nbsp;This REGEX is obviously lazy, how can you tell? &amp;nbsp;Think about it a bit.&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;the ? indicates that you are going to look for the next sequence imediately after. &amp;nbsp;&lt;/li&gt;
&lt;li&gt;the (...) indicates you are going to &quot;capture&quot; whatever you find presumably for later use.&lt;/li&gt;
&lt;li&gt;therefore the ( ) are not matched but are just part of the regex capture syntax.&lt;/li&gt;
&lt;li&gt;So the answer is: if the ? is inside the capture group e.g. (...?) the matching is lazy; if the ? is outside of the capture group, the matching is greedy e.g. (...)?&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;\(([^;]+?)\) &amp;nbsp;- says, adds the \(...\) to the previous the \ is an escape character and says match a ( and a ), don&#39;t create another capture group.&lt;/li&gt;
&lt;li&gt;(\(...\)) - says, now add another capture group containing everything inside the literals ( ).&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;; the semicolon at the end says match a literal semicolon.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
That is pretty much all there is to it. &amp;nbsp;Look at the following REGEX, which might be a common mistake and see if you can figure out why it won&#39;t work. &amp;nbsp;Guess what it will match. &amp;nbsp;(HINT thing about greedy vs lazy).&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;pre class=&quot;brush: shell&quot;&gt;   (?s)System.out.println(\(([^;]+)?\));
&lt;/pre&gt;
&lt;div&gt;
&lt;br /&gt;
Now that we have our matching REGEX, we need to get our replacement REGEX:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: shell&quot;&gt;   System.out.println$1;
&lt;/pre&gt;
&lt;br /&gt;
This is much simpler, it says: &amp;nbsp;replace the above match, with logger.debug$1; where $1 is inclusive the literal (...). &amp;nbsp;e.g. the braces and everything inside of them.&lt;br /&gt;
&lt;br /&gt;
How do we do this inside of Eclipse or NetBeans?&lt;br /&gt;
I find NetBeans to be much nicer in some respects, and not so nice in others.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;float: left; margin-right: 1em; text-align: left;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJsxf5DqX_52k6D0BONySyAVH5eKzHNc23UFN8ZHcQopA8A1MOQ5S86fNhfO3a5YW8XQ4ceqNwUuJrukDyo3rPrk5Gl0MU1tfFumROju9WM_8TOlQBtPEvawq1L_sojlP6u0Ov_eNQXIY/s1600/netbeans-regex1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;149&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJsxf5DqX_52k6D0BONySyAVH5eKzHNc23UFN8ZHcQopA8A1MOQ5S86fNhfO3a5YW8XQ4ceqNwUuJrukDyo3rPrk5Gl0MU1tfFumROju9WM_8TOlQBtPEvawq1L_sojlP6u0Ov_eNQXIY/s640/netbeans-regex1.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;NetBeans in File Search Replace&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
This is the netbeans view, it uses the space very nicely and there is NO POPUPS... &amp;nbsp;You really have to like the ergonomics of NetBeans. &amp;nbsp;The search is dynamic and nicely highlighted so you can see the search as you go.&lt;br /&gt;
&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;float: left; margin-right: 1em; text-align: left;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCwGvvXkkA-j_C99ln77UEV5IlJ0JsW5qas4W5H4E9Yea2REgeKJhjThW04p9Dhr8fCKeIapwnA5DoUN4eqETU7gz0Rr9tVxG1JLzJbLXYBCiV3eMaV4eSKyzmnSaPY-92cTOfJYlZTj0/s1600/netbeans-regex2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCwGvvXkkA-j_C99ln77UEV5IlJ0JsW5qas4W5H4E9Yea2REgeKJhjThW04p9Dhr8fCKeIapwnA5DoUN4eqETU7gz0Rr9tVxG1JLzJbLXYBCiV3eMaV4eSKyzmnSaPY-92cTOfJYlZTj0/s1600/netbeans-regex2.jpg&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;NetBeans Replace Across All Files&lt;br /&gt;
USE CRTL-H for a shortcut to this Menu.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;float: left; margin-right: 1em; text-align: left;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMkbaOk1MwSeh2h8BmZv4B8CuTsoSjMBbIX7Ptf4517r3lVbDY2cpyH2avBm43jDkteWHdRfqH4NHBLlk1uCzrLXawhb18mYwodfeRvSQMIjuyz0V8xXcFfh9nNJDrE7qRUiHuNWttaec/s1600/netbeans-regex3.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;307&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMkbaOk1MwSeh2h8BmZv4B8CuTsoSjMBbIX7Ptf4517r3lVbDY2cpyH2avBm43jDkteWHdRfqH4NHBLlk1uCzrLXawhb18mYwodfeRvSQMIjuyz0V8xXcFfh9nNJDrE7qRUiHuNWttaec/s640/netbeans-regex3.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;NetBeans Confirmation Dialog&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3&gt;


Eclipse:&lt;/h3&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbHl4HcMFZc-Zwg-9b4yW4U3qepTtXdGolV3XEQq_4S4UOpwBwlRAAlwxs4Kze6Ju9YJSLZhlXMECxOqG3hMPBG29Qysc_GFtMRuiaIjq0dEAlh6dd2VDlwrBqrA4ZqH6p0okx0D051W4/s1600/eclipse-regex1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;346&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbHl4HcMFZc-Zwg-9b4yW4U3qepTtXdGolV3XEQq_4S4UOpwBwlRAAlwxs4Kze6Ju9YJSLZhlXMECxOqG3hMPBG29Qysc_GFtMRuiaIjq0dEAlh6dd2VDlwrBqrA4ZqH6p0okx0D051W4/s640/eclipse-regex1.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;The Eclipse Search Dialog. &amp;nbsp;(Allows you to select scope)&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBqBjdwk5ZckSqBFMsVOWweyGylgEAjOiTvG-nSuNoyQCZaRI3hyphenhyphen8OTScrYQ8C_L3FSn3nXbjqMFjfwEDag5tR7L0-T2iFG0g-8zuSWScHwbu250Kavcij6sohxTEeeebRPWvA7A7zcNw/s1600/eclipse-regex2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBqBjdwk5ZckSqBFMsVOWweyGylgEAjOiTvG-nSuNoyQCZaRI3hyphenhyphen8OTScrYQ8C_L3FSn3nXbjqMFjfwEDag5tR7L0-T2iFG0g-8zuSWScHwbu250Kavcij6sohxTEeeebRPWvA7A7zcNw/s1600/eclipse-regex2.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.ecocrypt.com/feeds/3757932292550905539/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.ecocrypt.com/2012/06/eclipsenetbeans-multi-line-search-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/3757932292550905539'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/3757932292550905539'/><link rel='alternate' type='text/html' href='http://blog.ecocrypt.com/2012/06/eclipsenetbeans-multi-line-search-and.html' title='Eclipse/NetBeans Multi Line Search and Replace Across Files'/><author><name>Q. B.</name><uri>http://www.blogger.com/profile/08502256579896627307</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9e-xzbIV9ABn9OHlgiNbVBplXewci_K0F0yYD52TW8scrP1IbQfmHRVQKv9uy5wULo5xDNj8aPq51gJ4O84pgc3K3HFXWP1rYGbQMXPdcXeuEyzvl9lGkIWrLVbghNjY/s220/JetCloud.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJsxf5DqX_52k6D0BONySyAVH5eKzHNc23UFN8ZHcQopA8A1MOQ5S86fNhfO3a5YW8XQ4ceqNwUuJrukDyo3rPrk5Gl0MU1tfFumROju9WM_8TOlQBtPEvawq1L_sojlP6u0Ov_eNQXIY/s72-c/netbeans-regex1.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3158873714071458599.post-7988561422454985498</id><published>2012-01-06T07:21:00.000-06:00</published><updated>2012-01-06T07:21:04.927-06:00</updated><title type='text'>Creating A Java Applet to Run in Chrome, Firefox, IE, Opera, and Safari</title><content type='html'>Just throwing together a really quick page to allow people to grab a code snipit &lt;br /&gt;
showing how to write html to allow an applet to be embedded in a page, such that it works in Chrome, Firefox, IE, Opera and Safari.&lt;br /&gt;
&lt;br /&gt;
The following should work.&lt;br /&gt;
I would love comments on better ideas.&lt;br /&gt;
&lt;br /&gt;
&lt;script class=&quot;brush: bash&quot; type=&quot;syntaxhighlighter&quot;&gt;
&lt;![CDATA[
&lt;!--  Cross browser applet embedding --&gt;

&lt;object classid=&quot;clsid:8AD9C840-044E-11D1-B3E9-00805F499D93&quot; height=&quot;500&quot; width=&quot;650&quot;&gt;  
    &lt;param name=&quot;type&quot; value=&quot;application/x-java-applet;version=1.6&quot;&gt;
    &lt;param name=&quot;codebase&quot; value=&quot;.&quot;&gt;
    &lt;param name=&quot;archive&quot; value=&quot;http://qpapplets.googlecode.com/files/47906Proxy_0_1_6.jar&quot;&gt;
    &lt;param name=&quot;code&quot; value=&quot;com.ecocrypt.proxy.forwarder.gui.$.class&quot;&gt;
    &lt;object classid=&quot;java:com.ecocrypt.proxy.forwarder.gui.$&quot; codetype=&quot;application/x-java-applet;version=1.6&quot; height=&quot;500px&quot; width=&quot;650px&quot;&gt;  
        &lt;param name=&quot;codebase&quot; value=&quot;http://qpapplets.googlecode.com/&quot;&gt;
        &lt;param name=&quot;archive&quot; value=&quot;http://qpapplets.googlecode.com/files/47906Proxy_0_1_6.jar&quot;&gt;
        &lt;embed code=&quot;com.ecocrypt.proxy.forwarder.gui.$.class&quot;
               width=&quot;650&quot; height=&quot;500&quot;
               archive=&quot;http://qpapplets.googlecode.com/files/47906Proxy_0_1_6.jar&quot;
               codebase=&quot;http://qpapplets.googlecode.com/&quot;
               type=&quot;application/x-java-applet;version=1.6.0&quot;
               pluginspage=&quot;http://java.sun.com/j2se/1.6.0/download.html&quot;/&gt;   
    &lt;/object&gt;  
&lt;/object&gt;
]]&gt;
&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.ecocrypt.com/feeds/7988561422454985498/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.ecocrypt.com/2012/01/creating-java-applet-to-run-in-chrome.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/7988561422454985498'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/7988561422454985498'/><link rel='alternate' type='text/html' href='http://blog.ecocrypt.com/2012/01/creating-java-applet-to-run-in-chrome.html' title='Creating A Java Applet to Run in Chrome, Firefox, IE, Opera, and Safari'/><author><name>Q. B.</name><uri>http://www.blogger.com/profile/08502256579896627307</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9e-xzbIV9ABn9OHlgiNbVBplXewci_K0F0yYD52TW8scrP1IbQfmHRVQKv9uy5wULo5xDNj8aPq51gJ4O84pgc3K3HFXWP1rYGbQMXPdcXeuEyzvl9lGkIWrLVbghNjY/s220/JetCloud.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3158873714071458599.post-1641455146006777874</id><published>2011-10-19T17:47:00.002-05:00</published><updated>2011-10-28T19:31:13.962-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="47906Proxy"/><category scheme="http://www.blogger.com/atom/ns#" term="network sniffer"/><category scheme="http://www.blogger.com/atom/ns#" term="port forwarding"/><category scheme="http://www.blogger.com/atom/ns#" term="protocol analysis"/><title type='text'>Running 47906Proxy as an Applet</title><content type='html'>This article describes running the 47906Proxy as an Applet:&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;Brief History of the 47906Proxy:&lt;/i&gt; &amp;nbsp;The proxy was developed initially as a port forwarder, or simply a forwarding proxy. &amp;nbsp;What is a forwarder proxy, and how is it used? &amp;nbsp;Three &lt;b&gt;use cases&lt;/b&gt; are included below the 47906Proxy demonstration applet (the &lt;b&gt;use cases &lt;/b&gt;include &lt;i&gt;Tunneling, Application level Protocol Sniffing, and Network Latency Trending)&lt;/i&gt;. &amp;nbsp;In addition a&amp;nbsp;code&amp;nbsp;snip-it has been included below the proxy to allow for a cut and paste usage on your website.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;object classid=&quot;clsid:8AD9C840-044E-11D1-B3E9-00805F499D93&quot; height=&quot;500&quot; width=&quot;650&quot;&gt; &lt;param name=&quot;type&quot; value=&quot;application/x-java-applet;version=1.6&quot;&gt;&lt;param name=&quot;codebase&quot; value=&quot;.&quot;&gt;&lt;param name=&quot;archive&quot; value=&quot;http://qpapplets.googlecode.com/files/47906Proxy_0_1_6.jar&quot;&gt;&lt;param name=&quot;code&quot; value=&quot;com.ecocrypt.proxy.forwarder.gui.$.class&quot;&gt;&lt;object classid=&quot;java:com.ecocrypt.proxy.forwarder.gui.$&quot; codetype=&quot;application/x-java-applet;version=1.6&quot; height=&quot;500px&quot; width=&quot;650px&quot;&gt; &lt;param name=&quot;codebase&quot; value=&quot;http://qpapplets.googlecode.com/&quot;&gt;&lt;param name=&quot;archive&quot; value=&quot;http://qpapplets.googlecode.com/files/47906Proxy_0_1_6.jar&quot;&gt;&lt;embed code=&quot;com.ecocrypt.proxy.forwarder.gui.$.class&quot;
       width=&quot;650&quot; height=&quot;500&quot;
       archive=&quot;http://qpapplets.googlecode.com/files/47906Proxy_0_1_6.jar&quot;
       codebase=&quot;http://qpapplets.googlecode.com/&quot;
       type=&quot;application/x-java-applet;version=1.6.0&quot;
       pluginspage=&quot;http://java.sun.com/j2se/1.6.0/download.html&quot;/&gt;  &lt;/object&gt; &lt;/object&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;USE CASE 1: &amp;nbsp;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;b&gt;Firewall hopping.&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;Firewall hopping is some times called tunneling, this will allow an application to access a port on a remote machine behind a firewall, without the need or requirement to poke a hole in the firewall. &amp;nbsp;Additionally, forwarding proxies can add additional checking and validation to ensure that the individual trying to tunnel has the privileges and rights to do that.&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;USE CASE 2: &amp;nbsp;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;b&gt;Protocol Sniffing&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;This allows a very high level of stream sniffing, or application layer protocol sniffing. &amp;nbsp;Frequently this is much more desirable than low level packet capture sniffing.&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;USE CASE 3: &amp;nbsp;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;b&gt;Performance Monitoring&lt;/b&gt;&lt;/div&gt;&lt;div&gt;This allows for data flow rate analysis, and latency analysis at a much higher level than a packet sniffer.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.ecocrypt.com/feeds/1641455146006777874/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.ecocrypt.com/2011/10/running-47906proxy-as-applet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/1641455146006777874'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/1641455146006777874'/><link rel='alternate' type='text/html' href='http://blog.ecocrypt.com/2011/10/running-47906proxy-as-applet.html' title='Running 47906Proxy as an Applet'/><author><name>Q. B.</name><uri>http://www.blogger.com/profile/08502256579896627307</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9e-xzbIV9ABn9OHlgiNbVBplXewci_K0F0yYD52TW8scrP1IbQfmHRVQKv9uy5wULo5xDNj8aPq51gJ4O84pgc3K3HFXWP1rYGbQMXPdcXeuEyzvl9lGkIWrLVbghNjY/s220/JetCloud.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3158873714071458599.post-3525614922830643403</id><published>2011-08-24T19:11:00.001-05:00</published><updated>2011-08-24T19:21:40.992-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Entrepreneur"/><category scheme="http://www.blogger.com/atom/ns#" term="RoundTable"/><category scheme="http://www.blogger.com/atom/ns#" term="Software"/><title type='text'>Software Entrepreneur Round-Table</title><content type='html'>What:  A Software Entrepreneur Round-Table&lt;br /&gt;
When: October 24 from 6:30 PM - 8:30 PM CST &lt;br /&gt;
Venue:  TBD (Skype/google-voice/ tele-video conference)&lt;br /&gt;
Who:  We are looking for a global perspective, In particular looking for Entrepreneur&#39;s from China, India, Europe/Russia, US and South America&lt;br /&gt;
Format: Informal Moderated Discussion.&lt;br /&gt;
Language: English&lt;br /&gt;
&lt;br /&gt;
Goal group size 6-10 Entrepreneurs or perspective entrepreneurs:&lt;br /&gt;
&lt;br /&gt;
Agenda:&lt;br /&gt;
1.  Welcome and Introductions&lt;br /&gt;
2.  Discussion Rules&lt;br /&gt;
3.  Each Idea is presented and Brainstormed (semi open)&lt;br /&gt;
4.  10/4 voting on difficulty, competition, and feasibility&lt;br /&gt;
5.  Exchange of contact info &lt;br /&gt;
6.  Business plan partner assignment&lt;br /&gt;
7.  Followups&lt;br /&gt;
&lt;br /&gt;
To Sign Up, Email: October.RoundTable@ecocrypt.com&lt;br /&gt;
Include: your name&lt;br /&gt;
your country&lt;br /&gt;
your phone &lt;br /&gt;
your email&lt;br /&gt;
&lt;br /&gt;
You will receive either a phone call, or an email within 72 hours.&lt;br /&gt;
</content><link rel='replies' type='application/atom+xml' href='http://blog.ecocrypt.com/feeds/3525614922830643403/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.ecocrypt.com/2011/08/software-entrepreneur-round-table.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/3525614922830643403'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/3525614922830643403'/><link rel='alternate' type='text/html' href='http://blog.ecocrypt.com/2011/08/software-entrepreneur-round-table.html' title='Software Entrepreneur Round-Table'/><author><name>Q. B.</name><uri>http://www.blogger.com/profile/08502256579896627307</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9e-xzbIV9ABn9OHlgiNbVBplXewci_K0F0yYD52TW8scrP1IbQfmHRVQKv9uy5wULo5xDNj8aPq51gJ4O84pgc3K3HFXWP1rYGbQMXPdcXeuEyzvl9lGkIWrLVbghNjY/s220/JetCloud.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3158873714071458599.post-7410577188109742261</id><published>2011-05-11T19:35:00.000-05:00</published><updated>2011-05-13T15:28:39.804-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java.regex"/><category scheme="http://www.blogger.com/atom/ns#" term="productivity"/><category scheme="http://www.blogger.com/atom/ns#" term="Regex"/><category scheme="http://www.blogger.com/atom/ns#" term="Regular Expressions"/><title type='text'>Ecocrypt&#39;s RegEx Testing Applet and Java-Regex Source Generator</title><content type='html'>&lt;b&gt;This is the Discussion Board For EcoCrypt&#39;s RegEx Testing Applet.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;Feel free to use this, or bookmark the actual link &lt;a href=&quot;http://www.ecocrypt.com/regex&quot;&gt;http://www.ecocrypt.com/regex&lt;/a&gt;&lt;/i&gt;&lt;br /&gt;
*Features:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Test your regex pattern against text input.&lt;/li&gt;
&lt;li&gt;Generate the Java source code for the regex matcher.&lt;/li&gt;
&lt;li&gt;Run your regex against a file on your local harddrive.&lt;/li&gt;
&lt;/ul&gt;&lt;div&gt;&lt;b&gt;&lt;i&gt;Please Leave Comments! Comments Can Be Related To Wish List, Usability, Or Other RegEx Thoughts.&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;object classid=&quot;clsid:8AD9C840-044E-11D1-B3E9-00805F499D93&quot; height=&quot;500&quot; width=&quot;650&quot;&gt; &lt;param name=&quot;type&quot; value=&quot;application/x-java-applet;version=1.6&quot;&gt;&lt;param name=&quot;codebase&quot; value=&quot;.&quot;&gt;&lt;param name=&quot;archive&quot; value=&quot;http://www.ecocrypt.com/dist/SqpApplets.jar&quot;&gt;&lt;param name=&quot;code&quot; value=&quot;com.ecocrypt.regex.RegexApplet.class&quot;&gt;&lt;object classid=&quot;java:com.ecocrypt.regex.RegexApplet&quot; codetype=&quot;application/x-java-applet;version=1.6&quot; height=&quot;500px&quot; width=&quot;650px&quot;&gt; &lt;param name=&quot;codebase&quot; value=&quot;http://www.ecocrypt.com/&quot;&gt;&lt;param name=&quot;archive&quot; value=&quot;http://www.ecocrypt.com/dist/SqpApplets.jar&quot;&gt;&lt;embed code=&quot;com.ecocrypt.regex.RegexApplet.class&quot;
       width=&quot;650&quot; height=&quot;500&quot;
       archive=&quot;http://www.ecocrypt.com/dist/SqpApplets.jar&quot;
       codebase=&quot;http://www.ecocrypt.com&quot;
       type=&quot;application/x-java-applet;version=1.6.0&quot;
       pluginspage=&quot;http://java.sun.com/j2se/1.6.0/download.html&quot;/&gt;  &lt;/object&gt; &lt;/object&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.ecocrypt.com/feeds/7410577188109742261/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.ecocrypt.com/2011/05/ecocrypts-regex-testing-applet-and-java.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/7410577188109742261'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/7410577188109742261'/><link rel='alternate' type='text/html' href='http://blog.ecocrypt.com/2011/05/ecocrypts-regex-testing-applet-and-java.html' title='Ecocrypt&#39;s RegEx Testing Applet and Java-Regex Source Generator'/><author><name>Q. B.</name><uri>http://www.blogger.com/profile/08502256579896627307</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9e-xzbIV9ABn9OHlgiNbVBplXewci_K0F0yYD52TW8scrP1IbQfmHRVQKv9uy5wULo5xDNj8aPq51gJ4O84pgc3K3HFXWP1rYGbQMXPdcXeuEyzvl9lGkIWrLVbghNjY/s220/JetCloud.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3158873714071458599.post-1561827207097462142</id><published>2011-04-29T23:57:00.000-05:00</published><updated>2011-04-29T23:57:27.334-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="bluehost"/><category scheme="http://www.blogger.com/atom/ns#" term="prductivity"/><category scheme="http://www.blogger.com/atom/ns#" term="subversion"/><category scheme="http://www.blogger.com/atom/ns#" term="svn"/><title type='text'>Creating an SVN repository on Bluehost</title><content type='html'>&lt;b&gt;Motivation:&lt;/b&gt;&lt;br /&gt;
There are many free svn repository providers. &amp;nbsp;If you are an individual developer, you may choose to use one of those. &amp;nbsp;Some have the restriction that repository is publicly accessible such as google code and sourceforge, while others keep the repository private such as projectlocker and sliksvn. &amp;nbsp;After reading the license agreements and contracts, I decided to maintain my own&amp;nbsp;repository.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Warning:&lt;/b&gt;&lt;br /&gt;
This discusses how to set up and configured a svn repository on BlueHost using a windows 7 as the client machine:&amp;nbsp;&lt;i&gt;&lt;u&gt;This setup is not for the faint of heart&lt;/u&gt;&lt;/i&gt;. &amp;nbsp;It requires modifying configuration settings, compiling source code with multiple complex config options, generating ssh keys, setting up ssh, and properly configuring the windows environment. &amp;nbsp;(&lt;i&gt;NOTE: &amp;nbsp;All of these steps can be followed for linux/bsd/mac. &amp;nbsp;Slight modifications to the commands may be required, such as using forward-slashes for paths instead of back-slashes; using : for path separators instead of &#39;;&#39;; and other OS specific&amp;nbsp;idiosyncrasies)&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Quick Overview:&lt;/b&gt;&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Install SSH on the client&lt;/li&gt;
&lt;li&gt;Setup SSH Keys (you will have to contact bluehost directly to get permission to use SSH to access your server)&lt;/li&gt;
&lt;li&gt;Install an SVN Client&lt;/li&gt;
&lt;li&gt;Compile and Install the SVN Server from source on your bluehost box.&lt;/li&gt;
&lt;li&gt;Setup an ssh-svn service bridge (sshsvnserve)&lt;/li&gt;
&lt;li&gt;Instruct svn to use the service bridge when connecting to your repo.&lt;/li&gt;
&lt;li&gt;Using the repository.&lt;/li&gt;
&lt;li&gt;Properly backing up the repository (don&#39;t trust bluehost to back up the repository for you).&lt;/li&gt;
&lt;/ol&gt;&lt;div&gt;&lt;b&gt;Getting Started:&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;u style=&quot;font-weight: bold;&quot;&gt;Install SSH On Windows 7 &lt;/u&gt;(or any other version of windows)&lt;/i&gt;&lt;/div&gt;&lt;div&gt;I use mingw (which is minimal gnu for windows). &amp;nbsp;This is an excellent package, and does not have all the complexities of cygwin. &amp;nbsp;However, cygwin might work just fine. &amp;nbsp;I don&#39;t use it because it tends to mess up gmake/gnu&#39;s make program.&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;Download and install mingw from&amp;nbsp;&lt;a href=&quot;http://www.mingw.org/&quot;&gt;http://www.mingw.org/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Assuming you installed at c:\MinGW, then add&amp;nbsp;C:\MinGW\msys\1.0\bin to your system path environment variable.&lt;/li&gt;
&lt;li&gt;Confirm all is working by typing svn -v from any directory on your box, you should get:&lt;/li&gt;
&lt;ul&gt;&lt;li&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;C:\&amp;gt;ssh -v

OpenSSH_5.4p1, OpenSSL 1.0.0 29 Mar 2010
usage: ssh [-1246AaCfgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
           [-D [bind_address:]port] [-e escape_char] [-F configfile]
           [-I pkcs11] [-i identity_file]
           [-L [bind_address:]port:host:hostport]
           [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]
           [-R [bind_address:]port:host:hostport] [-S ctl_path]
           [-W host:port] [-w local_tun[:remote_tun]]
           [user@]hostname [command]
&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;li&gt;Congrats! step 1 is done&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;i&gt;&lt;u&gt;Setup SSH Keys&lt;/u&gt;&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
SSH keys allow you to login to your account on BlueHost without the need for a password. &amp;nbsp;It works by storing a private key on your computer, and you upload a public key to your account on the BlueHost box. &amp;nbsp;You can then login using ssh, or interact using scp without specifying a password, by specifying the ssh private key file. &amp;nbsp;The public and &amp;nbsp;private keys are&amp;nbsp;asymmetric keys. &amp;nbsp;This means that which ever key is used to encrypt the data, the other key must be used to decrypt data. &amp;nbsp;Authentication is accomplished by providing a challenge to the requesting client.&lt;br /&gt;
&lt;i&gt;Assuming Step 1 was completed successfully, the ssh-keygen program should be in your path.&lt;/i&gt;&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;pick a directory to store your public and private key, and switch to that directory&lt;br /&gt;
&lt;i&gt;A good choice would be -&amp;gt; c:\Users\[Windows User]\.ssh&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;Generate the public and private key, there are many options, choosing all defaults (with the exception of the file name) is typically good.&lt;/li&gt;
&lt;/ul&gt;&lt;blockquote&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;C:\Users\[My Account]\.ssh&amp;gt;ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (//.ssh/id_rsa): id_rsa_svn
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in id_rsa_svn.
Your public key has been saved in id_rsa_svn.pub.
The key fingerprint is:
04:a3:1a:b7:5d:6f:29:39:bc:30:a3:c7:c6:b0:2f:49 [My Account]@[mycomputer&#39;s name]
The key&#39;s randomart image is:
+--[ RSA 2048]----+
|      o          |
|     . o         |
|  . o   o        |
|   + o + o .     |
|  . o = S +      |
|    E* + =       |
|   .o.= .        |
|    o+           |
|     ..          |
+-----------------+

&lt;/pre&gt;Test out your SSH Key&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;upload the public key to the bluehost server, &lt;i&gt;&lt;b&gt;KEEP the private key private! &lt;/b&gt;This is important because this protects the bluehost account from unauthorized access.&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;&lt;i&gt;Install the key in your authorized_keys file&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;&lt;i&gt;Test the access.&lt;/i&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;i&gt;From your windows box:&lt;/i&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;C:\Users\[Windows User]\.ssh&amp;gt;ls
id_rsa  id_rsa.pub  id_rsa_svn  id_rsa_svn.pub

C:\Users\[Windows User]\.ssh&amp;gt;scp id_rsa_svn.pub [bluehost account]@[bluehost machine]:~/.ssh
[bluehost account]@[bluehost machine]&#39;s password:
id_rsa_svn.pub                                                                                            100%  401     0.4KB/s   00:00

&lt;/pre&gt;You will now need to log into the bluehost box, and manually add the public key to the authorized_keys file.  To do this, log on to your bluehost account, and follow the following steps.&lt;br /&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;[bluehost account]@[bluehost machine] [~]# cd .ssh
[bluehost account]@[bluehost machine] [~/.ssh]# dir
./  ../  authorized_keys2  environment  id_rsa_svn.pub
[bluehost account]@[bluehost machine] [~/.ssh]# cat id_rsa_svn.pub &amp;gt;&amp;gt; authorized_keys2

NOTE to see the changed file:
[~/.ssh]# cat authorized_keys2

&lt;/pre&gt;Finally From the windows box, test out the key to make sure that it works:&lt;br /&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;C:\&amp;gt;ssh -i &quot;c:\Users\[Windows User]\.ssh\id_rsa_svn&quot; [bluehost account]@[bluehost machine]
Last login: Thu Apr 28 17:08:06 2011 from 32.178.80.204
[bluehost account]@[bluehost machine] [~]#
&lt;/pre&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;br /&gt;
&lt;b&gt;&lt;i&gt;Install An SVN client&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
Any svn client should do the job, SlikSVN seems to be a good distribution. &amp;nbsp;However, many others will do the job. &amp;nbsp;SlikSvn comes as a standard windows installer, it will typically add the subversion client tools to your path. &amp;nbsp;Once it is installed on your windows box, test to make sure the svn.exe file is executable from any directory.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;C:\&amp;gt;svn --version
svn, version 1.6.16 (SlikSvn/1.6.16) X64
   compiled Mar  3 2011, 22:35:47

Copyright (C) 2000-2009 CollabNet.
Subversion is open source software, see http://subversion.apache.org/
This product includes software developed by CollabNet (http://www.Collab.Net/).

The following repository access (RA) modules are available:

* ra_neon : Module for accessing a repository via WebDAV protocol using Neon.
  - handles &#39;http&#39; scheme
  - handles &#39;https&#39; scheme
* ra_svn : Module for accessing a repository using the svn network protocol.
  - with Cyrus SASL authentication
  - handles &#39;svn&#39; scheme
* ra_local : Module for accessing a repository on local disk.
  - handles &#39;file&#39; scheme
* ra_serf : Module for accessing a repository via WebDAV protocol using serf.
  - handles &#39;http&#39; scheme
  - handles &#39;https&#39; scheme

&lt;/pre&gt;&lt;b&gt;&lt;i&gt;Compiling SVN Server on BlueHost&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Download the latest version of Subversion from sourceforge.&lt;/li&gt;
&lt;li&gt;copy it up to the BlueHost Account&lt;/li&gt;
&lt;li&gt;configure the compilation process for BlueHost&lt;/li&gt;
&lt;li&gt;make the components&lt;/li&gt;
&lt;li&gt;install the svn server and libraries&lt;/li&gt;
&lt;/ol&gt;I will outline these steps in the following shell capture. &amp;nbsp;Note that config and compiling take several minutes each.&lt;br /&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;[~]# cd src
[~/src]# cd subversion-1.6.16
[~/src/subversion-1.6.16]# ./configure --prefix=$HOME/svn/bin --without-apxs --exec-prefix=$HOME/svn/lib --disable-mod-activation
[~/src/subversion-1.6.16]# nohup make &amp;amp;
[~/src/subversion-1.6.16]# tail -f nohup.out
[~/src/subversion-1.6.16]# make install
&lt;/pre&gt;&lt;br /&gt;
Subversion server is now installed on BlueHost.  At this point, it must be tested.&lt;br /&gt;
The following shell snippet shows the testing expectation:&lt;br /&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;[~]# cd svn/lib/bin
[~/svn/lib/bin]# ./svnserve --version
svnserve, version 1.6.16 (r1073529)
   compiled Apr 27 2011, 17:27:09

Copyright (C) 2000-2009 CollabNet.
Subversion is open source software, see http://subversion.apache.org/
This product includes software developed by CollabNet (http://www.Collab.Net/).

The following repository back-end (FS) modules are available:

* fs_fs : Module for working with a plain file (FSFS) repository.

Cyrus SASL authentication is available.
&lt;/pre&gt;&lt;br /&gt;
&lt;b&gt;&lt;i&gt;Setting up an ssh-svn service bridge:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
In this step a bridge will be set up. &amp;nbsp;The purpose of this bridge will be two things:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Set up enough of an environment to execute svnserve command (by default and for security purposes bluehost disables shells and environments for remote logins)&lt;/li&gt;
&lt;li&gt;Instruct ssh to invoke a temporary service&amp;nbsp;immediately&amp;nbsp;on connect. &amp;nbsp;(this service will of course be the svnserve command which serves content from an svn repository)&lt;/li&gt;
&lt;/ul&gt;Log into your BlueHost machine, change to the .ssh directory, open the authorized_keys2 file with a text editor, vi or pico should do. Find the public key entry that was added to this file in the step above. &amp;nbsp;This key is going to be modified by adding some instructions to the front of the key. &amp;nbsp;the instructions to be added are:&amp;nbsp;&lt;i&gt;command=&quot;/home1/[your bluehost account]/sshsvnserve -t&quot; &lt;/i&gt;see the code snippet below for an example of what things should look like:&lt;br /&gt;
&lt;div&gt;&lt;/div&gt;&lt;pre class=&quot;brush: bash&quot;&gt;command=&quot;/home1/[your bluehost account]/sshsvnserve -t&quot; ssh-rsa AAAABCCCCCCDDDDDDDD3NzaC1yc2EAAAADAQABAAABAQDJezPXNZb8rls8GrxH46zZwUO6vm1bkgxD2jma4RJMlXH0ADTDsQ2PGZAW80hVamojBsKGUN8zYH2i3LiEYiNSqL2d6mvFZAxIGH4mxhQQZdImyIWEnAK5a9HL9SQlIRnKa0ZEEsi/KWmiyB/gOXtKxxW7aU9KIsk2mjG0UZfmRHE4OhvXQqguAZCScOHh/WDRXiC2t2WbmfSXJK7KNz2sjla8Y62Z+u3Lg0m4SlmNqLgllh+tY0Nbxd623sJSQVqNwutPPMd1IhybjQskXUv8OlSmVepkhnGpSteRIzI99MocX8LzrZefHSaPsyMeHri52VzTb0
3 [windows usr]@[windows machine name]
&lt;/pre&gt;&lt;br /&gt;
The only thing added is the first command=..... up to the &#39;ssh-rsa&#39; of course modified to match your account. &lt;br /&gt;
&lt;br /&gt;
Now create the sshsvnserve shell script. &amp;nbsp;This is a very simple shell script. &amp;nbsp;Switch back to the home directory on the bluehost machine, and create a file with the following content. &amp;nbsp;&lt;b&gt;&lt;i&gt;Note that you will have to change this file to executable before it can be used.&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: shell&quot;&gt;#!/bin/sh
/home1/[your bluehost account]/svn/lib/bin/svnserve $*
&lt;/pre&gt;&lt;br /&gt;
&lt;b&gt;&lt;i&gt;Instruct svn to use the service bridge when connecting to your repo.&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
This is done by adding an ssh directive to your tunnels command. &amp;nbsp;On the windows box, create a subversion config file as bellow.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: shell&quot;&gt;C:\Users\[Windows Account]\.subversion&amp;gt;cat config


[tunnels]
ssh = ssh -i &quot;c:\\Users\\[Windows Account]\\.ssh\\id_rsa_svn&quot;
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
USING your new repository:&lt;br /&gt;
&lt;pre class=&quot;brush: shell&quot;&gt;C:\repos&amp;gt;svn --config-dir=&quot;c:\Users\[Your Windows Account]\.subversion&quot; co svn+ssh://[your bluehost account]@[your bluehost machine/ip]/home1/[your bluehost account]/repos

&lt;/pre&gt;&lt;br /&gt;
&lt;b&gt;&lt;i&gt;Using the repository&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
The repository can be used by simply making sure that the --config-dir option is specified, and points to the directory that contains your config file with the [tunnels] entry.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;Backing up the Repository:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
Assuming that you are using BlueHost for a single user or very small number of users, you can simply create a synchronized repository on your local machine.  The steps will be outlined in a code snippet block, with comments.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: shell&quot;&gt;#  First create the repository.
C:\repos&amp;gt;svnadmin create .

#  Modify the hooks so the repos can accept
#  backup requests from other repositories.
C:\repos&amp;gt;cd hooks
C:\repos\hooks&amp;gt;echo exit 0 &amp;gt; pre-revprop-change.bat
C:\repos\hooks&amp;gt;cat pre-revprop-change.bat
exit 0

# 
C:\repos&amp;gt;svnsync initialize file:///repos svn+ssh://[bluehost caccount]@[bluehost machine]/home1/[bluehost account]/repos --config-dir=&quot;c:\Users\[Windows Account]\.subversion&quot;
Copied properties for revision 0.

C:\repos&amp;gt;svnsync synchronize file:///repos --config-dir=&quot;c:\Users\[Windows Account]\.subversion&quot;
Committed revision 1.
Copied properties for revision 1.
Committed revision 2.
Copied properties for revision 2.
Transmitting file data .......................................................................
..............................................................................................
...........
Committed revision 3.
Copied properties for revision 3.
Transmitting file data .......................................................................
..............................................................................................
...
Committed revision 4.
Copied properties for revision 4.
Transmitting file data .


&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.ecocrypt.com/feeds/1561827207097462142/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.ecocrypt.com/2011/04/creating-svn-repository-on-bluehost.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/1561827207097462142'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/1561827207097462142'/><link rel='alternate' type='text/html' href='http://blog.ecocrypt.com/2011/04/creating-svn-repository-on-bluehost.html' title='Creating an SVN repository on Bluehost'/><author><name>Q. B.</name><uri>http://www.blogger.com/profile/08502256579896627307</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9e-xzbIV9ABn9OHlgiNbVBplXewci_K0F0yYD52TW8scrP1IbQfmHRVQKv9uy5wULo5xDNj8aPq51gJ4O84pgc3K3HFXWP1rYGbQMXPdcXeuEyzvl9lGkIWrLVbghNjY/s220/JetCloud.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3158873714071458599.post-8417148433538421515</id><published>2011-04-03T22:46:00.000-05:00</published><updated>2011-04-03T22:46:33.317-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="algorithm"/><category scheme="http://www.blogger.com/atom/ns#" term="Insertion sort"/><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><category scheme="http://www.blogger.com/atom/ns#" term="sorting"/><title type='text'>Python - Insertion Sort Impl</title><content type='html'>This article will discuss a simple insertion sort algorithm for python.&lt;br /&gt;
&lt;i style=&quot;font-weight: bold;&quot;&gt;See ALL &lt;/i&gt;Python postings&amp;nbsp;&amp;nbsp;| &amp;nbsp;Insertion Sort By Language &lt;a href=&quot;http://ecocrypt.blogspot.com/2011/03/java-insertion-sort-implementation-and.html&quot;&gt;Java&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://ecocrypt.blogspot.com/2011/03/scala-insertion-sort-implementation.html&quot;&gt;Scala&lt;/a&gt; &lt;b&gt;&lt;a href=&quot;http://ecocrypt.blogspot.com/2011/03/golang-insertion-sort-implimentaion-w.html&quot;&gt;Go&lt;/a&gt;&lt;/b&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #666666;&quot;&gt;&amp;nbsp;C++ Python Perl&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Overview of the Insertion Sort Algorithm&lt;/b&gt;&lt;br /&gt;
Insertion sort is one of the most natural wayTs of sorting a collection of comparable items. &amp;nbsp;The reason it is one of the most natural ways is because it is the way most people will sort physical items. &amp;nbsp; For example each year (about this time) I will sort all 12 of my previous years phone bills, gas bills, etc... &amp;nbsp;The algorithm used to sort them is to place the first one in stack. &amp;nbsp;Then the second one is compared to the first one to see if it goes in front of or behind the first one. &amp;nbsp;The third one is then compared to each if the two sorted items to determine where it fits in. &amp;nbsp;This procedure continues until all 12 bills are in the pile. &amp;nbsp;Once all 12 bills are in the pile it is sorted. I happen to sort form oldest to newest, my spouse does it the other way newest to oldest.&lt;br /&gt;
&lt;br /&gt;
Applying this concept to a collection of objects in a computer is fundamentally the same. &amp;nbsp;The algorithm dictates that one will iterate over a collection of elements in an unsorted list 1 at a time, and place that item into it&#39;s correct location in a sorted list.&lt;br /&gt;
&lt;br /&gt;
If the collection of objects to sort is n, insertion sort will take at most $O(n^2)$ operations to perform the sort, it will take on average $\frac{1}{2} O(n^2) = O(n^2)$, and in the best case senario will take $O(n)$ operations.&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;Questions: &amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;1. &amp;nbsp;What would be the initial characteristics of a list that took the worst case order $O(n^2)$ to sort?&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;2. &amp;nbsp;&lt;/b&gt;&lt;b&gt;What would be the initial characteristics of a list that took the best case order $O(n)$ to sort?&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;About the Python Solution:&lt;/b&gt;&lt;br /&gt;
In python this solution relied a bit on creativity. &amp;nbsp;The solution is clearly not $O(n^2)$, &amp;nbsp;however it may take a bit to understand why. &amp;nbsp;The reason lies in the fact that python does not have a linked list that allows insert at a given point in the list. &amp;nbsp;Therefore, to simulate that behavior, this solution rotates the list until it cat append to the left side of the list, and then rotates back. &amp;nbsp;This ensures that the order is correct. &amp;nbsp;What would be the big O of this solution assuming that each rotation is O(n)? Some additional inline comments have been included.&lt;br /&gt;
&lt;br /&gt;
If you have a question about the solution (or feel it should be improved) please leave a comment. &amp;nbsp;All comments are moderated and posted with your name/Identification so please be professional and straight forward. &lt;b&gt;Python Solution:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: python&quot;&gt;#!/opt/python
from collections import deque
import random

dq = deque()
for i in range(20):
    dq.append(random.randrange(1001))

for elem in dq:
    print(elem)

sortedQueue = deque()
j=int(0)
k=int(0)
for elem in dq:


    for sortedElem in sortedQueue :
        if elem&amp;gt;sortedElem:
            sortedQueue.rotate(-j)
            sortedQueue.appendleft(elem)
            sortedQueue.rotate(j)
            k=1+k
            break
        j=j+1
    if (k == 0):
        sortedQueue.append(elem)
    else:
        k=0
    j=0

print (sortedQueue)
&lt;/pre&gt;&lt;b&gt;Answers:&lt;/b&gt; &lt;b&gt;&lt;i&gt;1. &amp;nbsp;The best case senario would be order: $O(n)$&lt;/i&gt;&lt;/b&gt; &lt;b&gt;&lt;i&gt;2. &amp;nbsp;The worst case senario would be order: $O(n^{2})$&lt;a href=&quot;http://ecocrypt.blogspot.com/p/go-language.html&quot;&gt;golang postings&lt;/a&gt;&lt;/i&gt;&lt;/b&gt; &lt;b&gt;&lt;i&gt; &lt;/i&gt;&lt;/b&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.ecocrypt.com/feeds/8417148433538421515/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.ecocrypt.com/2011/04/python-insertion-sort-impl.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/8417148433538421515'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/8417148433538421515'/><link rel='alternate' type='text/html' href='http://blog.ecocrypt.com/2011/04/python-insertion-sort-impl.html' title='Python - Insertion Sort Impl'/><author><name>Q. B.</name><uri>http://www.blogger.com/profile/08502256579896627307</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9e-xzbIV9ABn9OHlgiNbVBplXewci_K0F0yYD52TW8scrP1IbQfmHRVQKv9uy5wULo5xDNj8aPq51gJ4O84pgc3K3HFXWP1rYGbQMXPdcXeuEyzvl9lGkIWrLVbghNjY/s220/JetCloud.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3158873714071458599.post-2596257314738194916</id><published>2011-04-01T18:46:00.000-05:00</published><updated>2011-04-01T18:46:48.466-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="algorithm"/><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><category scheme="http://www.blogger.com/atom/ns#" term="Insertion sort"/><category scheme="http://www.blogger.com/atom/ns#" term="sorting"/><title type='text'>C++ - Insertion Sort Implementation w/ Make file Introduction</title><content type='html'>This article will discuss a simple insertion sort algorithm in C++.  Unlike any of the other languages in this series on the insertion sort algorithm.  C++ has for more caveats and options.  While the algorithm is exactly the same the implementation details are filled with pitfalls.&lt;br /&gt;
&lt;i&gt;&lt;b&gt;See ALL &lt;/b&gt;C++ postings&lt;/i&gt;&amp;nbsp;&amp;nbsp; | &amp;nbsp;Insertion Sort By Language &lt;a href=&quot;http://ecocrypt.blogspot.com/2011/03/java-insertion-sort-implementation-and.html&quot;&gt;Java&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://ecocrypt.blogspot.com/2011/03/scala-insertion-sort-implementation.html&quot;&gt;Scala&lt;/a&gt; &lt;b&gt;&lt;a href=&quot;http://ecocrypt.blogspot.com/2011/03/golang-insertion-sort-implimentaion-w.html&quot;&gt;Go&lt;/a&gt;&lt;/b&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #666666;&quot;&gt;&amp;nbsp;C++ Python Perl&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Overview of the Insertion Sort Algorithm&lt;/b&gt;&lt;br /&gt;
Insertion sort is one of the most natural ways of sorting a collection of comparable items. &amp;nbsp;The reason it is one of the most natural ways is because it is the way most people will sort physical items. &amp;nbsp; For example each year (about this time) I will sort all 12 of my previous years phone bills, gas bills, etc... &amp;nbsp;The algorithm used to sort them is to place the first one in stack. &amp;nbsp;Then the second one is compared to the first one to see if it goes in front of or behind the first one. &amp;nbsp;The third one is then compared to each if the two sorted items to determine where it fits in. &amp;nbsp;This procedure continues until all 12 bills are in the pile. &amp;nbsp;Once all 12 bills are in the pile it is sorted. I happen to sort form oldest to newest, my spouse does it the other way newest to oldest.&lt;br /&gt;
&lt;br /&gt;
Applying this concept to a collection of objects in a computer is fundamentally the same. &amp;nbsp;The algorithm dictates that one will iterate over a collection of elements in an unsorted list 1 at a time, and place that item into it&#39;s correct location in a sorted list.&lt;br /&gt;
&lt;br /&gt;
If the collection of objects to sort is n, insertion sort will take at most $O(n^2)$ operations to perform the sort, it will take on average $\frac{1}{2} O(n^2) = O(n^2)$, and in the best case senario will take $O(n)$ operations.&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;Questions: &amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;1. &amp;nbsp;What would be the initial characteristics of a list that took the worst case order $O(n^2)$ to sort?&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;2. &amp;nbsp;&lt;/b&gt;&lt;b&gt;What would be the initial characteristics of a list that took the best case order $O(n)$ to sort?&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;About the C++ Solution:&lt;/b&gt;&lt;br /&gt;
There are several caveats to the C++ solution. &amp;nbsp;Therefore the source file will simply be discussed from top to bottom, with each decision discussed in turn. &lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;&lt;i&gt;Imports:&lt;/i&gt; The first thing to notice is the choice of the imports, this solution imports the iostream, list, and cstdlib. &amp;nbsp;&lt;/li&gt;
&lt;ol&gt;&lt;li&gt;The iostream should be familiar as it is used for I/O. &amp;nbsp;&lt;/li&gt;
&lt;li&gt;The list chosen here is from the STL of C++ and is included with the #import &amp;lt;list&amp;gt; directive.&lt;/li&gt;
&lt;li&gt;The cstdlib is imported to expose the rand function which is a sudo random number generator.&lt;/li&gt;
&lt;/ol&gt;&lt;li&gt;&lt;i&gt;using namespace std&lt;/i&gt; - this allows reference without the need for adding std:: to methods or objects included from std libraries.&lt;/li&gt;
&lt;li&gt;&lt;i&gt;Forward Declarations&lt;/i&gt;- C++ requires knowledge of all methods and classes before they are used. &amp;nbsp;That means that the compiler must know what each class/methods signature is before first use. &amp;nbsp;(see inline comment)&lt;/li&gt;
&lt;li&gt;&lt;i&gt;Pointers Vs Automatics&lt;/i&gt; - In this simple example, two lists of ints are created, the unsorted list, and the sorted list. &amp;nbsp;For&amp;nbsp;pedagogical purposes, one was created on the heap, and the other as an &quot;automatic&quot; on the stack. &amp;nbsp;Heap allocated objects must be explicitly freed, or there might be a memory leak. &amp;nbsp;In C++ malloc and free go together, and new/delete go together, where delete releases the memory back to the operating system. &amp;nbsp;Objects that are stack allocated (created without a call to new or malloc/calloc) will be automatically released once the object goes out of scope. &amp;nbsp;Note that it might be possible to blow your stack if you allocate to many automatics.&lt;/li&gt;
&lt;li&gt;&lt;i&gt;Iterators&lt;/i&gt; - This code example is using the concept of a C++ STL iterator. &amp;nbsp;The concept of an iterator actually warrants multiple posts. &amp;nbsp;Basically from a very simplistic point of view, an iterator will visit each member of the list in turn.&lt;/li&gt;
&lt;/ol&gt;&lt;br /&gt;
The code has comments that are non-verbose, and useful. &amp;nbsp;Reading the code and comments along with compiling and running the code will help in the understanding of this&amp;nbsp;exercise. &amp;nbsp;If you have a question about the solution (or feel it should be improved) please leave a comment. &amp;nbsp;All comments are moderated and posted with your name/Identification so please be professional and straight forward.&lt;br /&gt;
&lt;b&gt;C++ Solution:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;script class=&quot;brush: cpp&quot; type=&quot;syntaxhighlighter&quot;&gt;
&lt;![CDATA[
/*------------------------------------------------------------------------------
  Copyright (c) 2011 ecocrypt.com
 
  Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
 
      http://www.apache.org/licenses/LICENSE-2.0
 
  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the spe\]cific language governing permissions and
  limitations under the License.
-----------------------------------------------------------------------------*/

#include &lt;iostream&gt;
#include &lt;list&gt;
#include &lt;cstdlib&gt;

using namespace std;

//  Forward Declarations reqired in c.
void printList(std::list&lt;int&gt; list);
std::list&lt;int&gt; insertionSort(std::list&lt;int&gt; unsortedList);
std::list&lt;int&gt;* createRandomList(void);

int main(int argc, const char** argv)
{
    std::list&lt;int&gt; *unsortedList = createRandomList();
    std::list&lt;int&gt; sortedList = insertionSort(*unsortedList);
    printList(sortedList);

 //  to prevent memory leaks, we must free objects before they go out of scope.
 //  Note: that sortedList is an automatic and will be allocated on the stack.
 free(unsortedList);

    return 0;
}


std::list&lt;int&gt;* createRandomList()
{
    srand(1);
    std::list&lt;int&gt; *int_list = new std::list&lt;int&gt;();
    for(int i =0;i&lt;10;++i)
    {
        int_list-&gt;push_back(rand());
    }
 return int_list;
}

void printList(std::list&lt;int&gt; int_list)
{
    for(std::list&lt;int&gt;::iterator list_iter = int_list.begin();list_iter != int_list.end(); list_iter++)
    {
        std::cout&lt;&lt;&quot;    &quot;&lt;&lt; (int)*list_iter  &lt;&lt;endl;
    }
}

std::list&lt;int&gt; insertionSort(std::list&lt;int&gt; unsortedList)
{
    std::list&lt;int&gt; sortedList;
    for(std::list&lt;int&gt;::iterator list_iter = unsortedList.begin();
            list_iter!=unsortedList.end(); list_iter++)
    {
        int found=0;
        for(std::list&lt;int&gt;::iterator sortedIter = sortedList.begin();
                    list_iter!=sortedList.end(); sortedIter++)
        {
            if((int)*sortedIter&gt;(int)*list_iter)
            {
                // insert before the first larger item
                sortedList.insert(sortedIter,(int)*list_iter);
                found=1;
                break;
            }
        }
        if(found!=1)
        {
            // insert tail.
            sortedList.push_back((int)*list_iter);
        }
    }
    return sortedList;
}

//-------------------------------------------------------------------------------------------
//  Some after thoughts...
//int_list.sort();
//int_list.unique();
//int_list = insertionSort(int_list);
//-------------------------------------------------------------------------------------------


]]&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
The make file:&lt;br /&gt;
The make file is presented twice, once with inline comments, and once without. &amp;nbsp;Make files have many interesting caveats that may make direct cutting and pasting of the file difficult, but I will explain.&lt;br /&gt;
in a make file, targets are the commands that can be executed. &amp;nbsp;Each target line contains instructions to be carried out. &amp;nbsp;The instruction lines are on the line(s)&amp;nbsp;immediately&amp;nbsp;following the target line. &amp;nbsp;Each target knows it&#39;s instructions ONLY by looking for the consecutive lines that immediately follow it, AND are indented with a single TAB &#39;\t&#39; character. &amp;nbsp;Therefore, if you text editor converts tabs to spaces or something like that, it will mangle the make file because the tab characters are significant and have meaning.&lt;br /&gt;
&lt;br /&gt;
first without comments, then with comments for reference:&lt;br /&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;#--------------------------------------
#
#  Copyright (c) 2011 EcoCrypt.com 
# 
#--------------------------------------

CPP=g++

MAIN=InsertionSort

.SUFFIXES : .exe .cpp

ifeq (${OS},Windows_NT)
EXES=${MAIN}.exe
RM=del /S 
else
EXES=${MAIN}
RM=rm -f # implicitly defined on unix
endif

ALL: ${EXES}

.cpp.exe: 
 echo ${CPP} ${DIRECTIVES} $? -o $@ 
 ${CPP} ${DIRECTIVES} $? -o $@ 

clean:
 ${RM} ${EXES}


&lt;/pre&gt;&lt;br /&gt;
Find below the make file with comments:&lt;br /&gt;
&lt;pre class=&quot;brush: bash; smart-tabs: false; tab-size=9;&quot;&gt;#--------------------------------------
#
#  Copyright (c) 2011 EcoCrypt.com 
# 
#--------------------------------------

#---------------------------------------
#  Set your compiler
#  On Windows Microsoftt compiler:
#  (i.e. CPP=cl)
#  On Linux, GUN compiler:
#  CPP=g++
#  On Windows MinGW (Minimal GNU for Windows):
#  CPP=g++.exe
#

CPP=g++
#CPP=cl.exe

#  The name of the main output
MAIN=InsertionSort

#  WE have to pass in VC98 and -GX if the compiler
#  is the cl compiler from Microsoft.
ifeq ($(CPP),cl.exe)
DIRECTIVES= -DVC98 -GX
else
endif

.SUFFIXES : .exe .cpp
#---------------------------------------
#  The windows version will contain a .exe
#  extention for each file.
#
#  List the executables.
#  here we have 2 mains that we 
#  will make: test and greetings.
#
#  Also redefine the implicit RM var.
ifeq (${OS},Windows_NT)
EXES=${MAIN}.exe
RM=del /S 
else
EXES=${MAIN}
RM=rm -f # implicitly defined on unix
endif

#---------------------------------------
#  The first target will create all
#  the EXES and recreate any that are 
#  out of Date.
#
#  This is also important because it is 
#  the default target, if you just invoke
#  make from the command like, the first 
#  dependency line becomes the default target.
#
ALL: ${EXES}

#---------------------------------------
#  Suffix rules are powerful and cryptic.
#  This states, for any target with no  (or .exe on windows)
#  suffix, look for a like named file with
#  an extension of .cpp, and perform the command
#  
#  (e.g.  for a file/dependecy named &#39;test.exe&#39;
#         look for test.cpp, and perform
#         g++ test.cpp -o test.exe)
.cpp.exe: 
 echo ${CPP} ${DIRECTIVES} $? -o $@ 
 ${CPP} ${DIRECTIVES} $? -o $@ 

#---------------------------------------
#  clean the targets so you can force a 
#  rebuild

clean:
 ${RM} ${EXES}


&lt;/pre&gt;&lt;br /&gt;
&lt;b&gt;Common Issues:&lt;/b&gt;&lt;br /&gt;
Forgetting to add the &quot;using namespace std&quot;&lt;br /&gt;
This is a common issue because older C++ books did not discuss this as it was added to C++ some time after the ansi standard was initially finalized.&lt;br /&gt;
Typically Error:&lt;br /&gt;
&lt;pre class=&quot;brush: bash; smart-tabs: false; tab-size=9;&quot;&gt;EcoCryptCppExamples\src\InsertionSort % make
echo g++  InsertionSort.cpp -o InsertionSort.exe
g++  InsertionSort.cpp -o InsertionSort.exe
g++  InsertionSort.cpp -o InsertionSort.exe
InsertionSort.cpp: In function &#39;void printList(std::list&lt;int&gt;)&#39;:
InsertionSort.cpp:57:48: error: &#39;endl&#39; was not declared in this scope
make: *** [InsertionSort.exe] Error 1
&lt;/pre&gt;&lt;br /&gt;
Leaving off one of the import statements.  This demonstrates the error if the cstdlib is not imported, which defines the rand and srand functions.&lt;br /&gt;
&lt;pre class=&quot;brush: bash; smart-tabs: false; tab-size=9;&quot;&gt;
EcoCryptCppExamples\src\InsertionSort % make
echo g++  InsertionSort.cpp -o InsertionSort.exe
g++  InsertionSort.cpp -o InsertionSort.exe
g++  InsertionSort.cpp -o InsertionSort.exe
InsertionSort.cpp: In function &#39;void printList(std::list&lt;int&gt;)&#39;:
InsertionSort.cpp:57:48: error: &#39;endl&#39; was not declared in this scope
make: *** [InsertionSort.exe] Error 1

&lt;/pre&gt;The make file is missing key tabs:&lt;br /&gt;
&lt;pre class=&quot;brush: bash; smart-tabs: false; tab-size=9;&quot;&gt;C:\47906Proxy\EcoCryptCppExamples\src\InsertionSort&gt;make
Makefile:70: *** missing separator.  Stop.

&lt;/pre&gt;&lt;pre class=&quot;brush: bash; smart-tabs: false; tab-size=9;&quot;&gt;&lt;/pre&gt;&lt;pre class=&quot;brush: bash; smart-tabs: false; tab-size=9;&quot;&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;b&gt;Answers:&lt;/b&gt; &lt;b&gt;&lt;i&gt;1. &amp;nbsp;The best case senario would be order: $O(n)$&lt;/i&gt;&lt;/b&gt; &lt;b&gt;&lt;i&gt;2. &amp;nbsp;The worst case senario would be order: $O(n^{2})$&lt;a href=&quot;http://ecocrypt.blogspot.com/p/go-language.html&quot;&gt;golang postings&lt;/a&gt;&lt;/i&gt;&lt;/b&gt; &lt;b&gt;&lt;i&gt; &lt;/i&gt;&lt;/b&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.ecocrypt.com/feeds/2596257314738194916/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.ecocrypt.com/2011/04/c-insertion-sort-implementation-w-make.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/2596257314738194916'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/2596257314738194916'/><link rel='alternate' type='text/html' href='http://blog.ecocrypt.com/2011/04/c-insertion-sort-implementation-w-make.html' title='C++ - Insertion Sort Implementation w/ Make file Introduction'/><author><name>Q. B.</name><uri>http://www.blogger.com/profile/08502256579896627307</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9e-xzbIV9ABn9OHlgiNbVBplXewci_K0F0yYD52TW8scrP1IbQfmHRVQKv9uy5wULo5xDNj8aPq51gJ4O84pgc3K3HFXWP1rYGbQMXPdcXeuEyzvl9lGkIWrLVbghNjY/s220/JetCloud.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3158873714071458599.post-6337804575449566515</id><published>2011-03-26T15:32:00.004-05:00</published><updated>2011-03-26T21:54:31.537-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="algorithm"/><category scheme="http://www.blogger.com/atom/ns#" term="golang"/><category scheme="http://www.blogger.com/atom/ns#" term="google go"/><category scheme="http://www.blogger.com/atom/ns#" term="Insertion sort"/><category scheme="http://www.blogger.com/atom/ns#" term="sorting"/><title type='text'>GoLang - Insertion Sort Implimentaion w/ google go</title><content type='html'>This article will discuss a simple insertion sort algorithm in golang (google go).&lt;br /&gt;
&lt;b&gt;&lt;i&gt;See ALL&lt;/i&gt;&lt;/b&gt; &lt;a href=&quot;http://ecocrypt.blogspot.com/p/go-language.html&quot;&gt;golang interest postings&lt;/a&gt;&amp;nbsp;&amp;nbsp; | &amp;nbsp;Insertion Sort By Language &lt;a href=&quot;http://ecocrypt.blogspot.com/2011/03/java-insertion-sort-implementation-and.html&quot;&gt;Java&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://ecocrypt.blogspot.com/2011/03/scala-insertion-sort-implementation.html&quot;&gt;Scala&lt;/a&gt; &lt;b&gt;&lt;a href=&quot;http://ecocrypt.blogspot.com/2011/03/golang-insertion-sort-implimentaion-w.html&quot;&gt;Go&lt;/a&gt;&lt;/b&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #666666;&quot;&gt;&amp;nbsp;Python Perl&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Overview of the Insertion Sort Algorithm&lt;/b&gt;&lt;br /&gt;
Insertion sort is one of the most natural wayTs of sorting a collection of comparable items. &amp;nbsp;The reason it is one of the most natural ways is because it is the way most people will sort physical items. &amp;nbsp; For example each year (about this time) I will sort all 12 of my previous years phone bills, gas bills, etc... &amp;nbsp;The algorithm used to sort them is to place the first one in stack. &amp;nbsp;Then the second one is compared to the first one to see if it goes in front of or behind the first one. &amp;nbsp;The third one is then compared to each if the two sorted items to determine where it fits in. &amp;nbsp;This procedure continues until all 12 bills are in the pile. &amp;nbsp;Once all 12 bills are in the pile it is sorted. I happen to sort form oldest to newest, my spouse does it the other way newest to oldest.&lt;br /&gt;
&lt;br /&gt;
Applying this concept to a collection of objects in a computer is fundamentally the same. &amp;nbsp;The algorithm dictates that one will iterate over a collection of elements in an unsorted list 1 at a time, and place that item into it&#39;s correct location in a sorted list.&lt;br /&gt;
&lt;br /&gt;
If the collection of objects to sort is n, insertion sort will take at most $O(n^2)$ operations to perform the sort, it will take on average $\frac{1}{2} O(n^2) = O(n^2)$, and in the best case senario will take $O(n)$ operations.&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;Questions: &amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;1. &amp;nbsp;What would be the initial characteristics of a list that took the worst case order $O(n^2)$ to sort?&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;2. &amp;nbsp;&lt;/b&gt;&lt;b&gt;What would be the initial characteristics of a list that took the best case order $O(n)$ to sort?&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;About the GoLang Solution:&lt;/b&gt;&lt;br /&gt;
Inline comments have been added to the code to discuss some of the syntax and code structure.&lt;br /&gt;
If you have a question about the solution (or feel it should be improved) please leave a comment. &amp;nbsp;All comments are moderated and posted with your name/Identification so please be professional and straight forward.&lt;br /&gt;
&lt;b&gt;GoLang Solution:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: cpp&quot;&gt;package main

/*------------------------------------------------------------------------------
  Copyright (c) 2011 ecocrypt.com

  Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the spe\]cific language governing permissions and
  limitations under the License.
-----------------------------------------------------------------------------*/
import fmt &quot;fmt&quot;  
import &quot;container/list&quot; 
import &quot;rand&quot;

//  The main entry point.
func main() {
    // create a list of integers randomly ordered.
    var  randomOrderedList = createRandomUnsortedList() 

    //  Perform the insertion sort.
    //  return a new sorted list.
    var sortedList = insertionSort(randomOrderedList)


    //  display the list to standard out.
    displayListToStandardOut(sortedList) 

}


//  private function takes unsortedList, returns sortedList
func insertionSort(unsortedList *list.List) (sortedList *list.List){
    sortedList = list.New()
    for e :=unsortedList.Front();e!=nil; e=e.Next() {
        var found = 0
        for s := sortedList.Front();s!=nil;s=s.Next(){
            if(e.Value.(int)&amp;gt;s.Value.(int)){
                found=1
                sortedList.InsertBefore(e.Value,s)
                s=sortedList.Back()
            }
        }
        if(found==0){
            sortedList.PushBack(e.Value)
        }
    }
    return sortedList
}


//  private method displays the lList to standard out.
func displayListToStandardOut(lList *list.List) {
    counter := 0
    for y :=lList.Front();y!=nil; y=y.Next() {
        counter += 1
        fmt.Printf(&quot;%d -&amp;gt; %d\n&quot;,counter,y.Value)
    }
}

// private method returns lList
func createRandomUnsortedList() (lList *list.List) {
    //  Create a New Random Generator from a Random Source
    //  with a seed of 10.
        var r = rand.New(rand.NewSource(10))

    //  create a list of random integers.
    lList = list.New()
    for i :=0; i&amp;lt;15; i=i + 1 {
        lList.PushFront(r.Int())
    }
    return lList
}
&lt;/pre&gt;&lt;b&gt;Answers:&lt;/b&gt; &lt;b&gt;&lt;i&gt;1. &amp;nbsp;The best case senario would be order: $O(n)$&lt;/i&gt;&lt;/b&gt; &lt;b&gt;&lt;i&gt;2. &amp;nbsp;The worst case senario would be order: $O(n^{2})$&lt;a href=&quot;http://ecocrypt.blogspot.com/p/go-language.html&quot;&gt;golang postings&lt;/a&gt;&lt;/i&gt;&lt;/b&gt; &lt;b&gt;&lt;i&gt; &lt;/i&gt;&lt;/b&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.ecocrypt.com/feeds/6337804575449566515/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.ecocrypt.com/2011/03/golang-insertion-sort-implimentaion-w.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/6337804575449566515'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/6337804575449566515'/><link rel='alternate' type='text/html' href='http://blog.ecocrypt.com/2011/03/golang-insertion-sort-implimentaion-w.html' title='GoLang - Insertion Sort Implimentaion w/ google go'/><author><name>Q. B.</name><uri>http://www.blogger.com/profile/08502256579896627307</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9e-xzbIV9ABn9OHlgiNbVBplXewci_K0F0yYD52TW8scrP1IbQfmHRVQKv9uy5wULo5xDNj8aPq51gJ4O84pgc3K3HFXWP1rYGbQMXPdcXeuEyzvl9lGkIWrLVbghNjY/s220/JetCloud.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3158873714071458599.post-3750791964410832514</id><published>2011-03-22T23:16:00.003-05:00</published><updated>2011-03-26T21:13:37.282-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="algorithm"/><category scheme="http://www.blogger.com/atom/ns#" term="Insertion sort"/><category scheme="http://www.blogger.com/atom/ns#" term="scala"/><category scheme="http://www.blogger.com/atom/ns#" term="sorting"/><title type='text'>Scala - Insertion Sort Implementation</title><content type='html'>This article will discuss a simple insertion sort algorithm in Scala.&lt;br /&gt;
&lt;b&gt;&lt;i&gt;See ALL&lt;/i&gt;&lt;/b&gt; &lt;a href=&quot;http://ecocrypt.blogspot.com/p/scala-interest.html&quot;&gt;Scala postings&lt;/a&gt;&amp;nbsp;&amp;nbsp; | &amp;nbsp;Insertion Sort By Language &lt;a href=&quot;http://ecocrypt.blogspot.com/2011/03/java-insertion-sort-implementation-and.html&quot;&gt;Java&lt;/a&gt; &lt;b&gt;Scala&lt;/b&gt; &lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #666666;&quot;&gt;Go Python Perl&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Overview of the Insertion Sort Algorithm&lt;/b&gt;&lt;br /&gt;
Insertion sort is one of the most natural ways of sorting a collection of comparable items. &amp;nbsp;The reason it is one of the most natural ways is because it is the way most people will sort physical items. &amp;nbsp; For example each year (about this time) I will sort all 12 of my previous years phone bills, gas bills, etc... &amp;nbsp;The algorithm used to sort them is to place the first one in stack. &amp;nbsp;Then the second one is compared to the first one to see if it goes in front of or behind the first one. &amp;nbsp;The third one is then compared to each if the two sorted items to determine where it fits in. &amp;nbsp;This procedure continues until all 12 bills are in the pile. &amp;nbsp;Once all 12 bills are in the pile it is sorted. I happen to sort form oldest to newest, my spouse does it the other way newest to oldest.&lt;br /&gt;
&lt;br /&gt;
Applying this concept to a collection of objects in a computer is fundamentally the same. &amp;nbsp;The algorithm dictates that one will iterate over a collection of elements in an unsorted list 1 at a time, and place that item into it&#39;s correct location in a sorted list.&lt;br /&gt;
&lt;br /&gt;
If the collection of objects to sort is n, insertion sort will take at most $O(n^2)$ operations to perform the sort, it will take on average $\frac{1}{2} O(n^2) = O(n^2)$, and in the best case senario will take $O(n)$ operations.&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;Questions: &amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;1. &amp;nbsp;What would be the initial characteristics of a list that took the worst case order $O(n^2)$ to sort?&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;2. &amp;nbsp;&lt;/b&gt;&lt;b&gt;What would be the initial characteristics of a list that took the best case order $O(n)$ to sort?&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;About the Scala Solution:&lt;/b&gt;&lt;br /&gt;
Inline comments have been added to the code to discuss some of the syntax and code structure.&lt;br /&gt;
If you have a question about the solution (or feel it should be improved) please leave a comment. &amp;nbsp;All comments are moderated and posted with your name/Identification so please be professional and straight forward.&lt;br /&gt;
&lt;b&gt;Scala Solution:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: scala&quot;&gt;package com.ecocrypt.scala.helloworld.com.ecocrypt.scala.algorithms.sort

import java.util.LinkedList

/*------------------------------------------------------------------------------
  Copyright (c) 2011 ecocrypt.com

  Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the spe\]cific language governing permissions and
  limitations under the License.
-----------------------------------------------------------------------------*/

object InsertionSort {
    var flag = 0
    var counter = 0


    def sort(unsortedList: List[Int]): LinkedList[Int] = {
        // Start with an empty LinkedList.
        // as items are added to the list, they will be
        // placed in sorted order.
        var sorted = new LinkedList[Int]()

        // Iterate over the unsorted list one Item at a time.
        for (currentItem &amp;lt;- unsortedList) {
            flag = 0
            counter = 0;

            //------------------------------------------------------------------------------------
            //  Scala allows us to define helper functions with scope inside of other functions.
            //        this creates some very interesting closure situation.
            //        More on this in later code samples
            //------------------------------------------------------------------------------------
            def checkRecordToRightAndInsertIfLocationFound(itemRightOfCurrentPostion: Int): Int = {
                if (itemRightOfCurrentPostion &amp;gt; currentItem) {
                    // flag is a var defined in an enclosed scope.
                    flag = 1
                    if (counter &amp;lt; 0) {
                        sorted.addFirst(currentItem)
                    } else {
                        sorted.add(counter, currentItem);
                    }
                }
                //  this is the return val of this method.
                flag
            }


            do {
                if (counter == sorted.size) {
                    sorted.addLast(currentItem)
                    flag = 1
                } else {
                    var itemRightOfCurrentPostion = sorted.get(counter)
                    flag = checkRecordToRightAndInsertIfLocationFound(itemRightOfCurrentPostion)
                }
                counter = counter + 1
            } while (flag == 0)
        }
        return sorted
    }
}

//  Here we use an application to serve as the entry point.
object EntryPointForInsertionSortExample extends Application {
    val randomOrderedList = List.fill(10)(scala.util.Random.nextInt(1000))
    println(&quot;unsorted List : &quot; + randomOrderedList)
    val sortedList = InsertionSort.sort(randomOrderedList)
    println(&quot;sorted List : &quot; + sortedList)
}


&lt;/pre&gt;&lt;b&gt;Answers:&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;i&gt;1. &amp;nbsp;The best case senario would be order: $O(n)$&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;i&gt;2. &amp;nbsp;The worst case senario would be order: $O(n^{2})$&lt;/i&gt;&lt;/b&gt; &lt;b&gt;&lt;i&gt; &lt;/i&gt;&lt;/b&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.ecocrypt.com/feeds/3750791964410832514/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.ecocrypt.com/2011/03/scala-insertion-sort-implementation.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/3750791964410832514'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/3750791964410832514'/><link rel='alternate' type='text/html' href='http://blog.ecocrypt.com/2011/03/scala-insertion-sort-implementation.html' title='Scala - Insertion Sort Implementation'/><author><name>Q. B.</name><uri>http://www.blogger.com/profile/08502256579896627307</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9e-xzbIV9ABn9OHlgiNbVBplXewci_K0F0yYD52TW8scrP1IbQfmHRVQKv9uy5wULo5xDNj8aPq51gJ4O84pgc3K3HFXWP1rYGbQMXPdcXeuEyzvl9lGkIWrLVbghNjY/s220/JetCloud.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3158873714071458599.post-2512304701076016423</id><published>2011-03-16T22:07:00.011-05:00</published><updated>2011-03-26T21:06:15.189-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="algorithm"/><category scheme="http://www.blogger.com/atom/ns#" term="Insertion sort"/><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><category scheme="http://www.blogger.com/atom/ns#" term="sorting"/><title type='text'>Java - Insertion Sort Implementation and discussion.</title><content type='html'>This article will discuss a simple insertion sort algorithm in Java.&lt;br /&gt;
&lt;b&gt;&lt;i&gt;See ALL&lt;/i&gt;&lt;/b&gt;&amp;nbsp;&lt;a href=&quot;http://ecocrypt.blogspot.com/p/java-interest.html&quot;&gt;Java Postings&lt;/a&gt;&amp;nbsp;&amp;nbsp; | &amp;nbsp;Insertion Sort By Language &lt;a href=&quot;http://ecocrypt.blogspot.com/2011/03/java-insertion-sort-implementation-and.html&quot;&gt;&lt;b&gt;Java&lt;/b&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://ecocrypt.blogspot.com/2011/03/scala-insertion-sort-implementation.html&quot;&gt;Scala&lt;/a&gt; &lt;a href=&quot;http://ecocrypt.blogspot.com/2011/03/golang-insertion-sort-implimentaion-w.html&quot;&gt;Go&lt;/a&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #666666;&quot;&gt;&amp;nbsp;Python Perl&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Discussion of Insertion Sort&lt;/b&gt;&lt;br /&gt;
Insertion sort is one of the most natural ways of sorting a collection of comparable items. &amp;nbsp;The reason it is one of the most natural ways is because it is the way most people will sort physical items. &amp;nbsp; For example each year (about this time) I will sort all 12 of my previous years phone bills, gas bills, etc... &amp;nbsp;The algorithm used to sort them is to place the first one in stack. &amp;nbsp;Then the second one is compared to the first one to see if it goes in front of or behind the first one. &amp;nbsp;The third one is then compared to each if the two sorted items to determine where it fits in. &amp;nbsp;This procedure continues until all 12 bills are in the pile. &amp;nbsp;Once all 12 bills are in the pile it is sorted. I happen to sort form oldest to newest, my spouse does it the other way newest to oldest.&lt;br /&gt;
&lt;br /&gt;
Applying this concept to a collection of objects in a computer is fundamentally the same. &amp;nbsp;The algorithm dictates that one will iterate over a collection of elements in an unsorted list 1 at a time, and place that item into it&#39;s correct location in a sorted list.&lt;br /&gt;
&lt;br /&gt;
If the collection of objects to sort is n, insertion sort will take at most $O(n^2)$ operations to perform the sort, it will take on average $\frac{1}{2} O(n^2) = O(n^2)$, and in the best case senario will take $O(n)$ operations.&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;Questions: &amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;1. &amp;nbsp;What would be the initial characteristics of a list that took the worst case order $O(n^2)$ to sort?&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;2. &amp;nbsp;&lt;/b&gt;&lt;b&gt;What would be the initial characteristics of a list that took the best case order $O(n)$ to sort?&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;Java Solution:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java&quot;&gt;/*------------------------------------------------------------------------------
   Copyright (c) 2011 ecocrypt.com

   Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
 -----------------------------------------------------------------------------*/
package insertionsort;

import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;

public class InsertionSortAlgorithm&amp;lt;type extends Comparable&amp;gt; {
    Collection&amp;lt;type&amp;gt; unsortedCollection;

    public InsertionSortAlgorithm(){
        unsortedCollection = new ArrayList&amp;lt;type&amp;gt;();
    }

    public InsertionSortAlgorithm(Collection&amp;lt;type&amp;gt; sourceCollection){
        unsortedCollection = new ArrayList&amp;lt;type&amp;gt;(sourceCollection);
    }
    public void add(Type element){
        unsortedCollection.add(element);
    }
    public Collection&amp;lt;type&amp;gt; getUnsortedCollection(){
        return unsortedCollection;
    }

    public List&amp;lt;type&amp;gt; sortWithInsertionSort(){
        LinkedList&amp;lt;type&amp;gt; sortedList = new LinkedList&amp;lt;type&amp;gt;();
        for (Type nextObject : unsortedCollection) {
            sortedList = placeInSortedList(sortedList,nextObject);
        }
        return sortedList;
    }

    private LinkedList&amp;lt;type&amp;gt; placeInSortedList(LinkedList&amp;lt;type&amp;gt; sortedList, Type nextObject){
        int insertionIndex = 0;
        for (Type object : sortedList) {
            if(nextObject.compareTo(object)&amp;gt;0){
                break;
            }
            ++insertionIndex;
        }
        sortedList.add(insertionIndex, nextObject);
        return sortedList;
    }
}
&lt;/pre&gt;&lt;br /&gt;
&lt;b&gt;Answers:&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;i&gt;1. &amp;nbsp;The best case senario would be order: $O(n)$&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;i&gt;2. &amp;nbsp;The worst case senario would be order: $O(n^{2})$&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/b&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.ecocrypt.com/feeds/2512304701076016423/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.ecocrypt.com/2011/03/java-insertion-sort-implementation-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/2512304701076016423'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/2512304701076016423'/><link rel='alternate' type='text/html' href='http://blog.ecocrypt.com/2011/03/java-insertion-sort-implementation-and.html' title='Java - Insertion Sort Implementation and discussion.'/><author><name>Q. B.</name><uri>http://www.blogger.com/profile/08502256579896627307</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9e-xzbIV9ABn9OHlgiNbVBplXewci_K0F0yYD52TW8scrP1IbQfmHRVQKv9uy5wULo5xDNj8aPq51gJ4O84pgc3K3HFXWP1rYGbQMXPdcXeuEyzvl9lGkIWrLVbghNjY/s220/JetCloud.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3158873714071458599.post-5300428181406900968</id><published>2011-03-13T17:31:00.023-05:00</published><updated>2011-03-26T21:16:56.633-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Hello World"/><category scheme="http://www.blogger.com/atom/ns#" term="scala"/><title type='text'>Scala - Hello World</title><content type='html'>&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;Scala&#39;s Hello World can be either similar to Java&#39;s, or simpler depending on how the problem is approached. &amp;nbsp;This article will approach the problem from both the Java style as well as the much more pure functional style. &amp;nbsp;Remember that Scala is a highly expressive functional language. &amp;nbsp;The second form of the hello world program will show this feature much more clearly.&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;b&gt;Step 1:&amp;nbsp;&lt;i&gt;Create a Scala source file&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;Scala does not have the same restrictions on source file naming that Java has. &amp;nbsp;Therefore, you can give the Scala source file pretty much any name you like, so long as it ends in .scala. &amp;nbsp;The fist form of Hello World looks as:&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;__________________________________________________________________________________&lt;/div&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: scala&quot;&gt;object HelloWorld {
    def main(args: Array[String]) {
      println(&quot;Hello in scala from ecocrypt.blogspot.com&quot;)
    }
  }
&lt;/pre&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;__________________________________________________________________________________&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;b&gt;Step 2:&amp;nbsp;&lt;i&gt;Compile the Scala Source&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;At a command prompt, type the scala compiler command:&lt;/div&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;prompt %
prompt % scalac HelloWorld.scala
prompt %
&lt;/pre&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;prompt % scalac HelloWorld.scala&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;The result of this will be to produce an output file called HelloWorld.class, this class file is a byte code version of the HelloWorld.scala source file. &amp;nbsp;This class file is identical to a Java class file, but has Scala class references embedded in it. &amp;nbsp;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;b&gt;Step 3:&amp;nbsp;&lt;i&gt;Running HelloWorld&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;At the command prompt, type:&lt;/div&gt;&lt;pre class=&quot;brush: bash&quot;&gt;prompt %
prompt % scala HelloWorld
Hello in scala from ecocrypt.blogspot.com
prompt %
&lt;/pre&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;prompt % scala HelloWorld&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Hello in scala from ecocrypt.blogspot.com&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;Congratulate yourself! &amp;nbsp;You have successfully installed the Scala compiler and execution environment, created a simple scala source file compiled it to byte code, and run it inside of the Scala/Java Virtual Machine.&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;The exact same thing could be accomplished using a scala Application. &amp;nbsp;The source code for a Scala application based solution would look as:&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;__________________________________________________________________________________&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0c343d; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0c343d; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;object HelloWorld2 extends Application {&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0c343d; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;println(&quot;Hello world in scala from ecocrypt.blogspot.com&quot;)&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0c343d; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;__________________________________________________________________________________&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.ecocrypt.com/feeds/5300428181406900968/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.ecocrypt.com/2011/03/scala-hello-world.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/5300428181406900968'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/5300428181406900968'/><link rel='alternate' type='text/html' href='http://blog.ecocrypt.com/2011/03/scala-hello-world.html' title='Scala - Hello World'/><author><name>Q. B.</name><uri>http://www.blogger.com/profile/08502256579896627307</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9e-xzbIV9ABn9OHlgiNbVBplXewci_K0F0yYD52TW8scrP1IbQfmHRVQKv9uy5wULo5xDNj8aPq51gJ4O84pgc3K3HFXWP1rYGbQMXPdcXeuEyzvl9lGkIWrLVbghNjY/s220/JetCloud.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3158873714071458599.post-2333529960647815388</id><published>2011-03-13T01:16:00.002-06:00</published><updated>2011-03-26T21:11:39.311-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><category scheme="http://www.blogger.com/atom/ns#" term="Hello World"/><title type='text'>C++ - Hello World</title><content type='html'>&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;C++&#39;s Hello World is similar to Go&#39;s (golang), but there are some differences. &amp;nbsp;The similarity is that both C++ and Go create a file that is executed natively on the platform it is compiled to. &amp;nbsp;Also both C++ and Go follow a procedure of compile then link. &amp;nbsp;The main differences, for the Hello World program, are in the expressiveness and the syntax. &amp;nbsp;Writing hello world in C++ requires the following steps:&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;b&gt;Step 1:&amp;nbsp;&lt;i&gt;Create a C++ source file&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;The source file for Hello World thus looks like the following:&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;__________________________________________________________________________________&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0c343d; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0c343d; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;#include &amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0c343d; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;using namespace std;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0c343d; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0c343d; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;int main(int argc, const char** argv){&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0c343d; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;cout&amp;lt;&amp;lt;&quot;Hello World in C++ from ecocrypt.blogspot.com&quot;&amp;lt;&amp;lt;endl;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0c343d; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return 0;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0c343d; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;__________________________________________________________________________________&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;Save this to any file name you like, but typically, you will have to have a .cpp extension on the end of the file name. &amp;nbsp;A good name to choose for this example would be helloworld.cpp.&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;b&gt;Step 2:&amp;nbsp;&lt;i&gt;Compile the C++ Source&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;At a command prompt, type the c++ compiler-linker command:&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;prompt % c++ HelloWorld.cpp&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;This will typically do a 2 step process of compiling and linking. &amp;nbsp;Therefore no intermediate object files will be created. &amp;nbsp;The result of this will be to produce an output file called a.out, or a.exe.&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;b&gt;Step 3:&amp;nbsp;&lt;i&gt;Running HelloWorld&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;At the command prompt, type:&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;prompt % a.out &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #a2c4c9;&quot;&gt;(or a.exe on windows)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0c343d;&quot;&gt;Hello World in C++ from ecocrypt.blogspot.com&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;Congratulate yourself! &amp;nbsp;You have successfully installed a C++ compiler, and created a simple hello world executable.&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.ecocrypt.com/feeds/2333529960647815388/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.ecocrypt.com/2011/03/c-hello-world.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/2333529960647815388'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/2333529960647815388'/><link rel='alternate' type='text/html' href='http://blog.ecocrypt.com/2011/03/c-hello-world.html' title='C++ - Hello World'/><author><name>Q. B.</name><uri>http://www.blogger.com/profile/08502256579896627307</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9e-xzbIV9ABn9OHlgiNbVBplXewci_K0F0yYD52TW8scrP1IbQfmHRVQKv9uy5wULo5xDNj8aPq51gJ4O84pgc3K3HFXWP1rYGbQMXPdcXeuEyzvl9lGkIWrLVbghNjY/s220/JetCloud.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3158873714071458599.post-7787169385299328459</id><published>2011-03-13T00:35:00.001-06:00</published><updated>2011-03-26T21:15:59.467-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Hello World"/><category scheme="http://www.blogger.com/atom/ns#" term="perl"/><title type='text'>Perl - Hello World</title><content type='html'>&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Writing hello world in perl is almost to simple to justify a post, however there are some caveats and for completeness of this group of posts, it will be included.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Step 1&amp;nbsp;&lt;i&gt;Install Perl (5.x)&lt;/i&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Once installed, make sure that you can access the perl executable. &amp;nbsp;If perl is not in the path, you will need to add it.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Step 2&amp;nbsp;&lt;i&gt;Create a Perl Source file&lt;/i&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;______________________Source File____________________________&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0c343d; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;#!/opt/perl&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0c343d; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;print (&quot;Hello World in Perl from ecocrypt.blogspot.com&quot;)&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;______________________End Source____________________________&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;save the source to a file called helloworld.pl &amp;nbsp;(or any other name of your choice)&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Step 3&amp;nbsp;&lt;i&gt;Tell Perl to execute the input file&lt;/i&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;prompt % perl helloworld.pl&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Hello World in Perl from ecocrypt.blogspot.com&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Congratulate yourself! You have successfully installed perl, create a perl source file, and executed it.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.ecocrypt.com/feeds/7787169385299328459/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.ecocrypt.com/2011/03/perl-hello-world.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/7787169385299328459'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/7787169385299328459'/><link rel='alternate' type='text/html' href='http://blog.ecocrypt.com/2011/03/perl-hello-world.html' title='Perl - Hello World'/><author><name>Q. B.</name><uri>http://www.blogger.com/profile/08502256579896627307</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9e-xzbIV9ABn9OHlgiNbVBplXewci_K0F0yYD52TW8scrP1IbQfmHRVQKv9uy5wULo5xDNj8aPq51gJ4O84pgc3K3HFXWP1rYGbQMXPdcXeuEyzvl9lGkIWrLVbghNjY/s220/JetCloud.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3158873714071458599.post-7756317540762065045</id><published>2011-03-13T00:16:00.008-06:00</published><updated>2011-03-26T21:53:18.682-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Hello World"/><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><title type='text'>Java - Hello World</title><content type='html'>Java&#39;s Hello World is simpler than Go&#39;s (golang), but not as simple as Python&#39;s. &amp;nbsp;Also like python the output is quite portable from platform to platform. &amp;nbsp;Writing hello world in Java requires the following steps:&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Step 1: &lt;i&gt;Create a Java source file&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
There are actually quite a few caveats to this step alone because Java as some requirements that make it more restrictive &amp;nbsp;than any other language in this blog. &amp;nbsp;In Java, there everything is an &quot;Object&quot; and thus extends from java.lang.Object. &amp;nbsp;Therefore, you will have to create a full class definition even though we will not be instantiating any classes. &amp;nbsp;The source file for Hello World thus looks like the following:&lt;br /&gt;
__________________________________________________________________________________&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java&quot;&gt;public class HelloWorld extends java.lang.Object {
    public static void main(String args[]){
        System.out.println(&quot;Hello World in Java from ecocrypt.blogspot.com&quot;);
    }
}
&lt;/pre&gt;__________________________________________________________________________________&lt;br /&gt;
&lt;br /&gt;
There is another caveat in Java the class HelloWord must be stored in a file called HelloWorld.java. Picking another name will cause a compiler error.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Step 2: &lt;i&gt;Compile the Java Source&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
At a command prompt, type the java compiler command:&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;prompt % javac HelloWorld.java&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The result of this will be to produce an output file called HelloWorld.class, this class file is a byte code version of the HelloWorld.java source file. &amp;nbsp;Unlike golang, where the output of the linker can be directly executed, the java class file is not executable. &amp;nbsp;However, a java executable program and load the HelloWorld.class file, and execute the instructions.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Step 3: &lt;i&gt;Running HelloWorld&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
At the command prompt, type:&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;prompt % java HelloWorld&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0c343d;&quot;&gt;Hello World in Java from ecocrypt.blogspot.com&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Congratulate yourself! &amp;nbsp;You have successfully installed the JDK, created a simple java source file compiled it to byte code, and run it inside of the Java Virtual Machine.</content><link rel='replies' type='application/atom+xml' href='http://blog.ecocrypt.com/feeds/7756317540762065045/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.ecocrypt.com/2011/03/java-hello-world.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/7756317540762065045'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/7756317540762065045'/><link rel='alternate' type='text/html' href='http://blog.ecocrypt.com/2011/03/java-hello-world.html' title='Java - Hello World'/><author><name>Q. B.</name><uri>http://www.blogger.com/profile/08502256579896627307</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9e-xzbIV9ABn9OHlgiNbVBplXewci_K0F0yYD52TW8scrP1IbQfmHRVQKv9uy5wULo5xDNj8aPq51gJ4O84pgc3K3HFXWP1rYGbQMXPdcXeuEyzvl9lGkIWrLVbghNjY/s220/JetCloud.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3158873714071458599.post-8192763788772782518</id><published>2011-03-11T19:53:00.002-06:00</published><updated>2011-03-26T21:12:26.632-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="golang"/><category scheme="http://www.blogger.com/atom/ns#" term="google go"/><category scheme="http://www.blogger.com/atom/ns#" term="Hello World"/><title type='text'>Go Lang - Hello World</title><content type='html'>Starting a new language the first example is always Hello World. &amp;nbsp;Getting going with go-lang is only slightly different. &amp;nbsp;As of this writing, the current state of &#39;go-lang&#39; is that you have to build the compiler first, and then write compile and run Hello World. &amp;nbsp;On UNIX/Linux you can do that pretty easily based on the instructions maintained on the golang.org website. &amp;nbsp;On windows the &lt;a href=&quot;http://goo.gl/T9V5C&quot;&gt;GOMINGW&lt;/a&gt;&amp;nbsp;&amp;nbsp;seems to be maintaining good binary compatible version of go built with the mingw compiler collection on windows.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Step 1 &lt;i&gt;Set your environment variables:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;E.G. On my windows box I set:&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, sans-serif; font-size: 13px;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;pre style=&quot;font-size: 12px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: hidden; overflow-y: hidden; padding-left: 0.7em; white-space: pre-wrap;&quot;&gt;set GOROOT=C:\golang\go
set GOOS=windows
set GOARCH=386&lt;/pre&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&lt;i&gt;(look in $GOROOT/pkg for applicable architecture and OS Options)&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, sans-serif; font-size: 13px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;Step 2 &lt;i&gt;Create a source file in the go language (a go source file):&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
Use a text editor or write a golang source file:&lt;br /&gt;
Sample Hello World GO Language source file:&lt;br /&gt;
________________________SOURCE FILE________________________________________&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #660000; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;package main&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #660000;&quot;&gt;&lt;br /&gt;
import fmt &quot;fmt&quot; &amp;nbsp;// Package implementing formatted I/O.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #660000;&quot;&gt;&lt;br /&gt;
func main() {&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #660000; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;fmt.Printf(&quot;Hello, world; from go to ecocrypt.blogspot.com \n&quot;)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #660000; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;________________________END SOURCE_________________________________________&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Save this file to helloworld.go or any filename of your choice.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Step 3 &lt;i&gt;&amp;nbsp;Compile&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
prompt % 8g helloworld.go&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Step 4&lt;/b&gt; &lt;i&gt;&lt;b&gt;Link&lt;/b&gt;&lt;/i&gt;&lt;br /&gt;
prompt % 8l helloworld.go&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Step 5&lt;/b&gt; &lt;i&gt;&lt;b&gt;Run the newly created executable:&lt;/b&gt;&lt;/i&gt;&lt;br /&gt;
prompt % 8.out&lt;br /&gt;
Hello, world; from go to ecocrypt.blogspot.com&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Congratulate Yourself!&lt;/b&gt; &amp;nbsp;You have created and run Hello World in Go.&lt;br /&gt;
You should now have a Go compiler successfully installed on your computer.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;SOME COMMON ERRORS:&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;i&gt;Using the wrong executable to compile go source:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
prompt % &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #20124d;&quot;&gt;8c.exe helloworld.go&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #cc0000;&quot;&gt;helloworld.go:1 not a function&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #cc0000;&quot;&gt;helloworld.go:1 syntax error, last name: main&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #274e13;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; This Error is caused because you are trying to compile a go source file with a c compiler. &amp;nbsp;8c is a c compiler embedded in the go&amp;nbsp;distribution&amp;nbsp;package.&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;b&gt;&lt;i&gt;Using the wrong architecture or os settings:&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;prompt % &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;8g.exe helloworld.go&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;helloworld.go:3: can&#39;t find import: fmt&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #274e13;&quot;&gt;Make sure you have set the go environment variables correctly:&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #274e13;&quot;&gt;Determining the GOOS, and GOARCH can be tricky, you will have to look in:&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #274e13;&quot;&gt;$GOROOT/pkg/&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #274e13;&quot;&gt;and there will be a directory of format $GOOS_$ARCH&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
E.G. On my windows box I set:&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, sans-serif; font-size: 13px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;font-size: 12px; overflow-x: hidden; overflow-y: hidden; padding-left: 0.7em; white-space: pre-wrap;&quot;&gt;set GOROOT=C:\golang\go
set GOOS=windows
set GOARCH=386&lt;/pre&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, sans-serif; font-size: 13px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;font-size: 12px; overflow-x: hidden; overflow-y: hidden; padding-left: 0.7em; white-space: pre-wrap;&quot;&gt;&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.ecocrypt.com/feeds/8192763788772782518/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.ecocrypt.com/2011/03/go-lang-hello-world.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/8192763788772782518'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/8192763788772782518'/><link rel='alternate' type='text/html' href='http://blog.ecocrypt.com/2011/03/go-lang-hello-world.html' title='Go Lang - Hello World'/><author><name>Q. B.</name><uri>http://www.blogger.com/profile/08502256579896627307</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9e-xzbIV9ABn9OHlgiNbVBplXewci_K0F0yYD52TW8scrP1IbQfmHRVQKv9uy5wULo5xDNj8aPq51gJ4O84pgc3K3HFXWP1rYGbQMXPdcXeuEyzvl9lGkIWrLVbghNjY/s220/JetCloud.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3158873714071458599.post-4105246133277928460</id><published>2011-03-09T21:58:00.004-06:00</published><updated>2011-03-26T21:11:05.228-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Hello World"/><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><title type='text'>Python - Hello World</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Writing hello world in python is almost to simple to justify a post, however there are some caveats and for completeness of this group of posts, it will be included.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Step 1 &lt;i&gt;Install Python 3.2&amp;nbsp;&lt;/i&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Once installed, make sure that you can access the python executable. &amp;nbsp;If python is not in the path, you will need to add it.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Step 2 &lt;i&gt;Create a Python Source file&lt;/i&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;______________________Source File____________________________&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0c343d; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;#!/opt/python&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0c343d; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;print (&quot;Hello World in Python from ecocrypt.blogspot.com&quot;)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;______________________End Source____________________________&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;save the source to a file called helloworld.py &amp;nbsp;(or any other name of your choice)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Step 3 &lt;i&gt;Tell the Python&amp;nbsp;Interrupter&amp;nbsp;to execute the instructions in the file&lt;/i&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;prompt % python helloworld.py&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Hello World in Python from ecocrypt.blogspot.com&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;This entire exercise could have been done from within the python interrupter. &amp;nbsp;To start the&amp;nbsp;interpretor simply type &#39;python&#39;&amp;nbsp;at the command prompt this will give you a python interpretor prompt:&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;print (&quot;hello world in python from ecocyrpt.blogspot.com&quot;)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;hello world in python from ecocyrpt.blogspot.com&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;type &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;quit()&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt; to leave the interpretor&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #222222; line-height: 18px;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;SOME COMMON ERRORS:&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #222222; font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 18px;&quot;&gt;&lt;i&gt;Using the wrong Python Syntax for version 3.2.&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 18px;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: #222222;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;gt;&amp;gt;&amp;gt; print &quot;Hello World&quot;&lt;/span&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #222222;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&amp;nbsp;File &quot;&amp;lt;stdin&amp;gt;&quot;, line 1&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;print &quot;Hello World&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;^&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;SyntaxError: invalid syntax&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: #222222;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #274e13; font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 18px;&quot;&gt;&lt;i&gt;There were some syntax changes between python 2.7 and 3.2.&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #274e13; font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 18px;&quot;&gt;&lt;i&gt;This fails because the print method is not enclosed in braces().&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 18px;&quot;&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #274e13;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Try &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;gt;&amp;gt;&amp;gt; print (&quot;Hello World&quot;)&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #222222; font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 18px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #222222; font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 18px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.ecocrypt.com/feeds/4105246133277928460/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.ecocrypt.com/2011/03/python-hello-world.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/4105246133277928460'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3158873714071458599/posts/default/4105246133277928460'/><link rel='alternate' type='text/html' href='http://blog.ecocrypt.com/2011/03/python-hello-world.html' title='Python - Hello World'/><author><name>Q. B.</name><uri>http://www.blogger.com/profile/08502256579896627307</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9e-xzbIV9ABn9OHlgiNbVBplXewci_K0F0yYD52TW8scrP1IbQfmHRVQKv9uy5wULo5xDNj8aPq51gJ4O84pgc3K3HFXWP1rYGbQMXPdcXeuEyzvl9lGkIWrLVbghNjY/s220/JetCloud.jpg'/></author><thr:total>0</thr:total></entry></feed>