Skip to content

Instantly share code, notes, and snippets.

Zia Ul Rehman ziaulrehman40

Block or report user

Report or block ziaulrehman40

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View date_range_splitter_spec.rb
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 / date_range_splitter.rb
Created Aug 3, 2019
Simple ruby date range splitter
View date_range_splitter.rb
class DateRangeSplitter
include Enumerable
def initialize(date_from, date_to, max_days, end_inclusive: true)
@date_from = date_from
@date_to = date_to
@max_days = max_days
@end_inclusive = end_inclusive
generate_split_dates
end
@ziaulrehman40
ziaulrehman40 / DigitalOcean rails server setup.md
Last active Oct 15, 2019
Server setup on digital ocean for rails and with managed DigitalOcean database
View DigitalOcean rails server setup.md

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):

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.

Select your resources and create droplet(provide your ssh key while creating and enable private networking, ipv6 and monitoring, this all is free).

@ziaulrehman40
ziaulrehman40 / CircleCI 2.0 Parallel builds coverage report to codeclimate.md
Created Dec 21, 2018
CircleCI 2.0 Parallel builds SimpleCov coverage report for CodeClimate reporting
View CircleCI 2.0 Parallel builds coverage report to codeclimate.md

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 / postgres app multiple versions.md
Created Dec 19, 2018
Using multiple postgresql version with appropoiate psql and other pg tools version on mac with postgresapp
View postgres app multiple versions.md

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 / PDF.js rails integration notes for S3 hosted files.md
Last active Sep 4, 2018
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
View PDF.js rails integration notes for S3 hosted files.md

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 SimpleCov coverage report merging locally overview.md
Last active Oct 16, 2019
CircleCI 2.0 Parallel builds SimpleCov coverage report merging locally
View CircleCI 2.0 Parallel builds SimpleCov coverage report merging locally overview.md

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 / Guidelines for our standard development enviroment.md
Last active Mar 19, 2018
This document outlines the standard development environment in devsinc
View Guidelines for our standard development enviroment.md

Book we are following for training is:

Ruby on Rails Tutorial: Learn Web Development with Rails

or

Ruby on Rails 5.0 for autodidacts by Stefan Wintermeyer

(You will be provided with the book to follow)

@ziaulrehman40
ziaulrehman40 / sublime packages I use.md
Last active Mar 19, 2018
subime packages for rails dev
View sublime packages I use.md
A File Icon
All Autocomplete
Better CoffeeScript
Bootstrap 3 Autocomplete
BracketHighlighter
Cucumber Step Finder
Cucumber
Dockerfile Syntax Highlighting
Emmet
View ubuntu machine setup for rails.md

Skip this section, unless you know what you are doing

sudo dpkg --add-architecture i386
sudo add-apt-repository ppa:danielrichter2007/grub-customizer
wget --quiet -O - https://dl.winehq.org/wine-builds/Release.key | sudo apt-key add -
sudo apt-add-repository https://dl.winehq.org/wine-builds/ubuntu/
sudo add-apt-repository ppa:otto-kesselgulasch/gimp
sudo apt update
sudo apt install grub-customizer
sudo apt install --install-recommends winehq-staging
You can’t perform that action at this time.