Where Are The Wise Men?

Mike's Ramblings

Java Java Everywhere

| Comments

It seems that everyone needs my Java expertise. The following all happened within a 12 hour period:

  • I'm now a contractor and my current contract is to get a bunch of semi-programmers up to speed on Grails so they can actually support the applications that are tossed over the wall.
  • As soon as I get home from work, my daughter doesn't let me into the house, because she's having problems with Minecraft on our Ubuntu laptop. I used a lot of my Java troubleshooting-fu to figure out what is happening. It comes done to Majong doing something that make Minecraft on Linux janky with Minecraft 1.8 and new servers with mods. Works fine on my Mac (which my daughter does not use).
  • During the day, I get a frantic text from a friend of mine. Her son is on college and not going well in his second semester college programming class and asked if I knew anything about Java and if I could help him. I said I do Java for a living. I got with him that night and found out that the instructer is not explaining things well, giving examples with bad practices, and an extremely superficial and insipid assignment.

My Personal Cloud

| Comments

I've been having an ongoing conversation with a good friend of mine for a long time about email management. We want to keep our emails so we can find them later, and either don't trust or don't like the interfaces what GMail and other free providers give us. In that vein, early this spring, he sent me a link to the Sovereign project on github that is, essentially, your own cloud server with storage, email, et al.

What he didn't know at the time was that I was lamenting all the cloud services I was using (and spending bits of money on) but still not feeling in control of what was where. Add that to the fact that I've never really trusted a cloud storage service like Dropbox, Box.net, GDrive with my files. Yes I had all of them and had files in all of them, but never really dedicating anything to any of them, i.e. paying them money.

So I tried it out -- I got a cheap VPS and ran the Ansible scripts, taking out the things I didn't need (like, I haven't been on IRC for years!). As time as went on I tweaked things and simplified my digital services by replacing them with things on the server.

This is what I use:

ownCloud

This is really the most important item on this list, and probably the most surprising one to me. I have learned to like cloud storage, now that I feel like I have some control (and, honestly, some space to actually hold things). I'm using it to hold my ebooks I store in Calibre. I still don't have room to put my music on there, but I'm toying with the idea of upgrading the VPS so I have the room. I have all sorts of documents there for work. The Android app is great for most things -- it doesn't keep an entire folder in sync but, luckily, ownCloud implements webdav so I can use existing tools like FolderSync. ownCloud also keeps contacts via CardDav so I can keep my own copy of contacts.

This personal cloud storage is great, but I use the syncing abilities to keep track of other things. So Todo.txt has replaced Remember The Milk for tasks and KeePass2 has replaced LastPass. The last one was hard for me to let go of, but I'm actually now happier now with KeePass2.

On the Android side, the official Todo.txt Android app utilizes Dropbox for syncing, but a little research I found Simpletask Cloudless and Keepass2Android, using the fore-mentioned FolderSync to keep the files in sync. At most they are an hour behind, which is fine for me.

gitolite

This wasn't end the original version of Sovereign that I installed, but I'm glad that it was included. I do like having my own private git repo that I don't have to pay Github for. I disabled cgit mostly because I didn't see the need for it, for just me. Though I have included others in a couple of my projects.

selfoss

When the Google Reader Shutdown happened and I looked for self-hosted alternatives, selfoss didn't no pop up on my searches. But I'm glad that the it was included with this! It's very clean, lets me scan the articles from my feeds quickly. The mobile version (through my mobile browser) is actually better than the full-screen one, IMHO.

wallabag

Wallabag is another new-comer to Sovereign but I like it a lot -- it has replaced Pocket for me. It works just the same as Pocket, but with an added feature of saving articles to epub. I haven't actually done that yet but I fancy putting together a cookbook with it. Wouldn't that be cool?

There are other things I like -- using OpenVPN when using an open wifi connection, automatic backup to Tarsnap, and just having a SSH prompt at my exposure, when I need it.

To Begin Anew

| Comments

I've been wanting to get off my provider for a long time. They were one of the first webhosts that were ultra-cheap. And I could put up a WordPress blog with now problem. It was 2006 . . . what could go wrong? I mean, they didn't have sftp but only clear-text ftp, but they wouldn't have that forever, right?

Well . . . it's 2014. The WordPress site is usually very slow. They still do not have sftp ("it would take too much server power to support sftp"). And the email system only hold 250MB per account. Not address -- 10 addresses would share the 250MB. Crazy. Insane.

The WordPress was so bad that I didn't want to write in it again. . . which is bad for someone who like to write. And I finally have some techincal stull I want to write about again. Like code snippets, which I have never been able to get right in my WordPress blog.

And there are some neat things happening in the static generator world. I've looked (and have used) a few. But since I've been using Groovy lately I decided to eat my own dogfood. So this site is being generated by a Groovy-powered generator called Grain. I honestly grabbed a template that I liked and started writing. It has SASS/Compass support built in and uses Python for Pygments as well inside the page generation. Yeah, seems like a kitchen sink. But I can update the Sass files and I don't have to run a script or anything to process them -- it happens automagically. That's pretty cool.

I plan on writing a bit more about stuff I've discovered in Groovy, my dive back into the Java world, and how I (imperfectly) converted all my old blog content into this Grain blog.

Hoss Dreams of Software

| Comments

The other night we watched Jiro Dreams Of Sushi which I highly recommend everyone watch, even if you don’t like sushi. Even if you don’t know anything about sushi. Because it’s not about sushi — it’s about Jiro, an artist who is obsessed about quality, and his craft. And his craft is making sushi.

Jiro Ono is 85 years old and owns a nondescript sushi restaurant in Tokyo. His restaurant only has 10 seats, but it costs $300 per seat and you have to make your reservations at least a month in advance. Oh, and it is a 3-star Michelin rated restaurant. Jiro is, in face, the oldest chef to be awarded a 3-star Michelin award. The restaurant reviewer interviewed in the film said, many times, that Jiro’s sushi is the consistently the best he’s ever had. It’s always the best — never was there a time a bit worse than the other. And that is an astounding review. This all has to do with Jiro, who has committed his entire life to making sushi. Meaning, he’s been at this since he’s been 14 years old. He’s at his restaurant every day, overseeing the preparation of the fish, rice, eggs, etc. He will quickly give a criticism when he sees or tastes something under his exact standards — including his own 50-year old son who works there. Jiro keeps a close eye on his customers, noticing if they are left-handed (he puts the sushi in a different place on the plate if it is) as well as making slightly smaller pieces for females. H also admits when his restaurant is closed on state holidays, he doesn’t know what to with himself.

I’ve been saying for years that cooking is a lot like programming software, and I thought many times about that through this film. Jiro said that, if you want to be the best chef, you can never be satisfied, always strive to be better, and you have to love it. These traits, to me, are the same as what makes a great developer. You have to always been learning, striving to make you things better, and you have to love the work. I think the last item is the most important — writing software is hard and takes a certain kind of dedication, nerves, and brain work that, frankly, not everyone is cut out for.

But if you decide that you like this kind of work, then you dedicate your life to it. And, if you want to dedicate your life to it, then you should be constantly looking for ways to get better. Back to Jiro . . he has been making sushi for 70 years. 70 years! And he is always looking for ways to get better. Not necessarily One Big Thing that will change sushi forever, but little increments, like the kind of rice to use, the temperature of the rice when the the sushi is made and served, massaging the octopus for a longer time to bring that much more flavor out of it, finding the best fish mongers to buy from . . the list goes on and on.

I think most software developers (including myself) want to find the silver bullet, the one thing that will make us all better. But, alas, it doesn’t exist. There is no one methodology to follow, no one language to use, no One True Editor or IDE that solves all the problems. We have to get better, in bits of a time.

Really, what I am talking about comes back to craftsmanship. We want to write great software and, after we do that, we want to do it again, but better this time. Never going back, but always improving. Uncle Bob already wrote a great summary of what this looks like so I will just close with telling you to read that. And get started on your personal improvement.

Add a Read-Only Role to Django Admin

| Comments

I was in a meeting where I was asked to give someone read-only access to the Admin part of our application. That was fine -- it was written in Django and Django has really fantastic Admin functionality. So I assumed that it could handle it, no problem. So I said yes.

Of course, after a little googling, I found that that it doesn't support this at all -- you can only give people Add, Change, or Delete permissions. You can make individual fields read-only but, in an ideal world, I needed a whole object to be read-only or not, hopefully determined by Group membership.

My searches didn't give me a lot of hope, but I did find something close [in this post.][]. So I expanded it to look for a Group.

So you used ReadOnlyAdmin to inherit from instead of ModelAdmin for all Admin objects you want to make read-only. Then you also have to add these two properties:

  • user_readonly - list of the fields to be read-only. If you don't put in there, the user will be able to change the Model!
  • user_readonly_inlines - If you have a related Model that you want to display Inline, then you can't add it to user_readonly because it's not part of the Model. You have create a read-only InlineAdmin object and list that here.

Creating a read-only Admin object is simple:

  class MyModelInline(admin.StackedInline):

     model =MyModel


class MyModelReadOnlyInline(MyModelInline):

    readonly_fields = ["label",]

Then you just list MyModelReadOnlyInline in the user_readonly_inlines and MyModelInline in inlines.

To use the ReadOnlyAdmin:

  • Create a Admin Group called readonly.
  • Add the User to readonly and give them full access to the Models you want them to read -- yes, give them Add, Change, etc. Or they can't view them at all.

When the user logs in, they will see the Model and go to individual ones, but none of the fields will be in form fields -- just straight text.