Skip to content

Instantly share code, notes, and snippets.

View sloanlance's full-sized avatar
Certified GitHub Pro

Mr. Lance E Sloan sloanlance

Certified GitHub Pro
View GitHub Profile
@sloanlance
sloanlance / durationToSeconds.py
Last active November 25, 2021 03:27
Convert ISO 8601 durations to seconds.
import re
from functools import reduce
import string
def durationToSecondsRegex(duration: str) -> int:
"""
Parse duration string; return integer number of seconds.
For example, the duration string "1h2m3s" (1 hour, 2 minutes, 3 seconds)
would return 3723 seconds.
@bobdobbalina
bobdobbalina / Chrome Remote Debugging
Created May 21, 2020 21:16
Mac Terminal command to open Chrome in remote debugging mode
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222
@Dobby233Liu
Dobby233Liu / gtimedToSRT.js
Last active February 27, 2025 17:58
Translates YouTube timed text to SRT. WTFPL. WIP.
// parse-ms
// MIT License, copyright (c) Sindre Sorhus <[email protected]> (sindresorhus.com)
// Modified by Dobby233Liu in slight cooperation with MIT License
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
@gsmitheidw
gsmitheidw / Readme.md
Created November 8, 2019 16:43
Getting started with Termux and termux-dialog

Put the output from a dialog box into a bash variable:

termux-dialog outputs data in json format so we need to parse that. One way is to use jq which needs to be installed: apt install jq -y

Then because we're going to pipe the output into jq we'll need to enclose everything in double quotes before assiging to a variable. This is is a good example:

myvariable="$(termux-dialog -t "Please enter some text" | jq '.text' -r)"

@bittner
bittner / keyboard-keys.md
Created February 28, 2019 22:50
Keyboard keys markup in MarkDown

Ctrl + Alt + Space

#!/bin/bash
# https://www.facebook.com/groups/dataninja/permalink/1978799319092483/
# https://www.metoffice.gov.uk/pub/data/weather/uk/climate/datasets/Tmin/ranked/UK.txt
# https://gist.github.com/patperu/5521d51f2a0eda485e31dcd6bef69587
curl -sL "https://www.metoffice.gov.uk/pub/data/weather/uk/climate/datasets/Tmin/ranked/UK.txt?fbclid=IwAR26RJZPfZYJd4GJ5bn4zmAHlXkGmDj4UPxujCIgLWFW5ErgM9AWkmpG_IM" >data.csv
# normalizza la separazione tra campi e gestisci i valori nulli
sed -i -r 's/^ {1,}//g;s/([0-9]) ([0-9])/\1 \2/g;s/([a-zA-Z]) {2,}([a-zA-Z])/\1 \2/g' data.csv
@sloanlance
sloanlance / Jekyll & Liquid Cheatsheet
Last active September 17, 2022 11:33 — forked from magicznyleszek/jekyll-and-liquid.md
Jekyll & Liquid Cheatsheet (A fork of the gist by "magicznyleszek", FKA "smutnyleszek")
See: `Jekyll & Liquid Cheatsheet.md`
@gatopeich
gatopeich / install_Jupyter.sh
Last active March 29, 2024 22:10
Install Jupyter iPython Notebook on Android via Termux
pkg upgrade
# Install runtime deps
pkg install python libzmq libcrypt
# Add build deps
pkg install python-dev libzmq-dev libcrypt-dev clang
pip3 install -U pip
pip3 install pyzmq --install-option="--zmq=/usr/lib"
pip3 install jupyter
@sloanlance
sloanlance / jq_jsonl_conversion.md
Last active May 22, 2025 15:17
jq: JSONL ↔︎ JSON conversion

jq: JSONL ↔︎ JSON conversion

Prerequisites

  • jqhttps://jqlang.org/ — "like sed for JSON data"

    There are several options available for installing jq. I prefer to use Homebrew: brew install jq

  • JSONL → JSON

@sloanlance
sloanlance / Karabiner: Require fn for esc
Last active December 21, 2017 17:10
Karabiner: Require fn modifier key to activate esc key. Useful for preventing accidental esc keypresses on Macs with a Touch Bar. Doesn't affect all other modifier combinations (i.e., option + command + esc works without requiring fn, too).
Please see the README.md file in this gist.