- Create a file to store our credentials:
sudo vim /etc/postfix/sasl_passwd
# list pid, execution time, and query text for running queries | |
def pg_ps | |
now = Time.now | |
ActiveRecord::Base.connection.execute("SELECT pid, query, query_start FROM pg_stat_activity WHERE state='active'").to_a.each do |q| | |
printf "%8d %10.2f %s\n", q['pid'], now - DateTime.parse(q['query_start']), q['query'] | |
end | |
nil | |
end | |
# cancel the current query for the given process |
-- Potentially quirky when it comes to week numbers. | |
BEGIN TRANSACTION; | |
DROP TABLE IF EXISTS numbers_small; | |
CREATE TABLE numbers_small ( | |
number SMALLINT NOT NULL | |
) DISTSTYLE ALL SORTKEY (number | |
); | |
INSERT INTO numbers_small VALUES (0), (1), (2), (3), (4), (5), (6), (7), (8), (9); |
CREATE VIEW dw.dim_time_vw AS | |
with nums AS ( | |
SELECT TOP 86400 | |
row_number() over ( | |
PARTITION BY NULL ORDER BY id) AS num | |
FROM l_browser) | |
SELECT | |
to_char( | |
DATEADD(second, num-1, cast('2000-01-01' AS date)), 'HH24MISS') AS time_key, |
# via https://ecommerce.shopify.com/c/api-announcements/t/upcoming-change-in-api-limit-calculations-159710 | |
# | |
# This automatically slows down requests to Shopify if we exceed their rate limit | |
# NOTE that we'll always be calling shopify in background threads such as sidekiq, | |
# so this should not impact users directly. | |
# | |
# This has been tested by hand, it seems to do the right thing, but has not been | |
# truly load tested at scale. | |
module ActiveResource | |
class Connection |
sudo vim /etc/postfix/sasl_passwd
// without callback | |
Array.prototype.eachSlice = function (size){ | |
this.arr = [] | |
for (var i = 0, l = this.length; i < l; i += size){ | |
this.arr.push(this.slice(i, i + size)) | |
} | |
return this.arr | |
}; | |
[1, 2, 3, 4, 5, 6].eachSlice(2) |
<%= f.time_zone_select :time_zone, TimeZoneWithFormattedOffset.all.sort_by { |tz| [tz.now.utc_offset, tz.name] } %> |
# Login as root | |
ssh root@domain | |
# Create deploy user | |
adduser <username> #Adds User with username given. Enter Password when Prompted. Other Details are Optional | |
# Add user to sudo group | |
usermod -g <groupname> <username> | |
# Add .ssh/authorized_keys for deploy user |
# encoding: utf-8 | |
# god -c config/app.god | |
module YourApp | |
module God | |
def self.generic_monitoring(w, options = {}) | |
# start if process is not running | |
w.start_if do |start| | |
start.condition(:process_running) do |c| | |
c.interval = 10.seconds |