Archive for February, 2019

Fixing up Clojure’s REPL Colorization and Formatting

Wednesday, February 20th, 2019

Clojure.jpg

A couple of days ago, I found out about the licensing rules for JDK 11 from Oracle, and wanted to install OpenJDK 11 with Homebrew. Sadly, Homebrew doesn't really like the idea of installing older versions of packages, so I'm going to live with JDK 1.8, and OpenJDK 11. But that's not what this is about. 🙂 This is about Clojure, and Leiningen's REPL, and the fact that in that post I found a known problem with the current version of Ultra, and Leiningen versions greater than 2.7.1

Well... a little digging, and I find that the core component of Ultra is another project, and that same author has a similar REPL formatter and colorizer - called whidbey. Now it turns out that whidbey also has issues with Leiningen 2.9.0 - but at least it works with 2.8.3, so I can upgrade to 2.8.3, and then let them figure out the issue with nREPL 0.6.0 - as it's already an issue on whidbey.

So until then, I have both in my ~/.lein/profiles.clj, and I can flip between the two as needed:

  {
   :user {:plugins [[lein-exec "0.3.7"]
  ;                  [venantius/ultra "0.5.4"]
                    [mvxcvi/whidbey "2.0.0"]
                    ]
          :middleware [whidbey.plugin/repl-pprint]
          :whidbey {:color-scheme {:delimiter [:bold :yellow]
                                   :tag [:bold :yellow]
                                   :nil [:cyan]
                                   :boolean [:bold :cyan]
                                   :number [:bold :green]
                                   :string [:bold :red]
                                   :character [:cyan]
                                   :keyword [:yellow]
                                   :symbol [:bold :magenta]
                                   :function-symbol [:bold :blue]
                                   :class-delimiter [:blue]
                                   :class-name [:green]
                                   :exception [:bold :red]}}
          :ultra {:color-scheme ;; :solarized_dark
                   {:delimiter [:bold :yellow]
                    :tag [:bold :yellow]
                    :nil [:cyan]
                    :boolean [:bold :cyan]
                    :number [:bold :green]
                    :string [:bold :red]
                    :character [:cyan]
                    :keyword [:yellow]
                    :symbol [:bold :magenta]
                    :function-symbol [:bold :blue]
                    :class-delimiter [:blue]
                    :class-name [:green]
                    :exception [:bold :red]}}
          }
  }

At this point, I can switch to 2.8.3 with:

  $ brew switch leiningen 2.8.3
  Cleaning /usr/local/Cellar/leiningen/2.7.1
  Cleaning /usr/local/Cellar/leiningen/2.9.0
  Cleaning /usr/local/Cellar/leiningen/2.8.3
  3 links created for /usr/local/Cellar/leiningen/2.8.3

and I'm good to go with Leiningen 2.8.3, and as soon as whidbey is updated, I'll be able to move up to 2.9.0. Really glad I found this project.

[3/6] UPDATE: it looks like ultra is getting an update that will allow it to work with Leiningen 2.9.0 - which is great! I just need to wait for ultra 0.6.0 to hit Clojars, and I can update and use it. That would be very nice!

Ordered a Chrome Duffel

Wednesday, February 20th, 2019

Chrome Bag

This morning I got an email that said that the Spectre Duffle Bag I'd ordered from Chrome Industries had shipped from California, and it should be at my door by the end of the day tomorrow - Thursday. The reason for the bag was that I've been using the same luggage that my delightful ex-wife bought for us - as a family, and while it's OK... it's two huge roller bags, and a cosmetic case, that I've been using for the few trips I have needed something.

But I'm old enough to get my own luggage - in fact, it's arguable that it's about time. So when I knew I had to make a trip to Seattle next week, I looked around and decided now is as good a time as any.

My top picks were Chrome bags - and Away Travel. The former made the messenger bag I use daily, and can't say enough good things about, and the latter is promoted on The Talk Show all the time. I like the hard exterior of the Away bags, but I wasn't sure how much they would hold, and they didn't give a lot of details on the size or what to expect.

Then I started looking at the Chrome bags, and I kinda ran into the same problem - What would it hold? Really not easy to see. So I measured the existing bag, and calculated the cubic inches, and then started comparing. Then I went to the airline carry-on page, and saw that the Chrome bag was exactly the right size to be a carry-on, and that you get one carry-on, and one laptop bag, and that would work great for me!

So I ordered the Chrome bag, and selected two-day shipping, because I wanted to make sure that I got it in time for this trip. And this morning, I found out that it would arrive! Fantastic!

Securing Google and Restoring GTalk

Wednesday, February 20th, 2019

Adium.jpg

Yesterday, I lost access to my GMail and GTalk accounts on my laptop - and it was saying that the password was bad. The first was covered in this post, and this morning I attacked the second. Overnight, I was just hoping that it was a transient thing, and that Google would restore whatever it decided to turn off, but that was not to be.

Given that Adium is now limited to just GTalk and ICQ, there really wasn't a lot of reason for me to keep it running, if I couldn't fix this authentication issue. So... knowing that Google wanted me to secure my account - but doing that would kill the old scheme for Adium, I decided to go ahead with it, and if it didn't work, then I'd just shut down Adium, and have to live with the loss of communication to my friends.

Securing Google

Police.jpg

So the first thing I needed to do was to turn off the Insecure Access in Google. This is just saying the old, plaintext, username and password being passed to Google. This was the only way the old Adium worked, and so I had to leave it like this. But that's all changing.

Once that was turned off, I knew I wanted to use Authy for the Authentication App for Google because I didn't like the SMS codes, and Authy is just a nice tool for exactly this purpose without worrying if your SIM card has been cloned. So I turned that on, and typed in the first code, and we're good to go.

Finally, I needed to generate a single Application Password for Adium, and that was all done from the Security tab in the Google Account Settings. Not bad at all, they generate a 16-character code, and you then use it for that app. You only get to see it once, so make sure you type it in correctly, but you can always make another.

Testing Adium

Once I had the 16-character application password for Adium, I pulled it up, typed it in, and BAM! it worked. I could almost not believe it! This was exactly like the POP3 issue - I'm guessing Google just got tired of the less-secure methods, and just shut them off. Period. Now with the 2FA on my account, the Application Password is as secure as Google wants to make it. 16 characters is gonna be really hard to guess.

And as I was testing Adium... still a little giddy that this all worked, and I had also locked down my account, I got a notice from Mail.app that I needed to enter my password.

Ah... IMAP was not using the 2FA, and I needed to pull up the accounts in Mail.app, and go through that login once to get the login using 2FA, and to to trust this device. When that was done, email was back online, and GTalk was too.

What a heck of a morning! Very good news!

Google Shutting Down POP3 Access

Tuesday, February 19th, 2019

Google Docs

Well... that was a heck of a realization! This morning, I notice that my Mail.app can't connect to GMail, and I wonder if it's something that is wrong with the account - or just Google. Oddly, Aduim also is not connecting to GTalk, and that's very strange. So I start digging into this.

I know that my password is valid. And I also know that I haven't had any Security Alerts from Google - so that's good. But still... both Gmail and GTalk are not allowing me to login.

I got caught up in a lot of other issues today, but got back to this, and on a lark, decided to look at the two Gmail entries in my Accounts for Mail.app - one was just for GMail, and the other was the more complete email/notes/contacts/calendar - and the latter had to be using IMAP, and I know the former was POP3. So let's disable POP3, and use the IMAP for mail.

Bingo!

It seems as though Google just shut off POP3 access. I looked at the settings, and it's still considered "on" in my GMail account settings, but that doesn't matter. I simply cannot connect to the POP3 site. OK... guess that's that.

At the same time, I'm wondering if the GTalk (XMPP) API is shut down as well? I'll give it a day, and then I'll have to accept that it's dead, and at that point, there's no need to have Adium running, as the only protocol it used anymore was GTalk, and with that gone, it's really pointless. Sad to see that happen. Very sad.

UPDATE: I downloaded Trillian from the App Store, and it doesn't connect to GTalk either. So this is not a single app or my credentials. This is just GTalk. We will have to see if it clears up tomorrow.

Neat Data Modeling Project

Tuesday, February 19th, 2019

Building Great Code

Today I've been having an email exchange with an old co-worker about an Open Source project that he's been working on - actually, it's pretty much done. It's all in Python, so it's not something that I'm really keen to use, but the design is good, and I can remember using something like it back at a previous job where we had to solve complex data modeling issues in as near real-time as possible.

The project is called dataflow and is really a compute/modeling system where you define Nodes and these nodes can be simple calculations on inputs, but they can be quite advanced - say rolling time averages, etc. and the key is that these Nodes can relate to one another in a simple Graph, that the user can describe, and then when any Node is updated, it fires off the updates of the dependent Nodes.

The nice thing is that these Nodes have a very simple API, and so they can do just about anything - averages of inputs, calculations, mean-square calls... it's really what the user wants to see. Tie this with a UI that displays the data, and you get something that is very powerful indeed. It can be a a Risk system where each Node can aggregate the child Nodes so that you can look across account, symbol, etc. and all updates as the input data updates.

It's been a nice reminder of some of the work I'd done at that job - but the work I did was in Java, and it was a bit more limited, but it still enabled some pretty nice apps to be built. Good stuff.

Moving to OpenJDK 11 – Kinda…

Monday, February 18th, 2019

java-logo-thumb.png

Well... today has been a very eventful day. I had noticed that Oracle dropped support for JDK 10, and mentioned it to some friends in Slack. I didn't know the details, so I decided to dig in and see if I could see anything on the net about it. I did. Lots. Changed my day.

Turns out, Oracle is changing it's licensing for JDK 11 - it's free for development and testing, but if you use it in production, it requires a license. A paid license. Yikes!

OpenJDK is also built by Oracle, and IBM, and RedHat - and it is Open Source - free for any use-case. So that's where people appear to be going. I can see that, but I've stayed away from OpenJDK because it's just the official JDK from Oracle. But now it seems Oracle is looking to cash in on the JDK, and this is just a lovely predicament.

But there is hope - kinda. Homebrew is supporting OpenJDK as a cask so that it can be versioned, and supported within the Homebrew ecosystem. That's good news. To install the latest, you simply need to:

  $ brew cask install java

and it will install it into:

  $ brew cask info java
  java: 11.0.2,9
  https://jdk.java.net/
  /usr/local/Caskroom/java/11.0.2,9 (64B)
  From: https://github.com/Homebrew/homebrew-cask/blob/master/Casks/java.rb
  ==> Name
  OpenJDK Java Development Kit
  ==> Artifacts
  jdk-11.0.2.jdk -> /Library/Java/JavaVirtualMachines/openjdk-11.0.2.jdk
  (Generic Artifact)

and the tools I built for switching JDK versions work just fine:

  $ setjdk 1.8; echo $JAVA_HOME
  /Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home
  $ setjdk 11; echo $JAVA_HOME
  /Library/Java/JavaVirtualMachines/openjdk-11.0.2.jdk/Contents/Home

That's the good news. What isn't really good is that there is an issue with the Java Collections where the toArray method added an additional arity and that breaks Clojure - badly. So it really doesn't help to have the OpenJDK 11 on the box - as Clojure can't make use of it.

However, that's not all... it appears that when I upgraded Leiningen, I broke one of the really nice plugins that I like to use with it - Ultra. The error is nasty as well:

  $ lein clean
  $ lein deps
  $ lein repl
  [WARNING] No nREPL middleware descriptor in metadata of
    #'clojure.tools.nrepl.middleware.render-values/render-values,
    see nrepl.middleware/set-descriptor!
  [WARNING] No nREPL middleware descriptor in metadata of
    #'clojure.tools.nrepl.middleware.render-values/render-values,
    see nrepl.middleware/set-descriptor!
  nREPL server started on port 54967 on host 127.0.0.1 - nrepl://127.0.0.1:54967
  ERROR: Unhandled REPL handler exception processing message
    {:id ad3092dd-8491-4d60-a1a9-5092d4d090a9, :op clone}
    java.lang.IllegalArgumentException: No implementation of method:
    :send of protocol: #'nrepl.transport/Transport

and if I removed Ultra from my ~/.lein/profiles.clj then everything worked fine again. But this was with Leiningen 2.9.0 - and that was an issue. In fact, it was an issue that's already been reported to Ultra. I added my notes, as the suggestion didn't work for me.

So now I'm left with downgrading Leiningen to get Clojure working again. This is not as easy as I'd hoped, but it's what needs to be done. First, get into where the Homebrew formulae are stored, :

  $ cd $(brew --prefix)/Homebrew/Library/Taps/homebrew/homebrew-core/Formula
  $ git log --follow leiningen.rb
  commit 2be19f3787d811247095e704765fc33a8815d639
  Author: BrewTestBot <homebrew-test-bot@lists.sfconservancy.org>
  Date:   Tue Feb 12 13:07:29 2019 +0000
 
      leiningen: update 2.9.0 bottle.
 
  commit 9ca7899818eb02cc8252d47cc32b5a42554a7655
  Author: Rahul De <rahul080327@gmail.com>
  Date:   Tue Feb 12 10:43:59 2019 +0100
 
      leiningen 2.9.0
 
      Closes #36927.
 
      Signed-off-by: Chongyu Zhu <i@lembacon.com>
 
  commit fd1c0ba8f162a3c41debef6143dca8ba19227f90
  Author: BrewTestBot <homebrew-test-bot@lists.sfconservancy.org>
  Date:   Sat Dec 15 10:45:41 2018 +0000
 
      leiningen: update 2.8.3 bottle.
 
  commit 40553be0b01710db9e16cff978f593b83ecdfe3b
  Author: Rahul De <rahul080327@gmail.com>
  Date:   Sat Dec 15 11:27:08 2018 +0100
 
      Leiningen 2.8.3
 
      Closes #35151.

at this point we heed the git SHA for the version we want to move to. In the case of Leiningen, the SHA for 2.8.3 is fd1c0ba8f162a3c41debef6143dca8ba19227f90 and the SHA for 2.7.1 is cdddd1094b26d0092e0030051dac97a286bb3fc4. I started with 2.8.3, and that didn't work, so I had to go back to 2.7.1. This is a big difference.

Then make a branch for that version, and reinstall Leininden from the Ruby file:

  $ git checkout -b leiningen-2.8.3 fd1c0ba8
  $ brew reinstall ./leiningen.rb
  $ brew switch leiningen 2.8.3
  $ git checkout master

for 2.8.3 and, for 2.7.1:

  $ git checkout -b leiningen-2.7.1 cdddd109
  $ brew reinstall ./leiningen.rb
  $ brew switch leiningen 2.7.1
  $ git checkout master

At this point, we can see that both versions are installed:

  $ brew info leiningen
  leiningen: stable 2.7.1 (bottled), HEAD
  Build tool for Clojure
  https://github.com/technomancy/leiningen
  /usr/local/Cellar/leiningen/2.7.1 (9 files, 14.7MB) *
    Poured from bottle on 2019-02-18 at 13:29:34
  /usr/local/Cellar/leiningen/2.8.3 (9 files, 13MB)
    Poured from bottle on 2019-02-18 at 13:22:14

Now it's possible to run Leiningen and Ultra - again. It has to be JDK 8, and Leiningen 2.7.1... but until Ultra is fixed for the change in Leiningen, this is as far as I can go.

What was even more annoying was that my new work laptop has a very recent version of Homebrew on it, and the git repo has been trimmed, and so there is no git SHAs for the previous versions. However, with tar and copying the tarball over, I was able to get the 2.7.1 and 2.8.3 versions there, and things are now working OK.

Wow! What a mess to get back to where I thought I started the day!

Really Enjoying the New Apple TV 4K

Monday, February 18th, 2019

TV.jpg

A few months ago, I got a new Apple TV 4K, primarily because my old Apple TV was getting very slow in selecting ESPN, and in the morning, I just want to get on the treadmill and start running. So I invested in a new one, and I'm very glad I did. It's just amazing.

First, I really like the remote. I like the touch pad, and while it took a little getting used to, it's nice to have it on the remote, as opposed to the four direction buttons. A very nice upgrade. Add to that, the remote is rechargeable with a Lightening cable. This is great because I can then charge my AirPods, the Remote, or my iPhone all from the one cable that's connected to my Thunderbolt Display. Very nice.

Second, it's fast. That's what I expected from it, and that was not a disappointment. Exactly as advertised, it is zippy, and I don't have the multi-minute waits switching channels on ESPN. That was expected.

Third, and this was a surprise - the TV App that exists on my iPhone and the new Apple TV 4K is really almost something to drop cable over. It allows me to focus on the Shows I want to watch, and not the networks they appear on. I can look at my iTunes Movies as well, and it remembers the position in each movie, and show, so that I can move to my iPhone and watch a little bit, and then transfer back to the Apple TV 4K. This isn't Rocket Science, but it's an excellent implementation of the iCloud storage, and syncing. It's just great.

Now I've heard there are games for the Apple TV 4K, but I am not a big game player, but I will admit that I've purchased a lot more movies now that I have the Apple TV 4K than I did before. Which is good for me, and good for Apple.

It's not the most amazing thing Apple makes, it'll never have the attention that the iPhone or iPad has, but it's a fantastic little box, that is absolutely what I was looking for. Nice.

Interesting Wrinkle with Homebrew and git

Friday, February 15th, 2019

Homebrew

This morning I was working to upgrade my laptop from Postgres 10.3 to 11.1, and I did the following, as part of the upgrade:

  $ brew update
  fatal: could not read Username for 'https://github.com': terminal
  prompts disabled
  Error: Fetching /usr/local/Homebrew/Library/Taps/homebrew
  /homebrew-boneyard failed!

I did a lot of googling, and came up with a couple of ideas. This was from GitHub:

  $ git config --global credential.helper osxkeychain

but that didn't work. Then I found another reference saying that the 2FA on GitHub was the problem, and that you needed to bypass that with:

  $ git config --global --add url."git@github.com:".insteadOf "https://github.com/"

and still that didn't work. So I took a different approach, I started looking at the Homebrew files on my laptop - specifically, the boneyard mentioned in the error. Turns out... if you looked at the .git/config file in that directory, it points to a directory in GitHub that no longer exists! OK... this might be something.

So I removed the nearly empty directory, and tried again:

  $ brew update
  Already up-to-date.

Success! It wasn't the config of git - it was that Homebrew was trying to update something that no longer existed. Lesson learned.

Upgrading Postgres 10.3 to 11.1 Using Homebrew

Friday, February 15th, 2019

PostgreSQL.jpg

It's time to make sure that my laptop has the latest version of PostgreSQL, as I was reading that they were making big strides in the windowing functions in postgreSQL 11. And with Homebrew 2.0 out, it made sense to just write it all down again, just so that I have it for reference.

The process isn't bad... dump all the databases into one file, stop the server, update Homebrew, update postgres. This gets us to the point that we are ready to rebuild the new database:

  $ pg_dumpall > dump.sql
  $ brew services stop postgresql
  $ brew update
  $ brew upgrade postgres

Now we need to move out the old database data, create a new structure, and restart the service:

  $ cd /usr/local/var
  $ mv postgres postgres.old
  $ initdb -D /usr/local/var/postgres
  $ brew services start postgresql

You then need to go back to the directory of the first command - the one where you dumped the databases, and reload them all:

  $ psql -d postgres -f dump.sql

and at this point, everything should be back and running:

  $ psql --version
  psql (PostgreSQL) 11.1
  $ psql -l
                                      List of databases
      Name     | Owner | Encoding  |    Collate     |     Ctype      |  Access privileges
  -------------+-------+-----------+----------------+----------------+---------------------
   health      | drbob | SQL_ASCII | en_US.US-ASCII | en_US.US-ASCII |
   inventory   | drbob | SQL_ASCII | en_US.US-ASCII | en_US.US-ASCII |
   northhollow | drbob | SQL_ASCII | en_US.US-ASCII | en_US.US-ASCII |
   postgres    | drbob | SQL_ASCII | en_US.US-ASCII | en_US.US-ASCII |
   template0   | drbob | SQL_ASCII | en_US.US-ASCII | en_US.US-ASCII | =c/drbob           +
               |       |           |                |                | drbob=CTc/drbob
   template1   | drbob | SQL_ASCII | en_US.US-ASCII | en_US.US-ASCII | drbob=CTc/drbob    +
               |       |           |                |                | =c/drbob           +
               |       |           |                |                | _postgres=CTc/drbob+
               |       |           |                |                | postgres=CTc/drbob
   test        | drbob | SQL_ASCII | en_US.US-ASCII | en_US.US-ASCII |
  (7 rows)

At this point you can remove the old data:

  $ rm -rf /usr/local/var/postgres.old
  $ rm dump.sql

and everything is updated. You can then use any of the normal tools, including the Apache/PHP/Postgres that Apple makes available, and Postico - a great GUI client.

Oracle Drops JDK 10

Thursday, February 14th, 2019

java-logo-thumb.png

I've been rebuilding a new MacBook Pro laptop from work because the security tools we use at The Shop don't allow Migration Assistant to work - which is sad, because it works so well under normal circumstances, but water under the bridge, and I have to reinstall a lot of things on the box - as if from scratch.

Because of Clojure, one of the things I have to make sure to install is the latest JDK. Actually, I need to install all the latest JDKs - 1.8, 9, 10, and 11. And then I have a simple little tool for changing the JDK version that I want to be using. Simple. Easy.

When I last went to upgrade the versions of the JDKs, I found that Oracle has dropped support for JDK 9. I had heard a lot of talk about how JDK 9 wasn't really doing well because of some of the design decisions... and so this wasn't really a surprise, but it was unexpected to see that Oracle had pulled it from the Downloads. But OK... they didn't want people using it, so they pulled it.

Today, I saw that Oracle had pulled JDK 10 as well. Now that was a bit of a surprise. I know that it wasn't as popular with the Clojure community as JDK 1.8, but to see a second abandoned JDK version... well... that's a heck of a realization from Oracle. It's not good... it's causing us too much to support it... drop it.

So I have JDK 1.8 and 11 on the new laptop, even though on my personal machine I still have the last available JDK 10. But at some point, that will have to be thinned out because it just won't be supported. Wild.

Hats off to the JDK 1.8 guys - You've made a heck of a product.