Skip to content

Instantly share code, notes, and snippets.

View chrissyhroberts's full-sized avatar

Chrissy h Roberts (He/Him) chrissyhroberts

View GitHub Profile
@chrissyhroberts
chrissyhroberts / ODK>BRIEFCASE>AGGREGATE
Created January 11, 2019 13:15
pull data from tablet to ODK Briefcase then send to aggregate
Ensure that *Asus File Manager* is installed.
https://asus-file-manager.en.uptodown.com/android
Open Asus File Manager and navigate to the Internal Storage Folder
Hold down the odk folder until a tick appears to the left of it, indicating that it has been selected
Press the Hamburger button (three dots in the top right corner of the screen)
Select 'Compress'
A box will appear with the message "Enter the Archive Name"
speakr <- function(message="hello, world")
{
if(.Platform$OS.type == "unix"){system(paste("say ",message,sep=""))}
else {system(paste("echo ",message,"|ptts",sep=""))}
}
# usage examples
speakr("Beepr is cool")
@chrissyhroberts
chrissyhroberts / mendeley-editor
Created October 14, 2018 00:43
Mendeley visual citation style editor
https://csl.mendeley.com/codeEditor/
This is a useful thing for editing mendeley styles when they are wrong.
Find the installed file on Mac at Library/Application Support/Mendeley Desktop/citationStyles-1.0
Make a copy in the same place, then rename
Change the Titles so that it shows up as a different style. then fiddle around until you have the correct style.
Save it and restart Mendeley and it will show up as a style
@chrissyhroberts
chrissyhroberts / update R
Created October 4, 2018 15:19
Update R and copy packages across
Before start open R and
.libPaths()
to get the old path to libraries
Install new versions of R and Rstudio
@chrissyhroberts
chrissyhroberts / secure_copy_ssh_via_R
Created September 27, 2018 18:39
R compatible scp secure copy over ssh using sshpass
#install sshpass
wget http://sourceforge.net/projects/sshpass/files/latest/download -O sshpass.tar.gz
tar -xvf sshpass.tar.gz
cd sshpass-1.06
./configure
sudo make install
#R command
system("sshpass -f pass.sh scp chrissyhroberts@10.23.0.82:/Users/chrissyhroberts/tasks/EDK0004_Downloader/data/EDK* .")
@chrissyhroberts
chrissyhroberts / itemlists.R
Last active October 2, 2018 14:01
make xlsform itemlists.csv file for use with ODK
###############################################
# Using Administrative dara from DIVA-GIS,
# this script will convert the geographical
# administrative data (levels 0-3)
# for one or more country
# and output an itemsets.csv file
# that works with ODK and preserves accented
# characters (tested only on roman characters)
# Also removes accents from internal variables
# like 'name'. Accents will appear on screen but
@chrissyhroberts
chrissyhroberts / removeaccents
Created September 13, 2018 15:28
remove accents from text in R
removeAccents<-function(x)
{
a <- c('À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'ÿ', 'Ā', 'ā', 'Ă', 'ă', 'Ą', 'ą', 'Ć', 'ć', 'Ĉ', 'ĉ', 'Ċ', 'ċ', 'Č', 'č', 'Ď', 'ď', 'Đ', 'đ', 'Ē', 'ē', 'Ĕ', 'ĕ', 'Ė', 'ė', 'Ę', 'ę', 'Ě', 'ě', 'Ĝ', 'ĝ', 'Ğ', 'ğ', 'Ġ', 'ġ', 'Ģ', 'ģ', 'Ĥ', 'ĥ', 'Ħ', 'ħ', 'Ĩ', 'ĩ', 'Ī', 'ī', 'Ĭ', 'ĭ', 'Į', 'į', 'İ', 'ı', 'IJ', 'ij', 'Ĵ', 'ĵ', 'Ķ', 'ķ', 'Ĺ', 'ĺ', 'Ļ', 'ļ', 'Ľ', 'ľ', 'Ŀ', 'ŀ', 'Ł', 'ł', 'Ń', 'ń', 'Ņ', 'ņ', 'Ň', 'ň', 'ʼn', 'Ō', 'ō', 'Ŏ', 'ŏ', 'Ő', 'ő', 'Œ', 'œ', 'Ŕ', 'ŕ', 'Ŗ', 'ŗ', 'Ř', 'ř', 'Ś', 'ś', 'Ŝ', 'ŝ', 'Ş', 'ş', 'Š', 'š', 'Ţ', 'ţ', 'Ť', 'ť', 'Ŧ', 'ŧ', 'Ũ', 'ũ', 'Ū', 'ū', 'Ŭ', 'ŭ', 'Ů', 'ů', 'Ű', 'ű', 'Ų', 'ų', 'Ŵ', 'ŵ', 'Ŷ', 'ŷ', 'Ÿ', 'Ź', 'ź', 'Ż', 'ż', 'Ž', 'ž', 'ſ', 'ƒ', 'Ơ', 'ơ', 'Ư', 'ư', 'Ǎ', 'ǎ', 'Ǐ', 'ǐ', 'Ǒ', 'ǒ', 'Ǔ', 'ǔ', 'Ǖ'
@chrissyhroberts
chrissyhroberts / KML2GPx
Created August 21, 2018 12:02
read KML file in to GPS formats for R
library(rgdal)
#get schema name from KML file
a<-readOGR("chrissy-nk3_planet_osm_point_points.kml","SELECT")
@chrissyhroberts
chrissyhroberts / timemachine.throttlecontrol
Created August 9, 2018 12:42
mac time machine speed throttling controls
#Time machine backups on macs are throttled as a low priority for CPU and bandwidth. If you are only backing up once a week or so, you may find that speed is very very slow.
#Possible to speed up by turning off throttling, but remember to put it back on or could impact on system performance.
#off
sudo sysctl debug.lowpri_throttle_enabled=0
#on
sudo sysctl debug.lowpri_throttle_enabled=1
@chrissyhroberts
chrissyhroberts / csv2md.R
Last active June 26, 2018 23:24
Really simple CSV to Markdown
# Function to render a list in R as a markdown file that is then rendered in chosen format.
# Useful for printing a line or lines of a table to individual PDF files (i.e. for reconstruction of participant data sheets)
# Has some really basic headers and titles and an automatic system for building output file names including timestamps.
# Prints variable names in bold and data in plain text. Renders using rmarkdown package but sinking data in to vanilla markdown for maximum interoperability rather than using RMD.
# Requires rmarkdown package and dependencies
# md files currently autodelete after render but easily modified as option
# only renders when file doesn't already exist
csv2pdf<-function(data,title,id=NULL,form.id=NULL,author,date=format(Sys.time(), "%Y_%m_%d__%X",tz = "Universal"),report.format="pdf_document",output_dir="./pdf")