Skip to content

Instantly share code, notes, and snippets.

View smach's full-sized avatar

Sharon Machlis smach

View GitHub Profile
@smach
smach / bitbucket-pipelines.yml
Last active January 25, 2023 18:48 — forked from ellisvalentiner/bitbucket-pipelines.yml
yaml to build R package for bitbucket pipelines continuous integration
image: rocker/tidyverse:latest
pipelines:
default:
- step:
script:
- cd /opt/atlassian/pipelines/agent/build
- Rscript -e 'devtools::install_deps(".", dependencies=TRUE, upgrade=FALSE)'
- Rscript -e 'devtools::build()'
- Rscript -e 'devtools::install(upgrade_dependencies = FALSE)'
@smach
smach / election_night_live_model.R
Created October 31, 2020 18:25 — forked from elliottmorris/election_night_live_model.R
A live election-night prediction model using The Economist's pre-election forecast
#' Description
#' This file runs a live election-night forecast based on The Economist's pre-election forecasting model
#' available at projects.economist.com/us-2020-forecast/president.
#' It is resampling model based on https://pkremp.github.io/update_prob.html.
#' This script does not input any real election results! You will have to enter your picks/constraints manually (scroll to the bottom of the script).
#'
#' Licence
#' This software is published by *[The Economist](https://www.economist.com)* under the [MIT licence](https://opensource.org/licenses/MIT). The data generated by *The Economist* are available under the [Creative Commons Attribution 4.0 International License](https://creativecommons.org/licenses/by/4.0/).
#' The licences include only the data and the software authored by *The Economist*, and do not cover any *Economist* content or third-party data or content made available using the software. More information about licensing, syndication and the copyright of *Economist* content can be fou
library(reactable)
library(dplyr)
red_pal <- function(x) rgb(colorRamp(c("#FFCDD2FF", "#C62828FF"))(x), maxColorValue = 255)
blue_pal <- function(x) rgb(colorRamp(c("#BBDEFBFF", "#1565C0FF"))(x), maxColorValue = 255)
mtcars %>%
select(cyl, mpg) %>%
reactable(
pagination = FALSE,
@smach
smach / GitHub-Forking.md
Created December 11, 2017 02:10 — forked from Chaser324/GitHub-Forking.md
GitHub Standard Fork & Pull Request Workflow

Whether you're trying to give back to the open source community or collaborating on your own projects, knowing how to properly fork and generate pull requests is essential. Unfortunately, it's quite easy to make mistakes or not know what you should do when you're initially learning the process. I know that I certainly had considerable initial trouble with it, and I found a lot of the information on GitHub and around the internet to be rather piecemeal and incomplete - part of the process described here, another there, common hangups in a different place, and so on.

In an attempt to coallate this information for myself and others, this short tutorial is what I've found to be fairly standard procedure for creating a fork, doing your work, issuing a pull request, and merging that pull request back into the original project.

Creating a Fork

Just head over to the GitHub page and click the "Fork" button. It's just that simple. Once you've done that, you can use your favorite git client to clone your repo or j

@smach
smach / google_calendar_demo.R
Last active October 2, 2017 23:34 — forked from MarkEdmondson1234/google_calendar_demo.R
A demo of calling Google Calendar API
library(googleAuthR)
## set scopes for calendar
options(googleAuthR.scopes.selected = "https://www.googleapis.com/auth/calendar.readonly",
googleAuthR.client_id = "XXXX", ## add your Google project client Id - find it at https://console.developers.google.com/apis/credentials then click on the appropriate OAuth 2.0 client ID
googleAuthR.client_secret = "XXXX") ## add your Google project client secret - at same place as above
## make sure calendar API is activated for your Google Project at below URL:
# https://console.cloud.google.com/apis/api/calendar-json.googleapis.com/overview
install.packages("jsonlite", dependencies = TRUE)
install.packages("RCurl", dependencies = TRUE)
library("jsonlite")
library("RCurl")
base_url <- "https://api.parsely.com/v2"
apikey <- "computerworld.com"
api_secret <- "YOUR SECRET KEY"
#!/usr/bin/env ruby
require 'mail'
#### THIS RUBY SCRIPT WAS ORIGINALLY POSTED BY blazeeboy ON GITHUB
mysql_username = 'root'
mysql_password = '123456'
mysql_database = 'test'
system("mysqldump --user=#{mysql_username} --password=#{mysql_password} #{mysql_database} > backup.sql")
@smach
smach / calc_age.r
Last active August 29, 2015 13:57 — forked from mmparker/calc_age.r
# Useful lubridate function for date subtraction written by mmparker
# Calculate age at a given reference date
# Create an interval between the date of birth and the enrollment date;
# intervals are specific to the two dates. Periods give the actual length
# of time between those dates, so convert to period and extract the year.
calc_age <- function(birthDate, refDate = Sys.Date()) {
require(lubridate)