Skip to content

Instantly share code, notes, and snippets.

View mkwatson's full-sized avatar

Mark Watson mkwatson

View GitHub Profile
from playwright.sync_api import Playwright, sync_playwright, expect
def run(playwright: Playwright) -> None:
browser = playwright.chromium.launch(headless=False)
context = browser.new_context()
page = context.new_page()
page.goto("https://www.nba.com/warriors/tickets/dub-nation-deals-activate-your-offer")
import json
import requests
from bs4 import BeautifulSoup
url = 'https://www.espn.com/nba/game/_/gameId/401360739'
soup = BeautifulSoup(requests.get(url).text, 'html.parser')
play_by_play = soup.find("div", {"data-plays": True}).attrs['data-plays']
print(json.dumps(json.loads(play_by_play), indent=2))
curl 'https://core-hsr.duneanalytics.com/v1/graphql' \
--data-raw $'
{
"operationName": "FindResultDataByResult",
"variables": { "result_id": "f0de20b7-fad3-4b20-adcd-4f8885292b7c" },
"query":"query FindResultDataByResult($result_id: uuid\u0021) {\\n query_results(where: {id: {_eq: $result_id}}) {\\n id\\n job_id\\n error\\n runtime\\n generated_at\\n columns\\n __typename\\n }\\n get_result_by_result_id(args: {want_result_id: $result_id}) {\\n data\\n __typename\\n }\\n}\\n"}
'
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.
/**
* @dev Wrappers over Solidity's arithmetic operations.
@mkwatson
mkwatson / golf.sh
Last active July 16, 2021 17:52
Search US golf courses with jq
# You might want to download all_course_ratings.json locally first
# QUESTION: What's the jq command to only return the TeeRows for TeeName=White and Gender=Male for a given course?
# Below is the query to return all tee rows for a course, in this case Peacock Gap Golf Club:
curl https://golfcourses.s3.us-west-1.amazonaws.com/all_course_ratings.json | \
jq '
.[] |
select(
send_texts () {
available_number="XXXXXX". # Get this from twilio
mark="XXXXXX"
jennifer="XXXXX"
for number in $mark $jennifer ; do
curl -X POST -d "Body=There's availability at Metreon! https://myturn.ca.gov/" \
-d "From=$available_number" -d "To=$number" \
"https://api.twilio.com/2010-04-01/Accounts/$ACCOUNT_ID/Messages" \
############################
# UNION
############################
WITH t1(v) AS
(VALUES (1), (1), (2)),
t2(v) AS
(VALUES (2), (2), (3))
(SELECT DISTINCT v FROM t1)
UNION
@mkwatson
mkwatson / review-checklist.md
Created July 24, 2020 16:29 — forked from bigsergey/review-checklist.md
Front-end Code Review Checklist

Review checklist

General

  1. Does the code work?
  2. Description of the project status is included.
  3. Code is easily understand.
  4. Code is written following the coding standarts/guidelines (React in our case).
  5. Code is in sync with existing code patterns/technologies.
  6. DRY. Is the same code duplicated more than twice?
@mkwatson
mkwatson / pyenv+virtualenv.md
Last active February 3, 2020 21:42 — forked from tiagoamx/pyenv+virtualenv.md
Cheatsheet: pyenv, virtualenvwrapper, and pip

Cheatsheet: pyenv, virtualenvwrapper, and pip

Installation (for Mac OS)

Install pyenv with brew

brew update
brew install pyenv
@mkwatson
mkwatson / long.sql
Created January 30, 2020 04:13
long ass sql
WITH normalized_match(name, starttime, endtime, youtube_video, twitch_channel) AS
(VALUES
('Jan 24: Academy - C9 vs TL', TIMESTAMP '2020-01-25 01:00', TIMESTAMP '2020-01-25 01:40', '999FdvjJyPY', 'Academy'),
('Jan 24: Academy - DIG vs EG', TIMESTAMP '2020-01-25 01:00', TIMESTAMP '2020-01-25 01:40', '999FdvjJyPY', 'Academy'),
('Jan 24: Academy - TSM vs IMT', TIMESTAMP '2020-01-25 01:00', TIMESTAMP '2020-01-25 01:40', '999FdvjJyPY', 'Academy'),
('Jan 24: Academy - FLY vs CLG', TIMESTAMP '2020-01-25 01:00', TIMESTAMP '2020-01-25 01:40', '999FdvjJyPY', 'Academy'),
('Jan 24: Academy - 100T vs GG', TIMESTAMP '2020-01-25 01:49', TIMESTAMP '2020-01-25 02:20', '999FdvjJyPY', 'Academy'),
('Jan 25: LCS - C9 vs TL', TIMESTAMP '2020-01-25 22:06', TIMESTAMP '2020-01-25 22:32', '3KABoEyHqUM', 'LCS'),
('Jan 25: LCS - CLG vs DIG', TIMESTAMP '2020-01-25 22:58', TIMESTAMP '2020-01-25 23:38', '3KABoEyHqUM', 'LCS'),
('Jan 25: LCS - 100T vs GG', TIMESTAMP '2020-01-26 00:02', TIMESTAMP '2020-01-26 0