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 / 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)
@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 / 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 
@abhinavmsra
abhinavmsra / pg_locks.md
Created March 21, 2019 08:44
How to list postgres locks & release them

List all active locks

SELECT 
  DISTINCT age(now(), query_start) AS age, 
  pg_stat_activity.pid,
  pg_locks.granted,
  pg_stat_activity.application_name,
  pg_stat_activity.backend_start, 
 pg_stat_activity.xact_start, 
@abhinavmsra
abhinavmsra / ballot_test.sol
Created May 24, 2019 03:26
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.5.8+commit.23d335f2.js&optimize=true&gist=
import "remix_tests.sol"; // this import is automatically injected by Remix.
import "./ballot.sol";
contract test3 {
Ballot ballotToTest;
function beforeAll () public {
ballotToTest = new Ballot(2);
}
@abhinavmsra
abhinavmsra / cff.sol
Created May 26, 2019 06:09
CFF 4 UNICEF - SURGE BANGKOK
pragma solidity >=0.4.22 <0.7.0;
contract CFF {
struct CFFChild {
string name;
string homeAddress;
uint dob; // timestamp of birth of a child,
uint withdrawalBalance;
uint lockedBalance;

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 / 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