Skip to content

Instantly share code, notes, and snippets.

View surendra-wal's full-sized avatar

Surendra surendra-wal

View GitHub Profile
@surendra-wal
surendra-wal / spree_codesnippet.md
Last active May 3, 2017 13:10
Spree code snippet

##Service to download a file from S3## ##Service to save a file to S3##

module Spree
  class AttachmentService
    attr_reader :content, :user
    attr_writer :success

    def initialize(content, key, user)

Keybase proof

I hereby claim:

  • I am surendra-wal on github.
  • I am surendra (https://keybase.io/surendra) on keybase.
  • I have a public key ASBHUO3WLTeo_n-dcim_k6UYOTFnzL9oJGfZI9UXB1sXpwo

To claim this, I am signing this object:

@surendra-wal
surendra-wal / popular_rails_gems
Last active October 4, 2018 06:03
Popular gems which we used to have in Rails applications
@surendra-wal
surendra-wal / newsfeed_question.rb
Created January 7, 2019 11:20
RoR assignment test - 01
class User < ApplicationRecord
has_many :posts
has_many :comments
# id :integer not null, primary key
# name :string(50) default("")
end
class Post < ApplicationRecord
belongs_to :user
has_many :comments
@surendra-wal
surendra-wal / requirements.md
Last active March 4, 2019 17:30
Ruby on Rails Flight booking web application assignment

Flight booking web application

Your client, an airline company, is looking to build an application that can facilitate the bookings of their flights. This application should be able to manage all of their flight bookings and in-flight seat allocations. Admins of this platform should be able to create flights from different origins and destinations with different seat combinations. Users (passengers) should be able to select their seats on the chosen flight upon entering a PNR number, similar to airport kiosks around the country.

Description

  • Admins can create airplanes with different seat configurations(Airbus A380, Boeing 747).
  • Each airplane should have its own seat configuration. A sample seat configuration is given below-
Seat configuration
Category Seats in a row No.of rows
First Class 3 10
@surendra-wal
surendra-wal / blog-requirements.md
Last active April 18, 2019 12:31
Blog development
  • Your client, a writer wants to start a blog. He wants to blog his article and open it for commenting by anyone viewinthe articles.The application should also have the ability to let the viewers to reply to a comment and further viewers can reply to that reply.This replying can be done for any of the replies and hence there is a hierarchy of replies and comments that is to be maintained.
  • Also all of the comment data should not loaded at once.Only the top 5 comments should be shown and when load more is clicked the next set should be displayed. The same should be done for the replies and the replies to those replies.

Description

  • Post an article
  • Comment on the article
  • Reply to the comment
  • Reply to the reply
  • Replying can be done to any comment or reply.
  • Load more for comments as well as at any of the levels of replies
@surendra-wal
surendra-wal / web-servers.md
Created January 18, 2020 18:28 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
Automate API documentation with specs and CI/CD pipeline
API documentation is very important to any application. This helps Mobile, Frontend developers and other API consumers for easy integration.
There are a couple of ways to maintain the documentation
Maintain separate repo to manage API documentation. So that they don’t commit every change of API docs into the codebase.
Use the same repo having docs or some other folder to manually update when there is a change in the APIs
It is very difficult to manually maintain the API documentation for every change. How can we automate this?
@surendra-wal
surendra-wal / inventory-changes.md
Last active November 26, 2020 04:00
Inventory item changes for per pay order

Inventoty will be updated right after an newItem/updateItem/deleteItem for pre pay orders

NewItem

inventoryObj() {
    const changeInQuantity = -this.item.count;
    const inventoryItemId = this.item.priceId;
    return { changeInQuantity, inventoryItemId };
}

EditItem

@surendra-wal
surendra-wal / read-access-pg-user.sql
Last active November 12, 2021 13:39
Create user in postgres with read only access
--
-- Read only
--
-- Create a group
CREATE ROLE cents_rd_group;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO cents_rd_group;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO cents_rd_group;