Skip to content

Instantly share code, notes, and snippets.

View khpatel4991's full-sized avatar
😄

Kashyap Patel khpatel4991

😄
View GitHub Profile
@khpatel4991
khpatel4991 / nested_validation.rb
Created January 4, 2017 23:45
Nested Dry Validations
class AppSchema < Dry::Validation::Schema::Form
configure do |config|
config.type_specs = true
def self.messages
super.merge(
en: { errors: {
discount_pricing: 'are not valid.',
base_package_price: 'You need to have a package_price with quantity 1.',
package_names: 'should be unique.'
} }
@khpatel4991
khpatel4991 / .zshrc
Last active March 14, 2017 19:20
ZSH RC files with custom aliases
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH=/home/kashyap/.oh-my-zsh
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="fino"
@khpatel4991
khpatel4991 / gist:df8d4a8840a6f8eda58534c2c121aa49
Created August 29, 2016 03:29
Add Whitespace based on validity o the words
def repair_whitespace(str)
buff = []
final_words = []
str.each_char do |char|
buff << char
if valid_word?(buff.join)
final_words << buff.join
@khpatel4991
khpatel4991 / island_count.rb
Created August 29, 2016 03:28
Find Number of Islands
require 'set'
# @param {Character[][]} grid
# @return {Integer}
def num_islands(grid)
puts grid.inspect
final_count = 0
grid.length.times do |i|
grid.length.times do |j|