Skip to content

Instantly share code, notes, and snippets.

@joegaudet
joegaudet / group_order_member.rb
Last active December 15, 2019 18:21
Crazy Pills
# == Schema Information
#
# Table name: group_order_members
#
# id :integer not null, primary key
# name :string
# email :string
class GroupOrderMember < ApplicationRecord
include Accounting::Interfaces::Invoiceable
module Accounting
module Interfaces
module Invoiceable
extend ActiveSupport::Concern
included do
# Quack like a duck
attribute :can_invoice?, :boolean, default: true
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
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
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
# == Schema Information
#
# Table name: restaurants_menu_item_rankings
#
# id :integer
# menu_id :integer
# menu_item_name :string
# count :decimal(, )
#
m = Menu.includes(:menu_groups).find(1)
m.menu_groups.all
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)
import Ember from 'ember';
const {computed} = Ember;
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
bar: '',
foo: computed('bar', function() {
i = 0
1000.times do |i|
Thread.new {
puts "#{i} #{i.even?}"
i += 1
puts "#{i} #{i.even?}"
}
end