Skip to content

Instantly share code, notes, and snippets.

View thatbudakguy's full-sized avatar

Nick Budak thatbudakguy

  • San Francisco, CA
  • 10:56 (UTC -08:00)
View GitHub Profile
@thatbudakguy
thatbudakguy / weather_report.py
Created April 24, 2024 20:23
weather reporting bot for MQTT
"""
Report weather data via MQTT.
"""
import sys
import os
import requests
import time
import paho.mqtt.client as mqtt
@thatbudakguy
thatbudakguy / make_conll.py
Created January 6, 2024 23:21
CoNLL-2002 and CoNLL-U generators (spaCy)
"""Auto-generate CoNLL-2002 (IOB) entities by tagging a text file."""
from pathlib import Path
from typing import Optional
from typing_extensions import Annotated
import spacy
from spacy.training import offsets_to_biluo_tags
from spacy.training import biluo_to_iob
import typer
@thatbudakguy
thatbudakguy / circ_index_profile.rb
Created May 19, 2023 17:43
FOLIO circ rules evaluation
# frozen_string_literal: true
# require 'ruby-prof'
require 'csv'
# locations
## institution
SU_ID = '8d433cdd-4e8f-4dc1-aa24-8a4ddb7dc929'
## campus
@thatbudakguy
thatbudakguy / supar.py
Last active October 15, 2021 14:43
supar-kanbun tokenizer
class SuParKanbunTokenizer(object):
to_disk = lambda self, *args, **kwargs: None
from_disk = lambda self, *args, **kwargs: None
to_bytes = lambda self, *args, **kwargs: None
from_bytes = lambda self, *args, **kwargs: None
def __init__(self, bert, segment, vocab) -> None:
self.bert = bert
self.vocab = vocab
self.simplify = {}
@thatbudakguy
thatbudakguy / visual_tests.py
Created July 8, 2021 14:04
percy scrapy crawler
from percy import percy_snapshot
from scrapy.spiders import SitemapSpider
from selenium import webdriver
class PercySpider(SitemapSpider):
"""Sitemap crawler that uploads DOM snapshots to Percy."""
name = "cdhweb"
sitemap_urls = ["http://localhost:8000/sitemap.xml"]
@thatbudakguy
thatbudakguy / docker-compose.yml
Created February 4, 2020 19:32
single solr compose file
version: '3'
services:
index:
image: solr
ports:
- "8983:8983"
volumes:
- ./solr_conf:/opt/solr/server/solr/configsets/core-name:ro
command:
- solr-precreate
@thatbudakguy
thatbudakguy / docker-compose.yml
Created January 6, 2020 18:44
django docker devenv
FROM node:8
RUN mkdir /code
WORKDIR /code
COPY package.json /code/
RUN npm -g config set user root
RUN npm install -g node-sass postcss-cli autoprefixer
RUN npm install
FROM python:3.5
ENV PYTHONUNBUFFERED 1
@thatbudakguy
thatbudakguy / ddj.json
Created November 8, 2019 20:15
passim-test
{"id": "老子", "text": "道可道,非常道。名可名,非常名。無名天地之始;有名萬物之母。故常無欲,以觀其妙;常有欲,以觀其徼。此兩者,同出而異名,同謂之玄。玄之又玄,衆妙之門天下皆知美之為美,斯惡已。皆知善之為善,斯不善已。故有無相生,難易相成,長短相較,高下相傾,音聲相和,前後相隨。是以聖人處無為之事,行不言之教;萬物作焉而不辭,生而不有。為而不恃,功成而弗居。夫唯弗居,是以不去不尚賢,使民不爭;不貴難得之貨,使民不為盜;不見可欲,使心不亂。是以聖人之治,虛其心,實其腹,弱其志,強其骨。常使民無知無欲。使天知者不敢為也。為無為,則無不治道沖而用之或不盈。淵兮似萬物之宗。挫其銳,解其紛,和其光,同其塵。湛兮似或存。吾不知誰之子,象帝之先天地不仁,以萬物為芻狗;聖人不仁,以百姓為芻狗。天地之間,其猶橐籥乎?虛而不屈,動而愈出。多言數窮,不如守中谷神不死,是謂玄牝。玄牝之門,是謂天地根。綿綿若存,用之不勤天長地久。天地所以能長且久者,以其不自生,故能長生。是以聖人後其身而身先;外其身而身存。非以其無私耶?故能成其私上善若水。水善利萬物而不爭,處衆人之所惡,故幾於道。居善地,心善淵,與善仁,言善信,正善治,事善能,動善時。夫唯不爭,故無尤持而盈之,不如其已;揣而銳之,不可長保。金玉滿堂,莫之能守;富貴而驕,自遺其咎。功遂身退天之道載營魄抱一,能無離乎?專氣致柔,能嬰兒乎?滌除玄覽,能無疵乎?愛民治國,能無知乎?天門開闔,能為雌乎?明白四達,能無知乎?生之、畜之,生而不有,為而不恃,長而不宰,是謂玄德三十輻,共一轂,當其無,有車之用。埏埴以為器,當其無,有器之用。鑿戶牖以為室,當其無,有室之用。故有之以為利,無之以為用五色令人目盲;五音令人耳聾;五味令人口爽;馳騁田獵,令人心發狂;難得之貨,令人行妨。是以聖人為腹不為目,故去彼取此寵辱若驚,貴大患若身。何謂寵辱若驚?寵為下,得之若驚,失之若驚,是謂寵辱若驚。何謂貴大患若身?吾所以有大患者,為吾有身,及吾無身,吾有何患?故貴以身為天下,若可寄天下;愛以身為天下,若可託天下視之不見,名曰夷;聽之不聞,名曰希;搏之不得,名曰微。此三者不可致詰,故混而為一。其上不皦,其下不昧。繩繩不可名,復歸於無物。是謂無狀之狀,無物之象,是謂惚恍。迎之不見其首,隨之不見其後。執古之道,以御今之有。能知古始,是謂道紀古之善為士者,微妙玄通,深不可識。夫唯不可識,故強為之容。豫兮若
@thatbudakguy
thatbudakguy / migrate_blogposts.py
Last active September 12, 2019 20:50
cdhweb blog post migration
import os
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'cdhweb.settings')
import django
django.setup()
from xml.etree import ElementTree
from dateutil.parser import parse
from mezzanine.core.models import CONTENT_STATUS_DRAFT
from cdhweb.blog.models import BlogPost
from cdhweb.people.models import Person
@thatbudakguy
thatbudakguy / stein.json
Created February 15, 2019 21:30
mep account events
["1900-01-19", "1900-01-24", "1900-03-20", "1900-05-30", "1920-03-16", "1920-03-18", "1920-04-29", "1920-06-03", "1920-06-15", "1920-07-10", "1920-10-01", "1920-10-09", "1920-11-01", "1920-11-02", "1920-11-30", "1920-12-23", "1921-01-05", "1921-02-14", "1921-03-11", "1921-03-16", "1921-03-22", "1921-05-21", "1921-05-27", "1921-06-16", "1921-08-05", "1921-08-27", "1921-09-16", "1921-09-27", "1921-10-13", "1921-12-05", "1921-12-13", "1922-01-04", "1922-01-23", "1922-02-11", "1922-02-14", "1922-04-03", "1922-04-13", "1922-05-27"]