Skip to content

Instantly share code, notes, and snippets.

View stephlocke's full-sized avatar

Steph Locke stephlocke

View GitHub Profile
@stephlocke
stephlocke / recursinghubspot.pq
Last active November 2, 2018 19:32
recursing through the hubspot deals api
let
iterations = 10, // Number of iterations
url =
"https://api.hubapi.com/deals/v1/deal/paged?" & "hapikey=demo" & "&includeAssociations=true" & "&limit=1" & "&properties=dealname" & "&propertiesWithHistory=true"
,
FnGetOnePage =
(url) as record =>
let
Source = Json.Document(Web.Contents(url)),
data = try Source[deals] otherwise null,
[
{
"userId": 1,
"id": 1,
"title": "Analytics",
"body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto"
},
{
"userId": 1,
"id": 2,
@stephlocke
stephlocke / PASS.R
Last active August 20, 2018 14:54
Latest R budget scrape plus charts and figures
## ----message=FALSE-------------------------------------------------------
library(tabulizer)
library(tidyverse)
library(zoo)
library(tidytext)
## ------------------------------------------------------------------------
"http://www.pass.org/Portals/0/Governance%202017/2018%20Budget.pdf?ver=2017-10-26-171625-747&timestamp=1509063392150" %>%
tabulizer::extract_text() ->
rawtxt
@stephlocke
stephlocke / .Rprofile
Last active July 20, 2018 07:04
HIBPwned .Rprofile examplel
.First<-function(){
cat(paste0("My data has been breached ",
length(HIBPwned::account_breaches("stephanie.g.locke@gmail.com")$name),
" times (that we know of)"))
}
@stephlocke
stephlocke / htmlwidgetiframeMWE.Rmd
Created July 12, 2018 13:34
Example of trying to get an iframe of a html widget
---
title: "sample"
output:
md_document:
variant: markdown_github
preserve_yaml: true
always_allow_html: yes
---
```{r setup, include = FALSE, message = FALSE, warning = FALSE, error = FALSE}
@stephlocke
stephlocke / scrape.R
Created July 8, 2018 11:41
Scrape and consolidate the year superheroes made their debut in comics
library(tidyverse)
library(rvest)
"https://en.wikipedia.org/wiki/List_of_superhero_debuts" %>%
read_html() %>%
html_nodes(xpath = "//*[@id='mw-content-text']/div/table") %>%
map(html_table, fill = TRUE) %>%
map_df( ~ mutate(., `Year Debuted` = as.character(`Year Debuted`))) %>%
mutate(`Char_Team` = coalesce(`Character / Team / Series`, `Character / Team`)) %>%
select(Char_Team, Year_Debut = `Year Debuted`) %>%
@stephlocke
stephlocke / Checklist.md
Last active May 25, 2018 19:01
Conference good practices according to Steph!
  • Have a Code of Conduct and a demonstrable commitment to diversity
    • The Code of Conduct must be prominently displayed
    • Sponsors and other third parties must adhere to the Code of Conduct
  • Provide a mechanism for low income attendees to get reduced prices and support where the event charges more than a day's income
  • Attendees encounter only non-defaulted opt-ins to marketing and future contact, especially from third parties
  • The data entrusted to the event is handled with due care and consideration
  • Diverse attendees' needs are considered and taken into consideration. Things like (but not limited to) large print agendas, gender neutral bathrooms, quiet rooms, family rooms, and prayer rooms are implemented to ensure a pleasant experience for all attendee
  • Volunteers and organisers should receive reduced or free entry to the event
  • New speakers are encouraged and offered extra support
  • The speaker selection process is performed in a way that reduces possible sources of bias
@stephlocke
stephlocke / preconlist.md
Created April 16, 2018 11:43
Current precon offerings

Precons

Practical R for everyone

This hands-on one-day training takes you through the following topics – fundamentals of R, R for ETL, producing reports, and doing data science. Starting with some simple data manipulation, we’ll quickly progress to tools that can make an immediate impact in your day job.

  • For ETL, we’ll look at ways to import and export data, transform it, and apply data quality checks along the way.
  • For producing reports we’ll see how we can build web reports, PDFs, and interactive dashboards.
  • For data science, we’ll look at how R supports you along the process.

By the end of the day, you’ll know some R (including some advanced stuff!) that you can add to your toolbelt.

@stephlocke
stephlocke / steph.R
Created March 24, 2018 20:22
Steph blogged what?
if(!require(locketweet))
devtools::install_github("lockedata/locketweet")
library(tidyverse)
library(locketweet)
locketweet::lockedata_blog %>%
filter(date.x >= as.Date("2016-10-01"),
coalesce(tolower(author), "steph") ==
"steph") %>%
select(starts_with("cat_")) %>%
@stephlocke
stephlocke / recipe.R
Created March 15, 2018 21:11
a recipes 📦 workflow
library(recipes)
library(tidyverse)
library(AppliedPredictiveModeling)
data(AlzheimerDisease)
predictors %>%
cbind(diagnosis) ->
alzheimers
alzheimers %>%