Skip to content

Instantly share code, notes, and snippets.

import os
from subprocess import check_output
from pprint import pprint
from plexapi.server import PlexServer
def process_movie_section(section, plex_media_paths, rclone_mount):
for directory in section.all():
# in case of a movie, this will host a list of files
# which is actually just 1 file, mentioning the movie's location
@ajitid
ajitid / 01-macbook-manual-setup.md
Last active December 23, 2023 07:58
Macbook manual setup

System Settings

Keyboard > Press 🌐 key to "Start dictatation (Press 🌐 twice)" (emojis have fn+e and ctrl+cmd+space)

Keyboard > Text Input > Input Sources > Edit... > disable "Add full stop with double space"

Desktop and Dock > Hot Corners > Bottom right > hold cmd key > choose Desktop

Displays > More Space (in resolution)

@ajitid
ajitid / main.js
Last active April 28, 2023 10:31
Understanding `this`
"use strict";
// using strict mode as `this` behavior can change in a non-strict JS https://egghead.io/lessons/javascript-this-in-function-calls
// ESM files use `"use strict";` by default
// -------------
// Let's see what top level `this` is in different environments
/*
in browsers
@ajitid
ajitid / simpler-wait-forever.go
Last active March 29, 2023 20:53
Wait forever so that your goroutines can finish in Golang
/*
NOT TO BE USED IN PRODUCTION
Lets you wait forever so that your goroutines can finish.
Works great when coupled with [watchexec](https://watchexec.github.io/) like `watchexec -rc go run .` while learning Go.
src: https://stackoverflow.com/questions/36419054/go-projects-main-goroutine-sleep-forever#comment132984686_36419288
Should be used like:
@ajitid
ajitid / Dockerfile
Last active March 25, 2023 14:41
Nvim (neovim) dockerfile using Fedora
# modified form of https://github.com/casonadams/nvim-container/blob/master/Dockerfile
FROM registry.fedoraproject.org/fedora-minimal:latest
RUN microdnf install -y \
bat \
fd-find \
fzf \
git \
neovim \
ripgrep \
@ajitid
ajitid / pasting-sensitive-info-x11.md
Last active May 17, 2023 23:21
Pasting sensitive info on X11
  1. Install keyring using conda install keyring. Then put your sensitive info by entering keyring set system apass. In a key value pair, apass would be your key and your sensitive info would be your value. (You can change key name from apass to anything you like)
  2. Install xdotool and xsel, and chmod u+x a script and put it into ~/.local/bin with the content:
#!/usr/bin/sh
xdotool type $(keyring get system apass | tr -d '\n')
xdotool key enter

The script types in the sensitive info and then hits enter key.

@ajitid
ajitid / full-height.md
Last active December 24, 2022 11:48
Make child occupy full height

I usally assign root div a color and give it a color with min-height: 100vh (min-h-screen). But sometimes I need to use different style in a page. So if I make this child <div class="h-full">, it doesn't work. See this post.

I found this to be most reliable:

.parent {
  /* min-h-screen */
  min-height: 100vh;
}
@ajitid
ajitid / Dockerfile
Last active March 25, 2023 14:41
Nvim (neovim) dockerfile using Alpine Linux
FROM anatolelucet/neovim:nightly
RUN apk add curl git
RUN mkdir -p /root/.config/nvim/
RUN sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
RUN echo -en 'call plug#begin()\ncall plug#end()\n' > /root/.config/nvim/init.vim
WORKDIR /root
@ajitid
ajitid / init.vim
Created June 21, 2022 09:11
Persistent undo
if has("persistent_undo")
let target_path = stdpath('data') . '/.undodir'
" create the directory and any parent directories
" if the location does not exist.
if !isdirectory(target_path)
call mkdir(target_path, "p", 0700)
endif
let &undodir=target_path
@ajitid
ajitid / index.ts
Last active March 9, 2023 12:05
Max async tasks - interview practice solution (NOT for prod use)
type AsyncFn = () => Promise<unknown>;
class AsyncWorkers {
private queue: Array<AsyncFn> = [];
private workersAvailable;
constructor(workersCount: number) {
this.workersAvailable = workersCount;
}