Skip to content

Instantly share code, notes, and snippets.

View bryanhanson's full-sized avatar

Bryan Hanson bryanhanson

View GitHub Profile
@bryanhanson
bryanhanson / check_stale_imports_suggests.R
Created February 9, 2022 23:23
Check an R package for stale imports and suggests
# run from the package top level
check_stale_imports_suggests <- function() {
# helper function: removes extra characters
# from strings read by read.dcf
clean_up <- function(string) {
string <- gsub("\n", "", string)
string <- gsub("\\(.+\\)", "", string)
string <- unlist(strsplit(string, ","))
---
title: "Explore Github Topics"
author: "Bryan Hanson"
date: 2020-01-24
---
<!-- Following code to keep printed version cleaner; see https://stackoverflow.com/a/24467913/633251 -->
<style type="text/css" media="print">
a:link:after, a:visited:after {
content: normal !important;
@bryanhanson
bryanhanson / GithubAccess.R
Last active January 25, 2020 19:26
Set up Github authorization on your local machine
# R code
# Based on https://stackoverflow.com/a/23810363/633251
# This is called "Web Application Flow"
# see https://developer.github.com/apps/building-oauth-apps/authorizing-oauth-apps/#web-application-flow
# Follow the instructions there to set up a token. Never share your key or secret.
library("httr")
myapp <- oauth_app("FOSS", key = "pqr", secret = "xyz")
github_token <- oauth2.0_token(oauth_endpoints("github"), myapp)
@bryanhanson
bryanhanson / d3simpleLine1.html
Created November 14, 2014 01:53
A simple d3 Line example
<!DOCTYPE html>
<meta charset="utf-8">
<body>
<script src = "http://d3js.org/d3.v3.min.js"> </script>
</body>
<script>
@bryanhanson
bryanhanson / reallySimpleD3line.html
Created April 27, 2014 12:21
Drawing a line in d3.js starting from separate x & y arrays
<!DOCTYPE html>
<meta charset="utf-8">
<body>
<script src = "http://d3js.org/d3.v3.min.js"> </script>
<script>
// Draw a very simple line using d3 functions
@bryanhanson
bryanhanson / IntersectLineSeg.R
Created April 26, 2013 23:44
Determine if two line segments intersect (not lines!)
# R functions to determine if two line segments intersect
# Note: this is very different question from whether
# two lines intersect (terminology is important!)
# These functions are based upon the excellent discussion here,
# written by Martin Thoma:
# martin-thoma.com/how-to-check-if-two-line-segments-intersect/
# The starting point was the code here:
# github.com/MartinThoma/algorithms/tree/master/crossingLineCheck/Geometry/src