Sep 12, 2013

Bỏ qua khoảng trắng khi diff

Trong git khi chuyển đổi giữa Windows và Linux hay bị vấn đề CR - LF làm cho cả file bị đánh dấu là sửa trong khi đó chỉ là khác biệt khoảng trắng

Nhiều khoảng trắng thêm bớt cũng bị coi là sửa => ko hay

Chỉ cần đặt thông số sau và ~/.gitconfig là ổn :D
[core]
        autocrlf = true
        safecrlf = false
        eol = lf

        whitespace = -trailing-space,-indent-with-non-tab,-tab-in-indent
 
[color]
        ui = auto
[push]
        default = simple
[apply]
        ignorewhitespace = true

Sep 11, 2013

Phím tắt khi gõ tiếng Nhật (MS Input IME)

F7 -> Chuyển từ Hiragana sang Katakana
F10 -> chuyển từ Hiragana sang Romanji
Dấu cách -> Chuyển sang Kanji

Sep 10, 2013

Sử dụng grep

grep "string" --color -r -n --include=*.{html,php} --exclude=*\.svn* .


-n hiển thị dòng chứa kết quả tìm thấy.

Phần mềm vẽ minh họa

Dia với các hình dạng có sẵn dung để thiết kế biểu đồ.
Đặc biệt, với dàn cairo nó khá phù hợp để dàn trang.

Tải về: http://dia-installer.de/download/index.html.en

Aug 30, 2013

Page break

For Chrome: use
 page-break-inside: avoid;
For others:
use page-break-after: always;

Jul 23, 2013

Search for a string in files


find . -type f -print | grep --color=auto -iR 'string'
 
Grep internally support this as well
grep --color=auto -i -r 'string' /dir

If we want to search in some only extensions, use "--include"
Grep also have --exclude directive.

Jun 20, 2013

Theme bootstrap

http://vinceg.github.io/Bootstrap-Admin-Theme

Tao giao dien

  • FontAwesome 3.0
  • Google "Open Sans" Font
  • jQuery Flot Charts 0.8
  • jQuery Sparklines 2.1.1
  • Easy Pie Chart 1.0.1
  • jQuery Knob 1.2.0
  • jQuery Validate 1.11.1
  • FuelUX 2.3.0 (Spinner & Wizard & Treeview)
  • FullCalendar 1.6.1
  • jQuery ColorBox 1.4.14
  • jQuery dataTables 1.9.4
  • jQuery Chosen 0.9.12
  • jQuery Masked Input 1.3.1
  • jQuery Input Limiter 1.3.1
  • jQuery AutoSize 1.16.7
  • Bootstrap Colorpicker
  • Bootstrap Datepicker
  • Bootstrap Timepicker v0.2.3
  • Bootstrap DateRange Picker 1.1
  • Bootbox.js 3.2.0
  • jQuery Gritter 1.7.4
  • jQuery slimScroll 1.1.1
  • Spin.js 1.3.0
  • jQuery UI Touch Punch 0.2.2
  • Google Code Prettify
  • ExplorerCanvas
  • Mindmup Wysiwyg Editor
  • Toopay Markdown Editor

Jun 13, 2013

Phông chữ tiếng Nhật mượt hơn cho Windows

Vào regedit chon tiếp HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontLink\SystemLink 
Chỉnh các thay thế của Segui UI và Tahoma failback về font Meriyo

Mass check for PHP error syntax

find /vagrant/application/*.php -type f -exec php -l '{}' \;

Jun 7, 2013

Compare changes in user posts

To show changes, we can point out what's were deleted, or added using decent syntax.
It's on PEAR, module:

Text_Diff_Renderer_inline

Jun 6, 2013

Debito - Experiences in Japan

http://www.debito.org/residentspage.html

Build houses
http://www.swedenhouse.co.jp/

Land.
http://www.keisei-land.co.jp

Jun 2, 2013

Laravel

Laravel có khái niệm Nested Controllers, khá tiện để tổ chức rất nhiều controllers vào các nhóm.
Ví dụ cần có controller Posts, Setup trong tên to là Admin, chỉ đơn giản là lồng thư mục. Quá tiện!

"Ghost" với Linux

Ngày xưa để sao lưu (backup) đĩa mình chỉ biết đến mỗi chương trình Ghost nổi tiếng Tuy nhiên có thể làm việc đó bằng Linux với cách hay hơn nhiều : ) Đầu tiên phải khởi động từ một đĩa Linux bất kỳ. Để sao lưu và nén một phân vùng (partition):
dd if=/dev/sda1 | gzip > /path/to/image.gz
Để phục hồi:
gzip -dc /path/to/image.gz | dd of=/dev/sda1

Jun 1, 2013

Handle many connections Postgres

Use a pooling, such as pgpool2
Or actively caching your popular queries

Nginx generate password for auth basic

<?php
echo "Usage: php gen_passwd.php passwd_to_crypted". PHP_EOL;
$pass = $argv[1];
echo crypt($pass, base64_encode($pass)). PHP_EOL;

Thêm user trong server

useradd -m -s /bin/bash userName
passwd userName

May 30, 2013

Update server time every 15 minutes

$ crontab -e
0,15,30,45 * * * * rdate -ncav ptbtime1.ptb.de > /dev/null

Postgres

Config pg_hba:
local   all             postgres                                peer
local   all             postgres                                md5
local   all             all                                         md5

Cac chu de hay ve Postgres:
http://momjian.us/main/blogs/pgblog_categories.html



Unicode:

update pg_database set datallowconn = TRUE where datname = 'template0';
\c template0
update pg_database set datistemplate = FALSE where datname = 'template1';
drop database template1;
create database template1 with template = template0 encoding = 'UTF8' LC_CTYPE = 'en_US.utf8' LC_COLLATE = 'en_US.utf8';
update pg_database set datistemplate = TRUE where datname = 'template1';
\c template1
update pg_database set datallowconn = FALSE where datname = 'template0';

May 29, 2013

Setup dev box

apt-get install
postgresql mysql-server php5-cli  php5-cgi php5-xdebug php5-curl php5-gd php5-mysql php5-pgsql php5-mcrypt php5-memcached memcached git mc
 apache2

a2enmod actions
a2enmod php5_cgi

Edit module conf file.


sudo apt-get install libsqlite3-dev

Các vấn đề về dữ liệu bản đồ

Tổng quan các dự án liên quan:
http://www.osgeo.org/


Cơ sở dữ liệu :

PostGIS và PostgreSQL

Render:
http://mapnik.org/

Sử dung trên để bàn:

Sử dung trên web (tương tác được)
OpenLayers http://openlayers.org/

May 27, 2013

Công cụ quản lý DB

Cả MySQL, Postgres, SQLite, cài trên web

Một file php duy nhất + css theme tùy ý :D đẹp
Và nó ở đây
http://www.adminer.org/

May 23, 2013

Sudo timeout


$ sudo visudo


defaults env_reset,timestamp_timeout=60
# one hour

DBGp


The debug progress will use DBGp protocol.
This can be applied to Notepad++ or Sublime Text.
In local machine:
Set the break points somewhere
Add to URL ?XDEBUG_SESSION_START=notepad
Or use some kind of extension to SET the cookie XDEBUG_SESSION_START=notepad

Uncheck Bypass (we really need this map)
Remote path: file:///var/www
Local path: C:\Dev\www
idekey: notepad
Remote server IP: obiviously
The local machine must listen to port 9000, Notepad++ will listen using this. The remote server should be able to connect to local machine using port 9000 (by NAT, tunnel, etc…)
In remote server:
apt-get install php5-xdebug
Edit php.ini
xdebug.remote_enable=1
xdebug.remote_handler=dbgp

; xdebug.remote_host=10.0.0.2
; This specify the local machine IP (exposed, not local address)
; This is important: to use any IP it detects – less pain to setup
xdebug.remote_connect_back = 1

xdebug.remote_mode=req
xdebug.remote_log="/var/log/xdebug.log"
xdebug.idekey="notepad"
xdebug.remote_port=9000