2016年11月30日水曜日

C#でWindowアプリケーションを作る方法

VC#を書くのに,VSではなくVimとコマンドプロンプトを使う人なので,
VSのこの設定を変えればいいよ!ってドコにあるんだろう?をしていました.

コマンドプロンプトから
>C:\Windows\Microsoft.NET\Framework\vx.x.xxxxx\csc.exe source.cs
を叩くとデフォルトではコンソールアプリケーションになるため,
.exeを実行した時にコマンドプロンプトが表示されてしまって正直うっとうしい.

/target:winexeオプションを追加してコンパイルすることでこの問題を解決できるらしい.


ちょっとモヤモヤが解決したのでした.

2016年6月24日金曜日

Developing your plugin for Icy:

Development environment


First, We should prepare the development environment by following Icy Document.
http://icy.bioimageanalysis.org/index.php?display=startDevWithIcy


I recommend you to do following all 4 steps.
By running hello World Plugin, we can check that the environment works or not.

1. Install Eclipse
2. Install Icy4Eclipse plugin
3. Configure Icy4Eclipse
4. Write your first plugin


Export Plugin


The upper way to run your plugin, max memory configure of icy does not work.
But by normal starting icy, your plugins is not found.
To load your plugins when icy is started by normal way, you have to export your plugin.

First, make your own folder under icy/plugins/. ( You set the folder name login name of your setting upper 3. step better.)
Then return to Eclipse, right click your project and select Export.
Select Java->JAR file and click Next.
Set like following picture and click Finish.
Then start icy by normal way, your plugin will be found!






Import Plugin(Advanced)


If you want to modify someone's plugin, you have to import .jar file into Eclipse.
In Eclipse select File->new Java Project, set Project name, select "Use default JRE",
select "Create separate folders for sources and class files", and click Finish.
Then select src folder and File->import  and import the plugin which you want to modify.
Right click project , select properties, select Icy tab and check "Is an Icy project".
Then reading error message, right click project, select Build path-> Add External Archives,
 import .jar files to fix the error.
NOTE the package name have to be fixed plugins.[your login name].[Project name].




2016年5月13日金曜日

Virtualboxで物理ディスクをブートする(Ubuntuホスト,Windowsゲスト)

日頃からWindowsもUbuntuもよく使うので思うのだが,
ホスト>ゲスト
という力関係が煩わしいことがある.

例えば,Ubuntuホスト,Windowsゲストの環境で,Windowsだけを使いたい場合にも1度Ubuntuを起動しなければならない.
それならデュアルブートすればいいじゃないかという話だが,Ubuntuを使ってる時にちょっとWindowsを使いたくなったとかいう状況が面倒くさい.

そこで,デュアルブートしといてVirtualboxから物理ディスクを起動できれば便利なのになぁと思ったらできるようなのでやってみたので作業ログ.

作りたかった環境はHostOS=Ubuntu14.04,GuestOS=Windows10.
UbuntuもWindowsもそれぞれ別のディスクにインストール済みである.
(別ディスクじゃなくてパーティション切っても行けると思う)

まず,Windows側の設定.
コンパネ→電源オプション→電源ボタンの動作を選択する→現在利用可能ではない設定を変更します
の順にクリックし,「現在利用可能ではない設定を変更します」をクリックし,
「高速スタートアップを有効にする(推奨)」のチェックを外す.
これをやっとかないとUbuntu側からうまくマウントできない.
ちなみに,こちらを参考にさせてもらった.

次に,Ubuntu側の設定.こちらこちらを参考にさせてもらった.
まず,自分をdiskグループに追加する.

$ sudo fdisk -l
でディスクを確認する.
Bootの項目に*が入っているディスクがbootableディスクだから"/dev/sd.."を覚えておく.
当環境ではLinux用とWidows用に2つ*が入っているディスクがあるが,Windows用の方を覚えておく.
次に,
$ ls -al /dev/sd..
を打ち込む./dev/sd..の部分はさっき覚えたディスク名にする.
ここでグループを確認する.(おそらくdiskグループだろう)

$ sudo gpasswd -a YOUR_USERNAME disk

を実行して,自分をdiskグループに追加する.(diskグループでなかった場合は先ほど確認したグループに適宜変更)
で,一度再起動する必要があるので再起動.
$ sudo reboot

再起動したら,次は仮想ディスクを作成する.
物理ディスクへのリンクみたいなもんなのかな???
$ VBoxManage internalcommands createrawvmdk -filename "</path/to/file>.vmdk" -rawdisk /dev/sd..

<path/to/file>と/dev/sd..は適宜変更する.

ここまでできたら,あとはVitualboxから新しい仮想マシンを作成し,Hard driveをどうするかと聞かれるので"Use an existing virtual hard drive file"にチェックを入れて今作成したディスク(hogehoge.vmdk)を選択するだけ.




余談だが,Virtualboxのホストキーは右Ctrlだが,右Ctrlがないキーボードを使っている場合は起動する前に変更するのを忘れないようにする.

2016年1月31日日曜日

TeXで図を並べる

自分はTeXで図を並べるとき、

\begin{figure}
  \begin{center}
  \begin{tabular}{cc}
    \includegraphics[width=0.45\hsize]{hoge.png} &
    \includegraphics[width=0.45\hsize]{hoge.png} \\
    (a) hoge &
    (b) hoge \\
    \includegraphics[width=0.45\hsize]{hoge.png} &
    \includegraphics[width=0.45\hsize]{hoge.png} \\
    (c) hoge &
    (d) hoge \\
  \end{tabular}
  \end{center}
\end{figure}

みたいに書くのですが、図が大きいと縦にはみ出ることがある。
で、longtableを使えば解決するのかなと思ったんですが、どうやらfigure内でpagebreakすることができないらしい。
でも、figureを2個にすると図番号がなぁ...とか思ってたら、figure*するといいらしい。
具体的には
\begin{figure*}
  \begin{center}
  \begin{tabular}{cc}
    \includegraphics[width=0.45\hsize]{hoge.png} &
    \includegraphics[width=0.45\hsize]{hoge.png} \\
    (a) hoge &
    (b) hoge \\
  \end{tabular}
  \end{center}
\end{figure*}
\begin{figure}
  \begin{center}
  \begin{tabular}{cc}
    \includegraphics[width=0.45\hsize]{hoge.png} &
    \includegraphics[width=0.45\hsize]{hoge.png} \\
    (c) hoge &
    (d) hoge \\
  \end{tabular}
  \end{center}
\end{figure}
って書いとけばOKって話。
\section*{hoge}的なのは知ってたけど、figureとかにも*が使えるっぽいですね。
勉強になりました。


2016年1月7日木曜日

vimの色をあれこれする

お久しぶりです。

普段ゲームしなくてもテスト前になると何故かゲームしたくなる現象ってありますよね。
そんな感じで、卒論で忙しくなったのでvimの色をあれこれ設定しています。
ubuntuのターミナル色が見やすいなぁとは思い、windowsでも同様の色設定にしたいなぁと思いまして。


$VIMRUNTIME/colors/mycolor.vim
なるファイルを作成して、
$VIMRUNTIME/syntax/syncolor.vim
の色設定の部分をコピー。
SynColorをhighlightにSynLinkをhighlight default linkに変更すればそれっぽくはなるようです。

ubuntuのターミナルの色は
/usr/share/gconf/schemas/gnome-terminal.schemas
に書いてありました。
背景色は#300A24みたいです。

:so $VIMRUNTIME/syntax/colortest.vim
コマンドを実行して使える色名を見ます。
/usr/share/gconf/schemas/gnome-terminal.schem
に書かれているカラーコードと合わせると、各色名は以下の様なカラーコードになります。

" background  = #300a24
" black       = #2e3436
" darkred     = #cc0000
" darkgreen   = #4e9a06
" brown       = #c4a000
" darkblue    = #3465a4
" darkmagenta = #75507b
" darkcyan    = #06989a
" lightgray   = #d3d7cf
" darkgray    = #555753
" red         = #ef2929
" green       = #8ae234
" yellow      = #fce94f
" blue        = #729fcf
" magenta     = #ad7fa8
" cyan        = #34e2e2
" white       = #eeeeec

ctermfgに書かれている色名と対応するカラーコードをguifgに叩きこめば完成。


colorschemeの書き方は検索すれば出てくるのでそれを参考にすれば...

ちなみに、デフォルトの背景色を設定するのは
highlight Normal ...
に色をいじればできるっぽいですね。


見た感じはなんかそれっぽい。




一応、作った.vimを投げとくので参考までに。




let g:colors_name = expand('<sfile>:t:r')
set background=dark
highlight clear

if exists("syntax_on")
    syntax reset
endif

" background  = #300a24
" black       = #2e3436
" darkred     = #cc0000
" darkgreen   = #4e9a06
" brown       = #c4a000
" darkblue    = #3465a4
" darkmagenta = #75507b
" darkcyan    = #06989a
" lightgray   = #d3d7cf
" darkgray    = #555753
" red         = #ef2929
" green       = #8ae234
" yellow      = #fce94f
" blue        = #729fcf
" magenta     = #ad7fa8
" cyan        = #34e2e2
" white       = #eeeeec

highlight Normal     term=NONE      cterm=NONE      ctermfg=black      ctermbg=NONE gui=NONE      guifg=#eeeeec guibg=#300a24

highlight Comment    term=bold      cterm=NONE      ctermfg=DarkBlue    ctermbg=NONE gui=bold      guifg=#3465a4 guibg=NONE
highlight Constant   term=underline cterm=NONE      ctermfg=DarkRed     ctermbg=NONE gui=NONE      guifg=#cc0000 guibg=NONE
highlight Special    term=bold      cterm=NONE      ctermfg=DarkMagenta ctermbg=NONE gui=bold      guifg=#75507b guibg=NONE
highlight Identifier term=underline cterm=NONE      ctermfg=DarkCyan    ctermbg=NONE gui=NONE      guifg=#06989a guibg=NONE
highlight Statement  term=bold      cterm=NONE      ctermfg=Brown       ctermbg=NONE gui=bold      guifg=#c4a000 guibg=NONE
highlight PreProc    term=underline cterm=NONE      ctermfg=DarkMagenta ctermbg=NONE gui=NONE      guifg=#75507b guibg=NONE
highlight Type       term=underline cterm=NONE      ctermfg=DarkGreen   ctermbg=NONE gui=bold      guifg=#4e9a06 guibg=NONE
highlight Underlined term=underline cterm=underline ctermfg=DarkMagenta              gui=underline guifg=#75507b
highlight Ignore     term=NONE      cterm=NONE      ctermfg=white       ctermbg=NONE gui=NONE      guifg=bg      guibg=NONE

highlight Error     term=reverse  cterm=NONE ctermfg=White ctermbg=Red    gui=NONE guifg=White guibg=Red
highlight Todo      term=standout cterm=NONE ctermfg=Black ctermbg=Yellow gui=NONE guifg=Blue  guibg=Yellow

highlight default link String         Constant
highlight default link Character      Constant
highlight default link Number         Constant
highlight default link Boolean        Constant
highlight default link Float          Number
highlight default link Function       Identifier
highlight default link Conditional    Statement
highlight default link Repeat         Statement
highlight default link Label          Statement
highlight default link Operator       Statement
highlight default link Keyword        Statement
highlight default link Exception      Statement
highlight default link Include        PreProc
highlight default link Define         PreProc
highlight default link Macro          PreProc
highlight default link PreCondit      PreProc
highlight default link StorageClass   Type
highlight default link Structure      Type
highlight default link Typedef        Type
highlight default link Tag            Special
highlight default link SpecialChar    Special
highlight default link Delimiter      Special
highlight default link SpecialComment Special
highlight default link Debug          Special