發表文章

目前顯示的是 2015的文章

AWS Route53 DNS redirect

由於AWS Route53沒有redirect功能,所以需要另外搭配S3使用,才能做到redirect。 步驟 1. 在s3建立bucket,bucket name與轉換前的domain name需要相同 2. 在bucket properties設定Static website hosting,開啟redirect all request to another host name,設定要轉換後的網址 3.在route53內,轉換前的domain name設定record type A,Alias: Yes,選擇剛剛建立好的Static website hosting 4. 完成 reference: http://stackoverflow.com/questions/10115799/set-up-dns-based-url-forwarding-in-amazon-route53 http://www.holovaty.com/writing/aws-domain-redirection/

修改Firefox ctrl+f搜尋的Match Case設定

1.Enter about:config into the address bar and press Enter. 2.Accept the warning message. 3.Type "case". 4.Double click on the entry accessibility.typeaheadfind.casesensitive in the list to open the Enter integer value dialog. 5.Change the number to 0 for case-sensitive search and press the OK button (or press Enter). ps. 1為開啟, 0為關閉

iOS App Transport Security has blocked a cleartext HTTP resource load since it is insecure

問題: App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file. Apple在iOS9之後新增App Transport Security(ATS)的機制,禁止訪問未加密的連線,如果沒有特別排除這個設定,會遇到這個錯誤。 解決方法: 1. 設定排除domain <key>NSAppTransportSecurity</key>     <dict>         <key>NSExceptionDomains</key>         <dict>             <key>www.domain.com</key>             <dict>                 <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>                 <true/>             </dict>         </dict>     </dict> 2. 關閉ATS機制,此方法允許訪問ip位址  <key>NSAppTransportSecurity</key>     <dict>         <key>NSAllowsArbitraryLoads</key>         <true/>     </dict> reference: https://forums.developer.apple.com/thread/6205 https://developer.apple.com/library/prerelease/ios/technotes/App-Transport-Securit

java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer

當用jersey 1.19建立RESTful服務時,遇到java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer的錯誤訊息。 解決方法: 1.將相關jar檔全複製到web-inf/lib/之內,就可以解決。(asm-3.3.1.jar, jersey-bundle-1.19.jar, jersey-core-1.19.jar, jersey-server-1.19.jar, son-20140107.jar, jsr311-api-1.1.1) 2. the server had no jars in the lib folder. Make sure it has access to all dependencies in: project -> properties -> development assembly -> add -> java build path entries. 正常啟動tomcat產生的訊息如下: 十月 20, 2015 4:35:02 下午 org.apache.catalina.core.StandardService startInternal INFO: Starting service Catalina 十月 20, 2015 4:35:02 下午 org.apache.catalina.core.StandardEngine startInternal INFO: Starting Servlet Engine: Apache Tomcat/7.0.52 十月 20, 2015 4:35:05 下午 com.sun.jersey.api.core.servlet.WebAppResourceConfig init INFO: Scanning for root resource and provider classes in the Web app resource paths:   /WEB-INF/lib   /WEB-INF/classes 十月 20, 2015 4:35:05 下午 com.sun.jersey.api.core.ScanningRe

iOS app

JSON Swift UITableView: Load data from JSON http://www.kaleidosblog.com/swift-uitableview-load-data-from-json iOS Tutorial: Loading data from an external database using JSON & Storyboards - VIDEO 3 https://www.youtube.com/watch?v=9R1ju28qFyE AFJSONOperation UTF-8 chars? http://www.raywenderlich.com/forums/viewtopic.php?f=2&t=3037 How To Fetch and Parse JSON Using iOS SDK http://www.appcoda.com/fetch-parse-json-ios-programming-tutorial/ Parsing JSON in Objective-C using NSJSONSerialization https://www.safaribooksonline.com/blog/2013/03/06/parsing-json-in-objective-c-using-nsjsonserialization/ Tutorial: Fetch and parse JSON in iOS6 http://www.touch-code-magazine.com/tutorial-fetch-and-parse-json-in-ios6/ IPhone, synchronous and asynchronous JSON Parse http://www.hbensalem.com/iphone-2/iphone-synchronous-and-asynchronous-json-parse/ Swift Swift resources https://developer.apple.com/swift/resources/ Start Developing iOS Apps (Swift) https://developer.a

修改ubuntu開機自動開啟或關閉X Window

關閉方法: 編輯/etc/default/grub 修改GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash” 或”” 改成GRUB_CMDLINE_LINUX_DEFAULT=”text” 或”quiet splash text” 再執行update-grub 開啟方法: 與上步驟相反的設定 或startx 或sudo service gdm start referrence http://askubuntu.com/questions/16371/how-do-i-disable-x-at-boot-time-so-that-the-system-boots-in-text-mode http://askubuntu.com/questions/276937/how-to-efficiently-enable-disable-gui-in-ubuntu-server-12-04 http://askubuntu.com/questions/402083/enable-disable-ubuntu-desktop-environment-on-ubuntu-12-04-1-server-i386 http://askubuntu.com/questions/53822/how-do-you-run-ubuntu-server-with-a-gui

Raspberry Pi相關文獻

Raspberry Pi 2 Model B 使用心得 http://cheng-min-i-taiwan.blogspot.tw/2015/02/raspberry-pi-2-model-b.html Raspberry Pi 網路設定 http://cheng-min-i-taiwan.blogspot.tw/2013/02/raspberry-pi_23.html RPi VerifiedPeripherals http://elinux.org/RPi_VerifiedPeripherals Category Archives: Raspberry Pi Hobby computer http://www.wirelesshack.org/category/raspberry-pi-hobby-computer Raspberry Pi 2 - FAQ and collated answers https://www.raspberrypi.org/forums/viewtopic.php?p=683295 Measuring Internet Speed In Python Using Speedtest-cli http://www.raspberrypi-spy.co.uk/2015/03/measuring-internet-speed-in-python-using-speedtest-cli/ Raspberry Pi 安裝心得、教學、簡介 https://wwssllabcd.github.io/blog/2013/01/31/how-to-setup-raspberry-pi/ 掛載外部_usb_storage https://wwssllabcd.github.io/blog/2013/01/31/how-to-setup-raspberry-pi/#%E6%8E%9B%E8%BC%89%E5%A4%96%E9%83%A8_usb_storage 安裝_VNC_server https://wwssllabcd.github.io/blog/2013/01/31/how-to-setup-raspberry-pi/#%E5%AE%89%E8%A3%9D_VNC_server A tea

防止linux ssh被暴力攻擊defend Brute Force Attacks

方法: 1.用fail2ban 2.用DenyHosts 3.用iptables (可能鎖到自己) reference https://www.rackaid.com/blog/how-to-block-ssh-brute-force-attacks/ http://pulipuli.blogspot.tw/2011/07/centosfail2ban.html http://denyhosts.sourceforge.net http://www.lovelucy.info/vps-anti-ssh-login-attempts-attack.html http://blogger.gtwang.org/2014/05/linux-ssh-public-key-authentication.html http://blog.longwin.com.tw/2005/12/ssh_keygen_no_passwd/ https://help.ubuntu.com/community/SSH/OpenSSH/Keys http://xtony77.logdown.com/posts/209067-ubuntu-notes-using-ssh-key-login

SMB for WIN and MAC

SMB是使用NetBIOS的協定 http://computers.tutsplus.com/tutorials/how-to-set-up-an-smb-server-in-os-x-and-windows-8--mac-46276

java read RS232

使用RXTX library,rxtx 2.1-7r2版本只支援x86,x64要另外從別的網站抓。而rxtx 2.2pre2支援x64。 reference http://puremonkey2010.blogspot.tw/2011/07/java-java-rs232.html http://rxtx.qbang.org/wiki/index.php/Download#Known_RXTX_forks http://simplecodelife.blogspot.tw/2013/09/java-rxtx.html

windows kms error code : 0xc004f074

如果windows在啟動kms時,遇到error code : 0xc004f074, 檢查時區和系統時間是否錯誤,修正後就可以了。 reference http://leoprosoho.pixnet.net/blog/post/42950439-windows-2008-r2找kms-server做產品啟動時,出現0xc00

Java ArrayList of Object Sort

Java ArrayList of Object Sort 使用Comparable或Comparator http://beginnersbook.com/2013/12/java-arraylist-of-object-sort-example-comparable-and-comparator/

java Web Services WSDL & restful

先用jdk的工具wsimport對wsdl url產生相關檔案, 接著可以呼叫wsdl,call soap wsdl example: C:\Users\vm\Desktop>"C:\Program Files\Java\jdk1.7.0_51\bin\wsimport.exe" -d test -keep http://www.webservicex.net/CurrencyConvertor.asmx?WSDL package clientweb.servlet; import java.io.IOException; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import thsrwebserviceproj.order.Order; import thsrwebserviceproj.order.OrderService; import thsrwebserviceproj.order.OrderServiceService; /**  * Servlet implementation class order  */ @WebServlet("/order") public class orderServlet extends HttpServlet {     private static final long serialVersionUID = 1L;            /**      * @see HttpServlet#HttpServlet()      */     public orderServlet() {         super();         //

java clone class

java clone class 複製class的value,而不是reference一個class http://howtodoinjava.com/2012/11/08/a-guide-to-object-cloning-in-java/ http://stackoverflow.com/questions/869033/how-do-i-copy-an-object-in-java

System.currentTimeMillis()

http://mqjing.blogspot.tw/2007/03/java.html http://my.oschina.net/xsh1208/blog/183858

查看apple ID下的設備

我的支援設定檔 https://supportprofile.apple.com/ 查詢保固期限  https://selfsolve.apple.com/agreementWarrantyDynamic.do

facebook: Bad Response Code: URL returned a bad HTTP response code.

因為facebook的爬蟲cache了舊的狀態,不會立即更新,所以一直顯示抓不到網頁。 解決方法: 進入https://developers.facebook.com/tools/debug/ 輸入網址debug,再按Fetch new scrape information

java 2D swing

http://myleslittlewolf.pixnet.net/blog/post/2836595 http://pydoing.blogspot.tw/2011/05/java-basic-concept-of-gui.html it-easy.tw/java-linedraw/ http://stackoverflow.com/questions/5801734/how-to-draw-lines-in-java https://www.youtube.com/watch?v=MqwSKoWTuZE https://www.youtube.com/watch?v=y7YbQrrcpAQ https://docs.oracle.com/javase/7/docs/api/javax/swing/JFrame.html http://docs.oracle.com/javase/7/docs/api/javax/swing/JComponent.html#method_summary http://www.java2s.com/Tutorial/Java/0261__2D-Graphics/Drawaline.htm http://www.java2s.com/Tutorial/Java/0240__Swing/ExtendsJComponenttocreatedrawingpad.htm http://codex.wiki/question/1992591-2967/ http://www.javaworld.com.tw/jute/post/view?bid=5&id=312003

java read json

http://stackoverflow.com/questions/6511880/how-to-parse-a-json-input-stream http://stackoverflow.com/questions/4308554/simplest-way-to-read-json-from-a-url-in-java http://stackoverflow.com/questions/7467568/parsing-json-from-url

java filter

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {         // TODO Auto-generated method stub         // place your code here                 //System.out.println("testfilter");         System.out.println(request.getCharacterEncoding());         System.out.println(request.getContentLength());         System.out.println(request.getContentType());         System.out.println(request.getLocalAddr());         System.out.println(request.getLocalName());         System.out.println(request.getLocalPort());         System.out.println(request.getProtocol());         System.out.println(request.getRemoteAddr());         System.out.println(request.getRemoteHost());         System.out.println(request.getRemotePort());         System.out.println(request.getScheme());         System.out.println(request.getServerName());         System.out.println(request.getServerPort());         System.out.println(request.getAsync

restfb publish

restfb publish message FacebookType publishMessageResponse = facebookClient.publish("me/feed",                         FacebookType.class, Parameter.with("message", "hello test")); System.out.println("Published message ID: " + publishMessageResponse.getId()); photo from local FacebookType publishPhotoResponse = facebookClient.publish("me/photos", FacebookType.class,                         BinaryAttachment.with("icon.jpg", new FileInputStream("c:\\icon.jpg")),                         Parameter.with("message", "photo post")); photo from url InputStream inputpic = new URL("http://www.url.com/jpg.jpg").openStream();                 FacebookType publishPhotoResponse = facebookClient.publish("me/photos", FacebookType.class,                         BinaryAttachment.with("icon.jpg", inputpic), Parameter.with("message", "photo post"));

*** /dev/xvda1 should be checked for errors ***

解決*** /dev/xvda1 should be checked for errors *** Edit rcS file: sudo vi /etc/default/rcS add: FSCKFIX=yes run touch /forcefsck then reboot reference http://serverfault.com/questions/627371/how-can-i-check-dev-xvda1

UTF-8 CSV 亂碼問題

要寫入UTF-8 BOM表頭,才能用office直接打開不會看到亂碼。 out = response.getOutputStream();     //UTF-8 BOM out.write(new   byte []{( byte ) 0xEF ,( byte ) 0xBB ,( byte ) 0xBF });    http://rainbow702.iteye.com/blog/1426354 http://blog.darkthread.net/post-2009-09-06-csv-encoding-again.aspx http://boringfreeware.blogspot.tw/2013/05/office-excel-csv.html http://wen198599.pixnet.net/blog/post/22314819

mysql-connector-java設定方法

問題:java.lang.ClassNotFoundException: com.mysql.jdbc.Driver 1. 放到<web app>\WEB-INF\lib ps.此方法容易造成: Mar 02, 2015 8:40:45 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc SEVERE: The web application [] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered. Mar 02, 2015 8:40:45 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads SEVERE: The web application [] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak. 2. 用eclipse build path add your folder to the build path     Project Properties -> Java build path     Libraries -> add external lib or any other solution to add your files/folder add your build path to deployment Assembly (reference)     Project Properties -> Deployment Assembly    

eclipse format length

自動分行的字元長度設定: java Preferences -> Java -> Code Style -> Formatter / Edit -> Line wrapping -> Maximum line width html(include html and jsp) Preferences -> Web -> HTML Files -> Editor -> Line width xml Preferences > XML > XML Files > Editor > Line width 不要自動合併行設定: java Preferences -> Java -> Code Style -> Formatter / Edit -> Line wrapping -> Never join already wrapped lines html(include html and jsp) Preferences -> Web -> HTML Files -> Editor -> in line elements -> 移除不要併行的tag xml Preferences > XML > XML Files > Editor > 取消 join lines

修改MAC hostname主機名稱

修改方法: system Preferences - Sharing - Computer Name or Edit - Local Hostname 修改完成後重開機生效,在terminal的hostname也自動變更。 terminal指令:hostname 其他方法reference: sudo scutil --set HostName "newname" http://apple.stackexchange.com/questions/66611/how-to-change-computer-name-so-terminal-displays-it-in-mac-os-x-mountain-lion

Tomcat: A docBase inside the host appBase has been specified, and will be ignore

錯誤警告A docBase inside the host appBase has been specified, and will be ignore 因為${catalina.home}/webapps底下已經存在一個mywebapp, 而conf\Catalina\localhost\ROOT.xml 也指定同一個mywebapp的docBase, 導致啟動Tomcat時,檢測到webapp docBase已被載入過。 解決方法:將mywebapp移出 ${catalina.home}/webapps到其他路徑 reference http://blog.sina.com.cn/s/blog_7623ecc40100wvlo.html

架設VPN server

PPTP: 用win7內建的pptp vpn server L2TP: 用packetix vpn http://blog.xuite.net/sendohshih/blog/73932762 打開L2TP防火牆: windows->防火牆->進階設定->輸入規則->新增規則: Port->UDP:500,4500,1701 reference: http://blogs.technet.com/b/rrasblog/archive/2006/06/14/which-ports-to-unblock-for-vpn-traffic-to-pass-through.aspx

Ubuntu中安裝並設定VPN Server

Ubuntu中安裝並設定VPN Server http://igene.tw/vpn-server-install/

FB login error:Invalid redirect_uri

當FB login功能出現這個訊息: {    "error": {       "message": "Invalid redirect_uri: \u61c9....",       "type": "OAuthException",       "code": 191    } } 因為FB app限制redirect的ip或url,程式裡指定的redirect uri,必須符合fb app設定的資料,所以設定以下兩者之一,才能正常運作: 1.settings-basic-Site URL 2.settings-advanced- Security -Valid OAuth redirect URIs reference http://stackoverflow.com/questions/8100043/facebook-invalid-redirect-uri-but-the-url-looks-fine-to-me