Skip to content

Instantly share code, notes, and snippets.

View id's full-sized avatar

Ivan Dyachkov id

  • EMQ Technologies
  • Stockholm
View GitHub Profile
@id
id / gist:476844f8bf1f328088eae08bca8c0cb1
Last active September 19, 2024 16:41
install-snowflake-odbc.sh
#!/usr/bin/env bash
set -xeuo pipefail
apt update && apt install -yyq unixodbc-dev odbcinst wget unixodbc libreadline8
wget -nc 'https://sfc-repo.snowflakecomputing.com/odbc/linux/3.3.2/snowflake-odbc-3.3.2.x86_64.deb'
dpkg -i snowflake-odbc-3.3.2.x86_64.deb
apt install -f
ODBC_INST_LIB=/usr/lib/x86_64-linux-gnu/libodbcinst.so
@id
id / gke.tf
Created August 31, 2024 07:08
provider "google" {
project = "<project_id>"
region = "europe-central2"
}
variable "project_id" {
type = string
}
variable "region" {
@id
id / cluster.hocon
Created May 31, 2024 16:22
Test emqx authz webhook
authorization {
deny_action = ignore
no_match = deny
sources = [
{
body {
username = "${username}"
}
enable = true
headers {
@id
id / Dockerfile
Created March 26, 2024 10:47
EMQX + HAProxy + Datadog Agent with EMQX integration in docker compose
FROM gcr.io/datadoghq/agent:latest
RUN agent integration install -r -t datadog-emqx==1.0.0
@id
id / index.js
Created February 21, 2024 14:20
mqtt.js sample code
const mqtt = require("mqtt");
const url = 'mqtts://127.0.0.1:8883'
const options = {
clean: true,
connectTimeout: 1000,
clientId: 'emqx_test',
username: 'emqx_test',
password: 'emqx_test',
rejectUnauthorized: false,
@id
id / pub.py
Created February 19, 2024 16:48
paho.mqtt python publisher
#!/usr/bin/env python3
import asyncio
import random
import string
import json
import paho.mqtt.client as mqtt
broker = 'localhost'
port = 1883
alhabet = string.ascii_lowercase+string.digits
@id
id / gist:e94cba0583debf38692d4b83dd360eb4
Created August 29, 2023 06:58
Encrypt in Typescript --> Decrypt with openssl
import * as crypto from 'crypto';
function encryptToken(token: string, password: string): string {
const iv = crypto.randomBytes(16);
let cipher = crypto.createCipheriv('aes-256-cbc', Buffer.from(password), iv);
let encrypted = cipher.update(token);
encrypted = Buffer.concat([encrypted, cipher.final()]);
return `${iv.toString('hex')}:${encrypted.toString('hex')}`;
}
@id
id / emqx-prometheus-cloudwatch.md
Created April 27, 2023 16:18
EMQX e4.4.17 --> Prometheus --> CloudWatch

EMQX e4.4.17 --> Prometheus --> CloudWatch

Tested on a stock Ubuntu 22.04 AMI.

EMQX

sudo apt update
sudo apt install ./emqx-ee-4.4.17-otp24.3.4.2-1-ubuntu22.04-amd64.deb
sudo systemctl restart emqx
curl -f "127.0.0.1:8081/api/v4/emqx_prometheus?type=prometheus"
@id
id / openssl@1.1.rb
Created September 6, 2022 17:06
brew formula for openssl@1.1 with no-shared
class OpensslAT11 < Formula
desc "Cryptography and SSL/TLS Toolkit"
homepage "https://openssl.org/"
url "https://www.openssl.org/source/openssl-1.1.1q.tar.gz"
mirror "https://www.mirrorservice.org/sites/ftp.openssl.org/source/openssl-1.1.1q.tar.gz"
mirror "http://www.mirrorservice.org/sites/ftp.openssl.org/source/openssl-1.1.1q.tar.gz"
mirror "https://www.openssl.org/source/old/1.1.1/openssl-1.1.1q.tar.gz"
mirror "https://www.mirrorservice.org/sites/ftp.openssl.org/source/old/1.1.1/openssl-1.1.1q.tar.gz"
mirror "http://www.mirrorservice.org/sites/ftp.openssl.org/source/old/1.1.1/openssl-1.1.1q.tar.gz"
sha256 "d7939ce614029cdff0b6c20f0e2e5703158a489a72b2507b8bd51bf8c8fd10ca"
@id
id / .tmux.conf
Created February 3, 2018 21:07
.tmux.conf
unbind C-b
set-option -g prefix C-a
bind C-a send-prefix
set-option -g default-terminal "screen-256color"
bind-key -temacs-copy M-w copy-pipe "tmux_send_clip.sh"
set-option -g default-command "/bin/bash && source ~/.bashrc"
set-option -g status-bg black
set-option -g status-fg white
set-option -g status-left ‘#[fg=green]#H’
set-option -g visual-activity on