Skip to content

Instantly share code, notes, and snippets.

View rakesh87's full-sized avatar
🎯

Rakesh Verma rakesh87

🎯
  • Eos
  • bangalore
View GitHub Profile
@rakesh87
rakesh87 / new.md
Created April 14, 2019 19:27
new gist

hello!

@rakesh87
rakesh87 / inline_bundler.rb
Created October 12, 2018 16:38
Inline bundler usages
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'actionpack', '~> 5.2', '>= 5.2.1'
gem 'rails'
end
@rakesh87
rakesh87 / config.rb
Created September 22, 2018 13:02
global config object to store shared variables
# 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 June 3, 2018 06:39
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 09:29
Invoke a rake task from another rake task
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 November 12, 2016 13:49
.eslintrc.json file
{
"root": true,
"extends": [
"eslint:recommended",
"plugin:import/errors",
"plugin:import/warnings"
],
"parserOptions": {
"ecmaVersion": 7,
"sourceType": "module"
@rakesh87
rakesh87 / package.json
Created November 11, 2016 05:19
new javascript project neccessary packages with npm
{
"name": "js-dev-env",
"version": "1.0.0",
"description": "Javascript develeopment environment setup",
"scripts": {
},
"author": "Rakesh Verma",
"license": "MIT",
"dependencies": {
},
class Api::RegistrationsController < Api::BaseController
respond_to :json
def create
user = User.new(params[:user])
if user.save
render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201
return
else
@rakesh87
rakesh87 / matrix.rb
Created April 28, 2015 18:44
transverse spiral all element of matrix
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
# config/routes.rb
resources :documents do
resources :versions, controller: "documents/versions" do
post :restore, on: :member
end
resource :lock, controller: "documents/locks"
end