Skip to content

Instantly share code, notes, and snippets.

@devster31
devster31 / ssh-tunnel.md
Created August 16, 2017 12:00
Bash script to setup a temporary SSH tunnel

You can do this cleanly with an ssh 'control socket'. To talk to an already-running SSH process and get it's pid, kill it etc. Use the 'control socket' (-M for master and -S for socket) as follows:

$ ssh -M -S my-ctrl-socket -fnNT -L 50000:localhost:3306 jm@sampledomain.com
$ ssh -S my-ctrl-socket -O check jm@sampledomain.com
Master running (pid=3517) 
$ ssh -S my-ctrl-socket -O exit jm@sampledomain.com
Exit request sent. 

Note that my-ctrl-socket will be an actual file that is created.

@devster31
devster31 / swap.yml
Last active February 28, 2024 10:43 — forked from manuelmeurer/swap.yml
Ansible role for creating a Swap file
- name: set swap_file variable
set_fact:
swap_file: /{{ swap_space }}.swap
- name: check if swap file exists
stat:
path: "{{ swap_file }}"
register: swap_file_check
- name: create swap file
@devster31
devster31 / example.html
Last active February 6, 2024 01:30
Bookmark parser for the NETSCAPE-Bookmark-file-1 format in node. Don't hesitate to comment with feedback.
<!DOCTYPE NETSCAPE-Bookmark-file-1>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<!-- This is an automatically generated file.
It will be read and overwritten.
Do Not Edit! -->
<TITLE>Bookmarks</TITLE>
<H1>Bookmarks</H1>
<DL><p>
<DT><A HREF="https://developer.apple.com/library/mac/releasenotes/InterapplicationCommunication/RN-JavaScriptForAutomation/index.html#//apple_ref/doc/-%20uid/TP40014508" ADD_DATE="1414706885" PRIVATE="0" TAGS="javascript,mac,osx,yosemite">JavaScript for Automation Release Notes</A>
<DD>This article describes JavaScript for Automation, a new feature in OS X Yosemite.
@devster31
devster31 / Dockerfile
Last active January 8, 2023 02:16
[Beets Docker] #config #software
FROM lsiobase/alpine
ARG VERSION
ARG AUDIOTOOLS_VERSION
ENV \
BEETS_VERSION="$VERSION" \
AUDIOTOOLS_VERSION="$AUDIOTOOLS_VERSION" \
# environment settings
BEETSDIR="/config" \
@devster31
devster31 / slugify.py
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
devster31 / fosfo.txt
Created January 16, 2022 22:11
fosfomycin monotherapy PubMed query
(
(
(
"fosfomycin"[MeSH Terms]
OR
"fosfomycin"[All Fields]
)
OR
(
"fosfomycin"[MeSH Terms]
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).
@devster31
devster31 / ffmpeg.md
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 \
@devster31
devster31 / ceph.md
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... https://pastebin.com/5q5XYLXY
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
devster31 / check
Last active January 23, 2022 00:44
[Media management] #commands
ls /directory/Show/Season\ number/ | cut -d '-' -f3- | cut -d '[' -f2- | column -t
pueue add --stashed --label rclone -- "rclone copy put-io: uni-drive-api-crypt:put.io --checksum --stats-one-line-date --stats-log-level NOTICE 2>&1"