Archive Page 2

09
Jun
12

emacs 24 ubuntu


sudo add-apt-repository ppa:cassou/emacs

sudo apt-get remove `apt-cache search emacs | awk '{print $1}'` --purge

sudo apt-get -f install # don't list packages here

sudo apt-get remove emacs-snapshot --purge

sudo apt-get autoclean

sudo apt-get autoremove

sudo apt-get update

sudo apt-get install emacs-snapshot

Information found: here

09
Jun
12

ruby, rvm and ubuntu

Here’s how to get a working installation of rvm on ubuntu:


sudo apt-get install curl git-core

sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion libcurl4-gnutls-dev postgresql postgresql-contrib libpq-dev

curl -L get.rvm.io | bash -s stable --ruby

Next, add a user to postgresql:


sudo -u postgres createuser --superuser john
sudo -u postgres psql postgres
\password john
\q

And add this to your .bashrc:


[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm
30
May
12

rails translating attribute names

I found the answer to my question from here.
Here’s the way:


  activerecord:
    attributes:
      user:
        first_name: "Name first"

22
May
12

making sure your integration tests view the actual data in the db


Monkeypatch ActiveRecord with this:


class ActiveRecord::Base
  mattr_accessor :shared_connection
  @@shared_connection = nil

  def self.connection
    @@shared_connection || retrieve_connection
  end
end

and your spec_helper with this:


RSpec.configure do |config|
  config.use_transactional_fixtures = false

  config.before :each do
    if Capybara.current_driver == :rack_test
      DatabaseCleaner.strategy = :transaction
    else
      DatabaseCleaner.strategy = :truncation
    end
    DatabaseCleaner.start
  end

  config.after do
    DatabaseCleaner.clean
  end
end

Full info available on Nicholas Rutherford’s blog. Thanks Nicholas!

22
May
12

rails select only some columns


If you want to only select a few columns on a query, here’s how you can do it:

 YourModel.find(:all,:select => "column1,column2") 

09
May
12

adding coffeescript support to sublime text 2 in ubuntu

Download Sublime, and start it one time, so that it creates the ~/.config/sublime-text-2 folder. chdir to ~/.config/sublime-text-2/Installed Packages and run:

git clone git://github.com/jashkenas/coffee-script-tmbundle CoffeeScriptBundle.tmbundle

Restart sublime, and now coffeescript syntax highlighting will work.

23
Apr
12

access the database of a heroku application from another heroku application


First thing you have to do is find out the DATABASE_URL of the app you’re interested in. Run heroku config –app your_app to get it. Then, in the other app, run this:

heroku config:add DATABASE_URL=whatever_the_result_of_the_first_command_was

Establish an ActiveRecord connection:


  db = URI.parse(ENV['DATABASE_URL'] || 'postgres://localhost/mydb')

  ActiveRecord::Base.establish_connection(
              :adapter  => db.scheme == 'postgres' ? 'postgresql' : db.scheme,
              :host     => db.host,
              :username => db.user,
              :password => db.password,
              :database => db.path[1..-1],
              :encoding => 'utf8'
   )




Blog Stats

  • 215,219 hits