This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from m5stack import lcd | |
from mqtt import MQTTClient | |
import time | |
import ujson | |
import ussl | |
import socket | |
import machine | |
MACHINE=hex(int.from_bytes(machine.unique_id(), 'big'))[2:] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from m5stack import lcd | |
import socket | |
import os | |
def split_list(l, s): | |
count = 0 | |
ni = [] | |
for i in range(0, len(l)-len(s)): | |
if l[i] == s[count]: | |
count=count+1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 同じ整数の繰り返しである数列に含まれる数を1つずつ使い、目的の数を作るための式を総当たりで求める | |
## Usage: npuzzle(2,4,24) => (2,2,2,2)を1つずつ使って24を作るにはどうするか. | |
npuzzle <- function(num, nrep, target, twofuncs = list( | |
"*"=function(x,y){x*y}, | |
"/"=function(x,y){x/y}, | |
"+"=function(x,y){x+y}, | |
"-"=function(x,y){x-y}, | |
"^"=function(x,y){x^y}), onefuncs = list( | |
" "=function(x){x}, | |
"factorial"=function(x){factorial(x)}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## いわゆる目標症例数とリクルートの進捗状況のグラフ | |
# ダミーの日付データを作る | |
# リクルート日付は2014-01-01からの2年間からランダムに100日 | |
dates <- as.Date("2014-01-01") + 365*2*runif(100) | |
# それぞれの日に10人までのランダムな人数がリクルートされたとするダミーデータ、100日分 | |
number <- floor(10*runif(100)) | |
# 1行1症例のデータセットのイメージ。登録日だけだけど。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## いわゆる目標症例数とリクルートの進捗状況のグラフ | |
# ダミーの日付データを作る | |
# リクルート日付は2014-01-01からの2年間からランダムに100日 | |
dates <- as.Date("2014-01-01") + 365*2*runif(100) | |
# それぞれの日に10人までのランダムな人数がリクルートされたとするダミーデータ、100日分 | |
number <- floor(10*runif(100)) | |
# 1行1症例のデータセットのイメージ。登録日だけだけど。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## いわゆる目標症例数とリクルートの進捗状況のグラフ | |
# ダミーの日付データを作る | |
# リクルート日付は2014-01-01からの2年間からランダムに100日 | |
dates <- as.Date("2014-01-01") + 365*2*runif(100) | |
# それぞれの日に10人までのランダムな人数がリクルートされたとするダミーデータ、100日分 | |
number <- floor(10*runif(100)) | |
# 1行1症例のデータセットのイメージ。登録日だけだけど。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## This gist is obsoleted. Refer https://github.com/mokjpn/Define2Validate/ for the new version. | |
library(R4DSXML) | |
library(testthat) | |
library(validate) | |
define2validate <- function(domain, file="exampleRules.yaml", definexml="Odm_Define.xml") { | |
varmd <- subset(getVarMD(definexml), IGD_Name == domain) | |
cat(file=file, append=FALSE, "") | |
out <- function(...) cat(file=file, append=TRUE, paste(...,"\n",sep="")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Read MediaWiki's WikiTable text and convert it into a dataframe | |
lines <- readLines(file.choose()) | |
columns <- NULL | |
row <- NULL | |
df <- data.frame() | |
ncol <- 0 | |
for(line in lines) { | |
if((m <- sub("^\\! *(.*)$", "\\1", line)) != line){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 早押しクイズでn問先取の時,問題をx問用意した時にどのくらいの確率で勝ち抜け者が出るか.ただし一人も正解がない場合はないものとする. | |
nquiz <- function(x,n) { | |
if(n > x) { | |
stop("n must be smaller than or equal to x") | |
} | |
sum(sapply(n:x, function(xx) { ncol(combn(x,xx))})) / (2^x) | |
} |