Skip to content

Instantly share code, notes, and snippets.

View zappingseb's full-sized avatar
🏠
Working from home

Sebastian Engel-Wolf zappingseb

🏠
Working from home
View GitHub Profile
HTML(glue("<script>$('#{id}').on('change',function(){{check_doublecolorpicker('{id}');}});</script>")),
HTML("<div class='warning' style='color:red;display:none'>Please choose more different colors</div>")
HTML(glue("<script>$('#{id}').on('change',function(){{check_doublecolorpicker('{id}');}});</script>")),
HTML("<div class='warning' style='color:red;display:none'>Please choose more different colors</div>")
// Function to check a doublecolorpicker
// item by id
function check_doublecolorpicker(id){
// derive an empty array of two inputs with
// colors
values = [];
// push the two colors into the array
$("#"+id).find('input').each(function(item){
@zappingseb
zappingseb / RTest_medium.xml
Last active January 8, 2019 00:06
RTest: A package for human readable tests in R
<?xml version="1.0" encoding="UTF-8"?>
<RTestCase xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../xsd/RTest.xsd">
<ID>RTest_TC-medium</ID>
<synopsis>
<version>01</version>
<author>Sebastian Wolf</author>
<creation-date>2018-12-11</creation-date>
</synopsis>
<input-data>
@zappingseb
zappingseb / RTest_part.xml
Last active December 31, 2018 13:29
RTest: part1
<my_function test-desc="Test data.frame">
<params>
<RTestData_input_data param="data" name="test01" />
</params>
<reference>
<col-defs>
<coldef name="x" type="numeric" /><coldef name="y" type="numeric" /><coldef name="sum" type="numeric" />
</col-defs>
<row>
<cell>1</cell><cell>2</cell><cell>3</cell>
@zappingseb
zappingseb / RTest_input_data.xml
Last active December 31, 2018 13:32
RTest_part2
<input-data>
<data.frame name="test01">
<col-defs>
<coldef name="x" type="numeric" /><coldef name="y" type="numeric" />
</col-defs>
<row>
<cell>1</cell><cell>2</cell>
</row>
<row>
<cell>1</cell><cell>2</cell>
@zappingseb
zappingseb / Report.R
Last active January 9, 2019 13:55
Report-class
setClass("Report",representation(plots="list", filename="character", obs="numeric", rendered="logical"))
setMethod("pdfElement",signature = "Report",definition = function(object){
tryCatch({
pdf(object@filename)
lapply(object@plots,function(x){
pdfElement(x)
})
dev.off()
object@rendered <- TRUE
@zappingseb
zappingseb / AnyPlot.R
Created January 9, 2019 14:08
AnyPlot-class
setClass("AnyPlot", representation(plot_element = "call"))
# constructor
AnyPlot <- function(plot_element=expr(plot(1,1))){
new("AnyPlot", plot_element = plot_element)
}
setMethod("evalElement",signature = "AnyPlot",definition = function(object){
eval(object@plot_element)
})
@zappingseb
zappingseb / render.R
Last active January 12, 2019 20:43
biowarpTruck rendering
# Create a reactive to create the Report object due to
# the chosen module
report_obj <- reactive({
module <- unlist(lapply(configuration,function(x)x$name==input$modules))
if(!any(module))module <- c(TRUE,FALSE)
do.call(configuration[[which(module)]][["class"]],
args=list(
obs = input$obs
))
})
@zappingseb
zappingseb / pdf.R
Created January 12, 2019 20:58
biowarptruck pdf
# Observe PDF button and create PDF
observeEvent(input$"renderPDF",{
# Create PDF
report <- pdfElement(report_obj())
# If the PDF was successfully rendered update text message
if(report@rendered){
output$renderedPDF <- renderText("PDF rendered")
}else{