Skip to content

Instantly share code, notes, and snippets.

View bibstha's full-sized avatar
💭
🇳🇵🇨🇦

Bibek Shrestha bibstha

💭
🇳🇵🇨🇦
  • Vancouver, Canada
  • 22:25 (UTC -07:00)
View GitHub Profile
@bibstha
bibstha / semaphore.c
Created November 18, 2020 22:16
sysv semaphore set, increment, decrement, blocking and reading current value.
#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
bibstha / message_queue.c
Created November 17, 2020 21:51
sysv message queue send and receive example.
// 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
bibstha / Installation.md
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
bibstha / work.py
Created June 30, 2020 20:09
Convert a csv with one column (latency / other time metric)
# must do `pip install hdrhistogram`
# uses package https://github.com/HdrHistogram/HdrHistogram_py
# 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 http://hdrhistogram.github.io/HdrHistogram/plotFiles.html
#
# Useful to download data from Splunk an generate Percentile distribution
from hdrh.histogram import HdrHistogram
import csv
import sys
@bibstha
bibstha / gist:6c36870990ca86f94c19ba6b40a63b04
Created January 14, 2020 04:40
Set tslime panes to newly opened tmux window
# Run this in vim
:let g:tslime={'window':1,'pane':1,'session':0}
@bibstha
bibstha / ctags.rb
Created April 7, 2019 22:00
Multiprocess threaded ctags generation with ripper-tags
#!/usr/bin/env ruby
require 'etc'
require 'shell'
def ruby_files
@ruby_files ||= %x{git ls-files | grep 'rb$'}.lines.map!(&:chomp)
end
dir = %x{git rev-parse --git-dir}.chomp
@bibstha
bibstha / gist:934990fd24705210f570770aef6bb036
Created February 25, 2019 02:10 — forked from xdite/gist:1641818
RR-020 RR Object Oriented Programming in Rails with Jim Weirich http://asciirogues.com/

Jim: What I really like is that there are so many Ruby podcasts out there that are newsy. This one dives into technical issues, and I really enjoy that.

Charles: Hey everybody, and welcome back to the Ruby Rhodes podcast. This is your host Charles Max Wood, and this week on our panel we have a special guest rogue. I met him at the Rocky Mountain Ruby Conference in Boulder. He actually suggested this week's topic, so we're going to welcome Jim Weirich to the podcast.

Jim: Thanks for having me. Glad to be here.

Charles: Do you want to introduce yourself really quickly Jim for those one or two people that don't know who you are?

Jim: Sure, absolutely. Jim Weirich. I'm from Cincinnati, Ohio. I've been doing Ruby for over ten years now. I work for EdgeCase. I'm the chief scientist, and I've probably written software that you are using, such as Rake and various mocking frame works and some XML builder stuff, too. You're probably using some of my code somewhere.

require "bundler/inline"
gemfile(true) do
source 'https://rubygems.org'
gem 'concurrent-ruby-edge', require: 'concurrent-edge'
gem 'concurrent-ruby-ext'
end
require 'concurrent/channel'
require "bundler/inline"
gemfile(true) do
source 'https://rubygems.org'
gem 'concurrent-ruby-edge', require: 'concurrent-edge'
gem 'concurrent-ruby-ext'
end
require 'concurrent/channel'
@bibstha
bibstha / recipe.rb
Created May 18, 2016 12:42
recipe.rb
# step 1
git "/path/to/folder" do
repository "myrepo"
action :sync
end
# step 2
rubyversion = library_get_ruby_version_from_git_folder("/path/to/folder")
# step 3