Skip to content

Instantly share code, notes, and snippets.

View francisbarton's full-sized avatar
🌱
Sowing seeds for 2024

Fran Barton francisbarton

🌱
Sowing seeds for 2024
View GitHub Profile
options(reactable.theme = reactable::reactableTheme(
color = "hsl(233, 9%, 87%)",
backgroundColor = "#002b36",
borderColor = "#eee8d5",
stripedColor = "#586e75",
highlightColor = "#6c71c4",
inputStyle = list(backgroundColor = "hsl(233, 9%, 25%)"),
selectStyle = list(backgroundColor = "hsl(233, 9%, 25%)"),
pageButtonHoverStyle = list(backgroundColor = "hsl(233, 9%, 25%)"),
pageButtonActiveStyle = list(backgroundColor = "hsl(233, 9%, 28%)")
unpack_double <- function(x) {
binary <- numToBits(x) # little-endian binary representation
structure(
list(
sign = binary[64], # 1-bit sign
exponent = binary[63:53], # 11-bit exponent
mantissa = binary[52:1] # 52-bit mantissa
),
class = "unpacked_double"
@ColinFay
ColinFay / fork-up-to-date
Last active October 9, 2020 15:59
Keep your fork up to date
# To do the first time
# git remote add upstream https://github.com/original-repo/goes-here.git
git fetch upstream
git rebase upstream/master
git push origin master --force
@MilesMcBain
MilesMcBain / anonymous.R
Created July 9, 2020 11:48
anonymous function examples
## apply a function to square a list of numbers
square <- function(x) {
x^2
}
lapply(list(1,2,3), square)
## save some code and declare 'square' anonymously - i.e. never assign it anywhere
## using the name 'square'
@olihawkins
olihawkins / coronavirus-api.R
Last active June 10, 2021 08:50
Download data on Coronavirus cases and deaths from the government dashboard API
# Functions for downloading data on Coronavirus cases in the UK by country,
# region, NHS region, and local authority from the government dashboard API.
#
# The developer guide is here:
#
# https://coronavirus.data.gov.uk/developers-guide
#
# The code below is based on the example code shown there.
#
# Run ...
@erdavis1
erdavis1 / allpubs.csv
Created May 5, 2019 19:03
Pubs of the British Isles
We can't make this file beautiful and searchable because it's too large.
ID,name,long,lat,region
1,'31 Market Place',-1.021284,53.429981,england
1,'The Commercial Hotel',-2.364444,53.752023,england
3,'The Park Inn ',-2.358299,53.747997,england
5,0 degrees North,-0.0309,53.560872,england
6,012 Bar And Grill,0.004034,51.544232,england
7,1 In 12 Club,-1.758029,53.794847,england
8,1 Step Social Limited,-1.633635044,54.81035995,england
9,1 Town Hall Square,-3.4474502,51.4620403,wales
10,100 Acre Catering Ltd,-1.838364,51.063689,england
@malcolmbarrett
malcolmbarrett / move_slides_to_web.R
Last active April 2, 2019 10:28
Move R Markdown HTML slides to Blogdown and Push to Web
# install.packages(c("here", "fs", "stringr", "purrr", "git2r"))
# to add invisibly in your R profile, open with usethis::edit_r_profile()
# then define it in an environment, e.g.
# .env <- new.env()
# .env$move_slides_to_web <- {function definition}
move_slides_to_web <- function(folder = NULL, index = NULL) {
if (is.null(folder)) {
@matt-dray
matt-dray / plot-lad-geojson-sf-ggplot2.R
Last active January 27, 2020 07:54
Plot a GeoJSON of UK local authorities from the Office for National Statistics's Open Geography Portal using the {geojsonio}, {sf} and {ggplot2} packages
# Plotting a UK local authorities geojson with sf and ggplot2
# Feb 2019
# Matt Dray
# Packages needed
library(sf) # spatial features package for working with geographies
library(geojsonio) # for working with GeoJSON files
library(ggplot2) # for plotting
@bennuttall
bennuttall / remotegpio.md
Last active July 8, 2021 18:22
Set up a Pi and host PC for remote GPIO access using gpiozero

Remote GPIO

GPIO Zero allows you to create objects representing GPIO devices. As well as running it on a Raspberry Pi, you can also install GPIO Zero on a PC and create objects referencing GPIO pins on a Pi over the network.

To do this, you'll need to do a few things to get set up:

  1. Enable Remote GPIO on the Pi in the Raspberry Pi Configuration Tool.

  2. Run the pigpio daemon on the Pi:

@DianaEromosele
DianaEromosele / Change "origin" of your GIT repository
Created August 7, 2016 00:31
Change "origin" of your GIT repository
$ git remote rm origin
$ git remote add origin git@github.com:aplikacjainfo/proj1.git
$ git config master.remote origin
$ git config master.merge refs/heads/master