Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Just a quick note that thanks to a gentle nudge an updated version of {uaparser} — a package that processes User Agent strings web clients send to servers — is making its way to all the CRAN mirrors and is also available on CINC. The most significant change is a much overdue update to the user agent regex dictionary.
It takes something like this Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.2 (KHTML, like Gecko) Ubuntu/11.10 Chromium/15.0.874.106 Chrome/15.0.874.106 Safari/535.2
and turns it into a tidy data frame:
uaparserjs::ua_parse("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.2 (KHTML, like Gecko) Ubuntu/11.10 Chromium/15.0.874.106 Chrome/15.0.874.106 Safari/535.2") ## # A tibble: 1 x 9 ## userAgent ua.family ua.major ua.minor ua.patch os.family os.major os.minor device.family ## <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> ## 1 Mozilla/5.0 (X11; Linux x86_64) AppleWebKi… Chromium 15 0 874 Ubuntu 11 10 Other
The js
on the end of the package name is a nod that it uses the javascript ua-parser-core
module via Jeroen’s seriously awesome {V8} package. Four years ago, {uaparserjs} did not work on Windows due to V8 VM stack limitations on Windows. Today, it now works on all platforms!
Tis no slouch, either, as it processes 100 user agent strings in ~20ms. No speed demon, but should get the job done for most use-cases.
There is an excellent C++-backed R version that is not on CRAN and some heavy dependencies, but is faster than the javascript version if you need to process scads of user agent strings (I tend to use at-scale Scala environments for this now, hence the reason for a long delay update).
Jeroen has an excellent writeup on how to use browserify
to create an application bundle for javascript-backed R packages or scripts. There are some idiosyncrasies with the ua-parser-core
reference implementation that was causing me no end of trouble with that method. On a lark, I tried:
$ webpack --mode="production" index.js -o bundle.js
and it worked perfectly on the first try (both in creating the app bundle and that bundle working just as before). This is due in no small part to Jeroen getting {V8} package to work with more recent lib-v8
releases (which is also why it works on Windows now). I’ll try to write-up the webpack
alternate method and PR into the vignette as I get time.
FIN
As usual, kick the tyres, jump in with PRs or issues and — most of all — be safe out there!
For folks who interact with CRAN or R Core: they’re continuing to support our community during these crazy times so when you are in exchanges with them, definitely take some time out to add an extra nod of thanks for managing to do so whilst juggling the same things we all are.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.