Skip to content

Instantly share code, notes, and snippets.

devster31 /
Last active September 12, 2022 12:03
[Slugify] #python
import re
import unicodedata
def slugify(value, allow_unicode=False):
Convert to ASCII if 'allow_unicode' is False. Convert spaces or repeated
dashes to single dashes. Remove characters that aren't alphanumerics,
underscores, or hyphens. Convert to lowercase. Also strip leading and
trailing whitespace, dashes, and underscores.
value = str(value)
devster31 / fosfo.txt
Created January 16, 2022 22:11
fosfomycin monotherapy PubMed query
View fosfo.txt
"fosfomycin"[MeSH Terms]
"fosfomycin"[All Fields]
"fosfomycin"[MeSH Terms]


Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla quis est nec lectus pellentesque vehicula. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Suspendisse eget velit arcu. Curabitur pellentesque pulvinar arcu, at placerat leo scelerisque sit amet. Vivamus vitae lobortis purus, consectetur suscipit ligula. Nunc scelerisque luctus odio id pharetra. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.

#!/usr/bin/env python3
"""Creates a shift scheduling problem and solves it."""
from absl import app
from absl import flags
from ortools.sat.python import cp_model
from google.protobuf import text_format
import glob
import pathlib
from import LongRunning
DOIT_CONFIG = {"action_string_formatting": "new"}
def aria_files():
globs = glob.glob("*.aria2.txt") + glob.glob("*.session")
devster31 / check
Last active January 23, 2022 00:44
[Media management] #commands
View check
ls /directory/Show/Season\ number/ | cut -d '-' -f3- | cut -d '[' -f2- | column -t
pueue add --stashed --label rclone -- "rclone copy put-io: --checksum --stats-one-line-date --stats-log-level NOTICE 2>&1"
devster31 /
Last active January 23, 2022 00:45
[Ceph] #instructions

from IRC channel:

17:17:39 <dirtwash> wowas: no
17:17:51 <dirtwash> wowas: out + purge, no further steps needed to remove
17:18:03 <dirtwash> purge command does everything
18:50:43 <devster> anyone can figure out what's wrong with this ceph-osd (in docker with ceph-ansible) that keeps crashing? It's a single OSD that keeps going up and down every 3 minutes almost exactly...
18:55:44 <dirtwash> devster: just purge it and redo, had this few times, could be any number of known bugs
18:55:59 <dirtwash> devster: or ask on ML
18:56:03 <dirtwash> there wont be an answer here
18:58:20 <devster> thanks dirtwash never did a purge with ceph-ansible
devster31 /
Last active January 23, 2022 00:45
[ffmpeg commands] #commands
ffmpeg -hide_banner -y \
  -c:a aac -ar 48000 \
  -c:v h264 -profile:v baseline \
  -crf 20 -sc_threshold 0 \
  -pix_fmt yuv420p -hls_time 10 \
  -strict -2 -vsync 2 \
  -vf scale=w=<vwidth>:h=<vheight> \
  -b:v <vbrate> -maxrate <maxrate> \
 -bufsize  -b:a 96k \
awk '!visited[$0]++' your_file > deduplicated_file
  • The awk "script" !visited[$0]++ is executed for each line of the input file.
  • visited[] is a variable of type associative array (a.k.a. Map). We don't have to initialize it because awk will do it the first time we access it.
  • The $0 variable holds the contents of the line currently being processed.
  • visited[$0] accesses the value stored in the map with a key equal to $0 (the line being processed), a.k.a. the occurrences (which we set below).
import requests
from bs4 import BeautifulSoup
css = """
table {
color: #666;
font-family: 'Raleway', sans-serif;
font-size: 16px;
font-weight: 400;