Tooling for localstorage

Localstorage is a newer way to store data locally in a browser, kind of like a cookie.  It is supposed to have a much easier interface than cookies and can do JSON.  Another developer I know was using this and she was using localstorage to track local data  for some dynamic web interactions.  Nothing will get sent back to the server — you’d still have to use cookies for that (example – a JSESSIONID).  But considering that much of the javascript I’ve written in my life was managing browser data by doing “single page websites” or passing form data with hidden fields back and forth, or passing data via query parameters — the localstorage idea is very compelling.

I did a little searching and this succinct post on HTML Dog has a nice example.

My interest for this post is in the tooling around localstorage.

What I want to do is create a localstorage entry and then see it in a tool like Firebug or a web development tool much like a cookie.  I’ve chosen Firefox built in web developer tools for now.

First, I have to create some localstorage.  I navigate to this blog site and open up Firefox’s  developer and toggle the toolbar

Screen Shot 2016-06-16 at 2.01.43 PM

Click on the Toolbox Options and then check Storage.

Screen Shot 2016-06-16 at 2.03.20 PM

Create a localstorage value, I’ll just use HTML Dog’s JSON Example, and include a println to show I can try out the setter/getter functionality.

localStorage.setItem('user', JSON.stringify({
    username: 'htmldog',
    api_key: 'abc123xyz789'
}));
var user = JSON.parse(localStorage.getItem('user'));
print(JSON.stringify(user));

Execute it in the console of the developer’s tool.

Screen Shot 2016-06-16 at 2.14.28 PMAnd after.

Screen Shot 2016-06-16 at 2.16.06 PMWe received the data back correctly for “user” object . . .

“{“username”:”htmldog”,”api_key”:”abc123xyz789″}”

Look in Storage.  Wow!  that’s a lot of cookies.

Screen Shot 2016-06-16 at 2.19.19 PM

And here is the localstorage data for “user”:

Screen Shot 2016-06-16 at 2.20.30 PMYou probably see the other two storage entries:

  • IndexedDB is a low-level API for client-side storage of significant amounts of structured data, including files/blobs.
  • Session Storage  – The sessionStorage property allows you to access a session Storage object. sessionStorage is similar to Window.localStorage, the only difference is while data stored in localStorage has no expiration set, data stored in sessionStorage gets cleared when the page session ends.

Persistence differences! Well that’s really good to know about local vs session.  Browser support as of this date:

Screen Shot 2016-06-16 at 2.24.55 PM

Disk Solutions 2016

My brother is a teacher and he sent me a text and a pic of a broken 500gb external drive he uses for simple backups.  He was asking the questions a lot of us are asking these days: how to store all of our data, short term/accessible and long term.

When I think about the question, for me, the big issues are:

  • Accessibility — slow or fast, always up, bandwidth, how do you get the data there/back, reliability
  • Security — safe from hacking/encrypted?
  • Cost — the balance between a local drive vs. cloud storage
  • Reliability — local drives break, clouds can break even more disastrously but less often (this just happened at work to our Azure firewall servers
  • Interaction — will you use it for time machine/real time backups? As an extended drive, media streaming etc?

Here is my reply as a developer:


I use a few solutions and its not there yet.  It’s complicated for me because of my needs.

Google Drive and DropBox; I use these for all my local daily stuff — up to date bills/finance, scanning (my scanner goes directly to google), sharing.  Both dropbox and google require local cache/storage. I might be storing 10 gigs max on these — also I have accounts on a few others (i.e. that server I uploaded business vids on).  I don’t do big storage on these because network isn’t there — its slow — THEY are slow.  Even over cable.  These services like them or Carbonite recommend sending in large data drives.  With 500 gb you probably could just put it up there yourself.

I have a lot of data.  I have two NAS servers, and old on that had a total of 3 TB accessible (6 terrabytes of drives raid 1 mirroring over 4 drives) — this device is 10 years old so bought a new one:.   5 TBs mirrored (10 tb total) on two drives.  I use these for long term storage and media streaming.   I have all of my extensive music collection, my movies, and digital photos, finances, important docs all digitized dating back to the late 1990’s.  Total data I actually have is probably about 3 tb but will grow with photos/media.  I also have old software libraries and work files, that take up a ton of space.  Will probably archive these on old external drives and dump over time. The data is too large to stream up and back at times for today’s services.

I keep several old hard drives around, enclosures and cables. These are good for small tasks — bare metal backups, moving larger files between work/home ‘puter; you just never know. For the 5 TB raided NAS I have a matching external drive I backup to.  Mirroring isn’t a total backup because rive errors get propogated; the other I keep in a fire case.  Also I have acronis that I keep live on my Win machine that backs up in real time when the NAS are on, automatically.  A licence is super cheap.

You can probably pop out that drive and buy new enclosure or a mutli-drive cable, I have one something like this for a while — good in a pinch, not for travel though:

https://www.amazon.com/Drive-Adapter-Converter-Optical-External/dp/B002OV1VJW

But, with that much data (which isn’t too much), I would look at cloud storage (Google, Drop Box) — check the costs.  Still not cost effective enough for me.  Also, have to be aware of security — are your files password protected?  Check the services, many differ.

Also you’d have to check how you interact with the service.  Needing files/service all the time different than “backup”/intermittent use.  In which case, a google/dropbox for daily and a long term backup – Carbonite etc. — good idea.

What do we all want?  Terabytes of secure space accessible in real time on the cloud.  It’s just not there yet . . . or at least not at a good price.

OSX- Relocate your applications bar on multiple monitors

Here’s a trick.  To relocate your applications bar on multiple monitors just move your mouse to the middle of the screen of whichever monitor you are using and then stright to the bottom.  BAM.  App bar.

This drove me crazy for a while and I’d use the System settings in a kluge, embarrassing way to do this thinking it was a non-Mac monitor problem; but it’s actually a feature.

Playing The Planning Poker King

Oh Estimate my Estimate!

“KEATING:  . . . Now, we all have a great need for acceptance. But you must trust that your beliefs are unique, your own, even though others may think them odd or unpopular, even though the herd may go, “That’s baaaaad.” Robert Frost said, “Two roads diverged in a wood and I, I took the one less traveled by, and that has made all the difference.” Now, I want you to find your own walk right now. Your own way of striding, pacing. Any direction. Anything you want. Whether it’s proud, whether it’s silly, anything. Gentlemen, the courtyard is yours.

The students begin walking about, some walking casually, others making up silly walks. Keating notices that Charlie is still leaning up against one of the pillars.

KEATING: You don’t have to perform. Just make it for yourself. Mr. Dalton? You be joining us?

CHARLIE: Exercising the right not to walk.

KEATING: Thank you, Mr. Dalton. You just illustrated the point. Swim against the stream.”

-Dead Poets Society

The content you are trying to access is only available to members. Sorry.

The Modern Agile Manifesto

Changing Memory for IntelliJ On OSX

I noticed my package scans were really slow in IntelliJ when starting/stopping my J2EE engines.  Real slow.  So I upped the memory and it helped a great deal.

This was done for IntelliJ 15 Community Edition on OSX El Capitan (10.11.3).

  • First, close IntelliJ of course.
  • Right click the application and choose “Show Package Contents.”

  • Open the file “idea.vmoptions” (I used TextWrangler).

  • Update your settings and save.

Two Year Anniversary for Code I Never Use

This hearkens to those Joel Spolsky code-tests — Tower of Annoy, Code Rolfing, etc.  And I was looking back in my posted articles and realized I had just passed a two-year anniversary for one of the strangest interviews I had ever done in my life which also involved a test on code I have never used before nor used since the interview.

The content you are trying to access is only available to members. Sorry.

EC Tech Meetup March 1, 2016: Java Concurrency Intro – Layman’s Delight

Obtained a room in downtown Eau Claire over lunch to practice giving presentations (since I don’t do that much anymore) via a Laymen’s Java Concurrency Intro.

At a very high level presented threads, concurrency, locks, synchronization and real world analogies to these mechanisms.

Java Constants – Not In The Interface

Business rules? Hopefully centralized to the One; or life will be short and brutal.

I was working on some code refactoring on a massive codebase when I was faced with the issue of where to put constants for the default values of business rules.  This issue has been a constant subject of design discussion in java since I can remember, and definitely over a decade for myself.  Doing “object” code, you try your hardest to avoid big “global” files.  But sometimes you have to have a central, global location to put constants.  In my case, refactoring the same rule spread out over several classes each containing:

public static final boolean DEFAULT_VALUE = false;

So you can see the problem here — if this definition sits in several classes there’s a chance any change will be missed and you’ll have breakage.  There should be one definition to rule them all.

Now one place you *might* be tempted to drop your constants in is an interface.  I’ve seen this before, but is decidely in my opinion a bad pattern since interfaces are generally used to define relationships to other components and this could be construed the same thing as defining a complete method in an interface.  It was unfortunate, imo, that this had already been done in the code and it’s a good policy to match the patterns — even bad ones — until you can get around to refactoring them out.  I decided to refactor.  And the discussion of where to put Java application constants has been going on fever — for instance in this older  venerable C2 site  article –  interfaces for defining constance – c2.com.

Some other solutions in the recent codebases I’ve worked on:

  1. property files
  2. enumerations
  3. abstract classes
  4. static classes
  5. depending on the scope – class level

And that is the key  — “what is the scope?”  Global/application/multi-context scope becomes more challenging in design.

In many of the web applications I’ve worked on if we’ve used the constants on the backend, we’d make enumerations or a static class with the constants.  Then if you need to expose them, say to tag libraries or the front end, you can import them or make a service to expose them.  Enumerations lend themselves to this quite well.

The important thing is to get that default centralized if it is a business rule.  Multiple definitions of a default value, or any value, become problematic.  I’ve seen implementations of lists of statuses kept in string constants, enumerations, and a database lookup table all in the same application.

The company paid a lot of money to fix that.

EC Tech Meetup February 10, 2016: Java Lambda Workshop

Hands on Java Lambdas with some online tutorials.   Breaking in the new Mac.

A general Java code learning session at my work site with a few interested parties who wanted to see some Groovy too and share some Scala/Clojure.

Thanks to the Milwaukee Colectivo Coffee suppliers and my workplace!