Skip to content

Instantly share code, notes, and snippets.

View ashishwadekar's full-sized avatar

Ashish Wadekar ashishwadekar

  • India
View GitHub Profile
@ashishwadekar
ashishwadekar / ruby_sftp_download.rb
Created December 28, 2016 07:54
This script is used to download the latest file from the server to your local machine using Ruby & pem key
#This script is used to download file from the server to your local machine
#The implementation is based on pure Ruby implementation of SFTP using gem Net SFTP
#To install this on your local machine please run the following command in your terminal 'gem install net-sftp'
#Author : Ashish Wadekar <ashishawadekar@gmail.com>
#Date : 18 December 2016
#This is the gem / library required for the SFTP connection management
require 'net/sftp'
#The host address
class Ticket < ActiveRecord::Base
belongs_to :grouper
belongs_to :user
validate :user_cant_be_blacklisted, on: :confirmation
validate :user_cant_double_book, on: :confirmation
validate :grouper_cant_be_full, on: :confirmation
validate :grouper_cant_have_occurred, on: :confirmation
@ashishwadekar
ashishwadekar / row_is_cut_in_the_middle_solution.rb
Created September 5, 2017 10:48 — forked from 3dd13/row_is_cut_in_the_middle_solution.rb
overflow / page break examples of Prawn Pdf generation.
# gem "prawn", "0.8.4"
# Sometime there is no enough space for the last table row when it reaches the end of page
Prawn::Document.generate("text_group_overflow_question.pdf") do |pdf|
add_page_break_if_overflow(pdf) do |pdf|
# generating table here
# ...
end
end
@ashishwadekar
ashishwadekar / nginx-config-rails4-with-puma-ssl-version.conf
Created September 26, 2017 05:17 — forked from rkjha/nginx-config-rails4-with-puma-ssl-version.conf
Nginx config for rails 4 application using puma [ssl and non-ssl version]
upstream myapp_puma {
server unix:/tmp/myapp_puma.sock fail_timeout=0;
}
# for redirecting to https version of the site
server {
listen 80;
rewrite ^(.*) https://$host$1 permanent;
}
@ashishwadekar
ashishwadekar / capybara cheat sheet
Created April 11, 2018 15:38 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@ashishwadekar
ashishwadekar / 42-things.md
Created May 29, 2018 07:54 — forked from xdite/42-things.md
Ten (42) Things You Didn't Know Rails Could Do
@ashishwadekar
ashishwadekar / .spacemacs
Last active April 9, 2019 15:23
My Spacemacs Configuration
;; -*- mode: emacs-lisp; lexical-binding: t -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Layer configuration:
This function should only modify configuration layer settings."
(setq-default
;; Base distribution to use. This is a layer contained in the directory
;; `+distribution'. For now available distributions are `spacemacs-base'
@ashishwadekar
ashishwadekar / .vimrc
Last active March 28, 2019 16:44
Current VIM configuration
syntax on
filetype plugin indent on
set background=dark
set guifont=Hack:h15
set shell=/bin/bash
set linespace=2
if !isdirectory($HOME."/.vim/undo-dir")
call mkdir($HOME."/.vim/undo-dir", "", 0700)
endif
@ashishwadekar
ashishwadekar / create_jwt_blacklist_table_migration.rb
Created December 24, 2018 18:20
Sample migration file to create JWT
class CreateJwtBlacklists < ActiveRecord::Migration[5.2]
def change
create_table :jwt_blacklist do |t|
t.string :jti, null: false
t.datetime :exp, null: false
end
add_index :jwt_blacklist, :jti
end
end
@ashishwadekar
ashishwadekar / user.rb
Created December 24, 2018 18:25
Sample User model for JWT with revocation strategy
class User < ApplicationRecord
devise :database_authenticatable, :jwt_authenticatable,
jwt_revocation_strategy: JwtBlacklist
end