Skip to content

Instantly share code, notes, and snippets.

View rishiip's full-sized avatar
🎯
Focusing

Rishi Pithadiya rishiip

🎯
Focusing
View GitHub Profile
@rishiip
rishiip / IndianCities.json
Created March 10, 2016 06:11 — forked from rishi-amura/IndianCities.json
Indian States and their Cities
{
"AP":[
"Adilabad",
"Anantapur",
"Chittoor",
"Kakinada",
"Guntur",
"Hyderabad",
"Karimnagar",
"Khammam",
method validation callbacks
save
save(validate: false)
update
update_attribute
update_attributes
update_all
set(for mongoid only)
@rishiip
rishiip / install.sh
Created July 31, 2019 06:13 — forked from maanavshah/install.sh
Install and Configure Ruby on Rails, MongoDB, PostgreSQL, Git, Sublime Text, Oh-my-zsh and Deepin on Ubuntu
#!/bin/bash
sudo apt-get update
# To make sure we have everything necessary for Webpacker support in Rails, we're first going to start by adding the Node.js and Yarn repositories to our system before installing them.
sudo apt-get install curl
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update
@rishiip
rishiip / gist:2eeef32fb087c0ecc18136df3c1f89b8
Created September 14, 2019 15:57 — forked from paulallies/gist:0052fab554b14bbfa3ef
Remove node_modules from git repo
#add 'node_modules' to .gitignore file
git rm -r --cached node_modules
git commit -m 'Remove the now ignored directory node_modules'
git push origin master
@rishiip
rishiip / kb.json
Created September 17, 2019 09:37 — forked from pkaminski/gist:1ea3df5301660ddc5b12
Custom key bindings for Reviewable
[
["n", "Next unreviewed file", "nextUnreviewedFile()"],
["p", "Previous unreviewed file", "prevUnreviewedFile()"],
["shift+n", "Next file", "nextFile()"],
["shift+p", "Previous file", "prevFile()"],
["x", "Mark file as reviewed / unreviewed", "toggleCurrentFileReviewed(); nextUnreviewedFile()"],
["j", "Next unreplied comment", "nextUnrepliedDiscussion()"],
["k", "Previous unreplied comment", "prevUnrepliedDiscussion()"],
["shift+j", "Next comment", "nextDiscussion()"],
["shift+k", "Previous comment", "prevDiscussion()"],
@rishiip
rishiip / .irbrc
Last active May 20, 2020 07:40
This is my current irbrc file which contains lots of helpful things.
require 'irb/completion'
require 'rubygems'
ActiveRecord::Base.logger.level = 1 if defined?(ActiveRecord)
IRB.conf[:SAVE_HISTORY] = 1000
# IRB.conf[:ECHO] = false
# Overriding Object class
class Object
# Easily print methods local to an object's class
module MyProject
module Mongoid
module Document
extend ActiveSupport::Concern
included do
include ::Mongoid::Document
include ::Mongoid::Timestamps
include ::Mongoid::DotNotation
include ::Mongoid::SearchForObject
end
@rishiip
rishiip / mongoid_counter_cache.rb
Created May 24, 2020 14:59 — forked from jeffreyiacono/mongoid_counter_cache.rb
counter cache extension for mongoid orm
module Mongoid
module CounterCache
extend ActiveSupport::Concern
module ClassMethods
# Use Case:
#
# keep a cached count of embedded collections in the parent collection(s)
#
# for example, if a Post embeds many Comments, and there have been 2
@rishiip
rishiip / irb_require_without_bundler_hack.rb
Created May 27, 2020 17:34 — forked from skojin/irb_require_without_bundler_hack.rb
workaround to load irb specific gem (loaded in .irbrc) in bundler environment, like rails3 console
# Add all gems in the global gemset to the $LOAD_PATH so they can be used in rails3 console with bundler
if defined?(::Bundler)
$LOAD_PATH.concat Dir.glob("#{ENV['rvm_path']}/gems/#{ENV['rvm_ruby_string']}@global/gems/*/lib")
end
@rishiip
rishiip / consider_my_requests_local.rb
Created May 27, 2020 18:21 — forked from skojin/consider_my_requests_local.rb
same as config.consider_all_requests_local but for production and only for specified ip address, rails 3.2
silence_warnings do
ActionDispatch::Request::LOCALHOST = (ActionDispatch::Request::LOCALHOST + ['192.168.0.1']).freeze
end
ActionController::Base.module_eval do
def show_detailed_exceptions?
request.local?
end
end