星期三, 4月 30, 2014

[Blogger Hack] If 條件式判斷 tag

Blogger樣式提供許多tag語法,可以來使用者來客制化樣版內容。
常用到有條件式判斷,可參考以下這個連結:D

http://www.bloggersentral.com/2010/08/targeting-specific-pages-with.html

[Blogger Hack] Blogger SEO小技巧

從來沒有好好對自已的部落格做做SEO的研究,因此就搜尋一些網路上針對Blogger SEO優化的文章來實驗看看,不過大部份目前Blogger都有提供設定介面來方便使用者做SEO。剛好從今天開始來比較一下SEO設定後的效果如何XD,以下SEO小技巧請大家服用。

對文章標題的最佳化


一般來說把網頁的title以部落格文章的主題開頭是對SEO比較好的,但預設設定確為網站名稱+文章標題,這可是非常不好!!

1.首先到後台選擇範本->編輯HTML


接著在head之間找到以下的tag
<title><data:blog.pagetitle/></title>



2. 將第一步驟的東西取代如下
<b:if cond='data:blog.pageType == &quot;index&quot;'>
<title><data:blog.title/></title>
<b:else/>
<title><data:blog.pageName/> - <data:blog.title/></title>
</b:if>

星期二, 4月 29, 2014

[AngularJS] 如何在AngularJS中存取全域變數

如果你有一個需求想要在Controller中存取全域的javascript變數,
可以透過$windowng-init directive二種方法,
最後回應的作者建議$window來存取全域的js變數

 可參考此篇說明: http://stackoverflow.com/questions/15275160/access-global-variable-from-angularjs

以下是擷錄內容:

There are at least two ways:

  • Declare your tags array in a standalone script tags, in which case your tags variable will be bound to window object. Inject $window into your controller to access your window-bound variables.
  • Declare your tags array inside the ng-init directive.

Showing both solutions:

HTML:
<body>

  <script type="text/javascript" charset="utf-8">
    var tags = [{"name": "some json"}];
  </script>

  <div ng-controller="AppController">
    tags: {{tags | json}}
    <ul>
      <li ng-repeat="tag in tags">{{tag.name}}</li>
    </ul>
  </div>  

  <div>
    <ul ng-init="tags = [{name: 'some json'}]">
      <li ng-repeat="tag in tags">{{tag.name}}</li>
    </ul>
  </div>

</body>
JS:
app.controller('AppController',
  [
    '$scope',
    '$window',
    function($scope, $window) {
      $scope.tags = $window.tags;
    }
  ]
);

星期五, 4月 25, 2014

[Java] 解析IE的版本

不透過第三方套件取得瀏覽器的主要版本!! ps: ie11的user-agent需變換判斷方式msie => trident
public class BrowserVersionDetect {
 
  public static void main(String[] args) {
   
  String userBrowser = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0; MATP)";
  userBrowser = userBrowser.toLowerCase();
   
  String browserVersion=userBrowser.substring(userBrowser.indexOf("msie")).split(";")[0];
        String majorNumber 
         = browserVersion.split(" ")[1];

  System.out.println("browserVersion:" + browserVersion);
  System.out.println("majorNumber:" + majorNumber);
  
  }
  
}

[PHP,jQuery] 實作圖片旋轉與儲存

如果你的網站有圖片需要旋轉與儲存的需求,可以參考這個範例外掛:D

UI:
https://code.google.com/p/jquery-rotate/

Server:
//define image path
$filename="image.jpg";

// Load the image
$source = imagecreatefromjpeg($filename);

// Rotate
$rotate = imagerotate($source, $degrees, 0);

//and save it on your server...
file_put_contents("myNEWimage.jpg",$rotate);


星期日, 4月 20, 2014

[Bootstrap] layoutlt 超級懶人bootstrap編輯器

http://www.layoutit.com/ 是可以支援bootstrap2與3的網頁編輯器,
在瀏覽器上就可以快速的透過拖拉的方法完成一個網頁設計。
目前也支援簡中XD


下圖是以bootstrap3的範例示範



星期二, 4月 15, 2014

[jQuery Plugin] 支援RWD的Slider

花14$美金就可以買到支援RWD的Slider,Flyingv也用這家的XD
另外可以看到擷圖上面有一個 loading bar,這樣可以提醒使用者下一頁要更換的時機。
蠻多網站採用這個效果的:D。



參考資料
http://www.themepunch.com/codecanyon/revolution_wp/

星期一, 4月 14, 2014

[jQuery Plugin] Flight Board

飛機時刻表外掛

http://keith-wood.name/flightBoard.htm


l

REST Authentication

記錄一些Rest Authentication實作

http://stackoverflow.com/questions/319530/restful-authentication 

Here is a truly and completely RESTful authentication solution:

 1. Create a public/private key pair on the authentication server.
 2. Distribute the public key to all servers.
 3. When a client authenticates:
3.1. issue a token which contains the following:
 * Expiration time
 * users name (optional)
 * users IP (optional)
 * hash of a password (optional)
3.2. Encrypt the token with the private key.
3.3. Send the encrypted token back to the user.
4. When the user accesses any API they must also pass in their auth token.
5. Servers can verify that the token is valid by decrypting it using the auth server's public key.

This is stateless/RESTful authentication. Note, that if a password hash were included the user would also send the unencrypted password along with the authentication token. The server could verify that the password matched the password that was used to create the authentication token by comparing hashes. A secure connection using something like HTTPS would be necessary. Javascript on the client side could handle getting the user's password and storing it client side, either in memory or in a cookie, possibly encrypted with the server's public key.

星期三, 4月 09, 2014

[GIT] 輕鬆了解Git 分支的概念與基本操作手記




這張圖讓人可以很快速了解整個Git Branch的精要(分支的種類與用途)

主要分支

 * master 主程式(除非重大 bug,則會分出 hotfix 分支)
 * develop 開發分支(用來在另外分支出 Release, feature)

次要分支

 * Hotfixes(由 master 直接分支,馬上修正 bug)
 * Feature(由 develop 直接分支,開發新功能)
 * Release(由 develop 直接分支,開發下一版 Release)

小惡魔神人在2011年的文章有中文版的操作步驟:
 Git 版本控制 branch model 分支模組基本介紹
建議可以好好閱讀與演練:D

星期二, 4月 08, 2014

[Alfresco] 如何使用log4j除錯

本文介紹如何使用alfresco內的log4j來除錯 :D
做完設定後,請記得重開tomcat server

log4j 路徑:
/usr/local/TOMCAT/webapps/alfresco/WEB-INF/classes/log4j.properties

Javascript webscript logging

在js controller加入以下語法

logger.log("Hello Debug");

修正log4j properties

log4j.logger.org.alfresco.repo.jscript=debug log4j.logger.org.alfresco.repo.jscript.ScriptLogger=debug

Java backed webscript logging

在java controller加入以下語法

private static Log LOGGER = LogFactory.getLog(UploadObject.class);

LOGGER.debug("Hello Debug");

修正log4j properties
log4j.logger.tw.org.iii.cosa.javabacked.webscript=debug log4j.logger.tw.org.iii.cosa.javabacked.utility=debug
log4j.logger.org.example=debug

星期一, 4月 07, 2014

[Bootstrap] 利用bootstrap實作parallax效果

http://www.script-tutorials.com/bootstrap-one-page-template-with-parallax-effect/

[Java] 跨站請求偽造Cross-site request forgery CSRF/XSRF 解決方案

一些針對CSRF漏洞的java web app解決方案:

參考資料
http://appsandsecurity.blogspot.tw/2012/01/stateless-csrf-protection.html
https://blog.whitehatsec.com/csrf-prevention-in-java/  (JAVA)
http://wiki.developerforce.com/page/Secure_Coding_Cross_Site_Request_Forgery (列出不同語言的工具與解決方案)
http://www.jtmelton.com/2010/05/16/the-owasp-top-ten-and-esapi-part-6-cross-site-request-forgery-csrf/
http://shiflett.org/articles/cross-site-request-forgeries (PHP)
CSRF 攻击的应对之道  (JAVA)

工具:

JAVA
http://hdiv.org/
https://code.google.com/p/csrf-filter/
https://github.com/esheri3/OWASP-CSRFGuard

PHP
http://csrf.htmlpurifier.org/

[SVN] TortoiseSVN 筆記

這篇記錄一下使用svn的使用經驗(直接用公司的專案來示範),
自已寫一篇有助於記憶力XD。

版本

Subversion 1.7.8

如何新增分支

利用分支(branch)可以有效隔離主幹(trunk),當需要開發一個額外的新功能、重構、測試寫法後,由於時程上可能無法馬上修改完畢,所以都應該透過分支的功能,避免主線被汙染。
此外SVN的分支功能屬於廉價複製,指的是SVN Copy的指令,雖然在資料夾內看到了你分支的資料夾與檔案產生,但並未複製所有的檔案內容,檔案庫實際上只是建立類似連結的動作,或儲存變動的內容而已。因此,成本低又沒有什麼負載,所以大家就稱為廉價複製

Step 1: TortoiseSVN->Branch/tag


其他你感興趣的文章

Related Posts with Thumbnails