Skip to content

Instantly share code, notes, and snippets.

View jgarth's full-sized avatar

Josh Garth jgarth

  • Tiny Empire
  • Dunedin, New Zealand
  • 20:28 (UTC +12:00)
View GitHub Profile
https://git.io/fpZ5b
WITH billed_by_courier AS (
SELECT
vendor_ref
FROM
accounting_vendor_billables
INNER JOIN
accounting_vendor_invoices ON accounting_vendor_invoices.id = accounting_vendor_billables.vendor_invoice_id
WHERE
accounting_vendor_invoices.type IN ('Accounting::VendorInvoices::UPS', 'Accounting::VendorInvoices::DPD')
GROUP BY
WITH billed_by_courier AS (
SELECT
vendor_ref
FROM
accounting_vendor_billables
INNER JOIN
accounting_vendor_invoices ON accounting_vendor_invoices.id = accounting_vendor_billables.vendor_invoice_id
WHERE
accounting_vendor_invoices.type IN ('Accounting::VendorInvoices::UPS', 'Accounting::VendorInvoices::DPD')
GROUP BY
WITH billed_by_courier AS (
SELECT
vendor_ref
FROM
accounting_vendor_billables
INNER JOIN
accounting_vendor_invoices ON accounting_vendor_invoices.id = accounting_vendor_billables.vendor_invoice_id
WHERE
accounting_vendor_invoices.type IN ('Accounting::VendorInvoices::UPS', 'Accounting::VendorInvoices::DPD')
GROUP BY
WITH billed_by_courier AS (
SELECT
vendor_ref
FROM
accounting_vendor_billables
INNER JOIN
accounting_vendor_invoices ON accounting_vendor_invoices.id = accounting_vendor_billables.vendor_invoice_id
WHERE
accounting_vendor_invoices.type IN ('Accounting::VendorInvoices::UPS', 'Accounting::VendorInvoices::DPD')
GROUP BY
WITH billed_by_ups AS (
SELECT
vendor_ref, SUM(amount) AS sum_amount, vendor_invoice_id
FROM
accounting_vendor_billables
INNER JOIN
accounting_vendor_invoices ON accounting_vendor_invoices.id = accounting_vendor_billables.vendor_invoice_id
WHERE
accounting_vendor_invoices.type = 'Accounting::VendorInvoices::UPS'
GROUP BY
WITH billed_by_ups AS (
SELECT
vendor_ref, SUM(amount) AS sum_amount, vendor_invoice_id
FROM
accounting_vendor_billables
INNER JOIN
accounting_vendor_invoices ON accounting_vendor_invoices.id = accounting_vendor_billables.vendor_invoice_id
WHERE
accounting_vendor_invoices.type = 'Accounting::VendorInvoices::UPS'
AND accounting_vendor_billables.type = 'delivery'
@jgarth
jgarth / postgresql.conf
Created September 25, 2018 08:45
PostgreSQL 10, tuned config for MBP with 16GB RAM
# -----------------------------
# PostgreSQL configuration file
# -----------------------------
#
# This file consists of lines of the form:
#
# name = value
#
# (The "=" is optional.) Whitespace may be used. Comments are introduced with
# "#" anywhere on a line. The complete list of parameter names and allowed
@jgarth
jgarth / aasm_hook_spec.rb
Last active August 25, 2016 17:15
AASM Transitional Hooks DSL / Spec / Implementation / Playground
require 'rails_helper'
describe 'AASM hooks' do
class Foo
include AASM
include Concerns::TriggersHooksAfterAASMStateChanges
aasm do
state :pending, initial: true # waiting for manual review
state :reviewed # either manual or auto; waiting for arrive, could be in transit
@jgarth
jgarth / RestKitTesting Fix
Created February 12, 2014 02:00
CocoaPods Podfile addition to fix RestKit/Testing "missing header" build issue in 0.22.0
pod 'RestKit'
pod 'RestKit/Testing'
# Fix RestKit/Testing Pod after installation
post_install do |installer|
print "Fixing RestKit/Testing Pod\n"
system "sed -ie '/RKManagedObjectStore\+RKSearchAdditions/d' ./Pods/RestKit/Code/Testing/RKTestFactory.m"
end