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 / 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 / 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,
require 'nori'
single_comment = <<~EOF
<?xml version="1.0" encoding="UTF-8"?>
<comments>
<comment>
<description>TEST COMMENT 123</description>
</comment>
</comments>
EOF
nc -v mongo_url 27017
heroku logs -t -n=10 | awk -F " |=" '/fwd/{system("geocode " $14)}' | grep --line-buffered "Full address\|State"
@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 ⏰\"'"
}
str="daily" && str_up="${str^^}" && echo $str_up | fold -bw1 > lol.txt && echo $str_up | fold -w1 | xargs echo && tail -n +2 lol.txt
@goromlagche
goromlagche / ruby_truncate_vs_first_vs_range.rb
Created August 8, 2019 08:21
compare between first, range and active_supports truncate
require 'benchmark/ips'
require 'active_support/all'
STRING = 'Once upon a time in a world far far away'
def use_truncate
STRING.truncate(27)
end
def use_first
@goromlagche
goromlagche / sendTil.el
Created April 27, 2019 17:30
sends til's to littil
(defun sendTil()
"Sends til to littil. If you select a region and sendTil then it will send the content of that region, else it will send the whole buffer content."
(interactive)
(request
"http://littil.io/api/tils"
:type "POST"
:data (json-encode '(("til" . (("snippet" . ,(if (use-region-p)
(buffer-substring (region-beginning) (region-end))
(buffer-string)))))))
:headers '(("Content-Type" . "application/json") ("Authorization" . "Basic *your key*"))