Skip to content

Instantly share code, notes, and snippets.

View dungvtdev's full-sized avatar

dungvt.dev dungvtdev

View GitHub Profile

Ảo hóa truyền thống? (Hypervisor based Virtualization)

Với công nghệ ảo hóa này, ta có thể chạy nhiều hệ điều hành cùng lúc trên một máy. Toàn bộ hệ thống từ phần cứng (RAM,CPU,HDD..) cho đến hệ điều hành đều được "ảo hóa". Tuy nhiên việc ảo hóa nảy sinh các vấn đề sau:

  • Tốn tài nguyên: khi chạy 1 máy ảo, nó sẽ luôn chiếm 1 phần tài nguyên cố định. Vd:máy chủ bạn có 512GB SSD, 16GB RAM. Bạn tạo ra 4 máy ảo Linux, mỗi máy bạn cấp 64GB SSD và 2GB RAM. Như vậy, bạn sẽ mất 256 GB SSD để chứa 4 máy ảo, và khi chạy cùng 4 máy ảo lên cùng lúc, chúng sẽ chiếm 8GB RAM. Mặc dù chỉ chạy lên để không đó thôi, chưa dùng gì cả nhưng nó vẫn chiếm từng đó.
  • Tốn thời gian thực thi: thời gian khởi động, shutdown của các máy ảo sẽ lâu, thường là hàng phút.
  • Cồng kềnh: việc phải ảo hóa nhiều OS làm server không thể chạy hết hiệu suất.

Từ những yếu điểm trên mà công nghệ Operating System/Container Virtualization ra đời.

Abu Ashraf Masnun

Tales of a Software Craftsman

PYTHON: A QUICK INTRODUCTION TO THE CONCURRENT.FUTURES MODULE

The concurrent.futures module is part of the standard library which provides a high level API for launching async tasks. We will discuss and go through code samples for the common usages of this module.

Executors

This module features the Executor class which is an abstract class and it can not be used directly. However it has two very useful concrete subclasses – ThreadPoolExecutor and ProcessPoolExecutor. As their names suggest, one uses multi threading and the other one uses multi-processing. In both case, we get a pool of threads or processes and we can submit tasks to this pool. The pool would assign tasks to the available resources (threads or pools) and schedule them to run.

Linux

List all disk device (hdd, mounted...) sudo lsblk -f

Vagrant

Create a base box

vagrant package --output name.box --base name_of_vm_in_virtualbox
vagrant box add name_box path_to_vm.box
@dungvtdev
dungvtdev / vagrant-cheat-sheet.md
Created November 15, 2016 02:09 — forked from wpscholar/vagrant-cheat-sheet.md
Vagrant Cheat Sheet

Typing vagrant from the command line will display a list of all available commands.

Be sure that you are in the same directory as the Vagrantfile when running these commands!

Common Vagrant Commands

  • vagrant up -- starts vagrant environment (also provisions only on the FIRST vagrant up)
  • vagrant status -- outputs status of the vagrant machine
  • vagrant halt -- stops the vagrant machine
  • vagrant reload -- restarts vagrant machine, loads new Vagrantfile configuration
  • vagrant provision -- forces reprovisioning of the vagrant machine
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'libvirt'
Vagrant.configure("2") do |config|
config.vm.provider :libvirt do |libvirt|
libvirt.host = 'asterisk_sip'
libvirt.uri = 'qemu+unix:///system'
libvirt.driver = 'kvm'
# libvirt_pool_name = 'SPool1'
end

Design Pattern

  • Must Know Patterns
    • Command Pattern
    • Decorator Pattern
    • Observer Pattern
    • Iterator Pattern
    • Delegation Pattern.
    • Constructor Pattern : In JavaScript almost everything is an object. We often need to create objects. There are 2 ways to create object. (1) object literal notation. (2) Using new operator.
  • Modular Pattern : This is used to emulate the concept of classes in JavaScript. A class/module in JavaScript is coded with the help of function expressions. This helps to break code in modules such that some of the variables and methods are private to the modules and other are public and exposed as API to other modules.

Transform concept

Model gồm skeleton (bones có kiểu Node) và skinning mesh. Hoạt động:

  • di chuyển bones.
  • render mesh, libgdx sẽ truyền vị trí các bone vào shader, gpu sẽ làm nhiệm vụ transform các vertex theo các bone liên quan tại vertex shader.

Di chuyển bones:

  • có parent là ModelInstance.
  • Node:
{
"scope": "text.html, ",
"completions":
[
{ "trigger": "blk", "contents": "{% block $1 %} $2 {% endblock %}" },
{ "trigger": "blu", "contents": "{% url '$1' %}" },
{ "trigger": "bls", "contents": "{% static'$1' %}" },
{ "trigger": "bl", "contents": "{% $1 %}" },
{ "trigger": "blv", "contents": "{{ $1 }}" },
]
@dungvtdev
dungvtdev / javascript.js
Created February 3, 2017 03:16
Javascript benmark and experiences
var c = $("#comments .comment"); // 4,649 ms
// jQuery 2.0
var c = $(".comment"); // 3,437 ms
// native querySelectorAll
var c = document.querySelectorAll("#comments .comment"); // 1,362 ms
// native querySelectorAll
var c = document.querySelectorAll(".comment"); // 1,168 ms
// native getElementById / getElementsByClassName
var n = document.getElementById("comments");
var c = n.getElementsByClassName("comment"); //107 ms