Skip to content

Instantly share code, notes, and snippets.

View ziaulrehman40's full-sized avatar
🎯
Focusing

Zia Ul Rehman ziaulrehman40

🎯
Focusing
  • Devsinc
  • Lahore
View GitHub Profile
@ziaulrehman40
ziaulrehman40 / jquery file upload rails installation.md
Last active May 26, 2017 08:15
blueimp/jQuery-File-Upload rails gem through rails-assets

blueimp/jQuery-File-Upload is a very helpful plugin, but using it in rails(<5.1, in rails 5.1 and above, we have webpack and yarn support, i would love to see how these work and if anyone can add how to add this library using that that would be great) is a pain like every other js library.
This is to have record of how i managed to get it working on rails, without manually adding all js files.

Using rails-assets to add gemfile https://rails-assets.org/#/components/jquery-file-upload
Pre-req: Jquery-ui configured.

Gemfile:
gem 'rails-assets-', source: 'https://rails-assets.org'

@ziaulrehman40
ziaulrehman40 / PDF.js rails integration notes for S3 hosted files.md
Last active September 4, 2018 06:44
Integrate PDF.js plugin in rails apps to properly display PDFs hosted on S3 in iframe on ipads/iphones, solving problem that ipads only display frist page of pdf

Integrate PDF.js plugin in rails apps

PDF.js is a plugin for displaying pdfs in webpages, it solves a problem on ipads too(indirectly) where ipads and iphones only render first page of the pdf and users can't scroll pdfs rendered in iframes.

pdfjs_rails is the gem which we are going to use for integrating PDF.js in rails.

This gem is pretty old and not maintained, its last commit in master was 5 years ago(at the time of writing). But nevertheless it works and you can easily get you pdfs working in iPads and iPhone. tada!

There are only a few steps which i had to perform to get it working for S3 hosted files on non-public buckets.

@ziaulrehman40
ziaulrehman40 / CircleCI 2.0 Parallel builds coverage report to codeclimate.md
Created December 21, 2018 08:58
CircleCI 2.0 Parallel builds SimpleCov coverage report for CodeClimate reporting

First of all you have to follow my other gist here: https://gist.github.com/ziaulrehman40/1516c0bb940b6ee653b57387cee4e62d In that gist, follow the second solution which is: Use deploy step in simple CircleCI 2.0 build

After that is done and everything seems working. Than there is very little needing to be done.

We will use CodeClimate's new way of reporting, which is cc-test-reporter, this is a binary to work with any kind of projects. Before this we had specific gem and other language specific solutions. Those are deprecated. And gem doesn't work with simplecov > 0.13

Ok, enough talk, now straight to action, following is the circleci config i used:

@ziaulrehman40
ziaulrehman40 / date_range_splitter_spec.rb
Created August 3, 2019 11:24
Specs for date range splitter
require "rails_helper"
RSpec.describe DateRangeSplitter, type: :service do
describe "#generate_split_dates" do
it "#splits dates properly exclusive in ranges" do
from = DateTime.now
to = from + 53.days
splitter = DateRangeSplitter.new(from, to, 10, end_inclusive: false)
splitter.each do |from_d, to_d|
check_against = to_d == to ? 3 : 10
@ziaulrehman40
ziaulrehman40 / CircleCI 2.0 Parallel builds SimpleCov coverage report merging locally overview.md
Last active August 30, 2020 15:10
CircleCI 2.0 Parallel builds SimpleCov coverage report merging locally

Simplecov aggregated coverage report from CircleCI 2.0 parallel builds (focused on storing locally/within CI containers as artifacts)

Problem Statement

We have Rails application which is running tests on circleCI 2.0, we have simplecov configured to track the coverage of our test suite. Now the problem is with parallelism enabled, we have partial coverage reports in all different containers according to the tests those containers ran.

We obviously want to have consolidated simplecov coverage report which actually shows us overall coverage report.

@ziaulrehman40
ziaulrehman40 / sublime packages I use.md
Last active March 12, 2021 11:14
subime packages for rails dev
A File Icon
All Autocomplete
Better CoffeeScript
Bootstrap 3 Autocomplete
BracketHighlighter
Cucumber Step Finder
Cucumber
Dockerfile Syntax Highlighting
Emmet
@ziaulrehman40
ziaulrehman40 / Rubocopconfig.md
Last active October 8, 2022 14:35
Rubocop config

Add following to Gemfile

group :development, :test do
  gem 'rubocop'
  gem 'rubocop-performance'
  gem 'rubocop-rails'
  gem 'rubocop-minitest' # or gem 'rubocop-rspec' depending on your test suite
end
@ziaulrehman40
ziaulrehman40 / VPS rails server setup.md
Last active December 13, 2022 09:37
Server setup on ubuntu VPS(DigitalOcean, EC2 or any other) for rails

Excellent GoRails Article(which is main source for this guide too). I did benefited from lot of other resources online as well.

Creating droplet on DigitalOcean(DO):

(Skip this if you are not using DO, and create your own VPS instance on the service of your choice. Steps below may still be helpful.)

There are few options for this step, DO provide us some pre built images for lot of platforms in which they have pre-installed nginx, node and other related dependencies for each image. Rails one is little outdated, I tried that but didn't go very well for me, you can give it a shot if you have enough time. For this guide we will go with bear bone ubuntu 18.04 server. While creating the droplet, you will be asked to set an ssh key, just generate an ssh key with ssh-keygen on your local system and copy contents of .pub file into the textbox provided.

@ziaulrehman40
ziaulrehman40 / postgres app multiple versions.md
Last active March 28, 2023 14:00
Using multiple postgresql version with appropoiate psql and other pg tools version on mac with postgresapp

Using multiple postgresql version with appropoiate psql and other pg tools version on mac with postgresapp

First make sure no postgres instance is configured to run on startup. And you get nothing when you run this command: which -a psql This is to make sure you don't have anything related to postgres in your PATH, which can conflict. If you do get some hits with above command, you have to manually either remove the installed versions of postgres or just fix PATH and remove ref to that path which has these binaries(psql, pg_dump etc)

For me, i was using brew installed postgres, i had to just comment out a PATH editing line which was inserted by brew in my .bash_profile

Ok, after this we are ready. Now things are simple:

@ziaulrehman40
ziaulrehman40 / ubuntu machine setup for rails.md
Last active August 21, 2023 10:29
Ubuntu setup for rails

Basic use libraries installation

sudo apt update
sudo apt install unace unrar zip unzip p7zip-full p7zip-rar sharutils gnupg2 rar uudeview mpack arj cabextract file-roller

Actual Development Setup

Essentials