Skip to content

Instantly share code, notes, and snippets.

🕳
[ o o ]

Brian Abelson abelsonlive

🕳
[ o o ]
Block or report user

Report or block abelsonlive

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@abelsonlive
abelsonlive / README.md
Last active Sep 9, 2019
A simple two player game of tic tac toe in the terminal.
View README.md

tic tac toe

A simple two player game of Tic Tac Toe written in Python 3.6+

To play, download the file below, open a terminal, and run the following command:

$ python3 tic-tac-toe.py
View base_models.yml
profile_dir: '~/.dbt' # the location of dbt configurations
target: prod # the dbt profile to use for connection
source_schema: fivetran_app # the tables' source schema (where fivetran imports your data to)
materialized: view # how to materialize these views
target_schema: app # the schema to materialize the base models under (where users will access the data from)
table_prefix: app # a prefix to prepend to each base model/view
directory: models/base/ # the directory under which to save the base models
empty_as_null: true # whether or not to apply EMPTYASNULL logic to all text fields
incl_fivetran_deleted: false # whether or not to include records marked as "deleted" by fivetran
excl_fivetran_synced: true # whether or not to include the time fivetran synced each record
View detect_superlatives.py
import sys
import json
import nltk
from nltk.tokenize import RegexpTokenizer
# For a list of all POS tags and their definitions, see:
# https://www.ling.upenn.edu/courses/Fall_2003/ling001/penn_treebank_pos.html
SUPERLATIVE_TAGS = {"JJS", "RBS"}
@abelsonlive
abelsonlive / gist:3703504
Created Sep 12, 2012
read dbf into R (for Cezary)
View gist:3703504
install.packages("foreign")
library("foreign")
data = read.dbf("path/to/file.dbf")
write.csv(data, "path/to/file.csv", row.names=F)
@abelsonlive
abelsonlive / wait_browser.py
Last active Jun 18, 2019
Waiting For responses in selenium
View wait_browser.py
from selenium import webdriver
from selenium.webdriver.support.wait import WebDriverWait
class WaitBrowser(object):
def __init__(self, **kw):
self.browser = webdriver.PhantomJS()
def readystate_complete(self):
@abelsonlive
abelsonlive / dbt_backfill.py
Created Apr 11, 2019
Script for backfilling DBT models which use partitions
View dbt_backfill.py
#!/usr/bin/env python
import json
import copy
import sys
import argparse
from datetime import datetime, timedelta
from subprocess import Popen, PIPE
# dictionary of partiton names to variable generating functions
@abelsonlive
abelsonlive / mongo_import.sh
Created Nov 17, 2012
import csv into mongodb from command line
View mongo_import.sh
#!/usr/bin/bash
## include --upsert if adding to a prexistitng collection
mongoimport -d db_name -c coll_name --type csv --file file.csv --headerline
@abelsonlive
abelsonlive / cosine_similarity.R
Last active Aug 20, 2018
Cosine Distance Recommendation / Collaborative Filtering Example
View cosine_similarity.R
# lets make some dummy data
n_rows <- 1000
n_cols <- 100
mat <- matrix(0, nrow=n_rows, ncol=n_cols)
mat <- apply(mat, 2, function(x) { return(rbinom(n_rows, size=1, prob=0.1))})
colnames(mat) <- paste0("event", 1:n_cols)
rownames(mat) <- paste0("pol", 1:n_rows)
# lets take a look at it before we do some math
head(mat)
@abelsonlive
abelsonlive / keybase.md
Created May 28, 2018
keybase verification
View keybase.md

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@abelsonlive
abelsonlive / srapeshell.R
Created Sep 23, 2012
# best practices for web scraping in R // ldply
View srapeshell.R
# best practices for web scraping in R #
# function should be used with ldply
# eg:
ldply(urls, scrape)
# add a try to ignore broken links/ unresponsive pages
# eg:
You can’t perform that action at this time.