Skip to content

Instantly share code, notes, and snippets.

View shaposhnikoff's full-sized avatar
🏠
Working from home

Shaposhnikoff shaposhnikoff

🏠
Working from home
  • Kiev,Ukraine
  • 10:16 (UTC +03:00)
View GitHub Profile
@shaposhnikoff
shaposhnikoff / tasmota multipress.md
Last active September 15, 2024 21:19
tasmota multipress
  1. SO73 1
rule1 
on button1#state=10 do publish button_test10 %value% endon
on button1#state=11 do publish button_test11 %value% endon
on button1#state=12 do publish button_test12 %value% endon
on button1#state=13 do publish button_test13 %value% endon
on button1#state=14 do publish cmnd/air_cond_tuya/POWER toggle endon
on button2#state do publish button_test2 %value% endon
on button3#state do publish button_test3 %value% endon
@shaposhnikoff
shaposhnikoff / pi-star preparation to normal work.txt
Created July 25, 2024 12:33
pi-star preparation to normal work
#!/bin/bash
# Flush all rules
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -t raw -F
@shaposhnikoff
shaposhnikoff / nkon_LiFePo4_batteries_availability_checker.py
Created July 17, 2024 16:04
LiFePo4 batteries availability checker
import requests
from bs4 import BeautifulSoup
# URL to scrape
url = "https://ru.nkon.nl/rechargeable/lifepo4/prismatisch.html"
# Send a GET request to the page
response = requests.get(url)
response.raise_for_status() # Ensure the request was successful

Prerequisites

AWS Account: Ensure you have an AWS account and necessary permissions to create resources.
AWS CLI: Install and configure the AWS CLI with your credentials.
Terraform: Install Terraform on your local machine.

Step 1: Set Up Your Project Directory

https://medium.com/@janvithakkar.583/implementing-serverless-api-with-amazon-api-gateway-lambda-function-and-amazon-cognito-user-pool-92ff44cc4949
https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-invoke-api-integrated-with-cognito-user-pool.html
Call the API with Cognito Credentials:
After integrating the user pool, users will need to sign in to Cognito and obtain a JSON Web Token (JWT).
When making API requests, users will include the JWT token in the "Authorization" header with the format "Bearer <token>".
API Gateway will validate the token with Cognito and grant access based on the user's permissions.
template(name="json-template"
type="list") {
constant(value="{")
constant(value="\"@timestamp\":\"") property(name="timereported" dateFormat="rfc3339")
constant(value="\",\"@version\":\"1")
constant(value="\",\"message\":\"") property(name="msg" format="json")
constant(value="\",\"sysloghost\":\"") property(name="hostname")
constant(value="\",\"severity\":\"") property(name="syslogseverity-text")
constant(value="\",\"facility\":\"") property(name="syslogfacility-text")
constant(value="\",\"programname\":\"") property(name="programname")
from kubernetes import client, config
import requests,sys
# list all PVCs in a namespace
def list_all_pvc(env, namespace):
config.load_kube_config(config_file='~/.kube/config', context=env)
v1 = client.CoreV1Api()
pvc_list = v1.list_namespaced_persistent_volume_claim(namespace)
return pvc_list
@shaposhnikoff
shaposhnikoff / FTDX10 Digital Mode Setup.csv
Last active May 1, 2024 09:52
FTDX10 Digital Mode Setup
Name Value Long_name Desc MenuPath
EX010101 2 AF TREBLE GAIN 0 RadioSetting->ModeSSB
EX010102 1 AF MIDDLE TONE GAIN 0 RadioSetting->ModeSSB
EX010103 0 AF BASS GAIN 0 RadioSetting->ModeSSB
EX010104 20 msec AGC FAST DELAY 0 RadioSetting->ModeSSB
EX010105 1000 msec AGC MID DELAY 0 RadioSetting->ModeSSB
EX010106 3220 msec AGC SLOW DELAY 0 RadioSetting->ModeSSB
EX010107 100Hz LCUT FREQ 0 RadioSetting->ModeSSB
EX010108 6dB/oct LCUT SLOP 0 RadioSetting->ModeSSB
EX010109 3000Hz HCUT FREQ 0 RadioSetting->ModeSSB
@shaposhnikoff
shaposhnikoff / NBUStatService.py
Created November 19, 2023 16:14
NBUStatService Prometheus Currency Exporter
import sys
import time
from prometheus_client import start_http_server, Gauge
import requests,json
nbu_api_endpoint = "https://bank.gov.ua/NBUStatService/v1/statdirectory/exchange?json"
date = time.strftime("%Y-%m-%d")
for item in json.loads(requests.get(nbu_api_endpoint).text):
globals()[item['cc']] = Gauge(item['cc'], "currency rate ", ["date","currency_name"])
globals()[item['cc']].labels(date = time.strftime("%Y-%m-%d"), currency_name = item['cc']).set(item['rate'])
@shaposhnikoff
shaposhnikoff / Ophran IAM Policies ( Not used in any role ).py
Created October 15, 2023 08:39
Ophran IAM Policies ( Not used in any role )
import boto3,os,shutil,re
session = boto3.session.Session(profile_name='default')
iam = session.client('iam')
def list_policy_arns():
policy_arns = []
paginator = iam.get_paginator('list_policies')
for response in paginator.paginate(Scope='Local'):
for policy in response['Policies']:
policy_arns.append(policy['Arn'])