Skip to content

Instantly share code, notes, and snippets.

View prasadsurase's full-sized avatar
🏋️‍♂️
:)

Prasad Surase prasadsurase

🏋️‍♂️
:)
  • Procore
  • Pune
  • 14:13 (UTC +05:30)
View GitHub Profile
@prasadsurase
prasadsurase / monitor-sidekiq-mongo.sh
Created May 10, 2018 05:31
SSH to multiple servers and run commands or tail log files using a single script
# sudo apt-get install wmctrl
# wmctrl -d => 0 * DG: 2732x1536 VP: 0,0 WA: 41,24 1325x744 N/A
# 2732/2 => 1366
# 1536/2 => 768
# if you have 4 workspaces
wmctrl -o 0,0
gnome-terminal --maximize --tab -e "ssh -t production-sidekiq-1 -vvv \"htop; /bin/bash \"" \
--tab -e "ssh -t production-sidekiq-2 -vvv \"htop; /bin/bash \"" \
--tab -e "ssh -t production-sidekiq-3 -vvv \"htop; /bin/bash \"" \
@prasadsurase
prasadsurase / gist:e483a202a5f6dcc30e3bae13e4ba33d1
Created July 17, 2017 10:08 — forked from brianjlandau/gist:4162654
Setting up a Rails engine for MySQL, RSpec & Capybara

Setup RSpec and Capybara on a new Rails engine

  1. rails plugin new ENGINE_NAME --full --database=mysql

  2. Add to gemspec:

s.add_development_dependency 'rspec-rails'
s.add_development_dependency 'shoulda-matchers'
s.add_development_dependency 'capybara'
s.add_development_dependency 'database_cleaner'
@prasadsurase
prasadsurase / gist:3eea664a4fd9772c63fd9679422fcd57
Created October 4, 2016 07:14
includes and joins in rails
Loading development environment (Rails 4.1.4)
2.2.0 :001 > User.count
(0.1ms) SELECT COUNT(*) FROM "users"
=> 2
2.2.0 :002 > User.pluck :id, :name
(0.2ms) SELECT "users"."id", "users"."name" FROM "users"
=> [[1, "John"], [2, "Jill"]]
2.2.0 :003 > User.first.industries.pluck :id, :name
User Load (0.2ms) SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1
(0.2ms) SELECT "industries"."id", "industries"."name" FROM "industries" INNER JOIN "user_industries" ON "industries"."id" = "user_industries"."industry_id" WHERE "user_industries"."user_id" = ? [["user_id", 1]]
@prasadsurase
prasadsurase / spec_helper.rb
Created September 19, 2016 06:33 — forked from sethbro/spec_helper.rb
Rails unit, functional and integration tests in Minitest spec format.
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rubygems'
gem 'minitest'
require 'minitest/autorun'
require 'action_controller/test_case'
require 'miniskirt'
require 'capybara/rails'
@prasadsurase
prasadsurase / find-duplicate-files.rb
Created September 15, 2016 07:42 — forked from ma11hew28/find-duplicate-files.rb
Ruby script that finds identical (md5) files in all subdirectories (recursive)
require 'digest/md5'
hash = {}
Dir.glob("**/*", File::FNM_DOTMATCH).each do |filename|
next if File.directory?(filename)
# puts 'Checking ' + filename
key = Digest::MD5.hexdigest(IO.read(filename)).to_sym
if hash.has_key? key
@prasadsurase
prasadsurase / facebook_service
Created August 29, 2015 08:58
A facebook service class defined in ruby to retrieve user's photos.
class FacebookService
attr_reader :graph
def initialize(token)
@graph = Koala::Facebook::API.new(token)
end
def picture
user_picture("me")

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"