Monday, December 3, 2012
Saturday, September 22, 2012
Sunday, September 2, 2012
RVM cheat sheets
Source: http://cheat.errtheblog.com/s/rvm/
RVM home page: https://rvm.beginrescueend.com Install RVM ------------ See https://rvm.beginrescueend.com/rvm/install/ bash -s stable < <(curl -s \ https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer) Update RVM ---------- rvm get stable In case of problems try first with development version (maybe it's already fixed): rvm get head Very old installations might not support those update methods, just run the installer and reopen your terminal. List known rubies ----------------- rvm list known Install Ruby dependencies ------------------------- Follow instructions from: rvm requirements Install Ruby ------------ rvm install 1.9.3 # Latest known patch level rvm install 1.9.3 -j 3 # Parallel compile, set to # of CPU cores rvm install 1.9.3 --patch falcon # Use a patch (falcon for performance) rvm install 1.9.2-p318 # Patchlevel 318 rvm install rbx --1.9 # Rubinius with 1.9 mode set as default List all rubies and gemsets --------------------------- rvm list # List rubies only rvm list gemsets # List rubies and gemsets rvm gemset list # List gemsets for current ruby Selecting Ruby for work ----------------------- rvm system # For system ruby, with fallback to default rvm use jruby # For current session only rvm use --default 1.9.3 # For current and new sessions rvm use --ruby-version rbx # For current session and this project RVM will automatically use a ruby and gemset when you `cd` to a project directory. Read more on project files: - https://rvm.beginrescueend.com/workflow/projects/#ruby-versions Using ruby and gems ------------------- After selecting Ruby work as usual: ruby -v gem install haml haml Temporarily selecting another Ruby or gemset -------------------------------------------- rvm 1.8.7 do gem install rspec # in the given ruby rvm 1.8.7,1.9.2 do gem install haml # in this two rubies rvm @global do gem install gist # in @global gemset of current ruby Gemsets ------- RVM by default allows creating multiple environments for one ruby - called *gemsets*. Gemsets can be specified together with ruby name using gemsets separator(@): - ruby-1.9.3-p125@my-project During installation of Ruby, RVM creates two gemsets: - default - automatically selected when no @gemset specified: rvm use 1.9.3 - global - super gemset, inherited by all other gemsets for the given ruby Working with gemsets: rvm use 1.8.7 # use the ruby to manage gemsets for rvm gemset create project_name # create a gemset rvm gemset use project_name # use a gemset in this ruby rvm gemset list # list gemsets in this ruby rvm gemset delete project_name # delete a gemset rvm 1.9.1@other_project_name # use another ruby and gemset rvm 1.9.3@_project --create # use and create gemset if not existing Install RVM for all users -------------------------- Discouraged; make sure to read http://rvm.beginrescueend.com/rvm/installation/ More help ? ----------- A lot of resources is available: - in your terminal: `rvm help` - https://rvm.beginrescueend.com/ - IRC #rvm @ freenode - http://webchat.freenode.net/?channels=#rvm
Installing MongoDB with Homebrew
Installation of mysql and mongodb with brew sometimes could end with an access error, for example:
Error: Permission denied - /usr/local/var/log/mongodb
Actually, there is no proper decision yet, so the short term solution might be the following:
ls -al /usr/local/bin/brew #confirm brew ownership
Error: Permission denied - /usr/local/var/log/mongodb
Actually, there is no proper decision yet, so the short term solution might be the following:
ls -al /usr/local/bin/brew #confirm brew ownership
sudo chown root:wheel /usr/local/bin/brew
sudo brew install mongodb
sudo chown <your user>:<your group> /usr/local/bin/brew #revert ownership
Wednesday, August 1, 2012
Working with a git branches
Addition info could be found at:
http://evasive.ru/articles/git_kung-fu.html
http://git-scm.com/about
http://www.gitguys.com
http://gitref.org
First, clone a remote git repository and cd into it:
$ git clone git://example.com/myproject
$ cd myproject
Next, look at the local branches in your repository:
$ git branch
* master
But there are other branches hiding in your repository! You can see these using the `-a` flag:
$ git branch -a
* master
origin/HEAD
origin/master
origin/v1.0-stable
origin/experimental
If you just want to take a quick peek at an upstream branch, you can check it out directly:
$ git checkout origin/experimental
But if you want to work on that branch, you'll need to create a local tracking branch:
$ git checkout -b experimental origin/experimental
Now, if you look at your local branches, this is what you'll see:
$ git branch
master
* experimental
You can actually track more than one remote repository using `git remote`.
$ git remote add win32 git://example.com/users/joe/myproject-win32-port
$ git branch -a
* master
origin/HEAD
origin/master
origin/v1.0-stable
origin/experimental
win32/master
win32/new-widgets
At this point, things are getting pretty crazy, so run `gitk` to see what's going on:
$ gitk --all &
From here: http://stackoverflow.com/a/72156/267000
http://evasive.ru/articles/git_kung-fu.html
http://git-scm.com/about
http://www.gitguys.com
http://gitref.org
First, clone a remote git repository and cd into it:
$ git clone git://example.com/myproject
$ cd myproject
Next, look at the local branches in your repository:
$ git branch
* master
But there are other branches hiding in your repository! You can see these using the `-a` flag:
$ git branch -a
* master
origin/HEAD
origin/master
origin/v1.0-stable
origin/experimental
If you just want to take a quick peek at an upstream branch, you can check it out directly:
$ git checkout origin/experimental
But if you want to work on that branch, you'll need to create a local tracking branch:
$ git checkout -b experimental origin/experimental
Now, if you look at your local branches, this is what you'll see:
$ git branch
master
* experimental
You can actually track more than one remote repository using `git remote`.
$ git remote add win32 git://example.com/users/joe/myproject-win32-port
$ git branch -a
* master
origin/HEAD
origin/master
origin/v1.0-stable
origin/experimental
win32/master
win32/new-widgets
At this point, things are getting pretty crazy, so run `gitk` to see what's going on:
$ gitk --all &
From here: http://stackoverflow.com/a/72156/267000
Wednesday, July 25, 2012
Saturday, July 7, 2012
Getting started Spree
Full documentation can be found here:
http://railscasts.com/episodes/298-getting-started-with-spree
http://guides.spreecommerce.com/getting_started.html
https://github.com/spree/spree
This is an approximate way of spree installation.
Why 'approximate' - because docs may differ, and if installing with rails '3.2.3' causes no troubles, '3.2.6' version pulls with itself, in my case, an outdated versions of spree_core, _api and so on.
1. Create rails application
In case of errors try fiddling with
rails version '3.2.3', '3.2.6' and
spree versions: '1.1.1', '1.1.2' (actual for the current moment)
3. This will create spree application.
http://railscasts.com/episodes/298-getting-started-with-spree
http://guides.spreecommerce.com/getting_started.html
https://github.com/spree/spree
This is an approximate way of spree installation.
Why 'approximate' - because docs may differ, and if installing with rails '3.2.3' causes no troubles, '3.2.6' version pulls with itself, in my case, an outdated versions of spree_core, _api and so on.
1. Create rails application
rails new app
cd app
bundle install
2. In gemfile add gem 'spree', '1.1.1'bundle install
This will add spree to the gemfile snapshot.In case of errors try fiddling with
rails version '3.2.3', '3.2.6' and
spree versions: '1.1.1', '1.1.2' (actual for the current moment)
3. This will create spree application.
rails g spree:install
4. Runrake db:bootstrap
5. [optional] This will setup default scheme for the application.gem 'spree_blue_theme', :git => 'git://github.com/spree/spree_blue_theme.git'
If you want to use edge version, modify gemfile:
gem 'spree', :git => 'git://github.com/spree/spree.git'
Saturday, June 30, 2012
Nokogiri installation error in Rails
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/Users/user/.rvm/rubies/ruby-1.8.7-p352/bin/ruby extconf.rb
checking for libxml/parser.h... yes
checking for libxslt/xslt.h... yes
checking for libexslt/exslt.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... yes
checking for xmlParseDoc() in -lxml2... yes
checking for xsltParseStylesheetDoc() in -lxslt... yes
checking for exsltFuncRegister() in -lexslt... yes
checking for xmlHasFeature()... no-----
The function 'xmlHasFeature' is missing from your installation of libxml2. Likely this means that your installed version of libxml2 is old enough that nokogiri will not work well. To get around this problem, please upgrade your installation of libxml2.
This is fixed with the following:
brew install libxml2 libxslt
brew link libxml2 libxslt
gem install nokogiri
Tuesday, June 26, 2012
Dispatcher and SynchronizationContext classes in WPF
- Use the Dispatcher when your code is tightly coupled to WPF.
- Use the AsyncOperationManager when you need to queue something on the 'Context' thread. This works with Windows Forms, ASP .NET and WCF applications as well.
- Avoid using the SynchronizationContext yourself. The AsyncOperationManager uses this mechanism internally.
SynchronizationContext.Current object is of type DispatcherSynchronizationContext which is actually just a wrapper around the Dispatcher object and the Post and Send methods just delegate to Dispatcher.BeginInvoke and Dispatcher.Invoke.
So even if you decide to use SynchronizationContext I think you end up calling dispatcher behind the scenes.
Besides, supposedly, it is a bit cumbersome to use SynchronizationContext as you have to pass a reference to the current context to all threads that need to call into your UI.
Monday, June 25, 2012
Monday, June 11, 2012
Using form_tag in Ruby on Rails
In controller a "new" action creates a sample object that is just a simple object, not ActiveRecord :
def new
@item = Item.new
end
"Create" action is a post action
def create
end
And in the view the following code just displays Item object fields and posts back a hash with fields filled in on the client side:
This will create the following markup:
Relevant references:
http://guides.rubyonrails.org/form_helpers.html
http://www.tutorialspoint.com/ruby-on-rails/rails-html-forms.htm
http://www.saalonmuyo.com/2010/01/27/using-form_tag-in-ruby-on-rails
def new
@item = Item.new
end
"Create" action is a post action
def create
end
And in the view the following code just displays Item object fields and posts back a hash with fields filled in on the client side:
This will create the following markup:
Relevant references:
http://guides.rubyonrails.org/form_helpers.html
http://www.tutorialspoint.com/ruby-on-rails/rails-html-forms.htm
http://www.saalonmuyo.com/2010/01/27/using-form_tag-in-ruby-on-rails
Friday, May 25, 2012
OpenSSL Errors and Rails – Certificate Verify Failed – Gem::RemoteFetcher::FetchError
A comprehensive guide that encompasses some posts below and
different platforms to deal with this Ruby on Rails ssl error.
http://railsapps.github.com/openssl-certificate-verify-failed.html
different platforms to deal with this Ruby on Rails ssl error.
http://railsapps.github.com/openssl-certificate-verify-failed.html
Saturday, May 19, 2012
Updating OpenSSL on Mac OS 10.5.x
If you don't want to build OpenSSL from source and want an easy way of upgrading to the latest version of OpenSSL, I'd suggest taking the MacPorts route.
Download the correct .dmg file from http://www.macports.org/install.php.
Open it and run the installer.
In the terminal, type:
$ sudo port sync; sudo port selfupdate; sudo port install openssl
Older versions OpenSSL may require installing newer zlib, and zlib in it's turn may require installing XCode 3.1.4:
Here is the link to get XCode 3.1.4 somewhere at bottom of the page:
http://connect.apple.com/cgi-bin/WebObjects/MemberSite.woa/wo/5.1.17.2.1.3.3.1.0.1.1.0.3.1.3.3.1
http://matthew.mceachen.us/blog/download-xcode-3-1-4-for-leopard-716.html
Download the correct .dmg file from http://www.macports.org/install.php.
Open it and run the installer.
In the terminal, type:
$ sudo port sync; sudo port selfupdate; sudo port install openssl
Older versions OpenSSL may require installing newer zlib, and zlib in it's turn may require installing XCode 3.1.4:
Here is the link to get XCode 3.1.4 somewhere at bottom of the page:
http://connect.apple.com/cgi-bin/WebObjects/MemberSite.woa/wo/5.1.17.2.1.3.3.1.0.1.1.0.3.1.3.3.1
http://matthew.mceachen.us/blog/download-xcode-3-1-4-for-leopard-716.html
To build OpenSSL this link may be helpful (not tested):
Wednesday, May 16, 2012
Ruby SSL Certificate Verify Failed
http://jimneath.org/2011/10/19/ruby-ssl-certificate-verify-failed.html
http://www.macfreek.nl/memory/Install_CA_Certificates
http://martinottenwaelter.fr/2010/12/ruby19-and-the-ssl-error
http://stackoverflow.com/questions/4528101/ssl-connect-returned-1-errno-0-state-sslv3-read-server-certificate-b-certificat
http://www.macfreek.nl/memory/Install_CA_Certificates
http://martinottenwaelter.fr/2010/12/ruby19-and-the-ssl-error
http://stackoverflow.com/questions/4528101/ssl-connect-returned-1-errno-0-state-sslv3-read-server-certificate-b-certificat
Saturday, May 5, 2012
Rails ExecJS::RuntimeError
(With the help of www.railszilla.com)
If you’re riding Ruby on Rails V3.11 and get the error
Then try installing the V8 Javascript interpreter into Ruby.
Just edit your Gemfile and add
then execute the famous
This has also several advantages, such like:
If you’re riding Ruby on Rails V3.11 and get the error
get rails ExecJS::RintimeError
Then try installing the V8 Javascript interpreter into Ruby.
Just edit your Gemfile and add
gem 'therubyracer'
then execute the famous
bundle install
This has also several advantages, such like:
- Evaluate Javascript from with in Ruby
- Embed your Ruby objects into the Javascript world
- Manipulate JavaScript objects and call JavaScript functions from Ruby
- API compatible with the The Ruby Rhino
Friday, May 4, 2012
Rails 3.1 and Ruby 1.9.3p125: ruby-debug19 crashes with “Symbol not found: _ruby_threadptr_data_type”
download linecache19 and ruby-debug-base19 from RubyForge:
% curl -OL http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem
% curl -OL http://rubyforge.org/frs/download.php/75415/ruby-debug-base19-0.11.26.gem
compile the two gems
% gem install linecache19-0.5.13.gem
Building native extensions. This could take a while...
Successfully installed linecache19-0.5.13
1 gem installed...
% gem install ruby-debug-base19-0.11.26.gem -- --with-ruby-include=$SANDBOX/packages/ruby-1.9.3-p0Building native extensions. This could take a while...
Successfully installed ruby-debug-base19-0.11.26
1 gem installed...
update your Gemfile
# file: Gemfile
...
group :development do
gem 'linecache19', '0.5.13'
gem 'ruby-debug-base19', '0.11.26'
gem 'ruby-debug19', :require => 'ruby-debug'
end
bundle install and test the debugger
% bundle installFetching source index for http://rubygems.org/
...
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
% irb
irb(main):001:0> require 'ruby-debug'
=> true
irb(main):002:0> debugger
$SANDBOX/usr/lib/ruby/1.9.1/irb/context.rb:166
@last_value = value(rdb:1) p 'hooray'
"hooray"
Ruby-debug fork:
https://github.com/cldwalker/debugger
Discussions:
http://stackoverflow.com/questions/9122232/how-do-i-install-ruby-debug-in-ruby-1-9-3-rails-3-2-1
http://blog.wyeworks.com/2011/11/1/ruby-1-9-3-and-ruby-debug
http://dirk.net/2010/04/17/ruby-debug-with-ruby-19x-and-rails-3-on-rvm
http://stackoverflow.com/questions/7054948/ruby-debug19-on-ruby-1-9-3-preview1
Subscribe to:
Posts (Atom)
Powered by Blogger.