Thursday, July 30, 2015

How to use LeanPub to publish your Poetry

Last night, I created a book of my poems, The Solemn Rose Poetry Collection, and published it to LeanPub.

You can do the same (publish your own poetry or other book ideas) in a few easy steps.

  • Gather your poetry
  • Register as a user on LeanPub
  • Create a new project on LeanPub
  • Organize your poetry and add the content to your project
  • Create a Cover Page
  • Monetize your Book
  • Publish!
That's it!  Now lets take a look at each step a little bit closer


Gather your poetry

Go ahead and gather all your poetry, so you have them ready when you go to add them into the project.  If you have and work that isn't typed up into your computer, now's the time.

Wonderful Poetry

Register for LeanPub

 Go to LeanPub and Signup... it's just as easy as registering for any other website.


LeanPub Sign Up



Create a new project on LeanPub

Next, use their online form to create a new project.  You will have several ways to work with your files.   I chose their "IN MY BROWSER ON LEANPUB" option, as I felt it to be the easiest and quickest way to get my book out. :)
LeanPub's New Book Form

Organize your poetry and add to your project

The next step is to organize your poetry and add them to files to be managed by LeanPub.  When creating files, you can do cool things like section breaks with ##, new lines with 'two spaces and a return' at the end of each line,  page breaks with {pagebreak} and more... LeanPub's documentation is great and will tell you all the features.

 
LeanPub Files


Create a Cover Page

Once all your files / manuscript is completed, make a nice cover page.  It's easy.  Just create a 2550 by 3300 pixels image file and save it into the images space on LeanPub as title_page.png.  Everything will come together in the end.
Sample LeanPub Cover Page

Monetize your Book 

How much is your book worth?  What would you pay for it?  Add your desired price and minimum price to your book to allow others purchase it.  LeanPub allows you to easy set the values, and after production, a nice component allows the consume to pay your recommend price, less to the minimum, or even more.

LeanPub Pricing

Publish!

Did you make it to the point of publication!  Great congrats!  You can now publish your by making your way to the Publish button!  That's it, LeanPub will automatically publish and setup everything for you, like magic.


That's it, please share the title of your poetry collection (or other published book) below, so we can go check it out on LeanPub!

Robert

Wednesday, July 29, 2015

How to perform currency conversion with Java

Java 9 includes the Java Money and Currency API (JSR 354) based on ISO-4217.

Of the various features this API provides, one of my favorites is working with exchange rates and  currency conversion.  I threw together some code to demonstrate this feature.

Currency Conversion using Currency Codes

The Money API uses a Fluent API, so the following code is easy to read... you'll see one can use an exchange rate provider to start the process towards currency conversion:

public static void convertCurrency
    (String currencyCode1, Double currencyValue, String currencyCode2) {

  ExchangeRateProvider ecbExchangeRateProvider = MonetaryConversions.getExchangeRateProvider("ECB");
  CurrencyUnit currencyUnit = MonetaryCurrencies.getCurrency(currencyCode2);
  CurrencyConversion ecbDollarConversion = ecbExchangeRateProvider.getCurrencyConversion(currencyUnit);
  MonetaryAmount monetaryAmount1 = Money.of(currencyValue, currencyCode1);
  MonetaryAmount monetaryAmount2 = monetaryAmount1.with(ecbDollarConversion);
  System.out.println(currencyCode1 + " " + currencyValue + " -> " + monetaryAmount2.toString());

    }

public static void main(String[] args) {
  ExchangeRateUtils.convertCurrency("USD", 100.00, "EUR");
}


This example converts one hundred US dollars to Euros. Note that when printed, MonetaryAmount will print the currency code and the value, so currencyCode2 does not need to be included in the standard output. 

$ USD 100.0 -> EUR 90.66183136899365

Currency Conversion for All Available Locales

When instantiating a CurrencyUnit,  a Locale object may be used in place of a currency code.  The following method uses exchange rates to convert values for all available Locales.

public static void convertCurrencyAgainstAllAvailableLocales(String currencyCode, Double currencyValue) {

  int counter = 0;
  Locale localeList[] = DateFormat.getAvailableLocales();
  for (Locale locale : localeList) {
    try {
     ExchangeRateProvider ecbExchangeRateProvider = MonetaryConversions.getExchangeRateProvider("ECB");

     CurrencyUnit currencyUnit = MonetaryCurrencies.getCurrency(locale);
     CurrencyConversion ecbDollarConversion = ecbExchangeRateProvider.getCurrencyConversion(currencyUnit);

     MonetaryAmount monetaryAmount1 = Money.of(currencyValue, currencyCode);
     MonetaryAmount monetaryAmount2 = monetaryAmount1.with(ecbDollarConversion);
 

     System.out.println("\n(" + ++counter + ")");
     System.out.println("Time: " + LocalDateTime.now());
     System.out.println("Locale: "
       + locale.getISO3Country()
       + " (" + locale.toString()
       + "), Language(Country): "
       + locale.getDisplayName());
     System.out.println(currencyCode + " " + currencyValue + " -> "
       + monetaryAmount2.toString());
     } catch (Exception e) {
       e.getMessage();
     }
  }
}


public static void main(String[] args) {
  ExchangeRateUtils
    .convertCurrencyAgainstAllAvailableLocales("USD", 50.00);
}


The output of converting USD currency against all available Locales looks like this:

(1)
Time: 2015-07-29T10:37:00.027
Locale: HRV (hr_HR), Language(Country): Croatian (Croatia)
USD 50.0 -> HRK 344.42429737080687635

(2)
Time: 2015-07-29T10:37:00.074
Locale: BEL (fr_BE), Language(Country): French (Belgium)
USD 50.0 -> EUR 45.330915684496825

...

As always, I hope this was helpful,
Robert

Note, if you are working with Maven, here's your dependency to use:

<dependency>
  <groupId>org.javamoney</groupId>
  <artifactId>moneta</artifactId>
  <version>0.9</version>
</dependency>


And here's the source all put together, if you'd like to cut/paste and run it:

import java.text.DateFormat;
import java.time.LocalDateTime;
import java.util.Locale;
import javax.money.CurrencyUnit;
import javax.money.MonetaryAmount;
import javax.money.MonetaryCurrencies;
import javax.money.convert.CurrencyConversion;
import javax.money.convert.ExchangeRateProvider;
import javax.money.convert.MonetaryConversions;
import org.javamoney.moneta.Money;

public class ExchangeRateUtils {

    public static void convertCurrencyAgainstAllAvailableLocales(String currencyCode, Double currencyValue) {

        int counter = 0;
        Locale localeList[] = DateFormat.getAvailableLocales();
        for (Locale locale : localeList) {
            try {
                ExchangeRateProvider ecbExchangeRateProvider = MonetaryConversions.getExchangeRateProvider("ECB");

                CurrencyUnit currencyUnit = MonetaryCurrencies.getCurrency(locale);
                CurrencyConversion ecbDollarConversion = ecbExchangeRateProvider.getCurrencyConversion(currencyUnit);

                MonetaryAmount monetaryAmount1 = Money.of(currencyValue, currencyCode);
                MonetaryAmount monetaryAmount2 = monetaryAmount1.with(ecbDollarConversion);

                System.out.println("\n(" + ++counter
                        + ")");
                System.out.println("Time: " + LocalDateTime.now());
                System.out.println("Locale: "
                        + locale.getISO3Country()
                        + " (" + locale.toString()
                        + "), Language(Country): "
                        + locale.getDisplayName());
                System.out.println(currencyCode + " " + currencyValue + " -> "
                        + monetaryAmount2.toString());
            } catch (Exception e) {
                e.getMessage();
            }
        }
    }

    public static void convertCurrency(String currencyCode1, Double currencyValue, String currencyCode2) {
        ExchangeRateProvider ecbExchangeRateProvider = MonetaryConversions.getExchangeRateProvider("ECB");
        CurrencyUnit currencyUnit = MonetaryCurrencies.getCurrency(currencyCode2);
        CurrencyConversion ecbDollarConversion = ecbExchangeRateProvider.getCurrencyConversion(currencyUnit);
        MonetaryAmount monetaryAmount1 = Money.of(currencyValue, currencyCode1);
        MonetaryAmount monetaryAmount2 = monetaryAmount1.with(ecbDollarConversion);
        System.out.println(currencyCode1 + " " + currencyValue + " -> " + monetaryAmount2.toString());
    }

    public static void main(String[] args) {


      // ExchangeRateUtils.convertCurrency("USD", 100.00, "EUR");     
      // ExchangeRateUtils.convertCurrencyAgainstAllAvailableLocales("USD", 50.00);

    }
}
 

Monday, July 27, 2015

Interesting covers to Thinking Out Loud

Thinking out Loud by Ed Sheeran, has done much more than entertained us, it has inspired us.



Below is a list of various covers of the songs in interesting ways.


You Tube Channel

Performer 1 Performer 2 Performer 3
1 boyceavenue Male Vocalist playing
Acoustic Guitar
Acoustic Guitar Soloist
3 jonny_neutron26 Female Vocalist Acoustic Guitar
2 TG Lurgan Female Vocalist
(foreign Language)
Female Background
Vocalist
Acoustic Guitarist
4 MAX Male Vocalist Female Vocalist Acoustic Guitarist
5 Peter Gergely Acoustic Fingerstyle
Guitarist
6 BensPianoSolo Pianist
7 JuNCurryAhn Violinist Dancer Background
instruments
8 Pop-Unpopped Cellist
9 GTAstrings Three Violinists Cellist
10 rikirjjacinto Saxophone Background
instruments
11 clANAnett Clarinet Background
music machine
12 TheSamTsui Vocalist Vocalist mashup with
I'm Not The Only One
13 The Tonight Show
Starring Jimmy Fallon
Vocalist Parody
on Piano


Are you aware of any other interesting covers of the song? Let me know and I'll add them to the table.

Thanks, Robert

Friday, July 24, 2015

Java Kurz & Gut - Translating the reviews from German

The Java Pocket Guide of which I wrote with my wife Patti has been translated to German into Java Kurz & Gut by Lars Schulten. Occasionally, I will read the reviews about the German version on amazon.de or on oreilly.de.


Now, how do I read the reviews, when they are in German and I don't know German?

It's a lot easier than you may think...

I just copy and paste the text into Google Translate.  I select German as the input and English as the output, and then I press the Translate button... and presto-bango, I get to see the translation.  Note that I actually don't even need to select "German" as Google Translate detects the language for you. :)

Here's an example:



A German review of the book:
Alles was man zu Java wissen muss, kann man hier schnell mal nachschlagen. Alle Grundlagen, und auch spezielle Feinheiten werden vorgestellt und Beispiele machen die Problematik verständlich. Wenn ich auf ein Problem stoße und nicht weiter komme, greife ich zu diesem Buch und finde schnell eine Lösung.  

A Google Translate translation of the review:
All you need to know about Java, you can look up here fast times. All foundations, and special subtleties are presented and examples make the problem understandable. If I run into a problem and am stuck, I reach for this book and find a solution quickly.

 And if you were wondering, yes... both Amazon and O'Reilly have international sites.

-- Robert

Bonus: Want to build your own translator webpage or app, check this out: TRANSLATE

Java Pocket Guide Buying Guide




There are several versions of the Java Pocket Guide available.  If you speak Chinese or Polish, each have their own version, so the selection is simple.  If you speak German, the 2014 version appends and updates the information for Java 8, so this is the version you should ideally purchase. For English, The Java 8 Pocket guide also appends and updates to the Java 7 Pocket guide, so go for this one.

Title Language Release Notes
Java Pocket Guide English Mar 15, 2008 Out of print
Java 7 Pocket Guide English July 28, 2013
Java 8 Pocket Guide English April 28, 2014
*Java Pocket Guide, 4th Edition English Target 2016 Includes Java 9
Java Kurz und Gut German April 2008
Java - kurz & gut, 2 Auflage German Jul 30, 2014 Includes Java 8
Java 8 Leksykon kieszonkowy Polish Nov 2014
Java语言袖珍指南(第2版) Chinese Nov 01 2014
TBD Russian
TBD Portuguese

*To try and remove some confusion with the naming conventions of the English books, we have decided to drop the "9" in the next edition planned for 2016.  Also, the Russian and Portuguese rights for the books have been acquired and hopefully, these books will be made available soon as well.

If anyone has any further questions on these available books and / or their content, please ask below and I'll answer any and all of your questions.

Sincerely,
Robert



Tuesday, July 21, 2015

Interesting GEDMatch IDs

This table seeks to add interesting GEDMatch IDs... e.g., that of perhaps great apes, and celebrities. The table is ongoing and will be frequently updated with new findings.

Interest GEDMatch ID
Gorrilla F999897
Chimpanzee (pan troglodytes) F999899

Enjoy, Robert

Sunday, July 19, 2015

Foods that heal

Remove sugars, trans fat, and other unhealthy foods from your diet and replace them with foods that heal, and you can likely look forward to a long, healthy and happy life.  I just did a few searches and came up with the following foods that heal.



Food Benefit
Adzuki beans Lowers Cholesterol
Apricots Prevents kidney stones
Bananas Reduces stress or anxiety
Basil Tummy troubles
Blueberries Boosts immunity
Broccoli Fights cancer
Buckwheat Honey Suppresses coughing
Cabbage Helps ulcers
Carrots decreased risk in postmenopausal breast cancer as well as cancers of the bladder
Chamomile Tea Relieves heartburn
Cherries Fights inflamation
Dandelion Treats hepatitis, kidney, and liver disorders
Figs Helps hemorrhoids
Garlic Fights yeast infections
Guava Fights cancer
Ginger Tea Relieves nausea
Kale Fights inflammation
Onions Lowers the risk of prostate and esophageal cancers
Orange Juice Relieves fatigue
Pears Reduces bad cholesterol
Potatoes Helps with headaches
Raisins High blood pressure
Spinach Protects against eye disease and vision loss
Tuna Helps with depression and anxiety
Turkey Helps with trouble sleeping
Watercress Protects against macular degeneration
Yogurt Constipation or gas

I hope you have found this helpful.  Btw, know anymore foods that heal?  Add them to the comments below