Showing posts with label Computer. Show all posts
Showing posts with label Computer. Show all posts

Tuesday, April 11, 2017

MySQL lỗi sql_mode=only_full_group_by

Một ngày đẹp trời bạn nâng cấp Mysql hoặc thì bị dính lỗi sql_mode=only_full_group_by
Nguyên nhân là từ MySQL 5.7.5+ mặc định nó xài thêm mode ONLY_FULL_GROUP_BY. Nên chúng ta phải khai báo lại... k xài mode đó nữa.

Mở file /etc/mysql/conf.d/mysql.cnf, thêm vào:

mysqld]
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

Khởi động lại mysql: sudo service mysql restart

Monday, September 28, 2015

Hàm javascript đọc số thành chữ

/**
* Đọc số thành chữ (Vietnamese)
* DOCSO.doc( 123 );
*/
var DOCSO=function(){var t=["không","một","hai","ba","bốn","năm","sáu","bảy","tám","chín"],r=function(r,n){var o="",a=Math.floor(r/10),e=r%10;return a>1?(o=" "+t[a]+" mươi",1==e&&(o+=" mốt")):1==a?(o=" mười",1==e&&(o+=" một")):n&&e>0&&(o=" lẻ"),5==e&&a>=1?o+=" lăm":4==e&&a>=1?o+=" tư":(e>1||1==e&&0==a)&&(o+=" "+t[e]),o},n=function(n,o){var a="",e=Math.floor(n/100),n=n%100;return o||e>0?(a=" "+t[e]+" trăm",a+=r(n,!0)):a=r(n,!1),a},o=function(t,r){var o="",a=Math.floor(t/1e6),t=t%1e6;a>0&&(o=n(a,r)+" triệu",r=!0);var e=Math.floor(t/1e3),t=t%1e3;return e>0&&(o+=n(e,r)+" ngàn",r=!0),t>0&&(o+=n(t,r)),o};return{doc:function(r){if(0==r)return t[0];var n="",a="";do ty=r%1e9,r=Math.floor(r/1e9),n=r>0?o(ty,!0)+a+n:o(ty,!1)+a+n,a=" tỷ";while(r>0);return n.trim()}}}();

Cách dùng

alert( DOCSO.doc(123000) );

Friday, September 11, 2015

Vô hiệu Xem trước In (Print review) của chrome

Tạo 1 shortcut của Chrome mới với Target: "C:\Program Files\Google\Chrome\Application\chrome.exe" --disable-print-preview

Tham số --disable-print-preview sẽ vô hiệu hóa xem trước khi in. Bấm in sẽ bật ra giao diện chọn máy in để in.

Nếu thay bằng tham số --kiosk-printing sẽ in luôn mà không cần hỏi chọn máy in nào. Máy in mặc định được in sẽ là máy in trước đó bạn chọn. Tham số rất hữu ích để triển khai hệ thống POS bán hàng... k phải mất thời gian xác nhận máy in.

Và tham số --kiosk sẽ cho phép Chrome chạy ở trạnh thái Full Screen.

Chú ý:
- Thoát Chrome hoàn toàn mà mở lại bằng shortcut mới thì tham số mới có hiệu lực.
- Đường dẫn đến ứng dụng Chrome thay đổi tùy theo máy tính của bạn.

Sunday, July 5, 2015

Thiết lập wildcard subdomain dùng BIND trên Ubuntu

Ví dụ ta code PHP trên ubuntu. Tạo 1 project dev.com (localhost) và muốn mọi subdomain của nó đều trỏ về 127.0.0.1 (Hoặc bất kỳ IP nào). Nhầm mục đích lập trình, test code.

Cài đặt bind
sudo apt-get install bind9

Thiết lập BIND như là 1 caching server. Có nghĩa là card mạng dùng DNS của BIND dùng DNS của public của DNS nào đó nếu muốn internet

Mở:
/etc/bind/named.conf.options

Thiết lập:
forwarders {
  # Phía dưới dùng google DNS. Bạn có thể dùng DNS khác
  8.8.8.8;
  8.8.4.4;
};

Tạo 1 ZONE

Mở:
/etc/bind/named.conf.local

Thêm 1 zone:
zone "dev.com" {
  type master;
  file "/etc/bind/db.dev.com";
};

Tạo:
/etc/bind/db.dev.com

Thêm vào:
;
; BIND data file for local loopback interface
;
$TTL 14400
@ IN  SOA dev.com. root.dev.com. (
            2012091901   ; Serial
                 86400   ; Refresh
                  7200   ; Retry
               3600000   ; Expire
                 86400 ) ; Negative Cache TTL
;
@ IN  NS  dev.com.
@ IN  A 127.0.0.1
* IN  A 127.0.0.1
@ IN  AAAA  ::1

Khởi động lại BIND

sudo service bind9 restart

Bước tiếp theo là thiết lập card mạng chúng ta dùng DNS 127.0.0.1
Please google!

Kết tiếp là thiết lập Apache (tạo virtual host) cho tên miền dev.com
<Virtualhost *:80>
  ServerName dev.com
  ServerAlias *.dev.com
  DocumentRoot /home/user/www/dev.com
  <directory "/home/user/www/dev.com">
    AllowOverride All
    Options All
    Order allow,deny
    Allow from all
  </Directory>
  ErrorLog /var/log/apache2/dev.com.error.log
  CustomLog /var/log/apache2/dev.com.access.log combined
</VirtualHost>

Tuesday, March 31, 2015

Driver Xerox Phaser 3110 for Windows 7, Windows 8.1, Windows 10

Xerox Phaser 3110 for Windows 7 (32 bit), Windows 8.1 (32 bit), Windows 10 (32 bit)

Download: https://www.dropbox.com/s/sdt0vv6qyqri869/Phaser3110.zip?dl=0

Xerox Phaser 3110 for Windows 7 (64 bit), Windows 8.1 (64 bit), Windows 10 (64 bit)

Download: https://www.dropbox.com/s/gwcs22mqfgsubi9/XeroxPhaser3110-win64bit.zip?dl=0

64bit driver is ported from Samsung ML-1200 driver (a other brand of Xerox 3110) so before install it you must disable driver signature verification (https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=How+to+Disable+Driver+Signature+Verification+on+64-Bit)

Go to Device Manager, right click on Printer and choice Update Driver Software..., browser to folder contain driver (after unzip) to install it.

-------------------------
Xerox Phaser 3110 là dòng Printer khá là cỗ lỗ, thông dụng và bền cực kỳ :-s