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
#!/usr/bin/env ruby | |
# frozen_string_literal: true | |
# Upgrade HAML attribute syntax to prepare for HAML 6. | |
# | |
# HAML 6 stopped supporting nested hash attributes other than `data` and `aria`. | |
# We used to be able to write: | |
# | |
# %div{ ng: { class: "upper", bind: "model" } } | |
# |
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
apt purge apache2 apache2-utils libapache2-mod-php mariadb-server mariadb-client php* | |
apt autoremove | |
adduser maikel | |
usermod -a maikel -G sudo | |
cp -a .ssh/ /home/maikel/ | |
chown maikel:maikel /home/maikel/.ssh/ -R | |
ssh-keygen | |
cd .ssh && cat id_ed25519.pub >> authorized_keys |
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
proxy_cache_path /data/nginx/cache keys_zone=STATIC:500m; | |
server { | |
listen 443 ssl http2; | |
listen [::]:443 ssl http2; | |
server_name discover.openfoodnetwork.org.au api.regenerative.org.au; | |
root /home/openfoodnetwork/apps/discover/current/public; | |
ssl_certificate /etc/letsencrypt/live/api.regenerative.org.au/fullchain.pem; # managed by Certbot | |
ssl_certificate_key /etc/letsencrypt/live/api.regenerative.org.au/privkey.pem; # managed by Certbot | |
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
# An idea for a convention. Not sure it will be useful yet. | |
module I18nLib | |
def lazy_translate(translation_key, options = {}) | |
scope = self.class.to_s.underscore.tr("/", ".") | |
options.merge!(scope: scope) | |
I18n.t(translation_key, **options) | |
end | |
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
producer | sku | name | display_name | category | description | units | unit_type | variant_unit_name | price | on_hand | available_on | on_demand | shipping_category | tax_category | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Freddy's Farm Shop | Fuji Apple | Fruit | 1 | g | 5.00 | 0 | 2022-07-27 01:59:03.412543 | 1 | Default | Tax Category | |||||
Freddy's Farm Shop | Mushrooms | Fungi | 1 | g | 50.00 | 0 | 2022-07-27 01:59:03.540333 | 1 | Default | Tax Category | |||||
Fredo's Farm Hub | Carrots | Vegetables | 1 | g | 3.00 | 0 | 2022-07-27 01:59:03.662664 | 1 | Default | Tax Category | |||||
Fredo's Farm Hub | Potatoes | Vegetables | 1 | g | 2.00 | 0 | 2022-07-27 01:59:03.78174 | 1 | Default | Tax Category | |||||
Fredo's Farm Hub | Tomatoes | Vegetables | 1 | g | 2.00 | 0 | 2022-07-27 01:59:03.900057 | 1 | Default | Tax Category | |||||
Fred's Farm | TestSKU | Garlic | Vegetables | 1 | g | 20.00 | 0 | 2022-07-27 01:59:03.212884 | 1 | Default | Tax Category |
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
sql=' | |
SELECT | |
SUBSTRING(CONCAT(completed_at) from 1 for 7) AS month, | |
COUNT(DISTINCT distributor_id) AS shops, | |
COUNT(DISTINCT email) AS customers, | |
COUNT(o.id) AS orders, | |
SUM(o.total) AS VALUE | |
FROM spree_orders o | |
WHERE o.completed_at >= DATE_TRUNC($$year$$, now() - interval $$2 months$$) | |
AND o.state = $$complete$$ GROUP BY month ORDER BY month; |
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
#!/bin/sh | |
git fetch upstream | |
latest="$(git tag --sort="-v:refname" | head -1)" | |
echo "Changes since last release $latest:" | |
pr_numbers() { | |
git log "$latest.." --merges --oneline |\ | |
grep -oP 'Merge pull request #\K[0-9]+(?= from)' |
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
enterprise = Enterprise.find_by_permalink("bawbawfoodhub") | |
scoper = OpenFoodNetwork::ScopeVariantToHub.new(enterprise) | |
#producer,distributor,name,display_name,variant_unit_name,sku,units,unit_type,price,on_hand,on_demand | |
data = enterprise.inventory_items.visible.map do |item| | |
variant = item.variant | |
scoper.scope(variant) if variant | |
product = variant&.product | |
{ | |
producer: product&.supplier&.name, |
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
producers = Enterprise.is_primary_producer.joins(:address).where(spree_addresses: {state_id: 1061493592}).map { |e| {id: e.id, name: e.name, contact: e.contact_name, phone: e.phone, email: e.email_address, properties: e.producer_properties.map(&:value).join("|")} } | |
CSV.open("producers.csv", "wb") { |csv| csv << producers.first.keys; producers.each { |p| csv << p.values } } |
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
#!/usr/bin/env ruby | |
# Create CSV files for each producer in recently closed order cycles. | |
# | |
# It's similar data to the email sent to producers but as a CSV file. | |
# | |
# Use like this: | |
# | |
# bundle exec rails runner script/order_cycle_producer_csv.rb |
NewerOlder