Skip to content

Instantly share code, notes, and snippets.

View rubyrider's full-sized avatar
🎯
Focusing

Irfan Ahmed rubyrider

🎯
Focusing
View GitHub Profile
/*! debug.css | MIT License | zaydek.github.com/debug.css */
*:not(path):not(g) {
color: hsla(210, 100%, 100%, 0.9) !important;
background: hsla(210, 100%, 50%, 0.5) !important;
outline: solid 0.25rem hsla(210, 100%, 100%, 0.5) !important;
box-shadow: none !important;
}
@rubyrider
rubyrider / documentation_example.rb
Created October 8, 2018 17:46
Documentation example
require_relative 'postman/email_base'
require_relative 'postman/mail_gun_postman'
require_relative 'postman/custom_sms_gateway'
module Janao
module Postman
# Sets list of allowed email adapters
EMAIL_ADAPTERS = {
'MailGun' => MailGunPostman
@rubyrider
rubyrider / # qt - 2018-10-07_16-01-34.txt
Created October 7, 2018 10:43
qt on macOS 10.14 - Homebrew build logs
Homebrew build logs for qt on macOS 10.14
Build date: 2018-10-07 16:01:34
@rubyrider
rubyrider / .rubocop.yml
Created September 19, 2018 07:46
Rubocop Configuration for Rails
require: rubocop-rspec
Rails:
Enabled: true
# Commonly used screens these days easily fit more than 80 characters.
Metrics/LineLength:
Max: 120
# Too short methods lead to extraction of single-use methods, which can make
# Original AFooClass
class AFoo
def bar
puts "Foooo Bar"
end
end
# Refining Module
module RefiningAFoo
module ActiveModel
class Errors
attr_accessor :error_code, :developer_message, :more_info
def add(attribute, message = :invalid, options = {})
options.each { |k,v| instance_variable_set("@#{k}", v) }
message = normalize_message(attribute, message, options)
if exception = options[:strict]
# Module MixArrayFlattener
# Add #flatten_array to Array for the purpose
# of flatten nested array
module MixArrayFlattener
InvalidArrayItemFound = Class.new(StandardError)
# Flatten nested array!
#
# @return single flat array,
@rubyrider
rubyrider / alter_user_migration.rb
Last active December 22, 2015 10:59
Example of migration
class AlterUser < ActiveRecord::Migration
def up
rename_table :users, :customers
add_column :customers, :username, :string, limit: 25
change_column :customers, :email, :string, limit: 100
rename_column :customers, :password, :hashed_password
add_column :customers, :salt, :string, limit: 40
add_index :customers, :username
end
@rubyrider
rubyrider / After Refactoring
Last active December 21, 2015 20:39
Order and Purchase Code Refactoring
class OrderService
class << self
def find_or_create_purchase_for_order(order, credit_card_id, shipping_fee = 0.0)
buyer, seller, purchase, s_state = order.buyer, order.seller, Purchase.find_by_user_id_and_order_id(user.id, order.id), order.cart.shipping_address.state.upcase
sale_tax = SalesTax.find_by_user_id(vendor.id).send(s_state) rescue 0.0
total_chargeable_amount = calculate_total order.price, sale_tax, vendor.reppio_cut
create_purchase order, credit_card_id, shipping_fee, total_chargeable_amount, sales_tax # updated here
# the day_statistics
include Mongoid::Document
field :date, type: Date
field :entity_id, type: Integer
field :todays_statistics, type: Hash
field :hotel_inventory, type: Hash