Skip to content

Instantly share code, notes, and snippets.

View rankitranjan's full-sized avatar
☀️
Working from home

Rankit Ranjan rankitranjan

☀️
Working from home
View GitHub Profile
@rankitranjan
rankitranjan / git-tag-delete-local-and-remote.sh
Created March 25, 2020 15:35 — forked from mobilemind/git-tag-delete-local-and-remote.sh
how to delete a git tag locally and remote
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName
@rankitranjan
rankitranjan / gist:2ccb884d5e50b74d06cab0829f0bee07
Created March 24, 2020 13:26 — forked from danielestevez/gist:2044589
GIT Commit to an existing Tag
1) Create a branch with the tag
git branch {tagname}-branch {tagname}
git checkout {tagname}-branch
2) Include the fix manually if it's just a change ....
git add .
git ci -m "Fix included"
or cherry-pick the commit, whatever is easier
git cherry-pick {num_commit}
@rankitranjan
rankitranjan / question1
Last active November 15, 2019 13:59
question1
I think from personal observation that most of them do:
1) Start going in the direction of the first button pressed, keep track of which direction we're going
2) When a floor is reached and that button was pressed, stop and open the doors, mark the buttons for this floor as
not pressed anymore.
3) If there are still more floors that we need to visit that are in the same direction, keep going in that direction.
If not and there are still floors we need to visit, move in that direction. (with help of cameras we can avoid this
scenario, if lift is empty), If not then we're done and will start at 1 when a button is pressed again.
@rankitranjan
rankitranjan / gist:05130459ee4f36ce3d17549025adfe9e
Created October 18, 2019 05:14
Add class methods and instance methods to class by including one Module
module A
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def all
p 'all'
end
@rankitranjan
rankitranjan / sti-rails.rb
Last active October 18, 2019 05:17
Single Table Inheritance with Rails
class User < ActiveRecord::Base
has_many :follows
delegate :following, :follower, to: :follows
end
class Follow < ActiveRecord::Base
scope :following, -> { where(type: 'following') }
scope :follower, -> { where(type: 'follower') }
end
@rankitranjan
rankitranjan / 1.rvm_ruby_install.log
Created September 16, 2019 07:49 — forked from ma11hew28/1.rvm_ruby_install.log
How to Install RVM, Ruby, and Gems without Xcode Command Line Tools
# How to Install RVM, Ruby, and Gems without Xcode Command Line Tools
# ===================================================================
#
# Mac OS X 10.8.2 (12C60) (Mountain Lion)
# Xcode 4.5 (4G182)
#
# While attempting to `rvm pkg install openssl`, I had encountered the error:
# > cryptlib.h:62:20: error: stdlib.h: No such file or directory
# But, the commands & ouput below show how I worked around the issue.
#
@rankitranjan
rankitranjan / System Design.md
Created August 28, 2019 13:57 — 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?
@rankitranjan
rankitranjan / Queue.js
Created August 24, 2019 17:17
Queue using linkedlist
class Node {
constructor(value) {
this.value = value;
this.next = null;
}
}
class Queue {
constructor(){
this.first = null;
@rankitranjan
rankitranjan / Queue.js
Created August 24, 2019 17:17
Queue using linkedlist
class Node {
constructor(value) {
this.value = value;
this.next = null;
}
}
class Queue {
constructor(){
this.first = null;
@rankitranjan
rankitranjan / stack.js
Last active August 24, 2019 16:16
stack using LinkedList / array
// using LinkedList
class Node {
constructor(value) {
this.value = value;
this.next = null;
};
}
class Stack {