Skip to content

Instantly share code, notes, and snippets.

@ysaito8015
ysaito8015 / file0.txt
Created December 3, 2013 06:23
ubuntu 13.10 で capslock を ctrl へ変更する ref: http://qiita.com/ysaito8015@github/items/0fd4ec3076293bc372d4
% xmodmap -pke> "~/.xmodmap"
@ysaito8015
ysaito8015 / calcOddsRatio.R
Created May 11, 2014 01:19
オッズレシオ計算スクリプト
calcOddsRatio <- function(mymatrix,alpha=0.05,referencerow=2,quiet=FALSE)
{
numrow <- nrow(mymatrix)
myrownames <- rownames(mymatrix)
for (i in 1:numrow)
{
rowname <- myrownames[i]
DiseaseUnexposed <- mymatrix[referencerow,1]
ControlUnexposed <- mymatrix[referencerow,2]
if (i != referencerow)
@ysaito8015
ysaito8015 / calcRerativeRist.R
Created May 11, 2014 01:21
相対危険度スクリプト
calcRelativeRisk <- function(mymatrix,alpha=0.05,referencerow=2)
{
numrow <- nrow(mymatrix)
myrownames <- rownames(mymatrix)
for (i in 1:numrow)
{
rowname <- myrownames[i]
DiseaseUnexposed <- mymatrix[referencerow,1]
ControlUnexposed <- mymatrix[referencerow,2]
if (i != referencerow)
@ysaito8015
ysaito8015 / calcMHRatio.R
Last active August 29, 2015 14:01
対症例対照研究(Matched Case-Control Study) Mantel-Haenszel のオッズ比計算スクリプト
calcMHRatio <- function(mymatrix, alpha=0.05)
{
caseExposedControlUnexposed <- mymatrix[1, 2]
caseUnexposedControlExposed <- mymatrix[2, 1]
MHRatio <- caseExposedControlUnexposed / caseUnexposedControlExposed
print(paste("Mantel-Haenszelのオッズ比 =", MHRatio))
# 信頼区間の計算
confidenceLevel <- (1 - alpha) * 100
sigma <- sqrt((1 / caseExposedControlUnexposed) + (1 / caseUnexposedControlExposed))
# sigmaは,オッズ比の対数の推定値の標準誤差
@ysaito8015
ysaito8015 / calcTaronesTest.R
Last active August 29, 2015 14:01
層によるオッズ比が異なるかどうかを検定するに は,Tarone の検定を利用する. Taroneの検定スクリプト
##metaforパッケージをインストールする
#install.packages("metafor")
#library("metafor")
calcTaronesTest <- function(mylist,referencerow=2)
{
numstrata <- length(mylist)
# 各層における曝露グループの人数のアレイ"ntrt"を作る
# 各層における非曝露グループの人数のアレイ"nctrl"を作る
# 各層における疾病を持つ曝露グループの人数のアレイ"ptrt"を作る
#/usr/bin/env bash
set -e
set -x
apt-get update
apt-get upgrade
apt-get -y install build-essential curl git-core openssl libreadline6 libreadline6-dev \
zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev \
#確率密度(対数正規分布 平均log=5,sdlog=1.5 )で
#当選番号は1から600の間から60こ抽出
sample(600,60,prob=dlnorm(1:600, meanlog=5, sdlog=1.5))
@ysaito8015
ysaito8015 / file0.sh
Last active August 29, 2015 14:15
Heroku Scheduler で月一回だけ実行したい ref: http://qiita.com/ysaito8015@github/items/578f7ebd6bfe3fb00d4e
[ $(date +%d) = 01 ] && ruby ./batch.rb #毎初日に実行
@ysaito8015
ysaito8015 / file4.txt
Last active August 29, 2015 14:16
Heroku で ransack による日付一致検索 ref: http://qiita.com/ysaito8015@github/items/66b1985f695da4efc528
app[web.1]: Parameters: {"utf8"=>"✓", "q"=>{"order_date_cont"=>"2015-03-02"}}
app[web.1]: Purchase Load (4.9ms) SELECT DISTINCT "purchases".* FROM "purchases" WHERE ("purchases"."order_date" ILIKE '%2015-03-02%') ORDER BY "purchases"."order_date" DESC
app[web.1]: PG::UndefinedFunction: ERROR: operator does not exist: date ~~* unknown
app[web.1]: LINE 1: ... FROM "purchases" WHERE ("purchases"."order_date" ILIKE '%20...
app[web.1]: ^
app[web.1]: HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
app[web.1]: SELECT DISTINCT "purchases".* FROM "purchases" WHERE ("purchases"."order_date" ILIKE '%2015-03-02%') ORDER BY "purchases"."order_date" DESC
app[web.1]: Rendered shared/_search_result_box.html.erb(6.9ms)
app[web.1]: Completed 500 Internal Server Error in 69ms
var gulp = require('gulp');
var connect = require('gulp-connect');
var modRewrite = require('connect-modrewrite');
var runSequence = require('run-sequence');
var shell = require('gulp-shell');
//proxy all requests to /api to localhost:3000 for rails api
gulp.task('connect', function(){
connect.server({
root: './app',