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/bash | |
# this script is used to update the openvpn access server certificates after | |
# certbot renews the certificates | |
# the cron job should be like this: | |
# certbot renew --deploy-hook /usr/local/bin/update-openvpn-certs.sh | |
$DOMAIN = "YOUR_DOMAIN_NAME" | |
./sacli --key "cs.priv_key" --value_file "/etc/letsencrypt/live/$DOMAIN/privkey.pem" ConfigPut | |
./sacli --key "cs.cert" --value_file "/etc/letsencrypt/live/$DOMAIN/cert.pem" ConfigPut | |
./sacli --key "cs.ca_bundle" --value_file "/etc/letsencrypt/live/$DOMAIN/chain.pem" ConfigPut |
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 GenerateCrumbsCsvService | |
def self.perform | |
data = [] | |
Category.where(listed: true, depth: 2).each do |category| | |
crumbs_id = [category.parent.parent._id.to_s, category.parent._id.to_s, category._id.to_s].join("|") | |
crumbs = [category.parent.parent.title, category.parent.title, category.title].join("|") | |
data.push([crumbs, crumbs_id]) | |
end | |
CSV.open("/tmp/crumbs.csv", "w") do |csv| |
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
def export_orders_promo_info_csv(start_date, end_date) | |
# start_date and end_date params should be Date objects | |
rows = [] | |
rows << ["order_number", "status", "sub_total", "total", "discount", "promotion_code"] | |
Order::History.where(order_number: /^WO/, finalized_at: start_date..end_date).each do |order| | |
row = [] | |
row << order.order_number | |
row << order.status | |
row << order.final_sub_total | |
row << order.final_total |
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
sync_updates to: ProductGroup::Dimension::Option, with: DimensionOption::SyncWorker, fields: [:all], after: [] | |
sync_updates to: Product, # with: Admin::Data::SyncWorker | |
perform(source_class, dest_class, source_id, fields) | |
# finds all types of to models that contain the source_id | |
# e.g. Products that embed property_ids | |
# e.g. ProductGroup::Dimension::Option that have property_id of XXX | |
# enqueues individual update jobs for each record update, using sidekiq batch | |
ProductGroup.where("dimensions.options.property_id" => property_id) |
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
find . -type d -exec chmod 0700 '{}' \; | |
find . -type f -exec chmod 0600 '{}' \; |
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
// Webpack Config File | |
// Allows import of: | |
// CSS styles | |
// Fonts | |
// CSV/TSV data | |
// XML data | |
const path = require('path'); | |
module.exports = { |
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 Mongoid::Migration | |
# renames a collection in mongodb, can be told to drop the target collection first | |
def self.rename_collection(old_name, new_name, drop_target=false) | |
client = Mongoid::Clients.default | |
current_db = client.database | |
admin_db = Mongo::Database.new(client, Mongo::Database::ADMIN, current_db.options) | |
admin_db.command(renameCollection: "#{current_db.name}.#{old_name}", | |
to: "#{current_db.name}.#{new_name}", | |
dropTarget: drop_target) | |
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
#!/bin/bash | |
OUTPUT=`/usr/local/bin/si | grep -Po '(?<=Fahrenheit : ).+?(?=F)'` | |
CMD="mosquitto_pub -h temp.adamrunner.com -t outTopic -m ESP_E2106F,${OUTPUT}" | |
`$CMD` |
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
# Sidekiq Preview/Staging Background worker | |
# sudo initctl sidekiq-staging {start, stop, restart} | |
# | |
description "Staging/Preview Sidekiq Background Worker" | |
# This script is not meant to start on bootup, workers.conf | |
# will start all sidekiq instances explicitly when it starts. | |
#start on runlevel [2345] | |
#stop on runlevel [06] |
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
/* interrupt routine for Rotary Encoders | |
The average rotary encoder has three pins, seen from front: A C B | |
Clockwise rotation A(on)->B(on)->A(off)->B(off) | |
CounterCW rotation B(on)->A(on)->B(off)->A(off) | |
and may be a push switch with another two pins, pulled low at pin 8 in this case | |
NewerOlder