Quick Tip: Fixing Postgres operator class “gin_trgm_ops” does not exist for access method “gin”

This error can show up when you are trying to load a schema into a new database in Postgres that has been dumped from a database with the pg_trgm extension. You can fix it by adding the extension to the template database (template1) so that when you create a new database, it is already there, ready to go.

To do this, run this at the command line:

 

Workaround: Google Apps for Business won’t automatically add flights to your calendar

My personal gmail account has a great feature where it will automatically add flights to my calendar. It even figures out time zones, which is awesome.

Google Apps for Business doesn’t have this feature, which is a shame. As a workaround, you can forward your flight confirmations from your work email to your personal Gmail account. Just be sure to change the title of the email so it doesn’t have the “Fwd:” prefix, and remove the froward headers from the email body (just select them and hit delete).

Your personal Gmail will now think these are new flight confirmations and add them to your personal calendar! Here’s to hoping Google gets this feature in Google Apps for Business.

Mapbox Studio Creation – OSM Hiking Map

I’ve been experimenting with Mapbox Studio, which is an awesome way to create maps without the pain of setting up a server or downloading Open Street Map data.

The way Mapbox Studio works is that Mapbox has pre-rendered vector tiles from Open Street Map at all 22 standard zoom levels. Mapbox has also pre-rendered hill shading tiles and contour lines! You just need to style them with CartoCSS, which is as easy as it sounds (if you know CSS).

They have a bunch of great starter styles, one of which is Mapbox Outdoors. I modified that to make it a little better for hiking by adjusting the trail labels and making trails more prominent.

You can get the CartoCSS for the hiking map here and see a demo of the hiking map here.

Here’s Great Falls, Maryland with my changes.

Great Falls Hiking Map. Data from Open Street Map and Mapbox.
Great Falls Hiking Map. Data from Open Street Map and Mapbox.

Lodash/Underscore on Google App Script

I’ve recently been working on a Google App Script project, and wanted to use Underscore or Lodash because writing Javascript is relatively painful without those libraries. The problem is that Lodash does a lot of feature detection by trying to throw exceptions, and the Google App Script debugger pauses on all exceptions.

The fix is to just modify Lodash slightly to hard-code the Google App Script features that throw exceptions. This isn’t too hard to do, but it is a pain, so I’ve posted my modified version of Lodash as a Gist here.

Two Cool Tools for Technology Consultants

1) InVision and Sketch

I’ve been making a lot of simple prototypes in the last few weeks, and the combination of tools that has been working best for me is Sketch 3 and InVision. Sketch is a simple drawing program like Illustrator that you can use to make mockups. It allows you to have one file with multiple pages, which you can use for multiple screens in your app.

InVision is a very simple online tool to create clickable prototypes. There are lots of these tools, and here is a good comparison, but for me, InVision has been working best because it is very simple. The way InVision works is you upload a bunch of screens and then draw boxes on them that become “hotlinks” to navigate to other screens. You cannot make more complex interactions, like with a tool like Axure, but for the simple prototypes I have been doing, this is all I need. You can learn to use InVision in about 10 minutes, while it took me 3-4 hours to figure out what the heck was going with Axure (not to knock Axure; it’s very powerful and is the right tool for the job sometimes).

The cool thing with the pair of InVision and Sketch is that you can just drag and drop your Sketch file into InVision, and InVision will create or update your screens. That means your revision workflow is very easy: make or update drawings in Sketch → save the file → drag the file to InVision.

You can drag and drop Sketch 3 files directly to InVision
You can drag and drop Sketch 3 files directly to InVision

 

2) IPython, IRuby, Jupyter

If you have ever used a REPL and wished it had more of a GUI, you should definitely check out IPython or IRuby (and the upcoming project Jupyter). I used IPython in the past, but I’ve been mostly coding Ruby recently. I didn’t realize that there is a very good Ruby counterpart called IRuby that is extremely powerful.

It turns out that IPython is morphing into Jupyter, which aims to be language-agnostic. This could be very cool: think IPython for NodeJS, R, or other languages, and more front-ends that work with any language!

IRuby - a Ruby REPL on steroids
IRuby – a Ruby REPL on steroids

 

Hacking Sleep

I’ve been hearing more and more about the importance of sleep, so as part of trying to be healthier in general I decided to see what I could do to sleep better. A lot of the stuff I tried is based on Tim Ferriss’s Four Hour Body, and I’d definitely recommend the chapter on sleep to anyone who is interested in hacking theirs, too.

I organized these by what I think worked the best for me, but since I tried a lot of things at once, it’s hard to tease out the differences.

Make your bedroom as dark as possible

My apartment is in a historic building, so the facade is lit up at night. While it looks impressive, it makes my bedroom bright even with blackout curtains. What I did to fix this was unfurl a blackout curtain and tack it to the edges of the window so there is practically no light that comes in. By no light, I mean I cannot even see my hand in front of my face. It does not look great, but it works!

Try this first: remove all electronics with lights (even small LEDs) and black out your windows. Use a heavy blanket or aluminum foil and tape. It will look terrible, but if it helps, you can invest in better curtains later.

Test 66-70F degrees as your bedroom temperature, with a thin blanket

This is from the Four Hour Body and it really made a big difference for me. 64 degrees and I’ll wake up shivering, 72 degrees and I’ll sweat and wake up mildly dehydrated. Try 68 with a sheet and maybe a light blanket.

Also, thermostats can be widely inaccurate so you might want to get a more accurate thermometer to test this. For example, if I set my thermostat to 65 degrees, its actually 72 in my bedroom. Try this one that I was using for a few months. It doesn’t really seem to help except maybe on the margins in the darkest days of winter.

Humidity level was more important than I thought

I went skiing in the mountains a few weeks ago and got a cold due to the very dry air. I also slept really poorly. I thought – maybe humidity is screwing up my sleep at home, too.

I had a humidifier that I never used, so I decided to try it. Turns out 40-45% relative humidity is ideal. This is also a narrow band like temperature. Below 40% and I’ll wake up with a dry throat and over 50% and everything feels somewhat damp in the morning. I actually sleep pretty well at 50-55% humidity, but I’m concerned about mold growing at that high of a level.

Eat almond butter on a carrot before bed

This idea is also from the Four Hour Body. A lot times when I woke up feeling sluggish in the morning, I’d feel better after eating breakfast. I figured this was definitely blood sugar related, so I tried another 4HB suggestion-almond butter before bed.

This worked well and mostly eliminated that groggy mornings. I found that the easiest way to do this was to buy a bag of carrots and a jar of almond butter. Eat one to two carrots, “double dipping” in the almond butter so you get the equivalent of three to four tablespoons. The carrots are great because there will be no spoons or plates to clean up, and takes less than 5 minutes.

Things that haven’t caused much of a difference for me

  • Screen time before bed. I have f.lux on my Mac and similar apps on my phone and tablet, so this might be a different story if I didn’t have those.
  • Melatonin doesn’t seem to do much for me, though I sometimes take it when traveling for jet-lag and it helps a bit.
  • I also have a Phillips goLITE that I was using for a few months. It doesn’t really seem to help except maybe on the margins in the darkest days of winter.

Photo credit: punch drunk

Staying Healthy in Tech

“Health Experts Recommend Standing Up At Desk, Leaving Office, Never Coming Back — Headline from The Onion

A lot of my friends were sharing that Onion article last week on social media, and like most things that are funny, there is definitely a bit of truth in it. No matter what kinds of hacks we do to make desk jobs healthier for us, the truth is, sitting (or standing) inside for large parts of the day isn’t really what the human body was designed to do.

Desk jobs are still a huge improvement over what people were doing just one hundred years ago. We don’t have to worry about black lung, 12-hour shifts on dangerous assembly lines, or back-breaking farm work. Plus, there are plenty of office workers (myself included, most days!) who actually like what they do. So I think the first step in figuring out how to make office jobs healthier is to be grateful of the fact that your job is already relatively safe on the spectrum of jobs that humans have had over the years. Practicing gratitude has been shown to make people happier, so this is an actual first suggestion!

Continue reading Staying Healthy in Tech

Choosing the Best Ideas

You’ve got ideas. I’ve got ideas. Your employees have ideas. Your customers have ideas. Lots of people would say try them all and fail fast! That’s better advice than “pick one and hope for the best”, but let’s be realistic: you’ve only got so much time so you’ll have to focus. So, how do you choose the most promising ideas to execute?

The most useful exercise I’ve used for this is to first come up with a rough strategy of how to execute the idea. Then ask yourself the two questions below. These will help you reality-check your plan and make the determination if your idea is a good one or one that should be tossed.

Question 1: What has to prove true for this to work?

Do a brainstorming session and list everything you can think of that needs to turn out correctly for your strategy to work. Sometimes you’ll come up with something absurd like “Bob can’t get hit by a bus for the first 6 months of this project”. And sometimes it will be much more insightful: “We need to make a key hire to free up some of Susan’s bandwidth so she can focus on X” or “We need to confirm that Z is technically feasible”.

The idea of this question is to unpack all of the assumptions that you’ve embedded into your strategy. It isn’t to kill the idea, though sometimes that can happen. In fact, if it’s a good idea, once you are finished with this you’ll look at all of your assumptions and say, “yeah, this has a good shot at success!”.

Question 2: Pretend a year from now this strategy has totally flopped. What was the most likely cause?

This is sometimes called a pre-mortem. The goal with this question is to help you identify the most uncertain or risky assumptions. This is important because the answer to this question will help you decide where to focus your risk-mitigation efforts.

None of this can ensure every project will be a success, but a little bit of upfront work can give you confidence to proceed. I also like to refer to my answers to these two questions when deep in the weeds of a project to help determine what I should be working on.

Further Reading

If you are interested in reading more about this, check out these resources.

Photo credit: alex yosifov

 

Business Model Canvas for Social Enterprises

Business model generation is difficult. Despite the startup renaissance currently going on, the battlefields of the marketplace are littered with seemed-great-at-the-time business ideas that were  not so great once they launched. The Lean Startup idea embraces this, teaching entrepreneurs to iterate quickly to find “product-market fit” before they run out of cash and need to get a job or go back to the coffers of their investors. In the Lean Startup school of thought, business models are sketched out on a Business Model Canvas (BMC) that is one page and can be filled out in half an hour or less. The engineer in me loves this idea. It embraces the Keep It Simple, Stupid ethos that underlies the most elegant engineering solutions.

The real world is not so simple, however. One wrinkle to the Lean Startup model I’ve been working on recently with a client is how to adapt it to a double bottom line business. A double-bottom line business is one where financial profit is not the sole goal of the owners. Talk about making an already difficult process more challenging! To solve this problem, I decided if we’re not going to Keep it Simple, let’s at least not make it too much more complex! I thought, how can I modify the traditional Lean Startup BMC to reflect a social enterprise with as little additional complexity as possible.

In some of the literature on social entrepreneurship and impact investing, there is the concept of a concessionary investment. A concessionary investment is, in effect, a grant because the investor is sacrificing a market-rate return in order to support some kind of social return on his investment. This could be providing a loan at a lower rate of interest, given the business’s credit risk, or it could be providing risk capital (equity) to a business that is far more financially risky that a traditional startup (which are risky enough!).

I like this approach to thinking of impact investing because is puts just one more constraint on a traditional business model: the fact that the business is capitalized by an investor who wants a financial return in addition to some kind of social return. This keeps the engineer in my happy, because as any good engineer knows, if you put too many constraints on a problem you will get no solution! This is how I decided to reflect the added complexity of a double bottom line business in the BMC.

I added two new boxes to the traditional BMC to capture this. The first is social good, which is non-financial value you are creating for your customers or society at large. The second is capitalization, which should describe how your impact investor (which could be yourself, if you are bootstrapping) will measure his social impact.

This canvas worked well for us, so I wanted to share it in case anyone else is working on a similar problem. If you’ve applied Lean Startup methodologies to a social enterprise, or if this was helpful to you, please let me know in the comments.

Business Model Canvas - Social Enterprise
Business Model Canvas for Social Enterprises

You can also access a version on Google Drive or a blank version.

Simple Regex to Match Options Symbology Initiative Tickers

This is a simple regular expression to match Options Symbology Initiative (OSI) tickers. It has been tested in C#: