Skip to content

Instantly share code, notes, and snippets.

View mkwatson's full-sized avatar

Mark Watson mkwatson

View GitHub Profile
# Base URL and HTTP method
# Query Parameters:
# - teamId=110 is for the Orioles
# - daysBack=-6 gathers data for the previous week
curl -G 'https://bdfed.stitch.mlbinfra.com/bdfed/stats/player' \
--data-urlencode 'stitch_env=prod' \
--data-urlencode 'season=2023' \
--data-urlencode 'sportId=1' \
--data-urlencode 'stats=season' \
def analyze_stats(stats):
insights = ''
if stats['orioles']['batting_average'] > stats['diamondbacks']['batting_average']:
insights += 'The Orioles have a higher batting average than the Diamondbacks. '
else:
insights += 'The Diamondbacks have a higher batting average than the Orioles. '
if stats['orioles']['slugging_percentage'] > stats['diamondbacks']['slugging_percentage']:
insights += 'The Orioles have a higher slugging percentage than the Diamondbacks. '
else:
{
"data": {
"offer": {
"offer": {
"id": "58950f92-62f2-4de8-b9df-744202c7cd42",
"pathSegment": "dub-nation-deals-b5a6e0b",
"offerShape": "event",
"status": "draft",
"selections": {
"views": [
query GetOffer($offerPathSegment: String!, $limit: Int!, $offset: Int = 0, $searchQuery: String, $minPrice: Int, $maxPrice: Int, $startDate: DateTime, $endDate: DateTime, $level1Filter: String, $level2Filter: String, $showAda: Boolean, $eventSort: EventSelectionsSort, $eventView: EventSelectionsView, $tickets: Int, $rootOfferId: UUID, $appliedCodes: [String!]) {
offer {
offer(pathSegment: $offerPathSegment, rootOfferId: $rootOfferId, appliedCodes: $appliedCodes) {
...offerInfo
__typename
children(limit: $limit, offset: $offset, searchQuery: $searchQuery, minPrice: $minPrice, maxPrice: $maxPrice, startDate: $startDate, endDate: $endDate, level1Filter: $level1Filter, level2Filter: $level2Filter, showAda: $showAda, eventSort: $eventSort, eventView: $eventView, tickets: $tickets) {
limit
offset
total
results {
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" \