Deploy Rails+Unicorn+Nginx+God using Mina -
No Cap, go Mina!
Some like TDD, others prefer BDD, I prefer BMDD. Black Magic Driven Development that is. — leprosorium.ru
In case you’ve hit OpenSSL::SSL::SSLError or SSL_set_tlsext_host_name error, and you have installed PostgreSQL using official installer - please, read on.
It seems that official PostgreSQL installer somehow modifies openssl and gems that was built upon it.
You should try to remove your PG installation completely (you may want to backup your pg data directory first, usually it’s ‘/Library/PostgreSQL/<version>/data’), and then re-install postgres using Homebrew. It helped in my case.
And, if you backed up your data directory, do the following:
sudo chmod -R <your_username> <backup_path>
Now you can run your PG server with all your data intact:
postgres -D <backup_path>
Full script for the lazy (it may not be fully working tho, I don’t remember it completely, so use at your own risk and check every step):
sudo chmod -R <your_username> /Library/PostgreSQL/<version>/data cp /Library/PostgreSQL/<version>/data /usr/local/var/postgres open /Library/PostgreSQL/9.0/uninstall-postgresql.app ...perform uninstall... brew install postgresql # for the install of the latest version. See "man brew" for versions info createuser ...create postgres user or superuser... postgres -D /usr/local/var/postgres/data
…well, something like that. It should be working now. Good luck!
Have you often seen this?
~/project$ rspec spec/controllers/some_controller.rb ....... Finished in 1.01159 seconds 7 examples, 0 failures
Is that supposed to be less than a second? You wish! Actually, your tests will run 20+ seconds or so: launching an instance and preparing stuff for testing is quite time consuming.
But what if you want to now exactly how long your tests run? The simplest and quickest solution is to add the following line to your ~/.profile:
alias rake="time rake"
Your tests will now output something like this:
~/project$ rspec spec/controllers/some_controller.rb ....... Finished in 1.01159 seconds 7 examples, 0 failures real 0m28.330s user 0m18.682s sys 0m1.886s
Not too pretty, but it does the job.
TL;DR: Nocturne, night mode, disable shadows.
Some time ago I’ve noticed that my screen on MacBook Pro starting to show a horizontal line across the whole screen, left to right, just above the dock. It’s like, if you leave a monitor turned on for a very long time with high-contrast wallpaper on desktop, image will be burned up on the screen and it will take weeks of white glow to get rid of it.
Reason for such a weird artifact was found shortly after. If you open 2+ windows on “full-screen”, stretched from menu bar to dock, they’ll be dropping very, very dark and strong shadow. And if you live with that on daily basis (on work I have a browser, code editor, and console stretched at max), and if you have a light wallpaper that contrasts with the shadow, you’ll have the same problem as I do: usually barely visible (but very annoying when watching movies) contrast dark bar at about 2 inches from the bottom edge of monitor, just above your dock.
There’s two solutions to this: 1. don’t use light wallpapers, instead try some dark ones, at least at bottom part of the screen; 2. Use Nocturne to disable shadows. It’s very easy to get on with it, really.
As I recently switched from Passenger to Pow to serve all my local Rails, Sinatra and Rack projects in development, it became obvious that I need a command to restart ALL Pow instances at once. And instead of doing "touch tmp/restart.txt" every time in project root, I’ve ended up with this simple bash alias:
alias reall='touch ~/.pow/restart.txt; echo "Touch."'
Hope you’ll find it usefull.
I’ve always wanted to be able to do something like:
my_hash = {} my_hash["Cloud"]["Stats"]["Strength"] = 100 p my_hash # => {"Cloud"=>{"Stats"=>{"Strength"=>100}}}So I whipped up the code below and now I can! Metaprogramming wins again!
class SuperHash < Hash def initialize super { |h, k| h[k] = SuperHash.new } end end sh = SuperHash.new sh["foo"]["bar"]["baz"] = "wtf" pp shAll this does is set the default value for the SuperHash to a new instance of SuperHash. Very…very cool.
(Source: ryanscottlewis)
Ever wanted to know, where exactly in code a method was defined?
>> String.new.method(:underscore).source_location => ["/path/to/gems/activesupport-3.0.3/lib/active_support/core_ext/string/inflections.rb", 82]
TL;DR: writes.count > reads.count ? InnoDB : MyISAM;
There’s a lot of articles all over teh internetz about comparing InnoDB vs MyISAM, but this note is rather like ‘note to self’. TL;DR says it all.
Decision QA, I’ve found here:
InnoDB if:
MyISAM if: