Skip to content

Instantly share code, notes, and snippets.

View AdamSpannbauer's full-sized avatar
👀
¯\_(ツ)_/¯

Adam Spannbauer AdamSpannbauer

👀
¯\_(ツ)_/¯
View GitHub Profile
("exit" to quit) Question: What market does FitBit compete in?
Search Rank Squad Rank Combined Rank Answer Context
0 2.0 6.0 1.5 crowded market ... rather crowded ma...
1 7.0 1.0 1.5 oncology ...te in the oncology ...
2 8.0 3.0 3.0 streaming services market ...trate the streaming ...
3 5.0 7.0 4.0 leash ...ck a long leash. Boe...
4 4.0 9.0 5.0 iPhones ...io of new iPhones - ...
5 1.0 13.0 6.5 wearables ...hough, is wearables,...
6 9.0 5.0 6.5 murky ...'re in a "murky" mar...
7 15.0 2.0 8.0 ad market ...ce in the ad market ...
>>> from whoosh.analysis import StandardAnalyzer
>>>
>>> [token.text for token in StandardAnalyzer()("This is an example analysis")]
@AdamSpannbauer
AdamSpannbauer / help2.R
Last active May 2, 2019 17:34
Experiment utility function to display docstring-esque help for R functions in Global Environment
# Experimental utility function
message("--------------------------------------------------------------------------------\n")
message("Overwriting `?` function with custom utility to display in memory function help.\n")
message("--------------------------------------------------------------------------------\n\n")
help2 = function(f, ...) {
#' Extend `help()` to show in memory function documentation
#'
#' @details Supports python docstring-esque roxygen documentation.
@AdamSpannbauer
AdamSpannbauer / diamond_problem.py
Created January 25, 2019 12:56
demonstrating diamond problem stuff with super in python
class A:
def x(self):
print('x: A')
class B(A):
def x(self):
super().x()
print('x: B')
@AdamSpannbauer
AdamSpannbauer / gganimate_heart.R
Last active February 10, 2022 14:40
animated heart using the R package gganimate
library(ggplot2)
library(gganimate)
library(data.table)
gen_heart_y = function(x, a) {
# source: https://i.imgur.com/avE8cxJ.gifv
(x^2)^(1 / 3) + 0.9 * (3.3 - x^2)^(1 / 2) * sin(a * pi * x)
}
heart_dt_list = lapply(seq(1, 15, by = 0.1), function(a) {
@AdamSpannbauer
AdamSpannbauer / r6_fractal_tree.R
Last active August 16, 2021 21:13
R6 Fractal Tree
library(R6)
library(ggplot2)
library(uuid)
options(stringsAsFactors = FALSE)
branch_base = R6Class('branch_base',
public = list(
start_x = NA_integer_,
start_y = NA_integer_,
end_x = NA_integer_,
@AdamSpannbauer
AdamSpannbauer / fractal_tree_gganimate.R
Created July 25, 2018 02:00
Create/animate fractal trees at various angles for branch splits
# Create/animate fractal trees at various angles for branch splits
library(gganimate)
library(ggplot2)
library(uuid)
options(stringsAsFactors = FALSE)
# create line segment from (0, 0) to (0, len) to be trunk of fractal tree
create_trunk = function(len = 1) {
end_point = c(0, len)
# Create/Draw a Binary Fractal Tree
library(ggplot2)
library(uuid)
options(stringsAsFactors = FALSE)
# create line segment from (0, 0) to (0, len) to be trunk of fractal tree
create_trunk = function(len = 1) {
end_point = c(0, len)
trunk_df = data.frame(x=c(0, 0),
@AdamSpannbauer
AdamSpannbauer / fractal_tree.R
Created July 24, 2018 17:12
Create/Draw a Binary Fractal Tree with plotly in R
# Create/Draw a Binary Fractal Tree
library(plotly)
# basic strucure for line shape in plotly
base_line = list(
type = "line",
line = list(color = "black"),
xref = "x",
yref = "y",
@AdamSpannbauer
AdamSpannbauer / barnsley_fern.R
Created July 23, 2018 19:14
generate/draw/animate Barnsley fern in R
# Barnsley fern in R
# reference: https://en.wikipedia.org/wiki/Barnsley_fern
library(plotly)
# FUNCTIONS FOR GENERATING BARNSLEY FERN POINTS ################################
transform_1 = function(x, y) {
x = 0
y = 0.16 * y
return(c(x, y))