2015年12月2日水曜日

MySQLでの実行コマンドの履歴を表示するには

MySQLのコマンドのログをチェックしたかったので調べたら、どうやらファイルが作成されているようだ。

cat ~/.mysql_history

http://stackoverflow.com/questions/7818031/sql-command-to-display-history-of-queries

SpringでUTF8エンコードで表示されない問題の解決方法

Spring MVCで文字エンコーディングがUTF8で表示されないので苦戦したが、どうやらエンコードで使っていたフィルターの順序が問題だったようなので、1番目に設定したらエンコード問題がなくなった。

 <filter>
     <filter-name>EncodingFilter</filter-name>
     <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
     <init-param>
         <param-name>encoding</param-name>
         <param-value>UTF-8</param-value>
     </init-param>
     <init-param>
         <param-name>forceEncoding</param-name>
         <param-value>true</param-value>
     </init-param>
 </filter>

http://stackoverflow.com/questions/16029269/utf-8-encoding-with-form-post-and-spring-controller

2015年9月13日日曜日

iPhotoの写真でビックリマークが出現した時の対処方法

MacのOSのバージョンアップを重ねたり、外付けハードが予期せぬ出来事でUSBから外れたりと、どういう状況で発生しているのか分かりませんが、iPhotoのアルバム内の写真がビックリマークの出現で表示できないという事態が起こる時があります。

こういう場合はiPhoto起動時にCommand+Optionを押すと、フォトライブラリFirst Aidを使う。データベースを修復というオプションで修復できない場合は、データベースの再構築で修復する。

参考:
https://discussions.apple.com/thread/3873468?start=0&tstart=0

2015年8月8日土曜日

Blocked loading mixed active contentが出た時に気をつけること

FirefoxのFirebugで"Blocked loading mixed active content..."というエラーが出てるので調べてみると、どうやらCDNを使ってHTMLページでインポートしてるJS/CSSファイルが読み込まれていない。

さらに掘り下げてみると、httpsで読み込んでるページからhttpでこれらのCDNからJS/CSSを読み込もうとするとエラーが出てるようだ。

What is Mixed Content?When a user visits a page served over HTTP, their connection is open for eavesdropping and man-in-the-middle (MITM) attacks. When a user visits a page served over HTTPS, their connection with the web server is authenticated and encrypted with SSL and hence safeguarded from eavesdroppers and MITM attacks.However, if an HTTPS page includes HTTP content, the HTTP portion can be read or modified by attackers, even though the main page is served over HTTPS. When an HTTPS page has HTTP content, we call that content “mixed”. The webpage that the user is visiting is only partially encrypted, since some of the content is retrieved unencrypted over HTTP. The Mixed Content Blocker blocks certain HTTP requests on HTTPS pages.
引用:
http://stackoverflow.com/questions/18251128/why-am-i-suddenly-getting-a-blocked-loading-mixed-active-content-issue-in-fire

要するに、HTTPSのページにHTTPリクエストで呼ばれているコンテンツがあると、それを”mixied(混在した)”コンテンツとみなし、MITM攻撃の被害になりえるのでやめて下さいとFirefoxが新しいバージョンではエラーとして表示してくれているようだ。

一般的な解決策は意外と簡単で、インポートしてるファイル(js/css)の構文をhttpからhttpsに変えてやればいい。もしくは//みたいな書き方でURLをブラウザが自動判別してくれるということ。

http://stackoverflow.com/questions/4831741/can-i-change-all-my-http-links-to-just

追加:

ただ、CDNによってはhttpからhttpsになぜかリクエストが変わってくれなかったので、そういうケースは泣く泣くCDNを使わずローカルにファイルを保存したりして回避した。

2015年8月5日水曜日

Tomcat6でjsessionidをURLから表示させないようにするには?

Tomcat6でjsessionidをURLから表示させないようにするには、context.xmlでContextの属性値をdisableURLRewriting="true"にしてやる。

<Context disableURLRewriting="true">
....
</Context>

http://tomcat.apache.org/tomcat-6.0-doc/config/context.html