Skip to content

Instantly share code, notes, and snippets.

View vraravam's full-sized avatar

Vijay Aravamudhan vraravam

  • ThoughtWorks Inc.
  • Chennai, India
  • X @avijayr1
View GitHub Profile
@vraravam
vraravam / .rubocop.yml
Last active January 13, 2016 05:34
Rubocop config file
require:
- rubocop-rspec
AllCops:
Include:
- '**/Capfile'
- '**/Gemfile'
- '**/Rakefile'
- '**/config.ru'
- '**/app/**/*'
@vraravam
vraravam / sitemap.rb
Created February 21, 2015 18:02
Using sitemap_generator gem and configuring it to generate pages from high_voltage
# Set the host name for URL creation
SitemapGenerator::Sitemap.default_host = 'http://www.pycosystems.com'
SitemapGenerator::Sitemap.create do
# Put links creation logic here.
#
# The root path '/' and sitemap index file are added automatically for you.
# Links are added to the Sitemap in the order they are specified.
#
# Usage: add(path, options={})
@vraravam
vraravam / string.rb
Created January 13, 2016 03:03
string to unicode conversion in ruby
# config/initializers/string.rb
class String
# TODO: Don't know how to convert to UTF-16BE encoding using built-in methods, and then arrive
# at the result similar to: http://api.mvaayoo.com/unicodeutil/unicode.jsp
def to_unicode
unpack('U*').map { |i| i.to_s(16).rjust(4, '0') }.join
end
end
@vraravam
vraravam / production.rb
Created January 13, 2016 05:39
LogRage configuration for production env in rails app
# config/environments/production.rb
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
config.lograge.enabled = true
# add time to lograge
config.lograge.custom_options = lambda do |event|
{ time: event.time, params: event.payload[:params].except('controller', 'action', 'utf8', 'authenticity_token', 'commit') }
end
@vraravam
vraravam / factory_girl.rb
Last active August 6, 2018 06:53
Configuration at project-level for factory_girl in a rails rspec codebase (spec/support/factory_girl.rb)
# frozen_string_literal: true
RSpec.configure do |config|
config.before(:suite) do
begin
DatabaseCleaner.start
setup_biz
FactoryBot.lint unless config.files_to_run.one?
ensure
DatabaseCleaner.clean
@vraravam
vraravam / database_cleaner.rb
Created January 13, 2016 05:41
If using database_cleaner gem in a rails app....
# spec/support/database_cleaner.rb
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
end
config.before(:each, js: true) do
DatabaseCleaner.strategy = :truncation
end
@vraravam
vraravam / gist:bd1373abeaee41b422ed
Created February 22, 2016 04:48
Git commands to remove specific files from history
To find the blobs taking up the max space:
git rev-list --objects --all | grep "$(git verify-pack -v .git/objects/pack/*.idx | sort -k 3 -n | tail -100 | awk '{print$1}')"
To delete blobs from history:
git filter-branch -f --prune-empty --index-filter 'git rm -rf --cached --ignore-unmatch node_modules/* plugins/* platforms/* resources/ios/* resources/android/*' --tag-name-filter cat -- --all
git filter-branch -f --prune-empty --index-filter 'git rm -rf --cached --ignore-unmatch public/assets/*' --tag-name-filter cat -- --all
@vraravam
vraravam / application.rb
Created March 5, 2016 03:46
Rails generator configuration using rspec and factory_girl
# config/application.rb
class Application < Rails::Application
config.generators do |g|
g.orm :active_record
g.template_engine :erb
g.stylesheets false
g.javascripts false
g.test_framework :rspec,
fixtures: true,
view_specs: false,
@vraravam
vraravam / paranoia_helper.rb
Created February 21, 2017 15:35
Paranoia Helper for Parent-Child edit functionality
# frozen_string_literal: true
module ParanoiaHelper
extend ActiveSupport::Concern
module ClassMethods
private
# This method generates an instance method with the name: associated_sym.to_s.pluralize.
#
# Example:
@vraravam
vraravam / fresh-install-of-osx.sh
Last active June 5, 2024 08:49
Steps to get "up and running" with new Mac OSX
This script has been moved here: https://github.com/vraravam/dotfiles/blob/master/scripts/fresh-install-of-osx.sh