Skip to content

Instantly share code, notes, and snippets.

View fauxneticien's full-sized avatar

Nay San fauxneticien

View GitHub Profile
@fauxneticien
fauxneticien / 1-austlangs-map.R
Created October 25, 2017 12:10
Visualise number of speakers of Australian languages in R
library(tidyverse)
library(leaflet)
lang_dialects <- read_csv(
# CSV file of languages with region, latitude and longitude
file = "https://git.io/vFeOj"
)
abs_2016 <- read_csv(
# CSBV file of ABS 2016 census data with language names and number of speakers
@fauxneticien
fauxneticien / readme.md
Last active October 29, 2017 23:40
Set up RStudio on Nectar for teaching R
@fauxneticien
fauxneticien / app.R
Last active November 9, 2017 06:44
Warlpiri reversalizer
library(shiny)
library(dplyr)
library(stringr)
library(zoo)
library(purrr)
library(tidyr)
options(shiny.maxRequestSize=30*1024^2)
reversalize <- function(wrl_txt_path) {
@fauxneticien
fauxneticien / _pipeline.sh
Created November 22, 2017 05:22
Dalabon hello world parsing and templating (Nearley, Moo, EJS)
# You may need to run
npm link moo
npm link nearley
# npm link [package-name-of-a-global-install]
# for the first you run things to get the packages linked to
# the directory in which you are running the scripts
# Compile nearley grammar to javascript code
nearleyc grammar.ne > grammar.js
@fauxneticien
fauxneticien / ejs_table_example.ejs
Created November 24, 2017 02:33
Make an HTML or CSV output in EJS
<%
my_table = [
{ "me" : "voiture", "eng": "car" },
{ "me": "rouge", "eng": "red" }
]
%>
<table>
<% my_table.map(row => {%>
<tr>
@fauxneticien
fauxneticien / flora_all.txt
Created November 28, 2017 04:54
Convert nested Warlpiri flora terms to HTML output
\me jakanypa (N): (H)
\dm flora: watiya: \edm
\lat Petalostylis cassioides \elat
\me jakutakuta (N): (La,Y)
\dm flora: miyi: \edm
\lat Cassytha filiformis \elat
\me janjinki (N): (Y)
\dm flora: watiya: \edm
\lat Acacia inaequilatera \elat
\me janjinngi (N): (Y)
@fauxneticien
fauxneticien / getVowelMeans.R
Created November 28, 2017 06:44
Join TextGrid and Formant data output from Praat, then get mean F1 and F2
# How to export TextGrid and Formant data from Praat: http://recordit.co/ybhGxsf99a
# Make sure to setwd() to where annotations.csv and formants.csv are located
library(dplyr)
library(readr)
left_join(
read_csv("annotations.csv") %>% mutate(join_col = "temp"),
read_csv("formants.csv") %>% mutate(join_col = "temp")
) %>%
@fauxneticien
fauxneticien / gather_names.R
Created November 30, 2017 23:36
Gather names from wide table to long table (and drop column name)
# Use install.packages() on dplyr and tidyr
library(dplyr)
library(tidyr)
# mock up data frame (or use read_xlsx function from readxl package to read in an excel sheet)
wrl_wide <-
data.frame(
Warlpiri = c("wumparlpa", "wartarurru"),
`scientificName 1` = c("ecucalyptus leucophloia", "acacia validinervia"),
`scientificName 2` = c("eucalyptus pruinosa", "acacia jennerae")
@fauxneticien
fauxneticien / gs_endecode.R
Last active December 5, 2017 04:05
Encode and decode authentication tokens for googlesheets R package
library(base64enc)
token2text <- function(token_obj, txt_file) {
rds_path <- tempfile()
saveRDS(object = token_obj,
file = rds_path)
# return base64 string
writeLines(base64encode(rds_path), txt_file)
}
@fauxneticien
fauxneticien / run.R
Last active December 5, 2017 05:48
Pipeline test
library(phonpack)
library(base64enc)
library(googlesheets)
# Get from BitBucket pipeline environment
BATCH_NO <- Sys.getenv("BITBUCKET_REPO_SLUG")
AUTH_STR <- Sys.getenv("GOOGLE_AUTH")
# Convert env variable to txt file, then to RDS file, then supply
# to gs_auth() as RDS file