Skip to content

Instantly share code, notes, and snippets.

View 8parth's full-sized avatar

Parth Modi 8parth

View GitHub Profile
8parth /
Last active February 15, 2021 06:32
Adds machine's external ip address to gcloud sql instance's whitelisted ip list
dig +short
8parth /
Created February 19, 2019 11:13
Resque start and stop commands
#!/bin/bash -ex
echo "stop running resque processes"
if [ -e $pidfile_sched ] ; then
scheduler_pid=$(cat $pidfile_sched)
echo "scheduler_pid: $scheduler_pid"
if [ -z $scheduler_pid ] ; then
echo "No PID found for resque scheduler"
8parth / Dockerfile
Created February 13, 2019 03:38
Codebuild Image for ruby 2.4.1 with ubuntu 16.04 based on
# Copyright 2017-2017, Inc. or its affiliates. All Rights Reserved.
# Licensed under the Amazon Software License (the "License"). You may not use this file except in compliance with the License.
# A copy of the License is located at
# or in the "license" file accompanying this file.
# This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied.
# See the License for the specific language governing permissions and limitations under the License.
8parth / bitbucket-pipelines.yml
Created December 31, 2018 10:49
bitbucket pipeline example yml
# This is a sample build configuration for Ruby.
# Check our guides at for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: ruby:2.4.1
- step:
8parth / filterable.rb
Created December 17, 2018 02:57
filterable concern
# frozen_string_literal: true
# Module maps filter parameters to filers
# class SomeClass < ApplicationRecord
# include Filterable
# ...
# scope :scope_name, ->(arg) { where(x: arg) }
# scope :another_scope, -> { where(b: :c) }
# available_filters param_key: { scope: :scope_name, args_needed: true }
# param_key2: { scope: another_scope }
8parth / cloudfront_signed_url_extension.rb
Created November 1, 2018 04:49
Paperclip Extension that provides `cloudfront_signed_url` method. The extension supports all options and styles that can be passed to `url` method of paperclip.
# frozen_string_literal: true
# lib/paperclip/cloudfront_signed_url_extension
module Paperclip
module CloudfrontSignedUrlExtension
include UriValidationHelper
def cloudfront_signed_url(time = nil, style_name = default_style, options = {})
return url(style_name, options) unless valid_url?(url(style_name))
8parth / USAGE
Created August 9, 2018 11:34
Service Class Generator
# lib/generators/service/USAGE
Generates Service Class
rails generate service Thing
This will create:
8parth /
Created June 5, 2018 02:23 — forked from revans/
AWS User Script for getting a server ready for Ruby, Rails, Sinatra, or Rack apps.
#!/usr/bin/env bash
# Author: Robert R Evans
# Description: AWS Ubuntu 13 Ruby Setup Script
# This script will setup a ubuntu box for Ruby, Rails, Sinatra, and/or Rack
# development/staging/production usage. It also installs Nodejs, Nginx, Git,
# Rbenv, and PostgreSQL adapters for using RDMS PostgreSQL. It assumes that
# git-deploy will be used, in place of the traditional capistrano deployments.