Skip to content

Instantly share code, notes, and snippets.

def delimited(filename, delimiter=' ', bufsize=4096):
'''
Creates a generator of word from a file based on a delimiter (by default white space).
'''
buf = ''
with open(filename) as file:
while True:
newbuf = file.read(bufsize)
if not newbuf:
@heroheman
heroheman / ranger-cheatsheet.md
Last active July 2, 2024 16:15
Ranger Cheatsheet

Ranger Cheatsheet

General

Shortcut Description
ranger Start Ranger
Q Quit Ranger
R Reload current directory
? Ranger Manpages / Shortcuts
@ChugunovRoman
ChugunovRoman / .bashrc
Last active January 6, 2024 10:04
Alias for npm run with auto completing a npm scripts from package.json from current directory.
alias nr="npm run"
_npm_scripts() {
# check package.json file in current directory
if [ ! -f ./package.json ]; then
return
fi
local scripts="$(node -e 'const { scripts } = require(`./package.json`); if (!scripts) process.exit(); let a = Object.entries(scripts); for (let s in scripts) { console.log(s); }' | grep -E ^$2)"
local -a toks
@mrreband
mrreband / AutoHotkey.ahk
Last active December 10, 2022 01:13
AutoHotKey config
#SingleInstance force
SetTitleMatchMode, 2
; FYI:
; # = Win
; + = Shift
; ! = Alt
; ^ = Ctrl
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
##################################################################
# standard directory functions
function mcd ($path) {
mkdir $path
chdir $path
}
function rmrf ($path) {
rm -r -force $path
@mrreband
mrreband / apod.ps1
Last active October 11, 2023 17:43
Scripts to get the NASA Image Of the Day (iotd) and NASA Astronomy Picture of the Day (apod)
# Download and open the NASA Astronomy picture of the day (apod)
# Download to target folder $TargetFolder (relative to this script's location)
# https://apod.nasa.gov/apod/archivepix.html
param
(
[string]$TargetFolder = "images"
)
$ErrorActionPreference = "Stop"
@mrreband
mrreband / restore_ableton_crashes.py
Created September 3, 2022 15:03
Restore Ableton Live Crashes
import os
import shutil
from typing import List, Dict
def prepare_crash(file_date: str,
source_cfg_file: str,
source_undo_folder: str,
source_basefiles_folder: str,
target_path: str,
overwrite: bool=True):