Skip to content

Instantly share code, notes, and snippets.

@jlstro
jlstro / tinyscraper.py
Created November 3, 2025 16:56
readwrite edition 1 tiny scraper
import requests
from bs4 import BeautifulSoup
r = requests.get("https://en.wikipedia.org/wiki/Middle_Rhine", headers={'User-Agent': 'tinyscraper'})
soup = BeautifulSoup(r.text, "html.parser")
for li in soup.find_all("table")[1].find_all("li"):
text = li.get_text(strip=True)
link_tag = li.find("a", href=True)
href = link_tag['href'] if link_tag else None
print(f"Text: {text} | Link: {href}")
@jlstro
jlstro / launch.json
Created January 14, 2024 10:53
vscode launch.json debug c
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug",
"type": "cppdbg",
"request": "launch",
"program": "/path/to/executable",
"args": ["1", "2", "3", "4"],
"stopAtEntry": false,
@jlstro
jlstro / tasks.json
Created January 14, 2024 10:52
vscode tasks.json debug from makefile
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "make -C /project/path/",
"group": {
"kind": "build",
"isDefault": true
@jlstro
jlstro / keybase.md
Last active November 3, 2020 21:06

Keybase proof

I hereby claim:

  • I am jlstro on github.
  • I am jstrozyk (https://keybase.io/jstrozyk) on keybase.
  • I have a public key whose fingerprint is 25F1 6246 0F8D FB31 3D86 9024 DA5D B5B4 5634 ACA4

To claim this, I am signing this object:

def convert(arcmin):
regex = r'(\d+)° (\d+)\' (\d+.\d+)\" (\w)'
match = re.findall(regex, arcmin)
degree = int(match[0][0])+(float(match[0][1])/60)+(float(match[0][2])/3600)
if match[0][-1] in ['S', 'W']:
degree = -degree
return(degree)
def convert_df(row):
lat = convert(row['Latitude'])
@jlstro
jlstro / tax_havens.csv
Created November 20, 2018 19:12
tax_haven_iso_codes
NL HK MU AD BM BS VG KY IE LR LI MH MC NR SG VU
@jlstro
jlstro / states_snippet.py
Last active August 29, 2018 14:54
[us/can state converter] convert state abbreviations to full names and vice versa
def convert_state(state_input):
if len(state_input)==2:
for state in states:
if state_input==state[0]:
return state[1]
else:
for state in states:
if state_input == state[1]:
return state[0]
@jlstro
jlstro / csv2sqlite.py
Created August 29, 2018 14:31
[csv2sqlite] convert a csv file to a sqlite data base
import pandas as pd
import sqlite3
#read csvs
first_df = pd.read_csv('file1.csv')
second_df = pd.read_csv('file2.csv')
#create connection
conn = sqlite3.connect('DATABASE_NAME.db')
@jlstro
jlstro / app.py
Created August 29, 2018 14:26
[flask app] basic flask web app (school data as example)
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask import request
from flask import render_template
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///schools.db'
db = SQLAlchemy(app)
class School(db.Model):
__tablename__ = 'schools'
@jlstro
jlstro / freezer.py
Created August 29, 2018 14:21
[flask freezer] freezer app for flask webapps
from flask_frozen import Freezer
from app import app, DATABASE
app.config['FREEZER_RELATIVE_URLS'] = True
app.config['FREEZER_DESTINATION'] = 'docs'
freezer = Freezer(app)
@freezer.register_generator
def VARIABLE():