Skip to content

Instantly share code, notes, and snippets.

View goromlagche's full-sized avatar
😴

Mrinmoy Das goromlagche

😴
View GitHub Profile
@goromlagche
goromlagche / camelCaseFilename.el
Last active April 27, 2019 19:40
function has documentation .
(defun camelCaseFileName()
"Get the camel case version of filename. Usefull when generating class name of ruby(or any other lang) file. You can use it in a yasnippet."
;; # -*- mode: snippet -*-
;; # name: cls
;; # key: cls
;; # --
;; class `(camelCaseFileName)`
;; $0
;; end
(interactive)
@goromlagche
goromlagche / parse_time_zone.rb
Last active October 1, 2019 12:01
its better to use `date + Time.zone.utc_offset` rather than `Time.zone.parse(date.to_s)` if you are worried about performance, and if you only need the value, not the whole object.
require 'benchmark/ips'
require 'active_support/all'
LOOP_FOR = 100_000
Time.zone = 'Hawaii'
DATE = Time.current.getutc
# a certain custom time format
Time::DATE_FORMATS[:local_db] =
@goromlagche
goromlagche / kgs.sh
Last active October 17, 2019 05:20
a simple bash function to get k8 secrets
function kgs(){
local NAMESPACE="${2:-default}"
echo -e "secret => ${1} namespace => ${NAMESPACE}"
kubectl get secrets $1 -n $NAMESPACE -o json | jq '.data[] | @base64d | fromjson'
}
@goromlagche
goromlagche / Sneaker log formatter
Last active August 24, 2018 11:39
writing a generic log formatter for rails and sneakers
A very simple generic log formatter for sneakers and rails.
module ArHelpers
def listen_to_insert_ar_calls(table)
ActiveSupport::Notifications
.subscribe('sql.active_record') do |_, _, _, _, details|
if details[:sql] =~ /INSERT INTO `#{table}`/
@sql = details[:sql]
end
end
end
end
@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,
@goromlagche
goromlagche / batman-jl.md
Created January 25, 2018 17:32 — forked from avinassh/batman-jl.md
Batman animated and JL viewing order.

Batman animated and JL viewing order.

Canon 1:

  1. Batman: mask of Phantasm *
  2. Batman and Mr. Freeze: SubZero
  3. Batman: Mystery of Batwoman

Canon 2: If you plan to watch Justice league too then refer JL canon #2

  1. Son of Batman
  2. Batman vs Robin
@goromlagche
goromlagche / compile-current-cpp-java-file.el
Last active November 8, 2017 14:38
a small function to compile cpp/java code on eshell
(defun compile-current-cpp-file ()
"Compile and run current file on eshell"
(interactive)
(let ((filename (buffer-file-name)))
(with-selected-window (get-buffer-window "*eshell*")
(recenter)
(insert "g++ -std=c++11 " filename " -o a.out && ./a.out")
(eshell-send-input)
(erase-buffer))
(message "File '%s' is compiled and ran" filename)))
module Archivable
extend ActiveSupport::Concern
included do
default_scope -> { where(is_archived: false) }
scope :with_archived, -> { all.unscope(where: :is_archived) }
scope :only_archived, -> { with_archived.where(is_archived: true) }
end
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
int countI;
int countDP;
int countKadne;