Thursday, April 3, 2014

Session error

Got this error when I change git branch from rails2 to rails3. When I am doing some upgrading task.
ActionDispatch::Session::SessionRestoreError
Session contains objects whose class definition isn't available.Remember to require the classes for all objects kept in the session.(Original exception: uninitialized constant ActionController::Flash::FlashHash [NameError])
Just delete the browser's cookie, fixed this issue. I guess this two version have different way to handle the session or cookie. Then I google again. Got this Link , Look like someone already figure it out.

Tuesday, April 1, 2014

Why my website not verify by Authority in Android browser.

  My boss told me my shopping cart checkout page isn't secure. There is a popup window said that something like "this website not verified, danger , danger .....".
   How it could be, we already buy SSL Certificate from godaddy.com and put it in the ngnix configuration file. And my desktop browser didn't complain anything. Something is not right I know.
   After google, it got this page - http://nginx.org/en/docs/http/configuring_https_servers.html#chains
The key point is this line "This occurs because the issuing authority has signed the server certificate using an intermediate certificate that is not present in the certificate base of well-known trusted certificate authorities which is distributed with a particular browser". My English isn't so well to understand this kind of compound sentence . I just guess and translate it as,  The android browser didn't play well with godaddy. 
   Ok, then we need the cure, follow the step, I copy gb_bundle.crt from godaddy. then put after the original crt file. Then reload. Hola, the warning is gone. 
   By the way, there is website could test your SSL certificate setting - https://www.ssllabs.com/ssltest/index.html
  Lesson learn: System administration take lots of time.

Tuesday, July 16, 2013

Mount Encrypted LVM Partition - RHEL

I  accidentally delete  RHEL6.4 libc.so.6 link file. The system don't work anymore.
Here is the command I use to mount that partition using ubuntu 12.04 live CD.

0. open terminal
1. sudo su -
2. fdisk -lu
   a. for finding /dev/sda2
3. cd /mnt
4. mkdir enc
5. cryptsetup luksOpen /dev/sda2 encrypted
    a. typing password
6. apt-get install lvm2
7. lvscan
    a. it will show lv inactive
8.vgchange -ay
   a. change lv to active
9.mount /dev/VolGroup00/LogVol101 /mnt/enc

Now you could workin on the /mnt/enc folder

Here is the source.
http://wiki.sabayon.org/index.php?title=HOWTO:_Mount_Encrypted_Partition
http://www.nixetra.com/mount-unknown-filesystem-type-lvm2-member/



Wednesday, July 3, 2013

WARNING: Remote desktop does not support colour depth 16; falling back to 8

I suddenly got this warning when I use rdesktop. It turn out I use full-screen mode and I just add  one more display.  So maybe my display card or X-Windows setting don't have enough RAM. Anyway, just change it not to use full-screen fixed this issue.

Wednesday, May 29, 2013

月亮沒有來

月亮沒有來
今天月亮沒有來
沒有來到我床前的窗沿
不是有霜雪的日子
不是有低頭思鄉的情結
今天月亮沒有來
平常她都是圓圓的臉
圓圓的眼
看著我入眠
月亮沒有來
我依然合著眼
靜靜的睡在沒有月亮的夜

Thursday, May 2, 2013

Rails , Angular and REST resource example.

I work on an rails application and trying to use angular with REST API.
Here I document what I do to make it work:
1. In layout view's head.

  <%= csrf_meta_tag %>
2. In javascript using ng-app module to update httpProvider add csrf token in the header.
var vmShowApp = angular.module('vmShowApp', ['ngResource']);
  vmShowApp.config([
    "$httpProvider", function($httpProvider) {
      $httpProvider.defaults.headers.common['X-CSRF-Token'] = $('meta[name=csrf-token]').attr('content');
    }
  ]);
3.In html page to do the update , it will call update function using ng-click.
<a class="action" href="" ng-click="update('<%= Vm::STATUS[:VM_STATUS_AVAIL] %>')"><%= Vm::STATUS[:VM_STATUS_AVAIL] %></a>
4. In javascript it define update function, looks like angular will create vm object inside this put request, so I add the status inside this vm object.
$scope.update = function(status){
      $scope.vm['status'] = status;
      var vm = Vm.get({id:<%= @vm[:id] %>});
      vm.vm = {}
      vm.vm.status = status;
      vm.$update({id:<%= @vm[:id] %>});
      }; 

5. In config/route.rb define the REST rerouces.
namespace :api do
    namespace :v1 do
      resources  :vms
    end
  end

6.In app/controllers/api/v1/vms_controller.rb define the update function
def update
 respond_with Vm.update(params[:id],params[:vm])
end

Monday, April 29, 2013

DB2 Rails rake test:units


When I try to run rake test:units I got error.

rake aborted!
Task not supported by 'ibm_db'
....

Tasks: TOP => db:test:load => db:test:purge
(See full trace by running task with --trace)

So the ibm_db plugin didn't provide db:test:purge task.

I found there is a project http://rubyforge.org/projects/db2extended/
But it looks like not work with Rails 3. So I just copy the db2extended_tasks.rake into lib/tasks. It seems works.