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 / 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 / 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 / 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",
@rishiip
rishiip / bson.rb
Created March 10, 2016 06:11 — forked from rishi-amura/bson.rb
Return mongo `_id` bson object as regular `id` within Rails application
Save below code to `bson.rb` file within `config/initializers` directory and restart the server
module BSON
class ObjectId
def as_json(*args)
to_s
end
end
end
@rishiip
rishiip / gist:bd36c65f85031e66ee56
Created December 8, 2015 11:08 — forked from mistrikushal/Rspec private methods.txt
RSpec - Testing private methods of a model
# RSpec allows us to test private methods of a model.
for example,
class User
def is_active?
true
end
private :is_active?
end
@rishiip
rishiip / nil_empty_blank_present_ffdierence_in_ruby
Last active December 8, 2015 10:56 — forked from pythonicrubyist/nil_empty_blank_present_ffdierence_in_ruby
Difference between nil?, empty?, blank? and present? in Ruby and Ruby on Rails.
# nil? can be used on any Ruby object. It returns true only if the object is nil.
nil.nil? # => true
[].nil? # => false
{}.nil? # => false
"".nil? # => false
" ".nil? # => false
true.nil? # => false
# empty? can be used on some Ruby objects including Arrays, Hashes and Strings. It returns true only if the object's length is zero.
nil.empty? # NoMethodError: undefined method `empty?' for nil:NilClass
@rishiip
rishiip / server.rb
Last active August 29, 2015 14:25 — forked from emad-elsaid/server.rb
require 'webrick'
Port = 3000
Directory = Dir::pwd
WEBrick::HTTPServer.new(
Port: Port,
DocumentRoot: Directory
).start
@rishiip
rishiip / arch.md
Last active August 29, 2015 14:23 — forked from mislav/arch.md

Create the partition:

sgdisk --zap-all /dev/sda
cgdisk /dev/sda
mkfs.ext4 /dev/sda1
mount /dev/sda1 /mnt

Edit the mirror list to bring the preferred mirror to the top:

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
@rishiip
rishiip / hashes.md
Last active August 29, 2015 14:17 — forked from ryansobol/hashes.md

What's a Hash and why is it important?

A Hash is a collection of key-value pairs. To add, fetch, modify, and delete a value from a Hash, you refer to it with a unique key.

While an Array is indexed by Integers only, a Hash is keyed by any object -- Strings, Integers, etc.

In other programming languages, a Hash might be known as an 'associative array', 'dictionary', or 'HashMap'.

What does a Hash look like?