First, ensure the following tools are available on the local system and reasonably up to date:
- Git
- Git-flow
- RVM
- Bash
- SSH
# vim: ft=sh:ts=4:sw=4:autoindent:expandtab: | |
# Author: Avishai Ish-Shalom <avishai@fewbytes.com> | |
# We need to specify GNU sed for OS X, BSDs, etc. | |
if [[ "$(uname -s)" == "Darwin" ]]; then | |
SED=gsed | |
else | |
SED=sed | |
fi |
require "google/cloud/monitoring/v3/metric_service_client" | |
client = Google::Cloud::Monitoring::V3::MetricServiceClient.new | |
project_path = Google::Cloud::Monitoring::V3::MetricServiceClient.project_path JSON.load(File.read ENV["GOOGLE_APPLICATION_CREDENTIALS"])["project_id"] | |
create_custom_gauge_metric = lambda do |type, display_name, value_type, labels = {}| | |
metric_descriptor = Google::Api::MetricDescriptor.new( # googleapis-common-protos-1.3.5/lib/google/api/metric_pb.rb | |
type: "custom.googleapis.com/#{type}", | |
metric_kind: :GAUGE, # google-cloud-monitoring-0.24.0/lib/google/cloud/monitoring/v3/doc/google/api/metric.rb | |
value_type: value_type, # google-cloud-monitoring-0.24.0/lib/google/cloud/monitoring/v3/doc/google/api/metric.rb | |
display_name: display_name, |
The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.
In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.
This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.
I hereby claim:
To claim this, I am signing this object:
import os | |
from email.mime.text import MIMEText | |
from email.mime.image import MIMEImage | |
from email.mime.application import MIMEApplication | |
from email.mime.multipart import MIMEMultipart | |
def message(subject="Python Notification", text="", img=None, attachment=None): | |
# build message contents | |
msg = MIMEMultipart() | |
msg['Subject'] = subject # add in the subject |
import smtplib | |
import socket | |
def send(server='smtp-mail.outlook.com', port='587', msg): | |
# contain following in try-except in case of momentary network errors | |
try: | |
# initialise connection to email server, the default is Outlook | |
smtp = smtplib.SMTP(server, port) | |
# this is the 'Extended Hello' command, essentially greeting our SMTP or ESMTP server | |
smtp.ehlo() |
# Copyright (c) 2018 Bao Nguyen <b@nqbao.com> | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is | |
# furnished to do so, subject to the following conditions: | |
# | |
# The above copyright notice and this permission notice shall be included in all |
btrfs fi show -d | |
Label: '2019.02.19-20:17:48 v23824' uuid: 7c19084c-9c53-4cea-b287-0e1a43e6860b | |
Total devices 1 FS bytes used 13.95TiB | |
devid 1 size 29.07TiB used 23.18TiB path /dev/md2 | |
syno_poweroff_task -d | |
(Interrupt this after a while to prevent losing SSH completely) |