Skip to content

Instantly share code, notes, and snippets.

View stephlocke's full-sized avatar

Steph Locke stephlocke

View GitHub Profile
@stephlocke
stephlocke / grouping.r
Created January 6, 2020 17:09
Quickly allocate some groups into partitions with other groups of similar size
# Generate sample distributions
n = 1e2
t = 3e6
min_r = t/1000
max_r = t/50
c = 0
r = vector(mode="numeric")
for(x in 1:n){
@stephlocke
stephlocke / generate.R
Last active October 19, 2019 22:40
Generate card backs for user logins
#setup
library(magick)
windowsFont("Roboto")
# inputs
setwd("c:/Users/steph/Dropbox/Locke Data/LoginCards/")
myfile <- "MiniBack.pdf"
n<-100
# write.csv(data.frame(usernames=paste0("u",stringr::str_pad(1:n,pad = "0",width = 3))
# ,pwords=random::randomStrings(n,len = 6,digits = FALSE,loweralpha = FALSE))
yo
@stephlocke
stephlocke / workingwithgit.md
Last active April 1, 2019 15:49
Work with git! 🎓=💪
title author date
Working with Git
Steph Locke
15 September 2018

Source control fundamentals

Source control concepts

---
title: "First dash"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
runtime: shiny
---
```{r setup, include=FALSE}
@stephlocke
stephlocke / find_local_tweeps.R
Last active February 19, 2019 23:24 — forked from noamross/find_local_tweeps.R
A visit to Durham
library(rtweet) #rtweet API creds should already be set up
library(stringi)
library(dplyr)
friends = get_friends(user="stephlocke")
followers = get_followers("stephlocke")
tweeps_id = distinct(bind_rows(friends, followers))
tweeps_info = lookup_users(tweeps_id$user_id)
# A regex for a visit to Durham
{
"name": "QnA Maker FAQ",
"qnaList": [
{
"id": 0,
"answer": "You can change the default message if you use QnAMakerDialog. See this for details https://docs.botframework.com/en-us/azure-bot-service/template",
"source": "Custom Editorial",
"questions": [
"How can I change the default message from QnA Maker?"
],
library(hexSticker)
library(datasauRus)
library(ggplot2)
library(dplyr)
library(svglite)
p <- ggplot(aes(x, y), data = datasaurus_dozen) +
geom_point(colour = "khaki",
alpha = .1,
size = 1) +
@stephlocke
stephlocke / hubspot.R
Last active December 21, 2018 15:39
Work with hubspot data
library(httr)
library(purrr)
library(dplyr)
library(tidyr)
apikey="demo"
get_deal_properties = function(apikey="demo"){
base_url = "https://api.hubapi.com"
properties_url = modify_url(base_url,
path ="/properties/v1/deals/properties/")
# Load R packages for use
library("dplyr")
library("recipes")
library("rsample")
library("broom")
library("jsonlite")
library("sessioninfo")
# Sample data
sm_iris = initial_split(iris)