Skip to content

Instantly share code, notes, and snippets.

View manojnaidu619's full-sized avatar
🎯
Focusing

Manoj Kumar manojnaidu619

🎯
Focusing
  • Bangalore,India
View GitHub Profile
@manojnaidu619
manojnaidu619 / article_image_uploader.rb
Created August 25, 2021 14:47 — forked from jcsrb/article_image_uploader.rb
CarrierWave extension fix_exif_rotation, strip, quality, resize_to_fill_if_larger
class ArticleImageUploader < ImageUploader
process :fix_exif_rotation
process :strip
process :convert => 'jpg'
process :quality => 85 # Percentage from 0 - 100
version :gallery_thumb do
process :resize_to_fill => Settings.images.article_images.processing.gallery_thumb #44x44
end
@manojnaidu619
manojnaidu619 / rails_eager_load.md
Created January 15, 2021 12:39 — forked from johncip/rails_eager_load.md
Active Record eager loading strategies

N+1 query problem

  • ORMs make it easy to a query per loop iteration, which we want to avoid

eager_load

  • single query (left outer join)
  • can reference the other table's columns in where

preload

  • a few queries (one per table)
  • typically faster
@manojnaidu619
manojnaidu619 / gist:3c0b973d2c8f4507eb518433253c1c7b
Created August 14, 2020 05:29 — forked from jrochkind/gist:59b6330e3f52710cc49e
Monkey patch to ActiveRecord to forbid
######################
#
# Monkey patch to ActiveRecord to prevent 'implicit' checkouts. Currently tested with Rails 4.0.8, prob
# should work fine in Rails 4.1 too.
#
# If you create a thread yourself, if it uses ActiveRecord objects without
# explicitly checking out a connection, one will still be checked out implicitly.
# If it is never checked back in with `ActiveRecord::Base.clear_active_connections!`,
# then it will be leaked.
#
@manojnaidu619
manojnaidu619 / rails-jsonb-queries
Created July 16, 2020 16:27 — forked from mankind/rails-jsonb-queries
Rails-5 postgresql-9.6 jsonb queries
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails
#payload: [{"kind"=>"person"}]
Segment.where("payload @> ?", [{kind: "person"}].to_json)
#data: {"interest"=>["music", "movies", "programming"]}
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json)
Segment.where("data #>> '{interest, 1}' = 'movies' ")
Segment.where("jsonb_array_length(data->'interest') > 1")
@manojnaidu619
manojnaidu619 / webdev_online_resources.md
Created November 13, 2019 02:19 — forked from bradtraversy/webdev_online_resources.md
Online Resources For Web Developers (No Downloading)
@manojnaidu619
manojnaidu619 / meta-tags.md
Created July 3, 2019 06:35 — forked from lancejpollard/meta-tags.md
Complete List of HTML Meta Tags

Copied from http://code.lancepollard.com/complete-list-of-html-meta-tags/

Basic HTML Meta Tags

<meta name="keywords" content="your, tags"/>
<meta name="description" content="150 words"/>
<meta name="subject" content="your website's subject">
<meta name="copyright"content="company name">
<meta name="language" content="ES">