Skip to content

Instantly share code, notes, and snippets.

Avatar
🦑
Tappity tap tap

Mark MarkEdmondson1234

🦑
Tappity tap tap
View GitHub Profile
@MarkEdmondson1234
MarkEdmondson1234 / google-natural-language-js-sample.htlml
Last active Jun 5, 2019
Authenticate to Google Natural Language API via client side javascript
View google-natural-language-js-sample.htlml
<html>
<head>
<script src="https://apis.google.com/js/api.js"></script>
<script>
function start() {
gapi.client.init({
'apiKey': 'XXXX',
'discoveryDocs': ['https://language.googleapis.com/$discovery/rest?version=v1beta1']
}).then(function() {
return gapi.client.language.documents.analyzeSentiment({
@MarkEdmondson1234
MarkEdmondson1234 / compareXMLtoGA.R
Last active Jul 5, 2018
Check 0 pageviews by comparing sitemap.XML URLs with Google Analytics visits.
View compareXMLtoGA.R
library(googleAnalyticsR)
library(xml2)
library(dplyr)
ga_auth()
## date range of URLs to test
dates <- c(Sys.Date() - 30, Sys.Date())
##GA View ID
@MarkEdmondson1234
MarkEdmondson1234 / send_email_mailgun.R
Last active Apr 22, 2021
Send an email via an R function using Mailgun
View send_email_mailgun.R
#' Email a user a report is ready
#'
#' Requires an account at Mailgun: https://mailgun.com
#' Pre-verification can only send to a whitelist of emails you configure
#'
#' @param email Email to send to
#' @param mail_message Any extra info
#'
#' @return TRUE if successful email sent
#' @import httr
@MarkEdmondson1234
MarkEdmondson1234 / snippet_modules.R
Last active Jul 17, 2020
RStudio snippet to make a shortcut for Shiny Module scaffolding
View snippet_modules.R
snippet module
#' ${1:module_name} UI
#'
#' Shiny Module for use with \link{${1:module_name}}
#'
#' @param id Shiny id
#'
#' @return Shiny UI
${1:module_name}UI <- function(id){
View .travis.yml
sudo: required
dist: trusty
group: edge
language: ruby
services:
- docker
cache:
View debug_dynamic_select.R
library(shiny)
dynamicSelectInput <- function(id, label, multiple = FALSE){
ns <- shiny::NS(id)
shiny::selectInput(ns("dynamic_select"), label,
choices = NULL, multiple = multiple, width = "100%")
}
@MarkEdmondson1234
MarkEdmondson1234 / dynamicSelectShinyModule.R
Last active Nov 21, 2020
Shiny modules for creating dynamic SelectInputs
View dynamicSelectShinyModule.R
library(shiny)
#' Safe subset
#'
#' @param df Dataframe
#' @param column One name of column to subset within
#' @param subset Vector of entries in column to subset to
#'
#' If column not in df, returns back the df
safeSubset <- function(df, column, subset){
@MarkEdmondson1234
MarkEdmondson1234 / RMessages.sh
Created Mar 21, 2016
Write R messages in StOut to a file
View RMessages.sh
Rscript -e "setwd('/srv/shiny-server/xxxxx/'); zz<-file('rscript.log', open='wt');sink(zz, type = 'm'); rmarkdown::render('getData.Rmd')"
View visgreatlessfilling.r
# devtools::install_github("hrbrmstr/vegalite")
library(vegalite)
library(htmltools)
dat <- jsonlite::fromJSON('[
{"a": "A","b": 28}, {"a": "B","b": 55}, {"a": "C","b": 43},
{"a": "D","b": 91}, {"a": "E","b": 81}, {"a": "F","b": 53},
{"a": "G","b": 19}, {"a": "H","b": 87}, {"a": "I","b": 52}
]')
View japan_pyramid.R
library(idbr) # devtools::install_github('walkerke/idbr')
library(ggplot2)
library(animation)
library(dplyr)
library(ggthemes)
idb_api_key("Your Census API key goes here")
male <- idb1('JA', 2010:2050, sex = 'male') %>%
mutate(POP = POP * -1,