Skip to content

Instantly share code, notes, and snippets.

View bhanuone's full-sized avatar
🎯
Focusing

Bhanu Prakash bhanuone

🎯
Focusing
  • Hyderabad
View GitHub Profile
@bhanuone
bhanuone / mysql_8_upgrade_checklist.md
Last active July 20, 2023 07:02
MySQL 8.0 Upgrade Checklist

MySQL 8 upgrade checklist

Features Deprecated in MySQL 8.0

  1. Legacy audit log filtering mode is deprecated as of MySQL 8.0.34.
  • audit_log_policy now writes a warning message to the MySQL server error log during server startup when the value is not ALL (default value)
  • audit_log_include_accounts, audit_log_exclude_accounts, audit_log_statement_policy, and audit_log_connection_policy. Dynamic variables print a warning message based on usage:
    • Passing in a non-NULL value to audit_log_include_accounts or audit_log_exclude_accounts during MySQL server startup now writes a warning message to the server error log.
    • Passing in a non-default value to audit_log_statement_policy or audit_log_connection_policy during MySQL server startup now writes a warning message to the server error log. ALL is the default value for both variables.
    • Changing an existing value using SET syntax during a MySQL client session now writes a warning message to the client log.
  • Persist
A memory-saving ActiveRecord setting has been used by just one application ever, according to GitHub
There's a common performance problem in many Rails background jobs.
Background jobs often do operations across large sets of data. Basically, they do silly things like User.all.each(&:send_daily_newsletter).
So, there's a problem with that query. In development and test environments, User.all will probably return a few rows, maybe a dozen at most. Most developers have extremely limited seed data on their local machines.
In production, however, User.all will probably return quite a few rows. Depending on the app you work on, maybe a few hundred thousand.
There's a tiiiiiny issue with a result set that returns 100,000 rows, and it's not just that the SQL query will take a long time to return. It will have irreversible effects on your Ruby app too!
@bhanuone
bhanuone / create_keystore_file.md
Created November 13, 2020 16:14
Create Android app signing keystore file

Create keystore file to sign android apk

keytool -genkey -v -keystore my-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000

@bhanuone
bhanuone / Setup MongoDB on localhost as Replica Set
Created November 6, 2020 11:14 — forked from davisford/Setup MongoDB on localhost as Replica Set
Setup MongoDB replica set on local host with only a single primary
Add the `replication` section to the mongod.conf file:
```
$cat /usr/local/etc/mongod.conf
systemLog:
destination: file
path: /usr/local/var/log/mongodb/mongo.log
logAppend: true
storage:
engine: mmapv1

Keybase proof

I hereby claim:

  • I am bhanuone on github.
  • I am bhanua1 (https://keybase.io/bhanua1) on keybase.
  • I have a public key ASAqTxwpGyzVeS8uKQ3SkrsKNg_CJaVfvhz2fL-C9nyflgo

To claim this, I am signing this object:

@bhanuone
bhanuone / gist:df6803ac66b2876f0d093dd1df3a10b4
Last active March 24, 2019 20:47 — forked from soumith/gist:01da3874bf014d8a8c53406c2b95d56b
Install PillowSIMD+libjpeg-turbo on Conda
conda uninstall --force pillow -y
# install libjpeg-turbo to $HOME/turbojpeg
git clone https://github.com/libjpeg-turbo/libjpeg-turbo
pushd libjpeg-turbo
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX:PATH=$HOME/turbojpeg
# if you get error like "No CMAKE_ASM_NASM_COMPILER could be found." Run `sudo apt install nasm`
make
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
body {
background: white;
margin: 0;
@bhanuone
bhanuone / nginx-config-rails4-with-puma-ssl-version.conf
Created November 30, 2017 11:15 — forked from rkjha/nginx-config-rails4-with-puma-ssl-version.conf
Nginx config for rails 4 application using puma [ssl and non-ssl version]
upstream myapp_puma {
server unix:/tmp/myapp_puma.sock fail_timeout=0;
}
# for redirecting to https version of the site
server {
listen 80;
rewrite ^(.*) https://$host$1 permanent;
}

My largest Sidekiq application had a memory leak and I was able to find and fix it in just few hours spent on analyzing Ruby's heap. In this post I'll show my profiling setup.

As you might know Ruby 2.1 introduced a few great changes to ObjectSpace, so now it's much easier to find a line of code that is allocating too many objects. Here is great post explaining how it's working.

I was too lazy to set up some seeding and run it locally, so I checked that test suite passes when profiling is enabled and pushed debugging to production. Production environment also suited me better since my jobs data can't be fully random generated.

So, in order to profile your worker, add this to your Sidekiq configuration:

if ENV["PROFILE"]
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://unpkg.com/@reactivex/rxjs@5.0.3/dist/global/Rx.js"></script>
<script src="https://code.jquery.com/jquery-3.1.0.js"></script>
<style id="jsbin-css">
html, body {