Allow localhost/insecure websites to access webcam/microphone on Firefox

On my daily development I came across the issue navigator.mediaDevices is undefined when testing a website I’m developing on Firefox browser. While the fix for Google Chrome is widely known, I didn’t find anything about Firefox and decided to dig deeper myself. Turns out the fix is pretty simple.

  • On the address bar of Firefox type about:config
  • Accept and continue
  • Search for insecure
  • Set media.devices.insecure.enabled and media.getusermedia.insecure.enabled flag to true

That should do it!! The next time you open your website, Firefox will ask your permissions for webcam/microphone.

Compiling and Serving Assets (JavaScript/CSS) in Production Environment -Rails 6

In order to server assets in Production environment; assets are first compiled and put into /public/assets directory. So, first you need to run the following command to compile the assets.

RAILS_ENV=production rails assets:precompile

It is encouraged to serve static content using NGINX/Apache. But if you want rails to serve the contents add/modify the following line on production.rb

config.public_file_server.enabled = true

In case you are facing anomaly and confident your code is correct then try clearing the cache using

rails tmp:cache:clear

 205 total views

Ruby Method for encoding Bangla Unicode Text to Hex Value to Send Bangla SMS using SSLWireless

The following ruby method converts an Bengali Text to Hex value.

def encode_for_bangla_sms( text )
	text.encode('utf-16be').unpack('H*').to_s.gsub!(/\W/,'').upcase
end

text_bangla = "১ ২ ৩, ১ ২ ৩ "
text_encoded = encode_for_bangla_sms text_bangla
#09E7002009E8002009E9002C002009E7002009E8002009E90020

SSLWireless providers a different stakeholder id for Bangla SMS. So if you use that along with the hex value, you should receive the Bangla text.

 70 total views,  1 views today

Adding Ruby SDK to RubyMine from rbenv wsl

Run the following to get the ruby bin path

rbenv which ruby

You should get a path like the following

/home/user/.rbenv/versions/2.6.1/bin/ruby

Now on RubyMine type Alt + Ctl + S to open settings and search for ‘sdk’. Under Languages & Frameworks you will find Ruby SDK and GEM; select it. Now click on the + icon and select ‘New Remote’. Now Select WSL, choose the linux invironment and paste the link we copied earlier. Now your SDK should be added to RubyMine.

 59 total views