Skip to content

Instantly share code, notes, and snippets.

@bhaskarvk
bhaskarvk / purrr_walk_test.R
Last active March 6, 2016 17:37
Some code to test purrr::walk
# Sample df with missing values
df <- data.frame(col1=sample(c('','Y','N'),100,replace = TRUE),
col2=sample(c('', as.character(0:9)),100,replace = TRUE),
stringsAsFactors = FALSE)
cols <- colnames(df) # store colnames
lapply(df,table) # check levels
df.forFor <- df # to be fixed with a for loop
@bhaskarvk
bhaskarvk / solaris.diff
Last active October 25, 2015 01:45
Shiny Server patch for Solaris
diff --git a/src/launcher.cc b/src/launcher.cc
index d8d04b6..835b149 100644
--- a/src/launcher.cc
+++ b/src/launcher.cc
@@ -73,7 +73,11 @@ int main(int argc, char **argv) {
int findBaseDir(std::string* shinyServerPath) {
char execPath[MAXPATHLEN + 1];
+#ifdef __sun
+ int cn = snprintf(execPath, MAXPATHLEN + 1, "/proc/%d/path/a.out", getpid());
@bhaskarvk
bhaskarvk / .raliases
Created September 8, 2015 16:21
Bash functions to install R packages from github
rInstGithub() {
Rscript -e "devtools::install_github('$1')"
}
rInstBob() {
rInstGithub "hrbrmstr/$1"
}
rInstKent() {
rInstGithub "timelyportfolio/$1"
}
rInstHadley() {
@bhaskarvk
bhaskarvk / ipUtils
Last active August 29, 2015 14:16
Vectorized functions to convert ipv4 to/from integer
# Vectorized functions to convert ipv4 to/from integer
require(bitops) # required for unsigned int bitwise ops
int_to_ipv4 <- function(i) {
return(lapply(i,function(x) {
paste(bitAnd(bitShiftR(x,c(24,16,8,0)),0xFF),collapse='.')
}))
}
ipv4_to_int <- function(i) {
@bhaskarvk
bhaskarvk / keybase.md
Last active October 23, 2015 16:12
keybase.md

Keybase proof

I hereby claim:

  • I am bhaskarvk on github.
  • I am bhaskarvk (https://keybase.io/bhaskarvk) on keybase.
  • I have a public key whose fingerprint is E92A 38BA A931 0D68 A2F5 4C30 B647 68F2 BF54 8FD9

To claim this, I am signing this object: