2013年7月22日 星期一

linux tar的用法


常用語法

  • 建立壓縮檔
    tar -czvf 檔案名稱.tgz 來源檔案
    將 來源檔案 壓縮後,打包成一個名稱為 檔案名稱.tgz 的壓縮檔,來源檔案 可以是檔案或目錄。
    來源檔案 也可以有很多個,以空白字元分隔:
    tar -czvf 檔案名稱.tgz 來源檔案1 來源檔案2 ... 來源檔案n
  • 檢視壓縮檔的內容
    tar -tzvf 檔案名稱.tgz
  • 解開壓縮檔的檔案到目前的目錄
    tar -xzvf 檔案名稱.tgz
  • 複製目錄
    tar -cvf - 來源目錄 | tar -xvf -
    將 來源目錄 下的所有檔案及子目錄複製到目前的目錄,這樣做的好處是可以保留原來的檔案屬性。

2013年7月6日 星期六

Drush


Drush = Drupal + shell
Drush 不是模組

Why Drush?
就是快,打指令看起來比較厲害

Drush 安裝Drupal
drush dl drupal
clear
mv drupal-7.22 drupal
cd drupal
drush site-install --db-url=mysql:\\drupal:00000000@localhost/dbName -y

[ok]
[ok]


install drush
in ubuntu -
pear install drush/drush

**administrator theme : seven ?

基本指令介紹
drush help
drush help dl
drush status

drush cc
drush cron
drush updb  等於執行 update.php
drush wd-show  列出系統資訊
drush wd-del all  刪除系統資訊
下載模組
drush dl view ctools
drush dl views --select all

查看套件資訊 project module information
drush pmi views

drush en [+project]  啟用模組
drush en views

drush dis [+project] 關閉模組
drush pm-uninstall [+project] 反安裝
drush pml  模組列表

drush rl views     #release for views
drush up  更新所有模組及資料庫

drush upc  更新程式碼,不更新資料庫
drush vset theme_default garland 更換版型
drush cc

user create
drush ucrt [account]
drush ucrt kuro --mail="kuro@hotmailt.com" --password="123456"

重設使用者密碼
drush upwd kuro --password="0000"
drush ublk [account]   block 帳號
drush uublk [account]  un-block 帳號

drush urol "role-name"  [account] 設定role
drush urrol  "role-name"  [account]  拿掉role

drush ucan [account]  刪除帳號

Drush Devel module
drush dl devel 下載devel
drush en devel_generate

drush genc  產生文章及回應數
drush genu 產生帳號
drush genu 100

drush make  #drupal 懶人包

drush make makefile.make drupal  #將makefile.make的套件下載到drupal目錄下
Drush Make 指替你建構環境但是不包含資料庫

drush generate-makefile druapl.mak  產生目前drupal網站的make file
###################################
drushmake.me  產生 druapl makefile 的生成器
###################################

drush make drush.mak drupal   安裝makefile到目錄drupal下
資料庫的部份
drush site install drupal

drush uli   # user login 

http://tinyurl.com/drupalCamp2013-drush

drupal 8 的瀏覽器支援


drupal 8 may release on 2014Q1 support IE9 and after all,
in case ,you want to support IE8 maybe down-grade built-in jQuery 2.0 to jQuery 1.9

----------------------------------------------
---- 那些年我們一起搞的金流  -----
藍新
成立2000年
中規中矩的公司

綠界

成立1996年
願意分享介接程式的公司
最近與歐付寶業務合併

紅陽
成立1998年
曾因資安事件上新聞
在行動支付上較積極


建議順序
1. paypal ,webatm
2. 超商代碼
3. 條碼

用戶喜好程度
1. 超商代碼
2. 條碼
3. paypal ,webatm


金流模組
安裝,ok
修改,很機車

-----------------
自行開發金流模組
- 銀行信用卡收單 
- 銀行四大超商收單

銀行收單申請
1. 接洽銀行
2. 確定收單種類
3. 簽訂合約
4. 提供介接API

開發流程
規格確定
開發
測試
正式上線 (換hashcode / return url)

在Drupal裡有許多購物車模組,如何寫一次就能用在所有購物車上
- Drupal 7 以上請用Payment模組架構開發
OrderNumber怎麼編
- Prefix + Time + OrderId
金流要跟物流結合嗎?
- 不要,但可以用訂單編號查詢物流狀態
如何補足付款過程中發生的斷點問題
- 用Cron做查單

-- 第三方支付 -----

第三方支付 = 帳房
- 有信任才能成就生意
- 資安問題是第一重要

服務項目決定客戶屬性
- 對常見的購物車提供介接程式
- 對客戶的商業模式提供解決方案
- 提供固定與不固定的撥款頻率


2013年6月25日 星期二

停止crontab的寄信通知


Crontab 在執行時, 只要營幕有任何標準輸出, 就會轉成信件寄出通知,初期要 Debug用時還不錯, 但是久了後就很煩, 就想把他丟到 /dev/null 或 改寄到其它地方去, 但是 /dev/null 丟了好多次都沒有用, 才發現到原來是少了 2>&1, 完整命令如下:
於設定時將標準輸出導到 /dev/null
0 * * * * script_name > /dev/null 2>&1
將信件改寄到其它地方, MATILTO="", (不過 "" 的話, 我不知道會寄到哪邊去)
於 Script 最前面加上 MAILTO=""


ref:http://blog.longwin.com.tw/2006/01/stop_crontab_send_mail/

如何在網站、部落格中安裝 LINE 分享、轉貼按鈕?行動網頁?


以下程式碼適用於一般網頁:


reference : http://briian.com/?p=9836

如何重置webmin的使用者密碼

reset Webmin的使用者密碼 
1.使用find找出Webmin安裝目錄下的密碼修改檔changepass.pl  
find / -iname changepass.pl 

2.切換到該檔所在目錄,執行: 
./changepass.pl /etc/webmin 欲修改的帳號 欲修改的密碼 

修改後就可以使用新密碼登入Webmin

ref:http://www.wretch.cc/blog/diskdupe/12322782

2013年6月18日 星期二

Apple Enterprize Developer Account 申請記錄

開始申請時間 5/31

Your Apple Developer Program Enrollment Request


蘋果美國公司來電確認時間 6/18 13:30
詢問三個問題
1. 詢問購買者是否了解企業者帳號無法上架到Apple Store
2. 詢問購買者購買企業者帳號的用途是限於企業內或客戶使用的
3. 詢問購買者是否可以代表公司與蘋果簽約

同意合約 6/18 13:41

Apple Developer Program Enrollment Update


付費購買 6/18 13:55

正在處理你的訂單 W226794118


完成購買時間 6/18 16:58




2013年6月13日 星期四

linux cron

path:

/var/spool/cron


sample:


44 11 * * * /etc/webmin/cron/tempdelete.pl
0 * * * * /etc/webmin/bandwidth/rotate.pl
*/5 * * * * /usr/sbin/ntpdate time.stdtime.gov.tw > /dev/null 2>&1
10 6 * * * /usr/local/sbin/tarDATA_day.sh
*/1 * * * * /usr/local/sbin/webcron/pushcron.sh
59 23 * * * /usr/local/sbin/webcron/webcron.sh

execute url (wget)
and no output result


wget http://p4.milkidea.com/app_tls/api-cron.sea -O /dev/null
wget http://p4.milkidea.com/app_discovery/api-cron.sea -O /dev/null
wget http://p4.milkidea.com/clinic2/api-cron.sea -O /dev/null
wget http://p4.milkidea.com/app_pushme/api-cron.sea -O /dev/null

Linux常用指令

shutdown / reboot , reference from 鳥哥

重起sendmail
service sendmail stop
service sendmail start


重起apache

apache reset
/usr/local/apache/bin/apachectl stop
/usr/local/apache/bin/apachectl start


掛上一個裝置

mount -t ext3 /dev/sdb1 /mnt/data2
rm -rf *   刪除,recursive & force
cp -rf * ../data2  複製,recursive & force
fg

symboic link
ln -sf /mnt/data2 /mnt/db_disk
$ ln [參數] 來源檔案或資料夾 要建立的 link 名稱
沒有參數的時候是建立 hard link,沒辦法跨 file system,沒辦法 link directory
-s : symbolic link
-f : 要建立的 link 如果存在,會先移除掉再建立

[root@www ~]# ln -s /etc/crontab crontab2
[root@www ~]# ll -i /etc/crontab /root/crontab2
1912701 -rw-r--r-- 2 root root 255 Jan  6  2007 /etc/crontab
 654687 lrwxrwxrwx 1 root root  12 Oct 22 13:58 /root/crontab2 -> /etc/crontab

rm db_disk
umount /mnt/data
若是busy請離開/mnt/data工作目錄

要複製資料且保留權限要使用
tar cvf * -R
tar xvf 

SFTP to non port 22

注意: -oPort 參數要在前面,以避免某些程式解命令列參數時解錯。
解法範例:
sftp -oPort=6789 jjdai@example.com

apatana git 練習

設定git 執行程式

建立git儲存空間


Git功能選單


Git Add remote



2013年6月1日 星期六

vi 常用指令筆記

command mode

u  : undo
dd : delete a line
x : delete a char
o : new line
y : mask a line
p : paste
$ : goto end of a line
0 : goto start of a line

更多的介紹
c9s Vim Hacks7 是相當好的 vim 學習資源    
http://c9s.blogspot.tw/2009/08/vim-hacks-coscup.html

2013年5月31日 星期五

mysql left join - 可以利用foreign key的關聯相關表格來補充擴充欄位

select a.c1, b.c2 from a left join b on a.c1 = b.c1
其實left join 是指 把 b 沒有符合 的也列出來 但是加了 where 會強制 b.c2 一定要符合 2009-10-23

範例


//195筆
select `store_book`.* from `store_book` where  `store_book`.`store_code`='P018' and `store_book`.`seat_name`='不限定'


//34筆 - cross table 相同user_id
select `store_book`.*,`user`.`UName`,`user`.`UPhone` from `store_book`, `user` where   `user`.user_id=`store_book`.user_id  and `store_book`.`store_code`='P018' and `store_book`.`seat_name`='不限定'

用left join從user表中來擴充UName,UPhone資訊

// 195筆
select `store_book`.*,`user`.`UName`,`user`.`UPhone` from `store_book` left join `user` on   `user`.user_id=`store_book`.user_id  where `store_book`.`store_code`='P018' and `store_book`.`seat_name`='不限定'


2013年5月23日 星期四

更改DNS對應IP,移機後的Drupal無法啟動


查詢網路發現可能是cache沒有清除乾淨
---
drupal 可以用phpmyadmin清除的資料表
Which Drupal tables are safe to manually clear using phpmyadmin?

In my experience, I purge all of the "cache_*" tables.
cache
cache_*


plus "watchdog" if I don't care about past Drupal logs
plus "accesslog" if I don't care about logged-in users
plus "search" if I don't care about indexed nodes contents

boost_cache
boost_cache_relationships

----
原來問題是  drupal_test/phpBB3/config.php 裡面有資料庫設定錯了
因為當初是用IP設定連結的Orz

----
要找出這個問題可以用字串搜尋的方式
方式很多,比方像是:

linux搜尋特定字串的指令

grep -r "STRING" /path
find /path -type f | xargs grep "STRING"
----



2013年4月14日 星期日

ssh 出現 remote host identification has change

最快的方式是清掉 ssh-keygen 重連

ssh-keygen -R 10.10.10.1

reference: http://conbar.pixnet.net/blog/post/27217157-ssh連線出現warning%3A-remote-host-identification-has-chang

2013年4月10日 星期三

zbar zxing的QRCode 二維條碼掃瞄器


ZBar可以直接扫二维码和条形码, 
ZXing可以直接扫二维码, 如果要扫条形码,则需要去改改代码花点功夫了。
同样, ZBar和ZXing的源码我们也是可以找到的, 
只是ZBar的源码找起来比较费功夫, 但在其官网还是可以找到, 找到后, 由于ZBar的源码包括了在其它各个平台的源码, 比如Mac, Python,等, 源码比较乱, 看起来有点费事, 而且最重要的是编译起来链接的东西太多, 又是运行脚本,又是安装什么库的, 感觉国外的这种库吧,给人使用倒是方便,但要是去进行维护还真不太容易。所以尽管我已经找到这个ZBar的开源码,但我从来都没有真正的把它完整地编译出来过, 自我鄙视一把。只好有空再深入研究一下了。(注:由于ZBar对中文支持不是很理想,所以要想彻底地用好ZBar,还是需要去读懂这个源码,并能真正地编译出来。)


reference:http://blog.csdn.net/smking/article/details/7792104

2013年3月31日 星期日

如何製作自己專屬的通訊錄QRcode

如何製作自己專屬的通訊錄QRcode

在 google store 上找到一個 QR Code 的應用程式網站 可以建立聯絡人資料的 QR Code 然後下載存到自己電腦,不只是可以在名片上應用,更可以放在『 Yahoo 奇摩拍賣 』或『 露天拍賣 』等拍賣網站的『 關於我 』說明內,讓客戶可以快速連絡你,還有很多的應用方法

reference:http://pgx.servu.tw/2012/08/10/qr-code-contact-list/

2013年2月25日 星期一

MAC使用NAS下放在home目錄下的Office檔案無法直接開啟

最後發現問題是
mac的home目錄跟NAS的home混淆所造成
也就是說
雖然開啟的是NAS的home目錄下的檔案
mac office軟體會去mac的home目錄下面去找,才會造成找不到

解決方法:
改放在另外新建立的一個共用目錄下就可以避掉了

ps:基本上是沒有解決 ><||

2013年2月11日 星期一

根目錄的空間不足

遇到空間不足
/var/spool/mail
下有占了很多空間

可以使用
cp /dev/nulll /var/spool/mail/root 如此一來就直接清空
不可以直接刪除喔!!

要找出哪個地方占空間可以使下面的指令
du搭配sort可以快速地整理出
du -B M --max-depth=1 | sort -g

-B M,意思是統一以Mega(百萬位元組)為單位
--max-depth=1可以把子目錄的容量不顯示出來,但會加總到它的父目錄容量下

df -M
可以先看出裝置的使用狀態

2013年1月31日 星期四

設定Windows Server 2008 為NTP時間伺服器 & 客戶端設定

1. Windows NTP設定
設定步驟如下
win server 2008
reference: http://www.dotblogs.com.tw/halladay/archive/2012/05/11/72124.aspx
win xp
http://windgo.pixnet.net/blog/post/22048041-ntp-server-in-winxp

修改
net stop w32timer
net start w32timer

w32tm /config /update

  net start

linux ntpdate 設定


[root@clientlinux ~]# ntpdate [-dv] [NTP IP/hostname]
選項與參數:
-d :進入除錯模式 (debug) ,可以顯示出更多的有效資訊。
-v :有較多訊息的顯示。

[root@clientlinux ~]# ntpdate 192.168.100.254
28 Jul 17:19:33 ntpdate[3432]: step time server 192.168.100.254 offset -2428.396146 sec
# 最後面會顯示微調的時間有多少 (offset),因為鳥哥這部主機時間差很多,所以秒數...

[root@clientlinux ~]# date; hwclock -r
四  7月 28 17:20:27 CST 2011
西元2011年07月28日 (週四) 18時19分26秒  -0.752303 seconds
# 知道鳥哥想要表達什麼嗎?對啊!還得 hwclock -w 寫入 BIOS 時間才行啊!

[root@clientlinux ~]# vim /etc/crontab
# 加入這一行去!
10 5 * * * root (/usr/sbin/ntpdate tock.stdtime.gov.tw && /sbin/hwclock -w) &> /dev/null

2. crontab 設定
crontab -e
可以對外的狀況
*/5 * * * * (/usr/sbin/ntpdate  clock.stdtime.gov.tw && /sbin/hwclock -w) &> /root/timesync.log
公司內部的設定,設定內部架設好的NTP的IP
*/5 * * * * (/usr/sbin/ntpdate 10.1.1.167 && /sbin/hwclock -w) &> /root/timesync.log

每五分鐘校正一次時間

2013年1月10日 星期四

忘記CentOS 密碼的找回方式

1. 可以到機器前
2. 重開機進入grub畫面3. 加入single,結果如下: kernel /vmlinuz-2.6.18-8.el5 single ro root=LABEL=/ rhgb quiet 4. 進入後出現提示符號# 代表成功啦 passwd root 改一下密碼


reference:http://mypaper.pchome.com.tw/joanneandy1479/post/1321478063