Skip to content

Instantly share code, notes, and snippets.

%matplotlib inline
import numpy as np
from lifelines import KaplanMeierFitter
from matplotlib import pyplot as plt
from pylab import rcParams
rcParams['figure.figsize'] = 20, 10
plt.style.use('ggplot')
@fredrick
fredrick / config.txt
Created April 6, 2015 14:48
Presto VM options
-ea -Xmx2G -Dconfig=etc/config.properties -Dlog.levels-file=etc/log.properties -Dhive.metastore.uri=thrift://localhost:9083
@fredrick
fredrick / App-example-test.js
Last active April 6, 2018 12:39
React Router Test Context Helper
var React = require('react/addons'),
TestUtils = React.addons.TestUtils,
TestContext = require('./TestContext'),
App = require('./App.jsx'),
app = TestContext.getRouterComponent(App);
describe('App', function() {
it('has something', function() {
expect(app.getDOMNode().textContent).toContain('something');
});
@fredrick
fredrick / cheatsheet.R
Last active August 29, 2015 14:01
R Statistics Cheetsheet
library(ggplot2)
library(plyr)
## Graphing
# Histogram of columnName in someDataFrame, ordered in descending frequency
# from left to right.
ggplot(someDataFrame, aes(x=reorder(columnName,columnName,function(x)-length(x)))) +
geom_bar() +
xlab("X Label") +
@fredrick
fredrick / thread_last_currying.clj
Created March 11, 2014 23:39
Thread last currying
;;
;; Example of thread last macro ->> and partial function application
;;
(defn header [this] {:head this})
(->> (header 1) :head ((partial + 1)))
;; => 2
(->> (header 3) :head ((partial - 1)))
;; => -2
@fredrick
fredrick / hp35.txt
Last active December 24, 2015 00:40
7 7
~:,,:~
7 +:,.~~~~~~:~7
777777 7~:.?7~~~~~~~~~,:+7
77 777 7 7 77~,.:,,:..7~~~~~~~~~.:7
7777777777777777777 77~:,7,:~::::,:..~~:~~~~~~~,:7 7
7777777777777777777777 777 7 77~:.7::::.:~:::..:::?~~~~~~~~~~,~7 7
777777777777777777777777777777777:,=,:::?::::..:~::,~::,.7~~~~~~~~~~,~77
77777777777777777777777777777::.7::~::~:...~:::.~?,::::::,.7~~~~~~~~~~,~ 7777777
77777777777777777777777777:.~,::::.:~,~:::,~~:::..:~~::::::..+~~~~~~~~~,,~777777
@fredrick
fredrick / powermean.r
Last active December 16, 2015 07:48
Generalized/power mean with R
# Power mean
## Examples:
## p = 1, arithmetic mean
## p = 2, quadratic mean (RMS)
pmean <- function(x, p) {
library(TTR)
return(tail(TTR::SMA(x^p, length(x))^(1/p), n=1))
}
@fredrick
fredrick / Preferences.sublime-settings
Created October 29, 2012 02:13
Sublime Text 2 Preferences
{
"color_scheme": "Packages/User/Monokai Soda.tmTheme",
"ensure_newline_at_eof_on_save": true,
"translate_tabs_to_spaces": true,
"font_face": "Monaco",
"font_size": 12,
"theme": "Soda Light.sublime-theme"
}
@fredrick
fredrick / PythonBenchmark.md
Created June 8, 2012 22:27
Real World Comparison of Python Platform Performance

Real World Comparison of Python Platform Performance

Data parsing benchmark, using homogeneous Python source code across all platforms with the exception of, for Cython, type annotation and compilation to C. CPython 2.7.2 invoked with python, Cython 0.16 with python with test script loading compiled module, and PyPy 1.9 with pypy.

wc data.log
  21768456  360606156 3563967905 data.log
@fredrick
fredrick / wordpress.sql
Created May 23, 2012 01:42
WordPress Test Installation
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
--
-- Database: `wordpress`
--
-- --------------------------------------------------------
--
-- Table structure for table `wp_commentmeta`