Tonight I’m doing a lightning talk titled “3 Gems That Saved My Bacon” at the Boulder Ruby Meetup. 5ish minutes or so. Hope to see you there. Plus, free pizza and beer, courtesy of our sponsors.
Really, you should come. It’s fun.
Tonight I’m doing a lightning talk titled “3 Gems That Saved My Bacon” at the Boulder Ruby Meetup. 5ish minutes or so. Hope to see you there. Plus, free pizza and beer, courtesy of our sponsors.
Really, you should come. It’s fun.
I think the Rails low level cache is the bees knees. It lets you store complicated values easily, manage TTLs, and improve the performance of your application.
I’d be remiss in stating that you shouldn’t cache until you need to. Caches will introduce additional complexity into your application, make troubleshooting harder, and in general can be confusing. How do you know if you need to introduce a cache? Profile. Using rack-mini-profiler is a great quick and dirty way to profile your code.
The rails low level cache is fairly simple to configure (especially if you’re using a PaaS like Heroku–you can drop in a managed memcached service easily).
From there, you need to build a cache key. This is a string, up to 250 characters in length, that uniquely identifies whatever you’re trying to cache. Basically anything that would cause a change in the contents of the cached object should be included in this key. However, since you are going to calculate this key every time the value is requested, you don’t want the cache key to be expensive to calculate, otherwise the value of the cache will be degraded. Good things for the key: timestamps, max updated_at
values for a collection, user ids or roles.
Then, putting a value in the cache is as easy as:
def pull_from_cache cache_key = 'mykeyval' myval = Rails.cache.fetch(cache_key, expires_in: 1.hours) do @service.build_expensive_object() end end
In the case above, the cached value will automatically expire in 1 hour. If you don’t set the expiration time, then the cached value will eventually be removed via LRU. How long that is depends on the size of your cache and what else you are putting in there.
If you want to test that something is being put in the cache, you can run a unit test and see how many times build_expensive_object()
is called.
#... object.service = @service expect(@service).to receive(:build_expensive_object).once object.pull_from_cache object.pull_from_cache #...
In a production troubleshooting situation, you may need to evict something from the cache. You can do so from the rails console by finding the cache key and running Rails.cache.delete('key')
.
Using the low level cache is a great way to push read heavy hot spots of your rails application (database queries or other complicated calculations) into memory and make your application faster.
I’ve been teaching AWS courses for the past year or so. Many have been with an online teaching environment. This opens up the class to more people–there’s less cost in taking a course from your office or living room, as compared to flying an instructor out for an on-site. However, this learning environment does have challenges. Below is my set of best practices, some suggested by other instructors.
Pre class:
During class:
After class:
Note that I didn’t cover the content or particular technology at all. They aren’t really relevant.
I’m constantly amazed at how productive you can be with rails. It simply lets you work on typical webapp problems at a much higher level. At 8z, we had a web application and a customer support team. Occasionally the customer support person had to ‘impersonate’ a normal user to troubleshoot an issue. We built a piece of software that let them assume that role. (We called it ‘sudo‘, obviously.) It’s been a few years, but as I recall it was complicated and error prone, lived on a different domain and wasn’t fully functional.
I needed to add similar functionality to a rails web app, and was able to find a couple of gems that looked useful. I selected pretender, mostly on the basis of documentation and google search results placement. I followed the instructions, tweaked a few settings and was off to the races in about an hour. (Note this isn’t a fair apples to apples comparison of the underlying technologies, due to the differences in available open source libraries between the mid 2000s and the late 2010s.)
Now, all this gem does is what it says it does. It lets a certain user or set of users in your application pretend to be another user. It doesn’t handle auditing or anything else you might want with an elevated privilege system.
But it does do what it does well.
I found this video, about 30 minutes long, courtesy of Brad Feld. It does a decent job of covering the macro fundamentals of a capitalist, credit based economy, and the inevitable cycles.
Do you know that moment which happens at almost every meeting or conference call, when a participant refers to a concept that you don’t quite understand? That moment happens to me often, and has throughout my career.
“The marketing funnel is part of the sales process.”
“We can just flurbuzz the bazznod.”
“We have plenty of runway.”
That is the moment when you can ask the hard question.
“Why is that connected?”
“What does that mean?”
“I’m sorry, I don’t understand. Could you repeat that? How do you define runway?”
Asking these questions is important. Otherwise you and the other parties will be talking past each other, which will only lead to pain down the line when the misunderstanding is crystallized in people, process or code.
I’ve been asking these kinds of questions my entire career. When I worked at a web consulting company in the early 2000s, there were often company wide conference calls discussing our precarious financial state. I got a reputation as “the question guy” because I wasn’t afraid of asking the awkward question, even of the CEO in front of the entire company. I was interested in hearing as real of an answer (as they could share).
If you’re interested in asking hard questions, here are some tips:
Again, the goal here is not to ‘get’ the speaker, it’s to help get everyone on the same page. Asking tough questions to pin down some of the nebulous concepts we work with every day can help everyone make better decisions.
Fred Wilson has a great post on reference checking. From the post:
The thing I have learned in thirty plus years of making reference calls is to pay attention to how things are said more than what is said. And pay particular attention to what is not said.
As always, there’s a number of great stories in the comments, including “warm up your network” when you are going to be referenced checked, and the story of a reference check poaching a candidate.
However, reference checks aren’t just for CEOs, hiring managers and VCs. They are a powerful tool for job candidates. It is tedious and time intensive, but is an additional source of information about a company for which you are considering working. LinkedIn is in particular very useful here, because if you are thinking about working for company XYZ you can find out not only who works now for them, but also who used to work for company XYZ. You can also find out who knows someone who knows someone who used to work for them. Yes, this takes additional time, but if you’re going to be spending 40+ hours a week at a company, isn’t it worth gaining some perspective from people who are or were on the inside?
Consider it one more method of doing your research.
When I joined The Food Corridor, the concept of financial runway was well known to me from my consulting days. You figure out your monthly expenses, your savings, and any income you have coming in. Divide your savings (or at least the amount you want to spend) by the expenses less the income, and you get the amount of time available to work on the startup before you run out of money.
You definitely want to pad this a bit, because if you run out of money, you’ll need some time to find another source of income. You can also pad this with debt, selling other assets, part time work, investment, etc. Heck, maybe the startup will even make some money too.
But the goal is to have an idea of how long you can go before you have to call it quits for financial reasons. Then you can see if you think you can build the company in that amount of time. (Hint, it’s going to take longer than you think to build the company.)
Emotional runway is another key aspect of surviving a startup. Startups are full of a lot of stress. Some examples:
All of the above make it tough to ‘tough out’ a startup. These are all costs that you will have to bear. Just like you only have a certain amount of savings to spend down, you also only have a certain amount of emotional wealth to spend. (There are times when a startup will deliver emotional wealth too.)
One of the hardest parts of the current startup for me is keeping an eye on my emotional runway. Taking some time off, celebrating successes, being open about the stresses with co-founders and family, and just being aware of what puts “money” into the emotional piggy bank and what takes it out are all ways I’ve dealt with this.
Railsconf, a conference focused on, well, Ruby on Rails, is happening in Pittsburgh in April this year. I attended last year and it was a fantastic experience. I enjoyed the people I met, the problems I saw discussed, and the size and content of the presentations and workshops. It definitely had a vendor experience (thank you, Heroku, for the t-shirts), but wasn’t too explicit.
Railsconf organizers are now accepting proposals for workshops, panels and speaking. For some reason the CFP isn’t on the website, but I noticed it was announced via twitter. I just submitted, so I can’t speak to the entire process, but the initial submission was pretty painless, just few sections on what you’re interested in presenting and why you might be a good fit.
They actually have a blind submission format, so I had to edit my initial submission to remove any reference to my identity. Seems like a good idea.
So, go forth and submit!
The internet makes some things frighteningly easy. Trolling, for example.
But the fact it makes research easy is a win for everyone. James Altucher has a post on how research helped him win a deal. I remember when research meant you had to head to the library, look in a card catalog and/or ask a librarian, and skim through books. If you wanted to take the information home, you used to have to check out the book. Some books were too valuable to leave the library, so you had to make photocopies of relevant pages.
That’s all changed, obviously. Now you can research a person or entity without leaving your home, though you still can leverage what libraries provide. And you can research non famous people in far more depth than you ever could in the past. When you meeting with a potential business partner, interviewee, or client, you can google the heck out of them.
The benefit of doing so is twofold.
These are both worthwhile goals and will lead to better outcomes. If you don’t do any research, that sends a message as well–“I don’t care much about this meeting” or “I’m too busy to do any research.” That may be OK, but be aware that you are sending these messages.
So, if you want to do research on someone, how do you go about it?
I’d start with setting a time limit and a goal, otherwise you can get bogged down or sidetracked. An example: “I’m researching this client and want to know their key business goal. I’m going to invest an hour of time in this.” Write this down, and check back in as you do your research to make sure you are heading towards your goal and not down a rabbit hole.
Then, start digging. I used the term “google” above to refer to searching, but I’d suggest using more than one search engine, as they each give a slightly different view of the web, and I’ve definitely had useful results pop up from Bing or Duck Duck Go. If this is a business meeting, LinkedIn connections can be useful.
If the client maintains a blog or social media account, spend some time reading that. You don’t have to read every tweet, but getting a feel for what’s on their mind, especially in recent posts, can be illuminating.
The amount of effort to put into such research depends on how much it will help you and how important the interaction with the research subject is. That is, if you are discussing going into business with someone, research the heck out of them. If you are interviewing for a very interesting job, spend some time. If, instead, this is a random coffee meeting, you may not want to invest any prep time.
You may find something disturbing in your research (a conviction report for example). Integrate this into your decision making process, but be aware that the content may not be accurate, or may not apply to the research subject, or may be far enough in the past to be irrelevant. Also be aware of any discrimination laws that may apply, such as employment laws.
If you find an interesting blog post or article that is relevant to my audience, you can promote it before the meeting (post it to Hacker News or Reddit, tweet it out). Your research subject probably won’t notice, but if you’ve already done the research and found something of value, you might as well share it. And on the off chance they do see the post, they’ll likely be flattered.
When the meeting occurs, feel free to casually mention some of the research. I’ve been on the other side of it (someone read a blog post I wrote and mentioned it in an interview) and I can tell you it was quite a pleasant surprise. And it can be a great starting point for a conversation. But don’t get bogged down in discussing something the person wrote years ago, just use the research you found as a way to connect.
No matter how thoroughly you research someone online, realize that online we are all painting some kind of picture of ourselves. Some people and companies are more transparent than others, but the mere fact that you have to pick and choose what to post means that you’re getting a curated view. Non verbal communication matters too If you’ve done the research, you’re ready to go into that meeting and take the connection and the relationship to the next level.