Skip to content

Instantly share code, notes, and snippets.

View itsprdp's full-sized avatar

Pradeep Gangadharaiah itsprdp

View GitHub Profile
@itsprdp
itsprdp / README.md
Last active June 23, 2016 07:47
CSS active link class method for rails views

Active link CSS class

Usage:

%li{:class => active_class(:c => 'controller_name',:a => ['action1','action2'],:id => @object.id) }
  = link_to some_path do
    %i.fa.fa-chevron-circle-right.fa-fw
    %span Link Name
@itsprdp
itsprdp / kubectl.zshrc
Last active March 9, 2016 08:28
kubectl shortcuts for zsh
kgp () {
kubectl get pods $argv
}
kdp () {
kubectl describe pods $argv
}
kdr () {
kubectl describe rc $argv
@itsprdp
itsprdp / release_version.rake
Last active January 29, 2017 05:32
Rails release_version bumper
#######################################
# Author: Pradeep ([email protected]) #
# Reference: http://semver.org #
#######################################
namespace :release_version do
@tags = %x[ git tag --sort version:refname ].split("\n")
def current_tag
@tags.last
end
@itsprdp
itsprdp / version.rb
Last active January 29, 2017 05:34
Git tag version bumper
module Release
@tags = %x[ git tag --sort version:refname ].split("\n")
@current_tag = @tags.last
@current_version = @current_tag.gsub("v","")
@major, @minor, @patch = @current_version.split(".").map(&:to_i)
def self.tags
@tags
end
@itsprdp
itsprdp / readonly.yml
Created February 2, 2016 10:42
Mount Persistent Disk to a container
kind: Pod
apiVersion: v1
metadata:
name: readonly-pod
spec:
containers:
- name: readonly-pod
image: nginx
volumeMounts:
- mountPath: /etc/secrets
@itsprdp
itsprdp / kuber-secret.rb
Last active January 18, 2016 15:40
Convert your .env file data to JSON key with values encoded to base64
#!/usr/bin/env ruby
# Encode .env file values to base64 and create json key values
require 'base64'
require 'yaml'
if ARGV[0]
env = {}
file = File.new(ARGV[0], "r")
@itsprdp
itsprdp / Dockerfile
Last active September 9, 2016 04:22
Kuber files for Rails App + Google Container Engine
# Dockerfile
# Using phusion passenger as base image.
# Refer - https://github.com/phusion/passenger-docker
FROM phusion/passenger-ruby22:latest
MAINTAINER Pradeep <[email protected]>
# Set ENV variables
ENV HOME /rubyapp/
@itsprdp
itsprdp / psql-mysql.taps
Created January 14, 2016 06:51
Using https://github.com/ricardochimal/taps to migrate data from Postgres to MySQL
# Serve the MySQL database (destination db)
taps server mysql://<user>:<pass>@localhost/<database> user1 pass123
# Push the schema and the records of the database to destination db
taps push postgres://<user>:<pass>@localhost/<database> http://user1:pass123@localhost:5000
@itsprdp
itsprdp / gcloud-kubectl-commands.txt
Last active January 14, 2016 08:45
GCE-container engine commands
# Init project settings
$ gcloud config set project PROJECT_ID
$ gcloud config set compute/zone us-east1-b
$ export PROJECT_ID=your-project-id-here
# Build docker image and push it to gcr.io
$ docker build -t gcr.io/${PROJECT_ID}/<project-name> .
Then push this image to the Google Container Registry:
$ gcloud docker push gcr.io/${PROJECT_ID}/<project-name>
@itsprdp
itsprdp / Dockerfile.rails-base
Last active September 9, 2016 04:21
RubyApp Dockerfile for staging
# Building rails-base image for the rubyapp
FROM phusion/passenger-ruby22
MAINTAINER Pradeep "[email protected]"
# Set correct environment variables.
ENV HOME /root
# Use baseimage-docker's init process.
CMD ["/sbin/my_init"]