“LifeLock CEO Todd Davis, whose [social security] number is displayed in the company’s ubiquitous advertisements, has [...] been a victim of identity theft at least 13 times, according to the Phoenix New Times.”
“Over the course of one weekend, the organizers took $17,000 from conventiongoers as part of an emergency fundraising drive, failed to pay any of their high-profile guests, and attempted to compensate disappointed ticket-holders by offering them an ‘extra’ hour in a children’s ball pit.”
“One of the most common complaints on review sites against us and many restaurants in the area is that the service was slow and or they needed to wait a bit long for a table.
Given in most cases the customers are constantly busy on their phones it took an average of 20 minutes more from when they were done eating until they requested a check. Furthermore once the check was delivered it took 15 minutes longer than 10 years ago for them to pay and leave.”
(Take this with a grain of salt, since the source is an anonymous Craigslist posting, and the “finding a surveillance tape from 2005″ strains belief.)
I spent hours today trying different ways of quickly and reproducibly provisioning a Mac for Rails + Postgresql development that could be deployed to Heroku. What follows is, believe it or not, the easiest method I came up with.
This is a cheatsheet, not a tutorial. I’m not going into much depth on what each command does, but if you’re just looking for a list of commands to get running quickly, you’re at the right place.
I tested these instructions against a stock installation of OS X Mavericks 10.9 in VMWare Fusion that had been patched up to 10.9.4 with Software Update. Mavericks 10.9.4 ships with ruby 2.0.0p451.
This cheatsheet was compiled with information from https://devcenter.heroku.com/articles/getting-started-with-rails4 and other sources.
• First, create an account on Heroku, if you don’t have one already.
• Trigger the OS to install Developer Tools if you don’t already have them:
$ git (Click Install) (Agree to license agreement)
Installing just the Developer Tools is faster than installing Xcode if you don’t have/need it.
• Visit this page in Safari:
• Click “Download Heroku Toolbelt for Mac OS X” and run the installer pkg file that it downloads.
• Install Homebrew:
$ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)" $ brew doctor
• Log in to Heroku:
$ heroku login (Enter Heroku email) (Enter Heroku password)
• Install postgresql:
$ brew install postgresql
• Install pg (postgresql) gem:
$ sudo ARCHFLAGS="-arch x86_64" gem install pg
• Start postgresql:
$ postgres -D /usr/local/var/postgres &
• Install Bundler:
$ sudo gem install bundler
• Install Rails:
$ sudo gem install rails --no-ri --no-rdoc (When warned about conflicting rails executable, allow overwrite)
• Create a new postgresql-backed Rails app:
$ rails new myapp -d postgresql
• Create a barebones ‘welcome’ route in the app:
$ cd myapp $ rails generate controller welcome
• Create app/views/welcome/index.html/erb with the editor of your choice, and insert the following content:
<h2>Hello World</h2> <p> The time is now: <%= Time.now %> </p>
• Edit config/routes.rb and uncomment this line:
• Add this line to the end of Gemfile:
gem 'rails_12factor', group: :production
• Run Bundler to get the rails_12factor gem installed (required by Heroku):
$ bundle install
• Create a default database named after your username (a convenience for if you want to use a postgresql GUI like PG Commander later):
• Create dev and test databases for the Rails app:
$ createdb myapp_development $ createdb myapp_test
• Edit config/database.yml and change the “production” section at the bottom to read like this:
production: url: <%= ENV['DATABASE_URL'] %>
Delete the database, username, and password lines from this section. You can delete the line that begins with << too.
• At this point you should be able to run the app locally on the built-in server:
$ rails server (visit url http://localhost:3000/) (^C to stop the server)
• Create a git repo for the project:
$ git init $ git add . $ git commit -m "init"
• Create a Heroku app:
$ heroku create
Heroku will automatically assign your app a name consisting of a couple of words and a number.
• If you already have an SSH keypair, you can upload the public key through the Heroku dashboard, then, on your Mac, use ssh-add to make the private key available to ssh-agent.
If you don’t already have an SSH keypair, or would rather use a new one, let Heroku generate one:
$ heroku keys:add (it asks if you want to generate one, say yes)
• Push git repository to Heroku:
$ git push heroku master (if you get a warning that the authenticity of the host cannot be established, enter yes to continue)
• Confirm your app is now running on Heroku:
$ heroku open
At this point, Heroku is running the app on webrick, which is not suitable for production.
• To switch to the unicorn web server, add this line to the end of Gemfile:
$ bundle install
• Create config/unicorn.rb with the following content (watch out for word-wrapping on the blog here):
worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3) timeout 15 preload_app true before_fork do |server, worker| Signal.trap 'TERM' do puts 'Unicorn master intercepting TERM and sending myself QUIT instead' Process.kill 'QUIT', Process.pid end defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect! end after_fork do |server, worker| Signal.trap 'TERM' do puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT' end defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection end
• Inform Heroku that you wish to use unicorn by creating a file called Procfile with this content:
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
• To test with the unicorn server locally, install Foreman:
$ sudo gem install foreman (answer yes if it asks if you want to overwrite the existing executable)
• You can now start the unicorn web server with:
$ foreman start
Note that unicorn runs by default on port 5000 instead of webrick’s port 3000, so to test, visit http://localhost:5000/
• Stop unicorn with ^C.
• Commit changes to git repo:
$ git add . $ git commit -m "added unicorn"
• Deploy to Heroku again:
$ git push heroku master
• Verify that Heroku is still serving a working app:
$ heroku open
• If you’d like extra confirmation that the app is now running atop unicorn, the server log should show something that looks like unicorn output:
$ heroku logs
And it’s just THAT EASY. ;)
“Among the projects awarded for the period 2014-2017 is a Cornell University-led study managed by the US Air Force Office of Scientific Research which aims to develop an empirical model ‘of the dynamics of social movement mobilisation and contagions.’
Twitter posts and conversations will be examined ‘to identify individuals mobilised in a social contagion and when they become mobilised.’”
“… Facebook data scientists tweaked the algorithm that determines which posts appear on users’ news feeds—specifically, researchers skewed the number of positive or negative terms seen by randomly selected users. Facebook then analyzed the future postings of those users over the course of a week to see if people responded with increased positivity or negativity of their own, thus answering the question of whether emotional states can be transmitted across a social network. Result: They can!”
“Some things are too precious to last in this brutal world, and Washboard, a startup that mailed you quarters to do your laundry, is one of them. It is, against all odds and after only a week in business, shutting down.”
I know some of you already own my harsh indictment of the CSS box model in mug or t-shirt form:
Today I’m adding a brand new design to my Zazzle store, which I call “Reviewer’s Lament”:
Featuring the oft-heard existential refrain “I’d give it zero stars if I could” and a soothing rainbow, the new design is available on mugs, t-shirts, and posters. Please enjoy it, if you can.
“‘We can get any Yo user’s phone number (I actually texted the founder, and he called me back). We can spoof Yo’s from any users, and we can spam any user with as many Yo. We could also send any Yo user a push notification with any text we want (though we decided not to do that).’
on Vine, Yo was seen playing bursts of Rick Astley’s Never Gonna Give You Up.”
“‘We do have some users who don’t get it and think it’s a joke,’ Arbel admits. … He describes the perception of Yo as a joke as a “problem we need to solve.”