Skip to content

Instantly share code, notes, and snippets.

Rakesh Verma rakesh87

Block or report user

Report or block rakesh87

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@rakesh87
rakesh87 / inline_bundler.rb
Created Oct 12, 2018
Inline bundler usages
View inline_bundler.rb
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'actionpack', '~> 5.2', '>= 5.2.1'
gem 'rails'
end
@rakesh87
rakesh87 / config.rb
Created Sep 22, 2018
global config object to store shared variables
View config.rb
# minimal example for singleton pattern
class Configs
class << self
def instance
@instance ||= new
end
private :new
end
end
@rakesh87
rakesh87 / git_stash_command
Last active Jun 3, 2018
Git Stash Command
View git_stash_command
1. git stash list
List out all stash entries that we have currently. stash entries are listed with name and latest entries first
ex:
git stash list
# example result
stash@{0}: On development: WIP README
stash@{1}: WIP on development: 1b78aaa7
2. git stash OR git stash push
This command saves your local changes to new stash entry and moves back the local working directory to the remote head.
@rakesh87
rakesh87 / invoke_rake_task.rake
Last active May 9, 2018
Invoke a rake task from another rake task
View invoke_rake_task.rake
namespace :app_task do
desc 'run web task'
task :run_web do
# my web task logic here
end
desc 'run backend task'
task :run_backend do
# my backend task logic here
# after this invoke other rake task
@rakesh87
rakesh87 / .eslintrc.json
Created Nov 12, 2016
.eslintrc.json file
View .eslintrc.json
{
"root": true,
"extends": [
"eslint:recommended",
"plugin:import/errors",
"plugin:import/warnings"
],
"parserOptions": {
"ecmaVersion": 7,
"sourceType": "module"
@rakesh87
rakesh87 / package.json
Created Nov 11, 2016
new javascript project neccessary packages with npm
View package.json
{
"name": "js-dev-env",
"version": "1.0.0",
"description": "Javascript develeopment environment setup",
"scripts": {
},
"author": "Rakesh Verma",
"license": "MIT",
"dependencies": {
},
@rakesh87
rakesh87 / matrix.rb
Created Apr 28, 2015
transverse spiral all element of matrix
View matrix.rb
module Matrix
class << self
def to_spiral(input_array)
array_length = input_array.length
# return element itself if array length is 1
return input_array[0][0] if array_length == 1
View documents.rb
# config/routes.rb
resources :documents do
resources :versions, controller: "documents/versions" do
post :restore, on: :member
end
resource :lock, controller: "documents/locks"
end
View reshaping_the_command_approach.rb
# MODEL
class Case < ActiveRecord::Base
include Eventable
has_many :tasks
concerning :Assignment do
def assign_to(new_owner:, details:)
transaction do
You can’t perform that action at this time.