Skip to content

Instantly share code, notes, and snippets.

View bibstha's full-sized avatar

Bibek Shrestha bibstha

  • Vancouver, Canada
  • 03:04 (UTC -08:00)
View GitHub Profile
bibstha / init.vim
Last active August 16, 2023 21:13
Minimal neovim config for use with VSCode
View init.vim
" VimPlug for plugin management
" Treesitter + VimMatchup improves start-end matching significantly
call plug#begin()
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'andymass/vim-matchup'
call plug#end()
lua <<EOF
bibstha / gist:97e7922fa6ee650d4adc2981ea0c00a9
Last active February 25, 2023 04:32
Compiling rubyfmt in M1 mac
View gist:97e7922fa6ee650d4adc2981ea0c00a9
# if you haven't cloned rubyfmt yet
git clone
cd rubyfmt
# update ruby submodule if previously checked in
cd librubyfmt/ruby_checkout/
git reset --hard HEAD
cd ..
git submodule update
# now build ruby
cd ruby_checkout
bibstha /
Created October 28, 2022 13:14
Speed test
wget -O /dev/null -q --show-progress
bibstha /
Last active July 19, 2022 11:35
Run rails test inside docker container using vimtest
let g:test#ruby#rails#executable = 'docker compose run -ti --rm backend-test rails test'
# Replace backend-test with the name of the service.
You wouldn't want to run it in the main service because it ends up using the resetting development database.
bibstha /
Created July 15, 2022 22:25
Vim command to play keystrokes on each matching line


a1, b1, c1, d1, e1 
a2, b2, c2, d2, e2

I could do :g/,/normal 2nd$ to delete everything from second , onwards to give sth like

bibstha /
Created May 31, 2021 15:39
negative lookahead with silversearcher ag on file pattern
# find sorbet strictly typed files that are not tests and also instantiate instance variables
ag '@.+=.+' $(ag -G '.*/?!.*(test)/somepath/.*.rb' 'typed: strict' -l)
bibstha / semaphore.c
Created November 18, 2020 22:16
sysv semaphore set, increment, decrement, blocking and reading current value.
View semaphore.c
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/sem.h>
#include <unistd.h>
union semun { /* Used in calls to semctl() */
int val;
struct semid_ds * buf;
unsigned short * array;
bibstha / message_queue.c
Created November 17, 2020 21:51
sysv message queue send and receive example.
View message_queue.c
// Playing around with sysv message queue
// This program will
// 1. Create a sysv message queue
// 2. Send messages
// 3. Receive messages
// How to run
// touch /tmp/c.txt <- this file is necessary for ftok to run.
// gcc -o mq message_queue.c
// ./mq send <- sends random long each time it is executed
// ./mq receive <- receives the values in the queue and displays them one at a time, oldest first.
bibstha /
Last active September 5, 2020 19:57
Manjaro I3 Installation Notes

Install notes for Manjaro

  1. Install broadcom-wl-dkms to get 5G. Default installed kernel linux56 didn't have kernel headers to install the dkms module. So had to upgrade to new kernel.
sudo mhwd -i linux58
sudo pacman -S linux58-headers
sudo pacman -S broadcom-wl-dkms
bibstha /
Created June 30, 2020 20:09
Convert a csv with one column (latency / other time metric)
# must do `pip install hdrhistogram`
# uses package
# This file can be used to convert a csv with one column (latency / other time metric)
# into hgrm file format which can then be plotted with
# Useful to download data from Splunk an generate Percentile distribution
from hdrh.histogram import HdrHistogram
import csv
import sys