2013年5月29日水曜日

耳を意識するべし!

昔録画したTVを観ていて勉強になった。

電話をどちらの耳で聴くか、人それぞれだと思ってましたが、
意識して右耳で聴く方が良いようです。

何故かというと、聴いた音を処理するのが(記憶・言語を司る)左脳だからです。

右耳は左脳に繋がっていますが、
左耳は右脳へ繋がるため、右脳を通して左脳へと伝わります。

このタイムロスが、脳の処理能力に影響するとのこと。
右耳で聴く人の方が有利で、素早く把握できるというのです。

左耳で聴く人は、
・ためらって行動にできない
・過去を引きずる傾向がある
と。。。
自分はいつも左耳で電話を取ります。
音楽も外で聴くときは危ないので片耳だけイヤホンしたりしますが、
その時も左で聴いてました。

行動が遅い、というのはバッチリ当てはまります(^_^;)
これからは電話を右耳で聴くことに決めた私です。

2013年5月1日水曜日

eclipseからant実行すると、コンソールの日本語が文字化け


またeclipseでのant実行について。
以下の様な日本語を含んだprojectをantで実行すると、文字化けしてしまいました。
System.out.println(”こんにちは”);
↓
?????

ちなみに通常の実行からではちゃんと表示されます。

projectやソースコードの文字コードはUTF-8で統一しているのに何故?
と思って調べると、実行時にUTF-8ではなくなっているらしい。

build.xmlの<java>に、VM引数を指定しました。


<java classname="aa.HelloWorld" classpath="${classes.dir}" classpathref="classpath" fork="true">
            <jvmarg value="-Dfile.encoding=UTF-8" />
</java>
↓
こんにちは


きちんと表示されました!


antビルドで、javac:無効なフラグエラー

eclipseでant用にbuild.xmlを作成して実行していました。
といっても中身がよくわからないのでコピペしたものです。

案の定、ビルドを実行するとエラー。

javac: -g:lines, vars, sourceは無効なフラグです

。。。何が?
調べると、オプションの指定自体は(コピペしたので)合っている

結局、単にスペースが挟まっていたという凡ミス。
「, 」と、カンマの後ろにスペースがあった。
サンプルをファイルごとコピーしたのに、、

javac: -g:lines,vars,sourceは無効なフラグです

で、うまくいきました!


2013年4月21日日曜日

iPhone5、バグる。。

16GBのiPhone5さんにとうとう限界が来ました。

アプリを入れすぎてしまい、iTunesにバックアップしようとしたら
空き容量が足りませんといわれ、エラーに。

あーあと思って見てみると、なんだか異常な光景。。
アプリの一部がダウンロード中のような薄暗いアイコンになり、バーが表示されています。
でも全く進みません。
タップしてみると『待機中』となり、やっぱり全く進みません。

仕方ないので薄暗いやつを一旦全て削除し、iTunesで再度同期すると、
iPhoneとiTunesの表示が一致しないまま『完了』とか言われる。。
バックアップ削除したり、Macの内部にあったAppのライブラリを全て削除したり
いろいろやっていたのですが、もうひとつ異変が。
iPhoneの容量が表示されているところを見ると、Appではなく『その他』が10GBに!
しかも、アプリを削除しても減らない!

もうわけわかりません。再起動。

すると、アプリが増えてる!!
えっ!!
削除したやつが全部戻ってきた!!

どうやらエラーになった時点で何か内部情報が壊れたのか、
アプリがエラー直前の状態に戻ってしまう様子。
『その他』が10GBもあるのはこれか。。
完全にバグっている。

Appleさんのサポートに電話。
いろいろ試した結果、
『OSに問題があるのかも、出荷状態に戻しましょう』と、そうなりますか。

iTunesでバックアップとり、購入したアプリも退避、写真もMacに退避。
私はauさんなので、アドレス帳の復元は失敗することがあるとかないとか。
メールとかカレンダーとかも退避いるのかな、、、面倒だからもういいや!


iPhoneを『復元』!

iTunesが最新のOSをダウンロードしている。
ほうほう、OSを上書きして、iTunesからバックアップを戻す様子。

おっ、超簡単ではないですか。


やったー!!
その他容量が700MBに縮小、
空き容量が10GBに!
リフレッシュ!!

しかもメールやアドレス帳も戻っている!!


ふー、疲れた。

2013年3月20日水曜日

Bloggerにソースコードを表示 その2

前回書いたソースコードの表示では、縦のスクロールバーが表示されます。
でもいらないですよね。
前回追加したshCore.cssを自作のものに切り替えることで、表示を変更できます。
前回同様、こちらを参考にさせて頂きました。

1. Bloggerのメニューから、テンプレート > HTMLの編集
2. shCore.cssをコメントアウトし、保存
<!-- <link href='http://alexgorbatchev.com/pub/sh/current/styles/shCore.css' rel='stylesheet' type='text/css'/> -->
<link href='http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js' type='text/javascript'/>
3. Bloggerのメニューから、テンプレート > カスタマイズ > アドバンス > CSSを追加
4. 以下を貼り付けて、適用
<link -moz-border-radius:="" -webkit-border-radius:="" .5em="" .9em="" .bold="" .container="" .italic="" .line="" .syntaxhighlighter.collapsed="" .syntaxhighlighter.ie="" .syntaxhighlighter.nogutter="" .syntaxhighlighter.show="" .syntaxhighlighter.source="" .syntaxhighlighter="" .toolbar="" 0.1em="" 0.5em="" 0.8em="" 02="" 0="" 0em="" 1.1em="" 100="" 10="" 10px="" 11px="" 1em="" 1px-="" 1px="" 2004-2010="" 2010="" 20px="" 3.0.83="" a.expandsource="" a="" absolute="" alex="" alexgorbatchev.com="" and="" are="" auto="" background:="" baseline="" block="" bold="" border-box="" border:="" bottom:="" box-sizing:="" caption="" center="" code="" content-box="" copyright="" courier="" display:="" div="" donate.="" donate.html="" donationware.="" dual="" float:="" font-family:="" font-size:="" font-style:="" font-weight:="" gorbatchev.="" gpl="" height:="" hidden="" http:="" if="" important="" inherit="" inline="" is="" it="" italic="" itstream="" left:="" left="" license="" licensed="" licenses.="" line-height:="" margin-right:="" margin:="" min-height:="" mit="" mono="" monospace="" new="" none="" normal="" onsolas="" ourier="" outline:="" overflow-y:="" overflow:="" padding-left:="" padding-top:="" padding:="" please="" position:="" pre="" relative="" right:="" right="" sans="" span.title="" span="" static="" syntaxhighlighter="" table="" tbody="" td.code="" td.gutter="" td="" text-align:="" text-decoration:="" textarea="" the="" thead="" top:="" tr="" uly="" under="" using="" vera="" version="" vertical-align:="" visible="" white-space:="" white="" width:="" yntaxhighlighter="" you="" z-index:=""></link>20pxに変更,IEで最後の行が横スクロールバーに隠れるのを防ぐ
}
.syntaxhighlighter.ie .toolbar {
  line-height: 8px !important;
}
.syntaxhighlighter.ie .toolbar a {
  padding-top: 0px !important;
}
.syntaxhighlighter.printing .line.alt1 .content,
.syntaxhighlighter.printing .line.alt2 .content,
.syntaxhighlighter.printing .line.highlighted .number,
.syntaxhighlighter.printing .line.highlighted.alt1 .content,
.syntaxhighlighter.printing .line.highlighted.alt2 .content {
  background: none !important;
}
.syntaxhighlighter.printing .line .number {
  color: #bbbbbb !important;
}
.syntaxhighlighter.printing .line .content {
  color: black !important;
}
.syntaxhighlighter.printing .toolbar {
  display: none !important;
}
.syntaxhighlighter.printing a {
  text-decoration: none !important;
}
.syntaxhighlighter.printing .plain, .syntaxhighlighter.printing .plain a {
  color: black !important;
}
.syntaxhighlighter.printing .comments, .syntaxhighlighter.printing .comments a {
  color: #008200 !important;
}
.syntaxhighlighter.printing .string, .syntaxhighlighter.printing .string a {
  color: blue !important;
}
.syntaxhighlighter.printing .keyword {
  color: #006699 !important;
  font-weight: bold !important;
}
.syntaxhighlighter.printing .preprocessor {
  color: gray !important;
}
.syntaxhighlighter.printing .variable {
  color: #aa7700 !important;
}
.syntaxhighlighter.printing .value {
  color: #009900 !important;
}
.syntaxhighlighter.printing .functions {
  color: #ff1493 !important;
}
.syntaxhighlighter.printing .constants {
  color: #0066cc !important;
}
.syntaxhighlighter.printing .script {
  font-weight: bold !important;
}
.syntaxhighlighter.printing .color1, .syntaxhighlighter.printing .color1 a {
  color: gray !important;
}
.syntaxhighlighter.printing .color2, .syntaxhighlighter.printing .color2 a {
  color: #ff1493 !important;
}
.syntaxhighlighter.printing .color3, .syntaxhighlighter.printing .color3 a {
  color: red !important;
}
.syntaxhighlighter.printing .break, .syntaxhighlighter.printing .break a {
  color: black !important;
}
これで、縦スクロールバーが表示されなくなります!!

2013年3月19日火曜日

Bloggerにソースコードを表示

ソースコードを綺麗に表示するには、
『SyntaxHighlighter』を使用すると良いようです。

こちらを参考にさせて頂きました。

すぐやりたい!という人は、以下でできます。

1. Bloggerのメニューから、テンプレート > HTMLの編集
2. </head>の直前に、以下を追記し、保存。
<link href="http://alexgorbatchev.com/pub/sh/current/styles/shCore.css" rel="stylesheet" type="text/css"></link>
<link href="http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css" rel="stylesheet" type="text/css"></link>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCpp.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCSharp.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPhp.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPython.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushRuby.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushVb.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPerl.js" type="text/javascript"></script>
<script language="javascript">
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/current/scripts/clipboard.swf';
SyntaxHighlighter.all();
</script>
3. Bloggerのメニューから投稿、『作成』ボタンの横にある『HTML』を選択
4. 『<』を『&lt;』に置換したソースコードを以下のように貼り付ける

<pre class="brush: ◯; first-line: 1; highlight: [,];" title="">
ソースコード
</pre>

※◯に言語を指定、例えばJavaなら『brush:java;』、C++なら『brush:cpp』
 この指定が、2.で4-15行目に読み込んでいるscriptに対応付けられます。
 詳細は参考サイトをご覧ください

※highlight: [,];で行番号を指定すると、行を強調できます。
 2.では、highlight: [4,5,6,7,8,9,10,11,12,13,14,15];としています。

2013年3月18日月曜日

foreachのコンパイルエラー

C++ -> androidプロジェクト
へのビルドでエラー。

range-based-for loops are not allowed in C++98 mode

なんてこった、 C++98では、foreachには対応していないらしい。。
Iteratorには対応しているらしいですが、Iteratorの書き方忘れた…
ということでベタに、
    std::vector<Levelhelper_tag> tags;

    tags.push_back(OBJECT_A);
    tags.push_back(OBJECT_B);

    for (LevelHelper_TAG tag : tags) {

    }
としていたのを、
    std::vector<LevelHelper_TAG> tags;

    tags.push_back(OBJECT_A);
    tags.push_back(OBJECT_B);

    for (int i = 0; i < tags.size(); i++) {
        LevelHelper_TAG tag = tags.at(i);
    }
としたら、通りました。