SSL/OpenSSL issue with Ruby 1.9.3



After upgrading to Ruby 1.9.3x, I was totally unable to use SSL. Even i could not run ‘bundle install’ when i was using ‘https://rubygems.org’ as the source. It was showing a multi-page error messages starting with something like ‘segmentation fault’. For the time being, i’ve used ‘http’ rather than ‘https’ for the rubygems.org url. However, it did not solve other problems.

While googling about it, i found many suggestions and i’ve screwed my OS (Mac OSx) OpenSSL. However, i’ve found a simple solution. It was just two lines of command if you are, like me, using RVM to managing Rubies.

First of all, you need to install openssl package using rvm. So run

$ rvm pkg install openssl

It will install openssl in your rvm path usually .rvm/usr under your home (~) directory.

Now, you need to reinstall your current ruby version (you can also install a newer version if you want) mentioning the path of the OpenSSL.

$ rvm reinstall 1.9.3 --with-openssl-dir=$rvm_path/usr

If you want to install a new version, you should use ‘install’ rather than ‘reinstall’.

That should solve your problem. If not, my sympathy goes for you. Good luck googling!

Posted in Ruby on Rails | Tagged , , , , , , , , , , , , , , , , | Leave a comment

Rails scaffold, create .haml rather than .erb views



After being tired of refactoring .erb files to .haml I headed for a way to modify the rails generator that will create .haml view files rather than .erb view files.

After a while, I found what exactly I needed. ‘haml-rails’ is the name of the solution. This is how you do it.

Add the following line to your Gemfile:

gem 'haml-rails'

Then run the bundler (bundle install).

Now append the following lines in your application.rb file (at the end of Application class):

config.generators do |g|
   g.template_engine :haml
end

That’s it. Your new scaffolds will generate .haml files (and obviously haml syntaxes) for you.

This is much easier than Haml-scaffold.

Posted in Ruby on Rails | Tagged , , , , , , , , , , , , , | 2 Comments

Showing drop down list box for a field in RailsAdmin


RailsAdmin is really good if you want to create a out-of-the-box admin panel for your rails based application. It will generate a nice admin panel based on your models. Though, to me, it is not as intuitive as that of Django, it is very useful.

RailsAdmin can create several types of form fields like Text Fields, Text Area, Date Picker, Checkbox etc. based on your column’s type. However, sometime we may need to override it’s default behavior. For example, we may need to show a drop down list box for a field instead of text field.

Let’s assume we want to show a drop down list for status column of User model. So, open your user.rb from models directory and add the following method to the class definition.


def status_enum
   [['Active'],['Pending'],['Banned']]
end



Now you will see a list box for Status field when you go to Users section of Rails Admin. However,  if we can store different values in the database other than the strings shown in the list. Let’s modify our code to something like:
Continue reading

Posted in Ruby on Rails | Tagged , , , , , , , , , , , , , , , , | 1 Comment

jQuery Mobile: Part 3 – Modifying default ‘loading’ and ‘error loading page’ messages

In the second part of this series we have learned how to link pages. If you followed them, probably, you’ve also noticed that a ‘loading’ message while you are visiting pages back and forth. jQuery Mobile shows this while it loads the page behind the scene. Well, you may not see this in fast connection or during testing in your computer as it loaded too fast. Similarly, jQuery Mobile shows ‘error loading page’ when it fails to load any page.

In my application, I wanted to change these texts as I wanted them in Bangla.  We were seeing these because they are set by default in the framework. By modifying the default properties, we can change them to something we want.

To do so we will hook into jQuery Mobile’s ‘mobileinit’ event. This event (on document object) is triggered just on the moment jQuery Mobile is started to load. So, we will have to override these before loading jQuery Mobile library.

So far, we have loaded the library files in the following order:

Continue reading

Posted in jQuery Mobile | Tagged , , , , , , , , , , , , , , , , , | 1 Comment

jQuery Mobile: Part 2 – Making multiple pages and linking them

Hey fellas, in the first part of our jQuery Mobile journey we have learned how to make the first jQuery Mobile page. That was quite easy and fun. As we ain’t going to give those introductions again, I believe, its a good idea to have a look into the previous part.

In this part we will dig a bit more. We will see how can we make more than one pages and link to each other.

Continue reading

Posted in jQuery Mobile | Tagged , , , , , , , , , , , , , , , , , | 1 Comment

jQuery Mobile: Part 1 – Making your first mobile page

Happy days are coming soon as jQuery Mobile 1.0 is already in Beta 2 phase which is going to enter Beta 3 in, probably, next month and then to Release Candidates (RC). However, the current state of jQuery Mobile is very well qualified for playing. So, I wish to write some beginner level blog posts as I discover it. If you find any mistake, error and/or you have any suggestion, please feel free to notify me.

Today we will see how to create first page with jQuery Mobile 1.0 Beta 2. We will see other things in near future, may be :P .

Continue reading

Posted in jQuery Mobile | Tagged , , , , , , , , , , , | 12 Comments

Rooting Samsung Galaxy Pop (Mini) on Mac OSx and enabling Bangla (Bengali) support

Introduction
(you can skip this part if you are in hurry)

I was planning to root my galaxy pop for a quite long time. But it was delayed as I found all tutorials applicable for Windows. That means, I need a windows machine to root my device but I don’t have any working windows machine.

Yesterday, I planned to upgrade to Gingerbread from Froyo as some of the friends suggested claiming it improves the battery performance (honestly, so far after upgrade, I believe it really does). I read some tutorials and this also requires windows machine. So, I borrowed my brother’s laptop. After about 10 hours of efforts, I could successfully upgrade the ROM.

So, this morning, I planned to root the device and in office I tried SuperOneClick.exe with colleague’s windows machine but failed. Then I was searching Google to do so on my Mac OSx. After several tries, I could do it. Continue reading

Posted in Tutorial | Tagged , , , , , , , , , | 5 Comments

Just received amazonkindle!

Today I came to office a bit late. Immediately after coming I was informed that a parcel has arrived on my name. I was expecting a dummy camera lens as it is supposed to come. However, seeing the packet I was a bit suspicious. The dummy lens’s package would not be so small. After I opened it, I could not believe my eyes. It is amazonkindle! Yes, I ordered it on 15th May from www.aliexpress.com! But still unbelievable. Do you know why? Keep following.

In aliexpress, when a order is placed and payment is done the order status was ‘Shipment Required‘. The seller was supposed to ship it and mark it as ‘Shipped’ and provide me the tracking ID. However, till now I did not receive any tracking and the order status was ‘Shipment Required’ last night. Seeing the seller is delaying unnecessarily, I canceled the order and aliexpress.com refunded me the whole money within few minutes. I also gave negative feedback to the buyer for wasting my time.

So, I guess you now can understand why I am so surprised seeing it. The seller must be stupid! Why s/he did not update the status of the order?

Anyway, as still in office, I could not get much time to explore it. I will explore it at home. I wish the seller will contact me and I will arrange a way to pay him.

The benefit of aliexpress is that it does keeps the money in escrow until you confirm that the product is reached to you and it is upto your expectation. I first heard about aliexpress.com from a member of Projanmo Forum.

My version is Kindle 3 WiFi + 3G. Costs (including shipping) was US$191. Also I had to pay 1050 tk here as excise duty and other fees.

Posted in General | Tagged , , , , , , , , , , | 17 Comments

Get free SMS alert on your server down (or something else)!

Well, first thing first. This blog may be little bit immoral even if it is not illegal by the provider terms of service. So, if you read this or later sentences, the responsibilities are on you.

—————-

I am going to share an idea that I’ve personally used a bit ago (2009) in my previous office to monitor the server and get notified when any server/service is down. I wrote a small PHP application that would do the tasks. Though I planned that time to blog about it, apparently, I forgot about it. The steps of the idea is:

  • A php chunk checks server status
  • If it finds something unexpected (or may be expected; depends on your logic :) ) it creates an event in your google calendar which is due just 1-3 minutes from now
  • If your SMS alert is setup in Google Calender, Google will email you about the event.

Here I will not show how to write a PHP script to monitor server. I just told it as I applied this idea for same purpose. I guess you will get lots if you google it. However, the initial version that I developed just checked site’s homepage (using CURL) and if they were returning 200 response within a sensible time limit. If the response was not 200, it would create the event for me.

How to create Event?

It’s very simple. First of all download the following classes from phpclasses.org

Put them in your project path. Create a php file. Lets assume it is createevent.php. Now include the wrapper file in createevent.php.

Continue reading

Posted in PHP, Tutorial | Tagged , , , , , , , , , , , , , , , , , | 6 Comments

Is it right time to buy Apple’s product from Bangladesh?

It has been about 11 months that I’ve purchased Macbook Pro 13.3 inches. Though I am extremely happy with hardware design, I am that level of unhappy due to instability of the Mac OS. I can’t run it for more than 3 days as it either hangs or become too unstable to use! Many applications including Firefox 4 crashing frequently on it.

Again, in the first month of purchase, a silica ball as been penetrated into its sound port (3.5mm) and to date it is safely there. Why? Because Aloha iShoppe, from where I’ve purchased it, said they can’t open it as it will void the Apple’s warranty though they are authorized dealer of Apple’s product! If I need to claim warranty, they would send the laptop to Singapore and it will take about 2 months to get back the laptop. Can you imagine?

Moreover from last week, power adapter for my macbook pro is dead. This morning I went to Executive Machines for asking the price of a macbook pro adapter. They said it is 8500 BDT. And they also said you can get yours one replaced from where you’ve purchased it as it has one year warranty (they also provide same warranty for their power adapters too)! Then I called to Aloha iShoppe and here is pattern of conversation:

Me: What is the warranty duration for power adapter of macbook pro?
Aloha: There is no warranty for the power adapter.
Me: But so far I know, it also has same warranty as the main body!
Aloha: When you’ve purchased it?
Me: Last june!
Aloha: Actually, it does not has so long warranty, it has about 90 days of warranty?
Me: But Executive Machines is giving 1 year warranty for power adapter.
Aloha: ummm, it is (1 year warranty) given for the products from this year, not for earlier products (power adapter)!
Me: What is the price of power adapter at your house?
Aloha: It is 9500 BDT.
Me: OMG! It is 8500 BDT at Executive Machines. Why you are charging higher prices with less warranty period?
Aloha: They might not have the product, they sometimes, tell prices for products even they don’t have.
Me: Well, they showed me the adapter

(I hang up the phone!)

If you read the above conversation, you will notice how inconsistent their information are!

With my bad experiences with Apple products, I don’t think we should buy Apple’s product unless there is a service center of Apple in Bangladesh! However, if you need to buy, I think it will be wise not to buy from Aloha iShoppe.

Few months ago, I purchased a remote control from Executive Machines by BDT 1700 whose price was asked 2800 at Aloha! So you see how much higher their prices and most importantly, poor after sales service.

Posted in General | Tagged , , , , , , , , | 8 Comments