2015/07/05

DAT 変換 ren

datとは、ファイル全般に対して用いられることがある汎用の拡張子である。ファイルタイプやアプリケーションの種類に関わらず使用される可能性がありま す。DATファイルとは、ファイル形式・拡張子の一つだが、標準化されたデータ形式ではなく、 アプリケーション独自の形式で保存されたデータのファイル名の拡張子などによく使われます。一般的なデータファイル、電子メールで添付ファイルとして winmail.datおよびVCDのビデオファイル三つの種類があります。

 XMediaRecode
http://www.forest.impress.co.jp/library/software/xmediarecode/download_10952.html

REN *.bat *.mpge

VCDにあるDATファイルをMPEGを修正して、見えるようになった。。

2015/06/24

Charles ios

CharlesのFAQにある通り、iPhoneにSSL証明ををインストールする必要があります。iPhoneのSafariから http://charlesproxy.com/charles.crt にアクセスし、SSL証明書をインストールしてください。

2015/06/21

windows user 自動 ログイン

Crl+R

Windows7
control userpasswords2
==>ログインユーザーパスポートが必要、チェックアウトする

control userpasswords2出ない

rundll32 netplwiz.dll,UsersRunDll
 
 
 

2015/06/06

改行コード DB java client?

つまらないことですが、思う通り行かない困るね。。。
世の中そんなことが多いと思いますが、
そんなことに時間を取られて、結局つまらないね。。。

DBに下記をinsert
 "今日は土曜日。\n明日は日曜日"
改行したいです!!

javaでoutPutして見る
System.out.print(description);
==> "今日は土曜日。\n明日は日曜日"

値は\\nになっている。


じゃ。。。

DB  "今日は土曜日。rn明日は日曜日"
JAVA 
        product.setDescription(product.getDescription().replaceAll("rn", "\n"));
System.out.println(product.getDescription());
==>
OK!!

2015/06/03

log4j pattern

%c ログイベントのカテゴリー名を出力する。
%C ロギング要求を行うクラス名を出力する。
%d ログイベントの日時を出力する。
%d{HH:mm:ss} や %d{dd MMM yyyy HH}として、より柔軟に日時情報を出力することが出来る。
%F(*) ログ要求が発生したファイル名を出力する。
%l(*) ログが生成されたときに呼び出された位置(ソース名、行)を出力する。
%L(*) ロギング要求を行なった行番号を出力する。
%m ロギングイベントで設定されたメッセージを出力する。
%M(*) ログ要求が行なわれたメソッド名を出力する。
%n プラットフォーム依存の改行文字を出力する。
%p ログの優先度を出力します。
%r アプリケーションが開始してから、ログが出力されるまでの時間をミリ秒単位で出力する。
%t ログを生成したスレッドの名前を出力する。
%x ログが生成されたスレッドのNDC(ネスト化診断コンテキスト) を出力する。
%% %を出力する。


 例:
<PatternLayout>
                <Pattern>%d %c{1.} [%t] %m%n</Pattern>
  </PatternLayout>

2015/05/29

時間 intergerで表示 java

    long now = System.currentTimeMillis();
==>1432909782064 13桁!

十桁で時間を表示する?
例: 1336383401 (2012-05-07 09:36:41Z)
UNIX時間 
10ケタの秒数で年月日時分秒すべて表現する

何が違う????

秒の表示とミリ秒の表示かな!!?
10            13

じゃ、13桁の方を1000で割り、で比較できるね!!!

2015/04/29

Git push halts on “Writing Objects: 100%”

getting this msg:
Counting objects: 8, done.
Compressing objects: 100% (3/3) done,
Writing objects: 100% (6/6)
This does not finish. I have introduced only a small change, so this should be completed very quickly.
am i doing something wrong here?


=->
git config --global  sendpack.sideband false

Git は send-packreceive-pack のプロセスを使用します。send-pack プロセスはクライアント上で実行されリモートサイド上の receive-pack プロセスに接続します。
sideband-->片方が阿呆になる??


http://git-scm.com/book/ja/v2/Git-Internals-Transfer-Protocols
これ後で読むね!!

Windows Git server

Git for Windowsをインストールする
改行コードを変更しないで

E:/gitServer/testRepo.git
でgit Bashを起動


git init --bare --shared=true
touch ./git-daemon-export-ok
git daemon --export-all --enable=receive-pack --base-path=/C/git


==これでサーバー起動完了
 ==>windowのサービスにして、便利
 sc create servicename binPath= "C:\hoge\hogehoge.exe"
“binPath= “の後ろには1つスペースが必要とのこと。

「SC」 Create Service Success!
==>これで起動時エラになる、Sexeを仲介にして登録、起動できた!

★他のPCから接続テスト

git clone git://<リモートリポジトリを構築したPCのIPアドレス>/tesRepo.git

2015/04/25

Http Boundary

コンテントタイプに以下を指定します。
Content-Type: multipart/form-data; boundary=「バウンダリ文字列」\r\n
バウンダリ文字列とは、複数の情報を続けて送る際の情報同士の「仕切線」の役目を果たします。この文字を調べて「仕切線」と判断するため、情報そのものにバウンダリ文字列が入っていてはいけません。
FireFoxで転送してみた内容を見てみると「---------------------------102852708831426」というように「-」27文字と数字15文字で構成されており、ランダムの数字が付いていました。
\r\nは改行文字を示します。

 IOSは
Boundary+5BA6C7D5E1A37EBE
Boundary+5BA6C7D5E1A37EBE
Boundary+5A402217BB55E461
Boundary+0A6551C579D31296
風、、、

headers.add(new BasicHeader("Content-type", multipart/form-data; boundary=Boundary+0A6551C579D31296
));
MultipartEntityBuilder.setBoundary("");

MultipartEntityBuilder and Charset

日本語化けになっている。。
 
 
entity.addTextBody("plain_text", plain_text);
will use the default ContentType.TEXT_PLAIN which look like this...
public static final ContentType TEXT_PLAIN = ContentType.create("text/plain", Consts.ISO_8859_1);

while ContentType.APPLICATION_JSON is using UTF-8 as below
public static final ContentType APPLICATION_JSON = ContentType.create("application/json", Consts.UTF_8);

So what i did was create our own ContentType like this..
entity.addTextBody("plain_text", plain_text, ContentType.create("text/plain", MIME.UTF8_CHARSET));

MultipartEntityBuilder: Omit Content-Type and Content-Transfer

What I want (what my chrome browser does):
POST .../some.jsp HTTP/1.1
Host: ...
Connection: keep-alive
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary6tcnkxC7txvqE5Xl


------WebKitFormBoundary6tcnkxC7txvqE5Xl
Content-Disposition: form-data; name="merkmal"

5
What I get from MultipartEntityBuilder
POST.../some.jsp HTTP/1.1
Host: ...
Content-Type: multipart/form-data; boundary=m9Zb2QD-QaH-j-HqgGQfI8KwDkToz17ULYkZ

--m9Zb2QD-QaH-j-HqgGQfI8KwDkToz17ULYkZ
Content-Disposition: form-data; name="merkmal"
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit

===>
 lright - intense googeling finally produced an answer.

1) There are apparently some servers that do not get on well with the "Content-Transfer-Encoding" header.
2) There is a browser compatibility mode in HttpComponents that is used like this:
MultipartEntityBuilder uploadEntityBuilder = MultipartEntityBuilder.create().setMode(HttpMultipartMode.BROWSER_COMPATIBLE);

2015/04/19

MIME Content-Type 表

MIME Content-Type 表

テキスト/ドキュメント

説明 拡張子 MIME Content-Type
HTML(Hyper Text Markup Language) html, htm text/html
LaTeX tex, latex, ltx application/x-latex
PDF(Portable Document Format) pdf application/pdf
Postscript ps application/postscript
Rich Text Format rtf application/rtf
SGML(Standard Generalized Markup Language) sgm, sgml text/sgml
TSV/タブ区切り形式 tab, tsv text/tab-separated-values
TeX tex application/x-tex
Text ファイル txt text/plain
XML(eXtended Markup Language) xml text/xml

圧縮

説明 拡張子 MIME Content-Type
JAR(Java Archiver) jar application/java-archiver
Compact Pro cpt application/mac-compactpro
GZIP(GNU ZIP) gz application/gzip
application/x-gzip
BinHex(テキストエンコード;Macintosh) hqx application/mac-binhex40
shar(Shell Archiver) sh, shar application/x-sh
application/x-shar
sit(StuffIt) sit application/x-stuffit
tar(Tape Archiver) tar application/x-tar
Compress z application/x-compress
ZIP(Zigzag In line Package) zip application/zip
application/x-zip-compressed

イメージ

説明 拡張子 MIME Content-Type
Illustrator ai application/postscript
BMP/Windows Bitmap bmp, rle, dib image/x-bmp
image/x-ms-bmp
CGM(Computer Graphics Metafile) cgm image/cgm
AutoCAD DWF(Drawing Web Format) dwf drawing/x-dwf
EPS(Encapsulated Postscript Format) epsf, eps, ps appilcation/postscript
FIF(Fractal Image Format) fif image/fif
FlashPix fpx image/fpx
image/x-fpx
GIF(Graphics Interchange Format) gif image/gif
JPEG(Joint Photographics Experts Group) jpg, jpeg, jpe, jfif, jfi image/jpeg
Kodak PhotoCD pcd image/pcd
image/x-photo-cd
PICT(QuickDraw Picture) pict, pct image/pict
PNG(Portable Network Graphics) png image/x-png
image/png
TGA(Targa)、VDA(Video Display Adapter) tga, tpic, vda, vst image/x-targa
TIFF(Tag Image File Format) tiff, tif image/tiff
image/x-tiff
VRML wrl model/vrml
x-world/x-vrml
xbm(X Bitmap format) xbm image/x-bitmap
xpm(X Pixmap) xpm image/x-xpixmap



サウンド

説明 拡張子 MIME Content-Type
AIFF(Audio Interchange File Format) aiff, aif audio/aiff
audio/x-aiff
au(Audio File) au audio/basic
MIDI カラオケ kar audio/midi
audio/x-midi
MPEG 1 Audio Stream m1a audio/mpeg
audio/x-mpeg
MPEG 2 Audio Stream m2a audio/mpeg
audio/x-mpeg
MIDI midi, mid, smf audio/midi
audio/x-midi
MPEG 1 Layer 2 Audio Stream mp2 audio/mpeg
audio/x-mpeg
MPEG 1 Layer 3 Audio Stream mp3 audio/mpeg
audio/x-mpeg
MPEG Audio Stream mpa, mpega audio/mpeg
audio/x-mpeg
Real Audio rpm audio/x-pn-realaudio-plugin
Next SND snd audio/basic
Shockwave Audio swa application/x-director
Twin VQ vqf audio/x-twinvq
WAVE wav audio/wav
audio/x-wav

動画

説明 拡張子 MIME Content-Type
Shockwave for Authorware aab application/x-authorware-bin
Shockwave for Authorware aam application/x-authorware-map
Shockwave for Authorware aas application/x-authorware-seg
Advanced Streaming Format asf video/x-ms-asf
AVI avi vide/x-msvideo
Shockwave for Director dcr, dir, dxr application/x-director
Autodesk Animator flc, fli video/flc
MNG(Multiple Network Graphics) mng video/mng
video/x-mng
MPEG 1 System Stream m1s vide/mpeg
video/x-mpeg
MPEG 1 Video Stream m1v vide/mpeg
video/x-mpeg
MPEG 2 System Stream m2s vide/mpeg
video/x-mpeg
MPEG 2 Video Stream m2v vide/mpeg
video/x-mpeg
Apple QuickTime Movie moov, mov, qt video/quicktime
MPEG Video/Audio/System mpeg, mpg, mpe, mpv vide/mpeg
video/x-mpeg
Power Point ppt application/mspowerpoint
application/ppt
RealMedia rm audio/x-pn-realaudio
Flash 1 & Future Splash Animator spl application/futuresplash
Flash 2 swf application/x-shockwave-flash
VDOLive vdo video/vdo
VivoActive viv, vivo video/vnd.vivo
StreamWorks xdm, xdma application/x-xdma

その他

説明 拡張子 MIME Content-Type
Channel Definition format cdf application/x-netcdf
Java クラスファイル class application/octet-stream
Windows 実行ファイル exe application/exe
application/octet-stream
Perl スクリプト pl application/x-perl
RealAudio Meta File ram audio/x-pn-realaudio
Active X Document vdb application/activexdocument
TwinVQ vqe, vql audio/x-twinvq-plugin
audio/x-twinvq

java Strings.format 特殊文字

書式 説明
% 指定を開始する。「%」自身を出力したい場合は「%%」とする。 printf("%%%n"); %
d 整数を十進数で出力する。(nullの時は「null」) printf("%d%n", 123); 123
o 整数を八進数で出力する。(nullの時は「null」) printf("%o%n", 123); 173
x 整数を十六進数で出力する。(nullの時は「null」) printf("%x%n", 123); 7b
c 文字を出力する。(nullの時は「null」) printf("%c%n", 'x'); x
s 文字列を出力する。(nullの時は「null」)
toString()あるいはFormattableで文字列に変換される)
printf("%s%n", "xyz"); xyz
- 左詰で出力する(省略時は右詰)。 printf("[%-4d]%n", 123);
printf("[%-4s]%n", "xyz");
[123 ]
[xyz ]
0 足りない桁数を0埋めする。
数値系(%d,%o,%x)で使用可能。[2009-10-21]
他(例えば%s,%b,%h)では使用不可(例外が発生する)。
printf("%04d%n", 123);
printf("%04x%n", 123);
0123
007b
# 代替フォームで変換する。
すなわち、「%o」において頭に「0」を、「%x」において頭に「0x」を付けて出力する。
%s」の場合はデフォルトでは特に何も無さそう。「%d」では例外が発生する。
printf("%#o%n", 123);
printf("%#x%n", 123);
printf("%#s%n", 123);
0173
0x7b
123
桁数(最小フィールド幅)を指定する。
最低限確保される桁数であり、この数値以上の桁の値は全部出力される。
%s(文字列)の場合は、文字数である
printf("[%4d]%n", 123);
printf("[%4s]%n", "xyz");
printf("[%4s]%n", "xyzab");
printf("[%4s]%n", "あいう");
[ 123]
[ xyz]
[xyzab]
[ あいう]
.数 精度(最大表示幅)を指定する。
この桁数より大きい場合は切り捨てられ、出力されない。
%s(文字列)の場合は、文字数である
printf("[%.4s]%n", "xyzab");
printf("[%5.4s]%n", "xyzab");
printf("[%-5.4s]%n", "xyzab");
printf("[%-5.4s]%n", "あいうえお");
[xyza]
[ xyza]
[xyza ]
[あいうえ ]
数$ 引数の番号を指定する(値の引数のうち、一番左が1)。
通常これは省略されており、その場合は引数の並び順に従って値が出力される。
C言語とJavaの違い
printf("%d:%d:%d%n",11,22,33);
printf("%1$d:%2$d:%3$d%n",11,22,33);
printf("%3$d:%2$d:%1$d%n",11,22,33);
printf("%3$d:%1$d:%d%n",11,22,33);
11:22:33
11:22:33
33:22:11
33:11:11

2015/04/07

htmlClient EntityUtils.consume?? why

try {

    //... some code

    HttpEntity httpEntity = httpResponse.getEntity();
    BufferedReader br = new BufferedReader(new InputStreamReader(http.Entity.getContent()));
    String line;
    while ((line = br.readLine())!= null) {
        System.out.println(line);
    }
    EntityUtils.consume(httpEntity);
} catch (Exception e) {
    //code
} finally { 
    httpClient.getConnectionManager().shutdown();
}
 
 What EntityUtils.consume will do is release all resources held by the httpEntity,
 which essentially implies releasing any underlying Stream and giving 
the Connection object back to its pool (in the case your connection 
manager is a multithreaded one) or freeing the connection manager so 
that it can process the next request.


何かメモリを開放するみたいね

2015/04/05

java ssl charles

httpClientからhttpsを接続する時、firefox/iosのように証明書が必要....

$JAVA_HOME/jre/lib/security/cacerts, where JAVA_HOME is your java home directory for the JVM you’re using.

keytool -import -alias charles -file charles-proxy-ssl-proxying-certificate.crt -keystore JAVA_HOME/jre/lib/security/cacerts -storepass changeit

(changeit is the default password on the cacerts file)
Then try: keytool -list -keystore JAVA_HOME/jre/lib/security/cacerts -storepass changeit