Skip to content

Instantly share code, notes, and snippets.

View ramnathv's full-sized avatar

Ramnath Vaidyanathan ramnathv

View GitHub Profile
@srvanderplas
srvanderplas / jqfp.js
Last active June 17, 2023 04:58
Shiny user fingerprint (md5 hash of browser characteristics) and ip address demo. The .R files are in the working directory ("./"), the .js files must be placed in ./www/js/ to be accessible. I wrote the R code, which I will release under the same WTF license as the jqfp.js library is released under.
// Browser fingerprinting is a technique to "mark" anonymous users using JS
// (or other things). To build an "identity" of sorts the browser is queried
// for a list of its plugins, the screen size and several other things, then
// hashes them. The idea is that these bits of information produce an unique
// "fingerprint" of sorts; the more elaborate the list of data points is, the
// more unique this fingerprint becomes. And you wouldn't even need to set a
// cookie to recognize this user when she visits again.
//
// For more information on this topic consult
// [Ars Technica](http://arstechnica.com/tech-policy/news/2010/05/how-your-web-browser-rats-you-out-online.ars)
@frankfarach
frankfarach / templateR.sh
Last active February 20, 2021 22:06
This shell script creates a version-controlled ProjectTemplate project and RStudio project for R code, with an option to specify the folder and project name. This clones http://github.com/frankfarach/templateR by default, but if you fork that you can override with your own user name in the second argument or by hard-coding it in.
#!/bin/bash
##############################################################################
# Name: templateR.sh
# Author: Frank Farach
# Description: Script to clone templateR repo from GitHub account,
# with options to name the local working directory and RStudio
# project. This depends on the existence of a repository called templateR
# in the GitHub account of user named in the global variable USER below.
# See: http://github.com/frankfarach/templateR
@ramnathv
ramnathv / README.md
Last active April 8, 2022 11:17
Parser to Convert Markdown to CTV file.

This is a proof-of-concept of a parser to convert a markdown file to a ctv file, that is required for task views. The basic idea is to use a combination of YAML and markdown sections in the md file, parse it and convert it into a payload, and render it using a template as specified by the ctv package.

Structure of Markdown File

---
name: Working with data on the web
maintainer: Scott Chamberlain, Karthik Ram, Christopher Gandrud
email: scott at ropensci.org
version: 2013-09-17
@millermedeiros
millermedeiros / osx_setup.md
Last active May 7, 2024 08:01
Mac OS X setup

Setup Mac OS X

I've done the same process every couple years since 2013 (Mountain Lion, Mavericks, High Sierra, Catalina) and I updated the Gist each time I've done it.

I kinda regret for not using something like Boxen (or anything similar) to automate the process, but TBH I only actually needed to these steps once every couple years...

@hadley
hadley / frndly.r
Created September 27, 2013 20:04
# A tutorial navigates through a series of states, either manually, with
# nxt(), prv(), jmp() etc, or automatically, by using addTaskCallback() and
# checking that preconditions are met.
#
# Each state has:
# * a message
# * a next state (a function name)
# (eventually may have multiple next named states)
# * an auto test
#
@ramnathv
ramnathv / to_json.R
Created October 29, 2013 20:28
Data Frame to JSON ala Pandas
to_json = function(df, orient = "columns", json = T){
dl = as.list(df)
dl = switch(orient,
columns = dl,
records = do.call('zip_vectors_', dl),
values = do.call('zip_vectors_', setNames(dl, NULL))
)
if (json){
dl = rjson::toJSON(dl)
}
@bearloga
bearloga / tabletools.R
Created January 9, 2014 00:40
This shows how to add a DataTables plug-in (in this case TableTools) to your Shiny app.
library(shiny)
library(ggplot2)
# Download DataTables JS file and TableTools full package from http://datatables.net/download/
# Change the paths appropriately:
addResourcePath('datatables','/Users/yourusername/Downloads/DataTables-1.9.4/media')
addResourcePath('tabletools','/Users/yourusername/Downloads/TableTools-2.1.5/media')
runApp(list(
ui = basicPage(
@leeper
leeper / update_github.R
Last active February 2, 2021 22:56
Update packages if a newer version is available from GitHub
library('devtools')
library('utils')
library('httr')
update_github <-
function(ask = TRUE, ...){
installed <- installed.packages()
oldVersion <- installed[,'Version']
urls <- sapply(names(oldVersion), function(x){
d <- packageDescription(x)
@DanHerbert
DanHerbert / fix-homebrew-npm.md
Last active February 12, 2024 17:18
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

OBSOLETE

This entire guide is based on an old version of Homebrew/Node and no longer applies. It was only ever intended to fix a specific error message which has since been fixed. I've kept it here for historical purposes, but it should no longer be used. Homebrew maintainers have fixed things and the options mentioned don't exist and won't work.

I still believe it is better to manually install npm separately since having a generic package manager maintain another package manager is a bad idea, but the instructions below don't explain how to do that.

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.

iclass <- function(x) {
c(
if (is.matrix(x)) "matrix",
if (is.array(x) && !is.matrix(x)) "array",
if (is.double(x)) "double",
if (is.integer(x)) "integer",
mode(x)
)
}