2014-08-01から1ヶ月間の記事一覧

ParseDateが最新版rubyだと使えなくなったので使えるように変更する方法

http://docs.ruby-lang.org/ja/1.8.7/method/Date/s/parse.html 変更前 a1=ParseDate.parsedate(from_data) a2=ParseDate.parsedate(to_data) a1b=Date::new(a1[0],a1[1],a1[2]) a2b=Date::new(a2[0],a2[1],a2[2]) 変更後 a1b=Date.parse(from_data) a2b=Dat…

2つの値の最小値を求める1行野郎

2つの値の最小値を求める1行野郎 a=3 b=4 ruby -e "puts [$a,$b].min"

RスクリプトのCGI化やシステムコールで使う方法

CGIの設定は, http://d.hatena.ne.jp/arupaka-_-arupaka/20140820 Rの実行コマンドは,Rscript コマンドを使う. Rscript xxx.R コマンド引数 コマンド引数 コマンド引数は, args=commandArgs(trailingOnly=T) でargs配列に入る.そのため,スクリプトの一…

jqueryでopenコマンドの非同期処理を扱うまとめ

(1) 関数にする.function f(){} (2)関数内にDeferredクラスを導入,function f(){d=$.Deferred} (3)処理が済んだらd.resolve()をよぶ function f(){d=$.Deferred;処理;d.resolve;} (4)d.promise()をリターン function f(){d=$.Deferred;処理;d.r…

ファイルのパーミッションをrubyでいじる

FILEのパーミッションをrubyでいじる FileUtils.chmod(0777,output_dir) あたまに0がつくのがポイント。

RをCGI上で実行

R

コマンドの基本 R --vanilla --slave --args 12 サンプルRスクリプト test.R args=commandArgs(trailingOnly=T) cat(args[1]); test.R に読み込みと実効権限をつけておけばよい. chmod a+x test.R chmod a+r test.R plot関数をdevをpng(file="test.rb")に変…

CGIの起動

CGI

設定ファイルの場所: /etc/init.d/httpd Directory "/var/www/html" CGIの許可 http://httpd.apache.org/docs/2.0/ja/howto/cgi.html 設定ファイルの変更 /etc/init.d/httpd (1)CGIの許可 Options +ExecCGI (2)rubyの許可 #AddHandler cgi-script .cgi ↓変…

csvtohtml CSVからhtml作成

csvtohtml 681 awk -F"," 'NF==3{print 0}' summary_sort_400_b.txt 682 awk -F"," 'NF==3{print 0}' summary_sort400_b.txt 683 awk -F"," 'NF==12{print 0}' summary_sort400_b.txt 684 awk -F"," '{print NF}' summary_sort400_b.txt 685 awk -F"," 'NF==…

rebaseallのかけ方

http://rcmdnk.github.io/blog/2013/07/05/computer-windows-cygwin-git/を参考に cygsrv -l cygsrv -E cygserv -R ps -a ファイル名を指定して実行から cygwin/bin/ash.exehttp://stackoverflow.com/questions/19672690/error-no-commands-supplied-when-tr…

cygwin にruby on rails をcygwin上に導入

gem update rdoc gem install rail これでOK 次に最初のプログラム http://railstutorial.jp/chapters/beginning?version=4.0 を参考にやっていくこの方とほぼ同じはまり方 http://blog.livedoor.jp/nures/環境のrubyは ruby 1.9.3p545 (2014-02-24) [x86_…

javascriptでマウスオーバーしたら他のページをツールチップ風に表示

javascriptでマウスオーバーしたら他のページをツールチップ風に表示 メインページ <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"> <script> $(document).ready(function(){ $("p.test2").hover( function(){ //alert("test"); $(this).append('<div id="tmp"><iframe src="in1.html"></iframe></div>

TFIDFを計算

TFIDF http://d.hatena.ne.jp/download_takeshi/20081031/1225463411 http://d.hatena.ne.jp/yutakikuchi/20130215/1360884220 http://yudoufu.hatenablog.jp/entry/20110421/1303405920

ruby-mecabでワードカウント

ruby-mecabのインストールと説明は, http://d.hatena.ne.jp/arupaka-_-arupaka/20140812 # -*- coding: utf-8 -*- require 'MeCab' def word_counts(text,mecab) parsed=mecab.parseToNode(text) word_list=Hash::new(); word_list.default=0; while parsed…

cygwinにmecab-rubyの導入

mecabの導入は, http://d.hatena.ne.jp/arupaka-_-arupaka/20140701/1404175285 を参考に. mecab-rubyの導入 http://antimon2.hatenablog.jp/entry/2012/07/08/092702を参考に インストール wget https://mecab.googlecode.com/files/mecab-ruby-0.996.tar…

apacheのローカルへの導入 (あきらめた)

apacheのローカルへの導入 wget http://ftp.meisei-u.ac.jp/mirror/apache/dist//httpd/httpd-2.4.10.tar.gz gzip -d http* tar -xvf http* ./configure --prefix=/home/username/usr とすると configure: error: APR not found. Please read the documentat…

jqplotでズーム(corsor)してもマウスクリックイベントが起動するようにする postDrawHooksで

postDrawHooksにプロット後の事後処理を登録しておく. マウスオーバーイベントを登録する. ズームされるごとにマウスオーバーイベントがよばれるため、 グラフが更新されてマウスオーバーイベントがうごかくなるのを避けることができる.http://stackoverf…

jqplotでマウスイベント。データ点に触れたらデータラベルのアラート (ズーム後もでるようにする)

postDrawHooksにプロット後の事後処理を書いて、 マウスオーバーイベントをリロードする. http://stackoverflow.com/questions/10426192/jqplot-how-to-change-opacity-or-z-index-of-canvasoverlay <html> <head> <script src="js/jquery-1.11.1.js"></script> </head></html>

jqplotでつかったグラフの横にマウスオーバーしたら画像を表示

class1 class2 class3 を使って無理やりに. 親要素のclass3を取得して,そこに書き出す. <html lang="ja"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>tryjquery_hide_p test</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> </meta></head></html>

jqueryで表の列を移動させる2

8列目から3列目へ移動 >|html| $("input:button#test3a").click(function(){ alert("This is button\n"); str=$("#myTable tr th:nth-of-type(9):eq("+0+")").html() $("#myTable tr th:nth-of-type(4):eq("+0+")").after(''+str+''); $("#myTable tr th:nth…

jqueryで表の列を移動させる

8列目から3列目へ移動 >|html| $("input:button#test3a").click(function(){ alert("This is button\n"); str=$("#myTable tr th:nth-of-type(9):eq("+0+")").html() $("#myTable tr th:nth-of-type(4):eq("+0+")").after(''+str+''); $("#myTable tr th:nth…

jqueryで表の列を移動させる

8列目から3列目へ移動 >|html| $("input:button#test3a").click(function(){ alert("This is button\n"); str=$("#myTable tr th:nth-of-type(9):eq("+0+")").html() $("#myTable tr th:nth-of-type(4):eq("+0+")").after(''+str+''); $("#myTable tr th:nth…

jqplotで日付横軸に縦線(基本はUNIXTIME入力)

jqplotで日付横軸に縦線(基本はUNIXTIME入力). https://groups.google.com/forum/#!topic/jqplot-users/xfBTrKYBDS8 を参考に.

ruby一行野郎で日付の差分をもとめる

データ tmp.csv 2007-1-1,-,1 2007-1-2,-,1 2007-1-3,-,1 2007-1-5,-,1 2007-1-6,-,1 2007-1-12,-,1 cat tmp.csv | ruby -r Date -F"," -alne 'BEGIN{str1=Date.parse("2007-11-1")}; puts str1.to_s+","+$F[1]+","+(str1-Date.parse($F[0])).to_i.to_s; str…

時系列の複数のグラフを同時に制御して同じ範囲をズームできるようにする。

http://alphasis.info/2012/05/jquery-plugin-jqplot-cursor/を参考に とりあえずCSVファイルを入力に hisana_freq.csv id,date,counts 1,2007-1-1,32 2,2007-1-2,42 3,2007-1-2,23 出来上がりはこんな感じ スクリプト <html> <head> <script language="javascript" type="text/javascript" src="../js/jquery-1.11.1.js"></script> </head></html>