Skip to content

Instantly share code, notes, and snippets.

View hriprsd's full-sized avatar
🦇
I am Batman

hriprsd hriprsd

🦇
I am Batman
View GitHub Profile
@hriprsd
hriprsd / slash_cmd.py
Created July 31, 2025 11:03
sample slack slash command
import slack_sdk, logging, configparser, datetime, mysql.connector
from slack_bolt import App
from slack_bolt.adapter.socket_mode import SocketModeHandler
channel_id, user_id, text, connection = None, None, None, None
# Initialize logger
logging.basicConfig(filename='log/logfile.log', filemode='a' ,encoding='utf-8', level=logging.INFO, format='%(asctime)s - [%(levelname)s] - %(message)s')
log = logging.getLogger()
# Initialize config parser
config = configparser.ConfigParser()
@hriprsd
hriprsd / get-gist.py
Created July 22, 2025 09:31
extract gists from an account
"""
Usage: python get_gist.py <username>
Description: This script will clone all gists for a user and rename the directory to the description of the gist(if present).
"""
import os, sys
import requests
from subprocess import call
user = sys.argv[1]
@hriprsd
hriprsd / influx-retention.md
Last active May 27, 2026 07:20
retention policy for influx db

This will create polciy for data reteion of 1 month on the specified db and set it as default policy

CREATE RETENTION POLICY "one-month<policy-name>" ON "my-db<db-name>" DURATION 720h REPLICATION 1 SHARD DURATION 24h DEFAULT

Create admin user

> CREATE USER admin WITH PASSWORD 'password'
> show users;
user admin
@hriprsd
hriprsd / reset-ilo-pwd.md
Created July 22, 2025 09:28
HP-ilo password reset

Make this file with the contents as shown

[root@server-01 ~]# cat reset_ilo_password.xml
<ribcl VERSION="2.0">
<login USER_LOGIN="Administrator" PASSWORD="password">
<user_INFO MODE="write">
<mod_USER USER_LOGIN="Administrator">
<password value="NewPasswordHere"/>
</mod_USER>
@hriprsd
hriprsd / GPG.md
Created July 22, 2025 09:27
Encrypt file using gpg

GPG:

GPG can be used to encrypt the data so it can be transported via email.

Both parties need GPG installed.

Both parties need to generate public/private keys.

If you are needing to send data to the outside vendor you will need the outside vendor’s GPG public key.

Importing outside vendor GPG public key into your GPG ring.

@hriprsd
hriprsd / en-de-vault.py
Created July 22, 2025 09:26
flips_ansible_vault_encrypt_or_decrypt
# Prerequisite, would need ansible, ansible-vault installed
import subprocess
import sys
import yaml
class VaultTag(yaml.YAMLObject):
yaml_tag = "!vault"

to add edit permissions to service account in a ns

kubectl create rolebinding default-view<role-binding-name> \
  --clusterrole=view<can be edit also> \
  --serviceaccount=my-namespace:default<ns:sa acc name> \
  --namespace=my-namespace<ns name>

sample command

Steps to have more than 1 port in cf

There is a chapter in the CF documentation which describes how to do it. step by step guide here with some explanations (replace all variables in [] with the actual values):

Configure your application to listen on multiple ports.

  • In my case I configured a spring boot app to listen on port 8080 for HTTPS requests and on port 8081 for HTTP requests (used for calls to actuator endpoints like health/prometheus as described here).
  • This means that I have configured one TCP route and one HTTP route in CF and mapped those routes to the CF app.
  • Get the [APP_GUID] of the CF app which should be reachable on multiple ports: cf app [APP_NAME] --guid
  • Add the ports (e.g. 8080, 8081) to the CF app: cf curl /v2/apps/[APP_GUID] -X PUT -d '{"ports": [8080, 8081]}'
---
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: ssis-cron
namespace: test
spec:
# “At 09:00 on day-of-month 28, 29, 30, and 31.”
schedule: "0 9 28,29,30,31 * *"
successfulJobsHistoryLimit: 3
hprasa638@APAC-4JTJD74:~$ cat app.py
LOG="""ts=2024-07-12T07:00:04.388Z caller=head.go:1287 level=info component=tsdb msg="WAL checkpoint complete" first=895 last=896 duration=1.348840271s
ts=2024-07-12T09:00:02.656Z caller=compact.go:530 level=info component=tsdb msg="write block" mint=1720764000003 maxt=1720771200000 ulid=01J2K2QCTEXJG88XP5Q8DK7E71 duration=2.450034038s
ts=2024-07-12T09:00:02.801Z caller=head.go:1325 level=info component=tsdb msg="Head GC completed" caller=truncateMemory duration=137.581212ms
ts=2024-07-12T09:00:02.807Z caller=checkpoint.go:100 level=info component=tsdb msg="Creating checkpoint" from_segment=897 to_segment=898 mint=1720771200000
ts=2024-07-12T09:00:04.088Z caller=head.go:1287 level=info component=tsdb msg="WAL checkpoint complete" first=897 last=898 duration=1.281156438s
ts=2024-07-12T11:00:02.621Z caller=compact.go:530 level=info component=tsdb msg="write block" mint=1720771200067 maxt=1720778400000 ulid=01J2K9K42G2DGC6GHRCV59FA5X duration=2.413140631s
ts=2024-07-12T11:00: