This file contains hidden or 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
# == Schema Information | |
# | |
# Table name: group_order_members | |
# | |
# id :integer not null, primary key | |
# name :string | |
# email :string | |
class GroupOrderMember < ApplicationRecord | |
include Accounting::Interfaces::Invoiceable |
This file contains hidden or 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
module Accounting | |
module Interfaces | |
module Invoiceable | |
extend ActiveSupport::Concern | |
included do | |
# Quack like a duck | |
attribute :can_invoice?, :boolean, default: true |
This file contains hidden or 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
class Accounting::LedgerItem < ApplicationRecord | |
acts_as_ledger_item | |
belongs_to :recipient, polymorphic: true | |
belongs_to :sender, polymorphic: true | |
has_many :line_items | |
# # specific line items |
This file contains hidden or 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
class Accounting::LedgerItem < ApplicationRecord | |
# super class | |
has_many :line_items, class_name: 'Accounting::LineItem', as: :ledger_item | |
# specific line items | |
has_many :ordered_items, class_name: 'Accounting::LineItems::OrderedItem', as: :ledger_item | |
has_many :fees, class_name: 'Accounting::LineItems::Fee', as: :ledger_item | |
has_many :payments, class_name: 'Accounting::LineItems::Payment', as: :ledger_item | |
has_many :discounts, class_name: 'Accounting::LineItems::Discount', as: :ledger_item | |
end |
This file contains hidden or 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
with menu_item_order_counts as ( | |
select o.id as order_id, | |
o.menu_id, | |
oi.menu_item_id, | |
sum(oi.quantity) as quantity | |
from orders o | |
join order_items oi on o.id = oi.order_id | |
join menu_items mi on oi.menu_item_id = mi.id | |
join menu_groups mg on mi.menu_group_id = mg.id | |
where o.menu_id is not null |
This file contains hidden or 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
# == Schema Information | |
# | |
# Table name: restaurants_menu_item_rankings | |
# | |
# id :integer | |
# menu_id :integer | |
# menu_item_name :string | |
# count :decimal(, ) | |
# |
This file contains hidden or 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
m = Menu.includes(:menu_groups).find(1) | |
m.menu_groups.all |
This file contains hidden or 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
from pprint import pprint | |
import numpy as np | |
from pandas import DataFrame, read_csv | |
from sklearn.cluster import KMeans | |
data = read_csv('features.csv').to_numpy() | |
matrix = data.transpose() | |
matrix = np.delete(matrix, 0, 0) |
This file contains hidden or 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
import Ember from 'ember'; | |
const {computed} = Ember; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
bar: '', | |
foo: computed('bar', function() { |
This file contains hidden or 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
i = 0 | |
1000.times do |i| | |
Thread.new { | |
puts "#{i} #{i.even?}" | |
i += 1 | |
puts "#{i} #{i.even?}" | |
} | |
end |