Skip to content

Instantly share code, notes, and snippets.

View manoj2411's full-sized avatar

Manoj Kumar Sehrawat manoj2411

View GitHub Profile
str = "the house is blue, it looks beautiful."
puts 'Initial string: ' + str
words_arr = []
i = 0
tmp_word = ''
while(i <= str.length)
<snippet>
<content><![CDATA[
javascript:void(0)
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>jsv</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
@manoj2411
manoj2411 / application.rb
Last active August 29, 2015 14:20
Rails application config to skip auto generators.
class Application < Rails::Application
# ...
config.generators do |g|
g.test_framework false
g.scaffold_controller "scaffold_controller"
g.stylesheets false
g.javascripts false
g.helper false
end
end
@manoj2411
manoj2411 / Gem dev.rb
Last active August 29, 2015 14:20
minimum gem for development
group :development do
gem 'annotate'
gem 'better_errors'
gem 'binding_of_caller'
gem 'bullet'
gem 'mailcatcher'
gem 'pry-rails'
gem 'quiet_assets'
gem 'xray-rails'
end
@manoj2411
manoj2411 / module_with_personalised_method_names.rb
Last active August 29, 2015 14:20
A module that shares code with personalised method names with respect to class
module ModuleWithPersonalisedMethods
def self.included(klass)
@methods_definer.call(klass)
end
@methods_definer = lambda do |klass|
klass_name = klass.name.downcase
klass.class_exec do
define_method "#{klass_name}_m1" do |arg1 = nil|
@manoj2411
manoj2411 / gemrc
Created June 28, 2015 14:26
No ri & no rdoc
gem: --no-ri --no-rdoc
install: --no-rdoc --no-ri
update: --no-rdoc --no-ri
@manoj2411
manoj2411 / sidekiq_manager.rb
Created November 16, 2017 01:14 — forked from kcore/sidekiq_manager.rb
a load balancer for sidekiq jobs!
module Amura
class SidekiqManager
# a datastructure to maintain queue meta data. the structure of which is {host_name: {queue_name:{min:1,max:1,conc:10,latency:1,queue_size:10,kill_idle:-1, tags:['default'], total_checks:1,current_check:0}}}
# host_name - name of the machine where its running. useful in a distributed environment where app is running on mulitple instances
# queue_name - name of the queue (which you can mention in the sidekiq worker as sidekiq_options :queue => :mailer )
# min: minimum number of processes required to process this queue on this machine.
# max: maximum number of processes permitted to process this queue on this machine. a upper limit to avoid memory overflow and unlimited process spawning.
# conc: concurreny (number of worker threads) for each of the processes. this is -C option given while booting up sidekiq.
# latency: this is the default safe latency which is permissable for this queue. anything beyond this will trigger new p
@manoj2411
manoj2411 / The Technical Interview Cheat Sheet.md
Created May 8, 2018 14:02 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
@manoj2411
manoj2411 / commit-msg
Created June 19, 2020 11:06
Checks git message every time and ensure that the message is starting with the defined format. Useful where you need Jira-ID or something similar in start of the message
#!/bin/sh
#
# save this file with this name and mark it executable `chmod +x .git/hooks/commit-msg`
commit_desired_format='(ZA-\d+|GH-\d+|merge)'
error_msg="Aborting commit. Commit message is missing ('ZA-XXX') or ('GH-XXX') or 'merge'"
if ! grep -iqE "$commit_desired_format" "$1"; then
echo "$error_msg" >&2
exit 1
@manoj2411
manoj2411 / System Design.md
Created August 11, 2020 13:39 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?