Title: PyCon AU Notes
- WebTest
- WSGIProxy
- FunkLoad
Science and Engineering
| nullable = function(name) { | |
| union_name = paste(name, 'NULL', sep='_') | |
| tryCatch({ | |
| # existing definition | |
| getClass(union_name) | |
| return(union_name) | |
| }, | |
| error=function(e) { | |
| # new definition |
| deps: | |
| brew install md5sha1sum automake snappy hadoop | |
| tweak OS X: | |
| # export JAVA_HOME=$(/usr/libexec/java_home) | |
| hack jvm: | |
| # sudo mkdir -p ${JAVA_HOME}/lib/{i386,x86_64}/server | |
| # sudo ln -s ${JAVA_HOME}/{../Libraries,lib/i386/server}/libjvm.dylib | |
| # sudo ln -s ${JAVA_HOME}/{../Libraries,lib/x86_64/server}/libjvm.dylib |
| # match on intersecting word set | |
| matching_words = function(x, y) { | |
| x = unlist(strsplit(x, ' ', fixed=TRUE)) | |
| y = strsplit(y, ' ', fixed=TRUE) | |
| # get intersections | |
| results = sapply(y, function(b) { length(intersect(x, b)) }) | |
| # break ties in intersection counts based on simplicity (length) of original phrase |
| library(robustbase) | |
| # black-scholes LGR function | |
| LGR = function (x, LGR_0, sigma) { | |
| d_1 = (log(x) + sigma ^ 2 / 2.0) / sigma | |
| d_2 = d_1 - sigma | |
| return(LGR_0 * ifelse(x > 0, pnorm(-d_2) - x * pnorm(-d_1), 1.0)) |
| library(gtools) | |
| step_length = 0.01 | |
| x = seq(0.0, 1.0, step_length) | |
| a = 20.0 | |
| b = 2.0 | |
| beta_mean = a / (a + b) |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>Title</title> | |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> | |
| <script type="text/javascript" src="https://github.com/downloads/gnab/remark/remark-0.4.2.min.js"></script> | |
| <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> | |
| <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML&delayStartupUntil=configured"> | |
| remark.on('ready', function () { | |
| MathJax.Hub.Config({ |
| require(plyr) | |
| # determine the flags that make up the number | |
| find_flags = function(x, dense=TRUE) { | |
| # collapse flags if more than one provided | |
| if (length(x) > 1) { | |
| x = Reduce(`|.hexmode`, x) | |
| } | |
| # nothing to do if nothing has been set... |
| library(plyr) | |
| # compute columns - similar to transform and plyr::mutate | |
| compute = function(.data, ..., .append=FALSE) { | |
| cols = as.list(substitute(list(...))[-1]) | |
| cols = cols[names(cols) != ''] | |
| env = parent.frame() | |
| # evaluate the columns |
| # evaluate a condition | |
| cond = function(expr, d=parent.frame()) { | |
| Reduce(`&`, lapply(expr, eval, d)) | |
| } | |
| # example | |
| l = list( | |
| 'Condition 1'=expression(x > 0), | |
| 'Condition 2'=expression(y < 0) |