Skip to content

Instantly share code, notes, and snippets.

@abhinavmsra
abhinavmsra / ruby_strings.rb
Last active September 11, 2015 08:31
Testing string operations in ruby
require 'benchmark'
iterations = 100_000
puts 'With Static Strings'
puts '======================================================'
Benchmark.bm do |bm|
bm.report('joining an array of strings') do
iterations.times do
['Testing', 'String', 'Operations', 'in', 'Ruby'].join(' ')
cd /etc/init.d
./ror_start_up.sh //filename may differ
@abhinavmsra
abhinavmsra / money_best_practices.md
Last active November 12, 2023 13:00
Tips for Money Related Arithmetic in Ruby

Tips for Money Related Arithmetic in Ruby

  1. Never use float for performing arithmetic calculations relating to money.

    Floating numbers can sometimes show funky behaviour. It is not Ruby’s fault but the very implementation of floating numbers raises precision issues.

Examples of odd behaviour:

@abhinavmsra
abhinavmsra / s3cmd.md
Last active March 14, 2024 10:58
Install s3cmd on CentOs

Installing s3cmd on CentOs

  1. As a superuser, go to /etc/yum.repos.d

    cd /etc/yum.repos.d

  2. Download the repo file

    wget http://s3tools.org/repo/RHEL_6/s3tools.repo

@abhinavmsra
abhinavmsra / rotate.md
Last active August 16, 2018 09:51
Rotating Server Logs

#Rotating Server Logs with LogRotate

Logrotate is a UNIX utility that does following operations:

  1. Rotates the log file when file size reaches a specific size or after a specified duration
  2. Continues to write the log information to the newly created file after rotating the old log file
  3. Compresses the rotated log files
  4. Specifies compression option for the rotated log files
@abhinavmsra
abhinavmsra / resume.md
Last active January 31, 2021 03:49
My Resume

Personal Info:

Fullname: Abhinav Mishra
Education: Bachelor's Degree in Electronics & Communication Engineering at Pulchowk Campus, 
            Tribhuvan University from 2010 - 2014
Address: Kathmandu, Nepal
TEL: +977-9842529593
Email: msraabhinav@gmail.com
Twitter: @abhinavmsra

Skype: abhinavmsra

@abhinavmsra
abhinavmsra / rspec_json_helper.md
Created July 11, 2016 09:13
DRY JSON Parsing in Rspec Tests
# spec/support/request_helpers.rb
module Requests
  module JsonHelpers
    def json
      JSON.parse(response.body)
    end
  end
end
@abhinavmsra
abhinavmsra / flatten_array.rb
Created July 16, 2016 03:55
Flattens an array of arbitrarily nested arrays of integers into a flat array of integers
# Flattens an array of arbitrarily nested arrays of integers into a flat array of integers
#
# Algorithm:
# 1. Iterate over each element in the array.
# 2. If the element contains nested array elements, apply the same function recursively to each elements.
# 3. For integer values, push them into a flat array
#
# @param array[Array], nested array to be flattened
# @return [Array], flattened array
def flatten(array)

Project boilerplate

While React itself doesn't enforce any specific project strucutre or setup for that matter, it's always better to have a boilerplate at disposal to kickstart a React project.

After studying some of the available boilerplates, we found react-slingshot from a Pluralsight Author coryhouse quite handy. However it is to be noted that it's just a recommendation and subject to personal preference and at some times project requirements.

Project Strucutre

@abhinavmsra
abhinavmsra / pronto.md
Last active March 6, 2019 15:08
Pronto Setup
  1. Add pronto and other pronto runners under test group in Gemfile
  group :test do
    gem 'pronto'
    gem 'pronto-rubocop', require: false # analyzes ruby code 
    gem 'pronto-flay', require: false # analyzes code for structural similarities
    gem 'pronto-brakeman', require: false # analyzes code for security vulnerabilities
    gem 'pronto-dirty_words', require: false # analyzes code for  Seven Dirty Words
    gem 'pronto-rails_best_practices', require: false # code metric tool for Rails projects