Skip to content

Instantly share code, notes, and snippets.

View trivektor's full-sized avatar
🏠
Working from home

Tri Vuong trivektor

🏠
Working from home
View GitHub Profile
@trivektor
trivektor / gist:1106993
Created July 26, 2011 15:18
Use route helpers in model in Rails 3
Add
include Rails.application.routes.url_helpers
to model
@trivektor
trivektor / gist:1114674
Created July 29, 2011 20:32
Mysql 5.5 on Snow Leopard
Set up databases to run AS YOUR USER ACCOUNT with:
unset TMPDIR
mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
To set up base tables in another folder, or use a differnet user to run
mysqld, view the help for mysqld_install_db:
mysql_install_db --help
and view the MySQL documentation:
* http://dev.mysql.com/doc/refman/5.5/en/mysql-install-db.html
@trivektor
trivektor / gist:1126489
Created August 4, 2011 22:46
Set TextMate EDITOR environment variable
vi ~/.bash_profile
export EDITOR="mate"
source ~/.bash_profile
@trivektor
trivektor / gist:1143168
Created August 12, 2011 22:49
Restart apache on Mac OSX
sudo /usr/sbin/apachectl restart
@trivektor
trivektor / rspec-syntax-cheat-sheet.rb
Created September 9, 2011 06:02 — forked from dnagir/rspec-syntax-cheat-sheet.rb
RSpec 2 syntax cheat sheet by example
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
@trivektor
trivektor / gist:1227114
Created September 19, 2011 18:00
Fix do_mysql gem installation problem
sudo env ARCHFLAGS="-arch x86_64" gem install do_mysql -- --with-mysql-dir=/usr/local/mysql/
@trivektor
trivektor / gist:1236116
Created September 22, 2011 21:30
Switch to rails 2.3.5
rvm --default use 1.9.2 (or whatever you want your default ruby interpreter to be)
rvm gemset create rails-3.0.3
rvm use 1.9.2@arails-3.0.3 --default
gem install rails
@trivektor
trivektor / gist:1254997
Created September 30, 2011 21:16
Override ActiveRecord single table inheritance mechanism
# In case your legacy database has a 'type' column and you need to use Rails with it
# Add this to your model
def self.inheritance_column
nil
end
@trivektor
trivektor / validation.js
Created October 10, 2011 05:37 — forked from netzpirat/validation.js
Backbone Model Validation
_.extend(Backbone.Model.prototype, Backbone.Events, {
errors: [],
validate: function (attrs) {
//reset
this.errors = [];
var model = this;
@trivektor
trivektor / gist:1307861
Created October 23, 2011 20:35
HTTP status codes
# Copy from http://www.codyfauser.com/2008/7/4/rails-http-status-code-to-symbol-mapping
Status Code Status Message Symbol
1xx Informational
100 Continue :continue
101 Switching Protocols :switching_protocols
102 Processing :processing
2xx Success
200 OK :ok