2014年11月22日 星期六

使用google analytics統計ajax內容重載

1.在js中加入

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXX']);
_gaq.push(['_trackPageview']);

(function() {
  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

2.在ajax function的success中加入


    _gaq.push(['_setAccount', 'UA-XXXXXX']);
    _gaq.push(['_trackPageview']);

在aws ec2 使用php mail功能寄信(ubuntu 14.04)

1.確認port 25沒被擋:

在VPC中的subnets與Security Groups確認SMTP (25) outbound 是否有開啟?



2.安裝 snedmail:

sudo apt-get install sendmail


參考資料:
http://stackoverflow.com/questions/19858457/send-mail-using-amazon-ec2-instance

2014年11月19日 星期三

mobile-friendly pages (defined by Google)

Google 將在行動裝置搜尋結果,加入mobile-friendly標籤。

符合以下條件會被加入標籤:
  • Avoids software that is not common on mobile devices, like Flash
  • Uses text that is readable without zooming
  • Sizes content to the screen so users don't have to scroll horizontally or zoom
  • Places links far enough apart so that the correct one can be easily tapped

Google測試:

Mobile-Friendly Test


資料來源:

Helping users find mobile-friendly pages

[連結備份]links that will show you what Google knows about you

凡走過必留下痕跡@@


1. Find out how Google sees you

Google attempts to create a basic profile of you, your age, gender, interests. They use this data to serve you relevant ads. You can review how Google sees you here:


2. Find out your location history

If you use Android, your mobile device may be sending your location as well as velocity data to Google. You can see your entire location history and export it here:


3. Find out your entire Google Search history

Google saves every single search you have ever done. On top of that, they record every Google ad you have clicked on. This log is available to you here:


4. Find out every device that has accessed your Google account

If you worry that someone else might be using your account, you can find a list of all devices that have accessed your Google account, their IP address and approximate location here:


5. Find out all the apps and extensions that are accessing your Google data

This is a list of all the apps that have any type of access to your data. You can see the exact type of permissions granted to the app and revoke access to your data here:


6. Export all of your data out of Google

Google let’s you export all your data: bookmarks, emails, contacts, drive files, profile info, your youtube videos, photos and more here:


 資料來源:
https://medium.com/productivity-in-the-cloud/6-links-that-will-show-you-what-google-knows-about-you-f39b8af9decc

2014年11月3日 星期一

configure: error: failed to recognize APR_INT64_T_FMT on this platform

configure: Configuring python swig binding
checking for Python includes... -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7
checking for compiling Python extensions... cc -arch x86_64 -arch i386 -pipe
checking for linking Python extensions... cc -bundle -undefined dynamic_lookup -arch x86_64 -arch i386 -Wl,-F. -framework Python
checking for linking Python libraries... -bundle -undefined dynamic_lookup -Wl,-F. -framework Python
checking for apr_int64_t Python/C API format string...
configure: error: failed to recognize APR_INT64_T_FMT on this platform


在mac os 10.10的solution為:

$ xcode-select --install

2014年10月30日 星期四

mac OSX 10.10 安裝PHP pcntl extension

1.抓取php 5.5.14 source code

http://tw1.php.net/get/php-5.4.24.tar.bz2/from/a/mirror

2.Build the PHP pcntl extension

tar -jxvf  PHP-5.5.14.tar.bz2

cd php-5.5.14/ext/pcntl/

/usr/bin/phpize

./configure

make

sudo make install

3.Enable the extension

編輯 /etc/php.ini  並加入

extension=pcntl.so

4.Restart apache
 
sudo /usr/sbin/apachectl restart

AWS RDS mysql 慢查詢 (slow query log)

以下為官方文件

The MySQL slow query log and the general log can be written to a file or a database table by setting parameters in your DB parameter group. For information about creating and modifying a DB parameter group, see Working with DB Parameter Groups. You must set these parameters before you can view the slow query log or general log in the Amazon RDS console or by using the Amazon RDS API, Amazon RDS CLI, or AWS SDKs.
You can control MySQL logging by using the parameters in this list:
  • slow_query_log: To create the slow query log, set to 1. The default is 0.
  • general_log: To create the general log, set to 1. The default is 0.
  • log_output: To write the general and slow query logs to the file system, set to FILE. The default is TABLE, which writes general queries to the mysql.general_log table, and slow queries to the mysql.slow_log table. To disable logging, set to NONE.
  • long_query_time: To prevent fast-running queries from being logged in the slow query log, specify a value for the shortest query execution time to be logged, in seconds. The default is 10 seconds, the minimum is 0. If log_output = FILE, you can specify a floating point value that goes to microsecond resolution. If log_output = TABLE, you must specify an integer value with second resolution. Only queries whose execution time exceeds the long_query_time value are logged. For example, setting long_query_time to 0.1 prevents any query that runs for less than 100 milliseconds from being logged.
  • log_queries_not_using_indexes: To log all queries that do not use an index to the slow query log, set to 1. The default is 0. Queries that do not use an index are logged even if their execution time is less than the value of the long_query_time parameter.



    資料來源
  • http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_LogAccess.Concepts.MySQL.html
  •  http://dev.mysql.com/doc/refman/5.6/en/slow-query-log.html