minitest is a great testing library and factory_girl is a handy fixture replace library, especially when working with Rails.
It can get tedious to repeat FactoryGirl. for every invocation of build, create, etcetera. Here is a handy shortcut to help reduce your Carpal Tunnel pain:
123456789
# for Test::Unit assertion styleclassMiniTest::Rails::ActiveSupport::TestCaseincludeFactoryGirl::Syntax::Methodsend# for Spec expectation styleclassMiniTest::SpecincludeFactoryGirl::Syntax::Methodsend
Place this in a file such as test/support/factory_girl.rb.
This allows you to use the core set of syntax methods (build, build_stubbed, create, attributes_for, and their *_list counterparts) without having to call them on FactoryGirl directly:
1234567
describeAwesomedo# do thissubject{create(:awesome)}# don't do thissubject{FactoryGirl.create(:awesome)}end
The executable files for PostgreSQL are in a non-standard location, so you you’ll want to update your PATH to make things easier. Most likely, you’ll want to edit your ~/.bashrc or ~/.zshrc (or similar) profile, though you can set apply the changes for all users system-wide by editing /etc/profile.
Make sure you set the new path before/usr/bin to ensure that you are using the latest versions and not the default apple-supplied tools:
1
export PATH=/opt/local/lib/postgresql92/bin:$PATH
You can verify this works by running which psql and you should see /opt/local/lib/postgresql92/bin/psql as the output.
Create a New User
You will be setup with a postgres user by default, but it is good practice to create a different user account.
To make things easy, create a new database user to match your OS X username:
My colleague Kenny Johnston wrote a nice piece about Upgrading to Mountain Lion with an emphasis on using Homebrew. Here are the relevant steps using MacPorts:
XCode:
Update to the latest XCode 4.4 from the App Store
Install the Command Line Tools
Of course, since it is zero-day, there was an issue fetching the Command Line Tools from the server and I had to install manually from a .pkg file retrieved from the Apple Developer Portal. If you install the CLI tools package manually, you may need to run the following:
sudo xcodebuild -license
That is required to accept the license terms system-wide.
MacPorts
First, you’ll need to update the base MacPorts installation:
sudo port -v selfupdate
If you run in to a compilation error, you may need to edit the file /opt/local/etc/macports/macports.conf and set the developer_dir option to be empty:
sudo vim /opt/local/etc/macports/macports.conf
/opt/local/etc/macports/macports.conf
123
# Directory containing Xcode Tools (default is to ask xcode-select)#developer_dir /Developerdeveloper_dir
You should now be able to update any outdated ports (grab a beverage while you wait):
sudo port -vu upgrade outdated
GCC 4.2
Now install the apple-gcc42 port to replace the missing GCC 4.2 in Mountain Lion:
sudo port install -vu apple-gcc42
Once that has been installed, you will need to link it to the expected system location:
The Internet Defense League is a network of people and sites who use their massive combined reach to defend the open internet and make it better. Because it can sound the alarm quickly to millions of users, people are calling it “a bat-signal for the Internet”.
The Internet Defense League takes the tactic that killed SOPA & PIPA and turns it into a permanent force for defending the internet, and making it better. Think of it like the internet’s Emergency Broadcast System, or its bat signal!
The Internet Blackout was just the beginning. Together, our websites and personal networks can mobilize the planet to defend the internet from bad laws & monopolies. Are you in?
A client of mine was having a hard time remembering the project workflow to keep topic branches updated, so I put together this simple shell function as a workflow reference:
If you have updated Boost to version 1.50.0 via MacPorts, you may have encountered something like the following:
$ port installed | grep mongodb
mongodb @2.0.6_0 (active)
$ port installed | grep boost
boost @1.50.0_0 (active)
$ mongo
dyld: Symbol not found: __ZNK5boost15program_options16validation_error4whatEv
Referenced from: /opt/local/bin/mongo
Expected in: /opt/local/lib/libboost_program_options-mt.dylib
in /opt/local/bin/mongo
There are numerous reports on the MacPorts Trac with various ports that are affected. Here is the solution that worked for me:
$ cd /tmp
$ svn co -r 93341 'http://svn.macports.org/repository/macports/trunk/dports/devel/boost/'
A boost/files
A boost/files/patch-boost-foreach.diff
A boost/files/patch-thread_visibility.diff
A boost/files/patch-libs-mpi-build-Jamfile.v2.diff
A boost/files/patch-tools-build-v2-tools-python-2.jam.diff
A boost/files/patch-tools-build-v2-tools-python.jam.diff
A boost/files/patch-bootstrap.sh.diff
A boost/files/patch-tools_build_v2_engine_src_build.jam.diff
A boost/files/patch-libs-python-src-converter-builtin_converters.cpp
A boost/files/patch-tools_build_v2_engine_src_build.sh.diff
A boost/Portfile
Checked out revision 93341.
$ cd boost
$ sudo port install
---> Computing dependencies for boost
---> Fetching archive for boost
---> Attempting to fetch boost-1.49.0_0.darwin_10.x86_64.tbz2 from http://packages.macports.org/boost
---> Attempting to fetch boost-1.49.0_0.darwin_10.x86_64.tbz2.rmd160 from http://packages.macports.org/boost
---> Installing boost @1.49.0_0
---> Deactivating boost @1.50.0_0
---> Cleaning boost
---> Activating boost @1.49.0_0
---> Cleaning boost
$ sudo port activate boost @1.49.0_0
---> Computing dependencies for boost
---> Cleaning boost
A Rack application running on Heroku can improve performance by using different application servers with different performance characteristics.
Some good choices include Thin (evented I/O), Unicorn (multi-process) and Puma (multi-threaded).
The exact configuration settings will vary by application and how much memory each app takes. A default Rails app with a basic scaffold can easily support 4 unicorn workers or 4 puma threads. A small Sinatra app can support several times that number.
Here are the Procfile settings you can use for each: