Skip to content

Instantly share code, notes, and snippets.

@benneely
benneely / anna_karenina_ch_1
Last active August 30, 2018 12:55
anna karenina chapter 1
This file has been truncated, but you can view the full file.
Chapter 1
Happy families are all alike; every unhappy family is unhappy in its own
way.
Everything was in confusion in the Oblonskys' house. The wife had
discovered that the husband was carrying on an intrigue with a French
girl, who had been a governess in their family, and she had announced to
her husband that she could not go on living in the same house with him.
@benneely
benneely / aGetPromise.js
Created March 9, 2017 15:36
Resolving a promise within iife?
/**
* Duke Data Service API.
* REST API to the Duke Data Service. Some requests require Authentication.
*
*/
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['axios'], factory);
@benneely
benneely / keybase.md
Created March 9, 2016 14:12
benneely github keybase proof

Keybase proof

I hereby claim:

  • I am benneely on github.
  • I am benneely (https://keybase.io/benneely) on keybase.
  • I have a public key ASB8sV7Hzga0dCEVbCirzM2dLLJQbbSr7HTk_dxaYmrbpQo

To claim this, I am signing this object:

@benneely
benneely / modify_R_function_in_Namespace
Created February 1, 2016 16:38
modify R function in Namespace
unlockBinding("basehaz", as.environment("package:survival"))
assignInNamespace("basehaz", my_basehaz, ns="survival", envir=as.environment("package:survival"))
assign("basehaz", my_basehaz, "package:survival")
lockBinding("basehaz", as.environment("package:survival"))
@benneely
benneely / cat_cont_examples.R
Created October 20, 2015 18:47
cat cont functions for baseline tables
cat <-function(catvar,colvar,label){
denoms <- tapply(!is.na(catvar),colvar,sum)
counts <- tapply(catvar,colvar,sum)
percen <- round(100*(counts/denoms),digits=2)
totals <- tapply(catvar,rep(1,length(catvar)),sum)
totalsden <- tapply(!is.na(catvar),rep(1,length(catvar)),sum)
totper <- round(100*(totals/totalsden),digits=2)
meatcols <- paste(counts,'/',denoms,'(',percen,'',')',sep="")
totcol <- paste(totals,'/',totalsden,'(',totper,'',')',sep="")
@benneely
benneely / dlo_slo_swiftclient_bakeoff.py
Created August 13, 2015 19:19
SLO vs DLO using swiftclient in python script
# -*- coding: utf-8 -*-
"""
Created on Tue Aug 11 14:03:59 2015
@author: nn31
"""
import swiftclient
import swiftclient.service
from swiftclient.service import SwiftService
import time
import json
@benneely
benneely / translate.R
Created July 2, 2015 19:35
translate cURL to httr (R package) syntax
library(httr)
#Usual cURL GET call
# curl https://api.github.com/users/defunkt
GET('https://api.github.com/users/defunkt')
#Pass custom header
# curl -i -H 'Authorization: token xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' https://api.github.com/repos/benneely/trailR/issues?state=all
GET('https://api.github.com/repos/benneely/trailR/issues?state=all', add_headers('Authorization' = 'token xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'))
@benneely
benneely / pmmlLinSpline
Created May 19, 2015 00:49
PMML Linear Spline Transformation
<DerivedField name="sbp_130"
dataType="double" optype="continuous">
<Apply function="max">
<Constant dataType="integer">0</Constant>
<Apply function="-">
<FieldRef field="sbp_imp"/>
<Constant dataType="integer">130</Constant>
</Apply>
</Apply>
</DerivedField>