Skip to content

Instantly share code, notes, and snippets.

View RichardPilbery's full-sized avatar
๐Ÿ›ฉ๏ธ

Richard Pilbery RichardPilbery

๐Ÿ›ฉ๏ธ
View GitHub Profile
@RichardPilbery
RichardPilbery / gist:8ae9391cb7477c42d63551a58326288f
Last active June 26, 2024 11:33
Using base64 to 'hide' code
super_advanced_AI_algorithm_fn <- function(grouping_number) {
ai <- "aWYoZ3JvdXBpbmdfbnVtYmVyID09IDEpIHByaW50KCJXb2FoLCB0aGV5IGRvbid0IGxvb2sgcGFyYWxsZWwiKSBlbHNlIHByaW50KCJMb29rcyBwYXJhbGxlbCB0byBtZSIp"
eval(parse(text = rawToChar(base64enc::base64decode(ai))))
}
super_advanced_AI_algorithm_fn(grouping_number)
@RichardPilbery
RichardPilbery / ender-3-pro-bltouch-gcode
Created November 27, 2022 09:30
Start and End Gcode for End 3 Pro
; Ender 3 Custom Start G-code
M140 S{material_bed_temperature_layer_0} ; Set Heat Bed temperature
M190 S{material_bed_temperature_layer_0} ; Wait for Heat Bed temperature
M104 S160; start warming extruder to 160
G28 ; Home all axes
G29 ; Auto bed-level (BL-Touch)
G92 E0 ; Reset Extruder
M104 S{material_print_temperature_layer_0} ; Set Extruder temperature
G1 X0.1 Y20 Z0.3 F5000.0 ; Move to start position
M109 S{material_print_temperature_layer_0} ; Wait for Extruder temperature
nhsNumberCheck <- function(nhs_vector) {
#print(nhs_vector)
df = data.frame(
NHSNumber = nhs_vector,
stringsAsFactors = F
)
Validity <- df %>%
@RichardPilbery
RichardPilbery / getDistance.php
Created September 9, 2021 12:29
Calculate distance between two lat/long co-ords
function calculateDist($geoLat,$geoLong,$asLat,$asLong) {
//User Haversine formula to calculate the distance
// http://stackoverflow.com/questions/5260423/torad-javascript-function-throwing-error
//Radius of the earth in: 1.609344 miles, 6371 km | var R = (6371 / 1.609344);
$R = 3958.7558657440545; // Radius of earth in miles
//var R = 6371; // km
$dLat = toRad($asLat-$geoLat);
$dLon = toRad($asLong-$geoLong);
$lat1 = toRad($geoLat);
$lat2 = toRad($asLat);
@RichardPilbery
RichardPilbery / blerp.js
Created August 26, 2021 07:05 — forked from botagar/blerp.js
Javascript implementation of Bilinear Interpolation
Math.blerp = function (values, x1, y1, x2, y2, x, y) {
let q11 = (((x2 - x) * (y2 - y)) / ((x2 - x1) * (y2 - y1))) * values[x1][y1]
let q21 = (((x - x1) * (y2 - y)) / ((x2 - x1) * (y2 - y1))) * values[x2][y1]
let q12 = (((x2 - x) * (y - y1)) / ((x2 - x1) * (y2 - y1))) * values[x1][y2]
let q22 = (((x - x1) * (y - y1)) / ((x2 - x1) * (y2 - y1))) * values[x2][y2]
return q11 + q21 + q12 + q22
}
@RichardPilbery
RichardPilbery / date_time.r
Last active March 22, 2021 09:34
Calculate difference between two date times
library(tidyverse)
library(lubridate)
df <- data.frame(
time1 = sample(seq(ymd_hms('2020-01-01 00:00:00'), ymd_hms('2020-01-01 23:59:59'), by="sec"), 10),
time2 = sample(seq(ymd_hms('2020-01-01 00:00:00'), ymd_hms('2020-01-01 23:59:59'), by="sec"), 10),
stringsAsFactors = F
)
df1 <- df %>%
@RichardPilbery
RichardPilbery / weekly_ons_data.r
Last active October 28, 2020 12:38
Retrieves Weekly ONS data and slurps it into a dataframe
library(tidyverse)
library(rvest)
# Scrape the ONS website for a list of URLS
weekly_ons_mortality <- read_html("https://www.ons.gov.uk/peoplepopulationandcommunity/birthsdeathsandmarriages/deaths/datasets/weeklyprovisionalfiguresondeathsregisteredinenglandandwales") %>%
html_nodes("a") %>%
html_attr("href")
# Just extract those that are spreadsheets
createPlot <- function(dataframe,thelegend=FALSE, wrapwidth=40) {
leg = c(1000,1000)
if(thelegend == TRUE) {
leg = "bottom"
}
plot <- plot(likert(dataframe), type="bar", wrap=wrapwidth, include.center=T, plot.percents=F,plot.percent.low=T, plot.percent.high=T, plot.percent.neutral=T, legend.position=leg, colors=c('#CC0016','#F6A57F','#DFDFDF','#90C5DF','#0070B2'))
return(plot)
}
#library(nhsnumber)
#nhsnumber::is_valid(x)
x <- c(
"251 170 9081", # FALSE
"699 864 6585", # TRUE
"A40 6565585", # FALSE
"202 993 9145", # TRUE
"958 408 6391", # TRUE
"490 189 1901", # TRUE
@RichardPilbery
RichardPilbery / gist:baa96908897ff9ace033f67ac86555b3
Created April 6, 2019 20:40 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: ๐Ÿ˜„ :smile: ๐Ÿ˜† :laughing:
๐Ÿ˜Š :blush: ๐Ÿ˜ƒ :smiley: โ˜บ๏ธ :relaxed:
๐Ÿ˜ :smirk: ๐Ÿ˜ :heart_eyes: ๐Ÿ˜˜ :kissing_heart:
๐Ÿ˜š :kissing_closed_eyes: ๐Ÿ˜ณ :flushed: ๐Ÿ˜Œ :relieved:
๐Ÿ˜† :satisfied: ๐Ÿ˜ :grin: ๐Ÿ˜‰ :wink:
๐Ÿ˜œ :stuck_out_tongue_winking_eye: ๐Ÿ˜ :stuck_out_tongue_closed_eyes: ๐Ÿ˜€ :grinning:
๐Ÿ˜— :kissing: ๐Ÿ˜™ :kissing_smiling_eyes: ๐Ÿ˜› :stuck_out_tongue: