Skip to content

Instantly share code, notes, and snippets.

View raybuhr's full-sized avatar

raybuhr raybuhr

View GitHub Profile
@raybuhr
raybuhr / 0_reuse_code.js
Last active August 29, 2015 14:27
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@raybuhr
raybuhr / slack_messages.py
Created March 1, 2016 07:22
function to pull slack message history
# coding: utf-8
from slacker import Slacker
import pandas as pd
def pull_messages(slack_api_token, channel_name, from_time=None):
"""
slack_api_token can be registered at https://api.slack.com/tokens.
from_time assumes unix_timestamp, such as 1456709957.004145
-- mysql can convert between unix and posix time easily
with the function FROM_UNIXTIME so best to just keep that
@raybuhr
raybuhr / get_safari_books.sh
Last active January 23, 2019 19:25
download html ebooks from Safari Books Online
#!/bin/bash
wget --mirror \
--recursive \
--convert-links \
--no-parent \
--domains learning.oreilly.com \
--random-wait \
--adjust-extension \
--header='cookie: cd_user_id=...; BrowserCookie=...; timezoneoffset=21600; csrfsafari=...; sign-on-email="..."; sessionid=...; logged_in=y;' \

re: dbt-labs/dbt-core#559

New Adapter Information Sheet

The following questions are intended to provide information about a warehouse, for use in building a new dbt adapter. Different data warehouses have pretty different semantics, so some of these questions may be more applicable than others. Where possible, please provide as much detail as you can!

Please copy this questionnaire to a GitHub gist, then fill out answers to the questions to the best of your ability. Where you're done, please post a link to the public gist in the relevant issue. If the issue does not already exist, please create it first.

Questions

@raybuhr
raybuhr / Python_Loops.md
Created June 21, 2019 15:50
More than you wanted to know about loops in python

Loops

Loops are a concept for repeat an action on each item in a collection. In day to day life, you might think of this like brushing your teeth -- for each tooth in your mouth scrub with toothbrush and a little bit of toothpaste.

For Loops

The basic format for looping in python is usually taught like this:

>>> for number in range(5):
@raybuhr
raybuhr / minimally_sufficient_pandas.md
Last active October 25, 2019 14:23
minimally sufficient pandas

the tl;dr of https://medium.com/dunder-data/minimally-sufficient-pandas-a8e67f2a2428

select a column of data, use brackets df['column_name']

select rows of data, use .loc or datetime index df['2019-01-01':'2019-02-28' ]

  • if performance is primary concern, using numpy array instead of Pandas

use read_csv and it's many arguments for reading files

use .isna method to filter NaN rows

@raybuhr
raybuhr / fruits.csv
Created October 25, 2019 16:29
a very basic dataset to use for example code
fruit_name tastiness coolness
Açaí 97 0.03422379581559809
Akee 62 0.061128096593225156
Apple 84 0.7736677658268445
Apricot 90 0.44466537189702615
Avocado 67 0.4503439195930089
Banana 53 0.5896125958014631
Bilberry 30 0.18371360990823216
Blackberry 54 0.33187359972401076
Blackcurrant 49 0.9812347721124494
@raybuhr
raybuhr / illinois_covid_cases.R
Last active May 13, 2020 23:04
fetch and plot covid cases and tests to plot
## This is my variation on Chase's first pass
## https://gist.github.com/chasemc/1a6978d500aa47268ecaf9f99719af61
library(htmltab)
library(reshape2)
library(ggplot2)
data_url <- "https://web.archive.org/web/20200513204922/http://covidtracking.com/data/state/illinois"
a <- htmltab(doc = data_url, which = 4)
a$date <- as.Date(a$Date, "%a %b %d %Y")
@raybuhr
raybuhr / emojipacks_slack_download_upload.py
Created April 3, 2021 01:53
python script to download and upload a bunch of emojis to slack
import argparse
import os
import pathlib
import sys
from time import sleep
from bs4 import BeautifulSoup
import pandas as pd
import requests
@raybuhr
raybuhr / .sqlfluff
Created July 9, 2021 16:25
config for sqlfluff
[sqlfluff]
verbose = 0
nocolor = False
dialect = postgres
templater = jinja
rules = None
exclude_rules = None
recurse = 0
output_line_length = 80
runaway_limit = 10