Skip to content

Instantly share code, notes, and snippets.

View 1990prashant's full-sized avatar

Prashant Kumar Mishra 1990prashant

View GitHub Profile
@1990prashant
1990prashant / application.html.slim
Created September 13, 2016 07:25
ChatBox Configuration
//Add following line of code if you want to use default chatbox
//Replace value of data-key with your api_key
script src="http://staging.simmpli.com/dist/chatbox.min.js" id="chatboxInit" data-key="1fad50443e7dfcb98f61fcc37386e5af728727daaff1c565"
@1990prashant
1990prashant / order_contents_decorator.rb
Created May 24, 2016 07:35
Add new fields in order's line items
#This is the last file where you need to change
module Spree
OrderContents.class_eval do
def initialize(order)
@order = order
end
def add(variant, quantity = 1, options = {}, attributes_name)
timestamp = Time.current
@1990prashant
1990prashant / terminal
Created March 30, 2016 10:22
Referesh Paperclip images without reuploading
bundle exec rake paperclip:refresh CLASS=Spree::ClassName
@1990prashant
1990prashant / Capfile
Last active February 23, 2017 09:37
Deploying rails server on production using capistrano gem
#CapFile
load 'deploy'
load 'deploy/assets'
load 'config/deploy'
@1990prashant
1990prashant / gemfile
Created March 25, 2016 07:27
Configuring puma for rails server
gem 'puma'
@1990prashant
1990prashant / gist:5d743dfb0549b6a186ec
Created March 17, 2016 07:57
How to check how many cases are covered in a rails test case
Run the below comman in terminal
xdg-open .
A file explorer is opened
then run index.html
@1990prashant
1990prashant / controller.rb
Created March 16, 2016 06:47
Render a page through controller
def comment
@comment = Spree::Post.new(post_params)
@comment.attributes = {user_id: current_spree_user.id}
if @comment.save
render json: {
success: true,
comment: render_to_string((@comment.parent_id.blank? ? 'spree/shared/_previous_comments' : 'spree/shared/_comment_line_item'), :layout => false, :locals => { :comment => @comment })
}
else
render json: {
@1990prashant
1990prashant / application.js
Created March 16, 2016 06:29
To call noty within javascript
noty({text: "Please select an image", type: "error"});
#type may be warning, notice etc.
@1990prashant
1990prashant / GemFile
Last active August 14, 2018 09:00
Noty in rails
#Add noty gem
gem 'noty-rails'
# Run bundle command from your terminal
@1990prashant
1990prashant / application.js
Created March 16, 2016 06:23
To write prototype js
var mashkar = {
init: function() {
this.calculateTotalPrice();
},
calculateTotalPrice: function() {
$(document).on("change", '.price-field', function() {
var variantRow = $(this).closest(".variant-row");
var sellerPrice = parseFloat($(this).val());