Saturday, December 17, 2011

Issue: Installing ree ruby via rvm in ubuntu 11.10

So if you have tried installing REE on Ubuntu 11.10 something like
praveen@praveen-laptop:~$ rvm install ree
Installing Ruby Enterprise Edition from source to: /home/praveen/.rvm/rubies/ree-1.8.7-2011.03
ree-1.8.7-2011.03 - #fetching (ruby-enterprise-1.8.7-2011.03)
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 184 100 184 0 0 107 0 0:00:01 0:00:01 --:--:-- 567
100 7713k 100 7713k 0 0 32397 0 0:04:03 0:04:03 --:--:-- 33764
ree-1.8.7-2011.03 - #extracting ruby-enterprise-1.8.7-2011.03 to /home/praveen/.rvm/src/ree-1.8.7-2011.03
Applying patch 'tcmalloc' (located at /home/praveen/.rvm/patches/ree/1.8.7/tcmalloc.patch)
Applying patch 'stdout-rouge-fix' (located at /home/praveen/.rvm/patches/ree/1.8.7/stdout-rouge-fix.patch)
Applying patch 'no_sslv2' (located at /home/praveen/.rvm/patches/ree/1.8.7/no_sslv2.diff)
ree-1.8.7-2011.03 - #installing
ERROR: Error running './installer -a /home/praveen/.rvm/rubies/ree-1.8.7-2011.03 --dont-install-useful-gems ', please read /home/praveen/.rvm/log/ree-1.8.7-2011.03/install.log
ERROR: There has been an error while trying to run the ree installer. Halting the installation.

and now that you will follow the log you will notice some dependencies not met and hence installation failed, some thing like this.
Checking for required software...
* C compiler... found at /usr/bin/gcc
* C++ compiler... found at /usr/bin/g++
* The 'make' tool... found at /usr/bin/make
* The 'patch' tool... found at /usr/bin/patch
* Zlib development headers... not found
* OpenSSL development headers... not found
* GNU Readline development headers... not found
but as per suggestion
* To install GNU Readline development headers:
Please run apt-get install libreadline5-dev as root.
Package libreadline5-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source.
So instead install libreadline-gplv2-dev
* To install GNU Readline development headers:
Please run apt-get install libreadline-gplv2-dev as root.
And you are good to go :)

These information are not tough to find but summarizing it just in case some body is in need of it in a quicky!

Thursday, November 17, 2011

What the hell! Can't serialize a Mysql object with Marshal in Ruby

Okey so got this strange information late in night at about 3.50am and it took more than 2 hrs for me to surrender. uff :D
and this is something that came in picture
`dump': no marshal_dump is defined for class Mysql (TypeError

and this is a small code snippet which will give you this situation
require "rubygems"
require "mysql"

class RandomClass
def initialize
@db_instance = Mysql.real_connect("hostname", "username", "password", "database_name")
end
end

random_class = RandomClass.new
a = Marshal.dump(random_class)

and there you are, so one can't serialize a object with MySql object in it and with the set of finding i can even say that serializing even with yaml is also not possible.

So work around to this that i can suggest is to do a close of live mysql object in the method itself so that at any give time when object will be passed to serialization using Marshal.dump there would be no live MySql object to hinder with serialization :)

try this piece of snippet now

require "rubygems"
require "mysql"

class RandomClass
def initialize
db_instance = Mysql.real_connect("hostname", "username", "password", "database_name")
db_instance.close
end
end

random_class = RandomClass.new
a = Marshal.dump(random_class)


And this should work :)

Tuesday, August 9, 2011

How to create .rvmrc file

rvm --create --rvmrc ruby-1.8.7-p352@gemset


Execute above command from the rails directory with obviously correct ruby version and gemset :) and enjoy

Thursday, June 2, 2011

How to enable Mongrel instead of Webrick for Rails3 app

To enable mongrel instead of Webrick for Rails3 application add following lines in Gemfile of the app
#Use mongrel as the web server
gem 'mongrel', '>= 1.2.0.pre2'
and do a bundle install and then of you start the server.. mongrel would be booting instead of Webrick

Monday, May 16, 2011

Revert back to Default look n feel of Ubuntu 11.04

Well guys i am back again.. and this time it is pretty fast :).
I downloaded Ubuntu 11.04 and after installation complete also tried installing desktop effects available (and runs fabulously good) in previous version of Ubuntu. And this time to using synaptic manager the installation was a breeze but the effect was something else :D

In 11.04 there is common menu-bar and then there is vertical side bar looks more like windows 7(but vertically placed) so i don;t know(if i am able to run those eff3cts successfully) how will they react with UI... well that is a future thought.

But the current situation was my fresh install of Ubuntu 11.04 was messed up and now i was not able to view the menu-bar and there is no bar from where i can try to fix it.. run dialog box was also not coming in picture on press of Alt + F2.

And the last resort was to again redo the install(which was expensive in terms of time consumed) so what to do. This is what i did and it worked for me.. hope it works for you too (if you ever get dirty with effects on Ubuntu)

Step 01: Right click on desktop and click on "Create a launcher"(because i was only able to see the desktop.. a blank desktop!!)
Step 02: Provide name as "Terminal" and command as "gnome-terminal" and click on OK.
Step 03: Now double click the newly created launcher to open up a console terminal(with no head bar and no menu bar)
Step 04: Issue following two commands one by one.
gconftool --recursive-unset /apps/compiz-1
gconftool --recursive-unset /apps/compizconfig-1


Wait for some time and you will get native UI back on Ubuntu 11.04 (if not try log-out and log-in back) :)
Well my thoughts stopped working when i lost the panels and menu-bar of 11.04 and this thing came first in my mind and it worked (for me). If there is/are any thing much better than this(which i am obviously unaware of) please provide that too in comment.. it may help somebody.

Till that time chaow!

Wednesday, May 11, 2011

"Error establishing a database connection" from wordpress even when db credentials are correct

Yes i got hit by this just today!!

Let me tell you guys one thing i am not that much into Wordpress for any reason. But one of my blog is on Wordpress and obviously i am not the person who manages it but i do look into technical stuff if it goes out of hand(of my buddy)

Encountered a strange problem where in an existing install of Wordpress(which is about 1 year old) showed a message "Error establishing a database connection" in complete page, all of a sudden. wooohhhh!!!

and then i tried looking out for any changes in wp-config.php(which stores db credentials) but they all were fine. I crossed checked it by manually connecting to the db with credentials provided from console and yes i was able to connect to but Wordpress was telling me that it didn't.

I thought lets take a backup of the existing database and then try to debug it (so that in case i loose some data during this play i am in a position to recover too) but there was something waiting for me.... ufff!!!!

mysqldump -u some_user -psome_password xxxxxxxxx_blog > xxxxxxxxx_blog.dump.sql

and i got this in response
mysqldump: Got error: 145: Table './xxxxxxxxx_blog/xxxxxxxxxblog_options' is marked as crashed and should be repaired when using LOCK TABLES

so due to some activity we have blog's options table all messed up... so what to do!!

Answer is go to /var/lib/mysql/
and run myisamchk on the tables mentioned that should fix it.

something like..
sudo myisamchk -r ./xxxxxxxxx_blog/xxxxxxxxxblog_options

with output:
- recovering (with sort) MyISAM-table './xxxxxxxxx_blog/xxxxxxxxxblog_options'
Data records: 210
- Fixing index 1
- Fixing index 2
Data records: 208

and whola!!! my blog is back :D

Hope this must have helped you in anyway or the other.... will be back soon with more life like post.. these computer tech blogs.. uff uff!!

Wednesday, February 9, 2011

How to install ruby 1.9 and rails with RVM

Just follow these steps
ruby -v
mkdir -p ~/.rvm/src/ && cd ~/.rvm/src && rm -rf ./rvm/ && git clone git://github.com/wayneeseguin/rvm.git && cd rvm && ./install
rvm install 1.9.1
rvm list
rvm 1.9.1
rvm 1.9.1 --default
rvm system
gem install tzinfo builder memcache-client rack rack-test rack-mount erubis mail text-format thor bundler i18n
gem install rails --pre
rails topscore
cd topscore
rails server
gem install sqlite3-ruby
rails generate scaffold game name:string
rake db:migrate

and you are done :)
taken from http://railscasts.com/episodes/200-rails-3-beta-and-rvm

Wednesday, February 2, 2011

How to make a remote call synchronous in Rails

new Ajax.Request('/controller/action?username=praveen', {asynchronous:false, evalScripts:true, parameters:'page_offset=' + page_offset + '&authenticity_token=' + encodeURIComponent('e060znd6JcrMCU6Bf4ZZnfyBac4tl1YXQ6HuEHZGY58=')});

What to do to get that "asynchronous:false" thing in your link_to_remote or any other helper function available in rails :)

I know its not a big thing and there is/are very few requirements to make an Ajax call synchronous but one might face this requirement sometimes, and the answers is
<%=remote_function(:url => {:controller => "controller", :action => "action", :username => "praveen"}, :type => :synchronous, :with => "'page_offset=' + page_offset") -%>

And you are done... so now till the time this thing is taking place, everything in browser will be waiting to complete the process first and then only proceed next.
Hope you stumble on me looking in for me.

Thursday, January 20, 2011

How to handle wrong car parking!

Hi

I am back but not with any thing on computer but for car commuters.
Have been putting up in Delhi for around i think 12 years now and it has been phenomenal and i love Delhi as it is but there are challenges to deal with everyday and rather than showing anger and swearing on it, it would be good if we try to resolve them in some what funny manner and i did :)

Well addressing to all those owning a car(vehicle) and thinking blank road is car parking area(in Delhi), just before leaving for office today i saw a parked Mahindra Scorpio consuming the rest of road which was half flooded with building materials (as a house construction is going on, common! in areas of Delhi).

But i need to get way so that can reach office i can't take my car from that 1.5 feet of space. Me and my mom tried looking in for that super talented person who has parked his/her car and was lost by now and even by so many queries from neighbourhood no one knew about it and now it was high time i should be doing something about it rather than shouting on air but my love towards cars didn't allowed me to break the car but how can i teach lesson to this person now.

So what i did is that 1 took two a4 blank sheets of paper and stick it with glue (like people paste movie posters) on drivers side of windshield and wrote.. "Hope next time your intelligence can use parking sense!! All the best"

and then i took my car from back road and believe me taking car from that place required 3 people to assist me to drag my car inch by inch(it was that narrow)

But later on came to know form my dad, that driver appeared after about 1hr and was shocked to see it. My mom, dad and even my sister was like all over him and he accepted his mistakes and it took about 20 mins to takes those two sheets out from his windscreen and i don't know whether text written, was even understood by the driver or not. and hopefully this will keep a guard on him next time doing a wrong parking..

So i dealt with it this way.. how about you?

Honda Civic & A/C problems.

Hello Friends, Got a post again on to Honda Civic (The good old favorite commuter of mine). This car has been doing great except for so...