Skip to content

Instantly share code, notes, and snippets.

View bborgesr's full-sized avatar

Barbara Borges Ribeiro bborgesr

View GitHub Profile
@bborgesr
bborgesr / database-benchmarking.Rmd
Created June 23, 2016 17:52
Comparing the time that a query takes to run using three different models of database connection: one connection per program/app; one connection per query; using a connection pool.
---
title: "Benchmarking database queries"
author: "Barbara Borges Ribeiro"
date: "June 23, 2016"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(DBI)
@bborgesr
bborgesr / iterative-comp-shiny.R
Created March 6, 2017 16:53
An example of doing prolonged, iterative computation in Shiny. Adapted from: https://gist.github.com/trestletech/8608815
library(shiny)
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
numericInput("steps", "Time steps:", 10, min=1),
actionButton("run", label="Start")
),
mainPanel(
textOutput("status")
@bborgesr
bborgesr / shiny-1.0.1-new-features.R
Created March 30, 2017 17:21
"Exciting" new features in Shiny 1.0.1
# ----------------------------------------------------------------- #
# ------------- "Exciting" new features in Shiny 1.0.1 ------------ #
# ----------------------------------------------------------------- #
library(shiny)
# 1. ----------------------------------------------- #
# ------------------ reactiveVal() ----------------- #
# -------------------------------------------------- #
ui <- fluidPage(
@bborgesr
bborgesr / shiny-simple-iterative-printing.R
Created May 5, 2017 17:04
Two simple examples of iterative printing in Shiny
# By default Shiny will always wait for any reactive dependencies to finish (re)calculcating
# before displaying the output that depends on them. Without async reactivity in Shiny (which
# is not currently available, but it's in the works), it's actually not really possible to
# make a reactive dependency be available before it finishes computing. But you can redefine
# your reactive so that its output is broken though.
#
# You can achieve this using reactive values, an observer and invalidateLater(). If this is
# new for you, I'd recommend, you read the documentation about invalidateLater().
#
# I'll show two simple examples here. For a more elaborate example, see this gist.
@bborgesr
bborgesr / exceptionally-good-presentations.txt
Created February 8, 2018 00:44 — forked from jmcphers/exceptionally-good-presentations.txt
How to Give an Exceptionally Good Presentation
"HOW TO GIVE AN EXCEPTIONALLY GOOD PRESENTATION"
CHARACTERS
Joe Cheng.............Moderator
Jennifer Bryan........As Herself
Hadley Wickham........As Himself
Aron Atkins...........Audience
Derrick Kearney.......Audience
@bborgesr
bborgesr / cards-crud-inside-map-inside-buildCards.js
Last active March 14, 2019 15:35
[Make a CMS card's id unique] Reusing existing code, and keeping in mind that it's preferrable to destructure the object rather than mutate the id in place. #cms
try {
const card = buildCard(
card,
data,
filtersAndFormatters,
Object.assign({}, settingsAndOptions, { cardIndex })
);
return {...card, id: `${card.id}:${cardIndex}`};
}
@bborgesr
bborgesr / checkbox-choiceNames-flags.R
Created April 4, 2017 19:51
Demo of new `checkboxGroupInput()` and `radioButtons()` functionality in Shiny 1.0.1
library(shiny)
countries <- c("Australia", "United Kingdom", "United States")
flags <- c(
"https://cdn.rawgit.com/lipis/flag-icon-css/master/flags/4x3/au.svg",
"https://cdn.rawgit.com/lipis/flag-icon-css/master/flags/4x3/gb.svg",
"https://cdn.rawgit.com/lipis/flag-icon-css/master/flags/4x3/us.svg"
)
@bborgesr
bborgesr / hide-datatable-shiny.R
Created March 7, 2017 08:38
How to make a DataTable actually become hidden in a Shiny app
# -------------------------------------------------------------------
# ------------------ HIDIND A DATATABLE IN SHINY --------------------
# -------------------------------------------------------------------
# -------------------------------------------------------------------
# --- EXAMPLE 1: this sets the datatable's underlying dataframe to --
# --- NULL, inside a reactive (recalculated whenever a checkbox is --
# --- clicked). While this does result in the datatable disappearing
# --- from view, the height does not show ---------------------------
@bborgesr
bborgesr / to-do-list-vanilla-js.html
Created December 19, 2019 14:00
A very simple ToDo app using only vanilla JS
<html>
<head>
<title>Wonderful Task Manager</title>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
@bborgesr
bborgesr / simple-server.js
Created February 4, 2020 09:26
A simple server to serve mock data for the Room Manager app (https://github.com/bborgesr/room-manager)
const express = require("express");
const cors = require("cors");
const reservations = [
{
reservaID: 1,
usuarioID: 1,
salaID: 1,
data: "2020-01-31",
horaEntrada: "2020-01-31T10:00:00",