Skip to content

Instantly share code, notes, and snippets.

View tejasbubane's full-sized avatar
💭
WFH 🏡

Tejas Bubane tejasbubane

💭
WFH 🏡
View GitHub Profile
@tejasbubane
tejasbubane / sidekiq_nested_test.rb
Created January 20, 2022 19:47
Testing nested workers in sidekiq
# Prepared for https://stackoverflow.com/questions/70790708/testing-enque-of-nested-worker-from-another-sidekiq-worker
require 'sidekiq'
require 'sidekiq/testing'
require 'rspec'
class WorkerOne
include Sidekiq::Worker
def perform(arg_1, arg_2)
@tejasbubane
tejasbubane / generated_columns.rb
Last active December 30, 2021 08:20
Postgres generated columns
# frozen_string_literal: true
# Read the blog: https://tejasbubane.github.io/posts/2021-12-18-rails-7-postgres-generated-columns/
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
# Activate the gem you are reporting the issue against.
@tejasbubane
tejasbubane / identical_equality_offenses.txt
Created February 21, 2021 11:53
Offenses for `RSpec/IdenticalEqualityAssertion` on https://github.com/pirj/real-world-rspec
Offenses:
brew/Library/Homebrew/test/pkg_version_spec.rb:20:5: C: RSpec/IdenticalEqualityAssertion: Identical expressions on both sides of the equality may indicate a flawed test.
expect(described_class.parse("1.0_1")).to be == described_class.parse("1.0_1")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
canvas-lms/gems/adheres_to_policy/spec/adheres_to_policy/class_methods_spec.rb:51:5: C: RSpec/IdenticalEqualityAssertion: Identical expressions on both sides of the equality may indicate a flawed test.
expect(@some_class.policy).to eql(@some_class.policy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
canvas-lms/spec/controllers/gradebooks_controller_spec.rb:2883:7: C: RSpec/IdenticalEqualityAssertion: Identical expressions on both sides of the equality may indicate a flawed test.
expect(@controller.post_grades_ltis).to eq(@controller.post_grades_ltis)
@tejasbubane
tejasbubane / arch-cleanup.sh
Created December 19, 2020 19:28
Arch system maintenance
# No need to run this everyday - once a month should be fine
# Remove cache:
sudo pacman -Scc
yay -Scc
# Remove unwanted dependencies:
yay -Yc
# Remove orphan packages
@tejasbubane
tejasbubane / test.rb
Created December 10, 2019 10:31
Rails single-table inheritance issue reproduction
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
# Activate the gem you are reporting the issue against.
@tejasbubane
tejasbubane / haskell_uninstall.sh
Last active December 2, 2019 07:17
Uninstall all haskell version
# Thanks to this mailing list message: https://mail.haskell.org/pipermail/haskell-cafe/2011-March/090170.html
# Note: This removes ALL haskell versions & anything related to it
sudo rm -rf /Library/Frameworks/GHC.framework
sudo rm -rf /Library/Frameworks/HaskellPlatform.framework
sudo rm -rf /Library/Haskell
rm -rf .cabal
rm -rf .ghc
rm -rf ~/Library/Haskell
find /usr/bin /usr/local/bin -type l | \
@tejasbubane
tejasbubane / middleware.rb
Last active November 13, 2019 09:10
Unit testing rack middlewares
# Make sure rack & rspec are installed -> gem install rack rspec
# Run this script using rspec -> rspec middleware.rb
require 'rack'
class BlockActions
def initialize(app)
@app = app
end
@tejasbubane
tejasbubane / .rubocop.yml
Created August 4, 2019 07:51
Sample rubocop with sane config
AllCops:
TargetRubyVersion: 2.5
Exclude:
- 'config/**/*.rb'
- 'db/**/*.rb'
- '**/Rakefile'
- '**/config.ru'
- '**/spec_helper.rb'
- '**/rails_helper.rb'
- 'lib/tasks/db_extensions.rake'
@tejasbubane
tejasbubane / with_lock_spec.rb
Created March 26, 2019 15:28
Testing with_lock activerecord
# For stackoverflow question: https://stackoverflow.com/questions/55339129/how-to-test-lock-mechanism
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
# Activate the gem you are reporting the issue against.
@tejasbubane
tejasbubane / rust-macros.rs
Created January 27, 2019 18:47
My notes while learning Rust Macros
// These are my notes from learning Rust Macros during a meetup
// https://www.meetup.com/rustox/events/256709420/
// I had not done any Rust before - but was still able to learn a lot!!
use std::collections::HashMap;
// All these macros run at compile time
// Simplest macro
macro_rules! hello {