Rails using Bootstrap templates in vendor

If you are considering using templates which you copied to vendor directory then things you need to keep in mind:-

  • Move all assets like Images, sounds, Fonts but not js or css to vendor/assets/ like
    • vendor/assets/fonts
  • Add this line in assets.rb
    • Rails.application.config.assets.precompile << /\.(?:svg|eot|woff|ttf)\z/
  • Make sure you are using `rails_12factor` gem in production
  • use image-url and font-url helpers
  • in scss files in @imports rule you do not use .css at last of the filename. It automatically calculates.
Nano editor Comment/Uncomment in GNU Nano editor using Alt+3 shortcut

GNU Nano editor adjust comment literal for PHP / C / C++

If you are a UNIX lover and fan of Nano text editor then while writing C / C++ code, you would like to put comments using Short-Cut key i.e. Alt+3. But the problem is, Nano puts the char # as comment literal instead of //. This happened because the default literal is # unless it is defined in configurations.

How to fix?

Continue reading

Display line numbers in GNU Nano text editor

These days developers go for heavy text-editors and IDEs like InteliJ, PyCharm, RubyMine, Sublime Text with much more extensions, Vim, Emacs, etc. However, in case of the later two they are not memory and processor heavy however they have very steep learning curves.

On the other hand, GNU Nano come as a life saver. It requires a few MB of RAM(say 3-4 MB) and uses very less CPU resource. Nano is a much powerful tool with much more features.

Continue reading

Memory Management Techniques in C

 

Computer’s primary memory is divided into four segments, namely: data, stack, heap and code.

What is Memory Management?

You are already familiar with the notion that Memory is most expensive resource in the system. Therefore you only use and ask for amount of memory that will suffice. As soon as you are done, you free up the memory so that OS can sell those memory blocks to some other needy software. This practice of using memory wisely is known as Memory Management. Continue reading

Auto Generate Authority Signed Free SSL Certificates | HTTPS | Nginx

Well, there are a number of SSL Certification Authorities but all of them charges yearly fees for certificates they provide. I feel bad because, they are like middle-men do nothing but sign your certificates. But, if you don’t want to pay them you can get signed certificates from letsencrypt.org. Continue reading

Rails | Avoiding race conditions while updating particular field in DB

It’s okay to make mistakes when you are up to building simple applications. But for mission critical applications like Banking/Payment Processors, you gotta be very careful and keep listening to seniors and experts in critical matters.

Lets say you are working on a feature to update the total amount deposited in a particular account. Simple code will do like

# just after amount is debited from payee's account
def credit_receiver_account(debited_amount)
  update_attribute :total_amount, total + debited_amount
end

What’s wrong with the code above?

Continue reading