Skip to content

Instantly share code, notes, and snippets.

@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;
}
const a = 1; // put cursor here and try to move down using keys bind to `goto_next_start`'s `@function.outer`
const arrowFn = () => {
console.log('some body')
}
function regularFn() {
console.log('some content')
}
@ajitid
ajitid / bluefin-silverblue.txt
Last active January 5, 2024 05:50
fedora distro (non-wsl)
(See readme.txt as well)
Used https://github.com/ublue-os/bluefin/releases/ in VMWare Workstation
Upon installing and opening Bluefin for the first time, a popup opens up asking to install more software, I close it and wait for remaining packages to be installed. I get a notification that flatpak pkgs have been installed and see Firefox in the dock.
I do a restart
Now I run `just update`. This can fail if you don’t have enough battery or CPU. (It’ll tell you to check the logs.) Otherwise wait for like 10 mins to let it update stuff. It doesn’t show any progress bar at the moment.
Then I restart. Then I run `just devmode`. Restart again once it is done.
@ajitid
ajitid / bypass-sudo.md
Last active December 22, 2023 14:51
Copy and paste pwd (Wayland)

Read readme.md first

It might happen that the input (in which you want to fill the pwd) exist inside a popup and thus opening pkexec could close it. To resolve this we can allow ydotool to be run in w/o sudo password:

  • Execute sudo visudo -f /etc/sudoers.d/my-overrides
  • Paste in this line ajitid ALL=(ALL:ALL) NOPASSWD: /usr/bin/ydotool *
  • Save and exit. Now do sudo -l and you would see an output for ydotool
  • To check if it is working, open a new terminal window and type in sudo /usr/bin/ydotool key 56:1 62:1 62:0 56:0. Upon pressing enter it should either close the window or ask for a confirmation.
  • In clippass script, replace pkexec with sudo
@ajitid
ajitid / step-1.md
Last active May 22, 2022 05:34
Postgres setup in WSL Fedora