Archive for the ‘cloud’ Category

Internship, Day 24 (23 May 2012)

Posted on May 24th, 2012 in cloud, computer, in English, in Thai, personal, PHP, programming | No Comments »


(Photo: I can has coffee?)

เหมือนอะไรๆ จะกลับเข้าสู่ภาวะปกติอีกครั้งเมื่อผมปิดงานโปรแกรมวิดีโอได้ซักที แต่สุดท้ายก็ไม่เป็นเช่นนั้น เพราะวันนี้ในขณะที่ผมกำลังอ่านเรื่อง Cloud ต่อพี่ก็เอางานใหม่มาให้ทันที งานนั้นคือระบบบันทึกการเข้าออกของลูกค้าที่เข้ามาใน data center

แน่นอน องค์กรมหาชนขนาดนี้เขามีใช้อยู่แต่แรกแล้วละ เพียงแค่ว่าเขาอยากให้ทำละเอียดลงไปอีกเท่านั้นเอง เพราะเดิมข้อมูลลูกค้าจะถูกแยกเป็นรายบริษัท คือเป็นความสัมพันธ์แบบ one-to-many จากบริษัทไปหาบุคคล (คือ บริษัทหนึ่งมีหลายคนที่เข้าออก data center ได้) แบบใหม่ต้องการแทรกรายละเอียดงานในระดับ project ลงไปด้วย ทำให้เป็น one-to-many-to-many จากบริษัทไปหาโปรเจคไปหาบุคคลแทน

โชคดีที่โปรแกรมเก่ามีอยู่แล้ว และมีการแก้ไขไปบ้างแล้วด้วย แต่ปัญหาคือมันยังสะดุดๆ เดี้ยงๆ อยู่ พี่ที่ทำก็ไม่ว่างทำต่อ และอีกปัญหาของผมคือโปรแกรมนี้ใช้ CodeIgniter เขียน ซึ่งเป็น MVC ที่ผมไม่คุ้นเคยอย่างแรง จะได้เรียนใหม่อีกรอบก็งานนี้แหละ!!!

Everything seemed to calm down when I close my video task, but it finally was not the case because while I was reading about Cloud the senior came and tasked me with a new job: visitor logging for data center.

Surely, this kind of public corporation already has one, but they want me to go a bit into deeper detail. Customer data relationship used to be one-to-many of company-to-person (one company may have many persons that can access the data center) but the new one will have “project” stuffed in the middle, giving a one-to-many-to-many of company-project-person.

Fortunately there already exists an application that does this and it is already being worked on. The problem is it bugs a lot and the seniors who worked on it no longer had time to continue this project. I have my own problem though: I have no experience with CodeIgniter MVC which this project uses.

Useful reads for vCloud:
http://www.yellow-bricks.com/2010/08/31/vmware-vcloud-director-vcd/
http://www.yellow-bricks.com/2010/09/07/vcd-networking-part-1-intro/
http://frankdenneman.nl/2010/09/provider-vdc-cluster-or-resource-pool/

Internship, Days 22-23 (21-22 May 2012)

Posted on May 23rd, 2012 in cloud, computer, CPE, in English, in Thai, JavaScript, personal, programming | No Comments »

No photo today. Sorry. Read on.

เนื่องจากมีการแก้บั๊กขนานใหญ่เกิดขึ้นซึ่งใช้เวลาสองวัน ผมก็ขออัพรวมไปเลยนะครับ ส่วนที่เป็นสีแดงคือส่วนที่มีการแก้ไขในวันที่สองนะครับ จะได้เห็นว่ามีอะไรเปลี่ยนไปยังไงบ้าง

งานที่ผมทำช่วงสองวันนี้มีสองส่วน ส่วนแรกคือเตรียมเอกสารนำเสนอเรื่อง vCloud Director (vCD) แต่ปัญหาคือผมยังไม่ค่อยเข้าใจสถาปัตยกรรมโดยรวมของ VMware เท่าไหร่ เลยต้องไปอ่านใหม่หมดตั้งแต่ VMware Workstation, VMware ESXi, ฯลฯ จนกระทั่งอ่านไปถึงหัวเรื่องของ vCloud Director เท่านั้น เท่าที่สรุปได้คือ (ไม่ได้บอกว่ารู้แค่นี้นะครับ)

  • ESXi เป็น Hypervisor ที่ติดตั้งลงบนฮาร์ดแวร์โดยตรง ไม่ขึ้นกับ OS ใดๆ
  • vCenter เป็นระบบควบคุมเครื่องที่ทำ virtualization อีกที
  • vSphere Client เป็นตัวที่ต่อไปยัง vCenter หรือโฮสแต่ละเครื่อง
  • vCloud Director เป็นตัวที่มา abstract หรือมาครอบ vCenter ตัวหนึ่งหรือหลายตัวอีกที
  • vMotion คือระบบและกระบวนการย้าย VM จากเครื่องหนึ่งไปอีกเครื่องหนึ่งโดยไม่มี downtime

จากนั้นพี่ก็มาสับงานผมอีกรอบ โดยต้องแก้ไขตัวเล่นวิดีโออีกหลายอย่าง

  • วิดีโอไม่เล่นอัตโนมัติบน iPad สาเหตุเป็นเพราะผมเอาโค้ดที่เคยใช้งานได้ออก แล้วไม่ได้ใส่กลับเข้าไปใหม่ แก้ไขโดยการสั่ง videotag.load(); videotag.get(0).play(); ตามอ้างอิง [1] , [2]   ทั้งนี้ iOS เวอร์ชันใหม่ๆ มีการป้องกัน autoplay ที่แข็งแกร่งขึ้นเรื่อยๆ จนวิธีนี้ใช้ไม่ได้ผล
  • ผลการค้นหาวิดีโอแสดงแค่คอลัมน์เดียว ไม่สะดวกและไม่สวยด้วย แก้โดยการลดขนาดใน CSS (สิ)
  • ลากวัตถุ (object) ไม่สะดวกเมื่อต้องเลื่อนจอไปมา คิดว่าต้องหาพวก autoscroll มาใส่ แต่บั๊กมันเยอะ ต้องค่อยๆ ดูไป ตอนนี้ทำได้แล้ว แต่ถึกมาก ใช้ global เก็บสถานะ แล้วใช้ event ในการ set สถานะของตัวแปรใน global
  • การเปิดปิดเสียง พี่ต้องการให้ no mute ตั้งแต่แรก ในขณะที่ผมไปทำ default mute ไว้เพราะรำคาญเสียงในคลิป (นิดเดียวแต่ก็ยังไม่ได้ทำ) (ตอนนี้ทำแล้ว)
  • พฤติกรรมของกล่อง drop-down ที่มันจะคอยเลือก default playlist ขึ้นมาตลอด ซึ่งแม้ว่าผมจะเซฟไฟล์ชื่ออื่นไปมันก็ยังเด้งกลับมาเป็น default playlist ทุกครั้ง อันนี้แก้ที่ฟังก์ชันสำหรับ rebuild drop-down list ไปเลย โดยถ้าเป็นการเซฟให้ set ชื่อใน drop-down list กลับมาเป็นชื่อที่เพิ่งเซฟไป ทำเสร็จแล้ว ไม่ค่อยยากเท่าไหร่
  • โปรแกรมขาดคำอธิบาย เช่น สัญลักษณ์ที่ใช้บอกว่าวิดีโอ (ทั้งข้อมูลและไฟล์) มาจากฐานข้อมูลหรือจาก YouTube ก็เลยใส่สัญลักษณ์ลงไป
  • ให้คลิกบนวิดีโอ MP4 แล้ว play/pause ได้เหมือนกับบน YouTube (ทำแล้ว)

Since there’s a big chunk of bug hunt which spanned two days, I decided to group them into one entry. The red bits indicate changes made during the second day.

I’ve done parts of two jobs during the two days. The first one is vCloud Director (vCD) presentation preparation. Since I did not really understand much about the entire VMware architecture, I had to read everything from start: Workstation, ESXi, etc., until the introduction to vCloud Director (where I left off) and here’s the summary (not “what I know” though)

  • ESXi is a Hypervisor installed on top of hardware (bare-metal), which is not OS-dependent
  • vCenter controls the virtualization host machines
  • vSphere Client connects to vCenter or individual hosts
  • vCloud Director abstracts one or more vCenters
  • vMotion is the thing that lets you move VM from one host to another without downtime
Then the supervisor came and asked me to change and fix my video player.
  • Video does not auto-play on iPad. This is because I forgot to add the force-autoplay code back into the main piece. Just a simple videotag.load(); videotag.get(0).play(); as described in  [1] [2] . However, newer iOS versions block autoplay more aggressively, and this method also fails.
  • Only one column of search result is displayed on mobile devices, so I reduced each search result’s size in CSS.
  • Object cannot be dragged from one part of document to another far side without auto-scroll. I managed to do so, but it’s a lot of kludge like global variables and get-set style of events, very old-fashioned.
  • Supervisor wants default playlist to no-mute, so I changed player behavior as required .
  • Drop-down list (of playlists) has a quirky behavior because I set it to “snap” to default playlist whenever the drop-down list is regenerated. Even if we save another playlist for example, the drop-down list still snaps to default playlist. I changed it so that when you save, it snaps to the name you just saved. Simple if-then, not really hard.
  • Application lacks explanation, such as video legend (video color codes, for example), so I added them in a bit.
  • Play/Pause when user clicks on MP4, just like that of YouTube.

Click-to-dismiss (requires jQuery)

Purpose: Ideal for simple message boxes, alert messages, etc.

Syntax: click_to_dismiss(what_to_dismiss [, where_to_click] );
(where_to_click defaults to “document”, which means “anywhere”)

 function click_to_dismiss(what_to_dismiss, where_to_click){
  if(where_to_click == undefined){
    where_to_click = document;
  }
  $(document).bind('click', function(){
    $(what_to_dismiss).hide();
    $(what_to_dismiss).unbind();
  });
} 

Limitation: This function also unbinds everything attached to what_to_dismiss, which is usually not a problem for me because my message boxes don’t have any other bindings attached. Please respond if you manage to make it work better (while readable by beginner because that’s what I am!)
Recommendation for Improvement: Overcome the limitation

Autoscroll page when dragging some element (requires jQuery. VERY BAD CASE OF KLUDGE!)

Purpose: Allows page to scroll up or down when you drag an element near the top or bottom edge of the browser.

Syntax: set_item_detect_drag(selector);
Selector is jQuery element like $(‘img’), $(‘.items’) or $(‘#namebox’)

 var autoscroll_mouse_item;
var autoscroll_click_item;
var autoscroll_drag_item;

function set_item_detect_drag(sel){
  sel.mouseenter(function(){
    autoscroll_mouse_item=this;
    set_drag_status();
  });
  sel.mouseleave(function(){
    autoscroll_mouse_item=undefined;
    set_drag_status();
  });
  sel.mousedown(function(){
    autoscroll_click_item=this
    set_drag_status();
  });
  sel.mouseup(function(){
    autoscroll_click_item=undefined
    set_drag_status();
  });
}

// Set detection vars
function set_drag_status(){
  if(autoscroll_mouse_item==autoscroll_click_item&&autoscroll_mouse_item!=undefined){
    autoscroll_drag_item = autoscroll_mouse_item;
  } else {
    autoscroll_drag_item = undefined;
  }
}

$(document).mousemove(function(e){
  //if drag_item is acquired and mouse is near edge, scroll.
  if(autoscroll_drag_item!=undefined){
    //mouse near top
    if(e.pageY - $(window).scrollTop() < 40)
    {
      //scroll a bit up
      $(window).scrollTop($(window).scrollTop()-5);
    }
    else if($(window).scrollTop()+parseInt(window.height)-e.pageY < 40)
    {
      //scroll a bit down
      $(window).scrollTop($(window).scrollTop()+5);
    }
  }
}); 

Limitation: Lots.
Recommendation: Use OO, extending jQuery and make it a full-blown plugin instead of a global-var-ridden kludge. Another: Variable, smooth scrolling speed (slow when not very close to edge, for example)

Internship, Day 21 (18 May 2012)

Posted on May 19th, 2012 in cloud, computer, in English, in Thai, personal, PHP, programming | No Comments »


(Photo: We have SCB. Your argument is invalid. << Wait what?!)

วันนี้ผมเริ่มจากการทำระบบตรวจสอบและปรับไฟล์ก่อนเลย โดยคราวนี้มามาดใหม่ แทนที่จะเอาไฟล์มาไล่ทีละชื่อ (โคตรเชยเลย) ผมใช้คำสั่ง array_diff($a, $b) เพื่อหา A-B (เมื่อ A และ B เป็นเซตที่แทนด้วยอาร์เรย์ $a และ $b ตามลำดับ) แล้วลบหรือโหลดไฟล์ทีเดียวหมดเลย ง่ายดี ทำไมตอนนั้นคิดไม่ได้แบบนี้ก็ไม่รู้ จากนั้นผมก็เขียนคู่มือการใช้งานต่อจนจบ โดยเปลี่ยนจาก text เป็น HTML จะได้อ่านง่ายๆ หน่อย แล้วก็ใส่ spinner (ไอ้ตัวหมุนๆ เวลารอ ajax ทำงาน) ขณะมีการดาวน์โหลดไฟล์ที่ใช้เวลาค่อนข้างนานโดยใช้ spin.js ซึ่งใช้งานได้ง่ายและเป็น MIT License ด้วย จึงนำมาใช้กับชิ้นงานของบริษัทได้ทันที

สุดท้ายผมก็เลยได้ทำงานชิ้นต่อไปคือการศึกษาเกี่ยวกับ vCloud Director อธิบายกันสั้นๆ จากผู้เริ่มต้น vCloud Director เป็นตัวที่มาครอบบน vCenter อีกที ก็หลักๆ ก็รู้แค่นี้แหละครับ (ยอมรับว่ารู้แค่นี้ เพราะตรงนี้เป็นรายงานประจำวัน ไม่ใช่บทความ) สำหรับลิงค์ที่อ่านไปจะไว้ท้ายเอนทรีนะครับ

Today I started from file consistency restorer, which I revised to use array_diff($a, $b) to find missing or extra files and take appropriate actions. Then, I finished the manual, which I converted into HTML format from plain text. Finally, I added spinner (that spinning thing when there are ajax calls) using spin.js , which uses MIT License and thereby is compatible with this work.

At the end of the day I started reading about vCloud Director. From a newbie, it’s something that runs on top of vCenter. That’s all I know. (And I’m going to admit my limits here because this is a daily report not an article).

References

http://www.yellow-bricks.com/2010/08/31/vmware-vcloud-director-vcd/
http://frankdenneman.nl/2010/09/provider-vdc-cluster-or-resource-pool/