Skip to content

Instantly share code, notes, and snippets.

@Bivek
Bivek / gist:3c470ed9153d6a099870019ef469bd85
Created March 12, 2024 01:30
MySQL Gem Install Workaround
# Getting clang error while installing mysql gem in macos
# Try this it might solve your issue or try trinity gem instead
gem install mysql2 -v '0.5.5' -- --with-mysql-config=$(brew --prefix mysql)/bin/mysql_config --with-ldflags="-L$(brew --prefix zstd)/lib -L$(brew --prefix openssl)/lib" --with-cppflags=-I$(brew --prefix openssl)/include
@Bivek
Bivek / gist:d6e8c66e7fcef8900168bfb2dc926b30
Last active March 5, 2024 09:27
MySQL command used for debugging the issue - Quick Ref
1. Show data lock held or requested (https://dev.mysql.com/doc/refman/8.0/en/performance-schema-data-locks-table.html)
mysql> SELECT * FROM performance_schema.data_locks
2. General information about tables
mysql> SHOW TABLE STATUS
3. Show table information
@Bivek
Bivek / gist:3114a4886677fcb293b4afae60c3720e
Last active January 31, 2024 05:09
Install Mysql2 gem on M1 chip
Working solution
-----------------
gem install mysql2 -v '0.5.5' -- --with-mysql-config=$(brew --prefix mysql)/bin/mysql_config --with-ldflags="-L$(brew --prefix zstd)/lib -L$(brew --prefix openssl)/lib" --with-cppflags=-I$(brew --prefix openssl)/include
Better to use ```trilogy``` gem instead of ```mysql2``` for smooth setup process.
In your database.yml file update adapter to trilogy if you are using trilogy instead.
@Bivek
Bivek / gist:332243d78ffcefdcefdb0e00b3b0f3cb
Created October 19, 2023 02:03
Get all the tables count in MySQL
#STEP1: SET Max lenght according the need
SET group_concat_max_len = 40048;
#STEP2: Execute this to get the query that needs to be executed
SELECT left(tab, length(tab)-6) AS query
FROM (
SELECT GROUP_CONCAT(tab SEPARATOR ' ') AS tab
FROM (
SELECT CONCAT(
'SELECT "',
alias k="kubectl"
kubectl get deploy
kubectl get services
kubectl get svc
kubectl create deployment nginx-deployment --image=nginx
kubectl get pods
kubectl expose deployment nginx-deployment --port=8080 --port-target=80
kubectl get svc
minikube ip
ssh docker@<above-ip> (default password is tcuser)
@Bivek
Bivek / gist:de9a6e4b0440a6288a357f0d6f946b81
Created August 19, 2022 00:17
clean copy/paste rails console
IRB.conf[:USE_READLINE] = false
rails console -- --nomultiline
#defaults write com.microsoft.VSCode ApplePressAndHoldEnabled -bool false
#defaults write -g ApplePressAndHoldEnabled -bool false
@Bivek
Bivek / bash_strict_mode.md
Created June 1, 2022 06:02 — forked from vncsna/bash_strict_mode.md
set -e, -u, -o, -x pipefail explanation

set -e, -u, -o, -x pipefail

The set lines

  • These lines deliberately cause your script to fail. Wait, what? Believe me, this is a good thing.
  • With these settings, certain common errors will cause the script to immediately fail, explicitly and loudly. Otherwise, you can get hidden bugs that are discovered only when they blow up in production.
  • set -euxo pipefail is short for:
set -e
set -u
1.next # => 2
next_method_object = 1.method("next")
next_method_object.call # => 2
arr = ['Ruby', 'Golang', 'Node.js', 'Deno', 'Typescript', 'Scala', 'Python']
arr.[](3) # => Deno
def add(*numbers)
@Bivek
Bivek / lambda_aws_face_rekognition.py
Created February 9, 2021 09:01
Lambda to Compare Faces using aws Rekognition
import boto3
import urllib.request
def lambda_handler(event, context):
# Anuska Sharma Images
#source_file='https://www.pinkvilla.com/files/styles/contentpreview/public/anushka_sharma_prays_for_those_affected_by_uttarakhand_glacier_burst_main_1.jpg'
# target_file='https://m.media-amazon.com/images/M/MV5BNGM5YmYwNjUtNzQyYS00OGY0LTljZDAtMDNiMjhiOTFiMzRiXkEyXkFqcGdeQXVyMTExNDQ2MTI@._V1_UY317_CR3,0,214,317_AL_.jpg'
# Katrina Kaif Images
source_file = 'https://cdn.dnaindia.com/sites/default/files/styles/full/public/2020/03/21/898813-katrina-kaif-coronavirus-video-public-transport-1.jpg'
target_file = 'https://author.vogue.in/wp-content/uploads/2020/07/Katrina-Kaif-during-Bharat-promotions-1366x768.jpg'