Skip to content

Instantly share code, notes, and snippets.

View 8parth's full-sized avatar

Parth Modi 8parth

View GitHub Profile
@8parth
8parth / README.md
Last active February 15, 2021 06:32
Adds machine's external ip address to gcloud sql instance's whitelisted ip list
dig +short myip.opendns.com @resolver1.opendns.com
@8parth
8parth / resque_stop.sh
Created February 19, 2019 11:13
Resque start and stop commands
#!/bin/bash -ex
echo "stop running resque processes"
pidfile_sched="tmp/pids/resque_scheduler.pid"
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
8parth / Dockerfile
Created February 13, 2019 03:38
Codebuild Image for ruby 2.4.1 with ubuntu 16.04 based on https://jonbake.com/blog/2018/08/29/setting-up-codebuild-rails.html
# Copyright 2017-2017 Amazon.com, 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
#
# http://aws.amazon.com/asl/
#
# 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
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 https://confluence.atlassian.com/x/8r-5Mw 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
pipelines:
default:
- step:
@8parth
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
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
8parth / USAGE
Created August 9, 2018 11:34
Service Class Generator
# lib/generators/service/USAGE
Description:
Generates Service Class
Example:
rails generate service Thing
This will create:
app/services/thing.rb
@8parth
8parth / user_script.sh
Created June 5, 2018 02:23 — forked from revans/user_script.sh
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.