My BLOG on DIY, Hacking and notes
This includes mostly useful information for myself and my BLOG about various free time projects.
Which are currently mostly hardware and electronics hacks
.
Besides this I'm fully occupied with programming the final parts of MPL, extending my software generation tools such as the precompiler. And finishing my PhD thesis text which is about Creating the integrated programming environment Multi Precision Lab using source code generation tools.
First time visitors, people with comments or questions are welcome to sign my guestbook . Some of my projects in my blog hit the masses like www.hackaday.com featuring binary clock and makezine featuring my Wii-remote hack resulting in 10000 new visitors on the day they appeared in my blog. Cya and have a nice day
.
rake test fails on any_instance? try installing mocha
Written by Walter on 20/01/2010 05:07:57.Today found this silly bug (later turned out a dependency probably).
I did just some nifty_scaffolds and then rake db:migrate and then rake test.
Boink I get errors like this:
1) Error:
test_create_invalid(BedrijfsControllerTest):
NoMethodError: undefined method `any_instance' for #
/test/functional/bedrijfs_controller_test.rb:20:in `test_create_invalid'
The weird part was that it did not give the errors on the first controller but only on the subsequent ones.
After some googling tried the solution someone else used.
Which is just:
sudo gem install mocha
Voila and errors are gone
.
What worries me is that shouldn't mocha be a dependency of nifty_generator?
Was using Rails 2.3.5
VIM as TextMate replacement continued
Written by VIM as textmate continued on 12/01/2010 05:31:41.Summarized do following, install vim with apt-get or download package for os x and then download this:
wget http://walter.schreppers.com/files/vim_settings.tar.gz
Extract it in your homedir :
tar -xzvf vim_settings.tar.gz
Optionally add following lines to .bashrc (or .profile on OS X):
alias mate='vim -c NERDTree'
alias edit='vim -c start'
export RAILS_DEFAULT_DATABASE=mysql
Standard vim stuff to remember:
Select view block by using CTRL-V, then use I (capital) for special insert mode. Start typing and then when you hit ESC. Text is added to all the lines select by block. Also you can use ESC+< or ESC+> to move indentation of entire block.
Quick switching is done with ESC+Rview
For instance %s/oldword/newword/gc is basically the same as doing ctrl-k f oldword, r, newword. But typing that whole sentence %s... is more tedious. Although I'm sure shortcuts can be created by editing .vimrc.
Exra shortcuts provided (was hard to find free ctrl combos cause almost all is used by vim):
Press ctrl-b : activate NERDTree
Press ctrl-l : switch between browse and file (switch split window shortcut for ctrl-w w)
Press ctrl-d : saves file (shortcut for esc :wq)
Press ctrl-c : quits (shortcut for esc :qa)
Clearance gem and VIM replaces TextMate!
Written by Walter on 10/01/2010 16:08:37.Today found out about the clearance gem. Up to now I was using login sugar but this seems much better/up to date like using formtastic views etc.
And this just made me laugh so much I had to post it, it's Bert And Ernie the MC's
:
I've also switched from textmate to vim (vim works both on my debian server and os x). And it's free and basically after doing a vim tutorial and installing some plugin's it rocks even better than textmate
. Thanks to Adam Lowe for the following tips:
Install MacVim or Gvim (For Debian based distros install with apt-get). I do frequently use terminal Vim or Vi but I like having both available. If you're on Windows you probably want to spin up a Linux box or a VM. Ruby on Rails development on Windows is going to painful.
Let's Get Plugged In
Download pathogen.vim it makes managing Vim plugins a lot simpler. Create a ~/.vim/autoload/ directory and copy pathogen.vim into it.
$ mkdir ~/.vimNext you need to create and edit your .vimrc file so that pathogen gets loaded in the correct order.
$ mkdir ~/.vim/autoload
$ cp ~/Downloads/pathogen.vim ~/.vim/autoload/
$ mvim ~/.vimrcContent:
call pathogen#runtime_prepend_subdirectories(expand('~/.vimbundles'))Create a .gvimrc to specify colorscheme
set tabstop=2
set smarttab
set shiftwidth=2
set autoindent
set expandtab
$ mvim ~/.gvimrcContent:
colorscheme vividchalkCreate a ~/.vimbundles directory and install plugins. I prefer to clone them from github.com when I can. Some plugins still need to be downloaded from vim.org, extracted and copied to your .vimbundles directory. Either way go vote up plugins you find useful on vim.org. If you don't have git installed check out git-scm.com
$ mkdir ~/.vimbundlesInstall rails.vim
$ cd ~/.vimbundles
$ git clone git://github.com/tpope/vim-rails.gitInstall cucumber.vim
$ git clone git://github.com/tpope/vim-cucumber.gitInstall vividchalk.vim
$ git clone git://github.com/tpope/vim-vividchalk.gitInstall haml.vim (There are two. I use Tim Pope's.)
$ git clone git://github.com/tpope/vim-haml.gitInstall endwise.vim
$ git clone git://github.com/tpope/vim-endwise.gitInstall surround.vim
$ git clone git://github.com/tpope/vim-surround.gitInstall unimpaired.vim
$ git clone git://github.com/tpope/vim-unimpaired.gitInstall abolish.vim
$ git clone git://github.com/tpope/vim-abolish.gitInstall repeat.vim
$ git clone git://github.com/tpope/vim-repeat.gitInstall NERD_tree.vim
$ git clone git://github.com/scrooloose/nerdtree.gitInstall NERD_commenter.vim
$ git clone git://github.com/scrooloose/nerdcommenter.gitRestart Vim and you now have a super powerful Rails editor at your fingertips.
First my .vimrc looked like this:
call pathogen#runtime_prepend_subdirectories(expand('~/.vimbundles'))
set background=dark
colorscheme railscasts
syntax on
set tabstop=2
set smarttab
set shiftwidth=2
set autoindent
set expandtab
autocmd VimEnter * NERDTree
autocmd VimEnter * wincmd p
This loads pathogen, uses railscasts colors and finally auto-loads NERDTree and switches to the right slice (wincmd p, or ctrl-w w works too).
Problem is not always we want vim to look like textmate.
So instead I left out the last two lines in .vimrc and made the following alias
in .bashrc:
alias mate='vim -c NERDTree'
Now when I go to a rails project and enter 'mate' I see something like this:
Quick reminder: cmd+shift+3 takes screenshot in os x
.
To close and save all, I use
It does autocompletion, has quick switching between MVC by doing :Rmodel, :Rview, etc. Has rake tasks etc. built right in. Basically it is as good (maybe better?) as textmate but then open-source/cross-platform
. Hooray!
Have to admit it does take some time to get used to all those vim shortcuts but I found it was time to dump my good ol' joe and finally go the vim way
Here is my sweet vim setup:
vim_settings.tar.gz