Author Archives: syewell

Environment Variables with Laravel Forge

laravel-four-icon1For our latest Laravel application, we decided to try the Laravel Forge service to configure and manage the staging and production sites for the app. If you haven’t heard about Laravel Forge, check out the free screencast series by Jefferey Way over at Laracasts.

The Forge UI is great, and takes away a ton of the pain of server and application configuration. Following best practices, we use environment variables to manage environment specific settings like the database name and credentials. One of the features Forge provides is the ability to automate deployment from your github / bitbucket repo upon a post to a specific branch.

The problem we were having was that our migrations would not run. The error was:

{"error":{"type":"ErrorException","message":"Undefined index: DB_HOST","file":"\/home\/forge\[ourbasedir]\/laravel\/app\/config\/database.php","line":51}}

In our case, we are using a non-standard repo directory structure where instead of the typical Laravel app directory structure:

---app
|-bootstrap
|-public
|-vendor

we have another layer above:

---docs
|-laravel
| |-app
| |-bootstrap
| |-public
|-html-templates

Upon inspection of the directory on the server, we found the “.env.php” file was in the base directory. The problem with this was that artisan, the application responsible for Laravel migrations, could not see the environment variables, and so the database configuration was wrong. The solution was simply to move .env.php file into our “laravel” directory so that artisan had access to it.

Setting up Vagrant with SSH Forwarding

Thanks to stackoverflow and github, I finally got Vagrant set up so I can ssh into vagrant and pull in my dotfiles from github without futzing with my ssh keys. Here’s the steps:

1) Make sure the ssh key you use for github is registered with your local ssh agent. You can check with ssh-add -L, if it’s not listed add it with ssh-add ~/.ssh/id_rsa. Credit: http://stackoverflow.com/questions/11955525/how-to-use-ssh-agent-forwarding-with-vagrant-ssh

2) Make sure ssh forwarding is enabled in the VM. Include `config.ssh.forward_agent = true` in your Vagrantfile.

3) Test: ssh -T git@github.com. If it’s not working, check out this link for more troubleshooting: https://help.github.com/articles/using-ssh-agent-forwarding

Email addresses as usernames in WordPress Multisite

wordpress-errorIn a recent project I was trying to create new users with just their email addresses in an instance of WordPress Multisite.  To do this, I planned to use the email address as the new user’s username.  But I kept getting this error:

“only lowercase letters (a-z) and numbers are allowed”

In case you run into this problem to, there is a solution: the Network Username Restrictions Override plugin. There’s a setting in the plug to allow email addresses for usernames.  Click that and you should be good to go.

Here’s another way to solve the same problem that overrides the error that pops up if you try to use an email address as a username in WordPress Multisite.  It attaches a custom filter to the the ‘wpmu_validate_user_signup’ hook that unsets the email address error.

On Quitting.

SocialClassChoice“I’m glad you came to talk to me, it’s a relief really”, my coach said.

I was sitting on the couch in the Cornell wrestling coach’s room.

I had walked on to the Cornell wrestling team two years back, a freshman nobody had heard of from California.  I wrestled three years in high school, was team MVP for three years, team captain for two, first in my league for two years, most wins in the high school history, so I figured I could do something like that in college too. Continue reading

Make reversible database migrations

bidirectionalRecently, I added a new feature that significantly changes one of the database tables in my application.  I ran into problems when I created a non-reversible database migration, and realized that other branches I am developing on still require the older database scheme.  In the end I had to end up dropping the DB, deleting the offending migration, rebuilding the DB, and figuring out a smarter way to migrate.  Not fun, and time wasted. Continue reading

Are you living with the most critical person in the world?

Fisheye Scorn - You're in Deep TroubleNo, not your husband / wife… Nope, not mom. Not your brother or sister.  Of course, not your cat.  I’m talking about that stupid a-hole in your head that sees the other side to everything you do.  I recently went through a period about a week-long where everything was annoying, and that voice was loud.  I got upset a lot, was easily offended by others, spent a lot of time counting to 10, recognizing that the outside world had not changed that much, but something was going on in my head. Continue reading

Start somewhere… ANYWHERE!

IMG_1524Ever feel like you want to do something new, but a little voice in your head says “oh… but you can’t”. Maybe you think about it again, and another voice asks “What if you don’t finish?”.  And then another voice pops up and says “they’ll think your dumb for not being good at that already…”

Maybe you want to build a website. Or learn to code. Or learn to dance. Or start a company. Or become a great cook. Whatever.

So instead you stop thinking about that new thing you could be doing because it feels bad. It’s like a tease, it excites you and you become vulnerable to the potential, and then those voices come in and cut you down, leaving you feeling silly and impotent. And the world is worse off for it.  And you are worse off for it.  Continue reading

Viewing your experiences through a PID Controller

PID

Heading into work today I was thinking about how we are the sum of the experiences we’ve had.  Our brains have been trained to recognize patterns in people and events and we use these patterns to “expect” what will happen next. Sometimes things don’t go the way we expected them and this makes us distraught, stressed, or upset.  And then the image of a PID controller popped into my head, as I’m sure it would have in yours. Continue reading

Why don’t people just like things?

hysteriaDo you know that feeling where some friends are ripping on some song, or musician, or genre, and you’re thinking, “but I like that”.  But you don’t say anything, because it would be embarrassing.  You don’t want them to think less of you. You want to fit in, and the easy way to fit in is to agree with them, or at least not disagree with them. And inside you make a note, “don’t tell these people / anyone that I like this thing”. Continue reading

Identify the Right Threshold

hurdleIt’s a paradox, the easy thing to do is to do more work. The hard thing to do is to decide where to place the good enough threshold, and to work enough to meet, but not exceed that threshold.

I had a boss once who, when evaluating a project would either describe the state as “above threshold” or “below threshold”. It was an interesting choice of words, and really described his point of view on things… Continue reading