Showing posts with label Thủ thuật. Show all posts
Showing posts with label Thủ thuật. Show all posts

Lỗi chuột bị lag trong Mac OSX

Chuột không dây Logitech dùng với Mac bị lag, không mượt như windows.

Dùng smooth mouse, giống windows

http://smoothmouse.com/

Surface pro 3 power cord, 2 pin and 3 pin plug

Problem:

  • Have to plug the surface pro 3 into different wall plug standard (say, 2 pin and 3 pin type).
  • Do not want to use the adapter as it is bulky.
Solution: Buy a power cord of MacBook charger. It fits perfectly.

I got my surface pro 3 with a three-pin plug in the power cord, as I live in Singapore. Unfortunately, I have to move to other country, and this country uses different type of socket. I hate using an adapter, because it make the plug, original bulky enough, more bulky. 


I try to buy a new cord for the charger, but as surface pro 3 is new, it is hard to find one. The only option is to buy a new charger from Microsoft. Luckily, I saw the charger of a Macbook and try it. It fits to the surface pro 3 charger. The best thing is that this cord can be found easily, from ebay or electronic shop.


The only problem is the color, Mac love white color while Mic love black :).

std:: shared pointer and container like std::vector

How to use shared pointer with container:
  • Use it as normal, except
  • When insert or push it to a container, using:
    • push_back(std::move(p))

Shared pointer is a feature that is included in C++ 11. Using shared pointer is great, but it has some problems with standard container like vector, map or queue in std.

The problem is that when we push a shared pointer to a container, the references counter of the shared pointer does increase, but when the container is out of scope, the counter does not decrease. It make the memory leak, as the shared pointer can not be released.

The solution is to use: std::move

Be note that the shared pointer that is moved will be invalid. You need to get it back or insert it to container at the end of function.

Assertion, exception and error handling

How to use them in your code:


Debug break point

Exception

  • Assertions are for debugging. The user of your shipped code should never see them. If an assertion is hit, your code needs to be fixed.
  • Exceptions are for exceptional circumstances. If one is encountered, the user won't be able to do what she wants, but may be able to resume somewhere else.
  • Error handling is for normal program flow. For instance, if you prompt the user for a number and get something unparsable, that's normal, because user input is not under your control and you must always handle all possible situations as a matter of course. (E.g. loop until you have a valid input, saying "Sorry, try again" in between.)

Phần mềm giúp tự động khóa máy tính bắt buộc chúng ta giải lao [Win]

Có lẽ có quá nhiều công việc trong thời hiện đại liên quan và sử dụng máy vi tính, khi giờ đây những chiếc máy tính mạnh mẽ được tận dụng giúp chúng ta giải quyết nhiều vấn đề khác nhau, kết nối con người, chia sẻ thông tin v.v. Nhưng một trong những tác hại là chúng ta thường ngồi quá lâu trước máy vi tính. Tác hại của việc ngồi lâu trước máy tính thì khá nhiều, đây là một bài viết hay về những tác hại ấy: The health hazards of sititng. Tôi xin tóm tắt những tác hại ấy là: Bệnh tim mạch, ung thư ruột, tụy, đãng trí, đau lưng ...