2016年2月28日 星期日

Using MySQL command line with MAMP

To use the MySQL command line with MAMP or MAMP PRO, perform the following steps
  1. Start MAMP or MAMP PRO
  2. Start the server
  3. echo $PATH
  4. Open Terminal (Applications -> Utilities)
    Type in: (one line)
    /Applications/MAMP/Library/bin/mysql --host=localhost -uroot -proot
Now you can use the MySQL command line. For exmaple to show all your databases with show databases;.

2015年9月11日 星期五

輕鬆學會 Fb developer api - 三步驟搞定串聯FB分享

前情概要: 最近做了一個案子,業主說要做分享活動可取得紅利,身為開發者的我們當然..只能...好吧!!沒問題!!!因此開啟了序幕...

fb 提供一組  FB.ui()方法 ,用於觸發dialogs,fb提供下列呼叫方法,這篇針對share dialog做說明:


  • The Share Dialog allows someone to post a link or Open Graph story to their profile.
  • The Login Dialog allows someone to use Facebook Login to grant permissions to an app.
  • The Add Page Tab Dialog allows someone to add an app to a tab on a Facebook Page which they admin.
  • The Requests Dialog allows someone to send a request to one or more of their friends from a game.
  • The Send Dialog allows someone to send a Facebook Message to one or more of their friends.
  • The Payments Dialog allows people to purchase virtual items for your app.

  1. 簡單安裝 JAVASCRIPT SDK: 不需要任何複雜的安裝,初始化成功後,fb會採用非同步讀取SDK放置頁面中,是不是很easy啊!

    1. 在html中加入下列代碼
    2. your-app-id替換自己的fb app id即可
<script>
  window.fbAsyncInit = function() {
    FB.init({
      appId      : 'your-app-id',
      xfbml      : true,
      version    : 'v2.4'
    });
  };

  (function(d, s, id){
     var js, fjs = d.getElementsByTagName(s)[0];
     if (d.getElementById(id)) {return;}
     js = d.createElement(s); js.id = id;
     js.src = "//connect.facebook.net/en_US/sdk.js";
     fjs.parentNode.insertBefore(js, fjs);
   }(document, 'script', 'facebook-jssdk'));
</script>


2.  輕鬆觸發fb ui分享的dialog : 將your url 替換成妳的url 然後搞定!簡單吧!! response會吐回成功或失敗的方法。




function share()
{
FB.ui(
 {
   method: 'share',
   href: 'your url',
 },
 // callback
 function(response) {
   if (response && !response.error_message) {
     alert('分享成功後即可領取紅利!');
   } else {
     // alert('Error while posting.');
   }
 }
)
};


3. 做手工藝的時間到囉,給他一個button 來觸發FB分享吧!


<button onclick="share()">點此分享</button>



END : 是不是真的三步驟就搞定啦!
附上官方文件:https://developers.facebook.com/docs/sharing/web
快開啟你的分享之旅吧~



2014年12月25日 星期四

程式執行時間

PHP


$time_start = microtime(true);
/*
測試時間的程式碼
*/
$time_end = microtime(true);
$time = $time_end - $time_start;
echo $time;


js



echo $time;


//--------------------------------
// run time
//--------------------------------


var ticks_start = performance.now();


//--------------------------------
// your code
//--------------------------------


// run time
var ticks_end = performance.now();
// alert(ticks_end - ticks_start);
window.performance = window.performance || {};
performance.now = (function() {
  return performance.now       ||
         performance.mozNow    ||
         performance.msNow     ||
         performance.oNow      ||
         performance.webkitNow ||
         function() { return new Date().getTime(); };
})();





2014年4月29日 星期二

good book

sql injection:
http://www.puritys.me/filemanage/blog_files/advance_sql_injection.pdf
http://www.jb51.net/article/31898.htm
http://w1a2d3s4q5e6.blogspot.tw/2013/06/php.html

php book:
http://issuu.com/milesgelidus/docs/johnwileysons-php5fordummies
http://issuu.com/abdulfazil/docs/php-object-oriented-solutions.9781430210115.35911

html5:
http://issuu.com/tavotribilin/docs/oreilly.html5.the.missing.manual.au

duolingo:
https://www.duolingo.com/

css style:
http://www.shejidaren.com/css-button-generator-and-beautifucl-style-sheet.html