The other day one of our devs ran into a problem. They vagrant up
ed their VM and instead of a happy working VM they receive the following message:
Instead of booting the VM that already existed it created a new VM. When we looked at Virtual Box we saw that the old VM (BrokenVM in this example) still existed and the new vm (ubuntu_default_1455929302562_42575) had been created in error:
Vagrant uses a file to keep track of what VirtualBox VM it’s using. If you look in the “.vagrant/machines/default/virtualbox/” directory (“default” is the name of the Vagrant box so it might be different if you have multiple VMs) in the folder that contains your Vagrantfile you’ll see a file named “id”. This represents the VirtualBox ID of the VM it’s using. In my case it looks like this:
5b9eb013-65e0-4d4c-91f3-87b0fd19156a
Now we need to figure out what is the “correct” VM ID by using VBoxManage
As you can see the second line refers to the ID of the newly created/wrong VM but the first line contains the correct VM. To fix this problem we just need to copy and paste the “cb533ed8-4267-4450-9955-b8b11add10b4” in the id file we looked at earlier.
Because we’re using Vagrant it wouldn’t have been the end of the world if we had to reset the development box but this way the dev didn’t loose their test data.
GitHub recently announced Scientist! and it allows you to refactor a piece of code that’s critical to your application so you can better “test” the change in production. I think it’s a great idea for those of us who are supporting legacy applications that need better tests.
The example on the GitHub projects page is a change in the permission system:
1
2
3
4
5
6
7
8
9
10
11
require "scientist"
class MyWidget
def allows?(user)
experiment = Scientist::Default.new "widget-permissions"
experiment.use { model.check_user?(user).valid? } # old way
experiment.try { user.can?(:read, model) } # new way
experiment.run
end
end
The important pieces of this are:
It’s amazing how simple it is in it’s execution.
I know what you’re saying, isn’t this in Ruby? Don’t you work in PHP? I do it just so happens the PHP community has created at LEAST two forks:
daylerees/scientist seems to be the better maintained (based on # of commits, contributers, forks, etc.) so I would highly recommend you look at that project. I personally think edison is a great name for this but I’ll have to move past that. :-)
It’s example is much more generic but still helpful:
I have a project at work that requires me to refactor large sections of legacy (non-unit tested) code so I’ll be experimenting with this in the very near future.
A couple minutes ago I bit the bullet and switch the DNS settings for this blog. We’re now officially running on the new server.
When I logged into Facebook recently I saw the following on my news feed:
It’s hard to believe I’ve spend 4 years working remotely and I thought would take the time to look back at what’s worked and what’s been difficult.
Read MoreWhen I work on this site I generally run through a quick check to see if the content looks like I want it too. The downside to using Google Analytics, AdSense, and Disqus is that it really slows down the total load time of a page. While it’s not a huge problem when the site is just loading once it’s a little annoying when I’m loading it 10+ times in a row and making small changes.
In order to get around this I can add the following around any code block I only want on my live server (production):
{% if jekyll.environment == 'production' %}
Production only code
{% endif %}
The bonus to this is that if you use Github Pages to generate the pages for you it automatically uses the production environment.
If you’re self hosting like me you’ll need to specify the environment when you build the page:
JEKYLL_ENV=production jekyll build
I added this to my deploy script and it’s working well.
So hit a wall of busy last month which really limited the amount of time I could work on my migration. As of today, I’m not adding anything additional to my Wordpress installation and I’m think I’m ready to transition the site over. The goal is to get everything checked out this week and then switch the DNS on Sunday of next week (2016-02-07).
As I’ve worked with Jekyll I have run into a annoyance.
The way I work I write a couple posts at a time and then schedule the release so I have content regularly posted. There isn’t any easy way to do that with Jekyll. My quick solution would be to write a script the redeploys the site every hour but that seems very heavy handed. I’ll have to see if there’s a better way. Right now I’m just going to not worry about it and force myself to push whenever there’s scheduled posts.
I use a lot of code blocks in my writing so I wanted to look at my options for how to format them now that I’m using Jekyll. Wordpress had me install extra plugins to get syntax highlighting.
Read MoreWe’re changing our infrastructure at work and moving from our old server(that isn’t well documented) to a new setup that is better documented and faster. As we’re doing this we’re finding odd problems that need to fixed. One of our processes uses wkhtmltopdf to convert some pages to PDF for reporting purposes. When we ran those processes on the new server the PDF file was corrupt and contained the string “No pdftotext Available”.
As an example, we ran the command and received the output below:
I would think the “Failed loading page” error would have kept it from going but we are running an old version.
The fix was to install the libssl-dev
package
And this fixed the errors and caused the PDF to generate correctly.
subscribe via RSS