Posts

Asymmetric encryption in Ruby On Rails OR Private Public key encryption

  First we need to generate a key pair. This creates two keys, a public key which will only be used to encrypt data, and a private key, which will only be used to decrypt data. The private key is protected by a password know only to us. When it comes to choosing strong passwords, I suggest using   Diceware .   2048   is the key size in bits. Bigger is better, but also slower; 2048 is considered a good trade off between speed and encryption strength. We are also limited by this to encrypting as most 2048 bits, more on this below. % openssl genrsa -des3 -out private.pem 2048 Generating RSA private key, 2048 bit long modulus ......+++ .+++ e is 65537 (0x10001) Enter pass phrase for private.pem: Verifying - Enter pass phrase for private.pem: Then we extract the public key: openssl rsa -in private.pem -out public.pem -outform PEM -pubout Enter pass phrase for private.pem: writing RSA key Once we have the keys, we can encrypt data using the following: #!/usr/bin/env ruby require 'open

Installing nio4r on macOS

  bundle config --local build.nio4r --with-cflags="-Wno-error=implicit-function-declaration -Wno-error=incompatible-function-pointer-types"

mysql error on MAC M1

  gem install mysql2 -- \  --with-mysql-lib=/opt/homebrew/opt/mysql/lib \  --with-mysql-dir=/opt/homebrew/opt/mysql \  --with-mysql-config=/opt/homebrew/opt/mysql/bin/mysql_config \  --with-mysql-include=/opt/homebrew/opt/mysql/include 

An error occurred while installing rmagick (5.2.0), and Bundler cannot continue.

To see why this extension failed to compile, please check the mkmf.log which can be found here:   /Users/apple/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/extensions/arm64-darwin-22/2.7.0/rmagick-5.2.0/mkmf.log extconf failed, exit code 1 Gem files will remain installed in /Users/apple/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/rmagick-5.2.0 for inspection. Results logged to /Users/apple/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/extensions/arm64-darwin-22/2.7.0/rmagick-5.2.0/gem_make.out An error occurred while installing rmagick (5.2.0), and Bundler cannot continue. Make sure that `gem install rmagick -v '5.2.0' --source 'https://rubygems.org/'` succeeds before bundling. In Gemfile:   rmagick The fix is very simple. Do the following brew uninstall imagemagick brew install imagemagick@6 export PATH="/usr/local/opt/imagemagick@6/bin:$PATH" brew link --force imagemagick@6 gem install rmagick This should do it!

pgloader not copying data from mysql 8 to postgresql

  Database is already created in Postgres. pgloader mysql: / / user :password @localhost / mydb postgresql: / / user :password @localhost / mydb You can also use a load file to make the tables public after import. Add this to a file (e.g load_file.load): LOAD DATABASE FROM mysql: / / root:mysql @localhost / from_db_name INTO postgresql: / / localhost / to_db_name ALTER schema 'to_db_name' rename to 'public' ; And run: $ pgloader load_file.load

Bootstrap Select Picker append add new item if search not exist

  <select class = "selectpicker" data-live-search= "true" id= "branch" multiple> < option > B.Tech </ option > < option > M.Tech </ option > < option > Ph.D </ option > </select> jQuery script $( '.selectpicker' ). selectpicker ({ noneResultsText : 'No result found <button class="btn btn-dark" onclick=(add_opt(this))>Add new option</button>' }); function add_opt ( event ){ var value = $(event). parents ( 'div' ). siblings ( '.bs-searchbox' ). find ( 'input' ). val (); $(event). parents ( 'div' ). siblings ( '.selectpicker' ). append ($( "<option></option>" ). text (value)). val (value); $( '.selectpicker' ). selectpicker ( 'refresh' ); }

Fix Health status on aws Elastic Beanstalk is red

Image
Solution 1: For someone that may come across this as I did, I found the solution to be   setting up the Health Check endpoint of the ELB target group to an actual URL on my website that returned an HTTP 200 code . On the EC2 dashboard, under Load Balancing -> Target Groups, go to the tab Health Checks and edit the path to a path in your site that returns an 200 code. Solution 2: Change the health check's "Success codes" setting from  200  to  200,301 View image - EC2 -> Load Balancing -> Target Groups