Replace a wordpress site url in database with sed
Wordpress is one of the crappiest piece of software ever written. If you ever want to do simple stuff, like running different environments, you are already on your own. Read this page if you feel like crying. Wordpress doesn’t provide anything for that and even if it would, some bad coded plugin will use hard coded urls anyway. It’s just a huge mess. I didn’t find anything to fix this, so I decided just to dump the whole database and replace the urls with the following sed commands:
sed -i -e 's/127\.0\.0\.1\/wordpress/production.example.com/g' database.sql
sed -i -e 's/localhost\/wordpress/production.example.com/g' database.sql
sed -i -e 's/localhost\\\/wordpress/production.example.com/g' database.sql
sed -i -e 's/localhost\\\\\/wordpress/production.example.com/g' database.sql
sed -i -e 's/localhost\%2Fwordpress/production.example.com/g' database.sql
With this you can replace localhost/wordpress with production.example.com.
Seriously, how can people run large wordpress installations in production environments?
SSL certificate error with elasticsearch gem on ruby 2.2.2
I don’t know exactly why but with Ruby 2.2.2p95 on OSX I get the following error when I try to use the elasticsearch gem:
Faraday::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
To fix it, just try to avoid using rubys build in Net::HTTP lib and switch to another one (for example typheous). Just add it to your Gemfile, let Bundler run and the elasticsearch gem will use it by itself:
gem 'typhoeus', require: 'typhoeus/adapters/faraday'
Set your paths right for rbenv and all the other cool stuff you're using
Rbenv is awesome. I find it the most simple solution to handle different Ruby versions. But if you use it with tons of other stuff like brew and heroku you have to take care in what order you set your paths to use everytime the right bins for loading your applications. Here is what I use in my .bash_profile:
export PATH="$HOME/.rbenv/bin:/usr/local/bin:/usr/local/sbin:/usr/local/heroku/bin:$PATH"
eval "$(rbenv init -)"
export PATH="./.bundle/bin:$PATH"
First add heroku, then add everything related to brew and then add everything
related to rbenv. After this, load rbenv and your currently selected Ruby
version. If you find gemsets useless like I do add the last line of the
example also. This will load all the binstubs in the current directory that you
can create with the --binstubs option for bundler. To make it even more
convenient add this also to your .bash_profile:
alias bi='bundle --binstubs .bundle/bin'
Now you can bundle with binstubs by just typing “bi” and all gems and bins will load in the following order:
- project specific gems in the current folder
- ruby specific gems from with rbenv currently selected ruby version
- gems/bins installed with brew
- gems/bin installed in the system


