When working with API which is bombarded by XHR requests, which often come from various subdomains, one turns CORS headers.
Common solution for most of Rails developers is to create before_action with custom headers.
This is an alright solution but I’d suggest moving that into a (Rack)[http://rack.github.io] middleware layer before your Rails router kicks in.
Issue with the controller method is that you must enable OPTIONS response in the rails router to handle requests.
If you don’t want to write your own middleware, Rack Cors comes quite handy.
In application.rb make sure that you serve CORS at the top of the stack or at least before middleware you need (in my case I had Warden::Manager instead of 0).
That’s an ‘OK’ setup for Heroku, (Aptible)[https://www.aptible.com] or other services, which allow you to deploy your app with cli but won’t let you access higher stack like Nginx or Apache
The proper way of handling Cross-origin is to set it up at the Nginx/Load-balancer level. So your Rails app is only busy with serving text but not the headers.
For NGINX you can make use of add_header in the location context (or server if all your server does is serving API)
Almost any reasonable deploy process now requires a docker box. Docker is awesome but I’d rather have an isolated environment for my containers.
Here is where vagrant’s docker priovider comes in to play. Vagrant guys did a great job explaining abstraction here.
As always things are not so easy when you actually try to implement Vagrant Docker Proxy/Host on your own.
After a day of googling errors caused by vagrant upI figured that Vagrant is too green for automating Docker installation.
Another issue came up after I failed to install Docker on linux box.
Even if you get Docker instaled you instantly get a permission error.
All issues above fixed with custom shell.sh provision script:
curl -sSL https://get.docker.com/ubuntu/ | sudo sh && will take care of installing correct binaries.
Here’s working Vagrantfile for host machine:
Then you can reference other containers in main Vagrantfile
Today I realized that there are about 2000 of messages / voicemail in my Google Voice account. By default Google will only allow 10 messages to be removed in one shot. Then you’ll find deleted messages in “History” which you also need to clean up.
I hate to leave all this text about me laying around on Google servers.
So here’s the gist of a code that will remove all of your messages from Google voice.
WARNING: this code will delete everything from your account. So use it cautiously!
This is first post for the Overengineering blog. I will be posting more usless or usefull stuff as I feel like sharing.
If want some details please let me know in comments…