Skip to content

Instantly share code, notes, and snippets.

@gd3kr
gd3kr / script.js
Created February 15, 2024 06:30
Download a JSON List of twitter bookmarks
/*
the twitter api is stupid. it is stupid and bad and expensive. hence, this.
Literally just paste this in the JS console on the bookmarks tab and the script will automatically scroll to the bottom of your bookmarks and keep a track of them as it goes.
When finished, it downloads a JSON file containing the raw text content of every bookmark.
for now it stores just the text inside the tweet itself, but if you're reading this why don't you go ahead and try to also store other information (author, tweetLink, pictures, everything). come on. do it. please?
*/
@harshildarji
harshildarji / docx_to_conll.py
Created November 7, 2023 12:52
Python script to extract comments from .docx file, and convert into CoNLL format.
import json
import os
import string
import zipfile
from lxml import etree
from nltk.tokenize import RegexpTokenizer
from tqdm import tqdm
import docx
@EcZachly
EcZachly / groups.sql
Created November 6, 2023 21:11
How to write an algorithm to group people in optimized groups based on timezone and track
-- first query all the users
WITH offsets AS (SELECT a.*,
EXTRACT(hour FROM ptn.utc_offset) AS utc_offset
FROM bootcamp.attendees a
JOIN pg_timezone_names ptn ON a.timezone = ptn.name
WHERE a.bootcamp_version = 3
AND a.timezone IS NOT NULL
AND a.content_delivery = 'Live'::text
),
-- then aggregate the users by track and offset, we want matching timezones to fill up first
@vrslev
vrslev / main.py
Last active May 28, 2024 10:08
Automatic browser reloading in FastAPI
import os
import arel
from fastapi import FastAPI, Request
from fastapi.templating import Jinja2Templates
app = FastAPI()
templates = Jinja2Templates("templates")
if _debug := os.getenv("DEBUG"):
# MIT LICENSE
import datetime
import plotly.graph_objs as go
from plotly.subplots import make_subplots
import numpy as np
import dash_core_components as dcc
import dash_html_components as html
import dash
version: '3'
services:
traefik:
image: traefik:v2.0
container_name: traefik
restart: unless-stopped
security_opt:
- no-new-privileges:true
networks:
@brasey
brasey / Configure systemd-resolved to use a specific DNS nameserver for a given domain.md
Created October 25, 2019 14:38
Configure systemd-resolved to use a specific DNS nameserver for a given domain

Configure systemd-resolved to use a specific DNS nameserver for a given domain

Use case

Given

  • I use a VPN to connect to my work network
  • I'm on a Linux computer that uses systemd-resolved
  • I have a work domain called example.com
  • example.com is hosted by both public and private DNS nameservers
@tvst
tvst / session_id.py
Last active May 18, 2023 12:05
Hack to get a session-specific ID in Streamlit. See https://discuss.streamlit.io/t/session-specific-caching/271
import streamlit.ReportThread as ReportThread
from streamlit.server.Server import Server
def get_session_id():
# Hack to get the session object from Streamlit.
ctx = ReportThread.get_report_ctx()
this_session = None
@ines
ines / streamlit_prodigy.py
Created October 3, 2019 20:37
Streamlit + Prodigy
"""
Example of a Streamlit app for an interactive Prodigy dataset viewer that also lets you
run simple training experiments for NER and text classification.
Requires the Prodigy annotation tool to be installed: https://prodi.gy
See here for details on Streamlit: https://streamlit.io.
"""
import streamlit as st
from prodigy.components.db import connect
from prodigy.models.ner import EntityRecognizer, merge_spans, guess_batch_size
@smartexpert
smartexpert / snippets.md
Last active January 30, 2021 12:37
Snippets

Create an empty file in Windows

This is to emulat touch file.extention on Mac

copy NUL filename.txt

Change conda auto activate base environment

conda config --set auto_activate_base false

Create new python3 virtual environment

python3 -m venv env