Skip to content

Instantly share code, notes, and snippets.

View goromlagche's full-sized avatar
😴

Mrinmoy Das goromlagche

😴
View GitHub Profile
#!/bin/bash
current_branch=$(git rev-parse --abbrev-ref HEAD)
remote="$1"
if [ "$current_branch" == "main" ] && [ "$remote" == "origin" ]; then
echo "You can not push to $remote from $current_branch"
exit 1
fi
@goromlagche
goromlagche / pagination.rb
Last active December 8, 2023 13:01
Cursor pagination
# frozen_string_literal: true
# drop this file in app/lib/pagination.rb
module Pagination
DEFAULT_PAGE_LIMIT = 10
def pages(records:, url:)
paginate = Paginate.new(records: records,
url: url,
limit: limit,
@goromlagche
goromlagche / setup_vpn.sh
Created October 26, 2023 08:40
setup vpn using nmcli
nmcli connection import type openvpn file your-connection.ovpn
nmcli connection modify your-connection +vpn.data username=your-user-name
nmcli connection modify your-connection ipv4.never-default true
nmcli connection up your-connection passwd-file passwd-file
# To list all VPN connections
nmcli connection show --active | grep vpn
# To connect to the VPN
nmcli connection up your-connection passwd-file passwd-file
@goromlagche
goromlagche / a_sample_rspec_api_concurrent_call_spec.rb
Last active October 10, 2023 05:03
A sample rspec spec to test concurrent api calls
require 'rails_helper'
describe Api::V1::CheckoutsController, type: :request do
let(:user) do
FactoryGirl.create(:user, current_balance: 100_000)
end
describe 'check concurrency' do
it 'send multiple same requests', truncation_only: true do
FactoryGirl.create(:item,
require 'nori'
single_comment = <<~EOF
<?xml version="1.0" encoding="UTF-8"?>
<comments>
<comment>
<description>TEST COMMENT 123</description>
</comment>
</comments>
EOF
@goromlagche
goromlagche / reminder.sh
Last active April 10, 2021 15:25
reminder script for osx
# use it with at command
# e.g. `reminder "make tea" | at now + 30 minutes`
# Also learn how to make atrun work in osx
# https://unix.stackexchange.com/questions/478823/making-at-work-on-macos/478840#478840
function reminder(){
echo "reattach-to-user-namespace say $1; reattach-to-user-namespace osascript -e 'tell app \"System Events\" to display dialog \"${1}\" with title \"Reminder ⏰\"'"
}
nc -v mongo_url 27017
import Data.Text (Text, map,
toLower, words, pack)
import Data.Text.IO (readFile)
import Data.Char (isLetter)
import Prelude hiding (map, words, readFile)
import Data.Map.Strict (toList, fromListWith)
import GHC.Exts (sortWith)
import Control.DeepSeq
import Control.Parallel.Strategies hiding(parMap)
#include <iostream>
#include <vector>
using namespace std;
typedef vector<int> vi ;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
vvvi qs;
heroku logs -t -n=10 | awk -F " |=" '/fwd/{system("geocode " $14)}' | grep --line-buffered "Full address\|State"