Cái này nhớ mang máng là post lâu rồi mà tìm không thấy, take note lại vậy.
<?php
if (isset($_SERVER['REMOTE_ADDR'])) exit(0);
if ($argc != 3) {
print 'Usage: ' . $argv[0] . ' <mail nguoi nhan> <noi dung>' . "\nExample: " . $argv[0] . ' "huyphungvan@gmail.com" "Phùng Văn Huy is now online"';
exit(1);
}
$to = $argv[1];
$msg = $argv[2];
$sentSuccess = sendEmail($to, $msg);
if ($sentSuccess) echo "Sent email to $to";
else echo "Sent email to $to failed";
function sendEmail($to, $message = '', $subject = 'Thư gửi Huy', $header = '') {
# Thêm header này để thư gửi thuần Việt :-j
$utf8Header = 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/html; charset=UTF-8' . "\r\n";
return mail($to, '=?UTF-8?B?' . base64_encode($subject) . '?=', $message, $utf8Header . $header);
}
Category Archives: Chỉ dẫn lập trình
Using mysqlimport
Text file (/var/text-data/film.txt)
1,Dead Note – part 1,mms://113.113.113.113/huypv/share/film/akzvx.avi
12,Dead Note – part 2,mms://113.113.113.113/huypv/share/film/akzvy.avi
Table film in database share
CREATE TABLE film (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(113), url VARCHAR(113));
mysqlimport –fields-terminated-by=, –lines-terminated-by=”\n” -uroot -pXXX share /var/text-data/film.txt
Notice: Nếu client và server không thuộc cùng một máy thì lệnh như trên sẽ không chạy nữa do mặc định nó sẽ tìm file trên máy server. Lúc này cần thêm tham số để nó tìm file nguồn import ở máy client (local)
mysqlimport –local –fields-terminated-by=, –lines-terminated-by=”\n” -uroot -pXXX share /var/text-data/film.txt
Bonus: Exec SQL query by command
mysql -uroot -pXXX share -e “TRUNCATE TABLE film”
Merging a Branch into Trunk
[protocol]://server/path/to/trunk
[protocol]://server/path/to/branches/b-v1
Có ứng dụng xxx, 1 nhánh được tách ra là b-v1
Check out trunk trên server về thư mục C:\source\xxx
Check out branches/b-v1 về thư mục C:\source\b-v1
Chuyển thư mục làm việc [C:\source\b-v1], gõ lệnh
svn log –stop-on-copy
# Nhìn thấy revision XXXX (là revision lúc branch được copy tách ra từ trunk)
Chuyển thư mục làm việc [C:\source\xxx], gõ lệnh
svn up
# Nhìn thấy: At revision YYYY
Để merge branch into trunk, dùng XXXX, YYYY ở trên gõ lệnh
svn merge -rXXXX:YYYY [protocol]://server/path/to/branches/b-v1
# Conflict chỗ nào thì tùy nghi mà di tản, chọn tc (their …) là dùng bên branch đè sang!, mc là giữ nguyên bên trunk – vứt bỏ branch.
Giờ thì commit lên trunk trên server
svn ci -m “MERGE branch b-v1 [XXXX]:[YYYY] into trunk”
Lại chiến với trunk thôi, bye bye branch.
break in Perl exit while loop
#!C:\Perl\bin\perl.exe
print “Content-type: text/html\n\n”;
$i = 1;
while ($i < 10) {
if ($i == 5) {print ‘Break<br />’; last;} #use last, not break
else {print ‘I am ‘, $i, ‘<br />’;}
$i++;
}
print ‘I am ‘, $i, ‘<br />’;
Notice when using header redirect
Why did I say that?
Test following script
header(‘Location: http://about:blank’);
file_put_contents(‘/tmp/still-running’, ‘I am here’);
Then
cat /tmp/still-running
So, don’t forget die!!!