Subheader

Lazy Programmer's Blog

Pages

Showing posts with label ruby. Show all posts
Showing posts with label ruby. Show all posts

Friday, December 29, 2017

Error installing ruby 2.1.1 on ubuntu 17.04

Installing ruby binary package via RVM you can get an error message that RVM is not able to find ruby binary distributive, for example:
rvm install ruby-2.1.1

Searching for binary rubies, this might take some time. No binary rubies available for: ubuntu/17.04/x86_64/ruby-2.1.1. Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies. Checking requirements for ubuntu. Installing requirements for ubuntu. Updating system.......There has been an error while updating your system using `apt-get`. .....It seems that there are some 404 Not Found errors for repositories listed in: /etc/apt/sources.list /etc/apt/sources.list.d/*.list Make sure that all repositories are available from your system and verify your setup by running manually: sudo apt-get update Make sure that it works correctly before proceeding with RVM. If you are working from the GUI instead of the terminal, you might want to verify and fix broken repositories using "Software & Updates" application. . Error running 'requirements_debian_update_system ruby-2.1.1', please read /home/home-pc/.rvm/log/1514552025_ruby-2.1.1/update_system.log Requirements installation failed with status: 100.

Solution:

Get the latest version of RVM:
rvm get head

Reload the RVM:
rvm reload

Install ruby:
rvm install ruby-2.1.1

Friday, May 6, 2016

How to install just PostgreSQL client tools on Windows and use it in rails application

Since in latest installers for PostgreSQL support for custom components is removed, installer will install both client tools and PostgreSQL server.

Solution:

Step 1. Install ruby
I like RubyInstaller

Step 2. Install rails
I like RailsInstaller

Step 3. Download PostgreSQL binary package
http://www.enterprisedb.com/products-services-training/pgbindownload
Lets copy files into
C:\Program Files\PostgreSQL

Step 4. Install gem pg
gem install pg -- --with-pg-config="C:\Program Files\PostgreSQL\9.1\bin"
Now we can use PostgreSQL client tools in rails application

Saturday, March 26, 2016

How to get character's unicode value in Ruby

The solution is to use .ord.to_s(16)

Examples:
'♥'.ord.to_s(16) = 2665
'$'.ord.to_s(16) = 24
'€'.ord.to_s(16) = 20ac
'a'.ord.to_s(16) = 61

Getting unicode value of string:
'my string'.each_char.map{|c| c.ord.to_s(16)}.join