Skip to content

Instantly share code, notes, and snippets.

View almartin82's full-sized avatar

Andrew Martin almartin82

  • Princeton, NJ
  • 13:34 (UTC -04:00)
View GitHub Profile
@alexcasalboni
alexcasalboni / aws-lambda-static-type-checker.md
Last active May 22, 2023 07:31
AWS Lambda Static Type Checker Example (Python3)

How to use Python3 Type Hints in AWS Lambda

TL;DR

Static Type Checkers help you find simple (but subtle) bugs in your Python code. Check out lambda_types.py and incrementally improve your code base and development/debugging experience with type hints.

Your Lambda Function code will go from this:

@abresler
abresler / exploding_boxplot_test
Last active February 1, 2017 14:35
Expoding Boxplot Function & nbastatR test use case
# load_packages -----------------------------------------------------------
packages <-
c('nbastatR', #devtools::install_github("abresler/nbastatR")
'explodingboxplotR', #devtools::install_github("timelyportfolio/explodingboxplotR")
'ggplot2',
'dplyr',
'purrr',
'magrittr')
@lmarkus
lmarkus / README.MD
Last active May 21, 2024 02:50
Extracting / Exporting custom emoji from Slack

Extracting Emoji From Slack!

Slack doesn't provide an easy way to extract custom emoji from a team. (Especially teams with thousands of custom emoji) This Gist walks you through a relatively simple approach to get your emoji out.

If you're an admin of your own team, you can get the list of emoji directly using this API: https://api.slack.com/methods/emoji.list. Once you have it, skip to Step 3

HOWEVER! This gist is intended for people who don't have admin access, nor access tokens for using that list.

Follow along...

@gene1wood
gene1wood / example_aws_lambda_cloudformation_context.md
Last active January 4, 2023 06:41
Details on the AWS Lambda Python LambdaContext context object when instantiated from a CloudFormation stack

LambdaContext

Here is the raw output from examining the Python LambdaContext context object in a AWS Lambda function when called from a CloudFormation stack. More information on the context object can be found here : http://docs.aws.amazon.com/lambda/latest/dg/python-context-object.html

LambdaContext object : print(context)

<__main__.LambdaContext object at 0x7fd706780710>

LambdaContext vars : vars(context)

@gluc
gluc / app.R
Last active November 23, 2022 10:14
Shiny CRUD
library(shiny)
library(shinyjs)
# Get table metadata. For now, just the fields
# Further development: also define field types
# and create inputs generically
GetTableMetadata <- function() {
fields <- c(id = "Id",
@paulsmith
paulsmith / scrape.py
Last active August 29, 2015 14:18
scrape april 7 2015 chicago mayoral runoff election results
from __future__ import print_function
from collections import namedtuple
import csv
import sys
import time
from urllib import urlopen
from bs4 import BeautifulSoup
@yihui
yihui / htmltools-deps.Rmd
Created March 31, 2015 02:33
A minimal example of HTML dependencies
---
title: HTML Dependencies
output: html_document
---
This example explains how HTML dependencies work in **htmltools**. Sometimes an HTML fragment may have additional dependencies to work correctly, such as JavaScript and/or CSS files. In R Markdown documents, you have to let **rmarkdown** know these dependencies, so they can be added to the HTML header when the document is rendered through Pandoc.
Another thing that you need to pay attention is you have to "protect" your HTML output so that Pandoc does not touch it, e.g. when you have four leading spaces, Pandoc may think this line is supposed to be a `<pre>` block whereas you only meant to indent the line for cosmetic purposes. In this case, the function `htmltools::htmlPreserve()` will be _automatically_ applied to your HTML content in R Markdown if the content is generated from `htmltools::tags` or wrapped in `htmltools::HTML()`.
Now we use a random CSS file in the **knitr** package to illustrate how dependencies work. The goal here is to generate a
@rich-iannone
rich-iannone / us_cities_graph.R
Last active August 29, 2015 14:17
This is a Graphviz diagram that shows major US cities (with population greater than 300,000 people). Uses chromatography.js to provide some color by US state, and, the DiagrammeR R package (https://github.com/rich-iannone/DiagrammeR) to render the graph.
# install.packages("downloader")
# devtools::install_github("rich-iannone/DiagrammeR")
# devtools::install_github("jeroenooms/V8")
library("downloader")
library("DiagrammeR")
library("V8")
# Create a function that uses the 'chromatography' JS library to generate a random
# set of colors from the CIE Lab color space
@datalove
datalove / non_generic_function
Last active January 31, 2017 18:18
How to take an R function that isn't generic, make it generic and add method for your class without breaking the standard functionality
identical <- function(x) UseMethod("identical")
identical.my_class <- function(x) do_something(x)
identical.default <- base::identical
@bayesball
bayesball / batter.matchup.ggplot.R
Last active December 16, 2016 20:23
Finds estimates of true batting averages for all batters against a specific pitcher.
# loading in Retrosheet data for the seasons 1960 through 2013 from my website
load(url("http://bayes.bgsu.edu/baseball/pbp.1960.1979.Rdata"))
load(url("http://bayes.bgsu.edu/baseball/pbp.1980.1999.Rdata"))
load(url("http://bayes.bgsu.edu/baseball/pbp.2000.2013.Rdata"))
batter.matchup.ggplot <- function(Name, graph=TRUE, retroid=FALSE){
# this function assumes the data frames pbp.60.79, pbp.80.99, and pbp.00.13 are
# in the workspace
fit.model <- function(y, n){
require(LearnBayes)