Tuesday, April 23, 2013

Curb gem Installation problems on Ubuntu


Install the follows libs

sudo apt-get install libcurl4-gnutls-dev libcurl4-openssl-dev

curb gem compiles natively using system libs and it requires curl headers to complile with is not installed by default.

Install the libs and run 

gem install curb

It should install smoothly.. \m/ 

Friday, March 8, 2013

Best way to use Modem Data Card (EVDO) in Ubuntu 12:04/12:10/ Linux Mint 14

Best way to use Modem Cdma Data Card (EVDO) in Ubuntu 12:04/12:10/ Linux Mint 14 

Hi Folks,

I have been struggling using data card in Ubuntu always  and in mint a bit.

I lot of us have been having issue connecting data card as mobile broadband in latest ubuntu versions especially 12:04 and later.

A very Simple trick can save you lots and lots of time and frustration . ( I know what it means as I had face it for around 6 months now)

I have tried this step in Linux Mint/ Ubuntu 12:04 and 12:10 worked for me on all of then.

Steps to Follow

  1. Connect your data card 
  2. Open terminal 
  3. and run this commands
    • nm-online
    • nm-tool
  4. check the output of nm-tool it should show an entry of mobile broadband or data card connected.
  5. (If data card detection does not show in the nm-tool output install apt-get install wvdial and start the process from step 3).
  6. Click on the network manager icon in the tray it should now show mobile broadband in the list with the detected modem 
  7. Click on the modem and configure it if not done it (Configuration should be pretty straight forward and easy mainly selection)
  8. Now the detection of modem should also word after reboot.
  9. Follow the above steps again if it stops detecting the devise on reboot.
  10. If it still does not work wvdial config is your friend google it lots of references availabe
This is the trick I discovered accidently while playing around with all diff ppp connection libs available in linux from gnome-ppp , kppp , ixconn to vanila wvdail script.

I don't know what exactly it does bit I think this trick just sets some flag to let OS discover the devise automatically.

NOTE: Haven't tried with Gsm modems but strongly feel this should work for them too.


Tried

Friday, January 4, 2013

truncate and link text helper in rails


snippet to truncate text and link to see more

Code this in application helper.

  def truncate_and_link( text,options ={})
    length = options[:length]
    return text if length.blank?
    url = options[:url] || '#'
    output = raw truncate(text, :length => length)
    output += link_to('more', url) if text.size > length
    output.html_safe
  end

Useful when eg linking big posts

Saturday, December 29, 2012

rails 3.2 with jruby and mysql with rvm in ubuntu


If was trying to migrate one of the app from ruby to jrby to try out the threading benifits.

this wasn't an easy task :D

well the gem dependency did not create a big issue.

the problem came when connecting to mysql with jdbc driver
I had replaced

 gem 'mysql2'
with

 gem 'activerecord-jdbcmysql-adapter'

in Gemfile


But it refused to load the driver saying :

"The driver encountered an unknown error: cannot load Java class com.mysql.jdbc.Driver'

I searched but Google could not answer me :(

then I started looking into activerecord-jdbsmysl-adapter gem and came upon the the file 

activerecord-jdbc-adapter / activerecord-jdbcmysql-adapter / lib / active_record / connection_adapters /jdbcmysql_adapter.rb 

I just copy pasted the code in a application.rb config with a condition if jruby used just after the bundler code


if defined?(JRUBY_VERSION)
  require 'jdbc/mysql'
  Jdbc::MySQL.load_driver(:require) if Jdbc::MySQL.respond_to?(:load_driver)
end

and boom it worked...!!!

I don't know why it did not load it even if it was included in Gemfile.

but at last I was able to run the app wit jruby and rails. Woaaahhhh..

Monday, December 10, 2012

Send devise compatible forgot password mail through action mailer in rails

To have multiple forgot password templates and send it through mailer in rails it is quite easy


Just


Cheers...!!




Wednesday, November 28, 2012

Using rvm in Kde Konsole

rvm (ruby version manager) needs a small change in konsole setting to make rvm use work

right click on the terminal and select 'edit current profile'

change the command from

/bin/bash

to

/bin/bash --login

Apply and boom you are ready to use rvm in terminal.