Skip to content

Instantly share code, notes, and snippets.

Avatar

Barbara Borges Ribeiro bborgesr

View GitHub Profile
@bborgesr
bborgesr / simple-server.js
Created Feb 4, 2020
A simple server to serve mock data for the Room Manager app (https://github.com/bborgesr/room-manager)
View simple-server.js
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",
@bborgesr
bborgesr / to-do-list-vanilla-js.html
Created Dec 19, 2019
A very simple ToDo app using only vanilla JS
View to-do-list-vanilla-js.html
<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 / cards-crud-inside-map-inside-buildCards.js
Last active Mar 14, 2019
[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
View cards-crud-inside-map-inside-buildCards.js
try {
const card = buildCard(
card,
data,
filtersAndFormatters,
Object.assign({}, settingsAndOptions, { cardIndex })
);
return {...card, id: `${card.id}:${cardIndex}`};
}
@bborgesr
bborgesr / exceptionally-good-presentations.txt
Created Feb 8, 2018 — forked from jmcphers/exceptionally-good-presentations.txt
How to Give an Exceptionally Good Presentation
View exceptionally-good-presentations.txt
"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 / shiny-insertUI-removable.R
Last active Apr 11, 2019
Uses Shiny's insertUI to create elements (in this example, datatables) at the user's discretion; each of these comes with a button that will remove it from the app (using removeUI).
View shiny-insertUI-removable.R
library(shiny)
ui <- fluidPage(
textInput("divID", "Enter an ID for the custom area:", ""),
helpText("Leave the text input blank for automatically unique IDs."),
actionButton("isrt", "Add a datatable"),
tags$div(id = "placeholder")
)
server <- function(input, output, session) {
rv <- reactiveValues()
@bborgesr
bborgesr / shiny-reactive-R6-object.R
Created Aug 1, 2017
Uses the reactiveTrigger() construct in an R6 object class in order to make it useful in reactive settings, like a Shiny app (MWE included)
View shiny-reactive-R6-object.R
library(shiny)
reactiveTrigger <- function() {
counter <- reactiveVal( 0)
list(
depend = function() {
counter()
invisible()
},
trigger = function() {
@bborgesr
bborgesr / pseudo-navigation-shiny.R
Created Jun 30, 2017
Implements pseudo navigation in a Shiny app
View pseudo-navigation-shiny.R
library(shiny)
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
tags$a("Go to Panel 1", href = "#panel1"), br(),
tags$a("Go to Panel 2", href = "#panel2"), br(),
tags$a("Go to Panel 3", href = "#panel3")
),
mainPanel(
@bborgesr
bborgesr / dynamic-dropdownMenu.R
Created May 9, 2017
How to dynamically add items to a dropdownMenu in shinydashboard
View dynamic-dropdownMenu.R
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(title = "Dropdowns 2.0",
dropdownMenuOutput("menu")
),
dashboardSidebar(
helpText("Add another item to the dropdown menu by clicking ",
"on the button below"),
@bborgesr
bborgesr / shiny-simple-iterative-printing.R
Created May 5, 2017
Two simple examples of iterative printing in Shiny
View shiny-simple-iterative-printing.R
# 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 / checkbox-choiceNames-flags.R
Created Apr 4, 2017
Demo of new `checkboxGroupInput()` and `radioButtons()` functionality in Shiny 1.0.1
View checkbox-choiceNames-flags.R
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"
)