This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
SCM_THEME_PROMPT_DIRTY=" ${red}✗" | |
SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓" | |
SCM_THEME_PROMPT_PREFIX=" ${green}|" | |
SCM_THEME_PROMPT_SUFFIX="${green}|" | |
GIT_THEME_PROMPT_DIRTY=" ${red}✗" | |
GIT_THEME_PROMPT_CLEAN=" ${bold_green}✓" | |
GIT_THEME_PROMPT_PREFIX=" ${green}|" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FacilityInfo = Struct.new(:facility, :pallet_quantity, :case_quantity, :item_quantity) | |
def index | |
products = Product.by_company(current_user.company.slug).includes(:facilities, :total_stocks).distinct(:sku) | |
sql = "SELECT DISTINCT ON (product_id) * FROM facility_stocks WHERE product_id IN (#{@products.pluck(:id).join(', ')}) ORDER BY product_id, created_at DESC" | |
facility_stocks = ActiveRecord::Base.connection.execute(sql) | |
facilities = Facility.all | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@products = Product.by_company(current_user.company.slug).includes(:facilities, :total_stocks).distinct(:sku) | |
sql = "SELECT DISTINCT ON (product_id) * FROM facility_stocks WHERE product_id IN (#{@products.pluck(:id).join(', ')}) ORDER BY product_id, created_at DESC" | |
@facility_stocks = ActiveRecord::Base.connection.execute(sql) | |
in view | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FacilityStock.where(product_id: @products).select('MAX(id), facilty_stocks.*').group(:product_id).to_sql | |
=> "SELECT MAX(id), facilty_stocks.* FROM \"facility_stocks\" WHERE \"facility_stocks\".\"product_id\" IN (SELECT DISTINCT \"products\".\"id\" FROM \"products\" WHERE \"products\".\"company_id\" = 10) GROUP BY \"facility_stocks\".\"product_id\"" | |
FacilityStock.where(product_id: @products).select('MAX(id), facilty_stocks.*').group(:product_id).size | |
{34=>2, 36=>4, 40=>2} | |
2.4.1 :054 > sql = "SELECT DISTINCT ON (product_id) * FROM facility_stocks WHERE product_id IN (#{@products.pluck(:id).join(', ')}) ORDER BY product_id, created_at DESC" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 @company.projects.each do |project| | |
1 @facility_projects = project.facility_projects.where(inactive: false) | |
21 @facility_projects.each do |fp| | |
1 @facilities << fp.facility | |
2 end | |
3 @inactive_facility_projects = project.facility_projects.where(inactive: true) | |
4 | |
5 @inactive_facility_projects.each do |fp| | |
6 @inactive_facilities << fp.facility | |
7 end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 jQuery(function() { | |
9 return $('form').on('click', '.add_fields', function(event) { | |
8 var regexp, time; | |
7 time = new Date().getTime(); | |
6 regexp = new RegExp($(this).data('id'), 'g'); | |
5 $(this).before($(this).data('fields').replace(regexp, time)); | |
4 return event.preventDefault(); | |
3 }); | |
2 }); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Edit the incomplete C source code to create a linked list to store the birthday information of 6 random students. For each person, the birthday information should include month, day, year, and name.When the module is loaded, traverse through the linked list and output its contentto the kernel log buffer. In addition, write code to identifythe youngeststudentby year (you can define 6 students born in 6 different years.)and remove that student from the list. After removing the youngest student, | |
output the updated linked list content to the kernel log buffer. In the module exit point, delete the elements from the updated linked list and returnthe free memory back to the kernel.Makesure to output a message to the kernel log buffer every time an element is deleted. | |
MakeFile | |
``` | |
obj-m += simple.o | |
all: | |
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 describe "POST #create" do | |
4 describe "with valid params" do | |
3 it "creates a new inbound order" do | |
0 inbound_params = FactoryGirl.attributes_for(:inbound_order, documents: [Document.create(name: Faker::App.name, doc: File.new("#{Rails.root}/spec/fixtures/test_file.pdf"))]) | |
1 expect { post :create, :inbound_order => inbound_params }.to change(InboundOrder, :count).by(1) | |
2 end | |
3 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 describe "POST #create" do | |
4 describe "with valid params" do | |
3 it "creates a new inbound order" do | |
2 inbound_params = FactoryGirl.attributes_for(:inbound_order) | |
>> 1 document = Document.create(name: Faker::App.name, doc: File.new("#{Rails.root}/spec/fixtures/test_file.pdf")) | |
27 inbound_params.documents << document # this is stupid but I need to do the for the inbound order not the params | |
1 expect { post :create, :inbound_order => inbound_params }.to change(InboundOrder, :count).by(1) | |
2 end | |
3 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
SCM_THEME_PROMPT_DIRTY=" ${red}✗" | |
SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓" | |
SCM_THEME_PROMPT_PREFIX=" ${green}|" | |
SCM_THEME_PROMPT_SUFFIX="${green}|" | |
GIT_THEME_PROMPT_DIRTY=" ${red}✗" | |
GIT_THEME_PROMPT_CLEAN=" ${bold_green}✓" | |
GIT_THEME_PROMPT_PREFIX=" ${green}|" |
NewerOlder