Skip to content

Instantly share code, notes, and snippets.

View reachlin's full-sized avatar

reachlin reachlin

View GitHub Profile
@reachlin
reachlin / prometheus.yml
Created April 19, 2017 07:06
sample prometheus configuration explained
// For all the confusing Prometheus configuration and
// regular expressions,
// explained in examples.
// Remember, there are default values for each item if it's missing.
// regex is (.*),
// replacement is $1,
// separator is ;
// ,and action is replace
@reachlin
reachlin / slack.py
Last active August 4, 2022 09:33
python verify slack bot message
def verify_slack_msg(msg):
try:
slack_signature = msg['headers']['X-Slack-Signature']
slack_signing_secret = all_secrets.get('SLACK_SIGNING_SECRET', '')
sig_basestring = f"v0:{msg['headers']['X-Slack-Request-Timestamp']}:{msg['body']}"
my_signature = 'v0=' + hmac.new(
bytes(slack_signing_secret, 'latin-1'),
msg=bytes(sig_basestring, 'latin-1'),
digestmod=hashlib.sha256
).hexdigest()
@reachlin
reachlin / gist:f0dd56e9b91c1d817ff1c1cc11d0b988
Last active December 16, 2022 06:13
encrypt and decrypt messages with ssh public key using openssl

If you created your ssh keys with default rsa settings, their format is not compatible in openssl. To encrypt and decrpt messages in openssl, you need your public key and private key in pem format, and start like this:

-----BEGIN PUBLIC KEY-----
or
-----BEGIN RSA PRIVATE KEY-----

Examples:

@reachlin
reachlin / datadog.ipynb
Last active May 18, 2023 09:22
datadog.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# A very simple ask and search AI bot.
from langchain import OpenAI
from langchain.utilities import GoogleSearchAPIWrapper
from langchain.agents import initialize_agent, Tool
from langchain.agents import AgentType
from flask import jsonify, request, Response, Flask
import os
app = Flask(__name__)