Skip to content

Instantly share code, notes, and snippets.

View ashishwadekar's full-sized avatar

Ashish Wadekar ashishwadekar

  • India
View GitHub Profile
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 / fontawesome.vue
Last active January 18, 2019 09:52 — forked from Ethanhackett/fontawesome.vue
Font Awesome 5 Pro - Vue.js + Native Script Component
<template>
<Span v-bind:class="classes + ' ' + type" v-bind:text="getIcon()" />
</template>
<script>
/*
Setup:
1. Setup CSS and Font in Native Script App like this:
https://medium.com/@JCAguilera/fontawesome-5-and-nativescript-22653f2b3bac
Thanks > Juanky Aguilera
module JsonSerializer
module_function
#
# Usage:
# JsonSerializer.find_by_id(User, 1, only: [:id, email, :address], except: [:address])
#
def find_by_id(klass, id, options = {})
sql = "SELECT row_to_json(results) FROM (
SELECT #{selected_attributes(klass, options)}
@ashishwadekar
ashishwadekar / rails_helper.rb
Created October 2, 2019 15:53 — forked from Amitesh/rails_helper.rb
Accessing Helper modules in rails
Accessing Helper modules in rails
http://www.funonrails.com/2010/12/accessing-helper-modules-in-rails.html
1. Helper methods all the time for views
class ApplicationController < ActionController::Base
helper :all# include all helpers, all the time for views
end
@ashishwadekar
ashishwadekar / all_email_provider_domains.txt
Created October 8, 2019 17:20 — forked from ammarshah/all_email_provider_domains.txt
A list of all email provider domains (free, paid, blacklist etc). Some of these are probably not around anymore. I've combined a dozen lists from around the web. Current "major providers" should all be in here as of the date this is created.
0-mail.com
007addict.com
020.co.uk
027168.com
0815.ru
0815.su
0clickemail.com
0sg.net
0wnd.net
0wnd.org
@ashishwadekar
ashishwadekar / ffmpeg-wrapper
Created April 26, 2020 19:37 — forked from BenjaminPoncet/ffmpeg-wrapper
Synology VideoStation ffmpeg wrapper with DTS, EAC3 and TrueHD support (Installation instructions in 1st comment)
#!/bin/bash
rev="12"
_log(){
echo "$(date '+%Y-%m-%d %H:%M:%S') - ${streamid} - $1" >> /tmp/ffmpeg.log
}
_log_para(){
echo "$1" | fold -w 120 | sed "s/^.*$/$(date '+%Y-%m-%d %H:%M:%S') - ${streamid} - = &/" >> /tmp/ffmpeg.log