Travel, Code, and Engineering
on March 19, 2017 by Kurt Tomlinson
Sometimes you need to add some special functions to your Ruby on Rails app, and you want these functions to be available everywhere in your application. In cases like these, you can put your code somewhere in Ruby on Rails's load path, and it will be loaded automatically without you having to "require" it in any of your other files.
For example, in Bloopist, I often need to process some Markdown and convert it to plain old HTML. For this, I made a method called markdown_to_html, and put it in my load path.
This raises the question, "what directories are in my Rails app's load path?" That's a pretty easy question to answer. Just load up your rails console and run the command puts $:.
$ rails console
> puts $:
Anything in the load path will be autoloaded by Rails so you don't need to require anything in those paths.
on March 5, 2017 by Kurt Tomlinson
Making OpenResty and Passenger work together isn't too hard, but it's not obvious how to do it. There's a lot of guides for getting Passenger to work with Nginx, but the process for OpenResty is a little different. For that reason, I'm documenting how I got them to work together here.
The script below installs RVM and version 2.3.3 of Ruby. To check for newer versions of Ruby you can ask RVM to list all known rubies with rvm list known.
echo "INSTALL RUBY WITH RVM"
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
curl -sSL https://get.rvm.io | bash -s stable
rvm use 2.3.3 --install --default
If we're going to use a Ruby gem, we might as well update the platform.
echo "UPDATE RUBYGEMS"
gem install rubygems-update --no-rdoc --no-ri
gem update --system
gem pristine --all
The Passenger gem is an easy way to get the passenger source code onto your system. We need it so we can compile passenger into OpenResty.
echo "INSTALL PASSENGER GEM"
gem install passenger --version 5.1.2 --no-rdoc --no-ri
You can check for the latest version on the Passenger RubyGems page.
In this step, we do several things. First we download the OpenResty source code. (Check the OpenResty download page for the latest version of OpenResty.) Then we unpack it. Then we configure it and indicate that we want to add the passenger module. Finally, we make and install it into /opt/openresty/. The configure options are the same options that the Passenger gem uses when installing Passenger+Nginx with the command passenger-install-nginx-module. (You can't use passenger-install-nginx-module with OpenResty because OpenResty's configure script is a Perl script, and passenger-install-nginx-module tries to call it with sh. Trying to run a Perl script as a Bash script results in all kinds of bad things.)
echo "INSTALL OPENRESTY (NGINX) AND PASSENGER"
tar xvfz openresty-18.104.22.168.tar.gz
./configure --prefix='/opt/openresty' \
sudo make install
If you follow the directions above, you will have Ruby 2.3.3, OpenResty 22.214.171.124, and Passenger 5.1.2 installed on your system. Ruby will be installed at ~/.rvm/rubies/ruby-2.3.3/bin/ruby OpenResty will be installed at /opt/openresty. And Passenger will be installed at ~/.rvm/gems/ruby-2.3.3/gems/passenger-5.1.2
on February 19, 2017 by Kurt Tomlinson
One year ago, I bought a washer and dryer from Best Buy. The technicians they sent to install the washer and dryer stripped out the threading inside the washer that's used to hold the shipping bolts. (Shipping bolts are used to stabilize the washer and prevent damage when it is moved.) I didn't realize this until one year later because I would have to uninstall and reinstall the washer myself in order to check that the shipping bolts were okay. Best Buy customer service lied to me to get me to hang up the first time I called. the second time I called, they refused to fix the problem in any way because I didn't realize the problem until after their 30 day warranty period expired.
I bought a washer and dryer from Best Buy about one year ago. They included installation in the price of the washer and dryer. The installation was performed by a couple of guys who worked for a company that did contract work for Best Buy. When they installed the washer, they had to remove four shipping bolts from the back of the washer. Shipping bolts are used on front-loading washing machines to stabilize them during transit and prevent damage.
A couple days ago I disconnected my washer and dryer so they could be moved to my new apartment. My movers wouldn't disconnect or reconnect the washer and dryer, so I tried to get ready for them. I disconnected both and then tried to install the shipping bolts. One shipping bolt installed without a problem. Another shipping bolt installed at kind of an odd angle.
The last two shipping bolts wouldn't install at all. There was plastic residue on the last two shipping bolts. When I looked at the threading inside the washer, I saw that it was plastic and the same color as the residue on the shipping bolts. The technicians that installed the washer must have turned the bolts in the wrong direction when loosening them, and instead of loosening them, they tightened them until the threads gave out and removed the bolt and the threading together.
I'm not sure they realized their mistake or not, but if they did, I'm sure they didn't tell me about it on purpose. They knew I would not find out about it until the next time I moved at the earliest and that would most likely be so far in the future that I'd have little to no recourse. (That would turn out to be very true.)
So I called Best Buy customer service to try to get this issue fixed. The first guy I talked to was Brian. I explained the problem to Brian. He put me on hold and talked to his manager. When he came back, he told me that the shipping bolts are one-time use only; they're only used when transporting the washer from the warehouse to the customer's home. He also said that the manufacturer would say the same thing.
I didn't know for sure, but I was pretty sure he was lying to me. I like to give people the benefit of the doubt, so I thanked him for his time even though he didn't solve my problem and hung up. I downloaded my washer's manual and looked in the section about shipping bolts to see if what Bryan said was true. The manual for my washer says, "Save the bolt assemblies for future use. To prevent damage to internal components, DO NOT transport the washer without reinstalling the shipping bolts."
That seems pretty clear to me. The manufacturer does not think the shipping bolts are one-time use, and Bryan was bullshitting me.
With this new information, I called back. This time I talked to Layla. I explained the situation to Layla. After conferring with her manager a couple times, she gave me two options: pay a $99 diagnostic fee to have someone come out and look at it with the implication that the the washer was still covered under the manufacturer's warranty, or call the manufacturer and try to get them to fix it for me.
I told her that both options were bad, and that if that was the best she could do, then I would never shop at Best Buy again. I told her I'm not going to pay an extra $99 to fix something that should have been done right the first time. She said that if I had bought the Geek Squad protection plan then she could give me some better options. So I asked her, "Why do I have to pay extra and buy protection in order to get Best Buy to do their job correctly?" Of course, she couldn't answer that question because she understood my situation. There's no reason why my previous purchase of Geek Squad protection should have anything to do with getting Best Buy to fix something that they broke.
And of course, the manufacturer will not cover this damage because that damage wasn't there when they produced the washer. The damage was caused by negligence. Why would LG repair a washer that someone else broke? That's not LG's problem.
Not willing to pay Best Buy a $99 diagnostic fee just to send someone out and tell me what i already know is broken on my washer, I told Layla that I couldn't do business with Best Buy any longer.
Any company that says you have to pay extra in order to ensure that the services they render are performed correctly should be boycotted. That's why I'm never shopping at Best Buy again and neither should you.
on February 5, 2017 by Kurt Tomlinson
There's something really wrong with my iPhone's software. For a couple weeks now, it has been constantly nagging me that I'm out of space. Initially, I handled this by backing up my photos and deleting those. Then it reminded me again, so I deleted my podcasts. Then it reminded me again, so I deleted a couple large applications. And now, it's still reminding me that it's out of space!
This morning I didn't believe it anymore. I had no photos, podcasts, or music on my phone, and the largest app on my phone was only a couple hundred megabytes. So I decided to add up everything that the phone said was taking up space. My phone indicates I'm using 11.64 GB of space right now. I went down the list of applications on my phone and added them up. I got a grand total of only 3.6 GB.
I guess I could take this in to an Apple store to get it fixed, but who has time for that? I'm probably just going to do a full backup and restore in the next couple days unless someone gives me a good idea about how to fix it.
Have you ever had a problem like this? Let me know about it in the comments!
on January 31, 2017 by Kurt Tomlinson
I recently bought another year supply of contacts. Most years in the past I just bought my contacts from 1800 Contacts just because that's the company that I've always used. This year I did some shopping around and I was surprised by what I found.
I have astigmatism in both of my eyes, and my old contacts had started to bother me. So I decided to change to Acuvue Oaysys for Astigmatism lenses. These lenses are bit more expensive because they use newer technology and are for astigmatism.
In total, I checked the price for an annual supply of my lenses at nine different suppliers. (I ignored any coupon codes or other discounts that they offered because I'd be reimbursed for anything under $200 anyway.) The cheapest supplier came in just a hair under $200, and the most expensive was $332.
Had I not shopped around, I would have spent $130.96 over my VSP allowance at 1800 Contacts. By shopping around, I was able to find a supplier that kept me under my allowance and I didn't have to spend any of my own money at all.
I've recorded the results of my comparison shopping below.
I was surprised by the results because I think of contacts as medical supplies, and I thought of medical supplies as having a fixed price. Clearly I was very wrong, and medical supplies can have widely varying prices.
What kinds of things have you saved money on unexpectedly by shopping around? Let me know in the comments!