How to get rid of that Company:0x000decafbad00 in favor of something more sensible

Sometimes our defaults are terrible.

= link_to(@company)

I expect the above to produce something pleasant, but instead I got this:

A lot of what slows me down as a coder is knowing the “right” way to do something. I still don’t know what the “right” way to fix this. I like writing short pieces of code that bake in some assumptions. So I changed my Company model like so:

class Company
def to_s
name
end
# your code here
end

For WhichOffice I’m building a little dashboard to keep track of locations of all the companies we track.

I have a Location model which references a Company model.

class CreateLocations < ActiveRecord::Migration[5.2]
def change
create_table :locations do |t|
t.references :company
...

I used the Rails generator for administrate to create a new Location dashboard:

rails generate administrate:dashboard Location

Added a resources :locations to the right spot in routes.rb.

Initially my Locations form had a big empty text field for company_id. Not quite what I had in mind:

A small tweak to the LocationDashboard :

ATTRIBUTE_TYPES = {
id: Field::Number…

tl;dr 0.0.0.0 tells a server to listen on any available IP address (localhost, 192.168.0.2, or whatever). You can’t connect to http://0.0.0.0/.

Recently I’ve had a few separate instances of people who did not fully understand how the 0.0.0.0 address works and more generally localhost.

With the caveat that I am not a network operator, I’ll explain.

Servers often have the ability to bind or listen on a specific address. For example if you start the the rails web server by default it will say something like:

=> Rails 4.2.4 application starting in development on http://localhost:3000

rails is bound to localhost


I started to add Rails Admin to WhichOffice which currently doesn’t have users (and to be honest, doesn’t have a lot of pages yet). I thought instead of adding users, I could put HTTP Basic Auth and be done with it, but it felt gross.

So I decided to add users. Models, Bcrypt, the whole nine yards. This was relatively easy with Clearance. I liked it’s simplicity and opinions that I decided to use another Thougthbot gem, Administrate, instead of Rails Admin. This paid off well.

Administrate

Having Administrate play with clearance is pretty easy. For the most part I used…


I’ve always liked using “naked” domains or apex domains. I worked on del.icio.us which wasn’t quite naked, but it didn’t contain the “www” until it became “www.delicious.com” (this was before it became del.icio.us and I honestly don’t know where it is now).

There’s caveats to doing this, however. CDNs can have trouble with this, I ran into this as we scaled up Pinterest (note the wwws).

Naturally when I created my new site, WhichOffice to help job seekers find a place to work near their homes, I opted to omit this.

I know… I’ll use a CNAME.

I host with…


I have a special purpose Amazon EC2 instance that does a long running task and shuts down. Occasionally I’d see it start to repeat itself over and over again and never shut down. I figured out the issue and it has to do with pipes (of the Unix variety).

The most recent incident had left me with some clues:


We talked about loans/notes briefly during a foray into real estate investing. When investing in notes an important ratio is Loan-to-Value (LTV). This is usually a percentage and if you’ve purchased a home you’ve probably targeted 80 or 90%. 80% LTV means if you are buying a $200,000 home, you’ll pay 20% (this is the down payment) or $40,000. The bank or lender will provide $160,000.

Down payments

Down payments are a way to show your lender that you have some skin in the game. While 10% down means you’ve got a 10x lever (e.g your $20,000 can buy $200,000 worth of…


The bank never runs out of money…

I’ve started casually looking at alternative investments. I can balance a traditional portfolio of stocks and bonds, but alternative investments (loans, real estate, private placements) are much harder to understand. I noticed myself naturally making lists of things I didn’t know and spending a bit of time researching them.

Note: I’m not a professional. The following is my opinion and if there are facts listed, some of them may be wrong. This is a new frontier for me.

Some people have a bias for debt over equity. I didn’t quite understand the preference, so I added it to my list. After reading and thinking I broke it down this way.

Edith might own a house. She has 100% of the equity in the house. Meaning if the house makes…


tl;dr avoid until necessary mocking in your test suite. Refactor your code.

I am a big fan of basic unit and functional testing. I ran a tutorial on testing at PyCon, I’ve contributed to a few testing libraries. I’ve helped drive testing at companies like Pinterest and Mozilla.

The first test in production-deployed code is always difficult. You’ve got to untangle database connections, API calls, etc. If you didn’t start with tests in your project, it’s going to be that much harder to add them later as your project grows.

With your first test it’s easy to gravitate towards a…


I use Sidekiq to do a lot of rails-related offline tasks. Because the Sidekiq jobs are tied to a large rails codebase my team often utilizes AWS Lambda for non-critical work.

The benefit of Sidekiq is it’s close to our rails app which uses ActiveRecord to maintain complicated relationships. Sidekiq also has modeled a lot of the work to be done. A job, MyPostHocAnalysisJob can take an input (usually an id of a model) and do work on it. These jobs may get written once and change very rarely.

What does sometimes change is triggering these jobs. Often I could…

Dave Dash

DadOps 24/7 and DevOps Consultant. Formerly @Pinterest and @Mozilla

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store